DgnModel.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
18 
19 #include "DgnModelRef.h"
22 #include "DgnFileIO/ModelInfo.h"
23 
25 
26 struct PersistentElementRefList;
27 struct PersistentElementRefBlock;
28 
29 
30 //=======================================================================================
31 // @bsiclass Bentley Systems
32 //=======================================================================================
33 struct PersistentElementRefVec : bvector<PersistentElementRefP>
34 {
37 };
38 
39 //=======================================================================================
43 //=======================================================================================
45 {
46 private:
47  virtual void MakeClassAbstract() = 0;
48 public:
49 };
50 
51 //=======================================================================================
56 //=======================================================================================
57 class PersistentElementRefListIterator : public std::iterator<std::forward_iterator_tag, PersistentElementRefP const>
58 {
59 private:
60  PersistentElementRefBlock* m_currBlock;
61  UInt32 m_currIndex;
62  PersistentElementRefP m_currElement;
63 
64 public:
66  PersistentElementRefListIterator () {m_currBlock = NULL; m_currElement=NULL;}
67 
69  PersistentElementRefP const& GetCurrentElementRef () const {return m_currElement;}
70 
73 
74 public:
75 
78  bool operator==(PersistentElementRefListIterator const& rhs) const {return !(*this != rhs);}
79 
81  PersistentElementRefP const& operator* () const {return m_currElement;}
82 };
83 
84 //=======================================================================================
101 //=======================================================================================
103 {
104 private:
105  virtual void MakeClassAbstract() = 0;
106 public:
107 public:
108 
111 
112  DGNPLATFORM_EXPORT bool IsEmpty () const;
115  DGNPLATFORM_EXPORT DgnModelP GetDgnModelP() const;
116 };
117 
118 //========================================================================================
124 //=======================================================================================
126  {
127  virtual ~DgnModelAppData() {}
128 
130  struct Key : AppDataKey {};
131 
134  virtual void _OnCleanup (DgnModelR host) = 0;
135 
137  virtual void _OnFilled (DgnModelR host) {}
138 
141  virtual bool _OnEmpty (DgnModelR host) {return true;}
142 
144  virtual bool _OnEmptied (DgnModelR host) {return false;}
145 
148  virtual void _OnModelDelete (DgnModelR host) {}
149 
151  virtual void _OnModelUnDelete (DgnModelR host) {}
152 
158  virtual void _OnElementAdded (DgnModelR host, PersistentElementRef& elem, bool isGraphicsList) {;}
159 
163  virtual void _OnSaveModelProperties (DgnModelR host, ModelInfoCR original) {;}
164 
165 private:
166  virtual bool _Dummy1(void*) {return false;}
167  virtual bool _Dummy2(void*) {return false;}
168  virtual bool _Dummy3(void*) {return false;}
169  };
170 
171 //=======================================================================================
174 //=======================================================================================
175 struct ReferencedByArray : bvector<DgnAttachmentP>
176  {
177  };
178 
179 //=======================================================================================
181 //=======================================================================================
183  {
184  Default = 0, // Attempt to reproject, mark attachment Not Found (with appropriate reason) if unable to do so.
185  DoNotReproject = 1, // Don't attempt to reproject, mark attachment Not Found (with appropriate reason). This is the default for models opend using mdlModelRef_createWorking
186  AcceptUnprojected = 2, // Don't attempt to reproject, do not mark attachment Not Found. Use with caution because reference elements are not correctly located.
187  };
188 
189 //=======================================================================================
235 //=======================================================================================
237  {
238  DGNPLATFORM_EXPORT IDgnComponentDefinitionHandlerP GetDgnComponentDefinitionHandler();
239 private:
240  virtual void MakeClassAbstract() = 0;
241 public:
242 public:
254  DGNPLATFORM_EXPORT DgnModelStatus SetModelInfo (ModelInfoR modelInfo);
255 
257 
258 
265  DGNPLATFORM_EXPORT StatusInt FillSections (DgnModelSections sectionsToFill, DgnModelFillContextP fillContext=NULL);
266 
270  DGNPLATFORM_EXPORT void Empty (bool evenIfDirty=false, bool andFree=false);
271 
275  DGNPLATFORM_EXPORT DgnModelSections IsFilled (DgnModelSections sections) const;
276 
283  DGNPLATFORM_EXPORT UInt32 GetElementCount (DgnModelSections sections);
284 
285 
291  DGNPLATFORM_EXPORT FileLevelCacheR GetFileLevelCacheR ();
292 
298  DGNPLATFORM_EXPORT FileLevelCacheCR GetFileLevelCache () const;
299 
301  DGNPLATFORM_EXPORT bool IsDictionaryModel () const;
303 
305 
306 
317  DGNPLATFORM_EXPORT PersistentElementRefList* GetControlElementsP();
318 
332  DGNPLATFORM_EXPORT PersistentElementRefList* GetGraphicElementsP();
333 
336  DGNPLATFORM_EXPORT int AddRef();
337 
340  DGNPLATFORM_EXPORT int Release();
341 
342  //=======================================================================================
346  //=======================================================================================
347  struct ElementRefIterator : std::iterator<std::forward_iterator_tag, PersistentElementRefP const>
348  {
349  private:
350  enum IteratorState {ITERATING_DictionaryElements = 0, ITERATING_ControlElms = 1, ITERATING_GraphicElms = 2, ITERATING_HitEOF = 3};
351 
352  private:
354  DgnModelP m_model;
355  DgnModelSections m_firstSection;
356  IteratorState m_state;
357  public:
358  DGNPLATFORM_EXPORT ElementRefIterator& operator++();
359  DGNPLATFORM_EXPORT bool operator!=(ElementRefIterator const& rhs) const;
360  bool operator==(ElementRefIterator const& rhs) const {return !(*this != rhs);}
361 
364  };
365 
366  //=======================================================================================
370  //=======================================================================================
372  {
373  private:
374  friend struct DgnModel;
375  DgnModel const& m_model;
376  ElementsCollection (DgnModel const& c) : m_model(c) {}
377 
378  public:
381 
384 
385  }; // ElementsCollection
386 
399  DGNPLATFORM_EXPORT ElementsCollection GetElementsCollection () const;
400 
403  DGNPLATFORM_EXPORT PersistentElementRefP FindElementByID (ElementId id) const;
404 
406 
407 
409 
410 
412  DGNPLATFORM_EXPORT ModelId GetModelId () const;
413 
418  DGNPLATFORM_EXPORT ModelInfoCR GetModelInfo () const;
419 
421  DGNPLATFORM_EXPORT StatusInt SaveModelSettings ();
422 
424  DGNPLATFORM_EXPORT WCharCP GetModelName () const;
425 
427  DGNPLATFORM_EXPORT bool IsReadOnly () const;
428 
431  DGNPLATFORM_EXPORT DgnFileP GetDgnFileP () const;
432 
435  DGNPLATFORM_EXPORT StatusInt GetRange (ScanRangeR range);
436  DGNPLATFORM_EXPORT StatusInt GetRange (DRange3dR range);
437 
439 
441  DGNPLATFORM_EXPORT StatusInt AddAppData (DgnModelAppData::Key const& key, DgnModelAppData* appData);
446 
451  DGNPLATFORM_EXPORT StatusInt DropAppData (DgnModelAppData::Key const& key);
452 
456  DGNPLATFORM_EXPORT DgnModelAppData* FindAppData (DgnModelAppData::Key const& key) const;
458 
460 
461  DGNPLATFORM_EXPORT ReferencedByArrayCR GetReferencedBy ();
464 
466  DGNPLATFORM_EXPORT UInt32 GetControlElmStart ();
467 
469  DGNPLATFORM_EXPORT UInt32 GetGraphicElmStart ();
470 
472  DGNPLATFORM_EXPORT UpdateSequenceListP GetUpdateSequence ();
473 
475  DGNPLATFORM_EXPORT void SetUpdateSequence (UpdateSequenceListP list);
476 
477 }; // DgnModel
478 
480 
482 
484 
485 
An ElementRefP for an element that is in a DgnModel.
Definition: DgnModel.h:44
PersistentElementRefListIterator()
Construct a blank PersistentElementRefListIterator.
Definition: DgnModel.h:66
#define END_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:69
bool operator==(ElementRefIterator const &rhs) const
Definition: DgnModel.h:360
*//* Bentley Systems
Definition: DgnModelRef.h:60
Application-defined object that is stored with a DgnModel.
Definition: DgnModel.h:125
ElementRefIterator const_iterator
Definition: DgnModel.h:379
iterator begin()
Definition: stdcxx/bstdmap.h:178
Definition: ModelInfo.h:27
virtual bool _OnEmptied(DgnModelR host)
Override this method to be notified after host DgnModel has been emptied. Won't be called unless _OnE...
Definition: DgnModel.h:144
iterator end()
Definition: stdcxx/bstdmap.h:186
PersistentElementRefP const & GetCurrentElementRef() const
Get the current ElementRefP pointed to by this iterator.
Definition: DgnModel.h:69
Collection of all elements in a model.
Definition: DgnModel.h:371
virtual void _OnElementAdded(DgnModelR host, PersistentElementRef &elem, bool isGraphicsList)
Override this method to be notified when a (top-level) element is added to the host DgnModel...
Definition: DgnModel.h:158
#define DGNPLATFORM_EXPORT
Definition: DgnPlatform/ExportMacros.h:58
A DgnFile is an in-memory representation of a physical file, regardless of its format.
Definition: DgnFile.h:308
wchar_t const * WCharCP
Definition: Bentley.h:224
PersistentElementRefListIterator const_iterator
Definition: DgnModel.h:109
uint32_t UInt32
Definition: Bentley.r.h:128
#define NULL
Definition: Bentley.h:157
#define BEGIN_BENTLEY_NAMESPACE
Definition: Bentley.r.h:24
PersistentElementRefList - a list of Dgn Elements.
Definition: DgnModel.h:102
A unique Key to identify each subclass of DgnModelAppData.
Definition: DgnModel.h:130
A DgnModel represents a DgnModel in memory.
Definition: DgnModel.h:236
Iterate over the elements in a PersistentElementRefList.
Definition: DgnModel.h:57
struct DgnPlatform::FileLevelCache const & FileLevelCacheCR
Definition: DgnPlatform.h:268
#define CLRPUBLIC
Definition: DgnPlatform/ExportMacros.h:12
virtual void _OnModelUnDelete(DgnModelR host)
Override this method to be notified after the persistent MicroStation Model is undeleted.
Definition: DgnModel.h:151
BentleyStatus
Definition: Bentley.h:208
A DgnModelRef provides access to a model in a Bentley::DgnPlatform::DgnFile.
Definition: DgnModelRef.h:172
virtual bool _OnEmpty(DgnModelR host)
Override this method to be notified when host DgnModel is about to be emptied.
Definition: DgnModel.h:141
DgnModelSections
The element sections within a DgnModel.
Definition: BentleyDgn.h:16
struct DgnPlatform::DgnModelFillContext * DgnModelFillContextP
Definition: DgnPlatform.h:169
A DgnComponentDefinitionHandler is associated with a DgnModel to provide access to parameters and par...
Definition: DgnComponentHandlers.h:24
bool operator==(PersistentElementRefListIterator const &rhs) const
Definition: DgnModel.h:78
DgnModelStatus
Errors generated by accessing or attempting to modify a DgnModel.
Definition: DgnPlatformErrors.r.h:146
A unique (for this session) key to identify this AppData type.
Definition: DgnAppData.h:21
Interface that provides direct and efficient access to element data.
Definition: ElementRefBase.h:120
Int32 ModelId
Definition: DgnPlatformBaseType.r.h:84
struct DgnPlatform::ReferencedByArray const & ReferencedByArrayCR
Definition: DgnPlatform.h:435
#define BEGIN_BENTLEY_DGNPLATFORM_NAMESPACE
Definition: DgnPlatformBaseType.r.h:68
A FileLevelCache contains the level definitions for a file.
Definition: LevelCache.h:850
DVec3d operator*(Transform const &transform, DVec3d const &vector)
operator overload for multiplication of a transform and a vector li>The vector appears on the left as...
bool operator!=(const BentleyAllocator< _Ty > &, const BentleyAllocator< _Other > &)
Definition: BentleyAllocator.h:152
virtual void _OnSaveModelProperties(DgnModelR host, ModelInfoCR original)
Override this method to be notified when a model's properties are changed.
Definition: DgnModel.h:163
int StatusInt
Definition: Bentley.h:222
UInt64 ElementId
Definition: DgnPlatformBaseType.r.h:83
The scan range used for mdlScanCriteria.
Definition: DgnPlatformBaseType.r.h:92
A vector of DgnAttachments.
Definition: DgnModel.h:175
GeoAttachmentHandling
Specifies the way Geographic Reference Attachments are treated.
Definition: DgnModel.h:182
#define END_BENTLEY_NAMESPACE
Definition: Bentley.r.h:25
const_iterator iterator
only const iteration is possible
Definition: DgnModel.h:110
const_iterator iterator
only const iteration is possible
Definition: DgnModel.h:380
Iterator over the elements in a DgnModel.
Definition: DgnModel.h:347
virtual void _OnModelDelete(DgnModelR host)
Override this method to be notified before the persistent MicroStation Model is marked for delete...
Definition: DgnModel.h:148
virtual void _OnFilled(DgnModelR host)
Override this method to be notified after host DgnModel has been filled.
Definition: DgnModel.h:137
struct DgnPlatform::ModelInfo const & ModelInfoCR
Definition: DgnPlatform.h:400
A 3d low and high corner pair for range boxes.
Definition: drange3d.h:20
virtual ~DgnModelAppData()
Definition: DgnModel.h:127

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.