CFx SDK Documentation  2020SP3
FMImpSimpleContour2D.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2015, 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-2015 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 #ifndef __FMIMP_SIMPLE_CONTOUR2D_H__
24 #define __FMIMP_SIMPLE_CONTOUR2D_H__
25 
26 #include "FMGeometryImpl.h"
28 #include "Contours/FM_IContour2D.h"
30 
31 namespace FacetModeler
32 {
33 
35 {
36 public:
37 
39 
41 
42 
44 // Internal data corresponding to a single vertex (a point, a bulge and some extra values).
45 
46  class VertexData
47  {
48  private:
49  // essential members
50  OdGePoint2d m_ptStart; // Start point of the segment
51  double m_dBulge; // Bulge value of the segment
52 
53  mutable Attributes2D m_Attr; //
54 
55  public:
56  VertexData() : m_dBulge(0) { }
57  VertexData(const OdGePoint2d & rPt, double dBulge = 0.0)
58  : m_ptStart(rPt), m_dBulge(dBulge) { }
59 
60  VertexData(const OdGePoint2d & rPt, double dBulge, const Attributes2D& rAttr )
61  : m_ptStart(rPt), m_dBulge(dBulge), m_Attr(rAttr) { }
62 
63  inline const OdGePoint2d & point() const { return m_ptStart; };
64  inline OdGePoint2d & point() { return m_ptStart; };
65 
66  inline const double & bulge() const { return m_dBulge; };
67  inline double & bulge() { return m_dBulge; };
68 
69  inline Attributes2D& attributes() const { return m_Attr; };
70  };
71 
72 
74 // ImplSeg2D class is used internally in implementation of Contour methods
75 
76  class ImplSeg2D: public CommonSeg2DImpl
77  {
78  public:
79  ImplSeg2D( ) : m_pVertex(0), m_pEndPt(0) { };
80 
81  ImplSeg2D( const VertexData & rVData, const OdGePoint2d & rPt )
82  : m_pVertex(&rVData), m_pEndPt( &rPt ) { };
83 
84  void set( const VertexData & rVData, const OdGePoint2d & rPt )
85  { m_pVertex = &rVData; m_pEndPt = &rPt; };
86 
87  // ToDo: another constructors...
88 
89 
91  // fast inline methods:
92 
93  inline const OdGePoint2d & _startPt() const { return m_pVertex->point(); };
94  inline double _bulge() const { return m_pVertex->bulge(); };
95  inline const OdGePoint2d & _endPt() const { return *m_pEndPt; };
96  inline Attributes2D& _attr() const { return m_pVertex->attributes(); };
97 
98 
100  // Implementation of methods not implemented in CommonSeg2DImpl
101 
102  virtual const OdGePoint2d & startPt() const { return _startPt(); };
103 
104  virtual const OdGePoint2d & endPt () const { return _endPt(); };
105 
106  virtual double bulge () const { return _bulge(); };
107 
108  // Update ends and bulge
109  virtual Result set( const OdGePoint2d & ptA, const OdGePoint2d & ptB, double dBulge, const Attributes2D& rAttr );
110 
111 
112  virtual const Attributes2D& attributes() const { return _attr(); }
113  virtual Attributes2D& attributes4U() { return _attr(); }
114 
116  // CommonSeg2DImpl overrides ( a faster implementation of some methods )
117 
118  // To Do ...
119 
120  private:
121  const VertexData * m_pVertex;
122  const OdGePoint2d * m_pEndPt;
123  };
124 
125 
127 //
128 // Contour data
129 private:
130 
131  // Array of vertex data (points, bulges etc.)
132  OdArray<VertexData> m_vecVertices;
133 
134  // If m_bClosed==true, the contour is closed and the last segment is
135  // [ m_vecVertices.back().point(), m_vecVertices.front().point(), m_vecVertices.back().bulge() ]
136  // Otherwise the last bulge value is ignored and the last point
137  // of the contour is m_vecVertices.back().point()
138  bool m_bClosed;
139 
140 
142 //
143 // methods used by TContour2DImpl
144 //
145 public:
146  inline ContourImplClass _implClass() const { return ecicSimple; };
147 
148  inline bool _closed() const { return m_bClosed; };
149 
150  inline bool _empty() const { return m_vecVertices.empty(); };
151 
152  inline OdUInt32 _numVerts() const { return m_vecVertices.size(); };
153 
154  inline OdUInt32 _numSegments() const { return m_vecVertices.empty() ? 0 : ( m_vecVertices.size() - !m_bClosed ); };
155 
156  Result _getSegment( OdUInt32 iIndex, ImplSeg2D & rSeg ) const;
157 
158  Result _normalizeIndex( OdUInt32 & iVertIndex ) const;
159 
160 
161  inline const VertexData& _vertex( OdUInt32 iIndex ) const
162  {
163  FMGE_ASSERT( iIndex < _numVerts() );
164  return m_vecVertices[iIndex];
165  };
166 
168  // Non-const methods
169 
170  inline VertexData& _vertex( OdUInt32 iIndex )
171  {
172  FMGE_ASSERT( iIndex < _numVerts() );
173  return m_vecVertices[iIndex];
174  };
175 
176 
177  void _reset( OdUInt32 iVertexCount = 0, bool bClosed = false );
178 
179  void _resize( OdUInt32 iNewVertNum );
180 
181  void _reserveVertices( OdUInt32 iReservedSize );
182 
183  inline void _setClosed( bool bClosed ) { m_bClosed = bClosed; };
184 
185  // these methods should not be empty, if some data is cached
186  inline void _setModifiedAll() { };
187  inline void _setModifiedSegs ( OdUInt32 /*iFirst*/, OdUInt32 /*iCount*/ = 1 ) { };
188  inline void _setModifiedVerts( OdUInt32 /*iFirst*/, OdUInt32 /*iCount*/ = 1 ) { };
189 
190 
192  const OdGePoint2d * paPoints, const double * paBulges = 0, const Attributes2D* pAttrs = 0);
193 
194  Result _removeVertices( OdUInt32 iIndex, OdUInt32 iCount = 1 );
195 
196 };
197 
198 
199 
200 
201 
202 class SimpleContour2DImpl : public TContour2DImpl<SimpleContour2DImplData>
203 {
204 public:
206 
207  // Implement some IContour2D methods, not implemented in TContour2DImpl
208  // or overload with better implementation
209 
210 
211  // virtual void set( const IContour2D & rSrcCont );
212 
213  virtual IContour2D * clone( ) const;
214 
215  /*
216  virtual Result transformBy(const OdGeMatrix2d& geMatrix );
217 
218  virtual void reverse();
219 
220  virtual void deleteCoincident( const OdGeTol & gTol = FMGeGbl::gTol );
221 
222  virtual void mergeSegments( bool bMergeArcsToo = true, const OdGeTol & gTol = FMGeGbl::gTol );
223 
224  virtual Result explodeTo( IContour2D & rDestCont, double dDeviation = 0.5, OdUInt16 iFacetMaximum = 128, OdUInt16 iMinPerCircle = 8 ) const;
225 
226  virtual OdUInt32 createVertexAt( double dParam, const OdGeTol & gTol = FMGeGbl::gTol );
227  */
228 };
229 
230 
231 }; // namespace AECContours
232 
233 
234 #endif //__FMIMP_SIMPLE_CONTOUR2D_H__
FacetModeler::SimpleContour2DImplData::_normalizeIndex
Result _normalizeIndex(OdUInt32 &iVertIndex) const
FacetModeler::SimpleContour2DImplData::_empty
bool _empty() const
Definition: FMImpSimpleContour2D.h:150
FacetModeler::SimpleContour2DImplData::ImplSeg2D::_endPt
const OdGePoint2d & _endPt() const
Definition: FMImpSimpleContour2D.h:95
FacetModeler::SimpleContour2DImpl
Definition: FMImpSimpleContour2D.h:203
FacetModeler::SimpleContour2DImplData
Definition: FMImpSimpleContour2D.h:35
FacetModeler::SimpleContour2DImplData::_insertVerticesAt
Result _insertVerticesAt(OdUInt32 iIndex, OdUInt32 iCount, const OdGePoint2d *paPoints, const double *paBulges=0, const Attributes2D *pAttrs=0)
FacetModeler::SimpleContour2DImplData::ImplSeg2D::set
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, double dBulge, const Attributes2D &rAttr)
FacetModeler::CommonSeg2DImpl
Definition: FMImpCommonSeg2D.h:43
FacetModeler::SimpleContour2DImplData::_reserveVertices
void _reserveVertices(OdUInt32 iReservedSize)
FacetModeler::SimpleContour2DImplData::SimpleContour2DImplData
SimpleContour2DImplData()
FacetModeler
Definition: FMContour2D.h:35
FacetModeler::SimpleContour2DImplData::ImplSeg2D::attributes4U
virtual Attributes2D & attributes4U()
Definition: FMImpSimpleContour2D.h:113
FacetModeler::SimpleContour2DImpl::clone
virtual IContour2D * clone() const
FacetModeler::SimpleContour2DImplData::VertexData::point
const OdGePoint2d & point() const
Definition: FMImpSimpleContour2D.h:63
FacetModeler::SimpleContour2DImplData::ImplSeg2D::_startPt
const OdGePoint2d & _startPt() const
Definition: FMImpSimpleContour2D.h:93
FacetModeler::SimpleContour2DImplData::_reset
void _reset(OdUInt32 iVertexCount=0, bool bClosed=false)
FacetModeler::SimpleContour2DImplData::VertexData::VertexData
VertexData()
Definition: FMImpSimpleContour2D.h:56
FacetModeler::SimpleContour2DImplData::_numVerts
OdUInt32 _numVerts() const
Definition: FMImpSimpleContour2D.h:152
FacetModeler::SimpleContour2DImplData::ImplSeg2D::ImplSeg2D
ImplSeg2D()
Definition: FMImpSimpleContour2D.h:79
OdArray
Definition: OdArray.h:591
FacetModeler::TContour2DImpl
Definition: FMImpTContour2D.h:70
FacetModeler::SimpleContour2DImplData::ImplSeg2D::_bulge
double _bulge() const
Definition: FMImpSimpleContour2D.h:94
FacetModeler::SimpleContour2DImplData::_implClass
ContourImplClass _implClass() const
Definition: FMImpSimpleContour2D.h:146
FacetModeler::SimpleContour2DImplData::VertexData::bulge
const double & bulge() const
Definition: FMImpSimpleContour2D.h:66
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
FacetModeler::SimpleContour2DImplData::_removeVertices
Result _removeVertices(OdUInt32 iIndex, OdUInt32 iCount=1)
FacetModeler::SimpleContour2DImplData::ImplSeg2D::ImplSeg2D
ImplSeg2D(const VertexData &rVData, const OdGePoint2d &rPt)
Definition: FMImpSimpleContour2D.h:81
FacetModeler::SimpleContour2DImplData::_numSegments
OdUInt32 _numSegments() const
Definition: FMImpSimpleContour2D.h:154
FacetModeler::ecicSimple
@ ecicSimple
Definition: FMContoursBase.h:221
FacetModeler::SimpleContour2DImpl::SimpleContour2DImpl
SimpleContour2DImpl()
Definition: FMImpSimpleContour2D.h:205
FacetModeler::SimpleContour2DImplData::_setModifiedVerts
void _setModifiedVerts(OdUInt32, OdUInt32=1)
Definition: FMImpSimpleContour2D.h:188
FacetModeler::SimpleContour2DImplData::~SimpleContour2DImplData
virtual ~SimpleContour2DImplData()
FacetModeler::IContour2D
Definition: FM_IContour2D.h:38
FacetModeler::SimpleContour2DImplData::_resize
void _resize(OdUInt32 iNewVertNum)
OdArray::size
size_type size() const
Definition: OdArray.h:893
FacetModeler::SimpleContour2DImplData::ImplSeg2D::attributes
virtual const Attributes2D & attributes() const
Definition: FMImpSimpleContour2D.h:112
FMGE_ASSERT
#define FMGE_ASSERT(x)
Definition: FMGeometryDebug.h:125
FacetModeler::SimpleContour2DImplData::_vertex
const VertexData & _vertex(OdUInt32 iIndex) const
Definition: FMImpSimpleContour2D.h:161
FacetModeler::SimpleContour2DImplData::ImplSeg2D
Definition: FMImpSimpleContour2D.h:77
FacetModeler::SimpleContour2DImplData::_vertex
VertexData & _vertex(OdUInt32 iIndex)
Definition: FMImpSimpleContour2D.h:170
FacetModeler::SimpleContour2DImplData::VertexData::bulge
double & bulge()
Definition: FMImpSimpleContour2D.h:67
FacetModeler::SimpleContour2DImplData::_getSegment
Result _getSegment(OdUInt32 iIndex, ImplSeg2D &rSeg) const
FacetModeler::SimpleContour2DImplData::_setClosed
void _setClosed(bool bClosed)
Definition: FMImpSimpleContour2D.h:183
FM_IContour2D.h
FMImpTContour2D.h
FacetModeler::Result
Result
Definition: FMContoursBase.h:44
FacetModeler::Attributes2D
Definition: FMContoursBaseImp.h:48
FacetModeler::SimpleContour2DImplData::ImplSeg2D::_attr
Attributes2D & _attr() const
Definition: FMImpSimpleContour2D.h:96
FacetModeler::SimpleContour2DImplData::ImplSeg2D::startPt
virtual const OdGePoint2d & startPt() const
Definition: FMImpSimpleContour2D.h:102
FacetModeler::SimpleContour2DImplData::_setModifiedSegs
void _setModifiedSegs(OdUInt32, OdUInt32=1)
Definition: FMImpSimpleContour2D.h:187
FacetModeler::ContourImplClass
ContourImplClass
DOM.
Definition: FMContoursBase.h:219
FacetModeler::SimpleContour2DImplData::_closed
bool _closed() const
Definition: FMImpSimpleContour2D.h:148
FacetModeler::SimpleContour2DImplData::VertexData::VertexData
VertexData(const OdGePoint2d &rPt, double dBulge=0.0)
Definition: FMImpSimpleContour2D.h:57
FacetModeler::SimpleContour2DImplData::VertexData::attributes
Attributes2D & attributes() const
Definition: FMImpSimpleContour2D.h:69
FacetModeler::SimpleContour2DImplData::VertexData
Definition: FMImpSimpleContour2D.h:47
FacetModeler::SimpleContour2DImplData::VertexData::VertexData
VertexData(const OdGePoint2d &rPt, double dBulge, const Attributes2D &rAttr)
Definition: FMImpSimpleContour2D.h:60
FacetModeler::SimpleContour2DImplData::ImplSeg2D::bulge
virtual double bulge() const
Definition: FMImpSimpleContour2D.h:106
FacetModeler::SimpleContour2DImplData::VertexData::point
OdGePoint2d & point()
Definition: FMImpSimpleContour2D.h:64
FacetModeler::SimpleContour2DImplData::ImplSeg2D::set
void set(const VertexData &rVData, const OdGePoint2d &rPt)
Definition: FMImpSimpleContour2D.h:84
FacetModeler::SimpleContour2DImplData::_setModifiedAll
void _setModifiedAll()
Definition: FMImpSimpleContour2D.h:186
FacetModeler::SimpleContour2DImplData::ImplSeg2D::endPt
virtual const OdGePoint2d & endPt() const
Definition: FMImpSimpleContour2D.h:104
FMImpCommonSeg2D.h
OdArray::empty
bool empty() const
Definition: OdArray.h:901
FMGeometryImpl.h
OdGePoint2d
Definition: GePoint2d.h:60