Commit 88a0b0c1 authored by untereiner's avatar untereiner

begin subdiv Primal Regular for simploidal shapes

parent c8834f1d
......@@ -281,7 +281,7 @@ bool importMeshSurfToVol(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts, fl
for(unsigned int k = 0 ; k < nbStage ; ++k)
{
Dart d = Algo::Modelisation::createPrism<PFP>(map, nbe);
Dart d = Algo::Modelisation::createPrism<PFP>(map, nbe,false);
//Embed the base faces
for (unsigned int j = 0; j < nbe; ++j)
......
......@@ -146,7 +146,7 @@ bool importNodeWithELERegions(typename PFP::MAP& map, const std::string& filenam
std::stringstream oss(line);
oss >> nbe;
Dart d = Algo::Modelisation::createTetrahedron<PFP>(map);
Dart d = Algo::Modelisation::createTetrahedron<PFP>(map,false);
Geom::Vec4ui pt;
oss >> pt[0];
--(pt[0]);
......
......@@ -145,7 +145,7 @@ bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filename
std::stringstream oss(line);
oss >> nbe;
Dart d = Algo::Modelisation::createTetrahedron<PFP>(map);
Dart d = Algo::Modelisation::createTetrahedron<PFP>(map,false);
Geom::Vec4ui pt;
oss >> pt[0];
oss >> pt[1];
......
......@@ -113,7 +113,7 @@ bool importTet(typename PFP::MAP& map, const std::string& filename, std::vector<
std::stringstream oss(ligne);
oss >> nbe; //number of vertices = 4 or used for region mark
Dart d = Algo::Modelisation::createTetrahedron<PFP>(map);
Dart d = Algo::Modelisation::createTetrahedron<PFP>(map,false);
Geom::Vec4ui pt;
oss >> pt[0];
......
......@@ -121,7 +121,7 @@ bool importTs(typename PFP::MAP& map, const std::string& filename, std::vector<s
oss >> nbe; //number of vertices = 4
assert(nbe == 4);
Dart d = Algo::Modelisation::createTetrahedron<PFP>(map);
Dart d = Algo::Modelisation::createTetrahedron<PFP>(map,false);
Geom::Vec4ui pt;
oss >> pt[0];
......
......@@ -81,49 +81,49 @@ void explodPolyhedron(typename PFP::MAP& map, Dart d, VertexAttribute<typename P
* create a n-sided pyramid
*/
template <typename PFP>
Dart createPyramid(typename PFP::MAP& map, unsigned int nbSides);
Dart createPyramid(typename PFP::MAP& map, unsigned int nbSides, bool withBoundary = true);
/**
* create a n-sided prism
*/
template <typename PFP>
Dart createPrism(typename PFP::MAP& map, unsigned int nbSides);
Dart createPrism(typename PFP::MAP& map, unsigned int nbSides, bool withBoundary = true);
/**
* create a n-sided diamond
*/
template <typename PFP>
Dart createDiamond(typename PFP::MAP& map, unsigned int nbSides);
Dart createDiamond(typename PFP::MAP& map, unsigned int nbSides, bool withBoundary = true);
/**
* create a tetrahedron
*/
template <typename PFP>
Dart createTetrahedron(typename PFP::MAP& map);
Dart createTetrahedron(typename PFP::MAP& map, bool withBoundary = true);
/**
* create a hexahedron
*/
template <typename PFP>
Dart createHexahedron(typename PFP::MAP& map);
Dart createHexahedron(typename PFP::MAP& map, bool withBoundary = true);
/**
* create a 3-sided prism
*/
template <typename PFP>
Dart createTriangularPrism(typename PFP::MAP& map);
Dart createTriangularPrism(typename PFP::MAP& map, bool withBoundary = true);
/**
* create a 4-sided pyramid
*/
template <typename PFP>
Dart createQuadrangularPyramid(typename PFP::MAP& map);
Dart createQuadrangularPyramid(typename PFP::MAP& map, bool withBoundary = true);
/**
* create 4-sided diamond (i.e. an octahedron)
*/
template <typename PFP>
Dart createOctahedron(typename PFP::MAP& map);
Dart createOctahedron(typename PFP::MAP& map, bool withBoundary = true);
......
......@@ -35,7 +35,7 @@ namespace Modelisation
* create a n-sided pyramid
*/
template <typename PFP>
Dart createPyramid(typename PFP::MAP& map, unsigned int n)
Dart createPyramid(typename PFP::MAP& map, unsigned int n, bool withBoundary)
{
Dart dres = Dart::nil();
std::vector<Dart> m_tableVertDarts;
......@@ -69,42 +69,9 @@ Dart createPyramid(typename PFP::MAP& map, unsigned int n)
base = map.phi1(base);
}
if(map.dimension() == 3)
if(map.dimension() == 3 && withBoundary)
map.closeMap();
if(map.template isOrbitEmbedded<VERTEX>())
{
for(unsigned int i = 0; i < n; ++i)
{
map.template initOrbitEmbeddingNewCell<VERTEX>(m_tableVertDarts[i]);
}
map.template initOrbitEmbeddingNewCell<VERTEX>(map.phi_1(m_tableVertDarts[0]));
}
if(map.template isOrbitEmbedded<EDGE>())
{
for(unsigned int i = 0; i < n; ++i)
{
map.template initOrbitEmbeddingNewCell<EDGE>(m_tableVertDarts[i]);
map.template initOrbitEmbeddingNewCell<EDGE>(map.phi1(m_tableVertDarts[i]));
}
}
if(map.template isOrbitEmbedded<FACE>())
{
for(unsigned int i = 0; i < n; ++i)
{
map.template initOrbitEmbeddingNewCell<FACE>(m_tableVertDarts[i]);
}
map.template initOrbitEmbeddingNewCell<FACE>(dres);
}
if(map.template isOrbitEmbedded<VOLUME>())
{
map.template initOrbitEmbeddingNewCell<VOLUME>(dres);
}
//return a dart from the base
return dres;
}
......@@ -113,7 +80,7 @@ Dart createPyramid(typename PFP::MAP& map, unsigned int n)
* create a n-sided prism
*/
template <typename PFP>
Dart createPrism(typename PFP::MAP& map, unsigned int n)
Dart createPrism(typename PFP::MAP& map, unsigned int n, bool withBoundary)
{
Dart dres = Dart::nil();
unsigned int nb = n*2;
......@@ -157,44 +124,9 @@ Dart createPrism(typename PFP::MAP& map, unsigned int n)
bottom = map.phi_1(bottom);
}
if(map.dimension() == 3)
if(map.dimension() == 3 && withBoundary)
map.closeMap();
if(map.template isOrbitEmbedded<VERTEX>())
{
for(unsigned int i = 0; i < nb; ++i)
{
map.template initOrbitEmbeddingNewCell<VERTEX>(m_tableVertDarts[i]);
}
}
if(map.template isOrbitEmbedded<EDGE>())
{
for(unsigned int i = 0; i < n; ++i)
{
map.template initOrbitEmbeddingNewCell<FACE>(m_tableVertDarts[i]);
map.template initOrbitEmbeddingNewCell<FACE>(map.phi1(m_tableVertDarts[i]));
map.template initOrbitEmbeddingNewCell<FACE>(map.phi1(map.phi1(m_tableVertDarts[i])));
}
}
if(map.template isOrbitEmbedded<FACE>())
{
for(unsigned int i = 0; i < n; ++i)
{
map.template initOrbitEmbeddingNewCell<FACE>(m_tableVertDarts[i]);
}
map.template initOrbitEmbeddingNewCell<FACE>(top);
map.template initOrbitEmbeddingNewCell<FACE>(bottom);
}
if(map.template isOrbitEmbedded<VOLUME>())
{
map.template initOrbitEmbeddingNewCell<VOLUME>(dres);
}
//return a dart from the base
return dres;
}
......@@ -203,12 +135,12 @@ Dart createPrism(typename PFP::MAP& map, unsigned int n)
* create a n-sided diamond
*/
template <typename PFP>
Dart createDiamond(typename PFP::MAP& map, unsigned int nbSides)
Dart createDiamond(typename PFP::MAP& map, unsigned int nbSides, bool withBoundary)
{
Dart res = Dart::nil();
Dart firstP = createPyramid<PFP>(map,nbSides);
Dart secondP = createPyramid<PFP>(map,nbSides);
Dart firstP = createPyramid<PFP>(map,nbSides, withBoundary);
Dart secondP = createPyramid<PFP>(map,nbSides, withBoundary);
res = map.phi2(firstP);
......@@ -224,45 +156,45 @@ Dart createDiamond(typename PFP::MAP& map, unsigned int nbSides)
* create a 3-sided prism
*/
template <typename PFP>
Dart createTriangularPrism(typename PFP::MAP& map)
Dart createTriangularPrism(typename PFP::MAP& map, bool withBoundary)
{
return createPrism<PFP>(map, 3);
return createPrism<PFP>(map, 3, withBoundary);
}
/**
* create a hexahedron
*/
template <typename PFP>
Dart createHexahedron(typename PFP::MAP& map)
Dart createHexahedron(typename PFP::MAP& map, bool withBoundary)
{
return createPrism<PFP>(map, 4);
return createPrism<PFP>(map, 4, withBoundary);
}
/**
* create a tetrahedron
*/
template <typename PFP>
Dart createTetrahedron(typename PFP::MAP& map)
Dart createTetrahedron(typename PFP::MAP& map, bool withBoundary)
{
return createPyramid<PFP>(map, 3);
return createPyramid<PFP>(map, 3, withBoundary);
}
/**
* create a 4-sided pyramid
*/
template <typename PFP>
Dart createQuadrangularPyramid(typename PFP::MAP& map)
Dart createQuadrangularPyramid(typename PFP::MAP& map, bool withBoundary)
{
return createPyramid<PFP>(map, 4);
return createPyramid<PFP>(map, 4, withBoundary);
}
/**
* create an octahedron (i.e. 4-sided diamond)
*/
template <typename PFP>
Dart createOctahedron(typename PFP::MAP& map)
Dart createOctahedron(typename PFP::MAP& map, bool withBoundary)
{
return createDiamond<PFP>(map,4);
return createDiamond<PFP>(map,4, withBoundary);
}
......
......@@ -123,7 +123,7 @@ void Map2MR<PFP>::addNewLevel(bool triQuad)
Dart next = m_map.phi1(m_map.phi1(dd)) ;
m_map.splitFace(dd, next) ; // insert a first edge
Dart ne = m_map.alpha1(dd) ;
Dart ne = m_map.phi2(m_map.phi_1(dd)) ;
m_map.cutEdge(ne) ; // cut the new edge to insert the central vertex
travF.skip(dd) ;
......
......@@ -29,6 +29,7 @@
#include "Algo/Geometry/centroid.h"
#include "Algo/Modelisation/tetrahedralization.h"
#include "Algo/Multiresolution/filter.h"
#include "Topology/generic/traversor2_closed.h"
namespace CGoGN
{
......@@ -174,28 +175,8 @@ public:
typename PFP::VEC3 ev(0.0);
typename PFP::VEC3 fv(0.0);
std::cout << "db = " << db << std::endl;
Dart dit = db;
do
{
std::cout << "dit = " << dit << std::endl;
m_map.incCurrentLevel() ;
Dart midEdgeV = m_map.phi1(dit);
ev += m_position[midEdgeV];
fv += m_position[m_map.phi1(midEdgeV)];
m_map.decCurrentLevel() ;
++count;
dit = m_map.phi2(m_map.phi_1(dit));
}while(dit != db);
//TODO Replace do--while with a Traversor2 on Boundary
// Traversor2VF<typename PFP::MAP> travVF(m_map,db);
// for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next())
// Dart dit = db;
// do
// {
// std::cout << "dit = " << dit << std::endl;
// m_map.incCurrentLevel() ;
......@@ -206,9 +187,24 @@ public:
//
// m_map.decCurrentLevel() ;
// ++count;
// }
//
// dit = m_map.phi2(m_map.phi_1(dit));
//
// }while(dit != db);
//TODO Replace do--while with a Traversor2 on Boundary
ClosedMap::Traversor2VF<typename PFP::MAP> travVF(m_map,db);
for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next())
{
m_map.incCurrentLevel() ;
Dart midEdgeV = m_map.phi1(dit);
ev += m_position[midEdgeV];
fv += m_position[m_map.phi1(midEdgeV)];
std::cout << std::endl;
m_map.decCurrentLevel() ;
++count;
}
fv /= count;
fv *= 4 * m_a * m_a;
......@@ -276,26 +272,26 @@ public:
Dart db = m_map.findBoundaryFaceOfEdge(d);
typename PFP::VEC3 fe(0.0);
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(m_map.phi1(db));
fe += m_position[midV];
midV = m_map.phi_1(m_map.phi2(db));
fe += m_position[midV];
m_map.decCurrentLevel() ;
// m_map.incCurrentLevel() ;
// Dart midV = m_map.phi1(m_map.phi1(db));
// fe += m_position[midV];
// midV = m_map.phi_1(m_map.phi2(db));
// fe += m_position[midV];
// m_map.decCurrentLevel() ;
//TODO Replace do--while with a Traversor2 on Boundary
// unsigned int count = 0;
// Traversor2EF<typename PFP::MAP> travEF(m_map, db);
// for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next())
// {
// m_map.incCurrentLevel() ;
// Dart midV = m_map.phi1(m_map.phi1(dit));
// fe += m_position[midV];
// m_map.decCurrentLevel() ;
// ++count;
// }
//TODO Replace do--while with a Traversor2 on Boundary
unsigned int count = 0;
ClosedMap::Traversor2EF<typename PFP::MAP> travEF(m_map, db);
for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next())
{
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(m_map.phi1(dit));
fe += m_position[midV];
m_map.decCurrentLevel() ;
++count;
}
fe /= 2;
fe /= count;
fe *= 2 * m_a;
m_map.incCurrentLevel() ;
......@@ -570,26 +566,26 @@ public:
Dart db = m_map.findBoundaryFaceOfEdge(d);
typename PFP::VEC3 fe(0.0);
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(m_map.phi1(db));
fe += m_position[midV];
midV = m_map.phi_1(m_map.phi2(db));
fe += m_position[midV];
m_map.decCurrentLevel() ;
// m_map.incCurrentLevel() ;
// Dart midV = m_map.phi1(m_map.phi1(db));
// fe += m_position[midV];
// midV = m_map.phi_1(m_map.phi2(db));
// fe += m_position[midV];
// m_map.decCurrentLevel() ;
//TODO Replace do--while with a Traversor2 on Boundary
// unsigned int count = 0;
// Traversor2EF<typename PFP::MAP> travEF(m_map, db);
// for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next())
// {
// m_map.incCurrentLevel() ;
// Dart midV = m_map.phi1(m_map.phi1(dit));
// fe += m_position[midV];
// m_map.decCurrentLevel() ;
// ++count;
// }
//TODO Replace do--while with a Traversor2 on Boundary
unsigned int count = 0;
ClosedMap::Traversor2EF<typename PFP::MAP> travEF(m_map, db);
for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next())
{
m_map.incCurrentLevel() ;
Dart midV = m_map.phi1(m_map.phi1(dit));
fe += m_position[midV];
m_map.decCurrentLevel() ;
++count;
}
fe /= 2;
fe /= count;
fe *= 2 * m_a;
m_map.incCurrentLevel() ;
......@@ -646,27 +642,8 @@ public:
typename PFP::VEC3 ev(0.0);
typename PFP::VEC3 fv(0.0);
std::cout << "db = " << db << std::endl;
Dart dit = db;
do
{
std::cout << "dit = " << dit << std::endl;
m_map.incCurrentLevel() ;
Dart midEdgeV = m_map.phi1(dit);
ev += m_position[midEdgeV];
fv += m_position[m_map.phi1(midEdgeV)];
m_map.decCurrentLevel() ;
++count;
dit = m_map.phi2(m_map.phi_1(dit));
}while(dit != db);
// Traversor2VF<typename PFP::MAP> travVF(m_map,db);
// for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next())
// Dart dit = db;
// do
// {
// std::cout << "dit = " << dit << std::endl;
// m_map.incCurrentLevel() ;
......@@ -677,9 +654,24 @@ public:
//
// m_map.decCurrentLevel() ;
// ++count;
// }
//
// dit = m_map.phi2(m_map.phi_1(dit));
//
// }while(dit != db);
std::cout << std::endl;
ClosedMap::Traversor2VF<typename PFP::MAP> travVF(m_map,db);
for(Dart dit = travVF.begin(); dit != travVF.end() ; dit = travVF.next())
{
std::cout << "dit = " << dit << std::endl;
m_map.incCurrentLevel() ;
Dart midEdgeV = m_map.phi1(dit);
ev += m_position[midEdgeV];
fv += m_position[m_map.phi1(midEdgeV)];
m_map.decCurrentLevel() ;
++count;
}
fv /= count;
fv *= 4 * m_a * m_a;
......
......@@ -108,6 +108,38 @@ public:
}
} ;
template <typename PFP>
class LerpTriQuadFaceSynthesisFilter : public Filter
{
protected:
typename PFP::MAP& m_map ;
VertexAttribute<typename PFP::VEC3>& m_position ;
public:
LerpTriQuadFaceSynthesisFilter(typename PFP::MAP& m, VertexAttribute<typename PFP::VEC3>& p) : m_map(m), m_position(p)
{}
void operator() ()
{
TraversorF<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
if(m_map.faceDegree(d) > 3)
{
typename PFP::VEC3 p = Algo::Geometry::faceCentroid<PFP>(m_map, d, m_position);
m_map.incCurrentLevel() ;
Dart midF = m_map.phi2(m_map.phi1(d));
m_position[midF] = p ;
m_map.decCurrentLevel() ;
}
}
}
} ;
template <typename PFP>
class LerpVolumeSynthesisFilter : public Filter
{
......@@ -128,11 +160,12 @@ public:
m_map.incCurrentLevel() ;
if(!Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d))
if(!Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d)) // && is not a pyramide && is not a prisme
{
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d)));
m_position[midV] = p ;
std::cout << "midV = " << midV << std::endl;
}
m_map.decCurrentLevel() ;
......
......@@ -118,57 +118,57 @@ public:
//@}
protected:
// /*! @name Topological helping functions
// *
// *************************************************************************/
// //@{
// //!
// /*!
// */
// void swapEdges(Dart d, Dart e);
//
// void splitSurfaceInVolume(std::vector<Dart>& vd, bool firstSideClosed = true, bool secondSideClosed = false);
//
// Dart cutEdgeInVolume(Dart d);
//
// void splitFaceInVolume(Dart d, Dart e);
//
// void splitVolume(std::vector<Dart>& vd);
//
// void saveRelationsAroundVertex(Dart d, std::vector<std::pair<Dart, Dart> >& vd);
//
// void unsewAroundVertex(std::vector<std::pair<Dart, Dart> >& vd);
//
// Dart cutEdge(Dart d) ;
// void splitFace(Dart d, Dart e) ;
// //@}
//
// /*! @name Subdivision
// *
// *************************************************************************/
// //@{
// //! Subdivide the edge of d to the next level
// /*! @param d Dart from the edge
// */
// void subdivideEdge(Dart d) ;
//
// //! Subdivide the edge of d to the next level
// /*! @param d Dart frome the face
// */
// void subdivideFace(Dart d, bool triQuad) ;
/*! @name Topological helping functions
*
*************************************************************************/
//@{
//!
/*!
*/
void swapEdges(Dart d, Dart e);
void splitSurfaceInVolume(std::vector<Dart>& vd, bool firstSideClosed = true, bool secondSideClosed = false);
Dart cutEdgeInVolume(Dart d);
void splitFaceInVolume(Dart d, Dart e);
void splitVolume(std::vector<Dart>& vd);
void saveRelationsAroundVertex(Dart d, std::vector<std::pair<Dart, Dart> >& vd);