opennurbs_geometry.h
Go to the documentation of this file.
00001 /* $NoKeywords: $ */
00002 /*
00003 //
00004 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
00005 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
00006 // McNeel & Associates.
00007 //
00008 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
00009 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
00010 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
00011 //                              
00012 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
00013 //
00015 */
00016 
00018 //
00019 //   virtual base class for all geomtric objects
00020 //
00022 
00023 #if !defined(OPENNURBS_GEOMETRY_INC_)
00024 #define OPENNURBS_GEOMETRY_INC_
00025 
00026 class ON_Brep;
00027 
00029 
00030 // Description:
00031 //   Base class for all geometry classes that must
00032 //   provide runtime class id.  Provides interface
00033 //   for common geometric operations like finding bounding
00034 //   boxes and transforming.
00035 //
00036 class ON_CLASS ON_Geometry : public ON_Object
00037 {
00038   // Any object derived from ON_Geometry should have a
00039   //   ON_OBJECT_DECLARE(ON_...);
00040   // as the last line of its class definition and a
00041   //   ON_OBJECT_IMPLEMENT( ON_..., ON_baseclass );
00042   // in a .cpp file.
00043   //
00044   // See the definition of ON_Object for details.
00045   ON_OBJECT_DECLARE(ON_Geometry);
00046 
00047 public:
00048   ON_Geometry();
00049   ON_Geometry(const ON_Geometry&);
00050   ON_Geometry& operator=(const ON_Geometry&);
00051   virtual ~ON_Geometry();
00052 
00053   // Description: 
00054   //   Get object's 3d axis aligned bounding box.
00055   // Returns:
00056   //   3d bounding box.
00057   // Remarks:
00058   //   Uses virtual GetBBox() function to calculate the result.
00059   ON_BoundingBox BoundingBox() const;
00060 
00061   // Description:
00062   //   Get object's 3d axis aligned bounding box or the
00063   //   union of the input box with the object's bounding box.
00064   // Parameters:
00065   //   bbox - [in/out] 3d axis aligned bounding box
00066   //   bGrowBox - [in] (default=false) 
00067   //     If true, then the union of the input bbox and the 
00068   //     object's bounding box is returned in bbox.  
00069   //     If false, the object's bounding box is returned in bbox.
00070   // Returns:
00071   //   true if object has bounding box and calculation was successful.
00072   // Remarks:
00073   //   Uses virtual GetBBox() function to calculate the result.
00074   ON_BOOL32 GetBoundingBox(
00075          ON_BoundingBox& bbox,
00076          int bGrowBox = false
00077          ) const;
00078 
00079   // Description:
00080   //   Get corners of object's 3d axis aligned bounding box
00081   //   or the union of the input box with the object's bounding
00082   //   box.
00083   // Parameters:
00084   //   bbox_min - [in/out] minimum corner of the 3d bounding box
00085   //   bbox_max - [in/out] maximum corner of the 3d bounding box
00086   //   bGrowBox - [in] (default=false) 
00087   //     If true, then the union of the input bbox and the 
00088   //     object's bounding box is returned.
00089   //     If false, the object's bounding box is returned.
00090   // Returns:
00091   //   true if successful.
00092   ON_BOOL32 GetBoundingBox(
00093          ON_3dPoint& bbox_min,
00094          ON_3dPoint& bbox_max,
00095          int bGrowBox = false
00096          ) const;
00097 
00098   // Description:
00099   //   Rotates the object about the specified axis.  A positive
00100   //   rotation angle results in a counter-clockwise rotation
00101   //   about the axis (right hand rule).
00102   // Parameters:
00103   //   sin_angle - [in] sine of rotation angle
00104   //   cos_angle - [in] sine of rotation angle
00105   //   rotation_axis - [in] direction of the axis of rotation
00106   //   rotation_center - [in] point on the axis of rotation
00107   // Returns:
00108   //   true if object successfully rotated
00109   // Remarks:
00110   //   Uses virtual Transform() function to calculate the result.
00111   ON_BOOL32 Rotate(
00112         double sin_angle,
00113         double cos_angle,
00114         const ON_3dVector& rotation_axis,
00115         const ON_3dPoint& rotation_center
00116         );
00117 
00118   // Description:
00119   //   Rotates the object about the specified axis.  A positive
00120   //   rotation angle results in a counter-clockwise rotation
00121   //   about the axis (right hand rule).
00122   // Parameters:
00123   //   rotation_angle - [in] angle of rotation in radians
00124   //   rotation_axis - [in] direction of the axis of rotation
00125   //   rotation_center - [in] point on the axis of rotation
00126   // Returns:
00127   //   true if object successfully rotated
00128   // Remarks:
00129   //   Uses virtual Transform() function to calculate the result.
00130   ON_BOOL32 Rotate(
00131         double rotation_angle,
00132         const ON_3dVector& rotation_axis,
00133         const ON_3dPoint& rotation_center
00134         );
00135 
00136   // Description:
00137   //   Translates the object along the specified vector.
00138   // Parameters:
00139   //   translation_vector - [in] translation vector
00140   // Returns:
00141   //   true if object successfully translated
00142   // Remarks:
00143   //   Uses virtual Transform() function to calculate the result.
00144   ON_BOOL32 Translate( 
00145     const ON_3dVector& translation_vector
00146     );
00147 
00148   // Description:
00149   //   Scales the object by the specified facotor.  The scale is
00150   //   centered at the origin.
00151   // Parameters:
00152   //   scale_factor - [in] scale factor
00153   // Returns:
00154   //   true if object successfully scaled
00155   // Remarks:
00156   //   Uses virtual Transform() function to calculate the result.
00157   ON_BOOL32 Scale( 
00158     double scale_factor
00159     );
00160 
00161   // Description:
00162   //   Dimension of the object.
00163   // Returns:
00164   //   Dimension of the object.
00165   // Remarks:
00166   //   The dimension is typically three.  For parameter space trimming
00167   //   curves the dimension is two.  In rare cases the dimension can
00168   //   be one or greater than three.
00169   virtual 
00170   int Dimension() const = 0;
00171 
00172   // Description:
00173   //   This is the virtual function that actually calculates axis
00174   //   aligned bounding boxes.
00175   // Parameters:
00176   //   boxmin - [in/out] array of Dimension() doubles
00177   //   boxmax - [in/out] array of Dimension() doubles
00178   //   bGrowBox - [in] (default=false) 
00179   //     If true, then the union of the input bbox and the 
00180   //     object's bounding box is returned in bbox.  
00181   //     If false, the object's bounding box is returned in bbox.
00182   // Returns:
00183   //   true if object has bounding box and calculation was successful
00184   virtual
00185   ON_BOOL32 GetBBox(
00186          double* boxmin,
00187          double* boxmax,
00188          int bGrowBox = false
00189          ) const = 0;
00190 
00191   /*
00192         Description:
00193     Get tight bounding box.
00194         Parameters:
00195                 tight_bbox - [in/out] tight bounding box
00196                 bGrowBox -[in]  (default=false)                 
00197       If true and the input tight_bbox is valid, then returned
00198       tight_bbox is the union of the input tight_bbox and the 
00199       curve's tight bounding box.
00200                 xform -[in] (default=NULL)
00201       If not NULL, the tight bounding box of the transformed
00202       geometry is calculated.  The geometry is not modified.
00203         Returns:
00204     True if a valid tight_bbox is returned.
00205   Remarks:
00206     In general, GetTightBoundingBox is slower that BoundingBox,
00207     especially when xform is not null.
00208   */
00209   virtual
00210         bool GetTightBoundingBox( 
00211                         ON_BoundingBox& tight_bbox, 
00212       int bGrowBox = false,
00213                         const ON_Xform* xform = 0
00214       ) const;
00215 
00216   // Description:
00217   //   Some objects cache bounding box information.
00218   //   If you modify an object, then call ClearBoundingBox()
00219   //   to inform the object that any cached bounding boxes
00220   //   are invalid.  
00221   //
00222   // Remarks:
00223   //   Generally, ClearBoundingBox() overrides
00224   //   simply invalidate a cached bounding box and then wait
00225   //   for a call to GetBBox() before recomputing the bounding box.
00226   //
00227   //   The default implementation does nothing.
00228   virtual
00229   void ClearBoundingBox();
00230 
00231   /*
00232   Description:
00233     Transforms the object.
00234  
00235   Parameters:
00236     xform - [in] transformation to apply to object.
00237       If xform.IsSimilarity() is zero, then you may
00238       want to call MakeSquishy() before calling
00239       Transform.
00240  
00241   Remarks:
00242     When overriding this function, be sure to include a call
00243     to ON_Object::TransformUserData() which takes care of 
00244     transforming any ON_UserData that may be attached to 
00245     the object.
00246 
00247   See Also:
00248     ON_Geometry::IsDeformable();
00249 
00250   Remarks:
00251     Classes derived from ON_Geometry should call
00252     ON_Geometry::Transform() to handle user data
00253     transformations and then transform their
00254     definition.
00255   */
00256   virtual
00257   ON_BOOL32 Transform( 
00258          const ON_Xform& xform
00259          );
00260 
00261   /*
00262   Returns:
00263     True if object can be accuratly modified with 
00264     "squishy" transformations like projections, 
00265     shears, an non-uniform scaling.
00266   See Also:
00267     ON_Geometry::MakeDeformable();
00268   */
00269   virtual
00270   bool IsDeformable() const;
00271 
00272   /*
00273   Description:
00274     If possible, converts the object into a form that can
00275     be accuratly modified with "squishy" transformations
00276     like projections, shears, an non-uniform scaling.
00277   Returns:
00278     False if object cannot be converted to a deformable
00279     object.  True if object was already deformable or
00280     was converted into a deformable object.
00281   See Also:
00282     ON_Geometry::IsDeformable();
00283   */
00284   virtual
00285   bool MakeDeformable();
00286 
00287   // Description:
00288   //   Swaps object coordinate values with indices i and j.
00289   //
00290   // Parameters:
00291   //   i - [in] coordinate index
00292   //   j - [in] coordinate index
00293   //
00294   // Remarks:
00295   //   The default implementation uses the virtual Transform() 
00296   //   function to calculate the result.  If you are creating
00297   //   an object where Transform() is slow, coordinate swapping
00298   //   will be frequently used, and coordinate swapping can
00299   //   be quickly accomplished, then override this function.
00300   //
00301   // Example:
00302   //
00303   //          ON_Point point(7,8,9);
00304   //          point.SwapCoordinates(0,2);
00305   //          // point = (9,8,7)
00306   virtual
00307   ON_BOOL32 SwapCoordinates(
00308         int i,
00309         int j
00310         );
00311 
00312   /*
00313   Description:
00314     Query an object to see if it has an ON_Brep form.
00315   Result:
00316     Returns true if the virtual ON_Geometry::BrepForm can compute
00317     an ON_Brep representation of this object.
00318   Remarks:
00319     The default implementation of ON_Geometry::BrepForm returns 
00320     false.
00321   See Also
00322     ON_Geometry::BrepForm
00323   */
00324   virtual
00325   ON_BOOL32 HasBrepForm() const;
00326 
00327   /*
00328   Description:
00329     If possible, BrepForm() creates a brep form of the
00330     ON_Geometry. 
00331   Parameters:
00332     brep - [in] if not NULL, brep is used to store the brep
00333         form of the geometry.
00334   Result:
00335     Returns a pointer to on ON_Brep or NULL.  If the brep
00336     parameter is not NULL, then brep is returned if the
00337     geometry has a brep form and NULL is returned if the
00338     geometry does not have a brep form.
00339   Remarks:
00340     The caller is responsible for managing the brep memory.
00341   See Also
00342     ON_Geometry::HasBrepForm
00343   */
00344   virtual
00345   ON_Brep* BrepForm( ON_Brep* brep = NULL ) const;
00346 
00347   /*
00348   Description:
00349     If this piece of geometry is a component in something
00350     larger, like an ON_BrepEdge in an ON_Brep, then this
00351     function returns the component index.
00352   Returns:
00353     This object's component index.  If this object is
00354     not a sub-piece of a larger geometric entity, then
00355     the returned index has 
00356     m_type = ON_COMPONENT_INDEX::invalid_type
00357     and
00358     m_index = -1.
00359   */
00360   virtual
00361   ON_COMPONENT_INDEX ComponentIndex() const;
00362 
00363   /*
00364   Description:
00365     Evaluate the location of a point from the object
00366     reference.
00367   Parameters:
00368     objref - [in]
00369     point - [out]
00370       If the evaluation cannot be performed, ON_UNSET_POINT
00371       is returned.
00372   Returns:
00373     True if successful.
00374   */
00375   virtual
00376   bool EvaluatePoint( const class ON_ObjRef& objref, ON_3dPoint& P ) const;
00377 };
00378 
00379 #endif
00380 


pcl
Author(s): Open Perception
autogenerated on Wed Aug 26 2015 15:27:01