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: Dépendences Linux:
installer les paquets suivants: 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: Pour compiler CGoGN:
- aller dans ThirdParty, cd build, taper "cmake .", puis make ( avec -j x si vous avez x core sur votre machine) - 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 ...@@ -41,7 +41,7 @@ https://iggservis.u-strasbg.fr/Data/data.zip
Linux dependencies: Linux dependencies:
install the following packages: 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: To compile CGoGN:
- Go ThirdParty, cd build, type "cmake .." and then make (with -j x if you have x core on your machine) - 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: ...@@ -517,8 +517,8 @@ private:
public: public:
HalfEdgeSelector_ColorExperimental(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) : HalfEdgeSelector_ColorExperimental(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
EdgeSelector<PFP>(m, pos, approx, select), EdgeSelector<PFP>(m, pos, approx),
m_approxindex_pos(-1), m_approxindex_pos(-1),
m_attrindex_pos(-1), m_attrindex_pos(-1),
m_approxindex_color(-1), m_approxindex_color(-1),
...@@ -612,8 +612,8 @@ private: ...@@ -612,8 +612,8 @@ private:
REAL computeSquaredLightfieldDifference(const Dart& d1, const Dart& d2) ; REAL computeSquaredLightfieldDifference(const Dart& d1, const Dart& d2) ;
public: public:
HalfEdgeSelector_LFexperimental(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx, const FunctorSelect& select = allDarts) : HalfEdgeSelector_LFexperimental(MAP& m, VertexAttribute<typename PFP::VEC3>& pos, std::vector<ApproximatorGen<PFP>*>& approx) :
EdgeSelector<PFP>(m, pos, approx, select), EdgeSelector<PFP>(m, pos, approx),
m_approxindex_pos(-1), m_approxindex_pos(-1),
m_attrindex_pos(-1), m_attrindex_pos(-1),
m_approxindex_FT(-1), m_approxindex_FT(-1),
......
...@@ -134,7 +134,7 @@ void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute<typ ...@@ -134,7 +134,7 @@ void computeNoise(typename PFP::MAP& map, long amount, const VertexAttribute<typ
} //namespace Filtering } //namespace Filtering
} } //namespace Surface
} //namespace Algo } //namespace Algo
......
...@@ -303,7 +303,6 @@ void computeCentroidELWVolumes(typename PFP::MAP& map, ...@@ -303,7 +303,6 @@ void computeCentroidELWVolumes(typename PFP::MAP& map,
* @param map the map * @param map the map
* @param position vertex attribute of position * @param position vertex attribute of position
* @param vertex_centroid vertex attribute to store the centroids * @param vertex_centroid vertex attribute to store the centroids
* @param select the selector
*/ */
template <typename PFP> template <typename PFP>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
......
...@@ -83,6 +83,26 @@ void computeCotanWeightEdges( ...@@ -83,6 +83,26 @@ void computeCotanWeightEdges(
} // namespace Surface } // 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 Algo
} // namespace CGoGN } // namespace CGoGN
......
...@@ -151,6 +151,46 @@ void computeCotanWeightEdges( ...@@ -151,6 +151,46 @@ void computeCotanWeightEdges(
} // namespace Surface } // 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 Algo
} // namespace CGoGN } // namespace CGoGN
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#include "Algo/Modelisation/subdivision.h" #include "Algo/Modelisation/subdivision.h"
#include "Algo/Modelisation/extrusion.h" #include "Algo/Modelisation/extrusion.h"
#include "Geometry/intersection.h" #include "Geometry/intersection.h"
#include "NL/nl.h"
#include "Algo/LinearSolving/basic.h"
#include "Algo/Geometry/laplacian.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -631,12 +634,35 @@ void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs) ...@@ -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> template <typename PFP>
void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position) void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position)
{ {
DartMarkerStore m(map); DartMarkerStore m(map);
DartMarkerStore newBoundaryV(map);
// //
// 1-4 flip of all tetrahedra // 1-4 flip of all tetrahedra
// //
...@@ -697,6 +723,8 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& posit ...@@ -697,6 +723,8 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& posit
Dart dres = Volume::Modelisation::Tetrahedralization::flip1To3<PFP>(map, dit); Dart dres = Volume::Modelisation::Tetrahedralization::flip1To3<PFP>(map, dit);
position[dres] = faceCenter; position[dres] = faceCenter;
newBoundaryV.markOrbit<VERTEX>(dres);
} }
} }
...@@ -714,6 +742,147 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& posit ...@@ -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> template <typename PFP>
...@@ -733,11 +902,11 @@ void computeDual(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& po ...@@ -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 ...@@ -49,12 +49,12 @@ namespace Primal
namespace Regular namespace Regular
{ {
enum FilterType enum FilteringType
{ {
F_HighPass = 0, F_HighPass = 0,
F_LowPass, F_LowPass,
F_BandPass, F_BandPass,
F_None, F_None
} ; } ;
template <typename PFP> template <typename PFP>
...@@ -70,7 +70,7 @@ protected: ...@@ -70,7 +70,7 @@ protected:
std::vector<Algo::MR::Filter*> synthesisFilters ; std::vector<Algo::MR::Filter*> synthesisFilters ;
std::vector<Algo::MR::Filter*> analysisFilters ; std::vector<Algo::MR::Filter*> analysisFilters ;
FilterType filter; FilteringType filter;
unsigned int thresholdLow; unsigned int thresholdLow;
unsigned int thresholdHigh; unsigned int thresholdHigh;
......
...@@ -46,7 +46,7 @@ Map2MR<PFP>::Map2MR(typename PFP::MAP& map) : ...@@ -46,7 +46,7 @@ Map2MR<PFP>::Map2MR(typename PFP::MAP& map) :
shareVertexEmbeddings(true), shareVertexEmbeddings(true),
filter(F_None) filter(F_None)
{ {
std::cout << "filter = " << filter << std::endl;
} }
template <typename PFP> template <typename PFP>
...@@ -252,8 +252,15 @@ void Map2MR<PFP>::analysis() ...@@ -252,8 +252,15 @@ void Map2MR<PFP>::analysis()
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
// for(unsigned int i = 0; i < analysisFilters.size(); ++i)
// (*analysisFilters[i])() ;
for(unsigned int i = 0; i < analysisFilters.size(); ++i) for(unsigned int i = 0; i < analysisFilters.size(); ++i)
(*analysisFilters[i])() ; {
std::cout << "filter false" << std::endl;
(*analysisFilters[i])(false) ;
}
} }
template <typename PFP> template <typename PFP>
...@@ -266,16 +273,18 @@ void Map2MR<PFP>::synthesis() ...@@ -266,16 +273,18 @@ void Map2MR<PFP>::synthesis()
for(unsigned int i = 0; i < synthesisFilters.size(); ++i) for(unsigned int i = 0; i < synthesisFilters.size(); ++i)
{ {
if((filter == F_LowPass && m_map.getCurrentLevel() <= thresholdHigh) || std::cout << "filter = " << filter << std::endl;
(filter == F_HighPass && m_map.getCurrentLevel() >= thresholdLow) ||
(filter == F_BandPass && (thresholdLow >= m_map.getCurrentLevel() && m_map.getCurrentLevel() <= thresholdHigh))) 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) ; (*synthesisFilters[i])(true) ;
} }
else else
{ {
std::cout << "with details" << std::endl; std::cout << "filter false" << std::endl;
(*synthesisFilters[i])(false) ; (*synthesisFilters[i])(false) ;
} }
} }
......
...@@ -138,20 +138,11 @@ public: ...@@ -138,20 +138,11 @@ public:
Dart df = m_map.phi_1(m_map.phi2(m_map.phi1(d))) ; Dart df = m_map.phi_1(m_map.phi2(m_map.phi1(d))) ;
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid<PFP>(m_map, df, m_position);
m_map.incCurrentLevel() ;
if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,df) m_position[d] = p ;
&& !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 ; return false ;
} }
......
...@@ -299,8 +299,8 @@ void Map3MR<PFP>::swapEdges(Dart d, Dart e) ...@@ -299,8 +299,8 @@ void Map3MR<PFP>::swapEdges(Dart d, Dart e)
} }
if(m_map.template isOrbitEmbedded<VOLUME>()) // if(m_map.template isOrbitEmbedded<VOLUME>())
m_map.template setOrbitEmbeddingOnNewCell<VOLUME>(d); // m_map.template setOrbitEmbeddingOnNewCell<VOLUME>(d);
m_map.duplicateDart(d); m_map.duplicateDart(d);
...@@ -343,6 +343,14 @@ void Map3MR<PFP>::splitSurfaceInVolume(std::vector<Dart>& vd, bool firstSideClos ...@@ -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> template <typename PFP>
...@@ -622,11 +630,14 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif ...@@ -622,11 +630,14 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
Dart dd = m_map.phi1(m_map.phi1(old)); Dart dd = m_map.phi1(m_map.phi1(old));
m_map.splitFace(old,dd) ; m_map.splitFace(old,dd) ;
//centralDart = old; centralDart = old;
} }
else else
{ {
isocta = true; if(ispyra)
isocta = false;
else
isocta = true;
Dart old = m_map.phi2(m_map.phi1(ditWV)); Dart old = m_map.phi2(m_map.phi1(ditWV));
Dart dd = m_map.phi1(old) ; Dart dd = m_map.phi1(old) ;
...@@ -713,7 +724,6 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif ...@@ -713,7 +724,6 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
//replonger l'orbit de ditV. //replonger l'orbit de ditV.
m_map.template setOrbitEmbedding<VERTEX>(centralDart, m_map.template getEmbedding<VERTEX>(centralDart)); m_map.template setOrbitEmbedding<VERTEX>(centralDart, m_map.template getEmbedding<VERTEX>(centralDart));
(*volumeVertexFunctor)(centralDart) ; (*volumeVertexFunctor)(centralDart) ;
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
...@@ -734,6 +744,7 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif ...@@ -734,6 +744,7 @@ unsigned int Map3MR<PFP>::subdivideVolume(Dart d, bool triQuad, bool OneLevelDif
m_map.incCurrentLevel(); m_map.incCurrentLevel();
Dart x = m_map.phi_1(m_map.phi2(m_map.phi1(ditV))); Dart x = m_map.phi_1(m_map.phi2(m_map.phi1(ditV)));
std::vector<Dart> embVol;