DATAKIT SDK  V2026.4
stepw::sample Namespace Reference

Set of sample functions to write specific data into a .stp file. More...

Functions

Dtk_AxisSystemPtr CreateAxisSystem ()
 
void CreateTransforms (Dtk_transfo &outFirst, Dtk_transfo &outSecond, Dtk_transfo &outThird, Dtk_transfo &outFourth)
 
DtkErrorStatus Write_MinimumViableFile (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus Write_UserDefinedHeader (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus WriteAssembly (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus WriteAssembly_BasicExternalReference_DimensionFDT (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus WriteAssembly_BasicExternalReferences (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus WriteAssembly_DimensionFDT (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus WriteAssembly_InstanceAttributes (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus WriteAssembly_InstanceOverride (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus WriteAssembly_NestedExternalReferences (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus WriteAssembly_WithProperties (const Dtk_string &inRootAssemblyName)
 
DtkErrorStatus WritePart_BodyAndMeshFromTessellation (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus WritePart_BodyInNamedLayer (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus WritePart_BodyOnly (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus WritePart_BodyWithAxisSystem (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus WritePart_Datum (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus WritePart_GeometricalTolerance (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus WritePart_MeshOnly (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus WritePart_MeshWithFaceColors (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus WritePart_UsedByExternalAssembly (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus WritePart_WireframeOnly (const Dtk_string &inPartName, int &outPartID)
 
DtkErrorStatus WritePart_WithProperties (const Dtk_string &inPartName, int &outPartID)
 

Detailed Description

Set of sample functions to write specific data into a .stp file.

Function Documentation

◆ CreateAxisSystem()

Dtk_AxisSystemPtr stepw::sample::CreateAxisSystem ( )
21  {
23  Dtk_transfo trsf;
24  trsf.setOrigin( Dtk_pnt( 100., 100., 100. ) );
25  axis->SetMatrix( trsf );
26  axis->SetName( "Axis_System" );
27  return axis;
28  }

◆ CreateTransforms()

void stepw::sample::CreateTransforms ( Dtk_transfo &  outFirst,
Dtk_transfo &  outSecond,
Dtk_transfo &  outThird,
Dtk_transfo &  outFourth 
)
31  {
32  outFirst = Dtk_transfo();
33  outSecond = Dtk_transfo();
34  outThird = Dtk_transfo();
35  outFourth = Dtk_transfo();
36  outFourth.setOrigin( Dtk_pnt( 150., 0., 0. ) );
37  outSecond.setOrigin( Dtk_pnt( 0., 150., -150. ) );
38  outThird.setOrigin( Dtk_pnt( 0., -150., -150. ) );
39  }

◆ Write_MinimumViableFile()

DtkErrorStatus stepw::sample::Write_MinimumViableFile ( const Dtk_string &  inPartName,
int &  outPartID 
)
44  {
45  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
46  PRINT_ERROR( stepw_Init3DPart( outPartID ) );
48  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
49  return dtkNoError;
50  }

◆ Write_UserDefinedHeader()

DtkErrorStatus stepw::sample::Write_UserDefinedHeader ( const Dtk_string &  inPartName,
int &  outPartID 
)
55  {
56  PRINT_ERROR( stepw_SetHeaderData( 0, L"This is the file description" ) );
57  PRINT_ERROR( stepw_SetHeaderData( 1, L"This is the author" ) );
58  PRINT_ERROR( stepw_SetHeaderData( 2, L"This is the organization writing the file" ) );
59  PRINT_ERROR( stepw_SetHeaderData( 3, L"This is the originating system" ) );
60  PRINT_ERROR( stepw_SetHeaderData( 4, L"This is the authorization" ) );
61 
62  return Write_MinimumViableFile( inPartName, outPartID );
63  }

◆ WriteAssembly()

DtkErrorStatus stepw::sample::WriteAssembly ( const Dtk_string &  inRootAssemblyName)
388  {
389  Dtk_transfo trf0, trf1, trf2, trf_unused;
390  CreateTransforms( trf0, trf1, trf2, trf_unused );
391 
392  int assignedID_leafPart = 0;
393  PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
394 
395  int assignedID_subProduct = 0;
396  {//Creates sub-product
397  PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
398 
399  PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
400 
401  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
402  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
403 
404  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
405  }
406  {//Creates root product
407  int assignedID_rootProduct = 0;
408  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
409 
410  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
411  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
412  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
413 
414  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
415  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
416 
417  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
418  }
419 
420  return dtkNoError;
421  }

◆ WriteAssembly_BasicExternalReference_DimensionFDT()

DtkErrorStatus stepw::sample::WriteAssembly_BasicExternalReference_DimensionFDT ( const Dtk_string &  inRootAssemblyName)
740  {
741  Dtk_transfo trf0, trf1, trf2, trf_unused;
742  CreateTransforms( trf0, trf1, trf2, trf_unused );
743 
744  int assignedID_leafPart;
745  Dtk_string uniqueNameForLeafProduct = L"ExternalPartWithBody_ReferencedByFDT";//Product names should be unique in the root assembly product context
746  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)
747  PRINT_ERROR( WritePart_UsedByExternalAssembly( uniqueNameForLeafProduct, assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
748 
749  int assignedID_instance1 = 0, assignedID_instance2 = 0, assignedID_instance3 = 0, assignedID_instance4 = 0;
750  int userID_instance1 = 101, userID_instance2 = 102, userID_instance3 = 103, userID_instance4 = 104;
751  int assignedID_subProduct = 0;
752  {//Creates sub-product
753  PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
754 
755  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
756 
757  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product product part context, required even if empty
758  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
759 
760  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product product context
761  }
762  {//Creates root product
763  int assignedID_rootProduct = 0;
764  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
765 
766  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
767  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
768  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
769 
770  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context
771 
773  int userDefinedID_dimensionNode = 42;
774 
775  stepw_InitNodeContext( userDefinedID_dimensionNode );//Initializes root product FDT node context, with identifier specified by the user
776  PRINT_ERROR( stepw_Add3DPartFDT( dimension ) );//Registers created dimension in root product part
777 
778  //Writes geometrical links, using element reference and element reference path
779  {//Targets face with ID 73 in the 3D part (geometry) of instance "ExternalPartWithBody_InRootProduct"
780  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.
781  stepw_ER ElementReference_1;
782  PRINT_ERROR( stepw_CreateReference( ElementReference_1, targetedFaceID_1, assignedID_leafPart ) );
783  stepw_ERP ElementReferencePath_1;
784  PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_1 ) );
785  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_1, assignedID_instance2 ) );
786  PRINT_ERROR( stepw_SetReferencePath( ElementReference_1, ElementReferencePath_1 ) );
787  PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );
788  }
789  {//Targets face with ID 105 in the 3D part (geometry) of instance "ExternalPartWithBody_InSubProduct" in instance "SubProduct_InRootProduct_2".
790  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.
791  stepw_ER ElementReference_2;
792  PRINT_ERROR( stepw_CreateReference( ElementReference_2, targetedFaceID_2, assignedID_leafPart ) );
793  stepw_ERP ElementReferencePath_2;
794  PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_2 ) );
795  {//Appends assigned instance identifiers individually
796  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance4 ) );
797  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance1 ) );
798  }
799  //{//Or define the whole instance identifier rout at once.
800  // Dtk_tab<Dtk_ID> instance_path;
801  // instance_path.push_back( assignedID_instance4 );
802  // instance_path.push_back( assignedID_instance1 );
803  // stepw_DefineInstancePath( ElementReferencePath_2, instance_path );
804  //}
805  PRINT_ERROR( stepw_SetReferencePath( ElementReference_2, ElementReferencePath_2 ) );
806  PRINT_ERROR( stepw_AddReference( ElementReference_2 ) );
807  }
808  stepw_EndNodeContext();//Ends root product FDT node context
809 
810  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
811  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
812  }
813 
814  return dtkNoError;
815  }

◆ WriteAssembly_BasicExternalReferences()

DtkErrorStatus stepw::sample::WriteAssembly_BasicExternalReferences ( const Dtk_string &  inRootAssemblyName)
659  {
660  Dtk_transfo trf0, trf1, trf2, trf_unused;
661  CreateTransforms( trf0, trf1, trf2, trf_unused );
662 
663  int assignedID_leafPart = 0;
664  Dtk_string uniqueNameForProduct = L"ExternalPartWithBody";//Product names should be unique in the root assembly product context
665  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)
666  PRINT_ERROR( WritePart_BodyOnly( uniqueNameForProduct, assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
667 
668  int assignedID_subProduct = 0;
669  {//Creates sub-product
670  PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
671  PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "ExternalPartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
672 
673  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
674  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
675 
676  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
677  }
678  {//Creates root product
679  int assignedID_rootProduct = 0;
680  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
681 
682  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
683  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
684  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
685 
686  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
687  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
688 
689  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
690  }
691 
692  return dtkNoError;
693  }

◆ WriteAssembly_DimensionFDT()

DtkErrorStatus stepw::sample::WriteAssembly_DimensionFDT ( const Dtk_string &  inRootAssemblyName)
477  {
478  Dtk_transfo trf0, trf1, trf2, trf_unused;
479  CreateTransforms( trf0, trf1, trf2, trf_unused );
480 
481  int assignedID_leafPart = 0;
482  PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
483 
484  int assignedID_instance1 = 0, assignedID_instance2 = 0, assignedID_instance3 = 0;
485  int assignedID_subProduct = 0;
486  {//Creates sub-product
487  PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
488 
489  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
490 
491  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
492  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
493 
494  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
495  }
496  {//Creates root product
497  int assignedID_rootProduct = 0;
498  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
499 
500  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
501  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
502  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
503 
504  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context
505 
506  {//Creates assembly level FDT and its link to final geometry
507  Dtk_FdtPtr dimension = sampleWriter::CreateDimension();//Registers a FDT at assembly level
508  dimension->TransformationMatrix().setXdir( Dtk_dir( 0., 1., 0. ) );
509  dimension->TransformationMatrix().setYdir( Dtk_dir( -1., 0., 0. ) );
510  dimension->TransformationMatrix().setZdir( Dtk_dir( 0., 0., 1. ) );
511  dimension->TransformationMatrix().setOrigin( Dtk_pnt( 0., 0., -50. ) );
512 
513  int userDefinedID_dimensionNode = 1002;
514  stepw_InitNodeContext( userDefinedID_dimensionNode );
515  PRINT_ERROR( stepw_Add3DPartFDT( dimension ) );
516  {//Targets face with ID 10 in the 3D part (geometry) of instance "PartWithBody_InRootProduct"
517  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)
518  stepw_ER ElementReference_1;
519  PRINT_ERROR( stepw_CreateReference( ElementReference_1, targetedFaceID_1, assignedID_leafPart ) );
520  stepw_ERP ElementReferencePath_1;
521  PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_1 ) );
522  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_1, assignedID_instance3 ) );
523  PRINT_ERROR( stepw_SetReferencePath( ElementReference_1, ElementReferencePath_1 ) );
524  PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );
525  }
526  {//Targets face with ID 10 in the 3D part (geometry) of instance "PartWithBody_InSubProduct" in instance "SubProduct_InRootProduct_2".
527  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)
528  stepw_ER ElementReference_2;
529  PRINT_ERROR( stepw_CreateReference( ElementReference_2, targetedFaceID_2, assignedID_leafPart ) );
530  stepw_ERP ElementReferencePath_2;
531  PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_2 ) );
532  {//Appends assigned instance identifiers individually
533  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance2 ) );
534  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance1 ) );
535  }
536  //{//Or define the whole instance identifier rout at once.
537  // Dtk_tab<Dtk_ID> instance_path;
538  // instance_path.push_back( assignedID_instance2 );
539  // instance_path.push_back( assignedID_instance1 );
540  // stepw_DefineInstancePath( ElementReferencePath_2, instance_path );
541  //}
542  PRINT_ERROR( stepw_SetReferencePath( ElementReference_2, ElementReferencePath_2 ) );
543  PRINT_ERROR( stepw_AddReference( ElementReference_2 ) );
544  }
546  }
547  {
549  int viewModeThatReferencesAllFDTs = 1;
550  PRINT_ERROR( stepw_Add3DModelDisplay( view, viewModeThatReferencesAllFDTs ) );//Adds a view in the definition of the current part, that references all FDT of current part context
551  }
552  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
553 
554  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
555  }
556 
557  return dtkNoError;
558  }

