5#include "MRCNCMachineSettings.h"
16class MRMESH_CLASS GcodeProcessor
20 template<
typename Vec>
24 std::vector<Vec> path;
34 std::vector<Vector3f> toolDirection;
36 float feedrate = 100.f;
38 bool valid()
const {
return action.warning.empty(); }
39 operator bool()
const {
return valid(); }
43 MRMESH_API
void reset();
46 MRMESH_API
void setGcodeSource(
const GcodeSource& gcodeSource );
49 MRMESH_API std::vector<MoveAction> processSource();
59 MRMESH_API
MoveAction processLine(
const std::string_view& line, std::vector<Command> & externalStorage );
74 static void parseFrame_(
const std::string_view& frame, std::vector<Command> & outCommands );
75 void applyCommand_(
const Command& command );
76 void applyCommandG_(
const Command& command );
77 MoveAction generateMoveAction_();
78 MoveAction generateReturnToHomeAction_();
79 void resetTemporaryStates_();
84 MoveAction moveLine_(
const Vector3f& newPoint,
const Vector3f& newAngles );
86 MoveAction moveArc_(
const Vector3f& newPoint,
const Vector3f& newAngles,
bool clockwise );
89 void updateWorkPlane_( WorkPlane wp );
92 void updateScaling_();
97 BaseAction2f getArcPoints2_(
const Vector2f& beginPoint,
const Vector2f& endPoint,
bool clockwise );
99 BaseAction3f getArcPoints3_(
const Vector3f& center,
const Vector3f& beginPoint,
const Vector3f& endPoint,
bool clockwise );
103 BaseAction3f getArcPoints3_(
float r,
const Vector3f& beginPoint,
const Vector3f& endPoint,
bool clockwise );
106 MoveAction getToolRotationPoints_(
const Vector3f& newRotationAngles );
108 Vector3f calcNewTranslationPos_();
109 Vector3f calcNewRotationAngles_();
110 Vector3f calcRealCoord_(
const Vector3f& translationPos,
const Vector3f& rotationAngles );
111 void updateRotationAngleAndMatrix_(
const Vector3f& rotationAngles );
112 Vector3f calcRealCoordCached_(
const Vector3f& translationPos,
const Vector3f& rotationAngles );
113 Vector3f calcRealCoordCached_(
const Vector3f& translationPos );
134 CoordType coordType_ = CoordType::Movement;
135 MoveMode moveMode_ = MoveMode::Idle;
136 WorkPlane workPlane_ = WorkPlane::xy;
137 Matrix3f toWorkPlaneXf_;
138 Vector3f translationPos_;
139 Vector3f rotationAngles_;
140 bool absoluteCoordinates_ =
true;
141 Vector3f scaling_ = Vector3f::diagonal( 1.f );
142 bool inches_ =
false;
143 float feedrate_ = 100.f;
144 float feedrateMax_ = 0.f;
147 std::array<Matrix3f, 3> cacheRotationMatrix_;
150 Vector3f inputCoords_;
151 Vector3b inputCoordsReaded_;
152 std::optional<float> radius_;
153 std::optional<Vector3f> arcCenter_;
154 Vector3f inputRotation_;
155 Vector3b inputRotationReaded_;
157 std::vector<std::string_view> gcodeSource_;
160 float accuracy_ = 1.e-3f;
161 CNCMachineSettings cncSettings_;
162 std::vector<int> rotationAxesOrderMap_ = {0, 1, 2};
Definition MRCNCMachineSettings.h:16
Definition MRGcodeProcessor.h:22
Definition MRGcodeProcessor.h:52
Definition MRGcodeProcessor.h:32