Ice Sheet System Model  4.18
Code documentation
Public Member Functions | Data Fields
KML_Polygon Class Reference

#include <KML_Polygon.h>

Inheritance diagram for KML_Polygon:
KML_Geometry KML_Object Object

Public Member Functions

 KML_Polygon ()
 
 ~KML_Polygon ()
 
void Echo ()
 
void DeepEcho ()
 
void DeepEcho (const char *indent)
 
void Write (FILE *fid, const char *indent)
 
void Read (FILE *fid, char *kstr)
 
void WriteExp (FILE *fid, const char *nstr, int sgn, double cm, double sp)
 
int Id ()
 
int ObjectEnum ()
 
Objectcopy ()
 
void Marshall (char **pmarshalled_data, int *pmarshalled_data_size, int marshall_direction)
 
- Public Member Functions inherited from KML_Geometry
 KML_Geometry ()
 
 ~KML_Geometry ()
 
- Public Member Functions inherited from KML_Object
 KML_Object ()
 
 ~KML_Object ()
 
virtual void AddAttrib (const char *name, const char *value)
 
virtual void WriteAttrib (FILE *fid, const char *indent)
 
virtual void AddCommnt (int ncom, char **pcom)
 
virtual void AddCommnt (char *value)
 
virtual void WriteCommnt (FILE *fid, const char *indent)
 
- Public Member Functions inherited from Object
virtual ~Object ()
 

Data Fields

bool extrude
 
bool tessellate
 
char altmode [KML_POLYGON_ALTMODE_LENGTH+1]
 
DataSetouter
 
DataSetinner
 
- Data Fields inherited from KML_Object
DataSetattrib
 
DataSetcommnt
 
DataSetkmlobj
 

Detailed Description

Definition at line 18 of file KML_Polygon.h.

Constructor & Destructor Documentation

◆ KML_Polygon()

KML_Polygon::KML_Polygon ( )

Definition at line 20 of file KML_Polygon.cpp.

20  {/*{{{*/
21 
22  extrude =false;
23  tessellate=false;
24  memcpy(altmode,"clampToGround",(strlen("clampToGround")+1)*sizeof(char));
25 
26  outer =new DataSet;
27  inner =new DataSet;
28 
29 }

◆ ~KML_Polygon()

KML_Polygon::~KML_Polygon ( )

Definition at line 31 of file KML_Polygon.cpp.

31  {/*{{{*/
32 
33  if (inner) {
34  delete inner;
35  inner =NULL;
36  }
37 
38  if (outer) {
39  delete outer;
40  outer =NULL;
41  }
42 
43 }

Member Function Documentation

◆ Echo()

void KML_Polygon::Echo ( void  )
virtual

Reimplemented from KML_Geometry.

Definition at line 47 of file KML_Polygon.cpp.

47  {/*{{{*/
48 
49  bool flag=true;
50 
51  if(flag) _printf0_("KML_Polygon:\n");
53 
54  if(flag) _printf0_(" extrude: " << (extrude ? "true" : "false") << "\n");
55  if(flag) _printf0_(" tessellate: " << (tessellate ? "true" : "false") << "\n");
56  if(flag) _printf0_(" altmode: \"" << altmode << "\"\n");
57  if(flag) _printf0_(" outer: (size=" << outer->Size() << ")\n");
58  if(flag) _printf0_(" inner: (size=" << inner->Size() << ")\n");
59 
60  return;
61 }

◆ DeepEcho() [1/2]

void KML_Polygon::DeepEcho ( void  )
virtual

Reimplemented from KML_Geometry.

Definition at line 63 of file KML_Polygon.cpp.

63  {/*{{{*/
64 
65  char indent[81]="";
66 
67  KML_Polygon::DeepEcho(indent);
68 
69  return;
70 }

◆ DeepEcho() [2/2]

void KML_Polygon::DeepEcho ( const char *  indent)
virtual

Reimplemented from KML_Geometry.

Definition at line 72 of file KML_Polygon.cpp.

