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) ...@@ -142,7 +142,7 @@ IF (WITH_QT)
ADD_DEFINITIONS(${QT_DEFINITIONS}) ADD_DEFINITIONS(${QT_DEFINITIONS})
find_package(QGLViewer REQUIRED) find_package(QGLViewer REQUIRED)
SET (CGoGN_EXT_INCLUDES ${CGoGN_EXT_INCLUDES} ${QT_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR} ) 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) ENDIF (WITH_QT)
IF (WITH_GLEWMX) IF (WITH_GLEWMX)
......
...@@ -195,7 +195,7 @@ int decimate( ...@@ -195,7 +195,7 @@ int decimate(
return -1 ; // init failed return -1 ; // init failed
} }
unsigned int nbVertices = Algo::Topo::getNbOrbits<VERTEX>(map) ; unsigned int nbVertices = Algo::Topo::getNbOrbits<VERTEX>(map) ;
bool finished = false ; bool finished = false ;
while(!finished) while(!finished)
......
...@@ -230,8 +230,8 @@ public: ...@@ -230,8 +230,8 @@ public:
m_approxindex_normal(-1), m_approxindex_normal(-1),
m_attrindex_normal(-1) m_attrindex_normal(-1)
{ {
halfEdgeInfo = m.template addAttribute<HalfEdgeInfo, DART>("halfEdgeInfo") ; halfEdgeInfo = m.template addAttribute<HalfEdgeInfo, DART, MAP>("halfEdgeInfo") ;
m_quadric = m.template addAttribute<Utils::QuadricNd<REAL,9>, VERTEX>("hQEMextNormal-quadric") ; m_quadric = m.template addAttribute<Utils::QuadricNd<REAL,9>, VERTEX, MAP>("hQEMextNormal-quadric") ;
} }
~HalfEdgeSelector_QEMextColorNormal() ~HalfEdgeSelector_QEMextColorNormal()
{ {
......
...@@ -619,7 +619,7 @@ bool HalfEdgeSelector_QEMextColorNormal<PFP>::init() ...@@ -619,7 +619,7 @@ bool HalfEdgeSelector_QEMextColorNormal<PFP>::init()
++ok ; ++ok ;
m_approxindex_color = approxindex ; m_approxindex_color = approxindex ;
m_attrindex_color = attrindex ; 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") ; assert(m_color.isValid() || !"EdgeSelector_QEMextColor: color attribute is not valid") ;
if (!saved) if (!saved)
{ {
...@@ -632,7 +632,7 @@ bool HalfEdgeSelector_QEMextColorNormal<PFP>::init() ...@@ -632,7 +632,7 @@ bool HalfEdgeSelector_QEMextColorNormal<PFP>::init()
++ok ; ++ok ;
m_approxindex_normal = approxindex ; m_approxindex_normal = approxindex ;
m_attrindex_normal = attrindex ; 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") ; assert(m_normal.isValid() || !"EdgeSelector_QEMextColorNormal: normal attribute is not valid") ;
if (!saved) if (!saved)
{ {
......
...@@ -46,7 +46,6 @@ template <typename PFP> ...@@ -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) 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::MAP MAP;
typedef typename PFP::VEC3 VEC3;
// open file // open file
std::ofstream out ; std::ofstream out ;
...@@ -989,7 +988,6 @@ template <typename PFP> ...@@ -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) 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::MAP MAP;
typedef typename PFP::VEC3 VEC3;
std::ofstream out(filename, std::ios::out) ; std::ofstream out(filename, std::ios::out) ;
if (!out.good()) if (!out.good())
......
...@@ -59,13 +59,24 @@ void sigmaBilateral(typename PFP::MAP& map, const VertexAttribute<typename PFP:: ...@@ -59,13 +59,24 @@ void sigmaBilateral(typename PFP::MAP& map, const VertexAttribute<typename PFP::
sigmaS = 2.5f * ( sumAngles / float(nbEdges) ) ; 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> 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 ; typedef typename PFP::VEC3 VEC3 ;
float sigmaC, sigmaS ; float sigmaC, sigmaS ;
sigmaBilateral<PFP>(map, position, normal, sigmaC, sigmaS) ; sigmaBilateral<PFP>(map, positionIn, normal, sigmaC, sigmaS) ;
TraversorV<typename PFP::MAP> t(map) ; TraversorV<typename PFP::MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next()) 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: ...@@ -80,7 +91,7 @@ void filterBilateral(typename PFP::MAP& map, const VertexAttribute<typename PFP:
Traversor2VE<typename PFP::MAP> te(map, d) ; Traversor2VE<typename PFP::MAP> te(map, d) ;
for(Dart it = te.begin(); it != te.end(); it = te.next()) 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 h = normal_d * vec ;
float t = vec.norm() ; float t = vec.norm() ;
float wcs = exp( ( -1.0f * (t * t) / (2.0f * sigmaC * sigmaC) ) + ( -1.0f * (h * h) / (2.0f * sigmaS * sigmaS) ) ) ; 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: ...@@ -88,10 +99,10 @@ void filterBilateral(typename PFP::MAP& map, const VertexAttribute<typename PFP:
normalizer += wcs ; normalizer += wcs ;
} }
position2[d] = position[d] + ((sum / normalizer) * normal_d) ; positionOut[d] = positionIn[d] + ((sum / normalizer) * normal_d) ;
} }
else else
position2[d] = position[d] ; positionOut[d] = positionIn[d] ;
} }
} }
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include "Topology/generic/traversor/traversorCell.h" #include "Topology/generic/traversor/traversorCell.h"
#include "Topology/generic/traversor/traversor2.h" #include "Topology/generic/traversor/traversor2.h"
#include "Algo/Parallel/parallel_foreach.h"
#include <cmath> #include <cmath>
namespace CGoGN namespace CGoGN
...@@ -45,8 +47,6 @@ namespace Geometry ...@@ -45,8 +47,6 @@ namespace Geometry
template<typename PFP, typename V_ATT> template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE triangleNormal(typename PFP::MAP& map, Face f, const V_ATT& position) 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( typename V_ATT::DATA_TYPE N = Geom::triangleNormal(
position[f.dart], position[f.dart],
position[map.phi1(f)], position[map.phi1(f)],
...@@ -59,8 +59,6 @@ typename V_ATT::DATA_TYPE triangleNormal(typename PFP::MAP& map, Face f, const V ...@@ -59,8 +59,6 @@ typename V_ATT::DATA_TYPE triangleNormal(typename PFP::MAP& map, Face f, const V
template<typename PFP, typename V_ATT> template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE newellNormal(typename PFP::MAP& map, Face f, const V_ATT& position) 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; typedef typename V_ATT::DATA_TYPE VEC3;
VEC3 N(0); VEC3 N(0);
...@@ -80,8 +78,6 @@ typename V_ATT::DATA_TYPE newellNormal(typename PFP::MAP& map, Face f, const V_A ...@@ -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> template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE faceNormal(typename PFP::MAP& map, Face f, const V_ATT& position) 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) if(map.faceDegree(f) == 3)
return triangleNormal<PFP>(map, f, position) ; return triangleNormal<PFP>(map, f, position) ;
else else
...@@ -91,8 +87,6 @@ typename V_ATT::DATA_TYPE faceNormal(typename PFP::MAP& map, Face f, const V_ATT ...@@ -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> template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V_ATT& position) 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 ; typedef typename V_ATT::DATA_TYPE VEC3 ;
VEC3 N(0) ; VEC3 N(0) ;
...@@ -104,12 +98,8 @@ typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V ...@@ -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 v1 = vectorOutOfDart<PFP>(map, f.dart, position) ;
VEC3 v2 = vectorOutOfDart<PFP>(map, map.phi_1(f), position) ; VEC3 v2 = vectorOutOfDart<PFP>(map, map.phi_1(f), position) ;
typename VEC3::DATA_TYPE l = (v1.norm2() * v2.norm2()); n *= convexFaceArea<PFP>(map, f, position) / (v1.norm2() * v2.norm2()) ;
if (l > (typename VEC3::DATA_TYPE(0.0)) ) N += n ;
{
n *= convexFaceArea<PFP>(map, f, position) / l ;
N += n ;
}
} }
}); });
...@@ -120,7 +110,6 @@ typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V ...@@ -120,7 +110,6 @@ typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V
template<typename PFP, typename V_ATT> template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexBorderNormal(typename PFP::MAP& map, Vertex v, const V_ATT& position) 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); assert(map.dimension() == 3);
typedef typename V_ATT::DATA_TYPE VEC3 ; typedef typename V_ATT::DATA_TYPE VEC3 ;
...@@ -156,43 +145,39 @@ typename V_ATT::DATA_TYPE vertexBorderNormal(typename PFP::MAP& map, Vertex v, c ...@@ -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> 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) void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_normal, unsigned int thread)
{ {
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX); if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
CHECK_ATTRIBUTEHANDLER_ORBIT(F_ATT, FACE);
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; return;
} }
foreach_cell<FACE>(map, [&] (Face f) foreach_cell<FACE>(map, [&] (Face f)
{ {
face_normal[f] = faceNormal<PFP>(map, f, position) ; face_normal[f] = faceNormal<PFP>(map, f, position) ;
}, AUTO, thread); },
AUTO, thread);
} }
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal, unsigned int thread) 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; return;
} }
foreach_cell<VERTEX>(map, [&] (Vertex v) foreach_cell<VERTEX>(map, [&] (Vertex v)
{ {
normal[v] = vertexNormal<PFP>(map, v, position) ; normal[v] = vertexNormal<PFP>(map, v, position) ;
}, FORCE_CELL_MARKING, thread); },
FORCE_CELL_MARKING, thread);
} }
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Edge e, const V_ATT& position) 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 ; typedef typename V_ATT::DATA_TYPE VEC3 ;
if(map.isBoundaryEdge(e)) if(map.isBoundaryEdge(e))
...@@ -226,58 +211,50 @@ typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Edge ...@@ -226,58 +211,50 @@ typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Edge
template <typename PFP, typename V_ATT, typename E_ATT> 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) void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& position, E_ATT& angles, unsigned int thread)
{ {
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX); if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
CHECK_ATTRIBUTEHANDLER_ORBIT(E_ATT, EDGE);
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; return;
} }
foreach_cell<EDGE>(map, [&] (Edge e) foreach_cell<EDGE>(map, [&] (Edge e)
{ {
angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ; angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ;
}, AUTO, thread); },
AUTO, thread);
} }
namespace Parallel namespace Parallel
{ {
template <typename PFP, typename V_ATT> template <typename PFP, typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal) 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) ; normal[v] = vertexNormal<PFP>(map, v, position) ;
}, FORCE_CELL_MARKING); },true,FORCE_CELL_MARKING);
} }
template <typename PFP, typename V_ATT, typename F_ATT> template <typename PFP, typename V_ATT, typename F_ATT>
void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& normal) void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& normal)
{ {
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX); CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
CHECK_ATTRIBUTEHANDLER_ORBIT(F_ATT, FACE);
CGoGN::Parallel::foreach_cell<FACE>(map, [&] (Face f, unsigned int /*thr*/)
{ {
normal[f] = faceNormal<PFP>(map, f, position) ; normal[f] = faceNormal<PFP>(map, f, position) ;
}); },true,AUTO);
} }
template <typename PFP, typename V_ATT, typename E_ATT> template <typename PFP, typename V_ATT, typename E_ATT>
void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& position, E_ATT& angles) void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& position, E_ATT& angles)
{ {
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX); CGoGN::Parallel::foreach_cell<EDGE>(map,[&](Edge e, unsigned int thr)
CHECK_ATTRIBUTEHANDLER_ORBIT(E_ATT, EDGE);
CGoGN::Parallel::foreach_cell<EDGE>(map,[&](Edge e, unsigned int /*thr*/)
{ {
angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ; angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ;
}); },true,AUTO);
} }
} // namespace Parallel } // namespace Parallel
......
...@@ -73,18 +73,6 @@ bool MeshTablesSurface<PFP>::importMesh(const std::string& filename, std::vector ...@@ -73,18 +73,6 @@ bool MeshTablesSurface<PFP>::importMesh(const std::string& filename, std::vector
CGoGNout << "TYPE: PLY" << CGoGNendl; CGoGNout << "TYPE: PLY" << CGoGNendl;
return importPly(filename, attrNames); return importPly(filename, attrNames);
break; 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: case OBJ:
CGoGNout << "TYPE: OBJ" << CGoGNendl; CGoGNout << "TYPE: OBJ" << CGoGNendl;
return importObj(filename, attrNames); return importObj(filename, attrNames);
...@@ -772,7 +760,7 @@ bool MeshTablesSurface<PFP>::importPlySLFgeneric(const std::string& filename, st ...@@ -772,7 +760,7 @@ bool MeshTablesSurface<PFP>::importPlySLFgeneric(const std::string& filename, st
// Define containers // Define containers
VertexAttribute<VEC3, MAP> positions = m_map.template getAttribute<VEC3, VERTEX, MAP>("position") ; VertexAttribute<VEC3, MAP> positions = m_map.template getAttribute<VEC3, VERTEX, MAP>("position") ;
;
if (!positions.isValid()) if (!positions.isValid())
positions = m_map.template addAttribute<VEC3, VERTEX, MAP>("position") ; positions = m_map.template addAttribute<VEC3, VERTEX, MAP>("position") ;
attrNames.push_back(positions.name()) ; attrNames.push_back(positions.name()) ;
......
...@@ -48,15 +48,6 @@ namespace Import ...@@ -48,15 +48,6 @@ namespace Import
if ((filename.rfind(".meshbin")!=std::string::npos) || (filename.rfind(".MESHBIN")!=std::string::npos)) if ((filename.rfind(".meshbin")!=std::string::npos) || (filename.rfind(".MESHBIN")!=std::string::npos))
return MESHBIN; 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)) if ((filename.rfind(".ply")!=std::string::npos) || (filename.rfind(".PLY")!=std::string::npos))
return PLY; return PLY;
......
...@@ -59,7 +59,7 @@ private: ...@@ -59,7 +59,7 @@ private:
MAP& m_map ; MAP& m_map ;
VertexAttribute<VEC3, MAP>& position ; VertexAttribute<VEC3, MAP>& position ;
DartMarker<MAP>& inactiveMarker ; DartMarker<MAP>& inactiveMarker ;
Algo::Surface::Decimation::Selector<PFP>* m_selector ; Algo::Surface::Decimation::Selector<PFP>* m_selector ;
std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*> m_approximators ; std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*> m_approximators ;
...@@ -81,15 +81,15 @@ private: ...@@ -81,15 +81,15 @@ private:
public: public:
ProgressiveMesh( ProgressiveMesh(
MAP& map, MAP& map,
DartMarker<MAP>& inactive, DartMarker<MAP>& inactive,
Algo::Surface::Decimation::SelectorType s, Algo::Surface::Decimation::SelectorType s,
Algo::Surface::Decimation::ApproximatorType a, Algo::Surface::Decimation::ApproximatorType a,
VertexAttribute<VEC3, MAP>& position VertexAttribute<VEC3, MAP>& position
) ; ) ;
ProgressiveMesh( ProgressiveMesh(
MAP& map, DartMarker& inactive, MAP& map, DartMarker<MAP>& inactive,
Algo::Surface::Decimation::Selector<PFP>* selector, std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*>& approximators, Algo::Surface::Decimation::Selector<PFP>* selector, std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*>& approximators,
VertexAttribute<typename PFP::VEC3>& position) ; VertexAttribute<VEC3, MAP>& position) ;
~ProgressiveMesh() ; ~ProgressiveMesh() ;
bool initOk() { return m_initOk ; } bool initOk() { return m_initOk ; }
......
...@@ -39,13 +39,13 @@ namespace PMesh ...@@ -39,13 +39,13 @@ namespace PMesh
template <typename PFP> template <typename PFP>
ProgressiveMesh<PFP>::ProgressiveMesh( ProgressiveMesh<PFP>::ProgressiveMesh(
MAP& map, MAP& map,
DartMarker<MAP>& inactive, DartMarker<MAP>& inactive,
Algo::Surface::Decimation::SelectorType s, Algo::Surface::Decimation::SelectorType s,
Algo::Surface::Decimation::ApproximatorType a, Algo::Surface::Decimation::ApproximatorType a,
VertexAttribute<VEC3, MAP>& pos VertexAttribute<VEC3, MAP>& pos
) : ) :
m_map(map), m_map(map),
position(pos), position(pos),
inactiveMarker(inactive) inactiveMarker(inactive)
{ {
CGoGNout << " creating approximator and predictor.." << CGoGNflush ; CGoGNout << " creating approximator and predictor.." << CGoGNflush ;
...@@ -87,22 +87,22 @@ ProgressiveMesh<PFP>::ProgressiveMesh( ...@@ -87,22 +87,22 @@ ProgressiveMesh<PFP>::ProgressiveMesh(
switch(s) switch(s)
{ {
case Algo::Surface::Decimation::S_MapOrder : { 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 ; } break ; }
case Algo::Surface::Decimation::S_Random : { 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 ; } break ; }
case Algo::Surface::Decimation::S_EdgeLength : { 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 ; } break ; }
case Algo::Surface::Decimation::S_QEM : { 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 ; } break ; }
case Algo::Surface::Decimation::S_MinDetail : { 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 ; } break ; }
case Algo::Surface::Decimation::S_Curvature : { 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 ; } break ; }
} }
CGoGNout << "..done" << CGoGNendl ; CGoGNout << "..done" << CGoGNendl ;
...@@ -137,11 +137,11 @@ ProgressiveMesh<PFP>::ProgressiveMesh( ...@@ -137,11 +137,11 @@ ProgressiveMesh<PFP>::ProgressiveMesh(
template <typename PFP> template <typename PFP>
ProgressiveMesh<PFP>::ProgressiveMesh( 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, 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 ; CGoGNout << " initializing approximators.." << CGoGNflush ;
for(typename std::vector<Algo::Surface::Decimation::ApproximatorGen<PFP>*>::iterator it = m_approximators.begin(); it != m_approximators.end(); ++it) 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() ...@@ -187,7 +187,7 @@ ProgressiveMesh<PFP>::~ProgressiveMesh()
template <typename PFP> template <typename PFP>
void ProgressiveMesh<PFP>::createPM(unsigned int percentWantedVertices) 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 ; unsigned int nbWantedVertices = nbVertices * percentWantedVertices / 100 ;
CGoGNout << " creating PM (" << nbVertices << " vertices).." << /* flush */ CGoGNendl ; CGoGNout << " creating PM (" << nbVertices << " vertices).." << /* flush */ CGoGNendl ;
...@@ -281,7 +281,7 @@ void ProgressiveMesh<PFP>::coarsen() ...@@ -281,7 +281,7 @@ void ProgressiveMesh<PFP>::coarsen()
edgeCollapse(vs) ; // collapse edge 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, d2, vs->getApproxE1()) ;
Algo::Topo::setOrbitEmbedding<EDGE>(m_map, dd2, vs->getApproxE2()) ; Algo::Topo::setOrbitEmbedding<EDGE>(m_map, dd2, vs->getApproxE2()) ;