| 1 | #ifndef OSG_SHAPE_H |
|---|
| 2 | #define OSG_SHAPE_H |
|---|
| 3 | |
|---|
| 4 | #include <stdio.h> |
|---|
| 5 | #ifndef WIN32 |
|---|
| 6 | #include <unistd.h> |
|---|
| 7 | #endif |
|---|
| 8 | #include <osg/Referenced> |
|---|
| 9 | |
|---|
| 10 | #include "ESRIType.h" |
|---|
| 11 | |
|---|
| 12 | namespace ESRIShape { |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | enum ByteOrder { |
|---|
| 16 | LittleEndian, |
|---|
| 17 | BigEndian |
|---|
| 18 | }; |
|---|
| 19 | |
|---|
| 20 | enum PartType{ |
|---|
| 21 | TriangleStrip = 0, |
|---|
| 22 | TriangleFan = 1, |
|---|
| 23 | OuterRing = 2, |
|---|
| 24 | InnerRing = 3, |
|---|
| 25 | FirstRing = 4, |
|---|
| 26 | Ring = 5 |
|---|
| 27 | }; |
|---|
| 28 | |
|---|
| 29 | enum ShapeType { |
|---|
| 30 | ShapeTypeNullShape = 0, |
|---|
| 31 | ShapeTypePoint = 1, |
|---|
| 32 | ShapeTypePolyLine = 3, |
|---|
| 33 | ShapeTypePolygon = 5, |
|---|
| 34 | ShapeTypeMultiPoint = 8, |
|---|
| 35 | ShapeTypePointZ = 11, |
|---|
| 36 | ShapeTypePolyLineZ = 13, |
|---|
| 37 | ShapeTypePolygonZ = 15, |
|---|
| 38 | ShapeTypeMultiPointZ = 18, |
|---|
| 39 | ShapeTypePointM = 21, |
|---|
| 40 | ShapeTypePolyLineM = 23, |
|---|
| 41 | ShapeTypePolygonM = 25, |
|---|
| 42 | ShapeTypeMultiPointM = 28, |
|---|
| 43 | ShapeTypeMultiPatch = 31 |
|---|
| 44 | }; |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | struct BoundingBox |
|---|
| 48 | { |
|---|
| 49 | Double Xmin; |
|---|
| 50 | Double Ymin; |
|---|
| 51 | Double Xmax; |
|---|
| 52 | Double Ymax; |
|---|
| 53 | Double Zmin; |
|---|
| 54 | Double Zmax; |
|---|
| 55 | Double Mmin; |
|---|
| 56 | Double Mmax; |
|---|
| 57 | |
|---|
| 58 | bool read( int fd ); |
|---|
| 59 | |
|---|
| 60 | void print(); |
|---|
| 61 | }; |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | struct ShapeHeader |
|---|
| 66 | { |
|---|
| 67 | Integer fileCode; |
|---|
| 68 | Byte _unused_0[20]; |
|---|
| 69 | Integer fileLength; |
|---|
| 70 | Integer version; |
|---|
| 71 | Integer shapeType; |
|---|
| 72 | BoundingBox bbox; |
|---|
| 73 | |
|---|
| 74 | bool read(int fd); |
|---|
| 75 | |
|---|
| 76 | void print(); |
|---|
| 77 | }; |
|---|
| 78 | |
|---|
| 79 | struct RecordHeader |
|---|
| 80 | { |
|---|
| 81 | Integer recordNumber; |
|---|
| 82 | Integer contentLength; |
|---|
| 83 | |
|---|
| 84 | RecordHeader(); |
|---|
| 85 | |
|---|
| 86 | bool read( int fd ); |
|---|
| 87 | |
|---|
| 88 | void print(); |
|---|
| 89 | }; |
|---|
| 90 | |
|---|
| 91 | |
|---|
| 92 | struct NullRecord |
|---|
| 93 | { |
|---|
| 94 | Integer shapeType; |
|---|
| 95 | NullRecord(); |
|---|
| 96 | |
|---|
| 97 | bool read( int fd ); |
|---|
| 98 | }; |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | struct Box |
|---|
| 103 | { |
|---|
| 104 | Double Xmin, Ymin, Xmax, Ymax; |
|---|
| 105 | |
|---|
| 106 | Box(); |
|---|
| 107 | Box(const Box &b ); |
|---|
| 108 | bool read( int fd ); |
|---|
| 109 | }; |
|---|
| 110 | |
|---|
| 111 | struct Range { |
|---|
| 112 | Double min, max; |
|---|
| 113 | Range(); |
|---|
| 114 | Range( const Range &r ); |
|---|
| 115 | |
|---|
| 116 | bool read( int fd ); |
|---|
| 117 | }; |
|---|
| 118 | |
|---|
| 119 | struct ShapeObject : public osg::Referenced |
|---|
| 120 | { |
|---|
| 121 | ShapeType shapeType; |
|---|
| 122 | ShapeObject(ShapeType s); |
|---|
| 123 | virtual ~ShapeObject(); |
|---|
| 124 | }; |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | struct Point : public ShapeObject |
|---|
| 128 | { |
|---|
| 129 | Double x, y; |
|---|
| 130 | |
|---|
| 131 | Point(); |
|---|
| 132 | Point(const Point &p); |
|---|
| 133 | virtual ~Point(); |
|---|
| 134 | |
|---|
| 135 | bool read( int fd ); |
|---|
| 136 | void print(); |
|---|
| 137 | }; |
|---|
| 138 | |
|---|
| 139 | struct PointRecord |
|---|
| 140 | { |
|---|
| 141 | Point point; |
|---|
| 142 | bool read( int fd ); |
|---|
| 143 | }; |
|---|
| 144 | |
|---|
| 145 | struct MultiPoint: public ShapeObject |
|---|
| 146 | { |
|---|
| 147 | Box bbox; |
|---|
| 148 | Integer numPoints; |
|---|
| 149 | struct Point *points; |
|---|
| 150 | |
|---|
| 151 | MultiPoint(); |
|---|
| 152 | |
|---|
| 153 | MultiPoint( const struct MultiPoint &mpoint ); |
|---|
| 154 | |
|---|
| 155 | virtual ~MultiPoint(); |
|---|
| 156 | |
|---|
| 157 | bool read( int fd ); |
|---|
| 158 | |
|---|
| 159 | void print(); |
|---|
| 160 | }; |
|---|
| 161 | |
|---|
| 162 | struct PolyLine: public ShapeObject |
|---|
| 163 | { |
|---|
| 164 | Box bbox; |
|---|
| 165 | Integer numParts; |
|---|
| 166 | Integer numPoints; |
|---|
| 167 | Integer *parts; |
|---|
| 168 | struct Point *points; |
|---|
| 169 | |
|---|
| 170 | PolyLine(); |
|---|
| 171 | |
|---|
| 172 | PolyLine( const PolyLine &p ); |
|---|
| 173 | |
|---|
| 174 | virtual ~PolyLine(); |
|---|
| 175 | |
|---|
| 176 | bool read( int fd ); |
|---|
| 177 | }; |
|---|
| 178 | |
|---|
| 179 | |
|---|
| 180 | |
|---|
| 181 | struct Polygon : public ShapeObject |
|---|
| 182 | { |
|---|
| 183 | Box bbox; |
|---|
| 184 | Integer numParts; |
|---|
| 185 | Integer numPoints; |
|---|
| 186 | Integer *parts; |
|---|
| 187 | Point *points; |
|---|
| 188 | |
|---|
| 189 | Polygon(); |
|---|
| 190 | |
|---|
| 191 | Polygon( const Polygon &p ); |
|---|
| 192 | |
|---|
| 193 | virtual ~Polygon(); |
|---|
| 194 | |
|---|
| 195 | |
|---|
| 196 | bool read( int fd ); |
|---|
| 197 | }; |
|---|
| 198 | |
|---|
| 199 | |
|---|
| 200 | struct PointM : public ShapeObject |
|---|
| 201 | { |
|---|
| 202 | Double x, y, m; |
|---|
| 203 | |
|---|
| 204 | PointM(); |
|---|
| 205 | |
|---|
| 206 | PointM(const PointM &p); |
|---|
| 207 | |
|---|
| 208 | virtual ~PointM(); |
|---|
| 209 | |
|---|
| 210 | bool read( int fd ); |
|---|
| 211 | |
|---|
| 212 | void print(); |
|---|
| 213 | }; |
|---|
| 214 | |
|---|
| 215 | struct PointMRecord |
|---|
| 216 | { |
|---|
| 217 | PointM pointM; |
|---|
| 218 | |
|---|
| 219 | bool read( int fd ); |
|---|
| 220 | }; |
|---|
| 221 | |
|---|
| 222 | |
|---|
| 223 | struct MultiPointM: public ShapeObject |
|---|
| 224 | { |
|---|
| 225 | Box bbox; |
|---|
| 226 | Integer numPoints; |
|---|
| 227 | struct Point *points; |
|---|
| 228 | struct Range mRange; |
|---|
| 229 | Double *mArray; |
|---|
| 230 | |
|---|
| 231 | MultiPointM(); |
|---|
| 232 | |
|---|
| 233 | MultiPointM( const struct MultiPointM &mpointm ); |
|---|
| 234 | |
|---|
| 235 | virtual ~MultiPointM(); |
|---|
| 236 | |
|---|
| 237 | bool read( int fd ); |
|---|
| 238 | |
|---|
| 239 | void print(); |
|---|
| 240 | }; |
|---|
| 241 | |
|---|
| 242 | |
|---|
| 243 | struct PolyLineM: public ShapeObject |
|---|
| 244 | { |
|---|
| 245 | Box bbox; |
|---|
| 246 | Integer numParts; |
|---|
| 247 | Integer numPoints; |
|---|
| 248 | Integer *parts; |
|---|
| 249 | struct Point *points; |
|---|
| 250 | struct Range mRange; |
|---|
| 251 | Double *mArray; |
|---|
| 252 | |
|---|
| 253 | PolyLineM(); |
|---|
| 254 | |
|---|
| 255 | PolyLineM(const PolyLineM &p); |
|---|
| 256 | |
|---|
| 257 | virtual ~PolyLineM(); |
|---|
| 258 | |
|---|
| 259 | bool read( int fd ); |
|---|
| 260 | }; |
|---|
| 261 | |
|---|
| 262 | |
|---|
| 263 | struct PolygonM : public ShapeObject |
|---|
| 264 | { |
|---|
| 265 | Box bbox; |
|---|
| 266 | Integer numParts; |
|---|
| 267 | Integer numPoints; |
|---|
| 268 | Integer *parts; |
|---|
| 269 | Point *points; |
|---|
| 270 | struct Range mRange; |
|---|
| 271 | Double *mArray; |
|---|
| 272 | |
|---|
| 273 | PolygonM(); |
|---|
| 274 | |
|---|
| 275 | PolygonM(const PolygonM &p); |
|---|
| 276 | |
|---|
| 277 | virtual ~PolygonM(); |
|---|
| 278 | |
|---|
| 279 | bool read( int fd ); |
|---|
| 280 | }; |
|---|
| 281 | |
|---|
| 282 | |
|---|
| 283 | |
|---|
| 284 | |
|---|
| 285 | |
|---|
| 286 | |
|---|
| 287 | |
|---|
| 288 | |
|---|
| 289 | |
|---|
| 290 | struct PointZ : public ShapeObject |
|---|
| 291 | { |
|---|
| 292 | Double x, y, z, m; |
|---|
| 293 | |
|---|
| 294 | PointZ(); |
|---|
| 295 | PointZ(const PointZ &p); |
|---|
| 296 | virtual ~PointZ(); |
|---|
| 297 | |
|---|
| 298 | bool read( int fd ); |
|---|
| 299 | |
|---|
| 300 | void print(); |
|---|
| 301 | }; |
|---|
| 302 | |
|---|
| 303 | struct MultiPointZ: public ShapeObject |
|---|
| 304 | { |
|---|
| 305 | Box bbox; |
|---|
| 306 | Integer numPoints; |
|---|
| 307 | struct Point *points; |
|---|
| 308 | struct Range zRange; |
|---|
| 309 | Double *zArray; |
|---|
| 310 | struct Range mRange; |
|---|
| 311 | Double *mArray; |
|---|
| 312 | |
|---|
| 313 | MultiPointZ(); |
|---|
| 314 | |
|---|
| 315 | MultiPointZ( const struct MultiPointZ &); |
|---|
| 316 | |
|---|
| 317 | virtual ~MultiPointZ(); |
|---|
| 318 | |
|---|
| 319 | bool read( int fd ); |
|---|
| 320 | |
|---|
| 321 | void print(); |
|---|
| 322 | }; |
|---|
| 323 | |
|---|
| 324 | |
|---|
| 325 | |
|---|
| 326 | struct PolyLineZ: public ShapeObject |
|---|
| 327 | { |
|---|
| 328 | Box bbox; |
|---|
| 329 | Integer numParts; |
|---|
| 330 | Integer numPoints; |
|---|
| 331 | Integer *parts; |
|---|
| 332 | struct Point *points; |
|---|
| 333 | struct Range zRange; |
|---|
| 334 | Double *zArray; |
|---|
| 335 | struct Range mRange; |
|---|
| 336 | Double *mArray; |
|---|
| 337 | |
|---|
| 338 | PolyLineZ(); |
|---|
| 339 | |
|---|
| 340 | PolyLineZ( const PolyLineZ &p ); |
|---|
| 341 | |
|---|
| 342 | virtual ~PolyLineZ(); |
|---|
| 343 | |
|---|
| 344 | bool read( int fd ); |
|---|
| 345 | }; |
|---|
| 346 | |
|---|
| 347 | |
|---|
| 348 | struct PolygonZ : public ShapeObject |
|---|
| 349 | { |
|---|
| 350 | Box bbox; |
|---|
| 351 | Integer numParts; |
|---|
| 352 | Integer numPoints; |
|---|
| 353 | Integer *parts; |
|---|
| 354 | Point *points; |
|---|
| 355 | struct Range zRange; |
|---|
| 356 | Double *zArray; |
|---|
| 357 | struct Range mRange; |
|---|
| 358 | Double *mArray; |
|---|
| 359 | |
|---|
| 360 | PolygonZ(); |
|---|
| 361 | |
|---|
| 362 | PolygonZ( const PolygonZ &p ); |
|---|
| 363 | |
|---|
| 364 | virtual ~PolygonZ(); |
|---|
| 365 | |
|---|
| 366 | |
|---|
| 367 | bool read( int fd ); |
|---|
| 368 | }; |
|---|
| 369 | |
|---|
| 370 | |
|---|
| 371 | |
|---|
| 372 | |
|---|
| 373 | |
|---|
| 374 | struct MultiPatch |
|---|
| 375 | { |
|---|
| 376 | Box bbox; |
|---|
| 377 | Integer numParts; |
|---|
| 378 | Integer numPoints; |
|---|
| 379 | Integer *parts; |
|---|
| 380 | Integer *partTypes; |
|---|
| 381 | struct Point *points; |
|---|
| 382 | Range zRange; |
|---|
| 383 | Double *zArray; |
|---|
| 384 | Range mRange; |
|---|
| 385 | Double *mArray; |
|---|
| 386 | |
|---|
| 387 | MultiPatch(); |
|---|
| 388 | MultiPatch( const MultiPatch &); |
|---|
| 389 | virtual ~MultiPatch(); |
|---|
| 390 | bool read( int ); |
|---|
| 391 | }; |
|---|
| 392 | |
|---|
| 393 | } |
|---|
| 394 | |
|---|
| 395 | #endif |
|---|