summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Witness_complex/example/CMakeLists.txt10
-rw-r--r--src/Witness_complex/example/example_witness_complex_off.cpp (renamed from src/Witness_complex/example/witness_complex_from_file.cpp)36
-rw-r--r--src/Witness_complex/example/example_witness_complex_sphere.cpp (renamed from src/Witness_complex/example/witness_complex_sphere.cpp)3
-rw-r--r--src/Witness_complex/example/output.h308
-rw-r--r--src/Witness_complex/example/output_tikz.h178
-rw-r--r--src/Witness_complex/test/CMakeLists.txt10
-rw-r--r--src/Witness_complex/test/test_simple_witness_complex.cpp (renamed from src/Witness_complex/test/simple_witness_complex.cpp)35
7 files changed, 28 insertions, 552 deletions
diff --git a/src/Witness_complex/example/CMakeLists.txt b/src/Witness_complex/example/CMakeLists.txt
index 0054775d..469c9aac 100644
--- a/src/Witness_complex/example/CMakeLists.txt
+++ b/src/Witness_complex/example/CMakeLists.txt
@@ -1,17 +1,13 @@
cmake_minimum_required(VERSION 2.6)
project(Witness_complex_examples)
-# A simple example
- add_executable( witness_complex_from_file witness_complex_from_file.cpp )
- add_test( witness_complex_from_bunny ${CMAKE_CURRENT_BINARY_DIR}/witness_complex_from_file ${CMAKE_SOURCE_DIR}/data/points/bunny_5000 100)
if(CGAL_FOUND)
if (NOT CGAL_VERSION VERSION_LESS 4.6.0)
if (EIGEN3_FOUND)
- add_executable ( witness_complex_sphere witness_complex_sphere.cpp )
- target_link_libraries(witness_complex_sphere ${Boost_SYSTEM_LIBRARY} ${CGAL_LIBRARY})
- add_test( witness_complex_sphere_10 ${CMAKE_CURRENT_BINARY_DIR}/witness_complex_sphere 10)
- add_executable ( relaxed_witness_persistence relaxed_witness_persistence.cpp )
+ add_executable( Witness_complex_example_off example_witness_complex_off.cpp )
+ add_executable ( Witness_complex_example_sphere example_witness_complex_sphere.cpp )
+ #add_executable ( relaxed_witness_persistence relaxed_witness_persistence.cpp )
endif(EIGEN3_FOUND)
endif (NOT CGAL_VERSION VERSION_LESS 4.6.0)
endif()
diff --git a/src/Witness_complex/example/witness_complex_from_file.cpp b/src/Witness_complex/example/example_witness_complex_off.cpp
index e5859b2a..6b0060d9 100644
--- a/src/Witness_complex/example/witness_complex_from_file.cpp
+++ b/src/Witness_complex/example/example_witness_complex_off.cpp
@@ -26,7 +26,7 @@
#include <gudhi/Simplex_tree.h>
#include <gudhi/Witness_complex.h>
#include <gudhi/pick_n_random_points.h>
-#include <gudhi/reader_utils.h>
+#include <gudhi/Points_off_io.h>
#include <CGAL/Epick_d.h>
@@ -42,32 +42,6 @@ typedef typename Gudhi::witness_complex::Witness_complex<K> Witness_complex;
typedef std::vector< Vertex_handle > typeVectorVertex;
typedef std::vector< Point_d > Point_vector;
-/**
- * \brief Customized version of read_points
- * which takes into account a possible nbP first line
- *
- */
-inline void
-read_points_cust(std::string file_name, Point_vector & points) {
- std::ifstream in_file(file_name.c_str(), std::ios::in);
- if (!in_file.is_open()) {
- std::cerr << "Unable to open file " << file_name << std::endl;
- return;
- }
- std::string line;
- double x;
- while (getline(in_file, line)) {
- std::vector< double > point;
- std::istringstream iss(line);
- while (iss >> x) {
- point.push_back(x);
- }
- if (point.size() != 1)
- points.push_back(Point_d(point));
- }
- in_file.close();
-}
-
int main(int argc, char * const argv[]) {
if (argc != 4) {
std::cerr << "Usage: " << argv[0]
@@ -85,7 +59,13 @@ int main(int argc, char * const argv[]) {
// Read the point file
Point_vector point_vector, landmarks;
- read_points_cust(file_name, point_vector);
+ Gudhi::Points_off_reader<Point_d> off_reader(file_name);
+ if (!off_reader.is_valid()) {
+ std::cerr << "Witness complex - Unable to read file " << file_name << "\n";
+ exit(-1); // ----- >>
+ }
+ point_vector = Point_vector(off_reader.get_point_cloud());
+
std::cout << "Successfully read " << point_vector.size() << " points.\n";
std::cout << "Ambient dimension is " << point_vector[0].dimension() << ".\n";
diff --git a/src/Witness_complex/example/witness_complex_sphere.cpp b/src/Witness_complex/example/example_witness_complex_sphere.cpp
index fe7f628f..8e2c5ff6 100644
--- a/src/Witness_complex/example/witness_complex_sphere.cpp
+++ b/src/Witness_complex/example/example_witness_complex_sphere.cpp
@@ -27,7 +27,6 @@
#include <gudhi/Simplex_tree.h>
#include <gudhi/Witness_complex.h>
-#include <gudhi/Construct_closest_landmark_table.h>
#include <gudhi/pick_n_random_points.h>
#include <gudhi/reader_utils.h>
@@ -85,7 +84,7 @@ int main(int argc, char * const argv[]) {
landmarks.end(),
point_vector.begin(),
point_vector.end());
- witness_complex.create_complex(simplex_tree, 0.1);
+ witness_complex.create_complex(simplex_tree, 0);
end = clock();
double time = static_cast<double>(end - start) / CLOCKS_PER_SEC;
std::cout << "Witness complex for " << number_of_landmarks << " landmarks took "
diff --git a/src/Witness_complex/example/output.h b/src/Witness_complex/example/output.h
deleted file mode 100644
index d3f534af..00000000
--- a/src/Witness_complex/example/output.h
+++ /dev/null
@@ -1,308 +0,0 @@
-#ifndef OUTPUT_H
-#define OUTPUT_H
-
-#include <fstream>
-#include <vector>
-#include <string>
-
-#include <gudhi/Simplex_tree.h>
-
-#include <CGAL/Epick_d.h>
-#include <CGAL/Delaunay_triangulation.h>
-
-//typename Gudhi::Witness_complex<> Witness_complex;
-
-typedef CGAL::Epick_d<CGAL::Dynamic_dimension_tag> K;
-typedef K::Point_d Point_d;
-typedef std::vector<Point_d> Point_Vector;
-typedef CGAL::Delaunay_triangulation<K> Delaunay_triangulation;
-
-/** \brief Write the table of the nearest landmarks to each witness
- * to a file.
- */
-template <class Value>
-void write_wl( std::string file_name, std::vector< std::vector <Value> > & WL)
-{
- std::ofstream ofs (file_name, std::ofstream::out);
- for (auto w : WL)
- {
- for (auto l: w)
- ofs << l << " ";
- ofs << "\n";
- }
- ofs.close();
-}
-
-/** \brief Write the coordinates of points in points to a file.
- *
- */
-void write_points( std::string file_name, std::vector< Point_d > & points)
-{
- std::ofstream ofs (file_name, std::ofstream::out);
- for (auto w : points)
- {
- for (auto it = w.cartesian_begin(); it != w.cartesian_end(); ++it)
- ofs << *it << " ";
- ofs << "\n";
- }
- ofs.close();
-}
-
-/** Write edges of a witness complex in a file.
- * The format of an edge is coordinates of u \n coordinates of v \n\n\n
- * This format is compatible with gnuplot
- */
-template< typename STree >
-void write_edges(std::string file_name, STree& witness_complex, Point_Vector& landmarks)
-{
- std::ofstream ofs (file_name, std::ofstream::out);
- for (auto u: witness_complex.complex_vertex_range())
- for (auto v: witness_complex.complex_vertex_range())
- {
- std::vector<int> edge = {u,v};
- if (u < v && witness_complex.find(edge) != witness_complex.null_simplex())
- {
- for (auto it = landmarks[u].cartesian_begin(); it != landmarks[u].cartesian_end(); ++it)
- ofs << *it << " ";
- ofs << "\n";
- for (auto it = landmarks[v].cartesian_begin(); it != landmarks[v].cartesian_end(); ++it)
- ofs << *it << " ";
- ofs << "\n\n\n";
- }
- }
- ofs.close();
-}
-
-/** \brief Write triangles (tetrahedra in 3d) of a simplicial complex in a file, compatible with medit.
- * `landmarks_ind` represents the set of landmark indices in W
- * `st` is the Simplex_tree to be visualized,
- * `shr` is the Simplex_handle_range of simplices in `st` to be visualized
- * `is2d` should be true if the simplicial complex is 2d, false if 3d
- * `l_is_v` = landmark is vertex
- */
-template <typename SimplexHandleRange,
- typename STree >
-void write_witness_mesh(Point_Vector& W, std::vector<int>& landmarks_ind, STree& st, SimplexHandleRange const & shr, bool is2d, bool l_is_v, std::string file_name = "witness.mesh")
-{
- std::ofstream ofs (file_name, std::ofstream::out);
- if (is2d)
- ofs << "MeshVersionFormatted 1\nDimension 2\n";
- else
- ofs << "MeshVersionFormatted 1\nDimension 3\n";
-
- if (!l_is_v)
- ofs << "Vertices\n" << W.size() << "\n";
- else
- ofs << "Vertices\n" << landmarks_ind.size() << "\n";
-
- if (l_is_v)
- for (auto p_it : landmarks_ind) {
- for (auto coord = W[p_it].cartesian_begin(); coord != W[p_it].cartesian_end() && coord != W[p_it].cartesian_begin()+3 ; ++coord)
- ofs << *coord << " ";
- ofs << "508\n";
- }
- else
- for (auto p_it : W) {
- for (auto coord = p_it.cartesian_begin(); coord != p_it.cartesian_end() && coord != p_it.cartesian_begin()+3 ; ++coord)
- ofs << *coord << " ";
- ofs << "508\n";
- }
-
- // int num_triangles = W.size(), num_tetrahedra = 0;
- int num_edges = 0, num_triangles = 0, num_tetrahedra = 0;
- if (!l_is_v) {
- for (auto sh_it : shr)
- if (st.dimension(sh_it) == 1)
- num_edges++;
- else if (st.dimension(sh_it) == 2)
- num_triangles++;
- else if (st.dimension(sh_it) == 3)
- num_tetrahedra++;
- ofs << "Edges " << num_edges << "\n";
- for (auto sh_it : shr) {
- if (st.dimension(sh_it) == 1) {
- for (auto v_it : st.simplex_vertex_range(sh_it))
- ofs << landmarks_ind[v_it]+1 << " ";
- ofs << "200\n";
- }
- }
- ofs << "Triangles " << num_triangles << "\n";
- for (unsigned i = 0; i < W.size(); ++i)
- ofs << i << " " << i << " " << i << " " << "508\n";
- for (auto sh_it : shr)
- {
- if (st.dimension(sh_it) == 2) {
- for (auto v_it : st.simplex_vertex_range(sh_it))
- ofs << landmarks_ind[v_it]+1 << " ";
- ofs << "508\n";
- }
- }
- ofs << "Tetrahedra " << num_tetrahedra << "\n";
- for (auto sh_it : shr)
- {
- if (st.dimension(sh_it) == 3) {
- for (auto v_it : st.simplex_vertex_range(sh_it))
- ofs << landmarks_ind[v_it]+1 << " ";
- ofs << "250\n";
- }
- }
- }
- else {
- for (auto sh_it : shr)
- if (st.dimension(sh_it) == 1)
- num_edges++;
- else if (st.dimension(sh_it) == 2)
- num_triangles++;
- else if (st.dimension(sh_it) == 3)
- num_tetrahedra++;
- ofs << "Edges " << num_edges << "\n";
- for (auto sh_it : shr) {
- if (st.dimension(sh_it) == 1) {
- for (auto v_it : st.simplex_vertex_range(sh_it))
- ofs << v_it+1 << " ";
- ofs << "200\n";
- }
- }
- ofs << "Triangles " << num_triangles << "\n";
- for (auto sh_it : shr)
- {
- if (st.dimension(sh_it) == 2) {
- for (auto v_it : st.simplex_vertex_range(sh_it))
- ofs << v_it+1 << " ";
- ofs << "508\n";
- }
- }
- ofs << "Tetrahedra " << num_tetrahedra << "\n";
- for (auto sh_it : shr)
- {
- if (st.dimension(sh_it) == 3) {
- for (auto v_it : st.simplex_vertex_range(sh_it))
- ofs << v_it+1 << " ";
- ofs << "250\n";
- }
- }
- }
-
- ofs << "End\n";
- /*
- else
- {
- ofs << "Tetrahedra " << t.number_of_finite_full_cells()+1 << "\n";
- for (auto fc_it = t.full_cells_begin(); fc_it != t.full_cells_end(); ++fc_it)
- {
- if (t.is_infinite(fc_it))
- continue;
- for (auto vh_it = fc_it->vertices_begin(); vh_it != fc_it->vertices_end(); ++vh_it)
- ofs << index_of_vertex[*vh_it] << " ";
- ofs << "508\n";
- }
- ofs << nbV << " " << nbV << " " << nbV << " " << nbV << " " << 208 << "\n";
- ofs << "End\n";
- }
- */
- ofs.close();
-}
-
-void write_witness_mesh(Point_Vector& W, std::vector<int>& landmarks_ind, Gudhi::Simplex_tree<>& st, bool is2d, bool l_is_v, std::string file_name = "witness.mesh")
-{
- write_witness_mesh(W, landmarks_ind, st, st.complex_simplex_range(), is2d, l_is_v, file_name);
-}
-
-/** \brief Write triangles (tetrahedra in 3d) of a Delaunay
- * triangulation in a file, compatible with medit.
- */
-void write_delaunay_mesh(Delaunay_triangulation& t, const Point_d& p, bool is2d)
-{
- std::ofstream ofs ("delaunay.mesh", std::ofstream::out);
- int nbV = t.number_of_vertices()+1;
- if (is2d)
- ofs << "MeshVersionFormatted 1\nDimension 2\n";
- else
- ofs << "MeshVersionFormatted 1\nDimension 3\n";
- ofs << "Vertices\n" << nbV << "\n";
- int ind = 1; //index of a vertex
- std::map<Delaunay_triangulation::Vertex_handle, int> index_of_vertex;
- for (auto v_it = t.vertices_begin(); v_it != t.vertices_end(); ++v_it)
- {
- if (t.is_infinite(v_it))
- continue;
- // Add maximum 3 coordinates
- for (auto coord = v_it->point().cartesian_begin(); coord != v_it->point().cartesian_end() && coord != v_it->point().cartesian_begin()+3; ++coord)
- ofs << *coord << " ";
- ofs << "508\n";
- index_of_vertex[v_it] = ind++;
- }
- for (auto coord = p.cartesian_begin(); coord != p.cartesian_end(); ++coord)
- ofs << *coord << " ";
- ofs << "208\n";
- if (is2d)
- {
- ofs << "Triangles " << t.number_of_finite_full_cells()+1 << "\n";
- for (auto fc_it = t.full_cells_begin(); fc_it != t.full_cells_end(); ++fc_it)
- {
- if (t.is_infinite(fc_it))
- continue;
- for (auto vh_it = fc_it->vertices_begin(); vh_it != fc_it->vertices_end(); ++vh_it)
- ofs << index_of_vertex[*vh_it] << " ";
- ofs << "508\n";
- }
- ofs << nbV << " " << nbV << " " << nbV << " " << 208 << "\n";
- ofs << "End\n";
- }
- else if (p.size() == 3)
- {
- ofs << "Tetrahedra " << t.number_of_finite_full_cells()+1 << "\n";
- for (auto fc_it = t.full_cells_begin(); fc_it != t.full_cells_end(); ++fc_it)
- {
- if (t.is_infinite(fc_it))
- continue;
- for (auto vh_it = fc_it->vertices_begin(); vh_it != fc_it->vertices_end(); ++vh_it)
- ofs << index_of_vertex[*vh_it] << " ";
- ofs << "508\n";
- }
- ofs << nbV << " " << nbV << " " << nbV << " " << nbV << " " << 208 << "\n";
- ofs << "End\n";
- }
- else if (p.size() == 4)
- {
- ofs << "Tetrahedra " << 5*(t.number_of_finite_full_cells())+1 << "\n";
- for (auto fc_it = t.full_cells_begin(); fc_it != t.full_cells_end(); ++fc_it)
- {
- if (t.is_infinite(fc_it))
- continue;
- for (auto vh_it = fc_it->vertices_begin(); vh_it != fc_it->vertices_end(); ++vh_it)
- {
- for (auto vh_it2 = fc_it->vertices_begin(); vh_it2 != fc_it->vertices_end(); ++vh_it2)
- if (vh_it != vh_it2)
- ofs << index_of_vertex[*vh_it2] << " ";
- ofs << "508\n";
- }
- }
- ofs << nbV << " " << nbV << " " << nbV << " " << nbV << " " << 208 << "\n";
- ofs << "End\n";
- }
- ofs.close();
-}
-
-///////////////////////////////////////////////////////////////////////
-// PRINT VECTOR
-///////////////////////////////////////////////////////////////////////
-
-template <typename T>
-void print_vector(std::vector<T> v)
-{
- std::cout << "[";
- if (!v.empty())
- {
- std::cout << *(v.begin());
- for (auto it = v.begin()+1; it != v.end(); ++it)
- {
- std::cout << ",";
- std::cout << *it;
- }
- }
- std::cout << "]";
-}
-
-
-#endif
diff --git a/src/Witness_complex/example/output_tikz.h b/src/Witness_complex/example/output_tikz.h
deleted file mode 100644
index 281c65b7..00000000
--- a/src/Witness_complex/example/output_tikz.h
+++ /dev/null
@@ -1,178 +0,0 @@
-#ifndef OUTPUT_TIKZ_H
-#define OUTPUT_TIKZ_H
-
-#include <vector>
-#include <string>
-#include <algorithm>
-#include <fstream>
-#include <cmath>
-
-typedef double FT;
-
-
-//////////////////AUX/////////////////////
-
-void write_preamble(std::ofstream& ofs)
-{
- ofs << "\\documentclass{standalone}\n"
- << "\\usepackage{tikz}\n\n"
- << "\\begin{document}\n"
- << "\\begin{tikzpicture}\n";
-}
-
-void write_end(std::ofstream& ofs)
-{
- ofs << "\\end{tikzpicture}\n"
- << "\\end{document}";
-}
-
-
-/////////////////MAIN//////////////////////
-
-void write_tikz_plot(std::vector<FT> data, std::string filename)
-{
- int n = data.size();
- FT vmax = *(std::max_element(data.begin(), data.end()));
- //std::cout << std::log10(vmax) << " " << std::floor(std::log10(vmax));
-
- FT order10 = pow(10,std::floor(std::log10(vmax)));
- int digit = std::floor( vmax / order10) + 1;
- if (digit == 4 || digit == 6) digit = 5;
- if (digit > 6) digit = 10;
- FT plot_max = digit*order10;
- std::cout << plot_max << " " << vmax;
- FT hstep = 10.0/(n-1);
- FT wstep = 10.0 / plot_max;
-
- std::cout << "(eps_max-eps_min)/(N-48) = " << (vmax-*data.begin())/(data.size()-48) << "\n";
- std::ofstream ofs(filename, std::ofstream::out);
-
- ofs <<
- "\\documentclass{standalone}\n" <<
- "\\usepackage[utf8]{inputenc}\n" <<
- "\\usepackage{amsmath}\n" <<
- "\\usepackage{tikz}\n\n" <<
- "\\begin{document}\n" <<
- "\\begin{tikzpicture}\n";
-
- ofs << "\\draw[->] (0,0) -- (0,11);" << std::endl <<
- "\\draw[->] (0,0) -- (11,0);" << std::endl <<
- "\\foreach \\i in {1,...,10}" << std::endl <<
- "\\draw (0,\\i) -- (-0.05,\\i);" << std::endl <<
- "\\foreach \\i in {1,...,10}" << std::endl <<
- "\\draw (\\i,0) -- (\\i,-0.05);" << std::endl << std::endl <<
-
- "\\foreach \\i in {1,...,10}" << std::endl <<
- "\\draw[dashed] (-0.05,\\i) -- (11,\\i);" << std::endl << std::endl <<
-
- "\\node at (-0.5,11) {$*$}; " << std::endl <<
- "\\node at (11,-0.5) {$*$}; " << std::endl <<
- "\\node at (-0.5,-0.5) {0}; " << std::endl <<
- "\\node at (-0.5,10) {" << plot_max << "}; " << std::endl <<
- "%\\node at (10,-0.5) {2}; " << std::endl;
-
- ofs << "\\draw[red] (0," << wstep*data[0] << ")";
- for (int i = 1; i < n; ++i)
- ofs << " -- (" << hstep*i << "," << wstep*data[i] << ")";
- ofs << ";\n";
-
- ofs <<
- "\\end{tikzpicture}\n" <<
- "\\end{document}";
-
- ofs.close();
-}
-
-
-// A little script to make a tikz histogram of epsilon distribution
-// Returns the average epsilon
-void write_histogram(std::vector<double> histo, std::string file_name = "histogram.tikz", std::string xaxis = "$\\epsilon/\\epsilon_{max}$", std::string yaxis = "$\\epsilon$", FT max_x = 1)
-{
- int n = histo.size();
-
- std::ofstream ofs (file_name, std::ofstream::out);
- FT barwidth = 20.0/n;
- FT max_value = *(std::max_element(histo.begin(), histo.end()));
- std::cout << max_value << std::endl;
- FT ten_power = pow(10, ceil(log10(max_value)));
- FT max_histo = ten_power;
- if (max_value/ten_power > 1) {
- if (max_value/ten_power < 2)
- max_histo = 0.2*ten_power;
- else if (max_value/ten_power < 5)
- max_histo = 0.5*ten_power;
- }
- std::cout << ceil(log10(max_value)) << std::endl << max_histo << std::endl;
- FT unitht = max_histo/10.0;
- write_preamble(ofs);
-
- ofs << "\\draw[->] (0,0) -- (0,11);\n" <<
- "\\draw[->] (0,0) -- (21,0);\n" <<
- "\\foreach \\i in {1,...,10}\n" <<
- "\\draw (0,\\i) -- (-0.1,\\i);\n" <<
- "\\foreach \\i in {1,...,20}\n" <<
- "\\draw (\\i,0) -- (\\i,-0.1);\n" <<
-
- "\\node at (-1,11) {" << yaxis << "};\n" <<
- "\\node at (22,-1) {" << xaxis << "};\n" <<
- "\\node at (-0.5,-0.5) {0};\n" <<
- "\\node at (-0.5,10) {" << max_histo << "};\n" <<
- "\\node at (20,-0.5) {" << max_x << "};\n";
-
- for (int i = 0; i < n; ++i)
- ofs << "\\draw (" << barwidth*i << "," << histo[i]/unitht << ") -- ("
- << barwidth*(i+1) << "," << histo[i]/unitht << ") -- ("
- << barwidth*(i+1) << ",0) -- (" << barwidth*i << ",0) -- cycle;\n";
-
- write_end(ofs);
- ofs.close();
-}
-
-struct Pers_interval {
- double alpha_start, alpha_end;
- int dim;
- Pers_interval(double alpha_start_, double alpha_end_, int dim_)
- : alpha_start(alpha_start_), alpha_end(alpha_end_), dim(dim_)
- {}
-};
-
-void write_barcodes(std::string in_file, double alpha2, std::string out_file = "barcodes.tikz.tex")
-{
- std::ifstream ifs(in_file, std::ios::in);
- std::string line;
- std::vector<Pers_interval> pers_intervals;
- while (getline(ifs, line)) {
- int p, dim;
- double alpha_start, alpha_end;
- std::istringstream iss(line);
- iss >> p >> dim >> alpha_start >> alpha_end;
- if (alpha_start != alpha_end) {
- if (alpha_end < alpha_start)
- alpha_end = alpha2;
- pers_intervals.push_back(Pers_interval(alpha_start, alpha_end, dim));
- }
- }
- ifs.close();
- std::ofstream ofs (out_file, std::ofstream::out);
- write_preamble(ofs);
- double barwidth = 0.01;
- int i = 0;
- for (auto interval: pers_intervals) {
- std::string color = "black";
- switch (interval.dim) {
- case 0: color = "orange"; break;
- case 1: color = "red"; break;
- case 2: color = "blue"; break;
- case 3: color = "green"; break;
- case 4: color = "yellow"; break;
- default: color = "orange"; break;
- }
- ofs << "\\fill[" << color << "] (" << interval.alpha_start << "," << barwidth*i << ") rectangle ("
- << interval.alpha_end << "," << barwidth*(i+1) <<");\n";
- i++;
- }
- write_end(ofs);
- ofs.close();
-}
-
-#endif
diff --git a/src/Witness_complex/test/CMakeLists.txt b/src/Witness_complex/test/CMakeLists.txt
index bb55b0f1..751f533c 100644
--- a/src/Witness_complex/test/CMakeLists.txt
+++ b/src/Witness_complex/test/CMakeLists.txt
@@ -10,14 +10,14 @@ if (GPROF_PATH)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
endif()
-add_executable ( simple_witness_complexUT simple_witness_complex.cpp )
-target_link_libraries(simple_witness_complexUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
+add_executable ( Witness_complex_test_simple_witness_complex test_simple_witness_complex.cpp )
+target_link_libraries(Witness_complex_test_simple_witness_complex ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
# Unitary tests definition and xml result file generation
-add_test(NAME simple_witness_complexUT
- COMMAND ${CMAKE_CURRENT_BINARY_DIR}/simple_witness_complexUT
+add_test(NAME simple_witness_complex
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/Witness_complex_test_simple_witness_complex
# XML format for Jenkins xUnit plugin
- --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/simple_witness_complexUT.xml --log_level=test_suite --report_level=no)
+ --log_format=XML --log_sink=${CMAKE_SOURCE_DIR}/Witness_complex_test_simple_witness_complex.xml --log_level=test_suite --report_level=no)
add_executable ( witness_complex_pointsUT witness_complex_points.cpp )
target_link_libraries(witness_complex_pointsUT ${Boost_SYSTEM_LIBRARY} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
diff --git a/src/Witness_complex/test/simple_witness_complex.cpp b/src/Witness_complex/test/test_simple_witness_complex.cpp
index 0c2c3710..abd0a0dd 100644
--- a/src/Witness_complex/test/simple_witness_complex.cpp
+++ b/src/Witness_complex/test/test_simple_witness_complex.cpp
@@ -44,11 +44,11 @@ typedef Gudhi::witness_complex::Witness_complex<Kernel> WitnessComplex;
typedef Gudhi::witness_complex::Strong_witness_complex<Kernel> StrongWitnessComplex;
/* All landmarks and witnesses are taken on the grid in the following manner.
- LWLWL 2W4W7
- WW.WW WW.WW
- L...L 1...6
- WW.WW WW.WW
- LWLWL 0W3W5
+ LWLWL
+ WW.WW
+ L...L
+ WW.WW
+ LWLWL
Witness complex consists of 8 vertices, 12 edges and 4 triangles
*/
@@ -78,39 +78,26 @@ BOOST_AUTO_TEST_CASE(simple_witness_complex) {
witnesses.push_back(Point_d(std::vector<FT>{ 1, 2}));
witnesses.push_back(Point_d(std::vector<FT>{ 2,-1}));
witnesses.push_back(Point_d(std::vector<FT>{ 2, 1}));
-
- // landmarks.push_back(Point_d(std::vector<FT>{1,0}));
- // landmarks.push_back(Point_d(std::vector<FT>{0,0}));
- // landmarks.push_back(Point_d(std::vector<FT>{0,1}));
- // witnesses.push_back(Point_d(std::vector<FT>{1,0}));
WitnessComplex witness_complex(landmarks.begin(),
landmarks.end(),
witnesses.begin(),
witnesses.end());
- // witness_complex.create_complex(complex, 0);
+ witness_complex.create_complex(complex, 0);
- //std::cout << complex << "\n";
+ BOOST_CHECK(complex.num_simplices() == 24);
- // BOOST_CHECK(complex.num_simplices() == 24);
+ witness_complex.create_complex(relaxed_complex, 8.01);
- // witness_complex.create_complex(relaxed_complex, 8.01);
+ BOOST_CHECK(relaxed_complex.num_simplices() == 239);
- // std::cout << "Num_simplices: " << relaxed_complex.num_simplices() << "\n";
- // std::cout << relaxed_complex << "\n";
-
StrongWitnessComplex strong_witness_complex(landmarks.begin(),
landmarks.end(),
witnesses.begin(),
witnesses.end());
strong_witness_complex.create_complex(strong_relaxed_complex, 9.1);
- std::cout << "Num_simplices: " << strong_relaxed_complex.num_simplices() << "\n";
- std::cout << strong_relaxed_complex << "\n";
-
- //BOOST_CHECK(relaxed_complex.num_simplices() == 24);
-
- //BOOST_CHECK(witnessComplex.is_witness_complex(knn, false));
-
+
+ BOOST_CHECK(strong_relaxed_complex.num_simplices() == 239);
}