public void AddTriangle(double x1, double y1, double z1, double x2, double y2, double z2, double x3, double y3, double z3)
        {
            var point1 = _store.Get(x1, y1, z1);
            var point2 = _store.Get(x2, y2, z2);
            var point3 = _store.Get(x3, y3, z3);
            var normal = GetNormal(point1.Position, point2.Position, point3.Position);

            var triangle = new CreatorTriangle()
            {
                Normal = normal,
                P1     = new CreatorVertex()
                {
                    Point = point1, Normal = normal
                },
                P2 = new CreatorVertex()
                {
                    Point = point2, Normal = normal
                },
                P3 = new CreatorVertex()
                {
                    Point = point3, Normal = normal
                }
            };

            CurrentFace.AddTriangle(triangle);
        }
Beispiel #2
0
        private static IEnumerable <CreatorVertex> GetTrianglesVertices(CreatorTriangle triangle)
        {
            yield return(triangle.P1);

            yield return(triangle.P2);

            yield return(triangle.P3);
        }
Beispiel #3
0
        private static Triangle ConvertToTriangle(
            CreatorTriangle CreatorTriangle,
            Dictionary <Point3D, Vector3D> verticesAndNormals)
        {
            var p1 = new Vertex()
            {
                Point  = CreatorTriangle.P1.Point,
                Normal = verticesAndNormals[CreatorTriangle.P1.Point]
            };

            var p2 = new Vertex()
            {
                Point  = CreatorTriangle.P2.Point,
                Normal = verticesAndNormals[CreatorTriangle.P2.Point]
            };

            var p3 = new Vertex()
            {
                Point  = CreatorTriangle.P3.Point,
                Normal = verticesAndNormals[CreatorTriangle.P3.Point]
            };

            var coEdges = new CoEdge[3];

            coEdges[0] = new CoEdge {
                Start = p1.Point, End = p2.Point
            };
            coEdges[1] = new CoEdge {
                Start = p2.Point, End = p3.Point
            };
            coEdges[2] = new CoEdge {
                Start = p3.Point, End = p1.Point
            };

            var triangle = new Triangle
            {
                P1      = p1,
                P2      = p2,
                P3      = p3,
                Normal  = CreatorTriangle.Normal,
                CoEdges = coEdges
            };

            coEdges.ForEach(coedge => coedge.ParentTriangle = triangle);

            return(triangle);
        }
 public void AddTriangle(CreatorTriangle triangle)
 {
     _triangles.Add(triangle);
     triangle.Parent = this;
 }