$search
00001 /****************************************************************************** 00002 * \file 00003 * 00004 * $Id:$ 00005 * 00006 * Copyright (C) Brno University of Technology 00007 * 00008 * This file is part of software developed by dcgm-robotics@FIT group. 00009 * 00010 * Author: Vit Stancl (stancl@fit.vutbr.cz) 00011 * Supervised by: Michal Spanel (spanel@fit.vutbr.cz) 00012 * Date: dd/mm/2012 00013 * 00014 * This file is free software: you can redistribute it and/or modify 00015 * it under the terms of the GNU Lesser General Public License as published by 00016 * the Free Software Foundation, either version 3 of the License, or 00017 * (at your option) any later version. 00018 * 00019 * This file is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU Lesser General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public License 00025 * along with this file. If not, see <http://www.gnu.org/licenses/>. 00026 */ 00027 00028 #include <srs_env_model/but_server/plugins/octomap_plugin_tools/testing_polymesh.h> 00029 #include <Eigen/Geometry> 00030 #include <iostream> 00031 00035 srs_env_model::CTestingPolymesh::CTestingPolymesh() 00036 { 00037 00038 } 00039 00043 srs_env_model::CTestingPolymesh::CTestingPolymesh(const tPoint ¢er, const tQuaternion &orientation, const tPoint & size) 00044 { 00045 setAsBox( center, orientation, size ); 00046 } 00047 00051 void srs_env_model::CTestingPolymesh::setAsBox(const tPoint ¢er, const tQuaternion &orientation, const tPoint & size) 00052 { 00053 // Corners 00054 tPoint points[8]; 00055 00056 // Create simple oriented box 00057 // Cube positions 00058 // 00059 // 7-----------6 00060 // /| /| 00061 // / / | 00062 // / | / | 00063 // 4-----------5 | 00064 // | | | | 00065 // | 3 - - - + - 2 00066 // | / | / 00067 // | | / 00068 // |/ |/ 00069 // 0-----------1 00070 // 00071 // 00072 // 00073 // 00074 /* 00075 points[0][0] = -size[0]; points[0][1] = -size[1]; points[0][2] = -size[2]; 00076 points[1][0] = size[0]; points[1][1] = -size[1]; points[1][2] = -size[2]; 00077 points[2][0] = size[0]; points[2][1] = size[1]; points[2][2] = -size[2]; 00078 points[3][0] = -size[0]; points[3][1] = size[1]; points[3][2] = -size[2]; 00079 points[4][0] = -size[0]; points[4][1] = -size[1]; points[4][2] = size[2]; 00080 points[5][0] = size[0]; points[5][1] = -size[1]; points[5][2] = size[2]; 00081 points[6][0] = size[0]; points[6][1] = size[1]; points[6][2] = size[2]; 00082 points[7][0] = -size[0]; points[7][1] = size[1]; points[7][2] = size[2]; 00083 */ 00084 points[0][0] = -size[0]/2.0; points[0][1] = -size[1]/2.0; points[0][2] = -size[2]/2.0; 00085 points[1][0] = size[0]/2.0; points[1][1] = -size[1]/2.0; points[1][2] = -size[2]/2.0; 00086 points[2][0] = size[0]/2.0; points[2][1] = size[1]/2.0; points[2][2] = -size[2]/2.0; 00087 points[3][0] = -size[0]/2.0; points[3][1] = size[1]/2.0; points[3][2] = -size[2]/2.0; 00088 points[4][0] = -size[0]/2.0; points[4][1] = -size[1]/2.0; points[4][2] = size[2]/2.0; 00089 points[5][0] = size[0]/2.0; points[5][1] = -size[1]/2.0; points[5][2] = size[2]/2.0; 00090 points[6][0] = size[0]/2.0; points[6][1] = size[1]/2.0; points[6][2] = size[2]/2.0; 00091 points[7][0] = -size[0]/2.0; points[7][1] = size[1]/2.0; points[7][2] = size[2]/2.0; 00092 00093 /* 00094 std::cerr << "Points: " << std::endl; 00095 00096 for( int i = 0; i < 8; ++i ) 00097 { 00098 00099 std::cerr << "X: " << points[i][0] << ", Y: " << points[i][1] << ", Z: " << points[i][2] << std::endl; 00100 00101 } 00102 */ 00103 00104 // Create transformation 00105 tTransform transform( tTransform::Identity() ); 00106 transform *= Eigen::Translation3f( center ); 00107 transform *= orientation; 00108 00109 // std::cerr << "Points: " << std::endl; 00110 00111 // Transform box coordinates 00112 for( int i = 0; i < 8; ++i ) 00113 { 00114 points[i] = transform * points[i]; 00115 00116 // std::cerr << "X: " << points[i][0] << ", Y: " << points[i][1] << ", Z: " << points[i][2] << std::endl; 00117 00118 } 00119 00120 // Create planes 00121 // Planes should be defined: 00122 // 00123 // n 00124 // | 3 00125 // |/ 00126 // 1----2 00127 00128 00129 00130 // Bottom 00131 addPlane( CTestingPlane(points[0], points[1], points[3] ) ); 00132 00133 // Top 00134 addPlane( CTestingPlane(points[4], points[7], points[5] ) ); 00135 00136 // Front 00137 addPlane( CTestingPlane(points[0], points[4], points[1] ) ); 00138 00139 // Back 00140 addPlane( CTestingPlane(points[3], points[2], points[7] ) ); 00141 00142 // Left 00143 addPlane( CTestingPlane(points[0], points[3], points[4] ) ); 00144 00145 // Right 00146 addPlane( CTestingPlane(points[1], points[5], points[2] ) ); 00147 } 00148