Simbody  3.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CablePath.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_CABLE_PATH_H_
2 #define SimTK_SIMBODY_CABLE_PATH_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm) *
6  * -------------------------------------------------------------------------- *
7  * This is part of the SimTK biosimulation toolkit originating from *
8  * Simbios, the NIH National Center for Physics-Based Simulation of *
9  * Biological Structures at Stanford, funded under the NIH Roadmap for *
10  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11  * *
12  * Portions copyright (c) 2012 Stanford University and the Authors. *
13  * Authors: Michael Sherman, Ian Stavness *
14  * Contributors: Andreas Scholz *
15  * *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
17  * not use this file except in compliance with the License. You may obtain a *
18  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19  * *
20  * Unless required by applicable law or agreed to in writing, software *
21  * distributed under the License is distributed on an "AS IS" BASIS, *
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23  * See the License for the specific language governing permissions and *
24  * limitations under the License. *
25  * -------------------------------------------------------------------------- */
26 
30 #include "SimTKmath.h"
32 
33 namespace SimTK {
34 
38 SimTK_DEFINE_UNIQUE_INDEX_TYPE(CableObstacleIndex);
39 
40 class CableTrackerSubsystem;
41 class MobilizedBody;
42 class CableObstacle;
43 
44 //==============================================================================
45 // CABLE PATH
46 //==============================================================================
93 public:
94 
99  const MobilizedBody& originBody,
100  const Vec3& defaultOriginPoint,
101  const MobilizedBody& terminationBody,
102  const Vec3& defaultTerminationPoint);
103 
108  const MobilizedBody& originBody,
109  const MobilizedBody& terminationBody);
110 
112 CablePath(const CablePath& source);
113 
115 CablePath& operator=(const CablePath& source);
116 
118 ~CablePath() {clear();}
119 
141 void solveForInitialCablePath(State& state) const;
142 
146 int getNumObstacles() const;
149 const CableObstacle& getObstacle(CableObstacleIndex obstacleIx) const;
150 
154 Real getCableLength(const State& state) const;
155 
161 Real getCableLengthDot(const State& state) const;
162 
168 void applyBodyForces(const State& state, Real tension,
169  Vector_<SpatialVec>& bodyForcesInG) const;
170 
177 Real calcCablePower(const State& state, Real tension) const;
178 
182 Real getIntegratedCableLengthDot(const State& state) const;
183 
188 void setIntegratedCableLengthDot(State& state, Real value) const;
189 
190 
193 CablePath() : impl(0) {}
194 class Impl;
195 const Impl& getImpl() const {assert(impl); return *impl;}
196 Impl& updImpl() {assert(impl); return *impl;}
197 //--------------------------------------------------------------------------
198 private:
199 void clear();
200 Impl* impl;
201 };
202 
203 
204 //==============================================================================
205 // CABLE OBSTACLE
206 //==============================================================================
211 public:
212 class ViaPoint; // also used for end points
213 class Surface;
214 
216 CableObstacle() : impl(0) {}
217 
219 explicit CableObstacle(CablePath& path);
222 CableObstacle(const CableObstacle& source);
225 CableObstacle& operator=(const CableObstacle& source);
228 ~CableObstacle() {clear();}
229 
233 const Transform& getDefaultTransform() const;
237 const MobilizedBody& getMobilizedBody() const;
239 const CablePath& getCablePath() const;
241 CableObstacleIndex getObstacleIndex() const;
245 const DecorativeGeometry& getDecorativeGeometry() const;
249 DecorativeGeometry& updDecorativeGeometry();
250 
254 bool isDisabledByDefault() const;
255 
259 CableObstacle& setDisabledByDefault(bool shouldBeDisabled);
260 
263 CableObstacle& setDefaultTransform(const Transform& X_BS);
264 
269 CableObstacle& setDecorativeGeometry(const DecorativeGeometry& viz);
270 
273 void clear();
275 bool isEmpty() const {return impl==0;}
276 
277 //--------------------------------------------------------------------------
278 class Impl;
279 const Impl& getImpl() const {assert(impl); return *impl;}
280 Impl& updImpl() {assert(impl); return *impl;}
281 
282 protected:
283 explicit CableObstacle(Impl* impl);
284 
285 private:
286 Impl* impl; // opaque pointer to reference-counted implementation object
287 };
288 
289 
290 //==============================================================================
291 // CABLE OBSTACLE :: VIA POINT
292 //==============================================================================
295 public:
299 ViaPoint(CablePath& path, const MobilizedBody& viaMobod,
300  const Vec3& defaultStation);
301 
303 static bool isInstance(const CableObstacle&);
306 static const ViaPoint& downcast(const CableObstacle&);
309 static ViaPoint& updDowncast(CableObstacle&);
310 
311 class Impl;
312 };
313 
314 //==============================================================================
315 // CABLE OBSTACLE :: SURFACE
316 //==============================================================================
321 public:
324 
329 Surface(CablePath& path, const MobilizedBody& mobod,
330  const Transform& X_BS, const ContactGeometry& surface);
331 
335 Surface& setDecorativeGeometry(const DecorativeGeometry& viz)
336 { CableObstacle::setDecorativeGeometry(viz); return *this; }
337 
348 Surface& setNearPoint(const Vec3& point);
349 
354 Surface& setContactPointHints(const Vec3& startHint,
355  const Vec3& endHint);
356 
358 static bool isInstance(const CableObstacle&);
361 static const Surface& downcast(const CableObstacle&);
364 static Surface& updDowncast(CableObstacle&);
365 class Impl;
366 };
367 
368 
369 } // namespace SimTK
370 
371 #endif // SimTK_SIMBODY_CABLE_PATH_H_