Commit 2fd71161 authored by untereiner's avatar untereiner
Browse files

modifs on subdivision3 (allow prism subdiv)

parent 56d8c1e8
......@@ -857,7 +857,7 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename P
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(!map.volumeIsSubdivided(d) || !"Trying to subdivide an already subdivided volume") ;
assert(!map.neighborhoodLevelDiffersByOne(d) || !"Trying to subdivide a volume with neighborhood Level difference greater than 1");
//assert(!map.neighborhoodLevelDiffersByOne(d) || !"Trying to subdivide a volume with neighborhood Level difference greater than 1");
unsigned int vLevel = map.volumeLevel(d);
Dart old = map.volumeOldestDart(d);
......@@ -965,8 +965,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename P
subdividedfaces.push_back(std::pair<char, std::pair<Dart,Dart> >('q',pd));
e = map.phi2(map.phi1(e));
}while (e != cf);
}
map.setCurrentLevel(cur);
......@@ -978,8 +976,12 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename P
std::vector<Dart> newEdges; //save darts from inner edges
newEdges.reserve(50);
bool istet = true;
bool isocta = false;
bool ishex = false;
bool isprism = false;
bool ispyra = false;
Dart centralDart = NIL;
//Second step : deconnect each corner, close each hole, subdivide each new face into 3
for (std::vector<Dart>::iterator edge = oldEdges.begin(); edge != oldEdges.end(); ++edge)
......@@ -1003,153 +1005,258 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename P
map.splitVolume(v) ;
//fonction qui calcule le degree max des faces atour d'un sommet
unsigned int fdeg = map.faceDegree(map.phi2(f1));
if(fdeg == 3)
{
unsigned int idface = map.getNewFaceId();
map.setFaceId(map.phi2(f1),idface, FACE);
}
else if(fdeg == 4)
{
std::cout << "== 4" << std::endl;
if(map.PFP::MAP::ParentMap::vertexDegree(*edge) == 3)
{
isocta = false;
ispyra = true;
std::cout << "pyra" << std::endl;
Dart it = *edge;
if((map.faceDegree(it) == 3) && (map.faceDegree(map.phi2(it))) == 3)
{
it = map.phi2(map.phi_1(it));
}
else if((map.faceDegree(it) == 3) && (map.faceDegree(map.phi2(it)) == 4))
{
it = map.phi1(map.phi2(it));
}
Dart old = map.phi2(map.phi1(it));
Dart dd = map.phi1(map.phi1(old));
map.splitFace(old,dd) ;
centralDart = old;
newEdges.push_back(map.phi_1(old));
}
else
{
isocta = true;
std::cout << "octa" << std::endl;
Dart old = map.phi2(map.phi1(*edge));
Dart dd = map.phi1(old) ;
map.splitFace(old,dd) ;
Dart ne = map.phi1(old);
map.cutEdge(ne);
position[map.phi1(ne)] = volCenter; //plonger a la fin de la boucle ????
centralDart = map.phi1(ne);
newEdges.push_back(ne);
newEdges.push_back(map.phi1(ne));
Dart stop = map.phi2(map.phi1(ne));
ne = map.phi2(ne);
do
{
dd = map.phi1(map.phi1(ne));
map.splitFace(ne, dd) ;
newEdges.push_back(map.phi1(dd));
ne = map.phi2(map.phi_1(ne));
dd = map.phi1(dd);
}
while(dd != stop);
}
}
else if(fdeg == 5)
{
std::cout << "== 5" << std::endl;
isprism = true;
Dart it = *edge;
if(map.faceDegree(it) == 3)
{
it = map.phi2(map.phi_1(it));
}
else if(map.faceDegree(map.phi2(map.phi_1(*edge))) == 3)
{
it = map.phi2(map.phi_1(map.phi2(map.phi_1(it))));
}
Dart old = map.phi2(map.phi1(it));
Dart dd = map.phi_1(map.phi_1(old));
map.splitFace(old,dd) ;
newEdges.push_back(map.phi_1(dd));
}
else if(fdeg == 6)
{
std::cout << "== 6" << std::endl;
ishex = true;
Dart old = map.phi2(map.phi1(e));
Dart dd = map.phi1(map.phi1(old)) ;
map.splitFace(old,dd) ;
Dart ne = map.phi1(map.phi1(old)) ;
map.cutEdge(ne);
position[map.phi1(ne)] = volCenter; //plonger a la fin de la boucle ????
newEdges.push_back(ne);
newEdges.push_back(map.phi1(ne));
// //fonction qui calcule le degree max des faces atour d'un sommet
// unsigned int fdeg = map.faceDegree(map.phi2(f1));
//
// if(fdeg > 4)
// {
// std::cout << "> 4" << std::endl;
//
// ishex = true;
//
// Dart old = map.phi2(map.phi1(e));
// Dart dd = map.phi1(map.phi1(old)) ;
// map.splitFace(old,dd) ;
//
// Dart ne = map.phi1(map.phi1(old)) ;
//
// map.cutEdge(ne);
// position[map.phi1(ne)] = volCenter; //plonger a la fin de la boucle ????
// newEdges.push_back(ne);
// newEdges.push_back(map.phi1(ne));
//
//
// Dart stop = map.phi2(map.phi1(ne));
// ne = map.phi2(ne);
// do
// {
// dd = map.phi1(map.phi1(map.phi1(ne)));
//
// //A Verifier !!
// map.splitFace(ne, dd) ;
//
// newEdges.push_back(map.phi1(dd));
//
// ne = map.phi2(map.phi_1(ne));
// dd = map.phi1(map.phi1(dd));
// }
// while(dd != stop);
// }
// else if(fdeg > 3)
// {
// std::cout << "> 3" << std::endl;
//
// //map.closeHole(f2);
// //map.sewVolumes(map.phi2(f1),map.phi2(f2));
// istet = false;
//
// Dart old = map.phi2(map.phi1(*edge));
// Dart dd = map.phi1(old) ;
// map.splitFace(old,dd) ;
//
// Dart ne = map.phi1(old);
//
// map.cutEdge(ne);
// position[map.phi1(ne)] = volCenter; //plonger a la fin de la boucle ????
// newEdges.push_back(ne);
// newEdges.push_back(map.phi1(ne));
//
// Dart stop = map.phi2(map.phi1(ne));
// ne = map.phi2(ne);
// do
// {
// dd = map.phi1(map.phi1(ne));
//
// map.splitFace(ne, dd) ;
//
// newEdges.push_back(map.phi1(dd));
//
// ne = map.phi2(map.phi_1(ne));
// dd = map.phi1(dd);
// }
// while(dd != stop);
// }
// else
// {
// //map.closeHole(f2);
// //map.sewVolumes(map.phi2(f1),map.phi2(f2));
//
// unsigned int idface = map.getNewFaceId();
// map.setFaceId(map.phi2(f1),idface, FACE);
// }
Dart stop = map.phi2(map.phi1(ne));
ne = map.phi2(ne);
do
{
dd = map.phi1(map.phi1(map.phi1(ne)));
//A Verifier !!
map.splitFace(ne, dd) ;
newEdges.push_back(map.phi1(dd));
ne = map.phi2(map.phi_1(ne));
dd = map.phi1(map.phi1(dd));
}
while(dd != stop);
}
break;
}
if(ishex)
{
map.deleteVolume(map.phi3(map.phi2(map.phi1(oldEdges.front()))));
//
// //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;
//
// //FAIS a la couture !!!!!!!
// //id pour toutes les aretes exterieurs des faces quadrangulees
// unsigned int idedge = map.getEdgeId(f1);
// map.setEdgeId(map.phi2(f1), idedge, DART);
// map.setEdgeId( map.phi2(f2), idedge, DART);
//
// }
//
// //LA copie de L'id est a gerer avec le sewVolumes normalement !!!!!!
// //id pour les aretes interieurs : (i.e. 16 pour un octa)
// DartMarker mne(map);
// for(std::vector<Dart>::iterator it = newEdges.begin() ; it != newEdges.end() ; ++it)
// {
// if(!mne.isMarked(*it))
// {
// unsigned int idedge = map.getNewEdgeId();
// map.setEdgeId(*it, idedge, EDGE);
// mne.markOrbit<EDGE>(*it);
// }
// }
//Third step : 3-sew internal faces
for (std::vector<std::pair<char, std::pair<Dart,Dart> > >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
{
Dart f1 = map.phi2( ((*it).second).first );
Dart f2 = map.phi2( ((*it).second).second );
//if(map.phi3(map.phi2(f1)) == map.phi2(f1) && map.phi3(map.phi2(f2)) == map.phi2(f2))
//if(map.phi3(f1) == f1 && map.phi3(f2) == f2)
if(map.isBoundaryFace(f1) && map.isBoundaryFace(f2))
{
std::cout << "sewvolumes" << std::endl;
map.sewVolumes(f1, f2);
//id pour toutes les faces interieures
//map.sewVolumes(map.phi2(f1), map.phi2(f2));
//Fais a la couture !!!!!
unsigned int idface = map.getNewFaceId();
map.setFaceId(f1,idface, FACE);
}
//FAIS a la couture !!!!!!!
//id pour toutes les aretes exterieurs des faces quadrangulees
unsigned int idedge = map.getEdgeId(map.phi2(f1));
map.setEdgeId(f1, idedge, DART);
map.setEdgeId(f2, idedge, DART);
}
//LA copie de L'id est a gerer avec le sewVolumes normalement !!!!!!
//id pour les aretes interieurs : (i.e. 16 pour un octa)
DartMarker mne(map);
for(std::vector<Dart>::iterator it = newEdges.begin() ; it != newEdges.end() ; ++it)
{
if(!mne.isMarked(*it))
{
unsigned int idedge = map.getNewEdgeId();
map.setEdgeId(*it, idedge, EDGE);
mne.markOrbit<EDGE>(*it);
}
}
}
if(!istet)
if(isocta)
{
DartMarker me(map);
for (std::vector<Dart>::iterator edge = oldEdges.begin(); edge != oldEdges.end(); ++edge)
{
//Dart e = *edge;
Dart x = map.phi_1(map.phi2(map.phi1(*edge)));
Dart f = x;
do
{
Dart f3 = map.phi3(f);
Dart tmp = map.phi_1(map.phi2(map.phi_1(map.phi2(map.phi_1(f3)))));
map.unsewFaces(f3);
map.unsewFaces(tmp);
map.sewFaces(f3, tmp);
if(!me.isMarked(f3))
{
Dart tmp = map.phi_1(map.phi2(map.phi_1(map.phi2(map.phi_1(f3))))); //future voisin par phi2
unsigned int idface = map.getNewFaceId();
map.setFaceId(map.phi2(f3),idface, FACE);
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 idedge = map.getNewEdgeId();
map.setEdgeId(f3, idedge, EDGE);
map.setEdgeId(f3,map.getEdgeId(f3), EDGE);
map.setEdgeId(f32,map.getEdgeId(f32), EDGE);
me.markOrbit<EDGE>(f3);
me.markOrbit<EDGE>(f32);
}
f = map.phi2(map.phi_1(f));
}while(f != x);
}
map.template embedOrbit<VERTEX>(centralDart, map.template getEmbedding<VERTEX>(centralDart));
//Third step : 3-sew internal faces
for (std::vector<std::pair<char, std::pair<Dart,Dart> > >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
{
Dart f1 = map.phi2( ((*it).second).first );
Dart f2 = map.phi2( ((*it).second).second );
unsigned int idedge = map.getEdgeId(f1);
map.setEdgeId(f1, idedge, EDGE);
map.setEdgeId(f2, idedge, EDGE);
}
}
if(isprism)
{
//map.deleteVolume(map.phi3(map.phi2(map.phi1(oldEdges.front()))));
// for (std::vector<std::pair<char, std::pair<Dart,Dart> > >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
// {
// Dart f1 = map.phi2( ((*it).second).first );
// Dart f2 = map.phi2( ((*it).second).second );
// }
}
if(ispyra)
{
}
// {
......@@ -1226,6 +1333,84 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename P
}
// if(fdeg > 4)
// {
// std::cout << "> 4" << std::endl;
//
// ishex = true;
//
// Dart old = map.phi2(map.phi1(e));
// Dart dd = map.phi1(map.phi1(old)) ;
// map.splitFace(old,dd) ;
//
// Dart ne = map.phi1(map.phi1(old)) ;
//
// map.cutEdge(ne);
// position[map.phi1(ne)] = volCenter; //plonger a la fin de la boucle ????
// newEdges.push_back(ne);
// newEdges.push_back(map.phi1(ne));
//
//
// Dart stop = map.phi2(map.phi1(ne));
// ne = map.phi2(ne);
// do
// {
// dd = map.phi1(map.phi1(map.phi1(ne)));
//
// //A Verifier !!
// map.splitFace(ne, dd) ;
//
// newEdges.push_back(map.phi1(dd));
//
// ne = map.phi2(map.phi_1(ne));
// dd = map.phi1(map.phi1(dd));
// }
// while(dd != stop);
// }
// else if(fdeg > 3)
// {
// std::cout << "> 3" << std::endl;
//
// //map.closeHole(f2);
// //map.sewVolumes(map.phi2(f1),map.phi2(f2));
// istet = false;
//
// Dart old = map.phi2(map.phi1(*edge));
// Dart dd = map.phi1(old) ;
// map.splitFace(old,dd) ;
//
// Dart ne = map.phi1(old);
//
// map.cutEdge(ne);
// position[map.phi1(ne)] = volCenter; //plonger a la fin de la boucle ????
// newEdges.push_back(ne);
// newEdges.push_back(map.phi1(ne));
//
// Dart stop = map.phi2(map.phi1(ne));
// ne = map.phi2(ne);
// do
// {
// dd = map.phi1(map.phi1(ne));
//
// map.splitFace(ne, dd) ;
//
// newEdges.push_back(map.phi1(dd));
//
// ne = map.phi2(map.phi_1(ne));
// dd = map.phi1(dd);
// }
// while(dd != stop);
// }
// else
// {
// //map.closeHole(f2);
// //map.sewVolumes(map.phi2(f1),map.phi2(f2));
//
// unsigned int idface = map.getNewFaceId();
// map.setFaceId(map.phi2(f1),idface, FACE);
// }
template <typename PFP>
Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position)
{
......
......@@ -25,11 +25,12 @@
#ifndef __VPMESH__
#define __VPMESH__
#include "Algo/DecimationVolumes/operator.h"
#include "Algo/DecimationVolumes/selector.h"
#include "Algo/DecimationVolumes/edgeSelector.h"
#include "Algo/DecimationVolumes/geometryApproximator.h"
//#include "Algo/DecimationVolumes/geometryPredictor.h"
#include "Algo/VolumetricProgressiveMesh/vsplit.h"
#include "Algo/Decimation/selector.h"
#include "Algo/Decimation/edgeSelector.h"
#include "Algo/Decimation/geometryApproximator.h"
#include "Algo/Decimation/geometryPredictor.h"
#include "Utils/quantization.h"
......@@ -56,23 +57,22 @@ private:
DartMarker& inactiveMarker ;
SelectorUnmarked dartSelect ;
Algo::Decimation::EdgeSelector<PFP>* m_selector ;
std::vector<Algo::Decimation::ApproximatorGen<PFP>*> m_approximators ;
std::vector<Algo::Decimation::PredictorGen<PFP>*> m_predictors ;
std::vector<VSplit<PFP>*> m_splits ;
unsigned int m_cur ;
Algo::DecimationVolumes::EdgeSelector<PFP>* m_selector ;
std::vector<Algo::DecimationVolumes::ApproximatorGen<PFP>*> m_approximators ;
std::vector<Algo::DecimationVolumes::PredictorGen<PFP>*> m_predictors ;
Algo::DecimationVolumes::OperatorList<PFP>* m_nodes;
unsigned int m_level ;
Algo::DecimationVolumes::Approximator<PFP, VEC3>* m_positionApproximator ;
Algo::Decimation::Approximator<PFP, VEC3>* m_positionApproximator ;
bool m_initOk ;
public:
VolumetricProgressiveMesh(
MAP& map, DartMarker& inactive,
Algo::DecimationVolumes::SelectorType s, Algo::DecimationVolumes::ApproximatorType a,
VertexAttribute<typename PFP::VEC3>& position
MAP& map, DartMarker& inactive,
Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a,
VertexAttribute<typename PFP::VEC3>& position
) ;
~VolumetricProgressiveMesh() ;
......@@ -80,9 +80,21 @@ public:
bool initOk() { return m_initOk ; }
void createPM(unsigned int percentWantedVertices) ;
std::vector<VSplit<PFP>*>& splits() { return m_splits ; }
Algo::Decimation::EdgeSelector<PFP>* selector() { return m_selector ; }
std::vector<Algo::Decimation::ApproximatorGen<PFP>*>& approximators() { return m_approximators ; }
std::vector<Algo::Decimation::PredictorGen<PFP>*>& predictors() { return m_predictors ; }
void edgeCollapse(VSplit<PFP>* vs) ;
void vertexSplit(VSplit<PFP>* vs) ;
void coarsen() ;
void refine() ;
void gotoLevel(unsigned int l) ;
unsigned int& currentLevel() { return m_level ; }
unsigned int nbSplits() { return m_nodes.size() ; }
unsigned int& currentLevel() { return m_cur ; }
unsigned int nbSplits() { return m_splits.size() ; }
} ;
......
......@@ -36,7 +36,7 @@ namespace VPMesh
template <typename PFP>
VolumetricProgressiveMesh<PFP>::VolumetricProgressiveMesh(
MAP& map, DartMarker& inactive,
Algo::DecimationVolumes::SelectorType s, Algo::DecimationVolumes::ApproximatorType a,
Algo::Decimation::SelectorType s, Algo::Decimation::ApproximatorType a,
VertexAttribute<typename PFP::VEC3>& position
) :
m_map(map), positionsTable(position), inactiveMarker(inactive), dartSelect(inactiveMarker)
......@@ -44,9 +44,9 @@ VolumetricProgressiveMesh<PFP>::VolumetricProgressiveMesh(
CGoGNout << " creating approximator and predictor.." << CGoGNflush ;
switch(a)
{
case Algo::DecimationVolumes::A_QEM :
m_approximators.push_back(new Algo::DecimationVolumes::Approximator_QEM<PFP>(m_map, positionsTable)) ;
break ;
case Algo::Decimation::A_QEM : {
m_approximators.push_back(new Algo::Decimation::Approximator_QEM<PFP>(m_map, positionsTable)) ;
break ; }
default :
CGoGNout << "not yet implemented" << CGoGNendl;
break;
......@@ -56,9 +56,9 @@ VolumetricProgressiveMesh<PFP>::VolumetricProgressiveMesh(
CGoGNout << " creating selector.." << CGoGNflush ;
switch(s)
{
case Algo::DecimationVolumes::S_QEM :
m_selector = new Algo::DecimationVolumes::EdgeSelector_QEM<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
break ;
case Algo::Decimation::S_QEM : {
m_selector = new Algo::Decimation::EdgeSelector_QEM<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
break ; }
default:
CGoGNout << "not yet implemented" << CGoGNendl;
break;
......@@ -68,17 +68,17 @@ VolumetricProgressiveMesh<PFP>::VolumetricProgressiveMesh(
m_initOk = true ;
CGoGNout << " initializing approximators.." << CGoGNflush ;
for(typename std::vector<Algo::DecimationVolumes::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
for(typename std::vector<Algo::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
{
if(! (*it)->init())
m_initOk = false ;
if((*it)->getApproximatedAttributeName() == "position")
m_positionApproximator = reinterpret_cast<Algo::DecimationVolumes::Approximator<PFP, VEC3>*>(*it) ;
m_positionApproximator = reinterpret_cast<Algo::Decimation::Approximator<PFP, VEC3>*>(*it) ;
}
CGoGNout << "..done" << CGoGNendl ;
CGoGNout << " initializing predictors.." << CGoGNflush ;
for(typename std::vector<Algo::DecimationVolumes::PredictorGen<PFP>*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it)
for(typename std::vector<Algo::Decimation::PredictorGen<PFP>*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it)
if(! (*it)->init())
m_initOk = false ;