Commit c34c0578 authored by Thomas's avatar Thomas

using traversor for exportPov, correction of volumic function (slicing and subdivision)

parent 16ac2bb6
......@@ -3,7 +3,7 @@ installer les paquets suivants:
cmake libXi-dev libXmu-dev libglew-dev libxml2-dev libboost-all-dev zlib1g-dev qt4-designer qt4-dev-tools uuid-dev
Pour compiler CGoGN:
- aller dans ThirdParty, cd build, taper "cmake ..", puis make ( avec -j x si vous avez x core sur votre machine)
- aller dans ThirdParty, cd build, taper "cmake .", puis make ( avec -j x si vous avez x core sur votre machine)
On peut fixer certaines option pour ne pas tout compiler (cf le README.TXT dans ThirdParty)
On peut aussi compiler en debug en créant un répertoir qui fini par Debug à la place de build
......
......@@ -39,33 +39,26 @@ void exportMeshPlain(std::ofstream& out, typename PFP::MAP& map, typename PFP::T
{
out << "#declare " << meshName << "= union {" << std::endl;
DartMarkerStore traite(map);
TraversorF<typename PFP::MAP > travF(map);
for(Dart d = map.begin() ; d!= map.end() ; map.next(d))
for(Dart d = travF.begin() ; d!= travF.end() ; travF.next(d))
{
if(good(d) && !traite.isMarked(d))
if(good(d))
{
unsigned int nb = 0;
Dart dd = d;
do
{
traite.mark(dd);
dd = map.phi1(dd);
nb++;
} while(dd != d);
unsigned int nb = map.faceDegree(d);
if(nb == 3)
Algo::ExportPov::exportTrianglePlain<PFP>(out,position[dd],position[map.phi1(dd)],position[map.phi1(map.phi1(dd))]);
Algo::ExportPov::exportTrianglePlain<PFP>(out,position[d],position[map.phi1(d)],position[map.phi1(map.phi1(d))]);
else
{
out << "polygon{ " << nb+1 << std::endl;
dd = d;
Dart dd = d;
do
{
out << "<" << position[dd][0] << "," << position[dd][2] << "," << position[dd][1] << ">," << std::endl;
out << "<" << position[dd][0] << "," << position[dd][1] << "," << position[dd][2] << ">," << std::endl;
dd = map.phi1(dd);
} while(dd!=d);
out << "<" << position[d][0] << "," << position[d][2] << "," << position[d][1] << ">" << std::endl;
out << "<" << position[d][0] << "," << position[d][1] << "," << position[d][2] << ">" << std::endl;
out << "}" << std::endl;
}
}
......
......@@ -67,7 +67,17 @@ Dart sliceConvexVolume(typename PFP::MAP& map, typename PFP::TVEC3& position, Da
template <typename PFP>
Dart sliceConvexVolume(typename PFP::MAP& map, typename PFP::TVEC3& position, Dart d, CellMarker& edgesToCut, CellMarker& verticesToSplit);
/**
* Cut a set of volumes considering a set of marked edges and vertices
* marked edges and vertices must form a simple path
* @param d dart of the volume
* @param edgesToCut marker to identify edges along the slice
* @param verticesToSplit marker to identify edges on the slice
* @return a dart from the created face
* TODO (optimization) change to build path while splitting faces
*/
template <typename PFP>
std::vector<Dart> sliceConvexVolumes(typename PFP::MAP& map, typename PFP::TVEC3& position,CellMarker& volumesToCut, CellMarker& edgesToCut, CellMarker& verticesToSplit);
/**
* catmull clark volumic : do not move the original vertices
......
......@@ -311,7 +311,7 @@ std::vector<Dart> sliceConvexVolumes(typename PFP::MAP& map, typename PFP::TVEC3
std::vector<Dart> vRes;
typedef typename PFP::VEC3 VEC3;
CellMarkerStore localVerticesToSplit(map, VERTEX); //marker for new vertices from edge cut
CellMarker localVerticesToSplit(map, VERTEX); //marker for new vertices from edge cut
//Step 1: Cut the edges and mark the resulting vertices as vertices to be face-split
TraversorE<typename PFP::MAP> te(map);
......@@ -368,10 +368,9 @@ std::vector<Dart> sliceConvexVolumes(typename PFP::MAP& map, typename PFP::TVEC3
TraversorW<typename PFP::MAP> tw(map);
for(Dart d = tw.begin(); d != tw.end(); d=tw.next()) //Parcours des volumes
{
if(volumesToCut.isMarked(d)){
if(volumesToCut.isMarked(d))
{
Traversor3WV<typename PFP::MAP> t3wv(map,d);
int nbVInPath=1;
Dart dPath;
bool found=false;
......@@ -380,36 +379,37 @@ std::vector<Dart> sliceConvexVolumes(typename PFP::MAP& map, typename PFP::TVEC3
{
if(localVerticesToSplit.isMarked(dd) || verticesToSplit.isMarked(dd))
{
Dart ddd = map.phi1(map.phi2(dd));
Dart ddd = dd;
while(!localVerticesToSplit.isMarked(map.phi1(ddd))
&& !verticesToSplit.isMarked(map.phi1(ddd))
&& ddd!=dd)
&& !verticesToSplit.isMarked(map.phi1(ddd)))
ddd = map.phi1(map.phi2(ddd));
found=true;
nbVInPath++;
dPath=ddd;
}
}
//define the path to split
std::vector<Dart> vPath;
vPath.reserve(nbVInPath);
vPath.reserve(32);
vPath.push_back(dPath);
CellMarker cmf(map,FACE);
//define the path to split for the whole volume
for(std::vector<Dart>::iterator it = vPath.begin() ;it != vPath.end(); ++it)
bool pathFound=false;
for(std::vector<Dart>::iterator it = vPath.begin() ; !pathFound && it != vPath.end(); ++it)
{
Dart dd = map.phi1(*it);
Dart ddd = map.phi1(map.phi2(dd));
while(!localVerticesToSplit.isMarked(map.phi1(ddd))
&& !verticesToSplit.isMarked(map.phi1(ddd))
&& ddd!=dd)
ddd = map.phi1(map.phi2(ddd));
if( !map.sameVertex(ddd,*vPath.begin()) )
if(map.sameVertex(dd,*vPath.begin()))
pathFound=true;
else
{
vPath.push_back(map.phi1(ddd));
localVerticesToSplit.unmark(map.phi1(ddd));
Dart ddd = map.phi1(map.phi2(dd));
while(!localVerticesToSplit.isMarked(map.phi1(ddd)) && !verticesToSplit.isMarked(map.phi1(ddd)))
ddd = map.phi1(map.phi2(ddd));
vPath.push_back(ddd);
}
}
......
......@@ -54,40 +54,41 @@ void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d)
template <typename PFP>
void hexahedronsToTetrahedrons(typename PFP::MAP& map)
{
TraversorV<typename PFP::MAP> tv(map);
for(Dart s=tv.begin() ; s!=tv.end() ; s=tv.next() )
{
bool allDegreesAroundEqual3=true;
std::vector<Dart> dov;
FunctorStore fs(dov);
map.foreach_dart_of_vertex(s,fs);
CellMarkerStore cmv(map,VOLUME);
for(std::vector<Dart>::iterator it=dov.begin();allDegreesAroundEqual3 && it!=dov.end();++it)
{
if(!cmv.isMarked(*it) && !map.isBoundaryMarked(*it))
{
cmv.mark(*it);
allDegreesAroundEqual3 = (map.phi1(map.phi2(map.phi1(map.phi2(map.phi1(map.phi2(*it))))))==*it);
}
}
if( allDegreesAroundEqual3)
{
CellMarkerStore cmv(map,VOLUME);
for(std::vector<Dart>::iterator it=dov.begin();it!=dov.end();++it)
{
if(!cmv.isMarked(*it) && !map.isBoundaryMarked(*it))
{
cmv.mark(*it);
cut3Ear<PFP>(map,*it);
}
}
}
}
TraversorV<typename PFP::MAP> tv(map);
//for each vertex
for(Dart d = tv.begin() ; d != tv.end() ; d = tv.next())
{
bool vertToTet=true;
std::vector<Dart> dov;
dov.reserve(32);
FunctorStore fs(dov);
map.foreach_dart_of_vertex(d,fs);
CellMarkerStore cmv(map,VOLUME);
//check if all vertices degree is equal to 3 (= no direct adjacent vertex has been split)
for(std::vector<Dart>::iterator it=dov.begin();vertToTet && it!=dov.end();++it)
{
if(!cmv.isMarked(*it) && !map.isBoundaryMarked(*it))
{
cmv.mark(*it);
vertToTet = (map.phi1(map.phi2(map.phi1(map.phi2(map.phi1(map.phi2(*it))))))==*it); //degree = 3
}
}
//if ok : create tetrahedrons around the vertex
if(vertToTet)
{
for(std::vector<Dart>::iterator it=dov.begin();it!=dov.end();++it)
{
if(cmv.isMarked(*it) && !map.isBoundaryMarked(*it))
{
cmv.unmark(*it);
cut3Ear<PFP>(map,*it);
}
}
}
}
}
......
......@@ -782,6 +782,7 @@ bool GMap2::checkSimpleOrientedPath(std::vector<Dart>& vd)
{
if(dm.isMarked(*it))
return false ;
dm.markOrbit(VERTEX, *it) ;
std::vector<Dart>::iterator prev ;
......
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