Commit 921efcb1 authored by untereiner's avatar untereiner

some changes

parent 71e149b3
This diff is collapsed.
...@@ -194,7 +194,12 @@ void MyQT::createMap(int n) ...@@ -194,7 +194,12 @@ void MyQT::createMap(int n)
m_render_topo->setDartWidth(4.0f); m_render_topo->setDartWidth(4.0f);
m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f); m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f);
m_render_topo->setInitialBoundaryDartsColor(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)) for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{ {
...@@ -213,7 +218,12 @@ void MyQT::createMap(int n) ...@@ -213,7 +218,12 @@ void MyQT::createMap(int n)
void MyQT::updateMap() void MyQT::updateMap()
{ {
m_render_topo->setInitialBoundaryDartsColor(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)) for (Dart d=myMap.begin(); d!=myMap.end(); myMap.next(d))
{ {
if (dm.isMarked(d) && (!myMap.isBoundaryMarked2(d))) if (dm.isMarked(d) && (!myMap.isBoundaryMarked2(d)))
...@@ -229,7 +239,11 @@ void MyQT::updateMap() ...@@ -229,7 +239,11 @@ void MyQT::updateMap()
void MyQT::cb_initGL() void MyQT::cb_initGL()
{ {
glClearColor(1.0f,1.0f,1.0f,1.0f); 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) // redraw GL callback (clear and swap already done)
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
//#define USE_GMAP //#define USE_GMAP
//#define PRIMAL_TOPO 1
#include "Topology/generic/parameters.h" #include "Topology/generic/parameters.h"
...@@ -36,8 +37,11 @@ ...@@ -36,8 +37,11 @@
#include "Topology/map/embeddedMap2.h" #include "Topology/map/embeddedMap2.h"
#endif #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 "ui_tuto_oper2.h"
#include "Utils/Qt/qtui.h" #include "Utils/Qt/qtui.h"
...@@ -88,7 +92,11 @@ protected: ...@@ -88,7 +92,11 @@ protected:
DartAttribute<VEC3> colorDarts; DartAttribute<VEC3> colorDarts;
// render (for the topo) // 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_selected;
Dart m_selected2; Dart m_selected2;
DartMarker dm; DartMarker dm;
......
This diff is collapsed.
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
//#define USE_GMAP //#define USE_GMAP
#define PRIMAL_TOPO 1
#include "Topology/generic/parameters.h" #include "Topology/generic/parameters.h"
...@@ -36,7 +37,12 @@ ...@@ -36,7 +37,12 @@
#include "Topology/map/embeddedMap3.h" #include "Topology/map/embeddedMap3.h"
#endif #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/Render/GL2/topoRender.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
...@@ -71,7 +77,7 @@ class MyQT: public Utils::QT::SimpleQT ...@@ -71,7 +77,7 @@ class MyQT: public Utils::QT::SimpleQT
{ {
Q_OBJECT Q_OBJECT
public: 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_redraw();
void cb_initGL(); void cb_initGL();
...@@ -95,12 +101,15 @@ protected: ...@@ -95,12 +101,15 @@ protected:
Geom::BoundingBox<PFP::VEC3> bb; Geom::BoundingBox<PFP::VEC3> bb;
// render (for the topo) // render (for the topo)
#ifdef PRIMAL_TOPO
Algo::Render::GL2::Topo3PrimalRender* m_render_topo;
#else
Algo::Render::GL2::Topo3Render* m_render_topo; Algo::Render::GL2::Topo3Render* m_render_topo;
#endif
Algo::Render::GL2::TopoRender* m_render_topo_boundary; Algo::Render::GL2::TopoRender* m_render_topo_boundary;
Dart m_selected; Dart m_selected;
Dart m_selected2; Dart m_selected2;
std::vector<Dart> m_selecteds; std::vector<Dart> m_selecteds;
DartMarker dm;
float m_shift; float m_shift;
float m_ex1, m_ex2, m_ex3; float m_ex1, m_ex2, m_ex3;
......
...@@ -150,6 +150,11 @@ ...@@ -150,6 +150,11 @@
<string>unsewVolumes</string> <string>unsewVolumes</string>
</property> </property>
</item> </item>
<item>
<property name="text">
<string>deleteVolume</string>
</property>
</item>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="6" column="0">
......
...@@ -1123,6 +1123,214 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, AttributeHandler<ty ...@@ -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> template <typename PFP>
void subdivideLoop(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position) 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 ...@@ -1152,7 +1360,7 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
{ {
//if needed subdivide face //if needed subdivide face
if(!map.faceIsSubdivided(dit)) 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 //save a dart from the subdivided face
unsigned int cur = map.getCurrentLevel() ; unsigned int cur = map.getCurrentLevel() ;
...@@ -1259,60 +1467,60 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP ...@@ -1259,60 +1467,60 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
} }
} }
//switch inner faces //switch inner faces
if(isNotTet) if(isNotTet)
{ {
DartMarker me(map); DartMarker me(map);
for(Dart dit = traV.begin(); dit != traV.end(); dit = traV.next()) for(Dart dit = traV.begin(); dit != traV.end(); dit = traV.next())
{ {
Dart x = map.phi_1(map.phi2(map.phi1(dit))); Dart x = map.phi_1(map.phi2(map.phi1(dit)));
Dart f = x; Dart f = x;
do do
{ {
Dart f3 = map.phi3(f); Dart f3 = map.phi3(f);
if(!me.isMarked(f3)) 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 tmp = map.phi_1(map.phi2(map.phi_1(map.phi2(map.phi_1(f3))))); //future voisin par phi2
Dart f32 = map.phi2(f3); Dart f32 = map.phi2(f3);
map.swapEdges(f3, tmp); map.swapEdges(f3, tmp);
unsigned int idface = map.getNewFaceId(); unsigned int idface = map.getNewFaceId();
map.setFaceId(f3,idface, FACE); map.setFaceId(f3,idface, FACE);
idface = map.getNewFaceId(); idface = map.getNewFaceId();
map.setFaceId(f32,idface, FACE); map.setFaceId(f32,idface, FACE);
unsigned int idedge = map.getNewEdgeId(); unsigned int idedge = map.getNewEdgeId();
map.setEdgeId(f3, idedge, EDGE); map.setEdgeId(f3, idedge, EDGE);
map.setEdgeId(f3,map.getEdgeId(f3), EDGE); map.setEdgeId(f3,map.getEdgeId(f3), EDGE);
map.setEdgeId(f32,map.getEdgeId(f32), EDGE); map.setEdgeId(f32,map.getEdgeId(f32), EDGE);
me.markOrbit<EDGE>(f3); me.markOrbit<EDGE>(f3);
me.markOrbit<EDGE>(f32); me.markOrbit<EDGE>(f32);
} }
f = map.phi2(map.phi_1(f)); f = map.phi2(map.phi_1(f));
}while(f != x); }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 //Third step : 3-sew internal faces
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it) for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
{ {
Dart f1 = (*it).first; Dart f1 = (*it).first;
Dart f2 = (*it).second; Dart f2 = (*it).second;
unsigned int idedge = map.getEdgeId(f1); unsigned int idedge = map.getEdgeId(f1);
map.setEdgeId(map.phi2(f1), idedge, EDGE); map.setEdgeId(map.phi2(f1), idedge, EDGE);
map.setEdgeId(map.phi2(f2), idedge, EDGE); map.setEdgeId(map.phi2(f2), idedge, EDGE);
} }
} }
map.setCurrentLevel(cur) ; map.setCurrentLevel(cur) ;
} }
......
...@@ -50,10 +50,11 @@ namespace Masks ...@@ -50,10 +50,11 @@ namespace Masks
/* MJ96 basic functions : polyhedral meshes /* MJ96 basic functions : polyhedral meshes
*********************************************************************************/ *********************************************************************************/
template <typename PFP, typename EMBV, typename EMB> template <typename PFP, typename EMBV>
class MJ96VertexVertexFunctor : public FunctorType class MJ96VertexVertexFunctor : public FunctorType
{ {
protected: protected:
typedef typename EMBV::DATA_TYPE EMB;
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
EMBV& m_attribut; EMBV& m_attribut;
//Algo::Volume::IHM::AttributeHandler_IHM<typename PFP::VEC3, VERTEX>& m_position ; //Algo::Volume::IHM::AttributeHandler_IHM<typename PFP::VEC3, VERTEX>& m_position ;
...@@ -118,7 +119,7 @@ public: ...@@ -118,7 +119,7 @@ public:
Traversor3VW<typename PFP::MAP> travVW(m_map, d); Traversor3VW<typename PFP::MAP> travVW(m_map, d);
for(Dart dit = travVW.begin() ; dit != travVW.end() ; dit = travVW.next()) 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; ++degree;
} }
Cavg /= degree; Cavg /= degree;
...@@ -128,7 +129,7 @@ public: ...@@ -128,7 +129,7 @@ public:
Traversor3VF<typename PFP::MAP> travVF(m_map, d); Traversor3VF<typename PFP::MAP> travVF(m_map, d);
for(Dart dit = travVF.begin() ; dit != travVF.end() ; dit = travVF.next()) 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; ++degree;
} }
Aavg /= degree; Aavg /= degree;
...@@ -156,10 +157,11 @@ public: ...@@ -156,10 +157,11 @@ public:
} }
}; };
template <typename PFP, typename EMBV, typename EMB> template <typename PFP, typename EMBV>
class MJ96EdgeVertexFunctor : public FunctorType class MJ96EdgeVertexFunctor : public FunctorType
{ {