OSDN Git Service

Coordinates::GetRectRange()を実装。 / Implement Coordinates::GetRectRange().
authorDeskull <desull@users.sourceforge.jp>
Sun, 4 Jan 2015 01:50:12 +0000 (10:50 +0900)
committerDeskull <desull@users.sourceforge.jp>
Sun, 4 Jan 2015 01:50:12 +0000 (10:50 +0900)
Deeangband/Coordinates.cpp
Deeangband/Coordinates.h

index ba7e79a..740e869 100644 (file)
@@ -80,4 +80,23 @@ namespace Deeangband
                return Coordinates::Distance(*this, a);
        }
 
+       void Coordinates::GetRectRange(std::vector<Coordinates> &rangeVec, Coordinates leftTop, Coordinates rightBottom)
+       {
+               GetRectRange(rangeVec, leftTop.GetX(), leftTop.GetY(), rightBottom.GetX(), rightBottom.GetY());
+               return;
+       }
+
+       void Coordinates::GetRectRange(std::vector<Coordinates> &rangeVec, int left, int top, int right, int bottom)
+       {
+               int x, y;
+               for(y = top; y <= bottom; y++)
+               {
+                       for(x = left; x <= right; x++)
+                       {
+                               rangeVec.push_back(Coordinates(x, y));
+                       }
+               }
+               return;
+       }
+
 }
\ No newline at end of file
index da4b287..ce595b6 100644 (file)
@@ -15,6 +15,9 @@ BOOST_CLASS_VERSION(Coordinates, 1);
 
 namespace Deeangband
 {
+       typedef std::vector<Coordinates> RANGE_VECTOR;
+
+       //#include "EngineTypedef.h"
 
        /*! 
        * @class Coordinates
@@ -129,6 +132,26 @@ namespace Deeangband
                 */
                int Coordinates::Distance(Coordinates a);
 
+               /*!
+                * @brief \8bé\8c`\94Í\88Í\8eæ\93¾
+                * @param rangeVec \92Ç\89Á\90æ\8eQ\8fÆ\83|\83C\83\93\83^
+                * @param leftTop \94Í\88Í\8d\8fã
+                * @param rightBottom \94Í\88Í\89E\89º
+                * @return \82È\82µ
+                */
+               void Coordinates::GetRectRange(std::vector<Coordinates> &rangeVec, Coordinates leftTop, Coordinates rightBottom);
+
+               /*!
+                * @brief \8bé\8c`\94Í\88Í\8eæ\93¾
+                * @param rangeVec \92Ç\89Á\90æ\8eQ\8fÆ\83|\83C\83\93\83^
+                * @param left \8d¶X\8dÀ\95W
+                * @param top \8fãY\8dÀ\95W
+                * @param right \89EX\8dÀ\95W
+                @ @param bottom \89ºY\8dÀ\95W
+                * @return \82È\82µ
+                */
+               void Coordinates::GetRectRange(std::vector<Coordinates> &rangeVec, int left, int top, int right, int bottom);
+
        };
 
 }