OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Attributes | Friends | List of all members
ossimPolyLine Class Reference

#include <ossimPolyLine.h>

Public Member Functions

 ossimPolyLine ()
 
 ossimPolyLine (const vector< ossimIpt > &polygon)
 
 ossimPolyLine (const vector< ossimDpt > &polygon)
 
 ossimPolyLine (int numVertices, const ossimDpt *vertex_array)
 
 ossimPolyLine (const ossimPolyLine &copy_this)
 
 ossimPolyLine (const ossimPolygon &polygon)
 
 ossimPolyLine (ossimDpt v1, ossimDpt v2, ossimDpt v3, ossimDpt v4)
 
 ossimPolyLine (const ossimIrect &rect)
 
 ossimPolyLine (const ossimDrect &rect)
 
 ~ossimPolyLine ()
 
ossimDptoperator[] (int index)
 
const ossimDptoperator[] (int index) const
 
ossim_uint32 getNumberOfVertices () const
 
void getIntegerBounds (ossim_int32 &minX, ossim_int32 &minY, ossim_int32 &maxX, ossim_int32 &maxY) const
 
void getBounds (double &minX, double &minY, double &maxX, double &maxY) const
 
void getBoundingRect (ossimDrect &rect) const
 
ossimDrect getBoundingRect () const
 
void roundToIntegerBounds (bool compress=true)
 
void clear ()
 
void addPoint (const ossimDpt &pt)
 
void addPoint (double x, double y)
 
void addAttribute (const ossimString &attribute)
 
ossimDpt midPoint () const
 
bool hasNans () const
 
ossim_uint32 size ()
 
void resize (ossim_uint32 newSize)
 
const vector< ossimDpt > & getVertexList () const
 
vector< ossimDpt > & getVertexList ()
 
vector< ossimString > & getAttributeList ()
 
bool clipToRect (vector< ossimPolyLine > &result, const ossimDrect &rect) const
 
bool isWithin (const ossimDrect &rect) const
 
bool pointWithin (const ossimDpt &point) const
 
bool isPointWithin (const ossimDpt &point) const
 
bool vertex (int index, ossimDpt &tbd_vertex) const
 
bool nextVertex (ossimDpt &tbd_vertex) const
 
void reverseOrder ()
 
const ossimPolyLineoperator= (const ossimPolyLine &copy_this)
 
const ossimPolyLineoperator= (const vector< ossimDpt > &vertexList)
 
const ossimPolyLineoperator= (const vector< ossimIpt > &vertexList)
 
const ossimPolyLineoperator= (const ossimIrect &rect)
 
const ossimPolyLineoperator= (const ossimPolygon &polygon)
 
const ossimPolyLineoperator= (const ossimDrect &rect)
 
bool operator== (const ossimPolyLine &compare_this) const
 
bool operator!= (const ossimPolyLine &compare_this) const
 
const ossimPolyLineoperator*= (const ossimDpt &scale)
 
const ossimPolyLineoperator*= (double scale)
 
ossimPolyLine operator* (const ossimDpt &scale) const
 
ossimPolyLine operator* (double scale) const
 
void print (ostream &os) const
 
bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 

Protected Attributes

vector< ossimDpttheVertexList
 
vector< ossimStringtheAttributeList
 
ossim_int32 theCurrentVertex
 

Friends

ostream & operator<< (ostream &, const ossimPolyLine &)
 

Detailed Description


CLASS: ossimPolyLine

Definition at line 34 of file ossimPolyLine.h.

Constructor & Destructor Documentation

◆ ossimPolyLine() [1/9]

ossimPolyLine::ossimPolyLine ( )
inline

Definition at line 37 of file ossimPolyLine.h.

39  {}
ossim_int32 theCurrentVertex

◆ ossimPolyLine() [2/9]

ossimPolyLine::ossimPolyLine ( const vector< ossimIpt > &  polygon)

Definition at line 23 of file ossimPolyLine.cpp.

References theVertexList.

25 {
26  for (std::vector<ossimIpt>::const_iterator iter = polyLine.begin();
27  iter != polyLine.end(); ++iter)
28  {
29  theVertexList.push_back(ossimDpt(*iter));
30  }
31 }
ossim_int32 theCurrentVertex
vector< ossimDpt > theVertexList

◆ ossimPolyLine() [3/9]

ossimPolyLine::ossimPolyLine ( const vector< ossimDpt > &  polygon)

Definition at line 33 of file ossimPolyLine.cpp.

References theVertexList.

35 {
36  theVertexList = polyLine;
37 }
ossim_int32 theCurrentVertex
vector< ossimDpt > theVertexList

◆ ossimPolyLine() [4/9]

ossimPolyLine::ossimPolyLine ( int  numVertices,
const ossimDpt vertex_array 
)

Definition at line 43 of file ossimPolyLine.cpp.

References theVertexList.

44  : theCurrentVertex(0)
45 {
46  theVertexList.insert(theVertexList.begin(),
47  v, v+numVertices);
48 }
ossim_int32 theCurrentVertex
vector< ossimDpt > theVertexList

◆ ossimPolyLine() [5/9]

ossimPolyLine::ossimPolyLine ( const ossimPolyLine copy_this)

Definition at line 54 of file ossimPolyLine.cpp.

56 {
57  *this = polyLine;
58 }
ossim_int32 theCurrentVertex

◆ ossimPolyLine() [6/9]

ossimPolyLine::ossimPolyLine ( const ossimPolygon polygon)

Definition at line 93 of file ossimPolyLine.cpp.

References ossimPolygon::getNumberOfVertices(), n, and theVertexList.

94  :theVertexList(polygon.getNumberOfVertices()+1),
96 {
98 
99  if(n)
100  {
101  for(ossim_uint32 i = 0; i < n; ++i)
102  {
103  theVertexList[i] = polygon[i];
104  }
105 
106  theVertexList[n] = polygon[n-1];
107  }
108  else
109  {
110  theVertexList.clear();
111  }
112 }
ossim_int32 theCurrentVertex
os2<< "> n<< " > nendobj n
unsigned int ossim_uint32
vector< ossimDpt > theVertexList
ossim_uint32 getNumberOfVertices() const

◆ ossimPolyLine() [7/9]

ossimPolyLine::ossimPolyLine ( ossimDpt  v1,
ossimDpt  v2,
ossimDpt  v3,
ossimDpt  v4 
)

CONSTRUCTOR: Provided for convenience. Does not imply the polygon is limited to four vertices:

Definition at line 60 of file ossimPolyLine.cpp.

References theVertexList.

64  : theVertexList(4),
66 {
67  theVertexList[0] = v1;
68  theVertexList[1] = v2;
69  theVertexList[2] = v3;
70  theVertexList[3] = v4;
71 }
ossim_int32 theCurrentVertex
vector< ossimDpt > theVertexList

◆ ossimPolyLine() [8/9]

ossimPolyLine::ossimPolyLine ( const ossimIrect rect)

Definition at line 73 of file ossimPolyLine.cpp.

References ossimIrect::ll(), ossimIrect::lr(), theVertexList, ossimIrect::ul(), and ossimIrect::ur().

74  : theVertexList(4),
76 {
77  theVertexList[0] = rect.ul();
78  theVertexList[1] = rect.ur();
79  theVertexList[2] = rect.lr();
80  theVertexList[3] = rect.ll();
81 }
const ossimIpt & ul() const
Definition: ossimIrect.h:274
ossim_int32 theCurrentVertex
const ossimIpt & ll() const
Definition: ossimIrect.h:277
const ossimIpt & lr() const
Definition: ossimIrect.h:276
vector< ossimDpt > theVertexList
const ossimIpt & ur() const
Definition: ossimIrect.h:275

◆ ossimPolyLine() [9/9]

ossimPolyLine::ossimPolyLine ( const ossimDrect rect)

Definition at line 83 of file ossimPolyLine.cpp.

References ossimDrect::ll(), ossimDrect::lr(), theVertexList, ossimDrect::ul(), and ossimDrect::ur().

84  : theVertexList(4),
86 {
87  theVertexList[0] = rect.ul();
88  theVertexList[1] = rect.ur();
89  theVertexList[2] = rect.lr();
90  theVertexList[3] = rect.ll();
91 }
const ossimDpt & ul() const
Definition: ossimDrect.h:339
ossim_int32 theCurrentVertex
vector< ossimDpt > theVertexList
const ossimDpt & ur() const
Definition: ossimDrect.h:340
const ossimDpt & ll() const
Definition: ossimDrect.h:342
const ossimDpt & lr() const
Definition: ossimDrect.h:341

