Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FormerLurker/ArcWelderLib.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFormerLurker <hochgebe@gmail.com>2020-05-17 01:17:15 +0300
committerFormerLurker <hochgebe@gmail.com>2020-05-17 01:17:15 +0300
commitd201085f565ed498d218ece1783a5c76bcfdb25d (patch)
treeaaa7304ecb0c89c0fdb5e4930e7db7a5897d907e /PyArcWelder
parentf98db3c33c4199eb966c45c9ab2e914b3a689ae1 (diff)
Add max_radius_mm and switch to polar coordinates for arc generation.
Diffstat (limited to 'PyArcWelder')
-rw-r--r--PyArcWelder/PyArcWelder.vcxproj24
-rw-r--r--PyArcWelder/py_arc_welder.cpp12
-rw-r--r--PyArcWelder/py_arc_welder.h4
-rw-r--r--PyArcWelder/py_arc_welder_extension.cpp20
-rw-r--r--PyArcWelder/py_arc_welder_extension.h10
5 files changed, 48 insertions, 22 deletions
diff --git a/PyArcWelder/PyArcWelder.vcxproj b/PyArcWelder/PyArcWelder.vcxproj
index 3f6138f..3888cca 100644
--- a/PyArcWelder/PyArcWelder.vcxproj
+++ b/PyArcWelder/PyArcWelder.vcxproj
@@ -26,26 +26,26 @@
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
+ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
+ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
+ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
- <ConfigurationType>Application</ConfigurationType>
+ <ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
@@ -71,19 +71,19 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
- <IncludePath>C:\Python27\include;$(SolutionDir)\GcodeProcessorLib\;$(SolutionDir)\ArcWelder\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
+ <IncludePath>C:\Python38\include;$(SolutionDir)\GcodeProcessorLib\;$(SolutionDir)\ArcWelder\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
- <IncludePath>C:\Python27\include;$(SolutionDir)\GcodeProcessorLib\;$(SolutionDir)\ArcWelder\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
+ <IncludePath>C:\Python38\include;$(SolutionDir)\GcodeProcessorLib\;$(SolutionDir)\ArcWelder\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
- <IncludePath>C:\Python27\include;$(SolutionDir)\GcodeProcessorLib\;$(SolutionDir)\ArcWelder\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
+ <IncludePath>C:\Python38\include;$(SolutionDir)\GcodeProcessorLib\;$(SolutionDir)\ArcWelder\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
- <IncludePath>C:\Python27\include;$(SolutionDir)\GcodeProcessorLib\;$(SolutionDir)\ArcWelder\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
+ <IncludePath>C:\Python38\include;$(SolutionDir)\GcodeProcessorLib\;$(SolutionDir)\ArcWelder\;$(VC_IncludePath);$(WindowsSDK_IncludePath)</IncludePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
@@ -95,7 +95,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>C:\Python27\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>C:\Python38\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>
@@ -112,7 +112,7 @@
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>C:\Python27\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>C:\Python38\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>
@@ -133,7 +133,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>C:\Python27\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>C:\Python38\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>$(SolutionDir)\DeployCodeToPlugin.bat $(SolutionDir) C:\Users\Brad\source\repos\ArcWelderPlugin\</Command>
@@ -153,7 +153,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
- <AdditionalLibraryDirectories>C:\Python27\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>C:\Python38\libs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<PostBuildEvent>
<Command>$(SolutionDir)\DeployCodeToPlugin.bat $(SolutionDir) C:\Users\Brad\source\repos\ArcWelderPlugin\</Command>
diff --git a/PyArcWelder/py_arc_welder.cpp b/PyArcWelder/py_arc_welder.cpp
index 7844cfe..302aa95 100644
--- a/PyArcWelder/py_arc_welder.cpp
+++ b/PyArcWelder/py_arc_welder.cpp
@@ -25,7 +25,7 @@
PyObject* py_arc_welder::build_py_progress(arc_welder_progress progress)
{
- PyObject* py_progress = Py_BuildValue("{s:d,s:d,s:d,s:i,s:i,s:i,s:i,s:i,s:i}",
+ PyObject* py_progress = Py_BuildValue("{s:d,s:d,s:d,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:f,s:f}",
u8"percent_complete",
progress.percent_complete,
u8"seconds_elapsed",
@@ -40,15 +40,21 @@ PyObject* py_arc_welder::build_py_progress(arc_welder_progress progress)
progress.points_compressed,
u8"arcs_created",
progress.arcs_created,
+ u8"source_file_position",
+ progress.source_file_position,
u8"source_file_size",
progress.source_file_size,
u8"target_file_size",
- progress.target_file_size
+ progress.target_file_size,
+ u8"compression_ratio",
+ progress.compression_ratio,
+ u8"compression_percent",
+ progress.compression_percent
);
return py_progress;
}
-bool py_arc_welder::on_progress_(arc_welder_progress progress)
+bool py_arc_welder::on_progress_(const arc_welder_progress& progress)
{
PyObject* py_dict = py_arc_welder::build_py_progress(progress);
if (py_dict == NULL)
diff --git a/PyArcWelder/py_arc_welder.h b/PyArcWelder/py_arc_welder.h
index b116791..ef56715 100644
--- a/PyArcWelder/py_arc_welder.h
+++ b/PyArcWelder/py_arc_welder.h
@@ -34,7 +34,7 @@
class py_arc_welder : public arc_welder
{
public:
- py_arc_welder(std::string source_path, std::string target_path, py_logger* logger, double resolution_mm, bool g90_g91_influences_extruder, int buffer_size, PyObject* py_progress_callback):arc_welder(source_path, target_path, logger, resolution_mm, g90_g91_influences_extruder, buffer_size)
+ py_arc_welder(std::string source_path, std::string target_path, py_logger* logger, double resolution_mm, double max_radius, bool g90_g91_influences_extruder, int buffer_size, PyObject* py_progress_callback):arc_welder(source_path, target_path, logger, resolution_mm, max_radius, g90_g91_influences_extruder, buffer_size)
{
py_progress_callback_ = py_progress_callback;
}
@@ -43,7 +43,7 @@ public:
}
static PyObject* build_py_progress(arc_welder_progress progress);
protected:
- virtual bool on_progress_(arc_welder_progress progress);
+ virtual bool on_progress_(const arc_welder_progress& progress);
private:
PyObject* py_progress_callback_;
};
diff --git a/PyArcWelder/py_arc_welder_extension.cpp b/PyArcWelder/py_arc_welder_extension.cpp
index ca60196..7879909 100644
--- a/PyArcWelder/py_arc_welder_extension.cpp
+++ b/PyArcWelder/py_arc_welder_extension.cpp
@@ -188,13 +188,14 @@ extern "C"
std::stringstream stream;
stream << "py_gcode_arc_converter.ConvertFile - Parameters received: source_file_path: '" <<
args.source_file_path << "', target_file_path:'" << args.target_file_path << "' resolution_mm:" <<
- args.resolution_mm << ", g90_91_influences_extruder: " << (args.g90_g91_influences_extruder ? "True" : "False") << "\n";
+ args.resolution_mm << "' max_radius_mm:" <<
+ args.max_radius_mm << ", g90_91_influences_extruder: " << (args.g90_g91_influences_extruder ? "True" : "False") << "\n";
p_py_logger->log(GCODE_CONVERSION, INFO, stream.str());
std::string message = "py_gcode_arc_converter.ConvertFile - Beginning Arc Conversion.";
p_py_logger->log(GCODE_CONVERSION, INFO, message);
- py_arc_welder arc_welder_obj(args.source_file_path, args.target_file_path, p_py_logger, args.resolution_mm, args.g90_g91_influences_extruder, 50, py_progress_callback);
+ py_arc_welder arc_welder_obj(args.source_file_path, args.target_file_path, p_py_logger, args.resolution_mm, args.max_radius_mm, args.g90_g91_influences_extruder, 50, py_progress_callback);
arc_welder_results results = arc_welder_obj.process();
message = "py_gcode_arc_converter.ConvertFile - Arc Conversion Complete.";
p_py_logger->log(GCODE_CONVERSION, INFO, message);
@@ -259,6 +260,21 @@ static bool ParseArgs(PyObject* py_args, py_gcode_arc_args& args, PyObject** py_
{
args.resolution_mm = 0.05; // Set to the default if no resolution is provided, or if it is less than 0.
}
+
+ // Extract the max_radius in mm
+ PyObject* py_max_radius_mm = PyDict_GetItemString(py_args, "max_radius_mm");
+ if (py_max_radius_mm == NULL)
+ {
+ std::string message = "ParseArgs - Unable to retrieve the max_radius_mm parameter from the args.";
+ p_py_logger->log_exception(GCODE_CONVERSION, message);
+ return false;
+ }
+ args.max_radius_mm = gcode_arc_converter::PyFloatOrInt_AsDouble(py_max_radius_mm);
+ if (args.max_radius_mm > DEFAULT_MAX_RADIUS_MM)
+ {
+ args.max_radius_mm = DEFAULT_MAX_RADIUS_MM; // Set to the default if no resolution is provided, or if it is less than 0.
+ }
+
// Extract G90/G91 influences extruder
// g90_influences_extruder
PyObject* py_g90_g91_influences_extruder = PyDict_GetItemString(py_args, "g90_g91_influences_extruder");
diff --git a/PyArcWelder/py_arc_welder_extension.h b/PyArcWelder/py_arc_welder_extension.h
index 47b7215..068621b 100644
--- a/PyArcWelder/py_arc_welder_extension.h
+++ b/PyArcWelder/py_arc_welder_extension.h
@@ -30,6 +30,7 @@
#endif
#include <string>
#include "py_logger.h"
+#include "arc_welder.h"
extern "C"
{
#if PY_MAJOR_VERSION >= 3
@@ -44,14 +45,16 @@ struct py_gcode_arc_args {
py_gcode_arc_args() {
source_file_path = "";
target_file_path = "";
- resolution_mm = 0.05;
- g90_g91_influences_extruder = false;
+ resolution_mm = DEFAULT_RESOLUTION_MM;
+ max_radius_mm = DEFAULT_MAX_RADIUS_MM;
+ g90_g91_influences_extruder = DEFAULT_G90_G91_INFLUENCES_EXTREUDER;
log_level = 0;
}
- py_gcode_arc_args(std::string source_file_path_, std::string target_file_path_, double resolution_mm_, bool g90_g91_influences_extruder_, int log_level_) {
+ py_gcode_arc_args(std::string source_file_path_, std::string target_file_path_, double resolution_mm_, double max_radius_mm_, bool g90_g91_influences_extruder_, int log_level_) {
source_file_path = source_file_path_;
target_file_path = target_file_path_;
resolution_mm = resolution_mm_;
+ max_radius_mm = max_radius_mm_;
g90_g91_influences_extruder = g90_g91_influences_extruder_;
log_level = log_level_;
}
@@ -59,6 +62,7 @@ struct py_gcode_arc_args {
std::string target_file_path;
double resolution_mm;
bool g90_g91_influences_extruder;
+ double max_radius_mm;
int log_level;
};