コード例 #1
0
        public override object Clone()
        {
            Face3d entity = new Face3d
            {
                //EntityObject properties
                Layer         = (Layer)this.Layer.Clone(),
                Linetype      = (Linetype)this.Linetype.Clone(),
                Color         = (AciColor)this.Color.Clone(),
                Lineweight    = this.Lineweight,
                Transparency  = (Transparency)this.Transparency.Clone(),
                LinetypeScale = this.LinetypeScale,
                Normal        = this.Normal,
                IsVisible     = this.IsVisible,
                //Face3d properties
                FirstVertex  = this.firstVertex,
                SecondVertex = this.secondVertex,
                ThirdVertex  = this.thirdVertex,
                FourthVertex = this.fourthVertex,
                EdgeFlags    = this.edgeFlags
            };

            foreach (XData data in this.XData.Values)
            {
                entity.XData.Add((XData)data.Clone());
            }

            return(entity);
        }
コード例 #2
0
ファイル: PolyfaceMesh.cs プロジェクト: liyangTeam/WSXCut
        public List <EntityObject> Explode()
        {
            List <EntityObject> entities = new List <EntityObject>();

            foreach (PolyfaceMeshFace face in this.Faces)
            {
                if (face.VertexIndexes.Count == 1)
                {
                    Point point = new Point
                    {
                        Layer         = (Layer)this.Layer.Clone(),
                        Linetype      = (Linetype)this.Linetype.Clone(),
                        Color         = (AciColor)this.Color.Clone(),
                        Lineweight    = this.Lineweight,
                        Transparency  = (Transparency)this.Transparency.Clone(),
                        LinetypeScale = this.LinetypeScale,
                        Normal        = this.Normal,
                        Position      = this.Vertexes[Math.Abs(face.VertexIndexes[0]) - 1].Location,
                    };
                    entities.Add(point);
                    continue;
                }
                if (face.VertexIndexes.Count == 2)
                {
                    Line line = new Line
                    {
                        Layer         = (Layer)this.Layer.Clone(),
                        Linetype      = (Linetype)this.Linetype.Clone(),
                        Color         = (AciColor)this.Color.Clone(),
                        Lineweight    = this.Lineweight,
                        Transparency  = (Transparency)this.Transparency.Clone(),
                        LinetypeScale = this.LinetypeScale,
                        Normal        = this.Normal,
                        StartPoint    = this.Vertexes[Math.Abs(face.VertexIndexes[0]) - 1].Location,
                        EndPoint      = this.Vertexes[Math.Abs(face.VertexIndexes[1]) - 1].Location,
                    };
                    entities.Add(line);
                    continue;
                }

                Face3dEdgeFlags edgeVisibility = Face3dEdgeFlags.Visibles;

                short indexV1 = face.VertexIndexes[0];
                short indexV2 = face.VertexIndexes[1];
                short indexV3 = face.VertexIndexes[2];
                // Polyface mesh faces are made of 3 or 4 vertexes, we will repeat the third vertex if the number of face vertexes is three
                int indexV4 = face.VertexIndexes.Count == 3 ? face.VertexIndexes[2] : face.VertexIndexes[3];

                if (indexV1 < 0)
                {
                    edgeVisibility = edgeVisibility | Face3dEdgeFlags.First;
                }
                if (indexV2 < 0)
                {
                    edgeVisibility = edgeVisibility | Face3dEdgeFlags.Second;
                }
                if (indexV3 < 0)
                {
                    edgeVisibility = edgeVisibility | Face3dEdgeFlags.Third;
                }
                if (indexV4 < 0)
                {
                    edgeVisibility = edgeVisibility | Face3dEdgeFlags.Fourth;
                }

                Vector3 v1 = this.Vertexes[Math.Abs(indexV1) - 1].Location;
                Vector3 v2 = this.Vertexes[Math.Abs(indexV2) - 1].Location;
                Vector3 v3 = this.Vertexes[Math.Abs(indexV3) - 1].Location;
                Vector3 v4 = this.Vertexes[Math.Abs(indexV4) - 1].Location;

                Face3d face3d = new Face3d
                {
                    Layer         = (Layer)this.Layer.Clone(),
                    Linetype      = (Linetype)this.Linetype.Clone(),
                    Color         = (AciColor)this.Color.Clone(),
                    Lineweight    = this.Lineweight,
                    Transparency  = (Transparency)this.Transparency.Clone(),
                    LinetypeScale = this.LinetypeScale,
                    Normal        = this.Normal,
                    FirstVertex   = v1,
                    SecondVertex  = v2,
                    ThirdVertex   = v3,
                    FourthVertex  = v4,
                    EdgeFlags     = edgeVisibility,
                };

                entities.Add(face3d);
            }
            return(entities);
        }