◆ ~ossimPolyLine()

ossimPolyLine::~ossimPolyLine ( )

Definition at line 118 of file ossimPolyLine.cpp.

119 {
120 }

Member Function Documentation

◆ addAttribute()

void ossimPolyLine::addAttribute ( const ossimString attribute)
inline

Definition at line 115 of file ossimPolyLine.h.

Referenced by ossimVpfAnnotationFeatureInfo::readAttributes().

116  {
117  theAttributeList.push_back( attribute );
118  }
vector< ossimString > theAttributeList

◆ addPoint() [1/2]

void ossimPolyLine::addPoint ( const ossimDpt pt)
inline

Definition at line 107 of file ossimPolyLine.h.

Referenced by clipToRect(), ossimGeoAnnotationMultiPolyLineObject::loadState(), and ossimVpfAnnotationFeatureInfo::readEdge().

108  {
109  theVertexList.push_back(pt);
110  }
vector< ossimDpt > theVertexList

◆ addPoint() [2/2]

void ossimPolyLine::addPoint ( double  x,
double  y 
)
inline

Definition at line 111 of file ossimPolyLine.h.

References x, and y.

112  {
113  theVertexList.push_back(ossimDpt(x, y));
114  }
ossim_uint32 x
ossim_uint32 y
vector< ossimDpt > theVertexList

◆ clear()

void ossimPolyLine::clear ( )
inline

Definition at line 103 of file ossimPolyLine.h.

Referenced by clipToRect(), ossimGeoAnnotationMultiPolyLineObject::loadState(), and ossimVpfAnnotationFeatureInfo::readEdge().

104  {
105  theVertexList.clear();
106  }
vector< ossimDpt > theVertexList

◆ clipToRect()

bool ossimPolyLine::clipToRect ( vector< ossimPolyLine > &  result,
const ossimDrect rect 
) const

Definition at line 256 of file ossimPolyLine.cpp.

References addPoint(), clear(), ossimDrect::clip(), getNumberOfVertices(), ossimDrect::pointWithin(), and theVertexList.

Referenced by ossimAnnotationMultiPolyObject::getNewClippedObject(), and ossimAnnotationPolyObject::getNewClippedObject().

258 {
259  result.clear();
260 
261  if(theVertexList.size() <1) return false;
262 
263  ossimPolyLine currentPoly;
264 
265  if(theVertexList.size() == 1)
266  {
267  rect.pointWithin(theVertexList[0]);
268  currentPoly.addPoint(theVertexList[0]);
269  result.push_back(currentPoly);
270  }
271  else
272  {
273  ossimDpt pt1 = theVertexList[0];
274  ossimDpt pt2 = theVertexList[1];
275  ossim_uint32 i = 1;
276 
277  while(i < theVertexList.size())
278  {
279 
280  bool p1Inside = rect.pointWithin(pt1);
281  bool p2Inside = rect.pointWithin(pt2);
282 
283  if(p1Inside&&p2Inside) // both inside so save the first
284  {
285  currentPoly.addPoint(pt1);
286  pt1 = pt2;
287  }
288  // going from inside to outside
289  else if(p1Inside&&
290  !p2Inside)
291  {
292  currentPoly.addPoint(pt1);
293  ossimDpt save = pt2;
294  if(rect.clip(pt1, pt2))
295  {
296  currentPoly.addPoint(pt2);
297  result.push_back(currentPoly);
298 
299  currentPoly.clear();
300  }
301  pt2 = save;
302  pt1 = save;
303  }// going outside to the inside
304  else if(!p1Inside&&
305  p2Inside)
306  {
307  if(rect.clip(pt1, pt2))
308  {
309  currentPoly.addPoint(pt1);
310  }
311  pt1 = pt2;
312 
313  }
314  else // both outside must do a clip to see if crosses rect
315  {
316  ossimDpt p1 = pt1;
317  ossimDpt p2 = pt2;
318 
319  if(rect.clip(p1, p2))
320  {
321  currentPoly.addPoint(p1);
322  currentPoly.addPoint(p2);
323  }
324  pt1 = pt2;
325  }
326  ++i;
327 
328  if(i < theVertexList.size())
329  {
330  pt2 = theVertexList[i];
331  }
332  }
333  if(rect.pointWithin(pt2))
334  {
335  currentPoly.addPoint(pt2);
336  }
337  }
338 
339  if(currentPoly.getNumberOfVertices() > 0)
340  {
341  result.push_back(currentPoly);
342  }
343 
344  return (result.size()>0);
345 }
bool pointWithin(const ossimDpt &pt, double epsilon=0.0) const
Definition: ossimDrect.h:781
ossim_uint32 getNumberOfVertices() const
Definition: ossimPolyLine.h:70
unsigned int ossim_uint32
vector< ossimDpt > theVertexList
bool clip(ossimDpt &p1, ossimDpt &p2) const
Definition: ossimDrect.cpp:653
void addPoint(const ossimDpt &pt)

