Commit aac0ab43 authored by Sylvain Thery's avatar Sylvain Thery

add svg of Edges in explodeVolumeRender

parent 96ca248e
...@@ -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
......
...@@ -39,6 +39,18 @@ namespace CGoGN ...@@ -39,6 +39,18 @@ namespace CGoGN
{ {
class RegisteredBaseAttribute; class RegisteredBaseAttribute;
class AttributeContainer;
class ContainerBrowser
{
public:
virtual unsigned int begin() const = 0;
virtual unsigned int end() const = 0;
virtual void next(unsigned int &it) const = 0;
virtual void enable() = 0;
virtual void disable() = 0;
};
/** /**
* Container for AttributeMultiVectors * Container for AttributeMultiVectors
...@@ -84,6 +96,8 @@ protected: ...@@ -84,6 +96,8 @@ protected:
*/ */
std::vector<unsigned int> m_tableBlocksEmpty; std::vector<unsigned int> m_tableBlocksEmpty;
ContainerBrowser* m_currentBrowser;
/** /**
* orbit of the container * orbit of the container
*/ */
...@@ -129,6 +143,8 @@ public: ...@@ -129,6 +143,8 @@ public:
void setRegistry(std::map<std::string, RegisteredBaseAttribute*>* re); void setRegistry(std::map<std::string, RegisteredBaseAttribute*>* re);
void setContainerBrowser(ContainerBrowser* bro) { m_currentBrowser = bro;}
/************************************** /**************************************
* BASIC FEATURES * * BASIC FEATURES *
**************************************/ **************************************/
...@@ -224,6 +240,25 @@ public: ...@@ -224,6 +240,25 @@ public:
*/ */
void next(unsigned int &it) const; void next(unsigned int &it) const;
/**
* return the index of the first line of the container
*/
unsigned int realBegin() const;
/**
* return the index of the last line of the container
*/
unsigned int realEnd() const;
/**
* get the index of the line after it in the container
* MUST BE USED INSTEAD OF ++ !
*/
void realNext(unsigned int &it) const;
/************************************** /**************************************
* INFO ABOUT ATTRIBUTES * * INFO ABOUT ATTRIBUTES *
**************************************/ **************************************/
......
...@@ -231,7 +231,50 @@ inline bool AttributeContainer::used(unsigned int index) const ...@@ -231,7 +231,50 @@ inline bool AttributeContainer::used(unsigned int index) const
* CONTAINER TRAVERSAL * * CONTAINER TRAVERSAL *
**************************************/ **************************************/
//inline unsigned int AttributeContainer::begin() const
//{
// unsigned int it = 0;
// while ((it < m_maxSize) && (!used(it)))
// ++it;
// return it;
//}
//inline unsigned int AttributeContainer::end() const
//{
// return m_maxSize;
//}
//inline void AttributeContainer::next(unsigned int &it) const
//{
// do
// {
// ++it;
// } while ((it < m_maxSize) && (!used(it)));
//}
inline unsigned int AttributeContainer::begin() const inline unsigned int AttributeContainer::begin() const
{
if (m_currentBrowser != NULL)
return m_currentBrowser->begin();
return AttributeContainer::realBegin();
}
inline unsigned int AttributeContainer::end() const
{
if (m_currentBrowser != NULL)
return m_currentBrowser->end();
return AttributeContainer::realEnd();
}
inline void AttributeContainer::next(unsigned int &it) const
{
if (m_currentBrowser != NULL)
m_currentBrowser->next(it);
else
AttributeContainer::realNext(it);
}
inline unsigned int AttributeContainer::realBegin() const
{ {
unsigned int it = 0; unsigned int it = 0;
while ((it < m_maxSize) && (!used(it))) while ((it < m_maxSize) && (!used(it)))
...@@ -239,12 +282,12 @@ inline unsigned int AttributeContainer::begin() const ...@@ -239,12 +282,12 @@ inline unsigned int AttributeContainer::begin() const
return it; return it;
} }
inline unsigned int AttributeContainer::end() const inline unsigned int AttributeContainer::realEnd() const
{ {
return m_maxSize; return m_maxSize;
} }
inline void AttributeContainer::next(unsigned int &it) const inline void AttributeContainer::realNext(unsigned int &it) const
{ {
do do
{ {
......
...@@ -104,45 +104,48 @@ Dart TraversorCell<MAP, ORBIT>::end() ...@@ -104,45 +104,48 @@ Dart TraversorCell<MAP, ORBIT>::end()
template <typename MAP, unsigned int ORBIT> template <typename MAP, unsigned int ORBIT>
Dart TraversorCell<MAP, ORBIT>::next() Dart TraversorCell<MAP, ORBIT>::next()
{ {
if(current != NIL) assert(current != NIL);
// if(current != NIL)
// {
if(quickTraversal != NULL)
{ {
if(quickTraversal != NULL) cont->next(qCurrent) ;
{ if (qCurrent != cont->end())
cont->next(qCurrent) ;
current = (*quickTraversal)[qCurrent] ; current = (*quickTraversal)[qCurrent] ;
} else current = NIL;
else }
else
{
if(dmark)
{ {
if(dmark) bool ismarked = dmark->isMarked(current) ;
while(current != NIL && (ismarked || m.template isBoundaryMarked<MAP::DIMENSION>(current)))
{ {
bool ismarked = dmark->isMarked(current) ; m.next(current) ;
while(current != NIL && (ismarked || m.template isBoundaryMarked<MAP::DIMENSION>(current))) if(current == m.end())
{ current = NIL ;
m.next(current) ; else
if(current == m.end()) ismarked = dmark->isMarked(current) ;
current = NIL ;
else
ismarked = dmark->isMarked(current) ;
}
if(current != NIL)
dmark->markOrbit<ORBIT>(current) ;
} }
else if(current != NIL)
dmark->markOrbit<ORBIT>(current) ;
}
else
{
bool ismarked = cmark->isMarked(current) ;
while(current != NIL && (ismarked || m.template isBoundaryMarked<MAP::DIMENSION>(current) ))
{ {
bool ismarked = cmark->isMarked(current) ; m.next(current) ;
while(current != NIL && (ismarked || m.template isBoundaryMarked<MAP::DIMENSION>(current) )) if(current == m.end())
{ current = NIL ;
m.next(current) ; else
if(current == m.end()) ismarked = cmark->isMarked(current) ;
current = NIL ;
else
ismarked = cmark->isMarked(current) ;
}
if(current != NIL)
cmark->mark(current) ;
} }
if(current != NIL)
cmark->mark(current) ;
} }
} }
// }
return current ; return current ;
} }
...@@ -237,45 +240,48 @@ Dart TraversorCell<GenericMap, ORBIT>::end() ...@@ -237,45 +240,48 @@ Dart TraversorCell<GenericMap, ORBIT>::end()
template <unsigned int ORBIT> template <unsigned int ORBIT>
Dart TraversorCell<GenericMap, ORBIT>::next() Dart TraversorCell<GenericMap, ORBIT>::next()
{ {
if(current != NIL) assert(current != NIL);
// if(current != NIL)
// {
if(quickTraversal != NULL)
{ {
if(quickTraversal != NULL) cont->next(qCurrent) ;
{ if (qCurrent != cont->end())
cont->next(qCurrent) ;
current = (*quickTraversal)[qCurrent] ; current = (*quickTraversal)[qCurrent] ;
} else current = NIL;
else }
else
{
if(dmark)
{ {
if(dmark) bool ismarked = dmark->isMarked(current) ;
while(current != NIL && (ismarked || m.isBoundaryMarkedCurrent(current) ))
{ {
bool ismarked = dmark->isMarked(current) ; m.next(current) ;
while(current != NIL && (ismarked || m.isBoundaryMarkedCurrent(current) )) if(current == m.end())
{ current = NIL ;
m.next(current) ; else
if(current == m.end()) ismarked = dmark->isMarked(current) ;
current = NIL ;
else
ismarked = dmark->isMarked(current) ;
}
if(current != NIL)
dmark->markOrbit<ORBIT>(current) ;
} }
else if(current != NIL)
dmark->markOrbit<ORBIT>(current) ;
}
else
{
bool ismarked = cmark->isMarked(current) ;
while(current != NIL && (ismarked || m.isBoundaryMarkedCurrent(current) ))
{ {
bool ismarked = cmark->isMarked(current) ; m.next(current) ;
while(current != NIL && (ismarked || m.isBoundaryMarkedCurrent(current) )) if(current == m.end())
{ current = NIL ;
m.next(current) ; else
if(current == m.end()) ismarked = cmark->isMarked(current) ;
current = NIL ;
else
ismarked = cmark->isMarked(current) ;
}
if(current != NIL)
cmark->mark(current) ;
} }
if(current != NIL)
cmark->mark(current) ;
} }
} }
// }
return current ; return current ;
} }
......
...@@ -64,6 +64,8 @@ public: ...@@ -64,6 +64,8 @@ public:
void setColor(const Geom::Vec4f& color); void setColor(const Geom::Vec4f& color);
const Geom::Vec4f& getColor() const;
void setClippingPlane(const Geom::Vec4f& plane); void setClippingPlane(const Geom::Vec4f& plane);
void setParams(float explodeV, const Geom::Vec4f& color, const Geom::Vec4f& plane); void setParams(float explodeV, const Geom::Vec4f& color, const Geom::Vec4f& plane);
......
...@@ -35,6 +35,7 @@ namespace CGoGN ...@@ -35,6 +35,7 @@ namespace CGoGN
{ {
AttributeContainer::AttributeContainer() : AttributeContainer::AttributeContainer() :
m_currentBrowser(NULL),
m_orbit(0), m_orbit(0),
m_nbAttributes(0), m_nbAttributes(0),
m_nbUnknown(0), m_nbUnknown(0),
......
...@@ -112,6 +112,11 @@ void ShaderExplodeVolumesLines::setColor(const Geom::Vec4f& color) ...@@ -112,6 +112,11 @@ void ShaderExplodeVolumesLines::setColor(const Geom::Vec4f& color)
unbind(); unbind();
} }
const Geom::Vec4f& ShaderExplodeVolumesLines::getColor() const
{
return m_color;
}
void ShaderExplodeVolumesLines::setClippingPlane(const Geom::Vec4f& plane) void ShaderExplodeVolumesLines::setClippingPlane(const Geom::Vec4f& plane)
{ {
m_plane = plane; m_plane = plane;
......
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