Commit be80cebc authored by Thomas's avatar Thomas

Merge branch 'master' of cgogn:~kraemer/CGoGN

parents 6d915276 dcb3252d
...@@ -17,7 +17,6 @@ include_directories( ...@@ -17,7 +17,6 @@ include_directories(
${CGoGN_ROOT_DIR}/ThirdParty/OpenCTM ${CGoGN_ROOT_DIR}/ThirdParty/OpenCTM
${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include ${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include
${CGoGN_ROOT_DIR}/ThirdParty/glm ${CGoGN_ROOT_DIR}/ThirdParty/glm
) )
# define libs path # define libs path
......
...@@ -43,7 +43,8 @@ ...@@ -43,7 +43,8 @@
#include "Algo/Geometry/laplacian.h" #include "Algo/Geometry/laplacian.h"
#include "Algo/Modelisation/subdivision.h" #include "Algo/Modelisation/subdivision.h"
#include "Algo/Decimation/decimation.h" #include "Algo/Decimation/decimation.h"
#include "Algo/Filters2D/filters2D.h" #include "Algo/Remeshing/pliant.h"
#include "Algo/Geometry/feature.h"
using namespace CGoGN ; using namespace CGoGN ;
...@@ -349,7 +350,7 @@ void MyGlutWin::myRedraw() ...@@ -349,7 +350,7 @@ void MyGlutWin::myRedraw()
glPushMatrix() ; glPushMatrix() ;
float sc = 50. / gWidthObj ; float sc = 50.0f / gWidthObj ;
glScalef(sc, sc, sc) ; glScalef(sc, sc, sc) ;
glTranslatef(-gPosObj[0], -gPosObj[1], -gPosObj[2]) ; glTranslatef(-gPosObj[0], -gPosObj[1], -gPosObj[2]) ;
...@@ -432,61 +433,102 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -432,61 +433,102 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
{ {
case 'l': case 'l':
{ {
GLint t1 = glutGet(GLUT_ELAPSED_TIME); GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;
Algo::Modelisation::LoopSubdivision<PFP>(myMap, position);
GLint t2 = glutGet(GLUT_ELAPSED_TIME); Algo::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "loop: "<< seconds << "sec" << std::endl; GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
GLfloat seconds = (t2 - t1) / 1000.0f ;
std::cout << "loop: "<< seconds << "sec" << std::endl ;
t1 = glutGet(GLUT_ELAPSED_TIME) ;
t1 = glutGet(GLUT_ELAPSED_TIME);
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ; updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ; updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ; topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
t2 = glutGet(GLUT_ELAPSED_TIME);
seconds = (t2 - t1) / 1000.0f;
std::cout << "display update: "<< seconds << "sec" << std::endl;
glutPostRedisplay() ; t2 = glutGet(GLUT_ELAPSED_TIME) ;
seconds = (t2 - t1) / 1000.0f ;
std::cout << "display update: "<< seconds << "sec" << std::endl ;
glutPostRedisplay() ;
break ; break ;
} }
case 'c': case 'c':
{ {
GLint t1 = glutGet(GLUT_ELAPSED_TIME); GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;
Algo::Modelisation::CatmullClarkSubdivision<PFP>(myMap, position);
GLint t2 = glutGet(GLUT_ELAPSED_TIME); Algo::Modelisation::CatmullClarkSubdivision<PFP>(myMap, position) ;
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "catmull-clark: "<< seconds << "sec" << std::endl; GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
GLfloat seconds = (t2 - t1) / 1000.0f ;
std::cout << "catmull-clark: "<< seconds << "sec" << std::endl ;
t1 = glutGet(GLUT_ELAPSED_TIME) ;
t1 = glutGet(GLUT_ELAPSED_TIME);
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ; updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ; updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ; topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
t2 = glutGet(GLUT_ELAPSED_TIME);
seconds = (t2 - t1) / 1000.0f; t2 = glutGet(GLUT_ELAPSED_TIME) ;
std::cout << "display update: "<< seconds << "sec" << std::endl; seconds = (t2 - t1) / 1000.0f ;
std::cout << "display update: "<< seconds << "sec" << std::endl ;
glutPostRedisplay() ; glutPostRedisplay() ;
break ;
}
case '3':
{
GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;
Algo::Modelisation::Sqrt3Subdivision<PFP>(myMap, position) ;
GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
GLfloat seconds = (t2 - t1) / 1000.0f ;
std::cout << "sqrt3: "<< seconds << "sec" << std::endl ;
normal = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal") ;
if(!normal.isValid())
normal = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal") ;
laplacian = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, "laplacian") ;
if(!laplacian.isValid())
laplacian = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "laplacian") ;
t1 = glutGet(GLUT_ELAPSED_TIME) ;
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
t2 = glutGet(GLUT_ELAPSED_TIME) ;
seconds = (t2 - t1) / 1000.0f ;
std::cout << "display update: "<< seconds << "sec" << std::endl ;
glutPostRedisplay() ;
break ; break ;
} }
case 't': case 't':
{ {
GLint t1 = glutGet(GLUT_ELAPSED_TIME); GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;
Algo::Modelisation::trianguleFaces<PFP>(myMap, position) ; Algo::Modelisation::trianguleFaces<PFP>(myMap, position) ;
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "triangulation: "<< seconds << "sec" << std::endl;
t1 = glutGet(GLUT_ELAPSED_TIME); GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
GLfloat seconds = (t2 - t1) / 1000.0f ;
std::cout << "triangulation: "<< seconds << "sec" << std::endl ;
t1 = glutGet(GLUT_ELAPSED_TIME) ;
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ; updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ; updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ; topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
t2 = glutGet(GLUT_ELAPSED_TIME);
seconds = (t2 - t1) / 1000.0f; t2 = glutGet(GLUT_ELAPSED_TIME) ;
std::cout << "display update: "<< seconds << "sec" << std::endl; seconds = (t2 - t1) / 1000.0f ;
std::cout << "display update: "<< seconds << "sec" << std::endl ;
glutPostRedisplay() ; glutPostRedisplay() ;
break ; break ;
...@@ -494,19 +536,23 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -494,19 +536,23 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
case 'q': case 'q':
{ {
GLint t1 = glutGet(GLUT_ELAPSED_TIME); GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;
Algo::Modelisation::quadranguleFaces<PFP>(myMap, position) ; Algo::Modelisation::quadranguleFaces<PFP>(myMap, position) ;
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "quadrangulation: "<< seconds << "sec" << std::endl;
t1 = glutGet(GLUT_ELAPSED_TIME); GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
GLfloat seconds = (t2 - t1) / 1000.0f ;
std::cout << "quadrangulation: "<< seconds << "sec" << std::endl ;
t1 = glutGet(GLUT_ELAPSED_TIME) ;
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ; updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ; updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ; topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
t2 = glutGet(GLUT_ELAPSED_TIME);
seconds = (t2 - t1) / 1000.0f; t2 = glutGet(GLUT_ELAPSED_TIME) ;
std::cout << "display update: "<< seconds << "sec" << std::endl; seconds = (t2 - t1) / 1000.0f ;
std::cout << "display update: "<< seconds << "sec" << std::endl ;
glutPostRedisplay() ; glutPostRedisplay() ;
break ; break ;
...@@ -516,19 +562,23 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -516,19 +562,23 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
{ {
unsigned int nbVertices = myMap.getNbOrbits(VERTEX_ORBIT) ; unsigned int nbVertices = myMap.getNbOrbits(VERTEX_ORBIT) ;
GLint t1 = glutGet(GLUT_ELAPSED_TIME); GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;
Algo::Decimation::decimate<PFP>(myMap, Algo::Decimation::S_QEM, Algo::Decimation::A_QEM, position, nbVertices * 0.75) ; Algo::Decimation::decimate<PFP>(myMap, Algo::Decimation::S_QEM, Algo::Decimation::A_QEM, position, nbVertices * 0.75) ;
GLint t2 = glutGet(GLUT_ELAPSED_TIME);
GLfloat seconds = (t2 - t1) / 1000.0f;
std::cout << "decimation: "<< seconds << "sec" << std::endl;
t1 = glutGet(GLUT_ELAPSED_TIME); GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
GLfloat seconds = (t2 - t1) / 1000.0f ;
std::cout << "decimation: "<< seconds << "sec" << std::endl ;
t1 = glutGet(GLUT_ELAPSED_TIME) ;
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ; updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ; updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ; topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
t2 = glutGet(GLUT_ELAPSED_TIME);
seconds = (t2 - t1) / 1000.0f; t2 = glutGet(GLUT_ELAPSED_TIME) ;
std::cout << "display update: "<< seconds << "sec" << std::endl; seconds = (t2 - t1) / 1000.0f ;
std::cout << "display update: "<< seconds << "sec" << std::endl ;
glutPostRedisplay() ; glutPostRedisplay() ;
break ; break ;
...@@ -536,40 +586,68 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -536,40 +586,68 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
case 'd': case 'd':
{ {
myMap.removeAttribute<PFP::VEC3>(normal) ; AttributeHandler<PFP::VEC3> positionF = myMap.getAttribute<PFP::VEC3>(FACE_ORBIT, "position") ;
myMap.removeAttribute<PFP::VEC3>(laplacian) ; if(!positionF.isValid())
positionF = myMap.addAttribute<PFP::VEC3>(FACE_ORBIT, "position") ;
AttributeHandler<PFP::VEC3> newPosition = myMap.addAttribute<PFP::VEC3>(FACE_ORBIT, "position") ; Algo::Geometry::computeCentroidFaces<PFP>(myMap, position, positionF) ;
Algo::Geometry::computeCentroidFaces<PFP>(myMap, position, newPosition) ;
GLint t1 = glutGet(GLUT_ELAPSED_TIME); GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;
Algo::Modelisation::computeDual<PFP>(myMap) ; Algo::Modelisation::computeDual<PFP>(myMap) ;
GLint t2 = glutGet(GLUT_ELAPSED_TIME); GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
GLfloat seconds = (t2 - t1) / 1000.0f; GLfloat seconds = (t2 - t1) / 1000.0f ;
std::cout << "dual computation: "<< seconds << "sec" << std::endl; std::cout << "dual computation: "<< seconds << "sec" << std::endl ;
newPosition = myMap.getAttribute<PFP::VEC3>(FACE_ORBIT, "position") ; position = positionF ;
myMap.removeAttribute<PFP::VEC3>(newPosition) ;
position = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, "position") ; normal = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal") ;
normal = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal") ; if(!normal.isValid())
laplacian = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "laplacian") ; normal = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "normal") ;
laplacian = myMap.getAttribute<PFP::VEC3>(VERTEX_ORBIT, "laplacian") ;
if(!laplacian.isValid())
laplacian = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "laplacian") ;
t1 = glutGet(GLUT_ELAPSED_TIME) ;
t1 = glutGet(GLUT_ELAPSED_TIME);
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ; updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ; updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ; topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
t2 = glutGet(GLUT_ELAPSED_TIME);
seconds = (t2 - t1) / 1000.0f; t2 = glutGet(GLUT_ELAPSED_TIME) ;
std::cout << "display update: "<< seconds << "sec" << std::endl; seconds = (t2 - t1) / 1000.0f ;
std::cout << "display update: "<< seconds << "sec" << std::endl ;
glutPostRedisplay() ; glutPostRedisplay() ;
break ; break ;
} }
case '3': case 'r':
{
GLint t1 = glutGet(GLUT_ELAPSED_TIME) ;
Algo::Remeshing::pliantRemeshing<PFP>(myMap, position, normal) ;
GLint t2 = glutGet(GLUT_ELAPSED_TIME) ;
GLfloat seconds = (t2 - t1) / 1000.0f ;
std::cout << "pliant remeshing: "<< seconds << "sec" << std::endl ;
t1 = glutGet(GLUT_ELAPSED_TIME) ;
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
t2 = glutGet(GLUT_ELAPSED_TIME) ;
seconds = (t2 - t1) / 1000.0f ;
std::cout << "display update: "<< seconds << "sec" << std::endl ;
glutPostRedisplay() ;
break ;
}
case '9':
{ {
CellMarker markVisit(myMap, VERTEX_CELL) ; CellMarker markVisit(myMap, VERTEX_CELL) ;
...@@ -623,6 +701,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y) ...@@ -623,6 +701,7 @@ void MyGlutWin::myKeyboard(unsigned char keycode, int x, int y)
updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ; updateVBOprimitives(Algo::Render::VBO::TRIANGLES | Algo::Render::VBO::LINES | Algo::Render::VBO::POINTS) ;
updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ; updateVBOdata(Algo::Render::VBO::POSITIONS | Algo::Render::VBO::NORMALS) ;
topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ; topo_render->updateData<PFP>(myMap, position, 0.9f, 0.9f) ;
glutPostRedisplay() ; glutPostRedisplay() ;
break ; break ;
} }
......
...@@ -46,11 +46,11 @@ typename PFP::REAL totalArea(typename PFP::MAP& map, const typename PFP::TVEC3& ...@@ -46,11 +46,11 @@ typename PFP::REAL totalArea(typename PFP::MAP& map, const typename PFP::TVEC3&
template <typename PFP> template <typename PFP>
void computeAreaFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& face_area, const FunctorSelect& select = SelectorTrue()) ; void computeAreaFaces(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& face_area, const FunctorSelect& select = SelectorTrue()) ;
} } // namespace Geometry
} } // namespace Algo
} } // namespace CGoGN
#include "Algo/Geometry/area.hpp" #include "Algo/Geometry/area.hpp"
......
...@@ -40,7 +40,7 @@ namespace Geometry ...@@ -40,7 +40,7 @@ namespace Geometry
* vectorOutOfDart return a dart from the position of vertex attribute of d to the position of vertex attribute of phi1(d) * vectorOutOfDart return a dart from the position of vertex attribute of d to the position of vertex attribute of phi1(d)
*/ */
template <typename PFP> template <typename PFP>
typename PFP::VEC3 vectorOutOfDart(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) inline typename PFP::VEC3 vectorOutOfDart(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
{ {
typename PFP::VEC3 vec = position[map.phi1(d)] ; typename PFP::VEC3 vec = position[map.phi1(d)] ;
vec -= position[d] ; vec -= position[d] ;
...@@ -48,11 +48,17 @@ typename PFP::VEC3 vectorOutOfDart(typename PFP::MAP& map, Dart d, const typenam ...@@ -48,11 +48,17 @@ typename PFP::VEC3 vectorOutOfDart(typename PFP::MAP& map, Dart d, const typenam
} }
template <typename PFP> template <typename PFP>
float angle(typename PFP::MAP& map, Dart d1, Dart d2, const typename PFP::TVEC3& position) inline typename PFP::REAL edgeLength(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
{ {
typename PFP::VEC3 v1, v2 ; typename PFP::VEC3 v = vectorOutOfDart<PFP>(map, d, position) ;
vectorOutOfDart<PFP>(map, d1, position, v1) ; return v.norm() ;
vectorOutOfDart<PFP>(map, d2, position, v2) ; }
template <typename PFP>
inline float angle(typename PFP::MAP& map, Dart d1, Dart d2, const typename PFP::TVEC3& position)
{
typename PFP::VEC3 v1 = vectorOutOfDart<PFP>(map, d1, position) ;
typename PFP::VEC3 v2 = vectorOutOfDart<PFP>(map, d2, position) ;
return Geom::angle(v1, v2) ; return Geom::angle(v1, v2) ;
} }
......
...@@ -119,9 +119,9 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at ...@@ -119,9 +119,9 @@ EMB vertexNeighborhoodCentroidGen(typename PFP::MAP& map, Dart d, const EMBV& at
Dart it = d ; Dart it = d ;
do do
{ {
center += attributs[map.phi2(it)]; center += attributs[map.phi1(it)];
++count ; ++count ;
it = map.phi1(map.phi2(it)) ; it = map.alpha1(it) ;
} while(it != d) ; } while(it != d) ;
center /= count ; center /= count ;
return center ; return center ;
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef __ALGO_GEOMETRY_FEATURE_H__
#define __ALGO_GEOMETRY_FEATURE_H__
namespace CGoGN
{
namespace Algo
{
namespace Geometry
{
template <typename PFP>
void featureEdgeDetection(typename PFP::MAP& map, const typename PFP::TVEC3& position, DartMarker& feature) ;
} // namespace Geometry
} // namespace Algo
} // namespace CGoGN
#include "Algo/Geometry/feature.hpp"
#endif
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Geometry/basic.h"
#include "Algo/Geometry/normal.h"
namespace CGoGN
{
namespace Algo
{
namespace Geometry
{
template <typename PFP>
void featureEdgeDetection(typename PFP::MAP& map, typename PFP::TVEC3& position, DartMarker& feature)
{
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
feature.unmarkAll() ;
AttributeHandler<VEC3> fNormal = map.template addAttribute<VEC3>(FACE_ORBIT, "fNormal") ;
Algo::Geometry::computeNormalFaces<PFP>(map, position, fNormal) ;
DartMarker m(map) ;
for(Dart d = map.begin(); d != map.end(); map.next(d))
{
if(!m.isMarked(d))
{
m.markOrbit(EDGE_ORBIT, d) ;
if(Geom::angle(fNormal[d], fNormal[map.phi2(d)]) > M_PI / REAL(6))
feature.markOrbit(EDGE_ORBIT, d) ;
}
}
map.template removeAttribute<VEC3>(fNormal) ;
}
} // namespace Geometry
} // namespace Algo
} // namespace CGoGN