CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
FMImpCommonSeg2D.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_COMMONSEG2D_H__
24#define __FMIMP_COMMONSEG2D_H__
25
27
28namespace FacetModeler
29{
30
31
33//
34// BulgeSeg2D is a convex 2-D curve given by 2 points and a bulge value
35// If the 2 points coincide, the segment has estCoincident type
36// Otherwise, if bulge==0, the segment is a straight line segment
37// otherwise it is a circular arc, and bulge=tan(Angle/4)
38//
39// This class contains default implementation of all methods, except the first three
40// (startPt, endPt, bulge).
41
43{
44public:
45 virtual ~CommonSeg2DImpl() { };
46
47
48 // returns esicUnknown - default value
49 virtual SegmentImplClass implClass() const;
50
51
52 // returns reference to the starting point
53 virtual const OdGePoint2d & startPt() const = 0;
54
55 // returns reference to the ending point
56 virtual const OdGePoint2d & endPt () const = 0;
57
58 // returns bulge value
59 virtual double bulge () const = 0;
60
61
63 // const methods
64
65 // returns the type of this segment
66 virtual SegmentType type() const;
67
68 // returns signed deviation from the line [start, end]
69 // the deviation has the same sign, as the bulge() value
70 virtual double deviation() const;
71
72
73 // returns vDir = endPt - startPt
74 virtual void getDir ( OdGeVector2d & vDir ) const;
75
76 // returns distance btw startPt and endPt
77 virtual double dirLength( ) const;
78
79 // returns length of the segment
80 virtual double length ( ) const;
81
82
83
84 // Returns OdGeLineSeg2d corresponding to this segment, if type()!=estArc
85 virtual Result getLineSeg ( OdGeLineSeg2d& geLine ) const;
86
87 // Returns OdGeCircArc2d corresponding to this segment, if type()==estArc
88 virtual Result getArcSeg ( OdGeCircArc2d& geArc ) const;
89
90
91
92 // returns point at the parameter [ 0, 1 ]
93 virtual Result getPoint ( double dParam, OdGePoint2d & ptPoint ) const;
94
95 // retruns tangent vector at the parameter [ 0, 1 ]
96 virtual Result getTangent( double dParam, OdGeVector2d& vTangent ) const;
97
98
99 // Adds extents of this segment (extended by dTol) to the given extents.
100 virtual void addExtents( OdGeExtents2d& rExtents, double dTol = 0.0 ) const;
101
102
103 // returns true, if the point lies on the segment
104 // *dParam stores the parameter of the point
105 virtual bool isOn( const OdGePoint2d & ptTest, double * pdParam = 0,
106 const OdGeTol & gTol = FMGeGbl::gTol ) const;
107
108
109 // returns parameter of a point on the curve, which is closest to the ptTest
110 virtual double nearestParam( const OdGePoint2d & ptTest, OdGePoint2d * ptNearest = 0 ) const;
111
112
113 // returns signed area of a contour bounded by this segment and 2 lines,
114 // connecting the ptOrigin and ends of this segment.
115 virtual double integrate( const OdGePoint2d & ptOrigin = OdGePoint2d::kOrigin ) const;
116
117
118 // returns subsegment given by 2 parameters
119 // Note: if (dStartParam > dEndParam) the rSubSeg will have opposite direction
120 virtual Result getSubSegment(double dStartParam, double dEndParam, IBulgeSeg2D & rSubSeg ) const;
121
122 // returns parallel segment.
123 // dNormalOffset - signed offset along normal vector at each point of original segment
124 // returns error, if source segment is coincident or the offset is too big to get
125 // valid result
126 virtual Result getParallelSegment( double dNormalOffset, IBulgeSeg2D & rParSeg ) const;
127
128
129 // The method returns number of different intersection points of
130 // the segment (including end with minimal Y) with a ray, starting at ptTest and
131 // going in the X direction.
132 // *pbOnSegment is set to true, if the test point lies on the segment.
133 virtual OdUInt32 intersectXRay( const OdGePoint2d& ptTest, bool * pbOnSegment = 0,
134 const OdGeTol & gTol = FMGeGbl::gTol ) const;
135
136
137 // Returns number of intersections (0, 1 or 2) and intersection points.
138 // If some parts of the segments coincide (with the given tolerance), returns UINT_MAX
139 // and ends of the coinciding part
140 virtual OdUInt32 intersect( const IBulgeSeg2D & rSegB,
141 OdGePoint2d * pPt1, OdGePoint2d * pPt2 = 0,
142 const OdGeTol & gTol = FMGeGbl::gTol ) const;
143
144 // Returns number of intersections (0, 1 or 2) and Intersection objects.
145 // If some parts of the segments coincide (with the given tolerance), returns UINT_MAX
146 // and ends of the coinciding part
147 virtual OdUInt32 intersect( const IBulgeSeg2D & rSegB,
148 Intersection * pInt1 = 0, Intersection * pInt2 = 0,
149 const OdGeTol & gTol = FMGeGbl::gTol ) const;
150
151 // Intersects this segment with an infinite line
152 // Returns number of intersections
154 const OdGePoint2d& ptLineOrigin, const OdGeVector2d& vLineDir,
155 Intersection * pInt1 = 0, Intersection * pInt2 = 0,
156 const OdGeTol & gTol = FMGeGbl::gTol ) const;
157
158 virtual OdUInt32 areOn( Intersection ** ppInt, const OdGeTol & gTol = FMGeGbl::gTol ) const;
159
161 // Arcs and circles ( length>0 and bulge != 0 )
162
163
164 // returns arc center, if type()==estArc
165 virtual OdGePoint2d arcCenter() const;
166
167 // returns arc radius, if type()==estArc
168 virtual double arcRadius( ) const;
169
170 // returns arc radius and center point, if type()==estArc
171 virtual Result getCircleData( OdGePoint2d & ptCenter, double & dRadius ) const;
172
173 // returns signed included angle of the arc segment
174 // The returned value belongs to range ( -2*Pi, 2*Pi )
175 virtual double arcAngle() const;
176
177 // returns starting angle of the arc (direction from center to startPt )
178 // The returned value belongs to range [ 0, 2*Pi )
179 virtual double arcStartAngle() const;
180
181 // returns arc center point, radius and angles if type()==estArc
182 virtual Result getArcData( OdGePoint2d & ptCenter, double & dRadius,
183 double & dStartAngle, double & dInclAngle ) const;
184
185
186
187
189 // non-const methods
190
191 // Update all
192 virtual Result set( const OdGePoint2d & ptA, const OdGePoint2d & ptB, double dBulge, const Attributes2D& rAttr ) = 0;
193
194 // Update ends and bulge
195 virtual Result set( const OdGePoint2d & ptA, const OdGePoint2d & ptB, double dBulge=0.0 );
196
197 // Update ends and calculate bulge using the intermediate point
198 // (some point on the curve between ptA and ptB )
199 virtual Result set( const OdGePoint2d & ptA, const OdGePoint2d & ptB, const OdGePoint2d & ptIntermediate );
200
201 // Copy from another segment with metadata
202 virtual Result set( const IBulgeSeg2D& rSeg );
203
204 // Copy from GeLineSeg2d and reset metadata.
205 virtual Result set( const OdGeLineSeg2d& geLine );
206
207 // Copy from GeCircArc2d and reset metadata.
208 virtual Result set( const OdGeCircArc2d& geArc );
209
210
211 // Transforms the object using the matrix
212 virtual Result transformBy( const OdGeMatrix2d& mTrans );
213
214 // inverts the segment (makes it going in opposite direction )
215 virtual Result reverse();
216
217
219 // Metadata access
220
221 // Get attributes (including metadata)
222 virtual const Attributes2D& attributes() const;
223
224 // Get attributes (including metadata) for update
226};
227
228
229
230};
231
232
233
234#endif //__FMIMP_COMMONSEG2D_H__
#define FMGEOMETRY_API
unsigned int OdUInt32
virtual Result getSubSegment(double dStartParam, double dEndParam, IBulgeSeg2D &rSubSeg) const
virtual Result getTangent(double dParam, OdGeVector2d &vTangent) const
virtual double arcStartAngle() const
virtual Result set(const OdGeCircArc2d &geArc)
virtual SegmentType type() const
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, const OdGePoint2d &ptIntermediate)
virtual double arcAngle() const
virtual Result transformBy(const OdGeMatrix2d &mTrans)
virtual Result getPoint(double dParam, OdGePoint2d &ptPoint) const
virtual Attributes2D & attributes4U()
virtual double nearestParam(const OdGePoint2d &ptTest, OdGePoint2d *ptNearest=0) const
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, double dBulge, const Attributes2D &rAttr)=0
virtual Result getArcSeg(OdGeCircArc2d &geArc) const
virtual OdUInt32 intersectLine(const OdGePoint2d &ptLineOrigin, const OdGeVector2d &vLineDir, Intersection *pInt1=0, Intersection *pInt2=0, const OdGeTol &gTol=FMGeGbl::gTol) const
virtual Result set(const IBulgeSeg2D &rSeg)
virtual const Attributes2D & attributes() const
virtual double length() const
virtual OdUInt32 intersectXRay(const OdGePoint2d &ptTest, bool *pbOnSegment=0, const OdGeTol &gTol=FMGeGbl::gTol) const
virtual Result getCircleData(OdGePoint2d &ptCenter, double &dRadius) const
virtual const OdGePoint2d & startPt() const =0
virtual double bulge() const =0
virtual double deviation() const
virtual Result getParallelSegment(double dNormalOffset, IBulgeSeg2D &rParSeg) const
virtual void getDir(OdGeVector2d &vDir) const
virtual OdGePoint2d arcCenter() const
virtual Result set(const OdGePoint2d &ptA, const OdGePoint2d &ptB, double dBulge=0.0)
virtual OdUInt32 areOn(Intersection **ppInt, const OdGeTol &gTol=FMGeGbl::gTol) const
virtual SegmentImplClass implClass() const
virtual void addExtents(OdGeExtents2d &rExtents, double dTol=0.0) const
virtual const OdGePoint2d & endPt() const =0
virtual Result set(const OdGeLineSeg2d &geLine)
virtual Result getArcData(OdGePoint2d &ptCenter, double &dRadius, double &dStartAngle, double &dInclAngle) const
virtual OdUInt32 intersect(const IBulgeSeg2D &rSegB, OdGePoint2d *pPt1, OdGePoint2d *pPt2=0, const OdGeTol &gTol=FMGeGbl::gTol) const
virtual double dirLength() const
virtual double arcRadius() const
virtual double integrate(const OdGePoint2d &ptOrigin=OdGePoint2d::kOrigin) const
virtual Result getLineSeg(OdGeLineSeg2d &geLine) const
virtual bool isOn(const OdGePoint2d &ptTest, double *pdParam=0, const OdGeTol &gTol=FMGeGbl::gTol) const
virtual OdUInt32 intersect(const IBulgeSeg2D &rSegB, Intersection *pInt1=0, Intersection *pInt2=0, const OdGeTol &gTol=FMGeGbl::gTol) const
static GE_STATIC_EXPORT const OdGePoint2d kOrigin
Definition: GePoint2d.h:93
Definition: GeTol.h:49