contrib/gel/vsol/vsol_tetrahedron.h
Go to the documentation of this file.
00001 // This is gel/vsol/vsol_tetrahedron.h
00002 #ifndef vsol_tetrahedron_h_
00003 #define vsol_tetrahedron_h_
00004 //*****************************************************************************
00005 //:
00006 // \file
00007 // \brief tetrahedral volume in 3D space
00008 //
00009 // The vertices order gives the orientation of the tetrahedron
00010 //
00011 // \author Peter Vanroose
00012 // \date   5 July 2000.
00013 //
00014 // \verbatim
00015 //  Modifications
00016 //   2004/05/14 Peter Vanroose  Added describe()
00017 //   2004/09/24 Peter Vanroose  Removed operator==() since parent's suffices
00018 // \endverbatim
00019 //*****************************************************************************
00020 
00021 #include <vsol/vsol_polyhedron.h>
00022 #include <vsol/vsol_point_3d.h>
00023 #include <vcl_iosfwd.h>
00024 
00025 class vsol_tetrahedron : public vsol_polyhedron
00026 {
00027  public:
00028   //***************************************************************************
00029   // Initialization
00030   //***************************************************************************
00031 
00032   //---------------------------------------------------------------------------
00033   //: Constructor from 4 points
00034   //---------------------------------------------------------------------------
00035   vsol_tetrahedron(vsol_point_3d_sptr const& new_p0,
00036                    vsol_point_3d_sptr const& new_p1,
00037                    vsol_point_3d_sptr const& new_p2,
00038                    vsol_point_3d_sptr const& new_p3);
00039 
00040   //---------------------------------------------------------------------------
00041   //: Copy constructor
00042   //---------------------------------------------------------------------------
00043   vsol_tetrahedron(vsol_tetrahedron const& other);
00044 
00045   //---------------------------------------------------------------------------
00046   //: Destructor
00047   //---------------------------------------------------------------------------
00048   virtual ~vsol_tetrahedron() {}
00049 
00050   //---------------------------------------------------------------------------
00051   //: Clone `this': creation of a new object and initialization
00052   //  See Prototype pattern
00053   //---------------------------------------------------------------------------
00054   virtual vsol_spatial_object_3d* clone(void) const { return new vsol_tetrahedron(*this); }
00055 
00056   //***************************************************************************
00057   // Access
00058   //***************************************************************************
00059 
00060   //---------------------------------------------------------------------------
00061   //: Return the first vertex
00062   //---------------------------------------------------------------------------
00063   vsol_point_3d_sptr p0(void) const;
00064 
00065   //---------------------------------------------------------------------------
00066   //: Return the second vertex
00067   //---------------------------------------------------------------------------
00068   vsol_point_3d_sptr p1(void) const;
00069 
00070   //---------------------------------------------------------------------------
00071   //: Return the third vertex
00072   //---------------------------------------------------------------------------
00073   vsol_point_3d_sptr p2(void) const;
00074 
00075   //---------------------------------------------------------------------------
00076   //: Return the last vertex
00077   //---------------------------------------------------------------------------
00078   vsol_point_3d_sptr p3(void) const;
00079 
00080   //***************************************************************************
00081   // Status report
00082   //***************************************************************************
00083 
00084   //---------------------------------------------------------------------------
00085   //: Return the volume of `this'
00086   //---------------------------------------------------------------------------
00087   virtual double volume(void) const;
00088 
00089   //***************************************************************************
00090   // Element change
00091   //***************************************************************************
00092 
00093   //---------------------------------------------------------------------------
00094   //: Set the first vertex
00095   //---------------------------------------------------------------------------
00096   void set_p0(vsol_point_3d_sptr new_p0);
00097 
00098   //---------------------------------------------------------------------------
00099   //: Set the second vertex
00100   //---------------------------------------------------------------------------
00101   void set_p1(vsol_point_3d_sptr new_p1);
00102 
00103   //---------------------------------------------------------------------------
00104   //: Set the third vertex
00105   //---------------------------------------------------------------------------
00106   void set_p2(vsol_point_3d_sptr new_p2);
00107 
00108   //---------------------------------------------------------------------------
00109   //: Set the last vertex
00110   //---------------------------------------------------------------------------
00111   void set_p3(vsol_point_3d_sptr new_p3);
00112 
00113   //***************************************************************************
00114   // Basic operations
00115   //***************************************************************************
00116 
00117   //---------------------------------------------------------------------------
00118   //: Is `p' in `this' ?
00119   //---------------------------------------------------------------------------
00120   virtual bool in(vsol_point_3d_sptr const &p) const;
00121 
00122   //---------------------------------------------------------------------------
00123   //: output description to stream
00124   //---------------------------------------------------------------------------
00125   void describe(vcl_ostream &strm, int blanking=0) const;
00126 
00127   //: Return a platform independent string identifying the class
00128   virtual vcl_string is_a() const { return vcl_string("vsol_tetrahedron"); }
00129 
00130   //: Return true if the argument matches the string identifying the class or any parent class
00131   virtual bool is_class(const vcl_string& cls) const
00132   { return cls==is_a() || vsol_polyhedron::is_class(cls); }
00133 };
00134 
00135 #endif // vsol_tetrahedron_h_