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:

using namespace cadex;
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;
}
...
Geom::Direction myDirection;
Defines a 3D Direction.
Definition Direction.hxx:34
UTF16String Name() const
Returns a name.
Definition ModelElement.cxx:55
Defines a leaf node in the scene graph hiearchy.
Definition Part.hxx:34
Contains information about projection of the model.
Definition Projector_PolyData.hxx:34
The poly projection tool.
Definition Projector_PolyProjector.hxx:43
Contains classes, namespaces, enums, types, and global functions related to Manufacturing Toolkit.
Definition LicenseManager_LicenseError.hxx:30

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

using namespace cadex;
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