◆ WriteAssembly_InstanceAttributes()

DtkErrorStatus stepw::sample::WriteAssembly_InstanceAttributes ( const Dtk_string &  inRootAssemblyName)
617  {
618  Dtk_transfo trf0, trf1, trf2, trf_unused;
619  CreateTransforms( trf0, trf1, trf2, trf_unused );
620 
621  int assignedID_leafPart = 0;
622  PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
623 
624  int assignedID_subProduct = 0;
625  {//Creates sub-product
626  PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
627  PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
628 
629  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
630  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
631 
632  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
633  }
634  {//Creates root product
635  int assignedID_rootProduct = 0;
636  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
637 
638  Dtk_InfoPtr first_instance_info = Dtk_Info::Create();
639  first_instance_info->SetColor( Dtk_RGB( 10, 10, 10 ) );//Defines color of the first instance
640 
641  Dtk_InfoPtr second_instance_info = Dtk_Info::Create();//Defines blanked status (invisibility) of the second instance
642  second_instance_info->SetBlankedStatus( 1 );
643 
644  PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1", first_instance_info ) );//Adds an instance of sub-product in root product
645  PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2", second_instance_info ) );//Adds an instance of sub-product in root product
646  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
647 
648  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
649  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
650 
651  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
652  }
653 
654  return dtkNoError;
655  }

