shapes.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, 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 
38 namespace robot_self_filter
39 {
40 
42 {
43  shapes::Shape *result = NULL;
44  switch (shape->type)
45  {
46  case SPHERE:
47  result = new Sphere(static_cast<const Sphere*>(shape)->radius);
48  break;
49  case CYLINDER:
50  result = new Cylinder(static_cast<const Cylinder*>(shape)->radius, static_cast<const Cylinder*>(shape)->length);
51  break;
52  case BOX:
53  result = new Box(static_cast<const Box*>(shape)->size[0], static_cast<const Box*>(shape)->size[1], static_cast<const Box*>(shape)->size[2]);
54  break;
55  case MESH:
56  {
57  const Mesh *src = static_cast<const Mesh*>(shape);
58  Mesh *dest = new Mesh(src->vertexCount, src->triangleCount);
59  unsigned int n = 3 * src->vertexCount;
60  for (unsigned int i = 0 ; i < n ; ++i)
61  dest->vertices[i] = src->vertices[i];
62  n = 3 * src->triangleCount;
63  for (unsigned int i = 0 ; i < n ; ++i)
64  {
65  dest->triangles[i] = src->triangles[i];
66  dest->normals[i] = src->normals[i];
67  }
68  result = dest;
69  }
70  break;
71  default:
72  break;
73  }
74  return result;
75 }
76 
78 {
79  shapes::StaticShape *result = NULL;
80  switch (shape->type)
81  {
82  case PLANE:
83  result = new Plane(static_cast<const Plane*>(shape)->a, static_cast<const Plane*>(shape)->b,
84  static_cast<const Plane*>(shape)->c, static_cast<const Plane*>(shape)->d);
85  break;
86  default:
87  break;
88  }
89 
90  return result;
91 }
92 
93 }
d
Definition of a box.
Definition: shapes.h:130
A basic definition of a static shape. Static shapes do not have a pose.
Definition: shapes.h:75
Definition of a cylinder.
Definition: shapes.h:110
double * normals
the normal to each triangle unit vector represented as (x,y,z)
Definition: shapes.h:201
Definition of a plane with equation ax + by + cz + d = 0.
Definition: shapes.h:205
Definition of a mesh.
Definition: shapes.h:152
double * vertices
the position for each vertex vertex k has values at index (3k, 3k+1, 3k+2) = (x,y,z)
Definition: shapes.h:190
Shape * cloneShape(const Shape *shape)
Create a copy of a shape.
Definition: shapes.cpp:41
Definition of a sphere.
Definition: shapes.h:91
A basic definition of a shape. Shapes are considered centered at origin.
Definition: shapes.h:59
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
unsigned int * triangles
the vertex indices for each triangle triangle k has vertices at index (3k, 3k+1, 3k+2) = (v1...
Definition: shapes.h:197
unsigned int vertexCount
the number of available vertices
Definition: shapes.h:186
unsigned int triangleCount
the number of triangles formed with the vertices
Definition: shapes.h:193


robot_self_filter
Author(s): Eitan Marder-Eppstein
autogenerated on Thu Jun 6 2019 19:59:05