$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_PRIMITIVE_H 00038 #define COLLISION_CHECKING_PRIMITIVE_H 00039 00040 #include "collision_checking/BVH_defs.h" 00041 00043 namespace collision_checking 00044 { 00045 00047 struct Triangle3e 00048 { 00049 unsigned int vids[3]; 00050 00051 int geom_id; // > 0 (geom_id - 1) is the index for geom object 00052 // < 0 -(geom_id + 1) is the index for space object 00053 // == 0 unset 00054 00055 int sub_geom_id; // the sub geom index within each object 00056 // for geom object: > 0 means attached body according to environment setting 00057 00058 Triangle3e() {} 00059 00060 Triangle3e(unsigned int p1, unsigned int p2, unsigned int p3) 00061 { 00062 set(p1, p2, p3); 00063 } 00064 00065 inline void set(unsigned int p1, unsigned int p2, unsigned int p3) 00066 { 00067 vids[0] = p1; vids[1] = p2; vids[2] = p3; 00068 } 00069 00070 inline unsigned int operator[](int i) const { return vids[i]; } 00071 00072 inline unsigned int& operator[](int i) { return vids[i]; } 00073 }; 00074 00075 typedef Triangle3e Triangle; 00076 00078 struct Triangle3f 00079 { 00080 unsigned int fids[3]; 00081 00082 Triangle3f() 00083 { 00084 set(-1, -1, -1); 00085 } 00086 00087 Triangle3f(unsigned int fid0, unsigned int fid1, unsigned int fid2) 00088 { 00089 set(fid0, fid1, fid2); 00090 } 00091 00092 inline void set(unsigned int fid0, unsigned int fid1, unsigned int fid2) 00093 { 00094 fids[0] = fid0; fids[1] = fid1; fids[2] = fid2; 00095 } 00096 00097 inline unsigned int operator[](int i) const { return fids[i]; } 00098 00099 inline unsigned int& operator[](int j) { return fids[j]; } 00100 }; 00101 00103 struct Edge2f 00104 { 00105 unsigned int vids[2]; 00106 unsigned int fids[2]; 00107 00108 Edge2f() 00109 { 00110 vids[0] = -1; vids[1] = -1; 00111 fids[0] = -1; fids[1] = -1; 00112 } 00113 00114 Edge2f(unsigned int vid0, unsigned int vid1, unsigned int fid) 00115 { 00116 vids[0] = vid0; 00117 vids[1] = vid1; 00118 fids[0] = fid; 00119 } 00120 00122 bool operator == (const Edge2f& other) const 00123 { 00124 return (vids[0] == other.vids[0]) && (vids[1] == other.vids[1]); 00125 } 00126 00127 bool operator < (const Edge2f& other) const 00128 { 00129 if(vids[0] == other.vids[0]) 00130 return vids[1] < other.vids[1]; 00131 00132 return vids[0] < other.vids[0]; 00133 } 00134 00135 }; 00136 00137 } 00138 00139 00140 #endif