📄 polyhedralboundedsolid.java
字号:
VSDK.reportMessage(this, VSDK.WARNING, "lmekr", "Given halfedges are not on the same face. Operation aborted."); return; } //----------------------------------------------------------------- ArrayList<_PolyhedralBoundedSolidHalfEdge> migratedHalfEdges; _PolyhedralBoundedSolidHalfEdge he; _PolyhedralBoundedSolidLoop ringToKill; migratedHalfEdges = new ArrayList<_PolyhedralBoundedSolidHalfEdge>(); ringToKill = he2.parentLoop; he = he2; do { migratedHalfEdges.add(he); he = he.next(); } while ( he != he2 ); //----------------------------------------------------------------- int i; for ( i = 0; i < ringToKill.halfEdgesList.size(); i++ ) { ringToKill.halfEdgesList.remove(i); } ringToKill.parentFace.boundariesList.locateWindowAtElem(ringToKill); ringToKill.parentFace.boundariesList.removeElemAtWindow(); //----------------------------------------------------------------- _PolyhedralBoundedSolidEdge newEdge; _PolyhedralBoundedSolidVertex v1; _PolyhedralBoundedSolidVertex v2; v1 = he1.startingVertex; v2 = he2.startingVertex; newEdge = new _PolyhedralBoundedSolidEdge(he1.parentLoop.parentFace.parentSolid); _PolyhedralBoundedSolidHalfEdge heLast; heLast = addhe(newEdge, v2, he1, MINUS); newEdge.rightHalf = addhe(newEdge, v1, heLast, MINUS); newEdge.leftHalf = heLast; for ( i = 0; i < migratedHalfEdges.size(); i++ ) { he = migratedHalfEdges.get(i); he.parentLoop = he1.parentLoop; he1.parentLoop.halfEdgesList.insertBefore(he, heLast); } } //= HIGH LEVEL EULER OPERATIONS =================================== /** smev: "Strut" or line-drawing "Simplified" version of mev operator. See mev method for a complete description. @param f1 existing face id (counted from 1) in current solid, where new edge and vertex will be created @param v1 existing vertex id (counted from 1) in current solid that will be taken as starting vertex for new edge @param v4 vertex id (counted from 1) for new vertex @param p coordinates for new vertex */ public boolean smev(int f1, int v1, int v4, Vector3D p) { _PolyhedralBoundedSolidFace oldface1; _PolyhedralBoundedSolidHalfEdge he1, he2; oldface1 = findFace(f1); if ( oldface1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "mev", "Face " + f1 + " not found."); return false; } he1 = oldface1.findHalfEdge(v1); if ( he1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "mev", "Edge " + v1 + " - * not found in face " + f1 + "."); return false; } lmev(he1, he1, v4, p); return true; } /** mev: (High level version) MakeEdgeVertex (vertex splitting operation). Operator `mev` divides the cycle of edges around the vertex `v1` so that all edges from `v1` -> `v2` (inclusive) to `v1` -> `v3` (exclusive) will become adjacent to a new vertex `v4`. The vertices `v1` and `v4` are joined with a new edge. Coordinates defined in `p` are assigned to `v4`. Similarly to the corresponding low level operator `lmev`, various special cases are possible. Of particular use is the "line-drawing" case that `f1` = `f2` and `v2` = `v3`. In this case, a new edge to a new vertex will be added within the face. We shall call such "dangling" edges <I>struts</I>. This case occurs so frequently that it is included a "convenience" procedure `smev` that performs this operation. The procedure assumes that `v1` appears just once in `f1`; hence, the argument `v2` can be left out. @return true if operation succeded, false otherway */ public boolean mev(int f1, int f2, int v1, int v2, int v3, int v4, Vector3D p) { _PolyhedralBoundedSolidFace oldface1, oldface2; _PolyhedralBoundedSolidHalfEdge he1, he2; oldface1 = findFace(f1); if ( oldface1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "mev", "Face " + f1 + " not found."); return false; } oldface2 = findFace(f2); if ( oldface2 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "mev", "Face " + f2 + " not found."); return false; } he1 = oldface1.findHalfEdge(v1, v2); if ( he1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "mev", "Edge " + v1 + " - " + v2 + " not found in face " + f1 + "."); return false; } he2 = oldface2.findHalfEdge(v1, v3); if ( he1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "mev", "Edge " + v1 + " - " + v3 + " not found in face " + f2 + "."); return false; } lmev(he1, he2, v4, p); return true; } /** smef: simplified version of mef operator. See mef method for a complete description. */ public boolean smef(int f1, int v1, int v3, int newfaceid) { _PolyhedralBoundedSolidFace oldface1, oldface2; _PolyhedralBoundedSolidHalfEdge he1, he2; oldface1 = findFace(f1); if ( oldface1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "smef", "Face " + f1 + " not found."); return false; } he1 = oldface1.findHalfEdge(v1); if ( he1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "smef", "Edge " + v1 + " - * not found in face " + f1 + "."); return false; } he2 = oldface1.findHalfEdge(v3); if ( he1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "smef", "Edge " + v3 + " - * not found in face " + f1 + "."); return false; } lmef(he1, he2, newfaceid); return true; } /** mef: (High level version) MakeEdgeFace (face splitting operation). Operator `mef` connects the vertices `v1` and `v3` of face `f1` with a new edge, and creates a new face `f2`. Similarly to method `smev`, there is included a convenience procedure `smef` that leaves the arguments `v1` and `v4` out; that method should be applied only if `v1` and `v3` are known to occur just once in the face. Executes a `lmef` in halfedges v1-v2, v3-v4 in respective faces `f1` and `f2`, and assigns to the new face the `newfaceid`. */ public boolean mef(int f1, int f2, int v1, int v2, int v3, int v4, int newfaceid) { _PolyhedralBoundedSolidFace oldface1, oldface2; _PolyhedralBoundedSolidHalfEdge he1, he2; oldface1 = findFace(f1); if ( oldface1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "mef", "Face " + f1 + " not found."); return false; } oldface2 = findFace(f2); if ( oldface2 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "mef", "Face " + f2 + " not found."); return false; } he1 = oldface1.findHalfEdge(v1, v2); if ( he1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "mef", "Edge " + v1 + " - " + v2 + " not found in face " + f1 + "."); return false; } he2 = oldface2.findHalfEdge(v3, v4); if ( he1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "mef", "Edge " + v3 + " - " + v3 + " not found in face " + f2 + "."); return false; } lmef(he1, he2, newfaceid); return true; } /** kemr: (High level version) KillEdgeMakeRing (loop splitting operation). Executes a `lkemr` in halfedges v1-v2, v3-v4 in respective faces `f1` and `f2`. */ public boolean kemr(int f1, int f2, int v1, int v2, int v3, int v4) { _PolyhedralBoundedSolidFace oldface1, oldface2; _PolyhedralBoundedSolidHalfEdge he1, he2; oldface1 = findFace(f1); if ( oldface1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "kemr", "Face " + f1 + " not found."); return false; } oldface2 = findFace(f2); if ( oldface2 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "kemr", "Face " + f2 + " not found."); return false; } he1 = oldface1.findHalfEdge(v1, v2); if ( he1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "kemr", "Edge " + v1 + " - " + v2 + " not found in face " + f1 + "."); return false; } he2 = oldface2.findHalfEdge(v3, v4); if ( he1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "kemr", "Edge " + v3 + " - " + v3 + " not found in face " + f2 + "."); return false; } lkemr(he1, he2); return true; } /** kfmrh: (High level version) KillFaceMakeRingHole (connected sum topological operation, global manipulation). Operator `kfmrhSameShell` "merges" two faces `f1` and `f2` by making the latter an interior loop of the former. Face `f2` is removed. As noted in section [MANT1988].9.2.4, the name `kfmrh` is actually a misnomer, because the operator does not necessarily create a "hole". Actualy, `kfmrh` creates a hole only if the two argument faces belong to the same shell. This method implements that case, taking `this` solid as the only shell. This method should be shecket to see if it is managing only the "same shell" case, or if it is done. */ public boolean kfmrh(int f1, int f2) { _PolyhedralBoundedSolidFace oldface1, oldface2; oldface1 = findFace(f1); if ( oldface1 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "kfmrh", "Face " + f1 + " not found."); return false; } oldface2 = findFace(f2); if ( oldface2 == null ) { VSDK.reportMessage(this, VSDK.WARNING, "kfmrh", "Face " + f2 + " not found."); return false; } lkfmrh(oldface1, oldface2); return true; } //================================================================= /** This method gives access to the higher vertex id used in current solid model. This method is useful for higher level modeling operations, as noted in section [MANT1988].12.2. Current method (and method getMaxFaceId) is build after the function `getmaxnames` of program [MANT1988].12.1. */ public int getMaxVertexId() { return maxVertexId; } /** This method gives access to the higher face id used in current solid model. This method is useful for higher level modeling operations, as noted in section [MANT1988].12.2. Current method (and method getMaxVertexId) is build after the function `getmaxnames` of program [MANT1988].12.1. */ public int getMaxFaceId() { return maxFaceId; } public void applyTransformation(Matrix4x4 T) { int i; minMax = null; for ( i = 0; i < verticesList.size(); i++ ) { _PolyhedralBoundedSolidVertex v; v = verticesList.get(i); v.position = T.multiply(v.position); } } /** Check the general interface contract in superclass method Geometry.doIntersection. */ public boolean doIntersection(Ray inOutRay) { int i; boolean intersection; // true if intersection founded double min_t; // Shortest distance founded so far // Initialization values for search algorithm min_t = Double.MAX_VALUE; intersection = false; GeometryIntersectionInformation Info; Info = new GeometryIntersectionInformation(); Vector3D p; int pos; for ( i = 0; i < polygonsList.size(); i++ ) { Ray ray = new Ray(inOutRay); _PolyhedralBoundedSolidFace face = polygonsList.get(i); if ( face.containingPlane.doIntersection(ray) ) { face.containingPlane.doExtraInformation(ray, 0.0, Info); if ( ray.t < min_t ) { ray.direction.normalize(); p = ray.origin.add(ray.direction.multiply(ray.t)); pos = face.testPointInside(p, VSDK.EPSILON); if ( pos == Geometry.INSIDE || pos == Geometry.LIMIT ) { min_t = ray.t; // Stores standard doIntersection operation information lastInfo.clone(Info); inOutRay.t = ray.t; intersection = true; } } } } return intersection; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -