Commit 13003306 authored by Pierre Kraemer's avatar Pierre Kraemer

debut algo feature detection

parent 3526329c
......@@ -287,7 +287,7 @@ public:
Algo::Geometry::computeNormalVertices<PFP>(m, pos, normal) ;
}
edgeangle = m.template getAttribute<REAL>(VERTEX, "edgeangle") ;
edgeangle = m.template getAttribute<REAL>(EDGE, "edgeangle") ;
if(!edgeangle.isValid())
{
edgeangle = m.template addAttribute<REAL>(EDGE, "edgeangle") ;
......
......@@ -40,6 +40,9 @@ void featureEdgeDetection(typename PFP::MAP& map, const typename PFP::TVEC3& pos
template <typename PFP>
std::vector<typename PFP::VEC3> occludingContoursDetection(typename PFP::MAP& map, const typename PFP::VEC3& cameraPosition, const typename PFP::TVEC3& position, const typename PFP::TVEC3& normal) ;
template <typename PFP>
std::vector<typename PFP::VEC3> featureLinesDetection(typename PFP::MAP& map, const typename PFP::TVEC3& position, const typename PFP::TVEC3& normal) ;
} // namespace Geometry
} // namespace Algo
......
......@@ -120,6 +120,66 @@ std::vector<typename PFP::VEC3> occludingContoursDetection(typename PFP::MAP& ma
return occludingContours ;
}
template <typename PFP>
std::vector<typename PFP::VEC3> featureLinesDetection(typename PFP::MAP& map, const typename PFP::TVEC3& position, const typename PFP::TVEC3& normal)
{
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
std::vector<VEC3> featureLines ;
Geom::BoundingBox<VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(map, position) ;
AttributeHandler<REAL> edgeangle = map.template getAttribute<REAL>(EDGE, "edgeangle") ;
if(!edgeangle.isValid())
{
edgeangle = map.template addAttribute<REAL>(EDGE, "edgeangle") ;
Algo::Geometry::computeAnglesBetweenNormalsOnEdges<PFP>(map, position, edgeangle) ;
}
AttributeHandler<REAL> kmax = map.template getAttribute<REAL>(VERTEX, "kmax") ;
AttributeHandler<REAL> kmin = map.template getAttribute<REAL>(VERTEX, "kmin") ;
AttributeHandler<VEC3> Kmax = map.template getAttribute<VEC3>(VERTEX, "Kmax") ;
AttributeHandler<VEC3> Kmin = map.template getAttribute<VEC3>(VERTEX, "Kmin") ;
AttributeHandler<VEC3> Knormal = map.template getAttribute<VEC3>(VERTEX, "Knormal") ;
// as all these attributes are computed simultaneously by computeCurvatureVertices
// one can assume that if one of them is not valid, the others must be created too
if(!kmax.isValid())
{
kmax = map.template addAttribute<REAL>(VERTEX, "kmax") ;
kmin = map.template addAttribute<REAL>(VERTEX, "kmin") ;
Kmax = map.template addAttribute<VEC3>(VERTEX, "Kmax") ;
Kmin = map.template addAttribute<VEC3>(VERTEX, "Kmin") ;
Knormal = map.template addAttribute<VEC3>(VERTEX, "Knormal") ;
Algo::Geometry::computeCurvatureVertices_NormalCycles<PFP>(map, 0.01f * bb.diagSize(), position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal) ;
}
AttributeHandler<VEC3> kmaxGrad = map.template addAttribute<VEC3>(FACE, "kmaxGrad") ;
AttributeHandler<VEC3> kminGrad = map.template addAttribute<VEC3>(FACE, "kminGrad") ;
CellMarker mf(map, FACE) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!mf.isMarked(d))
{
mf.mark(d) ;
Dart v1 = d ;
Dart v2 = myMap.phi1(d) ;
Dart v3 = myMap.phi_1(d) ;
VEC3 v3v2 = position[v3] - position[v2] ;
VEC3 v1v3 = position[v1] - position[v3] ;
VEC3 v2v1 = position[v2] - position[v1] ;
VEC3 n = Geom::triangleNormal(position[v1], position[v2], position[v3]) ;
n.normalize() ;
VEC3 g1 = (n^v3v2 * kmax[v1]) + (n^v1v3 * kmax[v2]) + (n^v2v1 * kmax[v3]) ;
VEC3 g2 = (n^v3v2 * kmin[v1]) + (n^v1v3 * kmin[v2]) + (n^v2v1 * kmin[v3]) ;
g1.normalize() ;
kmaxGrad[d] = g1 ;
kminGrad[d] = g2 ;
}
}
}
} // namespace Geometry
} // namespace Algo
......
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