[cig-commits] r13050 - cs/cigma/trunk/src
luis at geodynamics.org
luis at geodynamics.org
Wed Oct 15 02:07:49 PDT 2008
Author: luis
Date: 2008-10-15 02:07:49 -0700 (Wed, 15 Oct 2008)
New Revision: 13050
Modified:
cs/cigma/trunk/src/Point.h
cs/cigma/trunk/src/Points.cpp
Log:
Add subscript and assignment operators
Modified: cs/cigma/trunk/src/Point.h
===================================================================
--- cs/cigma/trunk/src/Point.h 2008-10-15 09:07:46 UTC (rev 13049)
+++ cs/cigma/trunk/src/Point.h 2008-10-15 09:07:49 UTC (rev 13050)
@@ -26,8 +26,11 @@
void set_coord(float *x, int len);
void zero_out();
+ double& operator[](int i);
double operator[](int i) const;
+ Point<dim>& operator=(const Point<dim>& pt);
+
public:
double coord[dim];
};
@@ -51,6 +54,12 @@
return coord[i];
}
+template <int dim>
+inline double& cigma::Point<dim>::operator[](int i)
+{
+ return coord[i];
+}
+
#endif
Modified: cs/cigma/trunk/src/Points.cpp
===================================================================
--- cs/cigma/trunk/src/Points.cpp 2008-10-15 09:07:46 UTC (rev 13049)
+++ cs/cigma/trunk/src/Points.cpp 2008-10-15 09:07:49 UTC (rev 13050)
@@ -30,6 +30,20 @@
// ----------------------------------------------------------------------------
+template <typename T, int dim>
+Point<dim> Points<T,dim>::get(int i) const
+{
+ Point<dim> pt;
+ for (int j = 0; j < dim; j++)
+ {
+ pt[j] = data[dim*i+j];
+ }
+ return pt;
+}
+
+// ----------------------------------------------------------------------------
+
+
template class cigma::Points<double,3>;
template class cigma::Points<double,2>;
template class cigma::Points<float,3>;
More information about the cig-commits
mailing list