DATAKIT API  V2025.1
testlibplmxmlwrite.cpp File Reference

Functions

Dtk_ErrorStatus CreateJtFileForPLMXML (const Dtk_string &ficname, const Dtk_BodyPtr &body)
 
int PlmxmlWriteSample (const Dtk_string &inResultDirectory)
 
Dtk_ErrorStatus PlmxmlwritesampleJT (const Dtk_string &inResultDirectory)
 
template<typename T >
void Shift (T &mesh, double sh)
 

Function Documentation

◆ CreateJtFileForPLMXML()

Dtk_ErrorStatus CreateJtFileForPLMXML ( const Dtk_string ficname,
const Dtk_BodyPtr body 
)
28 {
29  Dtk_ErrorStatus err;
30  Dtk_Jtw_Interface J(ficname,err);
31  CHECK_OK(err);
32  CHECK_OK(J.AddBody(body));
33  return dtkNoError;
34 }

◆ PlmxmlWriteSample()

int PlmxmlWriteSample ( const Dtk_string inResultDirectory)
101 {
102  std::cout << endl << "----------------------------------------------" << endl;
103  std::cout << "Plmxml Write start" << endl;
104 
105  tess_InitTesselation("./", 0.005); // For JT : Init Tessellation : working directory and default tolerance (needed for writing bodies)
106  tess_ComputeBoundariesFromMesh(0); // Disable wire creation on mesh during Brep tessellation.
107 
108  int err = PlmxmlwritesampleJT(inResultDirectory);
109 
110  tess_EndTesselation(); // End of tessellation
111  std::cout << "Plmxml Write end" << endl;
112 
113 
114  return err;
115 }

◆ PlmxmlwritesampleJT()

Dtk_ErrorStatus PlmxmlwritesampleJT ( const Dtk_string inResultDirectory)
37 {
38 // create JT leaves
39  Dtk_BodyPtr axle = sampleWriter::CreateCyl(0.2, 5);
41 
42  Dtk_string outputDirectory = inResultDirectory + L"dtk/Plmxml/";
43  outputDirectory.FixPathSeparator();
44  outputDirectory.mkdir();
45 
46  Dtk_string axlename = outputDirectory + L"axle.jt";
47  Dtk_string wheelname = outputDirectory + L"wheel.jt";
48  Dtk_string plmxmlfile = outputDirectory + L"sample1.plmxml";
49  CHECK_OK(CreateJtFileForPLMXML(axlename, axle));
50  CHECK_OK(CreateJtFileForPLMXML(wheelname, wheel));
51 
52 // prepare datas for PLMXML
53  Dtk_Int64 id_of_wheel = 1;
54  Dtk_Int64 id_of_axles = 2;
55  Dtk_dir X(1, 0, 0);
56  Dtk_dir Y(0, 1, 0);
57  Dtk_dir Z(0, 0, 1);
58  Dtk_tab<Dtk_MetaDataPtr> meta1,meta2;
62 
63 // create PLMXML
64  Dtk_ErrorStatus err;
65  Dtk_Plmxmlw_Interface P(plmxmlfile, err, 0.001); // scale millimeters to meters
66  CHECK_OK(err);
67 
68  CHECK_OK(P.OpenInstance("RootNode")); // Rootnode creation
69  CHECK_OK(P.OpenInstance("Axles", id_of_axles)); // open Axles, give an ID for future reinstance, placement by default : identity matrix
70 
71  CHECK_OK(P.OpenInstance("Axle")); // open
72  CHECK_OK(P.SetExternFic(axlename));
73  CHECK_OK(P.CloseLastInstance()); // close Axle
74 
75  CHECK_OK(P.OpenInstance("Wheels")); // open
76  CHECK_OK(P.OpenInstance("Wheel", id_of_wheel, Dtk_transfo(X, Y, Z, Dtk_pnt(0, 0, 5)))); // open instance
77  CHECK_OK(P.SetExternFic(wheelname));
78  CHECK_OK(P.CloseLastInstance()); // close Wheel
79 
80  CHECK_OK(P.OpenInstance("Wheel2", id_of_wheel, Dtk_transfo(X, -Y, -Z, Dtk_pnt()), meta1)); // open reinstance
81  CHECK_OK(P.CloseLastInstance()); // reinstancied : must close Wheel immediatly.
82 
83  CHECK_OK(P.CloseLastInstance()); // close Wheels
84 
85  CHECK_OK(P.CloseLastInstance()); // close Axles
86 
87  CHECK_OK(P.OpenInstance("Axles2", id_of_axles, Dtk_transfo(X, Y, Z, Dtk_pnt(10, 0, 0)),meta2)); // reinstance whole subassembly with matrix
88  CHECK_OK(P.CloseLastInstance()); // reinstancied : must close Wheel immediatly.
89 
90  CHECK_OK(P.CloseLastInstance()); // close RootNode
91  std::cout << "=> " << plmxmlfile.c_str() << endl;
92  return dtkNoError;// Automatic Finish while P released
93 }

◆ Shift()

template<typename T >
void Shift ( T &  mesh,
double  sh 
)
21 {
22  Dtk_transfo t;
23  t.addTranslate(Dtk_dir(sh, 0, 0));
24  mesh->Transform(t);
25 }
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
Dtk_Plmxmlw_Interface
Definition: plmxmlw.hpp:12
sampleWriter::CreateCyl
Dtk_BodyPtr CreateCyl(double radius, double height)
Definition: testcreatecube.cpp:1791
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
tess_InitTesselation
int tess_InitTesselation(Dtk_string inWorkingDirectory, double inTolerance)
Init the tesselation library.
PlmxmlwritesampleJT
Dtk_ErrorStatus PlmxmlwritesampleJT(const Dtk_string &inResultDirectory)
Definition: testlibplmxmlwrite.cpp:36
Dtk_Int64
int64_t Dtk_Int64
Definition: define.h:692
CreateJtFileForPLMXML
Dtk_ErrorStatus CreateJtFileForPLMXML(const Dtk_string &ficname, const Dtk_BodyPtr &body)
Definition: testlibplmxmlwrite.cpp:27
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
CHECK_OK
#define CHECK_OK(X)
Definition: testwriters.h:9
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
Dtk_MetaData::TypeParameter
@ TypeParameter
Definition: dtk_metadata.hpp:32
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
Dtk_string::mkdir
int mkdir() const
File Utility : Create a Directory.
Dtk_pnt
This is a mathematical point class.
Definition: dtk_pnt.hpp:22
Dtk_string::FixPathSeparator
void FixPathSeparator()
File Utility : Fixes path separator consistency. It lets you replace the '\' or '/' by the OS needed ...
tess_ComputeBoundariesFromMesh
int tess_ComputeBoundariesFromMesh()
: Check value of option memorize noundaries of mesh
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:85
Dtk_transfo::addTranslate
void addTranslate(const Dtk_dir &V)
Translate the Dtk_transfo.
tess_EndTesselation
void tess_EndTesselation()
Free the data used by tesselation library.
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:140
Dtk_tab::push_back
void push_back(const T &x)
Inserts an element at the end of the array.
Definition: util_stl_dtk.hpp:415
Dtk_Jtw_Interface
This is Jt Interface class used to write Jt files.
Definition: jtw.h:8
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:15
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 .