ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
PointStream.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2006, Michael Kazhdan and Matthew Bolitho
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without modification,
6 are permitted provided that the following conditions are met:
7 
8 Redistributions of source code must retain the above copyright notice, this list of
9 conditions and the following disclaimer. Redistributions in binary form must reproduce
10 the above copyright notice, this list of conditions and the following disclaimer
11 in the documentation and/or other materials provided with the distribution.
12 
13 Neither the name of the Johns Hopkins University nor the names of its contributors
14 may be used to endorse or promote products derived from this software without specific
15 prior writften permission.
16 
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES
19 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
20 SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
21 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
22 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
23 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 DAMAGE.
27 */
28 
29 #ifndef POINT_STREAM_INCLUDED
30 #define POINT_STREAM_INCLUDED
31 #include "Ply.h"
32 
33 template< class Real >
35 {
38 };
39 
40 template< class Real >
42 {
43 public:
44  virtual ~OrientedPointStream( void ){}
45  virtual void reset( void ) = 0;
46  virtual bool nextPoint( OrientedPoint3D< Real >& p ) = 0;
47 };
48 template< class Real , class Data >
50 {
51 public:
52  virtual ~OrientedPointStreamWithData( void ){}
53  virtual void reset( void ) = 0;
54  virtual bool nextPoint( OrientedPoint3D< Real >& p , Data& d ) = 0;
55 
56  virtual bool nextPoint( OrientedPoint3D< Real >& p ){ Data d ; return nextPoint( p , d ); }
57 };
58 
59 template< class Real >
61 {
62  const OrientedPoint3D< Real >* _points;
63  size_t _pointCount;
64  size_t _current;
65 public:
68  void reset( void );
70 };
71 
72 template< class Real , class Data >
74 {
75  const std::pair< OrientedPoint3D< Real > , Data >* _points;
76  size_t _pointCount;
77  size_t _current;
78 public:
79  MemoryOrientedPointStreamWithData( size_t pointCount , const std::pair< OrientedPoint3D< Real > , Data >* points );
81  void reset( void );
82  bool nextPoint( OrientedPoint3D< Real >& p , Data& d );
83 };
84 
85 template< class Real >
87 {
88  FILE* _fp;
89 public:
90  ASCIIOrientedPointStream( const char* fileName );
92  void reset( void );
94 };
95 
96 template< class Real , class Data >
98 {
99  FILE* _fp;
100  Data (*_readData)( FILE* );
101 public:
102  ASCIIOrientedPointStreamWithData( const char* fileName , Data (*readData)( FILE* ) );
104  void reset( void );
105  bool nextPoint( OrientedPoint3D< Real >& p , Data& d );
106 };
107 
108 template< class Real >
110 {
111  FILE* _fp;
112  static const int POINT_BUFFER_SIZE=1024;
113  OrientedPoint3D< Real > _pointBuffer[ POINT_BUFFER_SIZE ];
114  int _pointsInBuffer , _currentPointIndex;
115 public:
118  void reset( void );
120 };
121 
122 template< class Real , class Data >
124 {
125  FILE* _fp;
126  static const int POINT_BUFFER_SIZE=1024;
127  std::pair< OrientedPoint3D< Real > , Data > _pointBuffer[ POINT_BUFFER_SIZE ];
128  int _pointsInBuffer , _currentPointIndex;
129 public:
132  void reset( void );
133  bool nextPoint( OrientedPoint3D< Real >& p , Data& d );
134 };
135 
136 template< class Real >
138 {
139  char* _fileName;
140  PlyFile* _ply;
141  int _nr_elems;
142  char **_elist;
143 
144  int _pCount , _pIdx;
145  void _free( void );
146 public:
147  PLYOrientedPointStream( const char* fileName );
149  void reset( void );
151 };
152 
153 template< class Real , class Data >
155 {
156  struct _PlyOrientedVertexWithData : public PlyOrientedVertex< Real > { Data data; };
157  char* _fileName;
158  PlyFile* _ply;
159  int _nr_elems;
160  char **_elist;
161  PlyProperty* _dataProperties;
162  int _dataPropertiesCount;
163  bool (*_validationFunction)( const bool* );
164 
165  int _pCount , _pIdx;
166  void _free( void );
167 public:
168  PLYOrientedPointStreamWithData( const char* fileName , const PlyProperty* dataProperties , int dataPropertiesCount , bool (*validationFunction)( const bool* )=NULL );
170  void reset( void );
171  bool nextPoint( OrientedPoint3D< Real >& p , Data& d );
172 };
173 
174 #include "PointStream.inl"
175 #endif // POINT_STREAM_INCLUDED
std::string filename
int points
#define NULL
ASCIIOrientedPointStreamWithData(const char *fileName, Data(*readData)(FILE *))
bool nextPoint(OrientedPoint3D< Real > &p, Data &d)
bool nextPoint(OrientedPoint3D< Real > &p)
ASCIIOrientedPointStream(const char *fileName)
bool nextPoint(OrientedPoint3D< Real > &p, Data &d)
BinaryOrientedPointStreamWithData(const char *filename)
BinaryOrientedPointStream(const char *filename)
bool nextPoint(OrientedPoint3D< Real > &p)
bool nextPoint(OrientedPoint3D< Real > &p, Data &d)
MemoryOrientedPointStreamWithData(size_t pointCount, const std::pair< OrientedPoint3D< Real >, Data > *points)
bool nextPoint(OrientedPoint3D< Real > &p)
MemoryOrientedPointStream(size_t pointCount, const OrientedPoint3D< Real > *points)
virtual bool nextPoint(OrientedPoint3D< Real > &p, Data &d)=0
virtual ~OrientedPointStreamWithData(void)
Definition: PointStream.h:52
virtual bool nextPoint(OrientedPoint3D< Real > &p)
Definition: PointStream.h:56
virtual void reset(void)=0
virtual void reset(void)=0
virtual bool nextPoint(OrientedPoint3D< Real > &p)=0
virtual ~OrientedPointStream(void)
Definition: PointStream.h:44
PLYOrientedPointStreamWithData(const char *fileName, const PlyProperty *dataProperties, int dataPropertiesCount, bool(*validationFunction)(const bool *)=NULL)
bool nextPoint(OrientedPoint3D< Real > &p, Data &d)
bool nextPoint(OrientedPoint3D< Real > &p)
PLYOrientedPointStream(const char *fileName)
OrientedPoint3D(Point3D< Real > pp=Point3D< Real >(), Point3D< Real > nn=Point3D< Real >())
Definition: PointStream.h:37
Point3D< Real > n
Definition: PointStream.h:36
Point3D< Real > p
Definition: PointStream.h:36
Definition: Ply.h:134