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 #ifndef _SO_PATH_
00053 #define _SO_PATH_
00054
00055 #include <Inventor/misc/SoBase.h>
00056 #include <Inventor/nodes/SoNode.h>
00057 #include <Inventor/SoLists.h>
00058 #include <Inventor/lists/SbExtIntList.h>
00059 #include <Inventor/STL/iostream>
00060
00061 class SoTempPath;
00062
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00078
00079 class SoPathList;
00080 class SoWriteAction;
00081
00186 class SoPath : public SoBase {
00187
00188 public:
00189
00193 SoPath();
00194
00198 SoPath(int approxLength);
00199
00203 SoPath(SoNode *node);
00204
00209 void setHead(SoNode *node);
00210
00215 void append(int childIndex);
00216
00222 void append(SoNode *childNode);
00223
00228 void append(const SoPath *fromPath);
00229
00234 void push(int childIndex);
00235
00240 void pop();
00241
00245 SoNode* getHead() const { return (SoNode*)(nodes.get(0)); }
00246
00250 SoNode* getTail() const;
00251
00258 SoNode* getNode(int i) const;
00259
00266 SoNode* getNode(const SoType type, int &i) const;
00267
00268
00275 SoNode* getNodeFromTail(int i) const;
00276
00281 int getIndex(int i) const;
00282
00287 int getInstanceIndex(int i) const;
00288
00295 int getIndexFromTail(int i) const;
00296
00304 int getInstanceIndexFromTail(int i) const;
00305
00310 int getLength() const;
00311
00317 void truncate(int start);
00318
00322 SbBool containsNode(const SoNode *node) const;
00323
00328 SbBool containsNode(const SoType type) const;
00329
00334 SbBool containsPath(const SoPath *path) const;
00335
00341 int findFork(const SoPath *path) const;
00342
00350 SoPath *copy(int startFromNodeIndex = 0, int numNodes = 0) const;
00351
00355 friend int operator ==(const SoPath &p1, const SoPath &p2);
00356
00360 friend std::ostream& operator << (std::ostream& os, const SoPath& path);
00361
00365 virtual SoType getTypeId() const;
00366
00370 static SoType getClassTypeId();
00371
00380 static SoPath *getByName(const SbName &name);
00389 static int getByName(const SbName &name, SoPathList &list);
00390
00391
00392 private:
00393
00394 static void initClass();
00395 static void exitClass();
00396
00400 friend bool operator <(const SoPath &p1, const SoPath &p2);
00401
00402
00403
00404 void insertIndex(SoNode *parent, int newIndex);
00405
00406
00407
00408 void removeIndex(SoNode *parent, int oldIndex);
00409
00410
00411
00412 void replaceIndex(SoNode *parent, int index, SoNode *newChild);
00413
00414
00415 virtual void write(SoWriteAction *writeAction) const;
00416
00417
00418
00419
00420 SbBool isRelevantNotification(SoNotList *list) const;
00421
00422 void setNumPublic(int num);
00423
00424
00425
00426 void append(SoNode *node, int index);
00427
00428
00429
00430 void appendMI(SoNode *node, int index, int instanceIndex);
00431
00432
00433 SoPath *copy_(int startFromNodeIndex = 0, int numNodes = 0, bool createTempPath = false) const;
00434
00435
00436 const size_t& getHash() const;
00437
00438
00439 void truncate(int start, SbBool doNotify);
00440
00441
00442
00443 SoNode* u_getHead() const { return (SoNode*)(const_cast<SoNodeList*>(&nodes)->getArray()[0]); }
00444 SoNode* u_getTail() const { return (SoNode*)(const_cast<SoNodeList*>(&nodes)->getArray()[getLength() - 1]); }
00445 SoNode* u_getNode(int i) const { return (SoNode*)(const_cast<SoNodeList*>(&nodes)->getArray()[i]); }
00446 SoNode* u_getNodeFromTail(int i) const { return (SoNode*)(const_cast<SoNodeList*>(&nodes)->getArray()[getLength() - 1 - i]); }
00447 int u_getIndex(int i) const { return (int)indices[i]; }
00448 int u_getIndexFromTail(int i) const { return (int)indices[getLength() - 1 - i]; }
00449 int u_getInstanceIndex(int i) const { return (int)indices[i].second; }
00450 int u_getInstanceIndexFromTail(int i) const { return (int)indices[getLength() - 1 - i].second; }
00451
00452
00453
00458 void setHeadMI(SoNode *node, int instanceIndex);
00459
00465 void appendMI(int childIndex, int instanceIndex);
00466
00473 void appendMI(SoNode *childNode, int instanceIndex);
00474
00479 void pushMI(int childIndex, int instanceIndex);
00480
00481 bool isForwardTraversing() const;
00482
00483 private:
00484
00485 void auditPath(SbBool flag) { doAuditors = flag; }
00486
00487
00488 virtual SbBool readInstance(SoInput *in, unsigned short flags);
00489
00490 virtual ~SoPath();
00491
00492 private:
00493 SoNodeList nodes;
00494 SbExtIntList indices;
00495 int numPublic;
00496 int minNumPublic;
00497 SbBool doAuditors;
00498 static SoType classTypeId;
00499
00500
00501 int getFullLength() const
00502 { return nodes.getLength(); }
00503
00504
00505 static void* createInstance(SoType* dynamicType = NULL);
00506
00507
00508 size_t m_pathHash;
00509
00510 friend class SoFullPath;
00511 friend class SoTempPath;
00512 friend class SoAction;
00513 friend class SoPathNoRef;
00514 friend class SoTraversalPassImpl;
00515
00516 };
00517
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00530
00608 class SoFullPath : public SoPath {
00609
00610 public:
00611
00612
00613
00615 void pop()
00616 { truncate(getFullLength() - 1); }
00617
00619 SoNode *getTail() const
00620 { return (nodes[getFullLength() - 1]); }
00621
00623 SoNode *getNodeFromTail(int i) const
00624 { return (nodes[getFullLength() - 1 - i]); }
00625
00627 int getIndexFromTail(int i) const
00628 { return (indices[getFullLength() - 1 - i]); }
00629
00631 int getInstanceIndexFromTail(int i) const
00632 { return (indices[getFullLength() - 1 - i].second); }
00633
00635 int getLength() const
00636 { return getFullLength(); }
00637
00638 private:
00639 SoFullPath(int approxLength) : SoPath(approxLength) {}
00640 virtual ~SoFullPath();
00641
00642 friend class SoTempPath;
00643 };
00644
00645 #ifndef HIDDEN_FROM_DOC
00646
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00659
00660
00661 class SoLightPath {
00662
00663 private:
00664
00665
00666 SoLightPath(int approxLength=0);
00667
00668
00669
00670
00671 void setHead(SoNode *node);
00672
00673
00674 void append(int childIndex)
00675 { indices.append(childIndex);}
00676
00677
00678 void appendMI(int childIndex, int instanceIndex)
00679 { indices.append(childIndex, instanceIndex);}
00680
00681
00682
00683
00684 void push(int childIndex) { append(childIndex); }
00685 void pushMI(int childIndex, int instanceIndex) { appendMI(childIndex, instanceIndex); }
00686 void push() { append(-1);}
00687 void pop() { truncate(getFullLength() - 1); }
00688 void setTail(int childIndex) {
00689 indices.set(getFullLength() - 1, childIndex);
00690 }
00691 void setTail(int childIndex, int instanceIndex) {
00692 indices.set(getFullLength() - 1, childIndex, instanceIndex);
00693 }
00694 SoNode * getTail(){
00695 return getNode(getFullLength()-1);
00696 }
00697
00698
00699 SoNode * getHead() const { return headNode; }
00700
00701
00702 SoNode * getNode(int i) const;
00703
00704
00705
00706 int getIndex(int i) const
00707 { return indices[i]; };
00708
00709
00710 int getInstanceIndex(int i) const
00711 { return indices[i].second; };
00712
00713
00714
00715
00716 int getFullLength() const {return (int) indices.size();}
00717
00718
00719 void truncate(int start) { indices.truncate(start);}
00720
00721
00722
00723
00724 void makeTempPath(SoTempPath *) const;
00725
00726 private:
00727
00728 ~SoLightPath();
00729 SoNode * headNode;
00730 SbExtIntList indices;
00731
00732
00733 friend class SoAction;
00734 };
00735
00736 #endif // HIDDEN_FROM_DOC
00737
00741 std::ostream& operator << (std::ostream& os, const SoPath& path);
00742
00743 #endif
00744
00745