OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Static Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
RadialProcessor Class Reference

This class provides a common entry point for both SectorProcessorJob and RadialProcessorJob for processing a single radial. More...

#include <ossimViewshedTool.h>

Static Public Member Functions

static void doRadial (ossimViewshedTool *vs, ossim_uint32 s, ossim_uint32 r)
 

Private Member Functions

 RadialProcessor ()
 

Static Private Attributes

static std::mutex m_bufMutex
 

Detailed Description

This class provides a common entry point for both SectorProcessorJob and RadialProcessorJob for processing a single radial.

Eventually, SectorProcessorJob can likely go away (invoked with the "--tbs" command-line option, and doRadial() method can be moved into RadialProcessorJob class. In the meantime, both Sector/thread and Radial/thread schemes are supported to continue evaluating performance.

Definition at line 167 of file ossimViewshedTool.h.

Constructor & Destructor Documentation

◆ RadialProcessor()

RadialProcessor::RadialProcessor ( )
inlineprivate

Definition at line 174 of file ossimViewshedTool.h.

174 {};

Member Function Documentation

◆ doRadial()

void RadialProcessor::doRadial ( ossimViewshedTool vs,
ossim_uint32  s,
ossim_uint32  r 
)
static

Definition at line 906 of file ossimViewshedTool.cpp.

References ossimViewshedTool::Radial::azimuth, ossimViewshedTool::Radial::elevation, ossimGpt::hasNans(), ossimGpt::hgt, ossimViewshedTool::Radial::insideAoi, ossim::isnan(), ossimImageGeometry::localToWorld(), ossimChipProcTool::m_aoiViewRect, ossimViewshedTool::m_displayAsRadar, ossimChipProcTool::m_geom, ossimViewshedTool::m_halfWindow, ossimViewshedTool::m_hiddenValue, ossimViewshedTool::m_observerGpt, ossimViewshedTool::m_observerVpt, ossimViewshedTool::m_obsHgtAbvTer, ossimViewshedTool::m_outBuffer, ossimViewshedTool::m_overlayValue, ossimViewshedTool::m_radials, ossimViewshedTool::m_simulation, ossimViewshedTool::m_visibleValue, ossimIrect::pointWithin(), ossimImageData::setValue(), ossimIpt::x, ossimDpt::x, ossimIpt::y, and ossimDpt::y.

Referenced by SectorProcessorJob::run(), and RadialProcessorJob::run().

909 {
910  double u, v;
911  ossimDpt pt_i, vpt_i;
912  ossimGpt gpt_i;
913  double elev_i, elev;
914  double r2_max = vsUtil->m_halfWindow*vsUtil->m_halfWindow;
915 
916  // Establish shorthand access to radial:
917  ossimViewshedTool::Radial& radial = vsUtil->m_radials[sector_idx][radial_idx];
918 
919  // Walk along the radial using the appropriate coordinate abscissa for that sector and
920  // compute ordinate using the radials azimuth:
921  for (u=1.0; u <= (double) vsUtil->m_halfWindow; u += 1.0)
922  {
923  // Compute ordinate from abscissa and slope of this radial:
924  v = radial.azimuth*(u);
925  switch (sector_idx)
926  {
927  case 0: // N-NE, (u, v) = (-y, x)
928  pt_i.y = -u;
929  pt_i.x = v;
930  break;
931  case 1: // NE-E, (u, v) = (x, -y)
932  pt_i.x = u;
933  pt_i.y = -v;
934  break;
935  case 2: // E-SE, (u, v) = (x, y)
936  pt_i.x = u;
937  pt_i.y = v;
938  break;
939  case 3: // SE-S, (u, v) = (y, x)
940  pt_i.y = u;
941  pt_i.x = v;
942  break;
943  case 4: // S-SW, (u, v) = (y, -x)
944  pt_i.y = u;
945  pt_i.x = -v;
946  break;
947  case 5: // SW-W, (u, v) = (-x, y)
948  pt_i.x = -u;
949  pt_i.y = v;
950  break;
951  case 6: // W-NW, (u, v) = (-x, -y)
952  pt_i.x = -u;
953  pt_i.y = -v;
954  break;
955  case 7: // NW-N, (u, v) = (-y, -x)
956  pt_i.y = -u;
957  pt_i.x = -v;
958  break;
959  default:
960  break;
961  }
962 
963  // Shift to actual view coordinates:
964  vpt_i = pt_i + vsUtil->m_observerVpt;
965  ossimIpt ipt (vpt_i);
966 
967  // Check if alread accounted for at this location:
968  //if (!vsUtil->m_outBuffer->isNull(vpt_i))
969  // continue;
970 
971  // Check if we are exiting the AOI (no more processing required for this radial):
972  bool pointInsideAoi = vsUtil->m_aoiViewRect.pointWithin(ipt);
973  if (radial.insideAoi && !pointInsideAoi)
974  break;
975 
976  // Alternatively, check if we were OUTSIDE and now moving INSIDE:
977  if (!radial.insideAoi && pointInsideAoi)
978  radial.insideAoi = true;
979 
980  // Check if we passed beyong the visibilty radius, and exit loop if so:
981  if (vsUtil->m_displayAsRadar && ((u*u + v*v) >= r2_max))
982  {
983  vsUtil->m_outBuffer->setValue(ipt.x, ipt.y, vsUtil->m_overlayValue);
984  break;
985  }
986 
987  // Fetch the pixel value as the elevation value and compute elevation angle from
988  // the observer pt as dz/dx
989  vsUtil->m_geom->localToWorld(vpt_i, gpt_i);
990  if (vsUtil->m_simulation && ossim::isnan(gpt_i.hgt))
991  gpt_i.hgt = vsUtil->m_observerGpt.hgt-vsUtil->m_obsHgtAbvTer; // ground level
992 
993  if (!gpt_i.hasNans())
994  {
995  // Compare elev angle to max angle latched so far along this radial:
996  elev_i = (gpt_i.hgt - vsUtil->m_observerGpt.hgt) / u;
997  elev = radial.elevation;
998  if (elev_i > elev)
999  {
1000  // point is visible, latch this line-of-sight as the new max elevation angle for this
1001  // radial, and mark the output pixel as visible:
1002  radial.elevation = elev_i;
1003  vsUtil->m_outBuffer->setValue(ipt.x, ipt.y, vsUtil->m_visibleValue);
1004  }
1005  else
1006  {
1007  vsUtil->m_outBuffer->setValue(ipt.x, ipt.y, vsUtil->m_hiddenValue);
1008  }
1009  }
1010  } // end loop over radial's abscissas
1011 }
double y
Definition: ossimDpt.h:165
ossim_float64 hgt
Height in meters above the ellipsiod.
Definition: ossimGpt.h:274
bool hasNans() const
Definition: ossimGpt.h:135
double x
Definition: ossimDpt.h:164
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91

Member Data Documentation

◆ m_bufMutex

std::mutex RadialProcessor::m_bufMutex
staticprivate

Definition at line 173 of file ossimViewshedTool.h.


The documentation for this class was generated from the following files: