Commit b52ebd44 authored by untereiner's avatar untereiner

Merge cgogn:~thery/CGoGN

parents 9e2ce59c 8a677cc4
......@@ -35,6 +35,10 @@ add_executable( Geom_intersectionD ./Geom_intersection.cpp)
target_link_libraries( Geom_intersectionD
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS})
add_executable( test_compactD ./test_compact.cpp)
target_link_libraries( test_compactD
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS})
IF (WITH_QT)
QT4_WRAP_CPP(concave_rendering_moc concave_rendering.h)
......
......@@ -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)
else
position = myMap.getAttribute<PFP::VEC3>(VERTEX , attrNames[0]) ;
}
if(extension == std::string(".map"))
{
if(!myMap.loadMapBin(filename))
{
CGoGNerr << "could not import " << filename << CGoGNendl ;
return;
}
else
position = myMap.getAttribute<PFP::VEC3>(VERTEX , "position") ;
}
updateVBOprimitives(Algo::Render::GL2::TRIANGLES | Algo::Render::GL2::LINES | Algo::Render::GL2::POINTS) ;
......
......@@ -184,13 +184,25 @@ void Viewer::importMesh(std::string& filename)
{
myMap.clear(true) ;
std::vector<std::string> attrNames ;
if(!Algo::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames))
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
if (extension == std::string(".map"))
{
myMap.loadMapBin(filename);
position = myMap.getAttribute<PFP::VEC3>(VERTEX, "position") ;
}
else
{
CGoGNerr << "could not import " << filename << CGoGNendl ;
return;
std::vector<std::string> attrNames ;
if(!Algo::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames))
{
CGoGNerr << "could not import " << filename << CGoGNendl ;
return;
}
position = myMap.getAttribute<PFP::VEC3>(VERTEX, attrNames[0]) ;
}
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:
https://iggservis.u-strasbg.fr/Data/data.zip
=========================================================================================
ENGLISH VERSION
=========================================================================================
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!
WITH_ASSIMP (T)
WITH_NUMERICAL (T)
WITH_ZINRI (T)
WITH_QT (T)
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:
https://iggservis.u-strasbg.fr/Data/data.zip
Principe des applications dans CGoGN_Apps
Principe des applications dans CGoGN_Apps (english version bellow
......@@ -24,7 +24,6 @@ IF (NOT WIN32)
ENDIF (NOT WIN32)
Le CMakeLists (Release par exemple) doit ensuite contenir:
SET(CMAKE_BUILD_TYPE Release)
......@@ -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
et COMMON_LIBS.
On peut aussi utiliser cmake avec l'option -D (moins pratique).
=========================================================================================
ENGLISH VERSION
=========================================================================================
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)
PROJECT(NOM_DE_L_APPLICATION)
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/../../CGoGN CACHE STRING "CGoGN root dir")
INCLUDE(${CGoGN_ROOT_DIR}/apps_cmake.txt)
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)
IF (NOT WIN32)
add_subdirectory(${CMAKE_SOURCE_DIR}/Debug Debug)
ENDIF (NOT WIN32)
The CMakeLists (here in Release) must then contain:
SET(CMAKE_BUILD_TYPE Release)
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/$(ConfigurationName) )
ELSE (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release/ )
ENDIF (WIN32)
# 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
include_directories(
${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
${CMAKE_SOURCE_DIR}/mon_source.cpp
# for a QT application
${source_moc}
${source_ui}
)
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,
WITH_NUMERICAL, WITH_ZINRI.
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 ... : http://cmakeed.sourceforge.net/eclipse/
- Installer et redémarrer
- Dans Preferences -> General -> Editors -> File Associations il est possible d'associer les CMakeLists.txt à ce logiciel d'édition
=========================================================================================
ENGLISH VERSION
=========================================================================================
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" http://qt.nokia.com/developer/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: http://sourceforge.net/projects/glshaders/
- 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://cmakeed.sourceforge.net/eclipse/
- 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
=========================================================================================
ENGLISH VERSION
=========================================================================================
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 (http://qt.nokia.com/downloads/)
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)
Prérequis:
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 !)
=========================================================================================
ENGLISH VERSION
=========================================================================================
Prerequisites:
Visual Studio and C + + Express (at least 2005, possibly 2010)
CMake (at least 2.8)
Unzip the windows_dependencies.zip (http://iggservis.u-strasbg.fr/Data/) 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 (http://www.boostpro.com) 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 http://iggservis.u-strasbg.fr/Data/dependencies64.zip
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 (m_attIndex.map() != &map)
{
m_attIndex = map.template addAttribute<unsigned int>(DART, "dart_index");
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,7 +324,9 @@ void Topo3RenderGMap::updateData(typename PFP::MAP& map, const FunctorSelect& go
if (m_attIndex.map() != &map)
{
m_attIndex = map.template addAttribute<unsigned int>(DART, "dart_index");
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;
......
......@@ -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);
/**************************************
* CONTAINER MANAGEMENT *
**************************************/
......@@ -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);
public:
/**
......@@ -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)
memcpy(buffer+len1,s2,len2);
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)
{
return container.addAttribute<T>(attribName);
unsigned int id = container.getAttributeIndex(attribName);
// new attribute
if (id == AttributeContainer::UNKNOWN)
return container.addAttribute<T>(attribName);
// or existing one
return container.getDataVector<T>(id);
}
};
......
......@@ -45,6 +45,7 @@ public:
virtual void clear(bool removeAttrib) ;
/****************************************
* ATTRIBUTES MANAGEMENT *
****************************************/
......
......@@ -300,6 +300,13 @@ protected:
*/
AttributeMultiVector<Dart>* addRelation(const std::string& name) ;
/**
* Get attributeMultivector pointer of a relation attribute
* @param anem name of relation
* @return the attribute multi-vector pointer
*/
AttributeMultiVector<Dart>* getRelation(const std::string& name);
/****************************************
* THREAD MANAGEMENT *
****************************************/
......@@ -333,26 +340,31 @@ public:
* @param name the name
* @ return true if node has the good name
*/
bool chechXmlNode(xmlNodePtr node, const std::string& name) ;
// bool chechXmlNode(xmlNodePtr node, const std::string& name) ;
/**
* update the pointer of embedding vector after loading
*/
void update_m_emb_afterLoad();
/**
* update the markTables and recursively from real type the topo shortcut pointers
*/
virtual void update_topo_shortcuts();
/**
* Save map in a XML file
* @param filename the file name
* @return true if OK
*/
bool saveMapXml(const std::string& filename, bool compress = false) ;
// bool saveMapXml(const std::string& filename, bool compress = false) ;
/**
* Load map from a XML file
* @param filename the file name
* @return true if OK
*/
bool loadMapXml(const std::string& filename, bool compress = false) ;
// bool loadMapXml(const std::string& filename, bool compress = false) ;
/**
* Save map in a binary file
......@@ -368,6 +380,21 @@ public:
*/
bool loadMapBin(const std::string& filename) ;
/**
* Dump attributes types and names per orbit
*/
void dumpAttributesAndMarkers();
/**
* update topo relation after compacting the container:
*/
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew)=0;
/**
* compact the map
*/
void compact();
/****************************************
* DARTS TRAVERSALS *
****************************************/
......
......@@ -25,10 +25,10 @@
namespace CGoGN
{
inline bool GenericMap::chechXmlNode(xmlNodePtr node, const std::string& name)
{
return (strcmp((char*)(node->name),(char*)(name.c_str())) == 0);
}
//inline bool GenericMap::chechXmlNode(xmlNodePtr node, const std::string& name)
//{
// return (strcmp((char*)(node->name),(char*)(name.c_str())) == 0);
//}
/****************************************
* DARTS MANAGEMENT *
......@@ -211,5 +211,13 @@ inline AttributeMultiVector<Dart>* GenericMap::addRelation(const std::string& na
return amv ;
}
inline AttributeMultiVector<Dart>* GenericMap::getRelation(const std::string& name)
{
AttributeContainer& cont = m_attribs[DART] ;
AttributeMultiVector<Dart>* amv = cont.getDataVector<Dart>(cont.getAttributeIndex(name)) ;
return amv ;
}
} //namespace CGoGN
......@@ -52,6 +52,10 @@ public:
virtual void clear(bool removeAttrib);
virtual void update_topo_shortcuts();
virtual void compactTopoRelations(const std::vector<unsigned int>& oldnew);
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
......@@ -53,6 +53,12 @@ inline void GMap0::clear(bool removeAttrib)
init() ;
}
inline void GMap0::update_topo_shortcuts()
{
GenericMap::update_topo_shortcuts();
m_beta0 = getRelation("beta0");
}
/*! @name Basic Topological Operators
* Access and Modification
*************************************************************************/
......
......@@ -51,6 +51,10 @@ public:
virtual void clear(bool removeAttrib);
virtual void update_topo_shortcuts();