72  {/*{{{*/
73 
74  int i;
75  char indent2[81];
76  bool flag=true;
77 
78  if(flag) _printf0_(indent << "KML_Polygon:\n");
79  KML_Geometry::DeepEcho(indent);
80 
81  if(flag) _printf0_(indent << " extrude: " << (extrude ? "true" : "false") << "\n");
82  if(flag) _printf0_(indent << " tessellate: " << (tessellate ? "true" : "false") << "\n");
83  if(flag) _printf0_(indent << " altmode: \"" << altmode << "\"\n");
84 
85  memcpy(indent2,indent,(strlen(indent)+1)*sizeof(char));
86  strcat(indent2," ");
87 
88  if (outer->Size())
89  for (i=0; i<outer->Size(); i++) {
90  if(flag) _printf0_(indent << " outer: -------- begin [" << i << "] --------\n");
92  if(flag) _printf0_(indent << " outer: -------- end [" << i << "] --------\n");
93  }
94  else
95  if(flag) _printf0_(indent << " outer: [empty]\n");
96 
97  if (inner->Size())
98  for (i=0; i<inner->Size(); i++) {
99  if(flag) _printf0_(indent << " inner: -------- begin [" << i << "] --------\n");
100  ((KML_LinearRing *)inner->GetObjectByOffset(i))->DeepEcho(indent2);
101  if(flag) _printf0_(indent << " inner: -------- end [" << i << "] --------\n");
102  }
103  else
104  if(flag) _printf0_(indent << " inner: [empty]\n");
105 
106  return;
107 }

◆ Write()

void KML_Polygon::Write ( FILE *  fid,
const char *  indent 
)
virtual

Reimplemented from KML_Geometry.

Definition at line 109 of file KML_Polygon.cpp.

109  {/*{{{*/
110 
111  int i;
112  char indent4[81];
113 
114  fprintf(filout,"%s<Polygon",indent);
115  WriteAttrib(filout," ");
116  fprintf(filout,">\n");
117  WriteCommnt(filout,indent);
118 
119  KML_Geometry::Write(filout,indent);
120 
121  fprintf(filout,"%s <extrude>%d</extrude>\n",indent,(extrude ? 1 : 0));
122  fprintf(filout,"%s <tessellate>%d</tessellate>\n",indent,(tessellate ? 1 : 0));
123  fprintf(filout,"%s <altitudeMode>%s</altitudeMode>\n",indent,altmode);
124 
125  memcpy(indent4,indent,(strlen(indent)+1)*sizeof(char));
126  strcat(indent4," ");
127 
128 /* check outer boundary for the polygon */
129 
130  fprintf(filout,"%s <outerBoundaryIs>\n",indent);
131  if (outer->Size())
132  ((KML_LinearRing *)outer->GetObjectByOffset(0))->Write(filout,indent4);
133  fprintf(filout,"%s </outerBoundaryIs>\n",indent);
134 
135 /* loop over any inner boundaries for the polygon */
136 
137  for (i=0; i<inner->Size(); i++) {
138  fprintf(filout,"%s <innerBoundaryIs>\n",indent);
139  ((KML_LinearRing *)inner->GetObjectByOffset(i))->Write(filout,indent4);
140  fprintf(filout,"%s </innerBoundaryIs>\n",indent);
141  }
142 
143  fprintf(filout,"%s</Polygon>\n",indent);
144 
145  return;
146 }

◆ Read()

void KML_Polygon::Read ( FILE *  fid,
char *  kstr 
)
virtual

Reimplemented from KML_Geometry.

Definition at line 148 of file KML_Polygon.cpp.

