Commit 4211c862 authored by untereiner's avatar untereiner

modif import Obj with Ele regions

parent a5725bb3
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
Viewer::Viewer() : Viewer::Viewer() :
m_renderStyle(FLAT), m_renderStyle(FLAT),
m_drawTopo(true),
m_drawVertices(false), m_drawVertices(false),
m_drawEdges(false), m_drawEdges(false),
m_drawFaces(true), m_drawFaces(true),
m_drawNormals(false), m_drawNormals(false),
m_drawTopo(false),
m_render(NULL), m_render(NULL),
m_renderTopo(NULL), m_renderTopo(NULL),
m_phongShader(NULL), m_phongShader(NULL),
...@@ -128,7 +128,7 @@ void Viewer::cb_initGL() ...@@ -128,7 +128,7 @@ void Viewer::cb_initGL()
void Viewer::cb_redraw() void Viewer::cb_redraw()
{ {
glClearColor(1,1,1,0); //glClearColor(1,1,1,0);
if(m_drawVertices) if(m_drawVertices)
{ {
float size = vertexScaleFactor ; float size = vertexScaleFactor ;
...@@ -206,7 +206,8 @@ void Viewer::cb_mousePress(int button, int x, int y) ...@@ -206,7 +206,8 @@ void Viewer::cb_mousePress(int button, int x, int y)
Dart d = m_renderTopo->picking<PFP>(myMap, x, y, allDarts); Dart d = m_renderTopo->picking<PFP>(myMap, x, y, allDarts);
if (d != Dart::nil()) if (d != Dart::nil())
{ {
statusMsg("dart picked"); //statusMsg("dart picked");
myMap.mergeFaces(d);
} }
else else
{ {
......
...@@ -190,7 +190,6 @@ void MyQT::cb_redraw() ...@@ -190,7 +190,6 @@ void MyQT::cb_redraw()
} }
void MyQT::cb_mousePress(int button, int x, int y) void MyQT::cb_mousePress(int button, int x, int y)
{ {
if (!Shift()) if (!Shift())
...@@ -311,6 +310,20 @@ int main(int argc, char **argv) ...@@ -311,6 +310,20 @@ int main(int argc, char **argv)
else else
position = myMap.getAttribute<PFP::VEC3>(VERTEX , attrNames[0]) ; position = myMap.getAttribute<PFP::VEC3>(VERTEX , attrNames[0]) ;
} }
if(extension == std::string(".off"))
{
if(!Algo::Import::importMeshToExtrude<PFP>(myMap, argv[1], attrNames))
{
std::cerr << "could not import " << std::endl ;
return 1;
}
else
{
position = myMap.getAttribute<PFP::VEC3>(VERTEX , attrNames[0]) ;
myMap.closeMap();
}
}
} }
else else
{ {
......
...@@ -209,6 +209,9 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& ...@@ -209,6 +209,9 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, typename PFP::TVEC3&
mf.markOrbit(FACE, old) ; mf.markOrbit(FACE, old) ;
// TraversorW<typename PFP::MAP> tw(map);
// for(Dart d = tw.begin(); d != tw.end(); d = tw.next())
for(unsigned int i = 0; i < visitedFaces.size(); ++i) for(unsigned int i = 0; i < visitedFaces.size(); ++i)
{ {
Dart e = visitedFaces[i] ; Dart e = visitedFaces[i] ;
......
...@@ -186,13 +186,15 @@ bool importMeshSToV(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts, float d ...@@ -186,13 +186,15 @@ bool importMeshSToV(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts, float d
} }
FunctorSetEmb<typename PFP::MAP> fsetemb(map, VERTEX, em); FunctorSetEmb<typename PFP::MAP> fsetemb(map, VERTEX, 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.foreach_dart_of_orbit(PFP::MAP::ORBIT_IN_PARENT(VERTEX), 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> fsetemb2(map, VERTEX, em2); FunctorSetEmb<typename PFP::MAP> fsetemb2(map, VERTEX, 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.foreach_dart_of_orbit(PFP::MAP::ORBIT_IN_PARENT(VERTEX), 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
......
...@@ -126,14 +126,14 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename ...@@ -126,14 +126,14 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename
unsigned int id = container.insertLine(); unsigned int id = container.insertLine();
position[id] = pos; position[id] = pos;
// CGoGNout << "emb : " << pos << " / id = " << id << CGoGNendl;
verticesID.push_back(id); verticesID.push_back(id);
} }
std::vector<std::vector<Dart> > vecDartPtrEmb; std::vector<std::vector<Dart> > vecDartPtrEmb;
vecDartPtrEmb.reserve(m_nbVertices); vecDartPtrEmb.reserve(m_nbVertices);
DartMarkerNoUnmark m(map) ;
//Read and embed tetrahedra TODO //Read and embed tetrahedra TODO
for(unsigned i = 0; i < m_nbVolumes ; ++i) for(unsigned i = 0; i < m_nbVolumes ; ++i)
{ {
...@@ -144,10 +144,8 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename ...@@ -144,10 +144,8 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename
std::stringstream oss(line); std::stringstream oss(line);
oss >> nbe; oss >> nbe;
// CGoGNout << "tetra number : " << nbe << CGoGNendl;
//Algo::Modelisation::Polyhedron<PFP>::createTetra(map); Dart d = Algo::Modelisation::createTetrahedron<PFP>(map);
Dart d = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(map, 4);
Geom::Vec4ui pt; Geom::Vec4ui pt;
oss >> pt[0]; oss >> pt[0];
oss >> pt[1]; oss >> pt[1];
...@@ -157,74 +155,83 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename ...@@ -157,74 +155,83 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename
//regions ? //regions ?
oss >> nbe; oss >> nbe;
// CGoGNout << "\t embedding number : " << pt[0] << " " << pt[1] << " " << pt[2] << " " << pt[3] << CGoGNendl;
// Embed three vertices // Embed three vertices
for(unsigned int j = 0 ; j < 3 ; ++j) for(unsigned int j = 0 ; j < 3 ; ++j)
{ {
// CGoGNout << "\t embedding number : " << pt[j]; FunctorSetEmb<typename PFP::MAP> fsetemb(map, VERTEX, verticesID[pt[2-j]]);
map.foreach_dart_of_orbit( PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb);
FunctorSetEmb<typename PFP::MAP> femb(map, VERTEX, verticesID[pt[j]]);
//store darts per vertices to optimize reconstruction
Dart dd = d; Dart dd = d;
do { do
femb(dd); {
//vecDartPtrEmb[pt[j]].push_back(dd); m.mark(dd) ;
vecDartsPerVertex[pt[j]].push_back(dd); vecDartsPerVertex[pt[2-j]].push_back(dd);
dd = map.phi1(map.phi2(dd)); dd = map.phi1(map.phi2(dd));
} while(dd!=d); } while(dd != d);
d = map.phi1(d); d = map.phi1(d);
// CGoGNout << " done" << CGoGNendl;
} }
//Embed the last vertex //Embed the last vertex
// CGoGNout << "\t embedding number : " << pt[3] << CGoGNendl;
d = map.phi_1(map.phi2(d)); d = map.phi_1(map.phi2(d));
FunctorSetEmb<typename PFP::MAP> femb(map, VERTEX, verticesID[pt[3]]); FunctorSetEmb<typename PFP::MAP> fsetemb(map, VERTEX, verticesID[pt[3]]);
map.foreach_dart_of_orbit( PFP::MAP::ORBIT_IN_PARENT(VERTEX), d, fsetemb);
//store darts per vertices to optimize reconstruction
Dart dd = d; Dart dd = d;
do { do
femb(dd); {
// CGoGNout << "embed" << CGoGNendl; m.mark(dd) ;
//vecDartPtrEmb[pt[3]].push_back(dd);
vecDartsPerVertex[pt[3]].push_back(dd); vecDartsPerVertex[pt[3]].push_back(dd);
dd = map.phi1(map.phi2(dd)); dd = map.phi1(map.phi2(dd));
} while(dd != d); } while(dd != d);
// CGoGNout << "end tetra" << CGoGNendl;
} }
// CGoGNout << "end 1/2" << CGoGNendl;
foff.close(); foff.close();
fele.close(); fele.close();
//Association des phi3 //Association des phi3
unsigned int nbBoundaryFaces = 0 ;
for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = map.begin(); d != map.end(); map.next(d))
{ {
std::vector<Dart>& vec = vecDartsPerVertex[d]; if (m.isMarked(d))
for(typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end(); ++it)
{ {
if(map.phi3(*it)==*it) std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];
Dart good_dart = NIL;
for(typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
{ {
bool sewn=false; if(map.getEmbedding(VERTEX, map.phi1(*it)) == map.getEmbedding(VERTEX, d) &&
for(typename std::vector<Dart>::iterator itnext = it+1; itnext != vec.end() && !sewn; ++itnext) map.getEmbedding(VERTEX, map.phi_1(*it)) == map.getEmbedding(VERTEX, map.phi_1(d)) /*&&
map.getEmbedding(VERTEX, *it) == map.getEmbedding(VERTEX, map.phi1(d)) */)
{ {
if(map.getDartEmbedding(VERTEX,map.phi1(*it))==map.getDartEmbedding(VERTEX,map.phi_1(*itnext)) good_dart = *it ;
&& map.getDartEmbedding(VERTEX,map.phi_1(*it))==map.getDartEmbedding(VERTEX,map.phi1(*itnext)))
{
map.sewVolumes(*it,map.phi_1(*itnext));
sewn = true;
}
} }
} }
if (good_dart != NIL)
{
map.sewVolumes(d, good_dart, false);
m.unmarkOrbit(FACE, d);
}
else
{
m.unmarkOrbit(PFP::MAP::ORBIT_IN_PARENT(FACE), d);
++nbBoundaryFaces;
}
} }
} }
// CGoGNout << "end 2/2" << CGoGNendl; if (nbBoundaryFaces > 0)
{
std::cout << "closing" << std::endl ;
map.closeMap();
CGoGNout << "Map closed (" << nbBoundaryFaces << " boundary faces)" << CGoGNendl;
}
return true; return true;
} }
......
...@@ -37,15 +37,18 @@ namespace Tetrahedralization ...@@ -37,15 +37,18 @@ namespace Tetrahedralization
template <typename PFP> template <typename PFP>
void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d) void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d)
{ {
Dart d1 = d; //Splitting Path
Dart d2 = map.phi1(map.phi1(d)); std::vector<Dart> sp;
Dart d3 = map.phi_1(map.phi2(d)); sp.reserve(32);
Dart d4 = map.phi1(map.phi1(map.phi2(map.phi_1(d3))));
Traversor3VE<typename PFP::MAP> tra(map, d);
cut3Ear<PFP>(map,d1); for (Dart d = tra.begin() ; d != tra.end() ; d = tra.next())
cut3Ear<PFP>(map,d2); {
cut3Ear<PFP>(map,d3); map.splitFace(map.phi1(d), map.phi_1(d));
cut3Ear<PFP>(map,d4); sp.push_back(map.phi1(d));
}
map.splitVolume(sp);
} }
/************************************************************************************************ /************************************************************************************************
......
...@@ -274,6 +274,11 @@ public: ...@@ -274,6 +274,11 @@ public:
*/ */
bool isBoundaryVolume(Dart d) ; bool isBoundaryVolume(Dart d) ;
//! Tell if an edge of the volume is on the boundary
/* @param d a dart
*/
bool hasBoundaryEdge(Dart d);
//! Check the map completeness //! Check the map completeness
/*! Test if phi3 and phi2 ares involutions and if phi1 is a permutation /*! Test if phi3 and phi2 ares involutions and if phi1 is a permutation
*/ */
......
...@@ -24,7 +24,7 @@ void main(void) ...@@ -24,7 +24,7 @@ void main(void)
float lambertTerm = dot(N,L); float lambertTerm = dot(N,L);
int i; int i;
vec averageColor(0.,0.,0.); vec3 averageColor=vec3(0.,0.,0.);
for(i=0; i< NBVERTS_IN; i++) for(i=0; i< NBVERTS_IN; i++)
{ {
averageColor +=colorVertex[i]; averageColor +=colorVertex[i];
......
// ShaderFlatColorPerFace::vertexShaderText // ShaderFlatColorPerFace::vertexShaderText
ATTRIBUTE vec3 VertexPosition; ATTRIBUTE vec3 VertexPosition;
ATTRIBUTE vec3 VertexColor; ATTRIBUTE vec3 VertexColor;
VARYING_VERT vec3 colorVertex; VARYING_VERT vec3 colorVertex;
......
...@@ -446,7 +446,7 @@ unsigned int ImplicitHierarchicalMap3::volumeLevel(Dart d) ...@@ -446,7 +446,7 @@ unsigned int ImplicitHierarchicalMap3::volumeLevel(Dart d)
if(!mark.isMarked(ee)) // not already marked if(!mark.isMarked(ee)) // not already marked
{ {
visitedFaces.push_back(ee) ; visitedFaces.push_back(ee) ;
mark.markOrbit(ORIENTED_FACE, ee) ; mark.markOrbit(FACE, ee) ;
} }
e = phi1(e) ; e = phi1(e) ;
} while(e != visitedFaces[i]) ; } while(e != visitedFaces[i]) ;
...@@ -512,7 +512,7 @@ Dart ImplicitHierarchicalMap3::volumeOldestDart(Dart d) ...@@ -512,7 +512,7 @@ Dart ImplicitHierarchicalMap3::volumeOldestDart(Dart d)
// For every face added to the list // For every face added to the list
//the oldest dart from a volume is the oldest dart from all faces of this volume //the oldest dart from a volume is the oldest dart from all faces of this volume
mark.markOrbit(ORIENTED_FACE, d) ; mark.markOrbit(FACE, d) ;
for(unsigned int i = 0; i < visitedFaces.size(); ++i) for(unsigned int i = 0; i < visitedFaces.size(); ++i)
{ {
...@@ -529,7 +529,7 @@ Dart ImplicitHierarchicalMap3::volumeOldestDart(Dart d) ...@@ -529,7 +529,7 @@ Dart ImplicitHierarchicalMap3::volumeOldestDart(Dart d)
if(!mark.isMarked(ee)) // not already marked if(!mark.isMarked(ee)) // not already marked
{ {
visitedFaces.push_back(ee) ; visitedFaces.push_back(ee) ;
mark.markOrbit(ORIENTED_FACE, ee) ; mark.markOrbit(FACE, ee) ;
} }
e = phi1(e) ; e = phi1(e) ;
} while(e != visitedFaces[i]) ; } while(e != visitedFaces[i]) ;
...@@ -607,7 +607,7 @@ bool ImplicitHierarchicalMap3::volumeIsSubdivided(Dart d) ...@@ -607,7 +607,7 @@ bool ImplicitHierarchicalMap3::volumeIsSubdivided(Dart d)
if(!mark.isMarked(ee)) // not already marked if(!mark.isMarked(ee)) // not already marked
{ {
visitedFaces.push_back(ee) ; visitedFaces.push_back(ee) ;
mark.markOrbit(ORIENTED_FACE, ee) ; mark.markOrbit(FACE, ee) ;
} }
e = phi1(e) ; e = phi1(e) ;
} while(e != visitedFaces[i]) ; } while(e != visitedFaces[i]) ;
...@@ -781,7 +781,7 @@ bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersByOne(Dart d) ...@@ -781,7 +781,7 @@ bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersByOne(Dart d)
if(!mf.isMarked(ee)) // not already marked if(!mf.isMarked(ee)) // not already marked
{ {
visitedFaces.push_back(ee) ; visitedFaces.push_back(ee) ;
mf.markOrbit(ORIENTED_FACE, ee) ; mf.markOrbit(FACE, ee) ;
} }
e = phi1(e) ; e = phi1(e) ;
......
...@@ -64,7 +64,8 @@ Dart EmbeddedMap3::cutEdge(Dart d) ...@@ -64,7 +64,8 @@ Dart EmbeddedMap3::cutEdge(Dart d)
copyDartEmbedding(FACE2, f1, f); copyDartEmbedding(FACE2, f1, f);
Dart e = phi3(f1); Dart e = phi3(f1);
// copyDartEmbedding(ORIENTED_FACE, phi1(e), e); // copyDartEmbedding(ORIENTED_FACE, phi1(e), e);
copyDartEmbedding(FACE2, f1, f); // copyDartEmbedding(FACE2, f1, f);
copyDartEmbedding(FACE2, phi1(e), e);
f = alpha2(f); f = alpha2(f);
} while(f != d); } while(f != d);
} }
......
...@@ -657,6 +657,15 @@ Dart Map3::findBoundaryFaceOfEdge(Dart d) ...@@ -657,6 +657,15 @@ Dart Map3::findBoundaryFaceOfEdge(Dart d)
bool Map3::isBoundaryVolume(Dart d) bool Map3::isBoundaryVolume(Dart d)
{ {
//TraversorCell<Map3, FACE2> (*this);
// Traversor3WF<Map3> tra(*this);
// for(Dart dit = tra.begin() ; dit != tra.end() ; dit = tra.next())
// {
// if(isBoundaryMarked(phi3(dit)))
// return true ;
// }
// return false;
DartMarkerStore mark(*this); // Lock a marker DartMarkerStore mark(*this); // Lock a marker
std::vector<Dart> visitedFaces ; std::vector<Dart> visitedFaces ;
...@@ -684,6 +693,44 @@ bool Map3::isBoundaryVolume(Dart d) ...@@ -684,6 +693,44 @@ bool Map3::isBoundaryVolume(Dart d)
return false; return false;
} }
bool Map3::hasBoundaryEdge(Dart d)
{
// Traversor3WE<Map3> tra(*this);
// for(Dart dit = tra.begin() ; dit != tra.end() ; dit = tra.next())
// {
// if(isBoundaryEdge(dit))
// return true;
// }
//
// return false;
DartMarkerStore mark(*this); // Lock a marker
std::vector<Dart> visitedEdges ;
visitedEdges.reserve(512) ;
visitedEdges.push_back(d) ;
mark.markOrbit(EDGE2, d) ;
for(unsigned int i = 0; i < visitedEdges.size(); ++i)
{
if(isBoundaryEdge(i))
return true ;
Dart e = visitedEdges[i] ;
do // add all face neighbours to the table
{
//Dart ee = phi2(e) ;
if(!mark.isMarked(e)) // not already marked
{
visitedEdges.push_back(phi2(e)) ;
mark.markOrbit(EDGE2, e) ;
}
e = phi1(e) ;
} while(e != visitedEdges[i]) ;
}
return false;
}
bool Map3::check() bool Map3::check()
{ {
std::cout << "Check: topology begin" << std::endl; std::cout << "Check: topology begin" << std::endl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment