Commit d980362e authored by untereiner's avatar untereiner
Browse files

Merge cgogn:~thery/CGoGN

parents 0f47b2ad b2ff35a7
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "tuto1.h" #include "tuto1.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
#include "Topology/generic/mapBrowser.h"
using namespace CGoGN ; using namespace CGoGN ;
......
...@@ -290,11 +290,6 @@ void MyQT::createMap(int /*n*/) ...@@ -290,11 +290,6 @@ void MyQT::createMap(int /*n*/)
m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f); m_render_topo->setInitialDartsColor(0.0f,0.0f,0.0f);
m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3/*, nb*/); m_render_topo->updateData<PFP>(myMap, position, m_ex1,m_ex2,m_ex3/*, nb*/);
// SelectorDartBoundary<PFP::MAP> sdb(myMap);
// MapBrowserSelector mbs(myMap,sdb);
// myMap.setBrowser(&mbs);
// m_render_topo_boundary->updateData<PFP>(myMap,position,m_ex1,m_ex2);
// myMap.setBrowser(NULL);
m_render_topo_boundary->updateDataBoundary<PFP>(myMap,position,m_ex1,m_ex2,m_shift); m_render_topo_boundary->updateDataBoundary<PFP>(myMap,position,m_ex1,m_ex2,m_shift);
} }
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#define __COLOR_APPROXIMATOR_H__ #define __COLOR_APPROXIMATOR_H__
#include "Algo/Decimation/approximator.h" #include "Algo/Decimation/approximator.h"
#include "Topology/generic/mapBrowser.h"
namespace CGoGN namespace CGoGN
{ {
......
...@@ -322,6 +322,12 @@ void computeCentroidELWVolumes(typename PFP::MAP& map, ...@@ -322,6 +322,12 @@ void computeCentroidELWVolumes(typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3>& position, VolumeAttribute<typename PFP::VEC3>& vol_centroid, const VertexAttribute<typename PFP::VEC3>& position, VolumeAttribute<typename PFP::VEC3>& vol_centroid,
unsigned int nbth = 0) ; unsigned int nbth = 0) ;
template <typename PFP, typename EMBV, typename EMB>
void computeCentroidELWVolumesGen(typename PFP::MAP& map,
const EMBV& position, VolumeAttribute<typename PFP::VEC3>& vol_centroid,
unsigned int nbth = 0) ;
template <typename PFP> template <typename PFP>
void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
......
...@@ -347,6 +347,35 @@ void computeCentroidELWVolumes(typename PFP::MAP& map, ...@@ -347,6 +347,35 @@ void computeCentroidELWVolumes(typename PFP::MAP& map,
} }
template <typename PFP, typename EMBV, typename EMB>
class FunctorComputeCentroidELWVolumesGen: public FunctorMapThreaded<typename PFP::MAP >
{
const EMBV& m_position;
VolumeAttribute<typename PFP::VEC3>& m_vol_centroid;
public:
FunctorComputeCentroidELWVolumesGen<PFP,EMBV,EMB>( typename PFP::MAP& map, const EMBV& position, VolumeAttribute<typename PFP::VEC3>& vol_centroid):
FunctorMapThreaded<typename PFP::MAP>(map), m_position(position), m_vol_centroid(vol_centroid)
{ }
void run(Dart d, unsigned int threadID)
{
m_vol_centroid[d] = Surface::Geometry::volumeCentroidELWGen<PFP,EMBV,EMB>(this->m_map, d, m_position,threadID) ;
}
};
template <typename PFP, typename EMBV, typename EMB>
void computeCentroidELWVolumesGen(typename PFP::MAP& map,
const EMBV& position, VolumeAttribute<typename PFP::VEC3>& vol_centroid,
unsigned int nbth = 0)
{
FunctorComputeCentroidELWVolumesGen<PFP,EMBV,EMB> funct(map,position,vol_centroid);
Algo::Parallel::foreach_cell<typename PFP::MAP,VOLUME>(map, funct, nbth, true);
}
template <typename PFP> template <typename PFP>
class FunctorComputeNeighborhoodCentroidVertices: public FunctorMapThreaded<typename PFP::MAP > class FunctorComputeNeighborhoodCentroidVertices: public FunctorMapThreaded<typename PFP::MAP >
{ {
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#define __ALGO_GEOMETRY_NORMALIZATION_H__ #define __ALGO_GEOMETRY_NORMALIZATION_H__
#include "Geometry/vector_gen.h" #include "Geometry/vector_gen.h"
#include "Topology/generic/mapBrowser.h" #include "Container/containerBrowser.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -41,27 +41,50 @@ namespace Geometry ...@@ -41,27 +41,50 @@ namespace Geometry
template <typename PFP, unsigned int ORBIT> template <typename PFP, unsigned int ORBIT>
typename PFP::REAL normalizeLength(typename PFP::MAP & the_map, AttributeHandler<typename PFP::VEC3,ORBIT> & m_attr, const typename PFP::REAL scale = 1.0, ) typename PFP::REAL normalizeLength(typename PFP::MAP & the_map, AttributeHandler<typename PFP::VEC3,ORBIT> & m_attr, const typename PFP::REAL scale = 1.0, )
{ {
// typename PFP::REAL sum = 0 ;
// int count = 0 ;
// MapBrowserLinked<typename PFP::MAP> mb(the_map) ;
// the_map.foreach_orbit(m_attr.getOrbit(), mb) ;
// for (Dart d = mb.begin(); d != mb.end(); mb.next(d))
// {
// typename PFP::VEC3 length = m_attr[d] ;
// length -= m_attr[the_map.phi2(d)] ;
// sum += length.norm() ;
// ++count ;
// }
// sum /= typename PFP::REAL(count) ;
// typename PFP::REAL div = sum / scale ; // mutiply res by scale factor
// for (Dart d = mb.begin(); d != mb.end(); mb.next(d))
// {
// m_attr[d] /= div ;
// }
// return div ;
typename PFP::REAL sum = 0 ; typename PFP::REAL sum = 0 ;
int count = 0 ; int count = 0 ;
MapBrowserLinked<typename PFP::MAP> mb(the_map) ; TraversorCell<PFP::MAP,ORBIT> trav(the_map);
the_map.foreach_orbit(m_attr.getOrbit(), mb) ; for (Dart d = trav.begin(); d != trav.end(); d=trav.next())
for (Dart d = mb.begin(); d != mb.end(); mb.next(d))
{ {
typename PFP::VEC3 length = m_attr[d] ; typename PFP::VEC3 length = m_attr[d] ;
length -= m_attr[the_map.phi2(d)] ; length -= m_attr[the_map.phi2(d)] ;
sum += length.norm() ; sum += length.norm() ;
++count ; ++count ;
} }
sum /= typename PFP::REAL(count) ; sum /= typename PFP::REAL(count) ;
typename PFP::REAL div = sum / scale ; // mutiply res by scale factor typename PFP::REAL div = sum / scale ; // mutiply res by scale factor
for (Dart d = mb.begin(); d != mb.end(); mb.next(d)) for (Dart d = trav.begin(); d != trav.end(); d=trav.next())
{ {
m_attr[d] /= div ; m_attr[d] /= div ;
} }
return div ; return div ;
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
#ifndef IMPORTOBJTEX_H #ifndef IMPORTOBJTEX_H
#define IMPORTOBJTEX_H #define IMPORTOBJTEX_H
#include "Topology/generic/mapBrowser.h" //#include "Topology/generic/mapBrowser.h"
#include "Container/containerBrowser.h"
#include "Topology/generic/cellmarker.h" #include "Topology/generic/cellmarker.h"
namespace CGoGN namespace CGoGN
...@@ -180,7 +181,7 @@ public: ...@@ -180,7 +181,7 @@ public:
* @param browsers vector of MapBrowers representing the groups * @param browsers vector of MapBrowers representing the groups
* @return ok or not * @return ok or not
*/ */
bool generateBrowsers(std::vector<MapBrowser*>& browsers); bool generateBrowsers(std::vector<ContainerBrowser*>& browsers);
/** /**
* @brief getMaterialNames * @brief getMaterialNames
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
*******************************************************************************/ *******************************************************************************/
#include "Topology/generic/attributeHandler.h" #include "Topology/generic/attributeHandler.h"
#include "Topology/generic/autoAttributeHandler.h"
#include "Container/fakeAttribute.h" #include "Container/fakeAttribute.h"
#include <fstream> #include <fstream>
...@@ -214,30 +215,51 @@ void OBJModel<PFP>::readMaterials(const std::string& filename, std::vector<Mater ...@@ -214,30 +215,51 @@ void OBJModel<PFP>::readMaterials(const std::string& filename, std::vector<Mater
template <typename PFP> template <typename PFP>
bool OBJModel<PFP>::generateBrowsers(std::vector<MapBrowser*>& browsers) bool OBJModel<PFP>::generateBrowsers(std::vector<ContainerBrowser*>& browsers)
{ {
browsers.clear(); // browsers.clear();
// if (m_groupNames.empty())
// return false;
// MapBrowserLinked* MBLptr = new MapBrowserLinked(m_map);
// DartAttribute<Dart>& links = MBLptr->getLinkAttr();
// browsers.push_back(MBLptr);
// for (unsigned int i = 1; i<m_groupNames.size(); ++i)
// {
// MapBrowser* MBptr = new MapBrowserLinked(m_map,links);
// browsers.push_back(MBptr);
// m_groupMaterialID[i]= m_materialNames[m_groupMaterialNames[i]];
// }
// for (Dart d=m_map.begin(); d!=m_map.end(); m_map.next(d))
// {
// unsigned int g = m_groups[d] -1 ; // groups are name from 1
// MapBrowserLinked* mb = static_cast<MapBrowserLinked*>(browsers[g]);
// mb->pushBack(d);
// }
// return true;
browsers.clear();
if (m_groupNames.empty()) if (m_groupNames.empty())
return false; return false;
MapBrowserLinked* MBLptr = new MapBrowserLinked(m_map); ContainerBrowserLinked* MBLptr = new ContainerBrowserLinked(m_map,DART);
DartAttribute<Dart>& links = MBLptr->getLinkAttr();
browsers.push_back(MBLptr); browsers.push_back(MBLptr);
for (unsigned int i = 1; i<m_groupNames.size(); ++i) for (unsigned int i = 1; i<m_groupNames.size(); ++i)
{ {
MapBrowser* MBptr = new MapBrowserLinked(m_map,links); ContainerBrowser* MBptr = new ContainerBrowserLinked(*MBLptr);
browsers.push_back(MBptr); browsers.push_back(MBptr);
// std::string& matName = m_materialNames[i];
m_groupMaterialID[i]= m_materialNames[m_groupMaterialNames[i]]; m_groupMaterialID[i]= m_materialNames[m_groupMaterialNames[i]];
} }
for (Dart d=m_map.begin(); d!=m_map.end(); m_map.next(d)) for (Dart d=m_map.begin(); d!=m_map.end(); m_map.next(d))
{ {
unsigned int g = m_groups[d] -1 ; // groups are name from 1 unsigned int g = m_groups[d] -1 ; // groups are name from 1
MapBrowserLinked* mb = static_cast<MapBrowserLinked*>(browsers[g]); ContainerBrowserLinked* mb = static_cast<ContainerBrowserLinked*>(browsers[g]);
mb->pushBack(d); mb->pushBack(d.index);
} }
return true; return true;
} }
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "Utils/Shaders/shaderExplodeSmoothVolumes.h" #include "Utils/Shaders/shaderExplodeSmoothVolumes.h"
#include "Utils/Shaders/shaderExplodeVolumes.h" #include "Utils/Shaders/shaderExplodeVolumes.h"
#include "Utils/Shaders/shaderExplodeVolumesLines.h" #include "Utils/Shaders/shaderExplodeVolumesLines.h"
#include "Utils/svg.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -78,9 +79,17 @@ protected: ...@@ -78,9 +79,17 @@ protected:
*/ */
GLuint m_nbTris; GLuint m_nbTris;
/**
*number of lines to draw
*/
GLuint m_nbLines; GLuint m_nbLines;
Geom::Vec3f m_globalColor; Geom::Vec3f m_globalColor;
/**
* explode volume factor
*/
float m_explodeV;
template<typename PFP> template<typename PFP>
void computeFace(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions, void computeFace(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& positions,
...@@ -185,6 +194,20 @@ public: ...@@ -185,6 +194,20 @@ public:
* set color parameter for edge drawing * set color parameter for edge drawing
*/ */
void setColorLine(const Geom::Vec4f& col) ; void setColorLine(const Geom::Vec4f& col) ;
/**
* @brief svgout2D
* @param filename name of svg file
* @param model modelview matrix
* @param proj projection matrix
*/
void svgoutEdges(const std::string& filename, const glm::mat4& model, const glm::mat4& proj);
/**
* @brief toSVG
* @param svg svg struct reference
*/
void toSVG(Utils::SVG::SVGOut& svg);
}; };
}//end namespace GL2 }//end namespace GL2
......
...@@ -624,6 +624,7 @@ inline void ExplodeVolumeRender::drawEdges() ...@@ -624,6 +624,7 @@ inline void ExplodeVolumeRender::drawEdges()
inline void ExplodeVolumeRender::setExplodeVolumes(float explode) inline void ExplodeVolumeRender::setExplodeVolumes(float explode)
{ {
m_explodeV = explode;
if (m_smooth) if (m_smooth)
m_shaderS->setExplodeVolumes(explode); m_shaderS->setExplodeVolumes(explode);
else else
...@@ -697,6 +698,40 @@ inline Utils::GLSLShader* ExplodeVolumeRender::shaderLines() ...@@ -697,6 +698,40 @@ inline Utils::GLSLShader* ExplodeVolumeRender::shaderLines()
return m_shaderL; return m_shaderL;
} }
inline void ExplodeVolumeRender::svgoutEdges(const std::string& filename, const glm::mat4& model, const glm::mat4& proj)
{
Utils::SVG::SVGOut svg(filename,model,proj);
toSVG(svg);
svg.write();
}
inline void ExplodeVolumeRender::toSVG(Utils::SVG::SVGOut& svg)
{
Utils::SVG::SvgGroup* svg2 = new Utils::SVG::SvgGroup("alpha2", svg.m_model, svg.m_proj);
Geom::Vec3f* ptr = reinterpret_cast<Geom::Vec3f*>(m_vboPosLine->lockPtr());
svg2->setWidth(1.0f);
svg2->beginLines();
const Geom::Vec4f& col4 = m_shaderL->getColor();
Geom::Vec3f col3(col4[0],col4[1],col4[2]);
float XexplV = (1.0f-m_explodeV);
for (unsigned int i=0; i<m_nbLines; ++i)
{
Geom::Vec3f C = ptr[3*i];
Geom::Vec3f P = XexplV*C + m_explodeV*ptr[3*i+1];
Geom::Vec3f Q = XexplV*C + m_explodeV*ptr[3*i+2];
svg2->addLine(P, Q, col3);
}
svg2->endLines();
m_vboPosLine->releasePtr();
svg.addGroup(svg2);
}
}//end namespace VBO }//end namespace VBO
}//end namespace Algo }//end namespace Algo
......
...@@ -128,12 +128,13 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAttribut ...@@ -128,12 +128,13 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAttribut
if (!m_attIndex.isValid()) if (!m_attIndex.isValid())
m_attIndex = mapx.template addAttribute<unsigned int, DART>("dart_index"); m_attIndex = mapx.template addAttribute<unsigned int, DART>("dart_index");
m_nbDarts = 0; // m_nbDarts = 0;
for (Dart d = mapx.begin(); d != mapx.end(); mapx.next(d)) // for (Dart d = mapx.begin(); d != mapx.end(); mapx.next(d))
{ // {
// if (!map.isBoundaryMarked3(d)) // in the following code Traversor do not traverse boundary // m_nbDarts++;
m_nbDarts++; // }
}
m_nbDarts = mapx.getNbDarts();
// beta2/3 // beta2/3
DartAutoAttribute<VEC3> fv2(mapx); DartAutoAttribute<VEC3> fv2(mapx);
...@@ -150,8 +151,6 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAttribut ...@@ -150,8 +151,6 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAttribut
VEC3* positionDartBuf = reinterpret_cast<VEC3*>(m_bufferDartPosition); VEC3* positionDartBuf = reinterpret_cast<VEC3*>(m_bufferDartPosition);
std::vector<Dart> vecDartFaces;
vecDartFaces.reserve(m_nbDarts/6);
unsigned int posDBI=0; unsigned int posDBI=0;
int nbf=0; int nbf=0;
...@@ -159,8 +158,6 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAttribut ...@@ -159,8 +158,6 @@ void Topo3PrimalRender::updateData(typename PFP::MAP& mapx, const VertexAttribut
TraversorF<typename PFP::MAP> traFace(mapx); TraversorF<typename PFP::MAP> traFace(mapx);
for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next()) for (Dart d = traFace.begin(); d != traFace.end(); d = traFace.next())
{ {
vecDartFaces.push_back(d);
std::vector<VEC3> vecPos; std::vector<VEC3> vecPos;
vecPos.reserve(16); vecPos.reserve(16);
......
...@@ -275,6 +275,9 @@ public: ...@@ -275,6 +275,9 @@ public:
* @param kf exploding coef for face * @param kf exploding coef for face
* @param kv exploding coef for face * @param kv exploding coef for face
*/ */
template<typename PFP, typename EMBV, typename EMB>
void updateDataGen(typename PFP::MAP& map, const EMBV& positions, float ke, float kf, float kv);
template<typename PFP> template<typename PFP>
void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv); void updateData(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv);
...@@ -283,8 +286,12 @@ public: ...@@ -283,8 +286,12 @@ public:
* @param map the map * @param map the map
* @param colors attribute of dart's colors * @param colors attribute of dart's colors
*/ */
template<typename PFP, typename EMBV, typename EMB>
void updateColorsGen(typename PFP::MAP& map, const EMBV& colors);
template<typename PFP> template<typename PFP>
void updateColors(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& colors); void updateColors(typename PFP::MAP& map, const VertexAttribute<Geom::Vec3f>& colors);
/** /**
* Get back middle position of drawn darts * Get back middle position of drawn darts
...@@ -320,8 +327,8 @@ protected: ...@@ -320,8 +327,8 @@ protected:
* @param kf exploding coef for face * @param kf exploding coef for face
* @param kv exploding coef for face * @param kv exploding coef for face
*/ */
template<typename PFP> template<typename PFP, typename EMBV, typename EMB>
void updateDataMap3(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv); void updateDataMap3(typename PFP::MAP& map, const EMBV& positions, float ke, float kf, float kv);
/** /**
* update all drawing buffers to render a gmap * update all drawing buffers to render a gmap
...@@ -331,8 +338,8 @@ protected: ...@@ -331,8 +338,8 @@ protected:
* @param kf exploding coef for face * @param kf exploding coef for face
* @param kv exploding coef for face * @param kv exploding coef for face
*/ */
template<typename PFP> template<typename PFP, typename EMBV, typename EMB>
void updateDataGMap3(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv); void updateDataGMap3(typename PFP::MAP& map, const EMBV& positions, float ke, float kf, float kv);
}; };
......
...@@ -52,19 +52,38 @@ void Topo3Render::updateData(typename PFP::MAP& map, const VertexAttribute<typen ...@@ -52,19 +52,38 @@ void Topo3Render::updateData(typename PFP::MAP& map, const VertexAttribute<typen
Map3* ptrMap3 = dynamic_cast<Map3*>(&map); Map3* ptrMap3 = dynamic_cast<Map3*>(&map);
if (ptrMap3 != NULL) if (ptrMap3 != NULL)
{ {
updateDataMap3<PFP>(map,positions,ke,kf,kv); updateDataMap3<PFP, VertexAttribute<typename PFP::VEC3>, typename PFP::VEC3 >(map,positions,ke,kf,kv);
} }
GMap3* ptrGMap3 = dynamic_cast<GMap3*>(&map); GMap3* ptrGMap3 = dynamic_cast<GMap3*>(&map);
if (ptrGMap3 != NULL) if (ptrGMap3 != NULL)
{ {
updateDataGMap3<PFP>(map,positions,ke,kf,kv); updateDataGMap3<PFP, VertexAttribute<typename PFP::VEC3>, typename PFP::VEC3>(map,positions,ke,kf,kv);
} }
} }
template<typename PFP>
void Topo3Render::updateDataMap3(typename PFP::MAP& mapx, const VertexAttribute<typename PFP::VEC3>& positions, float ke, float kf, float kv) template<typename PFP, typename EMBV, typename EMB>
void Topo3Render::updateDataGen(typename PFP::MAP& map, const EMBV& positions, float ke, float kf, float kv)
{
Map3* ptrMap3 = dynamic_cast<Map3*>(&map);
if (ptrMap3 != NULL)
{
updateDataMap3<PFP,EMBV,EMB>(map,positions,ke,kf,kv);
}
GMap3* ptrGMap3 = dynamic_cast<GMap3*>(&map);
if (ptrGMap3 != NULL)
{
updateDataGMap3<PFP,EMBV,EMB>(map,positions,ke,kf,kv);
}
}
template<typename PFP, typename EMBV, typename EMB>