36 #ifndef NEKTAR_LIB_UTILITIES_NEK_POINT_HPP
37 #define NEKTAR_LIB_UTILITIES_NEK_POINT_HPP
39 #include <ExpressionTemplates/ExpressionTemplates.hpp>
45 #include <boost/concept_check.hpp>
46 #include <boost/lexical_cast.hpp>
47 #include <boost/tokenizer.hpp>
48 #include <boost/call_traits.hpp>
49 #include <boost/type_traits.hpp>
50 #include <boost/mpl/or.hpp>
51 #include <boost/mpl/logical.hpp>
52 #include <boost/mpl/assert.hpp>
60 template<
typename data_type>
85 ASSERTL0(result,
"Unable to create a point from a string.");
88 NekPoint(
typename boost::call_traits<DataType>::param_type
x,
89 typename boost::call_traits<DataType>::param_type
y,
90 typename boost::call_traits<DataType>::param_type
z)
97 explicit NekPoint(
typename boost::call_traits<DataType>::const_reference
a)
99 boost::function_requires< Nektar::AssignableConcept<DataType> >();
142 typename boost::call_traits<DataType>::reference
operator()(
unsigned int i)
144 ASSERTL0( (i>=0) && (i<
dim::Value),
"Invalid access to NekPoint data via parenthesis operator: index out of range");
148 typename boost::call_traits<DataType>::const_reference
operator()(
unsigned int i)
const
150 ASSERTL0( (i>=0) && (i<
dim::Value),
"Invalid access to NekPoint data via parenthesis operator: index out of range");
154 typename boost::call_traits<DataType>::reference
operator[](
unsigned int i)
159 typename boost::call_traits<DataType>::const_reference
operator[](
unsigned int i)
const
164 typename boost::call_traits<DataType>::const_reference
x()
const
170 typename boost::call_traits<DataType>::const_reference
y()
const
176 typename boost::call_traits<DataType>::const_reference
z()
const
182 typename boost::call_traits<DataType>::const_reference
a()
const
188 typename boost::call_traits<DataType>::const_reference
b()
const
194 typename boost::call_traits<DataType>::const_reference
c()
const
200 typename boost::call_traits<DataType>::const_reference
r()
const
206 typename boost::call_traits<DataType>::const_reference
s()
const
212 typename boost::call_traits<DataType>::const_reference
t()
const
218 void SetX(
typename boost::call_traits<DataType>::const_reference val)
224 void SetY(
typename boost::call_traits<DataType>::const_reference val)
230 void SetZ(
typename boost::call_traits<DataType>::const_reference val)
236 typename boost::call_traits<DataType>::reference
x()
242 typename boost::call_traits<DataType>::reference
y()
248 typename boost::call_traits<DataType>::reference
z()
275 return !(*
this == rhs);
285 (*this)[i] = -(*this)[i];
354 std::string result =
"(";
357 result += boost::lexical_cast<std::string>(
m_data[i]);
358 if( i < dim::Value-1 )
372 template<
typename DataType>
378 template<
typename DataType>
387 template<
typename DataType>
396 template<
typename DataType>
405 template<
typename DataType>
414 template<
typename DataType>
423 template<
typename DataType>
432 template<
typename DataType,
typename dim,
typename space,
typename ScalarType>
441 template<
typename DataType,
typename dim,
typename space,
typename ScalarType>
450 template<
typename DataType>
459 template<
typename DataType>
463 DataType result = 0.0;
464 for(
unsigned int i = 0; i < 3; ++i)
466 DataType temp = lhs[i] - rhs[i];
472 template<
typename DataType>
477 typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
478 boost::char_separator<char> sep(
"(<,>) ");
479 tokenizer tokens(str, sep);
483 result[i] = boost::lexical_cast<DataType>(*iter);
489 catch(boost::bad_lexical_cast&)
495 template<
typename DataType>
496 std::ostream& operator<<(std::ostream& os, const NekPoint<DataType>&
p)
542 #endif // NEKTAR_LIB_UTILITIES_NEK_POINT_HPP
static unsigned int dimension()
Returns the number of dimensions for the point.
NekPoint< DataType > operator-() const
void SetY(typename boost::call_traits< DataType >::const_reference val)
#define ASSERTL0(condition, msg)
boost::call_traits< DataType >::const_reference y() const
boost::call_traits< DataType >::reference operator()(unsigned int i)
Returns i^{th} element.
boost::call_traits< DataType >::const_reference r() const
NekPoint(const std::string &pointValues)
boost::call_traits< DataType >::value_type distanceBetween(const NekPoint< DataType > &lhs, const NekPoint< DataType > &rhs)
NekPoint< DataType > & operator-=(const NekPoint< DataType > &rhs)
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)
bool operator==(const NekPoint< DataType > &rhs) const
boost::call_traits< DataType >::const_reference operator()(unsigned int i) 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()
boost::call_traits< DataType >::const_reference s() const
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.
boost::call_traits< DataType >::const_reference a() const
NekPoint(typename boost::call_traits< DataType >::const_reference a)
boost::call_traits< DataType >::reference x()
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)
void negate(NekPoint< DataType > &rhs)
NekPoint< DataType > operator*(const ScalarType &lhs, const NekPoint< DataType > &rhs)
boost::call_traits< DataType >::const_reference z() const
boost::call_traits< DataType >::const_reference x() const
NekPoint< DataType > & operator*=(typename boost::call_traits< DataType >::param_type rhs)
Array< OneD, DataType > operator+(const Array< OneD, DataType > &lhs, unsigned int offset)
boost::call_traits< DataType >::const_reference b() const
NekPoint< DataType > operator-(const NekPoint< DataType > &lhs, const NekPoint< DataType > &rhs)
NekPoint< DataType > & operator/=(typename boost::call_traits< DataType >::param_type rhs)
NekPoint< DataType > & operator+=(typename boost::call_traits< DataType >::param_type rhs)
const DataType * GetPtr() const
StandardMatrixTag boost::call_traits< LhsDataType >::const_reference rhs typedef NekMatrix< LhsDataType, StandardMatrixTag >::iterator iterator
boost::call_traits< DataType >::const_reference operator[](unsigned int i) const
boost::call_traits< DataType >::reference z()
void SetX(typename boost::call_traits< DataType >::const_reference val)
DataType m_data[dim::Value]
boost::call_traits< DataType >::const_reference t() const
bool operator!=(const NekPoint< DataType > &rhs) const
std::string AsString() const
boost::call_traits< DataType >::reference operator[](unsigned int i)