コード例 #1
0
        private static CrossSectionCurve GenerateCrossSection(List <Line> meshLines, int numCrossSections)
        {
            CrossSectionCurve curve = new CrossSectionCurve();

            List <CrossSectionEvent> eventQueue   = GenerateEventQueue(meshLines, numCrossSections);
            HashSet <Line>           currentLines = new HashSet <Line>();

            for (int i = 0; i < eventQueue.Count; i++)
            {
                CrossSectionEvent currentEvent = eventQueue[i];
                if (currentEvent.crossSectionCut)
                {
                    //Calc cross section from current lines using convex hull algorithm
                    curve.AddCrossSection(GenerateCrossSectionFromLines(currentLines, currentEvent.point));
                }
                else
                {
                    Line currentLine = currentEvent.line;
                    if (!currentLines.Remove(currentLine))
                    {
                        currentLines.Add(currentLine);
                    }
                }
            }

            return(curve);
        }
コード例 #2
0
        public CrossSectionCurve(CrossSectionCurve curveToCopy)
        {
            crossSectionsTree = new LLRedBlackTree <CrossSection>();
            List <CrossSection> sections = curveToCopy.crossSectionsTree.InOrderTraversal();

            for (int i = 0; i < sections.Count; i++)
            {
                crossSectionsTree.Insert(sections[i]);
            }
        }
コード例 #3
0
        public static void GetCrossSectionalAreaCurves(Part p, out CrossSectionCurve xArea, out CrossSectionCurve yArea, out CrossSectionCurve zArea)
        {
            List <Line> meshLines = GenerateLinesFromPart(p);

            yArea = GenerateCrossSection(meshLines, 45);

            TransformLines(ref meshLines, Matrix4x4.TRS(Vector3.zero, Quaternion.FromToRotation(Vector3.up, Vector3.forward), Vector3.one));
            xArea = GenerateCrossSection(meshLines, 45);

            TransformLines(ref meshLines, Matrix4x4.TRS(Vector3.zero, Quaternion.FromToRotation(Vector3.forward, Vector3.right), Vector3.one));
            zArea = GenerateCrossSection(meshLines, 45);
        }