CFx SDK Documentation  2020SP3
FM_IBulgeSeg2D.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_IBULGESEG2D_H__
24 #define __FM_IBULGESEG2D_H__
25 
26 #include "FMGeometry.h"
28 
29 #include "Ge/GePoint2d.h"
30 #include "Ge/GeVector2d.h"
31 
32 class OdGeExtents2d;
33 class OdGeMatrix2d;
34 class OdGeLineSeg2d;
35 class OdGeCircArc2d;
36 
37 
38 namespace FacetModeler
39 {
40 
41 
43 // IBulgeSeg2D is a convex 2-D curve given by 2 points and a bulge value
44 // If the 2 points coincide, the segment has estCoincident type
45 // Otherwise, if bulge==0, the segment is a straight line segment
46 // otherwise it is a circular arc, and bulge=tan(Angle/4)
47 //
48 
49 class FMGEOMETRY_API IBulgeSeg2D
50 {
51 public:
52  virtual ~IBulgeSeg2D() { };
53 
54  // Create a segment of given class (esicBulgeSeg2D or esicCachedSeg2D ) and copy pSrcSeg to it
55  static IBulgeSeg2D * create( SegmentImplClass eClass, const IBulgeSeg2D * pSrcSeg = 0 );
56 
57  // returns implementation class information
58  virtual SegmentImplClass implClass() const = 0;
59 
61  // const methods
62 
63  // returns reference to the starting point
64  virtual const OdGePoint2d & startPt() const = 0;
65 
66  // returns reference to the ending point
67  virtual const OdGePoint2d & endPt () const = 0;
68 
69  // returns bulge value
70  virtual double bulge () const = 0;
71 
72 
74  // const methods
75 
76  // returns the type of this segment
77  virtual SegmentType type() const = 0;
78 
79  // returns signed deviation from the line [start, end]
80  // the deviation has the same sign, as the bulge() value
81  virtual double deviation() const = 0;
82 
83 
84  // returns vDir = endPt - startPt
85  virtual void getDir ( OdGeVector2d & vDir ) const = 0;
86 
87  // returns distance btw startPt and endPt
88  virtual double dirLength( ) const = 0;
89 
90  // returns length of the segment
91  virtual double length ( ) const = 0;
92 
93 
94 
95  // Returns OdGeLineSeg2d corresponding to this segment, if type()!=estArc
96  virtual Result getLineSeg ( OdGeLineSeg2d& geLine ) const = 0;
97 
98  // Returns OdGeCircArc2d corresponding to this segment, if type()==estArc
99  virtual Result getArcSeg ( OdGeCircArc2d& geArc ) const = 0;
100 
101 
102 
103  // returns point at the parameter [ 0, 1 ]
104  virtual Result getPoint ( double dParam, OdGePoint2d & ptPoint ) const = 0;
105 
106  // returns tangent vector at the parameter [ 0, 1 ]
107  virtual Result getTangent( double dParam, OdGeVector2d& vTangent ) const = 0;
108 
109 
110  // Adds extents of this segment (extended by dTol) to the given extents.
111  virtual void addExtents( OdGeExtents2d& rExtents, double dTol = 0.0 ) const = 0;
112 
113 
114  // returns true, if the point lies on the segment
115  // *dParam stores the parameter of the point
116  virtual bool isOn( const OdGePoint2d & ptTest, double * pdParam = 0,
117  const OdGeTol & gTol = FMGeGbl::gTol ) const = 0;
118 
119 
120  // returns parameter of a point on the curve, which is closest to the ptTest
121  virtual double nearestParam( const OdGePoint2d & ptTest, OdGePoint2d * ptNearest = 0 ) const = 0;
122 
123 
124  // returns signed area of a contour bounded by this segment and 2 lines,
125  // connecting the ptOrigin and ends of this segment.
126  virtual double integrate( const OdGePoint2d & ptOrigin = OdGePoint2d::kOrigin ) const = 0;
127 
128 
129  // returns subsegment given by 2 parameters
130  // Note: if (dStartParam > dEndParam) the rSubSeg will have opposite direction
131  virtual Result getSubSegment(double dStartParam, double dEndParam, IBulgeSeg2D & rSubSeg ) const = 0;
132 
133 
134  // returns parallel segment.
135  // dNormalOffset - signed offset along normal vector at each point of original segment
136  // returns error, if source segment is coincident or the offset is too big to get
137  // valid result
138  virtual Result getParallelSegment( double dNormalOffset, IBulgeSeg2D & rParSeg ) const = 0;
139 
140  // The method returns number of different intersection points of
141  // the segment (including end with minimal Y) with a ray, starting at ptTest and
142  // going in the X direction.
143  // *pbOnSegment is set to true, if the test point lies on the segment.
144  virtual OdUInt32 intersectXRay( const OdGePoint2d& ptTest, bool * pbOnSegment = 0,
145  const OdGeTol & gTol = FMGeGbl::gTol ) const = 0;
146 
147 
148  // Returns number of intersections (0, 1 or 2) and intersection points.
149  // ToDo: comments on endpoints
150  virtual OdUInt32 intersect( const IBulgeSeg2D & rSegB,
151  OdGePoint2d * pPt1, OdGePoint2d * pPt2 = 0,
152  const OdGeTol & gTol = FMGeGbl::gTol ) const = 0;
153 
154  // Returns number of intersections (0, 1 or 2) and Intersection objects.
155  // ToDo: comments on endpoints
156  virtual OdUInt32 intersect( const IBulgeSeg2D & rSegB,
157  Intersection * pInt1 = 0, Intersection * pInt2 = 0,
158  const OdGeTol & gTol = FMGeGbl::gTol ) const = 0;
159 
160  // Intersects this segment with an infinite line
161  // Returns number of intersections
163  const OdGePoint2d& ptLineOrigin, const OdGeVector2d& vLineDir,
164  Intersection * pInt1 = 0, Intersection * pInt2 = 0,
165  const OdGeTol & gTol = FMGeGbl::gTol ) const = 0;
166 
167  // This method is used internally in intersect, but it can be used separately
168  // to perform a fast check of multiple points.
169  // ppInt must be a null-terminated array of pointers to Intersection.
170  // The function fills dParamA fields and updates eType field
171  // Returns number of points, lying on this segment
172  virtual OdUInt32 areOn( Intersection ** ppInt, const OdGeTol & gTol = FMGeGbl::gTol ) const = 0;
173 
175  // Arcs and circles ( length>0 and bulge != 0 )
176 
177 
178  // returns arc center, if type()==estArc
179  virtual OdGePoint2d arcCenter() const = 0;
180 
181  // returns arc radius, if type()==estArc
182  virtual double arcRadius( ) const = 0;
183 
184  // returns arc radius and center point, if type()==estArc
185  virtual Result getCircleData( OdGePoint2d & ptCenter, double & dRadius ) const = 0;
186 
187  // returns signed included angle of the arc segment
188  // The returned value belongs to range ( -2*Pi, 2*Pi )
189  virtual double arcAngle() const = 0;
190 
191  // returns starting angle of the arc (direction from center to startPt )
192  // The returned value belongs to range [ 0, 2*Pi )
193  virtual double arcStartAngle() const = 0;
194 
195  // returns arc center point, radius and angles if type()==estArc
196  virtual Result getArcData( OdGePoint2d & ptCenter, double & dRadius,
197  double & dStartAngle, double & dInclAngle ) const = 0;
198 
199 
200 
202  // non-const methods
203 
204  // Update all
205  virtual Result set( const OdGePoint2d & ptA, const OdGePoint2d & ptB, double dBulge, const Attributes2D& rAttr ) = 0;
206 
207  // Update ends and bulge, reset attributes
208  virtual Result set( const OdGePoint2d & ptA, const OdGePoint2d & ptB, double dBulge=0.0 ) = 0;
209 
210  // Update ends and calculate bulge using the intermediate point
211  // (some point on the curve between ptA and ptB )
212  virtual Result set( const OdGePoint2d & ptA, const OdGePoint2d & ptB, const OdGePoint2d & ptIntermediate ) = 0;
213 
214  // Copy from GeLineSeg2d and reset metadata.
215  virtual Result set( const OdGeLineSeg2d& geLine ) = 0;
216 
217  // Copy from GeCircArc2d and reset metadata.
218  virtual Result set( const OdGeCircArc2d& geArc ) = 0;
219 
220 
221  // Copy from another segment with metadata
222  virtual Result set( const IBulgeSeg2D& rSeg ) = 0;
223 
224  inline IBulgeSeg2D& operator = ( const IBulgeSeg2D& rSeg ) { set( rSeg ); return *this; };
225 
226  // Transforms the object using the matrix
227  virtual Result transformBy( const OdGeMatrix2d& mTrans ) = 0;
228 
229  // inverts the segment (makes it going in opposite direction )
230  virtual Result reverse() = 0;
231 
232 
234  // Metadata access
235  // Contours and segments can hold some additional information: metadata.
236 
237  // Get attributes (including metadata)
238  virtual const Attributes2D& attributes() const = 0;
239 
240  // Get attributes (including metadata) for update
241  virtual Attributes2D& attributes4U() = 0;
242 
243  // Set attributes (including metadata)
244  inline void setAttributes( const Attributes2D& rNewAttr ) { attributes4U() = rNewAttr; }
245 
246  // Get metadata. Default value : 0
247  inline OdIntPtr metadata () const { return attributes().metadata(); }
248 
249  // Set metadata.
250  inline void setMetadata (OdIntPtr uNewData) { attributes4U().metadata() = uNewData; }
251 
252 };
253 
254 
255 }; // namespace AECContours
256 
257 
258 
259 #endif //__FM_IBULGESEG2D_H__
FacetModeler::FMGeGbl::gTol
static FMGEOMETRY_API_STATIC OdGeTol gTol
Definition: FMGeometry.h:156
FacetModeler::IBulgeSeg2D::set
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, double dBulge=0.0)=0
FacetModeler::IBulgeSeg2D::bulge
virtual double bulge() const =0
GeVector2d.h
FacetModeler::IBulgeSeg2D::transformBy
virtual Result transformBy(const OdGeMatrix2d &mTrans)=0
FacetModeler::IBulgeSeg2D::getArcSeg
virtual Result getArcSeg(OdGeCircArc2d &geArc) const =0
FacetModeler::IBulgeSeg2D::intersectLine
virtual OdUInt32 intersectLine(const OdGePoint2d &ptLineOrigin, const OdGeVector2d &vLineDir, Intersection *pInt1=0, Intersection *pInt2=0, const OdGeTol &gTol=FMGeGbl::gTol) const =0
FacetModeler::IBulgeSeg2D::getDir
virtual void getDir(OdGeVector2d &vDir) const =0
FacetModeler::IBulgeSeg2D::dirLength
virtual double dirLength() const =0
FacetModeler::IBulgeSeg2D::implClass
virtual SegmentImplClass implClass() const =0
FacetModeler
Definition: FMContour2D.h:35
FacetModeler::IBulgeSeg2D::arcRadius
virtual double arcRadius() const =0
FacetModeler::IBulgeSeg2D::intersectXRay
virtual OdUInt32 intersectXRay(const OdGePoint2d &ptTest, bool *pbOnSegment=0, const OdGeTol &gTol=FMGeGbl::gTol) const =0
FacetModeler::IBulgeSeg2D::getTangent
virtual Result getTangent(double dParam, OdGeVector2d &vTangent) const =0
FacetModeler::IBulgeSeg2D::nearestParam
virtual double nearestParam(const OdGePoint2d &ptTest, OdGePoint2d *ptNearest=0) const =0
FacetModeler::IBulgeSeg2D::length
virtual double length() const =0
FacetModeler::IBulgeSeg2D::isOn
virtual bool isOn(const OdGePoint2d &ptTest, double *pdParam=0, const OdGeTol &gTol=FMGeGbl::gTol) const =0
FacetModeler::IBulgeSeg2D::setMetadata
void setMetadata(OdIntPtr uNewData)
Definition: FM_IBulgeSeg2D.h:250
FacetModeler::IBulgeSeg2D::deviation
virtual double deviation() const =0
FacetModeler::IBulgeSeg2D::type
virtual SegmentType type() const =0
FacetModeler::IBulgeSeg2D::getSubSegment
virtual Result getSubSegment(double dStartParam, double dEndParam, IBulgeSeg2D &rSubSeg) const =0
FacetModeler::IBulgeSeg2D::reverse
virtual Result reverse()=0
FacetModeler::IBulgeSeg2D::getLineSeg
virtual Result getLineSeg(OdGeLineSeg2d &geLine) const =0
FacetModeler::IBulgeSeg2D::endPt
virtual const OdGePoint2d & endPt() const =0
OdGeExtents2d
Definition: GeExtents2d.h:43
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
FacetModeler::Intersection
Definition: FMContoursBase.h:239
OdGeLineSeg2d
Definition: GeLineSeg2d.h:42
FacetModeler::IBulgeSeg2D::addExtents
virtual void addExtents(OdGeExtents2d &rExtents, double dTol=0.0) const =0
FacetModeler::IBulgeSeg2D
Definition: FM_IBulgeSeg2D.h:50
FacetModeler::IBulgeSeg2D::metadata
OdIntPtr metadata() const
Definition: FM_IBulgeSeg2D.h:247
OdGeCircArc2d
Definition: GeCircArc2d.h:47
FMContoursBaseImp.h
FacetModeler::IBulgeSeg2D::create
static IBulgeSeg2D * create(SegmentImplClass eClass, const IBulgeSeg2D *pSrcSeg=0)
FacetModeler::IBulgeSeg2D::set
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, double dBulge, const Attributes2D &rAttr)=0
FacetModeler::IBulgeSeg2D::~IBulgeSeg2D
virtual ~IBulgeSeg2D()
Definition: FM_IBulgeSeg2D.h:52
FacetModeler::IBulgeSeg2D::attributes
virtual const Attributes2D & attributes() const =0
FacetModeler::IBulgeSeg2D::setAttributes
void setAttributes(const Attributes2D &rNewAttr)
Definition: FM_IBulgeSeg2D.h:244
FacetModeler::IBulgeSeg2D::set
virtual Result set(const IBulgeSeg2D &rSeg)=0
FacetModeler::IBulgeSeg2D::areOn
virtual OdUInt32 areOn(Intersection **ppInt, const OdGeTol &gTol=FMGeGbl::gTol) const =0
FacetModeler::SegmentImplClass
SegmentImplClass
DOM.
Definition: FMContoursBase.h:228
OdGeVector2d
Definition: GeVector2d.h:51
FacetModeler::Result
Result
Definition: FMContoursBase.h:44
FacetModeler::IBulgeSeg2D::arcAngle
virtual double arcAngle() const =0
FacetModeler::IBulgeSeg2D::startPt
virtual const OdGePoint2d & startPt() const =0
FacetModeler::Attributes2D
Definition: FMContoursBaseImp.h:48
FMGeometry.h
FacetModeler::SegmentType
SegmentType
Definition: FMContoursBase.h:158
FacetModeler::IBulgeSeg2D::getPoint
virtual Result getPoint(double dParam, OdGePoint2d &ptPoint) const =0
OdIntPtr
ptrdiff_t OdIntPtr
Definition: OdPlatformSettings.h:884
FacetModeler::IBulgeSeg2D::getParallelSegment
virtual Result getParallelSegment(double dNormalOffset, IBulgeSeg2D &rParSeg) const =0
FacetModeler::IBulgeSeg2D::set
virtual Result set(const OdGeLineSeg2d &geLine)=0
OdGeMatrix2d
Definition: GeMatrix2d.h:73
FacetModeler::IBulgeSeg2D::set
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, const OdGePoint2d &ptIntermediate)=0
FacetModeler::IBulgeSeg2D::integrate
virtual double integrate(const OdGePoint2d &ptOrigin=OdGePoint2d::kOrigin) const =0
OdGePoint2d::kOrigin
static GE_STATIC_EXPORT const OdGePoint2d kOrigin
Definition: GePoint2d.h:80
FacetModeler::IBulgeSeg2D::intersect
virtual OdUInt32 intersect(const IBulgeSeg2D &rSegB, OdGePoint2d *pPt1, OdGePoint2d *pPt2=0, const OdGeTol &gTol=FMGeGbl::gTol) const =0
OdGeTol
Definition: GeTol.h:49
FacetModeler::IBulgeSeg2D::intersect
virtual OdUInt32 intersect(const IBulgeSeg2D &rSegB, Intersection *pInt1=0, Intersection *pInt2=0, const OdGeTol &gTol=FMGeGbl::gTol) const =0
FacetModeler::IBulgeSeg2D::arcCenter
virtual OdGePoint2d arcCenter() const =0
GePoint2d.h
FacetModeler::IBulgeSeg2D::set
virtual Result set(const OdGeCircArc2d &geArc)=0
FacetModeler::IBulgeSeg2D::getCircleData
virtual Result getCircleData(OdGePoint2d &ptCenter, double &dRadius) const =0
FacetModeler::IBulgeSeg2D::arcStartAngle
virtual double arcStartAngle() const =0
FacetModeler::IBulgeSeg2D::attributes4U
virtual Attributes2D & attributes4U()=0
FacetModeler::IBulgeSeg2D::getArcData
virtual Result getArcData(OdGePoint2d &ptCenter, double &dRadius, double &dStartAngle, double &dInclAngle) const =0
OdGePoint2d
Definition: GePoint2d.h:60