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':
{
......
......@@ -31,7 +31,8 @@
#include "Utils/GLSLShader.h"
//#include "Algo/Geometry/area.h"
#include "Algo/Geometry/normal.h"
#include "Geometry/matrix.h"
#include "Geometry/transfo.h"
#include "Utils/cgognStream.h"
#include "Utils/chrono.h"
......@@ -106,7 +107,12 @@ void MyQT::squareTiling(int code)
{
std::cout << "square grid tiling" << std::endl;
Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,10,10,true);
g.embedIntoGrid(position,50,50);
g.embedIntoGrid(position,1.0,1.0, 0.0);
Geom::Matrix44f trf;
trf.identity();
Geom::translate<float>(0.5,0.5,0.0,trf);
g.transform(position, trf);
g.exportPositions(position, "grid.bs");
......@@ -116,7 +122,13 @@ void MyQT::squareTiling(int code)
{
std::cout << "square grid twisted strip tiling" << std::endl;
Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,10,10,true);
g.embedIntoTwistedStrip(position, 0.3, 0.8, 5);
g.embedIntoTwistedStrip(position, 0.2, 0.7, 5);
Geom::Matrix44f trf;
trf.identity();
Geom::translate<float>(0.5,0.5,0.0,trf);
g.transform(position, trf);
g.exportPositions(position, "gridtwisted.bs");
......@@ -126,7 +138,13 @@ void MyQT::squareTiling(int code)
{
std::cout << "square grid helicoid tiling" << std::endl;
Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,20,20,true);
g.embedIntoHelicoid(position, 0.3, 0.8, 5.0, 2.0);
g.embedIntoHelicoid(position, 0.2, 0.3, 0.8, 2.0);
// Geom::Matrix44f trf;
// trf.identity();
// Geom::translate<float>(0.5,0.5,0.0,trf);
// g.transform(position, trf);
g.exportPositions(position, "gridhelicoid.bs");
......@@ -136,7 +154,13 @@ void MyQT::squareTiling(int code)
{
std::cout << "square cylinder tiling" << std::endl;
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.embedIntoCylinder(position,0.5,0.7,5.0);
c.embedIntoCylinder(position,0.5,0.7,1.0);
Geom::Matrix44f trf;
trf.identity();
Geom::translate<float>(0.5,0.5,0.0,trf);
c.transform(position, trf);
c.exportPositions(position, "cylinder.bs");
......@@ -148,7 +172,7 @@ void MyQT::squareTiling(int code)
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.triangleBottom();
c.triangleTop();
c.embedIntoCylinder(position,0.5,0.7,5.0);
c.embedIntoCylinder(position,0.5,0.7,1.0);
break;
}
......@@ -168,15 +192,20 @@ void MyQT::squareTiling(int code)
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.triangleTop();
c.triangleBottom();
c.embedIntoCone(position,0.5, 5.0);
c.embedIntoCone(position,0.5, 1.0);
break;
}
case 8:
{
std::cout << "square cylinder cone tiling" << std::endl;
Algo::Surface::Tilings::Square::Cube<PFP> c(myMap,20,20,20);
c.embedIntoCube(position,5.0,5.0, 5.0);
std::cout << "square cube tiling" << std::endl;
Algo::Surface::Tilings::Square::Cube<PFP> c(myMap,1,1,2);
c.embedIntoCube(position,1.0, 1.0, 1.0);
Geom::Matrix44f trf;
trf.identity();
Geom::translate<float>(0.5,0.5,0.5,trf);
c.transform(position, trf);
c.exportPositions(position, "cube.bs");
......@@ -186,7 +215,7 @@ void MyQT::squareTiling(int code)
{
std::cout << "square tore tiling" << std::endl;
Algo::Surface::Tilings::Square::Tore<PFP> c(myMap,20,10);
c.embedIntoTore(position,5.0,2.0);
c.embedIntoTore(position, 0.9, 0.5);
c.exportPositions(position, "tore.bs");
break;
......@@ -208,79 +237,79 @@ void MyQT::triangularTiling(int code)
{
case 1:
{
std::cout << "square grid tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,10,10,true);
g.embedIntoGrid(position,50,50);
std::cout << "triangle grid tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,1,5,true);
g.embedIntoGrid(position,1,1);
break;
}
case 2:
{
// std::cout << "square grid twisted strip tiling" << std::endl;
// Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,10,10,true);
// g.embedIntoTwistedStrip(position, 0.3, 0.8, 5);
std::cout << "triangle grid twisted strip tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,10,10,true);
g.embedIntoTwistedStrip(position, 0.3, 0.8, 5);
break;
}
case 3:
{
// std::cout << "square grid helocoid tiling" << std::endl;
// Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,20,20,true);
// g.embedIntoHelicoid(position, 0.3, 0.8, 5.0, 2.0);
std::cout << "triangle grid helocoid tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,20,20,true);
g.embedIntoHelicoid(position, 0.3, 0.8, 5.0, 2.0);
break;
}
case 4:
{
// std::cout << "square cylinder tiling" << std::endl;
// Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
// c.embedIntoCylinder(position,0.5,0.7,5.0);
std::cout << "triangle cylinder tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
c.embedIntoCylinder(position,0.5,0.7,5.0);
break;
}
case 5:
{
// std::cout << "square cylinder tiling" << std::endl;
// Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
// c.triangleBottom();
// c.triangleTop();
// c.embedIntoCylinder(position,0.5,0.7,5.0);
std::cout << "triangle cylinder tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
c.triangleBottom();
c.triangleTop();
c.embedIntoCylinder(position,0.5,0.7,5.0);
break;
}
case 6:
{
// std::cout << "square cylinder sphere tiling" << std::endl;
// Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
// c.triangleTop();
// c.triangleBottom();
// c.embedIntoSphere(position,0.5);
std::cout << "triangle cylinder sphere tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
c.triangleTop();
c.triangleBottom();
c.embedIntoSphere(position,0.5);
break;
}
case 7:
{
// std::cout << "square cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
// c.triangleTop();
// c.triangleBottom();
// c.embedIntoCone(position,0.5, 5.0);
std::cout << "triangle cylinder cone tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
c.triangleTop();
c.triangleBottom();
c.embedIntoCone(position,0.5, 5.0);
break;
}
case 8:
{
// std::cout << "square cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Square::Cube<PFP> c(myMap,20,20,20);
// c.embedIntoCube(position,5.0,5.0, 5.0);
std::cout << "triangle cube tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Cube<PFP> c(myMap,4,4,4);
c.embedIntoCube(position,5.0,5.0, 5.0);
break;
}
case 9:
{
// std::cout << "square cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Square::Tore<PFP> c(myMap,20,10);
// c.embedIntoTore(position,5.0,2.0);
std::cout << "triangle tore tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Tore<PFP> c(myMap,20,10);
c.embedIntoTore(position,5.0,2.0);
break;
}
......@@ -292,6 +321,96 @@ void MyQT::triangularTiling(int code)
}
}
void MyQT::hexagonalTiling(int code)
{
switch(code)
{
case 1:
{
std::cout << "hexagonal grid tiling" << std::endl;
Algo::Surface::Tilings::Hexagonal::Grid<PFP> g(myMap,10,6,true);
g.embedIntoGrid(position,1,1);
break;
}
case 2:
{
// std::cout << "hexagonal grid twisted strip tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,10,10,true);
// g.embedIntoTwistedStrip(position, 0.3, 0.8, 5);
break;
}
case 3:
{
// std::cout << "hexagonal grid helocoid tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,20,20,true);
// g.embedIntoHelicoid(position, 0.3, 0.8, 5.0, 2.0);
break;
}
case 4:
{
// std::cout << "hexagonal cylinder tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
// c.embedIntoCylinder(position,0.5,0.7,5.0);
break;
}
case 5:
{
// std::cout << "hexagonal cylinder tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
// c.triangleBottom();
// c.triangleTop();
// c.embedIntoCylinder(position,0.5,0.7,5.0);
break;
}
case 6:
{
// std::cout << "hexagonal cylinder sphere tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
// c.triangleTop();
// c.triangleBottom();
// c.embedIntoSphere(position,0.5);
break;
}
case 7:
{
// std::cout << "hexagonal cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Cylinder<PFP> c(myMap,20,20);
// c.triangleTop();
// c.triangleBottom();
// c.embedIntoCone(position,0.5, 5.0);
break;
}
case 8:
{
// std::cout << "hexagonal cube tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Cube<PFP> c(myMap,4,4,4);
// c.embedIntoCube(position,5.0,5.0, 5.0);
break;
}
case 9:
{
// std::cout << "hexagonal tore tiling" << std::endl;
// Algo::Surface::Tilings::Triangular::Tore<PFP> c(myMap,20,10);
// c.embedIntoTore(position,5.0,2.0);
break;
}
default:
{
break;
}
}
}
int main(int argc, char **argv)
{
// interface:
......@@ -313,7 +432,12 @@ int main(int argc, char **argv)
sqt.squareTiling(atoi(argv[2]));
else if(argv[1][0] == 'T')
sqt.triangularTiling(atoi(argv[2]));
else if(argv[1][0] == 'H')
sqt.hexagonalTiling(atoi(argv[2]));
else
return -1;
}
myMap.check();
// bounding box
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
......
......@@ -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);
//!
/*!
......
......@@ -26,6 +26,7 @@
#include "Algo/Modelisation/subdivision3.h"
#include "Topology/generic/traversor/traversor3.h"
namespace CGoGN
{
......@@ -41,6 +42,238 @@ namespace Modelisation
namespace Tetrahedralization
{
template<typename PFP>
bool EarTriangulation<PFP>::inTriangle(const typename PFP::VEC3& P, const typename PFP::VEC3& normal, const typename PFP::VEC3& Ta, const typename PFP::VEC3& Tb, const typename PFP::VEC3& Tc)
{
typedef typename PFP::VEC3 VECT ;
typedef typename VECT::DATA_TYPE T ;
if (Geom::tripleProduct(P-Ta, (Tb-Ta), normal) >= T(0))
return false;