-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
RemovePoint.hpp
108 lines (86 loc) · 4.39 KB
/
RemovePoint.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*#######################################################################################
Copyright (c) 2017-2019 Kasugaccho
Copyright (c) 2018-2019 As Project
https://github.com/Kasugaccho/DungeonTemplateLibrary
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#######################################################################################*/
#ifndef INCLUDED_DUNGEON_TEMPLATE_LIBRARY_DTL_RETOUCH_REMOVE_POINT_HPP
#define INCLUDED_DUNGEON_TEMPLATE_LIBRARY_DTL_RETOUCH_REMOVE_POINT_HPP
/*#######################################################################################
日本語リファレンス (Reference-JP)
https://github.com/Kasugaccho/DungeonTemplateLibrary/wiki/dtl::retouch::RemovePoint-(修正クラス)/
#######################################################################################*/
#include <DTL/Macros/constexpr.hpp>
#include <DTL/Type/SizeT.hpp>
#include <DTL/Range/RectBase.hpp>
#include <DTL/Utility/DrawJagged.hpp>
/*#######################################################################################
[概要] "dtl名前空間"とは"DungeonTemplateLibrary"の全ての機能が含まれる名前空間である。
[Summary] The "dtl" is a namespace that contains all the functions of "DungeonTemplateLibrary".
#######################################################################################*/
namespace dtl {
inline namespace retouch { //"dtl::retouch"名前空間に属する
//マスを指定した数値で埋める
template<typename Matrix_Var_>
class RemovePoint : public ::dtl::range::RectBase<RemovePoint<Matrix_Var_>>,
public ::dtl::utility::DrawJagged<RemovePoint<Matrix_Var_>, Matrix_Var_> {
private:
///// エイリアス (Alias) /////
using Index_Size = ::dtl::type::size;
using ShapeBase_t = ::dtl::range::RectBase<RemovePoint>;
using DrawBase_t = ::dtl::utility::DrawJagged<RemovePoint, Matrix_Var_>;
friend DrawBase_t;
///// 代入処理 /////
template<typename Matrix_>
DTL_VERSIONING_CPP14_CONSTEXPR
static void assign(Matrix_&& matrix_, const Index_Size col, const Index_Size row)
noexcept(noexcept(matrix_(0, 0) != matrix_(0, 0)) && noexcept(matrix_(0, 0) = matrix_(0, 0))) {
if (matrix_(col - 1, row) == matrix_(col + 1, row) &&
matrix_(col + 1, row) == matrix_(col, row - 1) &&
matrix_(col, row - 1) == matrix_(col, row + 1))
matrix_(col, row) = matrix_(col + 1, row);
}
template<typename Matrix_, typename Function_>
DTL_VERSIONING_CPP14_CONSTEXPR
static void assign(Matrix_ && matrix_, const Index_Size col, const Index_Size row, Function_ && function_)
noexcept(noexcept(function_(matrix_(0, 0))) && noexcept(assign(matrix_, 0, 0))) {
if (function_(matrix_(col, row)))
assign(matrix_, col, row);
}
///// 基本処理 /////
//STL
template<typename Matrix_, typename ...Args_>
DTL_VERSIONING_CPP14_CONSTEXPR
typename DTL_TYPE_ENABLE_IF<Matrix_::is_jagged::value, bool>::DTL_TYPE_EITYPE
drawNormal(Matrix_ && matrix_, Args_ && ... args_) const
noexcept(noexcept(matrix_.getX()) && noexcept(matrix_.getY()) && noexcept(assign(matrix_, 0, 0, args_...))) {
const Index_Size end_y_ = this->calcEndY(matrix_.getY()) - 1;
for (Index_Size row{ this->start_y + 1 }; row < end_y_; ++row) {
const Index_Size end_x_ = this->calcEndX(matrix_.getX(row)) - 1;
for (Index_Size col{ this->start_x + 1 }; col < end_x_; ++col)
assign(matrix_, col, row, args_...);
}
return true;
}
//Normal
template<typename Matrix_, typename ...Args_>
DTL_VERSIONING_CPP14_CONSTEXPR
typename DTL_TYPE_ENABLE_IF<!Matrix_::is_jagged::value, bool>::DTL_TYPE_EITYPE
drawNormal(Matrix_ && matrix_, Args_ && ... args_) const
noexcept(noexcept(matrix_.getX()) && noexcept(matrix_.getY()) && noexcept(assign(matrix_, 0, 0, args_...))) {
const Index_Size end_x_ = this->calcEndX(matrix_.getX()) - 1;
const Index_Size end_y_ = this->calcEndY(matrix_.getY()) - 1;
for (Index_Size row{ this->start_y + 1 }; row < end_y_; ++row)
for (Index_Size col{ this->start_x + 1 }; col < end_x_; ++col)
assign(matrix_, col, row, args_...);
return true;
}
public:
///// コンストラクタ (Constructor) /////
using ShapeBase_t::ShapeBase_t;
};
}
}
#endif //Included Dungeon Template Library