Commit e4ff0d46 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge branch 'develop' of cgogn:~untereiner/CGoGN into develop

parents a98b37c5 d58716fa
......@@ -138,8 +138,8 @@ void MyQT::cb_Open()
std::vector<std::string> attrNames ;
//size_t pos = filename.rfind("."); // position of "." in filename
//std::string extension = filename.substr(pos);
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
// if(extension == std::string(".off"))
// {
......@@ -163,7 +163,7 @@ void MyQT::cb_Open()
}
else
position = myMap.getAttribute<PFP::VEC3,VERTEX>(attrNames[0]) ;
// }
//}
color = myMap.addAttribute<PFP::VEC3, VOLUME>("color");
......@@ -379,8 +379,8 @@ int main(int argc, char **argv)
{
std::vector<std::string> attrNames ;
std::string filename(argv[1]);
// size_t pos = filename.rfind("."); // position of "." in filename
// std::string extension = filename.substr(pos);
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
/*
if(extension == std::string(".off"))
{
......@@ -397,7 +397,8 @@ int main(int argc, char **argv)
}
else
{
*/ if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
*/
if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
{
std::cerr << "could not import " << filename << std::endl ;
return 1;
......
......@@ -244,7 +244,7 @@ void Viewer::cb_keyPress(int keycode)
Geom::Vec3f n(0.1,0.1,1.0);
Geom::Vec3f o = bb.center();
Geom::Plane3D<PFP::REAL> plan(n,o);
Geom::Plane3D<PFP::REAL> plan(n,o);
CellMarker<MAP, FACE> over(myMap);
Algo::Surface::Modelisation::planeCut2<PFP>(myMap, position, plan, over, true);
......@@ -259,7 +259,6 @@ void Viewer::cb_keyPress(int keycode)
position[d]+= n;
}
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::POINTS) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES) ;
......@@ -273,6 +272,16 @@ void Viewer::cb_keyPress(int keycode)
break;
}
case 'S':
{
Geom::Vec3f p1(0.0,1.0,0.0);
Geom::Vec3f p2(1.0,0.0,0.0);
Geom::Vec3f p3(1.0,1.0,0.0);
Geom::Plane3D<PFP::REAL> plan(p1, p2, p3);
}
case 'd':
{
......
This diff is collapsed.
......@@ -43,6 +43,7 @@
#include "Algo/Tiling/Surface/square.h"
#include "Algo/Tiling/Surface/triangular.h"
#include "Algo/Tiling/Surface/hexagonal.h"
// forward definitions (minimize includes)
namespace CGoGN { namespace Algo { namespace Render { namespace GL1 { class MapRender; } } } }
......@@ -76,8 +77,8 @@ public:
{}
void squareTiling(int code);
void triangularTiling(int code);
void hexagonalTiling(int code);
protected:
......
......@@ -81,6 +81,7 @@ bool importChoupi(const std::string& filename, const std::vector<typename PFP::V
namespace Volume
{
namespace Import
{
......@@ -112,25 +113,6 @@ bool importMeshToExtrude(typename PFP::MAP& map, const std::string& filename, st
template <typename PFP>
bool importMeshSAsV(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames);
/**
* TODO ADD TO MeshTablesVolume
*/
template <typename PFP>
bool importMSH(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
template <typename PFP>
bool importVTU(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
template <typename PFP>
bool importNAS(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
template <typename PFP>
bool importVBGZ(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
} // Import
} // Volume
......@@ -144,13 +126,7 @@ bool importVBGZ(typename PFP::MAP& the_map, const std::string& filename, std::ve
#include "Algo/Import/importChoupi.hpp"
#include "Algo/Import/importMSH.hpp"
#include "Algo/Import/importVTU.hpp"
#include "Algo/Import/importNAS.hpp"
#include "Algo/Import/importVBGZ.hpp"
//#include "Algo/Import/importMoka.hpp"
//#include "Algo/Import/importObjTex.hpp"
#endif
This diff is collapsed.
......@@ -195,7 +195,7 @@ private:
bool importTs(const std::string& filename, std::vector<std::string>& attrNames);
//
//TODO Hexahedra : not working yet
bool importMSH(const std::string& filename, std::vector<std::string>& attrNames);
......@@ -205,13 +205,13 @@ private:
bool importVBGZ(const std::string& filename, std::vector<std::string>& attrNames);
//TODO Moka / OVM not working
//bool importMoka(const std::string& filename, std::vector<std::string>& attrNames);
//bool importOVM(const std::string& filename, std::vector<std::string>& attrNames);
public:
//static ImportType getFileType(const std::string& filename);
inline unsigned getNbVertices() const { return m_nbVertices; }
inline unsigned getNbVolumes() const { return m_nbVolumes; }
......
This diff is collapsed.
......@@ -26,6 +26,7 @@
#define __TETRAHEDRALIZATION_H__
//#include "tetgen/tetgen.h"
#include "Algo/Geometry/normal.h"
namespace CGoGN
{
......@@ -43,6 +44,77 @@ namespace Modelisation
namespace Tetrahedralization
{
template <typename PFP>
class EarTriangulation
{
typedef typename PFP::MAP MAP ;
typedef typename PFP::MAP::IMPL MAP_IMPL ;
typedef typename PFP::VEC3 VEC3 ;
protected:
// forward declaration
class VertexPoly;
// multiset typedef for simple writing
typedef std::multiset< VertexPoly,VertexPoly> VPMS;
typedef typename VPMS::iterator VMPSITER;
typedef NoTypeNameAttribute<VMPSITER> EarAttr ;
class VertexPoly
{
public:
Dart dart;
float angle;
float length;
VertexPoly()
{}
VertexPoly(Dart d, float v, float l) : dart(d), angle(v), length(l)
{}
bool operator()(const VertexPoly& vp1, const VertexPoly& vp2)
{
if (fabs(vp1.angle - vp2.angle) < 0.2f)
return vp1.length < vp2.length;
return vp1.angle < vp2.angle;
}
};
protected:
MAP& m_map;
VertexAutoAttribute<EarAttr, MAP_IMPL> m_dartEars;
VertexAttribute<VEC3, MAP_IMPL> m_position;
std::vector<Dart> m_resTets;
VPMS m_ears;
bool inTriangle(const VEC3& P, const VEC3& normal, const VEC3& Ta, const VEC3& Tb, const VEC3& Tc);
void recompute2Ears(Dart d, const VEC3& normalPoly, bool convex);
float computeEarInit(Dart d, const VEC3& normalPoly, float& val);
public:
EarTriangulation(MAP& map) : m_map(map), m_dartEars(map)
{
m_position = map.template getAttribute<VEC3, VERTEX>("position");
}
// void trianguleFace(Dart d, DartMarker& mark);
void trianguleFace(Dart d);
void triangule(unsigned int thread = 0);
std::vector<Dart> getResultingTets() { return m_resTets; }
};
///**
//* subdivide a hexahedron into 5 tetrahedron
//*/
......@@ -106,7 +178,7 @@ Dart swap2To2(typename PFP::MAP& map, Dart d);
*
*/
template <typename PFP>
void swap4To4(typename PFP::MAP& map, Dart d);
Dart swap4To4(typename PFP::MAP& map, Dart d);
//!
/*!
......@@ -132,9 +204,20 @@ Dart swap5To4(typename PFP::MAP& map, Dart d);
//!
/*!
* called edge removal (equivalent to G32)
* Connect the vertex of dart d to each vertex of the polygonal face
* @return A dart from the vertex that is incident to the tetrahedra created during the swap
*/
template <typename PFP>
Dart swapGen3To2(typename PFP::MAP& map, Dart d);
//!
/*!
* Edge removal
* Optimized version : do an ear cutting on the sandwiched polygonal face
* @return : A dart of each tetrahedra created during the swap
*/
template <typename PFP>
void swapGen3To2(typename PFP::MAP& map, Dart d);
std::vector<Dart> swapGen3To2Optimized(typename PFP::MAP& map, Dart d);
//!
/*!
......
......@@ -352,7 +352,7 @@ unsigned int IHM2<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffere
unsigned int fLevel = faceLevel(d) ;
Dart old = faceOldestDart(d) ;
std::cout << "faceLevel = " << fLevel << std::endl;
//std::cout << "faceLevel = " << fLevel << std::endl;
unsigned int cur = m_map.getCurrentLevel() ;
m_map.setCurrentLevel(fLevel) ; // go to the level of the face to subdivide its edges
......@@ -378,7 +378,7 @@ unsigned int IHM2<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffere
m_map.setCurrentLevel(fLevel + 1) ; // go to the next level to perform face subdivision
if(triQuad && (degree == 3)) // if subdividing a triangle
if((degree == 3) && triQuad) // if subdividing a triangle
{
Dart dd = m_map.phi1(old) ;
Dart e = m_map.phi1(dd) ;
......@@ -386,16 +386,18 @@ unsigned int IHM2<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffere
e = m_map.phi1(e) ;
m_map.splitFace(dd, e) ; // insert a new edge
unsigned int id = m_map.getNewEdgeId() ;
m_map.setEdgeId(m_map.phi_1(dd), id) ; // set the edge id of the inserted
m_map.setEdgeId(m_map.phi_1(e), id) ; // edge to the next available id
// unsigned int id = m_map.getNewEdgeId() ;
unsigned int id = m_map.getTriRefinementEdgeId(m_map.phi_1(dd));
m_map.setEdgeId(m_map.phi_1(dd), id) ; // set the edge id of the inserted
m_map.setEdgeId(m_map.phi_1(e), id) ; // edge to the next available id
dd = e ;
e = m_map.phi1(dd) ;
(*vertexVertexFunctor)(e) ;
e = m_map.phi1(e) ;
m_map.splitFace(dd, e) ;
id = m_map.getNewEdgeId() ;
//id = m_map.getNewEdgeId() ;
id = m_map.getTriRefinementEdgeId(m_map.phi_1(dd));
m_map.setEdgeId(m_map.phi_1(dd), id) ;
m_map.setEdgeId(m_map.phi_1(e), id) ;
......@@ -404,7 +406,8 @@ unsigned int IHM2<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffere
(*vertexVertexFunctor)(e) ;
e = m_map.phi1(e) ;
m_map.splitFace(dd, e) ;
id = m_map.getNewEdgeId() ;
//id = m_map.getNewEdgeId() ;
id = m_map.getTriRefinementEdgeId(m_map.phi_1(dd));
m_map.setEdgeId(m_map.phi_1(dd), id) ;
m_map.setEdgeId(m_map.phi_1(e), id) ;
}
......@@ -419,10 +422,12 @@ unsigned int IHM2<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffere
Dart ne2 = m_map.phi2(ne) ;
m_map.cutEdge(ne) ; // cut the new edge to insert the central vertex
unsigned int id = m_map.getNewEdgeId() ;
//unsigned int id = m_map.getNewEdgeId() ;
unsigned int id = m_map.getQuadRefinementEdgeId(m_map.phi2(ne));
m_map.setEdgeId(ne, id) ;
m_map.setEdgeId(m_map.phi2(ne), id) ; // set the edge id of the inserted
id = m_map.getNewEdgeId() ;
//id = m_map.getNewEdgeId() ;
id = m_map.getQuadRefinementEdgeId(ne2);
m_map.setEdgeId(ne2, id) ; // edges to the next available ids
m_map.setEdgeId(m_map.phi2(ne2), id) ;
......@@ -433,7 +438,8 @@ unsigned int IHM2<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffere
{ // linked to the central vertex
m_map.splitFace(m_map.phi1(ne), dd) ;
Dart nne = m_map.alpha1(dd) ;
id = m_map.getNewEdgeId() ;
//id = m_map.getNewEdgeId() ;
id = m_map.getQuadRefinementEdgeId(m_map.phi2(nne));
m_map.setEdgeId(nne, id) ;
m_map.setEdgeId(m_map.phi2(nne), id) ;
dd = m_map.phi1(dd) ;
......
......@@ -56,8 +56,11 @@ public:
bool operator() (Dart d)
{
std::cout << "dartIndex(d) = " << m_map.dartIndex(d) << std::endl;
m_map.decCurrentLevel() ;
std::cout << "dartIndex(d) = " << m_map.dartIndex(d) << std::endl;
typename PFP::VEC3 p = m_position[d] ;
std::cout << "p = " << p << std::endl;
m_map.incCurrentLevel() ;
m_position[d] = p ;
......
......@@ -69,7 +69,6 @@ protected:
public:
Map2MR(MAP& map) ;
/***************************************************
* CELLS INFORMATION *
***************************************************/
......@@ -123,7 +122,7 @@ public:
bool faceIsSubdividedOnce(Dart d) ;
//protected:
protected:
/**
*
*/
......@@ -159,8 +158,6 @@ public:
*/
unsigned int subdivideFace(Dart d, bool triQuad = true, bool OneLevelDifference = true);
unsigned int subdivideFace2(Dart d, bool triQuad = true, bool OneLevelDifference = true);
/**
*
*/
......
......@@ -381,7 +381,8 @@ void Map2MR<PFP>::subdivideEdge(Dart d)
m_map.incCurrentLevel() ;
Dart nd = cutEdge(d) ;
//Dart nd = cutEdge(d) ;
Dart nd = m_map.cutEdge(d);
(*edgeVertexFunctor)(nd) ;
......@@ -403,6 +404,91 @@ void Map2MR<PFP>::coarsenEdge(Dart d)
m_map.removeLevelBack() ;
}
//template <typename PFP>
//unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDifference)
//{
// assert(m_map.getDartLevel(d) <= m_map.getCurrentLevel() || !"subdivideFace : called with a dart inserted after current level") ;
// assert(!faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ;
// unsigned int fLevel = faceLevel(d) ;
// Dart old = faceOldestDart(d) ;
// m_map.pushLevel() ;
// m_map.setCurrentLevel(fLevel) ; // go to the level of the face to subdivide its edges
// if(m_map.getCurrentLevel() == m_map.getMaxLevel())
// m_map.addLevelBack();
// unsigned int degree = 0 ;
// Dart it = old ;
// do
// {
// ++degree ; // compute the degree of the face
// if(OneLevelDifference)
// {
// Dart nf = m_map.phi2(it) ;
// if(faceLevel(nf) == fLevel - 1) // check if neighboring faces have to be subdivided first
// subdivideFace(nf,triQuad) ;
// }
// if(!edgeIsSubdivided(it))
// subdivideEdge(it) ; // and cut the edges (if they are not already)
// it = m_map.phi1(it) ;
// } while(it != old) ;
// m_map.setCurrentLevel(fLevel + 1) ; // go to the next level to perform face subdivision
// if(triQuad && degree == 3) // if subdividing a triangle
// {
// Dart dd = m_map.phi1(old) ;
// Dart e = m_map.phi1(dd) ;
// (*vertexVertexFunctor)(e) ;
// e = m_map.phi1(e) ;
// splitFace(dd, e) ;
// dd = e ;
// e = m_map.phi1(dd) ;
// (*vertexVertexFunctor)(e) ;
// e = m_map.phi1(e) ;
// splitFace(dd, e) ;
// dd = e ;
// e = m_map.phi1(dd) ;
// (*vertexVertexFunctor)(e) ;
// e = m_map.phi1(e) ;
// splitFace(dd, e) ;
// }
// else // if subdividing a polygonal face
// {
// Dart dd = m_map.phi1(old) ;
// Dart next = m_map.phi1(dd) ;
// (*vertexVertexFunctor)(next) ;
// next = m_map.phi1(next) ;
// splitFace(dd, next) ; // insert a first edge
// Dart ne = m_map.phi2(m_map.phi_1(dd)) ;
// cutEdge(ne) ; // cut the new edge to insert the central vertex
// dd = m_map.phi1(next) ;
// (*vertexVertexFunctor)(dd) ;
// dd = m_map.phi1(dd) ;
// while(dd != ne) // turn around the face and insert new edges
// { // linked to the central vertex
// splitFace(m_map.phi1(ne), dd) ;
// dd = m_map.phi1(dd) ;
// (*vertexVertexFunctor)(dd) ;
// dd = m_map.phi1(dd) ;
// }
// (*faceVertexFunctor)(m_map.phi1(ne)) ;
// }
// m_map.popLevel() ;
// return fLevel ;
//}
template <typename PFP>
unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDifference)
{
......@@ -415,9 +501,6 @@ unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffe
m_map.pushLevel() ;
m_map.setCurrentLevel(fLevel) ; // go to the level of the face to subdivide its edges
if(m_map.getCurrentLevel() == m_map.getMaxLevel())
m_map.addLevelBack();
unsigned int degree = 0 ;
Dart it = old ;
do
......@@ -444,22 +527,26 @@ unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffe
Dart e = m_map.phi1(dd) ;
(*vertexVertexFunctor)(e) ;
e = m_map.phi1(e) ;
splitFace(dd, e) ;
//splitFace(dd, e) ;
m_map.splitFace(dd, e) ;
dd = e ;
e = m_map.phi1(dd) ;
(*vertexVertexFunctor)(e) ;
e = m_map.phi1(e) ;
splitFace(dd, e) ;
//splitFace(dd, e) ;
m_map.splitFace(dd, e) ;
dd = e ;
e = m_map.phi1(dd) ;
(*vertexVertexFunctor)(e) ;
e = m_map.phi1(e) ;
splitFace(dd, e) ;
//splitFace(dd, e) ;
m_map.splitFace(dd, e) ;
}
else // if subdividing a polygonal face
{
std::cout << "wrong" << std::endl;
Dart dd = m_map.phi1(old) ;
Dart next = m_map.phi1(dd) ;
(*vertexVertexFunctor)(next) ;
......@@ -488,61 +575,6 @@ unsigned int Map2MR<PFP>::subdivideFace(Dart d, bool triQuad, bool OneLevelDiffe
return fLevel ;
}
template <typename PFP>
unsigned int Map2MR<PFP>::subdivideFace2(Dart d, bool triQuad, bool OneLevelDifference)
{
assert(m_map.getDartLevel(d) <= m_map.getCurrentLevel() || !"subdivideFace : called with a dart inserted after current level") ;
assert(!faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ;
unsigned int fLevel = faceLevel(d) ;
Dart old = faceOldestDart(d) ;
m_map.pushLevel() ;
m_map.setCurrentLevel(fLevel) ; // go to the level of the face to subdivide its edges
if(m_map.getCurrentLevel() == m_map.getMaxLevel())
m_map.addLevelBack();
unsigned int degree = 0 ;
Dart it = old ;
do
{
++degree ; // compute the degree of the face
if(!edgeIsSubdivided(it))
subdivideEdge(it) ; // and cut the edges (if they are not already)
it = m_map.phi1(it) ;
} while(it != old) ;
m_map.setCurrentLevel(fLevel + 1) ; // go to the next level to perform face subdivision
// Dart dd = m_map.phi1(old) ;
// Dart next = m_map.phi1(dd) ;
// (*vertexVertexFunctor)(next) ;
// next = m_map.phi1(next) ;
// splitFace(dd, next) ; // insert a first edge
// Dart ne = m_map.phi2(m_map.phi_1(dd)) ;
// cutEdge(ne) ; // cut the new edge to insert the central vertex
// dd = m_map.phi1(next) ;
// (*vertexVertexFunctor)(dd) ;
// dd = m_map.phi1(dd) ;
// while(dd != ne) // turn around the face and insert new edges
// { // linked to the central vertex
// splitFace(m_map.phi1(ne), dd) ;
// dd = m_map.phi1(dd) ;
// (*vertexVertexFunctor)(dd) ;
// dd = m_map.phi1(dd) ;
// }
// (*faceVertexFunctor)(m_map.phi1(ne)) ;
m_map.popLevel() ;
return fLevel ;
}
template <typename PFP>
void Map2MR<PFP>::coarsenFace(Dart d)
......
......@@ -54,17 +54,20 @@ void Grid<PFP>::grid(unsigned int x, unsigned int y, bool close)
{
for (unsigned int j = 1; j <= x; ++j)
{
Dart d = this->m_map.newFace(3, false);
Dart d = this->m_map.newFace(6, false);
this->m_tableVertDarts.push_back(d);
this->m_tableVertDarts.push_back(this->m_map.phi1(d));
if (j== 1)
this->m_tableVertDarts.push_back(this->m_map.phi_1(d));
if (j == x)
this->m_tableVertDarts.push_back(this->m_map.phi1(d));
this->m_tableVertDarts.push_back(this->m_map.phi1(this->m_map.phi1(d)));
}
}
// store last row of vertices
for (unsigned int i = 0; i < x; ++i)
{
//this->m_tableVertDarts.push_back(this->m_map.phi_1(this->m_tableVertDarts[(y-1)*(x+1) + i]) );
this->m_tableVertDarts.push_back(this->m_map.phi_1(this->m_tableVertDarts[(y-1)*(x+1) + i]) );
}
//this-> m_tableVertDarts.push_back(this->m_map.phi1(this->m_tableVertDarts[(y-1)*(x+1) +x]) );
......
......@@ -112,6 +112,188 @@ protected:
};