Skip to content

Commit

Permalink
Merge pull request #150 from aewallin/develop
Browse files Browse the repository at this point in the history
Release v2022.01.11
  • Loading branch information
vespakoen committed Jan 11, 2023
2 parents 94f1f31 + 41157c7 commit 0091710
Show file tree
Hide file tree
Showing 22 changed files with 468 additions and 254 deletions.
22 changes: 18 additions & 4 deletions .github/workflows/cd.yml
Expand Up @@ -63,7 +63,12 @@ jobs:
- name: cxxlib
shell: bash
run: |
git describe --tags > src/git-tag.txt
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
version="${GITHUB_REF##*/}"
else
version="$(date '+%Y.%-m.%-d').dev${GITHUB_RUN_NUMBER}"
fi
echo "${version}" > src/git-tag.txt
if [ "${{ matrix.docker_image }}" != "" ]; then
export OCL_DOCKER_IMAGE="${{ matrix.docker_image }}"
Expand Down Expand Up @@ -146,7 +151,12 @@ jobs:
- name: nodejslib
shell: bash
run: |
git describe --tags > src/git-tag.txt
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
version="${GITHUB_REF##*/}"
else
version="$(date '+%Y.%-m.%-d')-dev.${GITHUB_RUN_NUMBER}"
fi
echo "${version}" > src/git-tag.txt
if [ "${{ matrix.docker_image }}" != "" ]; then
export OCL_DOCKER_IMAGE="${{ matrix.docker_image }}"
Expand Down Expand Up @@ -262,7 +272,7 @@ jobs:
version="$(date '+%Y.%-m.%-d').dev${GITHUB_RUN_NUMBER}"
fi
sed -i.bak "s/^version = .*/version = \"${version}\"/g" pyproject.toml && rm pyproject.toml.bak
git describe --tags > src/git-tag.txt
echo "${version}" > src/git-tag.txt
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
if: matrix.architecture == 'aarch64'
Expand Down Expand Up @@ -435,7 +445,11 @@ jobs:
shell: bash
run: |
mkdir dist
mv prebuilds/*-cxx-*/* dist
zip -r dist/linux-cxx-x86_64.zip prebuilds/linux-cxx-x86_64
zip -r dist/macos-cxx-arm64.zip prebuilds/macos-cxx-arm64
zip -r dist/macos-cxx-x86_64.zip prebuilds/macos-cxx-x86_64
zip -r dist/windows-cxx-ia32.zip prebuilds/windows-cxx-ia32
zip -r dist/windows-cxx-x64.zip prebuilds/windows-cxx-x64
- name: Release
uses: softprops/action-gh-release@v1
with:
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
@@ -1,5 +1,6 @@
project(OpenCAMLib)
cmake_minimum_required(VERSION 3.15...3.25)

project(OpenCAMLib LANGUAGES CXX)

set( CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src )
add_subdirectory( src )
216 changes: 124 additions & 92 deletions examples/cpp/test/test_example.cpp
Expand Up @@ -9,45 +9,83 @@
#include <opencamlib/stlsurf.hpp>
#include <opencamlib/stlreader.hpp>
#include <opencamlib/cylcutter.hpp>
#include <opencamlib/ballcutter.hpp>
#include <opencamlib/bullcutter.hpp>
#include <opencamlib/conecutter.hpp>
#include <opencamlib/point.hpp>
#include <opencamlib/line.hpp>
#include <opencamlib/path.hpp>

void printXYZ(ocl::Point point)
{
// printf("X%g ", round(point.x * 100000.0) / 100000.0);
// printf("Y%g ", round(point.y * 100000.0) / 100000.0);
// printf("Z%g", round(point.z * 100000.0) / 100000.0);
}

void linear(ocl::Point point)
{
// printf("G01 ");
// printXYZ(point);
// printf("\n");
}

