/** * Returns the inner segment configuration. * @return inner segment configuration */ unsigned int BOP_Segment::getConfig() { if (isUndefined(m_cfg1)) return m_cfg2; else if (isUndefined(m_cfg2)) return m_cfg1; else if (isVertex(m_cfg1)) { // v1 is vertex if (isVertex(m_cfg2)) { // v2 is vertex return createEdgeCfg(getEdgeBetween(getVertex(m_cfg1),getVertex(m_cfg2))); } else if (isEdge(m_cfg2)) { // v2 is edge if (isOnEdge(m_cfg1,getEdge(m_cfg2))) return m_cfg2; else return createInCfg(); //IN } else return createInCfg(); //IN } else if (isEdge(m_cfg1)) { // v1 is edge if (isVertex(m_cfg2)) { // v2 is vertex if (isOnEdge(m_cfg2,getEdge(m_cfg1))) return m_cfg1; else return createInCfg(); //IN } else if (isEdge(m_cfg2)) { // v2 is edge if (m_cfg1 == m_cfg2) return m_cfg1; else return createInCfg(); // IN } else return createInCfg(); // IN } else return createInCfg(); // IN }
void ossimQuadTreeWarp::updateLockFlag(ossimQuadTreeWarpVertex* v) { std::vector<ossimQuadTreeWarpNode*> nodeList; findAllNodes(nodeList, v->getPosition()); if(nodeList.size() != v->theSharedNodeList.size()) { if(isOnEdge(theTree, v->getPosition())) { v->theLockedFlag = false; } else { v->theLockedFlag = true; } } else { v->theLockedFlag = false; } // if the original was not locked // then we need to make sure we change the delta // along the locked edge so to produce no artifacts // if(v->theLockedFlag) { updateDelta(v); } }
void Origami::makeValid() { // no dirty stuff, it uses only other member functions for (int j = 0; j < 20; ++j) //while (1) { bool found = false; int notValid; for (notValid = 0; notValid < verts.size(); ++notValid) { if (verts[notValid].isValid() == false && !isOnEdge(notValid)) { found = true; break; } } if (!found) break; vertex& v = verts[notValid]; crease c = v.getSuggestionByChoice(0); insertWithRaycast(notValid, c.angle, c.sDihedral); recompile(); printf("%d: %f, %f\n", notValid, c.angle, c.sDihedral); bool f = verts[notValid].isValid(); if (f) printf("vertex %d is GOOD\n", notValid); else printf("vertex %d is BAD\n", notValid); } }
void Delaunay::rebucket(VHandle vh, VHandleVec& vhvec) { // get all outgoing half_edge around the vertex HHandleVec hhvec; // for (auto vhit = mesh.voh_begin(vh); vhit != mesh.voh_end(vh); vhit++ ) //{ // hhvec.push_back(*vhit); //} for(auto& hh : mesh.voh_range(vh)) { hhvec.push_back(hh); } //for(auto& hh : mesh) // get all face handles around the vertex FHandleVec fhvec; //for(auto &hh : hhvec) //{ // fhvec.push_back(mesh.face_handle(hh)); //} //for(auto& fh : mesh.vf_range(vh)) //{ // fhvec.push_back(fh); //} for(auto fit = mesh.vf_begin(vh); fit != mesh.vf_end(vh); fit++) { fhvec.push_back(*fit); } // following code lead to compiler crash: //for(auto& fhi : mesh.vf_range(vh)) // fhvec.push_back(fhi); // clear the incident faces' property for(auto& fh : fhvec) { mesh.property(FaceToVertices, fh).clear(); } // what's the diff up and down // reset vertex's property for (auto& vh : vhvec) { mesh.property(VertexToFace, vh).invalidate(); mesh.property(VertexToHEdge, vh).invalidate(); } // for every vertex influenced, find new Face/Edge it belongs to for(auto& vhi : vhvec) { // ENSURE(vh != vhi) and deal with points OVERLAP if (isOverlap(vhi, vh)) { continue; } // find new face it belongs to for(auto& fh : fhvec) { if (isInTriangle(mesh.point(vhi), fh)) { mesh.property(FaceToVertices, fh).push_back(vhi); mesh.property(VertexToFace, vhi) = fh; break; } // if (isOnTriangleEdges) } // the vertex is not IN any triangle // check whether lies ON an edge of the triangles if (!mesh.property(VertexToFace, vhi).is_valid()) { for (auto &hhi : hhvec) { // find new edge it belongs to HHandle hh_on; HHandle hh_next = mesh.next_halfedge_handle(hhi); if (isOnEdge(mesh.point(vhi), hhi)) { hh_on = hhi; } else if (isOnEdge(mesh.point(vhi),hh_next)) { hh_on = hh_next; } if (hh_on.is_valid()) { mesh.property(VertexToHEdge, vhi) = hh_on; FHandle fh = mesh.face_handle(hh_on); mesh.property(FaceToVertices, fh).push_back(vhi); mesh.property(VertexToFace, vhi) = fh; break; } } } } }
/** * Returns whether or not the given point p belongs to the face defined * by the vector points. */ static bool onFace(gml::Point3D const & p, std::vector < gml::Point3D > const & points) { std::vector<double> plane; // double dist= 0.0; std::vector <int> samePoints; std::vector < gml::Point3D > allPoints; // Firstly copy of the vector points in the vector // samePoints, if all the points are different for(int i=0; i<(int)points.size(); i++) { for(int j=i+1; j<(int)points.size();j++) { if (isTheSame(points[i], points[j])) { samePoints.push_back(i); } } } // Construction of the vector allPoints, with only the different points bool diff=true; for (int i=0; i<(int)points.size();i++) { int j=0; while (j<(int)samePoints.size() && diff) { if (i==samePoints[j]) { diff = false; } else { j++; } } if (diff) { allPoints.push_back(points[i]); } diff = true; } // 1) Check if the vector allPoints is a really a plan plane = definePlane(allPoints); if( plane.empty() ) { return false; } // 2) Check if the current point is on the plan if( ! onPlane(p, allPoints) ) { return false; } // 3) Check if the point belows to one of edge of the face for (int i=0 ; i<(int)allPoints.size() ; i++) { int next = i+1; if (next == (int)allPoints.size()) { next = 0; } double t; if (isOnEdge(p, allPoints[i], allPoints[next], &t)) { return true; } } // 4) Computation of a line // double diffx = allPoints[0][0] - allPoints[1][0]; // double diffy = allPoints[0][1] - allPoints[1][1]; // double diffz = allPoints[0][2] - allPoints[1][2]; gml::Vector3D diffVector = allPoints[0] - allPoints[1]; gml::Point3D newPoint = p + diffVector; // newPoint[0] = p[0] + diffx; // newPoint[1] = p[1] + diffy; // newPoint[2] = p[2] + diffz; // 5) Check if the line cut or not the plan int nbCut = 0; for (int i=0 ; i<(int)allPoints.size() ; i++) { int next = i+1; if (next == (int)allPoints.size()) { next = 0; } std::vector< gml::Point3D > newPlane; newPlane.push_back(newPoint); newPlane.push_back(allPoints[i]); newPlane.push_back(allPoints[next]); double t1, t2; int valueCut = inter(p, newPlane, &t1, &t2); if (valueCut > 0) { if (isGreaterOrEqual(t1, 0) && isGreaterOrEqual(t2, 0) && isLesserOrEqual(t2, 1)) { nbCut++; } } if (nbCut == 1) { return true; } } return false; } //end of method on face