148  {/*{{{*/
149 
150  char* kstri;
151  char* kstrj;
152  int ncom=0;
153  char** pcom=NULL;
154  KML_Object* kobj;
155 
156 /* get object attributes and check for solo tag */
157 
158  if (KMLFileTagAttrib(this,
159  kstr))
160  return;
161 
162 /* loop over and process fields within opening and closing tags */
163 
164  while((kstri=KMLFileToken(fid, &ncom,&pcom))){
165  if (!strncmp(kstri,"</Polygon", 9)) {
166  xDelete<char>(kstri);
167  break;
168  }
169  else if (!strncmp(kstri,"</",2))
170  {_error_("KML_Polygon::Read -- Unexpected closing tag " << kstri << ".\n");}
171  else if (strncmp(kstri,"<",1))
172  {_error_("KML_Polygon::Read -- Unexpected field \"" << kstri << "\".\n");}
173 
174  else if (!strcmp(kstri,"<extrude>"))
176  kstri,
177  fid);
178  else if (!strcmp(kstri,"<tessellate>"))
180  kstri,
181  fid);
182  else if (!strcmp(kstri,"<altitudeMode>"))
184  kstri,
185  fid);
186 
187  else if (!strcmp(kstri,"<outerBoundaryIs>"))
188 
189 /* loop over and process fields within outer boundary */
190 
191  while((kstrj=KMLFileToken(fid, &ncom,&pcom))){
192  if (!strncmp(kstrj,"</outerBoundaryIs",17)) {
193  xDelete<char>(kstrj);
194  break;
195  }
196  else if (!strncmp(kstrj,"</",2))
197  {_error_("KML_Polygon::Read -- Unexpected closing tag " << kstrj << ".\n");}
198  else if (strncmp(kstrj,"<",1))
199  {_error_("KML_Polygon::Read -- Unexpected field \"" << kstrj << "\".\n");}
200 
201  else if (!strncmp(kstrj,"<LinearRing",11)) {
202  kobj=(KML_Object*)new KML_LinearRing();
203  kobj->Read(fid,kstrj);
204  outer ->AddObject((Object*)kobj);
205  }
206 
207  else if (!strncmp(kstrj,"<",1))
208  KML_Geometry::Read(fid,kstrj);
209 
210  xDelete<char>(kstrj);
211  }
212 
213  else if (!strcmp(kstri,"<innerBoundaryIs>"))
214 
215 /* loop over and process fields within inner boundaries */
216 
217  while((kstrj=KMLFileToken(fid, &ncom,&pcom))){
218  if (!strncmp(kstrj,"</innerBoundaryIs",17)) {
219  xDelete<char>(kstrj);
220  break;
221  }
222  else if (!strncmp(kstrj,"</",2))
223  {_error_("KML_Polygon::Read -- Unexpected closing tag " << kstrj << ".\n");}
224  else if (strncmp(kstrj,"<",1))
225  {_error_("KML_Polygon::Read -- Unexpected field \"" << kstrj << "\".\n");}
226 
227  else if (!strncmp(kstrj,"<LinearRing",11)) {
228  kobj=(KML_Object*)new KML_LinearRing();
229  kobj->Read(fid,kstrj);
230  inner ->AddObject((Object*)kobj);
231  }
232 
233  else if (!strncmp(kstrj,"<",1))
234  KML_Geometry::Read(fid,kstrj);
235 
236  xDelete<char>(kstrj);
237  }
238 
239  else if (!strncmp(kstri,"<",1))
240  KML_Geometry::Read(fid,kstri);
241 
242  xDelete<char>(kstri);
243  }
244 
245  this->AddCommnt(ncom,pcom);
246 
247  for(ncom=ncom; ncom>0; ncom--)
248  xDelete<char>(pcom[ncom-1]);
249  xDelete<char*>(pcom);
250 
251  return;
252 }

◆ WriteExp()

void KML_Polygon::WriteExp ( FILE *  fid,
const char *  nstr,
int  sgn,
double  cm,
double  sp 
)
virtual

Reimplemented from KML_Object.

Definition at line 254 of file KML_Polygon.cpp.

254  {/*{{{*/
255 
256  int i;
257  char nstr2[81];
258 
259 /* check outer boundary for the polygon */
260 
261  if (outer->Size()) {
262  if (strlen(nstr))
263  sprintf(nstr2,"%s (outer)",nstr);
264  else
265  sprintf(nstr2,"(outer)");
266 
267  ((KML_LinearRing *)outer->GetObjectByOffset(0))->WriteExp(fid,nstr2,sgn,cm,sp);
268  }
269 
270 /* loop over any inner boundaries for the polygon */
271 
272  for (i=0; i<inner->Size(); i++) {
273  if (strlen(nstr))
274  sprintf(nstr2,"%s (inner %d of %d)",nstr,i+1,inner->Size());
275  else
276  sprintf(nstr2,"(inner %d of %d)",i+1,inner->Size());
277 
278  ((KML_LinearRing *)inner->GetObjectByOffset(i))->WriteExp(fid,nstr2,sgn,cm,sp);
279  }
280 
281  return;
282 }

◆ Id()

int KML_Polygon::Id ( void  )
inlinevirtual

Reimplemented from KML_Geometry.

Definition at line 39 of file KML_Polygon.h.

39 {_error_("Not implemented yet.");};

◆ ObjectEnum()

int KML_Polygon::ObjectEnum ( void  )
inlinevirtual

Reimplemented from KML_Geometry.

Definition at line 40 of file KML_Polygon.h.

