diff options
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/doc/Gudhi_banner.jpg | bin | 0 -> 34437 bytes | |||
-rw-r--r-- | src/common/doc/main_page.h | 50 | ||||
-rw-r--r-- | src/common/include/gudhi/Clock.h | 27 | ||||
-rw-r--r-- | src/common/include/gudhi/Off_reader.h | 35 | ||||
-rw-r--r-- | src/common/include/gudhi/Utils.h | 30 | ||||
-rw-r--r-- | src/common/include/gudhi/iofile.h | 236 |
6 files changed, 98 insertions, 280 deletions
diff --git a/src/common/doc/Gudhi_banner.jpg b/src/common/doc/Gudhi_banner.jpg Binary files differnew file mode 100644 index 00000000..ebd3d8af --- /dev/null +++ b/src/common/doc/Gudhi_banner.jpg diff --git a/src/common/doc/main_page.h b/src/common/doc/main_page.h index 4e36066f..b640ea7b 100644 --- a/src/common/doc/main_page.h +++ b/src/common/doc/main_page.h @@ -1,20 +1,38 @@ /** \mainpage +\image html "Gudhi_banner.jpg" "" width=20cm + The Gudhi library (Geometric Understanding in Higher Dimensions) is a generic C++ library for -computational topology. Its goal is to provide robust, efficient, flexible and easy to use +topological analysis of high-dimensional data whose goal is to provide robust, efficient, flexible and easy to use implementations of -state-of-the-art algorithms and data structures for computational topology. We refer to +state-of-the-art algorithms and data structures for computational topology. + +The current release of the library allows to use several data-structures for simplicial complexes : +simplex tree, Hasse diagram or skeleton-blocker. Several operations can then be done on top of these +representations such a spersistent homology computation or simplification. + +All data-structures are generic and several of their aspects (such as stored elements, policies) +can be parametrized via template classes. + +We refer to \cite gudhilibrary_ICMS14 for a detailed description of the design of the library. -The current release of the library allows the user to construct representations of simplicial complexes -- -simplex tree or Hasse diagram -- from a point -cloud (Rips complex) or -a list of simplices, and to compute their persistent homology with coefficients in a field -\f$\mathbb{Z}/p\mathbb{Z}\f$ (for an arbitrary prime \f$p\f$), or simultaneously with coefficients -in a family of fields (multi-field persistent homology). +\section Compiling + +The library uses c++11 and requires Boost with version 1.48.0 or more recent : http://www.boost.org/. +Some packages require additional libraries : +\li the multi-field persistent homology algorithm has an optional dependency with GMP +\li Qt demos require CGAL, Qt4 and QGLViewer + +The procedure to install these packages according to your operating system is +detailled here http://doc.cgal.org/latest/Manual/installation.html + +The library compiles in Linux and Mac OSX. + +\section d Demos and Examples To build the library, run the following in a terminal: @@ -26,27 +44,13 @@ cmake -DCMAKE_BUILD_TYPE=Release .. make \endverbatim -The library has dependencies with Boost 1.48.0 or more recent (required): http://www.boost.org/ -and with GMP: https://gmplib.org/ The dependency with GMP is optional, and is used only for the -multi-field persistent homology algorithm. - - -We provide example files: run these examples with -h for details on their use, and read the README file. - -\li <CODE>rips_persistence.cpp</CODE> computes the Rips complex of a point cloud and its persistence diagram. -\li <CODE>rips_multifield_persistence.cpp</CODE> computes the Rips complex of a point cloud and its persistence diagram -with a family of field coefficients. -\li <CODE>performance_rips_persistence.cpp</CODE> provides timings for the construction of the Rips complex on a set of -points sampling a Klein bottle in \f$\mathbb{R}^5\f$ with a simplex tree, its conversion to a -Hasse diagram and the computation of persistent homology and multi-field persistent homology for the -different representations. \details \copyright GNU General Public License v3. -\verbatim Contact: Clément Maria, clement.maria@inria.fr \endverbatim +\verbatim Contact: gudhi-devel@lists.gforge.inria.fr \endverbatim */
\ No newline at end of file diff --git a/src/common/include/gudhi/Clock.h b/src/common/include/gudhi/Clock.h index ea21659e..08096c05 100644 --- a/src/common/include/gudhi/Clock.h +++ b/src/common/include/gudhi/Clock.h @@ -1,9 +1,24 @@ -/* - * Clock.h - * - * Created on: Jun 17, 2014 - * Author: dsalinas - */ + /* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ #ifndef GUDHI_CLOCK_H_ #define GUDHI_CLOCK_H_ diff --git a/src/common/include/gudhi/Off_reader.h b/src/common/include/gudhi/Off_reader.h index a9c64f97..e29218d8 100644 --- a/src/common/include/gudhi/Off_reader.h +++ b/src/common/include/gudhi/Off_reader.h @@ -1,8 +1,8 @@ /* * Off_reader.h * Created on: Nov 28, 2014 - * This file is part of the Gudhi Library. The Gudhi library - * (Geometric Understanding in Higher Dimensions) is a generic C++ + * This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * * Author(s): David Salinas @@ -21,7 +21,7 @@ * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * */ @@ -113,18 +113,26 @@ private: bool is_off_file = (line.find("OFF") != std::string::npos); bool is_noff_file = (line.find("nOFF") != std::string::npos); - if(!is_off_file && !is_noff_file) return false; + if(!is_off_file && !is_noff_file) { + std::cerr << line<<std::endl; + std::cerr << "missing off header\n"; + return false; + } if(!goto_next_uncomment_line(line)) return false; std::istringstream iss(line); if(is_off_file){ off_info_.dim = 3; - if(!(iss >> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)) + if(!(iss >> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)){ + std::cerr << "incorrect number of vertices/faces/edges\n"; return false; + } } else - if(!(iss >> off_info_.dim >> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)) + if(!(iss >> off_info_.dim >> off_info_.num_vertices >> off_info_.num_faces >> off_info_.num_edges)){ + std::cerr << "incorrect number of vertices/faces/edges\n"; return false; + } off_visitor.init(off_info_.dim,off_info_.num_vertices,off_info_.num_faces,off_info_.num_edges); return true; @@ -134,7 +142,7 @@ private: uncomment_line.clear(); do std::getline(stream_, uncomment_line); - while(uncomment_line[0] == '%'); + while(uncomment_line[0] == '%');// || uncomment_line.empty()); return (uncomment_line.size()>0 && uncomment_line[0] != '%'); } @@ -171,6 +179,19 @@ private: }; +template<typename OFFVisitor> +void read_off(const std::string& name_file_off,OFFVisitor& vis){ + std::ifstream stream(name_file_off); + if(!stream.is_open()) + std::cerr <<"could not open file \n"; + else{ + Off_reader off_reader(stream); + off_reader.read(vis); + } +} + + + } // namespace Gudhi diff --git a/src/common/include/gudhi/Utils.h b/src/common/include/gudhi/Utils.h index cef361dc..1626a0bf 100644 --- a/src/common/include/gudhi/Utils.h +++ b/src/common/include/gudhi/Utils.h @@ -1,17 +1,31 @@ -/* - * Utils.h - * - * Created on: 13 juin 2013 - * Author: salinasd - */ - + /* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ #ifndef GUDHI_UTILS_H_ #define GUDHI_UTILS_H_ #define PRINT(a) std::cerr << #a << ": " << (a) << " (DISP)"<<std::endl -//#define DBG_VERBOSE +#define DBG_VERBOSE #ifdef DBG_VERBOSE #define DBG(a) std::cerr << "DBG: " << (a)<<std::endl #define DBGMSG(a,b) std::cerr << "DBG: " << a<<b<<std::endl diff --git a/src/common/include/gudhi/iofile.h b/src/common/include/gudhi/iofile.h deleted file mode 100644 index b939d45b..00000000 --- a/src/common/include/gudhi/iofile.h +++ /dev/null @@ -1,236 +0,0 @@ -//todo remove and use off_reader instead - -#ifndef GUDHI_IOFILE_H_ -#define GUDHI_IOFILE_H_ - -#include <iostream> -#include <fstream> -#include <sstream> -#include <vector> -#include <cstdio> -#include <cstring> -#include <list> -#include <cassert> - - - -//todo use my new visitor based off instead -/** - * @brief OFF reader, save the content of the file (vertices and maximal faces) in 'complex'. - * The class Complex has to handle the following operations: - * - void add_vertex(double[dim],int dim) - * - void add_face(int dimension ,int[dimension] vertices) - * Source from : http://www.holmes3d.net/graphics/offfiles/OFFLoading.txt - * - * @todo todo ignore comments in the file -> # comment - */ -template<typename Complex> inline -bool general_read_off_file(const std::string & file_name, Complex& complex){ - // Declare temporary variables to read data into. - // If the read goes well, we'll copy these into - // our class variables, overwriting what used to - // be there. If it doesn't, we won't have messed up - // our previous data structures. - int tempNumPoints = 0; // Number of x,y,z coordinate triples - int tempNumFaces = 0; // Number of polygon sets - int tempNumEdges = 0; // Unused, except for reading. - int tempDimPoints = 0; - double** tempPoints = NULL; // An array of x,y,z coordinates. - int** tempFaces = NULL; // An array of arrays of point - // pointers. Each entry in this - // is an array of integers. Each - // integer in that array is the - // index of the x, y, and z - // coordinates in the corresponding - // arrays. - int* tempFaceSizes = NULL; // An array of polygon point counts. - // Each of the arrays in the tempFaces - // array may be of different lengths. - // This array corresponds to that - // array, and gives their lengths. - int i; // Generic loop variable. - bool goodLoad = true; // Set to false if the file appears - // not to be a valid OFF file. - char tempBuf[128]; // A buffer for reading strings - // from the file. - - // Create an input file stream for the file the CArchive - // is connected to. This allows use of the overloaded - // extraction operator for conversion from string - // data to doubles and ints. - std::ifstream ifs (file_name.c_str(), std::ios::in); - if(!ifs.is_open()) { - std::cerr << "Unable to open file " << file_name << std::endl; - return false; - } - - // Grab the first string. If it's "OFF", we think this - // is an OFF file and continue. Otherwise we give up. - ifs >> tempBuf; - if (strcmp(tempBuf, "OFF") != 0) { - goodLoad = false; - std::cerr << "No OFF preambule\n"; - } - - // Read the sizes for our two arrays, and the third - // int on the line. If the important two are zero - // sized, this is a messed up OFF file. Otherwise, - // we setup our temporary arrays. - if (goodLoad) { - ifs >> tempNumPoints >> tempNumFaces >> tempNumEdges; - if (tempNumPoints < 1 || tempNumFaces < 0) { - // If either of these were negative, we make - // sure that both are set to zero. This is - // important for later deleting our temporary - // storage. - goodLoad = false; - std::cerr << "tempNumPoints < 1 || tempNumFaces < 0\n"; - tempNumPoints = 0; - tempNumFaces = 0; - } else { - tempPoints = new double*[tempNumPoints]; - tempFaces = new int*[tempNumFaces]; - tempFaceSizes = new int[tempNumFaces]; - } - } - - if (goodLoad) { - // Load all of the points. - - // we start by loading the first one - // the case is difference because then we dont know the dimension by advance - // we discover the point dimension by reading the first line - std::string lineFirstPoint; - std::getline(ifs, lineFirstPoint); - while(lineFirstPoint.size()<3){ - std::getline(ifs, lineFirstPoint); - } - - // we store the first point in a temporary list - std::istringstream lineFirstPointStream(lineFirstPoint); - std::list<double> firstTempPoint; - double coord; - while(lineFirstPointStream>>coord){ - firstTempPoint.push_back(coord); - ++tempDimPoints; - } - // we store the point in our points array - tempPoints[0]=new double[tempDimPoints]; - for( int j = 0 ; j<tempDimPoints; ++j){ - tempPoints[0][j] = firstTempPoint.front(); - firstTempPoint.pop_front(); - } - - // now, we know the dimension and can read safely other points - for (i = 1; i < tempNumPoints; i++) { - tempPoints[i] = new double[tempDimPoints]; - for (int j = 0 ; j<tempDimPoints ; ++j){ - ifs>>tempPoints[i][j]; - } - } - - // Load all of the faces. - for (i = 0; i < tempNumFaces; i++) { - // This tells us how many points make up - // this face. - ifs >> tempFaceSizes[i]; - // So we declare a new array of that size - tempFaces[i] = new int[tempFaceSizes[i]]; - // And load its elements with the vertex indices. - for (int j = 0; j < tempFaceSizes[i]; j++) { - ifs >> tempFaces[i][j]; - } - // Clear out any face color data by reading up to - // the newline. 128 is probably considerably more - // space than necessary, but better safe than - // sorry. - ifs.getline(tempBuf, 128); - } - } - - // Here is where we copy the data from the temp - // structures into our permanent structures. We - // probably will do some more processing on the - // data at the same time. This code you must fill - // in on your own. - if (goodLoad) { - // we save vertices first in the complex - for (i = 0; i < tempNumPoints; i++) - complex.add_vertex(tempPoints[i],tempDimPoints); - - // we save faces - for (i = 0; i < tempNumFaces; i++) { - for (int j = 0; j < tempFaceSizes[i]; j++) - complex.add_face(tempFaceSizes[i],tempFaces[i]); - } - } - - // Now that we're done, we have to make sure we - // free our dynamic memory. - for (i = 0; i < tempNumPoints; i++) { - delete []tempPoints[i]; - } - delete []tempPoints; - - for (i = 0; i < tempNumFaces; i++) { - delete tempFaces[i]; - } - delete []tempFaces; - delete []tempFaceSizes; - - // Clean up our ifstream. The MFC framework will - // take care of the CArchive. - ifs.close(); - - return goodLoad; -} - - -template<typename Complex> -class Geometric_flag_complex_wrapper{ - Complex& complex_; - typedef typename Complex::Vertex_handle Vertex_handle; - typedef typename Complex::Point Point; - - const bool load_only_points_; - -public: - Geometric_flag_complex_wrapper(Complex& complex,bool load_only_points = false): - complex_(complex), - load_only_points_(load_only_points) -{} - - - void add_vertex(double* xyz,int dim){ - Point p(dim); - for(int i=0;i<dim;++i) - p[i] = xyz[i]; - complex_.add_vertex(p); - } - - void add_face(int dimension ,int* vertices){ - if (!load_only_points_){ - for (int i = 0; i<dimension ; ++i) - for (int j = i+1; j<dimension ; ++j) - complex_.add_edge(Vertex_handle(vertices[i]),Vertex_handle(vertices[j])); - } - } -}; - - - - -/** - * @brief Read a mesh into a OFF file - * load_only_points should be true if only the points have to be loaded. - */ -template<typename Complex> -bool read_off_file(std::string file_name,Complex &complex,bool load_only_points = false){ - complex.clear(); - Geometric_flag_complex_wrapper<Complex> complex_wrapper(complex,load_only_points); - return general_read_off_file(file_name,complex_wrapper); - -} - - -#endif |