OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimImageModel.cpp
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: David Burken
8 //
9 // Description: Class definition of ossimImageModel.
10 //
11 //-----------------------------------------------------------------------------
12 // $Id$
13 
14 #include <string>
15 
17 #include <ossim/base/ossimDrect.h>
20 
21 RTTI_DEF1(ossimImageModel, "ossimImageModel", ossimObject);
22 
24  : ossimObject(),
25  theSubImageOffset(),
26  theDecimationFactors(),
27  theLines(0),
28  theSamples(0),
29  theTargetRrds(0)
30 {
31 }
32 
34 {
35 }
36 
38 {
40  theLines = ih.getNumberOfLines(0);
43 }
44 
46  const ossimDpt& rnPt,
47  ossimDpt& r0Pt) const
48 {
49  if ( rrds < theDecimationFactors.size() )
50  {
51  r0Pt.x = rnPt.x / theDecimationFactors[rrds].x;
52  r0Pt.y = rnPt.y / theDecimationFactors[rrds].y;
53  }
54  else
55  {
56  std::string e = "ossimImageModel::rnToR0 rrds out of range!";
57  throw ossimException(e);
58  }
59 }
60 void ossimImageModel::rnToR0(const ossimDpt& rnPt, ossimDpt& r0Pt) const
61 {
62  rnToR0(theTargetRrds, rnPt, r0Pt);
63 }
64 
66  const ossimDpt& r0Pt,
67  ossimDpt& rnPt) const
68 {
69  if ( rrds < theDecimationFactors.size() )
70  {
71  rnPt.x = r0Pt.x * theDecimationFactors[rrds].x;
72  rnPt.y = r0Pt.y * theDecimationFactors[rrds].y;
73  }
74  else
75  {
76  std::string e = "ossimImageModel::r0ToRn rrds out of range!";
77  throw ossimException(e);
78  }
79 }
80 
81 void ossimImageModel::r0ToRn(const ossimDpt& r0Pt, ossimDpt& rnPt) const
82 {
83  r0ToRn(theTargetRrds, r0Pt, rnPt);
84 }
85 
87  ossimDpt& offset) const
88 {
89  if ( rrds < theDecimationFactors.size() )
90  {
91  offset.x = theSubImageOffset.x * theDecimationFactors[rrds].x;
92  offset.y = theSubImageOffset.y * theDecimationFactors[rrds].y;
93  }
94  else
95  {
96  std::string e = "ossimImageModel::getSubImageOffset rrds out of range!";
97  throw ossimException(e);
98  }
99 }
100 
102  ossimDrect& rect) const
103 {
104  if ( rrds < theDecimationFactors.size() )
105  {
106  ossim_float64 lrX = theSamples * theDecimationFactors[rrds].x - 1.0;
107  ossim_float64 lrY = theLines * theDecimationFactors[rrds].y - 1.0;
108  ossimDrect r(0.0, 0.0, lrX, lrY);
109  rect = r;
110  }
111  else
112  {
113  std::string e = "ossimImageModel::getImageRectangle rrds out of range!";
114  throw ossimException(e);
115  }
116 }
117 
119  ossimDrect& rect) const
120 {
121  if ( rrds < theDecimationFactors.size() )
122  {
125 
126  ossim_float64 lrX = urX + theSamples*theDecimationFactors[rrds].x - 1.0;
127  ossim_float64 lrY = urY + theLines *theDecimationFactors[rrds].y - 1.0;
128  ossimDrect r(0, 0, lrX, lrY);
129  rect = r;
130  }
131  else
132  {
133  std::string e =
134  "ossimImageModel::getBoundingRectangle rrds out of range!";
135  throw ossimException(e);
136  }
137 }
139 {
140  return (ossim_uint32)theDecimationFactors.size();
141 }
142 
144 {
145  theTargetRrds = rrds;
146 }
147 
149 {
150  return theTargetRrds;
151 }
152 
153 
154 
void r0ToRn(ossim_uint32 rrds, const ossimDpt &r0Pt, ossimDpt &rnPt) const
Get rn point from r0 point.
virtual void getDecimationFactors(vector< ossimDpt > &decimations) const
This returns all decimation for all levels.
void getBoundingRectangle(ossim_uint32 rrds, ossimDrect &rect) const
Gets the model-based image rectangle for a given reduced resolution data set.
virtual ~ossimImageModel()
virtual destructor
virtual void initialize(const ossimImageHandler &ih)
Method to initialize class from an image handler.
ossim_uint32 theSamples
std::vector< ossimDpt > theDecimationFactors
Decimation factors for each rrds level.
virtual ossim_uint32 getNumberOfLines(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
double y
Definition: ossimDpt.h:165
void setTargetRrds(ossim_uint32 rrds)
Set theTargetRrds data member.
double ossim_float64
ossim_uint32 getNumberOfDecimationLevels() const
ossim_uint32 theLines
ossimImageModel()
default constructor
unsigned int ossim_uint32
void getSubImageOffset(ossim_uint32 rrds, ossimDpt &offset) const
Get the sub image offset for a given resolution level.
ossim_uint32 theTargetRrds
RTTI_DEF1(ossimImageModel, "ossimImageModel", ossimObject)
void getImageRectangle(ossim_uint32 rrds, ossimDrect &rect) const
Gets the zero-based image rectangle for a given reduced resolution data set.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
double x
Definition: ossimDpt.h:164
virtual ossim_uint32 getNumberOfSamples(ossim_uint32 resLevel=0) const =0
Pure virtual, derived classes must implement.
void rnToR0(ossim_uint32 rrds, const ossimDpt &rnPt, ossimDpt &r0Pt) const
Get r0 point from rn point.
ossimDpt theSubImageOffset
Offset from the full image.
ossim_uint32 getTargetRrds() const
Class to handle transforming image points, rectangles, and offsets from one reduced resolution data s...