shapes.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2011, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 /* Author: Ioan Sucan */
36 
39 #include <octomap/octomap.h>
40 #include <console_bridge/console.h>
41 
42 namespace shapes
43 {
44 const std::string Sphere::STRING_NAME = "sphere";
45 const std::string Box::STRING_NAME = "box";
46 const std::string Cylinder::STRING_NAME = "cylinder";
47 const std::string Cone::STRING_NAME = "cone";
48 const std::string Mesh::STRING_NAME = "mesh";
49 const std::string Plane::STRING_NAME = "plane";
50 const std::string OcTree::STRING_NAME = "octree";
51 
52 std::ostream& operator<<(std::ostream& ss, ShapeType type)
53 {
54  switch (type)
55  {
56  case UNKNOWN_SHAPE:
57  ss << "unknown";
58  break;
59  case SPHERE:
60  ss << Sphere::STRING_NAME;
61  break;
62  case CYLINDER:
64  break;
65  case CONE:
66  ss << Cone::STRING_NAME;
67  break;
68  case BOX:
69  ss << Box::STRING_NAME;
70  break;
71  case PLANE:
72  ss << Plane::STRING_NAME;
73  break;
74  case MESH:
75  ss << Mesh::STRING_NAME;
76  break;
77  case OCTREE:
78  ss << OcTree::STRING_NAME;
79  break;
80  default:
81  ss << "impossible";
82  break;
83  }
84  return ss;
85 }
86 
88 {
90 }
91 
93 {
94 }
95 
96 Sphere::Sphere() : Shape()
97 {
98  type = SPHERE;
99  radius = 0.0;
100 }
101 
102 Sphere::Sphere(double r) : Shape()
103 {
104  if (r < 0)
105  throw std::runtime_error("Sphere radius must be non-negative.");
106  type = SPHERE;
107  radius = r;
108 }
109 
110 Cylinder::Cylinder() : Shape()
111 {
112  type = CYLINDER;
113  length = radius = 0.0;
114 }
115 
116 Cylinder::Cylinder(double r, double l) : Shape()
117 {
118  if (r < 0 || l < 0)
119  throw std::runtime_error("Cylinder dimensions must be non-negative.");
120  type = CYLINDER;
121  length = l;
122  radius = r;
123 }
124 
125 Cone::Cone() : Shape()
126 {
127  type = CONE;
128  length = radius = 0.0;
129 }
130 
131 Cone::Cone(double r, double l) : Shape()
132 {
133  if (r < 0 || l < 0)
134  throw std::runtime_error("Cone dimensions must be non-negative.");
135  type = CONE;
136  length = l;
137  radius = r;
138 }
139 
140 Box::Box() : Shape()
141 {
143  size[0] = size[1] = size[2] = 0.0;
144 }
145 
146 Box::Box(double x, double y, double z) : Shape()
147 {
148  if (x < 0 || y < 0 || z < 0)
149  throw std::runtime_error("Box dimensions must be non-negative.");
150  type = BOX;
151  size[0] = x;
152  size[1] = y;
153  size[2] = z;
154 }
155 
156 Mesh::Mesh() : Shape()
157 {
158  type = MESH;
159  vertex_count = 0;
160  vertices = nullptr;
161  triangle_count = 0;
162  triangles = nullptr;
163  triangle_normals = nullptr;
164  vertex_normals = nullptr;
165 }
166 
167 Mesh::Mesh(unsigned int v_count, unsigned int t_count) : Shape()
168 {
169  type = MESH;
170  vertex_count = v_count;
171  vertices = new double[v_count * 3];
172  triangle_count = t_count;
173  triangles = new unsigned int[t_count * 3];
174  triangle_normals = new double[t_count * 3];
175  vertex_normals = new double[v_count * 3];
176 }
177 
179 {
180  if (vertices)
181  delete[] vertices;
182  if (triangles)
183  delete[] triangles;
184  if (triangle_normals)
185  delete[] triangle_normals;
186  if (vertex_normals)
187  delete[] vertex_normals;
188 }
189 
190 Plane::Plane() : Shape()
191 {
192  type = PLANE;
193  a = b = c = d = 0.0;
194 }
195 
196 Plane::Plane(double pa, double pb, double pc, double pd) : Shape()
197 {
198  type = PLANE;
199  a = pa;
200  b = pb;
201  c = pc;
202  d = pd;
203 }
204 
205 OcTree::OcTree() : Shape()
206 {
207  type = OCTREE;
208 }
209 
210 OcTree::OcTree(const std::shared_ptr<const octomap::OcTree>& t) : octree(t)
211 {
212  type = OCTREE;
213 }
214 
215 Sphere* Sphere::clone() const
216 {
217  return new Sphere(radius);
218 }
219 
220 Cylinder* Cylinder::clone() const
221 {
222  return new Cylinder(radius, length);
223 }
224 
225 Cone* Cone::clone() const
226 {
227  return new Cone(radius, length);
228 }
229 
230 Box* Box::clone() const
231 {
232  return new Box(size[0], size[1], size[2]);
233 }
234 
235 Mesh* Mesh::clone() const
236 {
238  unsigned int n = 3 * vertex_count;
239  for (unsigned int i = 0; i < n; ++i)
240  dest->vertices[i] = vertices[i];
241  if (vertex_normals)
242  for (unsigned int i = 0; i < n; ++i)
243  dest->vertex_normals[i] = vertex_normals[i];
244  else
245  {
246  delete[] dest->vertex_normals;
247  dest->vertex_normals = nullptr;
248  }
249  n = 3 * triangle_count;
250  for (unsigned int i = 0; i < n; ++i)
251  dest->triangles[i] = triangles[i];
252  if (triangle_normals)
253  for (unsigned int i = 0; i < n; ++i)
254  dest->triangle_normals[i] = triangle_normals[i];
255  else
256  {
257  delete[] dest->triangle_normals;
258  dest->triangle_normals = nullptr;
259  }
260  return dest;
261 }
262 
263 Plane* Plane::clone() const
264 {
265  return new Plane(a, b, c, d);
266 }
267 
268 OcTree* OcTree::clone() const
269 {
270  return new OcTree(octree);
271 }
272 
273 void OcTree::scaleAndPadd(double /* scale */, double /* padd */)
274 {
275  CONSOLE_BRIDGE_logWarn("OcTrees cannot be scaled or padded");
276 }
277 
278 void Plane::scaleAndPadd(double /* scale */, double /* padd */)
279 {
280  CONSOLE_BRIDGE_logWarn("Planes cannot be scaled or padded");
281 }
282 
283 void Shape::scale(double scale)
284 {
285  scaleAndPadd(scale, 0.0);
286 }
287 
288 void Shape::padd(double padding)
289 {
290  scaleAndPadd(1.0, padding);
291 }
292 
293 void Sphere::scaleAndPadd(double scale, double padding)
294 {
295  const auto tmpRadius = radius * scale + padding;
296  if (tmpRadius < 0)
297  throw std::runtime_error("Sphere radius must be non-negative.");
298  radius = tmpRadius;
299 }
300 
301 void Cylinder::scaleAndPadd(double scaleRadius, double scaleLength, double paddRadius, double paddLength)
302 {
303  const auto tmpRadius = radius * scaleRadius + paddRadius;
304  const auto tmpLength = length * scaleLength + 2.0 * paddLength;
305  if (tmpRadius < 0 || tmpLength < 0)
306  throw std::runtime_error("Cylinder dimensions must be non-negative.");
307  radius = tmpRadius;
308  length = tmpLength;
309 }
310 
311 void Cylinder::scale(double scaleRadius, double scaleLength)
312 {
313  scaleAndPadd(scaleRadius, scaleLength, 0.0, 0.0);
314 }
315 
316 void Cylinder::padd(double paddRadius, double paddLength)
317 {
318  scaleAndPadd(1.0, 1.0, paddRadius, paddLength);
319 }
320 
321 void Cylinder::scaleAndPadd(double scale, double padd)
322 {
323  scaleAndPadd(scale, scale, padd, padd);
324 }
325 
326 void Cone::scaleAndPadd(double scaleRadius, double scaleLength, double paddRadius, double paddLength)
327 {
328  const auto tmpRadius = radius * scaleRadius + paddRadius;
329  const auto tmpLength = length * scaleLength + 2.0 * paddLength;
330  if (tmpRadius < 0 || tmpLength < 0)
331  throw std::runtime_error("Cone dimensions must be non-negative.");
332  radius = tmpRadius;
333  length = tmpLength;
334 }
335 
336 void Cone::scale(double scaleRadius, double scaleLength)
337 {
338  scaleAndPadd(scaleRadius, scaleLength, 0.0, 0.0);
339 }
340 
341 void Cone::padd(double paddRadius, double paddLength)
342 {
343  scaleAndPadd(1.0, 1.0, paddRadius, paddLength);
344 }
345 
346 void Cone::scaleAndPadd(double scale, double padd)
347 {
348  scaleAndPadd(scale, scale, padd, padd);
349 }
350 
351 void Box::scaleAndPadd(double scaleX, double scaleY, double scaleZ, double paddX, double paddY, double paddZ)
352 {
353  const auto tmpSize0 = size[0] * scaleX + paddX * 2.0;
354  const auto tmpSize1 = size[1] * scaleY + paddY * 2.0;
355  const auto tmpSize2 = size[2] * scaleZ + paddZ * 2.0;
356  if (tmpSize0 < 0 || tmpSize1 < 0 || tmpSize2 < 0)
357  throw std::runtime_error("Box dimensions must be non-negative.");
358  size[0] = tmpSize0;
359  size[1] = tmpSize1;
360  size[2] = tmpSize2;
361 }
362 
363 void Box::scale(double scaleX, double scaleY, double scaleZ)
364 {
365  scaleAndPadd(scaleX, scaleY, scaleZ, 0.0, 0.0, 0.0);
366 }
367 
368 void Box::padd(double paddX, double paddY, double paddZ)
369 {
370  scaleAndPadd(1.0, 1.0, 1.0, paddX, paddY, paddZ);
371 }
372 
373 void Box::scaleAndPadd(double scale, double padd)
374 {
375  scaleAndPadd(scale, scale, scale, padd, padd, padd);
376 }
377 
378 void Mesh::scaleAndPadd(double scaleX, double scaleY, double scaleZ, double paddX, double paddY, double paddZ)
379 {
380  // find the center of the mesh
381  double sx = 0.0, sy = 0.0, sz = 0.0;
382  for (unsigned int i = 0; i < vertex_count; ++i)
383  {
384  unsigned int i3 = i * 3;
385  sx += vertices[i3];
386  sy += vertices[i3 + 1];
387  sz += vertices[i3 + 2];
388  }
389  sx /= (double)vertex_count;
390  sy /= (double)vertex_count;
391  sz /= (double)vertex_count;
392 
393  // scale the mesh
394  for (unsigned int i = 0; i < vertex_count; ++i)
395  {
396  unsigned int i3 = i * 3;
397 
398  // vector from center to the vertex
399  double dx = vertices[i3] - sx;
400  double dy = vertices[i3 + 1] - sy;
401  double dz = vertices[i3 + 2] - sz;
402 
403  // Scaled coordinate
404  double scaledX = sx + dx * scaleX;
405  double scaledY = sy + dy * scaleY;
406  double scaledZ = sz + dz * scaleZ;
407  // Padding in each direction
408  vertices[i3] = scaledX + vertex_normals[i3] * paddX;
409  vertices[i3 + 1] = scaledY + vertex_normals[i3 + 1] * paddY;
410  vertices[i3 + 2] = scaledZ + vertex_normals[i3 + 2] * paddZ;
411  }
412 }
413 
414 void Mesh::scale(double scaleX, double scaleY, double scaleZ)
415 {
416  scaleAndPadd(scaleX, scaleY, scaleZ, 0.0, 0.0, 0.0);
417 }
418 
419 void Mesh::padd(double paddX, double paddY, double paddZ)
420 {
421  scaleAndPadd(1.0, 1.0, 1.0, paddX, paddY, paddZ);
422 }
423 
424 void Mesh::scaleAndPadd(double scale, double padd)
425 {
426  scaleAndPadd(scale, scale, scale, padd, padd, padd);
427 }
428 
429 void Shape::print(std::ostream& out) const
430 {
431  out << this << std::endl;
432 }
433 
434 void Sphere::print(std::ostream& out) const
435 {
436  out << "Sphere[radius=" << radius << "]" << std::endl;
437 }
438 
439 void Cylinder::print(std::ostream& out) const
440 {
441  out << "Cylinder[radius=" << radius << ", length=" << length << "]" << std::endl;
442 }
443 
444 void Cone::print(std::ostream& out) const
445 {
446  out << "Cone[radius=" << radius << ", length=" << length << "]" << std::endl;
447 }
448 
449 void Box::print(std::ostream& out) const
450 {
451  out << "Box[x=length=" << size[0] << ", y=width=" << size[1] << "z=height=" << size[2] << "]" << std::endl;
452 }
453 
454 void Mesh::print(std::ostream& out) const
455 {
456  out << "Mesh[vertices=" << vertex_count << ", triangles=" << triangle_count << "]" << std::endl;
457 }
458 
459 void Plane::print(std::ostream& out) const
460 {
461  out << "Plane[a=" << a << ", b=" << b << ", c=" << c << ", d=" << d << "]" << std::endl;
462 }
463 
464 void OcTree::print(std::ostream& out) const
465 {
466  if (octree)
467  {
468  double minx, miny, minz, maxx, maxy, maxz;
469  octree->getMetricMin(minx, miny, minz);
470  octree->getMetricMax(maxx, maxy, maxz);
471  out << "OcTree[depth = " << octree->getTreeDepth() << ", resolution = " << octree->getResolution()
472  << " inside box (minx=" << minx << ", miny=" << miny << ", minz=" << minz << ", maxx=" << maxx
473  << ", maxy=" << maxy << ", maxz=" << maxz << ")]" << std::endl;
474  }
475  else
476  out << "OcTree[NULL]" << std::endl;
477 }
478 
479 bool Shape::isFixed() const
480 {
481  return false;
482 }
483 
484 bool OcTree::isFixed() const
485 {
486  return true;
487 }
488 
489 bool Plane::isFixed() const
490 {
491  return true;
492 }
493 
494 void Mesh::computeTriangleNormals()
495 {
496  if (triangle_count && !triangle_normals)
497  triangle_normals = new double[triangle_count * 3];
498 
499  // compute normals
500  for (unsigned int i = 0; i < triangle_count; ++i)
501  {
502  unsigned int i3 = i * 3;
503  Eigen::Vector3d s1(vertices[triangles[i3] * 3] - vertices[triangles[i3 + 1] * 3],
504  vertices[triangles[i3] * 3 + 1] - vertices[triangles[i3 + 1] * 3 + 1],
505  vertices[triangles[i3] * 3 + 2] - vertices[triangles[i3 + 1] * 3 + 2]);
506  Eigen::Vector3d s2(vertices[triangles[i3 + 1] * 3] - vertices[triangles[i3 + 2] * 3],
507  vertices[triangles[i3 + 1] * 3 + 1] - vertices[triangles[i3 + 2] * 3 + 1],
508  vertices[triangles[i3 + 1] * 3 + 2] - vertices[triangles[i3 + 2] * 3 + 2]);
509  Eigen::Vector3d normal = s1.cross(s2);
510  normal.normalize();
511  triangle_normals[i3] = normal.x();
512  triangle_normals[i3 + 1] = normal.y();
513  triangle_normals[i3 + 2] = normal.z();
514  }
515 }
516 
517 void Mesh::computeVertexNormals()
518 {
519  if (!triangle_normals)
520  computeTriangleNormals();
521  if (vertex_count && !vertex_normals)
522  vertex_normals = new double[vertex_count * 3];
523  Eigen::Map<Eigen::Matrix<double, 3, Eigen::Dynamic>> mapped_normals(vertex_normals, 3, vertex_count);
524  mapped_normals.setZero();
525 
526  for (unsigned int tIdx = 0; tIdx < triangle_count; ++tIdx)
527  {
528  unsigned int tIdx3 = 3 * tIdx;
529  unsigned int tIdx3_1 = tIdx3 + 1;
530  unsigned int tIdx3_2 = tIdx3 + 2;
531 
532  unsigned int v1 = triangles[tIdx3];
533  unsigned int v2 = triangles[tIdx3_1];
534  unsigned int v3 = triangles[tIdx3_2];
535 
536  // Get angles for each vertex at this triangle
537  Eigen::Map<Eigen::Vector3d> p1{ vertices + 3 * v1, 3 };
538  Eigen::Map<Eigen::Vector3d> p2{ vertices + 3 * v2, 3 };
539  Eigen::Map<Eigen::Vector3d> p3{ vertices + 3 * v3, 3 };
540 
541  // Use eigen to calculate angle between the two vectors
542  auto angleBetweenVectors = [](const Eigen::Vector3d& vec1, const Eigen::Vector3d& vec2) -> double {
543  Eigen::AngleAxisd a(Eigen::Quaterniond::FromTwoVectors(vec1, vec2));
544  return a.angle();
545  };
546  auto ang1 = angleBetweenVectors(p2 - p1, p3 - p1);
547  auto ang2 = angleBetweenVectors(p1 - p2, p3 - p2);
548  auto ang3 = angleBetweenVectors(p1 - p3, p2 - p3);
549 
550  // Weight normal with angle
551  Eigen::Map<Eigen::Vector3d> triangle_normal{ triangle_normals + tIdx3, 3 };
552  mapped_normals.col(v1) += triangle_normal * ang1;
553  mapped_normals.col(v2) += triangle_normal * ang2;
554  mapped_normals.col(v3) += triangle_normal * ang3;
555  }
556 
557  // Normalize each column of the matrix
558  for (int i = 0; i < mapped_normals.cols(); ++i)
559  {
560  auto mapped_normal = mapped_normals.col(i);
561  if (mapped_normal.squaredNorm() != 0.0)
562  {
563  mapped_normal.normalize();
564  }
565  }
566 }
567 
568 void Mesh::mergeVertices(double threshold)
569 {
570  const double thresholdSQR = threshold * threshold;
571 
572  std::vector<unsigned int> vertex_map(vertex_count);
573  EigenSTL::vector_Vector3d orig_vertices(vertex_count);
574  EigenSTL::vector_Vector3d compressed_vertices;
575 
576  for (unsigned int vIdx = 0; vIdx < vertex_count; ++vIdx)
577  {
578  orig_vertices[vIdx][0] = vertices[3 * vIdx];
579  orig_vertices[vIdx][1] = vertices[3 * vIdx + 1];
580  orig_vertices[vIdx][2] = vertices[3 * vIdx + 2];
581  vertex_map[vIdx] = vIdx;
582  }
583 
584  for (unsigned int vIdx1 = 0; vIdx1 < vertex_count; ++vIdx1)
585  {
586  if (vertex_map[vIdx1] != vIdx1)
587  continue;
588 
589  vertex_map[vIdx1] = compressed_vertices.size();
590  compressed_vertices.push_back(orig_vertices[vIdx1]);
591 
592  for (unsigned int vIdx2 = vIdx1 + 1; vIdx2 < vertex_count; ++vIdx2)
593  {
594  double distanceSQR = (orig_vertices[vIdx1] - orig_vertices[vIdx2]).squaredNorm();
595  if (distanceSQR <= thresholdSQR)
596  vertex_map[vIdx2] = vertex_map[vIdx1];
597  }
598  }
599 
600  if (compressed_vertices.size() == orig_vertices.size())
601  return;
602 
603  // redirect triangles to new vertices!
604  for (unsigned int tIdx = 0; tIdx < triangle_count; ++tIdx)
605  {
606  unsigned int i3 = 3 * tIdx;
607  triangles[i3] = vertex_map[triangles[i3]];
608  triangles[i3 + 1] = vertex_map[triangles[i3 + 1]];
609  triangles[i3 + 2] = vertex_map[triangles[i3 + 2]];
610  }
611 
612  vertex_count = compressed_vertices.size();
613  delete[] vertices;
614  vertices = new double[vertex_count * 3];
615 
616  for (unsigned int vIdx = 0; vIdx < vertex_count; ++vIdx)
617  {
618  unsigned int i3 = 3 * vIdx;
619  vertices[i3] = compressed_vertices[vIdx][0];
620  vertices[i3 + 1] = compressed_vertices[vIdx][1];
621  vertices[i3 + 2] = compressed_vertices[vIdx][2];
622  }
623 
624  if (triangle_normals)
625  computeTriangleNormals();
626  if (vertex_normals)
627  computeVertexNormals();
628 }
629 
630 } /* namespace shapes */
shapes::Box::Box
Box()
Definition: shapes.cpp:172
shapes::Cone::radius
double radius
The radius of the cone.
Definition: shapes.h:221
shapes::Box::size
double size[3]
x, y, z dimensions of the box (axis-aligned)
Definition: shapes.h:270
shapes
Definition of various shapes. No properties such as position are included. These are simply the descr...
Definition: mesh_operations.h:47
shapes::Cone::length
double length
The length (height) of the cone.
Definition: shapes.h:218
shapes::Mesh::triangles
unsigned int * triangles
The vertex indices for each triangle triangle k has vertices at index (3k, 3k+1, 3k+2) = (v1,...
Definition: shapes.h:355
shapes::PLANE
@ PLANE
Definition: shapes.h:68
shapes::Mesh::~Mesh
~Mesh() override
Definition: shapes.cpp:210
shapes::Box::clone
Box * clone() const override
Create a copy of this shape.
Definition: shapes.cpp:262
shapes::UNKNOWN_SHAPE
@ UNKNOWN_SHAPE
Definition: shapes.h:63
shapes::Mesh::vertex_normals
double * vertex_normals
The normal to each vertex; unit vector represented as (x,y,z); If missing from the mesh,...
Definition: shapes.h:363
shapes::Cylinder::clone
Cylinder * clone() const override
Create a copy of this shape.
Definition: shapes.cpp:252
shapes::Cone::Cone
Cone()
Definition: shapes.cpp:157
shapes::Mesh::triangle_count
unsigned int triangle_count
The number of triangles formed with the vertices.
Definition: shapes.h:351
shapes::operator<<
std::ostream & operator<<(std::ostream &ss, ShapeType type)
Definition: shapes.cpp:84
shapes::SPHERE
@ SPHERE
Definition: shapes.h:64
shapes::Shape
A basic definition of a shape. Shapes are considered centered at origin.
Definition: shapes.h:77
shapes::Mesh
Definition of a triangle mesh By convention the "center" of the shape is at the origin....
Definition: shapes.h:281
shapes::Sphere::STRING_NAME
static const std::string STRING_NAME
The type of the shape, as a string.
Definition: shapes.h:115
shapes::MESH
@ MESH
Definition: shapes.h:69
shapes::CONE
@ CONE
Definition: shapes.h:66
shapes::OcTree::STRING_NAME
static const std::string STRING_NAME
The type of the shape, as a string.
Definition: shapes.h:393
shapes::Sphere::Sphere
Sphere()
Definition: shapes.cpp:128
shapes::Mesh::Mesh
Mesh()
Definition: shapes.cpp:188
shapes::Sphere::radius
double radius
The radius of the sphere.
Definition: shapes.h:122
shapes::Plane
Definition of a plane with equation ax + by + cz + d = 0.
Definition: shapes.h:367
shapes::Box
Definition of a box Aligned with the XYZ axes.
Definition: shapes.h:226
shapes::Sphere
Definition of a sphere.
Definition: shapes.h:106
shapes::Cylinder::STRING_NAME
static const std::string STRING_NAME
The type of the shape, as a string.
Definition: shapes.h:139
shapes::Mesh::vertex_count
unsigned int vertex_count
The number of available vertices.
Definition: shapes.h:344
y
double y
Definition: mesh_operations.cpp:202
EigenSTL::vector_Vector3d
std::vector< Eigen::Vector3d, Eigen::aligned_allocator< Eigen::Vector3d > > vector_Vector3d
shapes::ShapeType
ShapeType
A list of known shape types.
Definition: shapes.h:61
shapes::Cone::clone
Cone * clone() const override
Create a copy of this shape.
Definition: shapes.cpp:257
shapes::Cylinder::Cylinder
Cylinder()
Definition: shapes.cpp:142
eigen_stl_containers.h
shapes::Shape::type
ShapeType type
The type of the shape.
Definition: shapes.h:102
d
d
shapes::Shape::~Shape
virtual ~Shape()
Definition: shapes.cpp:124
shapes::Box::STRING_NAME
static const std::string STRING_NAME
The type of the shape, as a string.
Definition: shapes.h:236
shapes::Mesh::vertices
double * vertices
The position for each vertex vertex k has values at index (3k, 3k+1, 3k+2) = (x,y,...
Definition: shapes.h:348
shapes::OcTree
Representation of an octomap::OcTree as a Shape.
Definition: shapes.h:386
r
S r
shapes::OCTREE
@ OCTREE
Definition: shapes.h:70
shapes::Mesh::triangle_normals
double * triangle_normals
The normal to each triangle; unit vector represented as (x,y,z); If missing from the mesh,...
Definition: shapes.h:359
shapes.h
shapes::Sphere::clone
Sphere * clone() const override
Create a copy of this shape.
Definition: shapes.cpp:247
shapes::Plane::STRING_NAME
static const std::string STRING_NAME
The type of the shape, as a string.
Definition: shapes.h:374
bodies::detail::distanceSQR
static double distanceSQR(const Eigen::Vector3d &p, const Eigen::Vector3d &origin, const Eigen::Vector3d &dir)
Compute the square of the distance between a ray and a point Note: this requires 'dir' to be normaliz...
Definition: bodies.cpp:127
shapes::CYLINDER
@ CYLINDER
Definition: shapes.h:65
octomap.h
shapes::Cylinder::radius
double radius
The radius of the cylinder.
Definition: shapes.h:172
shapes::Mesh::clone
Mesh * clone() const override
Create a copy of this shape.
Definition: shapes.cpp:267
shapes::Shape::Shape
Shape()
Definition: shapes.cpp:119
x
double x
Definition: mesh_operations.cpp:202
shapes::Cylinder::length
double length
The length of the cylinder.
Definition: shapes.h:169
shapes::Cone
Definition of a cone Tip is on positive z axis. Center of base is on negative z axis....
Definition: shapes.h:178
shapes::Cone::STRING_NAME
static const std::string STRING_NAME
The type of the shape, as a string.
Definition: shapes.h:188
shapes::Mesh::STRING_NAME
static const std::string STRING_NAME
The type of the shape, as a string.
Definition: shapes.h:292
shapes::Plane::Plane
Plane()
Definition: shapes.cpp:222
shapes::OcTree::OcTree
OcTree()
Definition: shapes.cpp:237
z
double z
Definition: mesh_operations.cpp:202
shapes::BOX
@ BOX
Definition: shapes.h:67


geometric_shapes
Author(s): Ioan Sucan , Gil Jones
autogenerated on Tue Aug 13 2024 02:40:57