1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
7 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
13 * This library is free software; you can redistribute it and/or modify it *
14 * under the terms of the GNU Library General Public License as published *
15 * by the Free Software Foundation, version 2. *
17 * This library is distributed in the hope that it will be useful, but *
18 * WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
20 * Library General Public License for more details. *
22 * You should have received a copy of the GNU Library General Public *
23 * License along with this library; if not, write to the Free Software *
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
35 \*---------------------------------------------------------------------------*/
37 //---------------------------------------------------------------------------
39 //---------------------------------------------------------------------------
47 template <class ValueTypeT>
48 inline typename detail::NoNormalizationFunc<ValueTypeT>::ValueType
49 detail::NoNormalizationFunc<ValueTypeT>::apply(
50 const ValueType& src, const Real64, const Real64)
55 template <class ValueTypeT>
56 inline typename detail::InNormalizationFunc<ValueTypeT>::ValueType
57 detail::InNormalizationFunc<ValueTypeT>::apply(
58 const ValueType& src, const Real64 scale, const Real64 offset)
60 return static_cast<ValueType>((scale * src) + offset);
63 template <class ValueTypeT>
64 inline typename detail::OutNormalizationFunc<ValueTypeT>::ValueType
65 detail::OutNormalizationFunc<ValueTypeT>::apply(
66 const ValueType& src, const Real64 scale, const Real64 offset)
68 return static_cast<ValueType>((src - offset) / scale);
75 template <class ValueTypeT>
76 inline typename detail::VectorElementAccessFunc<ValueTypeT>::ElementType
77 detail::VectorElementAccessFunc<ValueTypeT>::apply(
78 const ValueType& src, const UInt32 index)
83 template <class ValueTypeT>
84 inline typename detail::Fixed32VectorElementAccessFunc<ValueTypeT>::ElementType
85 detail::Fixed32VectorElementAccessFunc<ValueTypeT>::apply(
86 const ValueType& src, const UInt32 index)
88 return src[index].getValue();
95 template <class DestTypeT,
97 template <class> class NormalizeFuncT,
98 template <class> class ElementAccessFuncT>
100 detail::GeoConvertFunc<DestTypeT,
103 ElementAccessFuncT>::convert(
104 DestType& dest, const SourceType& src,
105 const Real64 scale, const Real64 offset)
107 if(SourceType::_uiSize >= DestType::_uiSize)
110 for(i = 0; i < DestType::_uiSize; ++i)
112 dest[i] = static_cast<DestElementType>(
113 NormFunc::apply(AccessFunc::apply(src, i), scale, offset));
119 for(i = 0; i < SourceType::_uiSize; ++i)
121 dest[i] = static_cast<DestElementType>(
122 NormFunc::apply(AccessFunc::apply(src, i), scale, offset));
125 for(; i < DestType::_uiSize; ++i)
127 dest[i] = static_cast<DestElementType>(
129 AccessFunc::apply(SourceType::Null, i), scale, offset));
134 template <class ValueTypeT,
135 template <class> class ElementAccessFuncT>
137 detail::GeoConvertFunc<ValueTypeT,
139 detail::NoNormalizationFunc,
140 ElementAccessFuncT >::convert(
141 DestType& dest, const SourceType& src,
142 const Real64 scale, const Real64 offset)