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