DATAKIT API  V2025.4
STEP Write Samples

See How To Use Step Writer APIs for step writing of part or assembly for more detailed explanations to complement those code samples.


0. Introduction : Configuration and file creation.

Before writing STEP files, you need to initialize Datakit API.
Calls to stepw_SetModeProp() and stepw_SetModeFdt() allows to control respectively the filtering of written properties as well as presentation and representation type desired for FDT.

Every file creation starts with a call to stepw_InitFile(), and end with a call to stepw_EndFile().
You can input at this moment desired file name, as well as the version in which to write the STEP file.
See Supported versions and extensions for a reminder of Write API supported versions.

//start_of_mainstepwrite
int StepWriteSample( const Dtk_string &inResultDirectory )
{
Dtk_string outputFileName, outputDirectory;
std::cout << endl << "----------------------------------------------" << std::endl;
std::cout << "Step Write start" << std::endl;
// Choosing output directory and file name
outputDirectory = inResultDirectory + L"Step/";
outputDirectory.FixPathSeparator();
outputDirectory.mkdir();
// First, initialize the Step writer
//int codeForAP203 = 1;
int codeForAP214 = 2;
//int codeForAP203E2 = 3;
int codeForAP242 = 4;
int dummy;
{
outputFileName = outputDirectory + L"SamplePart_BodyOnly.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
stepw::sample::WritePart_BodyOnly( L"SamplePart_BodyOnly", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
//[...]
//end_of_mainstepwrite

1. Part creation.

In the following subsections, for each use cases, we display the corresponding code sample and expected output.
The .stp file written was read with STEP File Analyzer from NIST (Version 5.31).

1.1 Containing a Dtk_Body.

//start_of_stepw_sample_part_body
//Sample to write a product with only a simple BRep shape in its 3D part.
DtkErrorStatus WritePart_BodyOnly( const Dtk_string& inPartName, int& outPartID )
{
Dtk_BodyPtr body = sampleWriter::CreateCylinder();//Constructs a body, in the shape of a cylinder
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
PRINT_ERROR( stepw_Write3DPartBody( body ) );//Registers the 3D geometry in the current part context
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_body


Expected output in .stp file :


1.2 Containing a Dtk_Body and a Dtk_AxisSystem.

//start_of_stepw_sample_part_axis
//Sample to write a product with a simple BRep shape and an axis system in its 3D part.
DtkErrorStatus WritePart_BodyWithAxisSystem( const Dtk_string& inPartName, int& outPartID )
{
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds a brep as definition of the 3D geometry of the part
PRINT_ERROR( stepw_Write3DAxisSystem( AxisSystem ) );//Adds an axis system in the part context
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_axis


Expected output in .stp file :


1.3 Containing a Dtk_Mesh.

//start_of_stepw_sample_part_mesh
//Sample to write a product with a simple tessellated shape in its 3D part.
DtkErrorStatus WritePart_MeshOnly( const Dtk_string& inPartName, int& outPartID )
{
Dtk_MeshPtr mesh = sampleWriter::CreateMeshCube();//Constructs a mesh, in the shape of a cube
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
PRINT_ERROR( stepw_Write3DPartMesh( mesh ) );//Adds a mesh as definition of the 3D geometry of the part
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_mesh


Expected output in .stp file :


1.4 Containing a Dtk_Mesh with faces of different color.

//start_of_stepw_sample_part_mesh_color
//Sample to write a product with a simple tessellated shape in its 3D part. Each face of the mesh has different colors.
DtkErrorStatus WritePart_MeshWithFaceColors( const Dtk_string& inPartName, int& outPartID )
{
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
PRINT_ERROR( stepw_Write3DPartMesh( mesh ) );//Adds a mesh as definition of the 3D geometry of the part
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
};
//end_of_stepw_sample_part_mesh_color


Expected output in .stp file :


1.5 Containing both a Dtk_Body and its tessellated Dtk_Mesh counterpart.

//start_of_stepw_sample_part_body_tessellated
{
Dtk_BodyPtr body = sampleWriter::CreateCylinder();//Constructs a body, int the shape of a cylinder
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
Dtk_bool TessWireframe = false;
tess_InitTesselation( "../../SampleFiles/dtk/", 0.2 );//Initializes tessellation library
PRINT_ERROR( tess_BodyToMeshes( body, listMesh, IsSolid, TessWireframe ) );//Tessellates brep into a meshes
if( listMesh.size() >= static_cast< Dtk_Size_t >( 1 ) )
mesh = listMesh[ 0 ];
PRINT_ERROR( stepw_Write3DPartBodyWithMesh( body, mesh ) );//Registers both the body geometry and its corresponding tessellated mesh, bounding their topology information
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_body_tessellated


Expected output in .stp file :


1.6 Containing a datum Dtk_Annotation in a view Dtk_ModelDisplay, with a link to its geometry in Dtk_Face.

//start_of_stepw_sample_part_datum
DtkErrorStatus WritePart_Datum( const Dtk_string& inPartName, int& outPartID )
{
Dtk_BodyPtr body = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
//You init the Part writer
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Starts a part definition context
PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds body as definition of the 3D geometry of the part
{
int nodeid_Fdt1 = 42;
stepw_InitNodeContext( nodeid_Fdt1 );//Starts a node context to encapsulate an entity and be able to reference it from other nodes context
PRINT_ERROR( stepw_Add3DPartFDT( Fdt1 ) );//Adds a FDT in the definition of current the part
{// Defines the geometrical links : within the same part
Dtk_FacePtr faceToTarget = Dtk_FacePtr::DtkDynamicCast( body->GetEntity( 73 ) );//Retrieves in body the entity with Dtk_Info::GetId() == 73 (a Dtk_FacePtr in this sample, see CreateCube_2)
stepw_ER ElementReference_1;
PRINT_ERROR( stepw_CreateReference( ElementReference_1, faceToTarget->info()->GetId() ) );//Creates a reference from the current part context, to a face identifier of the current part context
PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );//Registers this reference
}
stepw_EndNodeContext();//Ends current node context
int userDefinedID_viewNode = 4242;
stepw_InitNodeContext( userDefinedID_viewNode );//Starts another node context, this time to encapsulate the view entity
PRINT_ERROR( stepw_Add3DModelDisplay( view, 0 ) );//Add a view in the definition of the current part
{//Lets the view reference the FDT, meaning the FDT is visible in this view. An FDT can appear in several views.
stepw_ER ElementReference_Fdt1;
PRINT_ERROR( stepw_CreateReferenceToNode( ElementReference_Fdt1, nodeid_Fdt1, outPartID, "fdt" ) );//Create a reference from the current part context, to a whole node (FDT) of the current part context
PRINT_ERROR( stepw_AddReference( ElementReference_Fdt1 ) );//Registers this reference
}
stepw_EndNodeContext();//Ends current node context
PRINT_ERROR( stepw_Write3DAxisSystem( AxisSystem ) );//Writes an axis system (complement FDT definition)
PRINT_ERROR( stepw_Write3DConstructionGeometry( constr_plane ) );//Writes a construction geometry (complement FDT definition)
}
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_datum


Expected output in .stp file :


1.7 Containing a tolerance Dtk_GeometricalTolerance in a view Dtk_ModelDisplay, with a link to its geometry in Dtk_Face.

//start_of_stepw_sample_part_geom_tol
DtkErrorStatus WritePart_GeometricalTolerance( const Dtk_string& inPartName, int& outPartID )
{
Dtk_BodyPtr body = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
//You init the Part writer
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Starts a part definition context
PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds body as definition of the 3D geometry of the part
{
Dtk_FdtPtr datum = sampleWriter::CreateFdtDatum();//CReates datum "A"
int datum_node_id = 42;
stepw_InitNodeContext( datum_node_id );//Starts a node context to encapsulate an entity and be able to reference it from other nodes context
PRINT_ERROR( stepw_Add3DPartFDT( datum ) );//Adds a FDT in the definition of current the part
{// Defines the geometrical links : within the same part
Dtk_FacePtr faceToTarget = Dtk_FacePtr::DtkDynamicCast( body->GetEntity( 73 ) );//Retrieves in body the entity with Dtk_Info::GetId() == 73 (a Dtk_FacePtr in this sample, see CreateCube_2)
stepw_ER ElementReference_1;
PRINT_ERROR( stepw_CreateReference( ElementReference_1, faceToTarget->info()->GetId() ) );//Creates a reference from the current part context, to a face identifier of the current part context
PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );//Registers this reference
}
stepw_EndNodeContext();//Ends current node context
Dtk_transfo fdt_transf;
fdt_transf.setOrigin( Dtk_pnt( 75., 125., 50. ) );
Dtk_FdtPtr geometricalTolerance = sampleWriter::CreateGeometricalTolerance();//Creates a geometrical tolerance that references datum "A"
geometricalTolerance->Transform( fdt_transf );
int geometrical_tolerance_node_id = 43;
stepw_InitNodeContext( geometrical_tolerance_node_id );//Starts a node context to encapsulate an entity and be able to reference it from other nodes context
PRINT_ERROR( stepw_Add3DPartFDT( geometricalTolerance ) );//Adds a FDT in the definition of current the part
{// Defines the geometrical links : within the same part
Dtk_FacePtr faceToTarget = Dtk_FacePtr::DtkDynamicCast( body->GetEntity( 105 ) );//Retrieves in body the entity with Dtk_Info::GetId() == 73 (a Dtk_FacePtr in this sample, see CreateCube_2)
stepw_ER ElementReference_1;
PRINT_ERROR( stepw_CreateReference( ElementReference_1, faceToTarget->info()->GetId() ) );//Creates a reference from the current part context, to a face identifier of the current part context
PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );//Registers this reference
}
stepw_EndNodeContext();//Ends current node context
int viewModeThatReferencesAllFDTs = 1;
PRINT_ERROR( stepw_Add3DModelDisplay( view, viewModeThatReferencesAllFDTs ) );//Adds a view in the definition of the current part, that references all FDT of current part context
}
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_geom_tol


Expected output in .stp file :


2. Assembly creation.

In the following subsections, for each use cases, we display the corresponding code sample and expected output.
The .stp file written, representing the assembly, was read with STEP File Analyzer from NIST (Version 5.31).


2.1 Containing a sub-assembly.

//start_of_stepw_sample_assy
DtkErrorStatus WriteAssembly( const Dtk_string& inRootAssemblyName )
{
Dtk_transfo trf0, trf1, trf2;
CreateTransforms( trf0, trf1, trf2 );
int assignedID_leafPart = 0;
PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
int assignedID_subProduct = 0;
{//Creates sub-product
PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
}
{//Creates root product
int assignedID_rootProduct = 0;
PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
}
return dtkNoError;
}
//end_of_stepw_sample_assy


Expected output in .stp file :


2.2 Containing a dimension Dtk_Dimension at assembly level, in a view Dtk_ModelDisplay, with link to its geometries Dtk_Face in leaf parts.

//start_of_stepw_sample_assy_dimension
{
Dtk_transfo trf0, trf1, trf2;
CreateTransforms( trf0, trf1, trf2 );
int assignedID_leafPart = 0;
PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
int assignedID_instance1 = 0, assignedID_instance2 = 0, assignedID_instance3 = 0;
int assignedID_subProduct = 0;
{//Creates sub-product
PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct", Dtk_Info::create(), assignedID_instance1 ) );//Adds an instance of leaf product in sub-product
PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
}
{//Creates root product
int assignedID_rootProduct = 0;
PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2", Dtk_Info::create(), assignedID_instance2 ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct", Dtk_Info::create(), assignedID_instance3 ) );//Adds an instance of leaf product in root product
PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context
{//Creates assembly level FDT and its link to final geometry
Dtk_FdtPtr dimension = sampleWriter::CreateDimension();//Registers a FDT at assembly level
dimension->TransformationMatrix().setXdir( Dtk_dir( 0., 1., 0. ) );
dimension->TransformationMatrix().setYdir( Dtk_dir( -1., 0., 0. ) );
dimension->TransformationMatrix().setZdir( Dtk_dir( 0., 0., 1. ) );
dimension->TransformationMatrix().setOrigin( Dtk_pnt( 0., 0., -50. ) );
int userDefinedID_dimensionNode = 1002;
stepw_InitNodeContext( userDefinedID_dimensionNode );
{//Targets face with ID 10 in the 3D part (geometry) of instance "PartWithBody_InRootProduct"
int targetedFaceID_1 = 10;//This matches in the already written body in current part context, the entity with Dtk_Info::GetId() == 10 (a Dtk_FacePtr, see CreateCylinder)
stepw_ER ElementReference_1;
PRINT_ERROR( stepw_CreateReference( ElementReference_1, targetedFaceID_1, assignedID_leafPart ) );
stepw_ERP ElementReferencePath_1;
PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_1 ) );
PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_1, assignedID_instance3 ) );
PRINT_ERROR( stepw_SetReferencePath( ElementReference_1, ElementReferencePath_1 ) );
PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );
}
{//Targets face with ID 10 in the 3D part (geometry) of instance "PartWithBody_InSubProduct" in instance "SubProduct_InRootProduct_2".
int targetedFaceID_2 = 10;//This matches in the already written body in current part context, the entity with Dtk_Info::GetId() == 10 (a Dtk_FacePtr, see CreateCylinder)
stepw_ER ElementReference_2;
PRINT_ERROR( stepw_CreateReference( ElementReference_2, targetedFaceID_2, assignedID_leafPart ) );
stepw_ERP ElementReferencePath_2;
PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_2 ) );
{//Appends assigned instance identifiers individually
PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance2 ) );
PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance1 ) );
}
//{//Or define the whole instance identifier rout at once.
// Dtk_tab<Dtk_ID> instance_path;
// instance_path.push_back( assignedID_instance2 );
// instance_path.push_back( assignedID_instance1 );
// stepw_DefineInstancePath( ElementReferencePath_2, instance_path );
//}
PRINT_ERROR( stepw_SetReferencePath( ElementReference_2, ElementReferencePath_2 ) );
PRINT_ERROR( stepw_AddReference( ElementReference_2 ) );
}
}
{
int viewModeThatReferencesAllFDTs = 1;
PRINT_ERROR( stepw_Add3DModelDisplay( view, viewModeThatReferencesAllFDTs ) );//Adds a view in the definition of the current part, that references all FDT of current part context
}
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
}
return dtkNoError;
}
//end_of_stepw_sample_assy_dimension


