00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "VoronoiCell.hpp"
00031
00032
00034
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 }