[cig-commits] r11529 - cs/benchmark/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Mon Mar 24 09:27:23 PDT 2008


Author: luis
Date: 2008-03-24 09:27:22 -0700 (Mon, 24 Mar 2008)
New Revision: 11529

Added:
   cs/benchmark/cigma/trunk/src/PointsReader.cpp
   cs/benchmark/cigma/trunk/src/PointsReader.h
Log:
Added PointsReader class


Added: cs/benchmark/cigma/trunk/src/PointsReader.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/PointsReader.cpp	                        (rev 0)
+++ cs/benchmark/cigma/trunk/src/PointsReader.cpp	2008-03-24 16:27:22 UTC (rev 11529)
@@ -0,0 +1,100 @@
+#include <iostream>
+#include <cstdlib>
+#include <cassert>
+#include "PointsReader.h"
+#include "StringUtils.h"
+
+using namespace std;
+using namespace cigma;
+
+
+// ---------------------------------------------------------------------------
+
+PointsReader::PointsReader()
+{
+    points = 0;
+}
+
+PointsReader::~PointsReader()
+{
+}
+
+
+// ---------------------------------------------------------------------------
+
+void PointsReader::load_args(AnyOption *opt, const char *opt_prefix)
+{
+    assert(opt != 0);
+
+    char *in;
+    string optstr;
+
+    in = opt->getValue("points");
+    if (in != 0)
+    {
+        this->pointsPath = in;
+    }
+}
+
+void PointsReader::validate_args(const char *cmd_name)
+{
+    if (pointsPath == "")
+    {
+        cerr << cmd_name << ": "
+             << "Missing option --points"
+             << endl;
+        exit(1);
+    }
+}
+
+
+// ---------------------------------------------------------------------------
+
+void PointsReader::load_points()
+{
+    int ierr;
+    double *pts;
+    int m,n;
+
+    pts = 0;
+    m = n = 0;
+
+
+    if (pointsPath == "")
+    {
+        return;
+    }
+
+    parse_dataset_path(pointsPath, pointsLoc, pointsFile, pointsExt);
+
+
+    pointsReader = NewReader(pointsExt.c_str());
+
+    if ((pointsLoc == "") && (pointsReader->getType() == Reader::HDF_READER))
+    {
+        pointsLoc = "/points";
+    }
+
+    ierr = pointsReader->open(pointsFile.c_str());
+    if (ierr < 0)
+    {
+        cerr << "Could not open points file " << pointsFile << endl;
+        exit(1);
+    }
+
+    ierr = pointsReader->get_dataset(pointsLoc.c_str(), &pts, &m, &n);
+    if (ierr < 0)
+    {
+        cerr << "Error: Could not open points dataset " << pointsLoc << endl;
+        exit(1);
+    }
+
+    if (pts != 0)
+    {
+        points = new Points();
+        points->set_data(pts, m, n);
+    }
+
+}
+
+// ---------------------------------------------------------------------------

Added: cs/benchmark/cigma/trunk/src/PointsReader.h
===================================================================
--- cs/benchmark/cigma/trunk/src/PointsReader.h	                        (rev 0)
+++ cs/benchmark/cigma/trunk/src/PointsReader.h	2008-03-24 16:27:22 UTC (rev 11529)
@@ -0,0 +1,36 @@
+#ifndef __POINTS_READER_H__
+#define __POINTS_READER_H__
+
+#include <string>
+#include "AnyOption.h"
+#include "Reader.h"
+#include "Points.h"
+
+class PointsReader
+{
+public:
+    PointsReader();
+    ~PointsReader();
+
+public:
+    void load_args(AnyOption *opt, const char *opt_prefix);
+    void validate_args(const char *cmd_name);
+
+public:
+    void load_points();
+
+public:
+    std::string pointsPath;
+    std::string pointsLoc;
+    std::string pointsFile;
+    std::string pointsExt;
+
+public:
+    cigma::Reader *pointsReader;
+
+public:
+    cigma::Points *points;
+
+};
+
+#endif



More information about the cig-commits mailing list