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 00017 #if !defined(OPENNURBS_POINT_GRID_INC_) 00018 #define OPENNURBS_POINT_GRID_INC_ 00019 00020 class ON_CLASS ON_PointGrid : public ON_Geometry 00021 { 00022 public: 00023 ON_PointGrid(); 00024 ON_PointGrid(const ON_PointGrid&); 00025 ON_PointGrid( 00026 int, // point count0 (>=1) 00027 int // point count1 (>=1) 00028 ); 00029 00030 void Initialize(void); // zeros all fields 00031 00032 ON_BOOL32 Create( 00033 int, // point count0 (>=1) 00034 int // point count1 (>=1) 00035 ); 00036 00037 void Destroy(); 00038 00039 virtual ~ON_PointGrid(); 00040 void EmergencyDestroy(); // call if memory used by point grid becomes invalid 00041 00042 ON_PointGrid& operator=(const ON_PointGrid&); 00043 00044 // point_grid[i][j] returns GetPoint(i,j) 00045 ON_3dPoint* operator[](int); // 0 <= index < PointCount(0) 00046 const ON_3dPoint* operator[](int) const; // 0 <= index < PointCount(0) 00047 00049 // ON_Object overrides 00050 00051 /* 00052 Description: 00053 Tests an object to see if its data members are correctly 00054 initialized. 00055 Parameters: 00056 text_log - [in] if the object is not valid and text_log 00057 is not NULL, then a brief englis description of the 00058 reason the object is not valid is appened to the log. 00059 The information appended to text_log is suitable for 00060 low-level debugging purposes by programmers and is 00061 not intended to be useful as a high level user 00062 interface tool. 00063 Returns: 00064 @untitled table 00065 true object is valid 00066 false object is invalid, uninitialized, etc. 00067 Remarks: 00068 Overrides virtual ON_Object::IsValid 00069 */ 00070 ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const; 00071 00072 void Dump( ON_TextLog& ) const; // for debugging 00073 00074 ON_BOOL32 Write( 00075 ON_BinaryArchive& // open binary file 00076 ) const; 00077 00078 ON_BOOL32 Read( 00079 ON_BinaryArchive& // open binary file 00080 ); 00081 00082 ON::object_type ObjectType() const; 00083 00085 // ON_Geometry overrides 00086 00087 int Dimension() const; 00088 00089 ON_BOOL32 GetBBox( // returns true if successful 00090 double*, // minimum 00091 double*, // maximum 00092 ON_BOOL32 = false // true means grow box 00093 ) const; 00094 00095 /* 00096 Description: 00097 Get tight bounding box of the point grid. 00098 Parameters: 00099 tight_bbox - [in/out] tight bounding box 00100 bGrowBox -[in] (default=false) 00101 If true and the input tight_bbox is valid, then returned 00102 tight_bbox is the union of the input tight_bbox and the 00103 tight bounding box of the point grid. 00104 xform -[in] (default=NULL) 00105 If not NULL, the tight bounding box of the transformed 00106 point grid is calculated. The point grid is not modified. 00107 Returns: 00108 True if the returned tight_bbox is set to a valid 00109 bounding box. 00110 */ 00111 bool GetTightBoundingBox( 00112 ON_BoundingBox& tight_bbox, 00113 int bGrowBox = false, 00114 const ON_Xform* xform = 0 00115 ) const; 00116 00117 ON_BOOL32 Transform( 00118 const ON_Xform& 00119 ); 00120 00121 // virtual ON_Geometry::IsDeformable() override 00122 bool IsDeformable() const; 00123 00124 // virtual ON_Geometry::MakeDeformable() override 00125 bool MakeDeformable(); 00126 00127 ON_BOOL32 SwapCoordinates( 00128 int, int // indices of coords to swap 00129 ); 00130 00132 // Interface 00133 00134 ON_BOOL32 IsClosed( 00135 int // dir 00136 ) const; 00137 00138 int PointCount( // number of points in grid direction 00139 int // dir 0 = "s", 1 = "t" 00140 ) const; 00141 00142 int PointCount( // total number of points in grid 00143 void 00144 ) const; 00145 00146 ON_3dPoint& Point( 00147 int, int // point index ( 0 <= i <= PointCount(0), 0 <= j <= PointCount(1) 00148 ); 00149 00150 ON_3dPoint Point( 00151 int, int // point index ( 0 <= i <= PointCount(0), 0 <= j <= PointCount(1) 00152 ) const; 00153 00154 double* PointArray(); 00155 00156 const double* PointArray() const; 00157 00158 int PointArrayStride( // point stride in grid direction 00159 int // dir 0 = "s", 1 = "t" 00160 ) const; 00161 00162 ON_BOOL32 SetPoint( // set a single point 00163 int, int, // point index ( 0 <= i <= PointCount(0), 0 <= j <= PointCount(1) 00164 const ON_3dPoint& // value of point 00165 ); 00166 00167 ON_BOOL32 GetPoint( // get a single control vertex 00168 int, int, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1) 00169 ON_3dPoint& // gets euclidean cv when NURBS is rational 00170 ) const; 00171 00172 ON_BOOL32 Reverse( // reverse grid order 00173 int // dir 0 = "s", 1 = "t" 00174 ); 00175 00176 ON_BOOL32 Transpose(); // transpose grid points 00177 00179 // Implementation 00180 protected: 00181 00182 int m_point_count[2]; // number of points (>=1) 00183 int m_point_stride0; // >= m_point_count[1] 00184 ON_3dPointArray m_point; 00185 // point[i][j] = m_point[i*m_point_stride0+j] 00186 00187 private: 00188 static ON_3dPoint m_no_point; // prevent crashes when sizes are 0 00189 00190 ON_OBJECT_DECLARE(ON_PointGrid); 00191 }; 00192 00193 00194 #endif