MeshLib
 
Loading...
Searching...
No Matches
MRCalcDims.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVoxelsFwd.h"
4#include <MRMesh/MRVector3.h>
5#include <MRMesh/MRBox.h>
6
7namespace MR
8{
9
16
18inline OriginAndDimensions calcOriginAndDimensions( const Box3f & box, float voxelSize )
19{
20 const auto expansion = Vector3f::diagonal( 2 * voxelSize );
21 const auto origin = box.min - expansion;
22 return
23 {
24 .origin = origin,
25 .dimensions = Vector3i( ( box.max + expansion - origin ) / voxelSize ) + Vector3i::diagonal( 1 )
26 };
27}
28
29} //namespace MR
30
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
Definition MRCameraOrientationPlugin.h:8
Vector3< int > Vector3i
Definition MRDotNet/MRMeshFwd.h:9
OriginAndDimensions calcOriginAndDimensions(const Box3f &box, float voxelSize)
computes origin and dimensions of voxel-grid to cover given 3D box with given spacing (voxelSize)
Definition MRCalcDims.h:18
V max
Definition MRMesh/MRBox.h:31
V min
Definition MRMesh/MRBox.h:31
shift of zero voxel in 3D space and dimensions of voxel-grid
Definition MRCalcDims.h:12
Vector3f origin
Definition MRCalcDims.h:13
Vector3i dimensions
Definition MRCalcDims.h:14
static constexpr Vector3 diagonal(float a) noexcept
Definition MRMesh/MRVector3.h:32