Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

Commit 0bd11b96 authored by Lionel Untereiner's avatar Lionel Untereiner
Browse files

Merge cgogn.unistra.fr:~/CGoGN

parents a177c353 7e142b2b
...@@ -42,127 +42,127 @@ namespace Import ...@@ -42,127 +42,127 @@ namespace Import
template <typename PFP> template <typename PFP>
bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts) bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
{ {
VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> > > vecDartsPerVertex(map, "incidents"); VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> > > vecDartsPerVertex(map, "incidents");
unsigned nbf = mts.getNbFaces(); unsigned nbf = mts.getNbFaces();
int index = 0; int index = 0;
// buffer for tempo faces (used to remove degenerated edges) // buffer for tempo faces (used to remove degenerated edges)
std::vector<unsigned int> edgesBuffer; std::vector<unsigned int> edgesBuffer;
edgesBuffer.reserve(16); edgesBuffer.reserve(16);
DartMarkerNoUnmark m(map) ; DartMarkerNoUnmark m(map) ;
FunctorInitEmb<typename PFP::MAP, VERTEX> fsetemb(map); FunctorInitEmb<typename PFP::MAP, VERTEX> fsetemb(map);
// for each face of table // for each face of table
for(unsigned int i = 0; i < nbf; ++i) for(unsigned int i = 0; i < nbf; ++i)
{ {
// store face in buffer, removing degenerated edges // store face in buffer, removing degenerated edges
unsigned int nbe = mts.getNbEdgesFace(i); unsigned int nbe = mts.getNbEdgesFace(i);
edgesBuffer.clear(); edgesBuffer.clear();
unsigned int prec = EMBNULL; unsigned int prec = EMBNULL;
for (unsigned int j = 0; j < nbe; ++j) for (unsigned int j = 0; j < nbe; ++j)
{ {
unsigned int em = mts.getEmbIdx(index++); unsigned int em = mts.getEmbIdx(index++);
if (em != prec) if (em != prec)
{ {
prec = em; prec = em;
edgesBuffer.push_back(em); edgesBuffer.push_back(em);
} }
} }
// check first/last vertices // check first/last vertices
if (edgesBuffer.front() == edgesBuffer.back()) if (edgesBuffer.front() == edgesBuffer.back())
edgesBuffer.pop_back(); edgesBuffer.pop_back();
// create only non degenerated faces // create only non degenerated faces
nbe = edgesBuffer.size(); nbe = edgesBuffer.size();
if (nbe > 2) if (nbe > 2)
{ {
Dart d = map.newFace(nbe, false); Dart d = map.newFace(nbe, false);
for (unsigned int j = 0; j < nbe; ++j) for (unsigned int j = 0; j < nbe; ++j)
{ {
unsigned int em = edgesBuffer[j]; // get embedding unsigned int em = edgesBuffer[j]; // get embedding
fsetemb.changeEmb(em) ; fsetemb.changeEmb(em) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb); map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
m.mark(d) ; // mark on the fly to unmark on second loop m.mark(d) ; // mark on the fly to unmark on second loop
vecDartsPerVertex[em].push_back(d); // store incident darts for fast adjacency reconstruction vecDartsPerVertex[em].push_back(d); // store incident darts for fast adjacency reconstruction
d = map.phi1(d); d = map.phi1(d);
} }
} }
} }
bool needBijectiveCheck = false; bool needBijectiveCheck = false;
// reconstruct neighbourhood // reconstruct neighbourhood
unsigned int nbBoundaryEdges = 0; unsigned int nbBoundaryEdges = 0;
for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = map.begin(); d != map.end(); map.next(d))
{ {
if (m.isMarked(d)) if (m.isMarked(d))
{ {
// darts incident to end vertex of edge // darts incident to end vertex of edge
std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)]; std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];
unsigned int embd = map.template getEmbedding<VERTEX>(d); unsigned int embd = map.template getEmbedding<VERTEX>(d);
Dart good_dart = NIL; Dart good_dart = NIL;
bool firstOK = true; bool firstOK = true;
for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it) for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
{ {
if (map.template getEmbedding<VERTEX>(map.phi1(*it)) == embd) if (map.template getEmbedding<VERTEX>(map.phi1(*it)) == embd)
{ {
good_dart = *it; good_dart = *it;
if (good_dart == map.phi2(good_dart)) if (good_dart == map.phi2(good_dart))
{ {
map.sewFaces(d, good_dart, false); map.sewFaces(d, good_dart, false);
m.unmarkOrbit<EDGE>(d); m.unmarkOrbit<EDGE>(d);
} }
else else
{ {
good_dart = NIL; good_dart = NIL;
firstOK = false; firstOK = false;
} }
} }
} }
if (!firstOK) if (!firstOK)
needBijectiveCheck = true; needBijectiveCheck = true;
if (good_dart == NIL) if (good_dart == NIL)
{ {
m.unmarkOrbit<EDGE>(d); m.unmarkOrbit<EDGE>(d);
++nbBoundaryEdges; ++nbBoundaryEdges;
} }
} }
} }
if (nbBoundaryEdges > 0) if (nbBoundaryEdges > 0)
{ {
unsigned int nbH = map.closeMap(); unsigned int nbH = map.closeMap();
CGoGNout << "Map closed (" << nbBoundaryEdges << " boundary edges / " << nbH << " holes)" << CGoGNendl; CGoGNout << "Map closed (" << nbBoundaryEdges << " boundary edges / " << nbH << " holes)" << CGoGNendl;
} }
if (needBijectiveCheck) if (needBijectiveCheck)
{ {
// ensure bijection between topo and embedding // ensure bijection between topo and embedding
map.template bijectiveOrbitEmbedding<VERTEX>(); map.template bijectiveOrbitEmbedding<VERTEX>();
} }
return true ; return true ;
} }
template <typename PFP> template <typename PFP>
bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, bool mergeCloseVertices) bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, bool mergeCloseVertices)
{ {
MeshTablesSurface<PFP> mts(map); MeshTablesSurface<PFP> mts(map);
if(!mts.importMesh(filename, attrNames)) if(!mts.importMesh(filename, attrNames))
return false; return false;
if (mergeCloseVertices) if (mergeCloseVertices)
mts.mergeCloseVertices(); mts.mergeCloseVertices();
return importMesh<PFP>(map, mts); return importMesh<PFP>(map, mts);
} }
template <typename PFP> template <typename PFP>
...@@ -183,103 +183,103 @@ bool importVoxellisation(typename PFP::MAP& map, Algo::Surface::Modelisation::Vo ...@@ -183,103 +183,103 @@ bool importVoxellisation(typename PFP::MAP& map, Algo::Surface::Modelisation::Vo
template <typename PFP> template <typename PFP>
bool importMeshSAsV(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts) bool importMeshSAsV(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
{ {
VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> > > vecDartsPerVertex(map, "incidents"); VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> > > vecDartsPerVertex(map, "incidents");
unsigned nbf = mts.getNbFaces(); unsigned nbf = mts.getNbFaces();
int index = 0; int index = 0;
// buffer for tempo faces (used to remove degenerated edges) // buffer for tempo faces (used to remove degenerated edges)
std::vector<unsigned int> edgesBuffer; std::vector<unsigned int> edgesBuffer;
edgesBuffer.reserve(16); edgesBuffer.reserve(16);
DartMarkerNoUnmark m(map) ; DartMarkerNoUnmark m(map) ;
// for each face of table // for each face of table
for(unsigned int i = 0; i < nbf; ++i) for(unsigned int i = 0; i < nbf; ++i)
{ {
// store face in buffer, removing degenerated edges // store face in buffer, removing degenerated edges
unsigned int nbe = mts.getNbEdgesFace(i); unsigned int nbe = mts.getNbEdgesFace(i);
edgesBuffer.clear(); edgesBuffer.clear();
unsigned int prec = EMBNULL; unsigned int prec = EMBNULL;
for (unsigned int j = 0; j < nbe; ++j) for (unsigned int j = 0; j < nbe; ++j)
{ {
unsigned int em = mts.getEmbIdx(index++); unsigned int em = mts.getEmbIdx(index++);
if (em != prec) if (em != prec)
{ {
prec = em; prec = em;
edgesBuffer.push_back(em); edgesBuffer.push_back(em);
} }
} }
// check first/last vertices // check first/last vertices
if (edgesBuffer.front() == edgesBuffer.back()) if (edgesBuffer.front() == edgesBuffer.back())
edgesBuffer.pop_back(); edgesBuffer.pop_back();
// create only non degenerated faces // create only non degenerated faces
nbe = edgesBuffer.size(); nbe = edgesBuffer.size();
if (nbe > 2) if (nbe > 2)
{ {
Dart d = map.newFace(nbe, false); Dart d = map.newFace(nbe, false);
for (unsigned int j = 0; j < nbe; ++j) for (unsigned int j = 0; j < nbe; ++j)
{ {
unsigned int em = edgesBuffer[j]; // get embedding unsigned int em = edgesBuffer[j]; // get embedding
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, em); FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, em);
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT2>(d, fsetemb); map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT2>(d, fsetemb);
m.mark(d) ; // mark on the fly to unmark on second loop m.mark(d) ; // mark on the fly to unmark on second loop
vecDartsPerVertex[em].push_back(d); // store incident darts for fast adjacency reconstruction vecDartsPerVertex[em].push_back(d); // store incident darts for fast adjacency reconstruction
d = map.phi1(d); d = map.phi1(d);
} }
} }
} }
// reconstruct neighbourhood // reconstruct neighbourhood
unsigned int nbBoundaryEdges = 0; unsigned int nbBoundaryEdges = 0;
for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = map.begin(); d != map.end(); map.next(d))
{ {
if (m.isMarked(d)) if (m.isMarked(d))
{ {
// darts incident to end vertex of edge // darts incident to end vertex of edge
std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)]; std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];
unsigned int embd = map.template getEmbedding<VERTEX>(d); unsigned int embd = map.template getEmbedding<VERTEX>(d);
Dart good_dart = NIL; Dart good_dart = NIL;
for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it) for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
{ {
if (map.template getEmbedding<VERTEX>(map.phi1(*it)) == embd) if (map.template getEmbedding<VERTEX>(map.phi1(*it)) == embd)
good_dart = *it; good_dart = *it;
} }
if (good_dart != NIL) if (good_dart != NIL)
{ {
map.sewFaces(d, good_dart, false); map.sewFaces(d, good_dart, false);
m.unmarkOrbit<EDGE>(d); m.unmarkOrbit<EDGE>(d);
} }
else else
{ {
m.unmark(d); m.unmark(d);
++nbBoundaryEdges; ++nbBoundaryEdges;
} }
} }
} }
unsigned int nbH = map.closeMap(); unsigned int nbH = map.closeMap();
CGoGNout << "Map closed (" << map.template getNbOrbits<FACE>() << " boundary faces / " << nbH << " holes)" << CGoGNendl; CGoGNout << "Map closed (" << map.template getNbOrbits<FACE>() << " boundary faces / " << nbH << " holes)" << CGoGNendl;
std::cout << "nb darts : " << map.getNbDarts() << std::endl ; std::cout << "nb darts : " << map.getNbDarts() << std::endl ;
// ensure bijection between topo and embedding // ensure bijection between topo and embedding
//map.template bijectiveOrbitEmbedding<VERTEX>(); //map.template bijectiveOrbitEmbedding<VERTEX>();
return true ; return true ;
} }
template <typename PFP> template <typename PFP>
bool importMeshSAsV(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames) bool importMeshSAsV(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames)
{ {
MeshTablesSurface<PFP> mts(map); MeshTablesSurface<PFP> mts(map);
if(!mts.importMesh(filename, attrNames)) if(!mts.importMesh(filename, attrNames))
return false; return false;
return importMeshSAsV<PFP>(map, mts); return importMeshSAsV<PFP>(map, mts);
} }
...@@ -298,242 +298,242 @@ namespace Import ...@@ -298,242 +298,242 @@ namespace Import
template <typename PFP> template <typename PFP>
bool importMeshSToV(typename PFP::MAP& map, Surface::Import::MeshTablesSurface<PFP>& mts, float dist) bool importMeshSToV(typename PFP::MAP& map, Surface::Import::MeshTablesSurface<PFP>& mts, float dist)
{ {
VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> > > vecDartsPerVertex(map, "incidents"); VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> > > vecDartsPerVertex(map, "incidents");
unsigned nbf = mts.getNbFaces(); unsigned nbf = mts.getNbFaces();
int index = 0; int index = 0;
// buffer for tempo faces (used to remove degenerated edges) // buffer for tempo faces (used to remove degenerated edges)
std::vector<unsigned int> edgesBuffer; std::vector<unsigned int> edgesBuffer;
edgesBuffer.reserve(16); edgesBuffer.reserve(16);
DartMarkerNoUnmark m(map) ; DartMarkerNoUnmark m(map) ;
VertexAttribute<typename PFP::VEC3> position = map.template getAttribute<typename PFP::VEC3, VERTEX>("position"); VertexAttribute<typename PFP::VEC3> position = map.template getAttribute<typename PFP::VEC3, VERTEX>("position");
std::vector<unsigned int > backEdgesBuffer(mts.getNbVertices(), EMBNULL); std::vector<unsigned int > backEdgesBuffer(mts.getNbVertices(), EMBNULL);
// for each face of table -> create a prism // for each face of table -> create a prism
for(unsigned int i = 0; i < nbf; ++i) for(unsigned int i = 0; i < nbf; ++i)
{ {
// store face in buffer, removing degenerated edges // store face in buffer, removing degenerated edges
unsigned int nbe = mts.getNbEdgesFace(i); unsigned int nbe = mts.getNbEdgesFace(i);
edgesBuffer.clear(); edgesBuffer.clear();
unsigned int prec = EMBNULL; unsigned int prec = EMBNULL;
for (unsigned int j = 0; j < nbe; ++j) for (unsigned int j = 0; j < nbe; ++j)
{ {
unsigned int em = mts.getEmbIdx(index++); unsigned int em = mts.getEmbIdx(index++);
if (em != prec) if (em != prec)
{ {
prec = em; prec = em;
edgesBuffer.push_back(em); edgesBuffer.push_back(em);
} }
} }
// check first/last vertices // check first/last vertices
if (edgesBuffer.front() == edgesBuffer.back()) if (edgesBuffer.front() == edgesBuffer.back())
edgesBuffer.pop_back(); edgesBuffer.pop_back();
// create only non degenerated faces // create only non degenerated faces
nbe = edgesBuffer.size(); nbe = edgesBuffer.size();
if (nbe > 2) if (nbe > 2)
{ {
Dart d = Surface::Modelisation::createPrism<PFP>(map, nbe,false); Dart d = Surface::Modelisation::createPrism<PFP>(map, nbe,false);
//Embed the base faces //Embed the base faces
for (unsigned int j = 0; j < nbe; ++j) for (unsigned int j = 0; j < nbe; ++j)
{ {
unsigned int em = edgesBuffer[j]; // get embedding unsigned int em = edgesBuffer[j]; // get embedding
if(backEdgesBuffer[em] == EMBNULL) if(backEdgesBuffer[em] == EMBNULL)
{ {
unsigned int emn = map.template newCell<VERTEX>(); unsigned int emn = map.template newCell<VERTEX>();
map.template copyCell<VERTEX>(emn, em); map.template copyCell<VERTEX>(emn, em);
backEdgesBuffer[em] = emn; backEdgesBuffer[em] = emn;
position[emn] += typename PFP::VEC3(0,0,dist); position[emn] += typename PFP::VEC3(0,0,dist);
} }
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, em); FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, em);
//foreach_dart_of_orbit_in_parent<typename PFP::MAP>(&map, VERTEX, d, fsetemb) ; //foreach_dart_of_orbit_in_parent<typename PFP::MAP>(&map, VERTEX, d, fsetemb) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb); map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
//Embed the other base face //Embed the other base face
Dart d2 = map.phi1(map.phi1(map.phi2(d))); Dart d2 = map.phi1(map.phi1(map.phi2(d)));
unsigned int em2 = backEdgesBuffer[em]; unsigned int em2 = backEdgesBuffer[em];
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb2(map, em2); FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb2(map, em2);
//foreach_dart_of_orbit_in_parent<typename PFP::MAP>(&map, VERTEX, d2, fsetemb2) ; //foreach_dart_of_orbit_in_parent<typename PFP::MAP>(&map, VERTEX, d2, fsetemb2) ;
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d2, fsetemb2); map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d2, fsetemb2);
m.mark(d) ; // mark on the fly to unmark on second loop m.mark(d) ; // mark on the fly to unmark on second loop
vecDartsPerVertex[em].push_back(d); // store incident darts for fast adjacency reconstruction vecDartsPerVertex[em].push_back(d); // store incident darts for fast adjacency reconstruction
d = map.phi_1(d); d = map.phi_1(d);
} }
} }
} }
// reconstruct neighbourhood // reconstruct neighbourhood
unsigned int nbBoundaryEdges = 0; unsigned int nbBoundaryEdges = 0;
for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = map.begin(); d != map.end(); map.next(d))
{ {
if (m.isMarked(d)) if (m.isMarked(d))
{ {
// darts incident to end vertex of edge // darts incident to end vertex of edge
std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)]; std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];
unsigned int embd = map.template getEmbedding<VERTEX>(d); unsigned int embd = map.template getEmbedding<VERTEX>(d);
Dart good_dart = NIL; Dart good_dart = NIL;
for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it) for (typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
{ {
if (map.template getEmbedding<VERTEX>(map.phi1(*it)) == embd) if (map.template getEmbedding<VERTEX>(map.phi1(*it)) == embd)
good_dart = *it; good_dart = *it;
} }
if (good_dart != NIL)