Exemple #1
0
        private void SetInternalInfo()
        {
            numberOfEdges = 0;
            pathTypeFlag  = BoundaryPathTypeFlag.Derived | BoundaryPathTypeFlag.External;

            foreach (IEntityObject entity in data)
            {
                switch (entity.Type)
                {
                case EntityType.Arc:
                    // a single arc is not a closed path
                    if (data.Count <= 1)
                    {
                        throw new ArgumentException("A single arc does not make closed loop.");
                    }
                    numberOfEdges += 1;
                    break;

                case EntityType.Circle:
                    // a circle is a closed loop
                    if (data.Count > 1)
                    {
                        throw new ArgumentException("A circle is a closed loop, there can be only per path.");
                    }
                    numberOfEdges += 1;
                    break;

                case EntityType.Ellipse:
                    // a full ellipse is a closed loop
                    if (((Ellipse)entity).IsFullEllipse && data.Count > 1)
                    {
                        throw new ArgumentException("A full ellipse is a closed loop, there can be only per path.");
                    }
                    // a single ellipse arc is not a closed path
                    if (!((Ellipse)entity).IsFullEllipse && data.Count <= 1)
                    {
                        throw new ArgumentException("A single ellipse arc does not make closed loop.");
                    }

                    numberOfEdges += 1;
                    break;

                case EntityType.Line:
                    // a single line is not a closed path
                    if (data.Count <= 1)
                    {
                        throw new ArgumentException("Only a line does not make closed loop.");
                    }
                    numberOfEdges += 1;
                    break;

                case EntityType.Polyline:

                    if (((Polyline)entity).IsClosed)
                    {
                        pathTypeFlag   = BoundaryPathTypeFlag.Derived | BoundaryPathTypeFlag.External | BoundaryPathTypeFlag.Polyline;
                        numberOfEdges += ((Polyline)entity).Vertexes.Count;
                    }
                    else
                    {
                        // open polylines will be exploded before being written in the dxf file
                        // for an open polyline the number of edges is equal the number of vertexes
                        numberOfEdges += ((Polyline)entity).Vertexes.Count - 1;
                    }
                    break;
                }
            }
        }
        private void SetInternalInfo()
        {
            numberOfEdges = 0;
            pathTypeFlag  = BoundaryPathTypeFlag.Derived | BoundaryPathTypeFlag.External;

            // the first loop will be considered as the Outermost path
            foreach (EntityObject entity in data)
            {
                // it seems that AutoCAD does not have problems on creating loops that theorically does not make sense, like, for example an internal loop that is made of a single arc.
                // so if AutoCAD is ok with that I am too, the program that make use of this information will take care of this inconsistencies
                switch (entity.Type)
                {
                case EntityType.Arc:
                    // a single arc is not a closed path
                    //if (data.Count <= 1) throw new ArgumentException("A single arc does not make closed loop.");
                    numberOfEdges += 1;
                    break;

                case EntityType.Circle:
                    // a circle is a closed loop
                    //if (data.Count>1) throw new ArgumentException("A circle is a closed loop, there can be only per path.");
                    numberOfEdges += 1;
                    break;

                case EntityType.Ellipse:
                    // a full ellipse is a closed loop
                    //if (((Ellipse)entity).IsFullEllipse && data.Count > 1) throw new ArgumentException("A full ellipse is a closed loop, there can be only per path.");
                    // a single ellipse arc is not a closed path
                    //if (!((Ellipse)entity).IsFullEllipse && data.Count <= 1) throw new ArgumentException("A single ellipse arc does not make closed loop.");
                    numberOfEdges += 1;
                    break;

                case EntityType.Line:
                    // a single line is not a closed path
                    //if (data.Count <= 1) throw new ArgumentException("Only a line does not make closed loop.");
                    numberOfEdges += 1;
                    break;

                case EntityType.LightWeightPolyline:
                    if (((LwPolyline)entity).IsClosed)
                    {
                        pathTypeFlag   = BoundaryPathTypeFlag.Derived | BoundaryPathTypeFlag.External | BoundaryPathTypeFlag.Polyline;
                        numberOfEdges += ((LwPolyline)entity).Vertexes.Count;
                    }
                    else
                    {
                        // open polylines will be exploded before being written in the dxf file
                        // for an open polyline the number of edges is equal the number of vertexes
                        numberOfEdges += ((LwPolyline)entity).Vertexes.Count - 1;
                    }
                    break;

                case EntityType.Spline:
                    // a closed spline is a closed loop
                    //if (((Spline)entity).IsClosed && data.Count > 1) throw new ArgumentException("A closed spline is a closed loop, there can be only per path.");
                    // an open spline is not a closed path
                    //if (!((Spline)entity).IsClosed && data.Count <= 1) throw new ArgumentException("An open spline does not make closed loop.");
                    numberOfEdges += 1;
                    break;

                default:
                    throw new ArgumentException("The entity type " + entity.Type + " unknown or not implemented as part of a hatch boundary.");
                }
            }
        }