MeshLib C++ Docs
Loading...
Searching...
No Matches
MRVDBFloatGrid.h
Go to the documentation of this file.
1#pragma once
2#include "MRVoxelsFwd.h"
3// this header includes the whole OpenVDB, so please include it from .cpp files only
4#include "MRMesh/MRVector3.h"
5#include "MRMesh/MRBox.h"
6
7#include "MROpenVDB.h"
8#include "MRPch/MRBindingMacros.h"
9
10namespace MR
11{
12
20struct OpenVdbFloatGrid : openvdb::FloatGrid
21{
22 OpenVdbFloatGrid() noexcept = default;
23 MR_BIND_IGNORE OpenVdbFloatGrid( openvdb::FloatGrid && in ) : openvdb::FloatGrid( std::move( in ) ) {}
24 [[nodiscard]] size_t heapBytes() const { return memUsage(); }
25};
26
27MR_BIND_IGNORE inline openvdb::FloatGrid & ovdb( OpenVdbFloatGrid & v ) { return v; }
28MR_BIND_IGNORE inline const openvdb::FloatGrid & ovdb( const OpenVdbFloatGrid & v ) { return v; }
29
31MR_BIND_IGNORE inline FloatGrid MakeFloatGrid( openvdb::FloatGrid::Ptr&& p )
32{
33 if ( !p )
34 return {};
35 return std::make_shared<OpenVdbFloatGrid>( std::move( *p ) );
36}
37
38MR_BIND_IGNORE inline Vector3i fromVdb( const openvdb::Coord & v )
39{
40 return Vector3i( v.x(), v.y(), v.z() );
41}
42
43MR_BIND_IGNORE inline openvdb::Coord toVdb( const Vector3i & v )
44{
45 return openvdb::Coord( v.x, v.y, v.z );
46}
47
48MR_BIND_IGNORE inline openvdb::CoordBBox toVdbBox( const Box3i& box )
49{
50 return openvdb::CoordBBox( toVdb( box.min ), toVdb( box.max ) );
51}
52
53MR_BIND_IGNORE inline openvdb::CoordBBox toVdbBox( const Vector3i& dims )
54{
55 return openvdb::CoordBBox( toVdb( Vector3i( 0, 0, 0 ) ),
56 toVdb( Vector3i( dims ) - Vector3i::diagonal(1) ) );
57}
58
60
61}
MR_BIND_IGNORE FloatGrid MakeFloatGrid(openvdb::FloatGrid::Ptr &&p)
makes MR::FloatGrid shared pointer taking the contents of the input pointer
Definition MRVDBFloatGrid.h:31
MR_BIND_IGNORE openvdb::FloatGrid & ovdb(OpenVdbFloatGrid &v)
Definition MRVDBFloatGrid.h:27
MR_BIND_IGNORE Vector3i fromVdb(const openvdb::Coord &v)
Definition MRVDBFloatGrid.h:38
MR_BIND_IGNORE openvdb::Coord toVdb(const Vector3i &v)
Definition MRVDBFloatGrid.h:43
MR_BIND_IGNORE openvdb::CoordBBox toVdbBox(const Box3i &box)
Definition MRVDBFloatGrid.h:48
std::shared_ptr< OpenVdbFloatGrid > FloatGrid
Definition MRVoxels/MRVoxelsFwd.h:25
this class just hides very complex type of typedef openvdb::FloatGrid
Definition MRVDBFloatGrid.h:21
OpenVdbFloatGrid() noexcept=default
size_t heapBytes() const
Definition MRVDBFloatGrid.h:24