Beispiel #1
0
 protected Vertex nextPointToAdd()
 {
     if (!claimed.isEmpty())
     {
         Face   eyeFace = claimed.first().face;
         Vertex eyeVtx  = null;
         double maxDist = 0;
         for (Vertex vtx = eyeFace.outside;
              vtx != null && vtx.face == eyeFace;
              vtx = vtx.next)
         {
             double dist = eyeFace.distanceToPlane(vtx.pnt);
             if (dist > maxDist)
             {
                 maxDist = dist;
                 eyeVtx  = vtx;
             }
         }
         return(eyeVtx);
     }
     else
     {
         return(null);
     }
 }
Beispiel #2
0
        protected void deleteFacePoints(Face face, Face absorbingFace)
        {
            Vertex faceVtxs = removeAllPointsFromFace(face);

            if (faceVtxs != null)
            {
                if (absorbingFace == null)
                {
                    unclaimed.addAll(faceVtxs);
                }
                else
                {
                    Vertex vtxNext = faceVtxs;
                    for (Vertex vtx = vtxNext; vtx != null; vtx = vtxNext)
                    {
                        vtxNext = vtx.next;
                        double dist = absorbingFace.distanceToPlane(vtx.pnt);
                        if (dist > tolerance)
                        {
                            addPointToFace(vtx, absorbingFace);
                        }
                        else
                        {
                            unclaimed.add(vtx);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        protected 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)
                    {
                        Console.WriteLine(findIndex + " CLAIMED BY " +
                                          maxFace.getVertexString());
                    }
                }
                else
                {
                    if (debug && vtx.index == findIndex)
                    {
                        Console.WriteLine(findIndex + " DISCARDED");
                    }
                }
            }
        }
Beispiel #4
0
        protected void calculateHorizon(Point3d eyePnt, HalfEdge edge0, Face face, ArrayList horizon)
        {
            //	   oldFaces.add (face);
            deleteFacePoints(face, null);
            face.mark = Face.DELETED;
            if (debug)
            {
                Console.WriteLine("  visiting face " + face.getVertexString());
            }
            HalfEdge edge;

            if (edge0 == null)
            {
                edge0 = face.getEdge(0);
                edge  = edge0;
            }
            else
            {
                edge = edge0.getNext();
            }
            do
            {
                Face oppFace = edge.oppositeFace();
                if (oppFace.mark == Face.VISIBLE)
                {
                    if (oppFace.distanceToPlane(eyePnt) > tolerance)
                    {
                        calculateHorizon(eyePnt, edge.getOpposite(),
                                         oppFace, horizon);
                    }
                    else
                    {
                        horizon.Add(edge);
                        if (debug)
                        {
                            Console.WriteLine("  adding horizon edge " +
                                              edge.getVertexString());
                        }
                    }
                }
                edge = edge.getNext();
            }while (edge != edge0);
        }