Commit d916df01 authored by untereiner's avatar untereiner

Merge cgogn:~cgogn/CGoGN

parents b2e6f0ef 351c36b2
......@@ -102,8 +102,6 @@ private:
bool importPlySLFgeneric(const std::string& filename, std::vector<std::string>& attrNames);
bool importPlySLFgenericBin(const std::string& filename, std::vector<std::string>& attrNames);
#ifdef WITH_ASSIMP
bool importASSIMP(const std::string& filename, std::vector<std::string>& attrNames);
#endif
......@@ -131,6 +129,8 @@ public:
bool importVoxellisation(Algo::Surface::Modelisation::Voxellisation& voxellisation, std::vector<std::string>& attrNames);
bool importPlySLFgenericBin(const std::string& filename, std::vector<std::string>& attrNames);
MeshTablesSurface(typename PFP::MAP& map):
m_map(map)
{ }
......
......@@ -506,66 +506,53 @@ void explodPolyhedron(typename PFP::MAP& map, Dart d, VertexAttribute<typename
}
}
// template <typename PFP>
// void quads2TrianglesCC(typename PFP::MAP& the_map, Dart primd)
// {
// DartMarker m(the_map);
// // list of faces to process and processed(before pos iterator)
// std::list<Dart> ld;
// ld.push_back(primd);
// // current position in list
// typename std::list<Dart>::iterator pos = ld.begin();
// do
// {
// Dart d = *pos;
// // cut the face of first dart of list
// Dart d1 = the_map.phi1(d);
// Dart e = the_map.phi1(d1);
// Dart e1 = the_map.phi1(e);
// Dart f = the_map.phi1(e1);
// if (f==d) // quad
// {
// the_map.splitFace(d,e);
// // mark the face
// m.markOrbit<FACE>(d);
// m.markOrbit<FACE>(e);
// }
// else m.markOrbit<FACE>(d);
// // and store neighbours faces in the list
// d = the_map.phi2(d);
// e = the_map.phi2(e);
// d1 = the_map.phi1(the_map.phi2(d1));
// e1 = the_map.phi1(the_map.phi2(e1));
// if (!m.isMarked(d))
// ld.push_back(d);
// if (!m.isMarked(e))
// ld.push_back(e);
// if (!m.isMarked(d1))
// ld.push_back(d1);
// if ((f==d) && (!m.isMarked(e1)))
// ld.push_back(e1);
// pos++;
// }while (pos!=ld.end()); // stop when no more face to process
// }
// template <typename PFP>
// Dart triangleFan_topo(typename PFP::MAP& the_map, int n)
// {
// Dart d = the_map.newFace(3,false);
// Dart e = the_map.phi1(d);
// for(int i=1;i<n;++i)
// {
// Dart f = the_map.newFace(3,false);
// the_map.sewFaces(the_map.phi_1(f),e);
// e = the_map.phi1(f);
// }
// the_map.sewFaces(the_map.phi_1(d),e);
// return d;
// }
template <typename PFP>
void quads2TrianglesCC(typename PFP::MAP& the_map, Dart primd)
{
DartMarker m(the_map);
// list of faces to process and processed(before pos iterator)
std::list<Dart> ld;
ld.push_back(primd);
// current position in list
typename std::list<Dart>::iterator pos = ld.begin();
do
{
Dart d = *pos;
// cut the face of first dart of list
Dart d1 = the_map.phi1(d);
Dart e = the_map.phi1(d1);
Dart e1 = the_map.phi1(e);
Dart f = the_map.phi1(e1);
if (f==d) // quad
{
the_map.splitFace(d,e);
// mark the face
m.markOrbit<FACE>(d);
m.markOrbit<FACE>(e);
}
else m.markOrbit<FACE>(d);
// and store neighbours faces in the list
d = the_map.phi2(d);
e = the_map.phi2(e);
d1 = the_map.phi1(the_map.phi2(d1));
e1 = the_map.phi1(the_map.phi2(e1));
if (!m.isMarked(d))
ld.push_back(d);
if (!m.isMarked(e))
ld.push_back(e);
if (!m.isMarked(d1))
ld.push_back(d1);
if ((f==d) && (!m.isMarked(e1)))
ld.push_back(e1);
pos++;
}while (pos!=ld.end()); // stop when no more face to process
}
} // namespace Modelisation
......
......@@ -60,9 +60,8 @@ private:
VertexAttribute<typename PFP::VEC3>& positionsTable ;
DartMarker& inactiveMarker ;
SelectorUnmarked dartSelect ;
Algo::Surface::Decimation::EdgeSelector<PFP>* m_selector ;
Algo::Surface::Decimation::Selector<PFP>* m_selector ;
std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*> m_approximators ;
std::vector<Algo::Surface::Decimation::PredictorGen<PFP>*> m_predictors ;
std::vector<VSplit<PFP>*> m_splits ;
......@@ -85,6 +84,10 @@ public:
Algo::Surface::Decimation::SelectorType s, Algo::Surface::Decimation::ApproximatorType a,
VertexAttribute<typename PFP::VEC3>& position
) ;
ProgressiveMesh(
MAP& map, DartMarker& inactive,
Algo::Surface::Decimation::Selector<PFP>* selector, std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*>& approximators,
VertexAttribute<typename PFP::VEC3>& position) ;
~ProgressiveMesh() ;
bool initOk() { return m_initOk ; }
......@@ -92,7 +95,7 @@ public:
void createPM(unsigned int percentWantedVertices) ;
std::vector<VSplit<PFP>*>& splits() { return m_splits ; }
Algo::Surface::Decimation::EdgeSelector<PFP>* selector() { return m_selector ; }
Algo::Surface::Decimation::Selector<PFP>* selector() { return m_selector ; }
std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*>& approximators() { return m_approximators ; }
std::vector<Algo::Surface::Decimation::PredictorGen<PFP>*>& predictors() { return m_predictors ; }
......
......@@ -42,7 +42,7 @@ ProgressiveMesh<PFP>::ProgressiveMesh(
Algo::Surface::Decimation::SelectorType s, Algo::Surface::Decimation::ApproximatorType a,
VertexAttribute<typename PFP::VEC3>& position
) :
m_map(map), positionsTable(position), inactiveMarker(inactive), dartSelect(inactiveMarker)
m_map(map), positionsTable(position), inactiveMarker(inactive)
{
CGoGNout << " creating approximator and predictor.." << CGoGNflush ;
......@@ -83,22 +83,22 @@ ProgressiveMesh<PFP>::ProgressiveMesh(
switch(s)
{
case Algo::Surface::Decimation::S_MapOrder : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_MapOrder<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_MapOrder<PFP>(m_map, positionsTable, m_approximators) ;
break ; }
case Algo::Surface::Decimation::S_Random : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_Random<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_Random<PFP>(m_map, positionsTable, m_approximators) ;
break ; }
case Algo::Surface::Decimation::S_EdgeLength : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_Length<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_Length<PFP>(m_map, positionsTable, m_approximators) ;
break ; }
case Algo::Surface::Decimation::S_QEM : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_QEM<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_QEM<PFP>(m_map, positionsTable, m_approximators) ;
break ; }
case Algo::Surface::Decimation::S_MinDetail : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_MinDetail<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_MinDetail<PFP>(m_map, positionsTable, m_approximators) ;
break ; }
case Algo::Surface::Decimation::S_Curvature : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_Curvature<PFP>(m_map, positionsTable, m_approximators, dartSelect) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_Curvature<PFP>(m_map, positionsTable, m_approximators) ;
break ; }
}
CGoGNout << "..done" << CGoGNendl ;
......@@ -131,6 +131,40 @@ ProgressiveMesh<PFP>::ProgressiveMesh(
quantizationApplied = false ;
}
template <typename PFP>
ProgressiveMesh<PFP>::ProgressiveMesh(
MAP& map, DartMarker& inactive,
Algo::Surface::Decimation::Selector<PFP>* selector, std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*>& approximators,
VertexAttribute<typename PFP::VEC3>& position
) :
m_map(map), m_selector(selector), m_approximators(approximators), positionsTable(position), inactiveMarker(inactive)
{
CGoGNout << " initializing approximators.." << CGoGNflush ;
for(typename std::vector<Algo::Surface::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::Surface::Decimation::Approximator<PFP, VEC3, EDGE>*>(*it) ;
}
CGoGNout << "..done" << CGoGNendl ;
CGoGNout << " initializing predictors.." << CGoGNflush ;
for(typename std::vector<Algo::Surface::Decimation::PredictorGen<PFP>*>::iterator it = m_predictors.begin(); it != m_predictors.end(); ++it)
if(! (*it)->init())
m_initOk = false ;
CGoGNout << "..done" << CGoGNendl ;
CGoGNout << " initializing selector.." << CGoGNflush ;
m_initOk = m_selector->init() ;
CGoGNout << "..done" << CGoGNendl ;
m_detailAmount = REAL(1) ;
m_localFrameDetailVectors = false ;
quantizationInitialized = false ;
quantizationApplied = false ;
}
template <typename PFP>
ProgressiveMesh<PFP>::~ProgressiveMesh()
{
......
......@@ -131,9 +131,9 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNorma
bufferNormals.push_back(PFP::toVec3f(normals[d]));
bufferColors.push_back(PFP::toVec3f(colorPerXXX[d]));
buffer.push_back(PFP::toVec3f(positions[b]));
bufferNormals.push_back(PFP::toVec3f(normals[b]);
bufferNormals.push_back(PFP::toVec3f(normals[b]));
bufferColors.push_back(PFP::toVec3f(colorPerXXX[b]));
buffer.push_back(PFP::toVec3f(positions[c]);
buffer.push_back(PFP::toVec3f(positions[c]));
bufferNormals.push_back(PFP::toVec3f(normals[c]));
bufferColors.push_back(PFP::toVec3f(colorPerXXX[c]));
b = c;
......
/*******************************************************************************
* 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 __UNIFORM_ORIENTATION__
#define __UNIFORM_ORIENTATION__
namespace CGoGN
{
namespace Algo
{
namespace Topo
{
/**
* @brief Restore an uniform orientation on a mesh that has been imported from set of triangle with non uniform orientation
* @param map a Map2 or inherited
* @param faceSeed a dart of a face of the CC to process.
*/
template <typename MAP>
void uniformOrientationCC(MAP& map, Dart faceSeed);
} // namespace Topo
} // namespace Algo
} // namespace CGoGN
#include "uniformOrientation.hpp"
#endif
namespace CGoGN
{
namespace Algo
{
namespace Topo
{
// private function
template <typename MAP>
void reverse2MapFaceKeepPhi2(MAP& map, Dart d)
{
unsigned int first = map.template getEmbedding<VERTEX>(d);
Dart e=d;
do
{
Dart f=map.phi1(e);
unsigned int emb = map.template getEmbedding<VERTEX>(f);
map.template setDartEmbedding<VERTEX>(e,emb);
e =f;
}while (e!=d);
map.template setDartEmbedding<VERTEX>(map.phi_1(d),first);
map.reverseCycle(d);
}
// private function
inline Dart findOtherInCouplesOfDarts(const std::vector<Dart>& couples, Dart d)
{
unsigned int nb = couples.size();
for (unsigned int i=0; i<nb; ++i)
{
if (couples[i] == d)
{
if (i%2 == 0)
return couples[i+1];
//else
return couples[i-1];
}
}
return NIL;
}
template <typename MAP>
void uniformOrientationCC(MAP& map, Dart faceSeed)
{
// first bufferize boundary edges
std::vector<Dart> boundEdges;
TraversorE<MAP> travEdge(map);
for (Dart d=travEdge.begin(); d!= travEdge.end(); d = travEdge.next())
{
if (map.isBoundaryEdge(d))
boundEdges.push_back(d);
}
// store couple of boundary edges the have same embedding
std::vector<Dart> couples;
int nb = boundEdges.size();
int nbm = nb-1;
for (int i=0; i< nbm; ++i)
{
if (boundEdges[i] != NIL)
{
for (int j=i+1; j< nb; ++j)
{
if (boundEdges[j] != NIL)
{
Dart d = boundEdges[i];
Dart d1 = map.phi1(d);
Dart e = boundEdges[j];
Dart e1 = map.phi1(e);
if ((map.template getEmbedding<VERTEX>(d) == map.template getEmbedding<VERTEX>(e)) && (map.template getEmbedding<VERTEX>(d1) == map.template getEmbedding<VERTEX>(e1)))
{
couples.push_back(d);
couples.push_back(e);
boundEdges[j] = NIL; // not using the dart again
j=nb; // out of the loop
}
}
}
}
}
// vector of front propagation for good orientation
std::vector<Dart> propag;
boundEdges.clear();
propag.swap(boundEdges);// reused memory of boundEdges
// vector of front propagation for wrong orientation
std::vector<Dart> propag_inv;
//vector of faces to invert
std::vector<Dart> face2invert;
// optimize memory reserve
propag_inv.reserve(1024);
face2invert.reserve(1024);
DartMarker cmf(map);
cmf.markOrbit<FACE>(faceSeed);
propag.push_back(faceSeed);
while (!propag.empty() || !propag_inv.empty())
{
if (!propag.empty())
{
Dart f = propag.back();
propag.pop_back();
Dart d = f;
do
{
Dart e = map.phi2(d);
if (map.isBoundaryMarked2(e))
{
e = findOtherInCouplesOfDarts(couples,d);
if (e!=NIL)
{
if (!cmf.isMarked(e))
{
propag_inv.push_back(e);
face2invert.push_back(e);
cmf.markOrbit<FACE>(e);
}
cmf.mark(map.phi2(e));// use cmf also to mark boudary cycle to invert
}
}
else
{
if (!cmf.isMarked(e))
{
propag.push_back(e);
cmf.markOrbit<FACE>(e);
}
}
d= map.phi1(d);
} while (d!=f);
}
if (!propag_inv.empty())
{
Dart f = propag_inv.back();
propag_inv.pop_back();
Dart d = f;
do
{
Dart e = map.phi2(d);
if (map.isBoundaryMarked2(e))
{
e = findOtherInCouplesOfDarts(couples,d);
if (e!=NIL)
{
if (!cmf.isMarked(e))
{
propag.push_back(e);
cmf.markOrbit<FACE>(e);
}
cmf.mark(map.phi2(d));// use cmf also to mark boudary cycle to invert
}
}
else
{
if (!cmf.isMarked(e))
{
propag_inv.push_back(e);
face2invert.push_back(e);
cmf.markOrbit<FACE>(e);
}
}
d= map.phi1(d); // traverse all edges of face
} while (d!=f);
}
}
// reverse all faces of the wrong orientation
for (std::vector<Dart>::iterator id=face2invert.begin(); id!=face2invert.end(); ++id)
reverse2MapFaceKeepPhi2<MAP>(map,*id);
// reverse the boundary cycles that bound reverse faces
for (std::vector<Dart>::iterator id=couples.begin(); id!=couples.end(); ++id)
{
Dart e = map.phi2(*id);
if (cmf.isMarked(e)) // check cmf for wrong orientation
{
reverse2MapFaceKeepPhi2<MAP>(map,e);
cmf.unmarkOrbit<FACE>(e);
}
}
// sew the faces that correspond to couples of boundary edges
for (std::vector<Dart>::iterator id=couples.begin(); id!=couples.end(); ++id)// second ++ inside !
{
Dart d = *id++;
Dart e = *id;
map.sewFaces(d,e);
}
}
} // namespace Topo
} // namespace Algo
} // namespace CGoGN
......@@ -544,15 +544,30 @@ inline void GenericMap::updateQuickTraversal()
{
assert(m_quickTraversal[ORBIT] != NULL || !"updateQuickTraversal on a disabled orbit") ;
CellMarker<ORBIT> cm(*this) ;
for(Dart d = begin(); d != end(); next(d))
// CellMarker<ORBIT> cm(*this) ;
// for(Dart d = begin(); d != end(); next(d))
// {
// if ((!cm.isMarked(d)) && (!isBoundaryMarkedCurrent(d)))
// {
// cm.mark(d) ;
// (*m_quickTraversal[ORBIT])[getEmbedding<ORBIT>(d)] = d ;
// }
// }
// ensure that we do not try to use quick traversal in Traversors
AttributeMultiVector<Dart>* qt = m_quickTraversal[ORBIT];
m_quickTraversal[ORBIT] = NULL;
// fill the quick travsersal
TraversorCell<GenericMap,VOLUME> trav(*this);
for(Dart d = trav.begin(); d != trav.end(); d=trav.next())
{
if(!cm.isMarked(d))
{
cm.mark(d) ;
(*m_quickTraversal[ORBIT])[getEmbedding<ORBIT>(d)] = d ;
}
(*qt)[getEmbedding<ORBIT>(d)] = d ;
}
// restore ptr
m_quickTraversal[ORBIT] = qt;
}
template <unsigned int ORBIT>
......
......@@ -33,6 +33,19 @@
namespace CGoGN
{
/// Macro for simple syntax traversal (can be nested)
/// parameters:
/// - cell type
/// - name of iterator variable (automatically declared)
/// - map type
/// - map used
///
/// Ex: FOR_ALL_CELLS(VERTEX, di, myMap) { ... }
///
#define FOR_ALL_CELLS(ORBIT, NAME_ITER, MAP_TYPE, MAP_PARAM) TraversorCell<MAP_TYPE, (ORBIT)> NAME_ITER_TraversalMacroLocalLoop(MAP_PARAM); \
for (Dart NAME_ITER = NAME_ITER_TraversalMacroLocalLoop.begin(); NAME_ITER != NAME_ITER_TraversalMacroLocalLoop.end(); NAME_ITER = NAME_ITER_TraversalMacroLocalLoop.next())
template <typename MAP, unsigned int ORBIT>
class TraversorCell //: public Traversor<MAP>
{
......
......@@ -37,20 +37,20 @@ template <typename MAP, unsigned int ORBIT>
class VTraversorCell : public Traversor
{
private:
MAP& m ;
const MAP& m ;
AttributeContainer* cont ;
const AttributeContainer* cont ;
unsigned int qCurrent ;
DartMarker* dmark ;
CellMarker<ORBIT>* cmark ;
AttributeMultiVector<Dart>* quickTraversal ;
const AttributeMultiVector<Dart>* quickTraversal ;
Dart current ;
bool firstTraversal ;
public:
VTraversorCell(MAP& map, bool forceDartMarker = false, unsigned int thread = 0) ;
VTraversorCell(const MAP& map, bool forceDartMarker = false, unsigned int thread = 0) ;
~VTraversorCell() ;
......@@ -68,20 +68,20 @@ template <unsigned int ORBIT>
class VTraversorCell<GenericMap,ORBIT> : public Traversor
{
private:
GenericMap& m ;
const GenericMap& m ;
AttributeContainer* cont ;
const AttributeContainer* cont ;
unsigned int qCurrent ;
DartMarker* dmark ;
CellMarker<ORBIT>* cmark ;
AttributeMultiVector<Dart>* quickTraversal ;
const AttributeMultiVector<Dart>* quickTraversal ;
Dart current ;
bool firstTraversal ;
public:
VTraversorCell(GenericMap& map, bool forceDartMarker = false, unsigned int thread = 0) ;
VTraversorCell(const GenericMap& map, bool forceDartMarker = false, unsigned int thread = 0) ;
~VTraversorCell() ;
......
......@@ -26,7 +26,7 @@ namespace CGoGN
{
template <typename MAP, unsigned int ORBIT>
VTraversorCell<MAP, ORBIT>::VTraversorCell(MAP& map, bool forceDartMarker, unsigned int thread) :
VTraversorCell<MAP, ORBIT>::VTraversorCell(const MAP& map, bool forceDartMarker, unsigned int thread) :
m(map), dmark(NULL), cmark(NULL), quickTraversal(NULL), current(NIL), firstTraversal(true)
{
if(forceDartMarker)
......@@ -159,7 +159,7 @@ void VTraversorCell<MAP, ORBIT>::skip(Dart d)
//special version (partial specialization) for Genric Map
template <unsigned int ORBIT>
VTraversorCell<GenericMap, ORBIT>::VTraversorCell(GenericMap& map, bool forceDartMarker, unsigned int thread) :
VTraversorCell<GenericMap, ORBIT>::VTraversorCell(const GenericMap& map, bool forceDartMarker, unsigned int thread) :
m(map), dmark(NULL), cmark(NULL), quickTraversal(NULL), current(NIL), firstTraversal(true)
{
if(forceDartMarker)
......
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