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