NTRT Simulator  Version: Master
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgBoxMoreAnchors.cpp
Go to the documentation of this file.
1 /*
2  * Copyright © 2012, United States Government, as represented by the
3  * Administrator of the National Aeronautics and Space Administration.
4  * All rights reserved.
5  *
6  * The NASA Tensegrity Robotics Toolkit (NTRT) v1 platform is licensed
7  * under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * http://www.apache.org/licenses/LICENSE-2.0.
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
15  * either express or implied. See the License for the specific language
16  * governing permissions and limitations under the License.
17 */
18 
26 // This module
27 #include "tgBoxMoreAnchors.h"
28 #include "core/tgModelVisitor.h"
29 // The Bullet Physics library
30 #include "BulletDynamics/Dynamics/btRigidBody.h"
31 #include "btBulletDynamicsCommon.h"
32 // The C++ Standard Library
33 #include <cassert>
34 #include <stdexcept>
35 
41 tgBoxMoreAnchors::tgBoxMoreAnchors(btRigidBody* pRigidBody,
42  const tgTags& tags,
43  const double length) :
44  tgBox(pRigidBody, tags, length),
45  m_length(length)
46 {
47  // This is checked in tgBox too, but check again here so that the
48  // error makes more sense if it's ever thrown.
49  if (pRigidBody == NULL)
50  {
51  throw std::invalid_argument("Pointer to btRigidBody is NULL");
52  }
53 
54  // Postcondition
55  assert(invariant());
56 }
57 
58 // Destructor does nothing.
60 
61 // If the tgBoxMoreAnchors ever needed to be rendered differently
62 // than tgBox, this method allows that to happen. (I think?)
64 {
65  v.render(*this);
66  // Do we need to render the base class?
67 }
68 
69 bool tgBoxMoreAnchors::invariant() const
70 {
71  return
72  (m_length >= 0.0);
73 }
virtual ~tgBoxMoreAnchors()
Definition: tgBox.h:43
virtual void render(const tgRod &rod) const
Contains the definition of interface class tgModelVisitor.
virtual void onVisit(const tgModelVisitor &v) const
tgBoxMoreAnchors(btRigidBody *pRigidBody, const tgTags &tags, const double length)
Create a box shape. This class supports more than two anchor points.
Definition: tgTags.h:44