Пример #1
0
 bool remove_duplicate_faces(double vtxTolerance, out int nRemoved)
 {
     nRemoved = 0;
     try {
         RemoveDuplicateTriangles dupe = new RemoveDuplicateTriangles(Mesh);
         dupe.VertexTolerance = vtxTolerance;
         bool bOK = dupe.Apply();
         nRemoved = dupe.Removed;
         return(bOK);
     } catch (Exception /*e*/) {
         return(false);
     }
 }
Пример #2
0
        void process()
        {
            DMesh3 useSourceMesh = SourceMesh;

            // try to do simple mesh repairs
            if (useSourceMesh.CachedIsClosed == false)
            {
                useSourceMesh = new DMesh3(SourceMesh);

                // [TODO] should remove duplicate triangles here?
                RemoveDuplicateTriangles dupes = new RemoveDuplicateTriangles(useSourceMesh);
                dupes.Apply();

                // close cracks
                MergeCoincidentEdges merge = new MergeCoincidentEdges(useSourceMesh);
                //merge.OnlyUniquePairs = true;
                merge.Apply();
            }

            //Util.WriteDebugMesh(useSourceMesh, "c:\\scratch\\__FIRST_MERGE.obj");


            DMesh3[] components = MeshConnectedComponents.Separate(useSourceMesh);

            List <DMesh3> solidComps = new List <DMesh3>();

            foreach (DMesh3 mesh in components)
            {
                // [TODO] check if this is a mesh w/ cracks, in which case we
                // can do other processing?

                bool closed = mesh.CachedIsClosed;
                if (closed == false)
                {
                    OpenMeshes.Add(mesh);
                    continue;
                }

                solidComps.Add(mesh);
            }


            if (solidComps.Count == 0)
            {
                return;
            }
            if (solidComps.Count == 1)
            {
                ClosedSolids = new List <DMesh3>()
                {
                    solidComps[0]
                };
            }


            if (HasNoVoids)
            {
                // each solid is a separate solid
                ClosedSolids = process_solids_novoid(solidComps);
            }
            else
            {
                ClosedSolids = process_solids(solidComps);
            }
        }