CFx SDK Documentation  2020SP3
FMCachedSeg2D.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 __FM_CACHEDSEG2D_H__
24 #define __FM_CACHEDSEG2D_H__
25 
27 
28 namespace FacetModeler
29 {
30 
32 //
33 //
34 //
35 //
36 //
37 //
38 
39 class FMGEOMETRY_API CachedSeg2D: public CommonSeg2DImpl
40 {
41 public:
42  // default constructor
44 
45  // constructor:
46  CachedSeg2D( const OdGePoint2d & ptA, const OdGePoint2d & ptB, double dBulge, const Attributes2D& rAttr );
47 
48  // constructor: 2 endpoints and a bulge value ( tan(a/4) )
49  CachedSeg2D( const OdGePoint2d & ptA, const OdGePoint2d & ptB, double dBulge=0.0 );
50 
51  // constructor: 2 endpoints and an intermediate point
52  CachedSeg2D( const OdGePoint2d & ptA, const OdGePoint2d & ptB, const OdGePoint2d & ptIntermediate );
53 
54  // slower copy constructor
55  CachedSeg2D( const IBulgeSeg2D & rAnySeg );
56 
57  // virtual ~CachedSeg2D();
58 
59 
60  // Fast copy operations (cache is copied too)
61  CachedSeg2D( const CachedSeg2D& rSeg );
62 
63  Result set( const CachedSeg2D& rSeg );
64 
65  inline CachedSeg2D & operator = ( const CachedSeg2D & rSeg )
66  { set( rSeg ); return *this; };
67 
68 
69  // type info: returns esicCachedSeg2D
70  virtual SegmentImplClass implClass() const;
71 
73  // const methods
74 
75  // returns reference to the starting point
76  virtual const OdGePoint2d & startPt() const;
77 
78  // returns reference to the ending point
79  virtual const OdGePoint2d & endPt () const;
80 
81  // returns bulge value
82  virtual double bulge () const;
83 
84 
86  // const methods
87 
88  // returns the type of this segment
89  virtual SegmentType type() const;
90 
91  // returns signed deviation from the line [start, end]
92  // the deviation has the same sign, as the bulge() value
93  virtual double deviation() const;
94 
95  // returns vDir = endPt - startPt
96  virtual void getDir ( OdGeVector2d & vDir ) const;
97 
98  // returns distance btw startPt and endPt
99  virtual double dirLength( ) const;
100 
101  // returns length of the segment
102  virtual double length ( ) const;
103 
104 
106  // Arcs and circles ( length>0 and bulge != 0 )
107 
108 
109  // returns arc center, if type()==estArc
110  virtual OdGePoint2d arcCenter() const;
111 
112  // returns arc radius, if type()==estArc
113  virtual double arcRadius( ) const;
114 
115  // returns arc radius and center point, if type()==estArc
116  virtual Result getCircleData( OdGePoint2d & ptCenter, double & dRadius ) const;
117 
118  // returns signed included angle of the arc segment
119  // The returned value belongs to range ( -2*Pi, 2*Pi )
120  virtual double arcAngle() const;
121 
122  // returns starting angle of the arc (direction from center to startPt )
123  // The returned value belongs to range [ 0, 2*Pi )
124  virtual double arcStartAngle() const;
125 
126  // returns arc center point, radius and angles if type()==estArc
127  virtual Result getArcData( OdGePoint2d & ptCenter, double & dRadius,
128  double & dStartAngle, double & dInclAngle ) const;
129 
130 
131 
133  // non-const methods
134 
135  using CommonSeg2DImpl::set;
136 
137  // Update ends and bulge
138  virtual Result set( const OdGePoint2d & ptA, const OdGePoint2d & ptB, double dBulge, const Attributes2D& rAttr );
139 
140  // Copy from another segment
141  virtual Result set( const IBulgeSeg2D& rSeg );
142 
143  // VC6 compatibility
144  virtual Result set( const OdGePoint2d & ptA, const OdGePoint2d & ptB, double dBulge=0.0 )
145  {
146  return CommonSeg2DImpl::set( ptA, ptB, dBulge );
147  }
148 
149  virtual Result set( const OdGePoint2d & ptA, const OdGePoint2d & ptB, const OdGePoint2d & ptIntermediate )
150  {
151  return CommonSeg2DImpl::set( ptA, ptB, ptIntermediate );
152  }
153 
154  virtual Result set( const OdGeLineSeg2d& geLine )
155  {
156  return CommonSeg2DImpl::set( geLine );
157  }
158 
159  virtual Result set( const OdGeCircArc2d& geArc )
160  {
161  return CommonSeg2DImpl::set( geArc );
162  }
163 
164  inline IBulgeSeg2D& operator = ( const IBulgeSeg2D& rSeg ) { set( rSeg ); return *this; };
165 
166  // Transforms the object using the matrix
167  virtual Result transformBy( const OdGeMatrix2d& mTrans );
168 
169  // inverts the segment (makes it going in opposite direction )
170  virtual Result reverse();
171 
172 
173 public:
174 
175  // Get attributes (including metadata)
176  virtual const Attributes2D& attributes() const;
177 
178  // Get attributes (including metadata) for update
180 
181 private:
182 
183  void _UpdateCache();
184 
185  inline const OdGePoint2d & _startPt() const { return m_ptStart; };
186  inline const OdGePoint2d & _endPt() const { return m_ptEnd; };
187  inline double _bulge() const { return m_dBulge; };
188 
189  inline SegmentType _type() const { return m_eType; };
190  inline double _length() const { return m_dLength; };
191  inline double _arcAngle() const { return m_dArcInclAngle; };
192  inline double _arcRadius() const { return m_dLength / ::fabs(m_dArcInclAngle); };
193  inline const OdGePoint2d & _arcCenter() const { return m_ptArcCenter; };
194 
195  double _arcStartAngle() const;
196 
197 private:
198 
200  // mandatory data:
201 
202  OdGePoint2d m_ptStart; // Starting point
203 
204  OdGePoint2d m_ptEnd; // Ending point
205 
206  double m_dBulge; // Bulge value = tan(angle/4)
207 
208  Attributes2D m_Attr; // Metadata value
209 
210 
212  // Cached data:
213 
214  // Type of the segment
215  SegmentType m_eType;
216 
217  // length of the segment
218  double m_dLength;
219 
220  // double m_dArcRadius; // = m_dLength / ::fabs(m_dInclAngle);
221  double m_dArcInclAngle;
222 
223  // Arc data: center, radius and included angle
224  OdGePoint2d m_ptArcCenter;
225 
226  // extents ?
227  //OdGeExtents2d m_Extents;
228 };
229 
230 
231 
232 }; // namespace AECContours
233 
234 
235 
236 #endif //__FM_CACHEDSEG2D_H__
FacetModeler::CachedSeg2D::bulge
virtual double bulge() const
FacetModeler::CommonSeg2DImpl
Definition: FMImpCommonSeg2D.h:43
FacetModeler::CachedSeg2D::set
virtual Result set(const OdGeLineSeg2d &geLine)
Definition: FMCachedSeg2D.h:154
FacetModeler::CachedSeg2D::dirLength
virtual double dirLength() const
FacetModeler::CachedSeg2D::set
virtual Result set(const OdGeCircArc2d &geArc)
Definition: FMCachedSeg2D.h:159
FacetModeler::CommonSeg2DImpl::set
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, double dBulge, const Attributes2D &rAttr)=0
FacetModeler
Definition: FMContour2D.h:35
FacetModeler::CachedSeg2D::arcAngle
virtual double arcAngle() const
FacetModeler::CachedSeg2D::CachedSeg2D
CachedSeg2D(const OdGePoint2d &ptA, const OdGePoint2d &ptB, double dBulge, const Attributes2D &rAttr)
FacetModeler::CachedSeg2D::arcStartAngle
virtual double arcStartAngle() const
FacetModeler::CachedSeg2D::deviation
virtual double deviation() const
OdGeLineSeg2d
Definition: GeLineSeg2d.h:42
FacetModeler::IBulgeSeg2D
Definition: FM_IBulgeSeg2D.h:50
FacetModeler::CachedSeg2D::type
virtual SegmentType type() const
FacetModeler::CachedSeg2D::arcRadius
virtual double arcRadius() const
FacetModeler::CachedSeg2D::startPt
virtual const OdGePoint2d & startPt() const
OdGeCircArc2d
Definition: GeCircArc2d.h:47
FacetModeler::CachedSeg2D::getArcData
virtual Result getArcData(OdGePoint2d &ptCenter, double &dRadius, double &dStartAngle, double &dInclAngle) const
FacetModeler::CachedSeg2D::implClass
virtual SegmentImplClass implClass() const
FacetModeler::CachedSeg2D::attributes
virtual const Attributes2D & attributes() const
FacetModeler::CachedSeg2D::reverse
virtual Result reverse()
FacetModeler::CachedSeg2D::set
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, const OdGePoint2d &ptIntermediate)
Definition: FMCachedSeg2D.h:149
FacetModeler::CachedSeg2D::transformBy
virtual Result transformBy(const OdGeMatrix2d &mTrans)
FacetModeler::CachedSeg2D::getDir
virtual void getDir(OdGeVector2d &vDir) const
FacetModeler::CachedSeg2D::CachedSeg2D
CachedSeg2D(const CachedSeg2D &rSeg)
FacetModeler::CachedSeg2D::set
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, double dBulge=0.0)
Definition: FMCachedSeg2D.h:144
FacetModeler::CachedSeg2D::CachedSeg2D
CachedSeg2D(const OdGePoint2d &ptA, const OdGePoint2d &ptB, double dBulge=0.0)
FacetModeler::SegmentImplClass
SegmentImplClass
DOM.
Definition: FMContoursBase.h:228
OdGeVector2d
Definition: GeVector2d.h:51
FacetModeler::Result
Result
Definition: FMContoursBase.h:44
FacetModeler::CachedSeg2D::attributes4U
virtual Attributes2D & attributes4U()
FacetModeler::CachedSeg2D::CachedSeg2D
CachedSeg2D(const OdGePoint2d &ptA, const OdGePoint2d &ptB, const OdGePoint2d &ptIntermediate)
FacetModeler::Attributes2D
Definition: FMContoursBaseImp.h:48
FacetModeler::SegmentType
SegmentType
Definition: FMContoursBase.h:158
FacetModeler::CachedSeg2D::arcCenter
virtual OdGePoint2d arcCenter() const
FacetModeler::CachedSeg2D::CachedSeg2D
CachedSeg2D(const IBulgeSeg2D &rAnySeg)
FacetModeler::CachedSeg2D::length
virtual double length() const
FacetModeler::CachedSeg2D::getCircleData
virtual Result getCircleData(OdGePoint2d &ptCenter, double &dRadius) const
FacetModeler::CachedSeg2D
Definition: FMCachedSeg2D.h:40
OdGeMatrix2d
Definition: GeMatrix2d.h:73
FacetModeler::CachedSeg2D::set
Result set(const CachedSeg2D &rSeg)
FacetModeler::CachedSeg2D::CachedSeg2D
CachedSeg2D()
FMImpCommonSeg2D.h
FacetModeler::CachedSeg2D::set
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, double dBulge, const Attributes2D &rAttr)
FacetModeler::CachedSeg2D::set
virtual Result set(const IBulgeSeg2D &rSeg)
FacetModeler::CachedSeg2D::endPt
virtual const OdGePoint2d & endPt() const
OdGePoint2d
Definition: GePoint2d.h:60