35 #ifndef NEKTAR_LIB_UTILITIES_NEK_POINT_HPP 36 #define NEKTAR_LIB_UTILITIES_NEK_POINT_HPP 41 #include <boost/lexical_cast.hpp> 42 #include <boost/tokenizer.hpp> 43 #include <boost/call_traits.hpp> 46 #include <type_traits> 52 template<
typename data_type>
77 ASSERTL0(result,
"Unable to create a point from a string.");
80 NekPoint(
typename boost::call_traits<DataType>::param_type
x,
81 typename boost::call_traits<DataType>::param_type
y,
82 typename boost::call_traits<DataType>::param_type
z)
89 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()(
unsigned int i)
const 143 "Invalid access to NekPoint data via parenthesis " 144 "operator: index out of range");
148 typename boost::call_traits<DataType>::reference
operator[](
unsigned int i)
153 typename boost::call_traits<DataType>::const_reference
operator[](
unsigned int i)
const 158 typename boost::call_traits<DataType>::const_reference
x()
const 160 static_assert(
dim::Value >= 1,
"invalid dimension");
164 typename boost::call_traits<DataType>::const_reference
y()
const 166 static_assert(
dim::Value >= 2,
"invalid dimension");
170 typename boost::call_traits<DataType>::const_reference
z()
const 172 static_assert(
dim::Value >= 3,
"invalid dimension");
176 typename boost::call_traits<DataType>::const_reference
a()
const 178 static_assert(
dim::Value >= 1,
"invalid dimension");
182 typename boost::call_traits<DataType>::const_reference
b()
const 184 static_assert(
dim::Value >= 2,
"invalid dimension");
188 typename boost::call_traits<DataType>::const_reference
c()
const 190 static_assert(
dim::Value >= 3,
"invalid dimension");
194 typename boost::call_traits<DataType>::const_reference
r()
const 196 static_assert(
dim::Value >= 1,
"invalid dimension");
200 typename boost::call_traits<DataType>::const_reference
s()
const 202 static_assert(
dim::Value >= 2,
"invalid dimension");
206 typename boost::call_traits<DataType>::const_reference
t()
const 208 static_assert(
dim::Value >= 3,
"invalid dimension");
212 void SetX(
typename boost::call_traits<DataType>::const_reference val)
214 static_assert(
dim::Value >= 1,
"invalid dimension");
218 void SetY(
typename boost::call_traits<DataType>::const_reference val)
220 static_assert(
dim::Value >= 2,
"invalid dimension");
224 void SetZ(
typename boost::call_traits<DataType>::const_reference val)
226 static_assert(
dim::Value >= 2,
"invalid dimension");
230 typename boost::call_traits<DataType>::reference
x()
232 static_assert(
dim::Value >= 1,
"invalid dimension");
236 typename boost::call_traits<DataType>::reference
y()
238 static_assert(
dim::Value >= 2,
"invalid dimension");
242 typename boost::call_traits<DataType>::reference
z()
244 static_assert(
dim::Value >= 3,
"invalid dimension");
269 return !(*
this ==
rhs);
279 (*this)[i] = -(*this)[i];
348 std::string result =
"(";
351 result += boost::lexical_cast<std::string>(
m_data[i]);
352 if( i < dim::Value-1 )
366 template<
typename DataType>
372 template<
typename DataType>
381 template<
typename DataType>
390 template<
typename DataType>
399 template<
typename DataType>
408 template<
typename DataType>
417 template<
typename DataType>
426 template<
typename DataType,
typename dim,
typename space,
typename ScalarType>
435 template<
typename DataType,
typename dim,
typename space,
typename ScalarType>
444 template<
typename DataType>
453 template<
typename DataType>
458 for(
unsigned int i = 0; i < 3; ++i)
466 template<
typename DataType>
471 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
472 boost::char_separator<char> sep(
"(<,>) ");
473 tokenizer tokens(str, sep);
475 for(tokenizer::iterator iter = tokens.begin(); iter != tokens.end(); ++iter)
477 result[i] = boost::lexical_cast<
DataType>(*iter);
483 catch(boost::bad_lexical_cast&)
489 template<
typename DataType>
490 std::ostream& operator<<(std::ostream& os, const NekPoint<DataType>&
p)
498 #endif // NEKTAR_LIB_UTILITIES_NEK_POINT_HPP boost::call_traits< DataType >::const_reference s() const
static unsigned int dimension()
Returns the number of dimensions for the point.
void SetY(typename boost::call_traits< DataType >::const_reference val)
#define ASSERTL0(condition, msg)
boost::call_traits< DataType >::const_reference a() const
boost::call_traits< DataType >::reference operator()(unsigned int i)
Returns i^{th} element.
NekPoint< DataType > operator-() const
NekPoint(const std::string &pointValues)
boost::call_traits< DataType >::value_type distanceBetween(const NekPoint< DataType > &lhs, const NekPoint< DataType > &rhs)
boost::call_traits< DataType >::const_reference y() const
NekPoint< DataType > & operator-=(const NekPoint< DataType > &rhs)
boost::call_traits< DataType >::const_reference t() const
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)
boost::call_traits< DataType >::const_reference z() const
boost::call_traits< DataType >::const_reference c() const
NekPoint< DataType > & operator+=(const NekPoint< DataType > &rhs)
NekPoint< DataType > & operator=(const NekPoint< DataType > &rhs)
NekPoint(const NekPoint< DataType > &rhs)
boost::call_traits< DataType >::reference y()
NekPoint< DataType > & operator-=(typename boost::call_traits< DataType >::param_type rhs)
bool fromString(const std::string &str, NekPoint< DataType > &result)
static const unsigned int Value
void negate()
Arithmetic Routines.
bool operator==(const NekPoint< DataType > &rhs) const
const DataType * GetPtr() const
NekPoint(typename boost::call_traits< DataType >::const_reference a)
boost::call_traits< DataType >::reference x()
std::string AsString() const
void SetZ(typename boost::call_traits< DataType >::const_reference val)
NekPoint< DataType > operator/(const NekPoint< DataType > &lhs, typename boost::call_traits< DataType >::param_type rhs)
NekVector< DataType > operator*(const NekMatrix< LhsDataType, MatrixType > &lhs, const NekVector< DataType > &rhs)
boost::call_traits< DataType >::const_reference r() const
boost::call_traits< DataType >::const_reference operator()(unsigned int i) const
NekPoint< DataType > & operator*=(typename boost::call_traits< DataType >::param_type rhs)
NekPoint< DataType > & operator/=(typename boost::call_traits< DataType >::param_type rhs)
NekPoint< DataType > & operator+=(typename boost::call_traits< DataType >::param_type rhs)
bool operator!=(const NekPoint< DataType > &rhs) const
boost::call_traits< DataType >::reference z()
void SetX(typename boost::call_traits< DataType >::const_reference val)
boost::call_traits< DataType >::const_reference b() const
DataType m_data[dim::Value]
boost::call_traits< DataType >::const_reference operator[](unsigned int i) const
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs
boost::call_traits< DataType >::const_reference x() const
boost::call_traits< DataType >::reference operator[](unsigned int i)
Array< OneD, DataType > operator+(const Array< OneD, DataType > &lhs, size_t offset)