SPHinXsys  alpha version
geometric_shape.h
1 /* -------------------------------------------------------------------------*
2  * SPHinXsys *
3  * --------------------------------------------------------------------------*
4  * SPHinXsys (pronunciation: s'finksis) is an acronym from Smoothed Particle *
5  * Hydrodynamics for industrial compleX systems. It provides C++ APIs for *
6  * physical accurate simulation and aims to model coupled industrial dynamic *
7  * systems including fluid, solid, multi-body dynamics and beyond with SPH *
8  * (smoothed particle hydrodynamics), a meshless computational method using *
9  * particle discretization. *
10  * *
11  * SPHinXsys is partially funded by German Research Foundation *
12  * (Deutsche Forschungsgemeinschaft) DFG HU1527/6-1, HU1527/10-1 *
13  * and HU1527/12-1. *
14  * *
15  * Portions copyright (c) 2017-2020 Technical University of Munich and *
16  * the authors' affiliations. *
17  * *
18  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
19  * not use this file except in compliance with the License. You may obtain a *
20  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
21  * *
22  * --------------------------------------------------------------------------*/
30 #ifndef GEOMETRIC_SHAPE_H
31 #define GEOMETRIC_SHAPE_H
32 
33 #include "base_geometry.h"
34 #include "simbody_middle.h"
35 
36 namespace SPH
37 {
38  class GeometricShape : public Shape
39  {
40  public:
41  explicit GeometricShape(const std::string &shape_name)
42  : Shape(shape_name), contact_geometry_(nullptr){};
43 
44  virtual bool checkContain(const Vec3d &pnt, bool BOUNDARY_INCLUDED = true) override;
45  virtual Vec3d findClosestPoint(const Vec3d &pnt) override;
46 
47  SimTK::ContactGeometry *getContactGeometry() { return contact_geometry_; };
48 
49  protected:
50  SimTK::ContactGeometry *contact_geometry_;
51  };
52 
53  class GeometricShapeBox : public GeometricShape
54  {
55  private:
56  SimTK::ContactGeometry::Brick brick_;
57 
58  public:
59  explicit GeometricShapeBox(const Vec3d &halfsize,
60  const std::string &shape_name = "GeometricShapeBox");
61  virtual ~GeometricShapeBox(){};
62 
63  virtual bool checkContain(const Vec3d &pnt, bool BOUNDARY_INCLUDED = true) override;
64  virtual Vec3d findClosestPoint(const Vec3d &pnt) override;
65 
66  protected:
67  Vec3d halfsize_;
68 
69  virtual BoundingBox findBounds() override;
70  };
71 
72  class GeometricShapeBall : public GeometricShape
73  {
74  private:
75  Vec3d center_;
76  SimTK::ContactGeometry::Sphere sphere_;
77 
78  public:
79  explicit GeometricShapeBall(const Vec3d &center, const Real &radius,
80  const std::string &shape_name = "GeometricShapeBall");
81  virtual ~GeometricShapeBall(){};
82 
83  virtual bool checkContain(const Vec3d &pnt, bool BOUNDARY_INCLUDED = true) override;
84  virtual Vec3d findClosestPoint(const Vec3d &pnt) override;
85 
86  protected:
87  virtual BoundingBox findBounds() override;
88  };
89 
90 }
91 
92 #endif // GEOMETRIC_SHAPE_H
Definition: geometric_shape.h:38
Base class for all volumetric geometries Note that checkContain and findClosest point are basic funct...
Definition: base_geometry.h:64
Definition: geometric_shape.h:38
Shape is the base class for all geometries.
Definition: solid_body_supplementary.cpp:9
file to include Simbody headers and suppress their warnings