Commit 46711425 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop' of cgogn:~vanhoey/CGoGN into develop

Conflicts:
	include/Algo/Geometry/normal.hpp
parents b9ae811b 5ebd12a3
......@@ -142,7 +142,7 @@ IF (WITH_QT)
ADD_DEFINITIONS(${QT_DEFINITIONS})
find_package(QGLViewer REQUIRED)
SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${QT_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR} )
SET (CGoGN_EXT_LIBS ${CGoGN_EXT_LIBS} ${QT_LIBRARIES} ${QGLVIEWER_LIBRARIES} )
SET (CGoGN_EXT_LIBS ${QT_LIBRARIES} ${QGLVIEWER_LIBRARIES} ${CGoGN_EXT_LIBS})
ENDIF (WITH_QT)
IF (WITH_GLEWMX)
......
......@@ -195,7 +195,7 @@ int decimate(
return -1 ; // init failed
}
unsigned int nbVertices = Algo::Topo::getNbOrbits<VERTEX>(map) ;
unsigned int nbVertices = Algo::Topo::getNbOrbits<VERTEX>(map) ;
bool finished = false ;
while(!finished)
......
......@@ -230,8 +230,8 @@ public:
m_approxindex_normal(-1),
m_attrindex_normal(-1)
{
halfEdgeInfo = m.template addAttribute<HalfEdgeInfo, DART>("halfEdgeInfo") ;
m_quadric = m.template addAttribute<Utils::QuadricNd<REAL,9>, VERTEX>("hQEMextNormal-quadric") ;
halfEdgeInfo = m.template addAttribute<HalfEdgeInfo, DART, MAP>("halfEdgeInfo") ;
m_quadric = m.template addAttribute<Utils::QuadricNd<REAL,9>, VERTEX, MAP>("hQEMextNormal-quadric") ;
}
~HalfEdgeSelector_QEMextColorNormal()
{
......
......@@ -619,7 +619,7 @@ bool HalfEdgeSelector_QEMextColorNormal<PFP>::init()
++ok ;
m_approxindex_color = approxindex ;
m_attrindex_color = attrindex ;
m_color = m.template getAttribute<typename PFP::VEC3, VERTEX>("color") ;
m_color = m.template getAttribute<typename PFP::VEC3, VERTEX, MAP>("color") ;
assert(m_color.isValid() || !"EdgeSelector_QEMextColor: color attribute is not valid") ;
if (!saved)
{
......@@ -632,7 +632,7 @@ bool HalfEdgeSelector_QEMextColorNormal<PFP>::init()
++ok ;
m_approxindex_normal = approxindex ;
m_attrindex_normal = attrindex ;
m_normal = m.template getAttribute<typename PFP::VEC3, VERTEX>("normal") ;
m_normal = m.template getAttribute<typename PFP::VEC3, VERTEX, MAP>("normal") ;
assert(m_normal.isValid() || !"EdgeSelector_QEMextColorNormal: normal attribute is not valid") ;
if (!saved)
{
......
......@@ -46,7 +46,6 @@ template <typename PFP>
bool exportPLY(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const char* filename, bool binary)
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
// open file
std::ofstream out ;
......@@ -989,7 +988,6 @@ template <typename PFP>
bool exportChoupi(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const char* filename)
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
std::ofstream out(filename, std::ios::out) ;
if (!out.good())
......
......@@ -59,13 +59,24 @@ void sigmaBilateral(typename PFP::MAP& map, const VertexAttribute<typename PFP::
sigmaS = 2.5f * ( sumAngles / float(nbEdges) ) ;
}
/**
* \brief Function applying a bilateral filter smoothing on the mesh.
* \param map the map of the mesh
* \param positionIn the current positions container of the mesh
* \param positionOut the smoothed positions after the function call
* \param normal the normals
*/
template <typename PFP>
void filterBilateral(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position2, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& normal)
void filterBilateral(
typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3,typename PFP::MAP>& positionIn,
VertexAttribute<typename PFP::VEC3,typename PFP::MAP>& positionOut,
const VertexAttribute<typename PFP::VEC3,typename PFP::MAP>& normal)
{
typedef typename PFP::VEC3 VEC3 ;
float sigmaC, sigmaS ;
sigmaBilateral<PFP>(map, position, normal, sigmaC, sigmaS) ;
sigmaBilateral<PFP>(map, positionIn, normal, sigmaC, sigmaS) ;
TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
......@@ -80,7 +91,7 @@ void filterBilateral(typename PFP::MAP& map, const VertexAttribute<typename PFP:
Traversor2VE<typename PFP::MAP> te(map, d) ;
for(Dart it = te.begin(); it != te.end(); it = te.next())
{
VEC3 vec = Algo::Surface::Geometry::vectorOutOfDart<PFP>(map, it, position) ;
VEC3 vec = Algo::Surface::Geometry::vectorOutOfDart<PFP>(map, it, positionIn) ;
float h = normal_d * vec ;
float t = vec.norm() ;
float wcs = exp( ( -1.0f * (t * t) / (2.0f * sigmaC * sigmaC) ) + ( -1.0f * (h * h) / (2.0f * sigmaS * sigmaS) ) ) ;
......@@ -88,10 +99,10 @@ void filterBilateral(typename PFP::MAP& map, const VertexAttribute<typename PFP:
normalizer += wcs ;
}
position2[d] = position[d] + ((sum / normalizer) * normal_d) ;
positionOut[d] = positionIn[d] + ((sum / normalizer) * normal_d) ;
}
else
position2[d] = position[d] ;
positionOut[d] = positionIn[d] ;
}
}
......
......@@ -28,6 +28,8 @@
#include "Topology/generic/traversor/traversorCell.h"
#include "Topology/generic/traversor/traversor2.h"
#include "Algo/Parallel/parallel_foreach.h"
#include <cmath>
namespace CGoGN
......@@ -45,8 +47,6 @@ namespace Geometry
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE triangleNormal(typename PFP::MAP& map, Face f, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typename V_ATT::DATA_TYPE N = Geom::triangleNormal(
position[f.dart],
position[map.phi1(f)],
......@@ -59,8 +59,6 @@ typename V_ATT::DATA_TYPE triangleNormal(typename PFP::MAP& map, Face f, const V
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE newellNormal(typename PFP::MAP& map, Face f, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typedef typename V_ATT::DATA_TYPE VEC3;
VEC3 N(0);
......@@ -80,8 +78,6 @@ typename V_ATT::DATA_TYPE newellNormal(typename PFP::MAP& map, Face f, const V_A
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE faceNormal(typename PFP::MAP& map, Face f, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
if(map.faceDegree(f) == 3)
return triangleNormal<PFP>(map, f, position) ;
else
......@@ -91,8 +87,6 @@ typename V_ATT::DATA_TYPE faceNormal(typename PFP::MAP& map, Face f, const V_ATT
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typedef typename V_ATT::DATA_TYPE VEC3 ;
VEC3 N(0) ;
......@@ -104,12 +98,8 @@ typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V
{
VEC3 v1 = vectorOutOfDart<PFP>(map, f.dart, position) ;
VEC3 v2 = vectorOutOfDart<PFP>(map, map.phi_1(f), position) ;
typename VEC3::DATA_TYPE l = (v1.norm2() * v2.norm2());
if (l > (typename VEC3::DATA_TYPE(0.0)) )
{
n *= convexFaceArea<PFP>(map, f, position) / l ;
N += n ;
}
n *= convexFaceArea<PFP>(map, f, position) / (v1.norm2() * v2.norm2()) ;
N += n ;
}
});
......@@ -120,7 +110,6 @@ typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexBorderNormal(typename PFP::MAP& map, Vertex v, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
assert(map.dimension() == 3);
typedef typename V_ATT::DATA_TYPE VEC3 ;
......@@ -156,43 +145,39 @@ typename V_ATT::DATA_TYPE vertexBorderNormal(typename PFP::MAP& map, Vertex v, c
template <typename PFP, typename V_ATT, typename F_ATT>
void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_normal, unsigned int thread)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(F_ATT, FACE);
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread == 0))
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeNormalFaces<PFP,V_ATT,F_ATT>(map, position, face_normal);
Parallel::computeNormalFaces<PFP,V_ATT,F_ATT>(map,position,face_normal);
return;
}
foreach_cell<FACE>(map, [&] (Face f)
{
face_normal[f] = faceNormal<PFP>(map, f, position) ;
}, AUTO, thread);
},
AUTO, thread);
}
template <typename PFP, typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal, unsigned int thread)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread == 0))
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeNormalVertices<PFP,V_ATT>(map, position, normal);
Parallel::computeNormalVertices<PFP,V_ATT>(map,position,normal);
return;
}
foreach_cell<VERTEX>(map, [&] (Vertex v)
{
normal[v] = vertexNormal<PFP>(map, v, position) ;
}, FORCE_CELL_MARKING, thread);
},
FORCE_CELL_MARKING, thread);
}
template <typename PFP, typename V_ATT>
typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Edge e, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typedef typename V_ATT::DATA_TYPE VEC3 ;
if(map.isBoundaryEdge(e))
......@@ -226,58 +211,50 @@ typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Edge
template <typename PFP, typename V_ATT, typename E_ATT>
void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& position, E_ATT& angles, unsigned int thread)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(E_ATT, EDGE);
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread == 0))
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
{
Parallel::computeAnglesBetweenNormalsOnEdges<PFP,V_ATT,E_ATT>(map, position, angles);
Parallel::computeAnglesBetweenNormalsOnEdges<PFP,V_ATT,E_ATT>(map,position,angles);
return;
}
foreach_cell<EDGE>(map, [&] (Edge e)
{
angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ;
}, AUTO, thread);
},
AUTO, thread);
}
namespace Parallel
{
template <typename PFP, typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CGoGN::Parallel::foreach_cell<VERTEX>(map, [&] (Vertex v, unsigned int /*thr*/)
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int /*thr*/)
{
normal[v] = vertexNormal<PFP>(map, v, position) ;
}, FORCE_CELL_MARKING);
},true,FORCE_CELL_MARKING);
}
template <typename PFP, typename V_ATT, typename F_ATT>
void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& normal)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(F_ATT, FACE);
CGoGN::Parallel::foreach_cell<FACE>(map, [&] (Face f, unsigned int /*thr*/)
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
normal[f] = faceNormal<PFP>(map, f, position) ;
});
},true,AUTO);
}
template <typename PFP, typename V_ATT, typename E_ATT>
void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& position, E_ATT& angles)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(E_ATT, EDGE);
CGoGN::Parallel::foreach_cell<EDGE>(map,[&](Edge e, unsigned int /*thr*/)
CGoGN::Parallel::foreach_cell<EDGE>(map,[&](Edge e, unsigned int thr)
{
angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ;
});
},true,AUTO);
}
} // namespace Parallel
......
......@@ -73,18 +73,6 @@ bool MeshTablesSurface<PFP>::importMesh(const std::string& filename, std::vector
CGoGNout << "TYPE: PLY" << CGoGNendl;
return importPly(filename, attrNames);
break;
/* case PLYPTM:
CGoGNout << "TYPE: PLYPTM" << CGoGNendl;
return importPlyPTM(filename, attrNames);
break;
*/ case PLYSLFgeneric:
CGoGNout << "TYPE: PLYSLFgeneric" << CGoGNendl;
return importPlySLFgeneric(filename, attrNames);
break;
case PLYSLFgenericBin:
CGoGNout << "TYPE: PLYSLFgenericBin" << CGoGNendl;
return importPlySLFgenericBin(filename, attrNames);
break;
case OBJ:
CGoGNout << "TYPE: OBJ" << CGoGNendl;
return importObj(filename, attrNames);
......@@ -772,7 +760,7 @@ bool MeshTablesSurface<PFP>::importPlySLFgeneric(const std::string& filename, st
// Define containers
VertexAttribute<VEC3, MAP> positions = m_map.template getAttribute<VEC3, VERTEX, MAP>("position") ;
;
if (!positions.isValid())
positions = m_map.template addAttribute<VEC3, VERTEX, MAP>("position") ;
attrNames.push_back(positions.name()) ;
......
......@@ -48,15 +48,6 @@ namespace Import
if ((filename.rfind(".meshbin")!=std::string::npos) || (filename.rfind(".MESHBIN")!=std::string::npos))
return MESHBIN;
/* if ((filename.rfind(".plyptm")!=std::string::npos) || (filename.rfind(".PLYGEN")!=std::string::npos))
return PLYPTM;
*/
if ((filename.rfind(".plyPTMextBin")!=std::string::npos) || (filename.rfind(".plySHrealBin")!=std::string::npos))
return PLYSLFgenericBin;
if ((filename.rfind(".plyPTMext")!=std::string::npos) || (filename.rfind(".plySHreal")!=std::string::npos))
return PLYSLFgeneric;
if ((filename.rfind(".ply")!=std::string::npos) || (filename.rfind(".PLY")!=std::string::npos))
return PLY;
......
......@@ -59,7 +59,7 @@ private:
MAP& m_map ;
VertexAttribute<VEC3, MAP>& position ;
DartMarker<MAP>& inactiveMarker ;
DartMarker<MAP>& inactiveMarker ;
Algo::Surface::Decimation::Selector<PFP>* m_selector ;
std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*> m_approximators ;
......@@ -81,15 +81,15 @@ private:
public:
ProgressiveMesh(
MAP& map,
DartMarker<MAP>& inactive,
DartMarker<MAP>& inactive,
Algo::Surface::Decimation::SelectorType s,
Algo::Surface::Decimation::ApproximatorType a,
VertexAttribute<VEC3, MAP>& position
) ;
ProgressiveMesh(
MAP& map, DartMarker& inactive,
MAP& map, DartMarker<MAP>& inactive,
Algo::Surface::Decimation::Selector<PFP>* selector, std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*>& approximators,
VertexAttribute<typename PFP::VEC3>& position) ;
VertexAttribute<VEC3, MAP>& position) ;
~ProgressiveMesh() ;
bool initOk() { return m_initOk ; }
......
......@@ -39,13 +39,13 @@ namespace PMesh
template <typename PFP>
ProgressiveMesh<PFP>::ProgressiveMesh(
MAP& map,
DartMarker<MAP>& inactive,
DartMarker<MAP>& inactive,
Algo::Surface::Decimation::SelectorType s,
Algo::Surface::Decimation::ApproximatorType a,
VertexAttribute<VEC3, MAP>& pos
) :
m_map(map),
position(pos),
position(pos),
inactiveMarker(inactive)
{
CGoGNout << " creating approximator and predictor.." << CGoGNflush ;
......@@ -87,22 +87,22 @@ ProgressiveMesh<PFP>::ProgressiveMesh(
switch(s)
{
case Algo::Surface::Decimation::S_MapOrder : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_MapOrder<PFP>(m_map, positionsTable, m_approximators) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_MapOrder<PFP>(m_map, position, m_approximators) ;
break ; }
case Algo::Surface::Decimation::S_Random : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_Random<PFP>(m_map, positionsTable, m_approximators) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_Random<PFP>(m_map, position, m_approximators) ;
break ; }
case Algo::Surface::Decimation::S_EdgeLength : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_Length<PFP>(m_map, positionsTable, m_approximators) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_Length<PFP>(m_map, position, m_approximators) ;
break ; }
case Algo::Surface::Decimation::S_QEM : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_QEM<PFP>(m_map, positionsTable, m_approximators) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_QEM<PFP>(m_map, position, m_approximators) ;
break ; }
case Algo::Surface::Decimation::S_MinDetail : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_MinDetail<PFP>(m_map, positionsTable, m_approximators) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_MinDetail<PFP>(m_map, position, m_approximators) ;
break ; }
case Algo::Surface::Decimation::S_Curvature : {
m_selector = new Algo::Surface::Decimation::EdgeSelector_Curvature<PFP>(m_map, positionsTable, m_approximators) ;
m_selector = new Algo::Surface::Decimation::EdgeSelector_Curvature<PFP>(m_map, position, m_approximators) ;
break ; }
}
CGoGNout << "..done" << CGoGNendl ;
......@@ -137,11 +137,11 @@ ProgressiveMesh<PFP>::ProgressiveMesh(
template <typename PFP>
ProgressiveMesh<PFP>::ProgressiveMesh(
MAP& map, DartMarker& inactive,
MAP& map, DartMarker<MAP>& inactive,
Algo::Surface::Decimation::Selector<PFP>* selector, std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*>& approximators,
VertexAttribute<typename PFP::VEC3>& position
VertexAttribute<VEC3,MAP>& position
) :
m_map(map), m_selector(selector), m_approximators(approximators), positionsTable(position), inactiveMarker(inactive)
m_map(map), position(position), inactiveMarker(inactive), m_selector(selector), m_approximators(approximators)
{
CGoGNout << " initializing approximators.." << CGoGNflush ;
for(typename std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it)
......@@ -187,7 +187,7 @@ ProgressiveMesh<PFP>::~ProgressiveMesh()
template <typename PFP>
void ProgressiveMesh<PFP>::createPM(unsigned int percentWantedVertices)
{
unsigned int nbVertices = m_map.template getNbOrbits<VERTEX>() ;
unsigned int nbVertices = Algo::Topo::getNbOrbits<VERTEX>(m_map) ;
unsigned int nbWantedVertices = nbVertices * percentWantedVertices / 100 ;
CGoGNout << " creating PM (" << nbVertices << " vertices).." << /* flush */ CGoGNendl ;
......@@ -281,7 +281,7 @@ void ProgressiveMesh<PFP>::coarsen()
edgeCollapse(vs) ; // collapse edge
Algo::Topo::setOrbitEmbedding<VERTEX>(m_map, d2,s->getApproxV()) ;
Algo::Topo::setOrbitEmbedding<VERTEX>(m_map, d2, vs->getApproxV()) ;
Algo::Topo::setOrbitEmbedding<EDGE>(m_map, d2, vs->getApproxE1()) ;
Algo::Topo::setOrbitEmbedding<EDGE>(m_map, dd2, vs->getApproxE2()) ;
......@@ -544,7 +544,7 @@ float ProgressiveMesh<PFP>::computeDistance2()
float distance = 0; // sum of 2-distance between original vertices and new vertices
gotoLevel(0) ; // mesh reconstruction from detail vectors
DartMarker mUpdate(m_map) ;
DartMarker<MAP> mUpdate(m_map) ;
for(Dart d = m_map.begin(); d != m_map.end(); m_map.next(d)) // vertices loop
{
if(!mUpdate.isMarked(d))
......
......@@ -71,7 +71,7 @@ public:
*/
template<typename PFP, unsigned int ORBIT>
void updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3>& positions, const AttributeHandler<typename PFP::VEC3,ORBIT>& colorPerXXX) ;
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& positions, const AttributeHandler<typename PFP::VEC3,ORBIT,typename PFP::MAP::IMPL>& colorPerXXX) ;
/**
* update drawing buffers
......@@ -85,7 +85,7 @@ public:
*/
template<typename PFP, unsigned int ORBIT>
void updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3>& positions, const VertexAttribute<typename PFP::VEC3>& normals, const AttributeHandler<typename PFP::VEC3,ORBIT>& colorPerXXX) ;
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& positions, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& normals, const AttributeHandler<typename PFP::VEC3,ORBIT,typename PFP::MAP::IMPL>& colorPerXXX) ;
/**
......
......@@ -51,7 +51,7 @@ m_nbTris(0)
template<typename PFP, unsigned int ORBIT>
void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor, typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3>& positions, const AttributeHandler<typename PFP::VEC3,ORBIT>& colorPerXXX)
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& positions, const AttributeHandler<typename PFP::VEC3,ORBIT, typename PFP::MAP::IMPL>& colorPerXXX)
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
......@@ -101,8 +101,8 @@ void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboColor
template<typename PFP, unsigned int ORBIT>
void ColorPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboNormal, Utils::VBO& vboColor, typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3>& positions, const VertexAttribute<typename PFP::VEC3>& normals,
const AttributeHandler<typename PFP::VEC3,ORBIT>& colorPerXXX)
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& positions, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP::IMPL>& normals,
const AttributeHandler<typename PFP::VEC3,ORBIT, typename PFP::MAP::IMPL>& colorPerXXX)
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
......
......@@ -70,7 +70,7 @@ public:
*/
template<typename PFP, unsigned int ORBIT, typename T>
void updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3>& positions, const AttributeHandler<T,ORBIT>& dataPerXXX) ;
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& positions, const AttributeHandler<T,ORBIT, typename PFP::MAP>& dataPerXXX) ;
/**
* draw
......
......@@ -50,7 +50,7 @@ m_nbTris(0)
template<typename PFP, unsigned int ORBIT, typename T>
void
DataPerFaceRender::updateVBO(Utils::VBO& vboPosition, Utils::VBO& vboData, typename PFP::MAP& map,
const VertexAttribute<typename PFP::VEC3>& positions, const AttributeHandler<T,ORBIT>& dataPerXXX)
const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& positions, const AttributeHandler<T,ORBIT, typename PFP::MAP>& dataPerXXX)
{
typedef typename PFP::VEC3 VEC3;
typedef typename PFP::REAL REAL;
......
......@@ -28,6 +28,8 @@
#include "Container/fakeAttribute.h"
#include "Geometry/basic.h"
#include "Topology/generic/traversor/traversor2.h"
/*****************************************
* Class hierarchy :
* Collector (virtual)
......
......@@ -119,7 +119,7 @@ void Collector_OneRing<PFP>::collectAll(Dart d)
this->insideVertices.push_back(d);
foreach_incident2<EDGE>(this->map, Vertex(d), [&] (Edge e)
foreach_incident2<EDGE>(this->map, Vertex(d), [&] (Edge e)
{
this->insideEdges.push_back(e);
this->insideFaces.push_back(e.dart);
......@@ -133,7 +133,7 @@ void Collector_OneRing<PFP>::collectBorder(Dart d)
this->init(d);
this->border.reserve(12);
foreach_incident2<FACE>(this->map, Vertex(d), [&] (Face f)
foreach_incident2<FACE>(this->map, Vertex(d), [&] (Face f)
{
this->border.push_back(this->map.phi1(f.dart));
});
......@@ -146,7 +146,7 @@ typename PFP::REAL Collector_OneRing<PFP>::computeArea(const VertexAttribute<VEC
REAL area = 0;
for (std::vector<Face>::const_iterator it = this->insideFaces.begin(); it != this->insideFaces.end(); ++it)
for (std::vector<Face>::const_iterator it = this->insideFaces.begin(); it != this->insideFaces.end(); ++it)
area += Algo::Surface::Geometry::triangleArea<PFP>(this->map, *it, pos);
return area;
......@@ -169,7 +169,7 @@ void Collector_OneRing<PFP>::computeNormalCyclesTensor (const VertexAttribute<VE
// collect edges on the border
// TODO : should be an option ?
// TODO : not boundary safe
for (std::vector<Dart>::const_iterator it = this->border.begin(); it != this->border.end(); ++it)
for (std::vector<Dart>::const_iterator it = this->border.begin(); it != this->border.end(); ++it)
{
const VEC3 e = Algo::Surface::Geometry::vectorOutOfDart<PFP>(this->map, *it, pos) ;
tensor += Geom::transposed_vectors_mult(e,e) * edgeangle[*it] * (1 / e.norm()) ;
......@@ -196,7 +196,7 @@ void Collector_OneRing<PFP>::computeNormalCyclesTensor (const VertexAttribute<VE
// collect edges on the border
// TODO : should be an option ?
// TODO : not boundary safe
for (std::vector<Dart>::const_iterator it = this->border.begin(); it != this->border.end(); ++it)
for (std::vector<Dart>::const_iterator it = this->border.begin(); it != this->border.end(); ++it)
{
const VEC3 e = Algo::Surface::Geometry::vectorOutOfDart<PFP>(this->map, *it, pos) ;
const REAL edgeangle = Algo::Surface::Geometry::computeAngleBetweenNormalsOnEdge<PFP>(this->map, *it, pos) ;
......@@ -518,12 +518,12 @@ void Collector_WithinSphere<PFP>::computeNormalCyclesTensor(const VertexAttribut
tensor += Geom::transposed_vectors_mult(e,e) * edgeangle * (1 / e.norm()) ;
}
// collect edges crossing the neighborhood's border
for (std::vector<Dart>::const_iterator it = this->border.begin(); it != this->border.end(); ++it)
for (std::vector<Dart>::iterator it = this->border.begin(); it != this->border.end(); ++it)
{
const VEC3 e = Algo::Surface::Geometry::vectorOutOfDart<PFP>(this->map, *it, pos) ;
REAL alpha ;
Algo::Surface::Geometry::intersectionSphereEdge<PFP>(this->map, centerPosition, radius, *it, pos, alpha) ;
const REAL edgeangle = Algo::Surface::Geometry::computeAngleBetweenNormalsOnEdge<PFP>(this->map, *it, pos) ;
const REAL edgeangle = Algo::Surface::Geometry::computeAngleBetweenNormalsOnEdge<PFP>(this->map, Edge(*it), pos) ;
tensor += Geom::transposed_vectors_mult(e,e) * edgeangle * (1 / e.norm()) * alpha ;
}
......
......@@ -76,9 +76,11 @@ Vector<DIM,T> isobarycenter(const Vector<DIM,T>& v1, const Vector<DIM,T>& v2, co
template <typename VEC>
typename VEC::DATA_TYPE cos_angle(const VEC& a, const VEC& b)
{
typename VEC::DATA_TYPE na2 = a.norm2() ;
typename VEC::DATA_TYPE nb2 = b.norm2() ;
return (a * b) / sqrt(na2 * nb2) ;
typename VEC::DATA_TYPE na2 = a.norm2() ;
typename VEC::DATA_TYPE nb2 = b.norm2() ;
typename VEC::DATA_TYPE res = (a * b) / sqrt(na2 * nb2) ;
return res > 1.0 ? 1.0 : (res < -1.0 ? -1.0 : res) ;
}
// angle formed by 2 vectors
......
......@@ -75,7 +75,7 @@ public:
* constructor that initialize all component to a given value
* @param x the value to assign to all component
*/
Vector(T x) ;
explicit Vector(T x) ;
void set(T a) ;
......
......@@ -49,7 +49,7 @@ public:
Cell(): dart() {}
/// constructor from Dart
inline Cell(Dart d): dart(d) {}
inline Cell(Dart d): dart(d) {}
/// copy constructor
inline Cell(const Cell<ORBIT>& c): dart(c.dart) {}
......
......@@ -206,9 +206,9 @@ template <typename MAP_IMPL>
template <typename T, unsigned int ORBIT, typename MAP>
inline AttributeHandler<T ,ORBIT, MAP> MapCommon<MAP_IMPL>::checkAttribute(const std::string& nameAttr)
{
AttributeHandler<T, ORBIT, MAP> att = this->getAttribute<T,ORBIT>(nameAttr);
AttributeHandler<T, ORBIT, MAP> att = this->getAttribute<T,ORBIT,MAP>(nameAttr);
if (!att.isValid())
att = this->addAttribute<T, ORBIT>(nameAttr);
att = this->addAttribute<T, ORBIT, MAP>(nameAttr);
return att;
}
......
// ShaderFlat::fragmentShaderText
VARYING_FRAG vec4 ColorFS;
FRAG_OUT_DEF;
void main()
{
gl_FragColor = ColorFS;
......
......@@ -19,9 +19,11 @@ void main(void)
vec4 newPos = ModelViewMatrix * vec4(center,0.0);
vec3 L = normalize (lightPosition - newPos.xyz);
float lambertTerm = dot(N,L);
ColorFS = ambient;
if(lambertTerm > 0.0)
ColorFS += diffuse * lambertTerm;
ColorFS = ambient;