◆ getAttributeList()

vector<ossimString>& ossimPolyLine::getAttributeList ( )
inline

Definition at line 144 of file ossimPolyLine.h.

145  {
146  return theAttributeList;
147  }
vector< ossimString > theAttributeList

◆ getBoundingRect() [1/2]

void ossimPolyLine::getBoundingRect ( ossimDrect rect) const
inline

Definition at line 83 of file ossimPolyLine.h.

84  {
85  ossim_int32 minX;
86  ossim_int32 minY;
87  ossim_int32 maxX;
88  ossim_int32 maxY;
89  getIntegerBounds(minX, minY, maxX, maxY);
90  rect = ossimDrect(minX, minY, maxX, maxY);
91 
92  }
void getIntegerBounds(ossim_int32 &minX, ossim_int32 &minY, ossim_int32 &maxX, ossim_int32 &maxY) const
int ossim_int32

◆ getBoundingRect() [2/2]

ossimDrect ossimPolyLine::getBoundingRect ( ) const
inline

Definition at line 93 of file ossimPolyLine.h.

94  {
95  ossimDrect result;
96 
97  getBoundingRect(result);
98 
99  return result;
100  }
ossimDrect getBoundingRect() const
Definition: ossimPolyLine.h:93

◆ getBounds()

void ossimPolyLine::getBounds ( double &  minX,
double &  minY,
double &  maxX,
double &  maxY 
) const

Definition at line 200 of file ossimPolyLine.cpp.

References max, min, ossim::nan(), theVertexList, x, and y.

204 {
205  ossim_int32 npoly = (ossim_int32)theVertexList.size();
206 
207  if(npoly)
208  {
209  int i = 0;
210  minX = theVertexList[0].x;
211  maxX = theVertexList[0].x;
212  minY = theVertexList[0].y;
213  maxY = theVertexList[0].y;
214 
215  for(i =1; i < npoly; ++i)
216  {
217  minX = std::min(theVertexList[i].x, minX);
218  maxX = std::max(theVertexList[i].x, maxX);
219  minY = std::min(theVertexList[i].y, minY);
220  maxY = std::max(theVertexList[i].y, maxY);
221  }
222  }
223  else
224  {
225  minX = ossim::nan();
226  minY = ossim::nan();
227  maxX = ossim::nan();
228  maxY = ossim::nan();
229  }
230 }
ossim_uint32 x
ossim_uint32 y
double nan()
Method to return ieee floating point double precision NAN.
Definition: ossimCommon.h:135
vector< ossimDpt > theVertexList
#define max(a, b)
Definition: auxiliary.h:76
#define min(a, b)
Definition: auxiliary.h:75
int ossim_int32

◆ getIntegerBounds()

void ossimPolyLine::getIntegerBounds ( ossim_int32 minX,
ossim_int32 minY,
ossim_int32 maxX,
ossim_int32 maxY 
) const

Definition at line 164 of file ossimPolyLine.cpp.

References max, min, OSSIM_INT_NAN, theVertexList, x, and y.

