Coin  4.0.3
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 SoPathList;
50
51
52class 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
138{
139 this->append(childindex);
140}
141
142inline 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
The SbList class is a template container class for lists.
Definition SbList.h:70
void truncate(const int length, const int dofit=0)
Definition SbList.h:172
int getLength(void) const
Definition SbList.h:168
Type pop(void)
Definition SbList.h:184
SbList< Type > & operator=(const SbList< Type > &l)
Definition SbList.h:99
int operator!=(const SbList< Type > &l) const
Definition SbList.h:217
int operator==(const SbList< Type > &l) const
Definition SbList.h:209
void copy(const SbList< Type > &l)
Definition SbList.h:92
void append(const Type item)
Definition SbList.h:121
void push(const Type item)
Definition SbList.h:180
The SbName class stores strings by reference.
Definition SbName.h:40
int getLength(void) const
Definition lists/SbPList.h:103
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 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
The SoNodeKitPath class is a path that contains only nodekit nodes.
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:52
void push(const int childindex)
Definition SoPath.h:137
void append(const int childindex)
Definition SoPath.cpp:211
void pop(void)
Definition SoPath.h:143
void truncate(const int length)
Definition SoPath.cpp:528
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