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 #ifndef _OSGNODE_H_
00040 #define _OSGNODE_H_
00041 #ifdef __sgi
00042 #pragma once
00043 #endif
00044
00045 #include "OSGReflexiveContainer.h"
00046 #include "OSGMatrix.h"
00047 #include "OSGFieldContainer.h"
00048 #include "OSGAttachmentContainer.h"
00049
00050 #include "OSGDynamicVolumeFields.h"
00051 #include "OSGUInt32Fields.h"
00052
00053 #include "OSGNodeFields.h"
00054 #include "OSGNodeCoreFields.h"
00055 #include "OSGContainerPtrFuncs.h"
00056 #include "OSGFieldContainerFactory.h"
00057
00058 #include <boost/assign/list_of.hpp>
00059
00060 OSG_BEGIN_NAMESPACE
00061
00070 class OSG_SYSTEM_DLLMAPPING Node : public AttachmentContainer
00071 {
00072
00073
00074 public:
00075
00076 typedef AttachmentContainer Inherited;
00077 typedef AttachmentContainer ParentContainer;
00078
00079 OSG_GEN_INTERNALPTR(Node);
00080
00081 typedef Inherited::TypeObject TypeObject;
00082
00083 typedef Node Self;
00084
00085 OSG_RC_FIRST_FIELD_DECL(Volume );
00086
00087 OSG_RC_FIELD_DECL (TravMask, Volume );
00088 OSG_RC_FIELD_DECL (Parent, TravMask);
00089 OSG_RC_FIELD_DECL (Core, Parent );
00090 OSG_RC_FIELD_DECL (Children, Core );
00091
00092 OSG_RC_LAST_FIELD_DECL (Children );
00093
00094 static const BitVector bLocalFieldMask = (VolumeFieldMask |
00095 TravMaskFieldMask |
00096 ParentFieldMask |
00097 ChildrenFieldMask |
00098 CoreFieldMask );
00099
00100 static const BitVector bInvLocalFieldMask = ~bLocalFieldMask;
00101
00102
00106 OSG_FIELD_CONTAINER_DECL;
00107
00109
00114
00118 NodeCorePtr getCore(void );
00119 NodeCorePtr getCore(void ) const;
00120
00121 void setCore(NodeCorePtrConstArg core);
00122
00124
00128 NodePtr getParent(void);
00129
00131
00135 UInt32 getNChildren (void ) const;
00136
00137 void addChild (NodePtrConstArg childP );
00138
00139 void insertChild (UInt32 childIndex,
00140 NodePtrConstArg childP );
00141
00142 void replaceChild (UInt32 childIndex,
00143 NodePtrConstArg childP );
00144
00145 bool replaceChildBy(NodePtrConstArg childP,
00146 NodePtrConstArg newChildP );
00147
00148 Int32 findChild (NodePtrConstArg childP ) const;
00149
00150 void subChild (NodePtrConstArg childP );
00151 void subChild (UInt32 childIndex);
00152
00153 NodePtr getChild (UInt32 childIndex);
00154
00155 void clearChildren (void );
00156
00158
00162 void setTravMask (UInt32 uiMask);
00163 UInt32 getTravMask (void ) const;
00164
00165 #ifdef OSG_1_COMPAT
00166 bool getActive (void ) const;
00167 void setActive (bool val);
00168
00169 void setOcclusionMask(UInt8 val);
00170 UInt8 getOcclusionMask(void ) const;
00171 #endif
00172
00174
00178 #if 0
00179 virtual void pushToField ( FieldContainerPtrConstArg pNewElement,
00180 const UInt32 uiFieldId );
00181
00182 virtual void insertIntoMField(const UInt32 uiIndex,
00183 FieldContainerPtrConstArg pNewElement,
00184 const UInt32 uiFieldId );
00185
00186 virtual void replaceInMField (const UInt32 uiIndex,
00187 FieldContainerPtrConstArg pNewElement,
00188 const UInt32 uiFieldId );
00189
00190 virtual void replaceInMField ( FieldContainerPtrConstArg pOldElement,
00191 FieldContainerPtrConstArg pNewElement,
00192 const UInt32 uiFieldId );
00193
00194 virtual void removeFromMField(const UInt32 uiIndex,
00195 const UInt32 whichField );
00196
00197 virtual void removeFromMField( FieldContainerPtrConstArg pElement,
00198 const UInt32 whichField );
00199
00200 virtual void clearField (const UInt32 whichField );
00201 #endif
00202
00204
00209
00214
00218 virtual UInt32 getBinSize (ConstFieldMaskArg whichField);
00219 virtual void copyToBin (BinaryDataHandler &pMem,
00220 ConstFieldMaskArg whichField);
00221 virtual void copyFromBin(BinaryDataHandler &pMem,
00222 ConstFieldMaskArg whichField);
00223
00225
00229 Matrixr getToWorld(void );
00230
00231 void getToWorld(Matrixr &result);
00232
00233
00235
00239 #ifdef OSG_1_GET_COMPAT
00240 DynamicVolume &getVolume (bool update = false );
00241 #endif
00242
00243 DynamicVolume &editVolume (bool update = false );
00244
00245 const DynamicVolume &getVolume (void ) const;
00246
00247 void getWorldVolume (DynamicVolume &result);
00248
00249 void updateVolume (void );
00250
00251 virtual void invalidateVolume(void );
00252
00254
00258 virtual void changed(ConstFieldMaskArg whichField,
00259 UInt32 origin,
00260 BitVector details);
00261
00263
00267 virtual void dump( UInt32 uiIndent = 0,
00268 const BitVector bvFlags = 0) const;
00269
00271
00275 SFDynamicVolume *editSFVolume (void);
00276 const SFDynamicVolume *getSFVolume (void) const;
00277
00278 SFUInt32 *editSFTravMask(void);
00279 const SFUInt32 *getSFTravMask (void) const;
00280
00281 const SFNodePtr *getSFParent (void) const;
00282 const SFNodeCorePtr *getSFCore (void) const;
00283 const MFNodePtr *getMFChildren (void) const;
00284
00286
00287
00288 protected:
00289
00290
00294 static TypeObject _type;
00295
00296 static void classDescInserter(TypeObject &oType);
00297 static Char8 *getClassname (void );
00298
00300
00304 SFDynamicVolume _sfVolume;
00305
00306 SFUInt32 _sfTravMask;
00307
00308 SFNodePtr _sfParent;
00309 MFNodePtr _mfChildren;
00310
00311 SFNodeCorePtr _sfCore;
00312
00313 #ifdef OSG_1_COMPAT
00314 UInt8 _occlusionMask;
00315 #endif
00316
00318
00322 Node(void);
00323 Node(const Node &source);
00324
00325 virtual ~Node(void);
00326
00328
00332 void setParent(const NodePtr &parent);
00333
00335
00339 #ifdef OSG_MT_CPTR_ASPECT
00340 virtual ObjPtr createAspectCopy(void) const;
00341 #endif
00342
00344
00348 #ifdef OSG_MT_CPTR_ASPECT
00349 virtual void execSyncV( FieldContainer &oFrom,
00350 ConstFieldMaskArg whichField,
00351 AspectOffsetStore &oOffsets,
00352 ConstFieldMaskArg syncMode ,
00353 const UInt32 uiSyncInfo);
00354
00355 void execSync ( Node *pFrom,
00356 ConstFieldMaskArg whichField,
00357 AspectOffsetStore &oOffsets,
00358 ConstFieldMaskArg syncMode ,
00359 const UInt32 uiSyncInfo);
00360 #endif
00361
00363
00367 EditFieldHandlePtr editHandleVolume (void);
00368 GetFieldHandlePtr getHandleVolume (void) const;
00369
00370 EditFieldHandlePtr editHandleTravMask(void);
00371 GetFieldHandlePtr getHandleTravMask (void) const;
00372
00373 GetFieldHandlePtr getHandleParent (void) const;
00374
00375 EditFieldHandlePtr editHandleCore (void);
00376 GetFieldHandlePtr getHandleCore (void) const;
00377
00378 EditFieldHandlePtr editHandleChildren(void);
00379 GetFieldHandlePtr getHandleChildren (void) const;
00380
00382
00386 virtual void resolveLinks(void);
00387
00389
00390
00391 private:
00392
00393 friend class FieldContainer;
00394
00395 friend struct PointerFuncs;
00396 friend struct CPointerFuncs;
00397
00399 void operator =(const Node &source);
00400 };
00401
00402 typedef RefPtr<NodePtr> NodeRefPtr;
00403
00404 OSG_SYSTEM_DLLMAPPING
00405 NodePtr cloneTree(
00406 NodePtrConstArg rootNode,
00407 const std::vector<std::string> &cloneTypeNames,
00408
00409 const std::vector<std::string> &ignoreTypeNames =
00410 std::vector<std::string>(),
00411
00412 const std::vector<std::string> &cloneGroupNames =
00413 std::vector<std::string>(),
00414
00415 const std::vector<std::string> &ignoreGroupNames =
00416 std::vector<std::string>() );
00417
00418 OSG_SYSTEM_DLLMAPPING
00419 NodePtr cloneTree(
00420 NodePtrConstArg rootNode,
00421 const std::vector<UInt16> &cloneGroupIds,
00422 const std::vector<UInt16> &ignoreGroupIds =
00423 std::vector<UInt16>() );
00424
00425 OSG_SYSTEM_DLLMAPPING
00426 NodePtr cloneTree(
00427 NodePtrConstArg rootNode,
00428 const std::string &cloneTypesString,
00429 const std::string &ignoreTypesString =
00430 std::string() );
00431
00432 #ifdef OSG_1_COMPAT
00433 OSG_SYSTEM_DLLMAPPING
00434 NodePtr cloneTree(
00435 NodePtrConstArg rootNode,
00436
00437 const std::vector<const ReflexiveContainerType *> &cloneTypes =
00438 std::vector<const ReflexiveContainerType *>(),
00439
00440 const std::vector<const ReflexiveContainerType *> &ignoreTypes =
00441 boost::assign::list_of(
00442 &FieldContainerAttachment::getClassType()),
00443
00444 const std::vector<UInt16> &cloneGroupIds =
00445 std::vector<UInt16>(),
00446 const std::vector<UInt16> &ignoreGroupIds =
00447 std::vector<UInt16>() );
00448 #else
00449 OSG_SYSTEM_DLLMAPPING
00450 NodePtr cloneTree(
00451 NodePtrConstArg rootNode,
00452
00453 const std::vector<const ReflexiveContainerType *> &cloneTypes =
00454 std::vector<const ReflexiveContainerType *>(),
00455
00456 const std::vector<const ReflexiveContainerType *> &ignoreTypes =
00457 std::vector<const ReflexiveContainerType *>(),
00458
00459 const std::vector<UInt16> &cloneGroupIds =
00460 std::vector<UInt16>(),
00461
00462 const std::vector<UInt16> &ignoreGroupIds =
00463 std::vector<UInt16>() );
00464 #endif
00465
00466 OSG_SYSTEM_DLLMAPPING
00467 NodePtr deepCloneTree(
00468 NodePtrConstArg rootNode,
00469 const std::vector<std::string> &shareTypeNames,
00470
00471 const std::vector<std::string> &ignoreTypeNames =
00472 std::vector<std::string>(),
00473
00474 const std::vector<std::string> &shareGroupNames =
00475 std::vector<std::string>(),
00476
00477 const std::vector<std::string> &ignoreGroupNames =
00478 std::vector<std::string>() );
00479
00480 OSG_SYSTEM_DLLMAPPING
00481 NodePtr deepCloneTree(
00482 NodePtrConstArg rootNode,
00483 const std::vector<UInt16> &shareGroupIds,
00484
00485 const std::vector<UInt16> &ignoreGroupIds =
00486 std::vector<UInt16>() );
00487
00488 OSG_SYSTEM_DLLMAPPING
00489 NodePtr deepCloneTree(
00490 NodePtrConstArg rootNode,
00491 const std::string &shareTypesString,
00492
00493 const std::string &ignoreTypesString =
00494 std::string() );
00495
00496 OSG_SYSTEM_DLLMAPPING
00497 NodePtr deepCloneTree(
00498 NodePtrConstArg rootNode,
00499
00500 const std::vector<const ReflexiveContainerType *> &shareTypes =
00501 std::vector<const ReflexiveContainerType *>(),
00502
00503 const std::vector<const ReflexiveContainerType *> &ignoreTypes =
00504 std::vector<const ReflexiveContainerType *>(),
00505
00506 const std::vector<UInt16> &shareGroupIds =
00507 std::vector<UInt16>(),
00508 const std::vector<UInt16> &ignoreGroupIds =
00509 std::vector<UInt16>() );
00510
00511 template <class Core> inline
00512 NodePtr makeCoredNode(typename Core::ObjPtr *coreP = NULL);
00513
00514 template <class CorePtr> inline
00515 NodePtr makeNodeFor(CorePtr core);
00516
00517 OSG_END_NAMESPACE
00518
00519 #include "OSGNode.inl"
00520 #include "OSGCoredNodePtr.h"
00521
00522 #endif