Commit aa4420a7 authored by Sylvain Thery's avatar Sylvain Thery

Merge branch 'develop'

parents 825a10ea 3032c9f1
# ignore QtCreator files
CMakeLists.txt.user
bin/
ThirdParty/bin/
SCHNApps/bin
\ No newline at end of file
Sylvain Thery <thery@unistra.fr> Sylvain Thery <sylvain@thery.pipo>
Lionel Untereiner <lionel.untereiner@unistra.fr> untereiner <lionel.untereiner@unistra.fr>
Pierre Kraemer <kraemer@unistra.fr> Pierre Kraemer <kraemer@unistra.fr>
Kenneth Vanhoey <kenneth.vanhoey@unistra.fr> Kenneth Vanhoey <kenneth.vanhoey@unistra.fr>
Sylvain Thery <thery@unistra.fr> Sylvain Thery <thery@unistra.fr>
Pierre Kraemer <kraemer@unistra.fr> Pierre Kraemer <kraemer@modelis.u-strasbg.fr>
Pierre Kraemer <kraemer@unistra.fr> Pierre Kraemer <kraemer@modelis.(none)>
Nicolas Maire <maire.nico@gmail.com> Maire Nicolas <maire.nico@gmail.com>
CGoGN <cgogn@unistra.fr> CGoGN GIT Supervisor <cgogn@igg.u-strasbg.fr>
Thomas Jund <thomas.jund@gmail.com> Thomas <thomas.jund@univ-poitiers.fr>
Sylvain Thery <thery@unistra.fr> Thery Sylvain <sylvain@youpi.fr>
Thomas Jund <thomas.jund@gmail.com> Thomas <jund@ulis.u-strasbg.fr>
Pierre Kraemer <kraemer@unistra.fr> Pierre Kraemer <kraemer@modelis>
Lionel Untereiner <lionel.untereiner@unistra.fr> Lionel Untereiner <lionel.untereiner@unistra.fr>
Kenneth Vanhoey <kenneth.vanhoey@unistra.fr> Kenneth Vanhoey <kenneth@canaris.(none)>
Thomas Jund <thomas.jund@gmail.com> Jund Thomas <tjund@sashimis.u-strasbg.fr>
Basile Sauvage <sauvage@unistra.fr> Basile Sauvage <sauvage@unistra.fr>
Basile Sauvage <sauvage@unistra.fr> Basile Sauvage <sauvage@sushis.u-strasbg.fr>
Thomas Jund <thomas.jund@gmail.com> Thomas Jund <tjund@example.com>
Basile Sauvage <sauvage@unistra.fr> Basile Sauvage <sauvage@factis.u-strasbg.fr>
Thomas Pitiot <thomas@pitiot.eu> pitiot <pitiot@elvis.u-strasbg.fr>
Thomas Jund <thomas.jund@gmail.com> Thomas <tjund@unistra.fr>
David Cazier <david.cazier@unistra.fr> David Cazier <cazier@caroll1.u-strasbg.fr>
Pierre Kraemer <kraemer@unistra.fr> Pierre Kraemer <kraemer@macbook>
CGoGN <cgogn@unistra.fr> CGoGN <cgogn@unistra.fr>
Basile Sauvage <sauvage@unistra.fr> Basile Sauvage <sauvage@oasis.u-strasbg.fr>
David Cazier <david.cazier@unistra.fr> David Cazier <david.cazier@unistra.fr>
Kenneth Vanhoey <kenneth.vanhoey@unistra.fr> Kenneth Vanhoey <kenneth@kvanhoey.eu>
Sylvain Thery <thery@unistra.fr> Sylvain Thery <thery@gris.u-strasbg.fr>
Sylvain Thery <thery@unistra.fr> unknown <thery@MacGenis.(none)>
Pierre Kraemer <kraemer@unistra.fr> julien <julien@julien-VirtualBox.(none)>
Sylvain Thery <thery@unistra.fr> thery <turlututu@pipo.net>
Nicolas AUBRY <nicolas.aubry90@gmail.com> Nicolas AUBRY <nicolas.aubry90@gmail.com>
Pierre Kraemer <kraemer@unistra.fr> Pierre Kraemer <kraemer@pierre-macbook.local>
Sylvain Thery <thery@unistra.fr> Sylvain <thery@unsitra.fr>
Sylvain Thery <thery@unistra.fr> Sylvain Thery <thery@toto.net>
Sylvain Thery <thery@unistra.fr> thery <thery@tournevis.u-strasbg.fr>
Thomas Jund <thomas.jund@gmail.com> thomas <thomas@MDSPC96.(none)>
Sylvain Thery <thery@unistra.fr> unknown <thery@.(none)>
Kenneth Vanhoey <kenneth.vanhoey@unistra.fr> Kenneth Vanhoey <kenneth@layla.(none)>
Sylvain Thery <thery@unistra.fr> Sylvain Thery <thery@MacBook-Pro-de-Sylvain-Thery.local>
Thomas Pitiot <thomas@pitiot.eu> pitiot <pitiot@sushis.u-strasbg.fr>
Sylvain Thery <thery@unistra.fr> sylvain thery <aaa@bbb.fr>
Sylvain Thery <thery@unistra.fr> thery <thery@ingenis.u-strasbg.fr>
Basile Sauvage <sauvage@unistra.fr> Basile Sauvage <sauvage@mimesis.u-strasbg.fr>
Sylvain Thery <thery@unistra.fr> Sylvain Thery <thery@macgenis.u-strasbg.fr>
Sylvain Thery <thery@unistra.fr> Sylvain Thery <thery@wifi-osiris-sec-181-226.u-strasbg.fr>
Sylvain Thery <thery@unistra.fr> Sylvain Thery <thery@wifi-osiris-sec-183-213.u-strasbg.fr>
Sylvain Thery <thery@unistra.fr> Sylvain Thery <toto@pipo.fr>
Sabah Boustila <boustila@unistra.fr> boustila <boustila@lapis.u-strasbg.fr>
Kenneth Vanhoey <kenneth.vanhoey@unistra.fr> kenneth <kenneth@canaris>
Kenneth Vanhoey <kenneth.vanhoey@unistra.fr> kenneth <kenneth@colibris.(none)>
Nicolas Maire <maire.nico@gmail.com> maire <maire@matris.u-strasbg.fr>
Sylvain Thery <thery@unistra.fr> sylvain <sylvain@ubuntu.(none)>
Sylvain Thery <thery@unistra.fr> unknown <sylvain@.(none)>
\ No newline at end of file
cmake_minimum_required(VERSION 2.8)
project(benches)
#SET(CMAKE_BUILD_TYPE Release)
#SET(CMAKE_BUILD_TYPE Debug)
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
# define includes path
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CGoGN_ROOT_DIR}/include
${CGoGN_EXT_INCLUDES}
)
# define libs path
#IF(WIN32)
# link_directories( ${CGoGN_ROOT_DIR}/lib/$(ConfigurationName) ${Boost_LIBRARY_DIRS} )
#ELSE(WIN32)
# link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
#ENDIF(WIN32)
add_executable(bench_trav bench_trav.cpp )
target_link_libraries( bench_trav ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
add_executable(bench_remesh bench_remesh.cpp )
target_link_libraries( bench_remesh ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
add_executable(bench_compact bench_compact.cpp )
target_link_libraries( bench_compact ${CGoGN_LIBS} ${CGoGN_EXT_LIBS} )
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Geometry/vector_gen.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Geometry/normal.h"
#include "Algo/Modelisation/subdivision.h"
#include "Algo/Decimation/decimation.h"
#include "Utils/chrono.h"
#include "Algo/Filtering/average.h"
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap2 MAP ;
};
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3;
int main(int argc, char **argv)
{
if(argc != 2)
return 1;
MAP myMap;
std::vector<std::string> attrNames ;
if(!Algo::Surface::Import::importMesh<PFP>(myMap, argv[1], attrNames))
{
CGoGNerr << "could not import " << argv[1] << CGoGNendl ;
return 2;
}
VertexAttribute<PFP::VEC3, MAP> position = myMap.getAttribute<PFP::VEC3,VERTEX,MAP>( attrNames[0]) ;
FaceAttribute<VEC3, MAP> center = myMap.addAttribute<VEC3, FACE, MAP>("centerFace");
foreach_cell<FACE>(myMap, [&](Face f)
{
center[f] =Algo::Surface::Geometry::faceCentroid<PFP>(myMap,f,position);
});
EdgeAttribute<float, MAP> edge_att = myMap.addAttribute<float, EDGE, MAP>("pipoEdge");
foreach_cell<EDGE>(myMap, [&](Edge e)
{
edge_att[e] = position[e.dart][0];
});
Utils::Chrono chrono;
chrono.start();
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
unsigned int nbVertices = Algo::Topo::getNbOrbits<VERTEX>(myMap) ;
std::cout << "4 passes loop -> "<< std::endl;
std::cout << " NB Faces "<< Algo::Topo::getNbOrbits<FACE>(myMap) << std::endl;
std::cout << " NB Vertices "<< nbVertices << std::endl;
std::vector<VertexAttribute<typename PFP::VEC3, MAP> *> attr;
attr.push_back(&position);
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices * 0.05) ;
VertexAttribute<PFP::VEC3, MAP> normal = myMap.addAttribute<PFP::VEC3,VERTEX,MAP>( "normal") ;
VertexAttribute<PFP::VEC3, MAP> position2 = myMap.addAttribute<PFP::VEC3,VERTEX,MAP>( "pos2") ;
CGoGNout << "creating "<< chrono.elapsed() << " ms"<< CGoGNendl;
std::cout << "decimation 5% -> "<< std::endl;
std::cout << " NB Faces "<< Algo::Topo::getNbOrbits<FACE>(myMap) << std::endl;
std::cout << " NB Vertices "<< Algo::Topo::getNbOrbits<VERTEX>(myMap) << std::endl;
chrono.start();
for (int i=0; i < 100; ++i)
{
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
Algo::Surface::Filtering::filterAverageAttribute_OneRing<PFP,PFP::VEC3>(myMap,position,position2, Algo::Surface::Filtering::INSIDE);
myMap.swapAttributes(position,position2);
}
CGoGNout << "BenchTime process "<< chrono.elapsed() << " ms"<< CGoGNendl;
std::cout << "Topologie fragmentation: "<<myMap.fragmentation(DART)<< std::endl;
std::cout << "Vertex fragmentation: "<<myMap.fragmentation(VERTEX)<< std::endl;
std::cout << "Face fragmentation: "<<myMap.fragmentation(FACE)<< std::endl;
chrono.start();
myMap.compact();
std::cout << std::endl << "compacting in "<< chrono.elapsed() << " ms"<< std::endl << std::endl;
std::cout << "Topologie fragmentation: "<<myMap.fragmentation(DART)<< std::endl;
std::cout << "Vertex fragmentation: "<<myMap.fragmentation(VERTEX)<< std::endl;
std::cout << "Face fragmentation: "<<myMap.fragmentation(FACE)<< std::endl;
chrono.start();
for (int i=0; i < 100; ++i)
{
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
Algo::Surface::Filtering::filterAverageAttribute_OneRing<PFP,PFP::VEC3>(myMap,position,position2, Algo::Surface::Filtering::INSIDE);
myMap.swapAttributes(position,position2);
}
CGoGNout << "BenchTime after compact "<< chrono.elapsed() << " ms"<< CGoGNendl;
Algo::Surface::Export::exportOFF<PFP>(myMap,position,"bench_res.off");
return 0;
}
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Geometry/vector_gen.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Geometry/normal.h"
#include "Algo/Modelisation/subdivision.h"
#include "Algo/Decimation/decimation.h"
#include "Utils/chrono.h"
#include "Algo/Filtering/average.h"
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap2 MAP ;
};
typedef PFP::MAP MAP ;
int main(int argc, char **argv)
{
if(argc != 2)
return 1;
MAP myMap;
std::vector<std::string> attrNames ;
if(!Algo::Surface::Import::importMesh<PFP>(myMap, argv[1], attrNames))
{
CGoGNerr << "could not import " << argv[1] << CGoGNendl ;
return 2;
}
VertexAttribute<PFP::VEC3, MAP> position = myMap.getAttribute<PFP::VEC3,VERTEX,MAP>( attrNames[0]) ;
Utils::Chrono chrono;
chrono.start();
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
unsigned int nbVertices = Algo::Topo::getNbOrbits<VERTEX>(myMap) ;
std::vector<VertexAttribute<typename PFP::VEC3, MAP> *> attr;
attr.push_back(&position);
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices * 0.1) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
nbVertices = Algo::Topo::getNbOrbits<VERTEX>(myMap) ;
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices * 0.1) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
Algo::Surface::Modelisation::LoopSubdivision<PFP>(myMap, position) ;
nbVertices = Algo::Topo::getNbOrbits<VERTEX>(myMap) ;
Algo::Surface::Decimation::decimate<PFP>(myMap, Algo::Surface::Decimation::S_QEM, Algo::Surface::Decimation::A_QEM, attr, nbVertices * 0.1) ;
Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP>(myMap, position) ;
Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP>(myMap, position) ;
CGoGNout << "BenchTime dynamic "<< chrono.elapsed() << " ms"<< CGoGNendl;
Algo::Surface::Export::exportOFF<PFP>(myMap,position,"bench_res.off");
return 0;
}
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, 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: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap3.h"
#include "Algo/Tiling/Volume/cubic.h"
#include "Algo/Geometry/area.h"
#include "Algo/Geometry/volume.h"
#include "Utils/chrono.h"
using namespace CGoGN ;
/**
* Struct that contains some informations about the types of the manipulated objects
* Mainly here to be used by the algorithms that are parameterized by it
*/
struct PFP: public PFP_STANDARD
{
// definition of the type of the map
typedef EmbeddedMap3 MAP;
typedef double REAL;
typedef Geom::Vector<3,REAL> VEC3;
};
typedef PFP::MAP MAP;
typedef PFP::MAP::IMPL MAP_IMPL;
typedef PFP::VEC3 VEC3;
int main()
{
// declare a map to handle the mesh
MAP myMap;
Utils::Chrono ch;
ch.start();
// add position attribute on vertices and get handler on it
VertexAttribute<VEC3, MAP> position = myMap.addAttribute<VEC3, VERTEX, MAP>("position");
const int nb = 100;
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, nb);
cubic.embedIntoGrid(position, 10.0f, 10.0f, 10.0f);
std::cout<< "construct grid in " << ch.elapsed()<< " ms"<< std::endl;
ch.start();
VEC3 centerMesh(0,0,0);
int nbVols=0;
foreach_cell<VOLUME>(myMap, [&](Vol w) // foreach volume
{
VEC3 centerVol(0,0,0);
int nbFaces=0;
foreach_incident3<FACE>(myMap, w, [&](Face f) // foreach face of each volume
{
VEC3 centerFace(0,0,0);
int nbVert=0;
foreach_incident3<VERTEX>(myMap, f, [&](Vertex v) // foreach vertex of each face of each volume
{
centerFace += position[v];
nbVert++;
});
centerFace /=nbVert;
centerVol += centerFace;
});
centerVol /= nbFaces;
centerMesh += centerVol;
});
centerMesh /= nbVols;
CGoGNout<< "Traverse with foreach in " << ch.elapsed()<< " ms"<< CGoGNendl;
ch.start();
centerMesh=VEC3(0,0,0);
nbVols=0;
TraversorW<MAP> tw(myMap); // alias for Traversor<MAP,VERTEX>
for (Dart dw=tw.begin(); dw!=tw.end(); dw=tw.next())
{
VEC3 centerVol(0,0,0);
int nbFaces=0;
Traversor3WF<MAP> trwf(myMap, dw);
for (Dart df = trwf.begin(); df != trwf.end(); df = trwf.next())
{
VEC3 centerFace(0,0,0);
int nbVert=0;
Traversor3FV<MAP> trfv(myMap, df);
for (Dart dv = trfv.begin(); dv != trfv.end(); dv = trfv.next())
{
centerFace += position[dv];
nbVert++;
}
centerFace /=nbVert;
centerVol += centerFace;
}
centerVol /= nbFaces;
centerMesh += centerVol;
}
CGoGNout<< "Traverse with traversor in " << ch.elapsed()<< " ms"<< CGoGNendl;
ch.start();
PFP::REAL vol = Algo::Geometry::totalVolume<PFP>(myMap, position);
CGoGNout<< "Parallel volume:" << ch.elapsed()<< " ms val="<<vol<< CGoGNendl;
vol = 0;
foreach_cell<VOLUME>(myMap, [&](Vol w) // foreach volume
{
vol += Algo::Geometry::convexPolyhedronVolume<PFP>(myMap, w, position) ;
});
CGoGNout<< "Linear volume:" << ch.elapsed()<< " ms val="<<vol<< CGoGNendl;
return 0;
}
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin)
IF (ONELIB)
SET(CGoGN_LIBS_R cgogn)
SET(CGoGN_LIBS cgogn)
ELSE (ONELIB)
SET(CGoGN_LIBS_R topology algo container utils)
SET(CGoGN_LIBS algo topology container utils)
ENDIF (ONELIB)
IF(WIN32)
# libs have same name but in different place in Visual
IF (ONELIB)
SET(CGoGN_LIBS_D cgogn)
ELSE (ONELIB)
SET(CGoGN_LIBS_D topology algo container utils)
ENDIF (ONELIB)
ELSE(WIN32)
IF (ONELIB)
SET(CGoGN_LIBS_D cgognD)
ELSE (ONELIB)
SET(CGoGN_LIBS_D topologyD algoD containerD utilsD)
ENDIF (ONELIB)
IF (WITH_QT)
add_subdirectory(Examples/Debug)
ENDIF (WITH_QT)
ENDIF(WIN32)
IF (WITH_QT)
IF (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/${ConfigurationName} ${Boost_LIBRARY_DIRS})
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/) # Release/Debug added automatically by visual
ELSE()
link_directories( ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE} )
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE} )
ENDIF()
include_directories(
${CGoGN_ROOT_DIR}/include
${CGoGN_EXT_INCLUDES})
IF (COMPILE_SANDBOX)
add_subdirectory(SandBox)
ENDIF()
IF (COMPILE_EXAMPLES AND WITH_QT)
add_subdirectory(Examples)
ENDIF()
IF (COMPILE_TUTOS)
add_subdirectory(Tuto)
add_subdirectory(Examples/Release)
IF (NOT DONOT_COMPILE_SANDBOX)
add_subdirectory(SandBox)
ENDIF (NOT DONOT_COMPILE_SANDBOX)
ENDIF (WITH_QT)
add_subdirectory(Examples/Tests)
add_subdirectory(Tuto/Traversals)
add_subdirectory(Tuto/Attributes)
add_subdirectory(Tuto/Markers)
add_subdirectory(Tuto/Boundary)
add_subdirectory(Tuto/Modelling)
ENDIF()
IF (COMPILE_BENCHES)
add_subdirectory(Benches)
ENDIF()
IF (COMPILE_TESTS)
add_subdirectory(Tests)
ENDIF()