From 0a0e5ab2231ba91f0f586b8d032c49342381d684 Mon Sep 17 00:00:00 2001 From: "jan.reininghaus" Date: Fri, 3 May 2013 09:43:28 +0000 Subject: new rips filtration builder as addon. depends on Dionysus. Does not work with VC9! git-svn-id: https://phat.googlecode.com/svn/trunk@58 8e3bb3c2-eed4-f18f-5264-0b6c94e6926d --- addons/rips.cpp | 91 +++++++++++++++++ build/Visual Studio/rips/rips.vcxproj | 181 ++++++++++++++++++++++++++++++++++ 2 files changed, 272 insertions(+) create mode 100644 addons/rips.cpp create mode 100644 build/Visual Studio/rips/rips.vcxproj diff --git a/addons/rips.cpp b/addons/rips.cpp new file mode 100644 index 0000000..e562443 --- /dev/null +++ b/addons/rips.cpp @@ -0,0 +1,91 @@ +#include +#include + +#include +#include + +#include // for BackInsertFunctor + +#include + +#include + +typedef PairwiseDistances Pair_distances; +typedef Pair_distances::DistanceType Distance_type; +typedef Pair_distances::IndexType Vertex; + +typedef Rips Generator; +typedef Generator::Simplex Smplx; +typedef Filtration Fltr; + +int main(int argc, char* argv[]) +{ + Dimension skeleton; + Distance_type max_distance; + std::string infilename; + + if(argc<2) { + std::cerr << "Requires inputfile" << std::endl; + std::exit(1); + } + infilename = argv[1]; + + if(argc>=3) { + skeleton=atoi(argv[2]); + if(skeleton==0) { + std::cerr << "# Command line argument 0 ignored" << std::endl; + skeleton=std::numeric_limits::max(); + } + } else { + skeleton=std::numeric_limits::max(); + } + + if(argc>=4) { + max_distance=atof(argv[3]); + } else { + max_distance=std::numeric_limits::max(); + } + + PointContainer points; + read_points(infilename, points); + + Pair_distances distances(points); + Generator rips(distances); + Generator::Evaluator size(distances); + Fltr f; + + // Generate 2-skeleton of the Rips complex for epsilon = 50 + rips.generate(skeleton, max_distance, make_push_back_functor(f)); + std::cerr << "# Generated complex of size: " << f.size() << std::endl; + + // Generate filtration with respect to distance and compute its persistence + f.sort(Generator::Comparison(distances)); + + + std::map simplex_map; + phat::index size_of_simplex_map=0; + + phat::boundary_matrix< phat::vector_vector > boundary_matrix; + boundary_matrix.set_num_cols( f.size() ); + + for(Fltr::Index it=f.begin();it!=f.end();it++) { + phat::column boundary_indices; + const Smplx& c = f.simplex(it); + for(Smplx::BoundaryIterator bit = c.boundary_begin(); bit != c.boundary_end(); bit++) + boundary_indices.push_back( simplex_map[*bit] ); + std::sort(boundary_indices.begin(),boundary_indices.end()); + + boundary_matrix.set_col( size_of_simplex_map, boundary_indices ); + + phat::dimension dim_of_column = boundary_indices.size()==0 ? 0 : boundary_indices.size()-1; + + boundary_matrix.set_dim( size_of_simplex_map, dim_of_column ); + + simplex_map[c] = size_of_simplex_map++; + } + + boundary_matrix.save_binary( "rips.bin" ); + + return 1; + +} diff --git a/build/Visual Studio/rips/rips.vcxproj b/build/Visual Studio/rips/rips.vcxproj new file mode 100644 index 0000000..7bd4cc1 --- /dev/null +++ b/build/Visual Studio/rips/rips.vcxproj @@ -0,0 +1,181 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {56999E92-DC5A-47CC-8044-B981E069F5B7} + rips + Win32Proj + + + + Application + v110 + Unicode + true + + + Application + v110 + Unicode + + + Application + v110 + Unicode + true + + + Application + v110 + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>11.0.50727.1 + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + true + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + true + + + $(SolutionDir)$(Configuration)\ + $(Configuration)\ + false + + + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + false + + + + Disabled + C:\CGAL\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + Level3 + EditAndContinue + + + true + Console + MachineX86 + + + + + X64 + + + Disabled + C:\CGAL\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + Level3 + ProgramDatabase + + + true + Console + MachineX64 + + + + + MaxSpeed + true + C:\CGAL\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + + Level3 + ProgramDatabase + + + true + Console + true + true + MachineX86 + + + + + X64 + + + Full + true + D:\Dionysus-29306411272b\include;c:\boost;$(SolutionDir)\..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + true + false + + Level3 + ProgramDatabase + AnySuitable + Speed + + + boost_chrono-vc90-mt-1_51.lib;libgmp-10.lib;libmpfr-4.lib;%(AdditionalDependencies) + C:\CGAL-4.2\auxiliary\gmp\lib;C:\CGAL-4.2\lib;C:\boost\lib;%(AdditionalLibraryDirectories) + true + Console + true + true + MachineX64 + + + + + + + + + \ No newline at end of file -- cgit v1.2.3