[cig-commits] r8955 - cs/benchmark/cigma/trunk/src/tests

luis at geodynamics.org luis at geodynamics.org
Wed Dec 19 12:07:46 PST 2007


Author: luis
Date: 2007-12-19 12:07:45 -0800 (Wed, 19 Dec 2007)
New Revision: 8955

Added:
   cs/benchmark/cigma/trunk/src/tests/TestNumeric.cpp
Log:
Quick test for some functions in Numeric.h

Added: cs/benchmark/cigma/trunk/src/tests/TestNumeric.cpp
===================================================================
--- cs/benchmark/cigma/trunk/src/tests/TestNumeric.cpp	2007-12-19 20:07:37 UTC (rev 8954)
+++ cs/benchmark/cigma/trunk/src/tests/TestNumeric.cpp	2007-12-19 20:07:45 UTC (rev 8955)
@@ -0,0 +1,49 @@
+#include <iostream>
+#include <cstdlib>
+#include <cassert>
+#include "../TextWriter.h"
+#include "../VtkUgReader.h"
+#include "../Numeric.h"
+using namespace cigma;
+
+int main(void)
+{
+    TextWriter *writer = new TextWriter();
+    writer->fp = stdout;
+
+
+    VtkUgReader *reader = new VtkUgReader();
+    std::string filename = "strikeslip_tet4_1000m_t0.vtk";
+    reader->open(filename);
+
+
+    double *coords;
+    int nno, nsd;
+    reader->get_coordinates(&coords, &nno, &nsd);
+    assert(nsd == 3);
+    std::cout << "coords :: [ " << nno << " x " << nsd << " ]\n";
+    //writer->write_coordinates(coords, 10, nsd);
+
+
+    double min[3],max[3];
+    minmax(coords, nno, nsd, min, max);
+    std::cout << "bbox = ("
+              << "(" << min[0] << ", " << min[1] << ", " << min[2] << "),"
+              << "(" << max[0] << ", " << max[1] << ", " << max[2] << "))"
+              << std::endl;
+    
+    double centroid[3];
+    cigma::centroid(coords, nno, nsd, centroid);
+    std::cout << "centroid = "
+              << "(" << centroid[0] << ", " << centroid[1] << ", " << centroid[2] << ")"
+              << std::endl;
+
+
+    delete reader;
+
+    writer->fp = NULL;
+    delete writer;
+
+
+    return 0;
+}



More information about the cig-commits mailing list