OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimPointCloudHandler.cpp
Go to the documentation of this file.
1 //**************************************************************************************************
2 //
3 // OSSIM (http://trac.osgeo.org/ossim/)
4 //
5 // License: LGPL -- See LICENSE.txt file in the top level directory for more details.
6 //
7 //**************************************************************************************************
8 // $Id$
9 
11 
12 RTTI_DEF1(ossimPointCloudHandler, "ossimPointCloudHandler" , ossimPointCloudSource);
13 
15 
17 : m_currentPID(0)
18 {
19 }
20 
22 : ossimPointCloudSource(owner),
23  m_currentPID(0)
24 {
25 
26 }
27 
29 {
30 }
31 
33 {
34  getFileBlock(m_currentPID, block, maxPts);
35  return;
36 }
37 
39 {
40  block.clear();
41 
42  // This default implementation simply reads the whole datafile in file-blocks, retaining
43  // only those points inside the bounds:
44  ossimPointBlock file_block;
45  rewind();
46  ossimGpt gpt;
47 
48  do
49  {
50  file_block.clear();
52  ossimPointBlock::PointList& pointList = file_block.getPoints();
53  ossimPointBlock::PointList::iterator iter = pointList.begin();
54  while (iter != pointList.end())
55  {
56  gpt = (*iter)->getPosition();
57  if (bounds.pointWithin(gpt))
58  {
59  block.addPoint(iter->get());
60  }
61  ++iter;
62  }
63  } while (file_block.size() == DEFAULT_BLOCK_SIZE);
64 }
65 
67 {
70  else
71  bounds.makeNan();
72 }
73 
75 {
76  if (!m_minRecord.valid() || !m_maxRecord.valid())
77  return;
78 
79  ossim_uint32 numPoints = block.size();
80  float val, norm, min, max;
81  vector<ossimPointRecord::FIELD_CODES> field_codes = block.getFieldCodesAsList();
82  vector<ossimPointRecord::FIELD_CODES>::const_iterator iter;
84  for (ossim_uint32 i=0; i<numPoints; ++i)
85  {
86  ossimPointRecord* opr = block[i];
87  iter = field_codes.begin();
88  while (iter != field_codes.end())
89  {
90  field_code = *iter;
91  min = m_minRecord->getField(field_code);
92  max = m_maxRecord->getField(field_code);
93  val = opr->getField(field_code);
94  norm = (val - min) / (max - min);
95  opr->setField(field_code, norm);
96  ++iter;
97  }
98  }
99 }
void normalizeBlock(ossimPointBlock &block)
virtual void getFileBlock(ossim_uint32 offset, ossimPointBlock &block, ossim_uint32 maxNumPoints=0xFFFFFFFF) const =0
Fetches up to maxNumPoints points starting at the dataset&#39;s <offset> in the order they appear in the ...
ossimRefPtr< ossimPointRecord > m_maxRecord
std::vector< ossimRefPtr< ossimPointRecord > > PointList
bool valid() const
Definition: ossimRefPtr.h:75
void makeNan()
Definition: ossimGrect.h:284
ossim_float32 getField(FIELD_CODES fc) const
Return the float value of the requested field.
virtual void getBounds(ossimGrect &bounds) const
virtual void clear()
Resets any storage to empty.
virtual void addPoint(ossimPointRecord *point)
Adds single point to the tail of the list.
bool pointWithin(const ossimGpt &gpt, bool considerHgt=false) const
METHOD: pointWithin(ossimGpt)
Definition: ossimGrect.h:232
static ossim_uint32 DEFAULT_BLOCK_SIZE
unsigned int ossim_uint32
virtual ossim_uint32 size() const
Returns allocated size.
virtual void getBlock(const ossimGrect &bounds, ossimPointBlock &block) const
Fetches the block of points inside the block bounds.
virtual void rewind() const
#define max(a, b)
Definition: auxiliary.h:76
const ossimGpt & getPosition() const
Returns the 3D position vector in the dataset&#39;s coodinate reference system (available from the ossimP...
void setField(FIELD_CODES fc, ossim_float32 value)
vector< ossimPointRecord::FIELD_CODES > getFieldCodesAsList() const
Base class for all point-cloud file readers.
ossimRefPtr< ossimPointRecord > m_minRecord
RTTI_DEF1(ossimPointCloudHandler, "ossimPointCloudHandler", ossimPointCloudSource)
virtual void getNextFileBlock(ossimPointBlock &block, ossim_uint32 maxNumPoints=0xFFFFFFFF) const
virtual const PointList & getPoints() const
#define min(a, b)
Definition: auxiliary.h:75