◆ WriteAssembly_InstanceOverride()

DtkErrorStatus stepw::sample::WriteAssembly_InstanceOverride ( const Dtk_string &  inRootAssemblyName)
427  {
428  Dtk_transfo trf0, trf1, trf2, trf3;
429  CreateTransforms( trf0, trf1, trf2, trf3 );
430 
431  int assignedID_leafPart = 0;
432  PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
433 
434  int assignedID_subProduct = 0;
435  int assignedID_instance1 = 0, assignedID_instance2 = 0;
436  int assignedID_unused1 = 0, assignedID_unused2 = 0;
437  {//Creates sub-product
438  stepw_InitProduct( L"SubProduct", assignedID_subProduct );//Initializes sub-product context
439 
440  stepw_AddInstanceWithInfo( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct_colored", Dtk_Info::Create(), assignedID_instance2 );//Adds an instance of leaf product in sub-product
441  stepw_AddInstanceWithInfo( assignedID_subProduct, assignedID_leafPart, trf3, "PartWithBody_InSubProduct_uncolored", Dtk_Info::Create(), assignedID_unused1 );//Adds an instance of leaf product in sub-product
442 
443  stepw_Init3DPart( assignedID_subProduct );//Initializes sub-product part context, required even if empty
444  stepw_End3DPart();//Ends current part context
445 
446  stepw_EndProduct( assignedID_subProduct );//Ends sub-product context
447  }
448  {//Creates root product
449  int assignedID_rootProduct = 0;
450  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
451 
452  PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_targeted", Dtk_Info::Create(), assignedID_instance1 ) );//Adds an instance of sub-product in root product
453  PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_untargeted", Dtk_Info::Create(), assignedID_unused2 ) );//Adds an instance of sub-product in root product
454 
455  auto overrideInfo = Dtk_Info::Create();
456  overrideInfo->SetColor( Dtk_RGB( 0, 0, 255 ) );//Creates an override info with a blue color
457  stepw_ERP ColoredInstancePath;
458  {
459  PRINT_ERROR( stepw_CreateInstancePath( ColoredInstancePath ) );
460  PRINT_ERROR( stepw_AddInstanceToPath( ColoredInstancePath, assignedID_instance1 ) );
461  PRINT_ERROR( stepw_AddInstanceToPath( ColoredInstancePath, assignedID_instance2 ) );
462  }
463  PRINT_ERROR( stepw_AddOverrideInstanceInfo( ColoredInstancePath, overrideInfo ) );//Adds an override info (color) on the first instance of sub-product in root product
464 
465  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
466  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
467 
468  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
469  }
470  return dtkNoError;
471  }

◆ WriteAssembly_NestedExternalReferences()

DtkErrorStatus stepw::sample::WriteAssembly_NestedExternalReferences ( const Dtk_string &  inRootAssemblyName)
698  {
699  Dtk_transfo trf0, trf1, trf2, trf_unused;
700  CreateTransforms( trf0, trf1, trf2, trf_unused );
701 
702  int assignedID_leafPart = 0;
703  Dtk_string uniqueNameForLeafProduct = L"NestedExternalPartWithBody";//Product names should be unique in the root assembly product context
704  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)
705  PRINT_ERROR( WritePart_BodyOnly( uniqueNameForLeafProduct, assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
706 
707  int assignedID_subProduct = 0;
708  {//Creates sub-product
709  Dtk_string uniqueNameForSubProduct = L"NestedExternalSubProduct";//Product names should be unique in the root assembly product context
710  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)
711  PRINT_ERROR( stepw_InitProduct( uniqueNameForSubProduct, assignedID_subProduct ) );//Initializes sub-product context
712 
713  PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "NestedExternalPartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
714 
715  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
716  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
717 
718  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
719  }
720  {//Creates root product
721  int assignedID_rootProduct = 0;
722  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
723 
724  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
725  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
726  PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_leafPart, trf0, "NestedExternalPartWithBody_InRootProduct", Dtk_Info::Create() ) );//Adds an instance of leaf product in root product
727 
728  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
729  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
730 
731  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
732  }
733 
734  return dtkNoError;
735  }