168 {
169  ossim_int32 npoly = (ossim_int32)theVertexList.size();
170  int i = 0;
171 
172  if(npoly)
173  {
174  minX = (ossim_int32)floor(theVertexList[0].x);
175  maxX = (ossim_int32)ceil(theVertexList[0].x);
176  minY = (ossim_int32)floor(theVertexList[0].y);
177  maxY = (ossim_int32)ceil(theVertexList[0].y);
178 
179  for(i =1; i < npoly; ++i)
180  {
181  minX = std::min((ossim_int32)floor(theVertexList[i].x),
182  (ossim_int32)minX);
183  maxX = std::max((ossim_int32)ceil(theVertexList[i].x),
184  (ossim_int32)maxX);
185  minY = std::min((ossim_int32)floor(theVertexList[i].y),
186  (ossim_int32)minY);
187  maxY = std::max((ossim_int32)ceil(theVertexList[i].y),
188  (ossim_int32)maxY);
189  }
190  }
191  else
192  {
193  minX = OSSIM_INT_NAN;
194  minY = OSSIM_INT_NAN;
195  maxX = OSSIM_INT_NAN;
196  maxY = OSSIM_INT_NAN;
197  }
198 }
ossim_uint32 x
ossim_uint32 y
#define OSSIM_INT_NAN
vector< ossimDpt > theVertexList
#define max(a, b)
Definition: auxiliary.h:76
#define min(a, b)
Definition: auxiliary.h:75
int ossim_int32

◆ getNumberOfVertices()

ossim_uint32 ossimPolyLine::getNumberOfVertices ( ) const
inline

Definition at line 70 of file ossimPolyLine.h.

Referenced by clipToRect(), ossimAnnotationMultiPolyLineObject::draw(), and ossimGeoAnnotationMultiPolyLineObject::saveState().

71  {
72  return (ossim_uint32)theVertexList.size();
73  }
unsigned int ossim_uint32
vector< ossimDpt > theVertexList

◆ getVertexList() [1/2]

const vector<ossimDpt>& ossimPolyLine::getVertexList ( ) const
inline

Definition at line 135 of file ossimPolyLine.h.

136  {
137  return theVertexList;
138  }
vector< ossimDpt > theVertexList

◆ getVertexList() [2/2]

vector<ossimDpt>& ossimPolyLine::getVertexList ( )
inline

Definition at line 140 of file ossimPolyLine.h.

141  {
142  return theVertexList;
143  }
vector< ossimDpt > theVertexList

◆ hasNans()

bool ossimPolyLine::hasNans ( ) const

will sequence through the polygon and check to see if any values are NAN

Definition at line 148 of file ossimPolyLine.cpp.

References theVertexList.

149 {
150  int upper = (int)theVertexList.size();
151  int i = 0;
152 
153  for(i = 0; i < upper; ++i)
154  {
155  if(theVertexList[i].hasNans())
156  {
157  return true;
158  }
159  }
160 
161  return false;
162 }
bool hasNans() const
vector< ossimDpt > theVertexList

◆ isPointWithin()

bool ossimPolyLine::isPointWithin ( const ossimDpt point) const

Definition at line 347 of file ossimPolyLine.cpp.

References ossimLine::isPointWithin(), and theVertexList.

348 {
349  if(theVertexList.size() == 1)
350  {
351  return (point == theVertexList[0]);
352  }
353  else
354  {
355  for(ossim_uint32 i = 1; i < theVertexList.size(); ++i)
356  {
357  if(ossimLine(theVertexList[i-1],
358  theVertexList[i]).isPointWithin(point))
359  {
360  return true;
361  }
362  }
363  }
364 
365  return false;
366 }
unsigned int ossim_uint32
vector< ossimDpt > theVertexList
bool isPointWithin(const ossimDpt &point, double delta=FLT_EPSILON) const
Definition: ossimLine.cpp:79

◆ isWithin()

bool ossimPolyLine::isWithin ( const ossimDrect rect) const

Will clip this poly line list to the past in rect and will return true if any part of this object is visible within the rectangle;

Definition at line 232 of file ossimPolyLine.cpp.

References ossimDrect::clip(), ossimDrect::pointWithin(), and theVertexList.

233 {
234  if(theVertexList.size() == 1)
235  {
236  return rect.pointWithin(theVertexList[0]);
237  }
238  else if(theVertexList.size() > 1)
239  {
240  for(ossim_uint32 i = 0; i < (theVertexList.size() - 1); ++i)
241  {
242  ossimDpt p1 = theVertexList[i];
243  ossimDpt p2 = theVertexList[i+1];
244 
245  if(rect.clip(p1, p2))
246  {
247  return true;
248  }
249  }
250  }
251 
252  return false;
253 }
bool pointWithin(const ossimDpt &pt, double epsilon=0.0) const
Definition: ossimDrect.h:781
unsigned int ossim_uint32
vector< ossimDpt > theVertexList
bool clip(ossimDpt &p1, ossimDpt &p2) const
Definition: ossimDrect.cpp:653

◆ loadState()

bool ossimPolyLine::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)

