SPHinXsys  alpha version
image_shape.h
Go to the documentation of this file.
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 * --------------------------------------------------------------------------*/
31 #ifndef IMAGE_SHAPE_3D_H
32 #define IMAGE_SHAPE_3D_H
33 
34 #ifndef __EMSCRIPTEN__
35 
36 #define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
37 
38 #include "base_geometry.h"
39 #include "image_mhd.h"
40 
41 #include <iostream>
42 #include <string>
43 #include <fstream>
44 
46 #ifdef __APPLE__
47 #include <boost/filesystem.hpp>
48 namespace fs = boost::filesystem;
49 #else
50 #include <experimental/filesystem>
51 namespace fs = std::experimental::filesystem;
52 #endif
53 
54 namespace SPH
55 {
56  class ImageShape : public Shape
57  {
58  public:
59  explicit ImageShape(const std::string &shape_name)
60  : Shape(shape_name), translation_(0.0), rotation_(1.0),
61  max_distance_(-INFINITY), min_distance_(INFINITY){};
62 
63  virtual bool checkContain(const Vec3d &input_pnt, bool BOUNDARY_INCLUDED = true) override;
64  virtual Vec3d findClosestPoint(const Vec3d &input_pnt) override;
65 
66  protected:
67  //- distance map has to be float type image
68  Vec3d translation_;
69  Mat3d rotation_;
70  std::unique_ptr<ImageMHD<float, 3>> image_;
71  Real max_distance_;
72  Real min_distance_;
73 
74  virtual BoundingBox findBounds() override;
75  };
76 
78  {
79  public:
80  //constructor for load mhd/raw file from out side
81  explicit ImageShapeFromFile(const std::string &file_path_name,
82  const std::string &shape_name = "ImageShapeFromFile");
83  virtual ~ImageShapeFromFile(){};
84  };
85 
87  {
88  public:
89  //constructor for load mhd/raw file from out side
90  ImageShapeSphere(Real radius, Vec3d spacings, Vec3d center,
91  const std::string &shape_name = "ImageShapeSphere");
92  virtual ~ImageShapeSphere(){};
93  };
94 }
95 
96 #endif //__EMSCRIPTEN__
97 
98 #endif //IMAGE_SHAPE_3D_H
Base class for all volumetric geometries Note that checkContain and findClosest point are basic funct...
Definition: base_geometry.h:64
Definition: image_shape.h:56
Definition: image_shape.h:86
Definition: image_shape.h:77
Shape is the base class for all geometries.
Definition: solid_body_supplementary.cpp:9