void moveSafely(ocl::Point point)
{
printf("G00 Z10\n");
printf("G00 ");
printf("X%g ", round(point.x * 100000.0) / 100000.0);
printf("Y%g\n", round(point.y * 100000.0) / 100000.0);
printf("G01 ");
printf("Z%g", round(point.z * 100000.0) / 100000.0);
printf(" F50\n");
// printf("G00 Z10\n");
// printf("G00 ");
// printf("X%g ", round(point.x * 100000.0) / 100000.0);
// printf("Y%g\n", round(point.y * 100000.0) / 100000.0);
// printf("G01 ");
// printf("Z%g", round(point.z * 100000.0) / 100000.0);
// printf(" F50\n");
}

void printPoints(std::vector<ocl::Point> points)
{
for (auto j = 0; j < points.size(); j++)
{
auto point = points[j];
if (j == 0)
moveSafely(point);
else
linear(point);
}
}

void printPoints(std::vector<ocl::CLPoint> points)
{
for (auto j = 0; j < points.size(); j++)
{
auto point = points[j];
if (j == 0)
moveSafely(point);
else
linear(point);
}
}

void printLoops(std::vector<std::vector<ocl::Point>> loops)
{
for (auto i = 0; i < loops.size(); i++)
{
printPoints(loops[i]);
}
}

void waterline(ocl::STLSurf surface, ocl::MillingCutter *cutter, double z, double sampling)
{
ocl::Waterline wl = ocl::Waterline();
wl.setSTL(surface);
wl.setCutter(cutter);
wl.setZ(z);
wl.setSampling(sampling);
wl.run();
auto loops = wl.getLoops();
// std::cout << "loops: " << loops.size() << "\n";
for (auto i = 0; i < loops.size(); i++)
for (double h = 0; h < z; h = h + 0.1)
{
for (auto j = 0; j < loops[i].size(); j++)
{
auto point = loops[i][j];
if (j == 0) {
moveSafely(point);
} else {
printf("G01 ");
printf("X%g ", round(point.x * 100000.0) / 100000.0);
printf("Y%g ", round(point.y * 100000.0) / 100000.0);
printf("Z%g\n", round(point.z * 100000.0) / 100000.0);
}
}
wl.reset();
wl.setZ(h);
wl.run();
auto loops = wl.getLoops();
printLoops(loops);
}
}

Expand All @@ -56,26 +94,15 @@ void adaptiveWaterline(ocl::STLSurf surface, ocl::MillingCutter *cutter, double
ocl::AdaptiveWaterline awl = ocl::AdaptiveWaterline();
awl.setSTL(surface);
awl.setCutter(cutter);
awl.setZ(z);
awl.setSampling(sampling);
awl.setMinSampling(minSampling);
awl.run();
auto loops = awl.getLoops();
// std::cout << "loops: " << loops.size() << "\n";
for (auto i = 0; i < loops.size(); i++)
for (double h = 0; h < z; h = h + 0.1)
{
for (auto j = 0; j < loops[i].size(); j++)
{
auto point = loops[i][j];
if (j == 0) {
moveSafely(point);
} else {
printf("G01 ");
printf("X%g ", round(point.x * 100000.0) / 100000.0);
printf("Y%g ", round(point.y * 100000.0) / 100000.0);
printf("Z%g\n", round(point.z * 100000.0) / 100000.0);
}
}
awl.reset();
awl.setZ(h);
awl.run();
auto loops = awl.getLoops();
printLoops(loops);
}
}

Expand All @@ -85,23 +112,12 @@ void pathDropCutter(ocl::STLSurf surface, ocl::MillingCutter *cutter, double sam
pdc.setSTL(surface);
pdc.setCutter(cutter);
pdc.setPath(path);
pdc.setZ(0);
pdc.setSampling(sampling);
pdc.reset();
pdc.setZ(0);
pdc.run();
auto points = pdc.getPoints();
// std::cout << "points: " << points.size() << "\n";
for (auto i = 0; i < points.size(); i++)
{
auto point = points[i];
if (i == 0) {
moveSafely(point);
} else {
printf("G01 ");
printf("X%g ", round(point.x * 100000.0) / 100000.0);
printf("Y%g ", round(point.y * 100000.0) / 100000.0);
printf("Z%g\n", round(point.z * 100000.0) / 100000.0);
}
}
printPoints(points);
}