Definition at line 541 of file ossimPolyLine.cpp.

References ossimKeywordlist::find().

543 {
544  const char* number_vertices = kwl.find(prefix, NUMBER_VERTICES_KW);
545  int i = 0;
546 
547  theVertexList.clear();
548  int vertexCount = ossimString(number_vertices).toLong();
549  double x = 0.0, y =0.0;
550  for(i = 0; i < vertexCount; ++i)
551  {
552  ossimString v = kwl.find(prefix, (ossimString("v")+ossimString::toString(i)).c_str());
553  v = v.trim();
554 
555  istringstream vStream(v);
556  vStream >> x >> y;
557  theVertexList.push_back(ossimDpt(x,y));
558  }
559 
560  return true;
561 }
ossim_uint32 x
ossim_uint32 y
const char * find(const char *key) const
static ossimString toString(bool aValue)
Numeric to string methods.
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
vector< ossimDpt > theVertexList
long toLong() const
toLong&#39;s deprecated, please use the toInts...
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32

◆ midPoint()

ossimDpt ossimPolyLine::midPoint ( ) const

◆ nextVertex()

bool ossimPolyLine::nextVertex ( ossimDpt tbd_vertex) const

METHOD: nextVertex() Assigns the ossimDpt tbd_vertex following the current vertex. The current vertex is initialized with a call to vertex(int), or after the last vertex is reached. Returns false if no vertex defined. Intended to be when cycling through all vertices.

Definition at line 382 of file ossimPolyLine.cpp.

References theCurrentVertex, and theVertexList.

383 {
386  {
387  return false;
388  }
389  tbd_vertex = theVertexList[theCurrentVertex];
390 
391  return true;
392 }
ossim_int32 theCurrentVertex
vector< ossimDpt > theVertexList
int ossim_int32

◆ operator!=()

bool ossimPolyLine::operator!= ( const ossimPolyLine compare_this) const
inline

Definition at line 230 of file ossimPolyLine.h.

231 {
232  return !(*this == compare_this);
233 }

◆ operator*() [1/2]

ossimPolyLine ossimPolyLine::operator* ( const ossimDpt scale) const

Definition at line 482 of file ossimPolyLine.cpp.

References theVertexList, ossimDpt::x, and ossimDpt::y.

483 {
484  ossimPolyLine result(*this);
485 
486  int i = 0;
487  int upper = (int)theVertexList.size();
488  for(i = 0; i < upper; ++i)
489  {
490  result.theVertexList[i].x*=scale.x;
491  result.theVertexList[i].y*=scale.y;
492  }
493 
494  return result;
495 }
double y
Definition: ossimDpt.h:165
vector< ossimDpt > theVertexList
double x
Definition: ossimDpt.h:164

◆ operator*() [2/2]

ossimPolyLine ossimPolyLine::operator* ( double  scale) const
inline

Definition at line 206 of file ossimPolyLine.h.

207  {
208  return ((*this)*ossimDpt(scale, scale));
209  }

◆ operator*=() [1/2]

const ossimPolyLine & ossimPolyLine::operator*= ( const ossimDpt scale)

Definition at line 468 of file ossimPolyLine.cpp.

References theVertexList, ossimDpt::x, and ossimDpt::y.

469 {
470  int upper = (int)theVertexList.size();
471  int i = 0;
472 
473  for(i = 0; i < upper; ++i)
474  {
475  theVertexList[i].x*=scale.x;
476  theVertexList[i].y*=scale.y;
477  }
478 
479  return *this;
480 }
double y
Definition: ossimDpt.h:165
vector< ossimDpt > theVertexList
double x
Definition: ossimDpt.h:164

◆ operator*=() [2/2]

const ossimPolyLine& ossimPolyLine::operator*= ( double  scale)
inline

Definition at line 200 of file ossimPolyLine.h.

201  {
202  return ((*this)*=ossimDpt(scale, scale));
203  }

◆ operator=() [1/6]

const ossimPolyLine & ossimPolyLine::operator= ( const ossimPolyLine copy_this)

OPERATORS: (Some are inlined at bottom)

Definition at line 419 of file ossimPolyLine.cpp.

References theAttributeList, theCurrentVertex, and theVertexList.

420 {
421  theVertexList = polyLine.theVertexList;
422  theCurrentVertex = polyLine.theCurrentVertex;
423  theAttributeList = polyLine.theAttributeList;
424 
425  return *this;
426 }
ossim_int32 theCurrentVertex
vector< ossimDpt > theVertexList
vector< ossimString > theAttributeList

◆ operator=() [2/6]

const ossimPolyLine & ossimPolyLine::operator= ( const vector< ossimDpt > &  vertexList)

Definition at line 428 of file ossimPolyLine.cpp.

References theCurrentVertex, and theVertexList.

429 {
430  theVertexList = vertexList;
431  theCurrentVertex = 0;
432 
433  return *this;
434 }
ossim_int32 theCurrentVertex
vector< ossimDpt > theVertexList

◆ operator=() [3/6]

const ossimPolyLine & ossimPolyLine::operator= ( const vector< ossimIpt > &  vertexList)

Definition at line 436 of file ossimPolyLine.cpp.

References theCurrentVertex, and theVertexList.

437 {
438  theVertexList.clear();
439  for (std::vector<ossimIpt>::const_iterator iter = vertexList.begin();
440  iter != vertexList.end(); ++iter)
441  {
442  theVertexList.push_back(*iter);
443  }
444 
445  theCurrentVertex = 0;
446 
447  return *this;
448 }
ossim_int32 theCurrentVertex
vector< ossimDpt > theVertexList

◆ operator=() [4/6]

const ossimPolyLine& ossimPolyLine::operator= ( const ossimIrect rect)

◆ operator=() [5/6]

const ossimPolyLine & ossimPolyLine::operator= ( const ossimPolygon polygon)

Definition at line 395 of file ossimPolyLine.cpp.

References ossimPolygon::getNumberOfVertices(), n, theCurrentVertex, and theVertexList.

396 {
397  theCurrentVertex = 0;
398  ossim_uint32 n = polygon.getNumberOfVertices();
399 
400  if(n)
401  {
402  theVertexList.resize(n+1);
403 
404  for(ossim_uint32 i = 0; i < n; ++i)
405  {
406  theVertexList[i] = polygon[i];
407  }
408 
409  theVertexList[n] = polygon[n-1];
410  }
411  else
412  {
413  theVertexList.clear();
414  }
415 
416  return *this;
417 }
ossim_int32 theCurrentVertex
os2<< "> n<< " > nendobj n
unsigned int ossim_uint32
vector< ossimDpt > theVertexList
ossim_uint32 getNumberOfVertices() const

◆ operator=() [6/6]

const ossimPolyLine& ossimPolyLine::operator= ( const ossimDrect rect)

◆ operator==()

bool ossimPolyLine::operator== ( const ossimPolyLine compare_this) const

Definition at line 454 of file ossimPolyLine.cpp.

References theVertexList.

455 {
456  if( (theVertexList.size() != polyLine.theVertexList.size()))
457  {
458  return false;
459  }
460  if(!theVertexList.size() && polyLine.theVertexList.size())
461  {
462  return true;
463  }
464 
465  return (theVertexList == polyLine.theVertexList);
466 }
vector< ossimDpt > theVertexList

◆ operator[]() [1/2]

ossimDpt& ossimPolyLine::operator[] ( int  index)
inline

Definition at line 61 of file ossimPolyLine.h.

62  {
63  return theVertexList[index];
64  }
vector< ossimDpt > theVertexList

◆ operator[]() [2/2]

const ossimDpt& ossimPolyLine::operator[] ( int  index) const
inline

Definition at line 65 of file ossimPolyLine.h.

66  {
67  return theVertexList[index];
68  }
vector< ossimDpt > theVertexList

◆ pointWithin()

bool ossimPolyLine::pointWithin ( const ossimDpt point) const
inline

METHOD: pointWithin(ossimDpt) Returns TRUE if point is inside polygon.

Definition at line 164 of file ossimPolyLine.h.

165  {
166  return isPointWithin(point);
167  }
bool isPointWithin(const ossimDpt &point) const

◆ print()

void ossimPolyLine::print ( ostream &  os) const

METHOD: print()

Definition at line 507 of file ossimPolyLine.cpp.

References theVertexList.

Referenced by operator<<().

508 {
509  copy(theVertexList.begin(),
510  theVertexList.end(),
511  ostream_iterator<ossimDpt>(os, "\n"));
512 }
vector< ossimDpt > theVertexList

◆ resize()

