private static void TestSlicing() { var _slicer = new MSTLSlicer(); _slicer.Load(@"C:\MSOLV\STLs\Ice Cream Type 2.stl"); //_slicer.Load(@"C:\MSOLV\STLs\tray.stl"); //_slicer.Load(@"C:\MSOLV\STLs\flange.stl"); //_slicer.Load(@"C:\MSOLV\STLs\TestBinaryKIT.stl"); List <ContourStructure>[] control = new List <ContourStructure>[] { }; List <MContourStructure>[] slices = new List <MContourStructure>[] { }; Console.WriteLine( PerformanceHelper.Compare( () => { control = _slicer.Slice(); }, () => { slices = _slicer.SliceParallel(); }, compareRepeat: 5, timingRepeat: 5, tagA: "Control", tagB: "Slices" ) ); //PrintSlicesCount("Control", control); //PrintSlicesCount("Slices", slices); }
private static void TestQuadTree() { var _slicer = new MSTLSlicer(); _slicer.Load(@"C:\MSOLV\STLs\Ice Cream Type 2.stl"); //_slicer.Load(@"C:\MSOLV\STLs\tray.stl"); var slices = _slicer.Slice(); IEnumerable <MVertex> contour = slices[7][0].ToVertices().Concat(slices[5][0].ToVertices()); //IEnumerable<MVertex> contour = slices[5][1].ToVertices(); var reference = ToPath(contour); var intersectingLine = new MarkGeometryLine( reference.Extents.MinimumPoint, reference.Extents.MaximumPoint ); List <MarkGeometryPoint> controlResults = new List <MarkGeometryPoint>(); List <MarkGeometryPoint> quadTreeResults = new List <MarkGeometryPoint>(); var lines = ToLines(contour); var contourQuadTree = new ContourQuadTree(contour); Console.WriteLine( PerformanceHelper.Compare( () => { // setup up controlResults.Clear(); MarkGeometryPoint intersection; for (int i = 0; i < lines.Count; i++) { if (( intersection = GeometricArithmeticModule.CalculateIntersection2D( intersectingLine, lines[i] )) != null ) { controlResults.Add(intersection); } } }, () => { // setup up quadTreeResults.Clear(); quadTreeResults = contourQuadTree.Intersect(intersectingLine).ToList(); }, tagA: "Lines (Control)", tagB: "Quad Tree" ) ); Println("Control", controlResults); Println("Quad Tree Intersections", quadTreeResults); contourQuadTree.SaveImage(@"C:\Users\Chibuike.Okpaluba\Downloads\quad_tree_v2.png"); }