OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimPointCloudUtilityFilter.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2000 ImageLinks Inc.
3 //
4 // License: LGPL
5 //
6 // See LICENSE.txt file in the top level directory for more details.
7 //
8 // Author: Oscar Kramer
9 //
10 //*******************************************************************
11 // $Id$
12 
18 
19 RTTI_DEF1(ossimPointCloudUtilityFilter, "ossimPointCloudUtilityFilter", ossimImageSourceFilter); // NOLINT
20 
21 
23 : m_util (pc_util)
24 {
25 }
26 
28 {
29  if (!result)
30  return false;
31 
32  ossimIrect irect (result->getImageRectangle());
33  ossimIpt ipt;
34  ossimGpt gpt;
35  double h, dh;
37  ossimRefPtr<ossimImageData> highest = 0;
38  ossimRefPtr<ossimImageData> lowest = 0;
39 
40  // Fetch tile from inputs as needed:
43  {
45  highest = m_util->m_pciHandler->getTile(irect, resLevel);
46  }
49  {
51  lowest = m_util->m_pciHandler->getTile(irect, resLevel);
52  }
53 
54  // Now loop over all pixels in tile and perform operations as needed:
55  ossimIpt pt_l0;
56  for (ipt.y=irect.ul().y; ipt.y<=irect.lr().y; ++ipt.y)
57  {
58  for (ipt.x=irect.ul().x; ipt.x<=irect.lr().x; ++ipt.x)
59  {
60  pt_l0 = ipt * (resLevel + 1);
61  switch (m_util->m_operation)
62  {
64  m_util->m_prodGeom->localToWorld(pt_l0, gpt);
65  h = elevation->getHeightAboveEllipsoid(gpt);
66  dh = highest->getPix(ipt) - h;
67  break;
68 
70  dh = highest->getPix(ipt) - lowest->getPix(ipt);
71  break;
72 
73  default: // LOWEST_DEM
74  m_util->m_prodGeom->localToWorld(pt_l0, gpt);
75  h = elevation->getHeightAboveEllipsoid(gpt);
76  dh = lowest->getPix(ipt) - h;
77  break;
78 
79  }
80  result->setValue(ipt.x, ipt.y, dh);
81  }
82  }
83 
84  result->validate();
85  return true;
86 }
87 
89 {
90  if (!m_util.valid())
91  return 0;
92  return m_util->m_prodGeom;
93 }
94 
virtual void setValue(ossim_int32 x, ossim_int32 y, ossim_float64 color)
enum ossimPointCloudTool::Operation m_operation
ossimPointCloudUtilityFilter(ossimPointCloudTool *pc_util)
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimPointCloudImageHandler > m_pciHandler
virtual ossimRefPtr< ossimImageGeometry > getImageGeometry()
Returns the image geometry object associated with this tile source or NULL if not defined...
static ossimElevManager * instance()
METHOD: instance() Implements singelton pattern.
virtual ossim_float64 getPix(const ossimIpt &position, ossim_uint32 band=0) const
Will return the pixel at location position.
ossimRefPtr< ossimImageGeometry > m_prodGeom
ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0) override
Returns a pointer to a tile given an origin representing the upper left corner of the tile to grab fr...
virtual bool getTile(ossimImageData *result, ossim_uint32 resLevel)
Method to get a tile.
virtual ossimDataObjectStatus validate() const
bool localToWorld(const ossimDpt &local_pt, ossimGpt &world_pt) const
Exposes the 3D projection from image to world coordinates.
virtual double getHeightAboveEllipsoid(const ossimGpt &gpt)
unsigned int ossim_uint32
virtual ossimIrect getImageRectangle() const
bool setCurrentEntry(ossim_uint32 entryIdx) override
RTTI_DEF1(ossimPointCloudUtilityFilter, "ossimPointCloudUtilityFilter", ossimImageSourceFilter)
ossimRefPtr< ossimPointCloudTool > m_util
Utility class for generating point-cloud-derived image products.