35#ifndef NEKTAR_LIB_UTILITIES_NEK_POINT_HPP
36#define NEKTAR_LIB_UTILITIES_NEK_POINT_HPP
41#include <boost/call_traits.hpp>
42#include <boost/lexical_cast.hpp>
43#include <boost/tokenizer.hpp>
76 ASSERTL0(result,
"Unable to create a point from a string.");
79 NekPoint(
typename boost::call_traits<DataType>::param_type
x,
80 typename boost::call_traits<DataType>::param_type
y,
81 typename boost::call_traits<DataType>::param_type
z)
88 explicit NekPoint(
typename boost::call_traits<DataType>::const_reference
a)
132 typename boost::call_traits<DataType>::reference
operator()(
unsigned int i)
135 "Invalid access to NekPoint data via parenthesis "
136 "operator: index out of range");
140 typename boost::call_traits<DataType>::const_reference
operator()(
141 unsigned int i)
const
144 "Invalid access to NekPoint data via parenthesis "
145 "operator: index out of range");
149 typename boost::call_traits<DataType>::reference
operator[](
unsigned int i)
154 typename boost::call_traits<DataType>::const_reference
operator[](
155 unsigned int i)
const
160 typename boost::call_traits<DataType>::const_reference
x()
const
162 static_assert(
dim::Value >= 1,
"invalid dimension");
166 typename boost::call_traits<DataType>::const_reference
y()
const
168 static_assert(
dim::Value >= 2,
"invalid dimension");
172 typename boost::call_traits<DataType>::const_reference
z()
const
174 static_assert(
dim::Value >= 3,
"invalid dimension");
178 typename boost::call_traits<DataType>::const_reference
a()
const
180 static_assert(
dim::Value >= 1,
"invalid dimension");
184 typename boost::call_traits<DataType>::const_reference
b()
const
186 static_assert(
dim::Value >= 2,
"invalid dimension");
190 typename boost::call_traits<DataType>::const_reference
c()
const
192 static_assert(
dim::Value >= 3,
"invalid dimension");
196 typename boost::call_traits<DataType>::const_reference
r()
const
198 static_assert(
dim::Value >= 1,
"invalid dimension");
202 typename boost::call_traits<DataType>::const_reference
s()
const
204 static_assert(
dim::Value >= 2,
"invalid dimension");
208 typename boost::call_traits<DataType>::const_reference
t()
const
210 static_assert(
dim::Value >= 3,
"invalid dimension");
214 void SetX(
typename boost::call_traits<DataType>::const_reference val)
216 static_assert(
dim::Value >= 1,
"invalid dimension");
220 void SetY(
typename boost::call_traits<DataType>::const_reference val)
222 static_assert(
dim::Value >= 2,
"invalid dimension");
226 void SetZ(
typename boost::call_traits<DataType>::const_reference val)
228 static_assert(
dim::Value >= 2,
"invalid dimension");
232 typename boost::call_traits<DataType>::reference
x()
234 static_assert(
dim::Value >= 1,
"invalid dimension");
238 typename boost::call_traits<DataType>::reference
y()
240 static_assert(
dim::Value >= 2,
"invalid dimension");
244 typename boost::call_traits<DataType>::reference
z()
246 static_assert(
dim::Value >= 3,
"invalid dimension");
271 return !(*
this == rhs);
281 (*this)[i] = -(*this)[i];
302 typename boost::call_traits<DataType>::param_type rhs)
321 typename boost::call_traits<DataType>::param_type rhs)
331 typename boost::call_traits<DataType>::param_type rhs)
341 typename boost::call_traits<DataType>::param_type rhs)
352 std::string result =
"(";
355 result += boost::lexical_cast<std::string>(
m_data[i]);
375template <
typename DataType>
384template <
typename DataType>
386 typename boost::call_traits<DataType>::const_reference lhs,
394template <
typename DataType>
397 typename boost::call_traits<DataType>::const_reference rhs)
404template <
typename DataType>
413template <
typename DataType>
415 typename boost::call_traits<DataType>::const_reference lhs,
423template <
typename DataType>
426 typename boost::call_traits<DataType>::const_reference rhs)
433template <
typename DataType,
typename dim,
typename space,
typename ScalarType>
442template <
typename DataType,
typename dim,
typename space,
typename ScalarType>
444 const ScalarType &rhs)
451template <
typename DataType>
454 typename boost::call_traits<DataType>::param_type rhs)
461template <
typename DataType>
465 DataType result = 0.0;
466 for (
unsigned int i = 0; i < 3; ++i)
468 DataType temp = lhs[i] - rhs[i];
469 result += temp * temp;
474template <
typename DataType>
479 typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
480 boost::char_separator<char> sep(
"(<,>) ");
481 tokenizer tokens(str, sep);
483 for (tokenizer::iterator iter = tokens.begin(); iter != tokens.end();
486 result[i] = boost::lexical_cast<DataType>(*iter);
492 catch (boost::bad_lexical_cast &)
498template <
typename DataType>
#define ASSERTL0(condition, msg)
boost::call_traits< DataType >::reference operator()(unsigned int i)
Returns i^{th} element.
boost::call_traits< DataType >::reference y()
NekPoint< DataType > & operator+=(typename boost::call_traits< DataType >::param_type rhs)
boost::call_traits< DataType >::const_reference t() const
NekPoint< DataType > & operator*=(typename boost::call_traits< DataType >::param_type rhs)
void SetX(typename boost::call_traits< DataType >::const_reference val)
NekPoint< DataType > & operator/=(typename boost::call_traits< DataType >::param_type rhs)
NekPoint(const std::string &pointValues)
NekPoint< DataType > & operator=(const NekPoint< DataType > &rhs)
boost::call_traits< DataType >::const_reference c() const
boost::call_traits< DataType >::const_reference x() const
bool operator!=(const NekPoint< DataType > &rhs) const
boost::call_traits< DataType >::const_reference operator[](unsigned int i) const
boost::call_traits< DataType >::const_reference a() const
NekPoint< DataType > & operator-=(typename boost::call_traits< DataType >::param_type rhs)
bool operator==(const NekPoint< DataType > &rhs) const
boost::call_traits< DataType >::reference z()
NekPoint(typename boost::call_traits< DataType >::const_reference a)
NekPoint(typename boost::call_traits< DataType >::param_type x, typename boost::call_traits< DataType >::param_type y, typename boost::call_traits< DataType >::param_type z)
NekPoint< DataType > & operator-=(const NekPoint< DataType > &rhs)
boost::call_traits< DataType >::const_reference r() const
static unsigned int dimension()
Returns the number of dimensions for the point.
boost::call_traits< DataType >::const_reference z() const
NekPoint< DataType > & operator+=(const NekPoint< DataType > &rhs)
void SetZ(typename boost::call_traits< DataType >::const_reference val)
boost::call_traits< DataType >::reference operator[](unsigned int i)
const DataType * GetPtr() const
boost::call_traits< DataType >::const_reference b() const
std::string AsString() const
boost::call_traits< DataType >::const_reference operator()(unsigned int i) const
boost::call_traits< DataType >::const_reference y() const
DataType m_data[dim::Value]
boost::call_traits< DataType >::const_reference s() const
NekPoint(const NekPoint< DataType > &rhs)
boost::call_traits< DataType >::reference x()
NekPoint< DataType > operator-() const
void SetY(typename boost::call_traits< DataType >::const_reference val)
void negate()
Arithmetic Routines.
NekMatrix< typename NekMatrix< LhsDataType, LhsMatrixType >::NumberType, StandardMatrixTag > operator-(const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const NekMatrix< RhsDataType, RhsMatrixType > &rhs)
void negate(NekPoint< DataType > &rhs)
boost::call_traits< DataType >::value_type distanceBetween(const NekPoint< DataType > &lhs, const NekPoint< DataType > &rhs)
Array< OneD, DataType > operator+(const Array< OneD, DataType > &lhs, typename Array< OneD, DataType >::size_type offset)
NekVector< DataType > operator*(const NekMatrix< LhsDataType, MatrixType > &lhs, const NekVector< DataType > &rhs)
bool fromString(const std::string &str, NekPoint< DataType > &result)
NekPoint< DataType > operator/(const NekPoint< DataType > &lhs, typename boost::call_traits< DataType >::param_type rhs)
std::ostream & operator<<(std::ostream &os, const NekMatrix< DataType, FormType > &rhs)
scalarT< T > sqrt(scalarT< T > in)
static const unsigned int Value