|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include <sofa/collisionAlgorithm/BaseElement.h> |
| 4 | +#include <sofa/collisionAlgorithm/BaseOperation.h> |
| 5 | + |
| 6 | +namespace sofa::collisionAlgorithm::Operations::ContainsPointInElement { |
| 7 | + |
| 8 | +typedef bool Result; |
| 9 | + |
| 10 | +class Operation : public GenericOperation<Operation,//Type of the operation |
| 11 | + Result,//Default return type |
| 12 | + const type::Vec3 & , const BaseElement::SPtr & //Parameters |
| 13 | + > { |
| 14 | +public: |
| 15 | + |
| 16 | + Result defaultFunc(const type::Vec3 & , const BaseElement::SPtr & ) const override { |
| 17 | + return false; |
| 18 | + } |
| 19 | + |
| 20 | + void notFound(const std::type_info & id) const override { |
| 21 | + std::cerr << "ERROR the operation ContainsPointOperation is not registered with for type = " << sofa::helper::NameDecoder::decodeFullName(id) << std::endl; |
| 22 | + } |
| 23 | + |
| 24 | +}; |
| 25 | + |
| 26 | +typedef Operation::FUNC FUNC; |
| 27 | + |
| 28 | +} |
| 29 | + |
| 30 | +namespace sofa::collisionAlgorithm::Operations::ContainsPointInProximity { |
| 31 | + |
| 32 | +typedef bool Result; |
| 33 | + |
| 34 | +class Operation : public GenericOperation<Operation,//Type of the operation |
| 35 | + Result,//Default return type |
| 36 | + const type::Vec3 & , const BaseProximity::SPtr & //Parameters |
| 37 | + > { |
| 38 | +public: |
| 39 | + |
| 40 | + Result defaultFunc(const type::Vec3 & , const BaseProximity::SPtr & ) const override { |
| 41 | + return false; |
| 42 | + } |
| 43 | + |
| 44 | + void notFound(const std::type_info & id) const override { |
| 45 | + std::cerr << "ERROR the operation ContainsPointProximityOperation is not registered with for type = " << sofa::helper::NameDecoder::decodeFullName(id) << std::endl; |
| 46 | + } |
| 47 | + |
| 48 | +}; |
| 49 | + |
| 50 | +template<typename PROX> |
| 51 | +Result containsPoint(const type::Vec3 & P, const typename std::shared_ptr<PROX> & prox) |
| 52 | +{ |
| 53 | + auto elem = prox->element(); |
| 54 | + auto containsPointInElem = sofa::collisionAlgorithm::Operations::ContainsPointInElement::Operation::get(elem); |
| 55 | + return containsPointInElem(P, elem); |
| 56 | +} |
| 57 | + |
| 58 | +typedef Operation::FUNC FUNC; |
| 59 | + |
| 60 | +} |
0 commit comments