1 #ifndef vsol_volume_3d_h_
2 #define vsol_volume_3d_h_
3 //*****************************************************************************
4 //:
5 //  \file
6 // \brief Abstract volume in a 3D space
7 //
8 // \author
9 // Peter Vanroose
10 //
11 // \verbatim
12 //  Modifications
13 //   2000/06/28 Peter Vanroose  First version
14 // \endverbatim
15 //*****************************************************************************
16 
17 class vsol_volume_3d;
18 class vsol_polyhedron;
19 class vsol_mesh_3d; // not in this library to avoid dependencies (see brl/bseg/betr)
20 #include "vsol_volume_3d_sptr.h"
21 #include <vsol/vsol_spatial_object_3d.h>
22 #include <vsol/vsol_point_3d_sptr.h>
23 
24 class vsol_volume_3d : public vsol_spatial_object_3d
25 {
26  protected:
27   enum vsol_volume_3d_type
28   { VOLUME_NO_TYPE=0,
29     POLYHEDRON,
30     MESH,
31     NUM_VOLUME_TYPES
32   };
volume_type()33   virtual vsol_volume_3d_type volume_type() const {
34     return vsol_volume_3d::VOLUME_NO_TYPE;
35   }
36 
37  public:
38   //---------------------------------------------------------------------------
39   //: Destructor
40   //---------------------------------------------------------------------------
41   ~vsol_volume_3d() override = default;
42 
43   //***************************************************************************
44   // Basic operations
45   //***************************************************************************
cast_to_volume()46   vsol_volume_3d* cast_to_volume() override { return this;}
cast_to_volume()47   vsol_volume_3d const* cast_to_volume() const override { return this;}
48 
cast_to_polyhedron()49   virtual vsol_polyhedron* cast_to_polyhedron() { return nullptr;}
cast_to_polyhedron()50   virtual vsol_polyhedron const* cast_to_polyhedron() const { return nullptr;}
51 
cast_to_mesh()52   virtual vsol_mesh_3d* cast_to_mesh() { return nullptr;}
cast_to_mesh()53   virtual vsol_mesh_3d const* cast_to_mesh() const { return nullptr;}
54   //---------------------------------------------------------------------------
55   //: Is the point `p' inside `this' volume ?
56   //---------------------------------------------------------------------------
57   virtual bool in(vsol_point_3d_sptr const& p) const=0;
58 
59   //---------------------------------------------------------------------------
60   //: Return the spatial type of `this'
61   //---------------------------------------------------------------------------
spatial_type()62   vsol_spatial_object_3d_type spatial_type() const override {
63     return vsol_spatial_object_3d::VOLUME;
64   }
65 
66   //---------------------------------------------------------------------------
67   //: Return the volume of `this'
68   //---------------------------------------------------------------------------
69   virtual double volume() const = 0;
70 
71   //: Return a platform independent string identifying the class
is_a()72   std::string is_a() const override { return std::string("vsol_volume_3d"); }
73 
74   //: Return true if the argument matches the string identifying the class or any parent class
is_class(const std::string & cls)75   virtual bool is_class(const std::string& cls) const { return cls==is_a(); }
76 };
77 
78 #endif // vsol_volume_3d_h_
79