Point Cloud Library (PCL) 1.15.0
Loading...
Searching...
No Matches
opennurbs_polyedgecurve.h
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6// McNeel & Associates.
7//
8// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10// MERCHANTABILITY ARE HEREBY DISCLAIMED.
11//
12// For complete openNURBS copyright information see <http://www.opennurbs.org>.
13//
14////////////////////////////////////////////////////////////////
15*/
16
17#if !defined(ON_POLYEDGECURVE_INC_)
18#define ON_POLYEDGECURVE_INC_
19
21
22class ON_CLASS ON_PolyEdgeCurve : public ON_PolyCurve
23{
24 ON_OBJECT_DECLARE(ON_PolyEdgeCurve);
25
26public:
29 // default copy constructor and operator= are fine.
30
31 // virtual ON_Object::DestroyRuntimeCache override
32 void DestroyRuntimeCache( bool bDelete = true );
33
34 // virtual ON_Curve::IsClosed override
35 ON_BOOL32 IsClosed() const;
36
37 // virtual ON_Curve::DuplicateCurve override
39
40 /*
41 Description:
42 Create a one segment ON_PolyEdgeCurve curve that uses a
43 single edge.
44 */
45 bool Create(
46 const ON_BrepTrim* trim,
47 const ON_UUID& object_id
48 );
49
50 /*
51 Description:
52 Create a one segment ON_PolyEdgeCurve curve that uses a
53 single curve.
54 */
55 bool Create(
56 const ON_Curve* curve,
57 const ON_UUID& object_id
58 );
59
60 int SegmentCount() const;
61
63 int segment_index
64 ) const;
65
67
68 ON_BOOL32 Prepend( ON_PolyEdgeSegment* new_segment ); // Prepend curve.
69 ON_BOOL32 Append( ON_PolyEdgeSegment* new_segment ); // Append curve.
70 ON_BOOL32 Insert(
71 int segment_index,
72 ON_PolyEdgeSegment* new_segment
73 );
74
75 // if the segment is an edge, the following
76 // return non-NULL pointers.
77 const ON_BrepEdge* EdgeAt(double t) const;
78 const ON_BrepTrim* TrimAt(double t) const;
79 const ON_Brep* BrepAt(double t) const;
80 const ON_BrepFace* FaceAt(double t) const;
81 const ON_Surface* SurfaceAt(double t) const;
82 ON_Surface::ISO IsoType( double t) const;
83
84 double EdgeParameter(double t) const;
85
86 // Test if there are any surface edges in the polyedge
87 bool ContainsAnyEdges() const;
88 // Test if all segments of the polyedge are surface edges
89 bool ContainsAllEdges() const;
90
91 /*
92 Description:
93 See if this polyedge has an edge as one of its segments
94 Parameters:
95 edge - [in] the edge to look for
96 Returns:
97 -1: edge is not in the polyedge
98 >=0: index of first segment that uses the edge
99 */
100 int FindEdge( const ON_BrepEdge* edge) const;
101
102 /*
103 Description:
104 See if this polyedge has a trim as one of its segments
105 Parameters:
106 trim - [in] the trim to look for
107 Returns:
108 -1: trim is not in the polyedge
109 >=0: index of first segment that uses the trim
110 */
111 int FindTrim( const ON_BrepTrim* trim) const;
112
113 /*
114 Description:
115 See if this polyedge has a wire curve as one of its segments
116 Parameters:
117 curve - [in] the curve to look for
118 Returns:
119 -1: trim is not in the polyedge
120 >=0: index of first segment that uses the curve
121 */
122 int FindCurve( const ON_Curve* curve) const;
123
124
125 // OBSOLETE and unreliable. Use FindCurve, FindEdge, or FindTrim
126 //bool Contains( const ON_Curve* curve) const;
127
128 // virtual ON_Curve overrides do nothing
129 // to prevent changing edge
130 ON_BOOL32 SetStartPoint(ON_3dPoint start_point);
131 ON_BOOL32 SetEndPoint(ON_3dPoint end_point);
132 ON_BOOL32 ChangeClosedCurveSeam( double t );
135
136 // 7-1-03 lw added override to unset cached closed flag
137 // when a segment is removed
138 ON_BOOL32 Remove(); // remove last
139 ON_BOOL32 Remove( int index);
140};
141
142class ON_CLASS ON_PolyEdgeSegment : public ON_CurveProxy
143{
144 ON_OBJECT_DECLARE(ON_PolyEdgeSegment);
145public:
146 // construction
147
150 // default copy constructor and operator= are fine.
151
152 // virtual ON_Object::DestroyRuntimeCache override
153 void DestroyRuntimeCache( bool bDelete = true );
154
155 ON_BOOL32 Write( ON_BinaryArchive& ) const;
156
157 ON_BOOL32 Read( ON_BinaryArchive& );
158
159 // virtual ON_Curve::IsClosed override
160 ON_BOOL32 IsClosed() const;
161
162
163 // virtual ON_Curve::DuplicateCurve override
165
166 /*
167 Description:
168 Creates a polyedge segment that uses the entire edge
169 and has the same domain as the edge.
170 Parameters:
171 trim - [in]
172 Returns:
173 true if successful (edge was valid and trim_index was valid)
174 Remarks:
175 Use ON_Curve::SetDomain, ON_Curve::Trim, ON_Curve::Reverse,
176 etc., to tweak the domain, support, direction etc.
177 */
178 bool Create(
179 const ON_BrepTrim* trim,
180 const ON_UUID& object_id
181 );
182
183 /*
184 Description:
185 Creates a polyedge segment that uses the entire curve
186 and has the same domain as the curve.
187 Parameters:
188 curve - [in]
189 Remarks:
190 Use ON_Curve::SetDomain, ON_Curve::Trim, ON_Curve::Reverse,
191 etc., to tweak the domain, support, direction etc.
192 */
193 bool Create(
194 const ON_Curve* curve,
195 const ON_UUID& object_id
196 );
197
198 using ON_CurveProxy::Trim; // Explicitly introduce the base class Trim function
199 const ON_BrepEdge* Edge() const;
200 const ON_BrepTrim* Trim() const; // overload, not override
201 const ON_Brep* Brep() const;
202 const ON_BrepFace* Face() const;
203 const ON_Surface* Surface() const;
205
206 double EdgeParameter(double t) const;
207
208 /*
209 Returns:
210 True if this segment has an ON_BrepEdge and the direction of
211 the ON_BrepEdge is the reverse of the direction of the segment.
212 */
213 bool ReversedEdgeDir() const;
214
215 /*
216 Returns:
217 True if this segment has an ON_BrepTrim and the direction of
218 the ON_BrepTrime is the reverse of the direction of the segment.
219 */
220 bool ReversedTrimDir() const;
221
222 /*
223 Returns:
224 subdomain of the edge that this segment uses. This can
225 be different than the domain returned by this->Domain().
226 */
228
229 /*
230 Returns:
231 subdomain of the trim that this segment uses. This can
232 be different than the domain returned by this->Domain().
233 */
235
236 // m_object_id = id of a brep or curve object in Rhino
238 // When the Rhino object is a brep, m_component_index
239 // refers to either an edge or a trim.
240 ON_COMPONENT_INDEX m_component_index;
241 // corresponding domain of the edge - see note below
243 // corresponding domain of the trim - see note below
245
246
247 // When m_component_index refers to an ON_BrepTrim, there
248 // are four domains and 4 classes derived from ON_Curve
249 // that play a role in the polyedge segment. It is possible
250 // for all 4 of these domains to be different.
251 //
252 // "this" ON_PolyEdgeSegment is an ON_ProxyCurve. The
253 // evaluation domain of "this" is
254 // = this->Domain()
255 // = ON_ProxyCurve::m_this_domain
256 //
257 // ON_ProxyCurve::m_real_curve points to the curve in the
258 // c3 = ON_Brep::m_C3[edge.m_c3i]. "this" is a proxy for some
259 // sub-interval of c3.
260 // = this->ProxyCurveDomain()
261 // = ON_ProxyCurve::m_real_curve_domain
262 //
263 // The edge, an ON_BrepEdge, is also a proxy based on c3,
264 // and the edge's evaluation domain is edge.m_this_domain.
265 // ON_PolyEdgeSegment::m_edge_domain records the increasing
266 // subinterval of edge.m_this_domain that corresponds
267 // to the portion of c3 "this" is using.
268 //
269 // The trim, an ON_BrepTrim, is a proxy based on a curve
270 // in ON_Brep::m_C2[]. Some portion of the trim corresponds
271 // to the portion of the edge we are using. m_trim_domain
272 // is an increasing, possible subinterval, of the trim's domain
273 // ON_BrepTrim::m_this_domain.
274
275 // Runtime helpers
276 const void* m_parent_object; // CRhinoBrepObject or CRhinoCurveObject
278 const ON_BrepTrim* m_trim; // 2d trim in m_brep
279 const ON_BrepEdge* m_edge; // 3d edge in m_brep
282
283private:
284 friend class ON_PolyEdgeCurve;
285 void ClearEvalCacheHelper();
286
287 // parameter evaluation cache
288 double m_t;
289 double m_edge_t;
290 double m_trim_t;
291 double m_srf_uv[2];
292 int m_trim_hint;
293 int m_edge_hint;
294
295 // surface evaluation cache
296 int m_evsrf_hint[2];
297 double m_evsrf_uv[2];
298 ON_3dPoint m_evsrf_pt;
299 ON_3dVector m_evsrf_du;
300 ON_3dVector m_evsrf_dv;
301 ON_3dVector m_evsrf_duu;
302 ON_3dVector m_evsrf_duv;
303 ON_3dVector m_evsrf_dvv;
304 ON_3dVector m_evsrf_tan;
305
306 void Init();
307};
308
309#endif
ON_BOOL32 Trim(const ON_Interval &domain)
int FindEdge(const ON_BrepEdge *edge) const
bool Create(const ON_BrepTrim *trim, const ON_UUID &object_id)
ON_Curve * DuplicateCurve() const
ON_BOOL32 AppendAndMatch(ON_Curve *)
ON_BOOL32 IsClosed() const
const ON_BrepEdge * EdgeAt(double t) const
const ON_BrepFace * FaceAt(double t) const
bool Create(const ON_Curve *curve, const ON_UUID &object_id)
const ON_Surface * SurfaceAt(double t) const
ON_BOOL32 Insert(int segment_index, ON_PolyEdgeSegment *new_segment)
const ON_BrepTrim * TrimAt(double t) const
ON_BOOL32 PrependAndMatch(ON_Curve *)
ON_BOOL32 Remove(int index)
const ON_Brep * BrepAt(double t) const
double EdgeParameter(double t) const
bool ContainsAnyEdges() const
ON_BOOL32 SetStartPoint(ON_3dPoint start_point)
ON_BOOL32 Remove()
ON_BOOL32 SetEndPoint(ON_3dPoint end_point)
int SegmentCount() const
int FindCurve(const ON_Curve *curve) const
int FindTrim(const ON_BrepTrim *trim) const
ON_Surface::ISO IsoType(double t) const
ON_BOOL32 Prepend(ON_PolyEdgeSegment *new_segment)
ON_PolyEdgeSegment * SegmentCurve(int segment_index) const
void DestroyRuntimeCache(bool bDelete=true)
ON_BOOL32 ChangeClosedCurveSeam(double t)
bool ContainsAllEdges() const
ON_BOOL32 Append(ON_PolyEdgeSegment *new_segment)
ON_PolyEdgeSegment * operator[](int) const
ON_COMPONENT_INDEX m_component_index
const ON_Surface * Surface() const
const ON_BrepTrim * Trim() const
const ON_BrepFace * Face() const
ON_Interval EdgeDomain() const
const ON_BrepEdge * m_edge
bool Create(const ON_BrepTrim *trim, const ON_UUID &object_id)
ON_Surface::ISO IsoType() const
const ON_Brep * Brep() const
ON_Interval TrimDomain() const
bool ReversedEdgeDir() const
void DestroyRuntimeCache(bool bDelete=true)
ON_Curve * DuplicateCurve() const
bool ReversedTrimDir() const
const ON_BrepTrim * m_trim
ON_BOOL32 IsClosed() const
ON_BOOL32 Read(ON_BinaryArchive &)
double EdgeParameter(double t) const
const ON_Surface * m_surface
bool Create(const ON_Curve *curve, const ON_UUID &object_id)
const ON_BrepFace * m_face
const ON_BrepEdge * Edge() const
ON_BOOL32 Write(ON_BinaryArchive &) const