Commit b9d7e3e2 authored by untereiner's avatar untereiner

Merge cgogn:~/CGoGN into HEAD

Conflicts:
	include/Algo/Modelisation/subdivision.h
	include/Algo/Modelisation/subdivision.hpp
	src/Topology/map/map3.cpp
parents 0f521214 9f0583a0
......@@ -130,13 +130,20 @@ void DooSabin(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& posit
//template <typename PFP>
//void Sqrt3Subdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, const FunctorSelect& selected = allDarts) ;
template <typename PFP>
void computeDual(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position);
template <typename PFP>
void computeBoundaryConstraintDual(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position);
template <typename PFP>
void computeBoundaryConstraintKeepingOldVerticesDual(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position);
} // namespace Modelisation
}
} // namespace Surface
} // namespace Algo
......
......@@ -697,11 +697,176 @@ inline double sqrt3_K(unsigned int n)
// }
//}
template <typename PFP>
void computeDual(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position)
{
// Face Attribute -> after dual new Vertex Attribute
FaceAttribute<typename PFP::VEC3> positionF = map.template getAttribute<typename PFP::VEC3, FACE>("position") ;
if(!positionF.isValid())
positionF = map.template addAttribute<typename PFP::VEC3, FACE>("position") ;
} // namespace Modelisation
// Compute Centroid for the faces
Algo::Surface::Geometry::computeCentroidFaces<PFP>(map, position, positionF) ;
// Compute the Dual mesh
map.computeDual();
position = positionF ;
}
template <typename PFP>
void computeBoundaryConstraintDual(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position)
{
// Face Attribute -> after dual new Vertex Attribute
FaceAttribute<typename PFP::VEC3> positionF = map.template getAttribute<typename PFP::VEC3, FACE>("position") ;
if(!positionF.isValid())
positionF = map.template addAttribute<typename PFP::VEC3, FACE>("position") ;
//Triangule boundary faces & compute for each new face the centroid
std::vector<Dart> boundsDart;
DartMarkerStore mf(map);
for(Dart dit = map.begin() ; dit != map.end() ; map.next(dit))
{
if(!mf.isMarked(dit) && map.isBoundaryMarked2(dit))
{
boundsDart.push_back(dit);
Dart db = dit;
Dart d1 = map.phi1(db);
Dart dprev = map.phi_1(db);
map.splitFace(db, d1) ;
map.cutEdge(map.phi_1(db)) ;
positionF[dit] = (position[dit] + position[map.phi2(dit)]) * typename PFP::REAL(0.5);
mf.markOrbit<FACE>(dit);
Dart x = map.phi2(map.phi_1(db)) ;
Dart dd = map.phi1(map.phi1(map.phi1(x)));
while(dd != x)
{
Dart next = map.phi1(dd) ;
Dart prev = map.phi_1(dd);
map.splitFace(dd, map.phi1(x)) ;
positionF[prev] = (position[prev] + position[map.phi1(prev)]) * typename PFP::REAL(0.5);
mf.markOrbit<FACE>(prev);
dd = next ;
}
positionF[dprev] = (position[dprev] + position[map.phi1(dprev)]) * typename PFP::REAL(0.5);
mf.markOrbit<FACE>(dprev);
}
}
// Compute Centroid for the other faces
Algo::Surface::Geometry::computeCentroidFaces<PFP>(map, position, positionF) ;
// Fill the holes
for(Dart dit = map.begin() ; dit != map.end() ; map.next(dit))
{
if(mf.isMarked(dit) && map.isBoundaryMarked2(dit))
{
map.fillHole(dit);
mf.unmarkOrbit<FACE>(dit);
}
}
// Compute the Dual mesh
map.computeDual();
position = positionF ;
// Create the new border with the old boundary edges
for(std::vector<Dart>::iterator it = boundsDart.begin() ; it != boundsDart.end() ; ++it)
{
map.createHole(map.phi2(map.phi1(*it)));
}
}
template <typename PFP>
void computeBoundaryConstraintKeepingOldVerticesDual(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position)
{
// Face Attribute -> after dual new Vertex Attribute
FaceAttribute<typename PFP::VEC3> positionF = map.template getAttribute<typename PFP::VEC3, FACE>("position") ;
if(!positionF.isValid())
positionF = map.template addAttribute<typename PFP::VEC3, FACE>("position") ;
//Triangule boundary faces & compute for each new face the centroid
std::vector<Dart> boundsDart;
DartMarkerStore mf(map);
for(Dart dit = map.begin() ; dit != map.end() ; map.next(dit))
{
if(!mf.isMarked(dit) && map.isBoundaryMarked2(dit))
{
boundsDart.push_back(dit);
Dart db = dit;
Dart d1 = map.phi1(db);
Dart dprev = map.phi_1(db);
map.splitFace(db, d1) ;
map.cutEdge(map.phi_1(db)) ;
positionF[dit] = (position[dit] + position[map.phi2(dit)]) * typename PFP::REAL(0.5);
mf.markOrbit<FACE>(dit);
Dart x = map.phi2(map.phi_1(db)) ;
Dart dd = map.phi1(map.phi1(map.phi1(x)));
while(dd != x)
{
Dart next = map.phi1(dd) ;
Dart prev = map.phi_1(dd);
map.splitFace(dd, map.phi1(x)) ;
positionF[prev] = (position[prev] + position[map.phi1(prev)]) * typename PFP::REAL(0.5);
mf.markOrbit<FACE>(prev);
dd = next ;
}
positionF[dprev] = (position[dprev] + position[map.phi1(dprev)]) * typename PFP::REAL(0.5);
mf.markOrbit<FACE>(dprev);
}
}
// Compute Centroid for the other faces
Algo::Surface::Geometry::computeCentroidFaces<PFP>(map, position, positionF) ;
// Fill the holes
for(Dart dit = map.begin() ; dit != map.end() ; map.next(dit))
{
if(mf.isMarked(dit) && map.isBoundaryMarked2(dit))
{
map.fillHole(dit);
mf.unmarkOrbit<FACE>(dit);
}
}
// Compute the Dual mesh
map.computeDual();
//Saving old position VertexAttribute to a FaceAttribute
FaceAttribute<typename PFP::VEC3> temp;
temp = position;
position = positionF ;
positionF = temp;
// Create the new border with the old boundary edges
for(std::vector<Dart>::iterator it = boundsDart.begin() ; it != boundsDart.end() ; ++it)
{
map.createHole(map.phi2(map.phi1(*it)));
}
// Manage old vertices with new FaceAttribute
for(Dart dit = map.begin() ; dit != map.end() ; map.next(dit))
{
if(!mf.isMarked(dit) && map.isBoundaryMarked2(dit))
{
Dart nd = map.cutEdge(dit);
position[nd] = positionF[map.phi2(dit)];
mf.markOrbit<EDGE>(dit);
mf.markOrbit<EDGE>(nd);
}
}
}
} // namespace Modelisation
} // namespace Surface
} // namespace Algo
} // namespace CGoGN
......@@ -102,15 +102,13 @@ void catmullClarkVol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>
template <typename PFP>
void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, const FunctorSelect& selected = allDarts);
///**
// * Dual mesh computation
// */
//template <typename PFP>
//void computeDual3(typename PFP::MAP& map, const FunctorSelect& selected = allDarts) ;
template <typename PFP>
void computeDual(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position);
} // namespace Modelisation
}
} // namespace Volume
} // namespace Algo
......
......@@ -716,87 +716,21 @@ void sqrt3Vol(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& posit
}
}
//template <typename PFP>
//void reverseOrientation3(typename PFP::MAP& map)
//{
// DartAttribute<unsigned int> emb0(&map, map.template getEmbeddingAttributeVector<VERTEX>()) ;
// if(emb0.isValid())
// {
// DartAttribute<unsigned int> new_emb0 = map.template addAttribute<unsigned int, DART>("new_EMB_0") ;
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// new_emb0[d] = emb0[map.phi1(d)] ;
// map.template swapAttributes<unsigned int>(emb0, new_emb0) ;
// map.removeAttribute(new_emb0) ;
// }
//
// DartAttribute<Dart> phi2 = map.template getAttribute<Dart, DART>("phi2") ;
// DartAttribute<Dart> phi3 = map.template getAttribute<Dart, DART>("phi3") ;
// map.template swapAttributes<Dart>(phi2, phi3) ;
//}
//
//template <typename PFP>
//void computeDual3(typename PFP::MAP& map, const FunctorSelect& selected)
//{
// DartAttribute<Dart> phi1 = map.template getAttribute<Dart, DART>("phi1") ;
// DartAttribute<Dart> phi_1 = map.template getAttribute<Dart, DART>("phi_1") ;
// DartAttribute<Dart> new_phi1 = map.template addAttribute<Dart, DART>("new_phi1") ;
// DartAttribute<Dart> new_phi_1 = map.template addAttribute<Dart, DART>("new_phi_1") ;
//
// DartAttribute<Dart> phi2 = map.template getAttribute<Dart, DART>("phi2") ;
// DartAttribute<Dart> new_phi2 = map.template addAttribute<Dart, DART>("new_phi2") ;
//
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// {
// Dart dd = map.phi2(map.phi3(d)) ;
// new_phi1[d] = dd ;
// new_phi_1[dd] = d ;
//
// Dart ddd = map.phi1(map.phi3(d));
// new_phi2[d] = ddd;
// new_phi2[ddd] = d;
// }
//
// map.template swapAttributes<Dart>(phi1, new_phi1) ;
// map.template swapAttributes<Dart>(phi_1, new_phi_1) ;
// map.template swapAttributes<Dart>(phi2, new_phi2) ;
//
// map.removeAttribute(new_phi1) ;
// map.removeAttribute(new_phi_1) ;
// map.removeAttribute(new_phi2) ;
//
// map.swapEmbeddingContainers(VERTEX, VOLUME) ;
//
// for(Dart d = map.begin(); d != map.end(); map.next(d))
// {
// if(map.isBoundaryMarked(d))
// {
// map.deleteVolume(d);
//// Traversor3VW<typename PFP::MAP> tWV(map, d);
//// std::vector<Dart> v;
//// for(Dart ditW = tWV.begin() ; ditW != tWV.end() ; ditW = tWV.next())
//// {
//// v.push_back(ditW);
//// }
////
//// for(std::vector<Dart>::iterator it = v.begin() ; it != v.end() ; ++it)
//// {
//// map.deleteVolume(*it);
//// }
//
// }
// }
//
//// reverseOrientation3<PFP>(map) ;
//
// //boundary management
//// for(Dart d = map.begin(); d != map.end(); map.next(d))
//// {
//// if(map.isBoundaryMarked(d))
//// {
//// map.deleteVolume(d); //map.template boundaryMarkOrbit<VOLUME>(
//// }
//// }
//}
template <typename PFP>
void computeDual(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position)
{
// VolumeAttribute -> after dual new VertexAttribute
VolumeAttribute<typename PFP::VEC3> positionV = map.template getAttribute<typename PFP::VEC3, VOLUME>("position") ;
if(!positionV.isValid())
positionV = map.template addAttribute<typename PFP::VEC3, VOLUME>("position") ;
// Compute Centroid for the volumes
Algo::Volume::Geometry::computeCentroidVolumes<PFP>(map, position, positionV) ;
// Compute the Dual mesh
map.computeDual();
position = positionV ;
}
} //namespace Modelisation
......
......@@ -1300,26 +1300,28 @@ void Map3::computeDual()
std::vector<Dart> vbound;
for(Dart d = begin(); d != end(); next(d))
{
if(isBoundaryMarked3(d) && !isBoundaryMarked3(phi3(d)))
{
vbound.push_back(d);
}
}
std::cout << "vbound size = " << vbound.size() << std::endl;
for(std::vector<Dart>::iterator it = vbound.begin() ; it != vbound.end() ; ++it)
{
Dart d = *it;
//Dart d3 = phi3(d);
phi3unsew(d);
//phi3unsew(d3);
}
//std::cout << "nb faces : " << closeMap() << std::endl;
// for(Dart d = begin(); d != end(); next(d))
// {
// if(isBoundaryMarked3(d) && !isBoundaryMarked3(phi3(d)))
// {
// vbound.push_back(d);
// }
// }
//
// std::cout << "vbound size = " << vbound.size() << std::endl;
//
// for(std::vector<Dart>::iterator it = vbound.begin() ; it != vbound.end() ; ++it)
// {
// Dart d = *it;
// //Dart d3 = phi3(d);
// phi3unsew(d);
// //phi3unsew(d3);
// }
//
// //std::cout << "nb faces : " << closeMap() << std::endl;
//
// if(d == 14208)
// {
// std::cout << "yeahhhhhhhh" << std::endl;
......@@ -1468,7 +1470,6 @@ void Map3::computeDualTest()
new_phi1[d] = dd ;
new_phi_1[dd] = d ;
//Dart ddd = phi3(phi_1(d));
Dart ddd = phi1(phi3(d));
new_phi2[d] = ddd;
new_phi2[ddd] = d;
......
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