00001 //---------------------------------------------------------------------------- 00002 /** @file SgPointSetUtil.h 00003 Utility functions for SgPointSet. 00004 */ 00005 //---------------------------------------------------------------------------- 00006 00007 #ifndef SG_POINTSETUTIL_H 00008 #define SG_POINTSETUTIL_H 00009 00010 #include <iosfwd> 00011 #include <string> 00012 #include "SgPointSet.h" 00013 00014 //---------------------------------------------------------------------------- 00015 00016 /** Write all points in set. */ 00017 class SgWritePointSet 00018 { 00019 public: 00020 SgWritePointSet(const SgPointSet& pointSet, std::string label = "", 00021 bool writeSize = true); 00022 00023 std::ostream& Write(std::ostream& out) const; 00024 00025 private: 00026 bool m_writeSize; 00027 00028 const SgPointSet& m_pointSet; 00029 00030 std::string m_label; 00031 }; 00032 00033 /** @relatesalso SgWritePointSet */ 00034 std::ostream& operator<<(std::ostream& out, const SgWritePointSet& write); 00035 00036 /** @relatesalso SgPointSet */ 00037 std::ostream& operator<<(std::ostream& out, const SgPointSet& set); 00038 00039 //---------------------------------------------------------------------------- 00040 00041 /** Write center point and size of set */ 00042 class SgWritePointSetID 00043 { 00044 public: 00045 explicit SgWritePointSetID(const SgPointSet& p) 00046 : m_p(p) 00047 { } 00048 00049 const SgPointSet& Points() const { return m_p; } 00050 private: 00051 00052 const SgPointSet& m_p; 00053 }; 00054 00055 std::ostream& operator<<(std::ostream& stream, const SgWritePointSetID& w); 00056 00057 //---------------------------------------------------------------------------- 00058 00059 /** Read all points in set. */ 00060 class SgReadPointSet 00061 { 00062 public: 00063 SgReadPointSet(SgPointSet& pointSet); 00064 00065 std::istream& Read(std::istream& in) const; 00066 00067 private: 00068 mutable SgPointSet& m_pointSet; // allow temp objects to modify 00069 }; 00070 00071 /** @relatesalso SgReadPointSet */ 00072 std::istream& operator>>(std::istream& in, const SgReadPointSet& Read); 00073 00074 std::istream& operator>>(std::istream& in, SgPointSet& pointSet); 00075 00076 //---------------------------------------------------------------------------- 00077 00078 namespace SgPointSetUtil 00079 { 00080 /** Rotate coordinates - see SgPointUtil::Rotate */ 00081 void Rotate(int rotation, SgPointSet& pointSet, int boardSize); 00082 } 00083 //---------------------------------------------------------------------------- 00084 00085 #endif // SG_POINTSETUTIL_H