Expected output in .stp file :


Full samples source code (testlibstepwrite.cpp)

#ifdef WIN32
#include <windows.h>
#endif
#include "testwriters.h"
//DATAKIT headers needed
#include "datakit.h"
#include "stepw/stepw.hpp"
// For tessellation
#include "tess/tess.h"
namespace stepw
{
namespace sample
{
{
trsf.setOrigin( Dtk_pnt( 100., 100., 100. ) );
axis->SetMatrix( trsf );
axis->SetName( "Axis_System" );
return axis;
}
void CreateTransforms( Dtk_transfo& outFirst, Dtk_transfo& outSecond, Dtk_transfo& outThird )
{
outFirst = Dtk_transfo();
outSecond = Dtk_transfo();
outThird = Dtk_transfo();
outSecond.setOrigin( Dtk_pnt( 0., 150., -150. ) );
outThird.setOrigin( Dtk_pnt( 0., -150., -150. ) );
}
{
layerInfosSet->SetLayerID(0, 42);
layerInfosSet->SetLayerID(1, 1900);
layerInfosSet->SetLayerID(2, 0);
layerInfosSet->SetLayerName(0, "MyFirstLayer");
layerInfosSet->SetLayerName(1, "MySecondLayer");
layerInfosSet->SetLayerName(2, "Faces");
return layerInfosSet;
}
//start_of_stepw_sample_part_body
//Sample to write a product with only a simple BRep shape in its 3D part.
DtkErrorStatus WritePart_BodyOnly( const Dtk_string& inPartName, int& outPartID )
{
Dtk_BodyPtr body = sampleWriter::CreateCylinder();//Constructs a body, in the shape of a cylinder
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
PRINT_ERROR( stepw_Write3DPartBody( body ) );//Registers the 3D geometry in the current part context
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_body
//start_of_stepw_sample_part_axis
//Sample to write a product with a simple BRep shape and an axis system in its 3D part.
DtkErrorStatus WritePart_BodyWithAxisSystem( const Dtk_string& inPartName, int& outPartID )
{
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds a brep as definition of the 3D geometry of the part
PRINT_ERROR( stepw_Write3DAxisSystem( AxisSystem ) );//Adds an axis system in the part context
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_axis
//Sample to write a product with a simple wireframe shape in its 3D part.
DtkErrorStatus WritePart_WireframeOnly( const Dtk_string& inPartName, int& outPartID )
{
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
PRINT_ERROR( stepw_Write3DPartBody( wireframe ) );//Adds a wireframe as definition of the 3D geometry of the part
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//start_of_stepw_sample_part_mesh
//Sample to write a product with a simple tessellated shape in its 3D part.
DtkErrorStatus WritePart_MeshOnly( const Dtk_string& inPartName, int& outPartID )
{
Dtk_MeshPtr mesh = sampleWriter::CreateMeshCube();//Constructs a mesh, in the shape of a cube
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
PRINT_ERROR( stepw_Write3DPartMesh( mesh ) );//Adds a mesh as definition of the 3D geometry of the part
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_mesh
//start_of_stepw_sample_part_mesh_color
//Sample to write a product with a simple tessellated shape in its 3D part. Each face of the mesh has different colors.
DtkErrorStatus WritePart_MeshWithFaceColors( const Dtk_string& inPartName, int& outPartID )
{
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
PRINT_ERROR( stepw_Write3DPartMesh( mesh ) );//Adds a mesh as definition of the 3D geometry of the part
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
};
//end_of_stepw_sample_part_mesh_color
//Sample to write a product with a simple brep shape in its 3D part, bounded with its corresponding tessellation.
//Not recommended for STEP versions before AP242
//start_of_stepw_sample_part_body_tessellated
{
Dtk_BodyPtr body = sampleWriter::CreateCylinder();//Constructs a body, int the shape of a cylinder
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
Dtk_bool TessWireframe = false;
tess_InitTesselation( "../../SampleFiles/dtk/", 0.2 );//Initializes tessellation library
PRINT_ERROR( tess_BodyToMeshes( body, listMesh, IsSolid, TessWireframe ) );//Tessellates brep into a meshes
if( listMesh.size() >= static_cast< Dtk_Size_t >( 1 ) )
mesh = listMesh[ 0 ];
PRINT_ERROR( stepw_Write3DPartBodyWithMesh( body, mesh ) );//Registers both the body geometry and its corresponding tessellated mesh, bounding their topology information
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_body_tessellated
//Sample to write a product with properties at various level (part and product).
DtkErrorStatus WritePart_WithProperties( const Dtk_string& inPartName, int& outPartID )
{
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Starts a part definition context
PRINT_ERROR( stepw_Add3DPartProperty( Dtk_MetaData::CreateMetaData( Dtk_MetaData::TypeConfigurationProperty, "Revision", "test_revision_4" ) ) );//Defines and adds a property at part level (Dtk_MetaData)
PRINT_ERROR( stepw_Add3DPartProperty( Dtk_MetaData::CreateMetaData( Dtk_MetaData::TypeProperty, "Cost", "12500 $" ) ) );//Defines and adds a property at part level (Dtk_MetaData)
PRINT_ERROR( stepw_Add3DPartProperty( Dtk_MetaDataWithUnit::CreateMetaDataWithUnits( Dtk_MetaData::TypeProperty, "User double with unit", "42.42", L"cm", L"REAL")));//Defines and adds a property at part level (Dtk_MetaData)
{//Defines and adds validation properties at part level (Dtk_Info)
Dtk_Val valprop_area( "1234 mm2" );
part_info->AddAttribute( "geometric validation property : : surface area measure", valprop_area );
Dtk_Val valprop_volume( "5678 mm3" );
part_info->AddAttribute( "geometric validation property : : volume measure", valprop_volume );
Dtk_Val valprop_CG( Dtk_pnt( 12., 34., 56. ) );
part_info->AddAttribute( "geometric validation property : : centre point", valprop_CG );
}
{//Defines and adds properties at product level (Dtk_Info)
Dtk_Val mat_name( "Steel YC38" );
prod_info->AddAttribute( "material property : material name : Steel", mat_name );
Dtk_Val mat_density( "7.89 g/cm3" );
prod_info->AddAttribute( "material property : density : density measure", mat_density );
}
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//Sample to write a product with a simple brep shape in its 3D part, with also a Datum annotation referencing this geometry, registered in a view of the model.
//start_of_stepw_sample_part_datum
DtkErrorStatus WritePart_Datum( const Dtk_string& inPartName, int& outPartID )
{
Dtk_BodyPtr body = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
//You init the Part writer
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Starts a part definition context
PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds body as definition of the 3D geometry of the part
{
int nodeid_Fdt1 = 42;
stepw_InitNodeContext( nodeid_Fdt1 );//Starts a node context to encapsulate an entity and be able to reference it from other nodes context
PRINT_ERROR( stepw_Add3DPartFDT( Fdt1 ) );//Adds a FDT in the definition of current the part
{// Defines the geometrical links : within the same part
Dtk_FacePtr faceToTarget = Dtk_FacePtr::DtkDynamicCast( body->GetEntity( 73 ) );//Retrieves in body the entity with Dtk_Info::GetId() == 73 (a Dtk_FacePtr in this sample, see CreateCube_2)
stepw_ER ElementReference_1;
PRINT_ERROR( stepw_CreateReference( ElementReference_1, faceToTarget->info()->GetId() ) );//Creates a reference from the current part context, to a face identifier of the current part context
PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );//Registers this reference
}
stepw_EndNodeContext();//Ends current node context
int userDefinedID_viewNode = 4242;
stepw_InitNodeContext( userDefinedID_viewNode );//Starts another node context, this time to encapsulate the view entity
PRINT_ERROR( stepw_Add3DModelDisplay( view, 0 ) );//Add a view in the definition of the current part
{//Lets the view reference the FDT, meaning the FDT is visible in this view. An FDT can appear in several views.
stepw_ER ElementReference_Fdt1;
PRINT_ERROR( stepw_CreateReferenceToNode( ElementReference_Fdt1, nodeid_Fdt1, outPartID, "fdt" ) );//Create a reference from the current part context, to a whole node (FDT) of the current part context
PRINT_ERROR( stepw_AddReference( ElementReference_Fdt1 ) );//Registers this reference
}
stepw_EndNodeContext();//Ends current node context
PRINT_ERROR( stepw_Write3DAxisSystem( AxisSystem ) );//Writes an axis system (complement FDT definition)
PRINT_ERROR( stepw_Write3DConstructionGeometry( constr_plane ) );//Writes a construction geometry (complement FDT definition)
}
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_datum
//Sample to write a product with a simple brep shape in its 3D part, with also a geometrical tolerance referencing this geometry, registered in a view of the model.
//start_of_stepw_sample_part_geom_tol
DtkErrorStatus WritePart_GeometricalTolerance( const Dtk_string& inPartName, int& outPartID )
{
Dtk_BodyPtr body = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
//You init the Part writer
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Starts a part definition context
PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds body as definition of the 3D geometry of the part
{
Dtk_FdtPtr datum = sampleWriter::CreateFdtDatum();//CReates datum "A"
int datum_node_id = 42;
stepw_InitNodeContext( datum_node_id );//Starts a node context to encapsulate an entity and be able to reference it from other nodes context
PRINT_ERROR( stepw_Add3DPartFDT( datum ) );//Adds a FDT in the definition of current the part
{// Defines the geometrical links : within the same part
Dtk_FacePtr faceToTarget = Dtk_FacePtr::DtkDynamicCast( body->GetEntity( 73 ) );//Retrieves in body the entity with Dtk_Info::GetId() == 73 (a Dtk_FacePtr in this sample, see CreateCube_2)
stepw_ER ElementReference_1;
PRINT_ERROR( stepw_CreateReference( ElementReference_1, faceToTarget->info()->GetId() ) );//Creates a reference from the current part context, to a face identifier of the current part context
PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );//Registers this reference
}
stepw_EndNodeContext();//Ends current node context
Dtk_transfo fdt_transf;
fdt_transf.setOrigin( Dtk_pnt( 75., 125., 50. ) );
Dtk_FdtPtr geometricalTolerance = sampleWriter::CreateGeometricalTolerance();//Creates a geometrical tolerance that references datum "A"
geometricalTolerance->Transform( fdt_transf );
int geometrical_tolerance_node_id = 43;
stepw_InitNodeContext( geometrical_tolerance_node_id );//Starts a node context to encapsulate an entity and be able to reference it from other nodes context
PRINT_ERROR( stepw_Add3DPartFDT( geometricalTolerance ) );//Adds a FDT in the definition of current the part
{// Defines the geometrical links : within the same part
Dtk_FacePtr faceToTarget = Dtk_FacePtr::DtkDynamicCast( body->GetEntity( 105 ) );//Retrieves in body the entity with Dtk_Info::GetId() == 73 (a Dtk_FacePtr in this sample, see CreateCube_2)
stepw_ER ElementReference_1;
PRINT_ERROR( stepw_CreateReference( ElementReference_1, faceToTarget->info()->GetId() ) );//Creates a reference from the current part context, to a face identifier of the current part context
PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );//Registers this reference
}
stepw_EndNodeContext();//Ends current node context
int viewModeThatReferencesAllFDTs = 1;
PRINT_ERROR( stepw_Add3DModelDisplay( view, viewModeThatReferencesAllFDTs ) );//Adds a view in the definition of the current part, that references all FDT of current part context
}
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
return dtkNoError;
}
//end_of_stepw_sample_part_geom_tol
//Sample to write a product with a simple brep shape in its 3D part, knowing it will be referenced later in the context of a nested assembly (separated in different physical files).
DtkErrorStatus WritePart_UsedByExternalAssembly( const Dtk_string& inPartName, int& outPartID )
{
Dtk_BodyPtr body = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
int userDefinedID_product = 42;
PRINT_ERROR( stepw_SetAnchorProduct( outPartID, userDefinedID_product ) );//Declares the designated product as having an ANCHOR section, meaning it will be able to contain entities to be referenced outside of its scope
{
Dtk_FacePtr faceToTarget_1 = Dtk_FacePtr::DtkDynamicCast( body->GetEntity( 73 ) );//Retrieves in body the entity with Dtk_Info::GetId() == 73 (a Dtk_FacePtr in this sample, see CreateCube_2)
Dtk_string anchor1( "73" );
PRINT_ERROR( stepw_AddAnchorItem( faceToTarget_1->info()->GetId(), outPartID, anchor1 ) );//Registers this entity in the ANCHOR section, it can now be targeted by external files
Dtk_FacePtr faceToTarget_2 = Dtk_FacePtr::DtkDynamicCast( body->GetEntity( 105 ) );//Retrieves in body the entity with Dtk_Info::GetId() == 105 (a Dtk_FacePtr in this sample, see CreateCube_2)
Dtk_string anchor2( "105" );
PRINT_ERROR( stepw_AddAnchorItem( faceToTarget_2->info()->GetId(), outPartID, anchor2 ) );//Registers this entity in the ANCHOR section, it can now be targeted by external files
}
PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Starts a part definition context
PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds body as definition of the 3D geometry of the part
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( outPartID ) );
return dtkNoError;
}
//Sample to write a product with a body and some geometry entities assigned to named layers.
DtkErrorStatus WritePart_BodyInNamedLayer(const Dtk_string& inPartName, int& outPartID)
{
Dtk_BodyPtr body1 = sampleWriter::CreateCylinder();//Constructs a body, int the shape of a cylinder
body1->get_info()->SetLayer(42);//Assign it to layer 42
body1->GetEntity( 10 )->info()->SetLayer( 0 );//Assign entity with ID 10 (Dtk_Face) to layer 0
body1->GetEntity( 20 )->info()->SetLayer( 0 );//Assign entity with ID 20 (Dtk_Face) to layer 0
body1->GetEntity( 30 )->info()->SetLayer( 0 );//Assign entity with ID 30 (Dtk_Face) to layer 0
Dtk_BodyPtr body2 = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
body2->get_info()->SetLayer(1900);//Assign it to layer 1900
Dtk_BodyPtr body3 = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
body3->get_info()->SetLayer(1900);//Assign it to layer 1900
Dtk_LayerInfosSetPtr layerInfosSet = CreateLayerInfosSet();//Create the layer infos set containing the name assigned to each layer
PRINT_ERROR(stepw_InitProduct(inPartName, outPartID))//Initializes root product context
PRINT_ERROR(stepw_SetProductLayerInfosSet(layerInfosSet));//Set the current product layer infos set
PRINT_ERROR(stepw_Init3DPart(outPartID));//Initializes a part context
PRINT_ERROR(stepw_Write3DPartBody(body1));//Registers body1 in part
PRINT_ERROR(stepw_Write3DPartBody(body2));//Registers body2 in part
PRINT_ERROR(stepw_Write3DPartBody(body3));//Registers body3 in part
PRINT_ERROR(stepw_End3DPart());//Ends current part context
PRINT_ERROR(stepw_EndProduct(outPartID));//Ends root product context
return dtkNoError;
}
//Sample to write a product as an assembly, having product children (instances).
//start_of_stepw_sample_assy
DtkErrorStatus WriteAssembly( const Dtk_string& inRootAssemblyName )
{
Dtk_transfo trf0, trf1, trf2;
CreateTransforms( trf0, trf1, trf2 );
int assignedID_leafPart = 0;
PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
int assignedID_subProduct = 0;
{//Creates sub-product
PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
}
{//Creates root product
int assignedID_rootProduct = 0;
PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
}
return dtkNoError;
}
//end_of_stepw_sample_assy
//Sample to write a product as an assembly, having product children (instances), with FDT at assembly level, referencing geometry in its children.
//start_of_stepw_sample_assy_dimension
{
Dtk_transfo trf0, trf1, trf2;
CreateTransforms( trf0, trf1, trf2 );
int assignedID_leafPart = 0;
PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
int assignedID_instance1 = 0, assignedID_instance2 = 0, assignedID_instance3 = 0;
int assignedID_subProduct = 0;
{//Creates sub-product
PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct", Dtk_Info::create(), assignedID_instance1 ) );//Adds an instance of leaf product in sub-product
PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
}
{//Creates root product
int assignedID_rootProduct = 0;
PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2", Dtk_Info::create(), assignedID_instance2 ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct", Dtk_Info::create(), assignedID_instance3 ) );//Adds an instance of leaf product in root product
PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context
{//Creates assembly level FDT and its link to final geometry
Dtk_FdtPtr dimension = sampleWriter::CreateDimension();//Registers a FDT at assembly level
dimension->TransformationMatrix().setXdir( Dtk_dir( 0., 1., 0. ) );
dimension->TransformationMatrix().setYdir( Dtk_dir( -1., 0., 0. ) );
dimension->TransformationMatrix().setZdir( Dtk_dir( 0., 0., 1. ) );
dimension->TransformationMatrix().setOrigin( Dtk_pnt( 0., 0., -50. ) );
int userDefinedID_dimensionNode = 1002;
stepw_InitNodeContext( userDefinedID_dimensionNode );
{//Targets face with ID 10 in the 3D part (geometry) of instance "PartWithBody_InRootProduct"
int targetedFaceID_1 = 10;//This matches in the already written body in current part context, the entity with Dtk_Info::GetId() == 10 (a Dtk_FacePtr, see CreateCylinder)
stepw_ER ElementReference_1;
PRINT_ERROR( stepw_CreateReference( ElementReference_1, targetedFaceID_1, assignedID_leafPart ) );
stepw_ERP ElementReferencePath_1;
PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_1 ) );
PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_1, assignedID_instance3 ) );
PRINT_ERROR( stepw_SetReferencePath( ElementReference_1, ElementReferencePath_1 ) );
PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );
}
{//Targets face with ID 10 in the 3D part (geometry) of instance "PartWithBody_InSubProduct" in instance "SubProduct_InRootProduct_2".
int targetedFaceID_2 = 10;//This matches in the already written body in current part context, the entity with Dtk_Info::GetId() == 10 (a Dtk_FacePtr, see CreateCylinder)
stepw_ER ElementReference_2;
PRINT_ERROR( stepw_CreateReference( ElementReference_2, targetedFaceID_2, assignedID_leafPart ) );
stepw_ERP ElementReferencePath_2;
PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_2 ) );
{//Appends assigned instance identifiers individually
PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance2 ) );
PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance1 ) );
}
//{//Or define the whole instance identifier rout at once.
// Dtk_tab<Dtk_ID> instance_path;
// instance_path.push_back( assignedID_instance2 );
// instance_path.push_back( assignedID_instance1 );
// stepw_DefineInstancePath( ElementReferencePath_2, instance_path );
//}
PRINT_ERROR( stepw_SetReferencePath( ElementReference_2, ElementReferencePath_2 ) );
PRINT_ERROR( stepw_AddReference( ElementReference_2 ) );
}
}
{
int viewModeThatReferencesAllFDTs = 1;
PRINT_ERROR( stepw_Add3DModelDisplay( view, viewModeThatReferencesAllFDTs ) );//Adds a view in the definition of the current part, that references all FDT of current part context
}
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
}
return dtkNoError;
}
//end_of_stepw_sample_assy_dimension
//Sample to write a product as an assembly, having product children (instances), with properties at various levels.
{
Dtk_transfo trf0, trf1, trf2;
CreateTransforms( trf0, trf1, trf2 );
int assignedID_leafPart = 0;
PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
int assignedID_subProduct = 0;
{//Creates sub-product
PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
{//Adds validation properties, AP242 form
Dtk_Val valprop_notional_CG( Dtk_pnt( 10., 20., 30. ) );
part_info->AddAttribute( "assembly validation property : : centre point", valprop_notional_CG );
PRINT_ERROR( stepw_SetPartProperties( part_info, 1 ) );//Adds properties at part level (PRODUCT_DEFINITION_SHAPE)
Dtk_Val valprop_nbchildren( 3 );
prod_info->AddAttribute( "assembly validation property : : number of children", valprop_nbchildren );
PRINT_ERROR( stepw_SetPartProperties( prod_info, 2 ) );//Adds properties at product level (PRODUCT_DEFINITION)
}
PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
}
{//Creates root product
int assignedID_rootProduct = 0;
PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
Dtk_InfoPtr instance_info = Dtk_Info::create();
Dtk_Val instance_kind( "first" );
instance_info->AddAttribute( "user defined attribute : : instance kind", instance_kind );//Defines properties to assign to the instance
Dtk_Val instance_valprop( 1 );
instance_info->AddAttribute( "attribute validation property : : text user attributes", instance_valprop );//Defines properties to assign to the instance
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1", instance_info ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
}
return dtkNoError;
}
//Sample to write a product as an assembly, having product children (instances), with attributes such as color or invisibility.
{
Dtk_transfo trf0, trf1, trf2;
CreateTransforms( trf0, trf1, trf2 );
int assignedID_leafPart = 0;
PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
int assignedID_subProduct = 0;
{//Creates sub-product
PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
}
{//Creates root product
int assignedID_rootProduct = 0;
PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
Dtk_InfoPtr first_instance_info = Dtk_Info::create();
first_instance_info->SetColor( Dtk_RGB( 10, 10, 10 ) );//Defines color of the first instance
Dtk_InfoPtr second_instance_info = Dtk_Info::create();//Defines blanked status (invisibility) of the second instance
second_instance_info->SetBlankedStatus( 1 );
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1", first_instance_info ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2", second_instance_info ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
}
return dtkNoError;
}
//Sample to write a product as an 'external' assembly, having product children (instances). The assembly is written in several physical files, one by leaf product.
{
Dtk_transfo trf0, trf1, trf2;
CreateTransforms( trf0, trf1, trf2 );
int assignedID_leafPart = 0;
Dtk_string uniqueNameForProduct = L"ExternalPartWithBody";//Product names should be unique in the root assembly product context
PRINT_ERROR( stepw_AddExternalReference( uniqueNameForProduct, L"ExternalPartWithBody.step", assignedID_leafPart ) );//Declares the product named L"ExternalPartWithBody" as an external product (written in a separated file)
PRINT_ERROR( WritePart_BodyOnly( uniqueNameForProduct, assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
int assignedID_subProduct = 0;
{//Creates sub-product
PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "ExternalPartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
}
{//Creates root product
int assignedID_rootProduct = 0;
PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
}
return dtkNoError;
}
//Sample to write a product as a 'nested external' assembly, having product children (instances). The assembly is written in several physical files, one by product.
{
Dtk_transfo trf0, trf1, trf2;
CreateTransforms( trf0, trf1, trf2 );
int assignedID_leafPart = 0;
Dtk_string uniqueNameForLeafProduct = L"NestedExternalPartWithBody";//Product names should be unique in the root assembly product context
PRINT_ERROR( stepw_AddExternalReference( uniqueNameForLeafProduct, L"NestedExternalPartWithBody.step", assignedID_leafPart ) );//Declares the product named L"ExternalPartWithBody" as an external product (written in a separated file)
PRINT_ERROR( WritePart_BodyOnly( uniqueNameForLeafProduct, assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
int assignedID_subProduct = 0;
{//Creates sub-product
Dtk_string uniqueNameForSubProduct = L"NestedExternalSubProduct";//Product names should be unique in the root assembly product context
PRINT_ERROR( stepw_AddExternalReference( uniqueNameForSubProduct, L"NestedExternalSubProduct.step", assignedID_subProduct ) );//Declares the product named L"NestedExternalSubProduct" as an external product (written in a separated file)
PRINT_ERROR( stepw_InitProduct( uniqueNameForSubProduct, assignedID_subProduct ) );//Initializes sub-product context
PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "NestedExternalPartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
}
{//Creates root product
int assignedID_rootProduct = 0;
PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_leafPart, trf0, "NestedExternalPartWithBody_InRootProduct", Dtk_Info::create() ) );//Adds an instance of leaf product in root product
PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
}
return dtkNoError;
}
//Sample to write a product as an 'external' assembly, having product children (instances), and a dimension (FDT) at assembly level, referencing geometries in its children.
{
Dtk_transfo trf0, trf1, trf2;
CreateTransforms( trf0, trf1, trf2 );
int assignedID_leafPart;
Dtk_string uniqueNameForLeafProduct = L"ExternalPartWithBody_ReferencedByFDT";//Product names should be unique in the root assembly product context
PRINT_ERROR( stepw_AddExternalReference( uniqueNameForLeafProduct, L"ExternalPartWithBody_ReferencedByFDT.step", assignedID_leafPart ) );//Declares the product named L"ExternalPartWithBody_ReferencedByFDT" as an external product (written in a separated file)
PRINT_ERROR( WritePart_UsedByExternalAssembly( uniqueNameForLeafProduct, assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
int assignedID_instance1 = 0, assignedID_instance2 = 0, assignedID_instance3 = 0, assignedID_instance4 = 0;
int userID_instance1 = 101, userID_instance2 = 102, userID_instance3 = 103, userID_instance4 = 104;
int assignedID_subProduct = 0;
{//Creates sub-product
PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_subProduct, assignedID_leafPart, trf0, "ExternalPartWithBody_InSubProduct", Dtk_Info::create(), assignedID_instance1, userID_instance1, "RD1" ) );//Adds an instance of leaf product in sub-product
PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product product part context, required even if empty
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product product context
}
{//Creates root product
int assignedID_rootProduct = 0;
PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1", Dtk_Info::create(), assignedID_instance3, userID_instance3, "RD3" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2", Dtk_Info::create(), assignedID_instance4, userID_instance4, "RD4" ) );//Adds an instance of sub-product in root product
PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_leafPart, trf0, "ExternalPartWithBody_InRootProduct", Dtk_Info::create(), assignedID_instance2, userID_instance2, "RD2" ) );//Adds an instance of leaf product in root product
PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context
int userDefinedID_dimensionNode = 42;
stepw_InitNodeContext( userDefinedID_dimensionNode );//Initializes root product FDT node context, with identifier specified by the user
PRINT_ERROR( stepw_Add3DPartFDT( dimension ) );//Registers created dimension in root product part
//Writes geometrical links, using element reference and element reference path
{//Targets face with ID 73 in the 3D part (geometry) of instance "ExternalPartWithBody_InRootProduct"
int targetedFaceID_1 = 73; //see "FaceGDCH" in testcreatecube.cpp : it is a const Dtk_ID assigned to one of the face of the sample cube.
stepw_ER ElementReference_1;
PRINT_ERROR( stepw_CreateReference( ElementReference_1, targetedFaceID_1, assignedID_leafPart ) );
stepw_ERP ElementReferencePath_1;
PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_1 ) );
PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_1, assignedID_instance2 ) );
PRINT_ERROR( stepw_SetReferencePath( ElementReference_1, ElementReferencePath_1 ) );
PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );
}
{//Targets face with ID 105 in the 3D part (geometry) of instance "ExternalPartWithBody_InSubProduct" in instance "SubProduct_InRootProduct_2".
int targetedFaceID_2 = 105; //see "FaceEHCA" in testcreatecube.cpp : it is a const Dtk_ID assigned to one of the face of the sample cube.
stepw_ER ElementReference_2;
PRINT_ERROR( stepw_CreateReference( ElementReference_2, targetedFaceID_2, assignedID_leafPart ) );
stepw_ERP ElementReferencePath_2;
PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_2 ) );
{//Appends assigned instance identifiers individually
PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance4 ) );
PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance1 ) );
}
//{//Or define the whole instance identifier rout at once.
// Dtk_tab<Dtk_ID> instance_path;
// instance_path.push_back( assignedID_instance4 );
// instance_path.push_back( assignedID_instance1 );
// stepw_DefineInstancePath( ElementReferencePath_2, instance_path );
//}
PRINT_ERROR( stepw_SetReferencePath( ElementReference_2, ElementReferencePath_2 ) );
PRINT_ERROR( stepw_AddReference( ElementReference_2 ) );
}
stepw_EndNodeContext();//Ends root product FDT node context
PRINT_ERROR( stepw_End3DPart() );//Ends current part context
PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
}
return dtkNoError;
}
}
}
//start_of_mainstepwrite
int StepWriteSample( const Dtk_string &inResultDirectory )
{
Dtk_string outputFileName, outputDirectory;
std::cout << endl << "----------------------------------------------" << std::endl;
std::cout << "Step Write start" << std::endl;
// Choosing output directory and file name
outputDirectory = inResultDirectory + L"Step/";
outputDirectory.FixPathSeparator();
outputDirectory.mkdir();
// First, initialize the Step writer
//int codeForAP203 = 1;
int codeForAP214 = 2;
//int codeForAP203E2 = 3;
int codeForAP242 = 4;
int dummy;
{
outputFileName = outputDirectory + L"SamplePart_BodyOnly.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
stepw::sample::WritePart_BodyOnly( L"SamplePart_BodyOnly", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
//[...]
//end_of_mainstepwrite
{
outputFileName = outputDirectory + L"SamplePart_BodyWithAxisSystem.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
stepw::sample::WritePart_BodyWithAxisSystem( L"SamplePart_BodyWithAxisSystem", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SamplePart_WireframeOnly.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
stepw::sample::WritePart_WireframeOnly( L"SamplePart_WireframeOnly", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SamplePart_MeshOnly.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
stepw::sample::WritePart_MeshOnly( L"SamplePart_MeshOnly", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SamplePart_MeshWithFaceColors.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
stepw::sample::WritePart_MeshWithFaceColors( L"SamplePart_MeshWithFaceColors", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SamplePart_BodyAndMeshFromTessellation.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
stepw::sample::WritePart_BodyAndMeshFromTessellation( L"SamplePart_BodyAndMeshFromTessellation", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SamplePart_WithProperties.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP214 ) );
stepw::sample::WritePart_WithProperties( L"SamplePart_WithProperties", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SamplePart_BodyInNamedLayer.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
stepw::sample::WritePart_BodyInNamedLayer( L"SamplePart_BodyInNamedLayer", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SamplePart_Datum.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
stepw::sample::WritePart_Datum( L"SamplePart_Datum", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SamplePart_GeometricalTolerance.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
stepw::sample::WritePart_GeometricalTolerance( L"SamplePart_GeometricalTolerance", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SamplePart_UsedByExternalAssembly.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
stepw::sample::WritePart_UsedByExternalAssembly( L"SamplePart_UsedByExternalAssembly", dummy );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SampleAssembly.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
stepw::sample::WriteAssembly( L"SampleAssembly" );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SampleAssembly_DimensionFDT.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
stepw::sample::WriteAssembly_DimensionFDT( L"SampleAssembly_DimensionFDT");
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SampleAssembly_WithProperties.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
stepw::sample::WriteAssembly_WithProperties( L"SampleAssembly_WithProperties");
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SampleAssembly_InstanceAttributes.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
stepw::sample::WriteAssembly_InstanceAttributes( L"SampleAssembly_InstanceAttributes" );
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SampleAssembly_BasicExternalReferences.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
stepw::sample::WriteAssembly_BasicExternalReferences( L"SampleAssembly_BasicExternalReferences");
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SampleAssembly_BasicExternalReference_DimensionFDT.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
stepw::sample::WriteAssembly_BasicExternalReference_DimensionFDT( L"SampleAssembly_BasicExternalReference_DimensionFDT");
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
{
outputFileName = outputDirectory + L"SampleAssembly_NestedExternalReferences.step";
PRINT_ERROR( stepw_InitFile( outputFileName, " sample ", codeForAP242 ) );
stepw::sample::WriteAssembly_NestedExternalReferences( L"SampleAssembly_NestedExternalReferences");
std::cout << "=> " << outputFileName.c_str() << std::endl;
}
std::cout << "Step Write end" << std::endl;
return 0;
}
//end_of_stepwrite_sample
sampleWriter::CreateCube_2
Dtk_BodyPtr CreateCube_2()
Definition: testcreatecylfdt.cpp:1070
testcreatefdt.hpp
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
sampleWriter::CreateCurves_2
Dtk_BodyPtr CreateCurves_2()
Definition: testcreatecylfdt.cpp:1114
Dtk_Info::AddAttribute
Dtk_ErrorStatus AddAttribute(Dtk_string name, Dtk_Val val)
sampleWriter::CreateMeshCube
Dtk_MeshPtr CreateMeshCube()
Mesh Cube sample.
Definition: testcreatemesh.cpp:209
stepw::sample::WritePart_MeshOnly
DtkErrorStatus WritePart_MeshOnly(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:111
Dtk_transfo::setOrigin
void setOrigin(const Dtk_pnt &O)
Set a new O center point.
stepw_InitProduct
DtkErrorStatus stepw_InitProduct(const Dtk_string &inProductName, int &outAssignedID, Dtk_ID inProductUserID=0)
Initializes the definition context of a product.
stepw_AddInstanceToPath
DtkErrorStatus stepw_AddInstanceToPath(stepw_ERP &inOutElementReferencePath, const int inInstanceID)
Appends an instance identifier to the element reference path. The instance identifier is provided by ...
stepw_SetProductLayerInfosSet
DtkErrorStatus stepw_SetProductLayerInfosSet(const Dtk_LayerInfosSetPtr inLayerInfoSet)
Sets the LayerInfosSet to refer to when writing the current product. It uses its mapping between laye...
stepw_Write3DConstructionGeometry
DtkErrorStatus stepw_Write3DConstructionGeometry(const Dtk_BodyPtr &inBody)
Writes a body as a construction geometry of a 3D part, of any kind (solid, shell / faces,...
stepw_ERP
Definition: stepw.hpp:443
stepw_Write3DPartMesh
DtkErrorStatus stepw_Write3DPartMesh(const Dtk_MeshPtr &inMesh)
Writes a mesh of a 3D part (3D content of a product).
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:714
stepw::sample::WritePart_BodyWithAxisSystem
DtkErrorStatus WritePart_BodyWithAxisSystem(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:74
Dtk_AxisSystem::create
static Dtk_SmartPtr< Dtk_AxisSystem > create()
Calls default constructor to allocate a new object.
PRINT_ERROR
#define PRINT_ERROR(inStatus)
Definition: testwriters.h:10
stepw::sample::WritePart_WireframeOnly
DtkErrorStatus WritePart_WireframeOnly(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:94
Dtk_bool
char Dtk_bool
Definition: define.h:727
stepw_Write3DPartBody
DtkErrorStatus stepw_Write3DPartBody(const Dtk_BodyPtr &inBody)
Writes a body of a 3D part (3D content of a product), of any kind (solid, shell / faces,...
stepw_Write3DPartBodyWithMesh
DtkErrorStatus stepw_Write3DPartBodyWithMesh(const Dtk_BodyPtr &inBody, const Dtk_MeshPtr &inMesh, const int inMode=0)
Writes a body of a 3D part (3D content of a product), associated with a mesh.
tess_InitTesselation
int tess_InitTesselation(Dtk_string inWorkingDirectory, double inTolerance)
Init the tesselation library.
sampleWriter::FillFacesColors
void FillFacesColors(Dtk_MeshPtr &inoutCubeMesh)
Filling mesh faces with colors.
Definition: testcreatemesh.cpp:246
stepw_EndProduct
DtkErrorStatus stepw_EndProduct(const int inProductID)
Ends the writing of a product - calls WriteAssemblyInstances if not yet done.
Dtk_Info::SetBlankedStatus
Dtk_ErrorStatus SetBlankedStatus(const Dtk_Int32 &inBlankedStatus)
stepw_SetModeProp
DtkErrorStatus stepw_SetModeProp(const int inMode)
Activates/Deactivates writing of properties : User Attributes, Product Data.
Dtk_MetaData::CreateMetaDataWithUnits
static Dtk_MetaDataPtr CreateMetaDataWithUnits(const MetaDataTypeEnum &inEnumType, Dtk_string inTitle, Dtk_string inValue, Dtk_string inUnits, Dtk_string inValueType=Dtk_string(L"STRING"))
Create a Dtk_MetaDataPtr .
Dtk_Val
Definition: dtk_val.hpp:67
stepw_Add3DPartProperty
Dtk_ErrorStatus stepw_Add3DPartProperty(const Dtk_MetaDataPtr &inProperty)
Adds a roperty to a part (default), or to an entity, according to InitPropertySet mode.
stepw_SetReferencePath
DtkErrorStatus stepw_SetReferencePath(stepw_ER &inOutElementReference, stepw_ERP &inElementReferencePath)
Assigns the element reference path to the element reference.
stepw_InitFile
DtkErrorStatus stepw_InitFile(const Dtk_string &inFileName, const char *inOriginatingSystem=" user ", const int inSchema=0)
Initializes a file to be written.
stepw_CreateReference
DtkErrorStatus stepw_CreateReference(stepw_ER &inOutElementReference, const int inEntityID, const int inProductID=0, const char *inReferenceKind="")
Creates a reference to an entity located in the designated Product/Part context, or current context i...
stepw::sample::WriteAssembly_BasicExternalReferences
DtkErrorStatus WriteAssembly_BasicExternalReferences(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:591
stepw::sample::WritePart_BodyOnly
DtkErrorStatus WritePart_BodyOnly(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:56
stepw_AddExternalReference
Dtk_ErrorStatus stepw_AddExternalReference(const Dtk_string &inProductName, const Dtk_string &inFileName, int &outID, Dtk_ID inInstCompId=0)
Declares a product to be written as an external reference (separated file).
stepw_SetModeFdt
DtkErrorStatus stepw_SetModeFdt(const int inMode, const int inPolyline=2)
Activates/Deactivates writing of FDT.
stepw_Init3DPart
DtkErrorStatus stepw_Init3DPart(const int inProductID)
Initializes the writing of a 3D part for the designated product.
stepw.hpp
stepw_AddInstanceWithInfo
DtkErrorStatus stepw_AddInstanceWithInfo(const int inFatherProductID, const int inChildProductID, const Dtk_transfo &inPosition, const Dtk_string &inInstanceName, const Dtk_InfoPtr &inInstanceInfo)
Adds an instance of a product ( child ) in an assembly product ( father ), with provided attributes.
sampleWriter::CreateFdtDatum
Dtk_FdtPtr CreateFdtDatum()
Creates simple Datum.
Definition: testcreatefdt.cpp:19
Dtk_MetaData::TypeConfigurationProperty
@ TypeConfigurationProperty
Definition: dtk_metadata.hpp:30
stepw_AddInstance
DtkErrorStatus stepw_AddInstance(const int inFatherProductID, const int inChildProductID, const Dtk_transfo &inPosition, const Dtk_string &inInstanceName)
Adds an instance of a product ( child ) in an assembly product ( father ).
stepw::sample::WritePart_BodyInNamedLayer
DtkErrorStatus WritePart_BodyInNamedLayer(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:336
Dtk_MetaData::TypeProperty
@ TypeProperty
Definition: dtk_metadata.hpp:28
stepw_Add3DPartFDT
DtkErrorStatus stepw_Add3DPartFDT(const Dtk_FdtPtr &inFDT)
Adds a FDT in the current part context.
Dtk_SmartPtr::DtkDynamicCast
static Dtk_SmartPtr< T > DtkDynamicCast(const Dtk_SmartPtr< T2 > &p)
Definition: util_ptr_dtk.hpp:101
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
stepw::sample::WritePart_Datum
DtkErrorStatus WritePart_Datum(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:210
stepw::sample::WriteAssembly_InstanceAttributes
DtkErrorStatus WriteAssembly_InstanceAttributes(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:549
sampleWriter::CreateConstructionPlane
Dtk_BodyPtr CreateConstructionPlane()
Definition: testcreatecylfdt.cpp:1161
stepw_SetPartProperties
DtkErrorStatus stepw_SetPartProperties(const Dtk_InfoPtr &inInfo, const int inItem)
Defines properties to be attached directly to the product : considers the list of Dtk_Val in the Dtk_...
stepw::sample::WriteAssembly_BasicExternalReference_DimensionFDT
DtkErrorStatus WriteAssembly_BasicExternalReference_DimensionFDT(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:672
stepw_SetAnchorProduct
DtkErrorStatus stepw_SetAnchorProduct(const int inProductID, const int inUserID)
Declares the product as having an ANCHOR section. If the designated product is already declared as su...
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
stepw_EndFile
DtkErrorStatus stepw_EndFile()
Ends the writing of the current STEP file.
stepw_End3DPart
DtkErrorStatus stepw_End3DPart()
Ends the writing of a product 3D part.
stepw_Write3DAxisSystem
DtkErrorStatus stepw_Write3DAxisSystem(const Dtk_AxisSystemPtr &inAxis)
Writes an axis system of a 3D part, in STEP, it is a construction geometry based on an axis placement...
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
tess.h
stepw::sample::CreateAxisSystem
Dtk_AxisSystemPtr CreateAxisSystem()
Definition: testlibstepwrite.cpp:23
stepw_AddReference
DtkErrorStatus stepw_AddReference(stepw_ER &inElementReference)
Registers the previously created element reference in the writer.
Dtk_string::mkdir
int mkdir() const
File Utility : Create a Directory.
Dtk_pnt
This is a mathematical point class.
Definition: dtk_pnt.hpp:22
stepw
Exported APIs for STEP Write Library.
Definition: testlibstepwrite.cpp:19
stepw_Add3DModelDisplay
Dtk_ErrorStatus stepw_Add3DModelDisplay(const Dtk_ModelDisplayPtr &inModelDisplay, const int inMode)
Adds a view ( Dtk_ModelDisplay ) in the current part context.
Dtk_string::FixPathSeparator
void FixPathSeparator()
File Utility : Fixes path separator consistency. It lets you replace the '\' or '/' by the OS needed ...
datakit.h
stepw::sample::WritePart_UsedByExternalAssembly
DtkErrorStatus WritePart_UsedByExternalAssembly(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:309
stepw::sample::WriteAssembly_WithProperties
DtkErrorStatus WriteAssembly_WithProperties(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:495
tess_BodyToMeshes
Dtk_ErrorStatus tess_BodyToMeshes(const Dtk_BodyPtr &inBodyToWrite, Dtk_tab< Dtk_MeshPtr > &outMeshes, Dtk_tab< Dtk_Int32 > &outIsSolid, Dtk_bool inTessWireframe=DTK_FALSE, Dtk_bool inApplyRenderInfos=DTK_FALSE)
: Make Tesselation from a Dtk_body and create a Set of Dtk_mesh if available
stepw::sample::WritePart_GeometricalTolerance
DtkErrorStatus WritePart_GeometricalTolerance(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:258
sampleWriter::CreateModelDisplayActivated
Dtk_ModelDisplayPtr CreateModelDisplayActivated()
Definition: testcreatefdt.cpp:324
testcreatemesh.hpp
stepw::sample::WriteAssembly_NestedExternalReferences
DtkErrorStatus WriteAssembly_NestedExternalReferences(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:630
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:85
stepw_ER
Definition: stepw.hpp:436
stepw::sample::WritePart_BodyAndMeshFromTessellation
DtkErrorStatus WritePart_BodyAndMeshFromTessellation(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:149
Dtk_tab::size
Dtk_Size_t size() const
Returns the size of the array.
Definition: util_stl_dtk.hpp:504
stepw_CreateInstancePath
DtkErrorStatus stepw_CreateInstancePath(stepw_ERP &inOutElementReferencePath)
Initializes a path for the element reference, identifying the sequence of instances to pass through.
stepw_CreateReferenceToNode
DtkErrorStatus stepw_CreateReferenceToNode(stepw_ER &inOutElementReference, const int inNodeID, const int inProductID=0, const char *inReferenceKind="")
Creates a reference to a whole node (Dtk_Node), located in the designated Product/Part context.
testcreatecylfdt.hpp
sampleWriter::CreateCylinder
Dtk_BodyPtr CreateCylinder()
Definition: testcreatecylfdt.cpp:1185
stepw::sample::WritePart_WithProperties
DtkErrorStatus WritePart_WithProperties(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:174
stepw::sample::WriteAssembly
DtkErrorStatus WriteAssembly(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:369
stepw_EndNodeContext
void stepw_EndNodeContext(const int unused=0)
Ends current node context.
sampleWriter::CreateDimension
Dtk_FdtPtr CreateDimension()
Definition: testcreatefdt.cpp:116
stepw::sample::WriteAssembly_DimensionFDT
DtkErrorStatus WriteAssembly_DimensionFDT(const Dtk_string &inRootAssemblyName)
Definition: testlibstepwrite.cpp:408
StepWriteSample
int StepWriteSample(const Dtk_string &inResultDirectory)
Definition: testlibstepwrite.cpp:753
Dtk_LayerInfosSet::Create
static Dtk_LayerInfosSetPtr Create(const Dtk_Size_t inNumLayers)
Calls a constructor to allocate a new object.
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:144
stepw::sample::CreateLayerInfosSet
Dtk_LayerInfosSetPtr CreateLayerInfosSet()
Definition: testlibstepwrite.cpp:42
testwriters.h
Dtk_RGB
Definition: dtk_rgb.hpp:7
Dtk_Info::SetColor
Dtk_ErrorStatus SetColor(const int &R, const int &G, const int &B)
stepw::sample::CreateTransforms
void CreateTransforms(Dtk_transfo &outFirst, Dtk_transfo &outSecond, Dtk_transfo &outThird)
Definition: testlibstepwrite.cpp:33
Dtk_Info::create
static Dtk_SmartPtr< Dtk_Info > create()
Calls default constructor to allocate a new object.
stepw_InitNodeContext
void stepw_InitNodeContext(const int inNodeID)
Initializes the context to write entities in a node.
stepw_AddAnchorItem
Dtk_ErrorStatus stepw_AddAnchorItem(const int inEntityID, const int inProductID, const Dtk_string &inGUID)
Registers an entity in the ANCHOR section, with an assigned GUID (optional).
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:15
stepw::sample::WritePart_MeshWithFaceColors
DtkErrorStatus WritePart_MeshWithFaceColors(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:129
sampleWriter::CreateGeometricalTolerance
Dtk_FdtPtr CreateGeometricalTolerance()
Definition: testcreatefdt.cpp:229
Dtk_MetaData::CreateMetaData
static Dtk_MetaDataPtr CreateMetaData(const MetaDataTypeEnum &inEnumType, Dtk_string inTitle, Dtk_string inValue, Dtk_string inValueType=Dtk_string(L"STRING"))
Create a Dtk_MetaDataPtr .