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