VoronoiCell.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
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 #include "VoronoiCell.hpp"
00031 
00032 
00034 // Implementation
00036 
00037 
00038 bool VoronoiCell::EqualFaces(Face<3>& face1, bool orientation1, Face<3>& face2, bool orientation2)
00039 {
00040     if (orientation1 == orientation2)
00041     {
00042         return (face1 == face2);
00043     }
00044     else
00045     {
00046         Face<3> face3 =- face2;
00047         return (face1 == face3);
00048     }
00049 }
00050 
00051 bool VoronoiCell::operator==(VoronoiCell& rOtherCell)
00052 {
00053     if (mFaces.size() != rOtherCell.GetNumFaces())
00054     {
00055         return false;
00056     }
00057 
00058     std::vector<bool> other_faces_matched;
00059 
00060     std::vector< Face<3>* >::iterator this_face_iterator = mFaces.begin();
00061     std::vector<bool>::iterator this_orientation_iterator = mOrientations.begin();
00062 
00063     while (this_face_iterator != mFaces.end())
00064     {
00065         std::vector< Face<3>* >::iterator other_face_iterator = rOtherCell.mFaces.begin();
00066         std::vector<bool>::iterator other_orientation_iterator = rOtherCell.mOrientations.begin();
00067 
00068         while ( other_face_iterator != rOtherCell.mFaces.end()
00069                 && !EqualFaces(**this_face_iterator, *this_orientation_iterator,
00070                                  **other_face_iterator, *other_orientation_iterator) )
00071         {
00072             other_face_iterator++;
00073             other_orientation_iterator++;
00074         }
00075         if (other_face_iterator == rOtherCell.mFaces.end())
00076         {
00077             return false;
00078         }
00079         this_face_iterator++;
00080         this_orientation_iterator++;
00081     }
00082     return true;
00083 }
00084 
00085 c_vector<double, 3>& VoronoiCell::rGetVoronoiCellCentre()
00086 {
00087     return mCellCentre;
00088 }
00089 
00090 unsigned VoronoiCell::GetNumFaces() const
00091 {
00092     return mFaces.size();
00093 }
00094 
00095 const Face<3>& VoronoiCell::rGetFace(unsigned index) const
00096 {
00097     return *(mFaces[index]);
00098 }
00099 
00100 bool VoronoiCell::FaceIsOrientatedClockwise(unsigned index) const
00101 {
00102     return mOrientations[index];
00103 }
00104 
00105 void VoronoiCell::AddFace(Face<3>* pFace)
00106 {
00107     mFaces.push_back(pFace);
00108 }
00109 
00110 void VoronoiCell::AddOrientation(bool isOrientedClockwise)
00111 {
00112     mOrientations.push_back(isOrientedClockwise);
00113 }
00114 
00115 void VoronoiCell::SetCellCentre(c_vector<double, 3> cellCentre)
00116 {
00117     mCellCentre = cellCentre;
00118 }

Generated on Tue Aug 4 16:10:24 2009 for Chaste by  doxygen 1.5.5