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