Esempio n. 1
0
 public Rectangle(ValidateOption should, params Point[] points) : base(points, should)
 {
     if (should == ValidateOption.Do)
     {
         throw new NotImplementedException();
     }
 }
Esempio n. 2
0
 public Rectangle(Polygon polygon, ValidateOption shouldValidate = ValidateOption.Do)
     : base(polygon)
 {
     if (shouldValidate == ValidateOption.Do && !polygon.IsRectangle())
     {
         throw new Exception("Polygon is not a rectangle!");
     }
 }
Esempio n. 3
0
        public ValidateContext CreateContext(object validateObject,
                                             ValidateOption option = ValidateOption.StopOnFirstFailure, params string[] ruleSetList)
        {
            var result = Provider.GetService <ValidateContext>();

            result.Option         = option;
            result.RuleSetList    = ruleSetList;
            result.ValidateObject = validateObject;
            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a polygon from the passed line segments, after validating that they in fact form a closed nondegenerate planar region.
        /// </summary>
        public Polygon(IList <LineSegment> lineSegments, ValidateOption shouldValidate = ValidateOption.Do)
        {
            if (shouldValidate == ValidateOption.Do)
            {
                lineSegments.ThrowIfInvalidPolygon();
                lineSegments = lineSegments.FixSegmentOrientation();
            }
            this.Edges = lineSegments.ToList().AsReadOnly();

            this.NormalLine = this._getNormalLine();
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a Polyhedron using the passed polygons as its side/polygons
        /// </summary>
        public Polyhedron(IEnumerable <Polygon> polygons, ValidateOption shouldValidate = ValidateOption.Do)
        {
            var faces = polygons.ToList();

            if (shouldValidate == ValidateOption.Do)
            {
                faces = _makeFacesWithProperOrientation(faces);
            }
            if (faces == null || !faces.Any())
            {
                throw new InvalidPolyhedronException(faces, "The polygons you're attempting to use do not form a single closed region.");
            }
            this.Faces    = faces.AsReadOnly();
            this.Edges    = faces.GetAllEdges().AsReadOnly();
            this.Vertices = faces.SelectMany(v => v.Vertices).DistinctEquatable().ToList().AsReadOnly();
        }
Esempio n. 6
0
 public Polygon(ValidateOption should, params LineSegment[] segments) : this(segments, should)
 {
 }
Esempio n. 7
0
 public Polygon(ValidateOption should, params Point[] points) : this(points, should)
 {
 }
Esempio n. 8
0
 /// <summary>
 /// Makes a polygon by connecting the points with line segments in the order they are in the list. If they are not in the correct order you can tell it
 /// to sort the line segments of the polygon clockwise with the boolean flag unless you need it in the specific order it is in
 /// </summary>
 /// <param name="passedPoints">The List of points to make the polygon with. It will create the line segments based on the order the points are inputted</param>
 public Polygon(IList <Point> passedPoints, ValidateOption shouldValidate = ValidateOption.Do)
     : this(passedPoints.MakeIntoLineSegmentsThatMeet(), shouldValidate)
 {
 }
Esempio n. 9
0
 /// <summary>
 /// Creates a Polyhedron using the passed polygons as its side/polygons
 /// </summary>
 public Polyhedron(ValidateOption shouldValidate, params Polygon[] faces)
     : this(faces, shouldValidate)
 {
 }