Commit 4eff38ed authored by Pierre Kraemer's avatar Pierre Kraemer

occluding contours v1

parent d204e178
......@@ -37,9 +37,9 @@ namespace Geometry
template <typename PFP>
typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
{
typename PFP::VEC3 p1 = position[d];
typename PFP::VEC3 p2 = position[map.phi1(d)];
typename PFP::VEC3 p3 = position[map.phi_1(d)];
typename PFP::VEC3 p1 = position[d] ;
typename PFP::VEC3 p2 = position[map.phi1(d)] ;
typename PFP::VEC3 p3 = position[map.phi_1(d)] ;
return Geom::triangleArea(p1, p2, p3) ;
}
......@@ -47,7 +47,7 @@ typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const typename P
template <typename PFP>
typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::VEC3 VEC3 ;
if(map.isFaceTriangle(d))
return triangleArea<PFP>(map, d, position) ;
......@@ -58,8 +58,8 @@ typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const typename
Dart it = d ;
do
{
VEC3 p1 = position[it];
VEC3 p2 = position[map.phi1(it)];
VEC3 p1 = position[it] ;
VEC3 p2 = position[map.phi1(it)] ;
area += Geom::triangleArea(p1, p2, centroid) ;
it = map.phi1(it) ;
} while (it != d) ;
......
......@@ -35,7 +35,10 @@ namespace Geometry
{
template <typename PFP>
void featureEdgeDetection(typename PFP::MAP& map, const typename PFP::TVEC3& position, DartMarker& feature) ;
void featureEdgeDetection(typename PFP::MAP& map, const typename PFP::TVEC3& position, CellMarker& featureEdge) ;
template <typename PFP>
std::vector<typename PFP::VEC3> occludingContoursDetection(typename PFP::MAP& map, const typename PFP::VEC3& viewDir, const typename PFP::TVEC3& position, const typename PFP::TVEC3& normal) ;
} // namespace Geometry
......
......@@ -35,28 +35,83 @@ namespace Geometry
{
template <typename PFP>
void featureEdgeDetection(typename PFP::MAP& map, typename PFP::TVEC3& position, DartMarker& feature)
void featureEdgeDetection(typename PFP::MAP& map, typename PFP::TVEC3& position, CellMarker& featureEdge)
{
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
feature.unmarkAll() ;
featureEdge.unmarkAll() ;
AttributeHandler<VEC3> fNormal = map.template addAttribute<VEC3>(FACE, "fNormal") ;
AttributeHandler<VEC3> fNormal = map.template getAttribute<VEC3>(FACE, "normal") ;
if(!fNormal.isValid())
fNormal = map.template addAttribute<VEC3>(FACE, "normal") ;
Algo::Geometry::computeNormalFaces<PFP>(map, position, fNormal) ;
DartMarker m(map) ;
CellMarker m(map, EDGE) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!m.isMarked(d))
{
m.markOrbit(EDGE, d) ;
m.mark(d) ;
if(Geom::angle(fNormal[d], fNormal[map.phi2(d)]) > M_PI / REAL(6))
feature.markOrbit(EDGE, d) ;
featureEdge.mark(d) ;
}
}
map.template removeAttribute<VEC3>(fNormal) ;
// map.template removeAttribute<VEC3>(fNormal) ;
}
template <typename PFP>
std::vector<typename PFP::VEC3> occludingContoursDetection(typename PFP::MAP& map, const typename PFP::VEC3& viewDir, const typename PFP::TVEC3& position, const typename PFP::TVEC3& normal)
{
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
std::vector<VEC3> occludingContours ;
CellMarker m(map, FACE) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!m.isMarked(d))
{
m.mark(d) ;
REAL dp1 = viewDir * normal[d] ;
REAL dp2 = viewDir * normal[map.phi1(d)] ;
REAL dp3 = viewDir * normal[map.phi_1(d)] ;
if(dp1 < 0 && dp2 > 0)
{
REAL alpha = -dp1 / (-dp1 + dp2) ;
occludingContours.push_back(alpha * position[d] + (1 - alpha) * position[map.phi1(d)]) ;
}
if(dp2 < 0 && dp1 > 0)
{
REAL alpha = dp1 / (dp1 - dp2) ;
occludingContours.push_back(alpha * position[d] + (1 - alpha) * position[map.phi1(d)]) ;
}
if(dp1 < 0 && dp3 > 0)
{
REAL alpha = -dp1 / (-dp1 + dp3) ;
occludingContours.push_back(alpha * position[d] + (1 - alpha) * position[map.phi_1(d)]) ;
}
if(dp3 < 0 && dp1 > 0)
{
REAL alpha = dp1 / (dp1 - dp3) ;
occludingContours.push_back(alpha * position[d] + (1 - alpha) * position[map.phi_1(d)]) ;
}
if(dp2 < 0 && dp3 > 0)
{
REAL alpha = -dp2 / (-dp2 + dp3) ;
occludingContours.push_back(alpha * position[map.phi1(d)] + (1 - alpha) * position[map.phi_1(d)]) ;
}
if(dp3 < 0 && dp2 > 0)
{
REAL alpha = dp2 / (dp2 - dp3) ;
occludingContours.push_back(alpha * position[map.phi1(d)] + (1 - alpha) * position[map.phi_1(d)]) ;
}
}
}
return occludingContours ;
}
} // namespace Geometry
......
......@@ -81,7 +81,7 @@ void pliantRemeshing(typename PFP::MAP& map, typename PFP::TVEC3& position, type
}
// compute feature edges
DartMarker featureEdge(map) ;
CellMarker featureEdge(map, EDGE) ;
Algo::Geometry::featureEdgeDetection<PFP>(map, position, featureEdge) ;
// compute feature vertices
......
......@@ -169,7 +169,7 @@ void BoundingBox<VEC>::fusion(const BoundingBox<VEC>& bb)
{
VEC bbmin = bb.min() ;
VEC bbmax = bb.max() ;
for(unsigned int i = 0; i < bbmin.size(); ++i)
for(unsigned int i = 0; i < bbmin.dimension(); ++i)
{
if(bbmin[i] < m_pMin[i])
m_pMin[i] = bbmin[i] ;
......
......@@ -910,14 +910,13 @@ void GLSLShader::addPathFileSeach(const std::string& path)
m_pathes.push_back(path);
}
unsigned int GLSLShader::bindVA_VBO(const std::string& name, VBO* vbo)
{
GLint idVA = glGetAttribLocation(this->m_program_object, name.c_str());
//valid ?
if (idVA < 0)
{
CGoGNerr << "GLSLShader: Attribute "<<name<< " does not exist in shader"<< CGoGNendl;
CGoGNerr << "GLSLShader: Attribute " << name << " does not exist in shader" << CGoGNendl;
return idVA;
}
// search if name already exist
......@@ -937,16 +936,11 @@ unsigned int GLSLShader::bindVA_VBO(const std::string& name, VBO* vbo)
return (m_va_vbo_binding.size() -1);
}
void GLSLShader::changeVA_VBO(unsigned int id, VBO* vbo)
{
m_va_vbo_binding[id].vbo_ptr = vbo;
}
void GLSLShader::unbindVA(const std::string& name)
{
GLint idVA = glGetAttribLocation(this->m_program_object, name.c_str());
......@@ -971,9 +965,6 @@ void GLSLShader::unbindVA(const std::string& name)
CGoGNerr << "GLSLShader: Attribute "<<name<< " not binded"<< CGoGNendl;
}
void GLSLShader::setCurrentOGLVersion(unsigned int version)
{
CURRENT_OGL_VERSION = version;
......@@ -1026,7 +1017,6 @@ void GLSLShader::disableVertexAttribs() const
this->unbind();
}
void GLSLShader::updateCurrentMatrices()
{
glm::mat4 model(currentModelView());
......@@ -1036,9 +1026,6 @@ void GLSLShader::updateCurrentMatrices()
it->second->updateMatrices(currentProjection(), model);
}
} // namespace Utils
} // namespace CGoGN
......@@ -316,9 +316,9 @@ GLfloat SimpleQT::getOrthoScreenRay(int x, int y, Geom::Vec3f& rayA, Geom::Vec3f
GLfloat depth_t[25];
glReadPixels(x-2, yy-2, 5, 5, GL_DEPTH_COMPONENT, GL_FLOAT, depth_t);
GLfloat depth=0.0f;
unsigned int nb=0;
for (unsigned int i=0; i< 25; ++i)
GLfloat depth = 0.0f;
unsigned int nb = 0;
for (unsigned int i = 0; i < 25; ++i)
{
if (depth_t[i] != 1.0f)
{
......@@ -326,7 +326,7 @@ GLfloat SimpleQT::getOrthoScreenRay(int x, int y, Geom::Vec3f& rayA, Geom::Vec3f
nb++;
}
}
if (nb>0)
if (nb > 0)
depth /= float(nb);
else
depth = 0.5f;
......
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