Go to the documentation of this file.00001 #ifndef OPENTISSUE_COLLISION_COLLISION_SDF_SDF_H
00002 #define OPENTISSUE_COLLISION_COLLISION_SDF_SDF_H
00003
00004
00005
00006
00007
00008
00009
00010 #include <OpenTissue/configuration.h>
00011
00012 #include <OpenTissue/collision/bvh/bvh_single_collision_query.h>
00013 #include <OpenTissue/collision/sdf/sdf_collision_policy.h>
00014
00015 namespace OpenTissue
00016 {
00017 namespace collision
00018 {
00019
00032 template<typename coordsys_type,typename sdf_geometry_type,typename contact_point_container,typename real_type>
00033 bool sdf_sdf(
00034 coordsys_type const & AtoWCS
00035 , sdf_geometry_type const & A
00036 , coordsys_type const & BtoWCS
00037 , sdf_geometry_type const & B
00038 , contact_point_container & contacts
00039 , real_type const & envelope
00040 )
00041 {
00042 typedef typename sdf_geometry_type::bvh_type bvh_type;
00043 typedef OpenTissue::sdf::CollisionPolicy<bvh_type,coordsys_type> collision_policy;
00044 typedef OpenTissue::bvh::SingleCollisionQuery< collision_policy > collision_query_type;
00045
00046 coordsys_type AtoB;
00047 coordsys_type BtoA;
00048 AtoB = model_update(AtoWCS,BtoWCS);
00049 BtoA = inverse(AtoB);
00050
00051 collision_query_type query;
00052 contacts.clear();
00053
00054 query.envelope() = envelope;
00055 query.flipped() = false;
00056 query.wcs_xform() = BtoWCS;
00057 query.run(AtoB, A.m_bvh, B, contacts);
00058
00059 query.envelope() = envelope;
00060 query.flipped() = true;
00061 query.wcs_xform() = AtoWCS;
00062 query.run(BtoA, B.m_bvh, A, contacts);
00063
00064 if(contacts.empty())
00065 return false;
00066 return true;
00067 }
00068
00069 }
00070 }
00071
00072
00073 #endif