40 {_error_("Not implemented yet.");};

◆ copy()

Object* KML_Polygon::copy ( void  )
inlinevirtual

Reimplemented from KML_Geometry.

Definition at line 41 of file KML_Polygon.h.

41 {_error_("Not implemented yet.");};

◆ Marshall()

void KML_Polygon::Marshall ( char **  pmarshalled_data,
int *  pmarshalled_data_size,
int  marshall_direction 
)
inlinevirtual

Reimplemented from KML_Geometry.

Definition at line 42 of file KML_Polygon.h.

42 { _error_("not implemented yet!");};

Field Documentation

◆ extrude

bool KML_Polygon::extrude

Definition at line 22 of file KML_Polygon.h.

◆ tessellate

bool KML_Polygon::tessellate

Definition at line 23 of file KML_Polygon.h.

◆ altmode

char KML_Polygon::altmode[KML_POLYGON_ALTMODE_LENGTH+1]

Definition at line 24 of file KML_Polygon.h.

◆ outer

DataSet* KML_Polygon::outer

Definition at line 25 of file KML_Polygon.h.

◆ inner

DataSet* KML_Polygon::inner

Definition at line 26 of file KML_Polygon.h.


The documentation for this class was generated from the following files:
DataSet::Size
int Size()
Definition: DataSet.cpp:399
KML_Object
Definition: KML_Object.h:13
_printf0_
#define _printf0_(StreamArgs)
Definition: Print.h:29
KML_Object::WriteAttrib
virtual void WriteAttrib(FILE *fid, const char *indent)
Definition: KML_Object.cpp:288
KML_Geometry::Write
void Write(FILE *fid, const char *indent)
Definition: KML_Geometry.cpp:56
DataSet::AddObject
int AddObject(Object *object)
Definition: DataSet.cpp:252
KMLFileTagAttrib
int KMLFileTagAttrib(KML_Object *kobj, char *ktag)
Definition: KMLFileReadUtils.cpp:287
KML_Polygon::outer
DataSet * outer
Definition: KML_Polygon.h:25
KML_Polygon::Write
void Write(FILE *fid, const char *indent)
Definition: KML_Polygon.cpp:109
KML_Polygon::altmode
char altmode[KML_POLYGON_ALTMODE_LENGTH+1]
Definition: KML_Polygon.h:24
KML_Polygon::extrude
bool extrude
Definition: KML_Polygon.h:22
KML_Polygon::DeepEcho
void DeepEcho()
Definition: KML_Polygon.cpp:63
KML_Object::Read
virtual void Read(FILE *fid, char *kstr)=0
Definition: KML_Object.cpp:143
Object
Definition: Object.h:13
KMLFileToken
char * KMLFileToken(FILE *fid, int *pncom=NULL, char ***ppcom=NULL)
Definition: KMLFileReadUtils.cpp:18
KML_POLYGON_ALTMODE_LENGTH
#define KML_POLYGON_ALTMODE_LENGTH
Definition: KML_Polygon.h:8
KML_Geometry::DeepEcho
void DeepEcho()
Definition: KML_Geometry.cpp:40
KML_Polygon::WriteExp
void WriteExp(FILE *fid, const char *nstr, int sgn, double cm, double sp)
Definition: KML_Polygon.cpp:254
KML_LinearRing
Definition: KML_LinearRing.h:16
KMLFileTokenParse
int KMLFileTokenParse(int *pival, char *ktag, FILE *fid)
Definition: KMLFileReadUtils.cpp:335
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
DataSet::GetObjectByOffset
Object * GetObjectByOffset(int offset)
Definition: DataSet.cpp:334
KML_Polygon::inner
DataSet * inner
Definition: KML_Polygon.h:26
DataSet
Declaration of DataSet class.
Definition: DataSet.h:14
KML_Polygon::tessellate
bool tessellate
Definition: KML_Polygon.h:23
KML_Object::AddCommnt
virtual void AddCommnt(int ncom, char **pcom)
Definition: KML_Object.cpp:301
KML_Object::WriteCommnt
virtual void WriteCommnt(FILE *fid, const char *indent)
Definition: KML_Object.cpp:326
KML_Geometry::Echo
void Echo()
Definition: KML_Geometry.cpp:33
KML_Geometry::Read
void Read(FILE *fid, char *kstr)
Definition: KML_Geometry.cpp:63