Class SoGetPrimitiveCountAction
After applying the action to a path or scene graph, the results can be obtained with the functions getTriangleCount(), getLineCount(), etc. The decimation value can be altered before applying, which is useful for finding the minimum and maximum number of primitives the scene requires (use LOWEST and HIGHEST).
3D Text, such as SoText3 can be counted as either text or triangles. The function setCount3DTextAsTriangles() will determine how these objects are counted.
Polygonal geometry nodes, for example SoIndexedFaceSet, are always counted as triangles even if the draw style (SoDrawStyle) is set to LINES or POINTS.
Some shapes, such as trimmed NURBS surfaces, can answer quicker if they are allowed to approximate how many primitives they will use instead of calculating an exact answer. If an exact answer is not required, passing true to setCanApproximate() will speed the action.
Elements
Sets: SoDecimationTypeElement, SoDecimationPercentageElement
// Count triangles in scene graph SoGetPrimitiveCountAction gpca = new SoGetPrimitiveCountAction(); gpca.apply( root ); int numTris = gpca.getTriangleCount();
SoAction, SoLevelOfSimplification, SoOctreeOrdering, SoRenderList, SoValueOrdering
-
Nested Class Summary
Nested classes/interfaces inherited from class com.openinventor.inventor.actions.SoAction
SoAction.AppliedCodes, SoAction.DistribModes, SoAction.PathCodes, SoAction.PathIndicesNested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand -
Field Summary
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNumImage(int num) voidaddNumLines(int num) voidaddNumPoints(int num) voidaddNumText(int num) voidaddNumTriangles(int num) booleanReturns whether shapes are allowed to approximate their count.booleanReturns true if scene contains some primitives that are not triangles.booleanReturns true if scene contains no primitives of any kind.static voidenableElement(Class<? extends Inventor> t, int stkIndex) floatGets decimation percentage.Gets decimation type.intReturns counted number of primitives (images).intReturns counted number of primitives (lines).intReturns counted number of primitives (points).intReturns counted number of primitives (text).intReturns counted number of primitives (triangles).voidvoidvoidvoidvoidbooleanReturns howSoText3should be counted: as a triangle-based shape (true) or as a text-based shape (false).voidsetCanApproximate(boolean onOff) Some shapes may be able to guess an approximate number of triangles without actually counting.voidsetCount3DTextAsTriangles(boolean treatAsTris) SoText3can be counted two ways: as a triangle-based shape or as a text-based shape.voidCalls setDecimationValue(type, (float)1.0).voidsetDecimationValue(SoDecimationTypeElement.Types type, float percentage) Sets decimation type and percentage.Methods inherited from class com.openinventor.inventor.actions.SoAction
apply, apply, clearApplyResult, forwardTraversal, forwardTraversal, getContinueActionInBranchFlag, getCurPath, getDistribMode, getNodeAppliedTo, getOriginalPathListAppliedTo, getPathAppliedTo, getPathCode, getPathListAppliedTo, getPipeId, getSceneManager, getState, getWhatAppliedTo, hasTerminated, invalidateState, isBeingApplied, isLastPathListAppliedTo, isUsingAlternateRep, nullAction, postDelayedTraversal, preDelayedTraversal, resetContinueActionInBranchFlag, setPipeId, setSceneManager, setUpState, stopActionInBranch, traverse, useAlternateRepMethods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
Constructor Details
-
SoGetPrimitiveCountAction
public SoGetPrimitiveCountAction()Constructor.
-
-
Method Details
-
setDecimationValue
Calls setDecimationValue(type, (float)1.0). -
getLineCount
public int getLineCount()Returns counted number of primitives (lines). -
incNumPoints
public void incNumPoints() -
incNumLines
public void incNumLines() -
incNumTriangles
public void incNumTriangles() -
getPointCount
public int getPointCount()Returns counted number of primitives (points). -
incNumImage
public void incNumImage() -
setCanApproximate
public void setCanApproximate(boolean onOff) Some shapes may be able to guess an approximate number of triangles without actually counting. In the interests of speed, and depending on how the results are used, a flag is available to allow shapes to approximate their count. The default is false. -
getTriangleCount
public int getTriangleCount()Returns counted number of primitives (triangles). -
incNumText
public void incNumText() -
getDecimationType
Gets decimation type. -
enableElement
-
setDecimationValue
Sets decimation type and percentage. Percentage should be a number between 0.0 and 1.0 (1.0 is full complexity).Type is one of:
SoDecimationTypeElement.LOWEST
Lowest complexity possible for scene.SoDecimationTypeElement.HIGHEST
Highest complexity possible for scene.SoDecimationTypeElement.AUTOMATIC
Scene uses decimation percentage; LODs calculate range value and then adjust them with percentage.SoDecimationTypeElement.PERCENTAGE
Scene uses decimation percentage; LODs use child based solely on decimation without looking at camera position. -
addNumTriangles
public void addNumTriangles(int num) -
canApproximateCount
public boolean canApproximateCount()Returns whether shapes are allowed to approximate their count. -
is3DTextCountedAsTriangles
public boolean is3DTextCountedAsTriangles()Returns howSoText3should be counted: as a triangle-based shape (true) or as a text-based shape (false). -
getDecimationPercentage
public float getDecimationPercentage()Gets decimation percentage. -
setCount3DTextAsTriangles
public void setCount3DTextAsTriangles(boolean treatAsTris) -
getImageCount
public int getImageCount()Returns counted number of primitives (images). -
addNumText
public void addNumText(int num) -
getTextCount
public int getTextCount()Returns counted number of primitives (text). -
addNumImage
public void addNumImage(int num) -
containsNonTriangleShapes
public boolean containsNonTriangleShapes()Returns true if scene contains some primitives that are not triangles. -
addNumLines
public void addNumLines(int num) -
containsNoPrimitives
public boolean containsNoPrimitives()Returns true if scene contains no primitives of any kind. -
addNumPoints
public void addNumPoints(int num)
-