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
00101 #include <cassert>
00102
00103
00104 namespace SimTK {
00105
00106 class AnalyticGeometry;
00107
00108
00109
00110 static const Vec3 Black = Vec3( 0, 0, 0);
00111 static const Vec3 Gray = Vec3(.5,.5,.5);
00112 static const Vec3 Red = Vec3( 1, 0, 0);
00113 static const Vec3 Green = Vec3( 0, 1, 0);
00114 static const Vec3 Blue = Vec3( 0, 0, 1);
00115 static const Vec3 Yellow = Vec3( 1, 1, 0);
00116 static const Vec3 Orange = Vec3( 1,.5, 0);
00117 static const Vec3 Magenta = Vec3( 1, 0, 1);
00118 static const Vec3 Purple = Vec3(.5, 0,.5);
00119 static const Vec3 Cyan = Vec3( 0, 1, 1);
00120 static const Vec3 White = Vec3( 1, 1, 1);
00121
00122
00123
00124 class DecorativeGeometryImplementation;
00125
00131 class SimTK_SimTKCOMMON_EXPORT DecorativeGeometry {
00132 public:
00133 DecorativeGeometry() : rep(0) { }
00134 ~DecorativeGeometry();
00135 DecorativeGeometry(const DecorativeGeometry&);
00136 DecorativeGeometry& operator=(const DecorativeGeometry&);
00137
00138
00139 enum Representation {
00140 DrawPoints = 1,
00141 DrawWireframe = 2,
00142 DrawSurface = 3,
00143
00144 DrawDefault = -1
00145 };
00146
00148 DecorativeGeometry(const AnalyticGeometry&);
00149
00154 DecorativeGeometry& setBodyId(int);
00155
00161 DecorativeGeometry& setTransform(const Transform& X_BG);
00162
00168 DecorativeGeometry& setResolution(Real);
00169
00177 DecorativeGeometry& setScale(Real);
00178
00181 int getBodyId() const;
00182
00185 Real getResolution() const;
00186
00190 const Transform& getTransform() const;
00191
00194 Real getScale() const;
00195
00199 DecorativeGeometry& setColor(const Vec3& rgb);
00200
00204 DecorativeGeometry& setOpacity(Real);
00205
00210 DecorativeGeometry& setLineThickness(Real);
00211
00212 const Vec3& getColor() const;
00213 Real getOpacity() const;
00214 Real getLineThickness() const;
00215
00217 DecorativeGeometry& setFaceCamera(bool face);
00219 bool getFaceCamera() const;
00220
00223 DecorativeGeometry& setRepresentation(const Representation&);
00224
00226 Representation getRepresentation() const;
00227
00228 void implementGeometry(DecorativeGeometryImplementation&) const;
00229
00230
00231
00232 bool isOwnerHandle() const;
00233 bool isEmptyHandle() const;
00234 explicit DecorativeGeometry(class DecorativeGeometryRep* r) : rep(r) { }
00235 bool hasRep() const {return rep!=0;}
00236 const DecorativeGeometryRep& getRep() const {assert(rep); return *rep;}
00237 DecorativeGeometryRep& updRep() {assert(rep); return *rep;}
00238 protected:
00239 DecorativeGeometryRep* rep;
00240 };
00241
00253 class SimTK_SimTKCOMMON_EXPORT DecorativeLine : public DecorativeGeometry {
00254 public:
00255 explicit DecorativeLine(const Vec3& p1=Vec3(0), const Vec3& p2=Vec3(1));
00256
00257
00258 DecorativeLine& setBodyId(int b) {DecorativeGeometry::setBodyId(b); return *this;}
00259 DecorativeLine& setTransform(const Transform& X_BD) {DecorativeGeometry::setTransform(X_BD); return *this;}
00260 DecorativeLine& setResolution(Real r) {DecorativeGeometry::setResolution(r); return *this;}
00261 DecorativeLine& setScale(Real s) {DecorativeGeometry::setScale(s); return *this;}
00262 DecorativeLine& setColor(const Vec3& rgb) {DecorativeGeometry::setColor(rgb); return *this;}
00263 DecorativeLine& setOpacity(Real o) {DecorativeGeometry::setOpacity(o); return *this;}
00264 DecorativeLine& setLineThickness(Real t) {DecorativeGeometry::setLineThickness(t); return *this;}
00265 DecorativeLine& setRepresentation(const Representation& r) {
00266 DecorativeGeometry::setRepresentation(r); return *this;
00267 }
00268
00269
00270 DecorativeLine& setPoint1(const Vec3& p1);
00271 DecorativeLine& setPoint2(const Vec3& p2);
00272 DecorativeLine& setEndpoints(const Vec3& p1, const Vec3& p2);
00273
00274 const Vec3& getPoint1() const;
00275 const Vec3& getPoint2() const;
00276
00277 SimTK_PIMPL_DOWNCAST(DecorativeLine, DecorativeGeometry);
00278 private:
00279 class DecorativeLineRep& updRep();
00280 const DecorativeLineRep& getRep() const;
00281 };
00282
00287 class SimTK_SimTKCOMMON_EXPORT DecorativeCircle : public DecorativeGeometry {
00288 public:
00289 explicit DecorativeCircle(Real radius=0.5);
00290
00291 void setRadius(Real);
00292 Real getRadius() const;
00293
00294 SimTK_PIMPL_DOWNCAST(DecorativeCircle, DecorativeGeometry);
00295 private:
00296 class DecorativeCircleRep& updRep();
00297 const DecorativeCircleRep& getRep() const;
00298 };
00299
00304 class SimTK_SimTKCOMMON_EXPORT DecorativeSphere : public DecorativeGeometry {
00305 public:
00306 explicit DecorativeSphere(Real radius=0.5);
00307
00308 void setRadius(Real);
00309 Real getRadius() const;
00310
00311 SimTK_PIMPL_DOWNCAST(DecorativeSphere, DecorativeGeometry);
00312 private:
00313 class DecorativeSphereRep& updRep();
00314 const DecorativeSphereRep& getRep() const;
00315 };
00316
00322 class SimTK_SimTKCOMMON_EXPORT DecorativeEllipsoid : public DecorativeGeometry {
00323 public:
00324 explicit DecorativeEllipsoid(const Vec3& radii = Vec3(0.5,1/3.,0.25));
00325
00326 void setRadii(const Vec3&);
00327 const Vec3& getRadii() const;
00328
00329 SimTK_PIMPL_DOWNCAST(DecorativeEllipsoid, DecorativeGeometry);
00330 private:
00331 class DecorativeEllipsoidRep& updRep();
00332 const DecorativeEllipsoidRep& getRep() const;
00333 };
00334
00340 class SimTK_SimTKCOMMON_EXPORT DecorativeBrick : public DecorativeGeometry {
00341 public:
00342 explicit DecorativeBrick(const Vec3& halfLengths = Vec3(0.5));
00343
00344 void setHalfLengths(const Vec3&);
00345 const Vec3& getHalfLengths() const;
00346
00347 SimTK_PIMPL_DOWNCAST(DecorativeBrick, DecorativeGeometry);
00348 private:
00349 class DecorativeBrickRep& updRep();
00350 const DecorativeBrickRep& getRep() const;
00351 };
00352
00358 class SimTK_SimTKCOMMON_EXPORT DecorativeCylinder : public DecorativeGeometry {
00359 public:
00360 explicit DecorativeCylinder(Real radius=0.5, Real halfHeight=0.5);
00361
00362 void setRadius(Real);
00363 void setHalfHeight(Real);
00364 Real getRadius() const;
00365 Real getHalfHeight() const;
00366
00367 SimTK_PIMPL_DOWNCAST(DecorativeCylinder, DecorativeGeometry);
00368 private:
00369 class DecorativeCylinderRep& updRep();
00370 const DecorativeCylinderRep& getRep() const;
00371 };
00372
00378 class SimTK_SimTKCOMMON_EXPORT DecorativeFrame : public DecorativeGeometry {
00379 public:
00380 explicit DecorativeFrame(Real axisLength=1);
00381
00382 void setAxisLength(Real);
00383 Real getAxisLength() const;
00384
00385 SimTK_PIMPL_DOWNCAST(DecorativeFrame, DecorativeGeometry);
00386 private:
00387 class DecorativeFrameRep& updRep();
00388 const DecorativeFrameRep& getRep() const;
00389 };
00390
00395 class SimTK_SimTKCOMMON_EXPORT DecorativeText : public DecorativeGeometry {
00396 public:
00397 explicit DecorativeText(const std::string& label="");
00398
00399 void setText(const std::string& label);
00400 const std::string& getText() const;
00401
00402 SimTK_PIMPL_DOWNCAST(DecorativeText, DecorativeGeometry);
00403 private:
00404 class DecorativeTextRep& updRep();
00405 const DecorativeTextRep& getRep() const;
00406 };
00407
00408
00413 class SimTK_SimTKCOMMON_EXPORT DecorativeGeometryImplementation {
00414 public:
00415 virtual ~DecorativeGeometryImplementation() { }
00416 virtual void implementLineGeometry( const DecorativeLine&) = 0;
00417 virtual void implementBrickGeometry( const DecorativeBrick&) = 0;
00418 virtual void implementCylinderGeometry( const DecorativeCylinder&) = 0;
00419 virtual void implementCircleGeometry( const DecorativeCircle&) = 0;
00420 virtual void implementSphereGeometry( const DecorativeSphere&) = 0;
00421 virtual void implementEllipsoidGeometry(const DecorativeEllipsoid&)= 0;
00422 virtual void implementFrameGeometry( const DecorativeFrame&) = 0;
00423 virtual void implementTextGeometry( const DecorativeText&) = 0;
00424
00425
00426 };
00427
00428 }
00429
00430 #endif // SimTK_SimTKCOMMON_DECORATIVE_GEOMETRY_H_