summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorulrich.bauer@gmail.com <ulrich.bauer@gmail.com@8e3bb3c2-eed4-f18f-5264-0b6c94e6926d>2013-09-13 09:47:41 +0000
committerulrich.bauer@gmail.com <ulrich.bauer@gmail.com@8e3bb3c2-eed4-f18f-5264-0b6c94e6926d>2013-09-13 09:47:41 +0000
commit62f3932fdaa9220abb5873e3305e33a062602633 (patch)
tree727dfa84e46c337f395bad54e3080a167f89d71a /src
parenta46bd27517be340115c34df6c38ceaa25625f0b4 (diff)
convert options: dualize, safe as ascii
git-svn-id: https://phat.googlecode.com/svn/trunk@136 8e3bb3c2-eed4-f18f-5264-0b6c94e6926d
Diffstat (limited to 'src')
-rw-r--r--src/convert.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/convert.cpp b/src/convert.cpp
index ae3304a..69142b9 100644
--- a/src/convert.cpp
+++ b/src/convert.cpp
@@ -19,6 +19,7 @@
#include <phat/representations/vector_vector.h>
#include <phat/boundary_matrix.h>
+#include <phat/helpers/dualize.h>
void print_help() {
std::cerr << "Usage: " << "convert " << "[options] input_filename output_filename" << std::endl;
@@ -27,6 +28,9 @@ void print_help() {
std::cerr << std::endl;
std::cerr << "--ascii -- use ascii file format for input_filename" << std::endl;
std::cerr << "--binary -- use binary file format for input_filename (default)" << std::endl;
+ std::cerr << "--save-ascii -- use ascii file format for output_filename" << std::endl;
+ std::cerr << "--save-binary -- use binary file format for output_filename (default)" << std::endl;
+ std::cerr << "--dualize -- dualize filtration" << std::endl;
std::cerr << "--help -- prints this screen" << std::endl;
}
@@ -35,7 +39,7 @@ void print_help_and_exit() {
exit( EXIT_FAILURE );
}
-void parse_command_line( int argc, char** argv, bool& use_binary, std::string& input_filename, std::string& output_filename) {
+void parse_command_line( int argc, char** argv, bool& use_binary, bool& use_save_binary, bool& use_dualize, std::string& input_filename, std::string& output_filename) {
if( argc < 3 ) print_help_and_exit();
@@ -45,8 +49,11 @@ void parse_command_line( int argc, char** argv, bool& use_binary, std::string& i
for( int idx = 1; idx < argc - 2; idx++ ) {
const std::string option = argv[ idx ];
- if( option == "--ascii" ) use_binary = false;
+ if( option == "--dualize" ) use_dualize = true;
+ else if( option == "--ascii" ) use_binary = false;
else if( option == "--binary" ) use_binary = true;
+ else if( option == "--save-ascii" ) use_save_binary = false;
+ else if( option == "--save-binary" ) use_save_binary = true;
else if( option == "--help" ) print_help_and_exit();
else print_help_and_exit();
}
@@ -55,16 +62,24 @@ void parse_command_line( int argc, char** argv, bool& use_binary, std::string& i
int main( int argc, char** argv )
{
bool use_binary = true; // interpret input as binary or ascii file
+ bool use_save_binary = true; // write output as binary or ascii file
+ bool use_dualize = true; // dualize filtration
std::string input_filename; // name of file that contains the boundary matrix
std::string output_filename; // name of file that will contain the boundary matrix in the new binary format
- parse_command_line( argc, argv, use_binary, input_filename, output_filename );
+ parse_command_line( argc, argv, use_binary, use_save_binary, use_dualize, input_filename, output_filename );
phat::boundary_matrix< phat::bit_tree_pivot_column > matrix;
if( use_binary )
matrix.load_binary( input_filename );
else
matrix.load_ascii( input_filename );
+
+ if( use_dualize )
+ dualize( matrix );
- matrix.save_binary( output_filename );
+ if( use_binary )
+ matrix.save_binary( output_filename );
+ else
+ matrix.save_ascii( output_filename );
}