DATAKIT API  V2025.1
OpenDocument.cpp File Reference

Functions

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

Variables

Dtk_tab< Dtk_IDComponentProcessed
 

Function Documentation

◆ ProcessCADFile()

Dtk_ErrorStatus ProcessCADFile ( const Dtk_string inInputFile,
const Dtk_string inOutputFolder 
)
19 {
20  DtkErrorStatus stError = dtkNoError;
21  Dtk_ErrorStatus stErrorPdf = dtkNoError;
22  Dtk_ErrorStatus stErrorXml = dtkNoError;
23 
24  Dtk_MainDocPtr TmpDoc;
25  ComponentProcessed.clear();
26 
27  // You Get the current API
28  Dtk_API * MyAPI = Dtk_API::GetAPI();
29 
30  cout << "Processing file " << inInputFile.c_str() << endl;
31 
32  Dtk_string FileVersion;
33  stError = MyAPI->GetFileVersion(inInputFile, FileVersion);
34 
35  if( FileVersion.is_not_NULL() )
36  cout <<"File version = " << FileVersion.c_str() << endl;
37  if (stError != dtkNoError)
38  {
39  cout << "Error with file version: " << dtkTypeError( stError ).c_str() << endl;
40  return stError;
41  }
42 
43  //If you want to get a log file for reader (inventory, missing files in assembly...) you have to set it
44  MyAPI->SetLogFile( "DtkLogFile.txt" );
45 
46  //Following Project Options
47  // To Write an Xml file
48  if(IsXmlDumpActivated())
49  {
50  stErrorXml = XmlWriteInit( inInputFile, inOutputFolder );
51  }
52  // To Write an PDF file
53  if(IsPdfDumpActivated())
54  {
55  stErrorPdf = PdfInitWrite( inInputFile, inOutputFolder );
56  }
57 
58 
59 
60  //You Open the file you want to read and get corresponding Document
61  Dtk_ErrorStatus err = MyAPI->OpenDocument( inInputFile, TmpDoc );
62 
63  //If no Error we write the Document
64  if( err == dtkNoError && TmpDoc.IsNotNULL() )
65  {
66  WriteDocument( TmpDoc ); //see WriteDocument.cpp
67  }
68  else
69  {
70  cout << "Error OpenDocument: " << err << dtkTypeError( err ).c_str() << endl;
71  }
72 
73  //We close the opened document
74  err = MyAPI->EndDocument( TmpDoc );
75 
76  if(IsXmlDumpActivated())
77  {
78  XmlWriteEnd();
79  }
80  if(IsPdfDumpActivated())
81  {
82  PdfEndWrite( inInputFile );
83  }
84 
85  return err;
86 }

Variable Documentation

◆ ComponentProcessed

Dtk_tab<Dtk_ID> ComponentProcessed
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:58
WriteDocument
Dtk_ErrorStatus WriteDocument(Dtk_MainDocPtr inDocument)
Definition: WriteDocument.cpp:12
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.
PdfEndWrite
void PdfEndWrite(const Dtk_string &inInputFile)
Definition: PdfWrite.cpp:80
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.
ComponentProcessed
Dtk_tab< Dtk_ID > ComponentProcessed
Definition: WritePrototype.cpp:12
IsXmlDumpActivated
Dtk_bool IsXmlDumpActivated()
Definition: XmlWrite.cpp:17
PdfInitWrite
Dtk_ErrorStatus PdfInitWrite(const Dtk_string &inInputFileName, const Dtk_string &inOutputFolder)
Definition: PdfWrite.cpp:31
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:140
Dtk_API::SetLogFile
Dtk_ErrorStatus SetLogFile(const Dtk_string &inLogFile)
Set Log File.
IsPdfDumpActivated
Dtk_bool IsPdfDumpActivated()
Definition: PdfWrite.cpp:26
Dtk_API
Definition: dtk_api.hpp:75