DATAKIT SDK  V2026.2
OpenDocument.cpp File Reference

Functions

Dtk_ErrorStatus ProcessCADFile (const Dtk_string &inInputFile, const Dtk_string &inOutputFolder)
 

Variables

Dtk_tab< Dtk_IDProcessedComponents
 

Function Documentation

◆ ProcessCADFile()

Dtk_ErrorStatus ProcessCADFile ( const Dtk_string inInputFile,
const Dtk_string inOutputFolder 
)
19 {
20  // Clear the list of processed components before starting.
21  ProcessedComponents.clear();
22 
23  // Get the current Datakit API instance.
24  Dtk_API* myApi = Dtk_API::GetAPI();
25 
26  std::cout << "Processing file: " << inInputFile.c_str() << std::endl;
27 
28  // Retrieve and display the file version.
29  Dtk_string fileVersion;
30  Dtk_ErrorStatus stError = myApi->GetFileVersion(inInputFile, fileVersion);
31 
32  if( fileVersion.is_not_NULL() )
33  {
34  // Display the file version.
35  std::cout << "File version: " << fileVersion.c_str() << std::endl;
36  }
37 
38  if (stError != dtkNoError)
39  {
40  // Report error if unable to get file version.
41  std::cout << "Unable to get file version (error code: " << dtkTypeError(stError).c_str() << ")" << std::endl;
42  return stError;
43  }
44 
45  // Set log file for the reader (inventory, missing files in assembly, etc.).
46  Dtk_string logFilePath = inInputFile.filename() + Dtk_string("-dtk.log");
47  myApi->SetLogFile( logFilePath );
48 
49  // Initialize XML writing if XML export is enabled.
50  Dtk_ErrorStatus stErrorXml = dtkNoError;
51  if (IsXmlDumpActivated())
52  {
53  stErrorXml = XmlWriteInit(inInputFile, inOutputFolder);
54  }
55 
56  // Initialize PDF writing if PDF export is enabled.
57  Dtk_ErrorStatus stErrorPdf = dtkNoError;
58  if (IsPdfDumpActivated())
59  {
60  stErrorPdf = PdfInitWrite(inInputFile, inOutputFolder);
61  }
62 
63  // Open the input file and obtain the corresponding document.
64  Dtk_MainDocPtr tmpDoc;
65  Dtk_ErrorStatus err = myApi->OpenDocument(inInputFile, tmpDoc);
66 
67  // If successful, write the document (see WriteDocument.cpp)
68  if (err == dtkNoError && tmpDoc.IsNotNULL())
69  {
70  WriteDocument(tmpDoc);
71  }
72  else
73  {
74  // Report error if unable to open the document.
75  std::cout << "Error with OpenDocument (error code: " << err << " " << dtkTypeError(err).c_str() << ")" << std::endl;
76  }
77 
78  // Close the opened document.
79  err = myApi->EndDocument(tmpDoc);
80 
81  // Finalize XML writing if XML export is enabled.
82  if (IsXmlDumpActivated())
83  {
84  XmlWriteEnd();
85  }
86 
87  // Finalize PDF writing if PDF export is enabled.
88  if (IsPdfDumpActivated())
89  {
90  PdfEndWrite(inInputFile);
91  }
92 
93  return err;
94 }

Variable Documentation

◆ ProcessedComponents

Dtk_tab<Dtk_ID> ProcessedComponents
extern
Dtk_API::EndDocument
Dtk_ErrorStatus EndDocument(Dtk_MainDocPtr &inoutDocument)
Close a Document.
Dtk_SmartPtr::IsNotNULL
Dtk_bool IsNotNULL() const
Definition: util_ptr_dtk.hpp:119
Dtk_string
This is a high level string class.
Definition: dtk_string.hpp:53
WriteDocument
Dtk_ErrorStatus WriteDocument(Dtk_MainDocPtr inDocument)
Definition: WriteDocument.cpp:14
XmlWriteInit
Dtk_ErrorStatus XmlWriteInit(Dtk_string inInputFile, const Dtk_string &inOutputFolder)
Definition: XmlWrite.cpp:22
Dtk_API::OpenDocument
Dtk_ErrorStatus OpenDocument(const Dtk_string &inInputFile, Dtk_MainDocPtr &outDocument)
Open a Document (call EndDocument to close it)
Dtk_string::is_not_NULL
Dtk_bool is_not_NULL() const
Dtk_API::GetAPI
static Dtk_API * GetAPI()
Get DATAKIT API.
Dtk_string::filename
Dtk_string filename() const
File Utility : Retrieves the filename in Dtk_string form.
PdfEndWrite
void PdfEndWrite(const Dtk_string &inInputFile)
Definition: PdfWrite.cpp:83
XmlWriteEnd
Dtk_ErrorStatus XmlWriteEnd()
Definition: XmlWrite.cpp:39
Dtk_ErrorStatus
Dtk_ErrorStatus
Definition: error_dtk.hpp:6
Dtk_SmartPtr
Definition: util_ptr_dtk.hpp:37
dtkTypeError
Dtk_string dtkTypeError(Dtk_Int32 errNumero)
Dtk_string::c_str
const char * c_str() const
Retrieve the ASCII conversion string.
ProcessedComponents
Dtk_tab< Dtk_ID > ProcessedComponents
Definition: WritePrototype.cpp:16
IsXmlDumpActivated
Dtk_bool IsXmlDumpActivated()
Definition: XmlWrite.cpp:17
PdfInitWrite
Dtk_ErrorStatus PdfInitWrite(const Dtk_string &inInputFileName, const Dtk_string &inOutputFolder)
Definition: PdfWrite.cpp:34
Dtk_API::GetFileVersion
Dtk_ErrorStatus GetFileVersion(const Dtk_string &inInputFile, Dtk_string &outVersion)
Independant method to get version of inInputFile.
dtkNoError
@ dtkNoError
Definition: error_dtk.hpp:149
Dtk_API::SetLogFile
Dtk_ErrorStatus SetLogFile(const Dtk_string &inLogFile)
Set Log File.
IsPdfDumpActivated
Dtk_bool IsPdfDumpActivated()
Definition: PdfWrite.cpp:29
Dtk_API
Definition: dtk_api.hpp:75