◆ WriteAssembly_WithProperties()

DtkErrorStatus stepw::sample::WriteAssembly_WithProperties ( const Dtk_string &  inRootAssemblyName)
563  {
564  Dtk_transfo trf0, trf1, trf2, trf_unused;
565  CreateTransforms( trf0, trf1, trf2, trf_unused );
566 
567  int assignedID_leafPart = 0;
568  PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
569 
570  int assignedID_subProduct = 0;
571  {//Creates sub-product
572  PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
573  PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
574 
575  {//Adds validation properties, AP242 form
576  Dtk_InfoPtr part_info = Dtk_Info::Create();
577  Dtk_Val valprop_notional_CG( Dtk_pnt( 10., 20., 30. ) );
578  part_info->AddAttribute( "assembly validation property : : centre point", valprop_notional_CG );
579  PRINT_ERROR( stepw_SetPartProperties( part_info, 1 ) );//Adds properties at part level (PRODUCT_DEFINITION_SHAPE)
580 
581  Dtk_InfoPtr prod_info = Dtk_Info::Create();
582  Dtk_Val valprop_nbchildren( 3 );
583  prod_info->AddAttribute( "assembly validation property : : number of children", valprop_nbchildren );
584  PRINT_ERROR( stepw_SetPartProperties( prod_info, 2 ) );//Adds properties at product level (PRODUCT_DEFINITION)
585  }
586 
587  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
588  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
589 
590  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
591  }
592  {//Creates root product
593  int assignedID_rootProduct = 0;
594  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
595 
596  Dtk_InfoPtr instance_info = Dtk_Info::Create();
597  Dtk_Val instance_kind( "first" );
598  instance_info->AddAttribute( "user defined attribute : : instance kind", instance_kind );//Defines properties to assign to the instance
599  Dtk_Val instance_valprop( 1 );
600  instance_info->AddAttribute( "attribute validation property : : text user attributes", instance_valprop );//Defines properties to assign to the instance
601 
602  PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1", instance_info ) );//Adds an instance of sub-product in root product
603  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
604  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
605 
606  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
607  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
608 
609  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
610  }
611 
612  return dtkNoError;
613  }

◆ WritePart_BodyAndMeshFromTessellation()

DtkErrorStatus stepw::sample::WritePart_BodyAndMeshFromTessellation ( const Dtk_string &  inPartName,
int &  outPartID 
)
162  {
163  Dtk_BodyPtr body = sampleWriter::CreateCylinder();//Constructs a body, int the shape of a cylinder
164 
165  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
166  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
167 
168  Dtk_MeshPtr mesh;
169  Dtk_tab<Dtk_MeshPtr> listMesh;
170  Dtk_tab<Dtk_Int32> IsSolid;
171  Dtk_bool TessWireframe = false;
172  tess_InitTesselation( "../../OutputFiles/", 0.2 );//Initializes tessellation library
173  PRINT_ERROR( tess_BodyToMeshes( body, listMesh, IsSolid, TessWireframe ) );//Tessellates brep into a meshes
174  if( listMesh.size() >= static_cast< Dtk_Size_t >( 1 ) )
175  mesh = listMesh[ 0 ];
176  PRINT_ERROR( stepw_Write3DPartBodyWithMesh( body, mesh ) );//Registers both the body geometry and its corresponding tessellated mesh, bounding their topology information
177 
178  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
179  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
180 
181  return dtkNoError;
182  }

◆ WritePart_BodyInNamedLayer()

DtkErrorStatus stepw::sample::WritePart_BodyInNamedLayer ( const Dtk_string &  inPartName,
int &  outPartID 
)
355  {
356  Dtk_BodyPtr body1 = sampleWriter::CreateCylinder();//Constructs a body, int the shape of a cylinder
357  body1->get_info()->SetLayer( 42 );//Assign it to layer 42
358  body1->GetEntity( 10 )->info()->SetLayer( 0 );//Assign entity with ID 10 (Dtk_Face) to layer 0
359  body1->GetEntity( 20 )->info()->SetLayer( 0 );//Assign entity with ID 20 (Dtk_Face) to layer 0
360  body1->GetEntity( 30 )->info()->SetLayer( 0 );//Assign entity with ID 30 (Dtk_Face) to layer 0
361 
362  Dtk_BodyPtr body2 = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
363  body2->get_info()->SetLayer( 1900 );//Assign it to layer 1900
364  Dtk_BodyPtr body3 = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
365  body3->get_info()->SetLayer( 1900 );//Assign it to layer 1900
366 
367 
368  Dtk_LayerInfosSetPtr layerInfosSet = sampleWriter::layer::CreateSet();//Create the layer infos set containing the name assigned to each layer
369 
370  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
371 
372  PRINT_ERROR( stepw_SetProductLayerInfosSet( layerInfosSet ) );//Set the current product layer infos set
373 
374  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
375  PRINT_ERROR( stepw_Write3DPartBody( body1 ) );//Registers body1 in part
376  PRINT_ERROR( stepw_Write3DPartBody( body2 ) );//Registers body2 in part
377  PRINT_ERROR( stepw_Write3DPartBody( body3 ) );//Registers body3 in part
378  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
379 
380  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
381 
382  return dtkNoError;
383  }

◆ WritePart_BodyOnly()

DtkErrorStatus stepw::sample::WritePart_BodyOnly ( const Dtk_string &  inPartName,
int &  outPartID 
)
69  {
70  Dtk_BodyPtr body = sampleWriter::CreateCylinder();//Constructs a body, in the shape of a cylinder
71 
72  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
73  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
74 
75  PRINT_ERROR( stepw_Write3DPartBody( body ) );//Registers the 3D geometry in the current part context
76 
77  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
78  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
79 
80  return dtkNoError;
81  }

◆ WritePart_BodyWithAxisSystem()

DtkErrorStatus stepw::sample::WritePart_BodyWithAxisSystem ( const Dtk_string &  inPartName,
int &  outPartID 
)
87  {
89 
90  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
91  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
92 
93  PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds a brep as definition of the 3D geometry of the part
94 
95  Dtk_AxisSystemPtr AxisSystem = CreateAxisSystem();
96  PRINT_ERROR( stepw_Write3DAxisSystem( AxisSystem ) );//Adds an axis system in the part context
97 
98  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
99  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
100 
101  return dtkNoError;
102  }

◆ WritePart_Datum()

DtkErrorStatus stepw::sample::WritePart_Datum ( const Dtk_string &  inPartName,
int &  outPartID 
)
229  {
230  Dtk_BodyPtr body = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
231 
232  //You init the Part writer
233  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
234  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Starts a part definition context
235 
236  PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds body as definition of the 3D geometry of the part
237  {
239  int nodeid_Fdt1 = 42;
240  stepw_InitNodeContext( nodeid_Fdt1 );//Starts a node context to encapsulate an entity and be able to reference it from other nodes context
241  PRINT_ERROR( stepw_Add3DPartFDT( Fdt1 ) );//Adds a FDT in the definition of current the part
242  {// Defines the geometrical links : within the same part
243  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)
244  stepw_ER ElementReference_1;
245  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
246  PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );//Registers this reference
247  }
248  stepw_EndNodeContext();//Ends current node context
249 
251  int userDefinedID_viewNode = 4242;
252  stepw_InitNodeContext( userDefinedID_viewNode );//Starts another node context, this time to encapsulate the view entity
253  PRINT_ERROR( stepw_Add3DModelDisplay( view, 0 ) );//Add a view in the definition of the current part
254  {//Lets the view reference the FDT, meaning the FDT is visible in this view. An FDT can appear in several views.
255  stepw_ER ElementReference_Fdt1;
256  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
257  PRINT_ERROR( stepw_AddReference( ElementReference_Fdt1 ) );//Registers this reference
258  }
259  stepw_EndNodeContext();//Ends current node context
260 
261  Dtk_AxisSystemPtr AxisSystem = CreateAxisSystem();
262  PRINT_ERROR( stepw_Write3DAxisSystem( AxisSystem ) );//Writes an axis system (complement FDT definition)
264  PRINT_ERROR( stepw_Write3DConstructionGeometry( constr_plane ) );//Writes a construction geometry (complement FDT definition)
265  }
266 
267  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
268  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
269 
270  return dtkNoError;
271  }

