Commit c02f8c6d authored by untereiner's avatar untereiner

Merge cgogn:~kraemer/CGoGN

parents 23f8022e 90151896
......@@ -28,21 +28,23 @@
#include "Algo/Modelisation/primitives3d.h"
#include "Algo/Modelisation/subdivision3.h"
SimpleGMap3::SimpleGMap3()
{
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
normal = myMap.addAttribute<PFP::VEC3>(VERTEX, "normal");
volume = myMap.addAttribute<PFP::VEC3>(VOLUME, "volume");
Algo::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(2,1,1);
primCat.embedHexaGrid(1,1,1);
Dart d = primCat.hexaGrid_topo(3,1,1);
primCat.embedHexaGrid(2,1,1);
myMap.check();
DartMarker markOrient(myMap);
std::vector<Dart> orient;
FunctorStore fs(orient);
d = 49;
myMap.foreach_dart_of_oriented_volume(d, fs);
for(std::vector<Dart>::iterator it = orient.begin() ; it != orient.end() ; ++it)
......
......@@ -54,6 +54,7 @@ public:
PFP::TVEC3 position ;
PFP::TVEC3 normal ;
PFP::TVEC3 volume ;
SimpleGMap3() ;
......
......@@ -194,7 +194,7 @@ void Viewer::importMesh(std::string& filename)
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES, false) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
......
......@@ -46,11 +46,19 @@ include_directories(
${CMAKE_CURRENT_BINARY_DIR} # for qt (ui,moc,etc.) if necessary
)
add_executable( mon_exec ${CMAKE_SOURCE_DIR}/mon_source.cpp)
# Pour une appli QT
QT4_WRAP_UI( source_ui ../source.ui )
QT4_WRAP_CPP( source_moc ../source.h )
add_executable( mon_exec
${CMAKE_SOURCE_DIR}/mon_source.cpp
# Pour une appli QT
${source_moc}
${source_ui}
)
target_link_libraries( mon_exec ${CGoGN_LIBS_R} ${COMMON_LIBS})
Pour le compiler le plus propre est de faire un repertoire build,
d'aller à l'interieur et de faire ccmake .. (j'ai bien ecrit "..")
ccmake (ou un equivalent type cmake-gui) permet de mettre à jour les variables,
......@@ -58,6 +66,3 @@ ici WITH_QT, WITH_ASSIMP, WITH_NUMERICAL, WITH_ZINRI.
Ceci ajoutera automatiquement tout ce qu'il faut aux variables COMMON_INCLUDES
et COMMON_LIBS.
On peut aussi utiliser cmake avec l'option -D (moins pratique).
......@@ -72,11 +72,8 @@ ENDIF (WITH_QT)
IF (WITH_NUMERICAL)
add_definitions(-DWITH_NUMERICAL)
# SET (NUMERICAL_INCLUDES ${CGoGN_ROOT_DIR}/ThirdParty/Numerical ${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig)
# SET (NUMERICAL_LIBS f2c blas numerical lapack)
SET (COMMON_INCLUDES ${COMMON_INCLUDES} ${CGoGN_ROOT_DIR}/ThirdParty/Numerical ${CGoGN_ROOT_DIR}/ThirdParty/Numerical/UFconfig)
SET (COMMON_LIBS ${COMMON_LIBS} f2c blas numerical lapack)
SET (COMMON_LIBS ${COMMON_LIBS} numerical lapack blas f2c)
ENDIF (WITH_NUMERICAL)
......@@ -102,5 +99,3 @@ SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
SET(CGoGN_LIBS_D topologyD algoD containerD utilsD)
SET(CGoGN_LIBS_R topology algo container utils)
......@@ -53,7 +53,7 @@ bool Approximator_RGBfunctionsHalf<PFP>::init()
m_approxFrame = this->m_map.template getAttribute<MATRIX33>(EDGE, "approx_frame") ;
m_quadricRGBfunctions = this->m_map.template getAttribute<QuadricRGBfunctions<REAL> >(EDGE, "quadricRGBfunctions") ;
MapBrowserLinkedAuto<typename PFP::MAP> mb(this->m_map) ;
MapBrowserLinked<typename PFP::MAP> mb(this->m_map) ;
this->m_map.foreach_orbit(EDGE, mb) ;
// create quadric embedding for computing and set them to 0
......@@ -196,7 +196,7 @@ bool Approximator_RGBfunctions<PFP>::init()
m_approxFrame = this->m_map.template getAttribute<MATRIX33>(EDGE, "approx_frame") ;
m_quadricRGBfunctions = this->m_map.template getAttribute<QuadricRGBfunctions<REAL> >(EDGE, "quadricRGBfunctions") ;
MapBrowserLinkedAuto<typename PFP::MAP> mb(this->m_map) ;
MapBrowserLinked<typename PFP::MAP> mb(this->m_map) ;
this->m_map.foreach_orbit(EDGE, mb) ;
// create quadric embedding for computing and set them to 0
......
......@@ -90,12 +90,6 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
template <typename PFP>
bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const typename PFP::TVEC3 frame[3], const typename PFP::TVEC3 colorPTM[6], const FunctorSelect& good) ;
/**
* export pout l'InESS
*/
template <typename PFP>
bool exportInESS(typename PFP::MAP& map, const char *filename, const typename PFP::TVEC3& position);
} // namespace Export
} // namespace Algo
......
......@@ -434,20 +434,6 @@ bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename P
return true ;
}
template <typename PFP>
bool exportInESS(typename PFP::MAP& map, const char *filename, const typename PFP::TVEC3& position)
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
std::ofstream out(filename, std::ios::out) ;
if (!out.good())
{
CGoGNerr << "Unable to open file " << CGoGNendl ;
return false ;
}
}
} // namespace Export
} // namespace Algo
......
......@@ -69,6 +69,9 @@ void filterBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position
{
if(!map.isBoundaryVertex(d))
{
// get normal of vertex
const VEC3& normal_d = normal[d] ;
// traversal of incident edges
float sum = 0.0f, normalizer = 0.0f ;
Traversor2VE<typename PFP::MAP> te(map, d) ;
......@@ -82,7 +85,7 @@ void filterBilateral(typename PFP::MAP& map, const typename PFP::TVEC3& position
normalizer += wcs ;
}
position2[d] = position[d] + ((sum / normalizer) * normal[d]) ;
position2[d] = position[d] + ((sum / normalizer) * normal_d) ;
}
else
position2[d] = position[d] ;
......
......@@ -43,7 +43,7 @@ typename PFP::REAL normalizeLength(typename PFP::MAP & the_map, typename PFP::TV
typename PFP::REAL sum = 0 ;
int count = 0 ;
MapBrowserLinkedAuto<typename PFP::MAP> mb(the_map) ;
MapBrowserLinked<typename PFP::MAP> mb(the_map) ;
the_map.foreach_orbit(m_attr.getOrbit(), mb) ;
for (Dart d = mb.begin(); d != mb.end(); mb.next(d))
......
......@@ -24,6 +24,7 @@
#include "Topology/generic/traversorCell.h"
#include "Algo/Geometry/centroid.h"
#include "Algo/Modelisation/tetrahedralization.h"
namespace CGoGN
{
......@@ -61,7 +62,7 @@ typename PFP::REAL convexPolyhedronVolume(typename PFP::MAP& map, Dart d, const
{
typedef typename PFP::VEC3 VEC3;
if(map.isVolumeTetrahedron(d))
if(Modelisation::Tetrahedralization::isTetrahedron<PFP>(map,d))
return tetrahedronVolume<PFP>(map,d,position) ;
else
{
......
......@@ -38,51 +38,49 @@ namespace Modelisation
template <typename PFP>
Dart cut3Ear(typename PFP::MAP& map, Dart d)
{
Dart e=d;
int nb=0;
Dart dNew;
Dart dRing;
Dart dRing2;
//count the valence of the vertex
do
{
nb++;
e=map.phi1(map.phi2(e));
} while (e!=d);
if(nb<3)
{
CGoGNout << "Warning : cannot cut 2 volumes without creating a degenerated face " << CGoGNendl;
return d;
}
else
{
//triangulate around the vertex
Dart e = d;
int nb = 0;
Dart dNew;
Dart dRing;
Dart dRing2;
//count the valence of the vertex
do
{
Dart dN = map.phi1(map.phi2(e));
if(map.template phi<111>(e)!=e)
map.splitFace(map.phi_1(e), map.phi1(e));
dRing = map.phi1(e);
dRing2 = map.phi2(dRing);
nb++;
e = map.phi1(map.phi2(e));
} while (e != d);
map.unsewFaces(dRing);
if(nb < 3)
{
CGoGNout << "Warning : cannot cut 2 volumes without creating a degenerated face " << CGoGNendl;
return d;
}
else
{
//triangulate around the vertex
do
{
Dart dN = map.phi1(map.phi2(e));
if(map.template phi<111>(e) != e)
map.splitFace(map.phi_1(e), map.phi1(e));
e= dN;
} while (e!=d);
dRing = map.phi1(e);
dRing2 = map.phi2(dRing);
map.closeHole(dRing);
map.closeHole(dRing2);
map.sewVolumes(map.phi2(dRing),map.phi2(dRing2));
}
map.unsewFaces(dRing);
return map.phi2(dRing);
}
e = dN;
} while (e != d);
map.closeHole(dRing);
map.closeHole(dRing2);
map.sewVolumes(map.phi2(dRing), map.phi2(dRing2));
}
return map.phi2(dRing);
}
template <typename PFP, typename EMBV, typename EMB>
void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected)
......@@ -113,7 +111,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
//memorize each vertices per volumes
if(selected(d) && !mv.isMarked(d))
{
std::cout << " d " << d << std::endl;
l_vertices.push_back(d);
mv.markOrbitInParent<typename PFP::MAP>(VERTEX,d);
}
......@@ -145,12 +142,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
}
}
unsigned int nb_=0;
for(unsigned int nb= attributs.begin() ; nb != attributs.end() ; attributs.next(nb))
nb_++;
std::cout << "first " << nb_ << std::endl;
// second pass: quandrangule faces
std::map<Dart,Dart> toSew;
for (Dart d = map.begin(); d != map.end(); map.next(d))
......@@ -230,12 +221,6 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
}
}
nb_=0;
for(unsigned int nb= attributs.begin() ; nb != attributs.end() ; attributs.next(nb))
nb_++;
std::cout << "then " << nb_ << std::endl;
map.check();
//sew all faces leading to the central vertex
......@@ -249,12 +234,9 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelec
}
}
} //namespace Modelisation
} //namespace Algo
} //namespace CGoGN
......@@ -48,7 +48,6 @@ void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d);
* Tetrahedron functions *
************************************************************************************************/
/**
* test if the volume is a tetrahedron
* @param map
......@@ -57,7 +56,6 @@ void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d);
template <typename PFP>
bool isTetrahedron(typename PFP::MAP& the_map, Dart d);
/************************************************************************************************
* Swap Functions *
************************************************************************************************/
......@@ -101,7 +99,6 @@ Dart swap2To3(typename PFP::MAP& map, Dart d);
template <typename PFP>
void swap5To4(typename PFP::MAP& the_map, Dart d, typename PFP::TVEC3& positions);
/************************************************************************************************
* Flip Functions *
************************************************************************************************/
......@@ -112,23 +109,20 @@ void swap5To4(typename PFP::MAP& the_map, Dart d, typename PFP::TVEC3& positions
template <typename PFP>
void flip1To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
/**
*
*/
template <typename PFP>
void edgeBisection(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
} // namespace Tetrahedralization
} // namespace Modelisation
} //end namespace Tetrahedralization
} //end namespace Modelisation
} //end namespace Algo
} //end namespace CGoGN
} // namespace Algo
} // namespace CGoGN
#include "Algo/Modelisation/tetrahedralization.hpp"
#endif
......@@ -22,8 +22,6 @@
* *
*******************************************************************************/
#include <list>
namespace CGoGN
{
......@@ -57,60 +55,47 @@ void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d)
template <typename PFP>
bool isTetrahedron(typename PFP::MAP& the_map, Dart d)
{
DartMarkerStore mark(*the_map); // Lock a marker
bool isTetrahedron = true; // Last return value
DartMarkerStore mark(the_map); // Lock a marker
std::list<Dart> visitedFaces; // Faces that are traversed
std::vector<Dart> visitedFaces; // Faces that are traversed
visitedFaces.reserve(64) ;
visitedFaces.push_back(d);
std::list<Dart>::iterator faces;
int nbFaces = 0; // Count the faces
unsigned int nbFaces = 0; // Count the faces
//Test the number of faces end its valency
for(faces = visitedFaces.begin() ; isTetrahedron && faces != visitedFaces.end() ; ++faces)
for(unsigned int i = 0; i < visitedFaces.size(); ++i)
{
Dart dc = *faces;
Dart dc = visitedFaces[i];
//if this dart is not marked
if(!mark.isMarked(dc))
{
//increase the number of faces
nbFaces++;
if(nbFaces > 4) //too much faces
return false;
//test the valency of this face
if(dc != the_map.phi1(the_map.phi1(the_map.phi1(dc))))
isTetrahedron = false;
else
return false;
//mark the face and push adjacent faces
Dart d1 = dc;
for(unsigned int i = 0; i <3 ; ++i)
{
//mark them
mark.markOrbit(DART,dc);
mark.mark(d1);
//if phi2 not marked
if(!mark.markOrbit(DART, the_map.phi2(dc)))
visitedFaces.push_back(the_map.phi2(dc));
//increase the number of faces
nbFaces++;
//too much faces
if(nbFaces > 4)
isTetrahedron = false;
// or count the size of the face
else
{
mark.markOrbit(DART, the_map.phi1(dc));
//if phi12 not marked
if(!mark.markOrbit(DART, the_map.phi2(the_map.phi1(dc))))
visitedFaces.push_back(the_map.phi2(the_map.phi1(dc)));
mark.markOrbit(DART, the_map.phi_1(dc));
//if phi_12 not marked
if(!mark.markOrbit(DART, the_map.phi2(the_map.phi_1(dc))))
visitedFaces.push_back(the_map.phi2(the_map.phi_1(dc)));
}
Dart d2 = the_map.phi2(d1);
if(!mark.isMarked(d2))
visitedFaces.push_back(d2);
d1 = the_map.phi1(dc);
}
}
}
//nettoyage
mark.unmarkAll();
return isTetrahedron;
return true;
}
/************************************************************************************************
......@@ -214,6 +199,7 @@ void insertFace(typename PFP::MAP& map, Dart d, Dart nF)
/***********************************************************************************************
* swap functions *
***********************************************************************************************/
//ok
template <typename PFP>
void swap2To2(typename PFP::MAP& map, Dart d)
......@@ -272,8 +258,8 @@ void swap4To4(typename PFP::MAP& map, Dart d)
map.unsewVolumes(d);
map.unsewVolumes(map.phi2(map.phi3(dd)));
Algo::Modelisation::Tetrahedron::swap2To2<PFP>(map, dd);
Algo::Modelisation::Tetrahedron::swap2To2<PFP>(map, e);
Algo::Modelisation::Tetrahedralization::swap2To2<PFP>(map, dd);
Algo::Modelisation::Tetrahedralization::swap2To2<PFP>(map, e);
//sew middle darts so that they do not cross
map.sewVolumes(d,map.phi2(map.phi3(e)));
......@@ -348,8 +334,6 @@ void swap3To2(typename PFP::MAP& map, Dart d)
}
//[precond] le brin doit venir d'une face partagé par 2 tetraèdres
// renvoie un brin de l'ancienne couture entre les 2 tetras qui est devenu une arête
template <typename PFP>
......@@ -417,7 +401,6 @@ void swap5To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positions)
* Flip Functions *
************************************************************************************************/
template <typename PFP>
void flip1To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
......@@ -501,8 +484,9 @@ void flip1To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
}
/************************************************************************************************
* Bisection Functions *
* Bisection Functions *
************************************************************************************************/
template <typename PFP>
void edgeBisection(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
......@@ -571,7 +555,6 @@ void edgeBisection(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
}
while(temp != d);
// if(map.phi3(d) == d)
// {
// map.splitFace(map.phi_1(d), map.phi1(d));
......@@ -644,10 +627,9 @@ void edgeBisection(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
// temp = map.alpha2(temp);
// }
// while(temp != d);
}
//
///**
// * create a tetra based on the two triangles that have a common dart and phi2(dart)
// * return a new dart inside the tetra
......@@ -688,8 +670,6 @@ void edgeBisection(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
// the_map.sewFaces(the_map.phi1(e),the_map.phi1(dd));
// the_map.sewFaces(ss2e,the_map.phi3(the_map.phi1(dd)));
//
//
//
// //embed the coords
// the_map.setVertexEmb(d,the_map.getVertexEmb(d));
// the_map.setVertexEmb(e,the_map.getVertexEmb(e));
......@@ -889,10 +869,10 @@ void edgeBisection(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
// return ret;
//}
} // namespace Tetrahedralization
}//end namespace Tetrahedralization
}//end namespace Modelisation
}//end namespace Algo
}//end namespace CGoGN
} // namespace Modelisation
} // namespace Algo
} // namespace CGoGN
......@@ -25,18 +25,20 @@
#ifndef _CGOGN_TRIANGULATION_H_
#define _CGOGN_TRIANGULATION_H_
#include <math.h>
#include <vector>
#include <list>
#include <set>
#include <utility>
#include "Algo/Geometry/normal.h"
namespace CGoGN
{
namespace Algo
{
namespace Modelisation
{
......@@ -44,7 +46,6 @@ template <typename PFP>
class EarTriangulation
{
protected:
// forward declaration
class VertexPoly;
......@@ -59,11 +60,16 @@ protected:
Dart dart;
float angle;
float length;
VertexPoly() {}
VertexPoly(Dart d, float v, float l): dart(d),angle(v),length(l) {}
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)
if (fabs(vp1.angle - vp2.angle) < 0.2f)
return vp1.length < vp2.length;
return vp1.angle < vp2.angle;
}
......@@ -86,24 +92,24 @@ protected:
public:
EarTriangulation(typename PFP::MAP& map):
m_map(map), m_dartEars(map,VERTEX)
EarTriangulation(typename PFP::MAP& map) : m_map(map), m_dartEars(map, VERTEX)
{
m_position = map.template getAttribute<typename PFP::VEC3>(VERTEX,"position");
}
// void trianguleFace( Dart d, DartMarker& mark);
void trianguleFace( Dart d);
// void trianguleFace(Dart d, DartMarker& mark);
void trianguleFace(Dart d);
void triangule(const FunctorSelect& good = allDarts, unsigned int thread=0);
void triangule(const FunctorSelect& good = allDarts, unsigned int thread = 0);
};
} // namespace Modelisation
} // namespace Algo