00001 #ifndef __FIBER_GRID_TYPES_CURVEOPERATORS_HPP
00002 #define __FIBER_GRID_TYPES_CURVEOPERATORS_HPP
00003
00004 #include "LineSet.hpp"
00005 #include <field/OnDemandCreator.hpp>
00006
00007
00008
00009 namespace Fiber
00010 {
00011 namespace Curve
00012 {
00013
00014
00015 struct CurveOperatorData
00016 {
00017 WeakPtr<Grid> theGrid;
00018 const RefPtr<FragmentID>& fragV;
00019
00020 CurveOperatorData(WeakPtr<Grid> theGridP, const RefPtr<FragmentID>& fragVP )
00021 : theGrid( theGridP )
00022 , fragV( fragVP )
00023 {}
00024 };
00025
00037 struct gridtypes_API ArcLength
00038 {
00039 typedef MemArray<1, double> ResultArray_t;
00040
00041 typedef CurveOperatorData Constructor_t;
00042
00043 RefPtr<MemArray<1, double> > Data;
00044
00048
00049 ArcLength(const CurveOperatorData& CurveData, const MemBase::Creator_t&C = MemCore::NullPtr() )
00050 {
00051 #ifdef VERBOSE
00052 puts("ArcLength::ArcLength() >>>>>>>> Computing Arclength, NOW !!!!");
00053 #endif
00054 const LineSet& LS = CurveData.theGrid;
00055
00056 if (!LS)
00057 return;
00058
00059 if (!LS.getCoords( CurveData.fragV ) )
00060 {
00061 puts("ArcLength::ArcLength() Arclength, has no coords found !!!!");
00062 return;
00063 }
00064 Data = new ResultArray_t( LS.getCoords( CurveData.fragV )->nElements(), C);
00065
00066 LS.ApplyOnVertexFragment( *this, CurveData.fragV );
00067 }
00068
00069 ~ArcLength();
00070
00071 RefPtr<ResultArray_t> result() const
00072 {
00073 return Data;
00074 }
00075
00076 void apply(const CreativeIterator<Eagle::PhysicalSpace::point>&Vertices,
00077 const std::vector<LineSet::LineIndex_t>&Line);
00078
00079 };
00080
00081
00093 struct gridtypes_API StepSize
00094 {
00095 typedef MemArray<1, double> ResultArray_t;
00096 typedef CurveOperatorData Constructor_t;
00097
00098 RefPtr<MemArray<1, double> > Data;
00099
00103 StepSize(const CurveOperatorData& CurveData, const MemBase::Creator_t&C = MemCore::NullPtr() )
00104 {
00105 const LineSet& LS = CurveData.theGrid;
00106
00107 if (!LS)
00108 return;
00109
00110 if (!LS.getCoords( CurveData.fragV ) )
00111 return;
00112
00113 Data = new ResultArray_t( LS.getCoords( CurveData.fragV )->nElements(), C);
00114
00115 LS.ApplyOnVertexFragment( *this, CurveData.fragV );
00116 }
00117
00118 ~StepSize();
00119
00120 RefPtr<ResultArray_t> result() const
00121 {
00122 return Data;
00123 }
00124
00125 void apply(const CreativeIterator<Eagle::PhysicalSpace::point>&Vertices,
00126 const std::vector<LineSet::LineIndex_t>&Line);
00127
00128 };
00129
00130
00131
00138 struct gridtypes_API Velocity
00139 {
00140 RefPtr<MemArray<1, Eagle::PhysicalSpace::tvector> > VelocityData;
00141
00142
00143 typedef CurveOperatorData Constructor_t;
00144
00145 Velocity( const CurveOperatorData& CD );
00146
00147 ~Velocity();
00148 };
00149
00150
00151
00156 template <class FieldType>
00157 struct gridtypes_API CurveQuantity : Velocity
00158 {
00159 typedef CurveQuantity CurveQuantity_t;
00160
00161 typedef MemArray<1, FieldType> ResultArray_t;
00162
00163 typedef CurveOperatorData Constructor_t;
00164
00165 RefPtr<ResultArray_t> Data;
00166
00170 CurveQuantity(const CurveOperatorData&CD, const MemBase::Creator_t&C = MemCore::NullPtr() )
00171 : Velocity( CD )
00172 {
00173 const LineSet& LS = CD.theGrid;
00174
00175 if (!LS)
00176 return;
00177
00178 if (!LS.getCoords( CD.fragV ) )
00179 return;
00180
00181 if (!VelocityData)
00182 return;
00183
00184 Data = new ResultArray_t( LS.getCoords( CD.fragV )->nElements(), C);
00185 }
00186
00187 RefPtr<ResultArray_t> result() const
00188 {
00189 return Data;
00190 }
00191
00192
00193
00194
00195 };
00196
00197
00198
00199
00200
00201
00202
00203
00208 struct gridtypes_API Energy : CurveQuantity<double>
00209 {
00210 Energy(const CurveOperatorData&CD, const MemBase::Creator_t&Crec = NullPtr() )
00211 : CurveQuantity_t(CD, Crec)
00212 {
00213 const LineSet& LS = CD.theGrid;
00214
00215 if (!LS)
00216 return;
00217
00218 if (!Data)
00219 return;
00220
00221 LS.ApplyOnVertexFragment( *this, CD.fragV );
00222 }
00223
00224 ~Energy();
00225
00226
00230 void apply(const CreativeIterator<Eagle::PhysicalSpace::point>&Vertices,
00231 const LineSet::LineIndices_t&Line);
00232 };
00233
00234
00235
00248 struct gridtypes_API ProperTime : CurveQuantity<double>
00249 {
00253 ProperTime(const CurveOperatorData&CD, const MemBase::Creator_t&C = MemCore::NullPtr() )
00254 : CurveQuantity_t(CD, C)
00255 {
00256 const LineSet& LS = CD.theGrid;
00257
00258 if (!LS)
00259 return;
00260
00261 if (!Data)
00262 return;
00263
00264 LS.ApplyOnVertexFragment( *this, CD.fragV );
00265 }
00266
00267 ~ProperTime();
00268
00269 void apply(const CreativeIterator<Eagle::PhysicalSpace::point>&Vertices,
00270 const std::vector<LineSet::LineIndex_t>&Line);
00271
00272 };
00273
00274
00275
00280 struct gridtypes_API Acceleration : CurveQuantity<Eagle::PhysicalSpace::tvector>
00281 {
00282
00283 Acceleration(const CurveOperatorData&CD, const MemBase::Creator_t&C = MemCore::NullPtr() )
00284 : CurveQuantity_t(CD, C)
00285 {
00286 const LineSet& LS = CD.theGrid;
00287
00288 if (!LS)
00289 return;
00290
00291 if (!Data)
00292 return;
00293
00294 LS.ApplyOnVertexFragment( *this, CD.fragV );
00295 }
00296
00297 ~Acceleration();
00298
00299 void apply(const CreativeIterator<Eagle::PhysicalSpace::point>&Vertices,
00300 const std::vector<LineSet::LineIndex_t>&Line);
00301
00302 };
00303
00304
00317 struct gridtypes_API Curvature : CurveQuantity<double>
00318 {
00322 Curvature(const CurveOperatorData&CD, const MemBase::Creator_t&C = MemCore::NullPtr() )
00323 : CurveQuantity_t(CD, C)
00324 {
00325 const LineSet& LS = CD.theGrid;
00326
00327 if (!LS)
00328 return;
00329
00330 if (!Data)
00331 return;
00332
00333 LS.ApplyOnVertexFragment( *this, CD.fragV );
00334 }
00335
00336 ~Curvature();
00337
00338
00339 void apply(const CreativeIterator<Eagle::PhysicalSpace::point>&Vertices,
00340 const std::vector<LineSet::LineIndex_t>&Line);
00341
00342 };
00343
00344
00357 struct gridtypes_API Torsion : CurveQuantity<double>
00358 {
00362 Torsion(const CurveOperatorData&CD, const MemBase::Creator_t&C = MemCore::NullPtr() )
00363 : CurveQuantity_t(CD, C)
00364 {
00365 const LineSet& LS = CD.theGrid;
00366
00367 if(!LS)
00368 return;
00369
00370 if (!Data)
00371 return;
00372
00373 LS.ApplyOnVertexFragment( *this );
00374 }
00375
00376 ~Torsion();
00377
00378 void apply(const CreativeIterator<Eagle::PhysicalSpace::point>&Vertices,
00379 const std::vector<LineSet::LineIndex_t>&Line);
00380
00381 };
00382
00383
00384 }
00385
00386 }
00387
00388 #endif // __FIBER_GRID_TYPES_CURVEOPERATORS_HPP
00389