FCL  0.6.0
Flexible Collision Library
distance_result-inl.h
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_DISTANCERESULT_INL_H
39 #define FCL_DISTANCERESULT_INL_H
40 
41 #include "fcl/narrowphase/distance_result.h"
42 
43 namespace fcl
44 {
45 
46 //==============================================================================
47 extern template
48 struct DistanceResult<double>;
49 
50 //==============================================================================
51 template <typename S>
52 DistanceResult<S>::DistanceResult(S min_distance_)
53  : min_distance(min_distance_),
54  o1(nullptr),
55  o2(nullptr),
56  b1(NONE),
57  b2(NONE)
58 {
59  // Do nothing
60 }
61 
62 //==============================================================================
63 template <typename S>
65  S distance,
66  const CollisionGeometry<S>* o1_,
67  const CollisionGeometry<S>* o2_,
68  int b1_,
69  int b2_)
70 {
71  if(min_distance > distance)
72  {
73  min_distance = distance;
74  o1 = o1_;
75  o2 = o2_;
76  b1 = b1_;
77  b2 = b2_;
78  }
79 }
80 
81 //==============================================================================
82 template <typename S>
84  S distance,
85  const CollisionGeometry<S>* o1_,
86  const CollisionGeometry<S>* o2_,
87  int b1_,
88  int b2_,
89  const Vector3<S>& p1,
90  const Vector3<S>& p2)
91 {
92  if(min_distance > distance)
93  {
94  min_distance = distance;
95  o1 = o1_;
96  o2 = o2_;
97  b1 = b1_;
98  b2 = b2_;
99  nearest_points[0] = p1;
100  nearest_points[1] = p2;
101  }
102 }
103 
104 //==============================================================================
105 template <typename S>
106 void DistanceResult<S>::update(const DistanceResult& other_result)
107 {
108  if(min_distance > other_result.min_distance)
109  {
110  min_distance = other_result.min_distance;
111  o1 = other_result.o1;
112  o2 = other_result.o2;
113  b1 = other_result.b1;
114  b2 = other_result.b2;
115  nearest_points[0] = other_result.nearest_points[0];
116  nearest_points[1] = other_result.nearest_points[1];
117  }
118 }
119 
120 //==============================================================================
121 template <typename S>
123 {
124  min_distance = std::numeric_limits<S>::max();
125  o1 = nullptr;
126  o2 = nullptr;
127  b1 = NONE;
128  b2 = NONE;
129 }
130 
131 } // namespace fcl
132 
133 #endif
S min_distance
minimum distance between two objects. if two objects are in collision, min_distance <= 0...
Definition: distance_result.h:56
Main namespace.
Definition: broadphase_bruteforce-inl.h:45
distance result
Definition: distance_request.h:48
int b1
information about the nearest point in object 1 if object 1 is mesh or point cloud, it is the triangle or point id if object 1 is geometry shape, it is NONE (-1), if object 1 is octree, it is the id of the cell
Definition: distance_result.h:71
const CollisionGeometry< S > * o2
collision object 2
Definition: distance_result.h:65
The geometry for the object for collision or distance computation.
Definition: collision_geometry.h:59
int b2
information about the nearest point in object 2 if object 2 is mesh or point cloud, it is the triangle or point id if object 2 is geometry shape, it is NONE (-1), if object 2 is octree, it is the id of the cell
Definition: distance_result.h:77
const CollisionGeometry< S > * o1
collision object 1
Definition: distance_result.h:62
Vector3< S > nearest_points[2]
nearest points
Definition: distance_result.h:59