CFx SDK Documentation  2023 SP0
AECDbSpaceTools.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 #ifndef __AECDBSPACETOOLS_H__
25 #define __AECDBSPACETOOLS_H__
26 
27 #include "DbEntity/AECDbSpace.h"
28 #include "AECDbOpeningBase.h"
29 #include "Ge/GeMatrix2d.h"
30 
36 namespace AECSpaceRegen
37 {
38 
40  class AECARCHBASE_API BlockRefPath
41  {
42  class Data;
43  Data* m_pData;
44  public:
45  BlockRefPath( ) : m_pData(0) { }
46  explicit BlockRefPath( const std::vector<OdDbObjectId>& vecBlockRefs );
47  BlockRefPath( const BlockRefPath& rPath );
49 
50  BlockRefPath& operator = ( const BlockRefPath& rPath );
51  //BlockRefPath& operator += ( const OdDbObjectId& idLastRef );
52  //BlockRefPath& operator += ( const BlockRefPath& rPath );
53 
54  bool IsEmpty() const;
55  const std::vector< OdDbObjectId >& GetBlockRefs() const;
56  const OdGeMatrix3d& GetTransform() const;
57 
58  AECARCHBASE_API_STATIC static const BlockRefPath kNull;
59  };
60 
61 
63  inline bool operator == (const BlockRefPath& rA, const BlockRefPath& rB )
64  {
65  return &rA == &rB || rA.GetBlockRefs() == rB.GetBlockRefs();
66  }
67 
69  inline bool operator != (const BlockRefPath& rA, const BlockRefPath& rB )
70  {
71  return !( rA == rB );
72  }
73 
74 
75 
76 
78  class AECARCHBASE_API EntityReference
79  {
80  OdDbObjectId m_idTarget;
81  BlockRefPath m_Path;
82  public:
84  explicit EntityReference( const OdDbObjectId& idTarget ) : m_idTarget(idTarget) { }
85  EntityReference( const OdDbObjectId& idTarget, const BlockRefPath& rPath )
86  : m_idTarget(idTarget), m_Path( rPath ) { }
87 
89  {
90  m_idTarget = idTarget;
91  m_Path = rPath;
92  return *this;
93  }
94 
95  inline const OdDbObjectId& GetTarget() const { return m_idTarget; }
96  inline const BlockRefPath& GetPath() const { return m_Path; }
97 
98  AECARCHBASE_API_STATIC static const EntityReference kNull;
99  };
100 
102  inline bool operator == (const EntityReference& rA, const EntityReference& rB )
103  {
104  return rA.GetTarget() == rB.GetTarget() && rA.GetPath() == rB.GetPath();
105  }
106 
108  inline bool operator != (const EntityReference& rA, const EntityReference& rB )
109  {
110  return !( rA == rB );
111  }
112 
113 
114 
116  {
119  };
120 
122  class BoundaryVectorizer;
123 
125  class AECARCHBASE_API BoundingEnt
126  {
127  public:
128  BoundingEnt(): m_pImpl(0) { }
129  //explicit BoundingEnt( const OdDbObjectId& idEnt );
130  //BoundingEnt( const EntityReference& rEntRef );
131  //BoundingEnt& operator = (const OdDbObjectId& idEnt );
132  //BoundingEnt& operator = (const EntityReference& rEntRef );
133  BoundingEnt( const EntityReference& rEntRef, BoundaryVectorizer* pVect );
134 
135  // copying
136  BoundingEnt( const BoundingEnt& rBEnt );
137  BoundingEnt& operator = (const BoundingEnt& rBEnt);
138 
140 
142  {
143  ebtInvalid = 0,
148  ebtOther
149  };
150 
151  bool IsNull() const;
152 
154 
155  const EntityReference& GetEntRef() const;
156 
162 
163  AECARCHBASE_API_STATIC static const BoundingEnt kNull;
164 
165  class Impl;
166  private:
167  Impl* m_pImpl;
168  };
169 
171  inline bool operator == (const BoundingEnt& rA, const BoundingEnt& rB )
172  {
173  return &rA == &rB || rA.GetEntRef() == rB.GetEntRef();
174  }
175 
177  inline bool operator != (const BoundingEnt& rA, const BoundingEnt& rB )
178  {
179  return !( rA == rB );
180  }
181 
182 }
183 
184 typedef std::map<OdDbObjectId, AECDbSpacePtr> TBoundingEntityIdToBoundedSpacePtrMap;
185 
190 {
191 public:
193  {
194  return ( m_boundingEntsIds.find(idObj) != m_boundingEntsIds.end() );
195  }
196 
198  OdDbObjectId idBE,
199  FacetModeler::Segment2D& segOverlappedPart );
200 
202  {
203  OdIntPtr iBeIdx = seg.metadata();
204  const AECSpaceRegen::BoundingEnt be = m_boundingEnts[iBeIdx];
205 
206  return be;
207  }
208 
209 public:
212  std::vector< AECSpaceRegen::BoundingEnt > m_boundingEnts;
213  std::set<OdDbObjectId> m_boundingEntsIds;
214 };
215 
216 typedef std::vector<SpaceBoundary> SpaceBoundaryCollection;
217 
219 {
222 };
223 
224 typedef std::vector<AdjacentBoundaryChunk> AdjacentBoundaryChunks;
225 
231 class AECARCHBASE_API AECSpaceCalculator
232 {
233 public:
234  typedef void (AECSpaceCalculator::*RULES_FUNCTION)( const AECSpaceRegen::BoundingEnt &be, const bool isAdjacentToOtherSpace, FacetModeler::Segment2D& curSeg, AECDbSpacePtr& ptrSpace, AECDbSpacePtr& ptrAdjacentSpace );
235 
236  public:
241  const OdDbObjectId& idRootBlock,
243 
248 
252  void Reset();
253 
257  void Reset( const OdGeMatrix3d& mUCS,
258  const OdDbObjectId& idRootBlock,
260 
261  public:
267  const OdDbObjectId& idEntity );
268 
269  public:
279  bool FindBoundary( const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
280  FacetModeler::Profile2D& rBoundary ) const;
281 
282  bool FindInnerBoundary( const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
283  FacetModeler::Profile2D& rBoundary ) const;
284  bool FindOuterBoundary( const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
285  FacetModeler::Profile2D& rBoundary ) const;
286  bool FindCenterlinesBoundary( const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
287  FacetModeler::Profile2D& rBoundary ) const;
288 
290  //
291  bool ApplyRulesFuncToBaseBoundary( AECDbSpacePtr& ptrSpace, const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
293 
295  // Basic standard
296  bool FindGrossBoundaryBasic( AECDbSpacePtr& ptrSpace, const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
297  FacetModeler::Profile2D& rBoundary );
298 
299  void ApplyBasicGrossRules( const AECSpaceRegen::BoundingEnt &be, const bool isAdjacentToOtherSpace,
300  FacetModeler::Segment2D& curSeg, AECDbSpacePtr& ptrSpace, AECDbSpacePtr& ptrAdjacentSpace );
301 
303  // DIN277 standard
304  bool FindGrossBoundaryDIN277( AECDbSpacePtr& ptrSpace, const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
305  FacetModeler::Profile2D& rBoundary );
306  void ApplyDIN277GrossRules( const AECSpaceRegen::BoundingEnt &be, const bool isAdjacentToOtherSpace,
307  FacetModeler::Segment2D& curSeg, AECDbSpacePtr& ptrSpace, AECDbSpacePtr& ptrAdjacentSpace );
308 
310  // SIS standard
311  bool FindNetBoundarySIS(const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
312  FacetModeler::Profile2D& rBoundary);
313  bool FindUsableBoundarySIS(AECDbSpacePtr& ptrSpace, const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
314  FacetModeler::Profile2D& rBoundary);
315 
316  void ApplySISUsableRules( const AECSpaceRegen::BoundingEnt &be, const bool isAdjacentToOtherSpace,
317  FacetModeler::Segment2D& curSeg, AECDbSpacePtr& ptrSpace, AECDbSpacePtr& ptrAdjacentSpace );
319 
321  // BOMA standard
322  bool FindNetBoundaryBOMA(const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
323  FacetModeler::Profile2D& rBoundary);
324  bool FindUsableBoundaryBOMA(AECDbSpacePtr& ptrSpace, const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
325  FacetModeler::Profile2D& rBoundary);
326  bool FindGrossBoundaryBOMA(AECDbSpacePtr& ptrSpace, const OdGePoint2d& ptHitTest, double dGap, bool bIgnoreHoles,
327  FacetModeler::Profile2D& rBoundary);
328 
329  void ApplyBomaUsableRules( const AECSpaceRegen::BoundingEnt &be, const bool isAdjacentToOtherSpace,
330  FacetModeler::Segment2D& curSeg, AECDbSpacePtr& ptrSpace, AECDbSpacePtr& ptrAdjacentSpace );
331  void ApplyBomaGrossRules( const AECSpaceRegen::BoundingEnt &be, const bool isAdjacentToOtherSpace,
332  FacetModeler::Segment2D& curSeg, AECDbSpacePtr& ptrSpace, AECDbSpacePtr& ptrAdjacentSpace );
333 
341 
346  const OdDbObjectId& idStyle, AECDefs::SpaceGeometryType eType,
347  AECDefs::SpaceOffsetBoundaries eOffsets ) const;
348 
352  bool UpdateSpace( AECDbSpacePtr pSpace ) const;
353 
354  private:
358  AECSpaceCalculator& operator =( const AECSpaceCalculator& );
359 
360  bool FindBoundingEntitiesForOtherSpacesOnTheDrawing(AECDbSpacePtr& ptrSpace,
361  double dGap, bool bIgnoreHoles,
362  SpaceBoundaryCollection& rOtherSpacesBounds) const;
363  void FillSpaceBoundaryDataForSpace(AECDbSpacePtr& ptrSpace,
364  SpaceBoundary& rSB, OdDbObjectId idOwnerBlock, double dGap, bool bIgnoreHoles) const;
365 
366  bool ShiftCenterSegmentToInsideOfTheWall( FacetModeler::Segment2D& segCenterline, const AECSpaceRegen::BoundingEnt& be ) const;
367  bool ShiftCenterSegmentToOutsideOfTheWall( FacetModeler::Segment2D& segCenterline, const AECSpaceRegen::BoundingEnt& be ) const;
368  void MakeClosedLoopFromSegments(std::vector<FacetModeler::Segment2D>& vecSegments, FacetModeler::Contour2D& rResult) const;
369 
370  AECSpaceRegen::BoundingEnt GetSegmentBoundingEnt(const FacetModeler::Segment2D& seg);
371 
372  private:
373  // debug functions
374  void DebugDrawBEGeometry(const AECSpaceRegen::BoundingEnt be, OdUInt16 color = 0) const;
375  void DebugDrawWallComponents(const AECSpaceRegen::BoundingEnt be, OdUInt16 color = 1) const;
376  void DebugDrawBoundaryAndMetadata(const FacetModeler::Profile2D& rBoundary, OdUInt16 clrBoundary = 1, OdUInt16 clrEnt = 6) const;
377  void DebugDrawBoundaryAndMetadata(const std::vector<FacetModeler::Segment2D>& vecSegments, OdUInt16 clrBoundary = 1, OdUInt16 clrEnt = 6) const;
378 
379  void DebugDrawWallCenterLine(const AECSpaceRegen::BoundingEnt be, OdUInt16 color = 2) const;
380  void DebugDrawOpening(AECDbOpeningBasePtr ptrOpeningBase, OdUInt16 color = 2) const;
381 
382  void FindAdjacentBoundaryPartsForSegment(const FacetModeler::Segment2D& curSeg, SpaceBoundaryCollection& rOtherSpacesBounds, AdjacentBoundaryChunks& adjacentBoundary);
383  private:
384  // Implementation.
385  class AECImpSpaceCalculator* m_pImpl;
386 };
387 
390 std::set<OdIntPtr> GetBoundingEntsIdx(FacetModeler::Profile2D& rBoundary);
391 #endif // __AECDBSPACETOOLS_H__
double GetWallWidth(const AECSpaceRegen::BoundingEnt be)
std::set< OdIntPtr > GetBoundingEntsIdx(FacetModeler::Profile2D &rBoundary)
std::map< OdDbObjectId, AECDbSpacePtr > TBoundingEntityIdToBoundedSpacePtrMap
DOM namespace AECSpaceRegen.
OdGeMatrix3d GetUCSMatrix(OdDbDatabase *pDb)
std::vector< SpaceBoundary > SpaceBoundaryCollection
std::vector< AdjacentBoundaryChunk > AdjacentBoundaryChunks
unsigned int OdUInt32
unsigned short OdUInt16
ptrdiff_t OdIntPtr
AECSpaceCalculator(const OdGeMatrix3d &mUCS, const OdDbObjectId &idRootBlock, AECDefs::SpaceBoundaryFilter eFilter)
bool FindGrossBoundaryDIN277(AECDbSpacePtr &ptrSpace, const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary)
void ApplyBasicGrossRules(const AECSpaceRegen::BoundingEnt &be, const bool isAdjacentToOtherSpace, FacetModeler::Segment2D &curSeg, AECDbSpacePtr &ptrSpace, AECDbSpacePtr &ptrAdjacentSpace)
void ApplyOpeningsToNetUsable_SIS(FacetModeler::Profile2D &rBoundary)
void ApplyBomaUsableRules(const AECSpaceRegen::BoundingEnt &be, const bool isAdjacentToOtherSpace, FacetModeler::Segment2D &curSeg, AECDbSpacePtr &ptrSpace, AECDbSpacePtr &ptrAdjacentSpace)
bool FindUsableBoundarySIS(AECDbSpacePtr &ptrSpace, const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary)
bool FindNetBoundarySIS(const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary)
void ApplySISUsableRules(const AECSpaceRegen::BoundingEnt &be, const bool isAdjacentToOtherSpace, FacetModeler::Segment2D &curSeg, AECDbSpacePtr &ptrSpace, AECDbSpacePtr &ptrAdjacentSpace)
const AECSpaceRegen::BoundingEnt GetBoundingEnt(OdUInt32 iMetadata) const
bool FindGrossBoundaryBOMA(AECDbSpacePtr &ptrSpace, const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary)
bool UpdateSpace(AECDbSpacePtr pSpace) const
bool FindBoundary(const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary) const
bool FindInnerBoundary(const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary) const
bool ApplyRulesFuncToBaseBoundary(AECDbSpacePtr &ptrSpace, const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary, RULES_FUNCTION pRuleFunc, AECSpaceRegen::BoundingMode ebm=AECSpaceRegen::ebmWallCenterLines)
void Reset(const OdGeMatrix3d &mUCS, const OdDbObjectId &idRootBlock, AECDefs::SpaceBoundaryFilter eFilter)
bool FindUsableBoundaryBOMA(AECDbSpacePtr &ptrSpace, const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary)
bool FindOuterBoundary(const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary) const
bool FindNetBoundaryBOMA(const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary)
bool FindGrossBoundaryBasic(AECDbSpacePtr &ptrSpace, const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary)
void ApplyBomaGrossRules(const AECSpaceRegen::BoundingEnt &be, const bool isAdjacentToOtherSpace, FacetModeler::Segment2D &curSeg, AECDbSpacePtr &ptrSpace, AECDbSpacePtr &ptrAdjacentSpace)
AECDbSpacePtr CreateSpace(const FacetModeler::Profile2D &rBoundary, const OdDbObjectId &idStyle, AECDefs::SpaceGeometryType eType, AECDefs::SpaceOffsetBoundaries eOffsets) const
void ApplyDIN277GrossRules(const AECSpaceRegen::BoundingEnt &be, const bool isAdjacentToOtherSpace, FacetModeler::Segment2D &curSeg, AECDbSpacePtr &ptrSpace, AECDbSpacePtr &ptrAdjacentSpace)
bool FindCenterlinesBoundary(const OdGePoint2d &ptHitTest, double dGap, bool bIgnoreHoles, FacetModeler::Profile2D &rBoundary) const
void AppendToBoundarySet(const OdDbObjectId &idEntity)
BlockRefPath(const std::vector< OdDbObjectId > &vecBlockRefs)
BlockRefPath(const BlockRefPath &rPath)
const std::vector< OdDbObjectId > & GetBlockRefs() const
const OdGeMatrix3d & GetTransform() const
static AECARCHBASE_API_STATIC const BlockRefPath kNull
const FacetModeler::Profile2D & GetGeometry() const
BoundingEnt(const BoundingEnt &rBEnt)
static AECARCHBASE_API_STATIC const BoundingEnt kNull
BoundingEnt(const EntityReference &rEntRef, BoundaryVectorizer *pVect)
BoundaryType GetType() const
const EntityReference & GetEntRef() const
EntityReference & set(const OdDbObjectId &idTarget, const BlockRefPath &rPath=BlockRefPath::kNull)
const OdDbObjectId & GetTarget() const
const BlockRefPath & GetPath() const
static AECARCHBASE_API_STATIC const EntityReference kNull
EntityReference(const OdDbObjectId &idTarget, const BlockRefPath &rPath)
EntityReference(const OdDbObjectId &idTarget)
OdIntPtr metadata() const
bool GetBoundaryOverlappedWith(const FacetModeler::Segment2D &aBoundarySeg, OdDbObjectId idBE, FacetModeler::Segment2D &segOverlappedPart)
FacetModeler::Profile2D rBoundary
AECDbSpacePtr m_ptrSpace
std::set< OdDbObjectId > m_boundingEntsIds
AECSpaceRegen::BoundingEnt GetBEForSegment(const FacetModeler::Segment2D &seg)
std::vector< AECSpaceRegen::BoundingEnt > m_boundingEnts
bool HasBoundaryWithEntity(OdDbObjectId idObj)
typedef void(APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture)
bool operator==(const BlockRefPath &rA, const BlockRefPath &rB)
DOM.
bool operator!=(const BlockRefPath &rA, const BlockRefPath &rB)
DOM.
FacetModeler::Segment2D segChunk
AECDbSpacePtr ptrAdjacentSpace