$search
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright (c) 2011, Willow Garage, Inc. 00005 * All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * * Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * * Redistributions in binary form must reproduce the above 00014 * copyright notice, this list of conditions and the following 00015 * disclaimer in the documentation and/or other materials provided 00016 * with the distribution. 00017 * * Neither the name of Willow Garage, Inc. nor the names of its 00018 * contributors may be used to endorse or promote products derived 00019 * from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00022 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00023 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00024 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00025 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00026 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00027 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00030 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00031 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00032 * POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 00037 #ifndef COLLISION_CHECKING_DISTANCE_PRIMITIVE_H 00038 #define COLLISION_CHECKING_DISTANCE_PRIMITIVE_H 00039 00040 #include "collision_checking/BVH_defs.h" 00041 #include "collision_checking/BVH_model.h" 00042 #include "collision_checking/BVH_front.h" 00043 00045 namespace collision_checking 00046 { 00047 00048 struct BVH_DistanceResult 00049 { 00051 int num_bv_tests; 00052 00054 int num_tri_tests; 00055 00057 BVH_REAL query_time_seconds; 00058 00060 BVH_REAL rel_err; 00061 BVH_REAL abs_err; 00062 00066 BVH_REAL distance; 00067 Vec3f p1, p2; 00068 00075 int qsize; 00076 00078 int last_tri_id1; 00079 int last_tri_id2; 00080 00081 BVH_DistanceResult(); 00082 00083 ~BVH_DistanceResult(); 00084 00086 void resetRecord() 00087 { 00088 num_bv_tests = 0; 00089 num_tri_tests = 0; 00090 } 00091 }; 00092 00093 00095 template<typename BV> 00096 void distanceRecurse(BVNode<BV>* tree1, BVNode<BV>* tree2, int b1, int b2, 00097 Vec3f* vertices1, Vec3f* vertices2, 00098 Triangle* tri_indices1, Triangle* tri_indices2, 00099 BVH_DistanceResult* res, BVHFrontList* front_list = NULL) 00100 { 00101 std::cerr << "Bounding volume structure default can not support distance operation!" << std::endl; 00102 } 00103 00105 void distanceRecurse(BVNode<RSS>* tree1, BVNode<RSS>* tree2, 00106 const Vec3f R[3], const Vec3f& T, 00107 int b1, int b2, 00108 Vec3f* vertices1, Vec3f* vertices2, 00109 Triangle* tri_indices1, Triangle* tri_indices2, 00110 BVH_DistanceResult* res, BVHFrontList* front_list = NULL); 00111 00112 00114 void distanceQueueRecurse(BVNode<RSS>* tree1, BVNode<RSS>* tree2, 00115 const Vec3f R[3], const Vec3f& T, 00116 int b1, int b2, 00117 Vec3f* vertices1, Vec3f* vertices2, 00118 Triangle* tri_indices1, Triangle* tri_indices2, 00119 BVH_DistanceResult* res, BVHFrontList* front_list = NULL); 00120 00121 } 00122 00123 00124 #endif