test_fcl_utility.h
Go to the documentation of this file.
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 TEST_FCL_UTILITY_H
00038 #define TEST_FCL_UTILITY_H
00039 
00040 #include "fcl/math/transform.h"
00041 #include "fcl/collision_data.h"
00042 #include "fcl/collision_object.h"
00043 
00044 #ifdef _WIN32
00045 #define NOMINMAX  // required to avoid compilation errors with Visual Studio 2010
00046 #include <windows.h>
00047 #else
00048 #include <sys/time.h>
00049 #endif
00050 
00051 
00052 namespace fcl
00053 {
00054 
00055 class Timer
00056 {
00057 public:
00058   Timer();
00059   ~Timer();
00060 
00061   void start();                               
00062   void stop();                                
00063   double getElapsedTime();                    
00064   double getElapsedTimeInSec();               
00065   double getElapsedTimeInMilliSec();          
00066   double getElapsedTimeInMicroSec();          
00067 
00068 private:
00069   double startTimeInMicroSec;                 
00070   double endTimeInMicroSec;                   
00071   int stopped;                                
00072 #ifdef _WIN32
00073   LARGE_INTEGER frequency;                    
00074   LARGE_INTEGER startCount;
00075   LARGE_INTEGER endCount;
00076 #else
00077   timeval startCount;
00078   timeval endCount;
00079 #endif
00080 };
00081 
00082 
00084 void loadOBJFile(const char* filename, std::vector<Vec3f>& points, std::vector<Triangle>& triangles);
00085 
00088 void generateRandomTransform(FCL_REAL extents[6], Transform3f& transform);
00089 
00091 void generateRandomTransforms(FCL_REAL extents[6], std::vector<Transform3f>& transforms, std::size_t n);
00092 
00094 void generateRandomTransforms(FCL_REAL extents[6], FCL_REAL delta_trans[3], FCL_REAL delta_rot, std::vector<Transform3f>& transforms, std::vector<Transform3f>& transforms2, std::size_t n);
00095 
00097 void generateRandomTransforms_ccd(FCL_REAL extents[6], std::vector<Transform3f>& transforms, std::vector<Transform3f>& transforms2, FCL_REAL delta_trans[3], FCL_REAL delta_rot, std::size_t n,
00098                                  const std::vector<Vec3f>& vertices1, const std::vector<Triangle>& triangles1,
00099                                  const std::vector<Vec3f>& vertices2, const std::vector<Triangle>& triangles2);
00100 
00101 
00103 struct DistanceRes
00104 {
00105   double distance;
00106   Vec3f p1;
00107   Vec3f p2;
00108 };
00109 
00111 struct CollisionData
00112 {
00113   CollisionData()
00114   {
00115     done = false;
00116   }
00117 
00119   CollisionRequest request;
00120 
00122   CollisionResult result;
00123 
00125   bool done;
00126 };
00127 
00128 
00130 struct DistanceData
00131 {
00132   DistanceData()
00133   {
00134     done = false;
00135   }
00136 
00138   DistanceRequest request;
00139 
00141   DistanceResult result;
00142 
00144   bool done;
00145 
00146 };
00147 
00148 
00149 
00151 bool defaultCollisionFunction(CollisionObject* o1, CollisionObject* o2, void* cdata);
00152 
00154 bool defaultDistanceFunction(CollisionObject* o1, CollisionObject* o2, void* cdata, FCL_REAL& dist);
00155 
00156 
00157 }
00158 
00159 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


fcl
Author(s): Jia Pan
autogenerated on Tue Jan 15 2013 16:05:31