コード例 #1
0
        public void CutHalfEdge(TriMesh.HalfEdge hf)
        {
            Vector3D p1 = hf.FromVertex.Traits.Position;
            Vector3D p2 = hf.ToVertex.Traits.Position;
            double   d1 = TriMeshUtil.GetDistance(plane, p1);
            double   d2 = TriMeshUtil.GetDistance(plane, p2);

            if (d1 < 0 && d2 > 0)
            {
                d1 = Math.Abs(d1);
                d2 = Math.Abs(d2);
                Vector3D       pos = p1 + (p2 - p1) * d1 / (d1 + d2);
                TriMesh.Vertex v1  = new TriMesh.Vertex(new VertexTraits(pos));
                this.mesh.AppendToVertexList(v1);
                TriMesh.Vertex v2 = new TriMesh.Vertex(new VertexTraits(pos));
                this.mesh.AppendToVertexList(v2);
                this.cutPoint[hf.Index] = new CutPoint {
                    Left = v1, Right = v2
                };
            }
        }