MeshLib C++ Docs
Loading...
Searching...
No Matches
MRToolPath.h
Go to the documentation of this file.
1#pragma once
2#include "MRVoxelsFwd.h"
3
4#include "MRMesh/MRAxis.h"
5#include "MRMesh/MRMesh.h"
6#include "MRMesh/MRPolyline.h"
8#include "MRMesh/MRExpected.h"
9
10namespace MR
11{
12
14{
17};
18
20{
21 // radius of the milling tool
22 float millRadius = {};
23 // size of voxel needed to offset mesh
24 float voxelSize = {};
25 // distance between sections built along Z axis
26 // in Constant Cusp mode sectionStep should be bigger than voxelSize (x1.2 or more is recomended)
27 float sectionStep = {};
28 // if distance to the next section is smaller than it, transition will be performed along the surface
29 // otherwise transition will be through the safe plane
31 // when the mill is moving down, it will be slowed down in this distance from mesh
32 float plungeLength = {};
33 // when the mill is moving up, it will be slowed down in this distance from mesh
34 float retractLength = {};
35 // speed of slow movement down
36 float plungeFeed = {};
37 // speed of slow movement up
38 float retractFeed = {};
39 // speed of regular milling
40 float baseFeed = {};
41 // z-coordinate of plane where tool can move in any direction without touching the object
42 float safeZ = {};
43 // which direction isolines or sections should be passed in
45 // mesh can be transformed using xf parameter
46 const AffineXf3f* xf = nullptr;
47 // if true then a tool path for a flat milling tool will be generated
48 bool flatTool = false;
49 // callback for reporting on progress
51
52 // optional output, stores isolines without transits
53 Contours3f* isolines = nullptr;
54 // optional output, polyline containing start vertices for isolines
56 // start vertices on the offset mesh used for calcutating isolines
57 std::vector<Vector3f>* startVertices = nullptr;
58
59 MeshPart* offsetMesh = nullptr;
60};
61
63{
64 // if true isolines will be processed from center point to the boundary (usually it means from up to down)
66};
67
69{
70 // maximal deviation from given line
71 float eps = {};
72 // maximal length of the line
73 float maxLength = {};
74 // callback for reporting on progress
76};
77
79{
80 // maximal deviation of arc from given path
81 float eps = {};
82 // maximal radius of the arc
83 float maxRadius = {};
84 // callback for reporting on progress
86};
87
88enum class MoveType
89{
90 None = -1,
91 FastLinear = 0,
92 Linear = 1,
93 ArcCW = 2,
94 ArcCCW = 3
95};
96
97enum class ArcPlane
98{
99 None = -1,
100 XY = 17,
101 XZ = 18,
102 YZ = 19
103};
104
106{
107 // type of command GX (G0, G1, etc). By default - G1
109 // Place for comment
111 // feedrate for move
112 float feed = std::numeric_limits<float>::quiet_NaN();
113 // coordinates of destination point
114 float x = std::numeric_limits<float>::quiet_NaN();
115 float y = std::numeric_limits<float>::quiet_NaN();
116 float z = std::numeric_limits<float>::quiet_NaN();
117 // if moveType is ArcCW or ArcCCW center of the arc shoult be specified
118 Vector3f arcCenter = Vector3f::diagonal( std::numeric_limits<float>::quiet_NaN() );
119};
120
122{
123 // mesh after fixing undercuts and offset
125 // selected region projected from the original mesh to the offset
126 FaceBitSet modifiedRegion;
127 // constains type of movement and its feed
128 std::vector<GCommand> commands;
129};
130
131// compute path of the milling tool for the given mesh with parameters ( direction of milling is from up to down along Z-direction )
132// this toolpath is built from the parallel sections along Z-axis
133// mesh can be transformed using xf parameter
134
136
137// compute path of the milling tool for the given mesh with parameters ( direction of milling is from up to down along Z-direction )
138// // this one is traditional lace-roughing toolpath
139
140// Slices are built along the axis defined by cutDirection argument (can be Axis::X or Axis::Y)
141MRVOXELS_API Expected<ToolPathResult> lacingToolPath( const MeshPart& mp, const ToolPathParams& params, Axis cutDirection );
142
143// compute path of the milling tool for the given mesh with parameters ( direction of milling is from up to down along Z-direction )
144// this toolpath is built from geodesic parallels divercing from the given start point or from the bounaries of selected areas
145// if neither is specified, the lowest section by XY plane will be used as a start contour
146// mesh can be transformed using xf parameter
148
149// generates G-Code for milling tool
150MRVOXELS_API std::shared_ptr<ObjectGcode> exportToolPathToGCode( const std::vector<GCommand>& commands );
151
152// interpolates several points lying on the same straight line with one move
153MRVOXELS_API Expected<void> interpolateLines( std::vector<GCommand>& commands, const LineInterpolationParams& params, Axis axis );
154// interpolates given path with arcs
155MRVOXELS_API Expected<void> interpolateArcs( std::vector<GCommand>& commands, const ArcInterpolationParams& params, Axis axis );
156
157// makes the given selection more smooth with shifthing a boundary of the selection outside and back. Input mesh is changed because we have to cut new edges along the new boundaries
158// \param expandOffset defines how much the boundary is expanded
159// \param expandOffset defines how much the boundary is shrinked after that
160MRVOXELS_API FaceBitSet smoothSelection( Mesh& mesh, const FaceBitSet& region, float expandOffset, float shrinkOffset );
161
162}
#define MRVOXELS_API
Definition MRVoxels/MRVoxelsFwd.h:13
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:663
@ XY
= 2 cause main axis is z - [2]
Definition MRVoxelPath.h:32
@ YZ
= 0 cause main axis is x - [0]
Definition MRVoxelPath.h:30
@ None
special value not to limit path in one slice
Definition MRVoxelPath.h:33
Definition MRCameraOrientationPlugin.h:8
Axis
Definition MRAxis.h:6
MRVOXELS_API Expected< ToolPathResult > constantCuspToolPath(const MeshPart &mp, const ConstantCuspParams &params)
BypassDirection
Definition MRToolPath.h:14
MRVOXELS_API std::shared_ptr< ObjectGcode > exportToolPathToGCode(const std::vector< GCommand > &commands)
tl::expected< T, E > Expected
Definition MRExpected.h:25
MoveType
Definition MRToolPath.h:89
MRVOXELS_API Expected< void > interpolateLines(std::vector< GCommand > &commands, const LineInterpolationParams &params, Axis axis)
MRVOXELS_API Expected< void > interpolateArcs(std::vector< GCommand > &commands, const ArcInterpolationParams &params, Axis axis)
MRVOXELS_API FaceBitSet smoothSelection(Mesh &mesh, const FaceBitSet &region, float expandOffset, float shrinkOffset)
Contours3< float > Contours3f
Definition MRMesh/MRMeshFwd.h:325
ArcPlane
Definition MRToolPath.h:98
MRVOXELS_API Expected< ToolPathResult > constantZToolPath(const MeshPart &mp, const ToolPathParams &params)
MRVOXELS_API Expected< ToolPathResult > lacingToolPath(const MeshPart &mp, const ToolPathParams &params, Axis cutDirection)
Definition MRToolPath.h:79
float maxRadius
Definition MRToolPath.h:83
float eps
Definition MRToolPath.h:81
ProgressCallback cb
Definition MRToolPath.h:85
Definition MRToolPath.h:63
bool fromCenterToBoundary
Definition MRToolPath.h:65
Definition MRToolPath.h:106
float y
Definition MRToolPath.h:115
float x
Definition MRToolPath.h:114
ArcPlane arcPlane
Definition MRToolPath.h:110
MoveType type
Definition MRToolPath.h:108
Vector3f arcCenter
Definition MRToolPath.h:118
float feed
Definition MRToolPath.h:112
float z
Definition MRToolPath.h:116
Definition MRToolPath.h:69
float eps
Definition MRToolPath.h:71
ProgressCallback cb
Definition MRToolPath.h:75
float maxLength
Definition MRToolPath.h:73
Definition MRMesh/MRMesh.h:22
Definition MRToolPath.h:20
float safeZ
Definition MRToolPath.h:42
Contours3f * isolines
Definition MRToolPath.h:53
float critTransitionLength
Definition MRToolPath.h:30
float sectionStep
Definition MRToolPath.h:27
MeshPart * offsetMesh
Definition MRToolPath.h:59
float baseFeed
Definition MRToolPath.h:40
float retractFeed
Definition MRToolPath.h:38
BypassDirection bypassDir
Definition MRToolPath.h:44
Contours3f * startContours
Definition MRToolPath.h:55
float voxelSize
Definition MRToolPath.h:24
float plungeLength
Definition MRToolPath.h:32
float retractLength
Definition MRToolPath.h:34
float plungeFeed
Definition MRToolPath.h:36
float millRadius
Definition MRToolPath.h:22
ProgressCallback cb
Definition MRToolPath.h:50
bool flatTool
Definition MRToolPath.h:48
std::vector< Vector3f > * startVertices
Definition MRToolPath.h:57
const AffineXf3f * xf
Definition MRToolPath.h:46
Definition MRToolPath.h:122
std::vector< GCommand > commands
Definition MRToolPath.h:128
FaceBitSet modifiedRegion
Definition MRToolPath.h:126
Mesh modifiedMesh
Definition MRToolPath.h:124