DATAKIT SDK  V2026.1
stepw::sample Namespace Reference

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

Functions

Dtk_AxisSystemPtr CreateAxisSystem ()
 
Dtk_LayerInfosSetPtr CreateLayerInfosSet ()
 
void CreateTransforms (Dtk_transfo &outFirst, Dtk_transfo &outSecond, Dtk_transfo &outThird)
 
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_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 ( )
20  {
22  Dtk_transfo trsf;
23  trsf.setOrigin( Dtk_pnt( 100., 100., 100. ) );
24  axis->SetMatrix( trsf );
25  axis->SetName( "Axis_System" );
26  return axis;
27  }

◆ CreateLayerInfosSet()

Dtk_LayerInfosSetPtr stepw::sample::CreateLayerInfosSet ( )
39  {
41  layerInfosSet->SetLayerID( 0, 42 );
42  layerInfosSet->SetLayerID( 1, 1900 );
43  layerInfosSet->SetLayerID( 2, 0 );
44  layerInfosSet->SetLayerName( 0, "MyFirstLayer" );
45  layerInfosSet->SetLayerName( 1, "MySecondLayer" );
46  layerInfosSet->SetLayerName( 2, "Faces" );
47  return layerInfosSet;
48  }

◆ CreateTransforms()

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

◆ Write_MinimumViableFile()

DtkErrorStatus stepw::sample::Write_MinimumViableFile ( const Dtk_string inPartName,
int &  outPartID 
)
53  {
54  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
55  PRINT_ERROR( stepw_Init3DPart( outPartID ) );
57  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
58  return dtkNoError;
59  }

◆ Write_UserDefinedHeader()

DtkErrorStatus stepw::sample::Write_UserDefinedHeader ( const Dtk_string inPartName,
int &  outPartID 
)
64  {
65  PRINT_ERROR( stepw_SetHeaderData( 0, L"This is the file description" ) );
66  PRINT_ERROR( stepw_SetHeaderData( 1, L"This is the author" ) );
67  PRINT_ERROR( stepw_SetHeaderData( 2, L"This is the organization writing the file" ) );
68  PRINT_ERROR( stepw_SetHeaderData( 3, L"This is the originating system" ) );
69  PRINT_ERROR( stepw_SetHeaderData( 4, L"This is the authorization" ) );
70 
71  return Write_MinimumViableFile( inPartName, outPartID );
72  }

◆ WriteAssembly()

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

◆ WriteAssembly_BasicExternalReference_DimensionFDT()

