Commit ae997b3c authored by Sylvain Thery's avatar Sylvain Thery

ajout culling sur rendu svg faces

parent a134c4e7
......@@ -153,7 +153,7 @@ public:
void renderLinesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& good = SelectorTrue(), unsigned int thread=0);
template <typename PFP>
void renderFacesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, float shrink, const FunctorSelect& good = SelectorTrue(), unsigned int thread=0);
void renderFacesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, float shrink, bool cull = false, 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);
......
......@@ -101,7 +101,7 @@ void SVGOut::renderLinesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3&
template <typename PFP>
void SVGOut::renderFacesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, float shrink, const FunctorSelect& good, unsigned int thread)
void SVGOut::renderFacesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, float shrink, bool cull, const FunctorSelect& good, unsigned int thread)
{
glm::i32vec4 viewport;
glGetIntegerv(GL_VIEWPORT, &(viewport[0]));
......@@ -111,25 +111,42 @@ void SVGOut::renderFacesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3&
{
if(!m.isMarked(d) && good(d))
{
typename PFP::VEC3 center = Algo::Geometry::faceCentroid<PFP>(map,d,position);
SvgPolygon* pol = new SvgPolygon();
Dart dd = d;
do
bool cullFace=false;
if (cull)
{
Geom::Vec3f P = position[d];
P = P*shrink + center*(1.0f-shrink);
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);
pol->addVertex(Geom::Vec3f(Q[0],float(viewport[3])-Q[1],Q[2]));
pol->addVertex3D(Geom::Vec3f(R[0],R[1],R[2]));
d = map.phi1(d);
}while (d!=dd);
pol->close();
pol->setColor(global_color);
pol->setWidth(global_width);
m_objs.push_back(pol);
const Geom::Vec3f& P = position[d];
glm::vec3 Q = glm::project(glm::vec3(P[0],P[1],P[2]),m_model,m_proj,viewport);
const Geom::Vec3f& P2 = position[map.phi1(d)];
glm::vec3 R = glm::project(glm::vec3(P2[0],P2[1],P2[2]),m_model,m_proj,viewport);
const Geom::Vec3f& P3 = position[map.phi1(map.phi1(d))];
glm::vec3 S = glm::project(glm::vec3(P3[0],P3[1],P3[2]),m_model,m_proj,viewport);
glm::vec3 N = glm::cross(S-R,Q-R);
if (N[2]<0.0f)
cullFace=true;
}
if (!cullFace)
{
typename PFP::VEC3 center = Algo::Geometry::faceCentroid<PFP>(map,d,position);
SvgPolygon* pol = new SvgPolygon();
Dart dd = d;
do
{
Geom::Vec3f P = position[d];
P = P*shrink + center*(1.0f-shrink);
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);
pol->addVertex(Geom::Vec3f(Q[0],float(viewport[3])-Q[1],Q[2]));
pol->addVertex3D(Geom::Vec3f(R[0],R[1],R[2]));
d = map.phi1(d);
}while (d!=dd);
pol->close();
pol->setColor(global_color);
pol->setWidth(global_width);
m_objs.push_back(pol);
}
m.markOrbit(FACE, 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