Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoNode.h
Go to the documentation of this file.
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : Paul S. Strauss (MMM yyyy)
25** Modified by : Nick Thompson (MMM yyyy)
26**=======================================================================*/
27/*=======================================================================
28 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
29 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
30 *** ***
31 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
32 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
33 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
34 *** ***
35 *** RESTRICTED RIGHTS LEGEND ***
36 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
37 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
38 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
39 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
40 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
41 *** ***
42 *** COPYRIGHT (C) 1996-2021 BY FEI S.A.S, ***
43 *** BORDEAUX, FRANCE ***
44 *** ALL RIGHTS RESERVED ***
45**=======================================================================*/
46/*=======================================================================
47** Modified by : VSG (MMM YYYY)
48**=======================================================================*/
49
50
51#ifndef _SO_NODE_
52#define _SO_NODE_
53
56#include <Inventor/SoLists.h>
57#include <Inventor/SbString.h>
58#include <Inventor/SoType.h>
60#include <Inventor/STL/vector>
61#include <Inventor/SbPImpl.h>
62#include <bitset>
63
64#ifdef _WIN32
65#pragma warning(push)
66#pragma warning(disable:4251)
67#endif
68
69class SoNodeList;
70class SoAction;
72class SoChildList;
73class SoFieldData;
78class SoInput;
79class SoOutput;
80class SoPickAction;
81class SoRayPickAction;
82class SoSearchAction;
83class SoWriteAction;
86class SoComputeRenderUnitIDAction;
88class SoState;
89
91namespace inventor
92{
93namespace impl
94{
95class SoCachedGroupImpl;
96}
97namespace node
98{
99class SoConstNode;
100}
101}
105
106
107//
108// Class: SoNode
109//
110// Base SoNode class (abstract).
111//
113
114
115
145class SoNode : public SoFieldContainer {
146
148 SO_PIMPL_BASE_PUBLIC_HEADER(SoNode)
149
150 public:
151
198 inline virtual void setOverride(const SbBool state);
199
203 inline virtual SbBool isOverride() const;
204
219 virtual SoNode * copy(SbBool copyConnections = FALSE) const;
220
226 virtual SbBool affectsState() const;
227
233 static SoNode * getByName(const SbName &name);
234
241 static int getByName(const SbName &name, SoNodeList &list);
242
243 virtual void touch();
244
245private:
246
259 inline virtual SoNode* getAlternateRep(SoAction* action);
260
267 inline virtual SbBool isBoundingBoxIgnoring() const;
268
269 // This method performs the "typical" operation of a node for any
270 // action. The default implementation does nothing.
271 virtual void doAction(SoAction *action);
272
273 // These virtual functions implement all of the actions for nodes,
274 // Most of the default implementations do nothing.
275 virtual void GLRender(SoGLRenderAction *action);
276 virtual void callback(SoCallbackAction *action);
277 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
278 virtual void getMatrix(SoGetMatrixAction *action);
279 virtual void handleEvent(SoHandleEventAction *action);
280 virtual void pick(SoPickAction *action);
281 virtual void rayPick(SoRayPickAction *action);
282 virtual void search(SoSearchAction *action);
283 virtual void write(SoWriteAction *action);
284 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action);
285 virtual void distribute(SoDistributeAction *action);
286
287 // These methods make render traversal faster by implementing
288 // different rendering paths corresponding to different action
289 // path codes. The SoNode methods just call GLRender.
290 virtual void GLRenderBelowPath(SoGLRenderAction *action);
291 virtual void GLRenderInPath(SoGLRenderAction *action);
292 virtual void GLRenderOffPath(SoGLRenderAction *action);
293
294 // These virtual functions are called when a node gains or loses
295 // status as "grabber" of events (see HandleEventAction::setGrabber()).
296 // The default methods do nothing.
297 virtual void grabEventsSetup();
298 virtual void grabEventsCleanup();
299
300 //
301 // This virtual function is called when ScaleViz want to now
302 // if the parent separator must be traversed or not in compositing mode.
303 //
304 // By default such decision is taken by the Separator iteself through the
305 // renderUnitID field and then returned value is SO_RENDERUNITID_INHERIT.
306 //
307 // For some class of nodes we want to force a specific values.
308 //
309 // example :
310 // - SoTransparency node in Depth Compositing on OIRU side return SO_RENDERUNITID_ALL
311 // to force all transparent node below the separator to be rendered on all OIRU.
312 //
313 virtual int32_t getRenderUnitID() const;
314
315 private:
316
317 // Creates and returns an exact copy of the node and returns the
318 // dictionary of original and new nodes. This method is used when
319 // creating the PROTOInstances on the fly.
320 SoNode * copyForPROTO(SbBool copyConnections = FALSE) const;
321 enum Stage {
322 FIRST_INSTANCE, // First real instance being constructed
323 PROTO_INSTANCE, // Prototype instance being constructed
324 OTHER_INSTANCE // Subsequent instance being constructed
325 };
326
327 // Initializes base node class
328 static void initClass();
329 static void exitClass();
330
331 // Initialize ALL Inventor node classes
332 static void initClasses();
333 static void exitClasses();
334
335 // Initiates notification from an instance.
336 virtual void startNotify();
337
338 // Propagates modification notification through an instance.
339 virtual void notify(SoNotList *list);
340
341 // Returns the unique id for a node
342 uint64_t getNodeId() const { return m_uniqueId; }
343
344 // Returns the next available unique id
345 static uint64_t getNextNodeId();
346
347 // Returns pointer to children, or NULL if none
348 virtual SoChildList *getChildren() const;
349 virtual bool isSynchronizingContentOnly() { return FALSE; }
350 virtual SoChildList *internalGetChildren() const;
351
352 virtual void internalRemoveChild(int);
353 virtual void internalRemoveChild(SoNode *);
354 virtual void internalRemoveAllChildren();
358 virtual void internalAddChild(SoNode *);
359 virtual int internalFindChild(const SoNode *) const;
360 virtual void internalInsertChild(SoNode *, int);
361 virtual SoNode *internalGetChild( int ) const;
362 virtual void internalReplaceChild(int, SoNode *);
363 virtual void internalReplaceChild(SoNode *, SoNode *);
364 virtual int internalGetNumChildren();
365
366 // Get details of change (only valid during notification)
367 SoNode* getChangedChild() const;
368 int getChangedIndex() const;
369 SoDataSensor::ChangeType getChangeType() const;
370
371 // Writes instance to SoOutput. (Used for either stage of writing.)
372 virtual void writeInstance(SoOutput *out);
373
374 // Returns the index of this node in the action/method table,
375 // given its type.
376 static int getActionMethodIndex(SoType t);
377
378 // Recursively adds this node and all nodes under it to the copy
379 // dictionary. Returns the copy of this node.
380 virtual SoNode * addToCopyDict() const;
381
382 // Copies the contents of the given node into this instance. The
383 // default implementation copies just field values and the name.
384 virtual void copyContents(const SoFieldContainer *fromFC,
385 SbBool copyConnections);
386
387 // Copies an instance that is encountered through a field connection
388 virtual SoFieldContainer * copyThroughConnection() const;
389
390 // Get the curent node alternate representation
391 // Cache the alternate rep if requested.
392 SoNode* getCachedAlternateRep(SoAction* action, SbBool doCache = FALSE);
393
399 virtual bool affectsPath() const;
400
401 // added to manage global node operations for shapes
402 virtual void GLRenderP(SoGLRenderAction *action);
403
404 private:
405
406 static void setNextActionMethodIndex(int index);
407 static int getNextActionMethodIndex();
408 static void incNextActionMethodIndex();
409
410 // Constructor, destructor
411 SoNode();
412 virtual ~SoNode();
413
414 private:
415 // Unique id for this node.
416 uint64_t m_uniqueId;
417
418 // Next index into the action method table
419 static int nextActionMethodIndex;
420
421 // These static methods are registered with the database - they
422 // simply call the appropriate virtual function
423 static void callbackS(SoAction *, SoNode *);
424 static void GLRenderS(SoAction *, SoNode *);
425 static void getBoundingBoxS(SoAction *, SoNode *);
426 static void getMatrixS(SoAction *, SoNode *);
427 static void handleEventS(SoAction *, SoNode *);
428 static void pickS(SoAction *, SoNode *);
429 static void rayPickS(SoAction *, SoNode *);
430 static void searchS(SoAction *, SoNode *);
431 static void writeS(SoAction *, SoNode *);
432 static void getPrimitiveCountS(SoAction *, SoNode *);
433
434 static void distributeS(SoAction *, SoNode *);
435
436 void commonConstructor();
437
438 // method to provide forward traversal
439 template < class SPEC_ACTION >
440 static void traverseS(SoAction *action, SoNode *node);
441 // helper to get node to traverse internally
442 SoNode* getNodeToTraverse(SoAction* action, bool force = false);
443
444 SoNode* m_cachedAlternateRep;
445
446 private:
447
448 //---------------------------------------------
449
450 SbProjectionCoordinates *getProjectionCoordinates(){return m_projCoords;}
451
452 void setProjectionCoordinates(SbProjectionCoordinates *projCoords){
453 m_projCoords = projCoords;
454 }
455
456 //Projections
457 private:
458 SbProjectionCoordinates *m_projCoords;
459
460 private:
461
462 // hold envvar OIV_CATCH_GLERROR for debugging purpose
463 static bool s_catchGLError;
464
465 // TO BE DELETED AS SOON AS REWORK OF THESE CLASSES IS DONE
466 friend class SoTraversalPassImpl;
467 friend class SoLdmValuationAction;
468 friend class SoPath;
469 friend class SoLightPath;
470 friend class SoAction;
471 friend class StringConcatCallback;
472 friend class SoChildList;
473 friend class SoCacheElement;
474 friend class inventor::impl::SoCachedGroupImpl;
475 friend class inventor::node::SoConstNode;
476 friend class SoCallbackAction;
477};
478
479SoNode*
480SoNode::getAlternateRep(SoAction*)
481{
482 return this;
483}
484
485SbBool
486SoNode::isBoundingBoxIgnoring() const
487{
488 return FALSE;
489}
490
491void
493{
494#if defined(_DEBUG)
495 SoDebugError::postWarning("SoNode::setOverride","not reimplemented and supported for this inherited node");
496#endif
497}
498
499SbBool
501{
502 return FALSE;
503}
504
505#ifdef _WIN32
506#pragma warning(pop)
507#endif
508
509#endif /* _SO_NODE_ */
510
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
SoFieldData(const SoFieldData *)
SO_PIMPL_BASE_PUBLIC_DECLARATION(SoImageDataAdapter)
#define SO_NODE_ABSTRACT_HEADER(className)
Definition SoSubNode.h:118
Character string stored in a hash table.
Definition SbName.h:162
Cache projected coordinates.
Abstract base class for all actions.
Definition SoAction.h:132
Stores the most recently opened cache.
Performs a generic traversal of a scene graph or path.
ChangeType
Change type.
static void postWarning(const char *methodName, const char *formatString ...)
Posts a warning.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Computes a distr...
Abstract base class for objects that contain fields.
Renders a scene graph using Open Inventor's Render Engine.
Computes bounding box of a scene.
Computes transformation matrix for a subgraph.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Counts number of...
Allows nodes in a graph to receive input events.
Used to read Open Inventor data files.
Definition SoInput.h:363
Abstract base class for all database nodes.
Definition SoNode.h:145
static int getByName(const SbName &name, SoNodeList &list)
A node's name can be set using SoBase::setName().
virtual void setOverride(const SbBool state)
Turns the override flag on or off.
Definition SoNode.h:492
virtual SbBool affectsState() const
Returns TRUE if a node has an effect on the state during traversal.
static SoNode * getByName(const SbName &name)
A node's name can be set using SoBase::setName().
virtual void touch()
Marks an instance as modified, simulating a change to it.
virtual SoNode * copy(SbBool copyConnections=FALSE) const
Creates and returns an exact copy of the node.
virtual SbBool isOverride() const
Returns the state of the override flag.
Definition SoNode.h:500
Maintains a list of pointers to nodes.
Definition SoNodeList.h:74
Used to write Open Inventor data files.
Definition SoOutput.h:185
Path that points to a list of hierarchical nodes.
Definition SoPath.h:187
Abstract base class for picking objects in a scene.
Intersects objects with a ray cast into scene.
Searches for nodes in a scene graph.
Traversal state.
Definition SoState.h:74
Stores runtime type information.
Definition SoType.h:98
Writes a scene graph to a file.
int SbBool
Boolean type.
Definition SbBase.h:87
void notify(SoNotList *list)
SoChildList(SoNode *parentNode, int size)
void getChildren(int &numIndices, const int *&indices)