Go to the documentation of this file.00001 #ifndef OPENTISSUE_COLLISION_OBB_TREE_OBB_TREE_TYPES_H
00002 #define OPENTISSUE_COLLISION_OBB_TREE_OBB_TREE_TYPES_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/core/containers/mesh/polymesh/polymesh.h>
00013 #include <OpenTissue/collision/bvh/bvh_bounding_volume_hierarchy.h>
00014 #include <OpenTissue/collision/bvh/top_down_constructor/bvh_top_down_constructor.h>
00015
00016 #include <OpenTissue/core/geometry/geometry_obb.h>
00017 #include <OpenTissue/core/geometry/geometry_plane.h>
00018 #include <OpenTissue/core/math/math_basic_types.h>
00019
00020 #include <OpenTissue/collision/obb_tree/obb_tree_collision_policy.h>
00021 #include <OpenTissue/collision/obb_tree/obb_tree_collision_query.h>
00022 #include <OpenTissue/collision/obb_tree/obb_tree_top_down_policy.h>
00023
00024 #include <list>
00025
00026 namespace OpenTissue
00027 {
00028 namespace obb_tree
00029 {
00030
00031 template<
00032 typename math_types_ = math::BasicMathTypes<double,size_t>
00033 >
00034 class OBBTreeTypes
00035 : public math_types_
00036 {
00037
00038 public:
00039
00040 typedef OBBTreeTypes<math_types_> obb_tree_types;
00041 typedef math_types_ math_types;
00042 typedef typename math_types::index_type time_stamp_type;
00043 typedef OpenTissue::geometry::OBB<math_types> obb_type;
00044 typedef OpenTissue::geometry::Plane<math_types> plane_type;
00045
00046 protected:
00047
00048 template<typename M>
00049 class OBBTreeVertexTraits : public mesh::DefaultVertexTraits<M>
00050 {};
00051
00052 class OBBTreeHalfEdgeTraits : public mesh::DefaultHalfEdgeTraits
00053 {};
00054
00055 class OBBTreeEdgeTraits : public mesh::DefaultEdgeTraits
00056 {};
00057
00058
00059 template<typename M>
00060 class OBBTreeFaceTraits : public mesh::DefaultFaceTraits
00061 {
00062 protected:
00063
00064 typedef typename M::vector3_type vector3_type;
00065 public:
00066
00067 vector3_type * m_v0;
00068 vector3_type * m_v1;
00069 vector3_type * m_v2;
00070 vector3_type * m_n0;
00071 vector3_type * m_n1;
00072 vector3_type * m_n2;
00073
00074 public:
00075
00076 OBBTreeFaceTraits()
00077 : m_v0()
00078 , m_v1()
00079 , m_v2()
00080 , m_n0()
00081 , m_n1()
00082 , m_n2()
00083 {}
00084
00085
00086 };
00087
00088 template<typename M>
00089 class OBBTreeMesh
00090 : public polymesh::PolyMesh<
00091 M
00092 , OBBTreeVertexTraits<M>
00093 , OBBTreeHalfEdgeTraits
00094 , OBBTreeEdgeTraits
00095 , OBBTreeFaceTraits<M>
00096 , polymesh::PolyMeshListKernel
00097 >
00098 {};
00099
00100 public:
00101
00102 typedef OBBTreeMesh< math_types > mesh_type;
00103 typedef typename mesh_type::face_type * face_ptr_type;
00104
00105 protected:
00106
00107 class OBBTreeBVTraits
00108 {
00109 public:
00110
00111 time_stamp_type m_query;
00112 obb_type m_cached_volume;
00113
00114 public:
00115
00116 OBBTreeBVTraits()
00117 : m_query()
00118 , m_cached_volume()
00119 {}
00120
00121 };
00122
00123
00124 public:
00125
00126 typedef OpenTissue::bvh::BoundingVolumeHierarchy<obb_type,face_ptr_type,OBBTreeBVTraits> bvh_type;
00127
00128 protected:
00129
00130 typedef TopDownPolicy<bvh_type,obb_tree_types> top_down_type;
00131 typedef CollisionPolicy<bvh_type,obb_tree_types> collision_type;
00132
00133 public:
00134
00135 typedef OpenTissue::bvh::TopDownConstructor< bvh_type, top_down_type > construtor_type;
00136 typedef CollisionQuery< collision_type > collision_query_type;
00137 typedef std::list< std::pair<face_ptr_type,face_ptr_type> > result_type;
00138
00139 };
00140
00141 }
00142
00143 }
00144
00145
00146 #endif