DATAKIT API  V2025.1
PDF 3D Write Sample
//start_of_mainpdfwrite
// ------------------------------------ PdfwSampleOneMesh_1_1 ---------------------------------------------
{
Dtk_ID meshID;
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_MeshPtr CubeMesh = sampleWriter::CreateMeshCube(); // create a simple red cube
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( CubeMesh ), meshID ) ); // write the cube
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// ---------------------------------- PdfwSampleMeshes_1_2 -----------------------------------------------
template <typename T>
inline void Shift( T& mesh, double sh )
{
t.addTranslate( Dtk_dir( sh, 0, 0 ) );
mesh->Transform( t );
}
{
Dtk_ID meshID;
options.PointSize = 5.; // setting point size
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_MeshPtr CubeMesh = sampleWriter::CreateMeshCube(); // create a simple red cube
CubeMesh->info()->SetName( "ColoredCube" );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( CubeMesh ), meshID ) ); // write the cube
Dtk_MeshPtr CubePervertexColorMesh = sampleWriter::CreateMeshCubeVertexColor(); // create a per vertex color cube
Shift( CubePervertexColorMesh, 3 ); // translate it not to be on previous geometry
CubePervertexColorMesh->info() = Dtk_Info::create();
CubePervertexColorMesh->info()->SetName( "VertexColoredCube" );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( CubePervertexColorMesh ), meshID ) ); // write the cube
Dtk_MeshPtr TransparentCube = sampleWriter::CreateMeshCube(); // create a simple red cube
TransparentCube->info()->SetColor( Dtk_RGB( 0, 255, 0, 128 ) ); // set whole cube as green and transparent
TransparentCube->info()->SetName( "TransparentCube" );
Shift( TransparentCube, 6 ); // translate it not to be on previous geometry
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( TransparentCube ), meshID ) ); // write the cube
Dtk_MeshPtr TransparentOneFaceCube = sampleWriter::CreateMeshCube(); // create a simple red cube
if( TransparentOneFaceCube->get_nb_mesh_face() == 6 )
{
if( TransparentOneFaceCube->get_mesh_face( 3 )->info().IsNULL() )
TransparentOneFaceCube->get_mesh_face( 3 )->info() = Dtk_Info::create();
TransparentOneFaceCube->get_mesh_face( 3 )->info()->SetColor( Dtk_RGB( 0, 0, 255, 128 ) ); // set face 3 as blue and transparent
}
Shift( TransparentOneFaceCube, 9 ); // translate it not to be on previous geometry
TransparentCube->info()->SetName( "TransparentCubeColoredFace" );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( TransparentOneFaceCube ), meshID ) ); // write the cube
Dtk_MeshPtr MeshWire = sampleWriter::CreateMeshWire(); // create wire mesh
Shift( MeshWire, 12 ); // translate it not to be on previous geometry
MeshWire->info() = Dtk_Info::create();
MeshWire->info()->SetName( "WireMesh" );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( MeshWire ), meshID ) ); // write the cube
Dtk_MeshPtr MeshPoints = sampleWriter::CreateMeshPoints(); // create a mesh wich contain only orange points.
Shift( MeshPoints, 15 ); // translate it not to be on previous geometry
MeshPoints->info()->SetName( "PointMesh" );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( MeshPoints ), meshID ) ); // write the cube
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// ------------------------------------ PdfwSampleOneMeshRender_1_3 ---------------------------------------------
Dtk_ErrorStatus PdfwSampleOneMeshRender_1_3( const Dtk_string& inOutputFileName, const Dtk_string& inImageDirectory )
{
Dtk_ID meshID;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_MeshPtr meshCube = sampleWriter::CreateTexturedMeshCube( inImageDirectory ); // create a simple textured cube
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( meshCube ), meshID ) ); // write the cube
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// ---------------------------------- PdfwSampleBody_2_1 -----------------------------------------------
Dtk_ErrorStatus PdfwSampleBody_2_1( const Dtk_string& inOutputFileName )
{
Dtk_ID bodyID;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_BodyPtr cylinder = sampleWriter::CreateCyl( 1, 2 ); // Create a Cylinder radius=1, height=2 (with a green face)
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cylinder ), bodyID ) ); // write the body
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// ---------------------------------- PdfwSampleWireBody_2_2 -----------------------------------------------
{
Dtk_ID bodyID;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( wire ), bodyID ) ); // write the body
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( wire2 ), bodyID ) ); // write the body
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// ---------------------------------- PdfwSampleBodyVisibility_2_3 -----------------------------------------------
{
Dtk_ID bodyID;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
cylinder->info()->SetName( "Cylinder.1" );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cylinder ), bodyID ) ); // write the 1st body
Dtk_BodyPtr cylinder2 = sampleWriter::CreateCyl( 1, 2 );
Shift( cylinder2, 3 );
cylinder2->info()->SetName( "Cylinder.2" );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cylinder2 ), bodyID ) ); // write the 2nd body
Dtk_BodyPtr cylinder3 = sampleWriter::CreateCyl( 1, 2 );
Shift( cylinder3, 6 );
cylinder3->info()->SetBlankedStatus( DTK_TRUE );
cylinder3->info()->SetName( "Cylinder.3" );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cylinder3 ), bodyID ) ); // write the 3rd body
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// ------------------------------------ PdfwSampleAssembly_3_1 ---------------------------------------------
{
Dtk_ID axleNodeID, axleID, wheelsNodeID, wheelNodeID, wheel2NodeID, wheel1ID, wheel2ID;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_string nodeName = "Axle";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, axleNodeID ) ); // open Axle node
axle->info()->SetName( "axle" );
CHECK_OK( Pdfw::WriteBodyAndMesh( axle, Dtk_MeshPtr(), axleID ) ); // write the body
CHECK_OK( Pdfw::EndNode() ); // close Axle
nodeName = "Wheels";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, wheelsNodeID ) ); // open Wheels node
nodeName = "Wheel";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, wheelNodeID ) ); // open Wheel node
Shift( wheel, 2 );
CHECK_OK( Pdfw::WriteBodyAndMesh( wheel, Dtk_MeshPtr(), wheel1ID ) ); // write the body
CHECK_OK( Pdfw::EndNode() ); // close Wheel
nodeName = "Wheel2";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, wheel2NodeID ) ); // open Wheel2 node
Shift( wheel, 3 );
CHECK_OK( Pdfw::WriteBodyAndMesh( wheel, Dtk_MeshPtr(), wheel2ID ) ); // write the body
CHECK_OK( Pdfw::EndNode() ); // close Wheel2
CHECK_OK( Pdfw::EndNode() ); // close Wheels
CHECK_OK( Pdfw::EndWrite() );// Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// -------------------------------- PdfwSamplePartInstances_3_2 -------------------------------------------------
{
Dtk_dir X( 1, 0, 0 );
Dtk_dir Y( 0, 1, 0 );
Dtk_dir Z( 0, 0, 1 );
Dtk_ID axleNodeID, axleID, wheelsID, wheelNodeID, wheelID;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_string nodeName = "Axle";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, axleNodeID ) ); // open Axle Node
axle->info()->SetName( "axle" );
CHECK_OK( Pdfw::EndNode() ); // close Axle
nodeName = "Wheels";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, wheelsID ) ); // open Wheels Node
nodeName = "Wheel1";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo( X, Y, Z, Dtk_pnt( 0, 0, 5 ) ), info, wheelNodeID ) ); // open Wheel1 Node
Pdfw::StorePrototype( wheelNodeID ); // Store Wheel node ID for future re-instanciation
wheel->info()->SetName( "wheel" );
CHECK_OK( Pdfw::WriteBodyAndMesh( wheel, Dtk_MeshPtr(), wheelID ) ); // write the body
CHECK_OK( Pdfw::EndNode() ); // close Wheel1
nodeName = "Wheel2";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo( X, -Y, -Z, Dtk_pnt() ) ) ); // open Wheel2 node
Pdfw::ReinstanciatePrototype( wheelNodeID ); // Re-instanciating Wheel node
CHECK_OK( Pdfw::EndNode() ); // close Wheel2
CHECK_OK( Pdfw::EndNode() ); // close Wheels
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// -------------------------------- PdfwSampleAsmInstances_3_3 -------------------------------------------------
{
Dtk_dir X( 1, 0, 0 );
Dtk_dir Y( 0, 1, 0 );
Dtk_dir Z( 0, 0, 1 );
Dtk_ID axlesNodeID, axlesNodeID2, axleNodeID, axleID, wheelsNodeID, wheelNodeID, wheelID;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_string nodeName = "Axles";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, axlesNodeID ) ); // open Axles Node, placement by default : identity matrix
Pdfw::StorePrototype( axlesNodeID ); // Store Axles node ID for future re-instanciation
nodeName = "Axle";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, axleNodeID ) ); // open Axle node
axle->info()->SetName( "axle" );
CHECK_OK( Pdfw::EndNode() ); // close Axle
nodeName = "Wheels";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, wheelsNodeID ) ); // open Wheels node
nodeName = "Wheel1";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo( X, Y, Z, Dtk_pnt( 0, 0, 5 ) ), info, wheelNodeID ) ); // open Wheel1 node
Pdfw::StorePrototype( wheelNodeID ); // Store Wheel node ID for future re-instanciation
wheel->info()->SetName( "wheel" );
CHECK_OK( Pdfw::WriteBodyAndMesh( wheel, Dtk_MeshPtr(), wheelID ) ); // write the body
CHECK_OK( Pdfw::EndNode() ); // close Wheel
nodeName = "Wheel2";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo( X, -Y, -Z, Dtk_pnt() ), info, wheelsNodeID ) ); // open Wheel2 node
Pdfw::ReinstanciatePrototype( wheelNodeID ); // Re-instanciating Wheel node
CHECK_OK( Pdfw::EndNode() ); // close Wheel2
CHECK_OK( Pdfw::EndNode() ); // close Wheels
CHECK_OK( Pdfw::EndNode() ); // close Axles
nodeName = "Axles2";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo( X, Y, Z, Dtk_pnt( 10, 0, 0 ) ), info, axlesNodeID2 ) ); // Open Axles2 node
Pdfw::ReinstanciatePrototype( axlesNodeID ); // Re-instanciating Axle node
CHECK_OK( Pdfw::EndNode() ); // close Axles2
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// -------------------------------- PdfwSampleInstancesColors_3_4 -------------------------------------------------
{
Dtk_dir X( 1, 0, 0 );
Dtk_dir Y( 0, 1, 0 );
Dtk_dir Z( 0, 0, 1 );
Dtk_ID axlesNodeID, axlesNodeID2, axlesNodeID3, axlesNodeID4, axlesNodeID5, axleNodeID, axleID, wheelsNodeID, wheelNodeID, wheelID;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_string nodeName = "Axles";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, axlesNodeID ) ); // open Axles node, placement by default : identity matrix
Pdfw::StorePrototype( axlesNodeID ); // Store Axles node ID for future re-instanciation
nodeName = "Axle";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, axleNodeID ) ); // open Axle node
axle->info()->SetName( "axle" );
CHECK_OK( Pdfw::WriteBodyAndMesh( axle, Dtk_MeshPtr(), axleID ) ); // write the body
CHECK_OK( Pdfw::EndNode() ); // close Axle
nodeName = "Wheels";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, wheelsNodeID ) ); // open Wheels node
nodeName = "Wheel1";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo( X, Y, Z, Dtk_pnt( 0, 0, 5 ) ), info, wheelNodeID ) ); // open wheel1 node
Pdfw::StorePrototype( wheelNodeID ); // Store Wheel node ID for future re-instanciation
wheel->info()->SetName( "wheel" );
CHECK_OK( Pdfw::WriteBodyAndMesh( wheel, Dtk_MeshPtr(), wheelID ) ); // write the body
CHECK_OK( Pdfw::EndNode() ); // close Wheel1
nodeName = "Wheel2";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo( X, -Y, -Z, Dtk_pnt() ), info, wheelsNodeID ) ); // open wheel2 node
Pdfw::ReinstanciatePrototype( wheelNodeID ); // Re-instanciating Wheel node
CHECK_OK( Pdfw::EndNode() ); // close wheel2
CHECK_OK( Pdfw::EndNode() ); // close Wheels
CHECK_OK( Pdfw::EndNode() ); // close Axles
nodeName = "Axles2";
axle2Info->SetColor( Dtk_RGB( 255, 0, 0, 128 ) );// Give a RED color with transparency
Dtk_transfo( X, Y, Z, Dtk_pnt( 5, 0, 0 ) ),
axle2Info,
Pdfw::keepsubcolor, // Keep mesh existing colors
axlesNodeID2 ) ); // reinstance whole subassembly with matrix
Pdfw::ReinstanciatePrototype( axlesNodeID ); // Re-instanciating Axles node
CHECK_OK( Pdfw::EndNode() ); // close Axles2
nodeName = "Axles3";
axle3Info->SetColor( Dtk_RGB( 0, 0, 255, 255 ) );// Give a BLUE opaque color
Dtk_transfo( X, Y, Z, Dtk_pnt( 10, 0, 0 ) ),
axle3Info,
Pdfw::attributeoverwrite, // Overwrites existing colors/transparency
axlesNodeID3 ) );
CHECK_OK( Pdfw::EndNode() ); // close Axles3
nodeName = "Axles4";
axle4Info->SetColor( Dtk_RGB( 255, 255, 0, 128 ) );// Give a YELLOW color with transparency
Dtk_transfo( X, Y, Z, Dtk_pnt( 15, 0, 0 ) ),
axle4Info,
Pdfw::keepsubcolor | Pdfw::keepsubtransparency, // Keep mesh existing color / transparency
axlesNodeID4 ) );
CHECK_OK( Pdfw::EndNode() ); // close Axles4*
nodeName = "Axles5";
axle5Info->SetColor( Dtk_RGB( 0, 255, 255 ) );// Give a BLUE GREEN color
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo( X, Y, Z, Dtk_pnt( 20, 0, 0 ) ), axle5Info, axlesNodeID5 ) );
CHECK_OK( Pdfw::EndNode() ); // close Axles5
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// -------------------------------- PdfwSampleInstancesVisibility_3_5 -------------------------------------------------
{
Dtk_dir X( 1, 0, 0 );
Dtk_dir Y( 0, 1, 0 );
Dtk_dir Z( 0, 0, 1 );
Dtk_ID axleNodeID, axleID, wheelsNodeID, wheelNodeID, wheelID;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_string nodeName = "Axle";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, axleNodeID ) ); // open Axle node
axle->info()->SetName( "axle" );
CHECK_OK( Pdfw::WriteBodyAndMesh( axle, Dtk_MeshPtr(), axleID ) ); // write the body
CHECK_OK( Pdfw::EndNode() ); // close Axle
nodeName = "Wheels";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo(), info, wheelsNodeID ) ); // open Wheels node
nodeName = "Wheel1";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo( X, Y, Z, Dtk_pnt( 0, 0, 5 ) ), info, wheelNodeID ) ); // open Wheel1 node
Pdfw::StorePrototype( wheelNodeID ); // Store Wheel node ID for future re-instanciation
wheel->info()->SetName( "wheel" );
CHECK_OK( Pdfw::WriteBodyAndMesh( wheel, Dtk_MeshPtr(), wheelID ) ); // write the body
CHECK_OK( Pdfw::EndNode() ); // close Wheel1
wheelInfo->SetBlankedStatus( 1 );
nodeName = "Wheel2";
CHECK_OK( Pdfw::InitNode( nodeName, Dtk_transfo( X, -Y, -Z, Dtk_pnt() ), wheelInfo, wheelsNodeID ) ); // open invisible Wheel2
Pdfw::ReinstanciatePrototype( wheelNodeID ); // Re-instanciating Wheel node
CHECK_OK( Pdfw::EndNode() ); // close Wheel2
CHECK_OK( Pdfw::EndNode() ); // close Wheels
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// ------------------------------- PdfwSampleMetadatas_4_1 --------------------------------------------------
{
Dtk_ID axleID;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_string nodeName = "Metadata";
CHECK_OK( Pdfw::InitNode( nodeName ) ); // Metadata creation
tabMetadata.push_back( Dtk_MetaData::CreateMetaData( Dtk_MetaData::TypeProperty, "MyTitle", "MyValue" ) );
CHECK_OK( Pdfw::AddNodeMetadata( tabMetadata ) ); // Adding metadata to node
axle->info()->SetName( "axle" );
CHECK_OK( Pdfw::WriteBodyAndMesh( axle, Dtk_MeshPtr(), axleID ) ); // write the body
CHECK_OK( Pdfw::EndNode() ); // close Metadata
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// ------------------------------- PdfwSampleDocumentProperties_4_2 --------------------------------------------------
{
Dtk_string application, pdfProducer, title, author, subject, keywords;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
// We fill Pdfw::PdfDocumentProperties with information we want
title = inOutputFileName.filename();
docProperties.SetTitle( title ); // title
author = "user";
docProperties.SetAuthor( author ); // author
subject = "Datakit PDF SDK demo";
docProperties.SetSubject( subject ); // subject
keywords = "Datakit;SDK;Demo";
docProperties.SetKeywords( keywords ); // keywords
application = "LibPdfWriteSample";
docProperties.SetApplication( application ); // application
pdfProducer = "DATAKIT API Version " + Dtk_API::GetAPI()->GetVersion();
docProperties.SetPDFProducer( pdfProducer ); // producer
metadatas.push_back( Dtk_MetaData::CreateMetaData( Dtk_MetaData::TypeFileProperty, "PartName", "SampleDocumentProperties_4_2" ) ); // custom metadata
CHECK_OK( Pdfw::AddDocumentProperties( docProperties, metadatas ) ); // We add properties to the document
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// --------------------------------PdfwSampleSimplePMI_5_1------------------------------------------------ -
{
Dtk_ID axleID;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_BodyPtr cylinder = sampleWriter::CreateCyl( 100, 150 ); // Create a Cylinder radius=1, height=2 (with a green face)
cylinder->info()->SetName( "Body" );
CHECK_OK( Pdfw::WriteBodyAndMesh( cylinder, Dtk_MeshPtr(), axleID ) ); // Add the body
Dtk_FdtPtr pmi = sampleWriter::CreateFdtDatum(); // Create an FDT (PMI)
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// -------------------------------- PdfwSampleSimpleModelview_5_2 -------------------------------------------------
{
options.CreateDefaultView = DTK_FALSE; // no default view needed
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_BodyPtr cylinder = sampleWriter::CreateCyl( 100, 150 ); // Create a Cylinder radius=100, height=150 (with a green face)
cylinder->info()->SetName( "Body" );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cylinder ) ) ); // Add the body
Dtk_FdtPtr pmi = sampleWriter::CreateFdtDatum(); // Create an FDT (PMI)
Dtk_ModelDisplayPtr mvfit, mv2;
Dtk_tab<Dtk_ID> tabNodeIDs;
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// -------------------------------- PdfwSample_MV_association_5_3 -------------------------------------------------
{
Dtk_ID cylID, datumID;
options.CreateDefaultView = DTK_FALSE; // no default view needed
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_BodyPtr cylinder = sampleWriter::CreateCyl( 100, 150 ); // Create a Cylinder radius=100, height=150 (with a green face)
cylinder->info()->SetName( "Body" );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cylinder ), cylID ) ); // Add the body
Dtk_FdtPtr pmi = sampleWriter::CreateFdtDatum(); // Create an FDT (PMI)
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( pmi ), datumID ) ); // Add the PMI
Dtk_tab<Dtk_ID> tabNodeIDs;
tabNodeIDs.push_back( cylID );
CHECK_OK( Pdfw::CreateModelDisplayWithVisibleNodes( mv, tabNodeIDs ) ); // create the model display with visible nodes
Dtk_ModelDisplayPtr mv2 = Dtk_ModelDisplay::Create( mv->GetCamera(), NULL, 0 );// create desactivated model display
mv2->info() = Dtk_Info::create();
mv2->info()->SetName( "PMIView" );
tabNodeIDs.clear();
tabNodeIDs.push_back( cylID );
tabNodeIDs.push_back( datumID );
CHECK_OK( Pdfw::CreateModelDisplayWithVisibleNodes( mv2, tabNodeIDs ) ); // create the model display with visible nodes
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// -------------------------------- PdfwSamplePMI_Geom_association_5_4 -------------------------------------------------
{
Dtk_ID bodyID, datumID;
options.CreateDefaultView = DTK_FALSE; // no default view needed
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_BodyPtr cylinder = sampleWriter::CreateCyl( 100, 150 ); // Create a Cylinder radius=100, height=150 (with a green face)
cylinder->info()->SetName( "Body" );
CHECK_OK( Pdfw::WriteBodyAndMesh( cylinder, Dtk_MeshPtr(), bodyID ) ); // Add the body
Dtk_FdtPtr pmi = sampleWriter::CreateFdtDatum(); // Create an FDT (PMI)
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( pmi ), datumID ) ); // Add the PMI
CHECK_OK( Pdfw::CreateNodeConnectorHighlight( datumID, bodyID, 1 ) ); // Connect datum PMI on body, on face index 1
mv->info()->SetName( "myView" );
Dtk_tab<Dtk_ID>tabNodeIDs;
tabNodeIDs.push_back( bodyID );
tabNodeIDs.push_back( datumID );
CHECK_OK( Pdfw::CreateModelDisplayWithVisibleNodes( mv, tabNodeIDs ) ); // Add ModelDisplay with visible nodes
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// -------------------------------- PdfwSampleModelview_section_5_5 -------------------------------------------------
{
Dtk_ID bodyID, datumID, curveID;
options.CreateDefaultView = DTK_FALSE; // no default view needed
// setting cross section graphic properties
options.CrossSection.CuttingPlaneColor = Dtk_RGB( 255, 255, 255 );
options.CrossSection.IntersectionColor = Dtk_RGB( 155, 255, 0 );;
options.CrossSection.AddSectionCap = false;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_BodyPtr cylinder = sampleWriter::CreateCyl( 100, 150 ); // Create a Cylinder radius=100, height=150 (with a green face)
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cylinder ), bodyID ) ); // Add the body
Dtk_FdtPtr pmi = sampleWriter::CreateFdtDatum(); // Create an FDT (PMI)
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( pmi ), datumID ) ); // Add the PMI
Dtk_ModelDisplayPtr mv1 = sampleWriter::CreateModelDisplayActivated(); // create first activated view
Dtk_tab<Dtk_ID>tabNodeIDs;
tabNodeIDs.push_back( bodyID );
tabNodeIDs.push_back( datumID );
CHECK_OK( Pdfw::CreateModelDisplayWithVisibleNodes( mv1, tabNodeIDs ) ); // Add ModelDisplay
CHECK_OK( Pdfw::CreateModelDisplayWithVisibleNodes( mv2, tabNodeIDs ) ); // Add ModelDisplay
CHECK_OK( Pdfw::CreateNodeConnectorHighlight( datumID, bodyID, 1 ) ); // Connect datum PMI on body, on face index 1
Dtk_EllipsePtr ellipse = Dtk_Ellipse::Create( Dtk_pnt(), Dtk_dir( 0., 0., 1. ), Dtk_dir( 1., 0., 0. ), 100 );
ellipse->info() = Dtk_Info::create();
ellipse->info()->SetName( "Curve" );
ellipse->info()->SetBlankedStatus( DTK_TRUE );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( ellipse ), curveID ) ); // Add the curve
//for curve
CHECK_OK( Pdfw::CreateNodeConnectorHighlight( datumID, curveID ) ); // Connect datum PMI on curve
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// -------------------------------- PdfwSamplePMI_PMI_association_5_6 -------------------------------------------------
{
Dtk_ID bodyID, datumID;
Dtk_tab<Dtk_ID> tabPMIIDs;
// First we initialize writing with name of files
options.CreateDefaultView = DTK_FALSE; // no default view needed
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_BodyPtr cylinder = sampleWriter::CreateCyl( 100, 150 ); // Create a Cylinder radius=100, height=150 (with a green face)
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( cylinder ), bodyID ) ); // Add the body
int i;
for( i = 0; i < 10; i++ ) // create 10 PMI
{
Dtk_FdtPtr pmi = sampleWriter::CreateFdtDatum(); // Create an FDT (PMI)
Shift( pmi, 15 * i );
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( pmi ), datumID ) ); // Add the PMI
tabPMIIDs.push_back( datumID );
}
mv2->info()->SetName( "SecondView" );
Dtk_tab<Dtk_ID>tabNodeIDs;
tabNodeIDs.push_back( bodyID );
tabNodeIDs += tabPMIIDs;
CHECK_OK( Pdfw::CreateModelDisplayWithVisibleNodes( mv2, tabNodeIDs ) ); // Add ModelDisplay with visible nodes
CHECK_OK( Pdfw::CreateNodeConnectorHighlight( tabNodeIDs[ 5 ], tabNodeIDs[ 7 ] ) ); // Connect datum PMI on body, on face index 1
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// -------------------------------- PdfwSampleAxis_References_5_7 -------------------------------------------------
{
Dtk_ID axisSysID, planeID, axisID;
Dtk_tab<Dtk_ID> tabNodeIDs;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
tabNodeIDs.push_back( axisSysID );
tabNodeIDs.push_back( planeID );
tabNodeIDs.push_back( axisID );
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// -------------------------------- PdfwSampleCloudPoint_6_1 -------------------------------------------------
{
Dtk_tab<Dtk_pnt> tabPoints;
Dtk_Size_t i, j;
Dtk_transfo transfo;
Dtk_ID pointID;
Dtk_Double64 xPos = 0., yPos = 0., offset = 1.;
Dtk_Size_t numPointX = 200, numPointY = 200;
Dtk_tab<Dtk_RGB> tabColors;
Dtk_tab<Dtk_dir> tabNormals;
options.CreateDefaultView = DTK_FALSE; // no default view needed
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
// generating cloud point
for( i = 0; i < numPointX; i++ )
{
for( j = 0; j < numPointY; j++ )
{
tabPoints.push_back( Dtk_pnt( xPos, yPos, 0. ) );
tabColors.push_back( Dtk_RGB( ( int )( std::rand() / double( RAND_MAX ) * 255 ),
( int )( std::rand() / double( RAND_MAX ) * 255 ),
( int )( std::rand() / double( RAND_MAX ) * 255 ) ) );
yPos += offset;
}
yPos = 0.;
xPos += offset;
}
CHECK_OK( Pdfw::WriteColoredPoints( tabPoints, tabNormals, tabColors, pointID ) ); // write the cloud point
Dtk_pnt from( 300, 300, 300 );
Dtk_pnt to( numPointX / 2., numPointY / 2., 0 );
Dtk_dir up( 0., 1., 0. );
Dtk_CameraPtr cam = Dtk_Camera::Create( from, to, 200, 200, up );
Dtk_ModelDisplayPtr mv1 = Dtk_ModelDisplay::Create( cam, NULL, 1 ); // create activated view
mv1->info() = Dtk_Info::create();
mv1->info()->SetName( "MainView" );
Dtk_tab<Dtk_ID>tabNodeIDs;
CHECK_OK( Pdfw::CreateModelDisplayWithVisibleNodes( mv1, tabNodeIDs ) ); // Add ModelDisplay
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// ------------------------------------ PdfwSampleBillboard_7_1 ---------------------------------------------
Dtk_ErrorStatus PdfwSampleBillboard_7_1( const Dtk_string& inOutputFileName, const Dtk_string& inImageDirectory )
{
Dtk_ID meshID;
Dtk_LeaderPtr emptyLeader;
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_MeshPtr meshCube = sampleWriter::CreateMeshCube(); // create a simple red cube
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( meshCube ), meshID ) ); // write the cube
// create a leader without terminator
Dtk_tab<Dtk_pnt> leaderPoints;
Dtk_pnt dtkLeaderEnd( 1., -1., 1. ), pictureOrigin( 2., -2, 2. );
leaderPoints.push_back( dtkLeaderEnd );
leaderPoints.push_back( pictureOrigin );
Dtk_LeaderPtr leader = Dtk_Leader::Create( 0, 0, dtkLeaderEnd, Dtk_Leader::TerminatorTypeNone, leaderPoints );
// write parallel to screen image with leader
CHECK_OK( Pdfw::WriteParallelToScreenPicture( inImageDirectory + "logodtk.bmp", 20, 20, DTK_ANCHOR_TOP_RIGHT, false, true, Dtk_transfo(), leader ) );
// write pin to screen image
CHECK_OK( Pdfw::WritePinToScreenPicture( inImageDirectory + "logodtk.bmp", 20, 20, Dtk_pnt( 1., 100. ), DTK_ANCHOR_BOTTOM_LEFT, true, emptyLeader ) );
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// ------------------------------------ PdfwSampleSecuredPdf_8_1 ---------------------------------------------
{
Dtk_ID meshID;
// setting protection password
options.OwnerPassword = "password";
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( inOutputFileName, "", NULL, options ) );
Dtk_MeshPtr meshCube = sampleWriter::CreateMeshCube(); // create a simple red cube
CHECK_OK( Pdfw::WriteEntity( Dtk_EntityPtr::DtkDynamicCast( meshCube ), meshID ) ); // write the cube
CHECK_OK( Pdfw::EndWrite() ); // Write final file and free memory allocated
cout << "=> " << inOutputFileName.c_str() << endl;
return dtkNoError;
}
// ------------------------------------ PdfwSampleLayoutMultipleViews_9_1 ---------------------------------------------
{
// iso view
Dtk_pnt from( 30, 30, 30 );
Dtk_pnt to( 0, 0, 0 );
Dtk_dir up( -0.57735, 0.57735, -0.57735 );
Dtk_CameraPtr isoCam = Dtk_Camera::Create( from, to, 10, 10, up );
Dtk_ModelDisplayPtr isoMd = Dtk_ModelDisplay::Create( isoCam, NULL, 1 ); // create first activated view
Dtk_tab<Dtk_ID> tabNodeIDs;
isoMd->info() = Dtk_Info::create();
isoMd->info()->SetName( "Iso" );
CHECK_OK( Pdfw::CreateModelDisplayWithVisibleNodes( isoMd, tabNodeIDs ) ); // Add ModelDisplay
// top view
from = Dtk_pnt( 0, 0, 300 );
up = Dtk_dir( 0, 1, 0 );
Dtk_CameraPtr topCam = Dtk_Camera::Create( from, to, 10, 10, up );
Dtk_ModelDisplayPtr topMd = Dtk_ModelDisplay::Create( topCam, NULL, 0 ); // create first activated view
topMd->info() = Dtk_Info::create();
topMd->info()->SetName( "Top" );
CHECK_OK( Pdfw::CreateModelDisplayWithVisibleNodes( topMd, tabNodeIDs ) ); // Add ModelDisplay
// Front view
from = Dtk_pnt( 0, -300, 0 );
up = Dtk_dir( 0, 0, 1 );
Dtk_CameraPtr frontCam = Dtk_Camera::Create( from, to, 10, 10, up );
Dtk_ModelDisplayPtr frontMd = Dtk_ModelDisplay::Create( frontCam, NULL, 0 ); // create first activated view
frontMd->info() = Dtk_Info::create();
frontMd->info()->SetName( "Front" );
CHECK_OK( Pdfw::CreateModelDisplayWithVisibleNodes( frontMd, tabNodeIDs ) ); // Add ModelDisplay
// right view
from = Dtk_pnt( 300, 0, 0 );
up = Dtk_dir( 0, 0, 1 );
Dtk_CameraPtr rightCam = Dtk_Camera::Create( from, to, 10, 10, up );
Dtk_ModelDisplayPtr rightMd = Dtk_ModelDisplay::Create( rightCam, NULL, 0 ); // create first activated view
rightMd->info() = Dtk_Info::create();
rightMd->info()->SetName( "Right" );
CHECK_OK( Pdfw::CreateModelDisplayWithVisibleNodes( rightMd, tabNodeIDs ) ); // Add ModelDisplay
return dtkNoError;
}
Dtk_ErrorStatus PdfwCreate3DAnnotations( Dtk_Double64 annotBBox[ 4 ], const Dtk_UInt32 &artworkIndex )
{
Dtk_Double64 margin = 3.0;
// first annotation 2d bbox (top right)
annotBBox[ 0 ] = margin / 2. + xPos;
annotBBox[ 1 ] = margin / 2. + yPos;
annotBBox[ 2 ] = xPos + width - margin;
annotBBox[ 3 ] = yPos + height - margin;
CHECK_OK( Pdfw::Layout::Create3DAnnotation( artworkIndex, annotBBox, 0 ) );
// second annotation 2d bbox (top left)
xPos = 0.0;
annotBBox[ 0 ] = margin + xPos;
annotBBox[ 1 ] = margin / 2. + yPos;
annotBBox[ 2 ] = xPos + width - margin / 2.;
annotBBox[ 3 ] = yPos + height - margin;
CHECK_OK( Pdfw::Layout::Create3DAnnotation( artworkIndex, annotBBox, 1 ) );
// third annotation 2d bbox (bottom left)
yPos = 0.0;
annotBBox[ 0 ] = margin + xPos;
annotBBox[ 1 ] = margin + yPos;
annotBBox[ 2 ] = xPos + width - margin / 2.;
annotBBox[ 3 ] = yPos + height - margin / 2.;
CHECK_OK( Pdfw::Layout::Create3DAnnotation( artworkIndex, annotBBox, 2 ) );
// fourth annotation 2d bbox (bottom right)
annotBBox[ 0 ] = margin / 2. + xPos;
annotBBox[ 1 ] = margin + yPos;
annotBBox[ 2 ] = xPos + width - margin;
annotBBox[ 3 ] = yPos + height - margin / 2.;
CHECK_OK( Pdfw::Layout::Create3DAnnotation( artworkIndex, annotBBox, 3 ) );
return dtkNoError;
}
void AssignFacesColors( Dtk_MeshPtr &meshCube )
{
for( Dtk_Size_t i = 1; i < 6; i++ )
meshCube->get_mesh_face( i )->info() = Dtk_Info::create();
meshCube->get_mesh_face( 1 )->info()->SetColor( Dtk_RGB( 0, 255, 0 ) );
meshCube->get_mesh_face( 2 )->info()->SetColor( Dtk_RGB( 0, 0, 255 ) );
meshCube->get_mesh_face( 3 )->info()->SetColor( Dtk_RGB( 255, 255, 0 ) );
meshCube->get_mesh_face( 4 )->info()->SetColor( Dtk_RGB( 255, 0, 255 ) );
meshCube->get_mesh_face( 5 )->info()->SetColor( Dtk_RGB( 0, 255, 255 ) );
}
{
Dtk_string artworkName, nodeName;
Dtk_UInt32 artworkIndex = 0;
Dtk_Double64 annotBBox[ 4 ];
Dtk_transfo transfo;
// We set the options of Writer
// First we initialize writing with name of files
CHECK_OK( Pdfw::InitWrite( pdfFileName, "", NULL, options ) );
// We open a new grey page
CHECK_OK( Pdfw::Layout::InitPage( Dtk_RGB( 200, 200, 200 ) ) );
// Let's initialise the artwork
artworkName = "myArtwork";
CHECK_OK( Pdfw::Layout::Init3DArtwork( artworkName, &options ) );
// add the render
Dtk_RenderInfosPtr renderInfos = NULL;
//RenderInfos Sample
Dtk_MeshPtr meshCube = sampleWriter::CreateMeshCube(); // create a simple red cube
// assigning faces colors
AssignFacesColors( meshCube );
// let's write the mesh cube
// end of artwork
// create the wiews
// create the annotations
PdfwCreate3DAnnotations( annotBBox, artworkIndex );
// close the page
// Finally closing pdf file
cout << "=> " << pdfFileName.c_str() << endl;
return dtkNoError;
}
int PdfWriteSample( const Dtk_string &inResultDirectory )
{
Dtk_ErrorStatus errStatus;
cout << endl << "----------------------------------------------" << endl;
cout << "Pdf Write start" << endl;
Dtk_string imageDirectory = inResultDirectory + L"../InputImages/";
Dtk_string outputDirectory;
// Choosing output directory and file name
outputDirectory = inResultDirectory + L"dtk/Pdf/";
outputDirectory.FixPathSeparator();
outputDirectory.mkdir();
Dtk_string pdfFileName = outputDirectory + L"PDFW_SampleOneMesh_1_1.pdf";
errStatus = PdfwSampleOneMesh_1_1( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleMeshes_1_2.pdf";
errStatus = PdfwSampleMeshes_1_2( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleOneMeshRender_1_3.pdf";
errStatus = PdfwSampleOneMeshRender_1_3( pdfFileName, imageDirectory );
pdfFileName = outputDirectory + L"PDFW_SampleBody_2_1.pdf";
errStatus = PdfwSampleBody_2_1( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleWireBody_2_2.pdf";
errStatus = PdfwSampleWireBody_2_2( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleBodyVisibility_2_3.pdf";
errStatus = PdfwSampleBodyVisibility_2_3( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleAssembly_3_1.pdf";
errStatus = PdfwSampleAssembly_3_1( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SamplePartInstances_3_2.pdf";
errStatus = PdfwSamplePartInstances_3_2( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleAsmInstances_3_3.pdf";
errStatus = PdfwSampleAsmInstances_3_3( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleInstancesColors_3_4.pdf";
errStatus = PdfwSampleInstancesColors_3_4( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleInstancesVisibility_3_5.pdf";
errStatus = PdfwSampleInstancesVisibility_3_5( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleMetadatas_4_1.pdf";
errStatus = PdfwSampleMetadatas_4_1( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleDocumentProperties_4_2.pdf";
errStatus = PdfwSampleDocumentProperties_4_2( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleSimplePMI_5_1.pdf";
errStatus = PdfwSampleSimplePMI_5_1( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleSimpleModelview_5_2.pdf";
errStatus = PdfwSampleSimpleModelview_5_2( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_Sample_MV_association_5_3.pdf";
errStatus = PdfwSample_MV_association_5_3( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SamplePMI_Geom_association_5_4.pdf";
errStatus = PdfwSamplePMI_Geom_association_5_4( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleModelview_sections_5_5.pdf";
errStatus = PdfwSampleModelview_section_5_5( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SamplePMI_PMI_association_5_6.pdf";
errStatus = PdfwSamplePMI_PMI_association_5_6( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleAxis_References_5_7.pdf";
errStatus = PdfwSampleAxis_References_5_7( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleCloudPoint_6_1.pdf";
errStatus = PdfwSampleCloudPoint_6_1( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleBillboard_7_1.pdf";
errStatus = PdfwSampleBillboard_7_1( pdfFileName, imageDirectory );
pdfFileName = outputDirectory + L"PDFW_SampleSecuredPdf_8_1.pdf";
errStatus = PdfwSampleSecuredPdf_8_1( pdfFileName );
pdfFileName = outputDirectory + L"PDFW_SampleLayoutMultipleViews_9_1.pdf";
errStatus = PdfwSampleLayoutMultipleViews_9_1( pdfFileName );
cout << "Pdf Write end" << endl;
return errStatus;
}
//end_of_mainpdfwrite
sampleWriter::CreateAxis
Dtk_BodyPtr CreateAxis()
Definition: testcreatecube.cpp:1492
PdfwSampleSecuredPdf_8_1
Dtk_ErrorStatus PdfwSampleSecuredPdf_8_1(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:856
Dtk_ModelDisplay::Create
static Dtk_ModelDisplayPtr Create(const Dtk_CameraPtr &inCamera, const Dtk_EntityPtr &inClippingEntity, const Dtk_bool inIsActivated)
Full featured constructor.
Pdfw::CreateModelDisplayWithVisibleNodes
DtkErrorStatus CreateModelDisplayWithVisibleNodes(Dtk_ModelDisplayPtr &inModelDisplay, Dtk_tab< Dtk_ID > &inTabVisibleNodes, Pdfw::RenderMode inRenderMode=Pdfw::Unset, Pdfw::Lighting inLighting=Pdfw::UnsetLighting)
Create a model display.
Dtk_ID
uint32_t Dtk_ID
Definition: define.h:689
Dtk_transfo
This is the Transformation dedicated class.
Definition: dtk_transfo.hpp:19
Pdfw::AddNodeMetadata
DtkErrorStatus AddNodeMetadata(Dtk_tab< Dtk_MetaDataPtr > &inTabMetadata)
Add table of metadata to current node.
Pdfw::Layout::Create3DAnnotation
DtkErrorStatus Create3DAnnotation(Dtk_UInt32 inArtworkIndex, Dtk_Double64 inBBox[4], Dtk_Int32 inModelDisplayIndex=-1, Dtk_Int32 inLayerID=-1, RenderMode inRenderMode=Unset, Lighting inLighting=UnsetLighting, Dtk_bool inAnnotActivation=0)
Creates 3D Annotation from 3D artwork in current page with its 2d bounding box.
Shift
void Shift(T &mesh, double sh)
Definition: testlibpdfwrite.cpp:38
Pdfw::WriteOptions
This class provides several options to tune Pdf Writer. It must be provided to Pdfw::InitWrite method...
Definition: pdfw.hpp:113
PdfwSampleMetadatas_4_1
Dtk_ErrorStatus PdfwSampleMetadatas_4_1(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:464
Pdfw::InitWrite
DtkErrorStatus InitWrite(const Dtk_string &inOutputFile, const Dtk_string &inLogFile, Licence_dtk inLicFct, WriteOptions &inOptions)
Initialize the PDF Writer
sampleWriter::CreateMeshCube
Dtk_MeshPtr CreateMeshCube()
Mesh Cube sample.
Definition: testcreatemesh.cpp:207
PdfwSampleAxis_References_5_7
Dtk_ErrorStatus PdfwSampleAxis_References_5_7(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:742
Pdfw::WriteOptions::PointSize
Dtk_Double64 PointSize
Size of points.
Definition: pdfw.hpp:163
Pdfw::WriteOptions::Layout
LayoutOptions Layout
Definition: pdfw.hpp:193
sampleWriter::CreateCyl
Dtk_BodyPtr CreateCyl(double radius, double height)
Definition: testcreatecube.cpp:1791
sampleWriter::CreateMeshCubeVertexColor
Dtk_MeshPtr CreateMeshCubeVertexColor()
Definition: testcreatemesh.cpp:299
sampleWriter::CreateModelDisplayWithSection
Dtk_ModelDisplayPtr CreateModelDisplayWithSection()
Definition: testcreatefdt.cpp:254
sampleWriter::CreateMeshPoints
Dtk_MeshPtr CreateMeshPoints()
Points mesh sample.
Definition: testcreatemesh.cpp:439
Pdfw::Layout::EndPage
Dtk_ErrorStatus EndPage()
End of page.
Pdfw::LayoutOptions::CreateAutomaticLayout
Dtk_bool CreateAutomaticLayout
DTK_TRUE : Creates automatic layout (One page with filled with 3D Annotation), DTK_FALSE : You must u...
Definition: pdfw.hpp:37
DTK_TRUE
#define DTK_TRUE
Definition: define.h:727
Pdfw::PdfDocumentProperties::SetKeywords
void SetKeywords(const Dtk_string &inString)
Add Keywords in Document Catalog Metadata.
sampleWriter::CreateInfinitePlane
Dtk_BodyPtr CreateInfinitePlane()
Definition: testcreatecube.cpp:1435
PdfwSamplePartInstances_3_2
Dtk_ErrorStatus PdfwSamplePartInstances_3_2(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:225
AssignFacesColors
void AssignFacesColors(Dtk_MeshPtr &meshCube)
Definition: testlibpdfwrite.cpp:966
Dtk_UInt32
uint32_t Dtk_UInt32
Definition: define.h:688
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:58
PdfWriteSample
int PdfWriteSample(const Dtk_string &inResultDirectory)
Definition: testlibpdfwrite.cpp:1030
Pdfw::Layout::GetCurrentPageWidth
Dtk_Double64 GetCurrentPageWidth()
Gets current page width.
DTK_ANCHOR_BOTTOM_LEFT
@ DTK_ANCHOR_BOTTOM_LEFT
Definition: util_draw_dtk.hpp:106
Dtk_Size_t
size_t Dtk_Size_t
Definition: define.h:712
Pdfw::Layout::GetCurrentPageHeight
Dtk_Double64 GetCurrentPageHeight()
Gets current page height.
Dtk_MetaData::TypeFileProperty
@ TypeFileProperty
Definition: dtk_metadata.hpp:29
Pdfw::PdfDocumentProperties::SetTitle
void SetTitle(const Dtk_string &inString)
Add Title in Document Catalog Metadata.
Pdfw::WriteOptions::CrossSection
cross_section CrossSection
Cross section parameters.
Definition: pdfw.hpp:165
Pdfw::cross_section::CuttingPlaneOpacity
Dtk_Double64 CuttingPlaneOpacity
Definition: pdfw.hpp:28
sampleWriter::CreateAxisSystem
Dtk_AxisSystemPtr CreateAxisSystem()
Definition: testcreatecube.cpp:1465
PdfwSampleLayoutMultipleViews_9_1
Dtk_ErrorStatus PdfwSampleLayoutMultipleViews_9_1(const Dtk_string &pdfFileName)
Definition: testlibpdfwrite.cpp:978
DTK_FALSE
#define DTK_FALSE
Definition: define.h:728
PdfwSampleModelview_section_5_5
Dtk_ErrorStatus PdfwSampleModelview_section_5_5(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:657
PdfwCreateViews
Dtk_ErrorStatus PdfwCreateViews()
Definition: testlibpdfwrite.cpp:877
Pdfw::cross_section::CuttingPlaneColor
Dtk_RGB CuttingPlaneColor
Definition: pdfw.hpp:27
PdfwSampleBillboard_7_1
Dtk_ErrorStatus PdfwSampleBillboard_7_1(const Dtk_string &inOutputFileName, const Dtk_string &inImageDirectory)
Definition: testlibpdfwrite.cpp:825
Dtk_Ellipse::Create
static Dtk_EllipsePtr Create(const Dtk_Ellipse &inEllipseToCopy)
Pdfw::keepsubtransparency
@ keepsubtransparency
Definition: pdfw.hpp:16
Dtk_Double64
double Dtk_Double64
Definition: define.h:699
Dtk_Info::SetBlankedStatus
Dtk_ErrorStatus SetBlankedStatus(const Dtk_Int32 &inBlankedStatus)
Pdfw::ReinstanciatePrototype
DtkErrorStatus ReinstanciatePrototype(Dtk_ID inID)
Reinstanciate children of node to reinstanciate in current node.
Pdfw::PdfDocumentProperties
Definition: pdfw.hpp:197
PdfwSampleInstancesVisibility_3_5
Dtk_ErrorStatus PdfwSampleInstancesVisibility_3_5(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:419
Pdfw::Layout::Init3DArtwork
DtkErrorStatus Init3DArtwork(Dtk_string inAnnotName=Dtk_string(), Pdfw::WriteOptions *inWriteOptions=NULL)
Starts Writing of 3D Artwork (3D model)
Pdfw::PdfDocumentProperties::SetAuthor
void SetAuthor(const Dtk_string &inString)
Add Author in Document Catalog Metadata.
Pdfw::StorePrototype
void StorePrototype(Dtk_ID inID)
Stores the identifier of a node.
Dtk_API::GetAPI
static Dtk_API * GetAPI()
Get DATAKIT API.
sampleWriter::CreateMeshWire
Dtk_MeshPtr CreateMeshWire()
Wire mesh sample.
Definition: testcreatemesh.cpp:388
Pdfw::PdfDocumentProperties::SetPDFProducer
void SetPDFProducer(const Dtk_string &inString)
Add PDFProducer in Document Catalog Metadata.
PdfwSampleOneMesh_1_1
Dtk_ErrorStatus PdfwSampleOneMesh_1_1(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:22
Dtk_string::filename
Dtk_string filename() const
File Utility : Retrieves the filename in Dtk_string form.
sampleWriter::CreateTexturedMeshCube
Dtk_MeshPtr CreateTexturedMeshCube(const Dtk_string &inImageDirectory)
Textured Mesh Cube sample.
Definition: testcreatemesh.cpp:272
Pdfw::EndWrite
DtkErrorStatus EndWrite()
Creation of the output file and free the PDF Writer
Dtk_MeshPtr
Dtk_SmartPtr< Dtk_mesh > Dtk_MeshPtr
Definition: dtk_maindoc.hpp:20
PdfwSampleCloudPoint_6_1
Dtk_ErrorStatus PdfwSampleCloudPoint_6_1(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:770
DTK_ANCHOR_TOP_RIGHT
@ DTK_ANCHOR_TOP_RIGHT
Definition: util_draw_dtk.hpp:102
sampleWriter::CreateFdtDatum
Dtk_FdtPtr CreateFdtDatum()
Create Simple Datum.
Definition: testcreatefdt.cpp:19
Pdfw::EndNode
DtkErrorStatus EndNode()
End the node.
Dtk_MetaData::TypeProperty
@ TypeProperty
Definition: dtk_metadata.hpp:28
PdfwSampleBodyVisibility_2_3
Dtk_ErrorStatus PdfwSampleBodyVisibility_2_3(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:154
PdfwSampleMeshes_1_2
Dtk_ErrorStatus PdfwSampleMeshes_1_2(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:45
Dtk_SmartPtr< Dtk_Entity >::DtkDynamicCast
static Dtk_SmartPtr< Dtk_Entity > DtkDynamicCast(const Dtk_SmartPtr< T2 > &p)
Definition: util_ptr_dtk.hpp:101
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
Dtk_SmartPtr::IsNULL
Dtk_bool IsNULL() const
Definition: util_ptr_dtk.hpp:118
Dtk_API::GetVersion
Dtk_string GetVersion() const
GetVersion of DatakitLibs.
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.
Pdfw::WriteOptions::OwnerPassword
Dtk_string OwnerPassword
Definition: pdfw.hpp:172
PdfwSampleInstancesColors_3_4
Dtk_ErrorStatus PdfwSampleInstancesColors_3_4(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:322
PdfwSampleAssembly_3_1
Dtk_ErrorStatus PdfwSampleAssembly_3_1(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:185
Dtk_string::mkdir
int mkdir() const
File Utility : Create a Directory.
PdfwSampleSimplePMI_5_1
Dtk_ErrorStatus PdfwSampleSimplePMI_5_1(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:533
Pdfw::keepsubcolor
@ keepsubcolor
Definition: pdfw.hpp:15
Dtk_pnt
This is a mathematical point class.
Definition: dtk_pnt.hpp:22
PdfwSamplePMI_Geom_association_5_4
Dtk_ErrorStatus PdfwSamplePMI_Geom_association_5_4(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:626
Pdfw::WritePinToScreenPicture
Dtk_ErrorStatus WritePinToScreenPicture(const Dtk_string &inPictureFilePath, Dtk_Double64 inPictureWidth, Dtk_Double64 inPictureHeight, Dtk_pnt inPictureOrigin, Dtk_anchor_type inAnchorType, bool inIsOnTop, Dtk_LeaderPtr &inLeader)
Creates a picture parallel to screen with an attached leader line.
Pdfw::Layout::End3DArtwork
DtkErrorStatus End3DArtwork(Dtk_UInt32 &outartworkIndex)
Ends Writing of 3D Artwork.
PdfwSampleAsmInstances_3_3
Dtk_ErrorStatus PdfwSampleAsmInstances_3_3(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:268
Dtk_string::FixPathSeparator
void FixPathSeparator()
File Utility : Fixes path separator consistency. It lets you replace the '\' or '/' by the OS needed ...
Pdfw::WriteColoredPoints
Dtk_ErrorStatus WriteColoredPoints(Dtk_tab< Dtk_pnt > &inTabPoints, Dtk_tab< Dtk_dir > &inTabNormals, Dtk_tab< Dtk_RGB > &inTabColors, Dtk_ID &outID, Dtk_InfoPtr inInfo=Dtk_InfoPtr())
Write colored points provided in parameter in one node.
PdfwSample_MV_association_5_3
Dtk_ErrorStatus PdfwSample_MV_association_5_3(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:586
PdfwSampleDocumentProperties_4_2
Dtk_ErrorStatus PdfwSampleDocumentProperties_4_2(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:489
Pdfw::WriteEntity
Dtk_ErrorStatus WriteEntity(const Dtk_EntityPtr &inEntity)
Write the entity provided in parameter in a node.
Dtk_Leader::Create
static Dtk_LeaderPtr Create()
Base constructor.
Dtk_Camera::Create
static Dtk_CameraPtr Create()
Base constructor.
sampleWriter::CreateModelDisplayActivated
Dtk_ModelDisplayPtr CreateModelDisplayActivated()
Definition: testcreatefdt.cpp:228
Pdfw::cross_section::AddSectionCap
Dtk_bool AddSectionCap
Definition: pdfw.hpp:24
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.
Pdfw::InitNode
DtkErrorStatus InitNode(Dtk_string &inNodeName, const Dtk_transfo &inTransfo=Dtk_transfo())
Initialize a node.
PdfwCreate3DAnnotations
Dtk_ErrorStatus PdfwCreate3DAnnotations(Dtk_Double64 annotBBox[4], const Dtk_UInt32 &artworkIndex)
Definition: testlibpdfwrite.cpp:925
Pdfw::WriteOptions::ConvertRenderInfos
Dtk_bool ConvertRenderInfos
DTK_TRUE : Creates render infos (lightning + texturing), DTK_FALSE : no render infos.
Definition: pdfw.hpp:159
PdfwSamplePMI_PMI_association_5_6
Dtk_ErrorStatus PdfwSamplePMI_PMI_association_5_6(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:704
Pdfw::WriteParallelToScreenPicture
Dtk_ErrorStatus WriteParallelToScreenPicture(const Dtk_string &inPictureFilePath, Dtk_Double64 inPictureWidth, Dtk_Double64 inPictureHeight, Dtk_anchor_type inAnchorType, bool inIsZoomable, bool inIsOnTop, Dtk_transfo inTransfo, Dtk_LeaderPtr &inLeader)
Creates a parallel to screen picture with an attached leader line.
Pdfw::PdfDocumentProperties::SetSubject
void SetSubject(const Dtk_string &inString)
Add Subject in Document Catalog Metadata.
PdfwSampleWireBody_2_2
Dtk_ErrorStatus PdfwSampleWireBody_2_2(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:133
PdfwSampleSimpleModelview_5_2
Dtk_ErrorStatus PdfwSampleSimpleModelview_5_2(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:554
sampleWriter::CreateCurves
Dtk_BodyPtr CreateCurves()
Definition: testcreatecube.cpp:1292
sampleWriter::CreateCurvesStyle
Dtk_BodyPtr CreateCurvesStyle()
Definition: testcreatecube.cpp:1370
Pdfw::AddDocumentProperties
Dtk_ErrorStatus AddDocumentProperties(const Pdfw::PdfDocumentProperties &inDocProperties, const Dtk_tab< Dtk_MetaDataPtr > &inMetadatas)
Writing Document Properties.
Pdfw::PdfDocumentProperties::SetApplication
void SetApplication(const Dtk_string &inString)
Add Application in Document Catalog Metadata.
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
PdfwSampleOneMeshRender_1_3
Dtk_ErrorStatus PdfwSampleOneMeshRender_1_3(const Dtk_string &inOutputFileName, const Dtk_string &inImageDirectory)
Definition: testlibpdfwrite.cpp:99
Pdfw::attributeoverwrite
@ attributeoverwrite
Definition: pdfw.hpp:14
Dtk_tab::clear
void clear(int no_delete=0)
Resets the Dtk_tab content.
Definition: util_stl_dtk.hpp:351
PdfwSampleBody_2_1
Dtk_ErrorStatus PdfwSampleBody_2_1(const Dtk_string &inOutputFileName)
Definition: testlibpdfwrite.cpp:117
Pdfw::WriteBodyAndMesh
DtkErrorStatus WriteBodyAndMesh(const Dtk_BodyPtr &inBody, const Dtk_MeshPtr &inMesh, Dtk_ID &outID)
Write the entities provided in parameter in a node.
Pdfw::cross_section::IntersectionColor
Dtk_RGB IntersectionColor
Definition: pdfw.hpp:26
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_dir
This is a mathematical direction class.
Definition: dtk_dir.hpp:15
Pdfw::CreateNodeConnectorHighlight
Dtk_ErrorStatus CreateNodeConnectorHighlight(const Dtk_ID &inPointingNodeID, const Dtk_ID &inPointedNodeID, const Dtk_UInt32 &inFaceIndex=-1, Dtk_Int32 inReasonLink=0)
Create a connexion between two nodes for visual response.
Pdfw::WriteOptions::CreateDefaultView
Dtk_bool CreateDefaultView
DTK_TRUE : Creates Default View (isometric view), DTK_FALSE : no default view.
Definition: pdfw.hpp:139
Pdfw::Layout::InitPage
Dtk_ErrorStatus InitPage(Dtk_RGB inColor=Dtk_RGB(255, 255, 255), Dtk_Double64 inWidth=842, Dtk_Double64 inHeight=595)
LAYOUT METHODS.
Dtk_Leader::TerminatorTypeNone
@ TerminatorTypeNone
Definition: util_draw_dtk.hpp:2001
sampleWriter::CreateModelDisplayDesactivated
Dtk_ModelDisplayPtr CreateModelDisplayDesactivated()
Definition: testcreatefdt.cpp:241
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 .
Pdfw::WriteOptions::ShowToolbar
Dtk_bool ShowToolbar
DTK_TRUE : Show 3D Toolbar, DTK_FALSE : Hides 3D Toolbar.
Definition: pdfw.hpp:145