Go to the documentation of this file.00001 #ifndef OPENTISSUE_COLLISION_SDF_SDF_GEOMETRY_H
00002 #define OPENTISSUE_COLLISION_SDF_SDF_GEOMETRY_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012
00013 #include <OpenTissue/collision/bvh/bvh.h>
00014 #include <OpenTissue/collision/collision_geometry_interface.h>
00015 #include <OpenTissue/core/geometry/geometry_sphere.h>
00016 #include <OpenTissue/core/geometry/geometry_compute_obb_aabb.h>
00017 #include <OpenTissue/utility/utility_class_id.h>
00018
00019
00020 #include <list>
00021
00022 namespace OpenTissue
00023 {
00024 namespace sdf
00025 {
00026
00027
00028
00042 template<typename mesh_type_,typename grid_type_>
00043 class Geometry
00044 : public OpenTissue::collision::GeometryInterface< typename mesh_type_::math_types >
00045 , public OpenTissue::utility::ClassID< Geometry<mesh_type_, grid_type_ > >
00046 {
00047 public:
00048
00049 typedef mesh_type_ mesh_type;
00050 typedef grid_type_ grid_type;
00051 typedef typename mesh_type::math_types math_types;
00052
00053 typedef typename math_types::real_type real_type;
00054 typedef typename math_types::vector3_type vector3_type;
00055 typedef typename math_types::matrix3x3_type matrix3x3_type;
00056
00057 typedef geometry::Sphere<math_types> sphere_type;
00058 typedef typename std::list<vector3_type> point_container;
00059 typedef typename point_container::iterator point_iterator;
00060 typedef typename point_container::const_iterator const_point_iterator;
00061
00062 typedef bvh::BoundingVolumeHierarchy<sphere_type,vector3_type*> bvh_type;
00063
00064 public:
00065
00066 mesh_type m_mesh;
00067 grid_type m_phi;
00068 real_type m_max_radius;
00069 vector3_type m_min_coord;
00070 vector3_type m_max_coord;
00071 point_container m_sampling;
00072 bvh_type m_bvh;
00073
00074 public:
00075
00076 size_t const class_id() const { return OpenTissue::utility::ClassID<OpenTissue::sdf::Geometry<mesh_type_,grid_type_> >::class_id(); }
00077
00078 Geometry()
00079 : m_max_radius()
00080 , m_min_coord(0,0,0)
00081 , m_max_coord(0,0,0)
00082 {}
00083
00084 public:
00085
00093 vector3_type ext() const { return vector3_type ( 0.5*(m_max_coord - m_min_coord) ); }
00094
00102 real_type const & max_radius() const { return m_max_radius; }
00103
00115 void compute_collision_aabb(
00116 vector3_type const & r
00117 , matrix3x3_type const & R
00118 , vector3_type & min_coord
00119 , vector3_type & max_coord
00120 ) const
00121 {
00122 OpenTissue::geometry::compute_obb_aabb(r,R,this->ext(),min_coord,max_coord);
00123 }
00124
00125 };
00126
00127 }
00128
00129 }
00130
00131
00132 #endif