Open Inventor Release 2024.1.1
 
Loading...
Searching...
No Matches
SoNode.h
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-2023 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
54#include <Inventor/fields/SoFieldContainer.h>
55#include <Inventor/nodes/SoSubNode.h>
56#include <Inventor/SoLists.h>
57#include <Inventor/SbString.h>
58#include <Inventor/SoType.h>
59#include <Inventor/sensors/SoDataSensor.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}
104SO_PIMPL_BASE_PUBLIC_DECLARATION(SoNode)
105
106
107//
108// Class: SoNode
109//
110// Base SoNode class (abstract).
111//
113
114
115
145class SoNode : public SoFieldContainer {
146
147 SO_NODE_ABSTRACT_HEADER(SoNode);
148 SO_PIMPL_BASE_PUBLIC_HEADER(SoNode)
149
150 public:
151
199 inline virtual void setOverride(const SbBool state);
200
204 inline virtual SbBool isOverride() const;
205
220 virtual SoNode * copy(SbBool copyConnections = FALSE) const;
221
227 virtual SbBool affectsState() const;
228
234 static SoNode * getByName(const SbName &name);
235
242 static int getByName(const SbName &name, SoNodeList &list);
243
244 virtual void touch();
245
246private:
247
260 inline virtual SoNode* getAlternateRep(SoAction* action);
261
268 inline virtual SbBool isBoundingBoxIgnoring() const;
269
270 // This method performs the "typical" operation of a node for any
271 // action. The default implementation does nothing.
272 virtual void doAction(SoAction *action);
273
274 // These virtual functions implement all of the actions for nodes,
275 // Most of the default implementations do nothing.
276 virtual void GLRender(SoGLRenderAction *action);
277 virtual void callback(SoCallbackAction *action);
278 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
279 virtual void getMatrix(SoGetMatrixAction *action);
280 virtual void handleEvent(SoHandleEventAction *action);
281 virtual void pick(SoPickAction *action);
282 virtual void rayPick(SoRayPickAction *action);
283 virtual void search(SoSearchAction *action);
284 virtual void write(SoWriteAction *action);
285 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action);
286 virtual void distribute(SoDistributeAction *action);
287
288 // These methods make render traversal faster by implementing
289 // different rendering paths corresponding to different action
290 // path codes. The SoNode methods just call GLRender.
291 virtual void GLRenderBelowPath(SoGLRenderAction *action);
292 virtual void GLRenderInPath(SoGLRenderAction *action);
293 virtual void GLRenderOffPath(SoGLRenderAction *action);
294
295 // These virtual functions are called when a node gains or loses
296 // status as "grabber" of events (see HandleEventAction::setGrabber()).
297 // The default methods do nothing.
298 virtual void grabEventsSetup();
299 virtual void grabEventsCleanup();
300
301 //
302 // This virtual function is called when ScaleViz want to now
303 // if the parent separator must be traversed or not in compositing mode.
304 //
305 // By default such decision is taken by the Separator iteself through the
306 // renderUnitID field and then returned value is SO_RENDERUNITID_INHERIT.
307 //
308 // For some class of nodes we want to force a specific values.
309 //
310 // example :
311 // - SoTransparency node in Depth Compositing on OIRU side return SO_RENDERUNITID_ALL
312 // to force all transparent node below the separator to be rendered on all OIRU.
313 //
314 virtual int32_t getRenderUnitID() const;
315
316 private:
317
318 // Creates and returns an exact copy of the node and returns the
319 // dictionary of original and new nodes. This method is used when
320 // creating the PROTOInstances on the fly.
321 SoNode * copyForPROTO(SbBool copyConnections = FALSE) const;
322 enum Stage {
323 FIRST_INSTANCE, // First real instance being constructed
324 PROTO_INSTANCE, // Prototype instance being constructed
325 OTHER_INSTANCE // Subsequent instance being constructed
326 };
327
328 // Initializes base node class
329 static void initClass();
330 static void exitClass();
331
332 // Initialize ALL Inventor node classes
333 static void initClasses();
334 static void exitClasses();
335
336 // Initiates notification from an instance.
337 virtual void startNotify();
338
339 // Propagates modification notification through an instance.
340 virtual void notify(SoNotList *list);
341
342 // Returns the unique id for a node
343 uint64_t getNodeId() const { return m_uniqueId; }
344
345 // Returns the next available unique id
346 static uint64_t getNextNodeId();
347
348 // Returns pointer to children, or NULL if none
349 virtual SoChildList *getChildren() const;
350 virtual bool isSynchronizingContentOnly() { return FALSE; }
351 virtual SoChildList *internalGetChildren() const;
352
353 virtual void internalRemoveChild(int);
354 virtual void internalRemoveChild(SoNode *);
355 virtual void internalRemoveAllChildren();
359 virtual void internalAddChild(SoNode *);
360 virtual int internalFindChild(const SoNode *) const;
361 virtual void internalInsertChild(SoNode *, int);
362 virtual SoNode *internalGetChild( int ) const;
363 virtual void internalReplaceChild(int, SoNode *);
364 virtual void internalReplaceChild(SoNode *, SoNode *);
365 virtual int internalGetNumChildren();
366
367 // Get details of change (only valid during notification)
368 SoNode* getChangedChild() const;
369 int getChangedIndex() const;
370 SoDataSensor::ChangeType getChangeType() const;
371
372 // Writes instance to SoOutput. (Used for either stage of writing.)
373 virtual void writeInstance(SoOutput *out);
374
375 // Returns the index of this node in the action/method table,
376 // given its type.
377 static int getActionMethodIndex(SoType t);
378
379 // Recursively adds this node and all nodes under it to the copy
380 // dictionary. Returns the copy of this node.
381 virtual SoNode * addToCopyDict() const;
382
383 // Copies the contents of the given node into this instance. The
384 // default implementation copies just field values and the name.
385 virtual void copyContents(const SoFieldContainer *fromFC,
386 SbBool copyConnections);
387
388 // Copies an instance that is encountered through a field connection
389 virtual SoFieldContainer * copyThroughConnection() const;
390
391 // Get the curent node alternate representation
392 // Cache the alternate rep if requested.
393 SoNode* getCachedAlternateRep(SoAction* action, SbBool doCache = FALSE);
394
400 virtual bool affectsPath() const;
401
402 // added to manage global node operations for shapes
403 virtual void GLRenderP(SoGLRenderAction *action);
404
405 private:
406
407 static void setNextActionMethodIndex(int index);
408 static int getNextActionMethodIndex();
409 static void incNextActionMethodIndex();
410
411 // Constructor, destructor
412 SoNode();
413 virtual ~SoNode();
414
415 private:
416 // Unique id for this node.
417 uint64_t m_uniqueId;
418
419 // Next index into the action method table
420 static int nextActionMethodIndex;
421
422 // These static methods are registered with the database - they
423 // simply call the appropriate virtual function
424 static void callbackS(SoAction *, SoNode *);
425 static void GLRenderS(SoAction *, SoNode *);
426 static void getBoundingBoxS(SoAction *, SoNode *);
427 static void getMatrixS(SoAction *, SoNode *);
428 static void handleEventS(SoAction *, SoNode *);
429 static void pickS(SoAction *, SoNode *);
430 static void rayPickS(SoAction *, SoNode *);
431 static void searchS(SoAction *, SoNode *);
432 static void writeS(SoAction *, SoNode *);
433 static void getPrimitiveCountS(SoAction *, SoNode *);
434
435 static void distributeS(SoAction *, SoNode *);
436
437 void commonConstructor();
438
439 // method to provide forward traversal
440 template < class SPEC_ACTION >
441 static void traverseS(SoAction *action, SoNode *node);
442 // helper to get node to traverse internally
443 SoNode* getNodeToTraverse(SoAction* action, bool force = false);
444
445 SoNode* m_cachedAlternateRep;
446
447 private:
448
449 //---------------------------------------------
450
451 SbProjectionCoordinates *getProjectionCoordinates(){return m_projCoords;}
452
453 void setProjectionCoordinates(SbProjectionCoordinates *projCoords){
454 m_projCoords = projCoords;
455 }
456
457 //Projections
458 private:
459 SbProjectionCoordinates *m_projCoords;
460
461 private:
462
463 // hold envvar OIV_CATCH_GLERROR for debugging purpose
464 static bool s_catchGLError;
465
466 // TO BE DELETED AS SOON AS REWORK OF THESE CLASSES IS DONE
467 friend class SoTraversalPassImpl;
468 friend class SoLdmValuationAction;
469 friend class SoPath;
470 friend class SoLightPath;
471 friend class SoAction;
472 friend class StringConcatCallback;
473 friend class SoChildList;
474 friend class SoCacheElement;
475 friend class inventor::impl::SoCachedGroupImpl;
476 friend class inventor::node::SoConstNode;
477 friend class SoCallbackAction;
478};
479
480SoNode*
481SoNode::getAlternateRep(SoAction*)
482{
483 return this;
484}
485
486SbBool
487SoNode::isBoundingBoxIgnoring() const
488{
489 return FALSE;
490}
491
492void
494{
495#if defined(_DEBUG)
496 SoDebugError::postWarning("SoNode::setOverride","not reimplemented and supported for this inherited node");
497#endif
498}
499
500SbBool
502{
503 return FALSE;
504}
505
506#ifdef _WIN32
507#pragma warning(pop)
508#endif
509
510#endif /* _SO_NODE_ */
511
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:493
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:501
Maintains a list of pointers to nodes.
Definition SoNodeList.h:74
Used to write Open Inventor data files.
Definition SoOutput.h:186
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