Commit 2d3d9fcd authored by Pierre Kraemer's avatar Pierre Kraemer
Browse files

Merge cgogn:~thery/CGoGN

parents 3d175ee5 0e633ea9
......@@ -35,6 +35,10 @@ add_executable( Geom_intersectionD ./Geom_intersection.cpp)
target_link_libraries( Geom_intersectionD
add_executable( test_compactD ./test_compact.cpp)
target_link_libraries( test_compactD
QT4_WRAP_CPP(concave_rendering_moc concave_rendering.h)
#include <iostream>
#include <Container/attributeContainer.h>
#include <iostream>
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
//#include "Geometry/vector_gen.h"
#include "Algo/Modelisation/polyhedron.h"
using namespace CGoGN;
struct PFP: public PFP_STANDARD
// definition of the map
typedef EmbeddedMap2 MAP ;
void dump(AttributeContainer& cont, AttributeMultiVector<int>* amv)
std::cout << "==============================================="<<std::endl;
int j=0;
for (unsigned int it = cont.begin(); it != cont.end();
if (j%10 == 0)
std::cout << std::endl << j<< " : ";
std::cout << amv->operator [](it) << " / ";
std::cout << std::endl <<"------------------------------------------------"<<std::endl;
void test_compact_container()
#define NB 200
AttributeContainer cont;
AttributeMultiVector<int>* amv = cont.addAttribute<int>("entiers");
for (int i =0; i< NB; ++i)
unsigned int l = cont.insertLine();
amv->operator [](l) = i;
for (int i =0; i< NB; i+=3)
std::vector<unsigned int> oldnew;
std::cout << "Size = "<< oldnew.size()<< std::endl;
int k=0;
for (std::vector<unsigned int>::iterator it =oldnew.begin(); it != oldnew.end() ;++it)
std::cout <<k << "->";
if (*it != 0xffffffff)
std::cout << *it;
std::cout << "X";
std::cout <<"/";
if (k%10 ==0)
std::cout << std::endl;
std::cout << std::endl;
#undef NB
void test_compact_map(const std::string& name)
EmbeddedMap2 myMap;
PFP::TVEC3 position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position") ;
#define NB 256
Algo::Modelisation::Polyhedron<PFP> prim1(myMap, position);
prim1.cylinder_topo(256, 256, false, false);
prim1.embedCylinder(30.0f, 10.0f, 70.0f);
#undef NB
DartMarker dm(myMap);
std::vector<Dart> verts;
int i=0;
for (Dart d = myMap.begin(); d!= myMap.end();
if (!dm.isMarked(d) && (!myMap.isBoundaryEdge(d))&& (i%11 ==0))
Dart e = d;
do // mark all edges incident to vertex;
dm.markOrbit( EDGE, e);
e = myMap.alpha1(e);
}while (e!=d);
for (std::vector<Dart>::iterator it=verts.begin(); it != verts.end(); ++it)
int main(int argc, char** argv)
if (argc>1)
return 0;
......@@ -793,11 +793,8 @@ void Clipping::importMesh(std::string& filename)
std::vector<std::string> attrNames ;
std::string extension;
size_t pos;
pos = filename.rfind("."); // position of "." in filename
extension = filename.substr(pos);
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
if(extension == std::string(".tet"))
......@@ -819,6 +816,17 @@ void Clipping::importMesh(std::string& filename)
position = myMap.getAttribute<PFP::VEC3>(VERTEX , attrNames[0]) ;
if(extension == std::string(".map"))
CGoGNerr << "could not import " << filename << CGoGNendl ;
position = myMap.getAttribute<PFP::VEC3>(VERTEX , "position") ;
updateVBOprimitives(Algo::Render::GL2::TRIANGLES | Algo::Render::GL2::LINES | Algo::Render::GL2::POINTS) ;
......@@ -184,6 +184,16 @@ void Viewer::importMesh(std::string& filename)
myMap.clear(true) ;
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
if (extension == std::string(".map"))
position = myMap.getAttribute<PFP::VEC3>(VERTEX, "position") ;
std::vector<std::string> attrNames ;
if(!Algo::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames))
......@@ -191,6 +201,8 @@ void Viewer::importMesh(std::string& filename)
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS) ;
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::LINES) ;
......@@ -24,7 +24,40 @@ Les applications (Examples et Tutos) sont dans le répertoire Apps
Les binaires sont générés dans le repertoire bin
Des exemples de données:
- fichiers trianbgz
- fichiers png (contenant des images voxel 3D)
- fichiers trianbgz, off, etc
sont accessible à l'adresse suivante:
Linux dependencies:
install the following packages:
ccmake libXi-dev libXmu-dev libglew-dev libxml2-dev libboost-all-dev zlib1g-dev qt4-designer qt4-dev-tools uuid-dev
To compile CGoGN:
- Go ThirdParty, cd build, type "cmake .." and then make (with -j x if you have x core on your machine)
We can set some option to not compile everything (see the README.TXT in ThirdParty)
You can also compile debug by creating a directory that ended Debug build instead
- Go to build and type "cmake .." and then make
Options (Boolean) are also available here:
BUILD_SHARED_LIBS (F) experimental!
to minimize dependencies and compilation time /
- the compilation of each sub-parts is done by going in the subdirectories of build
Applications (examples and tutorials) are in the Apps directory
The binaries are generated in the bin directory
Examples of data:
- Trianbgz files, off, etc.
are accessible at the following address:
Principe des applications dans CGoGN_Apps
Principe des applications dans CGoGN_Apps (english version bellow
......@@ -24,7 +24,6 @@ IF (NOT WIN32)
Le CMakeLists (Release par exemple) doit ensuite contenir:
......@@ -66,3 +65,80 @@ ici WITH_QT, WITH_ASSIMP, WITH_NUMERICAL, WITH_ZINRI.
Ceci ajoutera automatiquement tout ce qu'il faut aux variables COMMON_INCLUDES
On peut aussi utiliser cmake avec l'option -D (moins pratique).
Create a directory CGoGN_Apps where you want. Inside create subdirectories, one for each application.
The CMakeLists.txt to the root of the application must begin with
cmake_minimum_required(VERSION 2.8)
The .. / .. / CGoGN corresponds to the relative path to your version of CGoGN
(here placed at the same level as CGoGN_Apps)
If you want to do in release and debug directories:
add_subdirectory(${CMAKE_SOURCE_DIR}/Release Release)
add_subdirectory(${CMAKE_SOURCE_DIR}/Debug Debug)
The CMakeLists (here in Release) must then contain:
link_directories( ${CGoGN_ROOT_DIR}/lib/$(ConfigurationName) )
link_directories( ${CGoGN_ROOT_DIR}/lib/Release/ )
# Watch out for the debug version, two solutions:
# Debug and Release to be if you want to use ThirdParty in release version
# or Debug only, but you have to compile ThirdParty in debug
${CGoGN_ROOT_DIR}/include # for CGoGN
${COMMON_INCLUDES} # for thirdparty & system
${CMAKE_CURRENT_SOURCE_DIR} # for application
${CMAKE_CURRENT_BINARY_DIR} # for qt (ui,moc,etc.) if necessary
# for a QT application
QT4_WRAP_UI( source_ui ../source.ui )
QT4_WRAP_CPP( source_moc ../source.h )
add_executable( mon_exec
# for a QT application
target_link_libraries( mon_exec ${CGoGN_LIBS_R} ${COMMON_LIBS})
To compile the cleanest way is to build a directory, to go inside and make ccmake .. (I have written "..")
ccmake (or an equivalent type cmake-gui) is used to update the variables, WITH_QT here, WITH_ASSIMP,
This will automatically add it all the variables COMMON_INCLUDES and COMMON_LIBS.
You can also use cmake with -D option (less convenient).
Pour utiliser Eclipse (testé avec la version Helios, Galileo & Indigo)
English version bellow
* Configurer un projet dans Eclipse :
- Faire un nouveau projet C++
......@@ -57,3 +58,67 @@ Dans Preferences -> Shaders Preferences, on peut désormais configurer certaines
- Installer CMakeEditor pour Eclipse en ajoutant l'URL dans Help -> Install New Software ... :
- Installer et redémarrer
- Dans Preferences -> General -> Editors -> File Associations il est possible d'associer les CMakeLists.txt à ce logiciel d'édition
To use Eclipse (tested with version Helios, Galileo & Indigo)
* Setting up a project in Eclipse:
- Make a new C + + project
- Select Makefile project -> Empty Project
- Choose As "Location": root CGoGN
- Select Toolchain: GCC Linux
* Compilation with the small hammer (icon)
In the project properties:
-> C / C + + Build:
In the configuration Default | Active:
add to Build Directory path /build
you can then add configurations to compile what we want by just changing the Build directory:
CGoGNRelease: build / Release (compile the lib release)
CGoGNDebug: build / Debug (compiles in debug lib)
Apps: build / Apps (compile the examples and tutorials)
Tutorial: Build / Apps / Tutorial (compiles tutorials)
etc. ..
This added to the directory of CGoGN a .project. and .cproject files.
* Inter-dependencies projects and autocompletion
If the project X depends on another project, then:
Project X -> Properties -> Project references: check the project which it depends.
* Qt dependencies:
To avoid Eclipse rejects the Qt syntax (the Qt includes the Q_OBJECT, callbacks):
- Download the Qt plugin "eclipse-integration"
- Unzip the archive and copy its contents into the installation directory of Eclipse (plugins and features)
- Restart Eclipse at least once with the - clean (proofreading local directories)
Normally in Window-> Preferences of Eclipse, Qt appears in the menu.
- Add the Qt directory (/ usr / bin on Debian / Ubuntu) and the directory include (/ usr/include/qt4).
Then, for each project, add the following includes in Properties -> C / C + + general -> Paths and Symbols
among the C + + includes:
- / Usr/include/qt4
- / Usr/include/qt4/Qt
- / Usr/include/qt4/QtCore
- / Usr/include/qt4/QtGui
- / Usr/include/qt4/QtOpenGL
NOTE: at the bottom of this window, the button "Export Settings" allows you to export the configuration to XML
import it into other projects.
- Finally, a small right-click the project -> Index -> Freshen all files and go.
* Syntax of shaders
- Download and unzip EclipseShaders:
- Copy the directories features and plugins in the eclipse installation directory
- Restart Eclipse at least once with the - clean (proofreading local directories)
Eclipse will now recognize the files. And frag. Green.
To assign other files in the program GLSLeditor:
- Preferences -> General -> Editors -> File Associations
In Preferences -> Shaders Preferences, you can now configure some options related to the shader.
* Syntax highlighting for CMake files
- Install CMakeEditor for Eclipse by adding the URL in Help -> Install New Software ... : Http://
- Install and restart
- In Preferences -> General -> Editors -> File Associations You can associate the CMakeLists.txt to editing software
......@@ -16,4 +16,22 @@ Pour compiler CGoGN sur MAC (testé sur OS X 10.6)
export LIBRARY_PATH=/opt/local/lib:/usr/X11/lib
To compile CGoGN on MAC (tested on OSX 10.6 and OSX 10.7.2)
1) create a link from sys/malloc to malloc.h in usr/include:
cd /usr/include; sudo ln -s sys/malloc.h .
This solve compilation problems of some linux codes on mac
2) install with macports or homebrew
zlib, glew, boost (sudo port install xxxx)
3) install Qt (
4) Add if not already done (by homebrew) in bash_profile:
export LD_LIBRARY_PATH=/opt/local/lib
export C_INCLUDE_PATH=/opt/local/include:/usr/X11/include
export CPLUS_INCLUDE_PATH=/opt/local/include:/usr/X11/include
export LIBRARY_PATH=/opt/local/lib:/usr/X11/lib
Compilation sous VisualExpress C++ (english version bellow)
Visual Studio ou C++ Express (au moins 2005, si possible 2010)
CMake (au moins 2.8)
......@@ -62,3 +64,80 @@ Remarque: gain de performance non négligeable en 64 bits (20/25%)
(Merci à Olivier Génevaux pour son expertise en compilation sous Windows !)
Visual Studio and C + + Express (at least 2005, possibly 2010)
CMake (at least 2.8)
Unzip the ( is the root of CGoGN
Install boost and Qt
Warning installing the binaries of Qt in a version of different compilers (VS2008/VS2010)
allows you to run but not in debug mode!
If you use BoostPro ( install all versions multithreaded dll
to avoid the pb of compilation.
The safest but longest is to compile Qt yourself and Boost (good luck)
For the "ThirdParty libs"
Run CMake (gui)
Put the path to the root of CGoGN + / ThirdParty sources for
Put the path to the root of CGoGN + / ThirdParty / build to build in release
Put the path to the root of CGoGN + / ThirdParty / buildDebug to build in debug
Under windows the two versions are needed.
The following applies to two directories:
Click on Configure
Choosing the right compiler (your version of Visual C + +)
Change the variables in functions that you want to compile (README.TXT for ThirdParty)
Edit CMAKE_PREFIX_PATH if necessary (see note dependencies)
Click again on Configure
Click on Generate
Go compile under visual (in release)
For CGoGN:
Restart CMake
Put the path to the root of CGoGN for sources
Put the path to the root of CGoGN + / build (for example) to build
Click on Configure
Choosing the right compiler (your version of Visual C + +)
Change the variables as ThirdParty (and CMAKE_PREFIX_PATH if necessary)
Click again on Configure
Click on Generate
Go to Visual and double-click on CGoGN.sln!
For running executables you have to add the path to the dll dependencies in the variable
path environment (or copy the dll in a directory already in the path)
Note Dependencies:
If you want to use your own versions of dependency (Zlib / glew / Boost / Qt)
CMAKE_PREFIX_PATH change (see below)
Attention to Boost the prefix path does not work (use BOOST_ROOT and others if necessary)
Compiling 64-bit:
The libraries and the examples are compiled in 64bit Windows.
Tested with Visual Express C + + 2010 + Windows SDK 7.1
Dependencies are accessible in
Caution must be changed and select projects in Windows7.1SDK tools platform
in Configuration / General, to use the correct compiler and lib related.
Note: significant performance gain in 64-bit (20/25%)
(Thanks to Olivier Génevaux for its expertise in compilation under Windows!)
......@@ -52,9 +52,13 @@ void Topo3RenderMapD::updateData(typename PFP::MAP& map, const FunctorSelect& go
if ( != &map)
m_attIndex = map.template getAttribute<unsigned int>(DART, "dart_index");
if (!m_attIndex.isValid())
m_attIndex = map.template addAttribute<unsigned int>(DART, "dart_index");
m_nbDarts = 0;
// table of center of volume
......@@ -320,6 +324,8 @@ void Topo3RenderGMap::updateData(typename PFP::MAP& map, const FunctorSelect& go
if ( != &map)
m_attIndex = map.template getAttribute<unsigned int>(DART, "dart_index");
if (!m_attIndex.isValid())
m_attIndex = map.template addAttribute<unsigned int>(DART, "dart_index");
......@@ -251,12 +251,19 @@ public:
unsigned int getAttributeBlocksPointers(unsigned int attrIndex, std::vector<T*>& vect_ptr, unsigned int& byteBlockSize);
* fill a vector with attributes' names
* @param vector of names
* @return number of attribute
* fill a vector with attributes names
* @param names vector of names
* @return number of attributes
unsigned int getAttributesNames(std::vector<std::string>& names);
* fill a vector with attribute type names
* @param types vector of type names
* @return number of attributes
unsigned int getAttributesTypes(std::vector<std::string>& types);
......@@ -470,17 +477,17 @@ protected:
* load xmlpart of container
bool loadXmlBWF(xmlNodePtr node);
// bool loadXmlBWF(xmlNodePtr node);
* load xmlpart of container
bool loadXmlAN(xmlNodePtr node, unsigned int nbb);
// bool loadXmlAN(xmlNodePtr node, unsigned int nbb);
* load xmlpart of container
bool loadXmlDL(xmlNodePtr node);
// bool loadXmlDL(xmlNodePtr node);
......@@ -488,20 +495,20 @@ public:
* @param writer a xmlTextWriterPtr obj
* @param id the id to save
void saveXml(xmlTextWriterPtr writer, unsigned int id);
// void saveXml(xmlTextWriterPtr writer, unsigned int id);
* get id from xml node
* @param node the node of container node of xml tree
* @return the value of id of the node
static unsigned int getIdXmlNode(xmlNodePtr node);
// static unsigned int getIdXmlNode(xmlNodePtr node);
* load from xml node
* @param node the node of container node of xml tree
bool loadXml(xmlNodePtr node);
// bool loadXml(xmlNodePtr node);
* save binary file
......@@ -407,7 +407,6 @@ void AttributeMultiVector<T>::saveBin(CGoGNostream& fs, unsigned int id)
fs.write(reinterpret_cast<const char*>(buffer),(len1+len2)*sizeof(char));
nbs[0] = m_tableData.size();
nbs[1] = nbs[0] * _BLOCKSIZE_* sizeof(T);
fs.write(reinterpret_cast<const char*>(nbs),2*sizeof(unsigned int));
......@@ -66,7 +66,12 @@ public:
AttributeMultiVectorGen* addAttribute(AttributeContainer& container, const std::string& attribName)