Coin: SoPath.h Source File

| Coin3D is Free Software, published under the BSD 3-clause license. | https://coin3d.github.io https://www.kongsberg.com/en/kogt/

SoPath.h
1#ifndef COIN_SOPATH_H
2#define COIN_SOPATH_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <Inventor/misc/SoBase.h>
37#include <Inventor/lists/SbList.h>
38#include <Inventor/lists/SoNodeList.h>
39
40#ifndef COIN_INTERNAL
41// For SGI / TGS Open Inventor compile-time compatibility.
42#include <Inventor/SoLists.h>
43#endif // !COIN_INTERNAL
44
45
46class SoWriteAction;
47class SoNotList;
48class SoInput;
49class SoPathList;
50
51
52 class COIN_DLL_API SoPath : public SoBase {
53 typedef SoBase inherited;
54
55public:
56 static void initClass(void);
57
58 SoPath(const int approxlength = 4);
59 SoPath(SoNode * const head);
60 SoPath(const SoPath & rhs);
61
62 SoPath & operator=(const SoPath & rhs);
63
64 static SoType getClassTypeId(void);
65 virtual SoType getTypeId(void) const;
66
67 void setHead(SoNode * const head);
68 SoNode * getHead(void) const;
69 void append(const int childindex);
70 void append(SoNode * const node);
71 void append(const SoPath * const frompath);
72 void push(const int childindex);
73 void pop(void);
74 SoNode * getTail(void) const;
75 SoNode * getNode(const int index) const;
76 SoNode * getNodeFromTail(const int index) const;
77 int getIndex(const int index) const;
78 int getIndexFromTail(const int index) const;
79 int getLength(void) const;
80 void truncate(const int length);
81
82 int findFork(const SoPath * const path) const;
83 int findNode(const SoNode * const node) const;
84
85 SbBool containsNode(const SoNode * const node) const;
86 SbBool containsPath(const SoPath * const path) const;
87 SoPath * copy(const int startfromnodeindex = 0, int numnodes = 0) const;
88 friend COIN_DLL_API SbBool operator==(const SoPath & lhs, const SoPath & rhs);
89 friend COIN_DLL_API SbBool operator!=(const SoPath & lhs, const SoPath & rhs);
90
91 static SoPath * getByName(const SbName name);
92 static int getByName(const SbName name, SoPathList & l);
93
94 void insertIndex(SoNode * const parent, const int newindex);
95 void removeIndex(SoNode * const parent, const int oldindex);
96 void replaceIndex(SoNode * const parent, const int index,
97 SoNode * const newchild);
98 SbBool isRelevantNotification(SoNotList * const l) const;
99
100 virtual void write(SoWriteAction * action);
101
102protected:
103 virtual ~SoPath();
104 void auditPath(const SbBool flag);
105
106private:
107 static void cleanupClass(void);
108 static void * createInstance(void);
109 void append(SoNode * const node, const int index);
110 int getFullLength(void) const;
111 void truncate(const int length, const SbBool donotify);
112 virtual SbBool readInstance(SoInput * in, unsigned short flags);
113 void setFirstHidden(void);
114
115 SoNodeList nodes;
116 SbList<int> indices;
117 SbBool isauditing;
118 int firsthidden;
119 SbBool firsthiddendirty;
120 static SoType classTypeId;
121
122 friend class SoFullPath;
123 friend class SoNodeKitPath;
124 friend class SoAction;
125 friend class SoTempPath;
126};
127
129
130inline int
131SoPath::getFullLength(void) const
132{
133 return this->nodes.getLength();
134}
135
136inline void
137SoPath::push(const int childindex)
138{
139 this->append(childindex);
140}
141
142inline void
143SoPath::pop(void)
144{
145 this->truncate(this->getFullLength() - 1);
146}
147
149
150
151#ifndef COIN_INTERNAL
152// For SGI / TGS Open Inventor compile-time compatibility.
153#include <Inventor/SoFullPath.h>
154#include <Inventor/misc/SoLightPath.h>
155#endif // COIN_INTERNAL
156
157#endif // !COIN_SOPATH_H
SbList
The SbList class is a template container class for lists.
Definition SbList.h:70
SbName
The SbName class stores strings by reference.
Definition SbName.h:40
SbPList::getLength
int getLength(void) const
Definition lists/SbPList.h:103
SoBase::SoBase
SoBase(void)
Definition SoBase.cpp:190
SoBase::getClassTypeId
static SoType getClassTypeId(void)
This static method returns the SoType object associated with objects of this class.
Definition SoBase.cpp:641
SoBase::initClass
static void initClass(void)
Sets up initialization for data common to all instances of this class, like submitting necessary info...
Definition SoBase.cpp:351
SoBase::getTypeId
virtual SoType getTypeId(void) const =0
Returns the type identification of an object derived from a class inheriting SoBase....
SoBase::readInstance
virtual SbBool readInstance(SoInput *input, unsigned short flags)=0
SoInput
The SoInput class is an abstraction of file import functionality.
Definition SoInput.h:61
SoNodeList
The SoNodeList class is a container for pointers to SoNode objects.
Definition SoNodeList.h:40
SoNode
The SoNode class is the base class for nodes used in scene graphs.
Definition SoNode.h:56
SoNotList
The SoNotList class is a list of SoNotRec notification records.
Definition SoNotification.h:43
SoPathList
The SoPathList class is a container for pointers to SoPath objects.
Definition SoPathList.h:40
SoPath::operator=
SoPath & operator=(const SoPath &rhs)
Definition SoPath.cpp:148
SoPath::getNode
SoNode * getNode(const int index) const
Definition SoPath.cpp:437
SoPath::getIndex
int getIndex(const int index) const
Definition SoPath.cpp:471
SoPath::SoPath
SoPath(const int approxlength=4)
Definition SoPath.cpp:118
SoPath::getHead
SoNode * getHead(void) const
Definition SoPath.cpp:200
SoPath::write
virtual void write(SoWriteAction *action)
Definition SoPath.cpp:973
SoPath::auditPath
void auditPath(const SbBool flag)
Definition SoPath.cpp:1066
SoPath::push
void push(const int childindex)
Definition SoPath.h:137
SoPath::getByName
static SoPath * getByName(const SbName name)
Definition SoPath.cpp:758
SoPath::removeIndex
void removeIndex(SoNode *const parent, const int oldindex)
Definition SoPath.cpp:819
SoPath::getTail
SoNode * getTail(void) const
Definition SoPath.cpp:408
SoPath::getNodeFromTail
SoNode * getNodeFromTail(const int index) const
Definition SoPath.cpp:454
SoPath::replaceIndex
void replaceIndex(SoNode *const parent, const int index, SoNode *const newchild)
Definition SoPath.cpp:857
SoPath::copy
SoPath * copy(const int startfromnodeindex=0, int numnodes=0) const
Definition SoPath.cpp:713
SoPath::setHead
void setHead(SoNode *const head)
Definition SoPath.cpp:187
SoPath::getIndexFromTail
int getIndexFromTail(const int index) const
Definition SoPath.cpp:490
SoPath::append
void append(const int childindex)
Definition SoPath.cpp:211
SoPath::pop
void pop(void)
Definition SoPath.h:143
SoPath::isRelevantNotification
SbBool isRelevantNotification(SoNotList *const l) const
Definition SoPath.cpp:1016
SoPath::containsPath
SbBool containsPath(const SoPath *const path) const
Definition SoPath.cpp:651
SoPath::operator==
friend SbBool operator==(const SoPath &lhs, const SoPath &rhs)
Definition SoPath.cpp:674
SoPath::getLength
int getLength(void) const
Definition SoPath.cpp:511
SoPath::insertIndex
void insertIndex(SoNode *const parent, const int newindex)
Definition SoPath.cpp:790
SoPath::containsNode
SbBool containsNode(const SoNode *const node) const
Definition SoPath.cpp:641
SoPath::truncate
void truncate(const int length)
Definition SoPath.cpp:531
SoPath::findNode
int findNode(const SoNode *const node) const
Definition SoPath.cpp:627
SoPath::findFork
int findFork(const SoPath *const path) const
Definition SoPath.cpp:605
SoPath::operator!=
friend SbBool operator!=(const SoPath &lhs, const SoPath &rhs)
Definition SoPath.cpp:696
SoType
The SoType class is the basis for the runtime type system in Coin.
Definition SoType.h:59
SoWriteAction
The SoWriteAction class writes a scene graph to file.
Definition SoWriteAction.h:42