15 # include <vcl_msvc_warnings.h> 28 } dir_ext_pairs[] = { {
"pgm/",
".pgm"},
43 : start_(-1), step_(-1), end_(-1)
48 : seq_template_(std::move(seq_template)), indices_(std::move(indices)), start_(-1), step_(-1), end_(-1)
54 : seq_template_(std::move(seq_template)), start_(start), step_(step), end_(end)
56 for (
int i=start; i <= end; i+=step)
62 : seq_template_(std::move(seq_template)), start_(-1), step_(step), end_(-1)
95 vul_reg_exp re(
"[,;]([0-9]+)?(:[0-9]+)?:([0-9]+)?$");
96 if (re.
find(temp.c_str()))
98 std::string match_start = re.
match(1);
99 std::string match_step = re.
match(2);
100 std::string match_end = re.
match(3);
102 temp.erase(re.
start(0));
104 if (match_start.length() > 0)
105 start_ = std::atoi(match_start.c_str());
107 if (match_step.length() > 0)
108 step_ = std::atoi(match_step.c_str()+1);
110 if (match_end.length() > 0)
111 end_ = std::atoi(match_end.c_str());
117 if (re.
find(temp.c_str())) {
119 temp.erase(re.
start(0));
126 if (re.
find(temp.c_str())) {
128 temp.erase(re.
start(0));
132 if ( (pos = bt.find(
'%')) != std::string::npos)
134 else if ( (pos = bt.find(
'#')) != std::string::npos) {
135 std::size_t last_pos = bt.rfind(
'#');
153 bool found_match =
false;
156 for (;!found_match && bool(fn); ++fn)
166 std::string glob(dir_ext_pairs[i].
image_dir);
169 for (;!found_match && bool(fn);++fn)
177 std::cerr << __FILE__ <<
" : Can't find files matching " <<
basename_ 178 <<
index_format_ <<
" in common locations with common format!\n";
189 bool found_match =
false;
201 std::string glob(dir_ext_pairs[i].
image_dir); glob +=
"*";
212 std::string glob(dir_ext_pairs[i].
image_dir); glob +=
"*";
222 std::cerr << __FILE__ <<
" : Can't find files matching " <<
basename_ 233 bool found_match =
false;
240 for (;!found_match && bool(fn);++fn)
253 for (;!found_match && bool(fn); ++fn)
263 std::cerr << __FILE__ <<
" : Can't find files matching " <<
image_dir_ 280 max = (index > max) ? index : max;
281 min = (index < min) ? index : min;
284 std::cerr <<
"vul_sequence_filename_map: WARNING: no files in " <<
image_dir_ << std::endl;
297 <<
" basename : " <<
basename_ << std::endl
301 << std::endl << std::endl;
307 for (
int i=0; i < int(
indices_.size()); ++i)
323 s <<
vul_sprintf(
"vul_sequence_filename_map : %s%s%s [%i:%i:%i]",
332 static std::size_t expected_length = 0L;
333 if (expected_length == 0L)
337 std::string name_str(name_string);
339 return name_str.size() == expected_length
346 std::string name_str(name_string);
348 return std::atoi(index_str.c_str());
std::ostream & print(std::ostream &s) const
pretty print.
Pattern matching with regular expressions.
~vul_sequence_filename_map()
Contains class for mapping sequence frame indices to filenames.
bool find(char const *)
true if regexp in char* arg.
char const * filename()
Return the non-directory part of the current pathname.
std::vector< int > indices_
int get_mapped_index(int real) const
returns the frame number corresp. to on-disk index N, or -1 if out-of-range.
int extract_index(char const *name)
class to iterate through directories and/or "glob" patterns (*.
std::ostream & operator<<(std::ostream &os, const vul_sequence_filename_map &s)
std::string name(int frame)
returns frame name with no extension, e.g. "img.003", "img.003.004".
std::string triplet_name(int i, int j, int k)
Iterate through directories and/or "glob" patterns (*.
const int num_dir_ext_pairs
bool filter_dirent(char const *name, std::string const &extension)
contains class for pattern matching with regular expressions
std::string index_format_
std::ptrdiff_t start() const
Returns the start index of the last item found.
vul_sequence_filename_map()
Maps sequence frame indices to filenames.
C++ conforming replacement to the ANSI C functions sprintf and printf.
std::string match(int n) const
Return nth submatch as a string.
std::string pair_name(int i, int j)
std::string image_extension_
creates a formatted ANSI C++ string
std::string seq_template_