Commit 824c4141 authored by untereiner's avatar untereiner

ptit commit

parent ed431beb
......@@ -240,21 +240,23 @@ inline void ImplicitHierarchicalMap3::next(Dart& d)
inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType& f, unsigned int thread)
{
DartMarkerStore mv(*this); // Lock a marker
DartMarkerStore mv(*this,thread); // Lock a marker
bool found = false; // Last functor return value
std::list<Dart> darts_list; //Darts that are traversed
darts_list.push_back(d); //Start with the dart d
std::list<Dart>::iterator darts;
std::vector<Dart> darts_list; //Darts that are traversed
darts_list.reserve(50);
darts_list.push_back(d); //Start with the dart d
mv.mark(d);
for(darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts)
for(std::vector<Dart>::iterator darts = darts_list.begin(); !found && darts != darts_list.end() ; ++darts)
{
Dart dc = *darts;
//add phi21 and phi23 successor if they are not marked yet
Dart d2 = phi2(dc);
if(d2 != dc)
{
Dart d21 = phi1(d2); // turn in volume
Dart d23 = phi3(d2); // change volume
......@@ -269,6 +271,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType
darts_list.push_back(d23);
mv.mark(d23);
}
}
found = f(dc);
}
......
......@@ -85,7 +85,9 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
++degree;
p += position[it] ;
if(!map.edgeIsSubdivided(it)) // first cut the edges (if they are not already)
{
Algo::IHM::subdivideEdge<PFP>(map, it, position) ; // and compute the degree of the face
}
it = map.phi1(it) ;
} while(it != old) ;
p /= typename PFP::REAL(degree) ;
......@@ -94,38 +96,38 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
Dart res;
if(degree == 3 && sType == S_TRI) //subdiviser une face triangulaire
{
Dart dd = map.phi1(old) ;
Dart e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ; // insert a new edge
unsigned int id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ; // set the edge id of the inserted edge to the next available id
unsigned int idface = map.getFaceId(old);
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
dd = e ;
e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ;
id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ;
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
dd = e ;
e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ;
id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ;
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
}
else
{
// if(degree == 3 && sType == S_TRI) //subdiviser une face triangulaire
// {
// Dart dd = map.phi1(old) ;
// Dart e = map.phi1(map.phi1(dd)) ;
// map.splitFace(dd, e) ; // insert a new edge
// unsigned int id = map.getNewEdgeId() ;
// map.setEdgeId(map.phi_1(dd), id, EDGE) ; // set the edge id of the inserted edge to the next available id
//
// unsigned int idface = map.getFaceId(old);
// map.setFaceId(dd, idface, FACE) ;
// map.setFaceId(e, idface, FACE) ;
//
// dd = e ;
// e = map.phi1(map.phi1(dd)) ;
// map.splitFace(dd, e) ;
// id = map.getNewEdgeId() ;
// map.setEdgeId(map.phi_1(dd), id, EDGE) ;
//
// map.setFaceId(dd, idface, FACE) ;
// map.setFaceId(e, idface, FACE) ;
//
// dd = e ;
// e = map.phi1(map.phi1(dd)) ;
// map.splitFace(dd, e) ;
// id = map.getNewEdgeId() ;
// map.setEdgeId(map.phi_1(dd), id, EDGE) ;
//
// map.setFaceId(dd, idface, FACE) ;
// map.setFaceId(e, idface, FACE) ;
// }
// else
// {
Dart dd = map.phi1(old) ;
map.splitFace(dd, map.phi1(map.phi1(dd))) ;
......@@ -162,7 +164,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
dd = map.phi2(map.phi1(dd));
}
while(dd != ne);
}
// }
map.setCurrentLevel(cur) ;
}
......@@ -179,6 +181,9 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
unsigned int cur = map.getCurrentLevel();
map.setCurrentLevel(vLevel);
std::cout << "vLevel = " << vLevel << std::endl;
/*
* au niveau du volume courant i
* stockage d'un brin de chaque face de celui-ci
......@@ -186,7 +191,8 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
*/
DartMarkerStore mf(map); // Lock a face marker to save one dart per face
DartMarkerStore mv(map); // Lock a vertex marker to compute volume center
//DartMarkerStore mv(map); // Lock a vertex marker to compute volume center
CellMarker mv(map, VERTEX);
typename PFP::VEC3 volCenter;
unsigned count = 0 ;
......@@ -211,9 +217,10 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
//compute volume centroid
if(!mv.isMarked(e))
{
//mv.markOrbit(VERTEX, e);
mv.mark(e);
volCenter += position[e];
++count;
mv.markOrbit(VERTEX, e);
oldEdges.push_back(e);
}
......@@ -239,6 +246,7 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
std::vector<std::pair<Dart,Dart> > subdividedfaces;
subdividedfaces.reserve(25);
int i = 0;
//First step : subdivide edges and faces
//creates a i+1 edge level and i+1 face level
for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
......@@ -247,12 +255,24 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
//if needed subdivide face
if(!map.faceIsSubdivided(d))
{
++i;
Algo::IHM::subdivideFace<PFP>(map, d, position);
}
std::cout << "CHECK FACES " << std::endl;
map.check();
//save a dart from the subdivided face
unsigned int cur = map.getCurrentLevel() ;
unsigned int fLevel = map.faceLevel(d) + 1; //puisque dans tous les cas, la face est subdivisee
map.setCurrentLevel(map.getMaxLevel());
Dart old = map.faceOldestDart(d);
std::cout << " Oldest dart Face = " << old << std::endl;
unsigned int fLevel = map.faceLevel(old); //puisque dans tous les cas, la face est subdivisee
std::cout << "FACE LEVEL = " << fLevel << std::endl;
map.setCurrentLevel(fLevel) ;
......@@ -268,6 +288,8 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
map.setCurrentLevel(cur);
}
map.setCurrentLevel(vLevel + 1) ; // go to the next level to perform volume subdivision
std::vector<Dart> newEdges; //save darts from inner edges
......@@ -279,21 +301,33 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
Dart e = *edge;
Dart f1 = map.phi1(*edge);
int i = 0;
do
{
std::cout << "corner #" << i << " degree = " << map.faceDegree(e) << std::endl;
if(map.phi2(map.phi1(map.phi1(e))) != map.phi1(map.phi1(e)))
map.unsewFaces(map.phi1(map.phi1(e)));
//TODO utile ?
//if(map.phi2(map.phi1(e)) != map.phi1(e))
if(map.phi2(map.phi1(e)) != map.phi1(e))
map.unsewFaces(map.phi1(e));
++i;
e = map.phi2(map.phi_1(e));
}
while(e != *edge);
map.closeHole(f1);
std::cout << "CHECK CLOSE HOLE " << std::endl;
map.check();
std::cout << "corner degree = " << i << std::endl;
std::cout << "face degree = " << map.faceDegree(map.phi2(f1)) << std::endl;
// if(map.faceDegree(map.phi2(f1)) > 6)
// return Dart::nil();
Dart old = map.phi2(map.phi1(e));
Dart dd = map.phi1(map.phi1(old)) ;
map.splitFace(old,dd) ;
......@@ -361,6 +395,8 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
map.setCurrentLevel(cur) ;
std::cout << std::endl;
return subdividedfaces.begin()->first;
}
......
......@@ -2,6 +2,7 @@
#include "Geometry/bounding_box.h"
#include "Geometry/plane_3d.h"
#include "Algo/BooleanOperator/mergeVertices.h"
#include "Container/fakeAttribute.h"
#include <limits>
namespace CGoGN
......@@ -124,7 +125,7 @@ void getPolygonFromSVG(std::string allcoords, std::vector<VEC3>& curPoly, bool&
valueOf(yS,y);
typename PFP::VEC3 previous = (curPoly)[(curPoly).size()-1];
VEC3 previous = (curPoly)[(curPoly).size()-1];
x = previous[0];
push_point=true;
......
......@@ -122,26 +122,15 @@ void Sqrt3Subdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, con
/*
* TODO quadrangule volume
* volume subdivision scheme
*/
/**
* Quadrangule all the faces of the mesh
*/
template <typename PFP, typename EMBV, typename EMB>
void quadranguleFacesVolume(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected = SelectorTrue()) ;
template <typename PFP, typename EMBV, typename EMB>
void hexaCutVolume(typename PFP::MAP& map, Dart d, EMBV& attributs);
template <typename PFP, typename EMBV, typename EMB>
void dooSabinVolume(typename PFP::MAP& map, Dart d, EMBV& attributs);
/*
* Quadrangule a Volume
*/
template <typename PFP, typename EMBV, typename EMB>
void quadranguleVolumes(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected = SelectorTrue());
template <typename PFP>
void splitVolumes(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
// TODO a mettre ailleurs ?
......
......@@ -642,11 +642,6 @@ void Sqrt3Subdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, con
}
}
template <typename PFP, typename EMBV, typename EMB>
void quadranguleFacesVolume(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected)
{
}
template <typename PFP, typename EMBV, typename EMB>
void hexaCutVolume(typename PFP::MAP& map, Dart d, EMBV& attributs)
......@@ -826,83 +821,78 @@ void hexaCutVolume(typename PFP::MAP& map, Dart d, EMBV& attributs)
// }
}
template <typename PFP, typename EMBV, typename EMB>
void dooSabinVolume(typename PFP::MAP& map, Dart d, EMBV& attributs)
{
DartMarker mf(map) ; //mark face
DartMarker me(map) ; //mark edge
DartMarkerStore mark(map); // Lock a marker
//Store faces that are traversed and start with the face of d
std::vector<Dart> visitedFaces;
visitedFaces.reserve(100);
visitedFaces.push_back(d);
std::vector<Dart>::iterator face;
//Store a dart from a each face
std::vector<Dart> faces;
faces.reserve(100);
// First pass : for every face added to the list save a dart
for (face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
template <typename PFP>
void splitVolumes(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
//Cut the edges
DartMarker me(map, EDGE);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if (!mark.isMarked(*face)) // Face has not been visited yet
if(!me.isMarked(d))
{
// Cut the edge
Dart dd = map.phi2(d) ;
typename PFP::VEC3 p1 = position[d] ;
typename PFP::VEC3 p2 = position[map.phi1(d)] ;
map.cutEdge(d) ;
faces.push_back(*face);
position[map.phi1(d)] = (p1 + p2) * typename PFP::REAL(0.5) ;
Dart dNext = *face ;
do
{
mark.mark(dNext); // Mark
Dart adj = map.phi2(dNext); // Get adjacent face
if (adj != dNext && !mark.isMarked(adj))
visitedFaces.push_back(adj); // Add it
dNext = map.phi1(dNext);
} while(dNext != *face);
me.markOrbit(EDGE, d);
me.markOrbit(EDGE, map.phi1(d));
}
}
// Second pass : for every edges insert a face
for(face = faces.begin() ; face != faces.end() ; ++face)
{
Dart e = *face;
do
DartMarker mf(map, FACE);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!me.isMarked(e))
if(!mf.isMarked(d))
{
//insertion d'une face dans l'arete
Dart e2 = map.phi2(e);
map.unsewFaces(e);
Dart ne = map.newOrientedFace(4);
map.sewFaces(e,ne);
map.sewFaces(e2, map.phi1(map.phi1(ne)));
//marquage de l'orbite arete
me.markOrbit(EDGE,e);
mf.markOrbit(FACE, d);
}
e = map.phi1(e);
}while (e != *face);
}
// Dart f = map.phi1(d);
// map.cutEdge(d);
// Dart e = map.phi1(d);
// attributs[e] = attributs[d];
// attributs[e] += attributs[f];
// attributs[e] *= 0.5;
// //and split the faces
//
// //Insert the middleFaces
//
// // first cut the edges (if they are not already)
// Dart t = d;
// do
// {
// if(!map.edgeIsSubdivided(map.phi1(map.phi2(t))))
// Algo::IHM::subdivideEdge<PFP>(map, map.phi1(map.phi2(t)), position) ;
// t = map.phi1(t);
// }
// while(t != d);
//
// Dart neighboordVolume = map.phi1(map.phi1(map.phi2(d)));
//
// Dart dPrev = d;
// Dart ePrev = map.phi2(d);
// map.splitFace(dPrev,ePrev);
// //Split the faces and open the midlle
// do
// {
// Dart t2 = map.phi2(t);
//
// attributs[map.phi_1(d)] = attributs[map.phi1(ePrev)];
// Dart face2 = map.phi1(map.phi1(t2));
// map.splitFace(map.phi_1(t2), face2);
// map.unsewFaces(map.phi1(map.phi1(t2)));
//
// t = map.phi1(t);
// }
// while(t != d);
//
//
// map.closeHole(map.phi1(map.phi1(map.phi2(d))));
// map.closeHole(map.phi_1(neighboordVolume));
// map.sewVolumes(map.phi2(map.phi1(map.phi1(map.phi2(d)))), map.phi2(map.phi_1(neighboordVolume)));
}
} // namespace Modelisation
} // namespace Algo
......
......@@ -41,8 +41,8 @@ void EmbeddedMap3<MAP3>::sewVolumes(Dart d, Dart e)
unsigned int vEmb1 = EMBNULL ;
Dart dd = d ;
do {
vEmb1 = MAP3::getEmbedding(VERTEX, d);
MAP3::embedOrbit(VERTEX, d, vEmb1) ;
vEmb1 = MAP3::getEmbedding(VERTEX, dd);
MAP3::embedOrbit(VERTEX, dd, vEmb1) ;
dd = MAP3::phi1(dd) ;
} while(dd != d) ;
}
......@@ -328,9 +328,12 @@ bool EmbeddedMap3<MAP3>::check()
return false ;
}
if(MAP3::phi3(d) != d && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi3(MAP3::phi2(d))))
if(MAP3::phi3(d) != d && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi1(MAP3::phi3(d))))
{
CGoGNout << "Check: different embeddings on vertex in the 2 oriented faces" << CGoGNendl ;
std::cout << "Dart #" << d << std::endl;
std::cout << "Emb(d) = " << MAP3::getEmbedding(VERTEX, d) << std::endl;
std::cout << "Emb(phi32(d)) = " << MAP3::getEmbedding(VERTEX, MAP3::phi3(MAP3::phi2(d))) << std::endl;
return false ;
}
......
......@@ -345,7 +345,7 @@ public:
//@{
// TODO devrait disparaitre
// pour les mêmes raisons que dans map2
bool check();
virtual bool check();
//@}
};
......
......@@ -1148,6 +1148,7 @@ bool Map3::check()
{
CGoGNout << "Check: topology begin" << CGoGNendl;
DartMarker m(*this);
m.unmarkAll();
for(Dart d = this->begin(); d != this->end(); this->next(d))
{
Dart d3 = phi3(d);
......
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