CFx SDK Documentation  2023 SP0
FxBIM.h
Go to the documentation of this file.
1 //
2 // (C) Copyright 2020-2022 by Graebert GmbH.
3 //
4 // Permission to use, copy, modify, and distribute this software in
5 // object code form for any purpose and without fee is hereby granted,
6 // provided that the above copyright notice appears in all copies and
7 // that both that copyright notice and the limited warranty and
8 // restricted rights notice below appear in all supporting
9 // documentation.
10 //
11 // GRAEBERT PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
12 // GRAEBERT SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
13 // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. GRAEBERT GMBH
14 // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
15 // UNINTERRUPTED OR ERROR FREE.
16 
17 #pragma once
18 
19 #ifndef _MSC_VER
20  #define FXBIM_API
21 #else
22  #if defined( FX_STATIC_BUILD )
23  #define FXBIM_API
24  #else
25  #ifdef FXBIM_EXPORTS
26  #define FXBIM_API __declspec(dllexport)
27  #else
28  #define FXBIM_API __declspec(dllimport)
29  #endif
30  #endif
31 #endif
32 
33 #include <QtCore/QString>
34 
35 #include <OdaCommon.h>
36 #include <OdaDefs.h>
37 #include <DbDatabase.h>
38 
39 #include <sdk/FxBIMEntityReference.h>
40 
41 #if defined (Q_OS_LINUX)
42 #include <memory>
43 #endif
44 
45 #if !defined( FX_STATIC_BUILD )
46 #include "../../Kernel/DDKERNEL/FxThreadUtils.h"
47 #endif
48 
49 enum class Error
50 {
51  eOk = 0,
52  eFail,
53  eAbort,
65  eNotFound,
75 };
76 
77 enum class fileType
78 {
79  eUnknown = 0,
80  eRevit = 1,
81  eIFC = 2,
82 };
83 
84 class OdString;
86 
87 #include <functional>
88 #include <RxObject.h>
89 
92 
93 class CFxBIMIPC;
94 
96 {
97  enum Type
98  {
103  } _c;
104 
105  using fn_start_t = std::function< void( const OdString& viewName, OdInt64 idView ) >;
106  using fn_ready_t = std::function< void( const OdString& dwgPath, const OdString& originalPath, const OdString& viewName, OdInt64 idView, int flags ) >;
107  using fn_finish_t = std::function< void( int exitCode, int exitStatus ) >;
108  using fn_abort_t = std::function< bool() >;
109  using fn_error_t = std::function< void( const OdString& err ) >;
110 
111  struct Data
112  {
113  fn_start_t _fnStart = nullptr;
114  fn_ready_t _fnReady = nullptr;
115  fn_finish_t _fnFinish = nullptr;
116  fn_abort_t _fnAbort = nullptr;
117  fn_error_t _fnError = nullptr;
118  OdDbHostAppProgressMeter* _pProgress = 0;
119  } _d;
120 
121  enum Flags
122  {
124  };
125  int _flags = eFNone;
126 
128  explicit Conversion( fileType type, Data data, int flags );
129 
130  static Conversion::Type FromString( const OdString& arg );
131  static OdString ToString( const Conversion& c );
132 
133  std::shared_ptr< CFxBIMIPC > _ipc;
134 };
135 
136 namespace FxBIM
137 {
138  const OdString kBIMModuleName = OD_T( "FxBIM" );
139 
140  enum Version
141  {
142  k2019 = 1,
143  k2020 = 2,
144  k2021 = 3,
145  kSP0 = 0,
146  kSP1 = 1,
147  kSP2 = 2,
148  kSP3 = 3,
149  };
150 
154 
155  FXBIM_API OdInt64 bimVersion( OdInt16 major, OdInt16 minor, OdInt16 revision );
157 }
158 
159 FXBIM_API OdString convert( const QString& qstr );
160 FXBIM_API QString convert( const OdString& odstr );
161 
162 class CFxBIMObject;
163 typedef std::shared_ptr< CFxBIMObject > CFxBIMObjectPtr;
164 
165 class FXBIM_API CFxBIMObject : public std::enable_shared_from_this< CFxBIMObject >
166 {
167 protected:
169  virtual ~CFxBIMObject();
170 };
171 
172 #include <DbObjectId.h>
173 
174 namespace FxBIM
175 {
176  template <typename T>
177  std::shared_ptr<T> cast( CFxBIMObjectPtr pBase )
178  {
179  std::shared_ptr<T> p = std::dynamic_pointer_cast< T, CFxBIMObject >( pBase );
180  return( p );
181  }
182 
183  template <typename T>
184  OdSmartPtr<T> cast( OdDbObjectId id, OdDb::OpenMode mode = OdDb::kForRead, bool openErased = false )
185  {
186  OdSmartPtr<T> p = T::cast( id.openObject( mode, openErased ) );
187  return( p );
188  }
189 }
190 
191 class CFxBIMIterator;
192 typedef std::shared_ptr< CFxBIMIterator > CFxBIMIteratorPtr;
193 class CFxBIMIteratorRA;
194 typedef std::shared_ptr< CFxBIMIteratorRA > CFxBIMIteratorRAPtr;
195 class CFxBIMDbIterator;
196 typedef std::shared_ptr< CFxBIMDbIterator > CFxBIMDbIteratorPtr;
197 class CFxBIMDbIteratorRA;
198 typedef std::shared_ptr< CFxBIMDbIteratorRA > CFxBIMDbIteratorRAPtr;
199 
200 #include <functional>
201 
203 {
204 public:
205  virtual ~CFxBIMIterator() {};
206  virtual void SetPredicate( std::function< bool( CFxBIMObjectPtr ) > p ) = 0;
207  virtual void Start() = 0;
208  virtual bool Done() = 0;
209  virtual void Next() = 0;
210 
211  virtual CFxBIMObjectPtr Object() = 0;
212 };
213 
215 {
216 public:
217  virtual ~CFxBIMIteratorRA() {};
218  virtual size_t Count() = 0;
219  virtual CFxBIMObjectPtr Object( size_t index ) = 0;
220 };
221 
222 #include <DbObjectId.h>
223 
225 {
226 public:
227  virtual ~CFxBIMDbIterator() {};
228  virtual void SetPredicate( std::function< bool( OdDbObjectId ) > p ) = 0;
229  virtual void Start() = 0;
230  virtual bool Done() = 0;
231  virtual void Next() = 0;
232 
233  virtual OdDbObjectId Object() = 0;
234 };
235 
237 {
238 public:
239  virtual ~CFxBIMDbIteratorRA() {};
240  virtual size_t Count() = 0;
241  virtual OdDbObjectId Object( size_t index ) = 0;
242 };
243 
244 enum class BimStandards
245 {
246  eUnset = -2,
247  eUnknown = -1,
248  eISO = 0,
249  eANSI = 1,
250 };
251 
252 enum class BimUnitsLength
253 {
254  eUndefined = 0,
255  eFeet = 1,
256  eInch = 2,
257  eM = 3,
258  eDM = 4,
259  eCM = 5,
260  eMM = 6,
261 };
262 
263 namespace FxBIM
264 {
266  {
267  public:
268  Standard( const OdString& name );
269 
270  const OdString& Name() const;
271  const BimStandards& Type() const;
272 
273  bool operator< ( const Standard& other ) const;
274 
275  static OdString ToString( BimStandards standard );
276  static BimStandards FromString( const OdString& standard );
277 
278  protected:
281  };
282 
285 
286  FXBIM_API double BIMHPSCALE( const OdDbDatabase* pDb );
287  FXBIM_API void SetBIMHPSCALE( OdDbDatabase* pDb, const double& value );
288 
289  namespace Units
290  {
292  };
293 
295  FXBIM_API void SetBIMUNITSLENGTH( OdDbDatabase* pDb, const int& value );
296 
299 
302 
305 
308 
311 
314 
317 
320 
323 }
324 
325 namespace FxBIM
326 {
328  FXBIM_API void SetBIMCALLOUTSONOFF( OdDbDatabase* pDb, const bool& value );
329 
332 }
333 
334 namespace FxBIM
335 {
336  enum class EFileType
337  {
338  eModelDrawing = 0x0, //Files in 'models' directory
339  eFlatshotDrawing = 0x1 //Files in 'drawings' directory
340  };
341 
342  FXBIM_API Error resolvePath( const OdDbDatabase* pDb, OdString& path, EFileType eFileType );
343 }
344 
345 namespace FxBIM
346 {
348  FXBIM_API QString GetAbsoluteFilePath( const QString& sPath, OdDbDatabase* pCurrentDb );
349 }
350 
351 #if !defined( FX_STATIC_BUILD )
353 {
354  void FXBIM_API WaitFinishLoading( const QString& strTag );
355 
356  class FXBIM_API CFxBIMTaskLoadDbRef : public FxThreadUtils::Task
357  {
359  QString m_strTag;
360 
361  CFxBIMTaskLoadDbRef( CFxBIMDatabaseReferencePtr& ptrDb, const QString& strTag );
362 
363  public:
365 
366  void Process() override;
367  void OnFinished() override;
368 
369  static void clearFinishedTasks();
370  static void abortUnfinishedTasks();
371  static void pushTask( const OdDbObjectId& idObj, const QString& strTag );
372  static QString GetLoadingTag( int count );
373  static bool IsLoadingFinishedForTag( const QString& strTag );
374  };
375 
376  class FXBIM_API CFxBIMTaskUnloadDb : public FxThreadUtils::Task
377  {
378  OdDbDatabasePtr m_ptrDb;
379 
380  public:
383 
384  void Process() override;
385  void OnFinished() override;
386 
387  static void clearFinishedTasks();
388  static void abortUnfinishedTasks();
389  };
390 }
391 #endif
std::shared_ptr< CFxBIMDbIterator > CFxBIMDbIteratorPtr
Definition: FxBIM.h:195
std::shared_ptr< CFxBIMDbIteratorRA > CFxBIMDbIteratorRAPtr
Definition: FxBIM.h:197
Error
Definition: FxBIM.h:50
@ eCVTViewUnset
@ eNullBmDatabase
@ eNullBmObjectId
@ eGeomIsNotGElement
@ eNullFamSymbol
@ eNullBmObject
@ eWrongRVTFormat
@ eDegenerateTopology
@ eDegenerateGeometry
@ eCVTInvalidConversionType
@ eGeomIsNotNode
@ eNullDbObjectId
@ eWrongIFCFormat
@ eNotFound
@ eNotThatKindOfClass
@ eNotImplemented
@ eCVTInvalidSource
@ eCVTInvalidParameter
@ eCVTInvalidDestinationFolder
@ eInvalidParameter
@ eCVTInvalidDestinationExists
BimUnitsLength
Definition: FxBIM.h:253
BimStandards
Definition: FxBIM.h:245
std::shared_ptr< CFxBIMIteratorRA > CFxBIMIteratorRAPtr
Definition: FxBIM.h:193
FXBIM_API OdString convert(const QString &qstr)
#define FXBIM_API
Definition: FxBIM.h:20
OdSmartPtr< CFxBIMDatabaseReference > CFxBIMDatabaseReferencePtr
Definition: FxBIM.h:90
fileType
Definition: FxBIM.h:78
std::shared_ptr< CFxBIMObject > CFxBIMObjectPtr
Definition: FxBIM.h:162
std::shared_ptr< CFxBIMIterator > CFxBIMIteratorPtr
Definition: FxBIM.h:191
#define OD_T(x)
short OdInt16
bool operator<(const OdString &s1, const OdString &s2)
Definition: OdString.h:1284
virtual void Start()=0
virtual bool Done()=0
virtual void Next()=0
virtual ~CFxBIMDbIterator()
Definition: FxBIM.h:227
virtual void SetPredicate(std::function< bool(OdDbObjectId) > p)=0
virtual OdDbObjectId Object()=0
virtual ~CFxBIMDbIteratorRA()
Definition: FxBIM.h:239
virtual size_t Count()=0
virtual OdDbObjectId Object(size_t index)=0
virtual void Start()=0
virtual ~CFxBIMIterator()
Definition: FxBIM.h:205
virtual bool Done()=0
virtual void Next()=0
virtual void SetPredicate(std::function< bool(CFxBIMObjectPtr) > p)=0
virtual CFxBIMObjectPtr Object()=0
virtual ~CFxBIMIteratorRA()
Definition: FxBIM.h:217
virtual CFxBIMObjectPtr Object(size_t index)=0
virtual size_t Count()=0
virtual ~CFxBIMObject()
OdString m_Name
Definition: FxBIM.h:279
Standard(const OdString &name)
const BimStandards & Type() const
static OdString ToString(BimStandards standard)
const OdString & Name() const
static BimStandards FromString(const OdString &standard)
static QString GetLoadingTag(int count)
static void pushTask(const OdDbObjectId &idObj, const QString &strTag)
static bool IsLoadingFinishedForTag(const QString &strTag)
CFxBIMTaskUnloadDb(OdDbDatabasePtr &ptrDb)
Definition: Int64.h:43
typedef void(APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture)
GLint GLenum GLsizei GLsizei GLint GLsizei const void * data
Definition: gles2_ext.h:110
GLuint index
Definition: gles2_ext.h:265
GLuint const GLchar * name
Definition: gles2_ext.h:265
GLsizei GLsizei * count
Definition: gles2_ext.h:276
GLuint GLsizei GLsizei GLint GLenum * type
Definition: gles2_ext.h:274
GLsizei const GLfloat * value
Definition: gles2_ext.h:302
FXBIM_API double Scale(BimUnitsLength dst, BimUnitsLength src)
Definition: FxBIM.h:137
FXBIM_API OdInt64 currentVersion()
FXBIM_API void SetBIMCURRENTDIMSTYLE(OdDbDatabase *pDb, const OdString &value)
FXBIM_API OdString BIMCALLOUTBLOCKELEVATION(const OdDbDatabase *pDb)
FXBIM_API void SetBIMCALLOUTSFILE(OdDbDatabase *pDb, const OdString &value)
FXBIM_API void SetBIMCALLOUTBLOCKSECTIONALT(OdDbDatabase *pDb, const OdString &value)
FXBIM_API OdString BIMCALLOUTSFILE(const OdDbDatabase *pDb)
constexpr OdInt16 kCurrenVersionMinor
Definition: FxBIM.h:152
FXBIM_API bool BIMCALLOUTSONOFF(const OdDbDatabase *pDb)
FXBIM_API Error resolvePath(const OdDbDatabase *pDb, OdString &path, EFileType eFileType)
FXBIM_API void SetBIMVPSCALE(OdDbDatabase *pDb, const OdString &value)
FXBIM_API OdString BIMCALLOUTBLOCKSECTION(const OdDbDatabase *pDb)
FXBIM_API void SetBIMCALLOUTBLOCKSECTION(OdDbDatabase *pDb, const OdString &value)
FXBIM_API void SetBIMCALLOUTBLOCKELEVATION(OdDbDatabase *pDb, const OdString &value)
FXBIM_API OdString GetAbsoluteFilePath(const OdString &sPath, OdDbDatabase *pCurrentDb)
constexpr OdInt16 kCurrenVersionRevision
Definition: FxBIM.h:153
FXBIM_API OdInt64 bimVersion(OdInt16 major, OdInt16 minor, OdInt16 revision)
FXBIM_API OdString BIMCALLOUTBLOCKPLAN(const OdDbDatabase *pDb)
FXBIM_API OdString BIMPROJECTPATH(const OdDbDatabase *pDb)
FXBIM_API void SetBIMUNITSLENGTH(OdDbDatabase *pDb, const int &value)
const OdString kBIMModuleName
Definition: FxBIM.h:138
std::shared_ptr< T > cast(CFxBIMObjectPtr pBase)
Definition: FxBIM.h:177
FXBIM_API int BIMUNITSLENGTH(const OdDbDatabase *pDb)
Version
Definition: FxBIM.h:141
@ kSP3
Definition: FxBIM.h:148
@ kSP2
Definition: FxBIM.h:147
@ kSP0
Definition: FxBIM.h:145
@ k2020
Definition: FxBIM.h:143
@ k2021
Definition: FxBIM.h:144
@ kSP1
Definition: FxBIM.h:146
@ k2019
Definition: FxBIM.h:142
FXBIM_API void SetBIMCALLOUTSONOFF(OdDbDatabase *pDb, const bool &value)
EFileType
Definition: FxBIM.h:337
FXBIM_API OdString BIMCURRENTDIMSTYLE(const OdDbDatabase *pDb)
FXBIM_API void SetBIMHPSCALE(OdDbDatabase *pDb, const double &value)
FXBIM_API void SetBIMPROJECTPATH(OdDbDatabase *pDb, const OdString &value)
FXBIM_API void SetBIMCALLOUTBLOCKPLAN(OdDbDatabase *pDb, const OdString &value)
FXBIM_API OdString BIMVPSCALE(const OdDbDatabase *pDb)
FXBIM_API void SetBIMSTANDARD(OdDbDatabase *pDb, const OdString &value)
FXBIM_API void SetBIMCLIPPINGBOXONOFF(OdDbDatabase *pDb, const bool &value)
FXBIM_API void SetBIMVIEWTITLEBLOCK(OdDbDatabase *pDb, const OdString &value)
FXBIM_API bool BIMCLIPPINGBOXONOFF(const OdDbDatabase *pDb)
FXBIM_API OdString BIMCALLOUTBLOCKSECTIONALT(const OdDbDatabase *pDb)
OdSmartPtr< T > cast(OdDbObjectId id, OdDb::OpenMode mode=OdDb::kForRead, bool openErased=false)
Definition: FxBIM.h:184
constexpr OdInt16 kCurrenVersionMajor
Definition: FxBIM.h:151
FXBIM_API OdString BIMSTANDARD(const OdDbDatabase *pDb)
FXBIM_API OdString BIMVIEWTITLEBLOCK(const OdDbDatabase *pDb)
FXBIM_API double BIMHPSCALE(const OdDbDatabase *pDb)
void FXBIM_API WaitFinishLoading(const QString &strTag)
OpenMode
Definition: DbObjectId.h:54
@ kForRead
Definition: DbObjectId.h:56
std::function< void(const OdString &viewName, OdInt64 idView) > fn_start_t
Definition: FxBIM.h:105
@ eConvertToIfc
Definition: FxBIM.h:102
@ eConvertFromRevit
Definition: FxBIM.h:100
@ eConvertFromIfc
Definition: FxBIM.h:101
@ eNone
Definition: FxBIM.h:99
std::function< void(int exitCode, int exitStatus) > fn_finish_t
Definition: FxBIM.h:107
static Conversion::Type FromString(const OdString &arg)
@ eFNone
Definition: FxBIM.h:123
std::function< void(const OdString &dwgPath, const OdString &originalPath, const OdString &viewName, OdInt64 idView, int flags) > fn_ready_t
Definition: FxBIM.h:106
std::shared_ptr< CFxBIMIPC > _ipc
Definition: FxBIM.h:133
std::function< bool() > fn_abort_t
Definition: FxBIM.h:108
static OdString ToString(const Conversion &c)
Conversion(fileType type, Data data, int flags)
std::function< void(const OdString &err) > fn_error_t
Definition: FxBIM.h:109