Пример #1
0
        private void CreateQuadFace(List <Edge> existingEdges, Shape subdivided, Face face)
        {
            //                  0 1 2 -> 3
            //for a quad face (a,b,c,d):
            //   (a, edge_pointab, face_pointabcd, edge_pointda)
            //   (b, edge_pointbc, face_pointabcd, edge_pointab)
            //   (c, edge_pointcd, face_pointabcd, edge_pointbc)
            //   (d, edge_pointda, face_pointabcd, edge_pointcd)
            List <Point> points = face.AllPoints;
            Point        a      = points[0].Successor;
            Point        b      = points[1].Successor;
            Point        c      = points[2].Successor;
            Point        d      = points[3].Successor;

            Point facePoint = face.FacePoint;

            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, a, face.Edges[0].EdgePoint, facePoint));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, b, face.Edges[1].EdgePoint, facePoint));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, c, face.Edges[2].EdgePoint, facePoint));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, d, face.Edges[3].EdgePoint, facePoint));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, facePoint, face.Edges[3].EdgePoint, a));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, facePoint, face.Edges[0].EdgePoint, b));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, facePoint, face.Edges[1].EdgePoint, c));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, facePoint, face.Edges[2].EdgePoint, d));

            SubdivisionUtilities.VerifyThatThereAreNoEdgeDuplicates(existingEdges);
        }
Пример #2
0
        private void CreateTriangleFace(List <Edge> existingEdges, Shape subdivided, Face face)
        {
            List <Point> points = face.AllPoints;
            Point        a      = points[0];
            Point        b      = points[1];
            Point        c      = points[2];

            //for a triangle face (a,b,c):
            //   (a, edge_pointab, face_pointabc, edge_pointca)
            //   (b, edge_pointbc, face_pointabc, edge_pointab)
            //   (c, edge_pointca, face_pointabc, edge_pointbc)
            Point facePoint = face.FacePoint;

            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, a, face.Edges[0].EdgePoint, facePoint));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, b, face.Edges[1].EdgePoint, facePoint));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, c, face.Edges[2].EdgePoint, facePoint));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, facePoint, face.Edges[2].EdgePoint, a));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, facePoint, face.Edges[0].EdgePoint, b));
            subdivided.Faces.Add(SubdivisionUtilities.CreateFaceF(existingEdges, facePoint, face.Edges[1].EdgePoint, c));

            SubdivisionUtilities.VerifyThatThereAreNoEdgeDuplicates(existingEdges);
        }
Пример #3
0
        private void CreateFaces(Shape shape, Shape subdivided)
        {
            List <Face> faces         = shape.Faces;
            List <Edge> existingEdges = new List <Edge>();

            foreach (Face face in faces)
            {
                if (face.AllPoints.Count() == 3)
                {
                    CreateTriangleFace(existingEdges, subdivided, face);
                }
                else if (face.AllPoints.Count() == 4)
                {
                    CreateQuadFace(existingEdges, subdivided, face);
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Unhandled facetype (point count={0})!", face.AllPoints.Count()));
                }
            }
            SubdivisionUtilities.VerifyThatThereAreNoEdgeDuplicates(existingEdges);
        }