QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
opennurbs_geometry.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
17//
18// virtual base class for all geomtric objects
19//
21
22#if !defined(OPENNURBS_GEOMETRY_INC_)
23#define OPENNURBS_GEOMETRY_INC_
24
25class ON_Brep;
26
28
29// Description:
30// Base class for all geometry classes that must
31// provide runtime class id. Provides interface
32// for common geometric operations like finding bounding
33// boxes and transforming.
34//
36{
37 // Any object derived from ON_Geometry should have a
38 // ON_OBJECT_DECLARE(ON_...);
39 // as the last line of its class definition and a
40 // ON_OBJECT_IMPLEMENT( ON_..., ON_baseclass );
41 // in a .cpp file.
42 //
43 // See the definition of ON_Object for details.
45
46public:
50 virtual ~ON_Geometry();
51
52 // Description:
53 // Get object's 3d axis aligned bounding box.
54 // Returns:
55 // 3d bounding box.
56 // Remarks:
57 // Uses virtual GetBBox() function to calculate the result.
58 ON_BoundingBox BoundingBox() const;
59
60 // Description:
61 // Get object's 3d axis aligned bounding box or the
62 // union of the input box with the object's bounding box.
63 // Parameters:
64 // bbox - [in/out] 3d axis aligned bounding box
65 // bGrowBox - [in] (default=false)
66 // If true, then the union of the input bbox and the
67 // object's bounding box is returned in bbox.
68 // If false, the object's bounding box is returned in bbox.
69 // Returns:
70 // true if object has bounding box and calculation was successful.
71 // Remarks:
72 // Uses virtual GetBBox() function to calculate the result.
73 ON_BOOL32 GetBoundingBox(
74 ON_BoundingBox& bbox,
75 int bGrowBox = false
76 ) const;
77
78 // Description:
79 // Get corners of object's 3d axis aligned bounding box
80 // or the union of the input box with the object's bounding
81 // box.
82 // Parameters:
83 // bbox_min - [in/out] minimum corner of the 3d bounding box
84 // bbox_max - [in/out] maximum corner of the 3d bounding box
85 // bGrowBox - [in] (default=false)
86 // If true, then the union of the input bbox and the
87 // object's bounding box is returned.
88 // If false, the object's bounding box is returned.
89 // Returns:
90 // true if successful.
91 ON_BOOL32 GetBoundingBox(
92 ON_3dPoint& bbox_min,
93 ON_3dPoint& bbox_max,
94 int bGrowBox = false
95 ) const;
96
97 // Description:
98 // Rotates the object about the specified axis. A positive
99 // rotation angle results in a counter-clockwise rotation
100 // about the axis (right hand rule).
101 // Parameters:
102 // sin_angle - [in] sine of rotation angle
103 // cos_angle - [in] sine of rotation angle
104 // rotation_axis - [in] direction of the axis of rotation
105 // rotation_center - [in] point on the axis of rotation
106 // Returns:
107 // true if object successfully rotated
108 // Remarks:
109 // Uses virtual Transform() function to calculate the result.
111 double sin_angle,
112 double cos_angle,
113 const ON_3dVector& rotation_axis,
114 const ON_3dPoint& rotation_center
115 );
116
117 // Description:
118 // Rotates the object about the specified axis. A positive
119 // rotation angle results in a counter-clockwise rotation
120 // about the axis (right hand rule).
121 // Parameters:
122 // rotation_angle - [in] angle of rotation in radians
123 // rotation_axis - [in] direction of the axis of rotation
124 // rotation_center - [in] point on the axis of rotation
125 // Returns:
126 // true if object successfully rotated
127 // Remarks:
128 // Uses virtual Transform() function to calculate the result.
130 double rotation_angle,
131 const ON_3dVector& rotation_axis,
132 const ON_3dPoint& rotation_center
133 );
134
135 // Description:
136 // Translates the object along the specified vector.
137 // Parameters:
138 // translation_vector - [in] translation vector
139 // Returns:
140 // true if object successfully translated
141 // Remarks:
142 // Uses virtual Transform() function to calculate the result.
144 const ON_3dVector& translation_vector
145 );
146
147 // Description:
148 // Scales the object by the specified facotor. The scale is
149 // centered at the origin.
150 // Parameters:
151 // scale_factor - [in] scale factor
152 // Returns:
153 // true if object successfully scaled
154 // Remarks:
155 // Uses virtual Transform() function to calculate the result.
157 double scale_factor
158 );
159
160 // Description:
161 // Dimension of the object.
162 // Returns:
163 // Dimension of the object.
164 // Remarks:
165 // The dimension is typically three. For parameter space trimming
166 // curves the dimension is two. In rare cases the dimension can
167 // be one or greater than three.
168 virtual
169 int Dimension() const = 0;
170
171 // Description:
172 // This is the virtual function that actually calculates axis
173 // aligned bounding boxes.
174 // Parameters:
175 // boxmin - [in/out] array of Dimension() doubles
176 // boxmax - [in/out] array of Dimension() doubles
177 // bGrowBox - [in] (default=false)
178 // If true, then the union of the input bbox and the
179 // object's bounding box is returned in bbox.
180 // If false, the object's bounding box is returned in bbox.
181 // Returns:
182 // true if object has bounding box and calculation was successful
183 virtual
185 double* boxmin,
186 double* boxmax,
187 int bGrowBox = false
188 ) const = 0;
189
190 /*
191 Description:
192 Get tight bounding box.
193 Parameters:
194 tight_bbox - [in/out] tight bounding box
195 bGrowBox -[in] (default=false)
196 If true and the input tight_bbox is valid, then returned
197 tight_bbox is the union of the input tight_bbox and the
198 curve's tight bounding box.
199 xform -[in] (default=NULL)
200 If not NULL, the tight bounding box of the transformed
201 geometry is calculated. The geometry is not modified.
202 Returns:
203 True if a valid tight_bbox is returned.
204 Remarks:
205 In general, GetTightBoundingBox is slower that BoundingBox,
206 especially when xform is not null.
207 */
208 virtual
209 bool GetTightBoundingBox(
210 ON_BoundingBox& tight_bbox,
211 int bGrowBox = false,
212 const ON_Xform* xform = 0
213 ) const;
214
215 // Description:
216 // Some objects cache bounding box information.
217 // If you modify an object, then call ClearBoundingBox()
218 // to inform the object that any cached bounding boxes
219 // are invalid.
220 //
221 // Remarks:
222 // Generally, ClearBoundingBox() overrides
223 // simply invalidate a cached bounding box and then wait
224 // for a call to GetBBox() before recomputing the bounding box.
225 //
226 // The default implementation does nothing.
227 virtual
228 void ClearBoundingBox();
229
230 /*
231 Description:
232 Transforms the object.
233
234 Parameters:
235 xform - [in] transformation to apply to object.
236 If xform.IsSimilarity() is zero, then you may
237 want to call MakeSquishy() before calling
238 Transform.
239
240 Remarks:
241 When overriding this function, be sure to include a call
242 to ON_Object::TransformUserData() which takes care of
243 transforming any ON_UserData that may be attached to
244 the object.
245
246 See Also:
247 ON_Geometry::IsDeformable();
248
249 Remarks:
250 Classes derived from ON_Geometry should call
251 ON_Geometry::Transform() to handle user data
252 transformations and then transform their
253 definition.
254 */
255 virtual
257 const ON_Xform& xform
258 );
259
260 /*
261 Returns:
262 True if object can be accuratly modified with
263 "squishy" transformations like projections,
264 shears, an non-uniform scaling.
265 See Also:
266 ON_Geometry::MakeDeformable();
267 */
268 virtual
269 bool IsDeformable() const;
270
271 /*
272 Description:
273 If possible, converts the object into a form that can
274 be accuratly modified with "squishy" transformations
275 like projections, shears, an non-uniform scaling.
276 Returns:
277 False if object cannot be converted to a deformable
278 object. True if object was already deformable or
279 was converted into a deformable object.
280 See Also:
281 ON_Geometry::IsDeformable();
282 */
283 virtual
284 bool MakeDeformable();
285
286 // Description:
287 // Swaps object coordinate values with indices i and j.
288 //
289 // Parameters:
290 // i - [in] coordinate index
291 // j - [in] coordinate index
292 //
293 // Remarks:
294 // The default implementation uses the virtual Transform()
295 // function to calculate the result. If you are creating
296 // an object where Transform() is slow, coordinate swapping
297 // will be frequently used, and coordinate swapping can
298 // be quickly accomplished, then override this function.
299 //
300 // Example:
301 //
302 // ON_Point point(7,8,9);
303 // point.SwapCoordinates(0,2);
304 // // point = (9,8,7)
305 virtual
306 ON_BOOL32 SwapCoordinates(
307 int i,
308 int j
309 );
310
311
312 /*
313 Description:
314 Apply the space morph to this geometry.
315 Parameters:
316 morph - [in]
317 Returns:
318 True is successful. If false is returned,
319 the object may be damaged and should be discarded.
320 See Also:
321 ON_Geometry::IsMorphable
322 */
323 virtual
324 bool Morph( const ON_SpaceMorph& morph );
325
326 /*
327 Returns:
328 True if the object can be morphed by calling Morph().
329 See Also:
330 ON_Geometry::Morph
331 */
332 virtual
333 bool IsMorphable() const;
334
335 /*
336 Description:
337 Query an object to see if it has an ON_Brep form.
338 Result:
339 Returns true if the virtual ON_Geometry::BrepForm can compute
340 an ON_Brep representation of this object.
341 Remarks:
342 The default implementation of ON_Geometry::BrepForm returns
343 false.
344 See Also
345 ON_Geometry::BrepForm
346 */
347 virtual
348 ON_BOOL32 HasBrepForm() const;
349
350 /*
351 Description:
352 If possible, BrepForm() creates a brep form of the
353 ON_Geometry.
354 Parameters:
355 brep - [in] if not NULL, brep is used to store the brep
356 form of the geometry.
357 Result:
358 Returns a pointer to on ON_Brep or NULL. If the brep
359 parameter is not NULL, then brep is returned if the
360 geometry has a brep form and NULL is returned if the
361 geometry does not have a brep form.
362 Remarks:
363 The caller is responsible for managing the brep memory.
364 See Also
365 ON_Geometry::HasBrepForm
366 */
367 virtual
368 ON_Brep* BrepForm( ON_Brep* brep = NULL ) const;
369
370 /*
371 Description:
372 If this piece of geometry is a component in something
373 larger, like an ON_BrepEdge in an ON_Brep, then this
374 function returns the component index.
375 Returns:
376 This object's component index. If this object is
377 not a sub-piece of a larger geometric entity, then
378 the returned index has
379 m_type = ON_COMPONENT_INDEX::invalid_type
380 and
381 m_index = -1.
382 */
383 virtual
384 ON_COMPONENT_INDEX ComponentIndex() const;
385
386 /*
387 Description:
388 Evaluate the location of a point from the object
389 reference.
390 Parameters:
391 objref - [in]
392 point - [out]
393 If the evaluation cannot be performed, ON_UNSET_POINT
394 is returned.
395 Returns:
396 True if successful.
397 */
398 virtual
399 bool EvaluatePoint( const class ON_ObjRef& objref, ON_3dPoint& P ) const;
400};
401
402#endif
403
@ Transform
Definition RSMetaType.h:67
int i
Copyright (c) 2011-2018 by Andrew Mustun.
Definition autostart.js:32
Definition opennurbs_point.h:403
Definition opennurbs_point.h:931
Definition opennurbs_bounding_box.h:25
Definition opennurbs_brep.h:1585
Definition opennurbs_geometry.h:36
virtual ON_BOOL32 GetBBox(double *boxmin, double *boxmax, int bGrowBox=false) const =0
ON_OBJECT_DECLARE(ON_Geometry)
virtual int Dimension() const =0
Definition opennurbs_objref.h:167
Definition opennurbs_object.h:393
ON_Object & operator=(const ON_Object &)
Definition opennurbs_object.cpp:1362
Definition opennurbs_xform.h:1146
Definition opennurbs_xform.h:28
Rotates selected entities.
Definition Rotate.js:11
Scales selected entities.
Definition Scale.js:11
Translates (moves or copies) selected entities.
Definition Translate.js:11
#define ON_CLASS
Definition opennurbs_defines.h:91
#define NULL
Definition opennurbs_system.h:256
int ON_BOOL32
Definition opennurbs_system.h:362