Commit 50a9f367 authored by untereiner's avatar untereiner
Browse files

starting working on MR Progressive Meshes

parent 00a75e94
...@@ -120,7 +120,6 @@ bool MeshTablesSurface<PFP>::importMesh(const std::string& filename, std::vector ...@@ -120,7 +120,6 @@ bool MeshTablesSurface<PFP>::importMesh(const std::string& filename, std::vector
CGoGNout << "TYPE: PLYSLFgenericBin" << CGoGNendl; CGoGNout << "TYPE: PLYSLFgenericBin" << CGoGNendl;
return importPlySLFgenericBin(filename, attrNames); return importPlySLFgenericBin(filename, attrNames);
break; break;
case ImportSurfacique::OBJ: case ImportSurfacique::OBJ:
CGoGNout << "TYPE: OBJ" << CGoGNendl; CGoGNout << "TYPE: OBJ" << CGoGNendl;
return importObj(filename, attrNames); return importObj(filename, attrNames);
...@@ -591,7 +590,7 @@ bool MeshTablesSurface<PFP>::importPly(const std::string& filename, std::vector< ...@@ -591,7 +590,7 @@ bool MeshTablesSurface<PFP>::importPly(const std::string& filename, std::vector<
CGoGNerr << "Unable to open file " << filename << CGoGNendl; CGoGNerr << "Unable to open file " << filename << CGoGNendl;
return false; return false;
} }
AttributeHandler<typename PFP::VEC3> colors = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "color") ; AttributeHandler<typename PFP::VEC3> colors = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "color") ;
if (pid.hasColors()) if (pid.hasColors())
{ {
......
...@@ -268,8 +268,8 @@ bool importMeshV(typename PFP::MAP& map, const std::string& filename, std::vecto ...@@ -268,8 +268,8 @@ bool importMeshV(typename PFP::MAP& map, const std::string& filename, std::vecto
if ((filename.rfind(".tet") != std::string::npos) || (filename.rfind(".TET") != std::string::npos)) if ((filename.rfind(".tet") != std::string::npos) || (filename.rfind(".TET") != std::string::npos))
kind = ImportVolumique::TET; kind = ImportVolumique::TET;
if ((filename.rfind(".ele") != std::string::npos) || (filename.rfind(".ELE") != std::string::npos)) if ((filename.rfind(".off") != std::string::npos) || (filename.rfind(".OFF") != std::string::npos))
kind = ImportVolumique::ELE; kind = ImportVolumique::OFF;
if ((filename.rfind(".ts") != std::string::npos) || (filename.rfind(".TS") != std::string::npos)) if ((filename.rfind(".ts") != std::string::npos) || (filename.rfind(".TS") != std::string::npos))
kind = ImportVolumique::TS; kind = ImportVolumique::TS;
......
...@@ -323,7 +323,7 @@ public: ...@@ -323,7 +323,7 @@ public:
/** /**
* Traverse volumes adjacent to a volumee by a vertex * Traverse volumes adjacent to a volume by a vertex
*/ */
template <typename MAP> template <typename MAP>
class Traversor3WWaV: public Traversor3XXaY<MAP> class Traversor3WWaV: public Traversor3XXaY<MAP>
...@@ -333,7 +333,7 @@ public: ...@@ -333,7 +333,7 @@ public:
}; };
/** /**
* Traverse volumes adjacent to a volumee by an edge * Traverse volumes adjacent to a volume by an edge
*/ */
template <typename MAP> template <typename MAP>
class Traversor3WWaE: public Traversor3XXaY<MAP> class Traversor3WWaE: public Traversor3XXaY<MAP>
...@@ -343,7 +343,7 @@ public: ...@@ -343,7 +343,7 @@ public:
}; };
/** /**
* Traverse volumes adjacent to a volumee by a face * Traverse volumes adjacent to a volume by a face
*/ */
template <typename MAP> template <typename MAP>
class Traversor3WWaF: public Traversor3XXaY<MAP> class Traversor3WWaF: public Traversor3XXaY<MAP>
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __MAP2MR_PM__
#define __MAP2MR_PM__
#include "Topology/map/embeddedMap2.h"
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include "Topology/map/map2MR/filters_Primal.h"
#include "Algo/Modelisation/subdivision.h"
namespace CGoGN
{
class SelectorCollapsingEdges : public FunctorSelect
{
protected:
const DartMarker& m_dm;
public:
SelectorCollapsingEdges(const DartMarker& dm): m_dm(dm) {}
bool operator()(Dart d) const { return m_dm.isMarked(d); }
FunctorSelect* copy() const { return new SelectorCollapsingEdges(m_dm);}
};
class Map2MR_PM : public EmbeddedMap2
{
protected:
bool shareVertexEmbeddings ;
std::vector<Multiresolution::MRFilter*> synthesisFilters ;
std::vector<Multiresolution::MRFilter*> analysisFilters ;
DartMarkerStore* selectedEdges;
public:
Map2MR_PM() ;
virtual std::string mapTypeName() const { return "Map2MR_PM" ; }
void addNewLevel(bool embedNewVertices = true) ;
void addSynthesisFilter(Multiresolution::MRFilter* f) { synthesisFilters.push_back(f) ; }
void addAnalysisFilter(Multiresolution::MRFilter* f) { analysisFilters.push_back(f) ; }
void clearSynthesisFilters() { synthesisFilters.clear() ; }
void clearAnalysisFilters() { analysisFilters.clear() ; }
void analysis() ;
void synthesis() ;
} ;
} ;
} // namespace CGoGN
#endif
...@@ -609,137 +609,499 @@ public: ...@@ -609,137 +609,499 @@ public:
} }
}; };
/* BSXW02 on Boundary Vertices and on Insides Vertices /* Lerp on Boundary Vertices and on Insides Vertices and BSXW02 Averaging
*********************************************************************************/ *********************************************************************************/
template <typename PFP> template <typename PFP>
class BSXW02VertexSubdivision : public MRScheme class BSXW02AveragingSubdivision : public MRScheme
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; typename PFP::TVEC3& m_position ;
public: public:
BSXW02VertexSubdivision(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) BSXW02AveragingSubdivision(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
{ {
TraversorW<typename PFP::MAP> trav(m_map) ; m_map.incCurrentLevel() ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) TraversorV<typename PFP::MAP> trav(m_map) ;
for (Dart ditE = trav.begin(); ditE != trav.end(); ditE = trav.next())
{ {
//cell points : these points are the average of the if(m_map.isBoundaryVertex(ditE))
//vertices of the lattice that bound the cell {
typename PFP::VEC3 p = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position); Dart db = m_map.findBoundaryFaceOfVertex(ditE);
m_map.incCurrentLevel() ; typename PFP::VEC3 P(0);
unsigned int count = 0;
Traversor2VF<typename PFP::MAP> travVF(m_map, db);
for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next())
{
P += Algo::Geometry::faceCentroid<PFP>(m_map, ditVF, m_position);
++count;
}
if(!m_map.isTetrahedron(d)) P /= count;
m_position[db] = P;
}
else if(m_map.isBoundaryEdge(ditE))
{ {
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); Dart db = m_map.findBoundaryEdgeOfVertex(ditE);
m_position[midV] = p ;
typename PFP::VEC3 P(0);
unsigned int count = 0;
Traversor2VF<typename PFP::MAP> travVF(m_map, db);
for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next())
{
P += Algo::Geometry::faceCentroid<PFP>(m_map, ditVF, m_position);
++count;
}
P /= count;
m_position[db] = P;
} }
else
{
typename PFP::VEC3 P(0);
unsigned int count = 0;
Traversor3VW<typename PFP::MAP> travVF(m_map, ditE);
for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next())
{
P += Algo::Geometry::volumeCentroid<PFP>(m_map, ditVF, m_position);
++count;
}
m_map.decCurrentLevel() ; P /= count;
m_position[ditE] = P;
}
} }
m_map.decCurrentLevel() ;
} }
}; };
template <typename PFP> template <typename PFP>
class BSXW02EdgeSubdivision : public MRScheme class BSXW02EdgeAveragingSubdivision : public MRScheme
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; typename PFP::TVEC3& m_position ;
public: public:
BSXW02EdgeSubdivision(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) BSXW02EdgeAveragingSubdivision(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
{ {
TraversorW<typename PFP::MAP> trav(m_map) ; TraversorE<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) for (Dart ditE = trav.begin(); ditE != trav.end(); ditE = trav.next())
{ {
//cell points : these points are the average of the if(m_map.isBoundaryEdge(ditE))
//vertices of the lattice that bound the cell {
typename PFP::VEC3 p = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position); Dart db = m_map.findBoundaryFaceOfEdge(ditE);
m_map.incCurrentLevel() ; m_map.incCurrentLevel() ;
if(!m_map.isTetrahedron(d)) db = m_map.phi1(db);
typename PFP::VEC3 P(0);
unsigned int count = 0;
Traversor2VF<typename PFP::MAP> travVF(m_map, db);
for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next())
{
P += Algo::Geometry::faceCentroid<PFP>(m_map, ditVF, m_position);
++count;
}
P /= count;
m_position[db] = P;
m_map.decCurrentLevel() ;
}
}
}
};
template <typename PFP>
class BSXW02FaceAveragingSubdivision : public MRScheme
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
public:
BSXW02FaceAveragingSubdivision(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{}
void operator() ()
{
TraversorF<typename PFP::MAP> trav(m_map) ;
for (Dart ditE = trav.begin(); ditE != trav.end(); ditE = trav.next())
{
if(m_map.isBoundaryFace(ditE))
{ {
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); Dart db = m_map.phi3(ditE);
m_position[midV] = p ;
m_map.incCurrentLevel() ;
if(m_map.faceDegree(db) != 3)
{
db = m_map.phi2(m_map.phi1(db));
typename PFP::VEC3 P(0);
unsigned int count = 0;
Traversor2VF<typename PFP::MAP> travVF(m_map, db);
for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next())
{
P += Algo::Geometry::faceCentroid<PFP>(m_map, ditVF, m_position);
++count;
}
P /= count;
m_position[db] = P;
}
m_map.decCurrentLevel() ;
} }
}
}
};
template <typename PFP>
class BSXW02VolumeAveragingSubdivision : public MRScheme
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
public:
BSXW02VolumeAveragingSubdivision(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{}
void operator() ()
{
TraversorW<typename PFP::MAP> trav(m_map) ;
for (Dart ditE = trav.begin(); ditE != trav.end(); ditE = trav.next())
{
m_map.incCurrentLevel() ;
if(!m_map.isTetrahedron(ditE))
{
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(ditE)));
typename PFP::VEC3 P(0);
unsigned int count = 0;
Traversor3VW<typename PFP::MAP> travVF(m_map, midV);
for (Dart ditVF = travVF.begin(); ditVF != travVF.end(); ditVF = travVF.next())
{
P += Algo::Geometry::volumeCentroid<PFP>(m_map, ditVF, m_position);
++count;
}
P /= count;
m_position[midV] = P;
}
m_map.decCurrentLevel() ; m_map.decCurrentLevel() ;
} }
} }
}; };
/* DHL93 on Boundary Vertices and MCQ04 on Insides Vertices
*********************************************************************************/
template <typename PFP> template <typename PFP>
class BSXW02FaceSubdivision : public MRScheme class MCQ04VertexSubdivision: public MRScheme
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; typename PFP::TVEC3& m_position ;
public: public:
BSXW02FaceSubdivision(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) MCQ04VertexSubdivision(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
{ {
TraversorW<typename PFP::MAP> trav(m_map) ; TraversorV<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next()) for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{ {
//cell points : these points are the average of the typename PFP::VEC3 p = m_position[d];
//vertices of the lattice that bound the cell
typename PFP::VEC3 p = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
m_map.incCurrentLevel() ; m_map.incCurrentLevel() ;
m_position[d] = p ;
m_map.decCurrentLevel() ;
}
}
} ;
if(!m_map.isTetrahedron(d)) template <typename PFP>
class MCQ04EdgeSubdivision : public MRScheme
{
protected:
typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ;
public:
MCQ04EdgeSubdivision(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{}
void operator() ()
{
typename PFP::REAL omega = 1.0/16.0;
TraversorE<typename PFP::MAP> trav(m_map) ;
for (Dart ditE = trav.begin(); ditE != trav.end(); ditE = trav.next())
{
if(m_map.isBoundaryEdge(ditE))
{ {
Dart midV = m_map.phi_1(m_map.phi2(m_map.phi1(d))); Dart db = m_map.findBoundaryFaceOfEdge(ditE);
typename PFP::VEC3 p = (m_position[db] + m_position[m_map.phi2(db)]) * typename PFP::REAL(0.5);
m_map.incCurrentLevel() ;
Dart midV = m_map.phi2(db) ;
m_position[midV] = p ; m_position[midV] = p ;
m_map.decCurrentLevel() ;
} }
else
{
typename PFP::VEC3 P = ( m_position[ditE] + m_position[m_map.phi2(ditE)] ) * typename PFP::REAL(0.5);
m_map.decCurrentLevel() ; typename PFP::VEC3 Q(0);
typename PFP::VEC3 R(0);
unsigned int count = 0;
Dart dit = ditE;
do
{
Dart d_1 = m_map.phi_1(dit);
Dart d11 = m_map.phi1(m_map.phi1(dit));
Q += m_position[d_1];
Q += m_position[d11];
++count;
Dart dr1 = m_map.phi1(m_map.phi1(m_map.alpha2(d_1)));
R += m_position[dr1];
Dart dr2 = m_map.phi1(m_map.phi1(m_map.alpha2(m_map.phi1(dit))));
R += m_position[dr2];
dit = m_map.alpha2(dit);
}while(dit != ditE);
Q *= (omega / count);
R *= (omega / count);
m_map.incCurrentLevel() ;
Dart midV = m_map.phi2(ditE);
m_position[midV] = P + Q - R;
m_map.decCurrentLevel() ;
}
} }
} }
}; };
template <typename PFP> template <typename PFP>
class BSXW02VolumeSubdivision : public MRScheme class MCQ04FaceSubdivision : public MRScheme
{ {
protected: protected:
typename PFP::MAP& m_map ; typename PFP::MAP& m_map ;
typename PFP::TVEC3& m_position ; typename PFP::TVEC3& m_position ;
public: public:
BSXW02VolumeSubdivision(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p) MCQ04FaceSubdivision(typename PFP::MAP& m, typename PFP::TVEC3& p) : m_map(m), m_position(p)
{} {}
void operator() () void operator() ()
{ {
TraversorW<typename PFP::MAP> trav(m_map) ; typename PFP::REAL omega = 1.0/16.0;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
TraversorF<typename PFP::MAP> trav(m_map) ;
for (Dart ditF = trav.begin(); ditF != trav.end(); ditF = trav.next())
{ {
//cell points : these points are the average of the if(m_map.isBoundaryFace(ditF))
//vertices of the lattice that bound the cell {
typename PFP::VEC3 p = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position); typename PFP::VEC3 p = Algo::Geometry::faceCentroid<PFP>(m_map, ditF, m_position);