MeshLib C++ Docs
Loading...
Searching...
No Matches
MRBoxNesting.h
Go to the documentation of this file.
1#pragma once
3#include "MRMesh/MRVector.h"
4#include "MRMesh/MRId.h"
5#include "MRMesh/MRExpected.h"
6
7namespace MR
8{
11
12
13namespace Nesting
14{
15
17{
19 Vector3f pos;
21 uint8_t bitMask{ 0 };
22};
23
26{
27public:
28 virtual ~IBoxNestingPriority() = default;
29
31 virtual void init( const Box3f& thisBox ) = 0;
32
34 virtual void addNested( const Box3f& box ) = 0;
35
37 virtual double complete() const = 0;
38};
39
41MRMESH_API std::shared_ptr<IBoxNestingPriority> getNestPostionMinPriorityMetric( const Box3f& nest );
42
44MRMESH_API std::shared_ptr<IBoxNestingPriority> getNeighborigDensityPriorityMetric( const Box3f& nest, float neighborhood );
45
47{
49 bool allow3dNesting{ true };
50
52 bool allowRotation{ false };
53
55 bool volumeBasedOrder = true;
56
58 bool checkLessCombinations{ false };
59
61 int iterationLimit = 10'000'000;
62
65 std::shared_ptr<IBoxNestingPriority> priorityMetric;
66
68 const Vector3f* expansionFactor{ nullptr };
69
71 const std::vector<Box3f>* preNestedVolumes{ nullptr };
72
74 const std::vector<BoxNestingCorner>* additinalSocketCorners{ nullptr };
75
78};
79
82MRMESH_API Expected<void> fillNestingSocketCorneres( const std::vector<Box3f>& nestedBoxes, std::vector<BoxNestingCorner>& outCorners, const ProgressCallback& cb = {} );
83
89
92
93}
94
95}
#define MRMESH_API
Definition MRMeshFwd.h:80
#define MRMESH_CLASS
Definition MRMeshFwd.h:87
class to override box nesting metrics
Definition MRBoxNesting.h:26
std::vector<T>-like container that requires specific indexing type,
Definition MRVector.h:23
std::function< bool(float)> ProgressCallback
Definition MRMeshFwd.h:753
const std::vector< Box3f > * preNestedVolumes
if not-nullptr contains boxes that are fixed in the nest and should not be intersected by floating (i...
Definition MRBoxNesting.h:71
BoxNestingOptions options
Definition MRBoxNesting.h:87
bool allowRotation
set false to keep original XY orientation
Definition MRBoxNesting.h:52
Expected< Vector< NestingResult, ObjId > > boxNesting(const Vector< MeshXf, ObjId > &meshes, const BoxNestingParams &params)
finds best positions of input meshes to fit the nest (checks them by contacting box corners)
Vector3f pos
Vector3f - corner position.
Definition MRBoxNesting.h:19
virtual double complete() const =0
finalize priority and return the value (more - better)
const std::vector< BoxNestingCorner > * additinalSocketCorners
user might force these sockets to be considered as corners for placing candidates
Definition MRBoxNesting.h:74
std::shared_ptr< IBoxNestingPriority > getNeighborigDensityPriorityMetric(const Box3f &nest, float neighborhood)
priority metric that maximizes density of placement in local neighborhood
uint8_t bitMask
corner mask 0bZYX (0b000 - lower left corner, 0b111 - upper right)
Definition MRBoxNesting.h:21
std::shared_ptr< IBoxNestingPriority > priorityMetric
Definition MRBoxNesting.h:65
bool allow3dNesting
if true allows placing objects over the bottom plane
Definition MRBoxNesting.h:49
tl::expected< T, E > Expected
Definition MRExpected.h:31
bool volumeBasedOrder
if true - nests objects in the order of decreasing volume, otherwise nest in the input order
Definition MRBoxNesting.h:55
virtual void init(const Box3f &thisBox)=0
init priority calculation with box of placed object
Expected< void > fillNestingSocketCorneres(const std::vector< Box3f > &nestedBoxes, std::vector< BoxNestingCorner > &outCorners, const ProgressCallback &cb={})
int iterationLimit
limit maximum number of tries, not to freeze for too long in this function
Definition MRBoxNesting.h:61
std::shared_ptr< IBoxNestingPriority > getNestPostionMinPriorityMetric(const Box3f &nest)
priority metric that minimizes position of new object by Z->Y->X coordinate in nest
virtual ~IBoxNestingPriority()=default
ProgressCallback cb
callback indicating progress of the nesting
Definition MRBoxNesting.h:77
const Vector3f * expansionFactor
optional input expansion of boxes (useful to compensate shrinkage of material)
Definition MRBoxNesting.h:68
bool checkLessCombinations
reduces nesting candidate options for speedup
Definition MRBoxNesting.h:58
NestingBaseParams baseParams
Definition MRBoxNesting.h:86
virtual void addNested(const Box3f &box)=0
accumulate priority by one of already nested boxes
Definition MRNesting3mfExport.h:20
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRBoxNesting.h:17
Definition MRBoxNesting.h:47
Definition MRBoxNesting.h:85
Definition MRNestingStructures.h:33