coal 3.0.1
Coal, The Collision Detection Library. Previously known as HPP-FCL, fork of FCL -- The Flexible Collision Library
Loading...
Searching...
No Matches
convex.h
Go to the documentation of this file.
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2011-2014, Willow Garage, Inc.
5 * Copyright (c) 2014-2015, Open Source Robotics Foundation
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer in the documentation and/or other materials provided
17 * with the distribution.
18 * * Neither the name of Open Source Robotics Foundation nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
38#ifndef COAL_SHAPE_CONVEX_H
39#define COAL_SHAPE_CONVEX_H
40
42#include <iostream>
43
44namespace coal {
45
49template <typename PolygonT>
50class ConvexTpl : public ConvexBaseTpl<typename PolygonT::IndexType> {
51 public:
52 typedef typename PolygonT::IndexType IndexType;
54 typedef typename Base::Neighbors Neighbors;
55
56 using Base::neighbors;
57 using Base::num_points;
58 using Base::points;
59
62
64
72 ConvexTpl(std::shared_ptr<std::vector<Vec3s>> points_,
73 unsigned int num_points_,
74 std::shared_ptr<std::vector<PolygonT>> polygons_,
75 unsigned int num_polygons_);
76
79 Base &base() { return static_cast<Base &>(*this); }
80
83 const Base &base() const { return static_cast<const Base &>(*this); }
84
88 ConvexTpl(const ConvexTpl &other) { *this = other; }
89
94
95 // Clone (deep copy).
97 ConvexTpl *clone() const override { return this->deepcopy(); };
98
99 // Deep copy of a Convex.
100 // This method deep copies every field of the class.
101 ConvexTpl *deepcopy() const override {
102 ConvexTpl *copy = new ConvexTpl();
103 deepcopy(this, copy);
104 return copy;
105 }
106
109 template <typename OtherPolygonT>
112 deepcopy(this, &res);
113 return res;
114 }
115
117 virtual Matrix3s computeMomentofInertia() const override;
118
119 virtual Vec3s computeCOM() const override;
120
121 virtual Scalar computeVolume() const override;
122
132 void set(std::shared_ptr<std::vector<Vec3s>> points, unsigned int num_points,
133 std::shared_ptr<std::vector<PolygonT>> polygons,
134 unsigned int num_polygons);
135
139 std::shared_ptr<std::vector<PolygonT>> polygons;
140 unsigned int num_polygons;
141
142 protected:
143 void fillNeighbors();
144
145 // Deep copy of a Convex.
146 // This method deep copies every field of the class.
147 template <typename OtherPolygonT>
148 static void deepcopy(const ConvexTpl<PolygonT> *source,
150
151 using Base::nneighbors_;
152};
153
156
157} // namespace coal
158
159#include "coal/shape/convex.hxx"
160
161#endif
Base for convex polytope.
Definition geometric_shapes.h:691
unsigned int num_points
Definition geometric_shapes.h:797
std::shared_ptr< std::vector< Vec3s > > points
An array of the points of the polygon.
Definition geometric_shapes.h:796
std::shared_ptr< std::vector< Neighbors > > neighbors
Neighbors of each vertex. It is an array of size num_points. For each vertex, it contains the number ...
Definition geometric_shapes.h:809
std::shared_ptr< std::vector< IndexType > > nneighbors_
Array of indices of the neighbors of each vertex. Since we don't know a priori the number of neighbor...
Definition geometric_shapes.h:861
Convex polytope.
Definition convex.h:50
virtual Matrix3s computeMomentofInertia() const override
based on http://number-none.com/blow/inertia/bb_inertia.doc
Definition convex.hxx:115
ConvexTpl()
Construct an uninitialized convex object.
Definition convex.h:61
ConvexBaseTpl< IndexType > Base
Definition convex.h:53
ConvexTpl * deepcopy() const override
Deep copy of the ConvexBaseTpl. This method deep copies every field of the class.
Definition convex.h:101
ConvexTpl< OtherPolygonT > cast() const
Cast this Convex vertex indices to OtherIndexType. This effectively deep copies this Convex into a ne...
Definition convex.h:110
ConvexTpl & operator=(const ConvexTpl &other)
Copy operator. The copy operator only shallow copies the data (it copies the shared pointers but does...
Definition convex.hxx:60
void set(std::shared_ptr< std::vector< Vec3s > > points, unsigned int num_points, std::shared_ptr< std::vector< PolygonT > > polygons, unsigned int num_polygons)
Set the current Convex from a list of points and polygons.
Definition convex.hxx:101
~ConvexTpl()
Definition convex.h:63
void fillNeighbors()
Definition convex.hxx:266
Base::Neighbors Neighbors
Definition convex.h:54
ConvexTpl * clone() const override
Clone (deep copy).
Definition convex.h:97
std::shared_ptr< std::vector< PolygonT > > polygons
An array of PolygonT object. PolygonT should contains a list of vertices for each polygon,...
Definition convex.h:139
const Base & base() const
Const cast Convex to ConvexBaseTpl. This method should never be marked as virtual.
Definition convex.h:83
virtual Scalar computeVolume() const override
compute the volume
Definition convex.hxx:220
Base & base()
Cast Convex to ConvexBaseTpl. This method should never be marked as virtual.
Definition convex.h:79
PolygonT::IndexType IndexType
Definition convex.h:52
virtual Vec3s computeCOM() const override
compute center of mass
Definition convex.hxx:175
unsigned int num_polygons
Definition convex.h:140
ConvexTpl(const ConvexTpl &other)
Copy constructor. The copy constructor only shallow copies the data (it copies the shared pointers bu...
Definition convex.h:88
#define COAL_DEPRECATED_MESSAGE(message)
Definition deprecated.hh:38
Main namespace.
Definition broadphase_bruteforce.h:44
ConvexTpl< Triangle32 > Convex32
Definition convex.h:155
ConvexTpl< Triangle16 > Convex16
Definition convex.h:154
Eigen::Matrix< Scalar, 3, 1 > Vec3s
Definition data_types.h:70
double Scalar
Definition data_types.h:68
Eigen::Matrix< Scalar, 3, 3 > Matrix3s
Definition data_types.h:74
Definition geometric_shapes.h:638