Beispiel #1
0
        internal static Dictionary <TriangleConnectionInfo, bool> GetConnectedMesh(TriangleConnectionInfo parentTriangle, Dictionary <TriangleConnectionInfo, bool> availableConnections, TriangleInfoList triangles)
        {
            var connectedTriangles = new Dictionary <TriangleConnectionInfo, bool>();

            //if (triangles.Connections.Count == 0)
            //{
            //    triangles.UpdateConnections();
            //}

            if (availableConnections.Count == 1)
            {
                connectedTriangles.Add(availableConnections.ElementAt(0).Key, false);
            }
            else
            {
                var foundChildConnections = GetConnectedTriangles(new List <TriangleConnectionInfo>()
                {
                    parentTriangle
                }, availableConnections, triangles, connectedTriangles);
                while (foundChildConnections.Count > 0)
                {
                    foundChildConnections = GetConnectedTriangles(foundChildConnections, availableConnections, triangles, connectedTriangles);
                }
            }

            return(connectedTriangles);
        }
Beispiel #2
0
        internal void CalcOuterPathSegments(PolyNode outerPathAsPolyNode, Dictionary <Vector3, List <TriangleConnectionInfo> > outerPathUnsorted)
        {
            //find sourcepoint on outer path
            var sourcePointAsPolyNodeContourPoint = new IntPoint((int)(this.OuterPathSourcePoint.X * 10000), (int)(this.OuterPathSourcePoint.Y * 10000), (int)(this.OuterPathSourcePoint.Z * 10000));

            var sourcePointStartIndex = 0;

            for (var contourPointIndex = 0; contourPointIndex < outerPathAsPolyNode.Contour.Count; contourPointIndex++)
            {
                if (outerPathAsPolyNode.Contour[contourPointIndex] == sourcePointAsPolyNodeContourPoint)
                {
                    sourcePointStartIndex = contourPointIndex;
                    break;
                }
            }

            //create order list starting from startindex
            var polyContourWithStartIndex = new List <IntPoint>();

            for (var contourPointIndex = sourcePointStartIndex; contourPointIndex < outerPathAsPolyNode.Contour.Count; contourPointIndex++)
            {
                polyContourWithStartIndex.Add(outerPathAsPolyNode.Contour[contourPointIndex]);
            }
            for (var contourPointIndex = 0; contourPointIndex < sourcePointStartIndex; contourPointIndex++)
            {
                polyContourWithStartIndex.Add(outerPathAsPolyNode.Contour[contourPointIndex]);
            }

            //find intersectionpoint index
            var intersectionPointAsPolyNodeContourPoint = new IntPoint((int)(this.OuterPathIntersectionPointProperties.EdgeStartPoint.X * 10000), (int)(this.OuterPathIntersectionPointProperties.EdgeStartPoint.Y * 10000), (int)(this.OuterPathIntersectionPointProperties.EdgeStartPoint.Z * 10000));

            var segmentContourPoints = new List <IntPoint>();

            for (var contourPointIndex = 0; contourPointIndex < outerPathAsPolyNode.Contour.Count; contourPointIndex++)
            {
                segmentContourPoints.Add(outerPathAsPolyNode.Contour[contourPointIndex]);

                if (outerPathAsPolyNode.Contour[contourPointIndex] == intersectionPointAsPolyNodeContourPoint)
                {
                    this.OuterPathContourSegmentVectors.Add(segmentContourPoints);
                    segmentContourPoints = new List <IntPoint>();
                }
            }

            this.OuterPathContourSegmentVectors.Add(segmentContourPoints);

            var segmentStartBasedOnLowestOuterPathSegments = this.OuterPathContourSegmentVectors[0][0];

            if (this.OuterPathContourSegmentVectors[1].Count < this.OuterPathContourSegmentVectors[0].Count)
            {
                segmentStartBasedOnLowestOuterPathSegments = this.OuterPathContourSegmentVectors[1][0];
            }

            //find triangle based on intpoint
            var outerPathContourTriangleConnectionInfo = new TriangleConnectionInfo();
            var outerPathUnsortedKeys = new List <Vector3>();

            outerPathUnsortedKeys.AddRange(outerPathUnsorted.Keys);

            for (var outerPathUnsortedIndex = 0; outerPathUnsortedIndex < outerPathUnsorted.Count; outerPathUnsortedIndex++)
            {
                var outerPathKey = outerPathUnsortedKeys[outerPathUnsortedIndex];

                var outerPathContourPoint = new IntPoint((int)(outerPathKey.X * 10000), (int)(outerPathKey.Y * 10000), (int)(outerPathKey.Z * 10000));
                if (outerPathContourPoint == segmentStartBasedOnLowestOuterPathSegments)
                {
                    //get next
                    outerPathKey = outerPathUnsortedKeys[outerPathUnsortedIndex + 2];
                    var outerPathValues = outerPathUnsorted[outerPathKey];
                    outerPathContourTriangleConnectionInfo = outerPathValues[0];
                    break;
                }
            }

            this.OuterPathContourSmallestContourTriangleConnectionIndex = outerPathContourTriangleConnectionInfo;
        }