30 #include "LinearMath/btVector3.h"
68 assertUniqueElements(
"All nodes must be unique.");
71 for(std::size_t i = 0; i < nodes.size(); i++) {
72 addElement(
tgNode(nodes[i]));
79 assertUniqueElements(
"All nodes must be unique.");
91 void setNode(
int key,
const btVector3& node)
98 setElement(key, node);
101 std::vector<tgNode>& getNodes()
103 return getElements();
106 const std::vector<tgNode>& getNodes()
const
108 return getElements();
133 int addNode(
const btVector3& node, std::string tags) {
138 return addElement(node);
155 const btVector3 node(x, y, z);
159 int addNode(
double x,
double y,
double z, std::string tags)
161 const tgNode node(x, y, z, tags);
168 tgPair pair(
int from,
int to, std::string tags =
"");
175 void move(
const btVector3& offset)
178 std::vector<tgNode>& nodes = getElements();
179 for(std::size_t i = 0; i < nodes.size(); i++) {
184 void moveNode(
int idx,
const btVector3 offset)
186 (*this)[idx] += offset;
189 void addRotation(
const btVector3& fixedPoint,
190 const btVector3& axis,
193 btQuaternion rotation(axis, angle);
194 addRotation(fixedPoint, rotation);
197 void addRotation(
const btVector3& fixedPoint,
198 const btVector3& fromOrientation,
199 const btVector3& toOrientation)
203 addRotation(fixedPoint, rotation);
206 void addRotation(
const btVector3& fixedPoint,
207 const btQuaternion& rotation)
209 std::vector<tgNode>& nodes = getNodes();
210 for(std::size_t i = 0; i < nodes.size(); i++) {
211 nodes[i].addRotation(fixedPoint, rotation);
220 void scale(
const btVector3& referencePoint,
double scaleFactor) {
221 std::vector<tgNode>& nodes = getNodes();
222 for(
int i = 0; i < nodes.size(); i++) {
223 nodes[i].setX((nodes[i].x() - referencePoint.x()) * scaleFactor + referencePoint.x());
224 nodes[i].setY((nodes[i].y() - referencePoint.y()) * scaleFactor + referencePoint.y());
225 nodes[i].setZ((nodes[i].z() - referencePoint.z()) * scaleFactor + referencePoint.z());
232 std::map<int, std::string> m_names;
234 void assertNodeExists(
int key)
const
237 std::stringstream ss;
239 throw std::out_of_range(
"Node at index " + ss.str() +
" does not exist");
243 void assertUniqueNodes()
const
245 assertUniqueElements(
"Nodes muse be unique.");
261 os <<
"tgNodes(" << std::endl;
262 const std::vector<tgNode>& nodes = n.getNodes();
263 for(std::size_t i = 0; i < nodes.size(); i++) {
264 os <<
" " << nodes[i] << std::endl;
278 std::stringstream os;
279 std::string indent = std::string(2 * (indentLevel),
' ');
281 if (nodes.size() == 0) {
282 os << indent <<
"nodes: []" << std::endl;
286 os << indent <<
"nodes:" << std::endl;
287 for(
size_t i = 0; i < nodes.size(); i++)
static btQuaternion getQuaternionBetween(btVector3 a, btVector3 b, const btVector3 &fallbackAxis=btVector3(0, 0, 0))
void setNode(int key, const btVector3 &node)
bool nodeExists(int key) const
tgPair pair(int from, int to, std::string tags="")
Contains the definition of class tgTaggables.
Definition of class tgNode.
std::string asYamlItems(const tgNodes &nodes, int indentLevel=0)
int addNode(double x, double y, double z)
tgNodes(std::vector< btVector3 > &nodes)
std::ostream & operator<<(std::ostream &os, const tgNodes &n)
std::string asYamlItem(const tgNode &node, int indentLevel=0)
void move(const btVector3 &offset)
int addNode(const btVector3 &node)
bool keyExists(int key) const