00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00029 #ifndef GWS_H
00030
00031 #include <vector>
00032 #include <set>
00033 #include "matvec3D.h"
00034
00035 class Grasp;
00036 struct coordT;
00037
00039
00043 class GWS {
00044 public:
00046 static const std::vector<int> ALL_DIMENSIONS;
00047 protected:
00049 bool useGravity;
00050
00052 vec3 gravDirection;
00053
00055 int buildHyperplanesFromWrenches(void *wr, int numWrenches,
00056 std::vector<int> useDimensions);
00057
00059 void computeHyperplaneMetrics();
00060
00062 void clearGWS();
00063
00064 public:
00065
00067 void setGravity(bool use, vec3 gd=vec3(0,0,0));
00068
00070 Grasp *grasp;
00071
00073 int numHyperPlanes;
00074
00076 double **hyperPlanes;
00077
00079 std::vector<int> mUsedDimensions;
00080
00082 double hullArea;
00083
00085 double hullVolume;
00086
00088 bool forceClosure;
00089
00091 int refCount;
00092
00094 GWS(Grasp *g) : useGravity(false), grasp(g),numHyperPlanes(0),hyperPlanes(NULL),refCount(0) {}
00095
00096 virtual ~GWS();
00097
00099 Grasp *getGrasp() const {return grasp;}
00100
00102 void ref() {refCount++;}
00103
00105 void unref() {refCount--;}
00106
00108 int getRefCount() {return refCount;}
00109
00111 bool isForceClosure() {return forceClosure;}
00112
00114 bool hasPositiveVolume(){ if (hullVolume>0) return true; return false;}
00115
00117 virtual const char *getType() =0;
00118
00120 virtual int build(std::vector<int> useDimensions = ALL_DIMENSIONS) = 0;
00121
00123 virtual int projectTo3D(double *projCoords,std::set<int> fixedCoordSet,
00124 std::vector<position> &hullCoords,
00125 std::vector<int> &hullIndices);
00126
00128 static const char *TYPE_LIST[];
00129
00130 static GWS *createInstance(const char *type,Grasp *g);
00131 };
00132
00134
00138 class L1GWS : public GWS {
00139
00141 static const char *type;
00142
00143 public:
00144
00146 L1GWS(Grasp *g) : GWS(g) {}
00147
00149 int build(std::vector<int> useDimensions = ALL_DIMENSIONS);
00150
00152 static const char *getClassType() {return type;}
00153
00155 virtual const char *getType() {return type;}
00156 };
00157
00159
00163 class LInfGWS : public GWS {
00164
00166 static const char *type;
00167
00168 public:
00169
00171 LInfGWS(Grasp *g) : GWS(g) {}
00172
00173
00175 int build(std::vector<int> useDimensions = ALL_DIMENSIONS);
00176
00178 static const char *getClassType() {return type;}
00179
00181 virtual const char *getType() {return type;}
00182
00183 };
00184
00185 #define GWS_H
00186 #endif