Commit 1b7ac321 authored by Sylvain Thery's avatar Sylvain Thery

resolve bug of topo drawing in tuto_oper3

parent 3d4119e2
...@@ -251,7 +251,7 @@ public: ...@@ -251,7 +251,7 @@ public:
Dart raySelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax); Dart raySelection(MAP& map, const Geom::Vec3f& rayA, const Geom::Vec3f& rayAB, float distmax);
virtual void updateData(MAP& map, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, bool withBoundary = false) = 0; virtual void updateData(MAP& map, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, bool withBoundary = false, bool onlyBoundary=false) = 0;
/** /**
* Special update function used to draw boundary of map3 * Special update function used to draw boundary of map3
...@@ -290,7 +290,7 @@ class TopoRenderMap : public TopoRender<PFP> ...@@ -290,7 +290,7 @@ class TopoRenderMap : public TopoRender<PFP>
public: public:
TopoRenderMap(float bs = 0.01f) : TopoRender<PFP>(bs) {} TopoRenderMap(float bs = 0.01f) : TopoRender<PFP>(bs) {}
void updateData(MAP &map, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, bool withBoundary = false); void updateData(MAP &map, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, bool withBoundary = false, bool onlyBoundary=false);
}; };
template <typename PFP> template <typename PFP>
...@@ -302,7 +302,7 @@ class TopoRenderGMap : public TopoRender<PFP> ...@@ -302,7 +302,7 @@ class TopoRenderGMap : public TopoRender<PFP>
public: public:
TopoRenderGMap(float bs = 0.01f) : TopoRender<PFP>(bs) {} TopoRenderGMap(float bs = 0.01f) : TopoRender<PFP>(bs) {}
void updateData(MAP &map, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, bool withBoundary = false); void updateData(MAP &map, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, bool withBoundary = false, bool onlyBoundary=false);
}; };
} // namespace GL2 } // namespace GL2
......
...@@ -432,45 +432,34 @@ void TopoRender<PFP>::setBoundaryShift(float bs) ...@@ -432,45 +432,34 @@ void TopoRender<PFP>::setBoundaryShift(float bs)
} }
template<typename PFP> template<typename PFP>
void TopoRender<PFP>::updateDataBoundary(MAP& map, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf,float ns) void TopoRender<PFP>::updateDataBoundary(MAP& map, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, float ns)
{ {
m_normalShift = ns; m_normalShift = ns;
SelectorDartBoundary<MAP> sdb(map); SelectorDartBoundary<MAP> sdb(map);
DartContainerBrowserSelector<MAP> browser(map, sdb); DartContainerBrowserSelector<MAP> browser(map, sdb);
browser.enable(); browser.enable();
updateData(map, positions, ke, kf, true); updateData(map, positions, ke, kf, false,true); // false,true because we are drawing the boundary of a 3map
browser.disable(); browser.disable();
m_normalShift = 0.0f; m_normalShift = 0.0f;
} }
//template<typename PFP>
//void TopoRender<PFP>::updateData(MAP& map, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, bool withBoundary)
//{
// std::string typeName = map.mapTypeName();
// if (typeName[0] == 'M') // "Map2"
// {
// updateDataMap(map, positions, ke, kf, withBoundary);
// return;
// }
// if (typeName[0] == 'G') // "GMap2"
// {
// updateDataGMap(map, positions, ke, kf, withBoundary);
// return;
// }
//}
template<typename PFP> template<typename PFP>
void TopoRenderMap<PFP>::updateData(MAP& mapx, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, bool withBoundary) void TopoRenderMap<PFP>::updateData(MAP& mapx, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, bool withBoundary, bool onlyBoundary)
{ {
//Map2& map = reinterpret_cast<Map2&>(mapx); std::string name_index("dart_index2");
if (onlyBoundary)
name_index = std::string("dart_boundary_index2");
std::vector<Dart> vecDarts; std::vector<Dart> vecDarts;
vecDarts.reserve(mapx.getNbDarts()); // no problem dart is int: no problem of memory vecDarts.reserve(mapx.getNbDarts()); // no problem dart is int: no problem of memory
this->m_attIndex = mapx.template getAttribute<unsigned int, DART, MAP>("dart_index2"); this->m_attIndex = mapx.template getAttribute<unsigned int, DART, MAP>(name_index);
if (!this->m_attIndex.isValid()) if (!this->m_attIndex.isValid())
this->m_attIndex = mapx.template addAttribute<unsigned int, DART, MAP>("dart_index2"); this->m_attIndex = mapx.template addAttribute<unsigned int, DART, MAP>(name_index);
for(Dart d = mapx.begin(); d != mapx.end(); mapx.next(d)) for(Dart d = mapx.begin(); d != mapx.end(); mapx.next(d))
{ {
...@@ -653,18 +642,23 @@ void TopoRenderMap<PFP>::updateData(MAP& mapx, const VertexAttribute<VEC3, MAP>& ...@@ -653,18 +642,23 @@ void TopoRenderMap<PFP>::updateData(MAP& mapx, const VertexAttribute<VEC3, MAP>&
template<typename PFP> template<typename PFP>
void TopoRenderGMap<PFP>::updateData(MAP& map, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, bool withBoundary) void TopoRenderGMap<PFP>::updateData(MAP& map, const VertexAttribute<VEC3, MAP>& positions, float ke, float kf, bool withBoundary, bool onlyBoundary)
{ {
// GMap2& map = dynamic_cast<GMap2&>(mapx); // GMap2& map = dynamic_cast<GMap2&>(mapx);
std::vector<Dart> vecDarts; std::vector<Dart> vecDarts;
vecDarts.reserve(map.getNbDarts()); // no problem dart is int: no problem of memory vecDarts.reserve(map.getNbDarts()); // no problem dart is int: no problem of memory
std::string name_index("dart_index2");
if (onlyBoundary)
name_index = std::string("dart_boundary_index2");
if (this->m_attIndex.map() != &map) if (this->m_attIndex.map() != &map)
this->m_attIndex = map.template getAttribute<unsigned int, DART, MAP>("dart_index2"); this->m_attIndex = map.template getAttribute<unsigned int, DART, MAP>(name_index);
if (!this->m_attIndex.isValid()) if (!this->m_attIndex.isValid())
this->m_attIndex = map.template addAttribute<unsigned int, DART, MAP>("dart_index2"); this->m_attIndex = map.template addAttribute<unsigned int, DART, MAP>(name_index);
for(Dart d = map.begin(); d != map.end(); map.next(d)) for(Dart d = map.begin(); d != map.end(); map.next(d))
{ {
......
...@@ -232,12 +232,14 @@ protected: ...@@ -232,12 +232,14 @@ protected:
public: public:
inline void unmarkAll() inline void unmarkAll()
{ {
AttributeContainer& cont = this->m_map.template getAttributeContainer<DART>(); // AttributeContainer& cont = this->m_map.template getAttributeContainer<DART>();
if (cont.hasBrowser()) // if (cont.hasBrowser())
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i)) // for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
this->m_markVector->setFalse(i); // this->m_markVector->setFalse(i);
else // else
this->m_markVector->allFalse();
// always unmark all darts, it's to dangerous because of markOrbit that can mark dart out of Browser !
this->m_markVector->allFalse();
} }
} ; } ;
...@@ -354,12 +356,14 @@ protected: ...@@ -354,12 +356,14 @@ protected:
public: public:
inline void unmarkAll() inline void unmarkAll()
{ {
AttributeContainer& cont = this->m_map.template getAttributeContainer<DART>(); // AttributeContainer& cont = this->m_map.template getAttributeContainer<DART>();
if (cont.hasBrowser()) // if (cont.hasBrowser())
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i)) // for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
this->m_markVector->setFalse(i); // this->m_markVector->setFalse(i);
else // else
this->m_markVector->allFalse();
// always unmark all darts, it's to dangerous because of markOrbit that can mark dart out of Browser !
this->m_markVector->allFalse();
} }
#ifndef NDEBUG #ifndef NDEBUG
......
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