00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #include <cstdlib>
00054 #include <cstdio>
00055 #include <boost/assign/list_of.hpp>
00056
00057 #include "OSGConfig.h"
00058
00059
00060
00061 #include "OSGAlgorithm.h"
00062
00063 #include "OSGAlgorithmStageBase.h"
00064 #include "OSGAlgorithmStage.h"
00065
00066 #include <boost/bind.hpp>
00067
00068 #ifdef WIN32 // turn off 'this' : used in base member initializer list warning
00069 #pragma warning(disable:4355)
00070 #endif
00071
00072 OSG_BEGIN_NAMESPACE
00073
00074
00075
00076
00077
00082
00083
00084
00085
00103
00104
00105
00106
00107 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
00108 DataType FieldTraits<AlgorithmStage *>::_type("AlgorithmStagePtr", "StagePtr");
00109 #endif
00110
00111 OSG_FIELDTRAITS_GETTYPE(AlgorithmStage *)
00112
00113
00114
00115
00116
00117 void AlgorithmStageBase::classDescInserter(TypeObject &oType)
00118 {
00119 FieldDescriptionBase *pDesc = NULL;
00120
00121
00122 pDesc = new SFUnrecAlgorithmPtr::Description(
00123 SFUnrecAlgorithmPtr::getClassType(),
00124 "algorithm",
00125 "",
00126 AlgorithmFieldId, AlgorithmFieldMask,
00127 false,
00128 (Field::SFDefaultFlags | Field::FStdAccess),
00129 static_cast<FieldEditMethodSig>(&AlgorithmStage::editHandleAlgorithm),
00130 static_cast<FieldGetMethodSig >(&AlgorithmStage::getHandleAlgorithm));
00131
00132 oType.addInitialDesc(pDesc);
00133
00134 pDesc = new SFUInt32::Description(
00135 SFUInt32::getClassType(),
00136 "projectionMode",
00137 "",
00138 ProjectionModeFieldId, ProjectionModeFieldMask,
00139 false,
00140 (Field::SFDefaultFlags | Field::FStdAccess),
00141 static_cast<FieldEditMethodSig>(&AlgorithmStage::editHandleProjectionMode),
00142 static_cast<FieldGetMethodSig >(&AlgorithmStage::getHandleProjectionMode));
00143
00144 oType.addInitialDesc(pDesc);
00145
00146 pDesc = new SFBool::Description(
00147 SFBool::getClassType(),
00148 "copyViewing",
00149 "",
00150 CopyViewingFieldId, CopyViewingFieldMask,
00151 false,
00152 (Field::SFDefaultFlags | Field::FStdAccess),
00153 static_cast<FieldEditMethodSig>(&AlgorithmStage::editHandleCopyViewing),
00154 static_cast<FieldGetMethodSig >(&AlgorithmStage::getHandleCopyViewing));
00155
00156 oType.addInitialDesc(pDesc);
00157
00158 pDesc = new SFMatrix::Description(
00159 SFMatrix::getClassType(),
00160 "projectionMatrix",
00161 "",
00162 ProjectionMatrixFieldId, ProjectionMatrixFieldMask,
00163 false,
00164 (Field::SFDefaultFlags | Field::FStdAccess),
00165 static_cast<FieldEditMethodSig>(&AlgorithmStage::editHandleProjectionMatrix),
00166 static_cast<FieldGetMethodSig >(&AlgorithmStage::getHandleProjectionMatrix));
00167
00168 oType.addInitialDesc(pDesc);
00169 }
00170
00171
00172 AlgorithmStageBase::TypeObject AlgorithmStageBase::_type(
00173 AlgorithmStageBase::getClassname(),
00174 Inherited::getClassname(),
00175 "NULL",
00176 0,
00177 reinterpret_cast<PrototypeCreateF>(&AlgorithmStageBase::createEmptyLocal),
00178 AlgorithmStage::initMethod,
00179 AlgorithmStage::exitMethod,
00180 reinterpret_cast<InitalInsertDescFunc>(&AlgorithmStage::classDescInserter),
00181 false,
00182 0,
00183 "<?xml version=\"1.0\"?>\n"
00184 "\n"
00185 "<FieldContainer\n"
00186 "\tname=\"AlgorithmStage\"\n"
00187 "\tparent=\"Stage\"\n"
00188 "\tlibrary=\"Group\"\n"
00189 "\tpointerfieldtypes=\"none\"\n"
00190 "\tstructure=\"concrete\"\n"
00191 "\tsystemcomponent=\"true\"\n"
00192 "\tparentsystemcomponent=\"true\"\n"
00193 "\tdecoratable=\"false\"\n"
00194 "\tuseLocalIncludes=\"false\"\n"
00195 " isNodeCore=\"true\"\n"
00196 ">\n"
00197 "\t<Field\n"
00198 "\t\tname=\"algorithm\"\n"
00199 "\t\ttype=\"AlgorithmPtr\"\n"
00200 "\t\tcardinality=\"single\"\n"
00201 "\t\tvisibility=\"external\"\n"
00202 "\t\tdefaultValue=\"NULL\"\n"
00203 "\t\taccess=\"public\"\n"
00204 "\t>\n"
00205 "\t</Field>\n"
00206 "\t<Field\n"
00207 "\t\tname=\"projectionMode\"\n"
00208 "\t\ttype=\"UInt32\"\n"
00209 "\t\tcardinality=\"single\"\n"
00210 "\t\tvisibility=\"external\"\n"
00211 "\t\tdefaultValue=\"0x0001\"\n"
00212 "\t\taccess=\"public\"\n"
00213 "\t>\n"
00214 "\t</Field>\n"
00215 "\t<Field\n"
00216 "\t\tname=\"copyViewing\"\n"
00217 "\t\ttype=\"bool\"\n"
00218 "\t\tcardinality=\"single\"\n"
00219 "\t\tvisibility=\"external\"\n"
00220 "\t\tdefaultValue=\"false\"\n"
00221 "\t\taccess=\"public\"\n"
00222 "\t>\n"
00223 "\t</Field>\n"
00224 "\t<Field\n"
00225 "\t\tname=\"projectionMatrix\"\n"
00226 "\t\ttype=\"Matrix\"\n"
00227 "\t\tcardinality=\"single\"\n"
00228 "\t\tvisibility=\"external\"\n"
00229 "\t\tdefaultValue=\"\"\n"
00230 "\t\taccess=\"public\"\n"
00231 "\t>\n"
00232 "\t</Field>\n"
00233 "</FieldContainer>\n",
00234 ""
00235 );
00236
00237
00238
00239 FieldContainerType &AlgorithmStageBase::getType(void)
00240 {
00241 return _type;
00242 }
00243
00244 const FieldContainerType &AlgorithmStageBase::getType(void) const
00245 {
00246 return _type;
00247 }
00248
00249 UInt32 AlgorithmStageBase::getContainerSize(void) const
00250 {
00251 return sizeof(AlgorithmStage);
00252 }
00253
00254
00255
00256
00258 const SFUnrecAlgorithmPtr *AlgorithmStageBase::getSFAlgorithm(void) const
00259 {
00260 return &_sfAlgorithm;
00261 }
00262
00263 SFUnrecAlgorithmPtr *AlgorithmStageBase::editSFAlgorithm (void)
00264 {
00265 editSField(AlgorithmFieldMask);
00266
00267 return &_sfAlgorithm;
00268 }
00269
00270 SFUInt32 *AlgorithmStageBase::editSFProjectionMode(void)
00271 {
00272 editSField(ProjectionModeFieldMask);
00273
00274 return &_sfProjectionMode;
00275 }
00276
00277 const SFUInt32 *AlgorithmStageBase::getSFProjectionMode(void) const
00278 {
00279 return &_sfProjectionMode;
00280 }
00281
00282
00283 SFBool *AlgorithmStageBase::editSFCopyViewing(void)
00284 {
00285 editSField(CopyViewingFieldMask);
00286
00287 return &_sfCopyViewing;
00288 }
00289
00290 const SFBool *AlgorithmStageBase::getSFCopyViewing(void) const
00291 {
00292 return &_sfCopyViewing;
00293 }
00294
00295
00296 SFMatrix *AlgorithmStageBase::editSFProjectionMatrix(void)
00297 {
00298 editSField(ProjectionMatrixFieldMask);
00299
00300 return &_sfProjectionMatrix;
00301 }
00302
00303 const SFMatrix *AlgorithmStageBase::getSFProjectionMatrix(void) const
00304 {
00305 return &_sfProjectionMatrix;
00306 }
00307
00308
00309
00310
00311
00312
00313
00314
00315 UInt32 AlgorithmStageBase::getBinSize(ConstFieldMaskArg whichField)
00316 {
00317 UInt32 returnValue = Inherited::getBinSize(whichField);
00318
00319 if(FieldBits::NoField != (AlgorithmFieldMask & whichField))
00320 {
00321 returnValue += _sfAlgorithm.getBinSize();
00322 }
00323 if(FieldBits::NoField != (ProjectionModeFieldMask & whichField))
00324 {
00325 returnValue += _sfProjectionMode.getBinSize();
00326 }
00327 if(FieldBits::NoField != (CopyViewingFieldMask & whichField))
00328 {
00329 returnValue += _sfCopyViewing.getBinSize();
00330 }
00331 if(FieldBits::NoField != (ProjectionMatrixFieldMask & whichField))
00332 {
00333 returnValue += _sfProjectionMatrix.getBinSize();
00334 }
00335
00336 return returnValue;
00337 }
00338
00339 void AlgorithmStageBase::copyToBin(BinaryDataHandler &pMem,
00340 ConstFieldMaskArg whichField)
00341 {
00342 Inherited::copyToBin(pMem, whichField);
00343
00344 if(FieldBits::NoField != (AlgorithmFieldMask & whichField))
00345 {
00346 _sfAlgorithm.copyToBin(pMem);
00347 }
00348 if(FieldBits::NoField != (ProjectionModeFieldMask & whichField))
00349 {
00350 _sfProjectionMode.copyToBin(pMem);
00351 }
00352 if(FieldBits::NoField != (CopyViewingFieldMask & whichField))
00353 {
00354 _sfCopyViewing.copyToBin(pMem);
00355 }
00356 if(FieldBits::NoField != (ProjectionMatrixFieldMask & whichField))
00357 {
00358 _sfProjectionMatrix.copyToBin(pMem);
00359 }
00360 }
00361
00362 void AlgorithmStageBase::copyFromBin(BinaryDataHandler &pMem,
00363 ConstFieldMaskArg whichField)
00364 {
00365 Inherited::copyFromBin(pMem, whichField);
00366
00367 if(FieldBits::NoField != (AlgorithmFieldMask & whichField))
00368 {
00369 _sfAlgorithm.copyFromBin(pMem);
00370 }
00371 if(FieldBits::NoField != (ProjectionModeFieldMask & whichField))
00372 {
00373 _sfProjectionMode.copyFromBin(pMem);
00374 }
00375 if(FieldBits::NoField != (CopyViewingFieldMask & whichField))
00376 {
00377 _sfCopyViewing.copyFromBin(pMem);
00378 }
00379 if(FieldBits::NoField != (ProjectionMatrixFieldMask & whichField))
00380 {
00381 _sfProjectionMatrix.copyFromBin(pMem);
00382 }
00383 }
00384
00386 AlgorithmStageTransitPtr AlgorithmStageBase::createLocal(BitVector bFlags)
00387 {
00388 AlgorithmStageTransitPtr fc;
00389
00390 if(getClassType().getPrototype() != NULL)
00391 {
00392 FieldContainerTransitPtr tmpPtr =
00393 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
00394
00395 fc = dynamic_pointer_cast<AlgorithmStage>(tmpPtr);
00396 }
00397
00398 return fc;
00399 }
00400
00402 AlgorithmStageTransitPtr AlgorithmStageBase::createDependent(BitVector bFlags)
00403 {
00404 AlgorithmStageTransitPtr fc;
00405
00406 if(getClassType().getPrototype() != NULL)
00407 {
00408 FieldContainerTransitPtr tmpPtr =
00409 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
00410
00411 fc = dynamic_pointer_cast<AlgorithmStage>(tmpPtr);
00412 }
00413
00414 return fc;
00415 }
00416
00418 AlgorithmStageTransitPtr AlgorithmStageBase::create(void)
00419 {
00420 AlgorithmStageTransitPtr fc;
00421
00422 if(getClassType().getPrototype() != NULL)
00423 {
00424 FieldContainerTransitPtr tmpPtr =
00425 getClassType().getPrototype()-> shallowCopy();
00426
00427 fc = dynamic_pointer_cast<AlgorithmStage>(tmpPtr);
00428 }
00429
00430 return fc;
00431 }
00432
00433 AlgorithmStage *AlgorithmStageBase::createEmptyLocal(BitVector bFlags)
00434 {
00435 AlgorithmStage *returnValue;
00436
00437 newPtr<AlgorithmStage>(returnValue, bFlags);
00438
00439 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
00440
00441 return returnValue;
00442 }
00443
00445 AlgorithmStage *AlgorithmStageBase::createEmpty(void)
00446 {
00447 AlgorithmStage *returnValue;
00448
00449 newPtr<AlgorithmStage>(returnValue, Thread::getCurrentLocalFlags());
00450
00451 returnValue->_pFieldFlags->_bNamespaceMask &=
00452 ~Thread::getCurrentLocalFlags();
00453
00454 return returnValue;
00455 }
00456
00457
00458 FieldContainerTransitPtr AlgorithmStageBase::shallowCopyLocal(
00459 BitVector bFlags) const
00460 {
00461 AlgorithmStage *tmpPtr;
00462
00463 newPtr(tmpPtr, dynamic_cast<const AlgorithmStage *>(this), bFlags);
00464
00465 FieldContainerTransitPtr returnValue(tmpPtr);
00466
00467 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
00468
00469 return returnValue;
00470 }
00471
00472 FieldContainerTransitPtr AlgorithmStageBase::shallowCopyDependent(
00473 BitVector bFlags) const
00474 {
00475 AlgorithmStage *tmpPtr;
00476
00477 newPtr(tmpPtr, dynamic_cast<const AlgorithmStage *>(this), ~bFlags);
00478
00479 FieldContainerTransitPtr returnValue(tmpPtr);
00480
00481 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
00482
00483 return returnValue;
00484 }
00485
00486 FieldContainerTransitPtr AlgorithmStageBase::shallowCopy(void) const
00487 {
00488 AlgorithmStage *tmpPtr;
00489
00490 newPtr(tmpPtr,
00491 dynamic_cast<const AlgorithmStage *>(this),
00492 Thread::getCurrentLocalFlags());
00493
00494 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
00495
00496 FieldContainerTransitPtr returnValue(tmpPtr);
00497
00498 return returnValue;
00499 }
00500
00501
00502
00503
00504
00505
00506 AlgorithmStageBase::AlgorithmStageBase(void) :
00507 Inherited(),
00508 _sfAlgorithm (NULL),
00509 _sfProjectionMode (UInt32(0x0001)),
00510 _sfCopyViewing (bool(false)),
00511 _sfProjectionMatrix ()
00512 {
00513 }
00514
00515 AlgorithmStageBase::AlgorithmStageBase(const AlgorithmStageBase &source) :
00516 Inherited(source),
00517 _sfAlgorithm (NULL),
00518 _sfProjectionMode (source._sfProjectionMode ),
00519 _sfCopyViewing (source._sfCopyViewing ),
00520 _sfProjectionMatrix (source._sfProjectionMatrix )
00521 {
00522 }
00523
00524
00525
00526
00527 AlgorithmStageBase::~AlgorithmStageBase(void)
00528 {
00529 }
00530
00531 void AlgorithmStageBase::onCreate(const AlgorithmStage *source)
00532 {
00533 Inherited::onCreate(source);
00534
00535 if(source != NULL)
00536 {
00537 AlgorithmStage *pThis = static_cast<AlgorithmStage *>(this);
00538
00539 pThis->setAlgorithm(source->getAlgorithm());
00540 }
00541 }
00542
00543 GetFieldHandlePtr AlgorithmStageBase::getHandleAlgorithm (void) const
00544 {
00545 SFUnrecAlgorithmPtr::GetHandlePtr returnValue(
00546 new SFUnrecAlgorithmPtr::GetHandle(
00547 &_sfAlgorithm,
00548 this->getType().getFieldDesc(AlgorithmFieldId),
00549 const_cast<AlgorithmStageBase *>(this)));
00550
00551 return returnValue;
00552 }
00553
00554 EditFieldHandlePtr AlgorithmStageBase::editHandleAlgorithm (void)
00555 {
00556 SFUnrecAlgorithmPtr::EditHandlePtr returnValue(
00557 new SFUnrecAlgorithmPtr::EditHandle(
00558 &_sfAlgorithm,
00559 this->getType().getFieldDesc(AlgorithmFieldId),
00560 this));
00561
00562 returnValue->setSetMethod(
00563 boost::bind(&AlgorithmStage::setAlgorithm,
00564 static_cast<AlgorithmStage *>(this), _1));
00565
00566 editSField(AlgorithmFieldMask);
00567
00568 return returnValue;
00569 }
00570
00571 GetFieldHandlePtr AlgorithmStageBase::getHandleProjectionMode (void) const
00572 {
00573 SFUInt32::GetHandlePtr returnValue(
00574 new SFUInt32::GetHandle(
00575 &_sfProjectionMode,
00576 this->getType().getFieldDesc(ProjectionModeFieldId),
00577 const_cast<AlgorithmStageBase *>(this)));
00578
00579 return returnValue;
00580 }
00581
00582 EditFieldHandlePtr AlgorithmStageBase::editHandleProjectionMode (void)
00583 {
00584 SFUInt32::EditHandlePtr returnValue(
00585 new SFUInt32::EditHandle(
00586 &_sfProjectionMode,
00587 this->getType().getFieldDesc(ProjectionModeFieldId),
00588 this));
00589
00590
00591 editSField(ProjectionModeFieldMask);
00592
00593 return returnValue;
00594 }
00595
00596 GetFieldHandlePtr AlgorithmStageBase::getHandleCopyViewing (void) const
00597 {
00598 SFBool::GetHandlePtr returnValue(
00599 new SFBool::GetHandle(
00600 &_sfCopyViewing,
00601 this->getType().getFieldDesc(CopyViewingFieldId),
00602 const_cast<AlgorithmStageBase *>(this)));
00603
00604 return returnValue;
00605 }
00606
00607 EditFieldHandlePtr AlgorithmStageBase::editHandleCopyViewing (void)
00608 {
00609 SFBool::EditHandlePtr returnValue(
00610 new SFBool::EditHandle(
00611 &_sfCopyViewing,
00612 this->getType().getFieldDesc(CopyViewingFieldId),
00613 this));
00614
00615
00616 editSField(CopyViewingFieldMask);
00617
00618 return returnValue;
00619 }
00620
00621 GetFieldHandlePtr AlgorithmStageBase::getHandleProjectionMatrix (void) const
00622 {
00623 SFMatrix::GetHandlePtr returnValue(
00624 new SFMatrix::GetHandle(
00625 &_sfProjectionMatrix,
00626 this->getType().getFieldDesc(ProjectionMatrixFieldId),
00627 const_cast<AlgorithmStageBase *>(this)));
00628
00629 return returnValue;
00630 }
00631
00632 EditFieldHandlePtr AlgorithmStageBase::editHandleProjectionMatrix(void)
00633 {
00634 SFMatrix::EditHandlePtr returnValue(
00635 new SFMatrix::EditHandle(
00636 &_sfProjectionMatrix,
00637 this->getType().getFieldDesc(ProjectionMatrixFieldId),
00638 this));
00639
00640
00641 editSField(ProjectionMatrixFieldMask);
00642
00643 return returnValue;
00644 }
00645
00646
00647 #ifdef OSG_MT_CPTR_ASPECT
00648 void AlgorithmStageBase::execSyncV( FieldContainer &oFrom,
00649 ConstFieldMaskArg whichField,
00650 AspectOffsetStore &oOffsets,
00651 ConstFieldMaskArg syncMode,
00652 const UInt32 uiSyncInfo)
00653 {
00654 AlgorithmStage *pThis = static_cast<AlgorithmStage *>(this);
00655
00656 pThis->execSync(static_cast<AlgorithmStage *>(&oFrom),
00657 whichField,
00658 oOffsets,
00659 syncMode,
00660 uiSyncInfo);
00661 }
00662 #endif
00663
00664
00665 #ifdef OSG_MT_CPTR_ASPECT
00666 FieldContainer *AlgorithmStageBase::createAspectCopy(
00667 const FieldContainer *pRefAspect) const
00668 {
00669 AlgorithmStage *returnValue;
00670
00671 newAspectCopy(returnValue,
00672 dynamic_cast<const AlgorithmStage *>(pRefAspect),
00673 dynamic_cast<const AlgorithmStage *>(this));
00674
00675 return returnValue;
00676 }
00677 #endif
00678
00679 void AlgorithmStageBase::resolveLinks(void)
00680 {
00681 Inherited::resolveLinks();
00682
00683 static_cast<AlgorithmStage *>(this)->setAlgorithm(NULL);
00684
00685
00686 }
00687
00688
00689 OSG_END_NAMESPACE