00001 #include "SIGEL_Robot/SIG_Polygon.h"
00002 #include "SIGEL_Robot/SIG_Robot.h"
00003 #include <stdio.h>
00004
00005 namespace SIGEL_Robot {
00006 SIG_Polygon::SIG_Polygon (SIG_Geometry *within, SIG_Polygon *other)
00007 : myGeometry (within),
00008 vertices (0)
00009 {
00010 vertices.resize (other->vertices.count ());
00011 for (int i = 0; i < other->vertices.count (); i++)
00012 vertices [i] = other->vertices [i];
00013 }
00014
00015 SIG_Polygon::SIG_Polygon (SIG_Geometry *within)
00016 : myGeometry (within),
00017 vertices (0)
00018 {
00019 within->addPolygon (this);
00020 }
00021
00022 SIG_Polygon::SIG_Polygon (SIG_Geometry *mygeom, QTextStream & tx)
00023 : myGeometry (mygeom)
00024 {
00025 QString tmpstr;
00026 int zahl;
00027
00028 tx >> tmpstr;
00029 if (tmpstr != "Polygon")
00030
00031 ;
00032
00033 tx >> zahl;
00034 vertices.resize (zahl);
00035 for (int i = 0; i < zahl; i++)
00036 tx >> vertices [i];
00037 }
00038
00039 SIG_Polygon::~SIG_Polygon (void)
00040 {
00041 }
00042
00043 void SIG_Polygon::appendVertex (DL_vector pt)
00044 {
00045 int idx = vertices.size ();
00046 vertices.resize (idx + 1);
00047 vertices [idx] = myGeometry->getOrAddVertex (pt);
00048 }
00049
00050 int SIG_Polygon::getNumVertices (void) const
00051 {
00052 return vertices.size ();
00053 }
00054
00055 DL_vector SIG_Polygon::getVertex (int nr) const
00056 {
00057 return myGeometry->getVertex (vertices [nr]);
00058 }
00059
00060 int SIG_Polygon::getVertexIndex (int nr) const
00061 {
00062 return vertices [nr];
00063 }
00064
00065 void SIG_Polygon::writeToFileTransfer (QTextStream & tx) const
00066 {
00067 int vc = vertices.count ();
00068 tx << "Polygon " << vc;
00069 for (int i = 0; i < vc; i++) {
00070 tx << ' ' << vertices [i];
00071 }
00072 tx << '\n';
00073
00074 }
00075 }