Commit 9ec64050 authored by Sylvain Thery's avatar Sylvain Thery
Browse files

Merge cgogn:~untereiner/CGoGN

parents fb9c7943 c6ed99c2
This diff is collapsed.
......@@ -194,7 +194,12 @@ void MyQT::createMap(int n)
m_render_topo->setDartWidth(4.0f);
m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f);
m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true); // nb
#ifdef PRIMAL_TOPO
m_render_topo->updateData<PFP>(myMap, position, 0.9);
#else
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true);
#endif
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{
......@@ -213,7 +218,12 @@ void MyQT::createMap(int n)
void MyQT::updateMap()
{
m_render_topo->setInitialBoundaryDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true); // nb
#ifdef PRIMAL_TOPO
m_render_topo->updateData<PFP>(myMap, position, 0.9);
#else
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f,true);
#endif
for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{
if (dm.isMarked(d) && (!myMap.isBoundaryMarked2(d)))
......@@ -229,7 +239,11 @@ void MyQT::updateMap()
void MyQT::cb_initGL()
{
glClearColor(1.0f,1.0f,1.0f,1.0f);
m_render_topo = new Algo::Render::GL2::TopoRender(0.01f) ;
#ifdef PRIMAL_TOPO
m_render_topo = new Algo::Render::GL2::TopoPrimalRender() ;
#else
m_render_topo = new Algo::Render::GL2::TopoRender(0.01f) ;
#endif
}
// redraw GL callback (clear and swap already done)
......
......@@ -27,6 +27,7 @@
//#define USE_GMAP
//#define PRIMAL_TOPO 1
#include "Topology/generic/parameters.h"
......@@ -36,8 +37,11 @@
#include "Topology/map/embeddedMap2.h"
#endif
#include "Algo/Render/GL2/topoRender.h"
#ifdef PRIMAL_TOPO
#include "Algo/Render/GL2/topoPrimalRender.h"
#else
#include "Algo/Render/GL2/topoRender.h"
#endif
#include "ui_tuto_oper2.h"
#include "Utils/Qt/qtui.h"
......@@ -88,7 +92,11 @@ protected:
DartAttribute<VEC3> colorDarts;
// render (for the topo)
Algo::Render::GL2::TopoRender* m_render_topo;
#ifdef PRIMAL_TOPO
Algo::Render::GL2::TopoPrimalRender* m_render_topo;
#else
Algo::Render::GL2::TopoRender* m_render_topo;
#endif
Dart m_selected;
Dart m_selected2;
DartMarker dm;
......
This diff is collapsed.
......@@ -27,6 +27,7 @@
//#define USE_GMAP
//#define PRIMAL_TOPO 1
#include "Topology/generic/parameters.h"
......@@ -36,7 +37,12 @@
#include "Topology/map/embeddedMap3.h"
#endif
#include "Algo/Render/GL2/topo3Render.h"
#ifdef PRIMAL_TOPO
#include "Algo/Render/GL2/topo3PrimalRender.h"
#else
#include "Algo/Render/GL2/topo3Render.h"
#endif
#include "Algo/Render/GL2/topoRender.h"
#include "Algo/Geometry/boundingbox.h"
......@@ -71,7 +77,7 @@ class MyQT: public Utils::QT::SimpleQT
{
Q_OBJECT
public:
MyQT():m_render_topo(NULL),m_selected(NIL),m_selected2(NIL),dm(myMap),m_shift(0.01f),m_ex1(0.9f),m_ex2(0.9f),m_ex3(0.9f), clip_volume(true) , hide_clipping(false) {}
MyQT():m_render_topo(NULL),m_selected(NIL),m_selected2(NIL),m_shift(0.01f),m_ex1(0.9f),m_ex2(0.9f),m_ex3(0.9f), clip_volume(true) , hide_clipping(false) {}
void cb_redraw();
void cb_initGL();
......@@ -95,12 +101,15 @@ protected:
Geom::BoundingBox<PFP::VEC3> bb;
// render (for the topo)
#ifdef PRIMAL_TOPO
Algo::Render::GL2::Topo3PrimalRender* m_render_topo;
#else
Algo::Render::GL2::Topo3Render* m_render_topo;
#endif
Algo::Render::GL2::TopoRender* m_render_topo_boundary;
Dart m_selected;
Dart m_selected2;
std::vector<Dart> m_selecteds;
DartMarker dm;
float m_shift;
float m_ex1, m_ex2, m_ex3;
......@@ -136,6 +145,7 @@ protected:
public:
// example of simple map creation
void createMap(int n);
void createMapTets();
void updateMap();
void importMesh(std::string& filename);
......
......@@ -150,6 +150,11 @@
<string>unsewVolumes</string>
</property>
</item>
<item>
<property name="text">
<string>deleteVolume</string>
</property>
</item>
</widget>
</item>
<item row="6" column="0">
......
......@@ -1123,6 +1123,214 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, AttributeHandler<ty
}
template <typename PFP>
void subdivideEdgeLoop(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(!map.edgeIsSubdivided(d) || !"Trying to subdivide an already subdivided edge") ;
assert(!map.isBoundaryMarked3(d) || !"Trying to subdivide a dart marked boundary");
unsigned int eLevel = map.edgeLevel(d) ;
unsigned int cur = map.getCurrentLevel() ;
map.setCurrentLevel(eLevel) ;
Dart dd = map.phi2(d) ;
typename PFP::VEC3 p1 = position[d] ;
typename PFP::VEC3 p2 = position[map.phi1(d)] ;
map.setCurrentLevel(eLevel + 1) ;
map.cutEdge(d) ;
unsigned int eId = map.getEdgeId(d) ;
map.setEdgeId(map.phi1(d), eId, EDGE) ; //mise a jour de l'id d'arrete sur chaque moitie d'arete
map.setEdgeId(map.phi1(dd), eId, EDGE) ;
map.setFaceId(EDGE, d) ; //mise a jour de l'id de face sur chaque brin de chaque moitie d'arete
map.setFaceId(EDGE, dd) ;
position[map.phi1(d)] = (p1 + p2) * typename PFP::REAL(0.5) ;
map.setCurrentLevel(cur) ;
}
template <typename PFP>
void subdivideFaceLoop(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position, SubdivideType sType)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(!map.faceIsSubdivided(d) || !"Trying to subdivide an already subdivided face") ;
assert(!map.isBoundaryMarked3(d) || !"Trying to subdivide a dart marked boundary");
unsigned int fLevel = map.faceLevel(d) ;
Dart old = map.faceOldestDart(d) ;
unsigned int cur = map.getCurrentLevel() ;
map.setCurrentLevel(fLevel) ; // go to the level of the face to subdivide its edges
unsigned int vLevel = map.volumeLevel(old);
//one level of subdivision in the neighbordhood
// Traversor3VW<typename PFP::MAP> trav3EW(map, old);
// for(Dart dit = trav3EW.begin() ; dit != trav3EW.end() ; dit = trav3EW.next())
// {
// Dart oldit = map.volumeOldestDart(dit);
//
// //std::cout << "vLevel courant = " << map.volumeLevel(oldit) << std::endl;
//
// if(((vLevel+1) - map.volumeLevel(oldit)) > 1)
// IHM::subdivideVolumeClassic<PFP>(map, oldit, position);
// }
unsigned int degree = 0 ;
typename PFP::VEC3 p ;
Traversor2FE<typename PFP::MAP> travE(map, old);
for(Dart it = travE.begin(); it != travE.end() ; it = travE.next())
{
++degree;
p += position[it] ;
if(!map.edgeIsSubdivided(it)) // first cut the edges (if they are not already)
IHM::subdivideEdgeLoop<PFP>(map, it, position) ; // and compute the degree of the face
}
p /= typename PFP::REAL(degree) ;
map.setCurrentLevel(fLevel + 1) ; // go to the next level to perform face subdivision
Dart res;
if(degree == 3 && sType == IHM::S_TRI) //subdiviser une face triangulaire
{
Dart dd = map.phi1(old) ;
Dart e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ; // insert a new edge
unsigned int id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ; // set the edge id of the inserted edge to the next available id
unsigned int idface = map.getFaceId(old);
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
dd = e ;
e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ;
id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ;
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
dd = e ;
e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ;
id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ;
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
Dart stop = map.phi2(map.phi1(old));
Dart dit = stop;
do
{
unsigned int dId = map.getEdgeId(map.phi_1(map.phi2(dit)));
unsigned int eId = map.getEdgeId(map.phi1(map.phi2(dit)));
unsigned int t = dId + eId;
if(t == 0)
{
map.setEdgeId(dit, 1, EDGE) ;
map.setEdgeId(map.phi2(dit), 1, EDGE) ;
}
else if(t == 1)
{
map.setEdgeId(dit, 2, EDGE) ;
map.setEdgeId(map.phi2(dit), 2, EDGE) ;
}
else if(t == 2)
{
if(dId == eId)
{
map.setEdgeId(dit, 0, EDGE) ;
map.setEdgeId(map.phi2(dit), 0, EDGE) ;
}
else
{
map.setEdgeId(dit, 1, EDGE) ;
map.setEdgeId(map.phi2(dit), 1, EDGE) ;
}
}
else if(t == 3)
{
map.setEdgeId(dit, 0, EDGE) ;
map.setEdgeId(map.phi2(dit), 0, EDGE) ;
}
dit = map.phi1(dit);
}while(dit != stop);
}
else
{
Dart dd = map.phi1(old) ;
map.splitFace(dd, map.phi1(map.phi1(dd))) ;
Dart ne = map.phi2(map.phi_1(dd));
Dart ne2 = map.phi2(ne);
map.cutEdge(ne) ;
unsigned int id = map.getNewEdgeId() ;
map.setEdgeId(ne, id, EDGE) ;
id = map.getNewEdgeId() ;
map.setEdgeId(ne2, id, EDGE) ;
position[map.phi1(ne)] = p ;
dd = map.phi1(map.phi1(map.phi1(map.phi1(ne)))) ;
while(dd != ne)
{
Dart next = map.phi1(map.phi1(dd)) ;
map.splitFace(map.phi1(ne), dd) ;
Dart nne = map.phi2(map.phi_1(dd)) ;
id = map.getNewEdgeId() ;
map.setEdgeId(nne, id, EDGE) ;
dd = next ;
}
unsigned int idface = map.getFaceId(old);
//Dart e = dd;
do
{
map.setFaceId(dd, idface, DART) ;
map.setFaceId(map.phi2(dd), idface, DART) ;
dd = map.phi2(map.phi1(dd));
}
while(dd != ne);
position[map.phi1(ne)] = p ;
}
map.setCurrentLevel(cur) ;
}
template <typename PFP>
void subdivideLoop(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
......@@ -1152,7 +1360,7 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
{
//if needed subdivide face
if(!map.faceIsSubdivided(dit))
IHM::subdivideFace<PFP>(map, dit, position, IHM::S_TRI);
IHM::subdivideFaceLoop<PFP>(map, dit, position, IHM::S_TRI);
//save a dart from the subdivided face
unsigned int cur = map.getCurrentLevel() ;
......@@ -1259,60 +1467,60 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
}
}
//switch inner faces
if(isNotTet)
{
DartMarker me(map);
//switch inner faces
if(isNotTet)
{
DartMarker me(map);
for(Dart dit = traV.begin(); dit != traV.end(); dit = traV.next())
{
Dart x = map.phi_1(map.phi2(map.phi1(dit)));
Dart f = x;
for(Dart dit = traV.begin(); dit != traV.end(); dit = traV.next())
{
Dart x = map.phi_1(map.phi2(map.phi1(dit)));
Dart f = x;
do
{
Dart f3 = map.phi3(f);
do
{
Dart f3 = map.phi3(f);
if(!me.isMarked(f3))
{
Dart tmp = map.phi_1(map.phi2(map.phi_1(map.phi2(map.phi_1(f3))))); //future voisin par phi2
if(!me.isMarked(f3))
{
Dart tmp = map.phi_1(map.phi2(map.phi_1(map.phi2(map.phi_1(f3))))); //future voisin par phi2
Dart f32 = map.phi2(f3);
map.swapEdges(f3, tmp);
Dart f32 = map.phi2(f3);
map.swapEdges(f3, tmp);
unsigned int idface = map.getNewFaceId();
map.setFaceId(f3,idface, FACE);
idface = map.getNewFaceId();
map.setFaceId(f32,idface, FACE);
unsigned int idface = map.getNewFaceId();
map.setFaceId(f3,idface, FACE);
idface = map.getNewFaceId();
map.setFaceId(f32,idface, FACE);
unsigned int idedge = map.getNewEdgeId();
map.setEdgeId(f3, idedge, EDGE);
unsigned int idedge = map.getNewEdgeId();
map.setEdgeId(f3, idedge, EDGE);
map.setEdgeId(f3,map.getEdgeId(f3), EDGE);
map.setEdgeId(f32,map.getEdgeId(f32), EDGE);
map.setEdgeId(f3,map.getEdgeId(f3), EDGE);
map.setEdgeId(f32,map.getEdgeId(f32), EDGE);
me.markOrbit<EDGE>(f3);
me.markOrbit<EDGE>(f32);
}
me.markOrbit<EDGE>(f3);
me.markOrbit<EDGE>(f32);
}
f = map.phi2(map.phi_1(f));
}while(f != x);
}
f = map.phi2(map.phi_1(f));
}while(f != x);
}
map.template setOrbitEmbedding<VERTEX>(centralDart, map.template getEmbedding<VERTEX>(centralDart));
map.template setOrbitEmbedding<VERTEX>(centralDart, map.template getEmbedding<VERTEX>(centralDart));
//Third step : 3-sew internal faces
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
{
Dart f1 = (*it).first;
Dart f2 = (*it).second;
//Third step : 3-sew internal faces
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
{
Dart f1 = (*it).first;
Dart f2 = (*it).second;
unsigned int idedge = map.getEdgeId(f1);
map.setEdgeId(map.phi2(f1), idedge, EDGE);
map.setEdgeId(map.phi2(f2), idedge, EDGE);
}
unsigned int idedge = map.getEdgeId(f1);
map.setEdgeId(map.phi2(f1), idedge, EDGE);
map.setEdgeId(map.phi2(f2), idedge, EDGE);
}
}
}
map.setCurrentLevel(cur) ;
}
......
......@@ -529,9 +529,11 @@ Dart flip1To3(typename PFP::MAP& map, Dart d)
edges.push_back(dit);
map.splitVolume(edges);
map.splitFace(map.phi1(map.phi2(edges[0])),map.phi1(map.phi2(edges[2])));
// Cut the 2nd Tetrahedron
map.splitFace(map.phi1(map.phi2(edges[0])),map.phi1(map.phi2(edges[2])));
// Cut the 3rd Tetrahedron
dit = map.phi1(map.phi2(edges[0]));
edges.clear();
edges.push_back(dit);
......
......@@ -50,10 +50,11 @@ namespace Masks
/* MJ96 basic functions : polyhedral meshes
*********************************************************************************/
template <typename PFP, typename EMBV, typename EMB>
template <typename PFP, typename EMBV>
class MJ96VertexVertexFunctor : public FunctorType
{
protected:
typedef typename EMBV::DATA_TYPE EMB;
typename PFP::MAP& m_map ;
EMBV& m_attribut;
//Algo::Volume::IHM::AttributeHandler_IHM<typename PFP::VEC3, VERTEX>& m_position ;
......@@ -118,7 +119,7 @@ public:
Traversor3VW<typename PFP::MAP> travVW(m_map, d);
for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next())
{
Cavg += Algo::Surface::Geometry::volumeCentroidGen<PFP, EMBV, EMB>(m_map, dit, m_attribut);
Cavg += Algo::Surface::Geometry::volumeCentroid<PFP, EMBV>(m_map, dit, m_attribut);
++degree;
}
Cavg /= degree;
......@@ -128,7 +129,7 @@ public:
Traversor3VF<typename PFP::MAP> travVF(m_map, d);
for(Dart dit = travVF.begin() ; dit != travVF.end() ; dit = travVF.next())
{
Aavg += Algo::Surface::Geometry::faceCentroidGen<PFP, EMBV, EMB>(m_map, dit, m_attribut);
Aavg += Algo::Surface::Geometry::faceCentroid<PFP, EMBV>(m_map, dit, m_attribut);
++degree;
}
Aavg /= degree;
......@@ -156,10 +157,11 @@ public:
}
};
template <typename PFP, typename EMBV, typename EMB>
template <typename PFP, typename EMBV>
class MJ96EdgeVertexFunctor : public FunctorType
{
protected:
typedef typename EMBV::DATA_TYPE EMB;
typename PFP::MAP& m_map ;
EMBV& m_attribut;
//Algo::Volume::IHM::AttributeHandler_IHM<typename PFP::VEC3, VERTEX>& m_position ;
......@@ -217,7 +219,7 @@ public:
Traversor3EW<typename PFP::MAP> travEW(m_map, d2);
for(Dart dit = travEW.begin() ; dit != travEW.end() ; dit = travEW.next())
{
Cavg += Algo::Surface::Geometry::volumeCentroidGen<PFP, EMBV, EMB>(m_map, dit, m_attribut);
Cavg += Algo::Surface::Geometry::volumeCentroid<PFP, EMBV>(m_map, dit, m_attribut);
++degree;
}
Cavg /= degree;
......@@ -227,7 +229,7 @@ public:
Traversor3EF<typename PFP::MAP> travEF(m_map, d2);
for(Dart dit = travEF.begin() ; dit != travEF.end() ; dit = travEF.next())
{
Aavg += Algo::Surface::Geometry::faceCentroidGen<PFP, EMBV, EMB>(m_map, dit, m_attribut);
Aavg += Algo::Surface::Geometry::faceCentroid<PFP, EMBV>(m_map, dit, m_attribut);
++degree;
}
Aavg /= degree;
......@@ -247,10 +249,11 @@ public:
}
};
template <typename PFP, typename EMBV, typename EMB>
template <typename PFP, typename EMBV>
class MJ96FaceVertexFunctor : public FunctorType
{
protected:
typedef typename EMBV::DATA_TYPE EMB;
typename PFP::MAP& m_map ;
EMBV& m_attribut;
//Algo::Volume::IHM::AttributeHandler_IHM<typename PFP::VEC3, VERTEX>& m_position ;
......@@ -291,10 +294,10 @@ public:
m_map.decCurrentLevel() ;
//face points
EMB C0 = Algo::Surface::Geometry::volumeCentroidGen<PFP, EMBV, EMB>(m_map, df, m_attribut);
EMB C1 = Algo::Surface::Geometry::volumeCentroidGen<PFP, EMBV, EMB>(m_map, m_map.phi3(df), m_attribut);
EMB C0 = Algo::Surface::Geometry::volumeCentroid<PFP, EMBV>(m_map, df, m_attribut);
EMB C1 = Algo::Surface::Geometry::volumeCentroid<PFP, EMBV>(m_map, m_map.phi3(df), m_attribut);
EMB A = Algo::Surface::Geometry::faceCentroidGen<PFP, EMBV, EMB>(m_map, df, m_attribut);
EMB A = Algo::Surface::Geometry::faceCentroid<PFP, EMBV>(m_map, df, m_attribut);
EMB fp = C0 + A * 2 + C1;
fp /= 4;
......@@ -309,10 +312,11 @@ public:
};
template <typename PFP, typename EMBV, typename EMB>
template <typename PFP, typename EMBV>
class MJ96VolumeVertexFunctor : public FunctorType
{
protected:
typedef typename EMBV::DATA_TYPE EMB;
typename PFP::MAP& m_map ;
EMBV& m_attribut;
//Algo::Volume::IHM::AttributeHandler_IHM<typename PFP::VEC3, VERTEX>& m_position ;
......@@ -332,7 +336,7 @@ public:
//cell points : these points are the average of the
//vertices of the lattice that bound the cell
EMB p = Algo::Surface::Geometry::volumeCentroidGen<PFP, EMBV, EMB>(m_map,df,m_attribut);
EMB p = Algo::Surface::Geometry::volumeCentroid<PFP, EMBV>(m_map,df,m_attribut);
m_map.incCurrentLevel() ;
......
......@@ -90,6 +90,8 @@ public:
void swapEdges(Dart d, Dart e);
Dart swap2To2(Dart d);
void swap4To4(Dart d);
Dart swap2To3(Dart d);
void swapGen3To2(Dart d);
......
......@@ -171,6 +171,61 @@ Dart Map3MR<PFP>::swap2To3(Dart d)
return m_map.phi1(d2_1);