Example #1
0
        public void triangulate()
        {
            double minArea = 1000 * charLength * DOUBLE_PREC;

            newFaces.clear();
            for (int i = 0; i < faces.Count; i++)
            {
                if (faces[i].mark == Face.VISIBLE)
                {
                    faces[i].triangulate(newFaces, minArea);
                }
            }
            for (Face face = newFaces.first(); face != null; face = face.next)
            {
                faces.Add(face);
            }
        }
Example #2
0
        private void resolveUnclaimedPoints(FaceList newFaces)
        {
            Vertex vtxNext = unclaimed.first();

            for (Vertex vtx = vtxNext; vtx != null; vtx = vtxNext)
            {
                vtxNext = vtx.next;

                double maxDist = tolerance;
                Face   maxFace = null;
                for (Face newFace = newFaces.first(); newFace != null;
                     newFace = newFace.next)
                {
                    if (newFace.mark == Face.VISIBLE)
                    {
                        double dist = newFace.distanceToPlane(vtx.pnt);
                        if (dist > maxDist)
                        {
                            maxDist = dist;
                            maxFace = newFace;
                        }
                        if (maxDist > 1000 * tolerance)
                        {
                            break;
                        }
                    }
                }
                if (maxFace != null)
                {
                    addPointToFace(vtx, maxFace);
                    if (debug && vtx.index == findIndex)
                    {
                        Print(findIndex + " CLAIMED BY " +
                              maxFace.getVertexString());
                    }
                }
                else
                {
                    if (debug && vtx.index == findIndex)
                    {
                        Print(findIndex + " DISCARDED");
                    }
                }
            }
        }