Point Cloud Library (PCL)
1.7.0
|
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 // 00014 //////////////////////////////////////////////////////////////// 00015 */ 00016 00017 #if !defined(ON_OFFSETSURFACE_INC_) 00018 #define ON_OFFSETSURFACE_INC_ 00019 00020 // This file is to be used in V3 plug-ins. 00021 // In V4, this will be included as part of opennurbs. 00022 // Ask Dale Lear if you have any questions. 00023 00024 class ON_BumpFunction 00025 { 00026 public: 00027 ON_BumpFunction(); 00028 00029 bool operator==(const ON_BumpFunction& other) const; 00030 bool operator<(const ON_BumpFunction& other) const; 00031 bool operator>(const ON_BumpFunction& other) const; 00032 00033 double ValueAt( 00034 double s, 00035 double t 00036 ) const; 00037 00038 void Evaluate( 00039 double s, 00040 double t, 00041 int der_count, 00042 double* value 00043 ) const; 00044 00045 ON_2dPoint m_point; // center of bump 00046 int m_type[2]; // 1 = linear, 5 = quintic; 00047 00048 // numbers used in evaluation 00049 double m_x0; 00050 double m_y0; 00051 double m_sx[2]; // 1/(suppor radius) 00052 double m_sy[2]; // 1/(suppor radius) 00053 double m_a; // evaluation coefficient 00054 00055 void EvaluateHelperLinearBump(double t, double dt, int der_count, double* value) const; 00056 void EvaluateHelperQuinticBump(double t, double dt, int der_count, double* value) const; 00057 }; 00058 00059 00060 class ON_OffsetSurfaceValue 00061 { 00062 public: 00063 double m_s; 00064 double m_t; 00065 double m_distance; 00066 double m_radius; 00067 int m_index; 00068 }; 00069 00070 00071 #if defined(ON_DLL_TEMPLATE) 00072 // This stuff is here because of a limitation in the way Microsoft 00073 // handles templates and DLLs. See Microsoft's knowledge base 00074 // article ID Q168958 for details. 00075 #pragma warning( push ) 00076 #pragma warning( disable : 4231 ) 00077 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_BumpFunction>; 00078 ON_DLL_TEMPLATE template class ON_CLASS ON_SimpleArray<ON_OffsetSurfaceValue>; 00079 #pragma warning( pop ) 00080 #endif 00081 00082 00083 class ON_CLASS ON_OffsetSurfaceFunction 00084 { 00085 public: 00086 ON_OffsetSurfaceFunction(); 00087 ~ON_OffsetSurfaceFunction(); 00088 00089 /* 00090 Description: 00091 Sets base surface for the offset function. 00092 Parameters: 00093 srf - [in] pointer to the base surface. 00094 This surface must remain valid while 00095 the ON_OffsetSurfaceFunction class is used. 00096 Returns: 00097 True if successful. 00098 */ 00099 bool SetBaseSurface( 00100 const ON_Surface* srf 00101 ); 00102 00103 /* 00104 Returns: 00105 Base surface specified SetBaseSurface(). 00106 */ 00107 const ON_Surface* BaseSurface() const; 00108 00109 /* 00110 Description: 00111 Use set SetSideTangency if you want the offset 00112 surface and base surface to have the same unit 00113 normals along a side of the surfaces's parameter 00114 spaces. 00115 Parameters: 00116 side - [in] 00117 0 = south side 00118 1 = east side 00119 2 = north side 00120 3 = west side 00121 bEnable - [in] true to enable tangency, 00122 false to disable tangency 00123 Returns: 00124 True if successful. 00125 */ 00126 bool SetSideTangency( 00127 int side, 00128 bool bEnable 00129 ); 00130 00131 /* 00132 Parameters: 00133 side - [in] 00134 0 = south side 00135 1 = east side 00136 2 = north side 00137 3 = west side 00138 Returns: 00139 True if side tangency is enabled. 00140 */ 00141 bool SideTangency(int side) const; 00142 00143 /* 00144 Description: 00145 Sets the offset distance at a point. Call this function 00146 once for each point wher the user specifies an offset. 00147 Parameters: 00148 s - [in] 00149 t - [in] (s,t) is a base surface evaluation parameter 00150 distance - [in] distance is the offset distance. 00151 radius - [in] if radius>0, then this value will be the 00152 the approximate radius of the offset "bump". 00153 */ 00154 bool SetOffsetPoint( 00155 double s, 00156 double t, 00157 double distance, 00158 double radius = 0.0 00159 ); 00160 00161 /* 00162 Description: 00163 Sets the surface parameters of an existing offset point. 00164 Parameters: 00165 index - [in] index of the point to set 00166 s - [in] 00167 t - [in] (s,t) is a base surface evaluation parameter 00168 */ 00169 bool SetPoint( 00170 int index, 00171 double s, 00172 double t 00173 ); 00174 00175 00176 /* 00177 Description: 00178 Set the offset distance for an existing point 00179 Parameters: 00180 index - [in] index of the point to set 00181 distance - [in] new distance 00182 */ 00183 bool SetDistance( 00184 int index, 00185 double distance); 00186 00187 00188 /* 00189 Returns: 00190 Number of points specified using SetOffsetPoint(). 00191 */ 00192 int OffsetPointCount() const; 00193 00194 /* 00195 Parameters: 00196 i - [in] an index >= 0 and < OffsetPointCount() 00197 Returns: 00198 Surface parameter specified using SetOffsetPoint(). 00199 */ 00200 ON_2dPoint OffsetSurfaceParameter(int i) const; 00201 00202 /* 00203 Parameters: 00204 i - [in] an index >= 0 and < OffsetPointCount() 00205 Returns: 00206 Offset distance specified using SetOffsetPoint(). 00207 */ 00208 double OffsetDistance(int i) const; 00209 00210 /* 00211 Description: 00212 Value of the offset distance at any surface parameter. 00213 Parameters: 00214 s - [in] 00215 t - [in] (s,t) is a base surface evaluation parameter 00216 Returns: 00217 offset distance at the surface parameter 00218 */ 00219 double DistanceAt( 00220 double s, 00221 double t 00222 ) const; 00223 00224 /* 00225 Description: 00226 Value of the offset distance at any surface parameter. 00227 Parameters: 00228 s - [in] 00229 t - [in] (s,t) is a base surface evaluation parameter 00230 num_der - [in] number of derivatives 00231 value - [out] value and derivatives of distance function 00232 value[0] = distance, value[1] = 1rst derivative, 00233 value[2] = 2nd derivative, ... 00234 Returns: 00235 True if successful 00236 */ 00237 bool EvaluateDistance( 00238 double s, 00239 double t, 00240 int num_der, 00241 double* value 00242 ) const; 00243 00244 /* 00245 Description: 00246 Value of the offset function at any surface parameter. 00247 Parameters: 00248 s - [in] 00249 t - [in] (s,t) is a base surface evaluation parameter 00250 Returns: 00251 Point on the offset surface. 00252 */ 00253 ON_3dPoint PointAt( 00254 double s, 00255 double t 00256 ) const; 00257 00258 /* 00259 Description: 00260 Resets this class if you want to reuse it. 00261 */ 00262 void Destroy(); 00263 00264 private: 00265 friend class ON_OffsetSurface; 00266 bool Initialize(); 00267 00268 const ON_Surface* m_srf; 00269 00270 ON_Interval m_domain[2]; 00271 00272 bool m_bZeroSideDerivative[4]; // S,E,N,W side 00273 00274 ON_SimpleArray<ON_OffsetSurfaceValue> m_offset_value; 00275 00276 00277 ON_SimpleArray<class ON_BumpFunction> m_bumps; 00278 00279 bool m_bValid; 00280 }; 00281 00282 class ON_CLASS ON_OffsetSurface : public ON_SurfaceProxy 00283 { 00284 // This is still a work in progress. In particular, 00285 // this surface class can not be saved in files, used 00286 // as a brep surface, added to Rhino, etc. 00287 // 00288 // As of January 2004, it is useful for calculating 00289 // offset meshes and any other fitting and approximation 00290 // tools that requires a surface evaluator but do not need 00291 // NURBS forms, isocurves, and so on. 00292 ON_OBJECT_DECLARE(ON_OffsetSurface); 00293 public: 00294 ON_OffsetSurface(); 00295 ~ON_OffsetSurface(); 00296 ON_OffsetSurface( const ON_OffsetSurface& src); 00297 ON_OffsetSurface& operator=(const ON_OffsetSurface& src); 00298 00299 ON_BOOL32 GetBBox( 00300 double* bbox_min, 00301 double* bbox_max, 00302 int bGrowBox = false 00303 ) const; 00304 00305 ON_BOOL32 Evaluate( // returns false if unable to evaluate 00306 double, double, // evaluation parameters 00307 int, // number of derivatives (>=0) 00308 int, // array stride (>=Dimension()) 00309 double*, // array of length stride*(ndir+1)*(ndir+2)/2 00310 int = 0, // optional - determines which quadrant to evaluate from 00311 // 0 = default 00312 // 1 from NE quadrant 00313 // 2 from NW quadrant 00314 // 3 from SW quadrant 00315 // 4 from SE quadrant 00316 int* = 0 // optional - evaluation hint (int[2]) used to speed 00317 // repeated evaluations 00318 ) const; 00319 00320 /* 00321 Description: 00322 Sets base surface to a surface that is not managed 00323 by the ON_OffsetSurface class. 00324 Parameters: 00325 base_surface - [in] points to a base surface the 00326 caller insures will exist for the lifetimes 00327 of the ON_OffsetSurface class. 00328 Returns: 00329 True if successful. 00330 */ 00331 bool SetBaseSurface( 00332 const ON_Surface* base_surface 00333 ); 00334 00335 /* 00336 Description: 00337 Sets base surface to a surface that is optionally managed 00338 by the ON_OffsetSurface class. 00339 Parameters: 00340 base_surface - [in] points to a base surface the 00341 caller insures will exist for the lifetimes 00342 of the ON_OffsetSurface class. 00343 bManage - [in] if true, the base_surface must point 00344 to a surface that is on the heap and the surface 00345 will be deleted by ~ON_OffsetSurface. 00346 Returns: 00347 True if successful. 00348 */ 00349 bool SetBaseSurface( 00350 ON_Surface* base_surface, 00351 bool bManage 00352 ); 00353 00354 /* 00355 Returns: 00356 Base surface; 00357 */ 00358 const ON_Surface* BaseSurface() const; 00359 00360 ON_OffsetSurfaceFunction& OffsetFunction(); 00361 const ON_OffsetSurfaceFunction& OffsetFunction() const; 00362 00363 private: 00364 // If not NULL, this points to the base surface 00365 ON_Surface* m__pSrf; 00366 ON_OffsetSurfaceFunction m_offset_function; 00367 }; 00368 00369 00370 #endif