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

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

Overview

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:

public override void Apply(Part thePart)
{
Projector_PolyData aData = myProjector.Perform(thePart, myDirection);
Console.WriteLine($"Part projection [{thePart.Name()}] has:");
Console.WriteLine($" area = {aData.ProjectionArea()} mm\n");
}
private Direction myDirection;
private Projector_PolyProjector myProjector = new Projector_PolyProjector();

To traverse parts of the imported model, the ModelData.ModelElementVoidVisitor class is used:

var aProjector = new SceneGraphPolyProjector(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