00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __freReferencePointsAccessor_txx
00023 #define __freReferencePointsAccessor_txx
00024
00025 #include "freReferencePointsAccessor.h"
00026
00027 namespace FREE
00028 {
00029
00033 template <unsigned long iDimension>
00034 bool
00035 ReferencePointsAccessor<iDimension>::
00036 FixedPointsExist() const
00037 {
00038 return m_pFixed;
00039 };
00040
00041 template <unsigned long iDimension>
00042 bool
00043 ReferencePointsAccessor<iDimension>::
00044 MovingPointsExist() const
00045 {
00046 return m_pMoving;
00047 };
00048
00049 template <unsigned long iDimension>
00050 typename ReferencePointsAccessor<iDimension>::PointSetType*
00051 ReferencePointsAccessor<iDimension>::
00052 GetFixedPoints()
00053 {
00054 return m_pFixed;
00055 };
00056
00057 template <unsigned long iDimension>
00058 typename ReferencePointsAccessor<iDimension>::PointSetType*
00059 ReferencePointsAccessor<iDimension>::
00060 GetMovingPoints()
00061 {
00062 return m_pMoving;
00063 };
00064
00065 template <unsigned long iDimension>
00066 unsigned long
00067 ReferencePointsAccessor<iDimension>::
00068 GetFixedPointsCount()
00069 {
00070 if (FixedPointsExist()) return m_pFixed->GetNumberOfPoints();
00071 return 0;
00072 };
00073
00074 template <unsigned long iDimension>
00075 unsigned long
00076 ReferencePointsAccessor<iDimension>::
00077 GetMovingPointsCount()
00078 {
00079 if (MovingPointsExist()) return m_pMoving->GetNumberOfPoints();
00080 return 0;
00081 };
00082
00083
00084 template <unsigned long iDimension>
00085 typename ReferencePointsAccessor<iDimension>::PointType
00086 ReferencePointsAccessor<iDimension>::
00087 GetFixedPoint(unsigned long index)
00088 {
00089 PointType result;
00090 if (!FixedPointsExist()) throwExceptionMacro("Cache has no fixed point set. Create one before getting points");
00091 if (!m_pFixed->GetPoint(index,&result)) throwExceptionMacro("Index for fixed point out of bound, cannot convert to array. Index: " <<index);
00092
00093 return result;
00094 };
00095
00096 template <unsigned long iDimension>
00097 void
00098 ReferencePointsAccessor<iDimension>::
00099 SetFixedPoint(unsigned long index, PointType& point)
00100 {
00101 if (!FixedPointsExist()) throwExceptionMacro("Cache has no fixed reference point set. Create one before setting points");
00102
00103 m_pFixed->SetPoint(index,point);
00104 };
00105
00106 template <unsigned long iDimension>
00107 typename ReferencePointsAccessor<iDimension>::PointType
00108 ReferencePointsAccessor<iDimension>::
00109 GetMovingPoint(unsigned long index)
00110 {
00111 PointType result;
00112 if (!MovingPointsExist()) throwExceptionMacro("Cache has no moving point set. Create one before getting points");
00113 if (!m_pMoving->GetPoint(index,&result)) throwExceptionMacro("Index for moving point out of bound, cannot convert to array. Index: " <<index);
00114
00115 return result;
00116 };
00117
00118 template <unsigned long iDimension>
00119 void
00120 ReferencePointsAccessor<iDimension>::
00121 SetMovingPoint(unsigned long index, PointType& point)
00122 {
00123 if (!MovingPointsExist()) throwExceptionMacro("Cache has no moving reference point set. Create one before setting points");
00124
00125 m_pMoving->SetPoint(index,point);
00126 };
00127
00128
00129 template <unsigned long iDimension>
00130 ParameterArrayType
00131 ReferencePointsAccessor<iDimension>::
00132 GetFixedPointArray(unsigned long index)
00133 {
00134 PointType point = GetFixedPoint(index);
00135
00136 ParameterArrayType pointArray(iDimension);
00137 for (unsigned long iPos = 0; iPos<iDimension; iPos++)
00138 {
00139 pointArray.SetElement(iPos, point[iPos]);
00140 }
00141 return pointArray;
00142 };
00143
00144 template <unsigned long iDimension>
00145 void
00146 ReferencePointsAccessor<iDimension>::
00147 SetFixedPointArray(unsigned long index, const ParameterArrayType& point)
00148 {
00149 PointType newPoint;
00150
00151 for (unsigned long iPos = 0; iPos<iDimension; iPos++)
00152 {
00153 newPoint[iPos] = point.GetElement(iPos);
00154 }
00155
00156 SetFixedPoint(newPoint);
00157 };
00158
00159 template <unsigned long iDimension>
00160 ParameterArrayType
00161 ReferencePointsAccessor<iDimension>::
00162 GetMovingPointArray(unsigned long index)
00163 {
00164 PointType point = GetMovingPoint(index);
00165
00166 ParameterArrayType pointArray(iDimension);
00167 for (unsigned long iPos = 0; iPos<iDimension; iPos++)
00168 {
00169 pointArray.SetElement(iPos, point[iPos]);
00170 }
00171 return pointArray;
00172 };
00173
00174 template <unsigned long iDimension>
00175 void
00176 ReferencePointsAccessor<iDimension>::
00177 SetMovingPointArray(unsigned long index, const ParameterArrayType& point)
00178 {
00179 PointType newPoint;
00180
00181 for (unsigned long iPos = 0; iPos<iDimension; iPos++)
00182 {
00183 newPoint[iPos] = point.GetElement(iPos);
00184 }
00185
00186 SetMovingPoint(newPoint);
00187 };
00188
00189 template <unsigned long iDimension>
00190 void
00191 ReferencePointsAccessor<iDimension>::
00192 SetFixedPoints(PointSetType* pPoints)
00193 {
00194 if (pPoints)
00195 {
00196 DirectSessionComponentAccessor::SetRepositoryElement(cParam_FixedReferencePoints,pPoints,m_smpCache);
00197 }
00198 else
00199 {
00200 DirectSessionComponentAccessor::DeleteRepositoryElement(cParam_FixedReferencePoints,m_smpCache);
00201 }
00202 m_pFixed = pPoints;
00203 };
00204
00205
00206 template <unsigned long iDimension>
00207 void
00208 ReferencePointsAccessor<iDimension>::
00209 SetMovingPoints(PointSetType* pPoints)
00210 {
00211 if (pPoints)
00212 {
00213 DirectSessionComponentAccessor::SetRepositoryElement(cParam_MovingReferencePoints,pPoints,m_smpCache);
00214 }
00215 else
00216 {
00217 DirectSessionComponentAccessor::DeleteRepositoryElement(cParam_MovingReferencePoints,m_smpCache);
00218 }
00219 m_pMoving = pPoints;
00220 };
00221
00222
00223 template <unsigned long iDimension>
00224 void
00225 ReferencePointsAccessor<iDimension>::
00226 CreateFixedPointSet()
00227 {
00228 typename PointSetType::Pointer smpPoints = PointSetType::New();
00229 SetFixedPoints(smpPoints);
00230 };
00231
00232 template <unsigned long iDimension>
00233 void
00234 ReferencePointsAccessor<iDimension>::
00235 CreateMovingPointSet()
00236 {
00237 typename PointSetType::Pointer smpPoints = PointSetType::New();
00238 SetMovingPoints(smpPoints);
00239 };
00240
00241 template <unsigned long iDimension>
00242 ReferencePointsAccessor<iDimension>::
00243 ReferencePointsAccessor(SessionComponentCache* pCache)
00244 {
00245 if (!pCache) throwExceptionMacro("Passed cache is illegal (NULL).");
00246
00247 m_smpCache = pCache;
00248
00249 SessionComponentCache::GenericComponentType* pRepElement = DirectSessionComponentAccessor::GetRepositoryElement(cParam_MovingReferencePoints,m_smpCache);
00250
00251 m_pMoving = 0;
00252
00253 if (pRepElement)
00254 {
00255 m_pMoving = dynamic_cast<PointSetType*>(pRepElement);
00256 }
00257
00258 pRepElement = DirectSessionComponentAccessor::GetRepositoryElement(cParam_FixedReferencePoints,m_smpCache);
00259
00260 m_pFixed = 0;
00261
00262 if (pRepElement)
00263 {
00264 m_pFixed = dynamic_cast<PointSetType*>(pRepElement);
00265 }
00266 };
00267
00268 }
00269
00270 #endif