openNURBS SDK Help
opennurbs_pointgrid.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_POINT_GRID_INC_)
18 #define OPENNURBS_POINT_GRID_INC_
19 
20 class ON_CLASS ON_PointGrid : public ON_Geometry
21 {
22 public:
23  ON_PointGrid();
24  ON_PointGrid(const ON_PointGrid&);
26  int, // point count0 (>=1)
27  int // point count1 (>=1)
28  );
29 
30  void Initialize(void); // zeros all fields
31 
32  bool Create(
33  int, // point count0 (>=1)
34  int // point count1 (>=1)
35  );
36 
37  void Destroy();
38 
39  virtual ~ON_PointGrid();
40  void EmergencyDestroy(); // call if memory used by point grid becomes invalid
41 
43 
44  // point_grid[i][j] returns GetPoint(i,j)
45  ON_3dPoint* operator[](int); // 0 <= index < PointCount(0)
46  const ON_3dPoint* operator[](int) const; // 0 <= index < PointCount(0)
47 
48  /////////////////////////////////////////////////////////////////
49  // ON_Object overrides
50 
51  bool IsValid( class ON_TextLog* text_log = nullptr ) const override;
52 
53  void Dump( ON_TextLog& ) const override; // for debugging
54 
55  bool Write(
56  ON_BinaryArchive& // open binary file
57  ) const override;
58 
59  bool Read(
60  ON_BinaryArchive& // open binary file
61  ) override;
62 
63  ON::object_type ObjectType() const override;
64 
65  /////////////////////////////////////////////////////////////////
66  // ON_Geometry overrides
67 
68  int Dimension() const override;
69 
70  // virtual ON_Geometry GetBBox override
71  bool GetBBox( double* boxmin, double* boxmax, bool bGrowBox = false ) const override;
72 
73  // virtual ON_Geometry GetTightBoundingBox override
74  bool GetTightBoundingBox( class ON_BoundingBox& tight_bbox, bool bGrowBox = false, const class ON_Xform* xform = nullptr ) const override;
75 
76  bool Transform(
77  const ON_Xform&
78  ) override;
79 
80  // virtual ON_Geometry::IsDeformable() override
81  bool IsDeformable() const override;
82 
83  // virtual ON_Geometry::MakeDeformable() override
84  bool MakeDeformable() override;
85 
86  bool SwapCoordinates(
87  int, int // indices of coords to swap
88  ) override;
89 
90  /////////////////////////////////////////////////////////////////
91  // Interface
92 
93  bool IsClosed(
94  int // dir
95  ) const;
96 
97  int PointCount( // number of points in grid direction
98  int // dir 0 = "s", 1 = "t"
99  ) const;
100 
101  int PointCount( // total number of points in grid
102  void
103  ) const;
104 
105  ON_3dPoint& Point(
106  int, int // point index ( 0 <= i <= PointCount(0), 0 <= j <= PointCount(1)
107  );
108 
109  ON_3dPoint Point(
110  int, int // point index ( 0 <= i <= PointCount(0), 0 <= j <= PointCount(1)
111  ) const;
112 
113  double* PointArray();
114 
115  const double* PointArray() const;
116 
117  int PointArrayStride( // point stride in grid direction
118  int // dir 0 = "s", 1 = "t"
119  ) const;
120 
121  bool SetPoint( // set a single point
122  int, int, // point index ( 0 <= i <= PointCount(0), 0 <= j <= PointCount(1)
123  const ON_3dPoint& // value of point
124  );
125 
126  bool GetPoint( // get a single control vertex
127  int, int, // CV index ( 0 <= i <= CVCount(0), 0 <= j <= CVCount(1)
128  ON_3dPoint& // gets euclidean cv when NURBS is rational
129  ) const;
130 
131  bool Reverse( // reverse grid order
132  int // dir 0 = "s", 1 = "t"
133  );
134 
135  bool Transpose(); // transpose grid points
136 
137  /////////////////////////////////////////////////////////////////
138  // Implementation
139 protected:
140 
141  int m_point_count[2]; // number of points (>=1)
142  int m_point_stride0; // >= m_point_count[1]
144  // point[i][j] = m_point[i*m_point_stride0+j]
145 
146 private:
147  static ON_3dPoint m_no_point; // prevent crashes when sizes are 0
148 
149  ON_OBJECT_DECLARE(ON_PointGrid);
150 };
151 
152 
153 #endif
virtual bool Transform(const ON_Xform &xform)
virtual int Dimension() const
virtual bool GetBBox(double *boxmin, double *boxmax, bool bGrowBox=false) const
virtual bool MakeDeformable()
int m_point_stride0
>= m_point_count[1]
Definition: opennurbs_pointgrid.h:142
virtual bool SwapCoordinates(int i, int j)
virtual ON::object_type ObjectType() const
Definition: opennurbs_geometry.h:36
virtual bool GetTightBoundingBox(class ON_BoundingBox &tight_bbox, bool bGrowBox=false, const class ON_Xform *xform=nullptr) const
Definition: opennurbs_point.h:2073
Definition: opennurbs_bounding_box.h:25
Definition: opennurbs_xform.h:28
virtual void Dump(ON_TextLog &) const
void EmergencyDestroy()
virtual bool IsDeformable() const
ON_Geometry & operator=(const ON_Geometry &)=default
Definition: opennurbs_textlog.h:20
< use for generic serialization of binary data
Definition: opennurbs_archive.h:1866
virtual bool Read(ON_BinaryArchive &binary_archive)
Definition: opennurbs_point.h:480
ON_3dPointArray m_point
Definition: opennurbs_pointgrid.h:143
bool IsValid(class ON_TextLog *text_log=nullptr) const override
virtual bool Write(ON_BinaryArchive &binary_archive) const
Definition: opennurbs_pointgrid.h:20