void ossimPolyLine::resize ( ossim_uint32  newSize)
inline

Definition at line 131 of file ossimPolyLine.h.

132  {
133  theVertexList.resize(newSize);
134  }
vector< ossimDpt > theVertexList

◆ reverseOrder()

void ossimPolyLine::reverseOrder ( )

Definition at line 498 of file ossimPolyLine.cpp.

References theVertexList.

499 {
500  std::reverse(theVertexList.begin(), theVertexList.end());
501 }
vector< ossimDpt > theVertexList

◆ roundToIntegerBounds()

void ossimPolyLine::roundToIntegerBounds ( bool  compress = true)

Definition at line 122 of file ossimPolyLine.cpp.

References theCurrentVertex, and theVertexList.

123 {
124  int i = 0;
125  for(i = 0; i < (int)theVertexList.size(); ++i)
126  {
128  }
129  if(compress&&theVertexList.size())
130  {
131  vector<ossimDpt> polyLine;
132 
133  polyLine.push_back(theVertexList[0]);
134  ossimDpt testPt = theVertexList[0];
135  for(i=1; i < (int)theVertexList.size(); ++i)
136  {
137  if(testPt!=theVertexList[i])
138  {
139  testPt = theVertexList[i];
140  polyLine.push_back(testPt);
141  }
142  }
143  theVertexList = polyLine;
144  theCurrentVertex = 0;
145  }
146 }
ossim_int32 theCurrentVertex
vector< ossimDpt > theVertexList

◆ saveState()

bool ossimPolyLine::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const

Definition at line 514 of file ossimPolyLine.cpp.

References ossimKeywordlist::add(), and ossimKeywordNames::TYPE_KW.

516 {
517  int i = 0;
518  kwl.add(prefix,
520  "ossimPolyLine",
521  true);
522  kwl.add(prefix,
523  NUMBER_VERTICES_KW,
524  (int)theVertexList.size(),
525  true);
526  for(i = 0; i < (int)theVertexList.size();++i)
527  {
528  ossimString vert = "v"+ossimString::toString(i);;
529  ossimString value = (ossimString::toString(theVertexList[i].x) + " " +
531  kwl.add(prefix,
532  vert.c_str(),
533  value.c_str(),
534  true);
535  }
536  ossimString order = "";
537 
538  return true;
539 }
ossim_uint32 x
ossim_uint32 y
static ossimString toString(bool aValue)
Numeric to string methods.
static const char * TYPE_KW
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
vector< ossimDpt > theVertexList
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396

◆ size()

ossim_uint32 ossimPolyLine::size ( )
inline

Definition at line 127 of file ossimPolyLine.h.

Referenced by ossimGeoAnnotationMultiPolyLineObject::loadState().

128  {
129  return getNumberOfVertices();
130  }
ossim_uint32 getNumberOfVertices() const
Definition: ossimPolyLine.h:70

◆ vertex()

bool ossimPolyLine::vertex ( int  index,
ossimDpt tbd_vertex 
) const

METHOD: vertex(index) Returns the ossimDpt vertex given the index. Returns false if no vertex defined.

Definition at line 368 of file ossimPolyLine.cpp.

References theCurrentVertex, and theVertexList.

369 {
370  if((index >= (int)theVertexList.size()) ||
371  (index < 0))
372  {
373  return false;
374  }
375 
376  tbd_vertex = theVertexList[index];
377  theCurrentVertex = index;
378 
379  return true;
380 }
ossim_int32 theCurrentVertex
vector< ossimDpt > theVertexList

Friends And Related Function Documentation

◆ operator<<

ostream& operator<< ( ostream &  os,
const ossimPolyLine polyLine 
)
friend

Definition at line 235 of file ossimPolyLine.h.

236 {
237  polyLine.print(os);
238  return os;
239 }
void print(ostream &os) const

Member Data Documentation

◆ theAttributeList

vector<ossimString> ossimPolyLine::theAttributeList
protected

Definition at line 225 of file ossimPolyLine.h.

Referenced by operator=().

◆ theCurrentVertex

ossim_int32 ossimPolyLine::theCurrentVertex
mutableprotected

Definition at line 227 of file ossimPolyLine.h.

Referenced by nextVertex(), operator=(), roundToIntegerBounds(), and vertex().

◆ theVertexList

vector<ossimDpt> ossimPolyLine::theVertexList
protected

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