⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 polyhedralboundedsolid.java

📁 基于java的3d开发库。对坐java3d的朋友有很大的帮助。
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            VSDK.reportMessage(this, VSDK.WARNING, "lkev",            "Given halfedges must be different!");            return;        }                //-----------------------------------------------------------------        // Answer borrowed from [.wMANT2008]        _PolyhedralBoundedSolidHalfEdge he, he2next;        he = he2.next();        while ( he != he1 ) {            he.startingVertex = he2.startingVertex;            he = he.mirrorHalfEdge().next();        }        he2next = he2.next();        he1.parentLoop.unlistHalfEdge(he1);        he2.parentLoop.unlistHalfEdge(he2);        he2.startingVertex.emanatingHalfEdge = he2next;        if ( he2.parentLoop.halfEdgesList.size() < 1 ) {            he2.startingVertex.emanatingHalfEdge = null;        }        edgesList.locateWindowAtElem(he1.parentEdge);        edgesList.removeElemAtWindow();        verticesList.locateWindowAtElem(he1.startingVertex);        verticesList.removeElemAtWindow();        if ( he2.parentLoop.halfEdgesList.size() <= 0 ) {            he2.parentEdge = null;            he2.parentLoop.halfEdgesList.add(he2);        }    }    /**    lkef: Low Level Kill Edge Face    Operator `lkef` is the inverse of `lmef`. It removes the edge of    `he1` and `he2`, and "joins" the two adjacent faces by merging    their loops. The face `he2.parentLoop.parentFace` is removed.    `lkef` is applicable to the halves of an edge that occurs in two    distinct faces. That is, it is assumed that:      - `he1.parentEdge` == `he2.parentEdge`      - `he1.parentLoop.parentFace` != `he2.parentLoop.parentFace`    */    public void lkef(_PolyhedralBoundedSolidHalfEdge he1,                     _PolyhedralBoundedSolidHalfEdge he2)    {        if ( he1.parentEdge != he2.parentEdge ) {            VSDK.reportMessage(this, VSDK.FATAL_ERROR, "lkef",            "Given halfedges must lie over the same edge. Operation aborted.");            return;        }        if ( he1.parentLoop.parentFace == he2.parentLoop.parentFace ) {            VSDK.reportMessage(this, VSDK.FATAL_ERROR, "lkef",            "Given halfedges must belong to different faces. Operation aborted.");            return;        }        _PolyhedralBoundedSolidEdge edgeToBeKilled;        _PolyhedralBoundedSolidLoop loopToBeKilled;        _PolyhedralBoundedSolidFace faceToBeKilled;        _PolyhedralBoundedSolidHalfEdge hepivot;        hepivot = he1.next();        edgeToBeKilled = he1.parentEdge;        loopToBeKilled = he2.parentLoop;        faceToBeKilled = loopToBeKilled.parentFace;        ArrayList<_PolyhedralBoundedSolidHalfEdge> migratedHalfEdges;        migratedHalfEdges = new ArrayList<_PolyhedralBoundedSolidHalfEdge>();        _PolyhedralBoundedSolidHalfEdge he;        he = he2.next();        while ( he != he2 ) {            migratedHalfEdges.add(he);            he = he.next();        }        he1.parentLoop.unlistHalfEdge(he1);        he2.parentLoop.unlistHalfEdge(he2);        edgesList.locateWindowAtElem(edgeToBeKilled);        edgesList.removeElemAtWindow();        faceToBeKilled.boundariesList.locateWindowAtElem(loopToBeKilled);        faceToBeKilled.boundariesList.removeElemAtWindow();        polygonsList.locateWindowAtElem(faceToBeKilled);        polygonsList.removeElemAtWindow();        int i;        for ( i = migratedHalfEdges.size()-1; i >= 0; i-- ) {            he = migratedHalfEdges.get(i);            he.parentLoop = he1.parentLoop;            he1.parentLoop.halfEdgesList.insertBefore(he, hepivot);            hepivot = he;        }    }    /**    lmef: LowlevelMakeEdgeFace (face splitting operator).    Operator lmef adds a new edge between `he1.startingVertex` and    `he2.startingVertex`, and "splits" their common face into two faces    such that `he1` will occur in the new face `newFaceId`, and `he2`     remains in the old face. The new edge is oriented from     `he1.startingVertex` to `he2.startingVertex`.    Halfedges `he1` and `he2` must belong to the same loop (i.e.    he1.parentLoop == he2.parentLoop ). They may be equal, in which case    a "circular" face with just one edge is created. A pointer to the new    face is returned.    As described in sections [MANT1988].9.2.3, [MANT1988].11.3.3 and    [MANT1988].11.5.1; and following the structure of sample program    [MANT1988].11.7, this method is the dual to lmev. Note that creates    the halfedges as usual, and then swaps them.    */    public _PolyhedralBoundedSolidFace lmef(        _PolyhedralBoundedSolidHalfEdge he1,        _PolyhedralBoundedSolidHalfEdge he2,         int newFaceId)    {        _PolyhedralBoundedSolidFace newFace;        _PolyhedralBoundedSolidLoop newLoop;        _PolyhedralBoundedSolidLoop oldLoop;        _PolyhedralBoundedSolidEdge newEdge;        _PolyhedralBoundedSolidHalfEdge he, nhe1, nhe2, temp;        if ( newFaceId > maxFaceId ) maxFaceId = newFaceId;        newFace = new _PolyhedralBoundedSolidFace(he1.parentLoop.parentFace.parentSolid, newFaceId);        oldLoop = he1.parentLoop;        newLoop = new _PolyhedralBoundedSolidLoop(newFace);        newEdge = new _PolyhedralBoundedSolidEdge(he1.parentLoop.parentFace.parentSolid);        ArrayList<_PolyhedralBoundedSolidHalfEdge> migratedHalfEdges;        migratedHalfEdges = new ArrayList<_PolyhedralBoundedSolidHalfEdge>();        he = he1;        while ( he != he2 ) {            migratedHalfEdges.add(he);            he = he.next();            if ( he == he1 ) break;        }        int i;        for ( i = 0; i < migratedHalfEdges.size(); i++ ) {            he = migratedHalfEdges.get(i);            he.parentLoop = newLoop;            oldLoop.unlistHalfEdge(he);            newLoop.halfEdgesList.add(he);        }        if ( he1 == null ) {            VSDK.reportMessage(this, VSDK.FATAL_ERROR, "lmef",            "Non-existing halfedge 1!");        }        if ( he2 == null ) {            VSDK.reportMessage(this, VSDK.FATAL_ERROR, "lmef",            "Non-existing halfedge 2!");        }        nhe1 = addhe(newEdge, he2.startingVertex, he1, MINUS);        nhe2 = addhe(newEdge, he1.startingVertex, he2, PLUS);        newLoop.boundaryStartHalfEdge = nhe1;        he2.parentLoop.boundaryStartHalfEdge = nhe2;        return newFace;    }    /**    lkemr: LowlevelKillEdgeMakeRing (loop splitting operator).    Operator lkemr removes the edge of `he1` and `he2`, and divides their    common loop into two components (i.e., it creates a new "ring").  If    the original loop was "outer", the component of `he1.startingVertex`    becomes the new "outer" loop. (If this default is inappropiate, you    can simply swap the arguments of lkemr, or use lringmv to make the    desired loop "outer").  It is assumed that    he1.parentEdge == he2.parentEdge and     he1.parentLoop == he2.parentLoop.    As described in section [MANT1988].9.2.3, the operator splits a loop    into two new ones by removing and edge that appears twice in it. Hence    the operator divides a connected bounding curve of a face into two    bounding curves, and has the net effect of removing one edge and adding    one ring to the PolyhedralBoundedSolid data structure. The special    cases that one or both of the resulting loops are empty are also    included. Note that current code follows section [MANT1988].11.3.4    and the structure of sample program [MANT1988].11.8.    */    public void lkemr(        _PolyhedralBoundedSolidHalfEdge he1,        _PolyhedralBoundedSolidHalfEdge he2)    {        //-----------------------------------------------------------------        _PolyhedralBoundedSolidHalfEdge he3 = null, he4;        _PolyhedralBoundedSolidLoop newLoop;        _PolyhedralBoundedSolidLoop oldLoop;        _PolyhedralBoundedSolidEdge killedEdge;        oldLoop = he1.parentLoop;        newLoop = new _PolyhedralBoundedSolidLoop(oldLoop.parentFace);        killedEdge = he1.parentEdge;        //-----------------------------------------------------------------        ArrayList<_PolyhedralBoundedSolidHalfEdge> migratedHalfEdges;        migratedHalfEdges = new ArrayList<_PolyhedralBoundedSolidHalfEdge>();        he4 = he1.next();        do {            migratedHalfEdges.add(he4);            if ( he4 == he2 ) break;        } while ( (he4 = he4.next()) != he2 );        //-----------------------------------------------------------------        int i;        for ( i = 0; i < migratedHalfEdges.size(); i++ ) {            he3 = migratedHalfEdges.get(i);            oldLoop.halfEdgesList.locateWindowAtElem(he3);            oldLoop.halfEdgesList.removeElemAtWindow();            newLoop.halfEdgesList.add(he3);            he3.parentLoop = newLoop;        }        newLoop.boundaryStartHalfEdge = newLoop.halfEdgesList.get(0);        //-----------------------------------------------------------------        oldLoop.delhe(he1);        oldLoop.delhe(he2);        if ( newLoop.halfEdgesList.size() <= 1 ) {            newLoop.boundaryStartHalfEdge.parentEdge = null;            if ( newLoop.halfEdgesList.size() <= 0 ) {                VSDK.reportMessage(this, VSDK.FATAL_ERROR, "lkemr",                "Case A Should not happen!");            }            newLoop.halfEdgesList.get(0).startingVertex.emanatingHalfEdge = null;        }        if ( oldLoop.halfEdgesList.size() <= 1 ) {            oldLoop.boundaryStartHalfEdge.parentEdge = null;            if ( oldLoop.halfEdgesList.size() <= 0 ) {                VSDK.reportMessage(this, VSDK.FATAL_ERROR, "lkemr",                "Case B Should not happen!");            }            oldLoop.halfEdgesList.get(0).startingVertex.emanatingHalfEdge = null;        }        edgesList.locateWindowAtElem(killedEdge);        edgesList.removeElemAtWindow();    }    /**    lkfmrh: LowlevelKillFaceMakeRingHoleinSameShell.    Operator `lkfmrh` merges two faces `face1` and `face2` by making    the loop of the latter a ring into the former. Face `face2` is hence    removed.    PRE: It is assumed that `face2` is simple, i.e., has just one loop.    Note that this method is a partial solution to problem [MANT1988].11.5,     and follows the functional definition of section [MANT1988].11.5.2.    This method should be shecket to see if it is managing only the    "same shell" case, or if it is done.    */    public void lkfmrh(        _PolyhedralBoundedSolidFace face1,        _PolyhedralBoundedSolidFace face2)    {        if ( face2.boundariesList.size() > 1 ) {            VSDK.reportMessage(this, VSDK.WARNING, "lkfmrh",                "Internal face to form new loop must have just one boundary!");            return;        }        _PolyhedralBoundedSolidLoop newLoop;        _PolyhedralBoundedSolidLoop oldLoop;        _PolyhedralBoundedSolidHalfEdge he;        int i;        oldLoop = face2.boundariesList.get(0);        newLoop = new _PolyhedralBoundedSolidLoop(face1);        for ( i = 0; i < oldLoop.halfEdgesList.size(); i++ ) {            he = oldLoop.halfEdgesList.get(i);            he.parentLoop = newLoop;            newLoop.halfEdgesList.add(he);        }        newLoop.boundaryStartHalfEdge = newLoop.halfEdgesList.get(0);        polygonsList.locateWindowAtElem(face2);        polygonsList.removeElemAtWindow();    }    /**    lmfkrh: LowLevelMakeFaceKillRingHole.    Operator `lmfkrh` is the inverse of `lkfmrh`. It makes the loop `l`    the outer loop of a new face `newFaceId`. It is assumed that `l` is an    inner loop of its parent face.    Note that this method is a partial solution to problem [MANT1988].11.5,     and follows the functional definition of section [MANT1988].11.5.2.    */    public _PolyhedralBoundedSolidFace lmfkrh(_PolyhedralBoundedSolidLoop l, int newFaceId)    {        _PolyhedralBoundedSolidFace newFace;        newFace = new _PolyhedralBoundedSolidFace(this, newFaceId);        if ( newFaceId > maxFaceId ) maxFaceId = newFaceId;        l.parentFace.boundariesList.locateWindowAtElem(l);        l.parentFace.boundariesList.removeElemAtWindow();        l.parentFace = newFace;        newFace.boundariesList.add(l);        return newFace;    }    /**    Method `lringmv` moves the loop `l` from its parent face to face `tofac`.    If `setAsOuterLoop` is false, `l` becomes an "inner" loop, and otherwise    the outer loop of `tofac`. If `l.parentFace` == `tofac`, `lringmv` has no    effect except for assigning the inner vs. outer information. Note that    `lringmv` is an addendum to `lmef`, and not an Euler operator.    This method follows the functional definition of section [MANT1988].11.5.2.    */    public boolean lringmv(_PolyhedralBoundedSolidLoop l, _PolyhedralBoundedSolidFace tofac, boolean setAsOuterLoop)    {        if ( setAsOuterLoop ) {            VSDK.reportMessage(this, VSDK.FATAL_ERROR, "lringmv",                "Outer loop case not implemented!");        }        tofac.boundariesList.add(l);        l.parentFace.boundariesList.locateWindowAtElem(l);        l.parentFace.boundariesList.removeElemAtWindow();        l.parentFace = tofac;        return true;    }    /**    lmekr: LowlevelMakeEdgeKillRing.        Operator `lmekr` is the inverse of `lkemr`. It inserts a new edge    between the starting vertices of `he1` and `he2`, and merges the    corresponding loops into one loop (i.e. removes a ring). The    operator assumes that:      - `he1.parentLoop` and `he2.parentLoop` are different, i.e.        `he1` and `he2` belong to two distinct loops.      - `he1.parentLoop.parentFace` and `he2.parentLoop.parentFace`        are equal, i.e. they occur in a single face.    Current implementation was builded as an answer to exercise    [MANT1988].11.4, and follows the signature from section    [MANT1988].11.5.2.    */    public void lmekr(        _PolyhedralBoundedSolidHalfEdge he1,        _PolyhedralBoundedSolidHalfEdge he2)    {        //-----------------------------------------------------------------        if ( he1.parentLoop == he2.parentLoop ) {            VSDK.reportMessage(this, VSDK.WARNING, "lmekr",            "Given halfedges are on the same loop. Operation aborted.");            return;        }        if ( he1.parentLoop.parentFace != he2.parentLoop.parentFace ) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -