DATAKIT API  V2025.1
Full samples source code
#ifdef WIN32
#include <windows.h>
#endif
#include "testwriters.h"
//DATAKIT headers needed
#include "datakit.h"
#include "ugw/ugw.hpp"
// sample cube
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample11
Dtk_ErrorStatus UgwSimpleBody(const Dtk_string& outputFileName, int version)
{
// Cube Sample
//CubeBody->info()->AddAttribute("MATERIALNAME", Dtk_string("Ash Gloss"));
// First we initialize writer with name of output file (see macro CHECK_OK above)
CHECK_OK(Ugw::InitFile(outputFileName, version));
// Then we write the body constructed
// Write final file and release the writer.
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample11
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample12
Dtk_ErrorStatus UgwTwoBodies(const Dtk_string& outputFileName, int version)
{
// Cube Sample
// We construct 2 cubes, translating the second
cube1->info()->SetName("FirstCube");
cube2->info()->SetName("SecondCube");
Dtk_transfo translate(Dtk_dir(1, 0, 0), Dtk_dir(0, 1, 0), Dtk_dir(0, 0, 1), Dtk_pnt(200, 0, 0));
cube2->Transform(translate);
// First we initialize writing with name of output file (see macro CHECK_OK above)
CHECK_OK(Ugw::InitFile(outputFileName, version));
// Then we write the 2 bodies constructed
// Write final file and release the writer.
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample12
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample13
Dtk_ErrorStatus UgwMesh(const Dtk_string& outputFileName, int version)
{
Dtk_MeshPtr CubeMesh = sampleWriter::CreateMeshCylinder(8); // get a meshcylinder (common sample)
CubeMesh->info()->SetName("MyMesh");
CHECK_OK(Ugw::InitFile(outputFileName, version));
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample13
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample14
Dtk_ErrorStatus UgwWire(const Dtk_string& outputFileName, int version)
{
CHECK_OK(Ugw::InitFile(outputFileName, version));
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample14
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample15
{
t.addTranslate(Dtk_dir(-100, 50, 200));
axis->SetName("MyAxisSystem");
axis->info()->AddAttribute("NXNAME", Dtk_Val("ANOTHERAXISSYSTEM"));
axis->info()->SetColor(255, 255, 0);
axis->SetMatrix(t);
return axis;
}
{
body->info() = Dtk_Info::create();
body->info()->SetName("MyReferencePlane");
body->info()->AddAttribute("NXNAME", Dtk_Val("MYPLANE"));
body->info()->SetColor(0, 255, 255);
body->AddOpenShell(shell);
Dtk_PlaneSurfacePtr plane = Dtk_PlaneSurface::Create(Dtk_pnt(150, 150, 0), Dtk_dir(0, 0, 1), Dtk_dir(1, 0, 0));
face->SetGeom(Dtk_SurfacePtr::DtkDynamicCast(plane));
shell->AddFace(face, DTK_TRUE);
return body;
}
{
body->info() = Dtk_Info::create();
body->info()->SetName("MyFixedRefPlane");
body->info()->AddAttribute("NXNAME", Dtk_Val("ANOTHERFIXEDPLANENAME"));
body->info()->SetColor(0, 0, 255);
body->AddOpenShell(shell);
Dtk_PlaneSurfacePtr plane = Dtk_PlaneSurface::Create(Dtk_pnt(250, 250, 0), Dtk_dir(0, 0, 1), Dtk_dir(1, 0, 0));
double trim[] = { -10,10,-10,10 };
plane->SetTrimUVBox(trim);
face->SetGeom(Dtk_SurfacePtr::DtkDynamicCast(plane));
shell->AddFace(face, DTK_TRUE);
return body;
}
{
body->info() = Dtk_Info::create();
body->info()->SetName("MyRefAxis");
body->info()->AddAttribute("NXNAME", Dtk_Val("ANOTHERAXISNAME"));
body->info()->SetColor(0, 255, 0);
body->AddOpenShell(shell);
Dtk_LinePtr line = Dtk_Line::Create(Dtk_pnt(160, 100, 10), Dtk_pnt(260, 200, 30));
shell->AddWire(tab);
return body;
}
{
body->info() = Dtk_Info::create();
body->info()->SetName("MyRefPoint");
body->info()->SetColor(255, 100, 0);
body->AddOpenShell(shell);
Dtk_PointPtr point = Dtk_Point::Create(Dtk_pnt(0, 310, 10));
tab.push_back(point);
shell->AddWire(tab);
return body;
}
Dtk_ErrorStatus UgwReferences(const Dtk_string& outputFileName, int version)
{
CHECK_OK(Ugw::InitFile(outputFileName, version));
cube->info()->SetName("MyCube");
cube->info()->AddAttribute("NXNAME", Dtk_Val("SOLIDBODYNAME"));
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample15
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample16
Dtk_ErrorStatus UgwExternParasolid(const Dtk_string& outputFileName, const Dtk_string& parasolidfic, int version)
{
FILE* F = parasolidfic.OpenFile(DTK_RB);
if (!F)
{
std::cout << "error : " << parasolidfic.c_str() << " does not exist";
}
fseek(F, 0, SEEK_END);
flux.resize(ftell(F));
fseek(F, 0, SEEK_SET);
if (flux.size() > 0)
fread(&flux[0], 1, flux.size(), F);
fclose(F);
inf->SetName("MyFeatureName");
inf->AddAttribute("NXNAME", Dtk_string("SolidName"));
//inf->SetBlankedStatus(1); // set as invisible
//inf->SetColor(Dtk_RGB(255, 0, 0)); // set a body color (appear on non colored faces)
CHECK_OK(Ugw::InitFile(outputFileName, version));
CHECK_OK(Ugw::WriteExternParasolidBody(&flux[0], flux.size(), inf));
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample16
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample17
Dtk_ErrorStatus UgwExternJTMesh(const Dtk_string& outputFileName, const Dtk_string& jtfic, int version)
{
FILE* F = jtfic.OpenFile(DTK_RB);
if (!F)
{
std::cout << "error : " << jtfic.c_str() << " does not exist";
}
fseek(F, 0, SEEK_END);
flux.resize(ftell(F));
fseek(F, 0, SEEK_SET);
if (flux.size() > 0)
fread(&flux[0], 1, flux.size(), F);
fclose(F);
inf->SetName("MyFeatureName");
inf->AddAttribute("NXNAME", Dtk_string("SolidName"));
//inf->SetBlankedStatus(1); // set as invisible
//inf->SetColor(Dtk_RGB(255, 0, 0)); // set a body color (appear on non colored faces)
CHECK_OK(Ugw::InitFile(outputFileName, version));
CHECK_OK(Ugw::WriteExternJtMesh(&flux[0], flux.size(), inf));
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample17
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample21
{
const int maxlayer = 257; // 256 layers (from 1 to 256 included for NX)
visible.resize(maxlayer, 1);
selectable.resize(maxlayer, 1);
// visibles and selectables
int i;
for (i = 1; i < maxlayer; i++)
{
visible[i] = (i % 2); // one on two
selectable[i] = ((i % 3) != 0); // one on three
}
// 2 layer filters :
Dtk_LayerFilterInfosPtr filter456 = lay->CreateLayerFilterInfos("FILTER_456", "MyDescription");
lay456.push_back(4); lay456.push_back(5); lay456.push_back(6);
filter456->SelectLayers(lay456);
Dtk_LayerFilterInfosPtr filter678 = lay->CreateLayerFilterInfos("FILTER_678");
lay678.push_back(6); lay678.push_back(7); lay678.push_back(8);
filter678->SelectLayers(lay678);
// wrok layer (default)
lay->SetDefaultLayer(12);
return lay;
}
Dtk_ErrorStatus UgwLayers(const Dtk_string& outputFileName, int version)
{
Dtk_BodyPtr CubeBody = sampleWriter::CreateCube(); // get a brepcube (common sample)
Dtk_MeshPtr CylMesh = sampleWriter::CreateMeshCylinder(8); // get a meshcyl (common sample)
Dtk_transfo translatescale(Dtk_dir(20, 0, 0), Dtk_dir(0, 20, 0), Dtk_dir(0, 0, 20), Dtk_pnt(150, 0, 0));
CylMesh->Transform(translatescale);
CHECK_OK(Ugw::InitFile(outputFileName, version));
Dtk_tab<Dtk_Int32> visible, selectable;
Dtk_LayerInfosSetPtr layerinfoset = CreateLayerInfosSet(visible, selectable);
CubeBody->info()->SetLayer(5);
CylMesh->info()->SetLayer(6);
CHECK_OK(Ugw::SetLayerData(layerinfoset, visible, selectable));
// Then we write the 2 bodies constructed
// Write final file and release the writer.
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample21
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample22
Dtk_ErrorStatus UgwGroups(const Dtk_string& outputFileName, int version)
{
cube1->info()->SetName("FirstCube");
cube2->info()->SetName("SecondCube");
Dtk_transfo translate(Dtk_dir(1, 0, 0), Dtk_dir(0, 1, 0), Dtk_dir(0, 0, 1), Dtk_pnt(200, 0, 0));
cube2->Transform(translate);
Dtk_MeshPtr CylMesh = sampleWriter::CreateMeshCylinder(8); // get a meshcyl (common sample)
CylMesh->info()->SetName("OneMesh");
Dtk_transfo translatescale(Dtk_dir(10, 0, 0), Dtk_dir(0, 10, 0), Dtk_dir(0, 0, 10), Dtk_pnt(-100, 0, 0));
CylMesh->Transform(translatescale);
WireBody->Transform(translatescale);
CHECK_OK(Ugw::InitFile(outputFileName, version));
// put cube1 in group GroupRoot/Sub1
cube1->info()->AddAttribute("NXGROUPS", Dtk_Val("GroupRoot\\Sub1\\"));
// put cube1 in group GroupRoot/Sub1 and also GroupRoot/Sub2
cube2->info()->AddAttribute("NXGROUPS", Dtk_Val("GroupRoot\\Sub1\\\\GroupRoot\\Sub2\\"));
// put Mesh in group GroupRoot/Sub2
CylMesh->info()->AddAttribute("NXGROUPS", Dtk_Val("GroupRoot\\Sub2\\"));
// put Wire in group GroupRoot/Sub2
WireBody->info()->AddAttribute("NXGROUPS", Dtk_Val("GroupRoot\\Sub2\\"));
// set property to group Sub2
infsub2->SetBlankedStatus(1);
infsub2->SetLayer(23);
CHECK_OK(Ugw::SetGroupDatas("Sub2", infsub2)); // Sub2 become invisible, and on layer 23
// make an empty group
infsub3->AddAttribute("NXGROUPS", Dtk_Val("GroupRoot\\Sub3\\"));
infsub3->SetLayer(19);
CHECK_OK(Ugw::SetGroupDatas("Sub3", infsub3)); // Sub3 become an empty group on layer 19
// Then we write the 2 bodies constructed
// Write final file and release the writer.
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample22
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample23
Dtk_ErrorStatus UgwRefSets(const Dtk_string& outputFileName, int version)
{
cube1->info()->SetName("FirstCube");
cube2->info()->SetName("SecondCube");
Dtk_transfo translate(Dtk_dir(1, 0, 0), Dtk_dir(0, 1, 0), Dtk_dir(0, 0, 1), Dtk_pnt(200, 0, 0));
cube2->Transform(translate);
// reference set
// Cube1 into reference set "MyRef1","MyRef2","MyRef3"
cube1->info()->AddAttribute("NXREFERENCESET", Dtk_Val("MyRef1\\MyRef2\\MyRef3\\"));
// Cube2 into reference set "MyRef1","MyRef3"
cube2->info()->AddAttribute("NXREFERENCESET", Dtk_Val("MyRef1\\MyRef3\\"));
CHECK_OK(Ugw::InitFile(outputFileName, version));
// Then we write the 2 bodies constructed
// Write final file and release the writer.
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample23
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample24
Dtk_MetaDataPtr MakeMetaData(const Dtk_string& propname, const Dtk_string& value, const Dtk_string& category = "")
{
meta->SetCategory(category);
return meta;
}
Dtk_ErrorStatus UgwMeta(const Dtk_string& outputFileName, int version)
{
// lastparameter 0 indicate to set INCH. (default value = 1 = millimeters)
CHECK_OK(Ugw::InitFile(outputFileName, version, 0));
// custom metadata
CHECK_OK(Ugw::AddMetaData(MakeMetaData("MyPropTitle", "MyPropValue", "CategoryNX1980")));
CHECK_OK(Ugw::AddMetaData(MakeMetaData("MyPropTitle2", "MyPropValue2", "CategoryNX1980")));
// modeling preference
CHECK_OK(Ugw::AddMetaData(MakeMetaData("Distance Tolerance", "0.015", "Modeling Preferences")));
CHECK_OK(Ugw::AddMetaData(MakeMetaData("Angle Tolerance", "0.1", "Modeling Preferences")));
CHECK_OK(Ugw::AddMetaData(MakeMetaData("Density", "6500", "Modeling Preferences")));
// for Density Units, supported values are "lb/in3", "lb/ft3", "g/m3", "kg/m3"
CHECK_OK(Ugw::AddMetaData(MakeMetaData("Density Units", "lb/ft3", "Modeling Preferences")));
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample24
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample25
Dtk_ErrorStatus UgwColors(const Dtk_string& outputFileName, int version)
{
CHECK_OK(Ugw::InitFile(outputFileName, version));
for (int i = 0; i < 217; i++)
{
Dtk_string name = "Datakit_";
name.add_int(i);
Dtk_RGB rgb = Dtk_RGB(i + 30, 0, 0);
}
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample25
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample31
Dtk_InfoPtr MakeInstanceData(const Dtk_string& instancename, const Dtk_RGB& col, bool visible, int layer)
{
infos->SetName(instancename);
infos->SetColor(col);
if (!visible)
infos->SetBlankedStatus(1);
if (layer != -1)
infos->SetLayer(layer);
return infos;
}
Dtk_ErrorStatus UgwAsm(const Dtk_string& outputFileName, int version)
{
Dtk_BodyPtr CubeBody = sampleWriter::CreateCube(); // get a brepcube (common sample)
Dtk_MeshPtr CubeMesh = sampleWriter::CreateMeshCylinder(8); // get a meshcube (common sample)
Dtk_BodyPtr WireBody = sampleWriter::CreateCurves(); // get wire curve into a body.
CubeMesh->Transform(Dtk_transfo(Dtk_dir(30, 0, 0), Dtk_dir(0, 30, 0), Dtk_dir(0, 0, 30), Dtk_pnt())); // rescale mesh too small
Dtk_transfo cubetransfo; // identity
CHECK_OK(Ugw::InitFile(outputFileName, version)); // create root prt file
CHECK_OK(Ugw::OpenInstance("sub1", cubetransfo, MakeInstanceData("SubAssembly", Dtk_RGB(), true, -1))); // sub1 subassembly
CHECK_OK(Ugw::WriteBody(CubeBody)); // put a cube on the subassembly
cubetransfo.addTranslate(Dtk_dir(350, 0, 0)); // shift matrix.
CHECK_OK(Ugw::OpenInstance("leaf1", cubetransfo, MakeInstanceData("RedCube_SpecificLayer12", Dtk_RGB(255, 0, 0), true, 12)));
cubetransfo.addTranslate(Dtk_dir(150, 0, 0)); // shift matrix.
CHECK_OK(Ugw::OpenInstance("leaf2", cubetransfo, MakeInstanceData("GreenCube_Transparent", Dtk_RGB(0, 255, 0, 128), true, -1)));
// create a second instance of "leaf2.prt", reusing "leaf2.prt" automatic retrieve instance
cubetransfo.addTranslate(Dtk_dir(150, 0, 0)); // shift matrix.
CHECK_OK(Ugw::OpenInstance("leaf2", cubetransfo, MakeInstanceData("ReinstanciedBlueCube", Dtk_RGB(0, 0, 255), true, -1)));
CHECK_OK(Ugw::CloseLastInstance()); // for reinstance, close immediatly
cubetransfo.addTranslate(Dtk_dir(150, 0, 0)); // shift matrix again
CHECK_OK(Ugw::OpenInstance("leaf3", cubetransfo, MakeInstanceData("TealCube_Invisible", Dtk_RGB(0, 255, 255), false, -1)));
CHECK_OK(Ugw::CloseLastInstance()); // for reinstance, close immediatly
cubetransfo.addTranslate(Dtk_dir(150, 0, 0)); // shift matrix.
CHECK_OK(Ugw::OpenInstance("leaf4", cubetransfo, MakeInstanceData("MeshCyl", Dtk_RGB(), true, -1)));
cubetransfo.addTranslate(Dtk_dir(150, 0, 0)); // shift matrix.
CHECK_OK(Ugw::OpenInstance("leaf5", cubetransfo, MakeInstanceData("Wire", Dtk_RGB(), true, -1)));
CHECK_OK(Ugw::EndFile()); // close root prt file
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample31
// ----------------------------------------------------------------------------------------------
//start_of_ugwsample32
//#define USE_NX_READER
#ifdef USE_NX_READER
extern void nxreader_GetData(const Dtk_string&, void*&);
#define NX_RETRIEVE_ASSEMBLYDATA nxreader_GetData
#else
#define NX_RETRIEVE_ASSEMBLYDATA NULL
#endif
Dtk_ErrorStatus UgwExternAsm(const Dtk_string& outputFileName, int version)
{
// This example create an assembly from extern prt files
// First we initialize writing with name of output file (see macro CHECK_OK above)
CHECK_OK(Ugw::InitFile(outputFileName, version));
// We add extern twobodies (.prt) written by this sample previously
// The last parameter is a pointer on a function from datakit NXreader to retrieve subassembly datas : (instance names, colors, layer, visbility).
// This is optional, if NULL is given, the current file doesn't know these datas from subassemblies.
Dtk_transfo trans;
trans.addTranslate(Dtk_dir(0, 0, 200));
// We add extern asm (.prt) written by this sample previously
// We transmit function nxreader_GetData from NXReader, to retrieve cube colors set in subassembly sub1.prt
CHECK_OK(Ugw::AddExternInstance("asm", trans, MakeInstanceData("FirstInstance", Dtk_RGB(), true, 5), NX_RETRIEVE_ASSEMBLYDATA));
trans.addTranslate(Dtk_dir(0, 200, 0));
// We add a second time extern asm (.prt) written by this sample previously
CHECK_OK(Ugw::AddExternInstance("asm", trans, MakeInstanceData("SecondInstance", Dtk_RGB(), true, 15), NX_RETRIEVE_ASSEMBLYDATA));
// Write final file and release the writer.
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample32
// ----------------------------------------------------------------------------------------
//start_of_ugwsample41
{
// text informations
Dtk_TextStyle textstyle;
// All datas below match NX menu Note Settings/ lettering
textinfos->AddAttribute("NX_AlignmentPosition", 4); // optional (1=TL,2=TC,3=TR,4=ML(def),5=MC,6=MR,7=BL,8=BC,9=BR)
textstyle.Justification() = Dtk_TextStyle::JustificationLeft; // Text Justification
textinfos->SetCurveThickNessInMM(0.1); // optional, assume <0.5 = thin, >1.0 = thick else normal
textstyle.CharHeight() = 11; // mandatory height
textinfos->AddAttribute("NX_FontGapFactor", 0.0); // optional (def 0.0)
textstyle.Ratio() = 1.0; // optional Text Aspect Ratio
textinfos->AddAttribute("NX_LineGapFactor", 1.0);// optional (def 1.0)
textinfos->AddAttribute("NX_LetteringAngle", 0.0);// optional (def 0.0)
textinfos->AddAttribute("NX_HeightFactor", 2.0); // optional (def 2.0)
textinfos->SetColor(Dtk_RGB(255, 0, 0)); // optional, a red text
//textstyle.Font().Name() = "Arial"; // optional, defaut blockfont (strokefont).
// NX5 supports only "blockfont", "Arial" and "NX ANSI Symbols"
// NX1980, append font name in table
Dtk_pnt textorigin2D = Dtk_pnt(100, 20, 0); // all location are defined a 2D Coordinate system where Z = 0.
Dtk_Oriented2dBBox textbbox(textorigin2D, -1, -1); // -1 for width if unknown, height is given by textstyle.CharHeight()
Dtk_Text text("SampleText\nsub1\nsub2", textbbox, textbbox, DTK_PI / 2.0, 0, dtk_text_type_value, textinfos, textstyle);
Dtk_CompositeText compotext;
compotext.AddText(text);
symb->Texts() = compotext;
// arrow, see menu in NX : Note Settings / ArrowHead
Dtk_pnt arrowlocation = Dtk_pnt(50, 0, 0); // all location are defined a 2D Coordinate system where Z = 0.
double arrowlength = 5.5; // length of arrow througt line
Dtk_LeaderPtr leader = Dtk_Leader::Create(arrowlength, 0.0, arrowlocation, arrowtype, Dtk_tab<Dtk_pnt>());
// Note Settings / ArrowLine
leader->GetInfo()->SetColor(Dtk_RGB(0, 0, 255)); // optional, a blue leader
leader->GetInfo()->SetCurveThickNessInMM(0.7); // optional, assume <0.5 = thin, >1.0 = thick else normal
leader->GetInfo()->SetCurveLineType(DTK_PHANTOM); // optional, see enum enum Dtk_FontLineType
leader->GetInfo()->AddAttribute("NX_TextToLineGap", 10.0);// optional (def = 10.0)
leader->GetInfo()->AddAttribute("NX_TextOverStubFactor", 0.1);// optional (def = 0.1)
// Note Settings
leader->GetInfo()->AddAttribute("NX_StubLength", 20.0); // optional (def = 20.0)
leader->GetInfo()->AddAttribute("NX_StubSide", 1); // optional 1 for left (default), 0 for right
leader->GetInfo()->AddAttribute("NX_TextAlignment", 1); // optional 1 for top (default), 2 for middle, 3 for bottom
// Note Settings / ArrowHead
leader->GetArrowHead().GetInfo()->AddAttribute("NX_ArrowAngle", 30.0); // optional length given above (def = 30)
leader->GetArrowHead().GetInfo()->AddAttribute("NX_DotDiameter", 1.5); // optional (def = 1.5)
leader->GetArrowHead().GetInfo()->SetColor(Dtk_RGB(255, 0, 255)); // optional, a purple arrow
leader->GetArrowHead().GetInfo()->SetCurveThickNessInMM(2.0); // optional, assume <0.5 = thin, >1.0 = thick else normal
leader->GetArrowHead().GetInfo()->SetCurveLineType(DTK_SOLIDLINE); // optional, see enum enum Dtk_FontLineType
symb->AddLeader(leader);
// Final Placement :
Dtk_dir X(0, 0, 1);
Dtk_dir Y(-1, 0, 0);
Dtk_pnt O(0, 0, 0);
Dtk_transfo trans = Dtk_transfo(X, Y, X^Y, O);
pmi->info() = Dtk_Info::create();
pmi->info()->SetName("MyAnnot");
return pmi;
}
Dtk_ErrorStatus UgwAnnot(const Dtk_string& outputFileName, int version)
{
// Cube Sample
// First we initialize writing with name of output file (see macro CHECK_OK above)
CHECK_OK(Ugw::InitFile(outputFileName, version));
// Then we write the 2 bodies constructed
// Write final file and release the writer.
std::cout << "=> " << outputFileName.c_str() << endl;
return dtkNoError;
}
//end_of_ugwsample41
// -----------------------------------------------------------------
Dtk_ErrorStatus UgWriteSampleVersion(const Dtk_string &outputDirectory, int version)
{
Dtk_string outputFileName;
Dtk_ErrorStatus errStatus;
// sample 1.1 : one body
outputFileName = outputDirectory + L"simplebody.prt";
errStatus = UgwSimpleBody(outputFileName, version);
// sample 1.2 : just write 2 bodies
outputFileName = outputDirectory + L"twobodies.prt";
errStatus = UgwTwoBodies(outputFileName, version);
// sample 1.3 : mesh
outputFileName = outputDirectory + L"mesh.prt";
errStatus = UgwMesh(outputFileName, version);
// sample 1.4 : wire
outputFileName = outputDirectory + L"wire.prt";
errStatus = UgwWire(outputFileName, version);
// sample 1.5 : References
outputFileName = outputDirectory + L"refs.prt";
errStatus = UgwReferences(outputFileName, version);
// sample 1.6 : Extern Parasolid
outputFileName = outputDirectory + L"extparasolid.prt";
errStatus = UgwExternParasolid(outputFileName, outputDirectory + "../../../Parasolid/extparasolid.x_t", version);
// sample 1.7 : Extern JT
outputFileName = outputDirectory + L"extjt.prt";
errStatus = UgwExternJTMesh(outputFileName, outputDirectory + "../../../JT/externjt.jt", version);
// sample 2.1 : Layer filters
outputFileName = outputDirectory + L"layers.prt";
errStatus = UgwLayers(outputFileName, version);
// sample 2.2 : Groups
outputFileName = outputDirectory + L"groups.prt";
errStatus = UgwGroups(outputFileName, version);
// sample 2.3 : Reference Sets
outputFileName = outputDirectory + L"refsets.prt";
errStatus = UgwRefSets(outputFileName, version);
// sample 2.4 : MetaDatas, units, modeling preferences
outputFileName = outputDirectory + L"meta.prt";
errStatus = UgwMeta(outputFileName, version);
// sample 2.5 : Colors
outputFileName = outputDirectory + L"colors.prt";
errStatus = UgwColors(outputFileName, version);
// sample 3.1 : Simple Assembly
outputFileName = outputDirectory + L"asm.prt";
errStatus = UgwAsm(outputFileName, version);
// sample 3.2 : Extern Assembly
outputFileName = outputDirectory + L"externasm.prt";
errStatus = UgwExternAsm(outputFileName, version);
// sample 4.1 : Annotation
outputFileName = outputDirectory + L"annot.prt";
errStatus = UgwAnnot(outputFileName, version);
return errStatus;
}
// -----------------------------------------------------------------
//start_of_mainugwrite
int UgWriteSample(const Dtk_string &inResultDirectory)
{
Dtk_string outputDirectory, nxDirectory;
Dtk_ErrorStatus errStatus;
std::cout << endl << "----------------------------------------------" << endl;
std::cout << "Ug Write start" << endl;
nxDirectory = inResultDirectory + L"dtk/NX-Unigraphics/";
nxDirectory.FixPathSeparator();
nxDirectory.mkdir();
// Choosing output for version NX5
outputDirectory = inResultDirectory + L"dtk/NX-Unigraphics/nx5/";
outputDirectory.FixPathSeparator();
outputDirectory.mkdir();
errStatus = UgWriteSampleVersion(outputDirectory, DTK_UGW_VERSION_NX5);
// Choosing output for version NX1980
outputDirectory = inResultDirectory + L"dtk/NX-Unigraphics/nx1980/";
outputDirectory.FixPathSeparator();
outputDirectory.mkdir();
errStatus = UgWriteSampleVersion(outputDirectory, DTK_UGW_VERSION_NX1980);
// Choosing output for version NX2212
outputDirectory = inResultDirectory + L"dtk/NX-Unigraphics/nx2212/";
outputDirectory.FixPathSeparator();
outputDirectory.mkdir();
errStatus = UgWriteSampleVersion(outputDirectory, DTK_UGW_VERSION_NX2212);
std::cout << "Ug Write end" << endl;
return errStatus;
}
//end_of_mainugwrite_dtk
UgwGroups
Dtk_ErrorStatus UgwGroups(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:332
Dtk_TextStyle::Ratio
Dtk_Double64 & Ratio()
Retrieves the text ratio - get/set -.
MakeInstanceData
Dtk_InfoPtr MakeInstanceData(const Dtk_string &instancename, const Dtk_RGB &col, bool visible, int layer)
Definition: testlibugwrite.cpp:483
UgwRefSets
Dtk_ErrorStatus UgwRefSets(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:391
Dtk_InfoPtr
Dtk_SmartPtr< Dtk_Info > Dtk_InfoPtr
Handles a Dtk_Info object.
Definition: util_ptr_dtk.hpp:310
UgwExternParasolid
Dtk_ErrorStatus UgwExternParasolid(const Dtk_string &outputFileName, const Dtk_string &parasolidfic, int version)
Definition: testlibugwrite.cpp:205
UgwExternAsm
Dtk_ErrorStatus UgwExternAsm(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:560
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
Ugw::WriteAxisSystem
Dtk_ErrorStatus WriteAxisSystem(const Dtk_AxisSystemPtr &inAxisSystem)
Add an axis system into the current node.
MakeRefAxis
Dtk_BodyPtr MakeRefAxis()
Definition: testlibugwrite.cpp:148
UgwColors
Dtk_ErrorStatus UgwColors(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:458
Dtk_TextStyle::Justification
TextJustificationEnum & Justification()
Retrieves the text justification - get/set -.
Dtk_Info::AddAttribute
Dtk_ErrorStatus AddAttribute(Dtk_string name, Dtk_Val val)
Dtk_TextStyle::JustificationLeft
@ JustificationLeft
Definition: util_draw_dtk.hpp:299
Dtk_PlaneSurface::Create
static Dtk_PlaneSurfacePtr Create(const Dtk_pnt &inOrigin, const Dtk_dir &inNormal, const Dtk_dir &inUDirection, const Dtk_dir &inVDirection=Dtk_dir())
Create an infinite plane surface.
Dtk_Info::SetName
Dtk_ErrorStatus SetName(Dtk_string inName)
UgwLayers
Dtk_ErrorStatus UgwLayers(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:301
Ugw::SetColorInTable
Dtk_ErrorStatus SetColorInTable(size_t inIth, const Dtk_RGB &inColor, const Dtk_string &inColorname)
Replace color value and color name on the palette.
Dtk_TextStyle
This is the text_style. This class gathers several informations about text style.
Definition: util_draw_dtk.hpp:260
dtkErrorFileNotExist
@ dtkErrorFileNotExist
Definition: error_dtk.hpp:95
MakeRefPlane
Dtk_BodyPtr MakeRefPlane()
Definition: testlibugwrite.cpp:114
UgwMeta
Dtk_ErrorStatus UgwMeta(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:430
Ugw::AddExternInstance
Dtk_ErrorStatus AddExternInstance(const Dtk_string &inProtoFileName, const Dtk_transfo &inTrans, Dtk_InfoPtr inInfos, void(*innxread_getdata)(const Dtk_string &, void *&))
Open an extern file to add as instance in current assembly, inProtoFileName must be in the output dir...
UgWriteSample
int UgWriteSample(const Dtk_string &inResultDirectory)
Definition: testlibugwrite.cpp:756
DTK_TRUE
#define DTK_TRUE
Definition: define.h:727
DTK_UGW_VERSION_NX5
#define DTK_UGW_VERSION_NX5
Definition: ugw.hpp:7
dtk_text_type_value
@ dtk_text_type_value
Definition: str_def.h:14
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
Ugw::WriteReferenceGeometry
Dtk_ErrorStatus WriteReferenceGeometry(const Dtk_BodyPtr &inRefgeom)
Add a reference geometry into the current node.
UgwAnnot
Dtk_ErrorStatus UgwAnnot(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:660
Ugw::WriteExternJtMesh
Dtk_ErrorStatus WriteExternJtMesh(const char *inFlux, size_t inSize, const Dtk_InfoPtr &inInf)
Add a JT file as lightweight body inside the file.
Dtk_Text
This is the base text class. It's part of Dtk_CompositeText. It's used into a lot of 2D Entities It c...
Definition: util_draw_dtk.hpp:1126
Dtk_AxisSystem::create
static Dtk_SmartPtr< Dtk_AxisSystem > create()
Dtk_Body::Create
static Dtk_BodyPtr Create()
Create a body.
Ugw::WriteBody
Dtk_ErrorStatus WriteBody(const Dtk_BodyPtr &inBody)
Add a body inside the file.
Dtk_string::OpenFile
FILE * OpenFile(const Dtk_string &inRights) const
File Utility : Open a file with the given rights.
MakeFixedRefPlane
Dtk_BodyPtr MakeFixedRefPlane()
Definition: testlibugwrite.cpp:130
UgwSimpleBody
Dtk_ErrorStatus UgwSimpleBody(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:17
DTK_SOLIDLINE
@ DTK_SOLIDLINE
Definition: util_ent_dtk.hpp:46
Dtk_Symbol::Create
static Dtk_SymbolPtr Create()
Base constructor.
Ugw::SetLayerData
Dtk_ErrorStatus SetLayerData(const Dtk_LayerInfosSetPtr &inLayerDataSet, const Dtk_tab< Dtk_Int32 > &inVisibles=Dtk_tab< Dtk_Int32 >(), const Dtk_tab< Dtk_Int32 > &inSelectables=Dtk_tab< Dtk_Int32 >())
define Data for layers
Dtk_Info::SetBlankedStatus
Dtk_ErrorStatus SetBlankedStatus(const Dtk_Int32 &inBlankedStatus)
Dtk_string::add_int
void add_int(const int integer, int force_unsigned_int=0)
concat an int to the Dtk_string (convert the int to Dtk_string)
Dtk_Val
Definition: dtk_val.hpp:67
UgwMesh
Dtk_ErrorStatus UgwMesh(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:71
Dtk_Face::Create
static Dtk_FacePtr Create(const Dtk_BodyPtr &inParentBody)
Create a face in a body.
UGW_Sample_MakePMI
Dtk_FdtPtr UGW_Sample_MakePMI()
Definition: testlibugwrite.cpp:594
MakeAxisSystem
Dtk_AxisSystemPtr MakeAxisSystem()
Definition: testlibugwrite.cpp:102
Ugw::InitFile
Dtk_ErrorStatus InitFile(const Dtk_string &inFilename, int inVersiontowrite=45, int inUnitasmm=1, int inMultithread=0)
Initialize UG Writer.
Dtk_Line::Create
static Dtk_LinePtr Create(const Dtk_Line &inLineToCopy)
constructors returning Smart pointers
Dtk_tab::resize
void resize(Dtk_Size_t n, const T &t)
Resizes the array.
Definition: util_stl_dtk.hpp:603
Ugw::WritePMI
Dtk_ErrorStatus WritePMI(const Dtk_FdtPtr &inPmi)
Add a pmi inside the file.
Ugw::WriteExternParasolidBody
Dtk_ErrorStatus WriteExternParasolidBody(const char *inFlux, size_t inSize, const Dtk_InfoPtr &inInf)
Add a Parasolid file as body inside the file.
Dtk_MetaData::TypeProperty
@ TypeProperty
Definition: dtk_metadata.hpp:28
Ugw::CloseLastInstance
Dtk_ErrorStatus CloseLastInstance()
Close the last instance.
DTK_PHANTOM
@ DTK_PHANTOM
Definition: util_ent_dtk.hpp:50
Ugw::SetGroupDatas
Dtk_ErrorStatus SetGroupDatas(const Dtk_string &inGroupName, Dtk_InfoPtr inInfos)
define Visibility for a specific group
Dtk_SmartPtr::DtkDynamicCast
static Dtk_SmartPtr< T > DtkDynamicCast(const Dtk_SmartPtr< T2 > &p)
Definition: util_ptr_dtk.hpp:101
Dtk_Info::SetCurveThickNessInMM
Dtk_ErrorStatus SetCurveThickNessInMM(const Dtk_Double64 inCurveThickNessInMM)
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
Dtk_Fdt::Create
static Dtk_FdtPtr Create()
Base constructor.
CHECK_OK
#define CHECK_OK(X)
Definition: testwriters.h:9
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
sampleWriter::CreateMeshCylinder
Dtk_MeshPtr CreateMeshCylinder(int nbpoints)
Mesh Cylinder sample.
Definition: testcreatemesh.cpp:337
UgwTwoBodies
Dtk_ErrorStatus UgwTwoBodies(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:39
Dtk_string::mkdir
int mkdir() const
File Utility : Create a Directory.
Dtk_Info::SetLayer
Dtk_ErrorStatus SetLayer(const Dtk_Int32 &inLayer)
Dtk_pnt
This is a mathematical point class.
Definition: dtk_pnt.hpp:22
UgWriteSampleVersion
Dtk_ErrorStatus UgWriteSampleVersion(const Dtk_string &outputDirectory, int version)
Definition: testlibugwrite.cpp:684
UgwAsm
Dtk_ErrorStatus UgwAsm(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:495
Dtk_string::FixPathSeparator
void FixPathSeparator()
File Utility : Fixes path separator consistency. It lets you replace the '\' or '/' by the OS needed ...
Dtk_CompositeText
This is the composite text class. It's basically a Dtk_Text Container. This class represents a group ...
Definition: util_draw_dtk.hpp:1557
datakit.h
Dtk_Leader::Create
static Dtk_LeaderPtr Create()
Base constructor.
MakeMetaData
Dtk_MetaDataPtr MakeMetaData(const Dtk_string &propname, const Dtk_string &value, const Dtk_string &category="")
Definition: testlibugwrite.cpp:423
testcreatemesh.hpp
testcreatecube.hpp
Dtk_TextStyle::CharHeight
Dtk_Double64 & CharHeight()
Retrieves the char height - get/set -.
NX_RETRIEVE_ASSEMBLYDATA
#define NX_RETRIEVE_ASSEMBLYDATA
Definition: testlibugwrite.cpp:556
Dtk_tab
This is a high level array class.
Definition: util_stl_dtk.hpp:85
CreateLayerInfosSet
Dtk_LayerInfosSetPtr CreateLayerInfosSet(Dtk_tab< Dtk_Int32 > &visible, Dtk_tab< Dtk_Int32 > &selectable)
Definition: testlibugwrite.cpp:272
Ugw::WriteMesh
Dtk_ErrorStatus WriteMesh(const Dtk_MeshPtr &inMesh)
Add a mesh inside the file.
Dtk_transfo::addTranslate
void addTranslate(const Dtk_dir &V)
Translate the Dtk_transfo.
sampleWriter::CreateCube
Dtk_BodyPtr CreateCube()
Definition: testcreatecube.cpp:1249
Dtk_tab::size
Dtk_Size_t size() const
Returns the size of the array.
Definition: util_stl_dtk.hpp:502
Ugw::AddMetaData
Dtk_ErrorStatus AddMetaData(const Dtk_MetaDataPtr &inMeta)
Add a MetaData in the current component.
DTK_UGW_VERSION_NX1980
#define DTK_UGW_VERSION_NX1980
Definition: ugw.hpp:8
ugw.hpp
UgwWire
Dtk_ErrorStatus UgwWire(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:86
UgwReferences
Dtk_ErrorStatus UgwReferences(const Dtk_string &outputFileName, int version)
Definition: testlibugwrite.cpp:179
Ugw::OpenInstance
Dtk_ErrorStatus OpenInstance(const Dtk_string &inInstanceName, const Dtk_string &inProtoFileName, Dtk_bool &outWasAlreadyInstancied, const Dtk_transfo &inTrans, const Dtk_RGB &inRgb)
deprecated
DTK_RB
#define DTK_RB
Definition: dtk_string.hpp:40
UgwExternJTMesh
Dtk_ErrorStatus UgwExternJTMesh(const Dtk_string &outputFileName, const Dtk_string &jtfic, int version)
Definition: testlibugwrite.cpp:238
Dtk_Leader::LeaderTerminatorTypeEnum
LeaderTerminatorTypeEnum
Internal leader terminator type.
Definition: util_draw_dtk.hpp:1999
sampleWriter::CreateCurves
Dtk_BodyPtr CreateCurves()
Definition: testcreatecube.cpp:1292
Dtk_LayerInfosSet::Create
static Dtk_LayerInfosSetPtr Create(const Dtk_Size_t inNumLayers)
Base constructor.
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_Shell::Create
static Dtk_ShellPtr Create(const Dtk_BodyPtr &inParentBody)
Create a shell in a body.
MakeRefPoint
Dtk_BodyPtr MakeRefPoint()
Definition: testlibugwrite.cpp:164
testwriters.h
Dtk_Point::Create
static Dtk_PointPtr Create(const Dtk_Point &inToCopy)
constructors returning Smart pointers
Dtk_CompositeText::AddText
void AddText(Dtk_Text inText)
Adds a Dtk_Text to the Dtk_CompositeText.
Dtk_RGB
Definition: dtk_rgb.hpp:7
Dtk_Info::SetColor
Dtk_ErrorStatus SetColor(const int &R, const int &G, const int &B)
Dtk_Info::create
static Dtk_SmartPtr< Dtk_Info > create()
Dtk_Oriented2dBBox
This is the base bounding box class. It's used into a lot of 2D Entities This class represents the ba...
Definition: util_draw_dtk.hpp:479
Dtk_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:15
DTK_UGW_VERSION_NX2212
#define DTK_UGW_VERSION_NX2212
Definition: ugw.hpp:9
Dtk_Leader::TerminatorTypeFillArrow
@ TerminatorTypeFillArrow
Definition: util_draw_dtk.hpp:2007
Ugw::EndFile
Dtk_ErrorStatus EndFile()
Close the UG file.
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_PI
#define DTK_PI
Definition: str_def.h:8