[cig-commits] r13057 - cs/cigma/trunk/src

luis at geodynamics.org luis at geodynamics.org
Wed Oct 15 02:08:00 PDT 2008


Author: luis
Date: 2008-10-15 02:08:00 -0700 (Wed, 15 Oct 2008)
New Revision: 13057

Modified:
   cs/cigma/trunk/src/nc_array.cpp
   cs/cigma/trunk/src/nc_array.h
Log:
Added array implementation of abstract class NodeCoordinates

Modified: cs/cigma/trunk/src/nc_array.cpp
===================================================================
--- cs/cigma/trunk/src/nc_array.cpp	2008-10-15 09:07:58 UTC (rev 13056)
+++ cs/cigma/trunk/src/nc_array.cpp	2008-10-15 09:08:00 UTC (rev 13057)
@@ -0,0 +1,53 @@
+#include "nc_array.h"
+
+using namespace cigma;
+
+nc_array::nc_array()
+{
+    nno = 0;
+    nsd = 0;
+    coords = 0;
+}
+
+nc_array::~nc_array()
+{
+    if (coords != 0)
+    {
+        delete [] coords;
+        coords = 0;
+    }
+}
+
+void nc_array::setCoordinates(double *coords, int nno, int nsd)
+{
+    this->nno = nno;
+    this->nsd = nsd;
+    if (this->coords != 0)
+    {
+        delete [] this->coords;
+    }
+    this->coords = new double[nno*nsd];
+
+    /* Copy data */
+    for (int n = 0; n < nno*nsd; n++)
+    {
+        this->coords[n] = coords[n];
+    }
+}
+
+void nc_array::setCoordinates(float *coords, int nno, int nsd)
+{
+    this->nno = nno;
+    this->nsd = nsd;
+    if (this->coords != 0)
+    {
+        delete [] this->coords;
+    }
+    this->coords = new double[nno*nsd];
+
+    /* Copy data */
+    for (int n = 0; n < nno*nsd; n++)
+    {
+        this->coords[n] = coords[n];
+    }
+}

Modified: cs/cigma/trunk/src/nc_array.h
===================================================================
--- cs/cigma/trunk/src/nc_array.h	2008-10-15 09:07:58 UTC (rev 13056)
+++ cs/cigma/trunk/src/nc_array.h	2008-10-15 09:08:00 UTC (rev 13057)
@@ -1,12 +1,51 @@
 #ifndef __NC_ARRAY_H__
 #define __NC_ARRAY_H__
 
-#include <boost/noncopyable.hpp>
-class nc_array : private boost::noncopyable
+#include "NodeCoordinates.h"
+#include "Locator.h"
+#include "Common.h"
+
+class nc_array : public cigma::NodeCoordinates
 {
+public:
     nc_array();
     ~nc_array();
+
+    int n_points() const;
+    int n_dim() const;
+
+    double getPoint(int i, int j) const;
+    double *getPointOffset(int i);
+
+    void setCoordinates(double *coords, int nno, int nsd);
+    void setCoordinates(float *coords, int nno, int nsd);
+
+public:
+    int nno;
+    int nsd;
+    double *coords;     // XXX: replace double by CoordType
+    cigma::Locator *locator;
 };
 
+inline int nc_array::n_points() const
+{
+    return nno;
+}
+
+inline int nc_array::n_dim() const
+{
+    return nsd;
+}
+
+inline double nc_array::getPoint(int i, int j) const
+{
+    return coords[i*nsd + j];
+}
+
+inline double* nc_array::getPointOffset(int i)
+{
+    return &coords[i*nsd];
+}
+
 #endif
 



More information about the cig-commits mailing list