12 int main(
int argc,
char *argv[]){
27 for(
int file_num = 0; file_num < files.size(); file_num++){
28 if( files[file_num] != NULL )
29 delete files[file_num];
42 vector<datafile*> file_pointers;
66 if(file1 == NULL || file2 == NULL){
85 file_pointers.push_back(file1);
86 file_pointers.push_back(file2);
107 std::vector<points*> interp_pts;
109 for(
int i=0;
i<comparison_list.size();
i++){
111 cmp_map curr_comp = comparison_list[
i];
115 cmp_map prev_comp = comparison_list[(
i-1)];
124 for(
int partition_1_num = 0; partition_1_num < curr_comp.
file1_partitions.size(); partition_1_num++){
130 interp_pts.push_back(temp_points);
137 for(
int partition_1_num = 0; partition_1_num < curr_comp.
file1_partitions.size(); partition_1_num++){
143 interp_pts.push_back(temp_points);
150 out_msg =
"ERROR | Interpolation Failed, ";
151 out_msg +=
"Possible Invalid Partition or Variable Argument: \"";
154 for(
int partition_1_num = 0; partition_1_num < curr_comp.
file1_partitions.size(); partition_1_num++){
156 if(partition_1_num != 0)
164 out_msg +=
itoa(curr_comp.
var2) +
"\"";
167 cout << out_msg << endl;
175 metric_outprefix +=
"_part1_";
177 for(
int partition_1_num = 0; partition_1_num < curr_comp.
file1_partitions.size(); partition_1_num++){
179 if(partition_1_num != 0)
180 metric_outprefix +=
"_";
189 interp_pts, curr_comp.
var1, 2,
200 gCmdSwitches.
getLogFile() <<
"ERROR | " <<
"Invalid Metric Number: \"";
203 cout <<
"ERROR | " <<
"Invalid Metric Number: \"";
204 cout << curr_comp.
metric <<
"\"" << endl;
221 gCmdSwitches.
getLogFile() << std::left << msg_out;
222 gCmdSwitches.
getLogFile() << std::right << res <<
"\n";
226 cout << std::left << msg_out;
227 cout << std::right << res <<
"\n";
242 std::vector<points*> datasets;
244 for(
int partition_record = 0; partition_record < rPartitions.size(); partition_record++){
246 datasets.push_back( pFile->
get_points(rPartitions[partition_record]) );
249 datasets.push_back( NULL );
262 for(
int point_num = 0; point_num < pPoints->
get_num_points(); point_num++){
265 for(
int dimension = 0; dimension < curr.
size; dimension++)
266 cout << curr.
vals[dimension] <<
", ";
270 cout << endl <<
"Printed " << pPoints->
get_num_points() <<
" points" << endl;
278 long double sum = 0.0;
281 for(
int point_num = 0; point_num < pPoints->
get_num_points(); point_num++){
283 sum += curr.
vals[rVar];
294 long double min = std::numeric_limits<long double>::infinity();
296 for(
int point_num = 0; point_num < pPoints->
get_num_points(); point_num++){
298 if(curr.
vals[rVar] < min)
299 min = curr.
vals[rVar];
310 long double max = -std::numeric_limits<long double>::infinity();
312 for(
int point_num = 0; point_num < pPoints->
get_num_points(); point_num++){
314 if(curr.
vals[rVar] > max)
315 max = curr.
vals[rVar];
328 if(rErrorMessage.compare(
"") != 0)
329 cout <<
"\n" << rErrorMessage << endl;
330 cout <<
"\n" <<
gUsage << endl;
332 cout <<
"Comparisons are made at the point locations of input file 1" << endl << endl;
334 cout <<
"Valid Filetypes:\n";
338 cout <<
"Metrics:\n";
418 string err_ps(
"Missing Arguments");
441 if( !
mLog.is_open() )
482 std::vector<adj_map> ret;
497 std::vector<adj_map> ret;
569 std::vector< std::vector<int> >
empty;
589 std::vector<index_order>
empty;
600 string opt_string(
"o:1:2:f:i:c:n:m:r:vh");
603 static const struct option long_opts[] = {
604 {
"outfile", required_argument, NULL,
'o'},
605 {
"infile1", required_argument, NULL,
'1'},
606 {
"infile2", required_argument, NULL,
'2'},
607 {
"fieldmap", required_argument, NULL,
'f'},
608 {
"index-order", required_argument, NULL,
'i'},
609 {
"conv", required_argument, NULL,
'c'},
610 {
"norm", required_argument, NULL,
'n'},
611 {
"range", required_argument, NULL,
'r'},
612 {
"metric", required_argument, NULL,
'm'},
613 {
"verbose", no_argument, NULL,
'v'},
614 {
"help", no_argument, NULL,
'h'},
615 {NULL, no_argument, NULL, 0 }
625 const struct option *rLongOpts){
630 opt = getopt_long(
mArgc,
mpArgv, rOptString.c_str(), rLongOpts, NULL );
642 std::vector<string> infile_info =
str_tokenize(
string(optarg),
string(
":"));
644 if(infile_info.size() != 2)
656 std::vector<string> infile_info =
str_tokenize(
string(optarg),
string(
":"));
658 if(infile_info.size() != 2)
670 std::vector<string> field_map =
str_tokenize(
string(optarg),
string(
":/"));
672 if(field_map.size() != 3)
680 field_map[2].compare(
"null") != 0 ){
687 entry.push_back( atoi(field_map[1].c_str()) );
689 if(field_map[2].
compare(
"null") != 0)
690 entry.push_back( atoi(field_map[2].c_str()) );
692 entry.push_back( -1 );
695 switch( atoi(field_map[0].c_str()) ){
714 std::vector<string> order =
str_tokenize(
string(optarg),
string(
":,"));
715 std::vector<int> order_int;
717 if(order.size() <= 0)
723 file_num = atoi(order[0].c_str());
725 if(file_num != 1 && file_num != 2){
731 int partition_num = -1;
733 partition_num = atoi(order[1].c_str());
734 if(partition_num < 0)
738 bool non_numeric =
false;
741 for(
int token_num = 2; token_num < order.size(); token_num++){
746 int value = atoi(order[token_num].c_str());
750 for(
int prev_num = 0; prev_num < order_int.size(); prev_num++){
751 if(value == order_int[prev_num]){
759 order_int.push_back(value);
772 curr_index.
order = order_int;
777 else if(file_num == 2)
784 std::vector<string> conv_info =
str_tokenize(
string(optarg),
string(
":"));
786 if(conv_info.size() != 3)
790 add.
variable = atoi(conv_info[1].c_str());
791 add.
factor = strtold(conv_info[2].c_str(), NULL);
793 int file = atoi(conv_info[0].c_str());
808 std::vector< std::string > conv_info =
str_tokenize( std::string( optarg ), std::string(
"," ) );
813 if( conv_info.size( ) != 6 )
816 double xmin =
std::atof( conv_info[ 0 ].c_str( ) );
817 double ymin =
std::atof( conv_info[ 1 ].c_str( ) );
818 double zmin =
std::atof( conv_info[ 2 ].c_str( ) );
819 double xmax =
std::atof( conv_info[ 3 ].c_str( ) );
820 double ymax =
std::atof( conv_info[ 4 ].c_str( ) );
821 double zmax =
std::atof( conv_info[ 5 ].c_str( ) );
829 std::vector<string> norm_info =
str_tokenize(
string(optarg),
string(
":"));
831 if(norm_info.size() != 3)
835 add.
variable = atoi(norm_info[1].c_str());
836 add.
factor = strtold(norm_info[2].c_str(), NULL);
838 int file = atoi(norm_info[0].c_str());
848 std::vector<string> comp =
str_tokenize(
string(optarg),
string(
"=:/"));
861 bool bad_entry =
false;
864 std::vector<string> partitions_1 =
str_tokenize(
string(comp[1]),
string(
","));
865 std::vector<int> partitions_1_int;
867 for(
int token_num = 0; token_num < partitions_1.size(); token_num++){
874 partitions_1_int.push_back( atoi(partitions_1[token_num].c_str()) );
881 add_cmp.
metric = atoi(comp[0].c_str());
883 add_cmp.
var1 = atoi(comp[2].c_str());
885 add_cmp.
var2 = atoi(comp[4].c_str());
913 opt = getopt_long(
mArgc,
mpArgv, rOptString.c_str(), rLongOpts, NULL );
929 string err_ps(
"Invalid Output File Prefix Specified: Directory may not exist");
941 string err_ps(
"Could Not Open Input File 1: ");
954 string err_ps(
"Could Not Open Input File 2: ");
978 mLog <<
"ARGUMENTS: " << endl;
980 for(
int arg_num=0; arg_num <
mArgc; arg_num++){
984 mLog << endl << endl;
987 mLog <<
"INPUT FILES: " << endl;
992 mLog <<
"RUN OUTPUT:" << endl << flush;
BoundingBox getRange()
Returns a bounding box corresponding to the range of the region of interest.
static datafile * detectFiletype(ifstream &infile, ofstream &outfile, bool loud, string infile_name, int dim, std::vector< std::vector< int > > rFieldMappings, std::vector< index_order > rIndexOrder, std::vector< adj_map > conv_factor, std::vector< adj_map > norm_val)
Use test functions to determine the filetype and to create a new file object for the input file...
void compareFiles(vector< datafile * > pFiles)
Compare the two files, interpolating the points from the second onto the first mesh.
A concrete object that provides the functionality for representing a bounding box geometric primitive...
bool getVerbosity()
Get logging verbosity.
int mInfile2Dimensions
Infile 1 independent variable dimensions.
std::vector< int > file1_partitions
bool restrictToRange
Infile 2 independent variable dimensions.
std::vector< adj_map > mFile1Norm
void setArguments(int rArgc, char *rpArgv[])
Set command line arguments.
void setRange(BoundingBox *rangePtr)
const char * option(const char *const name, const int argc, const char *const *const argv, const char *defaut, const char *const usage=0)
std::vector< adj_map > getNormVal(int rFile)
Get normalization values.
long double maxPoint(points *pPoints, int rVar)
Find the maximum value.
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
Base class for file parsing.
virtual void parse()
Parse the data file.
~ComSwitch()
Free memory, and close open file handles.
boolean empty(T_VertexSet s)
string gUsage("Usage: [--outfile | -o] <output file prefix>\n\t""[--infile1 | -1] <intput file 1 name>:<dimensions>\n\t""[--infile2 | -2] <intput file 2 name>:<dimensions>\n\t""[--fieldmap | -f] <File (1,2)>:<File Dimension>/<Mapped Dimension or \"null\">\n\t""[--index-order | -i] <File (1,2)>:<Partition>:<Dimension 1>,<Dimension 2>,...\n\t""[--conv | -c] <File (1,2)>:<Variable>:<Conversion Factor> \n\t""[--norm | -n] <File (1,2)>:<Variable>:<Normalization Factor> \n\t""[--range | -r] <xmin>,<ymin>,<zmin>,<xmax>,<ymax>,<zmax> \n\t""[--metric | -m] <metric number>=<file 1 partition 1>,<file 1 partition 2>,...:<file 1 variable>/\n\t"" <file 2 partition>:<file 2 variable>\n\t""[--verbose | -v]\n")
std::vector< cmp_map > mComparisonList
Used to store index order information.
long double minPoint(points *pPoints, int rVar)
Find the minimum value.
Used by cmd parser to store comparison information.
ifstream & getInputFile(int rFile)
Get Input File.
std::vector< cmp_map > getComparisonList()
Get Comparison List.
void printUsage(const char *why)
bool isRangeSpecified()
Returns a flag that indicates whether a range was supplied to this instance of CommSwitch.
void print_metrics()
Sample Correlation Coefficient.
std::vector< index_order > mIndexOrderFile2
void setDefaultVars()
Set default member variables.
BoundingBox mRange
Flag used to indicate if the metrics will be restricted to a given range.
float atof(const char *const str)
Read a float number from a C-string.
void setCoordinates(const double x, const double y, const double z, const double X, const double Y, const double Z)
Sets the coordinates of this BoundingBox instance.
bool writeLogHeader()
Write the log file header Program Name - switches Input files.
bool requiredArgsSet()
Check if required arguments are set.
ofstream & getLogFile()
Get Log File.
Point object that represents a single point.
bool mHelp
Help flag is set from command line options.
std::vector< std::vector< int > > mFieldMappingsFile1
string itoa(int n)
Convert an int to a string.
std::vector< points * > retrievePoints(datafile *pFile, vector< int > rPartitions)
Construct a vector of pointers to datasets (point objects) from a list of partition numbers...
std::vector< std::vector< int > > getFieldMappings(int rFile)
Get the field mapping vector for the specified file.
virtual string get_metric_name()
string getFileName(int rFile)
Get File Name.
points * get_points(int partition)
Get a partitions' points.
bool readOptions()
Set option string and long opts struct then parse arguments.
char ** mpArgv
Number of arguments.
int get_num_partitions()
Get number of partition in the file.
int mInfile1Dimensions
Bad command line switch detection.
std::vector< adj_map > mFile2ConversionFactor
long double calcAverageValue(points *pPoints, int rVar)
Calculates the average value of the points.
metric * metric_select(int m, std::vector< points * > dss1, std::vector< points * > dss2, int var_ds1, int var_ds2, ofstream &outfile, string outprefix)
int main(int argc, char *argv[])
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
std::vector< std::vector< int > > mFieldMappingsFile2
static void delete_all(std::vector< points * > points_vector)
vector< datafile * > openAndParseFiles()
Open the files specified at the command line and parse them.
static points * bilinear(points *pTarget, points *pSource, int rTargetVariable, int rSourceVariable)
Performs bilinear interpolation to find values from source mesh at the target points.
std::vector< adj_map > getConvFactor(int rFile)
Get conversion factors.
bool parseOptions()
Parse command options, begin logging.
static bool contains_null(std::vector< points * > points_vector)
ComSwitch()
Default Constructor.
Used to store adjustment (normalization factor, conversion factor) information.
bool same_elements(std::vector< int > vector_1, std::vector< int > vector_2)
CGAL_KERNEL_INLINE Comparison_result compare(const NT &n1, const NT &n2)
std::vector< index_order > getIndexOrder(int rFile)
Get the index order for the specified file.
string getOutPrefix()
Get OutPrefix.
std::vector< adj_map > mFile1ConversionFactor
Range of region of interest.
bool parseValuesFromArguments(string rOptString, const struct option *rLongOpts)
Read and parse options from array.
std::vector< string > str_tokenize(string full, string delimiters)
static void printFiletypes()
Print list valid filetypes to stdout.
std::vector< index_order > mIndexOrderFile1
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation ** files(the"Software")
void printPointValues(points *pPoints)
Write point values to standard out.
std::vector< adj_map > mFile2Norm
bool mBadSwitch
The actual command line arguments.
bool check_non_numeric_str(string test_str)
bool initializeFileStreams()
Initialize file streams.
int getFileDimensions(int rFile)
Get file dimensions.