Open Inventor Release 2024.1.1
 
Loading...
Searching...
No Matches
SoGetPrimitiveCountAction.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2014 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24
25#ifndef _SO_GET_PRIMITIVE_COUNT_ACTION_
26#define _SO_GET_PRIMITIVE_COUNT_ACTION_
27
28#include <Inventor/actions/SoSubAction.h>
29#include <Inventor/elements/SoDecimationTypeElement.h>
30
32//
33// Class: SoGetPrimitiveCountAction
34//
35// For computing the amount of primitives (triangles, lines, points,
36// text, images) in a scene. This could be used as an estimate
37// for a scene's complexity, or rendering time. The triangles,
38// lines, and points are counted; however, the text and images
39// count only the number of text or image nodes.
40// SoText3 can be counted as either triangles or text, depending
41// on the setting in this action.
42// The counts can be approximated depending on the setting in this
43// action. This allows IndexedShapes to take a guess based on
44// the number of vertices, instead of searching through
45// the actual values of their fields.
46//
48
117
118 SO_ACTION_HEADER(SoGetPrimitiveCountAction);
119
120 public:
125
130
134 int32_t getTriangleCount() const { return numTriangles; }
138 int32_t getLineCount() const { return numLines; }
142 int32_t getPointCount() const { return numPoints; }
146 int32_t getTextCount() const { return numText; }
150 int32_t getImageCount() const { return numImage; }
151
160
182 float percentage = 1.0);
190 float getDecimationPercentage() { return decPercent; };
191
198 { treatText3AsTris = treatAsTris; };
203 SbBool is3DTextCountedAsTriangles() { return treatText3AsTris; };
204
212 { canApproximate = onOff; };
216 SbBool canApproximateCount() { return canApproximate; };
217
218 private:
219 // These functions are called by nodes to add a number of
220 // a type of primitive to the number of primitives found.
221 void addNumTriangles(int32_t num) { numTriangles += num; };
222 void addNumLines(int32_t num) { numLines += num; };
223 void addNumPoints(int32_t num) { numPoints += num; };
224 void addNumText(int32_t num) { numText += num; };
225 void addNumImage(int32_t num) { numImage += num; };
226 void incNumTriangles() { numTriangles++; };
227 void incNumLines() { numLines++; };
228 void incNumPoints() { numPoints++; };
229 void incNumText() { numText++; };
230 void incNumImage() { numImage++; };
231
232 private:
233 static void initClass();
234 static void exitClass();
235
236 private:
237 // Initiates action on graph
238 virtual void beginTraversal(SoNode *node);
239
240 private:
241 int32_t numTriangles;
242 int32_t numLines;
243 int32_t numPoints;
244 int32_t numText;
245 int32_t numImage;
246
247 SbBool treatText3AsTris;
248 SbBool canApproximate;
249
251 float decPercent;
252
253};
254
255#endif /* _SO_GET_PRIMITIVE_COUNT_ACTION_ */
256
Abstract base class for all actions.
Definition SoAction.h:132
Type
These are the available decimation types.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Counts number of...
int32_t getLineCount() const
Returns counted number of primitives (lines).
SbBool canApproximateCount()
Returns whether shapes are allowed to approximate their count.
virtual ~SoGetPrimitiveCountAction()
Destructor.
void setDecimationValue(SoDecimationTypeElement::Type type, float percentage=1.0)
Sets decimation type and percentage.
int32_t getTriangleCount() const
Returns counted number of primitives (triangles).
SoGetPrimitiveCountAction()
Constructor.
void setCount3DTextAsTriangles(SbBool treatAsTris)
SoText3 can be counted two ways: as a triangle-based shape or as a text-based shape.
void setCanApproximate(SbBool onOff)
Some shapes may be able to guess an approximate number of triangles without actually counting.
float getDecimationPercentage()
Gets decimation percentage.
int32_t getTextCount() const
Returns counted number of primitives (text).
SbBool containsNoPrimitives()
Returns TRUE if scene contains no primitives of any kind.
int32_t getPointCount() const
Returns counted number of primitives (points).
SbBool is3DTextCountedAsTriangles()
Returns how SoText3 should be counted: as a triangle-based shape (TRUE) or as a text-based shape (FAL...
int32_t getImageCount() const
Returns counted number of primitives (images).
SbBool containsNonTriangleShapes()
Returns TRUE if scene contains some primitives that are not triangles.
SoDecimationTypeElement::Type getDecimationType()
Gets decimation type.
Abstract base class for all database nodes.
Definition SoNode.h:145
int SbBool
Boolean type.
Definition SbBase.h:87