Commit 424ba2db authored by untereiner's avatar untereiner

correction namespace Map3MR + adding functions in map2/map3

parent e0307c22
......@@ -67,89 +67,15 @@ int main(int argc, char **argv)
VertexAttribute<PFP::VEC3> position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]);
//
// Dual
//
// FaceAttribute<PFP::VEC3> positionF = myMap.getAttribute<PFP::VEC3, FACE>("position") ;
// if(!positionF.isValid())
// positionF = myMap.addAttribute<PFP::VEC3, FACE>("position") ;
//
// Algo::Surface::Geometry::computeCentroidFaces<PFP>(myMap, position, positionF) ;
// myMap.computeDual();
// position = positionF ;
// AttributeHandler<PFP::VEC3, PFP::MAP::EDGE_OF_PARENT> positionE = myMap.getAttribute<PFP::VEC3, PFP::MAP::EDGE_OF_PARENT>("position") ;
// if(!positionE.isValid())
// positionE = myMap.addAttribute<PFP::VEC3, PFP::MAP::EDGE_OF_PARENT>("position") ;
//
// SelectorDartBoundary<PFP::MAP> sdb(myMap);
// TraversorE<PFP::MAP> te(myMap, sdb);
// for(Dart dit = te.begin() ; dit != te.end() ; dit = te.next())
// {
// positionE[dit] = (position[dit] + position[myMap.phi1(dit)]) * PFP::REAL(0.5);
// }
//
// std::cout << "boundary edges centroids : ok" << std::endl;
//
// //triangule old boundary faces
// std::vector<Dart> oldb;
//
// std::cout << "nb darts : " << myMap.getNbDarts() << std::endl;
//
// CellMarker<FACE> cmf(myMap);
// for(Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
// {
// if(!cmf.isMarked(d) && myMap.isBoundaryMarked2(d))
// {
// oldb.push_back(d);
// cmf.mark(d);
// std::cout << "d = " << d << std::endl;
// }
// }
//
// for(std::vector<Dart>::iterator it = oldb.begin() ; it != oldb.end() ; ++it)
// {
// Dart db = *it;
// Dart d1 = myMap.phi1(db);
// myMap.splitFace(db, d1) ;
// myMap.cutEdge(myMap.phi_1(db)) ;
// Dart x = myMap.phi2(myMap.phi_1(db)) ;
// Dart dd = myMap.phi1(myMap.phi1(myMap.phi1(x)));
// while(dd != x)
// {
// Dart next = myMap.phi1(dd) ;
// myMap.splitFace(dd, myMap.phi1(x)) ;
// dd = next ;
// }
//
// }
//
// std::cout << "boundary face triangulation : ok" << std::endl;
//
// myMap.swapEmbeddingContainers(FACE, PFP::MAP::EDGE_OF_PARENT) ;
//
// std::cout << "swap containers : ok" << std::endl;
//
// FaceAttribute<PFP::VEC3> positionF;
// positionF = positionE;
//
// Algo::Surface::Geometry::computeCentroidFaces<PFP>(myMap, position, positionF) ;
//
// for(std::vector<Dart>::iterator it = oldb.begin() ; it != oldb.end() ; ++it)
// {
// myMap.fillHole(*it);
// }
//
// std::cout << "fillHole : ok" << std::endl;
//
// myMap.computeDual();
//
// //myMap.closeMap();
//
// position = positionF ;
//
// myMap.check();
FaceAttribute<PFP::VEC3> positionF = myMap.getAttribute<PFP::VEC3, FACE>("position") ;
if(!positionF.isValid())
positionF = myMap.addAttribute<PFP::VEC3, FACE>("position") ;
Algo::Surface::Geometry::computeCentroidFaces<PFP>(myMap, position, positionF) ;
myMap.computeDual();
position = positionF ;
Algo::Surface::Export::exportOFF<PFP>(myMap, position, "result.off");
std::cout << "Exported" << std::endl;
......
......@@ -59,7 +59,7 @@ namespace Filters
//w-lift(a)
template <typename PFP>
class Ber02OddSynthesisFilter : public Filter
class Ber02OddSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -154,7 +154,7 @@ public:
// s-lift(a)
template <typename PFP>
class Ber02EvenSynthesisFilter : public Filter
class Ber02EvenSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -371,7 +371,7 @@ public:
// s-scale(a)
template <typename PFP>
class Ber02ScaleSynthesisFilter : public Filter
class Ber02ScaleSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -426,7 +426,7 @@ public:
//w-lift(a)
template <typename PFP>
class Ber02OddAnalysisFilter : public Filter
class Ber02OddAnalysisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -521,7 +521,7 @@ public:
// s-lift(a)
template <typename PFP>
class Ber02EvenAnalysisFilter : public Filter
class Ber02EvenAnalysisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -738,7 +738,7 @@ public:
// s-scale(a)
template <typename PFP>
class Ber02ScaleAnalysisFilter : public Filter
class Ber02ScaleAnalysisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......
......@@ -58,7 +58,7 @@ namespace Filters
template <typename PFP>
class LerpQuadOddSynthesisFilter : public Filter
class LerpQuadOddSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -73,7 +73,7 @@ public:
TraversorW<typename PFP::MAP> travW(m_map) ;
for (Dart d = travW.begin(); d != travW.end(); d = travW.next())
{
typename PFP::VEC3 vc = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
unsigned int count = 0;
typename PFP::VEC3 ec(0.0);
......@@ -169,7 +169,7 @@ public:
template <typename PFP>
class LerpQuadOddAnalysisFilter : public Filter
class LerpQuadOddAnalysisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -222,7 +222,7 @@ public:
TraversorW<typename PFP::MAP> travW(m_map) ;
for (Dart d = travW.begin(); d != travW.end(); d = travW.next())
{
typename PFP::VEC3 vc = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
typename PFP::VEC3 vc = Algo::Surface::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
unsigned int count = 0;
typename PFP::VEC3 ec(0.0);
......@@ -275,7 +275,7 @@ public:
template <typename PFP>
class LerpEdgeSynthesisFilter : public Filter
class LerpEdgeSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -303,7 +303,7 @@ public:
} ;
template <typename PFP>
class LerpFaceSynthesisFilter : public Filter
class LerpFaceSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -332,7 +332,7 @@ public:
} ;
template <typename PFP>
class LerpTriQuadFaceSynthesisFilter : public Filter
class LerpTriQuadFaceSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -349,7 +349,7 @@ public:
{
if(m_map.faceDegree(d) > 3)
{
typename PFP::VEC3 p = Algo::Geometry::faceCentroid<PFP>(m_map, d, m_position);
typename PFP::VEC3 p = Algo::Surface::Geometry::faceCentroid<PFP>(m_map, d, m_position);
m_map.incCurrentLevel() ;
......@@ -364,7 +364,7 @@ public:
template <typename PFP>
class LerpVolumeSynthesisFilter : public Filter
class LerpVolumeSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -379,9 +379,11 @@ public:
TraversorW<typename PFP::MAP> trav(m_map) ;
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
if(!Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d) && !Algo::Modelisation::isPrism<PFP>(m_map,d) && !Algo::Modelisation::isPyra<PFP>(m_map,d))
if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,d)
&& !Algo::Surface::Modelisation::isPrism<PFP>(m_map,d)
&& !Algo::Surface::Modelisation::isPyra<PFP>(m_map,d))
{
typename PFP::VEC3 p = Algo::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
typename PFP::VEC3 p = Algo::Surface::Geometry::volumeCentroid<PFP>(m_map, d, m_position);
m_map.incCurrentLevel() ;
......@@ -395,7 +397,7 @@ public:
} ;
template <typename PFP>
class LerpSqrt3VolumeSynthesisFilter : public Filter
class LerpSqrt3VolumeSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......
......@@ -50,7 +50,7 @@ namespace Filters
/* Catmull-clark on Boundary Vertices and MJ96 on Insides Vertices
*********************************************************************************/
template <typename PFP>
class MJ96VertexSubdivision : public Filter
class MJ96VertexSubdivision : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -155,7 +155,7 @@ public:
};
template <typename PFP>
class MJ96EdgeSubdivision : public Filter
class MJ96EdgeSubdivision : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -245,7 +245,7 @@ public:
};
template <typename PFP>
class MJ96FaceSubdivision : public Filter
class MJ96FaceSubdivision : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -305,7 +305,7 @@ public:
};
template <typename PFP>
class MJ96VolumeSubdivision : public Filter
class MJ96VolumeSubdivision : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......
......@@ -156,7 +156,7 @@ typename PFP::VEC3 SHW04Vertex(typename PFP::MAP& map, const VertexAttribute<typ
*********************************************************************************/
template <typename PFP>
class LoopEvenAnalysisFilter : public Filter
class LoopEvenAnalysisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -182,7 +182,7 @@ public:
} ;
template <typename PFP>
class LoopNormalisationAnalysisFilter : public Filter
class LoopNormalisationAnalysisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -212,7 +212,7 @@ public:
} ;
template <typename PFP>
class LoopOddAnalysisFilter : public Filter
class LoopOddAnalysisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -263,7 +263,7 @@ public:
/* Loop on Boundary Vertices and SHW04 on Insides Vertices
*********************************************************************************/
template <typename PFP>
class LoopOddSynthesisFilter : public Filter
class LoopOddSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -306,7 +306,7 @@ public:
} ;
template <typename PFP>
class LoopNormalisationSynthesisFilter : public Filter
class LoopNormalisationSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -336,7 +336,7 @@ public:
} ;
template <typename PFP>
class LoopEvenSynthesisFilter : public Filter
class LoopEvenSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -362,7 +362,7 @@ public:
} ;
template <typename PFP>
class LoopVolumeSynthesisFilter : public Filter
class LoopVolumeSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......@@ -393,7 +393,7 @@ public:
} ;
template <typename PFP>
class SHW04VolumeNormalisationSynthesisFilter : public Filter
class SHW04VolumeNormalisationSynthesisFilter : public Algo::MR::Filter
{
protected:
typename PFP::MAP& m_map ;
......
......@@ -133,88 +133,88 @@ void Map3MR<PFP>::splitSurfaceInVolume(std::vector<Dart>& vd, bool firstSideClos
/************************************************************************
* Level creation *
************************************************************************/
template <typename PFP>
void Map3MR<PFP>::addNewLevelSqrt3(bool embedNewVertices)
{
m_map.pushLevel();
m_map.addLevelBack();
m_map.duplicateDarts(m_map.getMaxLevel());
m_map.setCurrentLevel(m_map.getMaxLevel());
DartMarkerStore m(m_map);
//
// 1-4 flip of all tetrahedra
//
TraversorW<typename PFP::MAP> tW(m_map);
for(Dart dit = tW.begin() ; dit != tW.end() ; dit = tW.next())
{
Traversor3WF<typename PFP::MAP> tWF(m_map, dit);
for(Dart ditWF = tWF.begin() ; ditWF != tWF.end() ; ditWF = tWF.next())
{
if(!m_map.isBoundaryFace(ditWF))
m.markOrbit<FACE>(ditWF);
}
Algo::Volume::Modelisation::Tetrahedralization::flip1To4<PFP>(m_map, dit);
}
/*
//
// 2-3 swap of all old interior faces
//
TraversorF<typename PFP::MAP> tF(m_map);
for(Dart dit = tF.begin() ; dit != tF.end() ; dit = tF.next())
{
if(m.isMarked(dit))
{
m.unmarkOrbit<FACE>(dit);
Algo::Volume::Modelisation::Tetrahedralization::swap2To3<PFP>(m_map, dit);
}
}
//
// 1-3 flip of all boundary tetrahedra
//
TraversorW<typename PFP::MAP> tWb(m_map);
for(Dart dit = tWb.begin() ; dit != tWb.end() ; dit = tWb.next())
{
if(m_map.isBoundaryVolume(dit))
{
Traversor3WE<typename PFP::MAP> tWE(m_map, dit);
for(Dart ditWE = tWE.begin() ; ditWE != tWE.end() ; ditWE = tWE.next())
{
if(m_map.isBoundaryEdge(ditWE))
m.markOrbit<EDGE>(ditWE);
}
Algo::Volume::Modelisation::Tetrahedralization::flip1To3<PFP>(m_map, dit);
}
}
//
// edge-removal on all old boundary edges
//
TraversorE<typename PFP::MAP> tE(m_map);
for(Dart dit = tE.begin() ; dit != tE.end() ; dit = tE.next())
{
if(m.isMarked(dit))
{
m.unmarkOrbit<EDGE>(dit);
Dart d = m_map.phi2(m_map.phi3(m_map.findBoundaryFaceOfEdge(dit)));
Algo::Volume::Modelisation::Tetrahedralization::swapGen3To2<PFP>(m_map, d);
}
}
*/
m_map.setCurrentLevel(m_map.getMaxLevel());
m_map.popLevel() ;
}
//template <typename PFP>
//void Map3MR<PFP>::addNewLevelSqrt3(bool embedNewVertices)
//{
// m_map.pushLevel();
//
// m_map.addLevelBack();
// m_map.duplicateDarts(m_map.getMaxLevel());
// m_map.setCurrentLevel(m_map.getMaxLevel());
//
// DartMarkerStore m(m_map);
//
// //
// // 1-4 flip of all tetrahedra
// //
// TraversorW<typename PFP::MAP> tW(m_map);
// for(Dart dit = tW.begin() ; dit != tW.end() ; dit = tW.next())
// {
// Traversor3WF<typename PFP::MAP> tWF(m_map, dit);
// for(Dart ditWF = tWF.begin() ; ditWF != tWF.end() ; ditWF = tWF.next())
// {
// if(!m_map.isBoundaryFace(ditWF))
// m.markOrbit<FACE>(ditWF);
// }
//
// Algo::Volume::Modelisation::Tetrahedralization::flip1To4<PFP>(m_map, dit);
// }
//
///*
// //
// // 2-3 swap of all old interior faces
// //
// TraversorF<typename PFP::MAP> tF(m_map);
// for(Dart dit = tF.begin() ; dit != tF.end() ; dit = tF.next())
// {
// if(m.isMarked(dit))
// {
// m.unmarkOrbit<FACE>(dit);
// Algo::Volume::Modelisation::Tetrahedralization::swap2To3<PFP>(m_map, dit);
// }
// }
//
// //
// // 1-3 flip of all boundary tetrahedra
// //
// TraversorW<typename PFP::MAP> tWb(m_map);
// for(Dart dit = tWb.begin() ; dit != tWb.end() ; dit = tWb.next())
// {
// if(m_map.isBoundaryVolume(dit))
// {
// Traversor3WE<typename PFP::MAP> tWE(m_map, dit);
// for(Dart ditWE = tWE.begin() ; ditWE != tWE.end() ; ditWE = tWE.next())
// {
// if(m_map.isBoundaryEdge(ditWE))
// m.markOrbit<EDGE>(ditWE);
// }
//
// Algo::Volume::Modelisation::Tetrahedralization::flip1To3<PFP>(m_map, dit);
// }
// }
//
// //
// // edge-removal on all old boundary edges
// //
// TraversorE<typename PFP::MAP> tE(m_map);
// for(Dart dit = tE.begin() ; dit != tE.end() ; dit = tE.next())
// {
// if(m.isMarked(dit))
// {
// m.unmarkOrbit<EDGE>(dit);
// Dart d = m_map.phi2(m_map.phi3(m_map.findBoundaryFaceOfEdge(dit)));
// Algo::Volume::Modelisation::Tetrahedralization::swapGen3To2<PFP>(m_map, d);
//
// }
// }
//*/
//
// m_map.setCurrentLevel(m_map.getMaxLevel());
// m_map.popLevel() ;
//}
template <typename PFP>
void Map3MR<PFP>::addNewLevelTetraOcta(bool embedNewVertices)
void Map3MR<PFP>::addNewLevelTetraOcta()
{
m_map.pushLevel();
......@@ -778,7 +778,7 @@ void Map3MR<PFP>::addNewLevel()
m_map.incCurrentLevel();
Dart x = m_map.phi_1(m_map.phi2(m_map.phi1(ditWV)));
if(!Algo::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,x))
if(!Algo::Volume::Modelisation::Tetrahedralization::isTetrahedron<PFP>(m_map,x))
{
DartMarkerStore me(m_map);
......
......@@ -265,7 +265,6 @@ public:
FaceAttribute(GenericMap* m, AttributeMultiVector<T>* amv) : AttributeHandler<T, FACE>(m,amv) {}
FaceAttribute<T>& operator=(const AttributeHandler<T, FACE>& ah) { this->AttributeHandler<T, FACE>::operator=(ah); return *this; }
FaceAttribute<T>& operator=(const AttributeHandler<T, VERTEX>& ah) { this->AttributeHandler<T,FACE>::operator=(ah); return *this; }
FaceAttribute<T>& operator=(const AttributeHandler<T, EDGE>& ah) { this->AttributeHandler<T,FACE>::operator=(ah); return *this; } //TODO dangerous
};
/**
......
......@@ -149,6 +149,12 @@ public:
* @param d a dart of the face to fill
*/
virtual void fillHole(Dart d) ;
//! Open the mesh Transforming a face in a hole
/*! \pre Dart d is NOT boundary marked
* @param d a dart of the face filled
*/
virtual void createHole(Dart d) ;
//@}
/*! @name Topological Operators
......@@ -487,17 +493,6 @@ public:
/*! Crop the infinite faces of open meshes
*/
void computeDual();
//! Dual mesh computation (open mesh)
/*! Fit the infinite faces vertices to the middle of the old boundary edges
*/
void computeDualBorderConstraint();
//! Dual mesh computation (open mesh)
/*! Fit the infinite faces vertices to the middle of the old boundary edges AND
* fit the middle of the new boundary edges to the old boundary vertices
*/
//void computeDualBorderConstraintWithOldVertices();
//@}
};
......
......@@ -130,13 +130,19 @@ public:
/*! The phi3-links around the volume are removed
* @param d a dart of the volume
*/
virtual void deleteVolume(Dart d);
virtual void deleteVolume(Dart d, bool withBoundary = true);
//! Fill a hole with a volume
/*! \pre Dart d is boundary marked
* @param d a dart of the volume to fill
*/
virtual void fillHole(Dart d) ;
//! Open the mesh Transforming a face in a hole
/*! \pre Dart d is NOT boundary marked
* @param d a dart of the face filled
*/
virtual void createHole(Dart d) ;
//@}
/*! @name Topological Operators
......
......@@ -190,6 +190,12 @@ void Map2::fillHole(Dart d)
boundaryUnmarkOrbit<FACE,2>(dd) ;
}
void Map2::createHole(Dart d)
{
assert(!isBoundaryEdge(d)) ;
boundaryMarkOrbit<FACE,2>(d) ;
}
/*! @name Topological Operators
* Topological operations on 2-maps
*************************************************************************/
......@@ -942,74 +948,6 @@ void Map2::computeDual()
reverseOrientation() ;
// //boundary management
// for(Dart d = begin(); d != end(); next(d))
// {
// if(isBoundaryMarked2(d))
// {
// boundaryMarkOrbit<FACE,2>(deleteVertex(phi2(d)));
// }
// }
}
//TODO triangulation of the boundary face to compute correctly the dual(dual(T)) of mesh T
void Map2::computeDualBorderConstraint()
{
std::vector<Dart> oldb;
for(Dart d = begin(); d != end(); next(d))
{
if(isBoundaryMarked2(d))
{
oldb.push_back(d);
fillHole(d);
}
}
//triangule old boundary faces
for(std::vector<Dart>::iterator it = oldb.begin() ; it != oldb.end() ; ++it)