Open Inventor Reference
SoPath.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * Further, this software is distributed without any warranty that it is
16 * free of the rightful claim of any third person regarding infringement
17 * or the like. Any license provided herein, whether implied or
18 * otherwise, applies only to this software file. Patent licenses, if
19 * any, provided herein do not apply to combinations of this program with
20 * other software, or any other product whatsoever.
21 *
22 * You should have received a copy of the GNU Lesser General Public
23 * License along with this library; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 * Mountain View, CA 94043, or:
28 *
29 * http://www.sgi.com
30 *
31 * For further information regarding this notice, see:
32 *
33 * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 *
35 */
36
37
38/*
39 * Copyright (C) 1990,91 Silicon Graphics, Inc.
40 *
41 _______________________________________________________________________
42 ______________ S I L I C O N G R A P H I C S I N C . ____________
43 |
44 | $Revision: 1.2 $
45 |
46 | Description:
47 | This file contains the definition of the SoPath and SoFullPath
48 | classes, and the related class SoLightweightPath
49 |
50 | Author(s) : Paul S. Strauss, Nick Thompson, Alan Norton
51 |
52 ______________ S I L I C O N G R A P H I C S I N C . ____________
53 _______________________________________________________________________
54 */
55
56#ifndef _SO_PATH_
57#define _SO_PATH_
58
62#include <Inventor/SoLists.h>
63
64
65class SoPathList;
66class SoWriteAction;
67class SoTempPath;
68
71
108
109class INVENTOR_API SoPath : public SoBase {
110
111 public:
112
115
117 SoPath(int approxLength);
118
121
125 void setHead(SoNode *node);
126
129 void append(int childIndex);
130
135 void append(SoNode *childNode);
136
139 void append(const SoPath *fromPath);
140
143 void push(int childIndex) { append(childIndex); }
146 void pop() { truncate(getFullLength() - 1); }
147
149 SoNode * getHead() const { return nodes[0]; }
151 SoNode * getTail() const { return (nodes[getLength() - 1]); }
152
155 SoNode * getNode(int i) const { return (nodes[i]); }
156
159 SoNode * getNodeFromTail(int i) const
160 { return (nodes[getLength() - 1 - i]); }
161
164 int getIndex(int i) const { return (indices[i]); }
165
169 int getIndexFromTail(int i) const
170 { return (indices[getLength() - 1 - i]); }
171
173 int getLength() const;
174
179 void truncate(int start);
180
182 bool containsNode(const SoNode *node) const;
183
186 bool containsPath(const SoPath *path) const;
187
191 int findFork(const SoPath *path) const;
192
197 SoPath * copy(int startFromNodeIndex = 0,
198 int numNodes = 0) const;
199
201 friend INVENTOR_API bool operator ==(const SoPath &p1, const SoPath &p2);
202
204 virtual SoType getTypeId() const;
205
207 static SoType getClassTypeId() { return classTypeId; }
208
210 static SoPath * getByName(const SbName &name);
222 static int getByName(const SbName &name, SoPathList &list);
223
224 SoINTERNAL public:
226 static void initClass();
227
230 void insertIndex(SoNode *parent, int newIndex);
231
234 void removeIndex(SoNode *parent, int oldIndex);
235
238 void replaceIndex(SoNode *parent, int index,
239 SoNode *newChild);
240
242 virtual void write(SoWriteAction *writeAction) const;
243
248
249 protected:
251 void auditPath(bool flag) { doAuditors = flag; }
252
254
255 private:
256 SoNodeList nodes;
257 SbIntList indices;
258 int numPublic;
259 int minNumPublic;
260 bool doAuditors;
261 static SoType classTypeId;
262
264 int getFullLength() const { return nodes.getLength(); }
265
268 void append(SoNode *node, int index);
269
271 static void * createInstance();
272
274 virtual bool readInstance(SoInput *in, unsigned short flags);
275
277 void truncate(int start, bool doNotify);
278
279friend class SoFullPath;
280friend class SoTempPath;
281friend class SoAction;
282};
283
284INVENTOR_API bool operator ==(const SoPath &p1, const SoPath &p2);
285
298
300
301 public:
305
308 void pop() { truncate(getFullLength() - 1); }
309
311 SoNode * getTail() const
312 { return (nodes[getFullLength() - 1]); }
313
315 SoNode * getNodeFromTail(int i) const
316 { return (nodes[getFullLength() - 1 - i]); }
317
321 int getIndexFromTail(int i) const
322 { return (indices[getFullLength() - 1 - i]); }
323
325 int getLength() const { return getFullLength(); }
326
327 private:
328 SoFullPath(int approxLength) : SoPath(approxLength) {}
329 virtual ~SoFullPath();
330
331friend class SoTempPath;
332};
333
334
335
348
349
351
352 SoINTERNAL public:
353
355 SoLightweightPath(int approxLength);
356
357
360 void setHead(SoNode *node);
361
363 void append(int childIndex)
364 { indices.append(childIndex);}
365
366
369 void push(int childIndex) { append(childIndex); }
370 void push() { append(-1);}
371 void pop() { truncate(getFullLength() - 1); }
372 void setTail(int childIndex)
373 { indices.set(getFullLength()-1,(void *)(size_t)childIndex);}
375 { return getNode(getFullLength()-1);}
376
378 SoNode * getHead() const { return headNode; }
379
381 SoNode * getNode(int i) const;
382
385 int getFullLength() const {return indices.getLength();}
386
388 void truncate(int start) { indices.truncate(start);}
389
390
393 void makeTempPath(SoTempPath *tmpPath) const;
394
396
397 private:
398
399 SoNode * headNode;
400 SbIntList indices;
401
402
403 friend class SoAction;
404};
405
406
407
408#endif /* _SO_PATH_ */
#define SoEXTENDER
Provide inline template functions for abs, swap, min, max, and clamp.
Definition SbBasic.h:154
#define SoINTERNAL
Definition SbBasic.h:155
INVENTOR_API bool operator==(const SbBox3f &b1, const SbBox3f &b2)
#define INVENTOR_API
Disable some annoying warnings on MSVC 6.
Definition SbSystem.h:77
INVENTOR_API bool operator==(const SoPath &p1, const SoPath &p2)
List of generic (void *) pointers.
Definition SbPList.h:173
void append(int integer)
Adds given pointer to end of list.
Definition SbPList.h:181
Character string stored in a hash table.
Definition SbString.h:264
void truncate(int start)
Removes all pointers after one with given index, inclusive.
Definition SbPList.h:113
void set(int i, void *j)
Definition SbPList.h:136
int getLength() const
Returns number of pointers in list.
Definition SbPList.h:110
Abstract base class for all actions.
Definition SoAction.h:179
Base class for all nodes, paths, and engines.
Definition SoBase.h:90
virtual bool readInstance(SoInput *in, unsigned short flags)=0
Reads stuff into instance of subclass.
This SoEXTENDER class allows expert users to examine "hidden" children in paths.
Definition SoPath.h:299
void pop()
Override methods that normally stop at last public child:
Definition SoPath.h:308
SoNode * getNodeFromTail(int i) const
Returns a pointer to the i'th node. Passing 0 for i returns the tail node.
Definition SoPath.h:315
int getLength() const
Returns length of path chain (number of nodes).
Definition SoPath.h:325
int getIndexFromTail(int i) const
Returns the index of the i'th node (within its parent) in the chain, counting backward from the tail ...
Definition SoPath.h:321
SoNode * getTail() const
These return the first and last nodes in a path chain.
Definition SoPath.h:311
Used to read Inventor data files.
Definition SoInput.h:128
A SoLightweightPath is a light-weight version of an SoTempPath, intended to be used just to keep trac...
Definition SoPath.h:350
SoNode * getNode(int i) const
Returns pointer to ith node in chain.
void setTail(int childIndex)
Definition SoPath.h:372
void push(int childIndex)
Allows path to be treated as a stack: push a node at the end of the chain and pop the last node off.
Definition SoPath.h:369
void makeTempPath(SoTempPath *tmpPath) const
fills in nodes for a TempPath that is represented by this SoLightweightPath.
SoLightweightPath(int approxLength)
Constructor given approximate number of nodes in chain.
void truncate(int start)
Removes all nodes from indexed node on.
Definition SoPath.h:388
SoNode * getTail()
Definition SoPath.h:374
int getFullLength() const
Returns full length of path chain (number of nodes) note that public/private distinction is ignored.
Definition SoPath.h:385
void append(int childIndex)
Adds node specified by childindex to end of chain.
Definition SoPath.h:363
SoNode * getHead() const
Returns the first node in a path chain.
Definition SoPath.h:378
void setHead(SoNode *node)
Sets head node (first node in chain) Resulting path has only one node.
Maintains a list of pointers to nodes.
Definition SoLists.h:177
Abstract base class for all database nodes.
Definition SoNode.h:103
Holds a list of SoNotRec notification records.
Maintains a list of pointers to paths.
Definition SoLists.h:212
Path that points to a list of hierarchical nodes.
Definition SoPath.h:109
bool isRelevantNotification(SoNotList *list) const
Returns TRUE if the given notification list involves a change to a node that affects the path.
SoPath()
Constructs an empty path.
SoPath(int approxLength)
Constructs a path with a hint to length (number of nodes in chain).
bool containsNode(const SoNode *node) const
Returns TRUE if the node is found anywhere in the path chain.
SoPath * copy(int startFromNodeIndex=0, int numNodes=0) const
Creates and returns a new path that is a copy of some or all of this path.
void insertIndex(SoNode *parent, int newIndex)
This is called when a node in the path chain has a child added.
SoPath(SoNode *node)
Constructs a path and sets the head node to the given node.
static int getByName(const SbName &name, SoPathList &list)
These methods lookup and return paths with a given name.
void pop()
These allow a path to be treated as a stack; they push a node at the end of the chain and pop the las...
Definition SoPath.h:146
virtual void write(SoWriteAction *writeAction) const
Writes path using given write action.
void append(int childIndex)
Adds node to end of chain; the node is the childIndex'th child of the current tail node.
SoNode * getHead() const
These return the first and last nodes in a path chain.
Definition SoPath.h:149
int getLength() const
Returns length of path chain (number of nodes).
void setHead(SoNode *node)
Sets head node (first node in chain).
void replaceIndex(SoNode *parent, int index, SoNode *newChild)
This is called when a node in the path chain replaces a child.
void auditPath(bool flag)
Allows internal SoTempPath subclass to forego auditor overhead.
Definition SoPath.h:251
void append(SoNode *childNode)
Adds node to end of chain; uses the first occurrence of childNode as child of current tail node.
static SoType getClassTypeId()
Returns type identifier for SoPath class.
Definition SoPath.h:207
void truncate(int start)
Truncates the path chain, removing all nodes from index start on.
void removeIndex(SoNode *parent, int oldIndex)
This is called when a node in the path chain has a child removed.
SoNode * getNode(int i) const
Returns a pointer to the i'th node in the chain.
Definition SoPath.h:155
int getIndex(int i) const
Return the index of the i'th node (within its parent) in the chain.
Definition SoPath.h:164
static void initClass()
Initializes path class.
int findFork(const SoPath *path) const
If the two paths have different head nodes, this returns -1.
void push(int childIndex)
These allow a path to be treated as a stack; they push a node at the end of the chain and pop the las...
Definition SoPath.h:143
SoNode * getNodeFromTail(int i) const
Returns a pointer to the i'th node.
Definition SoPath.h:159
int getIndexFromTail(int i) const
Return the index of the i'th node (within its parent) in the chain, counting backward from the tail n...
Definition SoPath.h:169
virtual SoType getTypeId() const
Returns type identifier for path instance.
static SoPath * getByName(const SbName &name)
SoNode * getTail() const
These return the first and last nodes in a path chain.
Definition SoPath.h:151
void append(const SoPath *fromPath)
Adds all nodes in fromPath's chain to end of chain; the head node of fromPath must be the same as or ...
bool containsPath(const SoPath *path) const
Returns TRUE if the nodes in the chain in the passed path are contained (in consecutive order) in thi...
This class is internal to Inventor.
Definition SoTempPath.h:74
SoType has no virtual functions to keep it small...
Definition SoType.h:103
Writes a scene graph to a file.