DecorativeGeometry.h
Go to the documentation of this file.00001 #ifndef SimTK_SimTKCOMMON_DECORATIVE_GEOMETRY_H_
00002 #define SimTK_SimTKCOMMON_DECORATIVE_GEOMETRY_H_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099 #include "SimTKcommon/Simmatrix.h"
00100 #include "SimTKcommon/internal/PolygonalMesh.h"
00101
00102 #include <cassert>
00103
00104
00105 namespace SimTK {
00106
00107 class AnalyticGeometry;
00108
00109
00110
00111 static const Vec3 Black = Vec3( 0, 0, 0);
00112 static const Vec3 Gray = Vec3(.5,.5,.5);
00113 static const Vec3 Red = Vec3( 1, 0, 0);
00114 static const Vec3 Green = Vec3( 0, 1, 0);
00115 static const Vec3 Blue = Vec3( 0, 0, 1);
00116 static const Vec3 Yellow = Vec3( 1, 1, 0);
00117 static const Vec3 Orange = Vec3( 1,.5, 0);
00118 static const Vec3 Magenta = Vec3( 1, 0, 1);
00119 static const Vec3 Purple = Vec3(.5, 0,.5);
00120 static const Vec3 Cyan = Vec3( 0, 1, 1);
00121 static const Vec3 White = Vec3( 1, 1, 1);
00122
00123
00124
00125 class DecorativeGeometryImplementation;
00126
00132 class SimTK_SimTKCOMMON_EXPORT DecorativeGeometry {
00133 public:
00134 DecorativeGeometry() : rep(0) { }
00135 ~DecorativeGeometry();
00136 DecorativeGeometry(const DecorativeGeometry&);
00137 DecorativeGeometry& operator=(const DecorativeGeometry&);
00138
00139
00140 enum Representation {
00141 DrawPoints = 1,
00142 DrawWireframe = 2,
00143 DrawSurface = 3,
00144
00145 DrawDefault = -1
00146 };
00147
00149 DecorativeGeometry(const AnalyticGeometry&);
00150
00155 DecorativeGeometry& setBodyId(int);
00156
00162 DecorativeGeometry& setTransform(const Transform& X_BG);
00163
00169 DecorativeGeometry& setResolution(Real);
00170
00178 DecorativeGeometry& setScale(Real);
00179
00182 int getBodyId() const;
00183
00186 Real getResolution() const;
00187
00191 const Transform& getTransform() const;
00192
00195 Real getScale() const;
00196
00200 DecorativeGeometry& setColor(const Vec3& rgb);
00201
00205 DecorativeGeometry& setOpacity(Real);
00206
00211 DecorativeGeometry& setLineThickness(Real);
00212
00213 const Vec3& getColor() const;
00214 Real getOpacity() const;
00215 Real getLineThickness() const;
00216
00218 DecorativeGeometry& setFaceCamera(bool face);
00220 bool getFaceCamera() const;
00221
00224 DecorativeGeometry& setRepresentation(const Representation&);
00225
00227 Representation getRepresentation() const;
00228
00229 void implementGeometry(DecorativeGeometryImplementation&) const;
00230
00231
00232
00233 bool isOwnerHandle() const;
00234 bool isEmptyHandle() const;
00235 explicit DecorativeGeometry(class DecorativeGeometryRep* r) : rep(r) { }
00236 bool hasRep() const {return rep!=0;}
00237 const DecorativeGeometryRep& getRep() const {assert(rep); return *rep;}
00238 DecorativeGeometryRep& updRep() {assert(rep); return *rep;}
00239 protected:
00240 DecorativeGeometryRep* rep;
00241 };
00242
00254 class SimTK_SimTKCOMMON_EXPORT DecorativeLine : public DecorativeGeometry {
00255 public:
00256 explicit DecorativeLine(const Vec3& p1=Vec3(0), const Vec3& p2=Vec3(1));
00257
00258
00259 DecorativeLine& setBodyId(int b) {DecorativeGeometry::setBodyId(b); return *this;}
00260 DecorativeLine& setTransform(const Transform& X_BD) {DecorativeGeometry::setTransform(X_BD); return *this;}
00261 DecorativeLine& setResolution(Real r) {DecorativeGeometry::setResolution(r); return *this;}
00262 DecorativeLine& setScale(Real s) {DecorativeGeometry::setScale(s); return *this;}
00263 DecorativeLine& setColor(const Vec3& rgb) {DecorativeGeometry::setColor(rgb); return *this;}
00264 DecorativeLine& setOpacity(Real o) {DecorativeGeometry::setOpacity(o); return *this;}
00265 DecorativeLine& setLineThickness(Real t) {DecorativeGeometry::setLineThickness(t); return *this;}
00266 DecorativeLine& setRepresentation(const Representation& r) {
00267 DecorativeGeometry::setRepresentation(r); return *this;
00268 }
00269
00270
00271 DecorativeLine& setPoint1(const Vec3& p1);
00272 DecorativeLine& setPoint2(const Vec3& p2);
00273 DecorativeLine& setEndpoints(const Vec3& p1, const Vec3& p2);
00274
00275 const Vec3& getPoint1() const;
00276 const Vec3& getPoint2() const;
00277
00278 SimTK_PIMPL_DOWNCAST(DecorativeLine, DecorativeGeometry);
00279 private:
00280 class DecorativeLineRep& updRep();
00281 const DecorativeLineRep& getRep() const;
00282 };
00283
00288 class SimTK_SimTKCOMMON_EXPORT DecorativeCircle : public DecorativeGeometry {
00289 public:
00290 explicit DecorativeCircle(Real radius=0.5);
00291
00292 void setRadius(Real);
00293 Real getRadius() const;
00294
00295 SimTK_PIMPL_DOWNCAST(DecorativeCircle, DecorativeGeometry);
00296 private:
00297 class DecorativeCircleRep& updRep();
00298 const DecorativeCircleRep& getRep() const;
00299 };
00300
00305 class SimTK_SimTKCOMMON_EXPORT DecorativeSphere : public DecorativeGeometry {
00306 public:
00307 explicit DecorativeSphere(Real radius=0.5);
00308
00309 void setRadius(Real);
00310 Real getRadius() const;
00311
00312 SimTK_PIMPL_DOWNCAST(DecorativeSphere, DecorativeGeometry);
00313 private:
00314 class DecorativeSphereRep& updRep();
00315 const DecorativeSphereRep& getRep() const;
00316 };
00317
00323 class SimTK_SimTKCOMMON_EXPORT DecorativeEllipsoid : public DecorativeGeometry {
00324 public:
00325 explicit DecorativeEllipsoid(const Vec3& radii = Vec3(0.5,1/3.,0.25));
00326
00327 void setRadii(const Vec3&);
00328 const Vec3& getRadii() const;
00329
00330 SimTK_PIMPL_DOWNCAST(DecorativeEllipsoid, DecorativeGeometry);
00331 private:
00332 class DecorativeEllipsoidRep& updRep();
00333 const DecorativeEllipsoidRep& getRep() const;
00334 };
00335
00341 class SimTK_SimTKCOMMON_EXPORT DecorativeBrick : public DecorativeGeometry {
00342 public:
00343 explicit DecorativeBrick(const Vec3& halfLengths = Vec3(0.5));
00344
00345 void setHalfLengths(const Vec3&);
00346 const Vec3& getHalfLengths() const;
00347
00348 SimTK_PIMPL_DOWNCAST(DecorativeBrick, DecorativeGeometry);
00349 private:
00350 class DecorativeBrickRep& updRep();
00351 const DecorativeBrickRep& getRep() const;
00352 };
00353
00359 class SimTK_SimTKCOMMON_EXPORT DecorativeCylinder : public DecorativeGeometry {
00360 public:
00361 explicit DecorativeCylinder(Real radius=0.5, Real halfHeight=0.5);
00362
00363 void setRadius(Real);
00364 void setHalfHeight(Real);
00365 Real getRadius() const;
00366 Real getHalfHeight() const;
00367
00368 SimTK_PIMPL_DOWNCAST(DecorativeCylinder, DecorativeGeometry);
00369 private:
00370 class DecorativeCylinderRep& updRep();
00371 const DecorativeCylinderRep& getRep() const;
00372 };
00373
00379 class SimTK_SimTKCOMMON_EXPORT DecorativeFrame : public DecorativeGeometry {
00380 public:
00381 explicit DecorativeFrame(Real axisLength=1);
00382
00383 void setAxisLength(Real);
00384 Real getAxisLength() const;
00385
00386 SimTK_PIMPL_DOWNCAST(DecorativeFrame, DecorativeGeometry);
00387 private:
00388 class DecorativeFrameRep& updRep();
00389 const DecorativeFrameRep& getRep() const;
00390 };
00391
00396 class SimTK_SimTKCOMMON_EXPORT DecorativeText : public DecorativeGeometry {
00397 public:
00398 explicit DecorativeText(const std::string& label="");
00399
00400 void setText(const std::string& label);
00401 const std::string& getText() const;
00402
00403 SimTK_PIMPL_DOWNCAST(DecorativeText, DecorativeGeometry);
00404 private:
00405 class DecorativeTextRep& updRep();
00406 const DecorativeTextRep& getRep() const;
00407 };
00408
00412 class SimTK_SimTKCOMMON_EXPORT DecorativeMesh : public DecorativeGeometry {
00413 public:
00414 explicit DecorativeMesh(const PolygonalMesh& mesh);
00415 const PolygonalMesh& getMesh() const;
00416
00417 SimTK_PIMPL_DOWNCAST(DecorativeMesh, DecorativeGeometry);
00418 private:
00419 class DecorativeMeshRep& updRep();
00420 const DecorativeMeshRep& getRep() const;
00421 };
00422
00427 class SimTK_SimTKCOMMON_EXPORT DecorativeGeometryImplementation {
00428 public:
00429 virtual ~DecorativeGeometryImplementation() { }
00430 virtual void implementLineGeometry( const DecorativeLine&) = 0;
00431 virtual void implementBrickGeometry( const DecorativeBrick&) = 0;
00432 virtual void implementCylinderGeometry( const DecorativeCylinder&) = 0;
00433 virtual void implementCircleGeometry( const DecorativeCircle&) = 0;
00434 virtual void implementSphereGeometry( const DecorativeSphere&) = 0;
00435 virtual void implementEllipsoidGeometry(const DecorativeEllipsoid&)= 0;
00436 virtual void implementFrameGeometry( const DecorativeFrame&) = 0;
00437 virtual void implementTextGeometry( const DecorativeText&) = 0;
00438 virtual void implementMeshGeometry( const DecorativeMesh&) = 0;
00439
00440
00441 };
00442
00443 }
00444
00445 #endif // SimTK_SimTKCOMMON_DECORATIVE_GEOMETRY_H_