OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimGeoAnnotationMultiPolyObject.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Garrett Potts
6 //
7 //*************************************************************************
8 // $Id: ossimGeoAnnotationMultiPolyObject.cpp 18435 2010-11-17 19:41:13Z gpotts $
9 
16 
17 RTTI_DEF1(ossimGeoAnnotationMultiPolyObject, "ossimGeoAnnotationMultiPolyObject", ossimGeoAnnotationObject);
18 
20  :
22  theMultiPolygon(),
23  theBoundingRect(),
24  theFillEnabled(false),
25  theProjectedPolyObject(0)
26 {
29 }
30 
32  bool enableFill,
33  unsigned char r,
34  unsigned char g,
35  unsigned char b,
36  long thickness)
37  :
38  ossimGeoAnnotationObject(r, g, b, thickness),
39  theMultiPolygon(multiPoly),
40  theBoundingRect(),
41  theFillEnabled(enableFill),
42  theProjectedPolyObject(0)
43 {
46 }
47 
49  :
51  theMultiPolygon(rhs.theMultiPolygon),
52  theBoundingRect(rhs.theBoundingRect),
53  theFillEnabled(rhs.theFillEnabled),
54  theProjectedPolyObject(rhs.theProjectedPolyObject.valid()?(ossimAnnotationMultiPolyObject*)rhs.theProjectedPolyObject->dup():0)
55 {
56 }
57 
59 {
60  return new ossimGeoAnnotationMultiPolyObject(*this);
61 }
62 
64 {
66 }
67 
69  double /* y */)
70 {
72  << "ossimGeoAnnotationPolyObject::applyScale NOT IMPLEMENTED!!!!"
73  << endl;
74 }
75 
77 {
78  if(!projection)
79  {
80  return;
81  }
82 
84 
85  //---
86  // NOTE:
87  // allocateProjectedPolygon() will set theProjectedPolyObject to 0 if
88  // theMultiPolygon is empty (theMultiPolygon.size() == 0). So check before
89  // accessing pointer to avoid a core dump.
90  //---
92  {
93  return;
94  }
95 
96  ossimDpt temp;
97  std::vector<ossimPolygon> visiblePolygons;
98  ossimPolygon polygon;
99  for(ossim_uint32 polyI = 0; polyI < theMultiPolygon.size(); ++polyI)
100  {
101  polygon.clear();
102  for(ossim_uint32 pointI = 0;
103  pointI < theMultiPolygon[polyI].size();
104  ++pointI)
105  {
106  projection->worldToLocal(theMultiPolygon[polyI][pointI],
107  temp);
108  if(!temp.hasNans())
109  {
110  polygon.addPoint(temp);
111  }
112  }
113  theProjectedPolyObject->addPolygon(polyI, polygon);
114  }
115 
116  //---
117  // Update the bounding rect.
118  //---
120 }
121 
123 {
125  << "ossimGeoAnnotationMultiPolyObject::print NOT IMPLEMENTED"
126  << endl;
127  return out;
128 }
129 
131 {
133  << "ossimGeoAnnotationMultiPolyObject::intersects NOT IMPLEMENTED"
134  << endl;
135  return false;
136 }
137 
139  const ossimDrect& /* rect */)const
140 {
142  << "ossimGeoAnnotationMultiPolyObject::getNewClippedObject "
143  << "NOT IMPLEMENTED" << endl;
144 
145  return (ossimAnnotationObject*)(dup());
146 }
147 
149 {
151  {
152  theProjectedPolyObject->draw(anImage);
153  }
154 }
155 
157 {
158  //---
159  // Should we make non const and call computeBoundingRect if theBoundingRect
160  // is nan? (drb - 20100728)
161  //---
162  rect = theBoundingRect;
163  if (rect.isNan()&&theProjectedPolyObject.valid())
164  {
166  }
167 }
168 
170  const ossimGpt& pt)
171 {
172  if(polygonIndex < theMultiPolygon.size())
173  {
174  theMultiPolygon[polygonIndex].addPoint(pt);
175 
176  // we will have to reset the projected polygon
178  }
179 }
180 
182  const vector<ossimGeoPolygon>& multiPoly)
183 {
184  theMultiPolygon = multiPoly;
186 }
187 
189  unsigned char g,
190  unsigned char b)
191 {
194  {
196  }
197 }
198 
200 {
203  {
205  }
206 }
207 
209 {
212  {
215  }
216 }
217 
219 {
221  {
222  return theProjectedPolyObject->isPointWithin(imagePoint);
223  }
224 
225  return false;
226 }
227 
229 {
230  theFillEnabled = flag;
232  {
234  }
235 }
236 
238 {
240 
241  if(theMultiPolygon.size())
242  {
243  vector<ossimPolygon> polyList( theMultiPolygon.size() );
245  new ossimAnnotationMultiPolyObject(polyList,
247  theRed,
248  theGreen,
249  theBlue,
250  theThickness);
251  }
252 }
virtual void getBoundingRect(ossimDrect &rect) const
void makeNan()
Definition: ossimDrect.h:388
virtual void addPoint(ossim_uint32 polygonIndex, const ossimGpt &pt)
bool isNan() const
Definition: ossimDrect.h:401
virtual bool intersects(const ossimDrect &rect) const
virtual void setThickness(ossim_uint8 thickness)
virtual void draw(ossimRgbImage &anImage) const
bool valid() const
Definition: ossimRefPtr.h:75
virtual void setMultiPolygon(const vector< ossimGeoPolygon > &multiPoly)
void addPoint(const ossimDpt &pt)
virtual void draw(ossimRgbImage &anImage) const
RTTI_DEF1(ossimGeoAnnotationMultiPolyObject, "ossimGeoAnnotationMultiPolyObject", ossimGeoAnnotationObject)
virtual ossimAnnotationObject * getNewClippedObject(const ossimDrect &rect) const
virtual void setThickness(ossim_uint8 thickness)
virtual void addPolygon(ossim_uint32 polygonIndex, const ossimPolygon &poly)
virtual ossimDrect getBoundingRect() const
virtual bool isPointWithin(const ossimDpt &imagePoint) const
unsigned int ossim_uint32
ossimRefPtr< ossimAnnotationMultiPolyObject > theProjectedPolyObject
virtual void setColor(ossim_uint8 r, ossim_uint8 g, ossim_uint8 b)
bool hasNans() const
Definition: ossimDpt.h:67
virtual void transform(ossimImageGeometry *projection)
Container class that holds both 2D transform and 3D projection information for an image Only one inst...
bool worldToLocal(const ossimGpt &world_pt, ossimDpt &local_pt) const
Exposes the 3D world-to-local image coordinate reverse projection.
virtual void setColor(unsigned char r, unsigned char g, unsigned char b)
virtual std::ostream & print(std::ostream &out) const
Generic print method.
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
virtual bool isPointWithin(const ossimDpt &imagePoint) const