◆ WritePart_GeometricalTolerance()

DtkErrorStatus stepw::sample::WritePart_GeometricalTolerance ( const Dtk_string &  inPartName,
int &  outPartID 
)
277  {
278  Dtk_BodyPtr body = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
279 
280  //You init the Part writer
281  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
282  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Starts a part definition context
283 
284  PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds body as definition of the 3D geometry of the part
285  {
286  Dtk_FdtPtr datum = sampleWriter::CreateFdtDatum();//Creates datum "A"
287  int datum_node_id = 42;
288  stepw_InitNodeContext( datum_node_id );//Starts a node context to encapsulate an entity and be able to reference it from other nodes context
289  PRINT_ERROR( stepw_Add3DPartFDT( datum ) );//Adds a FDT in the definition of current the part
290  {// Defines the geometrical links : within the same part
291  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)
292  stepw_ER ElementReference_1;
293  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
294  PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );//Registers this reference
295  }
296  stepw_EndNodeContext();//Ends current node context
297 
298  Dtk_transfo fdt_transf;
299  fdt_transf.setOrigin( Dtk_pnt( 75., 125., 50. ) );
300  Dtk_FdtPtr geometricalTolerance = sampleWriter::CreateGeometricalTolerance();//Creates a geometrical tolerance that references datum "A"
301  geometricalTolerance->Transform( fdt_transf );
302 
303  int geometrical_tolerance_node_id = 43;
304  stepw_InitNodeContext( geometrical_tolerance_node_id );//Starts a node context to encapsulate an entity and be able to reference it from other nodes context
305  PRINT_ERROR( stepw_Add3DPartFDT( geometricalTolerance ) );//Adds a FDT in the definition of current the part
306  {// Defines the geometrical links : within the same part
307  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)
308  stepw_ER ElementReference_1;
309  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
310  PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );//Registers this reference
311  }
312  stepw_EndNodeContext();//Ends current node context
313 
315  int viewModeThatReferencesAllFDTs = 1;
316  PRINT_ERROR( stepw_Add3DModelDisplay( view, viewModeThatReferencesAllFDTs ) );//Adds a view in the definition of the current part, that references all FDT of current part context
317  }
318 
319  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
320  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
321 
322  return dtkNoError;
323  }

◆ WritePart_MeshOnly()

DtkErrorStatus stepw::sample::WritePart_MeshOnly ( const Dtk_string &  inPartName,
int &  outPartID 
)
124  {
125  Dtk_MeshPtr mesh = sampleWriter::CreateMeshCube();//Constructs a mesh, in the shape of a cube
126 
127  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
128  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
129 
130  PRINT_ERROR( stepw_Write3DPartMesh( mesh ) );//Adds a mesh as definition of the 3D geometry of the part
131 
132  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
133  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
134 
135  return dtkNoError;
136  }

◆ WritePart_MeshWithFaceColors()

DtkErrorStatus stepw::sample::WritePart_MeshWithFaceColors ( const Dtk_string &  inPartName,
int &  outPartID 
)
142  {
145 
146  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
147  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
148 
149  PRINT_ERROR( stepw_Write3DPartMesh( mesh ) );//Adds a mesh as definition of the 3D geometry of the part
150 
151  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
152  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
153 
154  return dtkNoError;
155  };

◆ WritePart_UsedByExternalAssembly()

DtkErrorStatus stepw::sample::WritePart_UsedByExternalAssembly ( const Dtk_string &  inPartName,
int &  outPartID 
)
328  {
329  Dtk_BodyPtr body = sampleWriter::CreateCube_2();//Constructs a body, int the shape of a cube
330 
331  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
332 
333  int userDefinedID_product = 42;
334  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
335  {
336  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)
337  Dtk_string anchor1( "73" );
338  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
339  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)
340  Dtk_string anchor2( "105" );
341  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
342  }
343 
344  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Starts a part definition context
345  PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds body as definition of the 3D geometry of the part
346 
347  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
348  PRINT_ERROR( stepw_EndProduct( outPartID ) );
349 
350  return dtkNoError;
351  }

◆ WritePart_WireframeOnly()

DtkErrorStatus stepw::sample::WritePart_WireframeOnly ( const Dtk_string &  inPartName,
int &  outPartID 
)
107  {
109 
110  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
111  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
112 
113  PRINT_ERROR( stepw_Write3DPartBody( wireframe ) );//Adds a wireframe as definition of the 3D geometry of the part
114 
115  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
116  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
117 
118  return dtkNoError;
119  }

◆ WritePart_WithProperties()

