Coin  4.0.10
Coin3D core library
Loading...
Searching...
No Matches
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 SoNode;
50class SoPathList;
51class SoPath;
52
53
55public:
56 int getLength(void) const;
57 SoNode * getTail(void) const;
58 SoNode * getNodeFromTail(const int index) const;
59 int getIndexFromTail(const int index) const;
60
61private:
62 friend class SoPath;
63 explicit SoFullPathView(const SoPath & sourcepath);
64
65 const SoPath * path;
66};
67
69public:
70 int getLength(void) const;
71 SoNode * getTail(void) const;
72 SoNode * getNode(const int index) const;
73 SoNode * getNodeFromTail(const int index) const;
74
75private:
76 friend class SoPath;
77 explicit SoNodeKitPathView(const SoPath & sourcepath);
78
79 const SoPath * path;
80};
81
82
83class COIN_DLL_API SoPath : public SoBase {
84 typedef SoBase inherited;
85
86public:
87 static void initClass(void);
88
89 SoPath(const int approxlength = 4);
90 SoPath(SoNode * const head);
91 SoPath(const SoPath & rhs);
92
93 SoPath & operator=(const SoPath & rhs);
94
95 static SoType getClassTypeId(void);
96 SoType getTypeId(void) const override;
97
98 void setHead(SoNode * const head);
99 SoNode * getHead(void) const;
100 void append(const int childindex);
101 void append(SoNode * const node);
102 void append(const SoPath * const frompath);
103 void push(const int childindex);
104 void pop(void);
105 SoNode * getTail(void) const;
106 SoNode * getNode(const int index) const;
107 SoNode * getNodeFromTail(const int index) const;
108 int getIndex(const int index) const;
109 int getIndexFromTail(const int index) const;
110 int getLength(void) const;
111 SoFullPathView fullPath(void) const;
112 SoNodeKitPathView nodeKitPath(void) const;
113 void truncate(const int length);
114
115 int findFork(const SoPath * const path) const;
116 int findNode(const SoNode * const node) const;
117
118 SbBool containsNode(const SoNode * const node) const;
119 SbBool containsPath(const SoPath * const path) const;
120 SoPath * copy(const int startfromnodeindex = 0, int numnodes = 0) const;
121 friend COIN_DLL_API SbBool operator==(const SoPath & lhs, const SoPath & rhs);
122 friend COIN_DLL_API SbBool operator!=(const SoPath & lhs, const SoPath & rhs);
123
124 static SoPath * getByName(const SbName name);
125 static int getByName(const SbName name, SoPathList & l);
126
127 void insertIndex(SoNode * const parent, const int newindex);
128 void removeIndex(SoNode * const parent, const int oldindex);
129 void replaceIndex(SoNode * const parent, const int index,
130 SoNode * const newchild);
131 SbBool isRelevantNotification(SoNotList * const l) const;
132
133 virtual void write(SoWriteAction * action);
134
135protected:
136 virtual ~SoPath();
137 void auditPath(const SbBool flag);
138
139private:
140 static void cleanupClass(void);
141 static void * createInstance(void);
142 void append(SoNode * const node, const int index);
143 int getFullLength(void) const;
144 void removePathAuditors(const int startindex);
145 void truncate(const int length, const SbBool donotify);
146 SbBool readInstance(SoInput * in, unsigned short flags) override;
147 void setFirstHidden(void);
148
149 SoNodeList nodes;
150 SbList<int> indices;
151 SbBool isauditing;
152 int firsthidden;
153 SbBool firsthiddendirty;
154 static SoType classTypeId;
155
156 friend class SoFullPathView;
157 friend class SoFullPath;
158 friend class SoNodeKitPath;
159 friend class SoAction;
160 friend class SoTempPath;
161};
162
164
165inline int
166SoPath::getFullLength(void) const
167{
168 return this->nodes.getLength();
169}
170
171inline void
173{
174 this->append(childindex);
175}
176
177inline void
179{
180 this->truncate(this->getFullLength() - 1);
181}
182
184
185
186#ifndef COIN_INTERNAL
187// For SGI / TGS Open Inventor compile-time compatibility.
188#include <Inventor/SoFullPath.h>
189#include <Inventor/misc/SoLightPath.h>
190#endif // COIN_INTERNAL
191
192#endif // !COIN_SOPATH_H
The SbList class is a template container class for lists.
Definition SbList.h:72
void truncate(const int length, const int dofit=0)
Definition SbList.h:180
int getLength(void) const
Definition SbList.h:176
Type pop(void)
Definition SbList.h:192
SbList< Type > & operator=(const SbList< Type > &l)
Definition SbList.h:101
int operator!=(const SbList< Type > &l) const
Definition SbList.h:225
int operator==(const SbList< Type > &l) const
Definition SbList.h:217
void copy(const SbList< Type > &l)
Definition SbList.h:94
void append(const Type item)
Definition SbList.h:129
void push(const Type item)
Definition SbList.h:188
The SbName class stores strings by reference.
Definition SbName.h:40
int getLength(void) const
Definition lists/SbPList.h:104
The SoAction class is the base class for all traversal actions.
Definition SoAction.h:77
The SoBase class is the top-level superclass for a number of class-hierarchies.
Definition SoBase.h:45
The SoFullPathView class provides safe access to a complete SoPath.
Definition SoPath.h:54
The SoFullPath class allows examination of hidden children in paths.
Definition SoFullPath.h:38
The SoInput class is an abstraction of file import functionality.
Definition SoInput.h:61
A borrowed, allocation-free nodekit projection of a SoPath.
Definition SoPath.h:68
The SoNodeKitPath class presents the nodekit projection of a path.
Definition SoNodeKitPath.h:42
The SoNodeList class is a container for pointers to SoNode objects.
Definition SoNodeList.h:40
The SoNode class is the base class for nodes used in scene graphs.
Definition SoNode.h:56
The SoNotList class is a list of SoNotRec notification records.
Definition SoNotification.h:43
The SoPathList class is a container for pointers to SoPath objects.
Definition SoPathList.h:40
The SoPath class is a container class for traversal path descriptions.
Definition SoPath.h:83
void push(const int childindex)
Definition SoPath.h:172
void append(const int childindex)
Definition SoPath.cpp:272
void pop(void)
Definition SoPath.h:178
void truncate(const int length)
Definition SoPath.cpp:746
The SoTempPath class is used to store temporary paths.
Definition SoTempPath.h:38
The SoType class is the basis for the runtime type system in Coin.
Definition SoType.h:59
The SoWriteAction class writes a scene graph to file.
Definition SoWriteAction.h:42