Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoShape.h
Go to the documentation of this file.
1
2/*=======================================================================
3 * Copyright 1991-1996, Silicon Graphics, Inc.
4 * ALL RIGHTS RESERVED
5 *
6 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
7 * States. Use of a copyright notice is precautionary only and does not
8 * imply publication or disclosure.
9 *
10 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
11 * Use, duplication or disclosure by the Government is subject to restrictions
12 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
13 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
14 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
15 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
16 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
17 *
18 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
19 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
20 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
21 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
22 * GRAPHICS, INC.
23**=======================================================================*/
24/*=======================================================================
25** Author : Paul S. Strauss (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-2022 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_SHAPE_
52#define _SO_SHAPE_
53
54#include <Inventor/SbBox.h>
55#include <Inventor/SbMatrix.h>
58#include <Inventor/SbPImpl.h>
59
60class SoDetail;
61class SbVec2s;
62class SoFaceDetail;
63class SoPickedPoint;
65class SoState;
66class SoMFInt32;
67class PickedPointListImpl;
68
71
73
74
75//
76// Class: SoShape
77//
78// Abstract base shape node class, which provides some convenience
79// functions for its subclasses.
80//
82
114class SoShape : public SoNode
115{
117 SO_PIMPL_PUBLIC_HEADER(SoShape)
118
119 public:
124
128 virtual SbBool affectsState() const;
129
145
150
160
161 private:
162
168 enum TriangleShape {
169 TRIANGLE_STRIP,
170 TRIANGLE_FAN,
171 TRIANGLES,
172 POLYGON,
173 SEGMENT_STRIP,
174 POINT_SET
175 };
176
199 void beginShape( SoAction *action, TriangleShape shapeType,
200 SoFaceDetail *faceDetail = NULL);
201
206 void shapeVertex(const SoPrimitiveVertex *v);
207
208
209
213 void endShape();
214
219 virtual void getBoundingBox(SoGetBoundingBoxAction *action);
220
225 virtual void GLRender(SoGLRenderAction *action);
226
232 virtual void rayPick(SoRayPickAction *action);
233
238 virtual void callback(SoCallbackAction *action);
239
246 static void getScreenSize(SoState *state, const SbBox3f &boundingBox, SbVec2s &rectSize);
247
256 static float getDecimatedComplexity(SoState *state, float complexity);
257
265 virtual void computeBBox(SoAction *action, SbBox3f &box, SbVec3f &center) = 0;
266
283 virtual void computeBBox(SoAction *action, SbXfBox3d &box, SbVec3d &center)
284 {
285 // SubClass did not redefine this function so by default use AABB version
286 SbBox3f boxf;
287 SbVec3f centerf;
288 computeBBox(action, boxf, centerf);
289
291 box.makeEmpty();
292 box.setBounds(SbVec3d(boxf.getMin().getValue()),SbVec3d(boxf.getMax().getValue()));
293 center.setValue(centerf);
294 }
295
301 inline virtual SbBool isBoundingBoxIgnoring() const
302 { return boundingBoxIgnoring.getValue(); }
303
309 virtual void getPrimitiveCount(SoGetPrimitiveCountAction *action);
310
311 // Gets multi-texturing info:
312 // - Indicates if the multi-texturing is active
313 // - The list of texture units where texture coordinate should be sent (that is
314 // where texture coordinates different from a function.)
315 static SbBool getMultiTextureInfo(SoState *state, SbIntList &imageTextUnitList) ;
316
320 void setShapeType(SoShape::ShapeType st);
321
322 // These methods invoke whatever callbacks are registered with the
323 // primitive generation procedures. If primitives are being
324 // generated for picking or rendering purposes, the appropriate
325 // SoShape methods are called. If primitives are being generated
326 // for the SoCallbackAction, the callbacks registered with the
327 // action are called.
328 void invokeTriangleCallbacks(SoAction *action,
329 const SoPrimitiveVertex *v1,
330 const SoPrimitiveVertex *v2,
331 const SoPrimitiveVertex *v3);
332
333 void invokeLineSegmentCallbacks(SoAction *action,
334 const SoPrimitiveVertex *v1,
335 const SoPrimitiveVertex *v2);
336
337 void invokePointCallbacks(SoAction *action,
338 const SoPrimitiveVertex *v);
339
340
341 private:
342 static void initClass();
343 static void exitClass();
344
345 // redefined for Shapes
346 virtual void GLRenderP(SoGLRenderAction *action);
347
349
350 // It is possible to disable projection for a given shape even if the element is set
351 SbBool m_forceDisableProjection;
352
353 void setForceDisableProjection( SbBool disable ){m_forceDisableProjection = disable;}
354
355 static bool isVertexArrayAvailable(SoState* state=NULL);
356 static bool isMultiDrawArrayAvailable(SoState* state=NULL);
357 static bool isVertexBufferAvailable(SoState* state=NULL);
358
359 // Returns 0 if not available, 1 if NV version, 2 if core
360 static int getPrimitiveRestartMode(SoState* state = NULL);
361
362 static int getMaxPrimitiveLoop();
363
364 static int getMinVertexNumForVA();
365
366 static int getMinVertexNumForVBO();
367
368 static int getMinVertexNumForVAVBONoCache();
369
370 static bool isDesindexingAllowed();
371
372 static bool isTrisStripAllowedForQuadMesh();
373
374 static SbBool isDetailDebugEnabled();
375
376 static bool isCreaseAngleFixSet();
377
378 // This endShape is used by SoIndexedFaceSet and SoFaceSet to create hole
379 // in a face.
380 void endShape( int wt, SoMFInt32* indexes );
381
382 // Returns TRUE if the shape should be rendered. Subclasses can
383 // call this in their rendering methods to determine whether to
384 // continue.
385 SbBool shouldPrimitiveCount(SoGetPrimitiveCountAction *action);
386
387 virtual int getNumVert(SoState *state = NULL ){ return getNumPrim( state ); }
388
389 virtual int getNumPrim( SoState *state = NULL );
390
391 inline SbBool isRenderable(SoGLRenderAction* action)
392 {
393 return shouldGLRender(action, FALSE);
394 }
395
396 private:
397
398 SoShape();
399
400 virtual SbBool checkShapeHints(SoGLRenderAction *action);
401
402 inline virtual void countPrim( SoState *state = NULL );
403
404 virtual SbBool checkTransparency(SoGLRenderAction *action, SbBool isPointsOrLines);
405
406 virtual SbBool isRenderingPointsOrLines(SoGLRenderAction *action);
407
408 virtual SbBool shouldRenderNow(SoGLRenderAction *action,SbBool &isPointsOrLines);
409
410 //-------------------------------------------------------------------------------
411
412 // This method MUST be defined by each subclass to generate
413 // primitives (triangles, line segments, points) that represent
414 // the shape.
415 virtual void generatePrimitives(SoAction *action) = 0;
416
417 // Returns TRUE if the shape should be rendered. Subclasses can
418 // call this in their rendering methods to determine whether to
419 // continue.
420 virtual SbBool shouldGLRender(SoGLRenderAction *action,
421 SbBool isPointsOrLines = FALSE);
422
423 // Implementation of shouldGLRender to split the general case
424 // to tessellationShader support case. shouldGLRender always
425 // return false if tessellation shaders are on the state. This
426 // method is called for every shape with no tessellation shaders on the
427 // state and bufferedShape.
428 SbBool shouldGLRenderCore(SoGLRenderAction *action,
429 SbBool isPointsOrLines = FALSE,
430 SbBool hasTessellationShader = FALSE);
431
432 // Returns FALSE if the shape is invisible. If the complexity
433 // is BOUNDING_BOX, it renders the cuboid and returns FALSE.
434 // Otherwise returns TRUE.
435 SbBool handleInvisibleOrBBox(SoGLRenderAction *action,
436 SbBool isPointsOrLines = FALSE);
437
438 // Returns TRUE if the shape may be picked. Subclasses can call
439 // this in their picking methods to determine whether to continue.
440 SbBool shouldRayPick(SoRayPickAction *action);
441
442
443
445 // rendering. They take care of setting up shape hints in the
446 // state. Calls to these two methods should bracket the rendering
447 // code.
448 void beginSolidShape(SoGLRenderAction *action);
449 void endSolidShape(SoGLRenderAction *action);
450
451 // Computes a picking ray in the object space of the shape
452 // instance. The picking ray is stored in the SoRayPickAction for
453 // later access by the subclass. The second form takes a matrix to
454 // concatenate with the current transformation matrix. It can be
455 // used, for example, if a shape has sizing or positioning info
456 // built into it.
457 void computeObjectSpaceRay(SoRayPickAction *action);
458 void computeObjectSpaceRay(SoRayPickAction *action,
459 const SbMatrix &matrix);
460
461 // These methods are called during picking to create details
462 // representing extra info about a pick intersection. The default
463 // methods implemented in SoShape return NULL. Subclasses can
464 // override these methods to set up specific detail instances that
465 // contain the extra info. Subclasses can get whatever information
466 // they need from the SoPickedPoint, and can set information in it
467 // as well.
468 virtual SoDetail *createTriangleDetail(SoRayPickAction *action,
469 const SoPrimitiveVertex *v1,
470 const SoPrimitiveVertex *v2,
471 const SoPrimitiveVertex *v3,
472 SoPickedPoint *pp);
473 virtual SoDetail *createLineSegmentDetail(SoRayPickAction *action,
474 const SoPrimitiveVertex *v1,
475 const SoPrimitiveVertex *v2,
476 SoPickedPoint *pp);
477 virtual SoDetail *createPointDetail(SoRayPickAction *action,
478 const SoPrimitiveVertex *v,
479 SoPickedPoint *pp);
480
481
482
483 virtual ~SoShape();
484
485 // Applies GLRender action to the bounding box surrounding the shape.
486 // This is used to render shapes when BOUNDING_BOX complexity is on.
487 virtual void GLRenderBoundingBox(SoGLRenderAction *action);
488
489 // Changes the GL_MULTISAMPLE_ARB OpenGL bit value. This method is used to filter the
490 // antialiasing when traversing the shape. (See SoFullSceneAntialiasing for more).
491 virtual void applyFullSceneAntialiasingFilter(SoState* state);
492
493 // isProjectCoordNeeded = true if projection need to be done by SoShape
494 // isProjectCoordNeeded = false if projection is already handled somewhere (ex: vertexShape)
495 void setNeedToProjectCoord(bool isProjectCoordNeeded);
496
497 private:
498
499 static int s_keepReset;
500 static int s_forceSend;
501 static SbBool s_noClip;
502
503private:
504
505 // Applies rayPick action to the bounding box surrounding the shape.
506 // This is used to pick shapes when BOUNDING_BOX complexity is on.
507 void rayPickBoundingBox(SoRayPickAction *action);
508
509 void commonConstructor();
510};
511
512inline SbBool
513SoShape::checkShapeHints(SoGLRenderAction *)
514{
515 return FALSE;
516}
517
518void
519SoShape::countPrim( SoState* /*state*/ )
520{}
521
522#endif /* _SO_SHAPE_ */
#define FALSE
Possible value of SbBool.
Definition SbBase.h:75
SbIntList(int initSize)
Maintains a list of integer (int) values.
#define SB_THREAD_TLS_HEADER()
Defines headers for required member variables in thread storage management.
SO_PIMPL_PUBLIC_DECLARATION(SoFileDataAdapter)
virtual void disable(QWidget *w, XtEventHandler f, XtPointer data)
SoPrimitiveVertex * jySoPrimitiveVertexPtr
Definition SoShape.h:69
SoDetail * jySoDetailPtr
Definition SoShape.h:70
#define SO_NODE_ABSTRACT_HEADER(className)
Definition SoSubNode.h:118
3D box class.
Definition SbBox.h:649
const SbVec3f & getMin() const
Returns the minimum point of the box.
Definition SbBox.h:684
const SbVec3f & getMax() const
Returns the maximum point of the box.
Definition SbBox.h:699
4x4 matrix class.
Definition SbMatrix.h:309
static SbMatrixd identity()
Returns an identity matrix.
2D vector class.
Definition SbVec.h:700
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D vector class ...
Definition SbVec.h:1214
SbVec3d & setValue(const double v[3])
Sets the vector components.
Definition SbVec.h:1292
3D vector class.
Definition SbVec.h:932
const float * getValue() const
Returns vector components.
Definition SbVec.h:977
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> 3D box with an a...
Definition SbBox.h:1513
void makeEmpty()
Sets the box to contain nothing.
Definition SbBox.h:1673
void setBounds(double xmin, double ymin, double zmin, double xmax, double ymax, double zmax)
Sets the bounds of the box.
Definition SbBox.h:1629
void setTransform(const SbMatrixd &m)
Sets the transformation on the box.
Abstract base class for all actions.
Definition SoAction.h:132
Performs a generic traversal of a scene graph or path.
Base class for describing detail information about a shape node.
Definition SoDetail.h:99
Stores detail information about vertex-based shapes made of faces.
Renders a scene graph using Open Inventor's Render Engine.
Computes bounding box of a scene.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Counts number of...
Multiple-value field containing any number of int32_t integers.
Definition SoMFInt32.h:88
Abstract base class for all database nodes.
Definition SoNode.h:145
Represents point on surface of picked object.
Represents a vertex of a generated primitive.
Intersects objects with a ray cast into scene.
Field containing a single Boolean value.
Definition SoSFBool.h:79
SbBool getValue() const
Returns this field's value.
Definition SoSFBool.h:82
Abstract base class for all shape nodes.
Definition SoShape.h:115
virtual SbBool affectsState() const
Overrides default method on SoNode.
static SbBool isPrimitiveRestartAvailable(SoState *state=NULL)
Returns TRUE if the primitive restart feature is available.
ShapeType
Basic type for antialiased rendering for this shape (Do not consider the SoDrawStyle property current...
Definition SoShape.h:135
@ LINES
The shape is render based on lines (Ex: SoLineSet).
Definition SoShape.h:139
@ POINTS
The shape is render based on points (Ex: SoPointSet).
Definition SoShape.h:137
@ POLYGONS
The shape is render based on polygons (Ex: SoFaceSet).
Definition SoShape.h:141
SoSFBool boundingBoxIgnoring
Whether to ignore this node during bounding box traversal.
Definition SoShape.h:123
ShapeType getShapeType()
Gets the current shape Full Scene Antialiasing type.
Traversal state.
Definition SoState.h:74
int SbBool
Boolean type.
Definition SbBase.h:87