Commit f64adf62 authored by David Cazier's avatar David Cazier

Essai de simplifications

parent 67742dd3
......@@ -89,4 +89,9 @@ target_link_libraries( clippingD
QT4_WRAP_CPP(tutoriel_moc ../tutoriel.h)
add_executable( tutorielD ../tutoriel.cpp ${tutoriel_moc})
target_link_libraries( tutorielD
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_CPP(essais_moc ../essais.h)
add_executable( essaisD ../essais.cpp ${essais_moc})
target_link_libraries( essaisD
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
\ No newline at end of file
......@@ -86,3 +86,8 @@ QT4_WRAP_CPP(tutoriel_moc ../tutoriel.h)
add_executable( tutoriel ../tutoriel.cpp ${tutoriel_moc})
target_link_libraries( tutoriel
${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_CPP(essais_moc ../essais.h)
add_executable( essais ../essais.cpp ${essais_moc})
target_link_libraries( essais
${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} )
......@@ -172,7 +172,7 @@ int main(int argc, char **argv)
CGoGNout << "Parcours avec le browser (les sommets)"<<CGoGNendl;
// creation d'un browser avec attribut cree a la volee
MapBrowserLinkedAuto<PFP::MAP>mbl(myMap);
MapBrowserLinked<PFP::MAP>mbl(myMap);
// on ajoute un brin par sommet dans le browser
myMap.foreach_orbit(VERTEX, mbl);
......@@ -188,14 +188,14 @@ int main(int argc, char **argv)
// on cree un attribut Dart pour la liste
AutoAttributeHandler<Dart> tableLink(myMap, DART);
// le browser
MapBrowserLinkedAttr<PFP::MAP>mbl2(tableLink);
MapBrowserLinked<PFP::MAP>mbl2(myMap,tableLink);
// que l'on remplit a la main
Dart d = d2;
mbl2.add(d);
mbl2.pushBack(d);
d = myMap.phi1(d);
mbl2.add(d);
mbl2.pushBack(d);
d = myMap.phi1(d);
mbl2.add(d);
mbl2.pushFront(d);
// et on parcours la sous-carte avec ce browser
TestDeParcoursAFF<PFP>(myMap, mbl2, position);
......
......@@ -144,8 +144,7 @@ void quadranguleFaces(typename PFP::MAP& map, EMBV& attributs, const FunctorSele
if (selected(d) && !me.isMarked(d))
{
Dart f = map.phi1(d);
map.cutEdge(d);
Dart e = map.phi1(d);
Dart e = map.cutEdge(d);
// TODO trouver pourquoi lerp bug avec ECell
// attributs[m] = AttribOps::lerp<EMB,PFP>(attributs[d],attributs[f], 0.5);
attributs[e] = attributs[d];
......
......@@ -3,18 +3,18 @@
* version 0.1 *
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* 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 *
* 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 *
* 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, *
* 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.u-strasbg.fr/ *
......@@ -37,29 +37,35 @@ namespace CGoGN
* those not selected by the selector
*/
template <typename MAP>
class MapBrowserSelector: public MapBrowser
class MapBrowserSelector : public MapBrowser
{
protected:
MAP& m_map;
const FunctorSelect& m_selector;
MAP& m_map ;
const FunctorSelect& m_selector ;
public:
MapBrowserSelector(MAP& m, const FunctorSelect& fs):
MapBrowserSelector(MAP& m, const FunctorSelect& fs) :
m_map(m), m_selector(fs)
{}
Dart begin() { return m_map.begin(); }
Dart begin()
{
return m_map.begin() ;
}
Dart end() { return m_map.end(); }
Dart end()
{
return m_map.end() ;
}
void next(Dart& d)
{
do
{
m_map.next(d);
m_map.next(d) ;
}
while ( (d != m_map.end()) && !m_selector(d) );
while ( (d != m_map.end()) && !m_selector(d) ) ;
}
};
} ;
/**
* Browser that traverses a "submap" stored in a
......@@ -71,96 +77,109 @@ template <typename MAP>
class MapBrowserLinked: public MapBrowser, public FunctorType
{
protected:
Dart m_first;
public:
MapBrowserLinked(): m_first(NIL)
{}
// The browsed map
MAP& m_map ;
MapBrowserLinked(MAP& map, const FunctorSelect& fs): m_first(NIL) { addSelected(map, fs); }
// The table attributes of links storing the linking
// The boolean autoAttribute is set if this attribut is managed by the browser
bool autoAttribute ;
AttributeHandler<Dart> m_links ;
Dart begin() { return m_first;}
Dart m_first ;
Dart m_end ;
Dart end() { return NIL;}
// init the list
void init() { m_first = NIL;}
public:
MapBrowserLinked(MAP& m) :
m_map(m), autoAttribute(true), m_first(NIL), m_end(NIL)
{
m_links = m.template addAttribute<Dart>(DART,"") ;
}
// add a dart to the list
virtual void add(Dart d) = 0;
MapBrowserLinked(MAP& m, AttributeHandler<Dart>& links) :
m_map(m), autoAttribute(false), m_links(links), m_first(NIL), m_end(NIL)
{
}
virtual void popFront() = 0;
~MapBrowserLinked()
{
if (autoAttribute)
m_map.template removeAttribute<Dart>(m_links) ;
}
void addSelected(MAP& map, const FunctorSelect& fs)
void clear()
{
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (fs(d))
add(d);
}
m_first = NIL ;
m_end = NIL ;
}
// operator() for use of foreach_cell
bool operator()(Dart d)
Dart begin()
{
add(d);
return false;
return m_first ;
}
};
/**
* MapBrowserLinked with AttributeHandler<Dart> given
* as parameter of construction (ref). the AttributeHandler
* can be shared by many MapBrowser
*/
template <typename MAP>
class MapBrowserLinkedAttr: public MapBrowserLinked<MAP>
{
protected:
/// ref to the table attributes of links
AttributeHandler<Dart>& m_links;
public:
MapBrowserLinkedAttr(AttributeHandler<Dart>& links):
MapBrowserLinked<MAP>(), m_links(links)
{}
Dart end()
{
return NIL ;
}
void next(Dart& d) { d = m_links[d];}
void next(Dart& d)
{
assert(d != NIL) ;
d = m_links[d] ;
}
/// add a dart to linked list
void add(Dart d) { m_links[d.index] = this->m_first; this->m_first = d; }
void pushFront(Dart d)
{
assert(d != NIL) ;
m_links[d] = m_first ;
m_first = d ;
if (m_end == NIL) // empty list
m_end = d ;
}
//pop the first
void popFront() { this->m_first = m_links[this->m_first.index]; }
};
void pushBack(Dart d)
{
assert(d != NIL) ;
m_links[d] = NIL ;
if (m_first == NIL) // empty list
{
m_first = d ;
m_end = d ;
}
else
{
m_links[m_end] = d ;
m_end = d ;
}
}
/**
* MapBrowser with local attribute of linked darts
* Attribute is added and removed automatically
* with the scope of object
*/
template <typename MAP>
class MapBrowserLinkedAuto: public MapBrowserLinked<MAP>
{
protected:
/// auto table attributes of links (added to construction and removed at destruction)
AutoAttributeHandler<Dart> m_links;
public:
/**
* Constructor
* @param m the map (used to add the attribute)
* @param nameAtt attributeName
*/
MapBrowserLinkedAuto(MAP& m):
MapBrowserLinked<MAP>(), m_links(m, DART)
{}
void popFront()
{
if (m_first == m_end) // one element or empty list
{
m_first = NIL ;
m_end = NIL ;
}
else m_first = m_links[m_first] ;
}
void next(Dart& d) { d = m_links[d]; }
/// add a dart to linked list
void add(Dart d) { m_links[d.index] = this->m_first; this->m_first = d; }
void addSelected(const FunctorSelect& fs)
{
for (Dart d = m_map.begin() ; d != m_map.end() ; m_map.next(d))
{
if (fs(d))
pushFront(d) ;
}
}
//pop the first
void popFront() { this->m_first = m_links[this->m_first.index]; }
};
// operator() for use of foreach_cell
bool operator()(Dart d)
{
pushFront(d) ;
return false ;
}
} ;
} // end namespace CGoGN
......
......@@ -48,7 +48,7 @@ public:
/**
* The attributes attached to the face of d are kept on the resulting face
*/
virtual bool deleteVertex(Dart d) ;
virtual Dart deleteVertex(Dart d) ;
/**
* No attribute is attached to the new edge
......@@ -60,7 +60,7 @@ public:
* No attribute is attached to the new vertex
* The attributes attached to the old edge are duplicated on both resulting edges
*/
virtual void cutEdge(Dart d) ;
virtual Dart cutEdge(Dart d) ;
/**
* The attributes attached to the edge of d are kept on the resulting edge
......
......@@ -42,13 +42,13 @@ public:
/*!
*
*/
virtual bool deleteVertex(Dart d);
virtual Dart deleteVertex(Dart d);
/*! No attribute is attached to the new vertex
* The attributes attached to the old edge are duplicated on both resulting edges
* @param d a dart
*/
virtual void cutEdge(Dart d);
virtual Dart cutEdge(Dart d);
/*! The attributes attached to the edge of d are kept on the resulting edge
......
......@@ -134,7 +134,7 @@ public:
/*! @param d the edge to cut
* \image hmtl map1_cutEdge.png
*/
void cutEdge(Dart d);
Dart cutEdge(Dart d);
//! Collapse an edge of a face
/*! \warning Dart d no longer exists after the call
......
......@@ -149,10 +149,11 @@ inline void Map1::deleteFace(Dart d)
* Topological operations on 1-maps
*************************************************************************/
inline void Map1::cutEdge(Dart d)
inline Dart Map1::cutEdge(Dart d)
{
Dart e = newDart() ; // Create a new dart
phi1sew(d, e) ; // Insert dart e between d and phi1(d)
return e;
}
inline void Map1::collapseEdge(Dart d)
......
......@@ -127,7 +127,7 @@ public:
* @param d a dart of the vertex to delete
* @return true if the deletion has been executed, false otherwise
*/
virtual bool deleteVertex(Dart d) ;
virtual Dart deleteVertex(Dart d) ;
//! Link two vertices belonging to distinct faces (add an edge between the two vertices)
/*! \pre Dart d and e MUST be different and belong to distinct face
......@@ -139,7 +139,7 @@ public:
//! Cut the edge of d and its opposite edge if it exists
/*! @param d a dart of the edge to cut
*/
virtual void cutEdge(Dart d);
virtual Dart cutEdge(Dart d);
//! Undo the cut of the edge of d and its opposite edge if it exists
/*! @param d a dart of the edge to uncut
......
......@@ -123,12 +123,12 @@ public:
* @param d a dart of the vertex to delete
* @return true if the deletion has been executed, false otherwise
*/
virtual bool deleteVertex(Dart d);
virtual Dart deleteVertex(Dart d);
//! Cut the edge of d (all darts around edge orbit are cutted)
/*! @param d a dart of the edge to cut
*/
virtual void cutEdge(Dart d);
virtual Dart cutEdge(Dart d);
//! Uncut the edge of d (all darts around edge orbit are uncutted)
/*! @param d a dart of the edge to uncut
......
......@@ -52,18 +52,18 @@ void EmbeddedMap2::splitVertex(Dart d, Dart e)
}
}
bool EmbeddedMap2::deleteVertex(Dart d)
Dart EmbeddedMap2::deleteVertex(Dart d)
{
Dart f = phi1(d) ;
if(Map2::deleteVertex(d))
Dart f = Map2::deleteVertex(d) ;
if(f != NIL)
{
if (isOrbitEmbedded(FACE))
{
embedOrbit(FACE, f, getEmbedding(FACE, f)) ;
}
return true ;
return f ;
}
return false ;
return NIL ;
}
void EmbeddedMap2::linkVertices(Dart d, Dart e)
......@@ -84,11 +84,9 @@ void EmbeddedMap2::linkVertices(Dart d, Dart e)
}
}
void EmbeddedMap2::cutEdge(Dart d)
Dart EmbeddedMap2::cutEdge(Dart d)
{
Map2::cutEdge(d) ;
Dart nd = phi1(d) ;
Dart nd = Map2::cutEdge(d) ;
if (isOrbitEmbedded(EDGE))
{
......@@ -103,6 +101,7 @@ void EmbeddedMap2::cutEdge(Dart d)
if(e != nd)
copyDartEmbedding(FACE, phi1(e), e) ;
}
return nd;
}
void EmbeddedMap2::uncutEdge(Dart d)
......
......@@ -30,21 +30,19 @@
namespace CGoGN
{
bool EmbeddedMap3::deleteVertex(Dart d)
Dart EmbeddedMap3::deleteVertex(Dart d)
{
//the merge volumes inside deleteVertex merges the volume embedding
return Map3::deleteVertex(d);
}
void EmbeddedMap3::cutEdge(Dart d)
Dart EmbeddedMap3::cutEdge(Dart d)
{
Map3::cutEdge(d);
Dart nd = Map3::cutEdge(d);
if(isOrbitEmbedded(EDGE))
{
Dart nd = phi1(d) ;
//embed the new darts created in the cutted edge
unsigned int vEmb = getEmbedding(EDGE, d);
embedOrbit(EDGE, d, vEmb) ;
......@@ -59,14 +57,14 @@ void EmbeddedMap3::cutEdge(Dart d)
Dart f = d;
do
{
Dart nd = phi1(f) ;
copyDartEmbedding(FACE, nd, f);
Dart nf = phi1(f) ;
copyDartEmbedding(FACE, nf, f);
Dart f2 = phi2(nd);
if(f2!=nd)
Dart f2 = phi2(nf);
if(f2!=nf)
{
Dart nd2 = phi2(f);
copyDartEmbedding(FACE, nd2, f2);
Dart nf2 = phi2(f);
copyDartEmbedding(FACE, nf2, f2);
}
f = alpha2(f);
......@@ -78,16 +76,17 @@ void EmbeddedMap3::cutEdge(Dart d)
Dart f = d;
do
{
Dart nd = phi1(f) ;
copyDartEmbedding(VOLUME, nd, f);
Dart nf = phi1(f) ;
copyDartEmbedding(VOLUME, nf, f);
Dart nd2 = phi2(f);
if(f!=nd2)
copyDartEmbedding(VOLUME, nd2, f);
Dart nf2 = phi2(f);
if(f!=nf2)
copyDartEmbedding(VOLUME, nf2, f);
f = alpha2(f);
} while(f != d);
}
return nd;
}
void EmbeddedMap3::uncutEdge(Dart d)
......
......@@ -48,50 +48,51 @@ void Map2::deleteOrientedFace(Dart d)
void Map2::splitVertex(Dart d, Dart e)
{
assert(sameOrientedVertex(d, e));
Dart dd = phi2(d) ;
Dart ee = phi2(e) ;
Map1::cutEdge(dd); // Cut the edge of dd (make a new half edge)
Map1::cutEdge(ee); // Cut the edge of ee (make a new half edge)
phi2sew(phi1(dd), phi1(ee));// Sew the two faces along the new edge
assert(sameOrientedVertex(d, e)) ;
Dart d2 = phi2(d) ; assert(d != d2) ;
Dart e2 = phi2(e) ; assert(e != e2) ;
Dart nd = Map1::cutEdge(d2) ; // Cut the edge of dd (make a new half edge)
Dart ne = Map1::cutEdge(e2) ; // Cut the edge of ee (make a new half edge)
phi2sew(nd, ne) ; // Sew the two faces along the new edge
}
bool Map2::deleteVertex(Dart d)
Dart Map2::deleteVertex(Dart d)
{
if(isBoundaryVertex(d))
return false ;
return NIL ;
Dart vit = d ;
Dart f;
do
{
Dart f = phi_1(phi2(vit)) ;
f = phi_1(phi2(vit)) ;
phi1sew(vit, f) ;
vit = alpha1(vit) ;
} while(vit != d) ;
Map1::deleteFace(d) ;
return true ;
return f ;
}
void Map2::linkVertices(Dart d, Dart e)
{
Map1::linkVertices(d, e); // Split the face
Map1::linkVertices(d, e); // Split the face
phi2sew(phi_1(d), phi_1(e)); // Sew the two resulting faces along the new edge
}
void Map2::cutEdge(Dart d)
Dart Map2::cutEdge(Dart d)
{
Map1::cutEdge(d); // Cut the edge of d
Dart nd = phi1(d);
Dart nd = Map1::cutEdge(d); // Cut the edge of d
Dart e = phi2(d);
if (e != d) // Test if an opposite edge exists
if (e != d) // Test if an opposite edge exists
{
Map1::cutEdge(e); // Cut the opposite edge
Dart ne = phi1(e);
phi2unsew(d); // Correct the phi2 links
Dart ne = Map1::cutEdge(e); // Cut the opposite edge
phi2unsew(d); // Correct the phi2 links
phi2sew(d, ne);
phi2sew(e, nd);
}
return nd;
}
void Map2::uncutEdge(Dart d)
......
......@@ -69,7 +69,7 @@ void Map3::deleteVolume(Dart d)
* Topological operations on 3-maps
*************************************************************************/
bool Map3::deleteVertex(Dart d)
Dart Map3::deleteVertex(Dart d)
{
//Save the darts around the vertex
//(one dart per face should be enough)
......@@ -100,14 +100,14 @@ bool Map3::deleteVertex(Dart d)
return true;
}
void Map3::cutEdge(Dart d)
Dart Map3::cutEdge(Dart d)
{
if(isBoundaryFace(d))
d = phi2(d);
Dart prev = d;
Dart dd = alpha2(d);
Map2::cutEdge(d);
Dart nd = Map2::cutEdge(d);
while (dd!=d)
{
......@@ -132,6 +132,7 @@ void Map3::cutEdge(Dart d)
phi3sew(d, phi1(d3));
phi3sew(d3, phi1(d));
}
return nd;
}
void Map3::uncutEdge(Dart 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