diff options
-rw-r--r-- | src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h | 11 | ||||
-rw-r--r-- | src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h | 117 |
2 files changed, 68 insertions, 60 deletions
diff --git a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h index c06678a1..00b39f01 100644 --- a/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h +++ b/src/Bitmap_cubical_complex/doc/Gudhi_Cubical_Complex_doc.h @@ -36,7 +36,7 @@ namespace Cubical_complex * @{
*
-*Cubical complex is an example of a structured complex useful in computational mathematics (specially rigorous numerics) and image analysis. The presented implementation of cubical complexes is based on the following definition.
+*Bitmap_cubical_complex is an example of a structured complex useful in computational mathematics (specially rigorous numerics) and image analysis. The presented implementation of cubical complexes is based on the following definition.
*
* An <em>elementary interval</em> is an interval of a form \f$ [n,n+1] \f$, or \f$[n,n]\f$, for \f$ n \in \mathcal{Z} \f$. The first one is called <em>non-degenerate</em>, while the second one is \a degenerate interval. A <em>boundary of a elementary
*interval</em> is a chain \f$\partial [n,n+1] = [n+1,n+1]-[n,n] \f$ in case of non-degenerate elementary interval and \f$\partial [n,n] = 0 \f$ in case of degenerate elementary interval. An <em>elementary cube</em> \f$ C \f$ is a
@@ -93,7 +93,7 @@ namespace Cubical_complex 5
\endverbatim
-\section Periodic boundary conditions
+\section PeriodicBoundaryConditions Periodic boundary conditions
Often one would like to impose periodic boundary conditions to the cubical complex. Let \f$ I_1\times ... \times I_n \f$ be a box
that is decomposed with a cubical complex \f$ \mathcal{K} \f$. Imposing periodic boundary conditions in the direction i, means that the left and the right side of a complex
\f$ \mathcal{K} \f$ are considered the same. In particular, if for a bitmap \f$ \mathcal{K} \f$ periodic boundary conditions are imposed in all directions, then complex
@@ -106,8 +106,8 @@ in this direction have to be multiplied by -1. For instance: -3
3
1
-2
-3
+4
+6
8
20
4
@@ -118,6 +118,9 @@ in this direction have to be multiplied by -1. For instance: Indicate that we have imposed periodic boundary conditions in the direction x, but not in the direction y.
+ * \section BitmapExamples Examples
+ * End user programs are available in example/Bitmap_cubical_complex folder.
+
*/
/** @} */ // end defgroup cubical_complex
diff --git a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h index 82ea8672..b599a0d9 100644 --- a/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h +++ b/src/Bitmap_cubical_complex/include/gudhi/Bitmap_cubical_complex.h @@ -23,7 +23,7 @@ #pragma once #include <limits> -#include "Bitmap_cubical_complex_base.h"
+#include "Bitmap_cubical_complex_base.h" #include "Bitmap_cubical_complex_periodic_boundary_conditions_base.h" @@ -35,10 +35,15 @@ namespace Cubical_complex { //global variable, was used just for debugging. -const bool globalDbg = false;
-
+const bool globalDbg = false; + template <typename T> class is_before_in_filtration; +/** + *@class Bitmap_cubical_complex + *@brief Cubical complex represented as a bitmap. + *@ingroup cubical_complex + */ template <typename T> class Bitmap_cubical_complex : public T { @@ -47,8 +52,8 @@ public: //Typedefs and typenames //*********************************************// typedef size_t Simplex_key; - typedef typename T::filtration_type Filtration_value;
- typedef Simplex_key Simplex_handle;
+ typedef typename T::filtration_type Filtration_value; + typedef Simplex_key Simplex_handle; //*********************************************// @@ -65,7 +70,7 @@ public: **/ Bitmap_cubical_complex( const char* perseus_style_file ): T(perseus_style_file),key_associated_to_simplex(this->total_number_of_cells+1) - {
+ { //clock_t begin = clock(); if ( globalDbg ){cerr << "Bitmap_cubical_complex( const char* perseus_style_file )\n";} for ( size_t i = 0 ; i != this->total_number_of_cells ; ++i ) @@ -75,7 +80,7 @@ public: //we initialize this only once, in each constructor, when the bitmap is constructed. //If the user decide to change some elements of the bitmap, then this procedure need //to be called again. - this->initialize_simplex_associated_to_key();
+ this->initialize_simplex_associated_to_key(); //cerr << "Time of running Bitmap_cubical_complex( const char* perseus_style_file ) constructor : " << double(clock() - begin) / CLOCKS_PER_SEC << endl; } @@ -97,12 +102,12 @@ public: //If the user decide to change some elements of the bitmap, then this procedure need //to be called again. this->initialize_simplex_associated_to_key(); - }
-
+ } + /** * Constructor that requires vector of elements of type unsigned, which gives number of top dimensional cells * in the following directions and vector of element of a type T::filtration_type - * with filtration on top dimensional cells. The last parameter of the constructor is a vector of bools of a length equal to the dimension of cubical complex.
+ * with filtration on top dimensional cells. The last parameter of the constructor is a vector of bools of a length equal to the dimension of cubical complex. * If the position i on this vector is true, then we impose periodic boundary conditions in this direction. **/ Bitmap_cubical_complex( const std::vector<unsigned>& dimensions , const std::vector<typename T::filtration_type>& top_dimensional_cells , std::vector< bool > directions_in_which_periodic_b_cond_are_to_be_imposed ): @@ -117,7 +122,7 @@ public: //If the user decide to change some elements of the bitmap, then this procedure need //to be called again. this->initialize_simplex_associated_to_key(); - }
+ } //*********************************************// @@ -135,10 +140,10 @@ public: * Returns a Simplex_handle to a cube that do not exist in this complex. **/ static Simplex_handle null_simplex() - {
+ { if ( globalDbg ){cerr << "Simplex_handle null_simplex()\n";} return std::numeric_limits<Simplex_handle>::max(); - }
+ } /** @@ -184,10 +189,10 @@ public: **/ Simplex_key key(Simplex_handle sh)const { - if ( globalDbg ){cerr << "Simplex_key key(const Simplex_handle& sh)\n";}
- if ( sh != std::numeric_limits<Simplex_handle>::max() )
- {
- return this->key_associated_to_simplex[sh];
+ if ( globalDbg ){cerr << "Simplex_key key(const Simplex_handle& sh)\n";} + if ( sh != std::numeric_limits<Simplex_handle>::max() ) + { + return this->key_associated_to_simplex[sh]; } return this->null_key(); } @@ -197,10 +202,10 @@ public: **/ Simplex_handle simplex(Simplex_key key) { - if ( globalDbg ){cerr << "Simplex_handle simplex(Simplex_key key)\n";}
- if ( key != std::numeric_limits<Simplex_handle>::max() )
- {
- return this->simplex_associated_to_key[ key ];
+ if ( globalDbg ){cerr << "Simplex_handle simplex(Simplex_key key)\n";} + if ( key != std::numeric_limits<Simplex_handle>::max() ) + { + return this->simplex_associated_to_key[ key ]; } return null_simplex(); } @@ -210,8 +215,8 @@ public: **/ void assign_key(Simplex_handle sh, Simplex_key key) { - if ( globalDbg ){cerr << "void assign_key(Simplex_handle& sh, Simplex_key key)\n";}
- if ( key == std::numeric_limits<Simplex_handle>::max() ) return;
+ if ( globalDbg ){cerr << "void assign_key(Simplex_handle& sh, Simplex_key key)\n";} + if ( key == std::numeric_limits<Simplex_handle>::max() ) return; this->key_associated_to_simplex[sh] = key; this->simplex_associated_to_key[key] = sh; } @@ -231,10 +236,10 @@ public: /** * Boundary_simplex_range class provides ranges for boundary iterators. - **/
- typedef typename std::vector< Simplex_handle >::iterator Boundary_simplex_iterator;
- typedef typename std::vector< Simplex_handle > Boundary_simplex_range;
-
+ **/ + typedef typename std::vector< Simplex_handle >::iterator Boundary_simplex_iterator; + typedef typename std::vector< Simplex_handle > Boundary_simplex_range; + /** @@ -301,8 +306,8 @@ public: { //Range over the simplices of the complex in the order of the filtration. //.begin() and .end() return type Filtration_simplex_iterator. - public:
- typedef Filtration_simplex_iterator const_iterator;
+ public: + typedef Filtration_simplex_iterator const_iterator; typedef Filtration_simplex_iterator iterator; Filtration_simplex_range(Bitmap_cubical_complex<T>* b):b(b){}; Filtration_simplex_iterator begin() @@ -328,19 +333,19 @@ public: /** * boundary_simplex_range creates an object of a Boundary_simplex_range class * that provides ranges for the Boundary_simplex_iterator. - **/
- Boundary_simplex_range boundary_simplex_range(Simplex_handle sh)
- {
- /*
- std::vector< size_t > bdry = this->get_boundary_of_a_cell(sh);
- Boundary_simplex_range result( bdry.size() );
- for ( size_t i = 0 ; i != bdry.size() ; ++i )
- {
- result[i] = this->simplex_associated_to_key[ bdry[i] ];
- }
- return result;
- */
- return this->get_boundary_of_a_cell(sh);
+ **/ + Boundary_simplex_range boundary_simplex_range(Simplex_handle sh) + { + /* + std::vector< size_t > bdry = this->get_boundary_of_a_cell(sh); + Boundary_simplex_range result( bdry.size() ); + for ( size_t i = 0 ; i != bdry.size() ; ++i ) + { + result[i] = this->simplex_associated_to_key[ bdry[i] ]; + } + return result; + */ + return this->get_boundary_of_a_cell(sh); } /** @@ -463,8 +468,8 @@ public: { //Range over the simplices of the complex in the order of the filtration. //.begin() and .end() return type Filtration_simplex_iterator. - public:
- typedef Skeleton_simplex_iterator const_iterator;
+ public: + typedef Skeleton_simplex_iterator const_iterator; typedef Skeleton_simplex_iterator iterator; Skeleton_simplex_range(Bitmap_cubical_complex<T>* b , unsigned dimension):b(b),dimension(dimension){}; Skeleton_simplex_iterator begin() @@ -500,28 +505,28 @@ protected: std::vector< size_t > key_associated_to_simplex; std::vector< size_t > simplex_associated_to_key; };//Bitmap_cubical_complex -
+ template <typename T> void Bitmap_cubical_complex<T>::initialize_simplex_associated_to_key() { if ( globalDbg ) { cerr << "void Bitmap_cubical_complex<T>::initialize_elements_ordered_according_to_filtration() \n"; - }
- this->simplex_associated_to_key = std::vector<size_t>( this->data.size() );
+ } + this->simplex_associated_to_key = std::vector<size_t>( this->data.size() ); std::iota (std::begin(simplex_associated_to_key), std::end(simplex_associated_to_key), 0); std::sort( simplex_associated_to_key.begin() , simplex_associated_to_key.end() , - is_before_in_filtration<T>(this) );
-
- //we still need to deal here with a key_associated_to_simplex:
- for ( size_t i = 0 ; i != simplex_associated_to_key.size() ; ++i )
- {
- this->key_associated_to_simplex[ simplex_associated_to_key[i] ] = i;
+ is_before_in_filtration<T>(this) ); + + //we still need to deal here with a key_associated_to_simplex: + for ( size_t i = 0 ; i != simplex_associated_to_key.size() ; ++i ) + { + this->key_associated_to_simplex[ simplex_associated_to_key[i] ] = i; } } -
-
+ + template <typename T> class is_before_in_filtration { @@ -560,4 +565,4 @@ protected: } -}
+} |