DtkErrorStatus stepw::sample::WritePart_WithProperties ( const Dtk_string &  inPartName,
int &  outPartID 
)
187  {
188  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
189  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Starts a part definition context
190 
191  Dtk_BodyPtr body = sampleWriter::CreateCylinder();//Constructs a body, int the shape of a cylinder
192 
193  body->GetEntity( 10 )->info()->AddAttribute( "face attribute : : surface finish", Dtk_Val( "Anodize per specification MIL-A-8625, Type I" ) );//Adds a property at face level
194  //AddCustomerDefinedAttribute allows you to add properties at various level (face, edge, vertex, part, product) without the need respect the string pattern "[property type] : : [property name]".
195  //The value of the property is given as a Dtk_Val.
196  //These properties are not typed and not structured (unless you respect the pattern), but they allow to add custom information in the file in a flexible way.
197  body->GetEntity( 10 )->info()->AddCustomerDefinedAttribute( "your float attribute", Dtk_Val( 105.2 ) );//Adds a property at face level
198  PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds a brep as definition of the 3D geometry of the part
199 
200  PRINT_ERROR( stepw_Add3DPartProperty( Dtk_MetaData::CreateMetaData( Dtk_MetaData::TypeConfigurationProperty, "Revision", "test_revision_4" ) ) );//Defines and adds a property at part level (Dtk_MetaData)
201  PRINT_ERROR( stepw_Add3DPartProperty( Dtk_MetaData::CreateMetaData( Dtk_MetaData::TypeProperty, "Cost", "12500 $" ) ) );//Defines and adds a property at part level (Dtk_MetaData)
202  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)
203 
204  {//Defines and adds validation properties at part level (Dtk_Info)
205  Dtk_InfoPtr part_info = Dtk_Info::Create();
206  part_info->AddCustomerDefinedAttribute( "your int attribute", Dtk_Val( 45 ) );//Adds a property at product level
207  part_info->AddAttribute( "geometric validation property : : surface area measure", Dtk_Val( "1234 mm2" ) );
208  part_info->AddAttribute( "geometric validation property : : volume measure", Dtk_Val( "5678 mm3" ) );
209  part_info->AddAttribute( "geometric validation property : : centre point", Dtk_Val( Dtk_pnt( 12., 34., 56. ) ) );
210  PRINT_ERROR( stepw_SetPartProperties( part_info, 1 ) );
211  }
212  {//Defines and adds properties at product level (Dtk_Info)
213  Dtk_InfoPtr prod_info = Dtk_Info::Create();
214  prod_info->AddCustomerDefinedAttribute( "uncategorized boolean attribute", Dtk_Val( static_cast<Dtk_Char8>( 'T' )));//Adds a property at product level
215  prod_info->AddAttribute( "material property : material name : Steel", Dtk_Val( "Steel YC38" ) );
216  prod_info->AddAttribute( "material property : density : density measure", Dtk_Val( "7.89 g/cm3" ) );
217  PRINT_ERROR( stepw_SetPartProperties( prod_info, 2 ) );
218  }
219 
220  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
221  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
222 
223  return dtkNoError;
224  }
Dtk_Info::Create
static Dtk_SmartPtr< Dtk_Info > Create()
Calls default constructor to allocate a new object.
sampleWriter::CreateCube_2
Dtk_BodyPtr CreateCube_2()
Creates a 100x100x100 mm BRep cube body augmented with face IDs (required for FDT linking),...
Definition: testcreatecylfdt.cpp:1064
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
sampleWriter::CreateCurves_2
Dtk_BodyPtr CreateCurves_2()
Creates a wireframe body with colored curves, augmented with additional curve-level attributes.
Definition: testcreatecylfdt.cpp:1110
Dtk_Info::AddAttribute
Dtk_ErrorStatus AddAttribute(Dtk_string name, Dtk_Val val)
sampleWriter::CreateMeshCube
Dtk_MeshPtr CreateMeshCube()
Mesh Cube sample.
Definition: testcreatemesh.cpp:207
stepw_AddOverrideInstanceInfo
Dtk_ErrorStatus stepw_AddOverrideInstanceInfo(stepw_ERP &inElementReferencePath, Dtk_InfoPtr &inOverrideInfo)
Assigns information on an instance in multi-level assembly context.
datum
b V2026 li b Entrée CATIA et non plus en tant qu’éléments réduisant la duplication des prototypes Amélioration de la prise en charge des systèmes de coordonnées d’assemblage réduisant la duplication des prototypes Correction d’un état masqué incorrect sur certains noeuds qui pouvaient parfois être définis deux fois dans le contexte d’un assemblage Amélioration du calcul des chaînes équivalentes Unicode sur plusieurs lignes Amélioration de l’écriture des normales de mockup en AP214 Correction de l’application de l’échelle aux coordonnées des points Correction de l’absence de lien entre les Datum et les autres FDT datum
Definition: FR_news.txt:70
Dtk_Info::AddCustomerDefinedAttribute
Dtk_ErrorStatus AddCustomerDefinedAttribute(Dtk_string name, Dtk_Val val)
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...
tess_InitTesselation
int tess_InitTesselation(Dtk_string inWorkingDirectory, double inTolerance)
Init the tesselation library.
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:445
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:53
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:711
PRINT_ERROR
#define PRINT_ERROR(inStatus)
Definition: testwriters.h:9
Dtk_bool
char Dtk_bool
Definition: define.h:724
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.
sampleWriter::FillFacesColors
void FillFacesColors(Dtk_MeshPtr &inoutCubeMesh)
Filling mesh faces with colors.
Definition: testcreatemesh.cpp:244
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)
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_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::WritePart_BodyOnly
DtkErrorStatus WritePart_BodyOnly(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:68
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_Init3DPart
DtkErrorStatus stepw_Init3DPart(const int inProductID)
Initializes the writing of a 3D part for the designated product.
stepw::sample::Write_MinimumViableFile
DtkErrorStatus Write_MinimumViableFile(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:43
Dtk_AxisSystem::Create
static Dtk_SmartPtr< Dtk_AxisSystem > Create()
Calls default constructor to allocate a new object.
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:14
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)
Tesselate a body. Generates one mesh per shell in the body.
Dtk_MetaData::TypeConfigurationProperty
@ TypeConfigurationProperty
Definition: dtk_metadata.hpp:31
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 ).
Dtk_MetaData::TypeProperty
@ TypeProperty
Definition: dtk_metadata.hpp:29
Dtk_Char8
char Dtk_Char8
Definition: define.h:696
stepw_Add3DPartFDT
DtkErrorStatus stepw_Add3DPartFDT(const Dtk_FdtPtr &inFDT)
Adds a FDT in the current part context.
Dtk_SmartPtr< Dtk_Face >::DtkDynamicCast
static Dtk_SmartPtr< Dtk_Face > DtkDynamicCast(const Dtk_SmartPtr< T2 > &p)
Definition: util_ptr_dtk.hpp:101
sampleWriter::CreateConstructionPlane
Dtk_BodyPtr CreateConstructionPlane()
Creates a construction plane body: an infinite plane at Y=50, returned as an open shell.
Definition: testcreatecylfdt.cpp:1154
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_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_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...
stepw::sample::CreateTransforms
void CreateTransforms(Dtk_transfo &outFirst, Dtk_transfo &outSecond, Dtk_transfo &outThird, Dtk_transfo &outFourth)
Definition: testlibstepwrite.cpp:30
stepw::sample::CreateAxisSystem
Dtk_AxisSystemPtr CreateAxisSystem()
Definition: testlibstepwrite.cpp:20
stepw_AddReference
DtkErrorStatus stepw_AddReference(stepw_ER &inElementReference)
Registers the previously created element reference in the writer.
Dtk_pnt
This is a mathematical point class.
Definition: dtk_pnt.hpp:20
stepw_Add3DModelDisplay
Dtk_ErrorStatus stepw_Add3DModelDisplay(const Dtk_ModelDisplayPtr &inModelDisplay, const int inMode)
Adds a view ( Dtk_ModelDisplay ) in the current part context.
stepw::sample::WritePart_UsedByExternalAssembly
DtkErrorStatus WritePart_UsedByExternalAssembly(const Dtk_string &inPartName, int &outPartID)
Definition: testlibstepwrite.cpp:327
sampleWriter::CreateModelDisplayActivated
Dtk_ModelDisplayPtr CreateModelDisplayActivated()
Creates an activated (visible) model display "MyView1" with a perspective camera.
Definition: testcreatefdt.cpp:321
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:84
stepw_ER
Definition: stepw.hpp:438
Dtk_tab::size
Dtk_Size_t size() const
Returns the size of the array.
Definition: util_stl_dtk.hpp:503
stepw_CreateInstancePath
DtkErrorStatus stepw_CreateInstancePath(stepw_ERP &inOutElementReferencePath)
Initializes a path for the element reference, identifying the sequence of instances to pass through.
stepw_SetHeaderData
DtkErrorStatus stepw_SetHeaderData(const int inNumItem, const wchar_t *inValItem)
Sets STEP file header fields value.
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.
sampleWriter::CreateCylinder
Dtk_BodyPtr CreateCylinder()
Creates a closed BRep cylinder body (radius 50, height 100) with two circular faces,...
Definition: testcreatecylfdt.cpp:1180
stepw_EndNodeContext
void stepw_EndNodeContext(const int unused=0)
Ends current node context.
sampleWriter::CreateDimension
Dtk_FdtPtr CreateDimension()
Creates a linear dimension FDT with a leader, dual-value text, and a frame.
Definition: testcreatefdt.cpp:112
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:151
Dtk_Info::GetId
int GetId() const
Dtk_RGB
Definition: dtk_rgb.hpp:8
Dtk_Info::SetColor
Dtk_ErrorStatus SetColor(const int &R, const int &G, const int &B)
sampleWriter::layer::CreateSet
Dtk_LayerInfosSetPtr CreateSet()
Create Layer info set.
Definition: testcreatelayerinfoset.cpp:17
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:14
sampleWriter::CreateGeometricalTolerance
Dtk_FdtPtr CreateGeometricalTolerance()
Creates a geometric tolerance FDT: cylindricity position tolerance | 0.02(M) | A |.
Definition: testcreatefdt.cpp:225
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 .
Dtk_Entity::info
Dtk_InfoPtr & info()