32static_assert(
sizeof(
OutEdge ) == 1 );
39 return map[ (size_t)e + 1 ];
42static constexpr int OutEdgeCount = 6;
61 explicit operator bool()
const {
return id.valid(); }
69 [[nodiscard]]
const Vector3i &
dims()
const {
return dims_; }
75 [[nodiscard]] VoxelId
endId()
const {
return VoxelId(
size_ ); }
79 [[nodiscard]] Vector3i
toPos( VoxelId
id )
const;
81 [[nodiscard]] VoxelId
toVoxelId(
const Vector3i & pos )
const;
87 [[nodiscard]]
bool isInDims(
const Vector3i& pos )
const {
return pos.x >= 0 && pos.x <
dims_.x && pos.y >= 0 && pos.y <
dims_.y && pos.z >= 0 && pos.z <
dims_.z; }
90 [[nodiscard]]
bool isBdVoxel(
const Vector3i & pos )
const {
return pos.x == 0 || pos.x + 1 ==
dims_.x || pos.y == 0 || pos.y + 1 ==
dims_.y || pos.z == 0 || pos.z + 1 ==
dims_.z; }
94 [[nodiscard]]
bool areNeigbors(
const Vector3i & pos0,
const Vector3i & pos1 )
const {
return ( pos0 - pos1 ).lengthSq() == 1; }
120 , sizeXY_( size_t( dims_.x ) * dims_.y )
121 , size_( sizeXY_ * dims_.z )
133 assert(
id.valid() );
135 int sumZ = int(
id %
sizeXY_ );
136 int y = sumZ /
dims_.x;
137 int x = sumZ %
dims_.x;
143 return VoxelId{ pos.x + pos.y * size_t(
dims_.x) + pos.z *
sizeXY_ };
149 return v +
neiInc_[(int)toNei];
#define MRMESH_API
Definition MRMesh/MRMeshFwd.h:46
Definition MRVolumeIndexer.h:65
OutEdge2 opposite(OutEdge2 e)
Definition MRRectIndexer.h:28
MRMESH_API void expandVoxelsMask(VoxelBitSet &mask, const VolumeIndexer &indexer, int expansion=1)
expands VoxelBitSet with given number of steps
constexpr Vector3i neiPosDelta[OutEdgeCount]
Definition MRVolumeIndexer.h:44
OutEdge
Definition MRVolumeIndexer.h:21
MRMESH_API void shrinkVoxelsMask(VoxelBitSet &mask, const VolumeIndexer &indexer, int shrinkage=1)
shrinks VoxelBitSet with given number of steps
size_t size() const
returns the total number of voxels
Definition MRVolumeIndexer.h:72
bool isInDims(const Vector3i &pos) const
returns true if this voxel is within dimensions
Definition MRVolumeIndexer.h:87
VoxelId toVoxelId(const Vector3i &pos) const
Definition MRVolumeIndexer.h:141
const Vector3i & dims() const
Definition MRVolumeIndexer.h:69
VoxelLocation toLoc(VoxelId id) const
Definition MRVolumeIndexer.h:83
VoxelId id
Definition MRVolumeIndexer.h:57
size_t sizeXY_
= dims_.x * dims_.y
Definition MRVolumeIndexer.h:113
VoxelLocation toLoc(const Vector3i &pos) const
Definition MRVolumeIndexer.h:84
bool isBdVoxel(const Vector3i &pos) const
returns true if this voxel is on the boundary of the volume
Definition MRVolumeIndexer.h:90
VoxelId getNeighbor(VoxelId v, OutEdge toNei) const
returns id of v's neighbor specified by the edge
Definition MRVolumeIndexer.h:100
size_t size_
= dims_.x * dims_.y * dims_.z
Definition MRVolumeIndexer.h:114
VoxelId endId() const
returns the last plus one voxel Id for defining iteration range
Definition MRVolumeIndexer.h:75
VoxelId getExistingNeighbor(VoxelId v, OutEdge toNei) const
returns id of v's neighbor specified by the edge, which is known to exist (so skipping a lot of check...
Definition MRVolumeIndexer.h:146
bool areNeigbors(const Vector3i &pos0, const Vector3i &pos1) const
Definition MRVolumeIndexer.h:94
Vector3i dims_
Definition MRVolumeIndexer.h:112
int neiInc_[OutEdgeCount]
Definition MRVolumeIndexer.h:115
VoxelId getNeighbor(VoxelId v, const Vector3i &pos, bool bdPos, OutEdge toNei) const
Definition MRVolumeIndexer.h:109
VolumeIndexer(const Vector3i &dims)
Definition MRVolumeIndexer.h:118
bool areNeigbors(VoxelId v0, VoxelId v1) const
returns true if v1 is within at most 6 neighbors of v0
Definition MRVolumeIndexer.h:93
Vector3i pos
Definition MRVolumeIndexer.h:58
MRMESH_API bool hasNeighbour(const Vector3i &pos, OutEdge toNei) const
given existing voxel at (pos), returns whether it has valid neighbor specified by the edge (toNei)
size_t sizeXY() const
Definition MRVolumeIndexer.h:77
Vector3i toPos(VoxelId id) const
Definition MRVolumeIndexer.h:131
VoxelId getNeighbor(VoxelId v, const Vector3i &pos, OutEdge toNei) const
Definition MRVolumeIndexer.h:101
Definition MRCameraOrientationPlugin.h:8
contains both linear Id and 3D coordinates of the same voxel
Definition MRVolumeIndexer.h:56