QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_offsetsurface.h
Go to the documentation of this file.
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2007 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_OFFSETSURFACE_INC_)
17#define ON_OFFSETSURFACE_INC_
18
19// This file is to be used in V3 plug-ins.
20// In V4, this will be included as part of opennurbs.
21// Ask Dale Lear if you have any questions.
22
24{
25public:
27
28 bool operator==(const ON_BumpFunction& other) const;
29 bool operator<(const ON_BumpFunction& other) const;
30 bool operator>(const ON_BumpFunction& other) const;
31
32 double ValueAt(
33 double s,
34 double t
35 ) const;
36
37 void Evaluate(
38 double s,
39 double t,
40 int der_count,
41 double* value
42 ) const;
43
44 ON_2dPoint m_point; // center of bump
45 int m_type[2]; // 1 = linear, 5 = quintic;
46
47 // numbers used in evaluation
48 double m_x0;
49 double m_y0;
50 double m_sx[2]; // 1/(suppor radius)
51 double m_sy[2]; // 1/(suppor radius)
52 double m_a; // evaluation coefficient
53
54 void EvaluateHelperLinearBump(double t, double dt, int der_count, double* value) const;
55 void EvaluateHelperQuinticBump(double t, double dt, int der_count, double* value) const;
56};
57
58
60{
61public:
62 double m_s;
63 double m_t;
64 double m_distance;
65 double m_radius;
67};
68
69
70#if defined(ON_DLL_TEMPLATE)
71// This stuff is here because of a limitation in the way Microsoft
72// handles templates and DLLs. See Microsoft's knowledge base
73// article ID Q168958 for details.
74#pragma warning( push )
75#pragma warning( disable : 4231 )
76ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_BumpFunction>;
77ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_OffsetSurfaceValue>;
78#pragma warning( pop )
79#endif
80
81
83{
84public:
87
88 /*
89 Description:
90 Sets base surface for the offset function.
91 Parameters:
92 srf - [in] pointer to the base surface.
93 This surface must remain valid while
94 the ON_OffsetSurfaceFunction class is used.
95 Returns:
96 True if successful.
97 */
98 bool SetBaseSurface(
99 const ON_Surface* srf
100 );
101
102 /*
103 Returns:
104 Base surface specified SetBaseSurface().
105 */
106 const ON_Surface* BaseSurface() const;
107
108 /*
109 Description:
110 Use set SetSideTangency if you want the offset
111 surface and base surface to have the same unit
112 normals along a side of the surfaces's parameter
113 spaces.
114 Parameters:
115 side - [in]
116 0 = south side
117 1 = east side
118 2 = north side
119 3 = west side
120 bEnable - [in] true to enable tangency,
121 false to disable tangency
122 Returns:
123 True if successful.
124 */
125 bool SetSideTangency(
126 int side,
127 bool bEnable
128 );
129
130 /*
131 Parameters:
132 side - [in]
133 0 = south side
134 1 = east side
135 2 = north side
136 3 = west side
137 Returns:
138 True if side tangency is enabled.
139 */
140 bool SideTangency(int side) const;
141
142 /*
143 Description:
144 Sets the offset distance at a point. Call this function
145 once for each point wher the user specifies an offset.
146 Parameters:
147 s - [in]
148 t - [in] (s,t) is a base surface evaluation parameter
149 distance - [in] distance is the offset distance.
150 radius - [in] if radius>0, then this value will be the
151 the approximate radius of the offset "bump".
152 */
153 bool SetOffsetPoint(
154 double s,
155 double t,
156 double distance,
157 double radius = 0.0
158 );
159
160 /*
161 Description:
162 Sets the surface parameters of an existing offset point.
163 Parameters:
164 index - [in] index of the point to set
165 s - [in]
166 t - [in] (s,t) is a base surface evaluation parameter
167 */
168 bool SetPoint(
169 int index,
170 double s,
171 double t
172 );
173
174
175 /*
176 Description:
177 Set the offset distance for an existing point
178 Parameters:
179 index - [in] index of the point to set
180 distance - [in] new distance
181 */
182 bool SetDistance(
183 int index,
184 double distance);
185
186
187 /*
188 Returns:
189 Number of points specified using SetOffsetPoint().
190 */
191 int OffsetPointCount() const;
192
193 /*
194 Parameters:
195 i - [in] an index >= 0 and < OffsetPointCount()
196 Returns:
197 Surface parameter specified using SetOffsetPoint().
198 */
199 ON_2dPoint OffsetSurfaceParameter(int i) const;
200
201 /*
202 Parameters:
203 i - [in] an index >= 0 and < OffsetPointCount()
204 Returns:
205 Offset distance specified using SetOffsetPoint().
206 */
207 double OffsetDistance(int i) const;
208
209 /*
210 Description:
211 Value of the offset distance at any surface parameter.
212 Parameters:
213 s - [in]
214 t - [in] (s,t) is a base surface evaluation parameter
215 Returns:
216 offset distance at the surface parameter
217 */
218 double DistanceAt(
219 double s,
220 double t
221 ) const;
222
223 /*
224 Description:
225 Value of the offset distance at any surface parameter.
226 Parameters:
227 s - [in]
228 t - [in] (s,t) is a base surface evaluation parameter
229 num_der - [in] number of derivatives
230 value - [out] value and derivatives of distance function
231 value[0] = distance, value[1] = 1rst derivative,
232 value[2] = 2nd derivative, ...
233 Returns:
234 True if successful
235 */
236 bool EvaluateDistance(
237 double s,
238 double t,
239 int num_der,
240 double* value
241 ) const;
242
243 /*
244 Description:
245 Value of the offset function at any surface parameter.
246 Parameters:
247 s - [in]
248 t - [in] (s,t) is a base surface evaluation parameter
249 Returns:
250 Point on the offset surface.
251 */
252 ON_3dPoint PointAt(
253 double s,
254 double t
255 ) const;
256
257 /*
258 Description:
259 Resets this class if you want to reuse it.
260 */
261 void Destroy();
262
263private:
264 friend class ON_OffsetSurface;
265 bool Initialize();
266
268
269 ON_Interval m_domain[2];
270
271 bool m_bZeroSideDerivative[4]; // S,E,N,W side
272
274
275
277
279};
280
282{
283 // This is still a work in progress. In particular,
284 // this surface class can not be saved in files, used
285 // as a brep surface, added to Rhino, etc.
286 //
287 // As of January 2004, it is useful for calculating
288 // offset meshes and any other fitting and approximation
289 // tools that requires a surface evaluator but do not need
290 // NURBS forms, isocurves, and so on.
292public:
296 ON_OffsetSurface& operator=(const ON_OffsetSurface& src);
297
298 ON_BOOL32 GetBBox(
299 double* bbox_min,
300 double* bbox_max,
301 int bGrowBox = false
302 ) const;
303
304 ON_BOOL32 Evaluate( // returns false if unable to evaluate
305 double, double, // evaluation parameters
306 int, // number of derivatives (>=0)
307 int, // array stride (>=Dimension())
308 double*, // array of length stride*(ndir+1)*(ndir+2)/2
309 int = 0, // optional - determines which quadrant to evaluate from
310 // 0 = default
311 // 1 from NE quadrant
312 // 2 from NW quadrant
313 // 3 from SW quadrant
314 // 4 from SE quadrant
315 int* = 0 // optional - evaluation hint (int[2]) used to speed
316 // repeated evaluations
317 ) const;
318
319 /*
320 Description:
321 Sets base surface to a surface that is not managed
322 by the ON_OffsetSurface class.
323 Parameters:
324 base_surface - [in] points to a base surface the
325 caller insures will exist for the lifetimes
326 of the ON_OffsetSurface class.
327 Returns:
328 True if successful.
329 */
330 bool SetBaseSurface(
331 const ON_Surface* base_surface
332 );
333
334 /*
335 Description:
336 Sets base surface to a surface that is optionally managed
337 by the ON_OffsetSurface class.
338 Parameters:
339 base_surface - [in] points to a base surface the
340 caller insures will exist for the lifetimes
341 of the ON_OffsetSurface class.
342 bManage - [in] if true, the base_surface must point
343 to a surface that is on the heap and the surface
344 will be deleted by ~ON_OffsetSurface.
345 Returns:
346 True if successful.
347 */
348 bool SetBaseSurface(
349 ON_Surface* base_surface,
350 bool bManage
351 );
352
353 /*
354 Returns:
355 Base surface;
356 */
357 const ON_Surface* BaseSurface() const;
358
359 ON_OffsetSurfaceFunction& OffsetFunction();
360 const ON_OffsetSurfaceFunction& OffsetFunction() const;
361
362private:
363 // If not NULL, this points to the base surface
366};
367
368
369#endif
int i
Copyright (c) 2011-2018 by Andrew Mustun.
Definition autostart.js:32
Definition opennurbs_point.h:253
Definition opennurbs_point.h:403
Definition opennurbs_offsetsurface.h:24
double m_x0
Definition opennurbs_offsetsurface.h:48
double m_y0
Definition opennurbs_offsetsurface.h:49
bool operator<(const ON_BumpFunction &other) const
Definition opennurbs_offsetsurface.cpp:881
void EvaluateHelperLinearBump(double t, double dt, int der_count, double *value) const
Definition opennurbs_offsetsurface.cpp:246
double m_a
Definition opennurbs_offsetsurface.h:52
bool operator==(const ON_BumpFunction &other) const
Definition opennurbs_offsetsurface.cpp:876
void EvaluateHelperQuinticBump(double t, double dt, int der_count, double *value) const
Definition opennurbs_offsetsurface.cpp:262
int m_type[2]
Definition opennurbs_offsetsurface.h:45
bool operator>(const ON_BumpFunction &other) const
Definition opennurbs_offsetsurface.cpp:886
ON_2dPoint m_point
Definition opennurbs_offsetsurface.h:44
ON_BumpFunction()
Definition opennurbs_offsetsurface.cpp:861
void Evaluate(double s, double t, int der_count, double *value) const
Definition opennurbs_offsetsurface.cpp:337
double m_sx[2]
Definition opennurbs_offsetsurface.h:50
double m_sy[2]
Definition opennurbs_offsetsurface.h:51
double ValueAt(double s, double t) const
Definition opennurbs_offsetsurface.cpp:891
Definition opennurbs_point.h:46
Definition opennurbs_offsetsurface.h:83
ON_SimpleArray< class ON_BumpFunction > m_bumps
Definition opennurbs_offsetsurface.h:276
bool m_bValid
Definition opennurbs_offsetsurface.h:278
friend class ON_OffsetSurface
Definition opennurbs_offsetsurface.h:264
const ON_Surface * m_srf
Definition opennurbs_offsetsurface.h:267
ON_SimpleArray< ON_OffsetSurfaceValue > m_offset_value
Definition opennurbs_offsetsurface.h:273
Definition opennurbs_offsetsurface.h:282
ON_OffsetSurfaceFunction m_offset_function
Definition opennurbs_offsetsurface.h:365
ON_OBJECT_DECLARE(ON_OffsetSurface)
ON_Surface * m__pSrf
Definition opennurbs_offsetsurface.h:364
Definition opennurbs_offsetsurface.h:60
double m_s
Definition opennurbs_offsetsurface.h:62
double m_radius
Definition opennurbs_offsetsurface.h:65
int m_index
Definition opennurbs_offsetsurface.h:66
double m_t
Definition opennurbs_offsetsurface.h:63
double m_distance
Definition opennurbs_offsetsurface.h:64
Definition opennurbs_array.h:46
Definition opennurbs_surface.h:58
Definition opennurbs_surfaceproxy.h:28
#define ON_CLASS
Definition opennurbs_defines.h:91
char s
Definition opennurbs_string.cpp:32
int ON_BOOL32
Definition opennurbs_system.h:362