Commit 26cc8e85 authored by Sylvain Thery's avatar Sylvain Thery

Ajour rendu de points en svg

parent c5c74a8f
......@@ -87,15 +87,21 @@ public:
};
class SvgPolyline: public SvgObj
class SvgPoints: public SvgObj
{
protected:
float m_pointSize;
public:
SvgPoints(): m_pointSize(4) {}
void save(std::ofstream& out);
void setPointSize(float ps) {m_pointSize=ps;}
};
class SvgPolyline: public SvgObj
{
public:
void save(std::ofstream& out);
};
......@@ -153,6 +159,10 @@ public:
template <typename PFP>
void renderFacesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, float shrink, const FunctorSelect& good = SelectorTrue(), unsigned int thread=0);
template <typename PFP>
void renderPointsToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& good = SelectorTrue(), unsigned int thread=0);
void orderPrimitives(std::list<SvgObj*>& primitives);
};
......
......@@ -38,6 +38,32 @@ namespace Render
namespace SVG
{
template <typename PFP>
void SVGOut::renderPointsToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& good, unsigned int thread)
{
glm::i32vec4 viewport;
glGetIntegerv(GL_VIEWPORT, &(viewport[0]));
SvgPoints* points = new SvgPoints();
points->setColor(global_color);
DartMarker m(map, thread);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!m.isMarked(d) && good(d))
{
const Geom::Vec3f& P = position[d];
glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
glm::vec3 R = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,glm::mat4(1.0),viewport);
points->addVertex(Geom::Vec3f(Q[0],float(viewport[3])-Q[1],Q[2]));
m.markOrbit(VERTEX, d);
}
}
m_objs.push_back(points);
}
template <typename PFP>
void SVGOut::renderLinesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& good, unsigned int thread)
{
......
......@@ -86,6 +86,35 @@ Geom::Vec3f SvgObj::normal()
}
void SvgPoints::save(std::ofstream& out)
{
std::stringstream ss;
std::cout << "SAVE" << std::endl;
for (std::vector<Geom::Vec3f>::iterator it =m_vertices.begin(); it != m_vertices.end(); ++it)
{
out << "<circle cx=\""<< (*it)[0];
out << "\" cy=\""<< (*it)[1];
out << "\" r=\""<< m_pointSize;
out << "\" style=\"stroke: none; fill: #";
out << std::hex;
unsigned int wp = out.width(2);
char prev = out.fill('0');
out << int(m_color[0]*255);
out.width(2); out.fill('0');
out<< int(m_color[1]*255);
out.width(2); out.fill('0');
out << int(m_color[2]*255)<<std::dec;
out.fill(prev);
out.width(wp);
out <<"\"/>"<< std::endl;
}
}
void SvgPolyline::save(std::ofstream& out)
{
......@@ -208,12 +237,13 @@ void SVGOut::setWidth(float w)
void SVGOut::closeFile()
{
// here do the sort in necessary
compNormObj cmp;
std::sort(m_objs.begin(),m_objs.end(),cmp);
// compNormObj cmp;
// std::sort(m_objs.begin(),m_objs.end(),cmp);
std::list<SvgObj*> primitives;
std::cout << "CLOSE"<< std::endl;
// std::list<SvgObj*> primitives;
for (std::list<SvgObj*>::iterator it = primitives.begin(); it != primitives.end(); ++it)
for (std::vector<SvgObj*>::iterator it = m_objs.begin(); it != m_objs.end(); ++it)
{
(*it)->save(*m_out);
}
......
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