Point Cloud Library (PCL)  1.14.1-dev
opennurbs_pointcloud.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_POINTCLOUD_INC_)
18 #define OPENNURBS_POINTCLOUD_INC_
19 
20 ///////////////////////////////////////////////////////////////////////////////
21 //
22 // Class ON_PointCloud - unordered set of points
23 // ON_PointField - point height field
24 //
25 
26 class ON_CLASS ON_PointCloud : public ON_Geometry
27 {
28  ON_OBJECT_DECLARE(ON_PointCloud);
29 
30 public:
33  int // initial point array capacity
34  );
38 
40  const ON_3dPoint& operator[](int) const;
41 
42  /*
43  Description:
44  Get a point cloud point from an ON_COMPONENT_INDEX.
45  Parameters:
46  ci - [in] a component index with m_typ set to ON_COMPONENT_INDEX::pointcloud_point
47  and 0 <= m_index and m_index < m_P.Count().
48  Returns:
49  Point at [ci.m_index] or ON_UNSET_POINT if ci is not valid.
50  */
51  ON_3dPoint Point( ON_COMPONENT_INDEX ci ) const;
52 
53  void Destroy();
54 
55  /*
56  Description:
57  Call when the memory pool used the point cloud's arrays is
58  no longer in existence.
59  */
61 
62  // virtual ON_Object override
63  ON_BOOL32 IsValid( ON_TextLog* text_log = NULL ) const;
64 
65  // virtual ON_Object override
66  void Dump( ON_TextLog& ) const; // for debugging
67 
68  // virtual ON_Object override
69  ON_BOOL32 Write( ON_BinaryArchive& ) const;
70 
71  // virtual ON_Object override
72  ON_BOOL32 Read( ON_BinaryArchive& );
73 
74  // virtual ON_Object override
75  ON::object_type ObjectType() const;
76 
77  // virtual ON_Geometry override
78  int Dimension() const;
79 
80  // virtual ON_Geometry override
81  ON_BOOL32 GetBBox( // returns true if successful
82  double*, // minimum
83  double*, // maximum
84  ON_BOOL32 = false // true means grow box
85  ) const;
86 
87  // virtual ON_Geometry override
89  ON_BoundingBox& tight_bbox,
90  int bGrowBox = false,
91  const ON_Xform* xform = 0
92  ) const;
93 
94  // virtual ON_Geometry override
95  ON_BOOL32 Transform(
96  const ON_Xform&
97  );
98 
99  // virtual ON_Geometry override
100  bool IsDeformable() const;
101 
102  // virtual ON_Geometry override
104 
105  // virtual ON_Geometry override
106  ON_BOOL32 SwapCoordinates(
107  int, int // indices of coords to swap
108  );
109 
110  /*
111  Description:
112  Get the index of the point in the point cloud that is closest
113  to P.
114  Parameters:
115  P - [in]
116  closest_point_index - [out]
117  maximum_distance - [in] optional distance constraint.
118  If maximum_distance > 0, then only points Q with
119  |P-Q| <= maximum_distance are tested.
120  Returns:
121  True if a point is found; in which case *closest_point_index
122  is the index of the point. False if no point is found
123  or the input is not valid.
124  See Also:
125  ON_GetClosestPointInPointList
126  */
128  ON_3dPoint P,
129  int* closest_point_index,
130  double maximum_distance = 0.0
131  ) const;
132 
133 
134  /////////////////////////////////////////////////////////////////
135  // Interface
136  //
137  int PointCount() const;
138  void AppendPoint( const ON_3dPoint& );
139  void InvalidateBoundingBox(); // call if you change values of points
140 
141  // for ordered streams
142  void SetOrdered(bool bOrdered); // true if set is ordered stream
143  bool IsOrdered() const; // true if set is ordered stream
144 
145  // for height fields
146  bool HasPlane() const; // true if set is height field above a plane
147  void SetPlane( const ON_Plane& );
148  const ON_Plane& Plane();
149  double Height(int);
150 
151  /*
152  Returns:
153  True if m_N.Count() == m_P.Count().
154  */
155  bool HasPointNormals() const;
156 
157  /*
158  Returns:
159  True if m_C.Count() == m_P.Count().
160  */
161  bool HasPointColors() const;
162 
163 
164  /*
165  Returns:
166  Number of points that are hidden.
167  */
168  int HiddenPointCount() const;
169 
170  /*
171  Description:
172  Destroys the m_H[] array and sets m_hidden_count=0.
173  */
175 
176  /*
177  Returns:
178  If the point cloud has some hidden points, then an array
179  of length PointCount() is returned and the i-th
180  element is true if the i-th vertex is hidden.
181  If no ponts are hidden, NULL is returned.
182  */
183  const bool* HiddenPointArray() const;
184 
185  /*
186  Description:
187  Set the runtime hidden point flag.
188  Parameters:
189  point_index - [in] point vertex index
190  bHidden - [in] true to hide vertex
191  */
192  void SetHiddenPointFlag( int point_index, bool bHidden );
193 
194  /*
195  Description:
196  Returns true if the point is hidden. This is a runtime
197  setting that is not saved in 3dm files.
198  Parameters:
199  point_index - [in]
200  Returns:
201  True if the point is hidden.
202  */
203  bool PointIsHidden( int point_index ) const;
204 
205  /////////////////////////////////////////////////////////////////
206  // Implementation
208 
209  /////////////////////////////////////////////////////////////////
210  // Implementation - OPTIONAL point normal
211  // Either m_N[] has zero count or it has the same
212  // count as m_P[], in which case m_N[j] reports
213  // the color assigned to m_P[j].
215 
216  /////////////////////////////////////////////////////////////////
217  // Implementation - OPTIONAL point color
218  // Either m_C[] has zero count or it has the same
219  // count as m_P[], in which case m_P[j] reports
220  // the color assigned to m_P[j].
222 
223  /////////////////////////////////////////////////////////////////
224  // Implementation - RUNTIME point visibility - not saved in 3dm files.
225  // If m_H.Count() = m_P.Count(), then
226  // m_H[j] is true if the point m_P[j]
227  // is hidden. Otherwise, all points are visible.
228  // m_hidden_count = number of true values in the m_H[] array.
231 
234  unsigned int m_flags; // bit 1 is set if ordered
235  // bit 2 is set if plane is set
236 
237 };
238 
239 #endif
void SetPlane(const ON_Plane &)
ON_SimpleArray< bool > m_H
ON_3dPoint Point(ON_COMPONENT_INDEX ci) const
void InvalidateBoundingBox()
void Dump(ON_TextLog &) const
void AppendPoint(const ON_3dPoint &)
ON::object_type ObjectType() const
ON_3dPointArray m_P
const bool * HiddenPointArray() const
bool HasPointNormals() const
void EmergencyDestroy()
ON_3dPoint & operator[](int)
ON_BOOL32 Read(ON_BinaryArchive &)
ON_BOOL32 SwapCoordinates(int, int)
void DestroyHiddenPointArray()
ON_PointCloud(const ON_PointCloud &)
ON_BOOL32 Write(ON_BinaryArchive &) const
ON_BOOL32 GetBBox(double *, double *, ON_BOOL32=false) const
bool HasPointColors() const
int Dimension() const
bool IsOrdered() const
ON_SimpleArray< ON_3dVector > m_N
const ON_3dPoint & operator[](int) const
bool PointIsHidden(int point_index) const
ON_BOOL32 Transform(const ON_Xform &)
bool MakeDeformable()
bool HasPlane() const
ON_PointCloud & operator=(const ON_PointCloud &)
unsigned int m_flags
bool GetTightBoundingBox(ON_BoundingBox &tight_bbox, int bGrowBox=false, const ON_Xform *xform=0) const
void SetHiddenPointFlag(int point_index, bool bHidden)
bool IsDeformable() const
bool GetClosestPoint(ON_3dPoint P, int *closest_point_index, double maximum_distance=0.0) const
const ON_Plane & Plane()
void SetOrdered(bool bOrdered)
int HiddenPointCount() const
ON_SimpleArray< ON_Color > m_C
ON_BOOL32 IsValid(ON_TextLog *text_log=NULL) const
double Height(int)
ON_BoundingBox m_bbox
int PointCount() const