collision_result-inl.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-2016, 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 FCL_COLLISIONRESULT_INL_H
39 #define FCL_COLLISIONRESULT_INL_H
40 
42 
43 namespace fcl
44 {
45 
46 //==============================================================================
47 extern template
48 struct CollisionResult<double>;
49 
50 //==============================================================================
51 template <typename S>
53 {
54  // Do nothing
55 }
56 
57 //==============================================================================
58 template <typename S>
60 {
61  contacts.push_back(c);
62 }
63 
64 //==============================================================================
65 template <typename S>
67  const CostSource<S>& c, std::size_t num_max_cost_sources)
68 {
69  cost_sources.insert(c);
70  while (cost_sources.size() > num_max_cost_sources)
71  cost_sources.erase(--cost_sources.end());
72 }
73 
74 //==============================================================================
75 template <typename S>
77 {
78  return contacts.size() > 0;
79 }
80 
81 //==============================================================================
82 template <typename S>
84 {
85  return contacts.size();
86 }
87 
88 //==============================================================================
89 template <typename S>
91 {
92  return cost_sources.size();
93 }
94 
95 //==============================================================================
96 template <typename S>
98 {
99  if(i < contacts.size())
100  return contacts[i];
101  else
102  return contacts.back();
103 }
104 
105 //==============================================================================
106 template <typename S>
108  std::vector<Contact<S>>& contacts_)
109 {
110  contacts_.resize(contacts.size());
111  std::copy(contacts.begin(), contacts.end(), contacts_.begin());
112 }
113 
114 //==============================================================================
115 template <typename S>
117  std::vector<CostSource<S>>& cost_sources_)
118 {
119  cost_sources_.resize(cost_sources.size());
120  std::copy(cost_sources.begin(), cost_sources.end(), cost_sources_.begin());
121 }
122 
123 //==============================================================================
124 template <typename S>
126 {
127  contacts.clear();
128  cost_sources.clear();
129 }
130 
131 } // namespace fcl
132 
133 #endif
fcl::CollisionResult::addContact
void addContact(const Contact< S > &c)
add one contact into result structure
Definition: collision_result-inl.h:59
fcl::Contact
Contact information returned by collision.
Definition: contact.h:48
fcl::CostSource
Cost source describes an area with a cost. The area is described by an AABB region.
Definition: cost_source.h:49
fcl::CollisionResult::isCollision
bool isCollision() const
return binary collision result
Definition: collision_result-inl.h:76
fcl::CollisionResult::clear
void clear()
clear the results obtained
Definition: collision_result-inl.h:125
fcl::CollisionResult::getCostSources
void getCostSources(std::vector< CostSource< S >> &cost_sources_)
get all the cost sources
Definition: collision_result-inl.h:116
fcl::CollisionResult::numCostSources
size_t numCostSources() const
number of cost sources found
Definition: collision_result-inl.h:90
fcl::CollisionResult::numContacts
size_t numContacts() const
number of contacts found
Definition: collision_result-inl.h:83
fcl::CollisionResult::CollisionResult
CollisionResult()
Definition: collision_result-inl.h:52
fcl::CollisionResult::addCostSource
void addCostSource(const CostSource< S > &c, std::size_t num_max_cost_sources)
add one cost source into result structure
Definition: collision_result-inl.h:66
collision_result.h
fcl::CollisionResult::getContacts
void getContacts(std::vector< Contact< S >> &contacts_)
get all the contacts
Definition: collision_result-inl.h:107
fcl::CollisionResult::getContact
const Contact< S > & getContact(size_t i) const
get the i-th contact calculated
Definition: collision_result-inl.h:97
fcl
Main namespace.
Definition: broadphase_bruteforce-inl.h:45


fcl
Author(s):
autogenerated on Sat Sep 11 2021 02:37:41