diff --git a/include/Algo/MC/marchingcube.hpp b/include/Algo/MC/marchingcube.hpp index cdd37f30ca18ed19f4830f23c0b521ad5fd8b289..96e1f87bcc90768ebfa822f7ab3031af2786f335 100644 --- a/include/Algo/MC/marchingcube.hpp +++ b/include/Algo/MC/marchingcube.hpp @@ -26,6 +26,8 @@ #include "Topology/generic/dartmarker.h" #include +#include "Algo/Modelisation/boundEmb.h" + namespace CGoGN { @@ -117,7 +119,9 @@ void MarchingCube::deleteMesh() template< typename DataType, template < typename D2 > class Windowing, typename PFP > Dart MarchingCube::createTriEmb(unsigned int e1, unsigned int e2, unsigned int e3) { - L_DART d = m_map->newFace(3,false); +// L_DART d = m_map->newFace(3,false); + + L_DART d = Modelisation::newFaceEmb(*m_map,3); FunctorSetEmb fsetemb(*m_map, e1); m_map->template foreach_dart_of_orbit(d, fsetemb); @@ -922,7 +926,9 @@ void MarchingCube::setNeighbourSimple(L_DART d1, L_DAR { if (m_map->phi2(d1) != d2) { - m_map->sewFaces(d1,d2,false); +// m_map->sewFaces(d1,d2,false); + Modelisation::sewFaceEmb(*m_map,d1,d2); + #ifdef MC_WIDTH_EDGE_Z_EMBEDED if (m_zslice!=NULL) { @@ -939,7 +945,9 @@ void MarchingCube::setNeighbour(L_DART d1, L_DART d2) { if (m_map->phi2(d1) != d2) { - m_map->sewFaces(d1,d2,false); +// m_map->sewFaces(d1,d2,false); + Modelisation::sewFaceEmb(*m_map,d1,d2); + #ifdef MC_WIDTH_EDGE_Z_EMBEDED if (m_zslice!=NULL) { diff --git a/include/Algo/Modelisation/boundEmb.h b/include/Algo/Modelisation/boundEmb.h new file mode 100644 index 0000000000000000000000000000000000000000..2cbc020728024d3b5a25249f50f620bb1b099535 --- /dev/null +++ b/include/Algo/Modelisation/boundEmb.h @@ -0,0 +1,57 @@ +/******************************************************************************* +* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps * +* version 0.1 * +* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg * +* * +* This library is free software; you can redistribute it and/or modify it * +* under the terms of the GNU Lesser General Public License as published by the * +* Free Software Foundation; either version 2.1 of the License, or (at your * +* option) any later version. * +* * +* This library is distributed in the hope that it will be useful, but WITHOUT * +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License * +* for more details. * +* * +* You should have received a copy of the GNU Lesser General Public License * +* along with this library; if not, write to the Free Software Foundation, * +* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * +* * +* Web site: http://cgogn.unistra.fr/ * +* Contact information: cgogn@unistra.fr * +* * +*******************************************************************************/ +#ifndef _BOUND_EMBD_H +#define _BOUND_EMBD_H + +namespace CGoGN +{ + +namespace Algo +{ + +namespace Modelisation +{ + +template +void sewFaceEmb(typename PFP::MAP& map, Dart d, Dart e) +{ + map.sewFaces(d, e, false) ; + if (map.template isOrbitEmbedded()) + map.template initOrbitEmbeddingNewCell(d) ; +} + +template +Dart newFaceEmb(typename PFP::MAP& map, unsigned int n) +{ + Dart d = map.newFace(n,false); + if (map.template isOrbitEmbedded()) + map.template initOrbitEmbeddingNewCell(d) ; + return d; +} + +} +} +} + +#endif diff --git a/include/Algo/Modelisation/polyhedron.h b/include/Algo/Modelisation/polyhedron.h index 20e3c2f74b2046d7a7707b8cbea92e99c84611ae..10a671bf2dc37e7c92dc75e9494753578ec73518 100644 --- a/include/Algo/Modelisation/polyhedron.h +++ b/include/Algo/Modelisation/polyhedron.h @@ -44,6 +44,12 @@ namespace Modelisation enum { NONE, GRID, CUBE, CYLINDER, CONE, SPHERE, TORE, COMPOSED }; +//template +//void sewFaceEmb(typename PFP::MAP& map, Dart d, Dart e); +// +//template +//Dart newFaceEmb(typename PFP::MAP& map, unsigned int n); + /** * sudivide the all quads of a CC into 2 triangles */ diff --git a/include/Algo/Modelisation/polyhedron.hpp b/include/Algo/Modelisation/polyhedron.hpp index 4a83ca23810382afcb24141c56b040546b0b236b..a4d34549aa0ba9f0dbf6cfc16df8a5549040f96a 100644 --- a/include/Algo/Modelisation/polyhedron.hpp +++ b/include/Algo/Modelisation/polyhedron.hpp @@ -21,6 +21,7 @@ * Contact information: cgogn@unistra.fr * * * *******************************************************************************/ +#include "Algo/Modelisation/boundEmb.h" namespace CGoGN { @@ -44,7 +45,7 @@ Dart createPyramid(typename PFP::MAP& map, unsigned int n) // creation of triangles around circunference and storing vertices for (unsigned int i = 0; i < n; ++i) { - Dart d = map.newFace(3, false); + Dart d = newFaceEmb(map, 3); m_tableVertDarts.push_back(d); } @@ -55,17 +56,17 @@ Dart createPyramid(typename PFP::MAP& map, unsigned int n) d = map.phi_1(d); Dart e = m_tableVertDarts[i+1]; e = map.phi1(e); - map.sewFaces(d, e, false); + sewFaceEmb(map, d, e); } //sewing the last with the first - map.sewFaces(map.phi1(m_tableVertDarts[0]), map.phi_1(m_tableVertDarts[n-1]), false); + sewFaceEmb(map, map.phi1(m_tableVertDarts[0]), map.phi_1(m_tableVertDarts[n-1])); //sewing the bottom face - Dart d1 = map.newFace(n, false); + Dart d1 = newFaceEmb(map, n); dres = d1; for(unsigned int i = 0; i < n ; ++i) { - map.sewFaces(m_tableVertDarts[i], d1, false); + sewFaceEmb(map, m_tableVertDarts[i], d1); d1 = map.phi1(d1); } @@ -87,7 +88,7 @@ Dart createPrism(typename PFP::MAP& map, unsigned int n) // creation of quads around circunference and storing vertices for (unsigned int i = 0; i < n; ++i) { - Dart d = map.newFace(4, false); + Dart d = newFaceEmb(map, 4); m_tableVertDarts.push_back(d); } @@ -104,19 +105,19 @@ Dart createPrism(typename PFP::MAP& map, unsigned int n) d = map.phi_1(d); Dart e = m_tableVertDarts[i+1]; e = map.phi1(e); - map.sewFaces(d, e, false); + sewFaceEmb(map, d, e); } //sewing the last with the first - map.sewFaces(map.phi1(m_tableVertDarts[0]), map.phi_1(m_tableVertDarts[n-1]), false); + sewFaceEmb(map, map.phi1(m_tableVertDarts[0]), map.phi_1(m_tableVertDarts[n-1])); //sewing the top & bottom faces - Dart d1 = map.newFace(n, false); - Dart d2 = map.newFace(n, false); + Dart d1 = newFaceEmb(map, n); + Dart d2 = newFaceEmb(map, n); dres = d1; for(unsigned int i = 0; i < n ; ++i) { - map.sewFaces(m_tableVertDarts[i], d1, false); - map.sewFaces(m_tableVertDarts[n+i], d2, false); + sewFaceEmb(map, m_tableVertDarts[i], d1); + sewFaceEmb(map, m_tableVertDarts[n+i], d2); d1 = map.phi1(d1); d2 = map.phi_1(d2); } @@ -343,7 +344,7 @@ Dart Polyhedron::grid_topo(unsigned int x, unsigned int y) { for (unsigned int j = 1; j <= x; ++j) { - Dart d = m_map.newFace(4, false); + Dart d = newFaceEmb(m_map, 4); m_tableVertDarts.push_back(d); if (j == x) m_tableVertDarts.push_back(m_map.phi1(d)); @@ -368,7 +369,7 @@ Dart Polyhedron::grid_topo(unsigned int x, unsigned int y) Dart d = m_tableVertDarts[pos]; Dart e = m_tableVertDarts[pos-(x+1)]; e = m_map.phi1(m_map.phi1(e)); - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } if (j > 0) // sew with preceeding column { @@ -377,7 +378,7 @@ Dart Polyhedron::grid_topo(unsigned int x, unsigned int y) d = m_map.phi_1(d); Dart e = m_tableVertDarts[pos-1]; e = m_map.phi1(e); - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } } } @@ -414,7 +415,7 @@ Dart Polyhedron::cylinder_topo(unsigned int n, unsigned int z, bool top_clo { for (unsigned int j = 0; j < n; ++j) { - Dart d = m_map.newFace(4, false); + Dart d = newFaceEmb(m_map, 4); m_tableVertDarts.push_back(d); } } @@ -434,7 +435,7 @@ Dart Polyhedron::cylinder_topo(unsigned int n, unsigned int z, bool top_clo Dart d = m_tableVertDarts[pos]; Dart e = m_tableVertDarts[pos-n]; e = m_map.phi1(m_map.phi1(e)); - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } if (j > 0) // sew with preceeding column { @@ -443,7 +444,7 @@ Dart Polyhedron::cylinder_topo(unsigned int n, unsigned int z, bool top_clo d = m_map.phi_1(d); Dart e = m_tableVertDarts[pos-1]; e = m_map.phi1(e); - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } else { @@ -452,7 +453,7 @@ Dart Polyhedron::cylinder_topo(unsigned int n, unsigned int z, bool top_clo d = m_map.phi_1(d); Dart e = m_tableVertDarts[pos+(n-1)]; e = m_map.phi1(e); - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } } } @@ -515,14 +516,14 @@ Dart Polyhedron::cylinder_topo(unsigned int n, unsigned int z, bool top_clo // // close bottom with one quad not three triangles // if (bottom_closed) // { -// Dart t= m_map.newFace(4,false); -// m_map.sewFaces(m_tableVertDarts[0],t); +// Dart t= newFaceEmb(m_map, 4); +// sewFaceEmb(m_map, m_tableVertDarts[0],t); // t=m_map.phi_1(t); -// m_map.sewFaces(m_tableVertDarts[1],t); +// sewFaceEmb(m_map, m_tableVertDarts[1],t); // t=m_map.phi_1(t); -// m_map.sewFaces(m_tableVertDarts[2],t); +// sewFaceEmb(m_map, m_tableVertDarts[2],t); // t=m_map.phi_1(t); -// m_map.sewFaces(m_tableVertDarts[3],t); +// sewFaceEmb(m_map, m_tableVertDarts[3],t); // } // return d; // } @@ -534,12 +535,12 @@ Dart Polyhedron::cylinder_topo(unsigned int n, unsigned int z, bool top_clo // // close bottom with one triangle not three // if (bottom_closed) // { -// Dart t= m_map.newFace(3,false); -// m_map.sewFaces(d,t); +// Dart t= newFaceEmb(m_map, 3); +// sewFaceEmb(m_map, d,t); // d=nextDV(d); t=m_map.phi_1(t); -// m_map.sewFaces(d,t); +// sewFaceEmb(m_map, d,t); // d=nextDV(d); t=m_map.phi_1(t); -// m_map.sewFaces(d,t); +// sewFaceEmb(m_map, d,t); // } // return d; // } @@ -571,7 +572,7 @@ Dart Polyhedron::cylinder_topo(unsigned int n, unsigned int z, bool top_clo // m_tableVertDarts.push_back(m_map.phi_1(dd)); // for (int i=0;i::cylinder_topo(unsigned int n, unsigned int z, bool top_clo // // if (bottom_closed) // { -// Dart t= m_map.newFace(4,false); -// m_map.sewFaces(m_tableVertDarts[0],t); +// Dart t= newFaceEmb(m_map, 4); +// sewFaceEmb(map, m_tableVertDarts[0],t); // t=m_map.phi_1(t); -// m_map.sewFaces(m_tableVertDarts[1],t); +// sewFaceEmb(map, m_tableVertDarts[1],t); // t=m_map.phi_1(t); -// m_map.sewFaces(m_tableVertDarts[2],t); +// sewFaceEmb(map, m_tableVertDarts[2],t); // t=m_map.phi_1(t); -// m_map.sewFaces(m_tableVertDarts[3],t); +// sewFaceEmb(map, m_tableVertDarts[3],t); // } // m_dart=dd; // return dd; @@ -624,12 +625,12 @@ Dart Polyhedron::cylinder_topo(unsigned int n, unsigned int z, bool top_clo // // if (bottom_closed) // { -// Dart t= m_map.newFace(3,false); -// m_map.sewFaces(m_tableVertDarts[0],t); +// Dart t= newFaceEmb(m_map, 3); +// sewFaceEmb(map, m_tableVertDarts[0],t); // t=m_map.phi_1(t); -// m_map.sewFaces(m_tableVertDarts[1],t); +// sewFaceEmb(map, m_tableVertDarts[1],t); // t=m_map.phi_1(t); -// m_map.sewFaces(m_tableVertDarts[2],t); +// sewFaceEmb(map, m_tableVertDarts[2],t); // } // m_dart=dd; // return dd; @@ -662,27 +663,27 @@ Dart Polyhedron::cube_topo(unsigned int x, unsigned int y, unsigned int z) { Dart d = m_map.phi_1(m_tableVertDarts[index_side++]); Dart e = tableTop[i]; - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } for(unsigned int i = 0; i < y; ++i) { Dart d = m_map.phi_1(m_tableVertDarts[index_side++]); Dart e = tableTop[x+i*(x+1)]; - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } for(unsigned int i = 0; i < x; ++i) { Dart d = m_map.phi_1(m_tableVertDarts[index_side++]); Dart e = tableTop[(x+1)*(y+1)-2 - i]; e = m_map.phi_1(e); - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } for(unsigned int i = 0; i < y; ++i) { Dart d = m_map.phi_1(m_tableVertDarts[index_side++]); Dart e = tableTop[(y-1-i)*(x+1)]; e = m_map.phi_1(e); - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } // the bottom @@ -695,27 +696,27 @@ Dart Polyhedron::cube_topo(unsigned int x, unsigned int y, unsigned int z) { Dart d = m_tableVertDarts[(index_side--)%(2*(x+y))]; Dart e = tableBottom[i]; - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } for(unsigned int i = 0; i < y; ++i) { Dart d = m_tableVertDarts[(index_side--)%(2*(x+y))]; Dart e = tableBottom[x+i*(x+1)]; - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } for(unsigned int i = 0; i < x; ++i) { Dart d = m_tableVertDarts[(index_side--)%(2*(x+y))]; Dart e = tableBottom[(x+1)*(y+1)-2 - i]; e = m_map.phi_1(e); - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } for(unsigned int i = 0; i < y; ++i) { Dart d = m_tableVertDarts[(index_side--)%(2*(x+y))]; Dart e = tableBottom[(y-1-i)*(x+1)]; e = m_map.phi_1(e); - m_map.sewFaces(d, e, false); + sewFaceEmb(m_map, d, e); } // and add new vertex in m_tableVertDarts @@ -752,7 +753,7 @@ Dart Polyhedron::tore_topo(unsigned int m, unsigned int n) Dart d = m_tableVertDarts[i]; Dart e = m_tableVertDarts[(m*n)+i]; e = m_map.phi_1(e); - m_map.sewFaces(d, e); + sewFaceEmb(m_map, d, e); } // remove the last n vertex darts that are no more necessary (sewed with n first) @@ -1196,10 +1197,10 @@ void Polyhedron::embedHelicoid(float radius_min, float radius_max, float ma // for(int i=1;i(phi2(d)) ; } } - else - { - if (isOrbitEmbedded()) - { -/* - Traversor2FV t(*this, d); - for(Dart it = t.begin(); it != t.end(); it = t.next()) - initOrbitEmbeddingNewCell(it) ; -*/ - Dart e = d; - do - { - initDartEmbedding(e,newCell()); - e = this->phi1(e); - } while (d!=e); - } - - if(isOrbitEmbedded()) - initOrbitEmbeddingNewCell(d) ; - - } +// else +// { +// if (isOrbitEmbedded()) +// { +///* +// Traversor2FV t(*this, d); +// for(Dart it = t.begin(); it != t.end(); it = t.next()) +// initOrbitEmbeddingNewCell(it) ; +//*/ +// Dart e = d; +// do +// { +// initDartEmbedding(e,newCell()); +// e = this->phi1(e); +// } while (d!=e); +// } +// +// if(isOrbitEmbedded()) +// initOrbitEmbeddingNewCell(d) ; +// +// } return d ; } @@ -316,15 +316,15 @@ void EmbeddedMap2::sewFaces(Dart d, Dart e, bool withBoundary) { Map2::sewFaces(d, e, false) ; - if(isOrbitEmbedded()) - { -/* - initOrbitEmbeddingNewCell(d) ; -*/ - unsigned int emb = newCell(); - initDartEmbedding(d,emb); - initDartEmbedding(e,emb); - } +// if(isOrbitEmbedded()) +// { +///* +// initOrbitEmbeddingNewCell(d) ; +//*/ +// unsigned int emb = newCell(); +// initDartEmbedding(d,emb); +// initDartEmbedding(e,emb); +// } return ; }