ChasteCuboid.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2011
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 
00029 
00030 #ifndef CHASTECUBOID_HPP_
00031 #define CHASTECUBOID_HPP_
00032 #include "ChasteSerialization.hpp"
00033 #include <boost/serialization/base_object.hpp>
00034 #include "AbstractChasteRegion.hpp"
00035 #include "ChastePoint.hpp"
00036 
00037 
00043 template <unsigned SPACE_DIM>
00044 class ChasteCuboid : public AbstractChasteRegion<SPACE_DIM>
00045 {
00047     friend class boost::serialization::access;
00054     template<class Archive>
00055     void serialize(Archive & archive, const unsigned int version)
00056     {
00057         archive & boost::serialization::base_object<AbstractChasteRegion<SPACE_DIM> >(*this);
00058     }
00059     
00060 private:
00062     ChastePoint<SPACE_DIM> mLowerCorner;
00063 
00065     ChastePoint<SPACE_DIM> mUpperCorner;
00066 
00067 public:
00074     ChasteCuboid(ChastePoint<SPACE_DIM>& rLowerPoint, ChastePoint<SPACE_DIM>& rUpperPoint);
00075     
00081     bool DoesContain(const ChastePoint<SPACE_DIM>& rPointToCheck) const;
00082 
00084     const ChastePoint<SPACE_DIM>& rGetUpperCorner() const;
00085     
00087     const ChastePoint<SPACE_DIM>& rGetLowerCorner() const;
00088     
00092     double GetWidth(unsigned rDimension) const;
00093     
00099      unsigned GetLongestAxis() const;
00100 };
00101 
00102 // Declare identifier for the serializer
00103 #include "SerializationExportWrapper.hpp"
00104 EXPORT_TEMPLATE_CLASS_SAME_DIMS(ChasteCuboid)
00105 
00106 namespace boost
00107 {
00108 namespace serialization
00109 {
00110 
00111 template<class Archive, unsigned SPACE_DIM>
00112 inline void save_construct_data(
00113     Archive & ar, const ChasteCuboid<SPACE_DIM> * t, const unsigned int file_version)
00114 {
00115     const ChastePoint<SPACE_DIM>* p_upper_corner =  &(t->rGetUpperCorner());
00116     const ChastePoint<SPACE_DIM>* p_lower_corner =  &(t->rGetLowerCorner());
00117     ar & p_upper_corner;
00118     ar & p_lower_corner;
00119 }
00120 
00125 template<class Archive, unsigned SPACE_DIM>
00126 inline void load_construct_data(
00127     Archive & ar, ChasteCuboid<SPACE_DIM> * t, const unsigned int file_version)
00128 {
00129     ChastePoint<SPACE_DIM>* p_upper_corner;
00130     ChastePoint<SPACE_DIM>* p_lower_corner;
00131 
00132     ar & p_upper_corner;
00133     ar & p_lower_corner;
00134 
00135     ::new(t)ChasteCuboid<SPACE_DIM>((*p_lower_corner), (*p_upper_corner));
00136 
00137     delete p_upper_corner;
00138     delete p_lower_corner;
00139 }
00140 }
00141 } // namespace ...
00142 
00143 #endif /*CHASTECUBOID_HPP_*/

Generated on Mon Apr 18 11:35:35 2011 for Chaste by  doxygen 1.5.5