Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

Commit e6aa01c5 by David Cazier

### Debug de merge vertex et importSVG

parent e32aeaa7
 ... ... @@ -42,10 +42,10 @@ template bool isBetween(typename PFP::MAP& map, const VertexAttribute& positions, Dart d, Dart e, Dart f) ; template void mergeVertex(typename PFP::MAP& map, const VertexAttribute& positions, Dart d, Dart e); void mergeVertex(typename PFP::MAP& map, VertexAttribute& positions, Dart d, Dart e); template void mergeVertices(typename PFP::MAP& map, const VertexAttribute& positions); void mergeVertices(typename PFP::MAP& map, VertexAttribute& positions); } ... ...
 ... ... @@ -40,51 +40,60 @@ bool isBetween(typename PFP::MAP& map, const VertexAttribute } template void mergeVertex(typename PFP::MAP& map, const VertexAttribute& positions, Dart d, Dart e) void mergeVertex(typename PFP::MAP& map, VertexAttribute& positions, Dart d, Dart e) { assert(Geom::arePointsEquals(positions[d],positions[e]) && !map.sameVertex(d,e)); // d1 traverses the vertex of d (following the alpha1 permutation) // y is a temporay buffer to stop the loop Dart d1=d; // e1 traverses the vertex of e (following the alpha1 permutation) Dart e1=e; bool notempty = true; do { if (map.phi2_1(e1) == e1) notempty = false; // detach z from its vertex map.removeEdgeFromVertex(e1); // Searchs the dart of the vertex of x where tz may be inserted Dart nd1 = d1; do { if (CGoGN::Algo::BooleanOperator::isBetween(map,positions,e1,d1,map.phi2_1(d1))) break; d1 = map.phi2_1(d1); } while (d1 != nd1); map.insertEdgeInVertex(d1,e1); d1 = e1; } while (notempty); assert(Geom::arePointsEquals(positions[d], positions[e]) && !map.sameVertex(d, e)) ; // 0-embed z on the vertex of x without copy of the vertex // positions[d] = ; } typedef typename PFP::VEC3 VEC3; VEC3 p = positions[d] ; bool notempty = true ; do // while vertex of e contains more than one dart { Dart e1 = map.alpha1(e) ; // e1 stores next dart of vertex of e if (e1 == e) notempty = false ; // last dart of vertex of e else { map.removeEdgeFromVertex(e) ; // detach e from its vertex } // Searchs where e may be inserted in the vertex of d Dart d1 = d ; do { if (CGoGN::Algo::BooleanOperator::isBetween(map, positions, e, d, map.alpha1(d))) break ; d = map.alpha1(d) ; } while (d != d1) ; // Inserted e in the correct place (after d) map.insertEdgeInVertex(d, e) ; // Go on with next darts d = e ; e = e1 ; } while (notempty) ; // 0-embed z on the merged vertex positions[d] = p ; } template void mergeVertices(typename PFP::MAP& map, const VertexAttribute& positions) void mergeVertices(typename PFP::MAP& map, VertexAttribute& positions) { // TODO optimiser en triant les sommets for(Dart d = map.begin() ; d != map.end() ; map.next(d)) { CellMarker vM(map); vM.mark(d); std::cout << "." ; std::cout.flush() ; for(Dart dd = map.begin() ; dd != map.end() ; map.next(dd)) { if(!vM.isMarked(dd)) { if(Geom::arePointsEquals(positions[d],positions[dd])) { mergeVertex(map,positions,d,dd); if (map.sameVertex(d,dd)) std::cout << "fusion: sameVertex" << std::endl ; if (!map.sameVertex(d,dd)) mergeVertex(map,positions,d,dd); // vM.mark(d); } } } ... ...
 ... ... @@ -336,6 +336,7 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, VertexAttrib map.sewFaces(d1,d_1,false) ; edgeWidth[d1] = *itW; if (*itW == 0) std::cout << "importSVG : null path width" << std::endl ; d1 = map.phi1(d1); d_1 = map.phi_1(d_1); ... ... @@ -404,153 +405,145 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, VertexAttrib ///////////////////////////////////////////////////////////////////////////////////////////// // DartMarker close(map); // map.closeMap(close); // map.closeMap(); std::cout << "importSVG : Vertices merging..." << std::endl; Algo::BooleanOperator::mergeVertices(map,position); std::cout << "importSVG : Vertices merged." << std::endl; std::cout << "importSVG : Merging of vertices." << std::endl; ///////////////////////////////////////////////////////////////////////////////////////////// //simplify the edges to have a more regular sampling float minDist = 20.0f ; for (Dart d = map.begin() ; d != map.end() ; map.next(d)) { bool canSimplify = true ; while ( canSimplify && ((position[map.phi1(d)] - position[d]).norm() < minDist) ) { if (map.vertexDegree(map.phi1(d)) == 2) { map.uncutEdge(d) ; } else canSimplify = false ; } } std::cout << "importSVG : Downsampling of vertices." << std::endl; ///////////////////////////////////////////////////////////////////////////////////////////// //cut the edges to have a more regular sampling // float maxDist=60.0f; // CellMarker treated(map,EDGE); // for(Dart d = map.begin(); d != map.end(); map.next(d)) // { // if(!treated.isMarked(d)) // { // treated.mark(d); // VEC3 p1 =position[d]; // VEC3 p2 =position[map.phi1(d)]; // // if((p1-p2).norm()>maxDist) // { // unsigned int nbSeg = ((p1-p2).norm())/int(maxDist); // for(unsigned int i=0;i treated(map) ; for (Dart d = map.begin() ; d != map.end() ; map.next(d)) { if (!treated.isMarked(d)) { treated.mark(d) ; VEC3 p1 = position[d] ; VEC3 p2 = position[map.phi1(d)] ; VEC3 v = p2 - p1 ; if (v.norm() > maxDist) { unsigned int nbSeg = (unsigned int)(v.norm() / maxDist) ; v /= nbSeg ; for (unsigned int i = 0 ; i < nbSeg - 1 ; ++i) map.cutEdge(d) ; brokenL.mark(d); brokenL.mark(map.phi2(d)); Dart dd = map.phi1(d) ; for (unsigned int i = 1 ; i < nbSeg ; ++i) { brokenL.mark(dd); brokenL.mark(map.phi2(dd)); position[dd] = p1 + v * i ; dd = map.phi1(dd) ; } } } } std::cout << "importSVG : Refinement of long edges." << std::endl; ///////////////////////////////////////////////////////////////////////////////////////////// //process broken lines CellMarker eMTreated(map); for(Dart d = map.begin();d != map.end(); map.next(d)) CellMarker eMTreated(map) ; for (Dart d = map.begin() ; d != map.end() ; map.next(d)) { if(brokenL.isMarked(d) && !eMTreated.isMarked(d)) if (brokenL.isMarked(d) && !eMTreated.isMarked(d)) { eMTreated.mark(d) ; //insert a quadrangular face in the broken line // -> we convert broken lines to faces to represent their width // -> the intersection are then closed Dart d1 = d; Dart d2 = map.phi2(d); VEC3 p1 = position[d1]; VEC3 p2 = position[d2]; Dart d1 = d ; Dart d2 = map.phi2(d1) ; float width = edgeWidth[d1]/2.0f; if(width==0) std::cout << "importSVG : error width of path is equal to zero" << std::endl; map.unsewFaces(d1) ; Dart dN = map.newFace(4) ; eMTreated.mark(d1); eMTreated.mark(d2); VEC3 p1 = position[d1] ; VEC3 p2 = position[d2] ; VEC3 v = p2 - p1 ; VEC3 ortho = v ^ VEC3(0, 0, 1); float width = edgeWidth[d1] / 2.0f ; ortho.normalize() ; v.normalize() ; VEC3 v = p2-p1; //take the orthogonal direction to the path to apply width afterward VEC3 ortho = v^VEC3(0,0,1); ortho.normalize(); v.normalize(); //if the valence of one of the vertex is equal to one //cut the edge to insert the quadrangular face // if(map.phi2_1(d1)==d1) if(map.phi_1(d1)==d2) if (map.phi2_1(d1) == d1) { map.cutEdge(d2); Dart dC = map.phi1(d2); eMTreated.mark(dC); map.cutEdge(d2) ; brokenL.mark(map.phi1(d2)) ; eMTreated.mark(map.phi1(d2)) ; map.sewFaces(map.phi_1(d1), map.phi1(dN)) ; position[map.phi_1(d1)]=p1; edgePlanes[map.phi_1(d1)] = Geom::Plane3D(v,p1); } else { if(d1 != map.phi1(d2) && map.phi_1(d1)!=map.phi1(d2)) { map.splitFace(d1,map.phi1(d2)); } position[map.phi_1(d1)] = p1 ; edgePlanes[map.phi_1(d1)] = Geom::Plane3D(v, p1) ; } // if(map.phi2_1(d2)==d2) if(map.phi_1(d2)==d1) if (map.phi2_1(d2) == d2) { map.cutEdge(d1); map.cutEdge(d1) ; brokenL.mark(map.phi1(d1)) ; eMTreated.mark(map.phi1(d1)) ; Dart dC = map.phi1(d1); eMTreated.mark(dC); map.sewFaces(map.phi_1(d2), map.phi_1(dN)) ; position[map.phi_1(d2)]=p2; edgePlanes[map.phi_1(d2)] = Geom::Plane3D(-1.0f*v, p2); } else { if(d2 != map.phi1(d1) && map.phi_1(d2)!=map.phi1(d1)) { map.splitFace(d2,map.phi1(d1)); } position[map.phi_1(d2)] = p2 ; edgePlanes[map.phi_1(d2)] = Geom::Plane3D(-1.0f * v, p2) ; } // map.sewFaces(d1, dN); // map.sewFaces(d2, map.phi1(map.phi1(dN))); map.sewFaces(d1, dN) ; map.sewFaces(d2, map.phi1(map.phi1(dN))) ; edgePlanes[d1] = Geom::Plane3D(ortho, p1-(width*ortho)); edgePlanes[d2] = Geom::Plane3D(-1.0f*ortho, p2+(width*ortho)); edgePlanes[d1] = Geom::Plane3D(ortho, p1 - (width * ortho)) ; edgePlanes[d2] = Geom::Plane3D(-1.0f * ortho, p2 + (width * ortho)) ; } } std::cout << "Broken line faces : inserted" << std::endl; // //close the intersections // for(Dart d = map.begin();d != map.end(); map.next(d)) // { // if(map.isBoundaryMarked(map.phi2(d))) // map.closeHole(d); // } //close the intersections for (Dart d = map.begin() ; d != map.end() ; map.next(d)) { if (d == map.phi2(d)) map.closeHole(d) ; } //embed the path for(Dart d = map.begin();d != map.end(); map.next(d)) for (Dart d = map.begin() ; d != map.end() ; map.next(d)) { if(brokenL.isMarked(d)) if (brokenL.isMarked(d)) { Geom::Plane3D pl = edgePlanes[d]; std::cout << "pl " << pl << std::endl; Geom::Plane3D pl; VEC3 pos = position[d] ; VEC3 pos = position[d]; pl.project(pos); pl = edgePlanes[map.phi_1(d)]; pl = edgePlanes[d] ; pl.project(pos) ; pl = edgePlanes[map.phi_1(d)] ; pl.project(pos) ; pl.project(pos); position[d] = pos; position[d] = pos ; } } ///////////////////////////////////////////////////////////////////////////////////////////// //process polygons ... ...
 ... ... @@ -89,17 +89,18 @@ public: * */ virtual void swapEdges(Dart d, Dart e); // /** // * The attributes attached to the vertex of dart d are kept on the resulting vertex // * The attributes attached to the face of dart d are overwritten on the face of dart e // */ // virtual void insertEdgeInVertex(Dart d, Dart e); // // /** // * The attributes attached to the vertex of dart d are kept on the resulting vertex // * The attributes attached to the face of dart d are overwritten on the face of dart e // */ // virtual void removeEdgeFromVertex(Dart d); /** * The attributes attached to the vertex of dart d are kept on the resulting vertex * The attributes attached to the face of dart d are overwritten on the face of dart e */ virtual void insertEdgeInVertex(Dart d, Dart e); /** * The attributes attached to the vertex of dart d are kept on the resulting vertex * The attributes attached to the face of dart d are overwritten on the face of dart e */ virtual bool removeEdgeFromVertex(Dart d); /** * The attributes attached to the vertices of the edge of d are kept on the vertices of the resulting edge ... ...
 ... ... @@ -231,54 +231,57 @@ void EmbeddedMap2::swapEdges(Dart d, Dart e) embedNewCell(d); } //void EmbeddedMap2::insertEdgeInVertex(Dart d, Dart e) //{ // Map2::insertEdgeInVertex(d, e); // // if (isOrbitEmbedded()) // { // copyDartEmbedding(e, d) ; // } // // if (isOrbitEmbedded()) // { // if(!sameFace(d,e)) // { // embedNewCell(e); // copyCell(e, d) ; // } // else // { // embedOrbit(d, getEmbedding(d)) ; // } // } //} // //void EmbeddedMap2::removeEdgeFromVertex(Dart d) //{ // Dart dPrev = alpha_1(d); // // Map2::removeEdgeFromVertex(d); // // if (isOrbitEmbedded()) // { // embedNewCell(d); // copyCell(d, dPrev); // } // // if (isOrbitEmbedded()) // { // if(!sameFace(d, dPrev)) // { // embedNewCell(d); // copyCell(d, dPrev) ; // } // else // { // embedOrbit(d, getEmbedding(d)) ; // } // } //} void EmbeddedMap2::insertEdgeInVertex(Dart d, Dart e) { Map2::insertEdgeInVertex(d, e); if (isOrbitEmbedded()) { copyDartEmbedding(e, d) ; } if (isOrbitEmbedded()) { if(!sameFace(d,e)) { embedNewCell(e); copyCell(e, d) ; } else { embedOrbit(d, getEmbedding(d)) ; } } } bool EmbeddedMap2::removeEdgeFromVertex(Dart d) { Dart dPrev = alpha_1(d); if (dPrev == d) return false ; bool b = Map2::removeEdgeFromVertex(d); if (isOrbitEmbedded()) { embedNewCell(d); copyCell(d, dPrev); } if (isOrbitEmbedded()) { if(!sameFace(d, dPrev)) { embedNewCell(d); copyCell(d, dPrev) ; } else { embedOrbit(d, getEmbedding(d)) ; } } return b ; } void EmbeddedMap2::sewFaces(Dart d, Dart e, bool withBoundary) { ... ...
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!