Commit f547dc86 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge cgogn:~cazier/CGoGN

Conflicts:
	include/Topology/map/embeddedMap2.h
	include/Topology/map/map1.hpp
	include/Topology/map/map2.h
	src/Topology/map/embeddedMap2.cpp
	src/Topology/map/embeddedMap3.cpp
	src/Topology/map/map2.cpp
	src/Topology/map/map3.cpp
parents e9112574 f64adf62
......@@ -72,4 +72,3 @@ QT4_WRAP_CPP( clipping_moc ../clipping.h )
add_executable( clippingD ../clipping.cpp ${clipping_ui} ${clipping_moc})
target_link_libraries( clippingD
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
......@@ -64,4 +64,3 @@ QT4_WRAP_CPP( clipping_moc ../clipping.h )
add_executable( clipping ../clipping.cpp ${clipping_ui} ${clipping_moc})
target_link_libraries( clipping
${CGoGN_LIBS_R} ${CGoGN_EXT_LIBS} )
This diff is collapsed.
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* 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 *
* 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.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef TP_MASTER_H_
#define TP_MASTER_H_
#include <iostream>
#include "Utils/qtSimple.h"
// forward definitions (minimize includes)
namespace CGoGN { namespace Algo { namespace Render { namespace GL2 { class MapRender; } } } }
namespace CGoGN { namespace Algo { namespace Render { namespace GL2 { class TopoRenderMapD; } } } }
namespace CGoGN { namespace Utils { class VBO; } }
namespace CGoGN { namespace Utils { class ShaderPhong; } }
namespace CGoGN { namespace Utils { class ShaderSimpleColor; } }
namespace CGoGN { namespace Utils { class Drawer; } }
using namespace CGoGN ;
/**
* A class for a little interface and rendering
*/
class MyQT: public Utils::QT::SimpleQT
{
Q_OBJECT
protected:
bool m_drawTopo;
void drawSelected();
public:
// render
Algo::Render::GL2::MapRender* m_render;
Algo::Render::GL2::TopoRenderMapD* m_render_topo;
// VBO
Utils::VBO* m_positionVBO;
Utils::VBO* m_normalVBO;
//2 shaders
Utils::ShaderPhong* m_shader;
Utils::ShaderSimpleColor* m_shader2;
bool renderTopo;
/**
* object that allow easy rendering
*/
Utils::Drawer* m_ds;
MyQT():
m_render(NULL), m_render_topo(NULL),
m_positionVBO(NULL), m_normalVBO(NULL),
m_shader(NULL), m_shader2(NULL),
renderTopo(true)
{}
// callbacks of simpleQT to overdefine:
void cb_redraw();
void cb_initGL();
void cb_keyPress(int code);
};
#endif
......@@ -170,7 +170,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);
......@@ -186,14 +186,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);
......
......@@ -137,8 +137,7 @@ void quadranguleFaces(typename PFP::MAP& map, EMBV& attributs, const FunctorSele
if (selected(d) && !map.isBoundaryMarked(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
......
......@@ -54,7 +54,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
......
......@@ -46,7 +46,7 @@ public:
* 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
* @param d a dart of the edge to cut
......
......@@ -126,7 +126,7 @@ public:
/*! @param d the edge to cut
* \image hmtl map1_cutEdge.png
*/
void cutEdge(Dart d);
Dart cutEdge(Dart d);
//! Undo the cut of the edge of d
/*! @param d a dart of the edge to uncut
......
......@@ -130,13 +130,15 @@ inline void Map1::phi1unsew(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)
if (isBoundaryMarked(d))
boundaryMark(e);
return e ;
}
inline void Map1::uncutEdge(Dart d)
......
......@@ -147,8 +147,9 @@ public:
//! Cut the edge of d by inserting a new vertex
/*! @param d a dart of the edge to cut
* @return a dart of the new vertex
*/
virtual void cutEdge(Dart d);
virtual Dart cutEdge(Dart d);
//! Undo the cut of the edge of d
/*! @param d a dart of the edge to uncut
......
......@@ -132,8 +132,9 @@ public:
//! Cut the edge of d (all darts around edge orbit are cut)
/*! @param d a dart of the edge to cut
* @return a dart of the new vertex
*/
virtual void cutEdge(Dart d);
virtual Dart cutEdge(Dart d);
//! Uncut the edge of d (all darts around edge orbit are uncut)
/*! @param d a dart of the edge to uncut
......
......@@ -65,11 +65,9 @@ Dart EmbeddedMap2::deleteVertex(Dart d)
return f ;
}
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))
{
......@@ -84,6 +82,8 @@ void EmbeddedMap2::cutEdge(Dart d)
Dart e = phi2(nd) ;
copyDartEmbedding(FACE, phi1(e), e) ;
}
return nd;
}
bool EmbeddedMap2::uncutEdge(Dart d)
......
......@@ -40,14 +40,12 @@ Dart EmbeddedMap3::deleteVertex(Dart d)
return v ;
}
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 cut edge
embedOrbit(EDGE, d, getEmbedding(EDGE, d)) ;
// embed a new cell for the new edge and copy the attributes' line (c) Lionel
......@@ -60,9 +58,9 @@ void EmbeddedMap3::cutEdge(Dart d)
Dart f = d;
do
{
Dart nd = phi1(f) ;
copyDartEmbedding(ORIENTED_FACE, nd, f);
Dart e = phi3(nd);
Dart f1 = phi1(f) ;
copyDartEmbedding(ORIENTED_FACE, f1, f);
Dart e = phi3(f1);
copyDartEmbedding(ORIENTED_FACE, phi1(e), e);
f = alpha2(f);
} while(f != d);
......@@ -91,6 +89,8 @@ void EmbeddedMap3::cutEdge(Dart d)
f = alpha2(f);
} while(f != d);
}
return nd ;
}
bool EmbeddedMap3::uncutEdge(Dart d)
......
......@@ -109,12 +109,12 @@ void Map2::fillHole(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
}
Dart Map2::deleteVertex(Dart d)
......@@ -138,14 +138,15 @@ Dart Map2::deleteVertex(Dart d)
return res ;
}
void Map2::cutEdge(Dart d)
Dart Map2::cutEdge(Dart d)
{
Dart e = phi2(d);
phi2unsew(d); // remove old phi2 links
Map1::cutEdge(d); // Cut the 1-edge of d
Map1::cutEdge(e); // Cut the 1-edge of phi2(d)
phi2sew(d, phi1(e)); // Correct the phi2 links
phi2sew(e, phi1(d));
Dart nd = Map1::cutEdge(d); // Cut the 1-edge of d
Dart ne = Map1::cutEdge(e); // Cut the 1-edge of phi2(d)
phi2sew(d, ne); // Correct the phi2 links
phi2sew(e, nd);
return nd;
}
bool Map2::uncutEdge(Dart d)
......
......@@ -129,11 +129,11 @@ Dart Map3::deleteVertex(Dart d)
return res ;
}
void Map3::cutEdge(Dart d)
Dart Map3::cutEdge(Dart d)
{
Dart prev = d;
Dart dd = alpha2(d);
Map2::cutEdge(d);
Dart nd = Map2::cutEdge(d);
while (dd != d)
{
......@@ -152,6 +152,8 @@ void Map3::cutEdge(Dart d)
phi3unsew(d);
phi3sew(d, phi1(d3));
phi3sew(d3, phi1(d));
return nd;
}
bool 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