DtkErrorStatus stepw::sample::WriteAssembly_BasicExternalReference_DimensionFDT ( const Dtk_string inRootAssemblyName)
694  {
695  Dtk_transfo trf0, trf1, trf2;
696  CreateTransforms( trf0, trf1, trf2 );
697 
698  int assignedID_leafPart;
699  Dtk_string uniqueNameForLeafProduct = L"ExternalPartWithBody_ReferencedByFDT";//Product names should be unique in the root assembly product context
700  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)
701  PRINT_ERROR( WritePart_UsedByExternalAssembly( uniqueNameForLeafProduct, assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
702 
703  int assignedID_instance1 = 0, assignedID_instance2 = 0, assignedID_instance3 = 0, assignedID_instance4 = 0;
704  int userID_instance1 = 101, userID_instance2 = 102, userID_instance3 = 103, userID_instance4 = 104;
705  int assignedID_subProduct = 0;
706  {//Creates sub-product
707  PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
708 
709  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
710 
711  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product product part context, required even if empty
712  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
713 
714  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product product context
715  }
716  {//Creates root product
717  int assignedID_rootProduct = 0;
718  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
719 
720  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
721  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
722  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
723 
724  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context
725 
727  int userDefinedID_dimensionNode = 42;
728 
729  stepw_InitNodeContext( userDefinedID_dimensionNode );//Initializes root product FDT node context, with identifier specified by the user
730  PRINT_ERROR( stepw_Add3DPartFDT( dimension ) );//Registers created dimension in root product part
731 
732  //Writes geometrical links, using element reference and element reference path
733  {//Targets face with ID 73 in the 3D part (geometry) of instance "ExternalPartWithBody_InRootProduct"
734  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.
735  stepw_ER ElementReference_1;
736  PRINT_ERROR( stepw_CreateReference( ElementReference_1, targetedFaceID_1, assignedID_leafPart ) );
737  stepw_ERP ElementReferencePath_1;
738  PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_1 ) );
739  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_1, assignedID_instance2 ) );
740  PRINT_ERROR( stepw_SetReferencePath( ElementReference_1, ElementReferencePath_1 ) );
741  PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );
742  }
743  {//Targets face with ID 105 in the 3D part (geometry) of instance "ExternalPartWithBody_InSubProduct" in instance "SubProduct_InRootProduct_2".
744  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.
745  stepw_ER ElementReference_2;
746  PRINT_ERROR( stepw_CreateReference( ElementReference_2, targetedFaceID_2, assignedID_leafPart ) );
747  stepw_ERP ElementReferencePath_2;
748  PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_2 ) );
749  {//Appends assigned instance identifiers individually
750  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance4 ) );
751  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance1 ) );
752  }
753  //{//Or define the whole instance identifier rout at once.
754  // Dtk_tab<Dtk_ID> instance_path;
755  // instance_path.push_back( assignedID_instance4 );
756  // instance_path.push_back( assignedID_instance1 );
757  // stepw_DefineInstancePath( ElementReferencePath_2, instance_path );
758  //}
759  PRINT_ERROR( stepw_SetReferencePath( ElementReference_2, ElementReferencePath_2 ) );
760  PRINT_ERROR( stepw_AddReference( ElementReference_2 ) );
761  }
762  stepw_EndNodeContext();//Ends root product FDT node context
763 
764  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
765  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
766  }
767 
768  return dtkNoError;
769  }

◆ WriteAssembly_BasicExternalReferences()

DtkErrorStatus stepw::sample::WriteAssembly_BasicExternalReferences ( const Dtk_string inRootAssemblyName)
613  {
614  Dtk_transfo trf0, trf1, trf2;
615  CreateTransforms( trf0, trf1, trf2 );
616 
617  int assignedID_leafPart = 0;
618  Dtk_string uniqueNameForProduct = L"ExternalPartWithBody";//Product names should be unique in the root assembly product context
619  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)
620  PRINT_ERROR( WritePart_BodyOnly( uniqueNameForProduct, assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
621 
622  int assignedID_subProduct = 0;
623  {//Creates sub-product
624  PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
625  PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "ExternalPartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
626 
627  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
628  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
629 
630  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
631  }
632  {//Creates root product
633  int assignedID_rootProduct = 0;
634  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
635 
636  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
637  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
638  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
639 
640  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
641  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
642 
643  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
644  }
645 
646  return dtkNoError;
647  }

◆ WriteAssembly_DimensionFDT()

DtkErrorStatus stepw::sample::WriteAssembly_DimensionFDT ( const Dtk_string inRootAssemblyName)
430  {
431  Dtk_transfo trf0, trf1, trf2;
432  CreateTransforms( trf0, trf1, trf2 );
433 
434  int assignedID_leafPart = 0;
435  PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
436 
437  int assignedID_instance1 = 0, assignedID_instance2 = 0, assignedID_instance3 = 0;
438  int assignedID_subProduct = 0;
439  {//Creates sub-product
440  PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
441 
442  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
443 
444  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
445  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
446 
447  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
448  }
449  {//Creates root product
450  int assignedID_rootProduct = 0;
451  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
452 
453  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
454  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
455  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
456 
457  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context
458 
459  {//Creates assembly level FDT and its link to final geometry
460  Dtk_FdtPtr dimension = sampleWriter::CreateDimension();//Registers a FDT at assembly level
461  dimension->TransformationMatrix().setXdir( Dtk_dir( 0., 1., 0. ) );
462  dimension->TransformationMatrix().setYdir( Dtk_dir( -1., 0., 0. ) );
463  dimension->TransformationMatrix().setZdir( Dtk_dir( 0., 0., 1. ) );
464  dimension->TransformationMatrix().setOrigin( Dtk_pnt( 0., 0., -50. ) );
465 
466  int userDefinedID_dimensionNode = 1002;
467  stepw_InitNodeContext( userDefinedID_dimensionNode );
468  PRINT_ERROR( stepw_Add3DPartFDT( dimension ) );
469  {//Targets face with ID 10 in the 3D part (geometry) of instance "PartWithBody_InRootProduct"
470  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)
471  stepw_ER ElementReference_1;
472  PRINT_ERROR( stepw_CreateReference( ElementReference_1, targetedFaceID_1, assignedID_leafPart ) );
473  stepw_ERP ElementReferencePath_1;
474  PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_1 ) );
475  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_1, assignedID_instance3 ) );
476  PRINT_ERROR( stepw_SetReferencePath( ElementReference_1, ElementReferencePath_1 ) );
477  PRINT_ERROR( stepw_AddReference( ElementReference_1 ) );
478  }
479  {//Targets face with ID 10 in the 3D part (geometry) of instance "PartWithBody_InSubProduct" in instance "SubProduct_InRootProduct_2".
480  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)
481  stepw_ER ElementReference_2;
482  PRINT_ERROR( stepw_CreateReference( ElementReference_2, targetedFaceID_2, assignedID_leafPart ) );
483  stepw_ERP ElementReferencePath_2;
484  PRINT_ERROR( stepw_CreateInstancePath( ElementReferencePath_2 ) );
485  {//Appends assigned instance identifiers individually
486  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance2 ) );
487  PRINT_ERROR( stepw_AddInstanceToPath( ElementReferencePath_2, assignedID_instance1 ) );
488  }
489  //{//Or define the whole instance identifier rout at once.
490  // Dtk_tab<Dtk_ID> instance_path;
491  // instance_path.push_back( assignedID_instance2 );
492  // instance_path.push_back( assignedID_instance1 );
493  // stepw_DefineInstancePath( ElementReferencePath_2, instance_path );
494  //}
495  PRINT_ERROR( stepw_SetReferencePath( ElementReference_2, ElementReferencePath_2 ) );
496  PRINT_ERROR( stepw_AddReference( ElementReference_2 ) );
497  }
499  }
500  {
502  int viewModeThatReferencesAllFDTs = 1;
503  PRINT_ERROR( stepw_Add3DModelDisplay( view, viewModeThatReferencesAllFDTs ) );//Adds a view in the definition of the current part, that references all FDT of current part context
504  }
505  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
506 
507  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
508  }
509 
510  return dtkNoError;
511  }

◆ WriteAssembly_InstanceAttributes()

DtkErrorStatus stepw::sample::WriteAssembly_InstanceAttributes ( const Dtk_string inRootAssemblyName)
571  {
572  Dtk_transfo trf0, trf1, trf2;
573  CreateTransforms( trf0, trf1, trf2 );
574 
575  int assignedID_leafPart = 0;
576  PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
577 
578  int assignedID_subProduct = 0;
579  {//Creates sub-product
580  PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
581  PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
582 
583  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
584  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
585 
586  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
587  }
588  {//Creates root product
589  int assignedID_rootProduct = 0;
590  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
591 
592  Dtk_InfoPtr first_instance_info = Dtk_Info::create();
593  first_instance_info->SetColor( Dtk_RGB( 10, 10, 10 ) );//Defines color of the first instance
594 
595  Dtk_InfoPtr second_instance_info = Dtk_Info::create();//Defines blanked status (invisibility) of the second instance
596  second_instance_info->SetBlankedStatus( 1 );
597 
598  PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1", first_instance_info ) );//Adds an instance of sub-product in root product
599  PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2", second_instance_info ) );//Adds an instance of sub-product in root product
600  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
601 
602  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
603  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
604 
605  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
606  }
607 
608  return dtkNoError;
609  }

◆ WriteAssembly_NestedExternalReferences()

DtkErrorStatus stepw::sample::WriteAssembly_NestedExternalReferences ( const Dtk_string inRootAssemblyName)
652  {
653  Dtk_transfo trf0, trf1, trf2;
654  CreateTransforms( trf0, trf1, trf2 );
655 
656  int assignedID_leafPart = 0;
657  Dtk_string uniqueNameForLeafProduct = L"NestedExternalPartWithBody";//Product names should be unique in the root assembly product context
658  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)
659  PRINT_ERROR( WritePart_BodyOnly( uniqueNameForLeafProduct, assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
660 
661  int assignedID_subProduct = 0;
662  {//Creates sub-product
663  Dtk_string uniqueNameForSubProduct = L"NestedExternalSubProduct";//Product names should be unique in the root assembly product context
664  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)
665  PRINT_ERROR( stepw_InitProduct( uniqueNameForSubProduct, assignedID_subProduct ) );//Initializes sub-product context
666 
667  PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "NestedExternalPartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
668 
669  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
670  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
671 
672  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
673  }
674  {//Creates root product
675  int assignedID_rootProduct = 0;
676  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
677 
678  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1" ) );//Adds an instance of sub-product in root product
679  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
680  PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_leafPart, trf0, "NestedExternalPartWithBody_InRootProduct", Dtk_Info::create() ) );//Adds an instance of leaf product in root product
681 
682  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
683  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
684 
685  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
686  }
687 
688  return dtkNoError;
689  }

◆ WriteAssembly_WithProperties()

DtkErrorStatus stepw::sample::WriteAssembly_WithProperties ( const Dtk_string inRootAssemblyName)
517  {
518  Dtk_transfo trf0, trf1, trf2;
519  CreateTransforms( trf0, trf1, trf2 );
520 
521  int assignedID_leafPart = 0;
522  PRINT_ERROR( WritePart_BodyOnly( L"PartWithBody", assignedID_leafPart ) );//Creates leaf product, to be done first in order to be able to instanciate it
523 
524  int assignedID_subProduct = 0;
525  {//Creates sub-product
526  PRINT_ERROR( stepw_InitProduct( L"SubProduct", assignedID_subProduct ) );//Initializes sub-product context
527  PRINT_ERROR( stepw_AddInstance( assignedID_subProduct, assignedID_leafPart, trf0, "PartWithBody_InSubProduct" ) );//Adds an instance of leaf product in sub-product
528 
529  {//Adds validation properties, AP242 form
530  Dtk_InfoPtr part_info = Dtk_Info::create();
531  Dtk_Val valprop_notional_CG( Dtk_pnt( 10., 20., 30. ) );
532  part_info->AddAttribute( "assembly validation property : : centre point", valprop_notional_CG );
533  PRINT_ERROR( stepw_SetPartProperties( part_info, 1 ) );//Adds properties at part level (PRODUCT_DEFINITION_SHAPE)
534 
535  Dtk_InfoPtr prod_info = Dtk_Info::create();
536  Dtk_Val valprop_nbchildren( 3 );
537  prod_info->AddAttribute( "assembly validation property : : number of children", valprop_nbchildren );
538  PRINT_ERROR( stepw_SetPartProperties( prod_info, 2 ) );//Adds properties at product level (PRODUCT_DEFINITION)
539  }
540 
541  PRINT_ERROR( stepw_Init3DPart( assignedID_subProduct ) );//Initializes sub-product part context, required even if empty
542  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
543 
544  PRINT_ERROR( stepw_EndProduct( assignedID_subProduct ) );//Ends sub-product context
545  }
546  {//Creates root product
547  int assignedID_rootProduct = 0;
548  PRINT_ERROR( stepw_InitProduct( inRootAssemblyName, assignedID_rootProduct ) );//Initializes root product context
549 
550  Dtk_InfoPtr instance_info = Dtk_Info::create();
551  Dtk_Val instance_kind( "first" );
552  instance_info->AddAttribute( "user defined attribute : : instance kind", instance_kind );//Defines properties to assign to the instance
553  Dtk_Val instance_valprop( 1 );
554  instance_info->AddAttribute( "attribute validation property : : text user attributes", instance_valprop );//Defines properties to assign to the instance
555 
556  PRINT_ERROR( stepw_AddInstanceWithInfo( assignedID_rootProduct, assignedID_subProduct, trf1, "SubProduct_InRootProduct_1", instance_info ) );//Adds an instance of sub-product in root product
557  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_subProduct, trf2, "SubProduct_InRootProduct_2" ) );//Adds an instance of sub-product in root product
558  PRINT_ERROR( stepw_AddInstance( assignedID_rootProduct, assignedID_leafPart, trf0, "PartWithBody_InRootProduct" ) );//Adds an instance of leaf product in root product
559 
560  PRINT_ERROR( stepw_Init3DPart( assignedID_rootProduct ) );//Initializes root product part context, required even if empty
561  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
562 
563  PRINT_ERROR( stepw_EndProduct( assignedID_rootProduct ) );//Ends root product context
564  }
565 
566  return dtkNoError;
567  }

◆ WritePart_BodyAndMeshFromTessellation()

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

◆ WritePart_BodyInNamedLayer()

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

◆ WritePart_BodyOnly()

DtkErrorStatus stepw::sample::WritePart_BodyOnly ( const Dtk_string inPartName,
int &  outPartID 
)
78  {
79  Dtk_BodyPtr body = sampleWriter::CreateCylinder();//Constructs a body, in the shape of a cylinder
80 
81  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
82  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
83 
84  PRINT_ERROR( stepw_Write3DPartBody( body ) );//Registers the 3D geometry in the current part context
85 
86  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
87  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
88 
89  return dtkNoError;
90  }

◆ WritePart_BodyWithAxisSystem()

DtkErrorStatus stepw::sample::WritePart_BodyWithAxisSystem ( const Dtk_string inPartName,
int &  outPartID 
)
96  {
98 
99  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
100  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
101 
102  PRINT_ERROR( stepw_Write3DPartBody( body ) );//Adds a brep as definition of the 3D geometry of the part
103 
104  Dtk_AxisSystemPtr AxisSystem = CreateAxisSystem();
105  PRINT_ERROR( stepw_Write3DAxisSystem( AxisSystem ) );//Adds an axis system in the part context
106 
107  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
108  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
109 
110  return dtkNoError;
111  }

◆ WritePart_Datum()

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

◆ WritePart_GeometricalTolerance()

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

◆ WritePart_MeshOnly()

DtkErrorStatus stepw::sample::WritePart_MeshOnly ( const Dtk_string inPartName,
int &  outPartID 
)
133  {
134  Dtk_MeshPtr mesh = sampleWriter::CreateMeshCube();//Constructs a mesh, in the shape of a cube
135 
136  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
137  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
138 
139  PRINT_ERROR( stepw_Write3DPartMesh( mesh ) );//Adds a mesh as definition of the 3D geometry of the part
140 
141  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
142  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
143 
144  return dtkNoError;
145  }

◆ WritePart_MeshWithFaceColors()

DtkErrorStatus stepw::sample::WritePart_MeshWithFaceColors ( const Dtk_string inPartName,
int &  outPartID 
)
151  {
154 
155  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
156  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
157 
158  PRINT_ERROR( stepw_Write3DPartMesh( mesh ) );//Adds a mesh as definition of the 3D geometry of the part
159 
160  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
161  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
162 
163  return dtkNoError;
164  };

◆ WritePart_UsedByExternalAssembly()

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

◆ WritePart_WireframeOnly()

DtkErrorStatus stepw::sample::WritePart_WireframeOnly ( const Dtk_string inPartName,
int &  outPartID 
)
116  {
118 
119  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) );//Initializes root product context
120  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Initializes a part context
121 
122  PRINT_ERROR( stepw_Write3DPartBody( wireframe ) );//Adds a wireframe as definition of the 3D geometry of the part
123 
124  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
125  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
126 
127  return dtkNoError;
128  }

◆ WritePart_WithProperties()

DtkErrorStatus stepw::sample::WritePart_WithProperties ( const Dtk_string inPartName,
int &  outPartID 
)
196  {
197  PRINT_ERROR( stepw_InitProduct( inPartName, outPartID ) )//Initializes root product context
198  PRINT_ERROR( stepw_Init3DPart( outPartID ) );//Starts a part definition context
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  Dtk_Val valprop_area( "1234 mm2" );
207  part_info->AddAttribute( "geometric validation property : : surface area measure", valprop_area );
208  Dtk_Val valprop_volume( "5678 mm3" );
209  part_info->AddAttribute( "geometric validation property : : volume measure", valprop_volume );
210  Dtk_Val valprop_CG( Dtk_pnt( 12., 34., 56. ) );
211  part_info->AddAttribute( "geometric validation property : : centre point", valprop_CG );
212  PRINT_ERROR( stepw_SetPartProperties( part_info, 1 ) );
213  }
214  {//Defines and adds properties at product level (Dtk_Info)
215  Dtk_InfoPtr prod_info = Dtk_Info::create();
216  Dtk_Val mat_name( "Steel YC38" );
217  prod_info->AddAttribute( "material property : material name : Steel", mat_name );
218  Dtk_Val mat_density( "7.89 g/cm3" );
219  prod_info->AddAttribute( "material property : density : density measure", mat_density );
220  PRINT_ERROR( stepw_SetPartProperties( prod_info, 2 ) );
221  }
222 
223  PRINT_ERROR( stepw_End3DPart() );//Ends current part context
224  PRINT_ERROR( stepw_EndProduct( outPartID ) );//Ends root product context
225 
226  return dtkNoError;
227  }
sampleWriter::CreateCube_2
Dtk_BodyPtr CreateCube_2()
Definition: testcreatecylfdt.cpp:1064
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
sampleWriter::CreateCurves_2
Dtk_BodyPtr CreateCurves_2()
Definition: testcreatecylfdt.cpp:1108
Dtk_Info::AddAttribute
Dtk_ErrorStatus AddAttribute(Dtk_string name, Dtk_Val val)
sampleWriter::CreateMeshCube
Dtk_MeshPtr CreateMeshCube()
Mesh Cube sample.
Definition: testcreatemesh.cpp:204
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:444
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:715
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
Dtk_bool
char Dtk_bool
Definition: define.h:728
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:241
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:77
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:52
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:15
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: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 ).
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< 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()
Definition: testcreatecylfdt.cpp:1155
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::CreateAxisSystem
Dtk_AxisSystemPtr CreateAxisSystem()
Definition: testlibstepwrite.cpp:19
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:330
sampleWriter::CreateModelDisplayActivated
Dtk_ModelDisplayPtr CreateModelDisplayActivated()
Definition: testcreatefdt.cpp:320
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:84
stepw_ER
Definition: stepw.hpp:437
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()
Definition: testcreatecylfdt.cpp:1179
stepw_EndNodeContext
void stepw_EndNodeContext(const int unused=0)
Ends current node context.
sampleWriter::CreateDimension
Dtk_FdtPtr CreateDimension()
Definition: testcreatefdt.cpp:112
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:147
stepw::sample::CreateLayerInfosSet
Dtk_LayerInfosSetPtr CreateLayerInfosSet()
Definition: testlibstepwrite.cpp:38
Dtk_Info::GetId
int GetId() const
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:29
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:14
sampleWriter::CreateGeometricalTolerance
Dtk_FdtPtr CreateGeometricalTolerance()
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()