Commit eeb7e0de authored by Pierre Kraemer's avatar Pierre Kraemer

bug closeMap GMap2 + correction cylinder polyhedron

parent 6ed3fb3a
...@@ -37,20 +37,20 @@ SimpleGMap2::SimpleGMap2() ...@@ -37,20 +37,20 @@ SimpleGMap2::SimpleGMap2()
position[myMap.phi_1(d)] = VEC3(10,20,15); position[myMap.phi_1(d)] = VEC3(10,20,15);
position[myMap.phi_1(myMap.phi2(d))] = VEC3(0,0,30); position[myMap.phi_1(myMap.phi2(d))] = VEC3(0,0,30);
VEC3 mid = (position[d]+position[myMap.phi1(d)])/2.0f; VEC3 mid = (position[d] + position[myMap.phi1(d)]) / 2.0f;
myMap.cutEdge(d); myMap.cutEdge(d);
position[myMap.phi1(d)] = mid; position[myMap.phi1(d)] = mid;
Algo::Modelisation::Polyhedron<PFP> poly(myMap,position); Algo::Modelisation::Polyhedron<PFP> poly(myMap, position);
d = poly.cylinder_topo(5,1,false,false); d = poly.cylinder_topo(5, 1, false, false);
poly.embedCylinder(10,10,5); poly.embedCylinder(10, 10, 5);
d = myMap.phi1(d); d = myMap.phi1(d);
Dart dd = myMap.beta2(d); Dart dd = myMap.beta2(d);
myMap.unsewFaces(d); myMap.unsewFaces(d);
myMap.sewFaces(d,dd); myMap.sewFaces(d, dd);
position[d][1] += 3.0f; position[d][1] += 3.0f;
} }
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
SimpleGMap3::SimpleGMap3() SimpleGMap3::SimpleGMap3()
{ {
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position"); position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
normal = myMap.addAttribute<PFP::VEC3>(VERTEX, "position"); normal = myMap.addAttribute<PFP::VEC3>(VERTEX, "normal");
Algo::Modelisation::Primitive3D<PFP> primCat(myMap,position); Algo::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(2,1,1); Dart d = primCat.hexaGrid_topo(2,1,1);
...@@ -43,33 +43,33 @@ SimpleGMap3::SimpleGMap3() ...@@ -43,33 +43,33 @@ SimpleGMap3::SimpleGMap3()
DartMarker markOrient(myMap); DartMarker markOrient(myMap);
std::vector<Dart> orient; std::vector<Dart> orient;
FunctorStore fs(orient); FunctorStore fs(orient);
myMap.foreach_dart_of_oriented_volume(d,fs); myMap.foreach_dart_of_oriented_volume(d, fs);
for(std::vector<Dart>::iterator it = orient.begin() ; it != orient.end() ; ++it) for(std::vector<Dart>::iterator it = orient.begin() ; it != orient.end() ; ++it)
markOrient.mark(*it); markOrient.mark(*it);
SelectorMarked sm(markOrient); SelectorMarked sm(markOrient);
Algo::Modelisation::catmullClarkVol<PFP,PFP::TVEC3,PFP::VEC3>(myMap,position,sm); Algo::Modelisation::catmullClarkVol<PFP,PFP::TVEC3,PFP::VEC3>(myMap, position, sm);
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i)) for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
position[i] += VEC3(2,0,0); position[i] += VEC3(2,0,0);
Algo::Modelisation::Primitive3D<PFP> prim(myMap,position); Algo::Modelisation::Primitive3D<PFP> prim(myMap, position);
d = prim.hexaGrid_topo(2,2,1); d = prim.hexaGrid_topo(2,2,1);
prim.embedHexaGrid(1,1,1); prim.embedHexaGrid(1,1,1);
Dart d1 = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d))))); Dart d1 = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d)))));
VEC3 mid0 = (position[d1]+position[myMap.phi1(d1)])/2.0f; VEC3 mid0 = (position[d1] + position[myMap.phi1(d1)]) / 2.0f;
myMap.cutEdge(d1); myMap.cutEdge(d1);
position[myMap.phi1(d1)] = mid0; position[myMap.phi1(d1)] = mid0;
VEC3 mid1 = (position[d]+position[myMap.phi1(d)])/2.0f; VEC3 mid1 = (position[d] + position[myMap.phi1(d)]) / 2.0f;
myMap.cutEdge(d); myMap.cutEdge(d);
position[myMap.phi1(d)] = mid1; position[myMap.phi1(d)] = mid1;
d = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d))))); d = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d)))));
VEC3 mid = (position[d]+position[myMap.phi1(d)])/2.0f; VEC3 mid = (position[d] + position[myMap.phi1(d)]) / 2.0f;
myMap.cutEdge(d); myMap.cutEdge(d);
position[myMap.phi1(d)] = mid; position[myMap.phi1(d)] = mid;
......
...@@ -415,28 +415,15 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo ...@@ -415,28 +415,15 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo
if (bottom_closed) if (bottom_closed)
{ {
Dart d = m_tableVertDarts[0]; Dart d = m_tableVertDarts[0];
if(m_map.closeHole(d,false)) if(m_map.closeHole(d, false))
{ {
d = m_map.phi2(d); d = m_map.phi2(d);
if(m_map.faceDegree(d) > 3) if(m_map.faceDegree(d) > 3)
{ {
Algo::Modelisation::trianguleFace<PFP>(m_map,d); Algo::Modelisation::trianguleFace<PFP>(m_map, d);
m_tableVertDarts.push_back(m_map.phi_1(d)); m_tableVertDarts.push_back(m_map.phi_1(d));
} }
} }
// // create bottom
// Dart d = triangleFan_topo<PFP>(m_map,n);
// // store center vertex dart
// m_tableVertDarts.push_back(m_map.phi_1(d));
//
// // sew it
// for (int i=0; i<n; ++i)
// {
// Dart e = m_tableVertDarts[i];
// m_map.sewFaces(d,e);
// d = precDV(d);
// }
} }
else else
m_map.closeHole(m_tableVertDarts[0]); m_map.closeHole(m_tableVertDarts[0]);
...@@ -449,24 +436,10 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo ...@@ -449,24 +436,10 @@ Dart Polyhedron<PFP>::cylinder_topo(unsigned int n, unsigned int z, bool top_clo
d = m_map.phi2(d); d = m_map.phi2(d);
if(m_map.faceDegree(d) > 3) if(m_map.faceDegree(d) > 3)
{ {
Algo::Modelisation::trianguleFace<PFP>(m_map,d); Algo::Modelisation::trianguleFace<PFP>(m_map, d);
m_tableVertDarts.push_back(m_map.phi_1(d)); m_tableVertDarts.push_back(m_map.phi_1(d));
} }
} }
// // create bottom
// Dart d = triangleFan_topo<PFP>(m_map,n);
// // store center vertex dart
// m_tableVertDarts.push_back(m_map.phi_1(d));
//
// // sew it
// for (int i=0; i<n; ++i)
// {
// Dart e = m_tableVertDarts[n*z+i];
// e = m_map.phi_1(e);
// m_map.sewFaces(d,e);
// d = nextDV(d);
// }
} }
else else
m_map.closeHole(m_map.phi_1(m_tableVertDarts[n*z])); m_map.closeHole(m_map.phi_1(m_tableVertDarts[n*z]));
......
...@@ -75,7 +75,7 @@ Dart Primitive3D<PFP>::HexaGrid1Topo(unsigned int nx) ...@@ -75,7 +75,7 @@ Dart Primitive3D<PFP>::HexaGrid1Topo(unsigned int nx)
{ {
Dart d2 = createHexa(); Dart d2 = createHexa();
m_tableVertDarts.push_back(d2); m_tableVertDarts.push_back(d2);
m_map.sewVolumes(d1, d2); m_map.sewVolumes(d1, d2, false);
d1 = m_map.template phi<2112>(d2); d1 = m_map.template phi<2112>(d2);
} }
...@@ -102,7 +102,7 @@ Dart Primitive3D<PFP>::HexaGrid2Topo(unsigned int nx, unsigned int ny) ...@@ -102,7 +102,7 @@ Dart Primitive3D<PFP>::HexaGrid2Topo(unsigned int nx, unsigned int ny)
// couture des deux lignes de cubes // couture des deux lignes de cubes
for (unsigned int i = 0; i < nx; ++i) for (unsigned int i = 0; i < nx; ++i)
{ {
m_map.sewVolumes(d1,d3); m_map.sewVolumes(d1, d3, false);
d1 = m_map.template phi<11232>(d1); d1 = m_map.template phi<11232>(d1);
d3 = m_map.template phi<11232>(d3); d3 = m_map.template phi<11232>(d3);
} }
...@@ -116,12 +116,12 @@ Dart Primitive3D<PFP>::HexaGrid2Topo(unsigned int nx, unsigned int ny) ...@@ -116,12 +116,12 @@ Dart Primitive3D<PFP>::HexaGrid2Topo(unsigned int nx, unsigned int ny)
for (unsigned int i = 0; i < nx; ++i) for (unsigned int i = 0; i < nx; ++i)
{ {
Dart dd = m_tableVertDarts[index++]; Dart dd = m_tableVertDarts[index++];
dd =m_map.template phi<112>(dd); dd = m_map.template phi<112>(dd);
m_tableVertDarts.push_back(dd); m_tableVertDarts.push_back(dd);
} }
// warning last vertex of row has not same dart // warning last vertex of row has not same dart
Dart dd = m_tableVertDarts[index++]; Dart dd = m_tableVertDarts[index++];
dd =m_map.template phi<211>(dd); dd = m_map.template phi<211>(dd);
m_tableVertDarts.push_back(dd); m_tableVertDarts.push_back(dd);
return d0; return d0;
...@@ -137,13 +137,13 @@ Dart Primitive3D<PFP>::hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned ...@@ -137,13 +137,13 @@ Dart Primitive3D<PFP>::hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned
m_tableVertDarts.clear(); m_tableVertDarts.clear();
m_tableVertDarts.reserve((nx+1)*(ny+1)*(nz+1)); m_tableVertDarts.reserve((nx+1)*(ny+1)*(nz+1));
Dart d0 = HexaGrid2Topo(nx,ny); Dart d0 = HexaGrid2Topo(nx, ny);
Dart d1 = m_map.template phi<12>(d0); Dart d1 = m_map.template phi<12>(d0);
for (unsigned int i = 1; i < nz; ++i) for (unsigned int i = 1; i < nz; ++i)
{ {
// creation grille suivante // creation grille suivante
Dart d2 = HexaGrid2Topo(nx,ny); Dart d2 = HexaGrid2Topo(nx, ny);
Dart d3 = m_map.phi2(m_map.phi_1(d2)); Dart d3 = m_map.phi2(m_map.phi_1(d2));
// couture des deux grilles 2D de cubes // couture des deux grilles 2D de cubes
...@@ -153,7 +153,7 @@ Dart Primitive3D<PFP>::hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned ...@@ -153,7 +153,7 @@ Dart Primitive3D<PFP>::hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned
Dart db = d3; Dart db = d3;
for (unsigned int k = 0; k < nx; ++k) for (unsigned int k = 0; k < nx; ++k)
{ {
m_map.sewVolumes(da,db); m_map.sewVolumes(da, db, false);
da = m_map.template phi<11232>(da); da = m_map.template phi<11232>(da);
db = m_map.template phi<11232>(db); db = m_map.template phi<11232>(db);
} }
...@@ -176,6 +176,8 @@ Dart Primitive3D<PFP>::hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned ...@@ -176,6 +176,8 @@ Dart Primitive3D<PFP>::hexaGrid_topo(unsigned int nx, unsigned int ny, unsigned
m_tableVertDarts.push_back(dd); m_tableVertDarts.push_back(dd);
} }
m_map.closeMap() ;
return d0; return d0;
} }
......
...@@ -94,8 +94,8 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec ...@@ -94,8 +94,8 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
CellMarkerNoUnmark me(map, EDGE); CellMarkerNoUnmark me(map, EDGE);
CellMarker mf(map, FACE); CellMarker mf(map, FACE);
AutoAttributeHandler< EMB > attBary(map,VOLUME); AutoAttributeHandler< EMB > attBary(map, VOLUME);
CellMarker vol(map,VOLUME); CellMarker vol(map, VOLUME);
//pre-computation : compute the centroid of all volume //pre-computation : compute the centroid of all volume
for (Dart d = map.begin(); d != map.end(); map.next(d)) for (Dart d = map.begin(); d != map.end(); map.next(d))
...@@ -103,7 +103,7 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec ...@@ -103,7 +103,7 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
if(selected(d) && !vol.isMarked(d)) if(selected(d) && !vol.isMarked(d))
{ {
vol.mark(d); vol.mark(d);
attBary[d] = Algo::Geometry::volumeCentroidGen<PFP,EMBV,EMB>(map,d,attributs); attBary[d] = Algo::Geometry::volumeCentroidGen<PFP,EMBV,EMB>(map, d, attributs);
} }
} }
......
...@@ -864,13 +864,14 @@ unsigned int GMap2::closeHole(Dart d, bool forboundary) ...@@ -864,13 +864,14 @@ unsigned int GMap2::closeHole(Dart d, bool forboundary)
beta2sew(d, beta0(first)); // sew the new edge to the hole beta2sew(d, beta0(first)); // sew the new edge to the hole
beta2sew(first, beta0(d)); beta2sew(first, beta0(d));
Dart prev = first ;
Dart dNext = d; // Turn around the hole Dart dNext = d; // Turn around the hole
Dart dPhi1; // to complete the face Dart dPhi1; // to complete the face
do do
{ {
dPhi1 = phi1(dNext) ; dPhi1 = phi1(dNext) ;
dNext = beta2(dPhi1) ; dNext = beta2(dPhi1) ;
while(dNext != dPhi1) while(dNext != dPhi1 && dPhi1 != d)
{ {
dPhi1 = beta1(dNext) ; // Search and put in dNext dPhi1 = beta1(dNext) ; // Search and put in dNext
dNext = beta2(dPhi1) ; // the next dart of the hole dNext = beta2(dPhi1) ; // the next dart of the hole
...@@ -880,14 +881,15 @@ unsigned int GMap2::closeHole(Dart d, bool forboundary) ...@@ -880,14 +881,15 @@ unsigned int GMap2::closeHole(Dart d, bool forboundary)
{ {
Dart next = newEdge(); // Add a new edge there and link it to the face Dart next = newEdge(); // Add a new edge there and link it to the face
++countEdges; ++countEdges;
Dart tmp = phi1(first) ; beta1sew(beta0(next), prev); // the edge is linked to the face
beta1sew(beta0(first), next); // the edge is linked to the face prev = next ;
beta1sew(beta0(next), tmp) ;
beta2sew(dNext, beta0(next)); // the face is linked to the hole beta2sew(dNext, beta0(next)); // the face is linked to the hole
beta2sew(next, beta0(dNext)); beta2sew(next, beta0(dNext));
} }
} while (dPhi1 != d); } while (dPhi1 != d);
beta1sew(prev, beta0(first)) ;
if(forboundary) if(forboundary)
boundaryMarkOrbit(FACE, phi2(d)); boundaryMarkOrbit(FACE, phi2(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