MeshLib Documentation
Loading...
Searching...
No Matches
MRTeethMaskToDirectionVolume.h
Go to the documentation of this file.
1#pragma once
2
3#include "MRVoxelsFwd.h"
4
5#include "MRMesh/MRExpected.h"
6#include "MRVoxelsVolume.h"
8#include "MRMesh/MRphmap.h"
9
10#include <array>
11#include <optional>
12
13namespace MR
14{
15
18{
19public:
21 template <int id>
22 static constexpr DentalId fromFDI()
23 {
24 const int t = id % 10;
25 const int q = id / 10;
26 static_assert( q >= 1 && q <= 4 && t >= 1 && t <= 8 );
27
28 return DentalId( id );
29 }
30
32 MRVOXELS_API static std::optional<DentalId> fromFDI( int id );
33
35 MRVOXELS_API int fdi() const;
36
37 auto operator <=> ( const DentalId& other ) const = default;
38
39private:
40 constexpr explicit DentalId( int fdi ):
41 fdi_( fdi )
42 {}
43
44 int fdi_;
45};
46
47}
48
49template <>
50struct std::hash<MR::DentalId>
51{
52 inline size_t operator() ( const MR::DentalId& id ) const noexcept
53 {
54 return hash<int>{}( id.fdi() );
55 }
56};
57
58namespace MR
59{
60
65{
66public:
70 MRVOXELS_API static Expected<TeethMaskToDirectionVolumeConvertor> create( const VdbVolume& volume, const std::vector<int>& additionalIds = {} );
71
74
76 using DirectionVolume = std::array<SimpleVolumeMinMax, 3>;
78 {
80 AffineXf3f xf;
81 };
82
85
88
89private:
91
92 HashMap<int, Box3i> presentObjects_;
93 SimpleVolume mask_;
94};
95
96
98MRVOXELS_API Expected<std::array<SimpleVolumeMinMax, 3>> teethMaskToDirectionVolume( const VdbVolume& volume, const std::vector<int>& additionalIds = {} );
99
100
101}
#define MRVOXELS_API
Definition MRVoxelsFwd.h:13
This class represents tooth id.
Definition MRTeethMaskToDirectionVolume.h:18
static MRVOXELS_API std::optional< DentalId > fromFDI(int id)
Creates id from FDI number known only at runtime.
auto operator<=>(const DentalId &other) const =default
MRVOXELS_API int fdi() const
Returns FDI representation of the id.
static constexpr DentalId fromFDI()
Creates id from FDI number known at compile time.
Definition MRTeethMaskToDirectionVolume.h:22
Definition MRTeethMaskToDirectionVolume.h:65
std::array< SimpleVolumeMinMax, 3 > DirectionVolume
See meshToDirectionVolume for details.
Definition MRTeethMaskToDirectionVolume.h:76
MRVOXELS_API Expected< ProcessResult > convertObject(int id) const
Converts single object into direction volume.
MRVOXELS_API Expected< ProcessResult > convertAll() const
Converts all the objects into direction volume.
static MRVOXELS_API Expected< TeethMaskToDirectionVolumeConvertor > create(const VdbVolume &volume, const std::vector< int > &additionalIds={})
MRVOXELS_API const HashMap< int, Box3i > & getObjectBounds() const
Returns all the objects present in volume and corresponding bounding boxes.
Definition MRCameraOrientationPlugin.h:8
MRVOXELS_API Expected< std::array< SimpleVolumeMinMax, 3 > > teethMaskToDirectionVolume(const VdbVolume &volume, const std::vector< int > &additionalIds={})
A shortcut for TeethMaskToDirectionVolumeConvertor::create and TeethMaskToDirectionVolumeConvertor::c...
tl::expected< T, E > Expected
Definition MRExpected.h:58
phmap::flat_hash_map< K, V, Hash, Eq > HashMap
Definition MRMesh/MRMeshFwd.h:460
Definition MRTeethMaskToDirectionVolume.h:78
DirectionVolume volume
Definition MRTeethMaskToDirectionVolume.h:79
AffineXf3f xf
Definition MRTeethMaskToDirectionVolume.h:80