void adaptivePathDropCutter(ocl::STLSurf surface, ocl::MillingCutter *cutter, double sampling, double minSampling, ocl::Path *path)
Expand All @@ -110,54 +126,70 @@ void adaptivePathDropCutter(ocl::STLSurf surface, ocl::MillingCutter *cutter, do
apdc.setSTL(surface);
apdc.setCutter(cutter);
apdc.setPath(path);
apdc.setZ(0);
apdc.setSampling(sampling);
apdc.setMinSampling(minSampling);
apdc.reset();
apdc.setZ(0);
apdc.run();
auto points = apdc.getPoints();
// std::cout << "points: " << points.size() << "\n";
for (auto i = 0; i < points.size(); i++)
{
auto point = points[i];
if (i == 0) {
moveSafely(point);
} else {
printf("G01 ");
printf("X%g ", round(point.x * 100000.0) / 100000.0);
printf("Y%g ", round(point.y * 100000.0) / 100000.0);
printf("Z%g\n", round(point.z * 100000.0) / 100000.0);
}
}
printPoints(points);
}

int main()
{
// std::cout << "ocl version: " << ocl::version() << "\n";
// std::cout << "max threads: " << ocl::max_threads() << "\n";
std::cout << "ocl version: " << ocl::version() << "\n";
std::cout << "max threads: " << ocl::max_threads() << "\n";
ocl::STLSurf surface = ocl::STLSurf();
std::wstring stlPath = L"../../../../stl/gnu_tux_mod.stl";
ocl::STLReader(stlPath, surface);
// std::cout << "surface size: " << surface.size() << "\n";
ocl::CylCutter cutter = ocl::CylCutter(4, 20);
double z = 1;
std::cout << "surface size: " << surface.size() << "\n";

ocl::CylCutter cylCutter = ocl::CylCutter(0.4, 10);
ocl::BallCutter ballCutter = ocl::BallCutter(4, 20);
ocl::BullCutter bullCutter = ocl::BullCutter(4, 0.05, 20);
ocl::ConeCutter coneCutter = ocl::ConeCutter(4, 0.05, 20);
std::vector<ocl::MillingCutter *> cutters;
cutters.push_back(&cylCutter);
cutters.push_back(&ballCutter);
cutters.push_back(&bullCutter);
cutters.push_back(&coneCutter);
double z = 0.5;
double sampling = 0.1;
waterline(surface, &cutter, z, sampling);
// std::cout << "waterline done.\n";
double minSampling = 0.001;
ocl::CylCutter cutter2 = ocl::CylCutter(4, 20);
adaptiveWaterline(surface, &cutter2, z, sampling, minSampling);
// std::cout << "adaptivewaterline done.\n";
for (auto cutter : cutters)
{
std::cout << "WL + Cutter: " << cutter->str() << "\n";
waterline(surface, cutter, z, sampling);
}
double minSampling = 0.01;
for (auto cutter : cutters)
{
std::cout << "AWL + Cutter: " << cutter->str() << "\n";
adaptiveWaterline(surface, cutter, z, sampling, minSampling);
}
ocl::Path path = ocl::Path();
ocl::Point p1 = ocl::Point(-2, 4, 0);
ocl::Point p2 = ocl::Point(11, 4, 0);
ocl::Line l = ocl::Line(p1, p2);
path.append(l);
ocl::CylCutter cutter3 = ocl::CylCutter(4, 20);
pathDropCutter(surface, &cutter3, sampling, &path);
// std::cout << "pathdropcutter done.\n";
ocl::CylCutter cutter4 = ocl::CylCutter(4, 20);
adaptivePathDropCutter(surface, &cutter4, sampling, minSampling, &path);
// std::cout << "adaptivepathdropcutter done.\n";
return 0;
}
int i = 0;
for (double y = 0; y <= 0.2; y = y + 0.1)
{
bool ltr = ((int)i % 2) == 0;
ocl::Point p1 = ocl::Point(ltr ? -2 : 11, y, 0);
ocl::Point p2 = ocl::Point(ltr ? 11 : -2, y, 0);
ocl::Line l = ocl::Line(p1, p2);
path.append(l);
ocl::Point p3 = ocl::Point(ltr ? 11 : -2, y + 1, 0);
ocl::Line l2 = ocl::Line(p2, p3);
path.append(l2);
i++;
}
for (auto cutter : cutters)
{
std::cout << "PDC + Cutter: " << cutter->str() << "\n";
pathDropCutter(surface, cutter, sampling, &path);
}
for (auto cutter : cutters)
{
std::cout << "APDC: " << cutter->str() << "\n";
adaptivePathDropCutter(surface, cutter, sampling, minSampling, &path);
}

