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 // if > 0 - expand the trajectory creation area and create toolpath to mill excess material to make empty areas.
53 // The area has the shape of a box.
54 // Lacing specific only.
55 float toolpathExpansion = 0.f;
56
57 // optional output, stores isolines without transits
58 Contours3f* isolines = nullptr;
59 // optional output, polyline containing start vertices for isolines
61 // start vertices on the offset mesh used for calcutating isolines
62 std::vector<Vector3f>* startVertices = nullptr;
63
64 MeshPart* offsetMesh = nullptr;
65};
66
68{
69 // if true isolines will be processed from center point to the boundary (usually it means from up to down)
71};
72
74{
75 // maximal deviation from given line
76 float eps = {};
77 // maximal length of the line
78 float maxLength = {};
79 // callback for reporting on progress
81};
82
84{
85 // maximal deviation of arc from given path
86 float eps = {};
87 // maximal radius of the arc
88 float maxRadius = {};
89 // callback for reporting on progress
91};
92
93enum class MoveType
94{
95 None = -1,
96 FastLinear = 0,
97 Linear = 1,
98 ArcCW = 2,
99 ArcCCW = 3
100};
101
102enum class ArcPlane
103{
104 None = -1,
105 XY = 17,
106 XZ = 18,
107 YZ = 19
108};
109
111{
112 // type of command GX (G0, G1, etc). By default - G1
114 // Place for comment
116 // feedrate for move
117 float feed = std::numeric_limits<float>::quiet_NaN();
118 // coordinates of destination point
119 float x = std::numeric_limits<float>::quiet_NaN();
120 float y = std::numeric_limits<float>::quiet_NaN();
121 float z = std::numeric_limits<float>::quiet_NaN();
122 // if moveType is ArcCW or ArcCCW center of the arc shoult be specified
123 Vector3f arcCenter = Vector3f::diagonal( std::numeric_limits<float>::quiet_NaN() );
124};
125
127{
128 // mesh after fixing undercuts and offset
130 // selected region projected from the original mesh to the offset
131 FaceBitSet modifiedRegion;
132 // constains type of movement and its feed
133 std::vector<GCommand> commands;
134};
135
136// compute path of the milling tool for the given mesh with parameters ( direction of milling is from up to down along Z-direction )
137// this toolpath is built from the parallel sections along Z-axis
138// mesh can be transformed using xf parameter
139
141
142// compute path of the milling tool for the given mesh with parameters ( direction of milling is from up to down along Z-direction )
143// // this one is traditional lace-roughing toolpath
144
145// Slices are built along the axis defined by cutDirection argument (can be Axis::X or Axis::Y)
146MRVOXELS_API Expected<ToolPathResult> lacingToolPath( const MeshPart& mp, const ToolPathParams& params, Axis cutDirection );
147
148// compute path of the milling tool for the given mesh with parameters ( direction of milling is from up to down along Z-direction )
149// this toolpath is built from geodesic parallels divercing from the given start point or from the bounaries of selected areas
150// if neither is specified, the lowest section by XY plane will be used as a start contour
151// mesh can be transformed using xf parameter
153
154// generates G-Code for milling tool
155MRVOXELS_API std::shared_ptr<ObjectGcode> exportToolPathToGCode( const std::vector<GCommand>& commands );
156
157// interpolates several points lying on the same straight line with one move
158MRVOXELS_API Expected<void> interpolateLines( std::vector<GCommand>& commands, const LineInterpolationParams& params, Axis axis );
159// interpolates given path with arcs
160MRVOXELS_API Expected<void> interpolateArcs( std::vector<GCommand>& commands, const ArcInterpolationParams& params, Axis axis );
161
162// 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
163// \param expandOffset defines how much the boundary is expanded
164// \param expandOffset defines how much the boundary is shrinked after that
165MRVOXELS_API FaceBitSet smoothSelection( Mesh& mesh, const FaceBitSet& region, float expandOffset, float shrinkOffset );
166
167}
#define MRVOXELS_API
Definition MRVoxels/MRVoxelsFwd.h:13
std::function< bool(float)> ProgressCallback
Definition MRMesh/MRMeshFwd.h:728
@ 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
Contours3< float > Contours3f
Definition MRMesh/MRMeshFwd.h:383
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:94
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)
ArcPlane
Definition MRToolPath.h:103
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:84
float maxRadius
Definition MRToolPath.h:88
float eps
Definition MRToolPath.h:86
ProgressCallback cb
Definition MRToolPath.h:90
Definition MRToolPath.h:68
bool fromCenterToBoundary
Definition MRToolPath.h:70
Definition MRToolPath.h:111
float y
Definition MRToolPath.h:120
float x
Definition MRToolPath.h:119
ArcPlane arcPlane
Definition MRToolPath.h:115
MoveType type
Definition MRToolPath.h:113
Vector3f arcCenter
Definition MRToolPath.h:123
float feed
Definition MRToolPath.h:117
float z
Definition MRToolPath.h:121
Definition MRToolPath.h:74
float eps
Definition MRToolPath.h:76
ProgressCallback cb
Definition MRToolPath.h:80
float maxLength
Definition MRToolPath.h:78
Definition MRMesh/MRMesh.h:23
Definition MRToolPath.h:20
float toolpathExpansion
Definition MRToolPath.h:55
float safeZ
Definition MRToolPath.h:42
Contours3f * isolines
Definition MRToolPath.h:58
float critTransitionLength
Definition MRToolPath.h:30
float sectionStep
Definition MRToolPath.h:27
MeshPart * offsetMesh
Definition MRToolPath.h:64
float baseFeed
Definition MRToolPath.h:40
float retractFeed
Definition MRToolPath.h:38
BypassDirection bypassDir
Definition MRToolPath.h:44
Contours3f * startContours
Definition MRToolPath.h:60
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:62
const AffineXf3f * xf
Definition MRToolPath.h:46
Definition MRToolPath.h:127
std::vector< GCommand > commands
Definition MRToolPath.h:133
FaceBitSet modifiedRegion
Definition MRToolPath.h:131
Mesh modifiedMesh
Definition MRToolPath.h:129