[cig-commits] r9307 - cs/benchmark/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Feb 13 10:28:31 PST 2008
Author: luis
Date: 2008-02-13 10:28:30 -0800 (Wed, 13 Feb 2008)
New Revision: 9307
Modified:
cs/benchmark/cigma/trunk/src/CompareCmd.cpp
cs/benchmark/cigma/trunk/src/MeshIO.cpp
cs/benchmark/cigma/trunk/src/MeshIO.h
Log:
Improvements to MeshIO
Modified: cs/benchmark/cigma/trunk/src/CompareCmd.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/CompareCmd.cpp 2008-02-13 16:10:03 UTC (rev 9306)
+++ cs/benchmark/cigma/trunk/src/CompareCmd.cpp 2008-02-13 18:28:30 UTC (rev 9307)
@@ -151,6 +151,11 @@
residualsIO.field_path = "foo.vtk";
}
+ if (residualsIO.field_path == "")
+ {
+ cerr << "compare: Please specify the option --output" << endl;
+ exit(1);
+ }
if (firstIO.field_path == "")
{
cerr << "compare: Please specify the option --first" << endl;
@@ -161,11 +166,7 @@
cerr << "compare: Please specify the option --second" << endl;
exit(1);
}
- if (residualsIO.field_path == "")
- {
- cerr << "compare: Please specify the option --output" << endl;
- exit(1);
- }
+ validate_args(&meshIO, "compare");
/* Load the datasets into memory */
@@ -241,6 +242,7 @@
if (output_frequency == 0)
{
+ // XXX: emit warning?
verbose = false;
}
Modified: cs/benchmark/cigma/trunk/src/MeshIO.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/MeshIO.cpp 2008-02-13 16:10:03 UTC (rev 9306)
+++ cs/benchmark/cigma/trunk/src/MeshIO.cpp 2008-02-13 18:28:30 UTC (rev 9307)
@@ -1,4 +1,5 @@
#include <iostream>
+#include <cstdlib>
#include "MeshIO.h"
#include "StringUtils.h"
@@ -37,8 +38,66 @@
}
}
+void validate_args(MeshIO *meshIO, const char *cmd_name)
+{
+ assert(meshIO != 0);
+
+ if (meshIO->has_paths())
+ {
+ if (meshIO->mesh_path == "")
+ {
+ if (meshIO->coords_path == "")
+ {
+ cerr << cmd_name
+ << ": Detected missing option --mesh-coordinates"
+ << endl;
+
+ exit(1);
+ }
+ if (meshIO->connect_path == "")
+ {
+ cerr << cmd_name
+ << ": Detected missing option --mesh-connectivity"
+ << endl;
+
+ exit(1);
+ }
+ }
+ }
+}
+
// ---------------------------------------------------------------------------
+
+bool MeshIO::has_paths()
+{
+ return (mesh_path != "") || (coords_path != "") || (connect_path != "");
+}
+
+bool MeshIO::has_coords_path()
+{
+ return (mesh_path != "") || (coords_path != "");
+}
+
+bool MeshIO::has_connect_path()
+{
+ return (mesh_path != "") || (connect_path != "");
+}
+
+bool MeshIO::has_valid_paths()
+{
+ // empty state is also valid
+ if (!has_paths())
+ {
+ return true;
+ }
+
+ // require both coords and connect paths if mesh path is absent
+ return (mesh_path != "") || ((coords_path != "") && (connect_path != ""));
+}
+
+// ---------------------------------------------------------------------------
+
MeshIO::MeshIO()
{
meshPart = 0;
@@ -58,10 +117,16 @@
{
cout << "Calling MeshIO::load()" << endl;
- string mesh_loc, mesh_file, mesh_ext;
- string coords_loc, coords_file, coords_ext;
- string connect_loc, connect_file, connect_ext;
+ // skip this method if paths are empty
+ if (!has_paths())
+ {
+ return;
+ }
+ //string mesh_loc, mesh_file, mesh_ext;
+ //string coords_loc, coords_file, coords_ext;
+ //string connect_loc, connect_file, connect_ext;
+
int nno, nsd;
double *coords = 0;
@@ -71,6 +136,13 @@
nno = nsd = 0;
nel = ndofs = 0;
+
+ //
+ // Note that each of coords_path and connect_path will override
+ // the corresponding component of mesh_path
+ //
+
+
// XXX: use auto_ptr for the local readers, so we can throw exceptions
if (coords_path != "")
{
Modified: cs/benchmark/cigma/trunk/src/MeshIO.h
===================================================================
--- cs/benchmark/cigma/trunk/src/MeshIO.h 2008-02-13 16:10:03 UTC (rev 9306)
+++ cs/benchmark/cigma/trunk/src/MeshIO.h 2008-02-13 18:28:30 UTC (rev 9307)
@@ -10,25 +10,40 @@
class MeshIO
{
public:
- cigma::Reader *reader;
- cigma::Writer *writer;
-
-public:
std::string mesh_path;
std::string coords_path;
std::string connect_path;
+
+public:
+ std::string mesh_loc, mesh_file, mesh_ext;
+ std::string coords_loc, coords_file, coords_ext;
+ std::string connect_loc, connect_file, connect_ext;
+
+public:
+ cigma::Reader *reader;
+ cigma::Writer *writer;
cigma::MeshPart *meshPart;
public:
MeshIO();
~MeshIO();
+
+public:
+ void prepare();
void load();
void save();
+public:
+ bool has_paths();
+ bool has_coords_path();
+ bool has_connect_path();
+ bool has_valid_paths();
};
+
void configure_mesh(AnyOption *opt, MeshIO *meshIO, const char *opt_prefix);
+void validate_args(MeshIO *meshIO, const char *cmd_name);
#endif
More information about the cig-commits
mailing list