return 0;
}
6 changes: 3 additions & 3 deletions install.sh
Expand Up @@ -31,7 +31,7 @@ Options:
--boost-python-version Set the python version to look for when compiling Boost (only valid when using --install-boost and --boost-with-python)
--python-executable Set a custom path (or name of) the Python executable (only valid when using --build-library python)
--python-prefix Set the python prefix, this will be passed to CMake as Python_ROOT_DIR, to make sure CMake is using the correct Python installation. (only valid when using --build-library python)
--python-prefix Set the python prefix, this will be passed to CMake as Python3_ROOT_DIR, to make sure CMake is using the correct Python installation. (only valid when using --build-library python)
--python-pip-install Uses "pip install ." to compile and install the Python library (only valid when using --build-library python)
--platform Set the platform, for when auto-detection doesn't work (one of: windows, macos, linux)
Expand Down Expand Up @@ -121,7 +121,7 @@ if [ "${OCL_BUILD_TYPE}" = "debug" ]; then
build_type="Debug"
build_type_lower="debug"
else
build_type="Release"
build_type="RelWithDebInfo"
build_type_lower="release"
fi
build_dir="${project_dir}/build/${OCL_BUILD_LIBRARY}/${build_type_lower}"
Expand Down Expand Up @@ -541,7 +541,7 @@ ${OCL_BOOST_PREFIX:+"-D BOOST_ROOT=${OCL_BOOST_PREFIX} "}"
-D Boost_ADDITIONAL_VERSIONS="${boost_additional_versions}" \
-D CMAKE_INSTALL_PREFIX="${OCL_INSTALL_PREFIX:-"${install_prefix_fallback}"}" \
${OCL_DISABLE_OPENMP:+"-DUSE_OPENMP=OFF"} \
${OCL_PYTHON_PREFIX:+"-DPython_ROOT_DIR=${OCL_PYTHON_PREFIX}"} \
${OCL_PYTHON_PREFIX:+"-DPython3_ROOT_DIR=${OCL_PYTHON_PREFIX}"} \
${OCL_BOOST_PREFIX:+"-DBOOST_ROOT=${OCL_BOOST_PREFIX}"} \
../../..
set +x
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Expand Up @@ -42,8 +42,8 @@ wheel.packages = ["src/pythonlib/opencamlib"]

[tool.scikit-build.cmake.define]
BUILD_PY_LIB = "ON"
USE_OPENMP = "ON"
Boost_ADDITIONAL_VERSIONS = "1.80.0;1.79.0;1.78.0;1.77.0;1.76.0;1.75.0;1.74.0;1.73.0;1.72.0;1.71.0;1.70.0"
BUILD_DOC = "OFF"

[tool.cibuildwheel]
build = ["cp37*", "cp38*", "cp39*", "cp310*", "cp311*"]
Expand All @@ -63,3 +63,4 @@ before-build = "cd {package} && bash ./install.sh --install-boost --boost-with-p
archs = ["x86_64", "arm64"]
before-all = "cd {package} && bash ./install.sh --install-ci-deps"
before-build = "cd {package} && bash ./install.sh --install-boost --boost-with-python --python-executable python"
repair-wheel-command = "python src/pythonlib/delocate-wheel.py --require-archs {delocate_archs} -w {dest_dir} -v {wheel}"

0 comments on commit 0091710

Please sign in to comment.