Example #1
0
 protected void GetPlanarPolys(PlanarRegion r, List <Polygon2d> polys)
 {
     try {
         MeshRegionBoundaryLoops loops = new MeshRegionBoundaryLoops(r.Mesh, r.Triangles);
         foreach (var loop in loops)
         {
             DCurve3   curve = loop.ToCurve();
             Polygon2d poly  = new Polygon2d();
             int       NV    = curve.VertexCount;
             for (int k = 0; k < NV; k++)
             {
                 poly.AppendVertex(curve[k].xy);
             }
             polys.Add(poly);
         }
     } catch (Exception) {
         // add each triangle as a polygon and let clipper sort it out
         Vector3d v0 = Vector3d.Zero, v1 = Vector3d.Zero, v2 = Vector3d.Zero;
         foreach (int tid in r.Triangles)
         {
             r.Mesh.GetTriVertices(tid, ref v0, ref v1, ref v2);
             Polygon2d p = new Polygon2d();
             p.AppendVertex(v0.xy); p.AppendVertex(v1.xy); p.AppendVertex(v2.xy);
             polys.Add(p);
         }
     }
 }
        public static void test_region_boundary()
        {
            List<int> cases = new List<int>() { 0, 1, 2, 3 };

            foreach ( int num in cases ) { 

                string name;
                DMesh3 mesh = MakeBoundaryTestMesh(num, out name);

                int[][] groups = FaceGroupUtil.FindTriangleSetsByGroup(mesh, 0);

                System.Console.WriteLine("case {0}:", name);
                for (int k = 0; k < groups.Length; ++k) {
                    int gid = mesh.GetTriangleGroup(groups[k][0]);
                    MeshRegionBoundaryLoops loops = new MeshRegionBoundaryLoops(mesh, groups[k]);
                    System.Console.WriteLine("  gid {0} : found {1} loops", gid, loops.Loops.Count);
                }

            }
        }