NTRT Simulator  v1.1
 All Classes Namespaces Files Functions Variables Typedefs Friends Pages
tgStructureInfo.h
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 
27 #ifndef TG_STRUCTURE_INFO_H
28 #define TG_STRUCTURE_INFO_H
29 
30 // NTRT Core library
31 #include "core/tgTaggable.h"
32 // The C++ Standard Library
33 #include <iostream>
34 #include <vector>
35 
36 // Forward declarations
37 class tgBuildSpec;
38 class tgConnectorInfo;
39 class tgModel;
40 class tgRigidInfo;
41 class tgStructure;
42 class tgWorld;
43 
49 {
50 
51  friend std::ostream& operator<<(std::ostream& os, const tgStructureInfo& obj);
52 
53 public:
54 
55  tgStructureInfo(tgStructure& structure, tgBuildSpec& buildSpec);
56 
57  tgStructureInfo(tgStructure& structure, tgBuildSpec& buildSpec, const tgTags& tags);
58 
59  virtual ~tgStructureInfo();
60 
61  // Return all rigids in this structure and its descendants
62  std::vector<tgRigidInfo*> getAllRigids() const;
63 
64  const std::vector<tgConnectorInfo*>& getConnectors() const
65  {
66  return m_connectors;
67  }
68 
69  // Build our info into the provided model
70  void buildInto(tgModel& model, tgWorld& world);
71 
72 private:
73 
74  // Initialize the rigid info for this structureInfo, then apply to children
75  void initRigidInfo();
76 
77  void autoCompoundRigids();
78 
79  void initConnectorInfo();
80 
81  void chooseConnectorRigids();
82 
83  void chooseConnectorRigids(std::vector<tgRigidInfo*> allRigids);
84 
85  void initRigidBodies(tgWorld& world);
86 
87  void initConnectors(tgWorld& world);
88 
89  const std::vector<tgRigidInfo*>& getRigids() const
90  {
91  return m_rigids;
92  }
93 
94  void addChild(tgStructureInfo* pChild);
95 
96  const std::vector<tgStructureInfo*>& getChildren() const
97  {
98  return m_children;
99  }
100 
104  void createTree(tgStructureInfo& scaffold, const tgStructure& structure);
105 
106  void buildIntoHelper(tgModel& model, tgWorld& world, tgStructureInfo& structureInfo);
107 
108  std::string toString(const std::string& prefix = "") const;
109 
110 private:
111 
112  tgStructure& m_structure;
113 
114  tgBuildSpec& m_buildSpec;
115 
116  // We do own these
117  std::vector<tgRigidInfo*> m_rigids;
118 
119  std::vector<tgConnectorInfo*> m_connectors;
120 
121  std::vector<tgStructureInfo*> m_children;
122 
123  std::vector<tgRigidInfo*> m_compounded;
124 };
125 
133 std::ostream& operator<<(std::ostream& os, const tgStructureInfo& obj);
134 
135 #endif
friend std::ostream & operator<<(std::ostream &os, const tgStructureInfo &obj)
Contains the definition of class tgTaggable.
std::ostream & operator<<(std::ostream &os, const tgStructureInfo &obj)
Definition: tgTags.h:44