QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_polyedgecurve.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2008 Robert McNeel & Associates. All rights reserved.
5// Rhinoceros is a registered trademark of Robert McNeel & Assoicates.
6//
7// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
8// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
9// MERCHANTABILITY ARE HEREBY DISCLAIMED.
10//
11// For complete openNURBS copyright information see <http://www.opennurbs.org>.
12//
14*/
15
16#if !defined(ON_POLYEDGECURVE_INC_)
17#define ON_POLYEDGECURVE_INC_
18
20
22{
24
25public:
28 // default copy constructor and operator= are fine.
29
30 // virtual ON_Object::DestroyRuntimeCache override
31 void DestroyRuntimeCache( bool bDelete = true );
32
33 // virtual ON_Curve::IsClosed override
34 ON_BOOL32 IsClosed() const;
35
36 // virtual ON_Curve::DuplicateCurve override
37 ON_Curve* DuplicateCurve() const;
38
39 /*
40 Description:
41 Create a one segment ON_PolyEdgeCurve curve that uses a
42 single edge.
43 */
44 bool Create(
45 const ON_BrepTrim* trim,
46 const ON_UUID& object_id
47 );
48
49 /*
50 Description:
51 Create a one segment ON_PolyEdgeCurve curve that uses a
52 single curve.
53 */
54 bool Create(
55 const ON_Curve* curve,
56 const ON_UUID& object_id
57 );
58
59 int SegmentCount() const;
60
62 int segment_index
63 ) const;
64
66
67 ON_BOOL32 Prepend( ON_PolyEdgeSegment* new_segment ); // Prepend curve.
68 ON_BOOL32 Append( ON_PolyEdgeSegment* new_segment ); // Append curve.
70 int segment_index,
71 ON_PolyEdgeSegment* new_segment
72 );
73
74 // if the segment is an edge, the following
75 // return non-NULL pointers.
76 const ON_BrepEdge* EdgeAt(double t) const;
77 const ON_BrepTrim* TrimAt(double t) const;
78 const ON_Brep* BrepAt(double t) const;
79 const ON_BrepFace* FaceAt(double t) const;
80 const ON_Surface* SurfaceAt(double t) const;
81 ON_Surface::ISO IsoType( double t) const;
82
83 double EdgeParameter(double t) const;
84 double TrimParameter(double t) const;
85 ON_2dPoint SurfaceParameter(double t) const;
86
87 // Test if there are any surface edges in the polyedge
88 bool ContainsAnyEdges() const;
89 // Test if all segments of the polyedge are surface edges
90 bool ContainsAllEdges() const;
91
92 /*
93 Description:
94 Evaluate surface binormal and normal.
95 Parameters:
96 t - [in] ON_PolyEdgeCurve curve parameter
97 bIsoDir - [in] (if true, the tangent will be parallel to an isodir)
98 srfpoint - [out] location on surface
99 srftangent - [out] "binormal" tangent to the surface.
100 The direction of this tangent is controled by
101 the surface tangent mode setting.
102 srfnormal - [out] normal to surface,
103 See Also:
104 ON_PolyEdgeCurve::SetSrfTangentMode
105 */
106 bool EvSrfTangent(
107 double t,
108 bool bIsoDir,
109 ON_3dPoint& srfpoint,
110 ON_3dVector& srftangent,
111 ON_3dVector& srfnormal
112 ) const;
113
114 /*
115 Description:
116 Evaluate surface normal curvature
117 Parameters:
118 t - [in] ON_PolyEdgeCurve curve parameter
119 srftangent - [in] tangent to the surface
120 srfnormalcurvature - [out] normal curvature
121 srfnormal - [out] normal to surface
122 See Also:
123 ON_PolyEdgeCurve::EvSrfTangent
124 */
125 bool EvSrfNormalCurvature(
126 double t,
127 ON_3dVector srftangent,
128 ON_3dVector& srfnormalcurvature,
129 ON_3dVector& srfnormal
130 ) const;
131
132 /*
133 Description:
134 Evaluate surface derivatives.
135 Parameters:
136 t - [in] ON_PolyEdgeCurve curve parameter
137 srfpoint - [out] location on surface
138 du - [out]
139 dv - [out]
140 duu - [out]
141 duv - [out]
142 dvv - [out]
143 */
144 bool EvSrfDerivatives(
145 double t,
146 ON_3dPoint& srfpoint,
147 ON_3dVector& du,
148 ON_3dVector& dv,
149 ON_3dVector& duu,
150 ON_3dVector& duv,
151 ON_3dVector& dvv
152 ) const;
153
154 /*
155 Description:
156 See if this polyedge has an edge as one of its segments
157 Parameters:
158 edge - [in] the edge to look for
159 Returns:
160 -1: edge is not in the polyedge
161 >=0: index of first segment that uses the edge
162 */
163 int FindEdge( const ON_BrepEdge* edge) const;
164
165 /*
166 Description:
167 See if this polyedge has a trim as one of its segments
168 Parameters:
169 trim - [in] the trim to look for
170 Returns:
171 -1: trim is not in the polyedge
172 >=0: index of first segment that uses the trim
173 */
174 int FindTrim( const ON_BrepTrim* trim) const;
175
176 /*
177 Description:
178 See if this polyedge has a wire curve as one of its segments
179 Parameters:
180 curve - [in] the curve to look for
181 Returns:
182 -1: trim is not in the polyedge
183 >=0: index of first segment that uses the curve
184 */
185 int FindCurve( const ON_Curve* curve) const;
186
187
188 // OBSOLETE and unreliable. Use FindCurve, FindEdge, or FindTrim
189 //bool Contains( const ON_Curve* curve) const;
190
191 // virtual ON_Curve overrides do nothing
192 // to prevent changing edge
198
199 // 7-1-03 lw added override to unset cached closed flag
200 // when a segment is removed
201 ON_BOOL32 Remove(); // remove last
202 ON_BOOL32 Remove( int index);
203};
204
206{
208public:
209 // construction
210
213 // default copy constructor and operator= are fine.
214
215 // virtual ON_Object::DestroyRuntimeCache override
216 void DestroyRuntimeCache( bool bDelete = true );
217
219
221
222 // virtual ON_Curve::IsClosed override
223 ON_BOOL32 IsClosed() const;
224
225
226 // virtual ON_Curve::DuplicateCurve override
227 ON_Curve* DuplicateCurve() const;
228
229 /*
230 Description:
231 Creates a polyedge segment that uses the entire edge
232 and has the same domain as the edge.
233 Parameters:
234 trim - [in]
235 Returns:
236 true if successful (edge was valid and trim_index was valid)
237 Remarks:
238 Use ON_Curve::SetDomain, ON_Curve::Trim, ON_Curve::Reverse,
239 etc., to tweak the domain, support, direction etc.
240 */
241 bool Create(
242 const ON_BrepTrim* trim,
243 const ON_UUID& object_id
244 );
245
246 /*
247 Description:
248 Creates a polyedge segment that uses the entire curve
249 and has the same domain as the curve.
250 Parameters:
251 curve - [in]
252 Remarks:
253 Use ON_Curve::SetDomain, ON_Curve::Trim, ON_Curve::Reverse,
254 etc., to tweak the domain, support, direction etc.
255 */
256 bool Create(
257 const ON_Curve* curve,
258 const ON_UUID& object_id
259 );
260
261 const ON_BrepEdge* Edge() const;
262 const ON_BrepTrim* Trim() const;
263 const ON_Brep* Brep() const;
264 const ON_BrepFace* Face() const;
265 const ON_Surface* Surface() const;
266 ON_Surface::ISO IsoType() const;
267
268 double EdgeParameter(double t) const;
269 double TrimParameter(double t) const;
270 ON_2dPoint SurfaceParameter(double t) const;
271
272 /*
273 Returns:
274 True if this segment has an ON_BrepEdge and the direction of
275 the ON_BrepEdge is the reverse of the direction of the segment.
276 */
277 bool ReversedEdgeDir() const;
278
279 /*
280 Returns:
281 True if this segment has an ON_BrepTrim and the direction of
282 the ON_BrepTrime is the reverse of the direction of the segment.
283 */
284 bool ReversedTrimDir() const;
285
286 /*
287 Returns:
288 subdomain of the edge that this segment uses. This can
289 be different than the domain returned by this->Domain().
290 */
291 ON_Interval EdgeDomain() const;
292
293 /*
294 Returns:
295 subdomain of the trim that this segment uses. This can
296 be different than the domain returned by this->Domain().
297 */
298 ON_Interval TrimDomain() const;
299
301 const ON_Interval& domain
302 );
303
305 double t,
306 ON_Curve*& left_side,
307 ON_Curve*& right_side
308 ) const;
309
310 // m_object_id = id of a brep or curve object in Rhino
312 // When the Rhino object is a brep, m_component_index
313 // refers to either an edge or a trim.
314 ON_COMPONENT_INDEX m_component_index;
315 // corresponding domain of the edge - see note below
317 // corresponding domain of the trim - see note below
319
320
321 // When m_component_index refers to an ON_BrepTrim, there
322 // are four domains and 4 classes derived from ON_Curve
323 // that play a role in the polyedge segment. It is possible
324 // for all 4 of these domains to be different.
325 //
326 // "this" ON_PolyEdgeSegment is an ON_ProxyCurve. The
327 // evaluation domain of "this" is
328 // = this->Domain()
329 // = ON_ProxyCurve::m_this_domain
330 //
331 // ON_ProxyCurve::m_real_curve points to the curve in the
332 // c3 = ON_Brep::m_C3[edge.m_c3i]. "this" is a proxy for some
333 // sub-interval of c3.
334 // = this->ProxyCurveDomain()
335 // = ON_ProxyCurve::m_real_curve_domain
336 //
337 // The edge, an ON_BrepEdge, is also a proxy based on c3,
338 // and the edge's evaluation domain is edge.m_this_domain.
339 // ON_PolyEdgeSegment::m_edge_domain records the increasing
340 // subinterval of edge.m_this_domain that corresponds
341 // to the portion of c3 "this" is using.
342 //
343 // The trim, an ON_BrepTrim, is a proxy based on a curve
344 // in ON_Brep::m_C2[]. Some portion of the trim corresponds
345 // to the portion of the edge we are using. m_trim_domain
346 // is an increasing, possible subinterval, of the trim's domain
347 // ON_BrepTrim::m_this_domain.
348
349 // Runtime helpers
350 const void* m_parent_object; // CRhinoBrepObject or CRhinoCurveObject
352 const ON_BrepTrim* m_trim; // 2d trim in m_brep
353 const ON_BrepEdge* m_edge; // 3d edge in m_brep
356
357 void SetTrimDomainFromEdgeDomain();
358
359private:
360 friend class ON_PolyEdgeCurve;
361 void ClearEvalCacheHelper();
362
363 // parameter evaluation cache
364 double m_t;
365 double m_edge_t;
366 double m_trim_t;
367 double m_srf_uv[2];
370
371 // surface evaluation cache
372 int m_evsrf_hint[2];
373 double m_evsrf_uv[2];
381
382 void Init();
383};
384
385#endif
Definition opennurbs_point.h:253
Definition opennurbs_point.h:403
Definition opennurbs_point.h:931
Definition opennurbs_archive.h:152
Definition opennurbs_brep.h:192
Definition opennurbs_brep.h:980
Definition opennurbs_brep.h:1585
Definition opennurbs_brep.h:420
Definition opennurbs_curve.h:88
Definition opennurbs_curveproxy.h:38
Definition opennurbs_point.h:46
Definition opennurbs_polycurve.h:38
ON_BOOL32 SetEndPoint(ON_3dPoint end_point)
Definition opennurbs_polycurve.cpp:2198
ON_BOOL32 Write(ON_BinaryArchive &) const
Definition opennurbs_polycurve.cpp:326
ON_BOOL32 ChangeClosedCurveSeam(double t)
Definition opennurbs_polycurve.cpp:538
ON_BOOL32 SetStartPoint(ON_3dPoint start_point)
Definition opennurbs_polycurve.cpp:2185
ON_BOOL32 Trim(const ON_Interval &domain)
Definition opennurbs_polycurve.cpp:2391
ON_BOOL32 Prepend(ON_Curve *)
Definition opennurbs_polycurve.cpp:1649
ON_Curve * operator[](int) const
Definition opennurbs_polycurve.cpp:1570
ON_BOOL32 Insert(int, ON_Curve *)
Definition opennurbs_polycurve.cpp:1719
void DestroyRuntimeCache(bool bDelete=true)
Definition opennurbs_polycurve.cpp:54
ON_Curve * SegmentCurve(int segment_index) const
Definition opennurbs_polycurve.cpp:1576
ON_Curve * DuplicateCurve() const
Definition opennurbs_polycurve.cpp:450
ON_BOOL32 AppendAndMatch(ON_Curve *)
Definition opennurbs_polycurve.cpp:1673
ON_BOOL32 PrependAndMatch(ON_Curve *)
Definition opennurbs_polycurve.cpp:1661
ON_BOOL32 IsClosed(void) const
Definition opennurbs_polycurve.cpp:962
ON_BOOL32 Split(double t, ON_Curve *&left_side, ON_Curve *&right_side) const
Definition opennurbs_polycurve.cpp:2804
ON_BOOL32 Append(ON_Curve *)
Definition opennurbs_polycurve.cpp:1655
ON_BOOL32 Remove()
Definition opennurbs_polycurve.cpp:1686
ON_BOOL32 Read(ON_BinaryArchive &)
Definition opennurbs_polycurve.cpp:357
Definition opennurbs_polyedgecurve.h:22
ON_OBJECT_DECLARE(ON_PolyEdgeCurve)
Definition opennurbs_polyedgecurve.h:206
ON_3dVector m_evsrf_tan
Definition opennurbs_polyedgecurve.h:380
ON_3dPoint m_evsrf_pt
Definition opennurbs_polyedgecurve.h:374
ON_OBJECT_DECLARE(ON_PolyEdgeSegment)
ON_COMPONENT_INDEX m_component_index
Definition opennurbs_polyedgecurve.h:314
ON_Interval m_trim_domain
Definition opennurbs_polyedgecurve.h:318
const ON_BrepEdge * m_edge
Definition opennurbs_polyedgecurve.h:353
double m_t
Definition opennurbs_polyedgecurve.h:364
ON_3dVector m_evsrf_dvv
Definition opennurbs_polyedgecurve.h:379
ON_UUID m_object_id
Definition opennurbs_polyedgecurve.h:311
int m_trim_hint
Definition opennurbs_polyedgecurve.h:368
ON_3dVector m_evsrf_dv
Definition opennurbs_polyedgecurve.h:376
ON_Interval m_edge_domain
Definition opennurbs_polyedgecurve.h:316
const void * m_parent_object
Definition opennurbs_polyedgecurve.h:350
const ON_Brep * m_brep
Definition opennurbs_polyedgecurve.h:351
ON_3dVector m_evsrf_du
Definition opennurbs_polyedgecurve.h:375
double m_edge_t
Definition opennurbs_polyedgecurve.h:365
const ON_BrepTrim * m_trim
Definition opennurbs_polyedgecurve.h:352
int m_edge_hint
Definition opennurbs_polyedgecurve.h:369
const ON_Surface * m_surface
Definition opennurbs_polyedgecurve.h:355
const ON_BrepFace * m_face
Definition opennurbs_polyedgecurve.h:354
ON_3dVector m_evsrf_duv
Definition opennurbs_polyedgecurve.h:378
ON_3dVector m_evsrf_duu
Definition opennurbs_polyedgecurve.h:377
double m_trim_t
Definition opennurbs_polyedgecurve.h:366
Definition opennurbs_surface.h:58
ISO
Definition opennurbs_surface.h:73
Definition opennurbs_uuid.h:31
void trim(void trimEntity, void trimClickPos, void limitingEntity, void limitingClickPos, void trimBoth)
Trims the given entity / entities or shape(s).
Definition simple_modify.js:78
#define ON_CLASS
Definition opennurbs_defines.h:91
int ON_BOOL32
Definition opennurbs_system.h:362