Commit 4211c862 authored by untereiner's avatar untereiner

modif import Obj with Ele regions

parent a5725bb3
......@@ -26,11 +26,11 @@
Viewer::Viewer() :
m_renderStyle(FLAT),
m_drawTopo(true),
m_drawVertices(false),
m_drawEdges(false),
m_drawFaces(true),
m_drawNormals(false),
m_drawTopo(false),
m_render(NULL),
m_renderTopo(NULL),
m_phongShader(NULL),
......@@ -128,7 +128,7 @@ void Viewer::cb_initGL()
void Viewer::cb_redraw()
{
glClearColor(1,1,1,0);
//glClearColor(1,1,1,0);
if(m_drawVertices)
{
float size = vertexScaleFactor ;
......@@ -206,7 +206,8 @@ void Viewer::cb_mousePress(int button, int x, int y)
Dart d = m_renderTopo->picking<PFP>(myMap, x, y, allDarts);
if (d != Dart::nil())
{
statusMsg("dart picked");
//statusMsg("dart picked");
myMap.mergeFaces(d);
}
else
{
......
......@@ -190,7 +190,6 @@ void MyQT::cb_redraw()
}
void MyQT::cb_mousePress(int button, int x, int y)
{
if (!Shift())
......@@ -311,6 +310,20 @@ int main(int argc, char **argv)
else
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
{
......
......@@ -209,6 +209,9 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, typename PFP::TVEC3&
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)
{
Dart e = visitedFaces[i] ;
......
......@@ -186,13 +186,15 @@ bool importMeshSToV(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts, float d
}
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
Dart d2 = map.phi1(map.phi1(map.phi2(d)));
unsigned int em2 = backEdgesBuffer[em];
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
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
unsigned int id = container.insertLine();
position[id] = pos;
// CGoGNout << "emb : " << pos << " / id = " << id << CGoGNendl;
verticesID.push_back(id);
}
std::vector<std::vector<Dart> > vecDartPtrEmb;
vecDartPtrEmb.reserve(m_nbVertices);
DartMarkerNoUnmark m(map) ;
//Read and embed tetrahedra TODO
for(unsigned i = 0; i < m_nbVolumes ; ++i)
{
......@@ -144,10 +144,8 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename
std::stringstream oss(line);
oss >> nbe;
// CGoGNout << "tetra number : " << nbe << CGoGNendl;
//Algo::Modelisation::Polyhedron<PFP>::createTetra(map);
Dart d = Algo::Modelisation::Polyhedron<PFP>::createPolyhedron(map, 4);
Dart d = Algo::Modelisation::createTetrahedron<PFP>(map);
Geom::Vec4ui pt;
oss >> pt[0];
oss >> pt[1];
......@@ -157,74 +155,83 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename
//regions ?
oss >> nbe;
// CGoGNout << "\t embedding number : " << pt[0] << " " << pt[1] << " " << pt[2] << " " << pt[3] << CGoGNendl;
// Embed three vertices
for(unsigned int j = 0 ; j < 3 ; ++j)
{
// CGoGNout << "\t embedding number : " << pt[j];
FunctorSetEmb<typename PFP::MAP> femb(map, VERTEX, verticesID[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);
//store darts per vertices to optimize reconstruction
Dart dd = d;
do {
femb(dd);
//vecDartPtrEmb[pt[j]].push_back(dd);
vecDartsPerVertex[pt[j]].push_back(dd);
do
{
m.mark(dd) ;
vecDartsPerVertex[pt[2-j]].push_back(dd);
dd = map.phi1(map.phi2(dd));
} while(dd!=d);
} while(dd != d);
d = map.phi1(d);
// CGoGNout << " done" << CGoGNendl;
}
//Embed the last vertex
// CGoGNout << "\t embedding number : " << pt[3] << CGoGNendl;
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;
do {
femb(dd);
// CGoGNout << "embed" << CGoGNendl;
//vecDartPtrEmb[pt[3]].push_back(dd);
do
{
m.mark(dd) ;
vecDartsPerVertex[pt[3]].push_back(dd);
dd = map.phi1(map.phi2(dd));
} while(dd != d);
// CGoGNout << "end tetra" << CGoGNendl;
}
// CGoGNout << "end 1/2" << CGoGNendl;
foff.close();
fele.close();
//Association des phi3
unsigned int nbBoundaryFaces = 0 ;
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
std::vector<Dart>& vec = vecDartsPerVertex[d];
for(typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end(); ++it)
{
if(map.phi3(*it)==*it)
if (m.isMarked(d))
{
bool sewn=false;
for(typename std::vector<Dart>::iterator itnext = it+1; itnext != vec.end() && !sewn; ++itnext)
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)
{
if(map.getDartEmbedding(VERTEX,map.phi1(*it))==map.getDartEmbedding(VERTEX,map.phi_1(*itnext))
&& map.getDartEmbedding(VERTEX,map.phi_1(*it))==map.getDartEmbedding(VERTEX,map.phi1(*itnext)))
if(map.getEmbedding(VERTEX, map.phi1(*it)) == map.getEmbedding(VERTEX, d) &&
map.getEmbedding(VERTEX, map.phi_1(*it)) == map.getEmbedding(VERTEX, map.phi_1(d)) /*&&
map.getEmbedding(VERTEX, *it) == map.getEmbedding(VERTEX, map.phi1(d)) */)
{
map.sewVolumes(*it,map.phi_1(*itnext));
sewn = true;
good_dart = *it ;
}
}
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;
}
......
......@@ -37,15 +37,18 @@ namespace Tetrahedralization
template <typename PFP>
void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d)
{
Dart d1 = d;
Dart d2 = map.phi1(map.phi1(d));
Dart d3 = map.phi_1(map.phi2(d));
Dart d4 = map.phi1(map.phi1(map.phi2(map.phi_1(d3))));
cut3Ear<PFP>(map,d1);
cut3Ear<PFP>(map,d2);
cut3Ear<PFP>(map,d3);
cut3Ear<PFP>(map,d4);
//Splitting Path
std::vector<Dart> sp;
sp.reserve(32);
Traversor3VE<typename PFP::MAP> tra(map, d);
for (Dart d = tra.begin() ; d != tra.end() ; d = tra.next())
{
map.splitFace(map.phi1(d), map.phi_1(d));
sp.push_back(map.phi1(d));
}
map.splitVolume(sp);
}
/************************************************************************************************
......
......@@ -274,6 +274,11 @@ public:
*/
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
/*! Test if phi3 and phi2 ares involutions and if phi1 is a permutation
*/
......
......@@ -24,7 +24,7 @@ void main(void)
float lambertTerm = dot(N,L);
int i;
vec averageColor(0.,0.,0.);
vec3 averageColor=vec3(0.,0.,0.);
for(i=0; i< NBVERTS_IN; i++)
{
averageColor +=colorVertex[i];
......
// ShaderFlatColorPerFace::vertexShaderText
ATTRIBUTE vec3 VertexPosition;
ATTRIBUTE vec3 VertexColor;
VARYING_VERT vec3 colorVertex;
......
......@@ -446,7 +446,7 @@ unsigned int ImplicitHierarchicalMap3::volumeLevel(Dart d)
if(!mark.isMarked(ee)) // not already marked
{
visitedFaces.push_back(ee) ;
mark.markOrbit(ORIENTED_FACE, ee) ;
mark.markOrbit(FACE, ee) ;
}
e = phi1(e) ;
} while(e != visitedFaces[i]) ;
......@@ -512,7 +512,7 @@ Dart ImplicitHierarchicalMap3::volumeOldestDart(Dart d)
// For every face added to the list
//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)
{
......@@ -529,7 +529,7 @@ Dart ImplicitHierarchicalMap3::volumeOldestDart(Dart d)
if(!mark.isMarked(ee)) // not already marked
{
visitedFaces.push_back(ee) ;
mark.markOrbit(ORIENTED_FACE, ee) ;
mark.markOrbit(FACE, ee) ;
}
e = phi1(e) ;
} while(e != visitedFaces[i]) ;
......@@ -607,7 +607,7 @@ bool ImplicitHierarchicalMap3::volumeIsSubdivided(Dart d)
if(!mark.isMarked(ee)) // not already marked
{
visitedFaces.push_back(ee) ;
mark.markOrbit(ORIENTED_FACE, ee) ;
mark.markOrbit(FACE, ee) ;
}
e = phi1(e) ;
} while(e != visitedFaces[i]) ;
......@@ -781,7 +781,7 @@ bool ImplicitHierarchicalMap3::neighborhoodLevelDiffersByOne(Dart d)
if(!mf.isMarked(ee)) // not already marked
{
visitedFaces.push_back(ee) ;
mf.markOrbit(ORIENTED_FACE, ee) ;
mf.markOrbit(FACE, ee) ;
}
e = phi1(e) ;
......
......@@ -64,7 +64,8 @@ Dart EmbeddedMap3::cutEdge(Dart d)
copyDartEmbedding(FACE2, f1, f);
Dart e = phi3(f1);
// copyDartEmbedding(ORIENTED_FACE, phi1(e), e);
copyDartEmbedding(FACE2, f1, f);
// copyDartEmbedding(FACE2, f1, f);
copyDartEmbedding(FACE2, phi1(e), e);
f = alpha2(f);
} while(f != d);
}
......
......@@ -657,6 +657,15 @@ Dart Map3::findBoundaryFaceOfEdge(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
std::vector<Dart> visitedFaces ;
......@@ -684,6 +693,44 @@ bool Map3::isBoundaryVolume(Dart d)
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()
{
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