Commit 9cc6ba9f authored by untereiner's avatar untereiner

modifs algo subdivision

parent 76350c08
......@@ -461,49 +461,49 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
}
}
//position[centralDart] = volCenter;
position[centralDart] = volCenter;
// //Third step : 3-sew internal faces
// for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
// {
// Dart f1 = (*it).first;
// Dart f2 = (*it).second;
//Third step : 3-sew internal faces
for (std::vector<std::pair<Dart,Dart> >::iterator it = subdividedfaces.begin(); it != subdividedfaces.end(); ++it)
{
Dart f1 = (*it).first;
Dart f2 = (*it).second;
if(map.isBoundaryFace(map.phi2(f1)) && map.isBoundaryFace(map.phi2(f2)))
{
std::cout << "boundary" << std::endl;
//id pour toutes les faces interieures
map.sewVolumes(map.phi2(f1), map.phi2(f2));
//
// //Fais a la couture !!!!!
// unsigned int idface = map.getNewFaceId();
// map.setFaceId(map.phi2(f1),idface, FACE);
}
//
// if(map.isBoundaryFace(map.phi2(f1)) && map.isBoundaryFace(map.phi2(f2)))
// {
// std::cout << "boundary" << std::endl;
// //id pour toutes les faces interieures
// map.sewVolumes(map.phi2(f1), map.phi2(f2));
// break;
////
//// //Fais a la couture !!!!!
//// unsigned int idface = map.getNewFaceId();
//// map.setFaceId(map.phi2(f1),idface, FACE);
// }
////
//// //FAIS a la couture !!!!!!!
//// //id pour toutes les aretes exterieurs des faces quadrangulees
//// unsigned int idedge = map.getEdgeId(f1);
//// map.setEdgeId(map.phi2(f1), idedge, DART);
//// map.setEdgeId( map.phi2(f2), idedge, DART);
// }
// //FAIS a la couture !!!!!!!
// //id pour toutes les aretes exterieurs des faces quadrangulees
// unsigned int idedge = map.getEdgeId(f1);
// map.setEdgeId(map.phi2(f1), idedge, DART);
// map.setEdgeId( map.phi2(f2), idedge, DART);
}
// //LA copie de L'id est a gerer avec le sewVolumes normalement !!!!!!
// //id pour les aretes interieurs : (i.e. 6 pour un hexa)
// DartMarker mne(map);
// for(unsigned int i = 0; i < newEdges.size(); ++i)
// {
// if(!mne.isMarked(newEdges[i]))
// {
// unsigned int idedge = map.getNewEdgeId();
// map.setEdgeId(newEdges[i], idedge, EDGE);
// mne.markOrbit(EDGE, newEdges[i]);
// }
// }
//LA copie de L'id est a gerer avec le sewVolumes normalement !!!!!!
//id pour les aretes interieurs : (i.e. 6 pour un hexa)
DartMarker mne(map);
for(unsigned int i = 0; i < newEdges.size(); ++i)
{
if(!mne.isMarked(newEdges[i]))
{
unsigned int idedge = map.getNewEdgeId();
map.setEdgeId(newEdges[i], idedge, EDGE);
mne.markOrbit(EDGE, newEdges[i]);
}
}
//plonger a la fin de la boucle ????
......
......@@ -1154,7 +1154,7 @@ bool MeshTablesSurface<PFP>::mergeCloseVertices()
}
d /= double(nbf);
typename PFP::REAL EPSILON = d/10000.0;
typename PFP::REAL epsilon = d/10000.0;
// traverse vertices
......@@ -1176,7 +1176,7 @@ bool MeshTablesSurface<PFP>::mergeCloseVertices()
typename PFP::VEC3 Q = positions[*v];
Q -= P;
typename PFP::REAL d2 = Q*Q;
if (d2 < EPSILON*EPSILON)
if (d2 < epsilon*epsilon)
{
newIndices[*v] = i;
*v = 0xffffffff;
......
......@@ -22,6 +22,8 @@
* *
*******************************************************************************/
#include "Topology/generic/traversor3.h"
namespace CGoGN
{
......@@ -59,44 +61,20 @@ void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d)
template <typename PFP>
bool isTetrahedron(typename PFP::MAP& the_map, Dart d)
{
DartMarkerStore mark(the_map); // Lock a marker
std::vector<Dart> visitedFaces; // Faces that are traversed
visitedFaces.reserve(64) ;
visitedFaces.push_back(d);
unsigned int nbFaces = 0; // Count the faces
unsigned int nbFaces = 0;
//Test the number of faces end its valency
for(unsigned int i = 0; i < visitedFaces.size(); ++i)
Traversor3WF<typename PFP::MAP> travWF(the_map, d);
for(Dart dit = travWF.begin() ; dit != travWF.end(); dit = travWF.next())
{
Dart dc = visitedFaces[i];
//if this dart is not marked
if(!mark.isMarked(dc))
{
//increase the number of faces
nbFaces++;
if(nbFaces > 4) //too much faces
return false;
//test the valency of this face
if(dc != the_map.phi1(the_map.phi1(the_map.phi1(dc))))
return false;
//mark the face and push adjacent faces
Dart d1 = dc;
for(unsigned int i = 0; i <3 ; ++i)
{
mark.mark(d1);
//if phi2 not marked
Dart d2 = the_map.phi2(d1);
if(!mark.isMarked(d2))
visitedFaces.push_back(d2);
d1 = the_map.phi1(dc);
}
}
//increase the number of faces
nbFaces++;
if(nbFaces > 4) //too much faces
return false;
//test the valency of this face
if(the_map.faceDegree(dit) != 3)
return false;
}
return true;
......@@ -408,83 +386,83 @@ void swap5To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positions)
template <typename PFP>
void flip1To4(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
typedef typename PFP::TVEC3 TVEC3;
typedef typename PFP::VEC3 VEC3;
//parcourir le tetra est sauvegarder un brin de chaque face + calcul du centroid
VEC3 volCenter;
unsigned count = 0 ;
DartMarkerStore mf(map); // Lock a face marker to save one dart per face
DartMarkerStore mv(map); // Lock a vertex marker to compute volume center
std::vector<Dart> visitedFaces;
visitedFaces.reserve(4);
visitedFaces.push_back(d);
mf.markOrbit(FACE, d) ;
//TODO diminuer complexite avec boucle specifique aux tetras
for(unsigned int i = 0; i < visitedFaces.size(); ++i)
{
Dart e = visitedFaces[i] ;
do
{
//compute volume centroid
if(!mv.isMarked(e))
{
volCenter += position[e];
++count;
mv.markOrbit(VERTEX, e);
}
// add all face neighbours to the table
Dart ee = map.phi2(e) ;
if(!mf.isMarked(ee)) // not already marked
{
visitedFaces.push_back(ee) ;
mf.markOrbit(FACE, ee) ;
}
e = map.phi1(e) ;
} while(e != visitedFaces[i]) ;
}
volCenter /= typename PFP::REAL(count) ;
//store the new faces to 3-sew
std::vector<std::pair<Dart,Dart> > nFaces;
nFaces.reserve(6);
//triangule chaque face avec plongement au centroid
for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
{
// on decoud et on ferme le trou
Dart temp = *face;
do
{
nFaces.push_back(std::pair<Dart,Dart>(temp, map.phi2(temp)));
map.unsewFaces(temp);
temp = map.phi1(temp);
}
while(temp != *face);
map.closeHole(*face);
Dart fi = map.phi2(*face);
Dart cd = Algo::Modelisation::trianguleFace<PFP>(map, fi);
position[cd] = volCenter;
}
//coudre les nouveaux brins entre eux par phi3
for (std::vector<std::pair<Dart,Dart> >::iterator face =nFaces.begin(); face != nFaces.end(); ++face)
{
if(map.phi3(map.phi2((*face).first)) == map.phi2((*face).first))
map.sewVolumes(map.phi2((*face).first), map.phi2((*face).second));
}
// typedef typename PFP::TVEC3 TVEC3;
// typedef typename PFP::VEC3 VEC3;
//
//
// //parcourir le tetra est sauvegarder un brin de chaque face + calcul du centroid
// VEC3 volCenter;
// unsigned count = 0 ;
//
// DartMarkerStore mf(map); // Lock a face marker to save one dart per face
// DartMarkerStore mv(map); // Lock a vertex marker to compute volume center
//
// std::vector<Dart> visitedFaces;
// visitedFaces.reserve(4);
// visitedFaces.push_back(d);
//
// mf.markOrbit(FACE, d) ;
//
// //TODO diminuer complexite avec boucle specifique aux tetras
// for(unsigned int i = 0; i < visitedFaces.size(); ++i)
// {
// Dart e = visitedFaces[i] ;
// do
// {
// //compute volume centroid
// if(!mv.isMarked(e))
// {
// volCenter += position[e];
// ++count;
// mv.markOrbit(VERTEX, e);
// }
//
// // add all face neighbours to the table
// Dart ee = map.phi2(e) ;
// if(!mf.isMarked(ee)) // not already marked
// {
// visitedFaces.push_back(ee) ;
// mf.markOrbit(FACE, ee) ;
// }
//
// e = map.phi1(e) ;
// } while(e != visitedFaces[i]) ;
// }
//
// volCenter /= typename PFP::REAL(count) ;
//
// //store the new faces to 3-sew
// std::vector<std::pair<Dart,Dart> > nFaces;
// nFaces.reserve(6);
//
// //triangule chaque face avec plongement au centroid
// for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
// {
// // on decoud et on ferme le trou
// Dart temp = *face;
// do
// {
// nFaces.push_back(std::pair<Dart,Dart>(temp, map.phi2(temp)));
// map.unsewFaces(temp);
// temp = map.phi1(temp);
// }
// while(temp != *face);
//
// map.closeHole(*face);
//
// Dart fi = map.phi2(*face);
//
// Dart cd = Algo::Modelisation::trianguleFace<PFP>(map, fi);
// position[cd] = volCenter;
// }
//
// //coudre les nouveaux brins entre eux par phi3
// for (std::vector<std::pair<Dart,Dart> >::iterator face =nFaces.begin(); face != nFaces.end(); ++face)
// {
//
// if(map.phi3(map.phi2((*face).first)) == map.phi2((*face).first))
// map.sewVolumes(map.phi2((*face).first), map.phi2((*face).second));
// }
}
/************************************************************************************************
......
......@@ -115,6 +115,7 @@ inline void GenericMap::deleteDart(Dart d)
for(unsigned int i = m_mrCurrentLevel; i < m_mrDarts.size(); ++i)
{
unsigned int index = (*m_mrDarts[i])[d.index] ;
std::cout << "deleteDart index = " << index << std::endl << std::endl;
if(isDartValid(index))
deleteDartLine(index) ;
}
......
......@@ -85,6 +85,10 @@ public:
*/
virtual bool flipBackEdge(Dart d) ;
/*
*
*/
virtual void swapEdges(Dart d, Dart e);
// /**
// * The attributes attached to the vertex of dart d are kept on the resulting vertex
// * The attributes attached to the face of dart d are overwritten on the face of dart e
......
......@@ -208,6 +208,12 @@ public:
*/
virtual bool flipBackEdge(Dart d);
//!
/*!
*
*/
void swapEdges(Dart d, Dart e);
// //! Insert an edge after a dart in the vertex orbit
// /*! \pre Dart d and e MUST be different and belong to distinct face
// * \pre Dart e must be phi2-linked with its phi_1 dart
......
......@@ -238,6 +238,12 @@ public:
*/
bool isBoundaryVertex(Dart d) ;
//! Find the dart of vertex that belong to the boundary
/*! return NIL if the vertex is not on the boundary
* @param d a dart
*/
Dart findBoundaryFaceOfVertex(Dart d) ;
//! Test if dart d and e belong to the same oriented edge
/*! @param d a dart
* @param e a dart
......@@ -255,14 +261,14 @@ public:
*/
unsigned int edgeDegree(Dart d) ;
/**
* tell if the edge of d is on the boundary of the map
//! Tell if the edge of d is on the boundary of the map
/*! @param d a dart
*/
bool isBoundaryEdge(Dart d) ;
/**
* find the dart of edge that belong to the boundary
* return NIL if the edge is not on the boundary
//! Find the dart of edge that belong to the boundary
/*! return NIL if the edge is not on the boundary
* @param d a dart
*/
Dart findBoundaryFaceOfEdge(Dart d) ;
......
......@@ -103,7 +103,7 @@ public:
void clear();
/**
* once all string are stored, we must send it to the gracphic card
* once all string are stored, we must send it to the graphic card
*/
void sendToVBO();
......
......@@ -570,7 +570,6 @@ unsigned int ImplicitHierarchicalMap3::volumeLevel(Dart d)
if(m_dartLevel[old] < m_dartLevel[oldest])
oldest = old ;
//
// add all face neighbours to the table
//
......
......@@ -208,6 +208,29 @@ bool EmbeddedMap2::flipBackEdge(Dart d)
return false ;
}
void EmbeddedMap2::swapEdges(Dart d, Dart e)
{
Dart d2 = phi2(d);
Dart e2 = phi2(e);
Map2::swapEdges(d,e);
if(isOrbitEmbedded(VERTEX))
{
copyDartEmbedding(VERTEX, d, phi2(phi_1(d)));
copyDartEmbedding(VERTEX, e, phi2(phi_1(e)));
copyDartEmbedding(VERTEX, d2, phi2(phi_1(d2)));
copyDartEmbedding(VERTEX, e2, phi2(phi_1(e2)));
}
if(isOrbitEmbedded(EDGE))
{
}
if(isOrbitEmbedded(VOLUME))
embedNewCell(VOLUME, d);
}
//void EmbeddedMap2::insertEdgeInVertex(Dart d, Dart e)
//{
// Map2::insertEdgeInVertex(d, e);
......
......@@ -325,6 +325,20 @@ bool Map2::flipBackEdge(Dart d)
return false ; // cannot flip a border edge
}
void Map2::swapEdges(Dart d, Dart e)
{
assert(!Map2::isBoundaryEdge(d) && !Map2::isBoundaryEdge(e));
Dart d2 = phi2(d);
Dart e2 = phi2(e);
phi2unsew(d);
phi2unsew(e) ;
phi2sew(d, e);
//phi2sew(d2, e2);
}
//void Map2::insertEdgeInVertex(Dart d, Dart e)
//{
// assert(!sameVertex(d,e) && phi2(e) == phi_1(e));
......@@ -538,10 +552,10 @@ void Map2::splitSurface(std::vector<Dart>& vd, bool firstSideClosed, bool second
unsewFaces(*it) ;
if(firstSideClosed)
fillHole(e) ;
Map2::fillHole(e) ;
if(secondSideClosed)
fillHole(e2) ;
Map2::fillHole(e2) ;
}
/*! @name Topological Queries
......
......@@ -636,6 +636,39 @@ bool Map3::isBoundaryVertex(Dart d)
return false ;
}
Dart Map3::findBoundaryFaceOfVertex(Dart d)
{
DartMarkerStore mv(*this); // Lock a marker
std::vector<Dart> darts; // Darts that are traversed
darts.reserve(256);
darts.push_back(d); // Start with the dart d
mv.mark(d);
for(unsigned int i = 0; i < darts.size(); ++i)
{
if(isBoundaryMarked(darts[i]))
return darts[i];
//add phi21 and phi23 successor if they are not marked yet
Dart d2 = phi2(darts[i]);
Dart d21 = phi1(d2); // turn in volume
Dart d23 = phi3(d2); // change volume
if(!mv.isMarked(d21))
{
darts.push_back(d21);
mv.mark(d21);
}
if(!mv.isMarked(d23))
{
darts.push_back(d23);
mv.mark(d23);
}
}
return NIL ;
}
bool Map3::sameOrientedEdge(Dart d, Dart e)
{
Dart it = 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