Caribou
CylinderIsoSurface.h
1 #pragma once
2 
3 #include <sofa/defaulttype/VecTypes.h>
4 #include <SofaCaribou/Topology/IsoSurface.h>
5 
6 namespace SofaCaribou::topology {
7 
8 class CylinderIsoSurface : public IsoSurface<sofa::defaulttype::Vec3Types> {
9  template < class T = void* >
10  using Data = sofa::core::objectmodel::Data<T>;
12  using Base::Coord;
13  using Base::Real;
14 public:
15 
17  : p_radius(initData(&p_radius, 1., "radius", "Radius of the cylinder."))
18  , p_length(initData(&p_length, 5., "length", "Length of the cylinder."))
19  , p_center(initData(&p_center, Coord(0, 0, 0), "center", "Coordinates at the center of the cylinder."))
20  {}
21 
22  inline Real iso_value(const Eigen::Matrix<Real, 3, 1> & x) const final {
23  const auto & r = p_radius.getValue();
24  Eigen::Map<const Eigen::Matrix<Real, 3, 1>> c (p_center.getValue().data());
25 
26  const auto d = x.block<2,1>(0,0) - c.block<2,1>(0,0);
27  return d.squaredNorm() - r*r;
28  }
29 
30 private:
31  Data<Real> p_radius;
32  Data<Real> p_length;
33  Data<Coord> p_center;
34 };
35 
36 }
SofaCaribou::topology::IsoSurface
Definition: IsoSurface.h:9
SofaCaribou::topology::CylinderIsoSurface
Definition: CylinderIsoSurface.h:8