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:

void operator() (const ModelData::Part& thePart) override
{
Projector_PolyData aData = myProjector.Perform (thePart, myDirection);
std::cout << "Part projection [" << thePart.Name() << "] has:" << endl;
std::cout << " area = " << aData.ProjectionArea() << " mm" << endl << endl;
}
...
Projector_PolyProjector myProjector;
Geom::Direction myDirection;

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

ModelPolyProjector aProjector (Geom::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