Simbody
3.4 (development)
|
00001 #ifndef SimTK_SIMBODY_CABLE_PATH_H_ 00002 #define SimTK_SIMBODY_CABLE_PATH_H_ 00003 00004 /* -------------------------------------------------------------------------- * 00005 * Simbody(tm) * 00006 * -------------------------------------------------------------------------- * 00007 * This is part of the SimTK biosimulation toolkit originating from * 00008 * Simbios, the NIH National Center for Physics-Based Simulation of * 00009 * Biological Structures at Stanford, funded under the NIH Roadmap for * 00010 * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. * 00011 * * 00012 * Portions copyright (c) 2012 Stanford University and the Authors. * 00013 * Authors: Michael Sherman, Ian Stavness * 00014 * Contributors: Andreas Scholz * 00015 * * 00016 * Licensed under the Apache License, Version 2.0 (the "License"); you may * 00017 * not use this file except in compliance with the License. You may obtain a * 00018 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. * 00019 * * 00020 * Unless required by applicable law or agreed to in writing, software * 00021 * distributed under the License is distributed on an "AS IS" BASIS, * 00022 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 00023 * See the License for the specific language governing permissions and * 00024 * limitations under the License. * 00025 * -------------------------------------------------------------------------- */ 00026 00030 #include "SimTKmath.h" 00031 #include "simbody/internal/common.h" 00032 00033 namespace SimTK { 00034 00038 SimTK_DEFINE_UNIQUE_INDEX_TYPE(CableObstacleIndex); 00039 00040 class CableTrackerSubsystem; 00041 class MobilizedBody; 00042 class CableObstacle; 00043 00044 //============================================================================== 00045 // CABLE PATH 00046 //============================================================================== 00092 class SimTK_SIMBODY_EXPORT CablePath { 00093 public: 00094 00098 CablePath(CableTrackerSubsystem& cables, 00099 const MobilizedBody& originBody, 00100 const Vec3& defaultOriginPoint, 00101 const MobilizedBody& terminationBody, 00102 const Vec3& defaultTerminationPoint); 00103 00107 CablePath(CableTrackerSubsystem& cables, 00108 const MobilizedBody& originBody, 00109 const MobilizedBody& terminationBody); 00110 00112 CablePath(const CablePath& source); 00113 00115 CablePath& operator=(const CablePath& source); 00116 00118 ~CablePath() {clear();} 00119 00141 void solveForInitialCablePath(State& state) const; 00142 00146 int getNumObstacles() const; 00149 const CableObstacle& getObstacle(CableObstacleIndex obstacleIx) const; 00150 00154 Real getCableLength(const State& state) const; 00155 00161 Real getCableLengthDot(const State& state) const; 00162 00168 void applyBodyForces(const State& state, Real tension, 00169 Vector_<SpatialVec>& bodyForcesInG) const; 00170 00177 Real calcCablePower(const State& state, Real tension) const; 00178 00182 Real getIntegratedCableLengthDot(const State& state) const; 00183 00188 void setIntegratedCableLengthDot(State& state, Real value) const; 00189 00190 00193 CablePath() : impl(0) {} 00194 class Impl; 00195 const Impl& getImpl() const {assert(impl); return *impl;} 00196 Impl& updImpl() {assert(impl); return *impl;} 00197 //-------------------------------------------------------------------------- 00198 private: 00199 void clear(); 00200 Impl* impl; 00201 }; 00202 00203 00204 //============================================================================== 00205 // CABLE OBSTACLE 00206 //============================================================================== 00210 class SimTK_SIMBODY_EXPORT CableObstacle { 00211 public: 00212 class ViaPoint; // also used for end points 00213 class Surface; 00214 00216 CableObstacle() : impl(0) {} 00217 00219 explicit CableObstacle(CablePath& path); 00222 CableObstacle(const CableObstacle& source); 00225 CableObstacle& operator=(const CableObstacle& source); 00228 ~CableObstacle() {clear();} 00229 00233 const Transform& getDefaultTransform() const; 00237 const MobilizedBody& getMobilizedBody() const; 00239 const CablePath& getCablePath() const; 00241 CableObstacleIndex getObstacleIndex() const; 00245 const DecorativeGeometry& getDecorativeGeometry() const; 00249 DecorativeGeometry& updDecorativeGeometry(); 00250 00254 bool isDisabledByDefault() const; 00255 00259 CableObstacle& setDisabledByDefault(bool shouldBeDisabled); 00260 00263 CableObstacle& setDefaultTransform(const Transform& X_BS); 00264 00269 CableObstacle& setDecorativeGeometry(const DecorativeGeometry& viz); 00270 00273 void clear(); 00275 bool isEmpty() const {return impl==0;} 00276 00277 //-------------------------------------------------------------------------- 00278 class Impl; 00279 const Impl& getImpl() const {assert(impl); return *impl;} 00280 Impl& updImpl() {assert(impl); return *impl;} 00281 00282 protected: 00283 explicit CableObstacle(Impl* impl); 00284 00285 private: 00286 Impl* impl; // opaque pointer to reference-counted implementation object 00287 }; 00288 00289 00290 //============================================================================== 00291 // CABLE OBSTACLE :: VIA POINT 00292 //============================================================================== 00294 class SimTK_SIMBODY_EXPORT CableObstacle::ViaPoint : public CableObstacle { 00295 public: 00297 ViaPoint() : CableObstacle() {} 00299 ViaPoint(CablePath& path, const MobilizedBody& viaMobod, 00300 const Vec3& defaultStation); 00301 00303 static bool isInstance(const CableObstacle&); 00306 static const ViaPoint& downcast(const CableObstacle&); 00309 static ViaPoint& updDowncast(CableObstacle&); 00310 00311 class Impl; 00312 }; 00313 00314 //============================================================================== 00315 // CABLE OBSTACLE :: SURFACE 00316 //============================================================================== 00320 class SimTK_SIMBODY_EXPORT CableObstacle::Surface : public CableObstacle { 00321 public: 00323 Surface() : CableObstacle() {} 00324 00329 Surface(CablePath& path, const MobilizedBody& mobod, 00330 const Transform& X_BS, const ContactGeometry& surface); 00331 00335 Surface& setDecorativeGeometry(const DecorativeGeometry& viz) 00336 { CableObstacle::setDecorativeGeometry(viz); return *this; } 00337 00348 Surface& setNearPoint(const Vec3& point); 00349 00354 Surface& setContactPointHints(const Vec3& startHint, 00355 const Vec3& endHint); 00356 00358 static bool isInstance(const CableObstacle&); 00361 static const Surface& downcast(const CableObstacle&); 00364 static Surface& updDowncast(CableObstacle&); 00365 class Impl; 00366 }; 00367 00368 00369 } // namespace SimTK 00370 00371 #endif // SimTK_SIMBODY_CABLE_PATH_H_