Skip to content

Commit 9130aab

Browse files
committed
sweep(until=, max=)
1 parent ecfca74 commit 9130aab

4 files changed

Lines changed: 18 additions & 4 deletions

File tree

collapse.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class collapse {
77
public:
88
abstract_voxel_storage* until = nullptr;
9+
boost::optional<int> max_depth;
910

1011
regular_voxel_storage* operator()(abstract_voxel_storage* storage, int dx, int dy, int dz) {
1112
int d[3] = { dx, dy, dz };
@@ -56,6 +57,7 @@ class collapse {
5657
class collapse_count {
5758
public:
5859
abstract_voxel_storage* until = nullptr;
60+
boost::optional<int> max_depth;
5961

6062
regular_voxel_storage* operator()(abstract_voxel_storage* storage, int dx, int dy, int dz) {
6163
int d[3] = { dx, dy, dz };

shift.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class shift {
77
public:
88
abstract_voxel_storage* until = nullptr;
9+
boost::optional<int> max_depth;
910

1011
regular_voxel_storage* operator()(abstract_voxel_storage* storage, int dx, int dy, int dz) {
1112
regular_voxel_storage* shifted = (regular_voxel_storage*)storage->empty_copy();

sweep.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class sweep {
77
public:
88
abstract_voxel_storage* until = nullptr;
9+
boost::optional<int> max_depth;
910

1011
regular_voxel_storage* operator()(abstract_voxel_storage* storage, int dx, int dy, int dz) {
1112
int d[3] = { dx, dy, dz };
@@ -49,15 +50,19 @@ class sweep {
4950
ijk2.get(D)--;
5051
}
5152

53+
if (!((ijk2 >= zero).all() && (ijk2 < extents).all())) {
54+
break;
55+
}
56+
5257
if (until) {
5358
if (until->Get(ijk2.as<size_t>())) {
5459
break;
5560
}
5661
}
62+
63+
swepts->Set(ijk2.as<size_t>());
5764

58-
if ((ijk2 >= zero).all() && (ijk2 < extents).all()) {
59-
swepts->Set(ijk2.as<size_t>());
60-
} else {
65+
if (max_depth && i >= *max_depth) {
6166
break;
6267
}
6368

voxec.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1418,7 +1418,7 @@ template <typename T>
14181418
class op_geom : public voxel_operation {
14191419
public:
14201420
const std::vector<argument_spec>& arg_names() const {
1421-
static std::vector<argument_spec> nm_ = { { true, "input", "voxels" }, { true, "dx", "integer|real" },{ true, "dy", "integer|real" },{ true, "dz", "integer|real" }, { false, "until", "voxels" } };
1421+
static std::vector<argument_spec> nm_ = { { true, "input", "voxels" }, { true, "dx", "integer|real" },{ true, "dy", "integer|real" },{ true, "dz", "integer|real" }, { false, "until", "voxels" }, { false, "max", "integer" } };
14221422
return nm_;
14231423
}
14241424
symbol_value invoke(const scope_map& scope) const {
@@ -1433,8 +1433,14 @@ class op_geom : public voxel_operation {
14331433
until = scope.get_value<abstract_voxel_storage*>("until");
14341434
} catch (scope_map::not_in_scope&) { }
14351435

1436+
boost::optional<int> max_depth;
1437+
try {
1438+
max_depth = scope.get_value<int>("max");
1439+
} catch (scope_map::not_in_scope&) {}
1440+
14361441
T s;
14371442
s.until = until;
1443+
s.max_depth = max_depth;
14381444
return s(voxels, dx, dy, dz);
14391445
}
14401446
};

0 commit comments

Comments
 (0)