CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
FMImpSimpleContour2D.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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 Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 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"
30
31namespace FacetModeler
32{
33
35{
36public:
37
39
41
42
44// Internal data corresponding to a single vertex (a point, a bulge and some extra values).
45
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
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
129private:
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//
145public:
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
195
196};
197
198
199
200
201
202class SimpleContour2DImpl : public TContour2DImpl<SimpleContour2DImplData>
203{
204public:
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};
232
233
234#endif //__FMIMP_SIMPLE_CONTOUR2D_H__
#define FMGE_ASSERT(x)
unsigned int OdUInt32
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, double dBulge, const Attributes2D &rAttr)
virtual const Attributes2D & attributes() const
void set(const VertexData &rVData, const OdGePoint2d &rPt)
ImplSeg2D(const VertexData &rVData, const OdGePoint2d &rPt)
VertexData(const OdGePoint2d &rPt, double dBulge, const Attributes2D &rAttr)
VertexData(const OdGePoint2d &rPt, double dBulge=0.0)
void _setModifiedSegs(OdUInt32, OdUInt32=1)
Result _getSegment(OdUInt32 iIndex, ImplSeg2D &rSeg) const
void _resize(OdUInt32 iNewVertNum)
VertexData & _vertex(OdUInt32 iIndex)
const VertexData & _vertex(OdUInt32 iIndex) const
void _setModifiedVerts(OdUInt32, OdUInt32=1)
Result _insertVerticesAt(OdUInt32 iIndex, OdUInt32 iCount, const OdGePoint2d *paPoints, const double *paBulges=0, const Attributes2D *pAttrs=0)
Result _removeVertices(OdUInt32 iIndex, OdUInt32 iCount=1)
void _reserveVertices(OdUInt32 iReservedSize)
Result _normalizeIndex(OdUInt32 &iVertIndex) const
void _reset(OdUInt32 iVertexCount=0, bool bClosed=false)
virtual IContour2D * clone() const
bool empty() const
Definition: OdArray.h:1257
size_type size() const
Definition: OdArray.h:1247