Hide menu
Loading...
Searching...
No Matches
Projector Example

Demonstrates how to create a projection of a 3D model and returns information about it.

Overview

In this example demonstrates how to create a projection of a 3D model using projector tool (Projector_PolyProjector). For this purpose, used a console application that imports a model, traverses through unique ModelData_Part , creates and runs Projector_PolyProjector and returns information about the projection into Projector_PolyData. Creating a projection will be performed for each ModelData_Part , but only for the scope of accepted geometries.


Application needs 2 input arguments to run:

Usage: poly_projector <input_file>, where:
<input_file> is a name of the file to be read


For more information about projector visit Projection Creation page.

Implementation

To explore the model and process ModelData_Part , it's need to create an inheritor from the ModelData_ModelElementVoidVisitor and override the part processing method void operator() (const ModelData::Part& thePart). For this purpose, the SceneGraphPolyProjector class was created.

After, the projection of the model Projector_PolyData is created in the specified direction using Projector_PolyProjector and the information about this projection is printed to the console:

class SceneGraphPolyProjector(mtk.ModelElementVoidVisitor):
def __init__(self, theDirection: mtk.Direction):
super().__init__()
self.myDirection = theDirection
self.myProjector = mtk.Projector_PolyProjector()
def VisitPart(self, thePart: mtk.Part):
aData = self.myProjector.Perform(thePart, self.myDirection)
print(f"Part projection [{thePart.Name()}] has:")
print(f" area = {aData.ProjectionArea()} mm\n")

To traverse parts of the imported model, the ModelData_ModelElementVoidVisitor class is used:

aProjector = SceneGraphPolyProjector(mtk.Direction.YDir())
aModel.Accept(aProjector)

Example output

Below is the example output for model from ./examples/models/Fresamento_CAM1_v3.stp:

Part projection [Fresamento_CAM1] has:
area = 41873.9 mm

Files