Commit fe31f368 authored by Sylvain Thery's avatar Sylvain Thery

Merge cgogn:~untereiner/CGoGN

Conflicts:
	include/Algo/Render/GL2/explodeVolumeRender.hpp
parents ab4545fa dfec257e
Dépendences Linux:
installer les paquets suivants:
cmake libXi-dev libXmu-dev libglew-dev libxml2-dev libboost-all-dev zlib1g-dev qt4-designer qt4-dev-tools uuid-dev libgsl0-dev
cmake libXi-dev libXmu-dev libglew-dev libxml2-dev libboost-all-dev zlib1g-dev qt4-designer qt4-dev-tools uuid-dev libgsl0-dev libsuitesparse-dev
Pour compiler CGoGN:
- aller dans ThirdParty, cd build, taper "cmake .", puis make ( avec -j x si vous avez x core sur votre machine)
......@@ -41,7 +41,7 @@ https://iggservis.u-strasbg.fr/Data/data.zip
Linux dependencies:
install the following packages:
ccmake libXi-dev libXmu-dev libglew-dev libxml2-dev libboost-all-dev zlib1g-dev qt4-designer qt4-dev-tools uuid-dev
ccmake libXi-dev libXmu-dev libglew-dev libxml2-dev libboost-all-dev zlib1g-dev qt4-designer qt4-dev-tools uuid-dev libgsl0-dev libsuitesparse-dev
To compile CGoGN:
- Go ThirdParty, cd build, type "cmake .." and then make (with -j x if you have x core on your machine)
......
......@@ -517,8 +517,8 @@ private:
public:
HalfEdgeSelector_ColorExperimental(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
EdgeSelector<PFP>(m, pos, approx, select),
HalfEdgeSelector_ColorExperimental(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
EdgeSelector<PFP>(m, pos, approx),
m_approxindex_pos(-1),
m_attrindex_pos(-1),
m_approxindex_color(-1),
......@@ -612,8 +612,8 @@ private:
REAL computeSquaredLightfieldDifference(const Dart& d1, const Dart& d2) ;
public:
HalfEdgeSelector_LFexperimental(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) :
EdgeSelector<PFP>(m, pos, approx, select),
HalfEdgeSelector_LFexperimental(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
EdgeSelector<PFP>(m, pos, approx),
m_approxindex_pos(-1),
m_attrindex_pos(-1),
m_approxindex_FT(-1),
......
......@@ -134,7 +134,7 @@ void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute<typ
} //namespace Filtering
}
} //namespace Surface
} //namespace Algo
......
......@@ -303,7 +303,6 @@ void computeCentroidELWVolumes(typename PFP::MAP& map,
* @param map the map
* @param position vertex attribute of position
* @param vertex_centroid vertex attribute to store the centroids
* @param select the selector
*/
template <typename PFP>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
......
......@@ -83,6 +83,26 @@ void computeCotanWeightEdges(
} // namespace Surface
namespace Volume
{
namespace Geometry
{
template <typename PFP, typename ATTR_TYPE>
ATTR_TYPE computeLaplacianTopoVertex( typename PFP::MAP& map, Dart d, const VertexAttribute<ATTR_TYPE>& attr) ;
template <typename PFP, typename ATTR_TYPE>
void computeLaplacianTopoVertices(typename PFP::MAP& map, const VertexAttribute<ATTR_TYPE>& attr,
VertexAttribute<ATTR_TYPE>& laplacian) ;
} // namespace Geometry
} // namespace Volume
} // namespace Algo
} // namespace CGoGN
......
......@@ -151,6 +151,46 @@ void computeCotanWeightEdges(
} // namespace Surface
namespace Volume
{
namespace Geometry
{
template <typename PFP, typename ATTR_TYPE>
ATTR_TYPE computeLaplacianTopoVertex(typename PFP::MAP& map, Dart d, const VertexAttribute<ATTR_TYPE>& attr)
{
ATTR_TYPE l(0) ;
ATTR_TYPE value = attr[d] ;
unsigned int wSum = 0 ;
Traversor3VE<typename PFP::MAP> t(map, d) ;
for(Dart it = t.begin(); it != t.end(); it = t.next())
{
l += attr[map.phi1(it)] - value ;
++wSum ;
}
l /= wSum ;
return l ;
}
template <typename PFP, typename ATTR_TYPE>
void computeLaplacianTopoVertices(typename PFP::MAP& map, const VertexAttribute<ATTR_TYPE>& attr,
VertexAttribute<ATTR_TYPE>& laplacian)
{
TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
laplacian[d] = computeLaplacianTopoVertex<PFP, ATTR_TYPE>(map, d, attr) ;
}
} // namespace Geometry
} // namespace Volume
} // namespace Algo
} // namespace CGoGN
......@@ -26,6 +26,9 @@
#include "Algo/Modelisation/subdivision.h"
#include "Algo/Modelisation/extrusion.h"
#include "Geometry/intersection.h"
#include "NL/nl.h"
#include "Algo/LinearSolving/basic.h"
#include "Algo/Geometry/laplacian.h"
namespace CGoGN
{
......@@ -631,12 +634,35 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs)
// }
}
inline double sqrt3_K(unsigned int n)
{
switch(n)
{
case 1: return 0.333333 ;
case 2: return 0.555556 ;
case 3: return 0.5 ;
case 4: return 0.444444 ;
case 5: return 0.410109 ;
case 6: return 0.388889 ;
case 7: return 0.375168 ;
case 8: return 0.365877 ;
case 9: return 0.359328 ;
case 10: return 0.354554 ;
case 11: return 0.350972 ;
case 12: return 0.348219 ;
default:
double t = cos((2.0*M_PI)/double(n)) ;
return (4.0 - t) / 9.0 ;
}
}
template <typename PFP>
void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position)
{
DartMarkerStore m(map);
DartMarkerStore newBoundaryV(map);
//
// 1-4 flip of all tetrahedra
//
......@@ -697,6 +723,8 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& posit
Dart dres = Volume::Modelisation::Tetrahedralization::flip1To3<PFP>(map, dit);
position[dres] = faceCenter;
newBoundaryV.markOrbit<VERTEX>(dres);
}
}
......@@ -714,6 +742,147 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& posit
}
}
TraversorV<typename PFP::MAP> tVg(map,selected);
for(Dart dit = tVg.begin() ; dit != tVg.end() ; dit = tVg.next())
{
if(map.isBoundaryVertex(dit) && !newBoundaryV.isMarked(dit))
{
typename PFP::VEC3 P = position[dit] ;
typename PFP::VEC3 newP(0) ;
unsigned int val = 0 ;
Dart vit = dit ;
do
{
newP += position[map.phi_1(map.phi2(map.phi1(vit)))] ;
++val ;
vit = map.phi2(map.phi_1(vit)) ;
} while(vit != dit) ;
typename PFP::REAL K = sqrt3_K(val) ;
newP *= typename PFP::REAL(3) ;
newP -= typename PFP::REAL(val) * P ;
newP *= K / typename PFP::REAL(2 * val) ;
newP += (typename PFP::REAL(1) - K) * P ;
position[dit] = newP ;
}
}
//AutoVertexAttribute laplacian qui est une copie de position
// TraversorV<typename PFP::MAP> tVg2(map,selected);
// for(Dart dit = tVg2.begin() ; dit != tVg2.end() ; dit = tVg2.next())
// {
// if(!map.isBoundaryVertex(dit))
// {
// //modifie laplacian
// }
// }
//echange lapaclian et position
VertexAutoAttribute<typename PFP::VEC3> diffCoord(map, "diffCoord");
Algo::Volume::Geometry::computeLaplacianTopoVertices<PFP>(map, position, diffCoord) ;
VertexAutoAttribute<unsigned int> vIndex(map, "vIndex");
unsigned int nb_vertices = map.template computeIndexCells<VERTEX>(vIndex);
CellMarker<VERTEX> lockingMarker(map);
TraversorV<typename PFP::MAP> tv(map);
for(Dart dit = tv.begin() ; dit != tv.end() ; dit = tv.next())
{
if(!lockingMarker.isMarked(dit) && map.isBoundaryVertex(dit))
lockingMarker.mark(dit);
}
NLContext nlContext = nlNewContext();
nlSolverParameteri(NL_NB_VARIABLES, nb_vertices);
nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE);
nlSolverParameteri(NL_SOLVER, NL_CHOLMOD_EXT);
nlMakeCurrent(nlContext);
if(nlGetCurrentState() == NL_STATE_INITIAL)
nlBegin(NL_SYSTEM) ;
for(int coord = 0; coord < 3; ++coord)
{
LinearSolving::setupVariables<PFP>(map, vIndex, lockingMarker, position, coord) ;
nlBegin(NL_MATRIX) ;
LinearSolving::addRowsRHS_Laplacian_Topo<PFP>(map, vIndex, diffCoord, coord) ;
// LinearSolving::addRowsRHS_Laplacian_Cotan<PFP>(*map, perMap->vIndex, perMap->edgeWeight, perMap->vertexArea, perMap->diffCoord, coord) ;
nlEnd(NL_MATRIX) ;
nlEnd(NL_SYSTEM) ;
nlSolve() ;
LinearSolving::getResult<PFP>(map, vIndex, position, coord) ;
nlReset(NL_TRUE) ;
}
nlDeleteContext(nlContext);
//
// float weight = 1.0;
// LinearSolving::LinearSolver<PFP::REAL> ls(nbV);
// ls.set_least_squares(true);
// for(unsigned int coord = 0 ; coord < 3 ; ++coord)
// {
// std::cout << "coord " << coord << std::flush;
// TraversorV<PFP::MAP> tv(map);
// for(Dart dit = tv.begin() ; dit != tv.end() ; dit = tv.next())
// {
// ls.variable(indexV[dit]).set_value(position[dit][coord]);
// if(map.isBoundaryVertex(dit))
// ls.variable(indexV[dit]).lock();
// }
// std::cout << "... variables set... " << std::flush;
// ls.begin_system();
// TraversorV<PFP::MAP> tv2(map);
// for(Dart dit = tv2.begin() ; dit != tv2.end() ; dit = tv2.next())
// {
// if(!map.isBoundaryVertex(dit))
// {
// ls.begin_row();
// float sum = 0;
// Traversor3VVaE<PFP::MAP> tvvae(map, dit);
// for(Dart ditvvae = tvvae.begin() ; ditvvae != tvvae.end() ; ditvvae = tvvae.next())
// {
// ls.add_coefficient(indexV[ditvvae],weight);
// sum += weight;
// }
// ls.add_coefficient(indexV[dit],-sum);
// ls.normalize_row();
// ls.end_row();
// }
// }
// ls.end_system();
// std::cout << "... system built... " << std::flush;
// ls.solve();
// std::cout << "... system solved... " << std::flush;
// TraversorV<PFP::MAP> tv3(map);
// for(Dart dit = tv3.begin() ; dit != tv3.end() ; dit = tv3.next())
// {
// position[dit][coord] = ls.variable(indexV[dit]).value();
// }
// ls.reset(false);
// std::cout << "... done" << std::endl;
// }
}
template <typename PFP>
......@@ -733,11 +902,11 @@ void computeDual(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& po
}
} //namespace Modelisation
} // namespace Modelisation
} // volume
} // namespace volume
} //namespace Algo
} // namespace Algo
} //namespace CGoGN
} // namespace CGoGN
......@@ -49,12 +49,12 @@ namespace Primal
namespace Regular
{
enum FilterType
enum FilteringType
{
F_HighPass = 0,
F_LowPass,
F_BandPass,
F_None,
F_None
} ;
template <typename PFP>
......@@ -70,7 +70,7 @@ protected:
std::vector<Algo::MR::Filter*> synthesisFilters ;
std::vector<Algo::MR::Filter*> analysisFilters ;
FilterType filter;
FilteringType filter;
unsigned int thresholdLow;
unsigned int thresholdHigh;
......
......@@ -46,7 +46,7 @@ Map2MR<PFP>::Map2MR(typename PFP::MAP& map) :
shareVertexEmbeddings(true),
filter(F_None)
{
std::cout << "filter = " << filter << std::endl;
}
template <typename PFP>
......@@ -252,8 +252,15 @@ void Map2MR<PFP>::analysis()
m_map.decCurrentLevel() ;
// for(unsigned int i = 0; i < analysisFilters.size(); ++i)
// (*analysisFilters[i])() ;
for(unsigned int i = 0; i < analysisFilters.size(); ++i)
(*analysisFilters[i])() ;
{
std::cout << "filter false" << std::endl;
(*analysisFilters[i])(false) ;
}
}
template <typename PFP>
......@@ -266,16 +273,18 @@ void Map2MR<PFP>::synthesis()
for(unsigned int i = 0; i < synthesisFilters.size(); ++i)
{
if((filter == F_LowPass && m_map.getCurrentLevel() <= thresholdHigh) ||
(filter == F_HighPass && m_map.getCurrentLevel() >= thresholdLow) ||
(filter == F_BandPass && (thresholdLow >= m_map.getCurrentLevel() && m_map.getCurrentLevel() <= thresholdHigh)))
std::cout << "filter = " << filter << std::endl;
if((filter == F_LowPass && m_map.getCurrentLevel() <= thresholdHigh))// ||
//(filter == F_HighPass && m_map.getCurrentLevel() >= thresholdLow) ||
//(filter == F_BandPass && (thresholdLow >= m_map.getCurrentLevel() && m_map.getCurrentLevel() <= thresholdHigh)))
{
std::cout << "without details" << std::endl;
std::cout << "filter true , currentLevel = " << m_map.getCurrentLevel() << ", level = " << thresholdHigh << std::endl;
(*synthesisFilters[i])(true) ;
}
else
{
std::cout << "with details" << std::endl;
std::cout << "filter false" << std::endl;
(*synthesisFilters[i])(false) ;
}
}
......
......@@ -138,20 +138,11 @@ public:
Dart df = m_map.phi_1(m_map.phi2(m_map.phi1(d))) ;
m_map.decCurrentLevel() ;
if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,df)
&& !Algo::Surface::Modelisation::isPrism<PFP>(m_map,df)
&& !Algo::Surface::Modelisation::isPyra<PFP>(m_map,df))
{
typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid<PFP>(m_map, df, m_position);
m_map.incCurrentLevel() ;
m_position[d] = p ;
}
else
m_map.incCurrentLevel() ;
return false ;
}
......
......@@ -299,8 +299,8 @@ void Map3MR<PFP>::swapEdges(Dart d, Dart e)
}
if(m_map.template isOrbitEmbedded<VOLUME>())
m_map.template setOrbitEmbeddingOnNewCell<VOLUME>(d);
// if(m_map.template isOrbitEmbedded<VOLUME>())
// m_map.template setOrbitEmbeddingOnNewCell<VOLUME>(d);
m_map.duplicateDart(d);
......@@ -343,6 +343,14 @@ void Map3MR<PFP>::splitSurfaceInVolume(std::vector<Dart>& vd, bool firstSideClos
}
}
// if(m_map.template isOrbitEmbedded<VOLUME>())
// {
// Dart v = vd.front() ;
// Dart v23 = m_map.alpha2(v) ;
// m_map.template setOrbitEmbeddingOnNewCell<VOLUME>(v23) ;
// m_map.template copyCell<VOLUME>(v23, v) ;
// }
}
template <typename PFP>
......@@ -622,10 +630,13 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
Dart dd = m_map.phi1(m_map.phi1(old));
m_map.splitFace(old,dd) ;
//centralDart = old;
centralDart = old;
}
else
{
if(ispyra)
isocta = false;
else
isocta = true;
Dart old = m_map.phi2(m_map.phi1(ditWV));
......@@ -713,7 +724,6 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
//replonger l'orbit de ditV.
m_map.template setOrbitEmbedding<VERTEX>(centralDart, m_map.template getEmbedding<VERTEX>(centralDart));
(*volumeVertexFunctor)(centralDart) ;
m_map.decCurrentLevel() ;
......@@ -734,6 +744,7 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
m_map.incCurrentLevel();
Dart x = m_map.phi_1(m_map.phi2(m_map.phi1(ditV)));
std::vector<Dart> embVol;
Dart f = x;
do
......@@ -741,13 +752,28 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
Dart f3 = m_map.phi3(f);
Dart tmp = m_map.phi_1(m_map.phi2(m_map.phi_1(m_map.phi2(m_map.phi_1(f3))))); //future voisin par phi2
swapEdges(f3, tmp);
embVol.push_back(tmp);
f = m_map.phi2(m_map.phi_1(f));
}while(f != x);
for(std::vector<Dart>::iterator it = embVol.begin() ; it != embVol.end() ; ++it)
{
Dart dit = *it;
m_map.template setOrbitEmbeddingOnNewCell<VOLUME>(dit);
m_map.template copyCell<VOLUME>(dit, ditV);
}
//embed the volumes around swapEdges
//replonger l'orbit de ditV.
m_map.template setOrbitEmbedding<VERTEX>(x, m_map.template getEmbedding<VERTEX>(x));
(*volumeVertexFunctor)(x) ;
m_map.template setOrbitEmbedding<VERTEX>(m_map.phi2(m_map.phi3(x)), m_map.template getEmbedding<VERTEX>(m_map.phi2(m_map.phi3(x))));
//m_map.template setOrbitEmbedding<VERTEX>(centralDart, m_map.template getEmbedding<VERTEX>(centralDart));
//(*volumeVertexFunctor)(x) ;
m_map.decCurrentLevel() ;
}
......@@ -760,6 +786,7 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
{
m_map.incCurrentLevel();
Dart x = m_map.phi_1(m_map.phi2(m_map.phi1(ditWV)));
std::vector<Dart> embVol;
if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,x))
{
......@@ -780,6 +807,8 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
me.markOrbit<EDGE>(f3);
me.markOrbit<EDGE>(f32);
embVol.push_back(tmp);
}
f = m_map.phi2(m_map.phi_1(f));
......@@ -787,6 +816,15 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
}
for(std::vector<Dart>::iterator it = embVol.begin() ; it != embVol.end() ; ++it)
{
Dart dit = *it;
m_map.template setOrbitEmbeddingOnNewCell<VOLUME>(dit);
m_map.template copyCell<VOLUME>(dit, d);
}
m_map.template setOrbitEmbedding<VERTEX>(x, m_map.template getEmbedding<VERTEX>(x));
(*volumeVertexFunctor)(x) ;
......@@ -838,7 +876,6 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
}
m_map.incCurrentLevel();
m_map.popLevel() ;
return vLevel;
......
......@@ -47,6 +47,7 @@ public:
} ;
} // namespace MR
} // namespace Algo
......
......@@ -443,7 +443,7 @@ void EmbeddedMap3::splitVolume(std::vector<Dart>& vd)
for(std::vector<Dart>::iterator it = vd.begin() ; it != vd.end() ; ++it)
{
Dart dit = *it;
Dart dit23 = alpha2(dit);
Dart dit23 = phi3(phi2(dit));
// embed the vertex embedded from the origin volume to the new darts
if(isOrbitEmbedded<VERTEX>())
......@@ -479,7 +479,7 @@ void EmbeddedMap3::splitVolume(std::vector<Dart>& vd)
if(isOrbitEmbedded<VOLUME>())
{
Dart v = vd.front() ;
Dart v23 = alpha2(v) ;
Dart v23 = phi3(phi2(v));
setOrbitEmbeddingOnNewCell<VOLUME>(v23) ;
copyCell<VOLUME>(v23, v) ;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment