Giter VIP home page Giter VIP logo

pyslm's People

Contributors

drlukeparry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyslm's Issues

Bug: PySLM - Support Structures Extruded Prisms are incorrectly trianglulated

With latest release of Trimesh (3.18) the default argument for the triangulation method is earbox-cut algorithm. This creates a triangular mesh that is not constrained to a prescribed triangle size with poor quality triangulation, causing failure of the Ray Intersection tests used to build the support volume.

LinearSort erroring out

Hopefully this screenshot of my debugger demonstrates the error well enough:
image

The error comes from this line of sorting.py:

idx2 = norm.dot(midPoints.T)

I've added a few comments in there just to try and figure stuff out, but I haven't changed any actual code from what's on the main branch.

The error is complaining that I'm taking the dot product of a 2-long array (essentially a vector representative of the hatch angle) and a X-long array of midpoints, where X is the number of vectors. My knowledge of linear algebra and numpy is sketchy at best, but isn't this expecting two same-length arrays for the dot product? Is a dot product the proper way to handle this?

Again, apologies for not knowing the linear algebra terminology and numpy, so I speak intuitively. I think the way to do this would be to basically extend each midpoint by the hatch angle to the x-axis, then sort the lines based on the x-value of their intersection point with the x-axis. How would you accomplish this via numpy?

I am running this with a pretty standard setup. I don't anticipate a specific test case will help much, as I think the error is apparent. I unfortunately just don't have enough background knowledge to fix it.

Missing package 'Cython' when installing PythonSLM

I was installing the PythonSLM package as suggested in your readme. This means first I installed all required packages beforehand then installed PythonSLM. The installation did not finish as Cython was expected. Maybe you add it to your readme?

Bug on class AlternateSort

Hi everyone,

Line 38 on pyslm/pyslm/hatching/sorting.py has a bug. It is not switching the direction of last vector if it has to be switched.

currently: sv[1:-1:2] = np.flip(sv[1:-1:2], 1)
suggested solution: sv[1::2] = np.flip(sv[1::2], 1)
Kind regards
ortmannrobert

Issues with visualize.plot()

I was able to successfully install pyslm and run the basic example code. However, I am not getting any output from pyslm.visualise.plot(layer, plot3D=False, plotOrderLine=True)

Running on windows Python 3.7.9 PythonSLM 0.5.0. Any suggestions on how to address this would be appreciated.

Trouble running example_support_structure.py on 0.6.0 (dev branch)

I am sitting on the dev branch, trying to set up the new support generation engine. I started with the example code and realized that the bracket stl file is not on the repo. I tried just with the nut.stl file instead, but I have a hard time getting the code to run. I keep getting this error:

Traceback (most recent call last):
File "...\pyslm-dev\examples\example_support_structure.py", line 85, in
supportBlockRegions = supportGenerator.identifySupportRegions(myPart, OVERHANG_ANGLE, True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "...\AppData\Local\Programs\Python\Python312\Lib\site-packages\pythonslm-0.6.0-py3.12.egg\pyslm\support\gridBlockSupport.py", line 1917, in identifySupportRegions
File "...\AppData\Local\Programs\Python\Python312\Lib\site-packages\pythonslm-0.6.0-py3.12.egg\pyslm\support\support.py", line 1005, in identifySupportRegions
File "...\AppData\Local\Programs\Python\Python312\Lib\site-packages\pythonslm-0.6.0-py3.12.egg\pyslm\support\geometry.py", line 347, in boolDiff
File "...\AppData\Local\Programs\Python\Python312\Lib\site-packages\trimesh-4.2.0-py3.12.egg\trimesh\boolean.py", line 45, in difference
raise ValueError("Not all meshes are volumes!")
ValueError: Not all meshes are volumes!

I can't figure out how to hunt down the issue, no matter how hard I try.

Hatches being output in unexpected order

Here's a short video to demonstrate:
Animation

I want the vectors to be output strictly top-right to bottom-left (the direction of the hatch angle, or 90deg from it - you get the gist). However, I'm seeing that some vectors entirely below the hole are being output before some vectors to the right of the hole. I want vectors directly parallel, across from each other across the hole, to be burned one right after another, so you get a nice, linear progression down and to the left (in this example).

Any idea what's going on here? Am I right to assume this could be remedied by LinearSort (which I've submitted a separate issue for, as I think it's flawed)?

Thank you!

libEGL warning DRI2 failed to authenticate

(base) oemSurface-Pro:~/qTdemo$ /usr/bin/python3 /home/oem/qTdemo/pyslm/examples/example 3d.py
Hatching started
Completed Hatching
libEGL warning: DRI2: failed to authenticate

Using the pyslm.hatching.*Hatcher with shapely object as input

Hi,
i'm trying to use some of the pySLM methods to do some basic hatching for robot tool path generation (there are not so many hatching implementation out there).

The idea is to create a shapely.Polygon oder shapely.LineString from a set of arbitrary points (x,y).
Then i like to feed this polygon into one of the Hatchers from pySLM.

The examples use getVectorSlice() for generating input for the .hatch() method.

Can i generate the input for hatching from shapely Objects?
Or would it be possible to generate input directly based on some list of points that describe a polygon?

The whole point is to generate paths for some laser cladding application, where the surface boundaries are extracted from some CAD document via FreeCAD.

Index error:index 2 is out of bounds for axis 2 with size 2

"""
A simple example showing how t use PySLM for generating a Stripe Scan Strategy across a single layer.
"""
import pyclipper
import sys
sys.path.insert(0,r'C:\Program Files\Python\Python310\Lib\site-packages')
import numpy as np
import pyslm.pyslm
import pyslm.pyslm.analysis.utils as analysis
import pyslm.pyslm.hatching as hatching

Imports the part and sets the geometry to an STL file (frameGuide.stl)

solidPart = pyslm.pyslm.Part('cylinder')
solidPart.setGeometry(r'C:\Users\wdkxn9\Downloads\trimesh-main\trimesh-main\models\cylinder.stl')

"""
Transform the part:
Rotate the part 30 degrees about the Z-Axis - given in degrees
Translate by an offset of (5,10) and drop to the platform the z=0 Plate boundary
"""
solidPart.origin = [5.0, 10.0, 0.0]
solidPart.rotation = np.array([0, 0, 30])
solidPart.dropToPlatform()

print(solidPart.boundingBox)

Set te slice layer position

z = 1.0

Create a BasicIslandHatcher object for performing any hatching operations (

myHatcher = hatching.BasicIslandHatcher()
myHatcher.islandWidth = 3.0
myHatcher.stripeWidth = 5.0

Set the base hatching parameters which are generated within Hatcher

myHatcher.hatchAngle = 10 # [°] The angle used for the islands
myHatcher.volumeOffsetHatch = 0.08 # [mm] Offset between internal and external boundary
myHatcher.spotCompensation = 0.06 # [mm] Additional offset to account for laser spot size
myHatcher.numInnerContours = 2
myHatcher.numOuterContours = 1
myHatcher.hatchSortMethod = hatching.AlternateSort()

"""
Perform the slicing. Return coords paths should be set so they are formatted internally.
This is internally performed using Trimesh to obtain a closed set of polygons.
The boundaries of the slice can be automatically simplified if desired.
"""

geomSlice = solidPart.getVectorSlice(z, simplificationFactor=0.1)
layer = myHatcher.hatch(geomSlice)

on above code, the error on line: layer = myHatcher.hatch(geomSlice)

Are you competing in https://github.com/AmericaMakes/OASIS-Challenge-Baseline-Code-and-Models

Are you competing in https://github.com/AmericaMakes/OASIS-Challenge-Baseline-Code-and-Models challenge. I am competing and have build a very similar program with different scan strategies and have build the output layer files very similar to yours but I am having difficulties converting it into the open-source XML format which can be used for laser fusion additive builds. I am looking actually looking to use the open-source XML format with a open source microcontroller that runs on LabView that takes in these files and build the machine build file. If you have any concern on copyright about using your codebase as inspiration, I can resolve that.

Hatcher class missing str() method

When trying to call str() on a Hatcher, it errors out with the following message:

return 'BaseHatcher <{:s}>'.format(self.name)
AttributeError: 'Hatcher' object has no attribute 'name'

Looking at the code, this is due to it missing a str() method like the rest of the example hatcher classes have.

Debug Output in Release Version

Hello,

While testing a fresh install of the library, there seems to be a lot of what equates to debug output (ignore the "Processing Layers"; that's just tqdm):
image

Is this intentional, or is there a good reason for this? I'd think output like this isn't useful to the end user and would be better off deleted or optionally enabled. It's messing with my tqdm progress bars and I wanted to double-check if there is a specific reason why this is still around in the library, particularly on the master branch. Note that I built from source to achieve this result; I have no idea if the PyPi version would exhibit this behavior.

Numba usage?

I'm unsure if it's already implemented, but have you considered implementing parts of the library in Numba? It's is a library works in conjunction with Numpy that essentially implements JIT compilation in Python, speeding up loops and simple functions. The downside is that you have to write code in a style similar to C, but you can essentially selectively enable the library to only run on certain code blocks, which is done pretty simply via decorators.

PySLM: Migrate to Shapely 2.0

PySLM 0.5 is not currently compatible with the latest release of Shapely.

Updates and methods to retain backwards compatibility will be required.

Compatibility with Python 3.11

Python 3.11 - released in March 2023, introduces signifiant changes to the underlying codebase for performance enhancement that are not equivalent to a minor release. This has a knock-on effect which affects the build tool-chain (setup.py, cython). Additionally, this results in various incompatibilities across various sub-packages (triangle, pyclipper) that may cause PySLM to not build successfully.

.rdn format generation and reading build files

Hi,
I wanted to know if there is any python example code to read and compile a .rdn file from Realizer, as well as the .rea file format. I only saw the .mtt format available.
Thank you

Error Installing PythonSLM from PyPi

I have a bit of an interesting environment. I am trying to bundle all the requirements for pyslm into a portable Python installation, as I'm essentially building a UI that wraps around my organization's infrastructure for interfacing with PySLM. I was able to get an embeddable version of Python working with pip by following this guide. I was then able to install 90% of the project dependencies to this embeddable version.

However, pip is running into the following error when it gets to the triangle package:

ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Kal\Documents\cdme-scangen-ui\python\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Kal\\AppData\\Local\\Temp\\pip-install-4oqlhgdx\\triangle_6607d6f5e9b84b9b9d04622fc8215807\\setup.py'"'"'; __file__='"'"'C:\\Users\\Kal\\AppData\\Local\\Temp\\pip-install-4oqlhgdx\\triangle_6607d6f5e9b84b9b9d04622fc8215807\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Kal\AppData\Local\Temp\pip-wheel-020a81mv'
       cwd: C:\Users\Kal\AppData\Local\Temp\pip-install-4oqlhgdx\triangle_6607d6f5e9b84b9b9d04622fc8215807\
  Complete output (115 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.9
  creating build\lib.win-amd64-3.9\triangle
  copying triangle\core1_run.py -> build\lib.win-amd64-3.9\triangle
  copying triangle\data.py -> build\lib.win-amd64-3.9\triangle
  copying triangle\plot.py -> build\lib.win-amd64-3.9\triangle
  copying triangle\tri.py -> build\lib.win-amd64-3.9\triangle
  copying triangle\version.py -> build\lib.win-amd64-3.9\triangle
  copying triangle\__init__.py -> build\lib.win-amd64-3.9\triangle
  creating build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\A.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\bbox.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.2.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.3.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.4.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\diamond_02_00009.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\diamond_02_00009.1.v.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\diamond_02_00009.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\dots.1.v.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\dots.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex.2.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex2.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex2.2.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex3.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex3.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\ell.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\face.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\greenland.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\la.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\spiral.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\spiral.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\spiral.q.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\spiral.r.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\square_circle_hole.1.node -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\A.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\bbox.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.2.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.3.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.4.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\diamond_02_00009.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex.2.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex2.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex2.2.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex3.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\ell.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\face.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\greenland.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\la.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\spiral.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\spiral.q.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\spiral.r.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\square_circle_hole.1.ele -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\A.1.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\A.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.1.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.2.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.3.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.4.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\box.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex.1.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex.2.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex2.1.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex2.2.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex2.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex3.1.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\double_hex3.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\face.1.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\face.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\la.1.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\la.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\square_circle_hole.poly -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\bbox.1.area -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\diamond_02_00009.1.v.edge -> build\lib.win-amd64-3.9\triangle\data
  copying triangle\data\dots.1.v.edge -> build\lib.win-amd64-3.9\triangle\data
  running build_ext
  building 'triangle.core' extension
  creating build\temp.win-amd64-3.9
  creating build\temp.win-amd64-3.9\Release
  creating build\temp.win-amd64-3.9\Release\c
  creating build\temp.win-amd64-3.9\Release\triangle
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DVOID=void -DREAL=double -DNO_TIMER=1 -DTRILIBRARY=1 -DANSI_DECLARATORS=1 -Ic -IC:\Users\Kal\Documents\cdme-scangen-ui\python\include -IC:\Users\Kal\Documents\cdme-scangen-ui\python\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /Tcc/triangle.c /Fobuild\temp.win-amd64-3.9\Release\c/triangle.obj
  triangle.c
  c/triangle.c(3685): warning C4311: 'type cast': pointer truncation from 'triangle *' to 'unsigned long'
  c/triangle.c(3691): warning C4311: 'type cast': pointer truncation from 'triangle *' to 'unsigned long'
  c/triangle.c(3698): warning C4311: 'type cast': pointer truncation from 'triangle *' to 'unsigned long'
  c/triangle.c(3705): warning C4311: 'type cast': pointer truncation from 'triangle *' to 'unsigned long'
  c/triangle.c(3714): warning C4311: 'type cast': pointer truncation from 'vertex' to 'unsigned long'
  c/triangle.c(3721): warning C4311: 'type cast': pointer truncation from 'vertex' to 'unsigned long'
  c/triangle.c(3728): warning C4311: 'type cast': pointer truncation from 'vertex' to 'unsigned long'
  c/triangle.c(3734): warning C4311: 'type cast': pointer truncation from 'subseg *' to 'unsigned long'
  c/triangle.c(3739): warning C4311: 'type cast': pointer truncation from 'subseg *' to 'unsigned long'
  c/triangle.c(3744): warning C4311: 'type cast': pointer truncation from 'subseg *' to 'unsigned long'
  c/triangle.c(3780): warning C4311: 'type cast': pointer truncation from 'subseg *' to 'unsigned long'
  c/triangle.c(3785): warning C4311: 'type cast': pointer truncation from 'subseg *' to 'unsigned long'
  c/triangle.c(3792): warning C4311: 'type cast': pointer truncation from 'subseg *' to 'unsigned long'
  c/triangle.c(3801): warning C4311: 'type cast': pointer truncation from 'vertex' to 'unsigned long'
  c/triangle.c(3808): warning C4311: 'type cast': pointer truncation from 'vertex' to 'unsigned long'
  c/triangle.c(3815): warning C4311: 'type cast': pointer truncation from 'triangle *' to 'unsigned long'
  c/triangle.c(3822): warning C4311: 'type cast': pointer truncation from 'triangle *' to 'unsigned long'
  c/triangle.c(3831): warning C4311: 'type cast': pointer truncation from 'vertex' to 'unsigned long'
  c/triangle.c(3838): warning C4311: 'type cast': pointer truncation from 'vertex' to 'unsigned long'
  c/triangle.c(6966): warning C4244: '=': conversion from 'double' to 'int', possible loss of data
  c/triangle.c(12465): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
  C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DVOID=void -DREAL=double -DNO_TIMER=1 -DTRILIBRARY=1 -DANSI_DECLARATORS=1 -Ic -IC:\Users\Kal\Documents\cdme-scangen-ui\python\include -IC:\Users\Kal\Documents\cdme-scangen-ui\python\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /Tctriangle/core.c /Fobuild\temp.win-amd64-3.9\Release\triangle/core.obj
  core.c
  triangle/core.c(4): fatal error C1083: Cannot open include file: 'Python.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
  ----------------------------------------
  ERROR: Failed building wheel for triangle

I've looked up the fatal part of the error (cannot find Python.h) and, while I can't find anything specifically related to my circumstance (most of it is in context to actually using Visual Studio), it seems related to my installation of the Visual C++ Build Tools, which I understand are a requirement for many of the tools.

The error appears both when I'm trying to install prerequisites for a version of pyslm built from source (our organization has a custom version with minor differences that shouldn't be relevant) and when simply trying to use the PythonSLM version from PyPi. This process works correctly when I am not using the embeddable version - that is, I've gotten the library working in general, just not when I'm trying to package it with a UI application built in Electron that essentially launches the Python script as a child process. Do you have any ideas for how I may go about fixing this?

Installing from PyPI failes as well as from github

I get this error with both kinds of installation, installing from PyPI and github.

How have you worked around this?


Collecting PythonSLM
Using cached PythonSLM-0.4.1.tar.gz (224 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
/usr/lib/python3.11/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /tmp/pip-install-pa6iivme/pythonslm_fbae5b0882424dc7ba28284e7d2c049c/external/pyclipper/pyclipper.pyx
tree = Parsing.p_module(s, pxd, full_module_name)

  Error compiling Cython file:
  ------------------------------------------------------------
  ...
  SCALING_FACTOR = 1
  
  
  def log_action(description):
      if not SILENT:
          print description
                ^
  ------------------------------------------------------------
  
  external/pyclipper/pyclipper.pyx:20:14: Syntax error in simple statement list
  Traceback (most recent call last):
    File "<string>", line 2, in <module>
    File "<pip-setuptools-caller>", line 34, in <module>
    File "/tmp/pip-install-pa6iivme/pythonslm_fbae5b0882424dc7ba28284e7d2c049c/setup.py", line 97, in <module>
      ext_modules=cythonize([ext, extB]),
                  ^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.11/site-packages/Cython/Build/Dependencies.py", line 1154, in cythonize
      cythonize_one(*args)
    File "/usr/lib/python3.11/site-packages/Cython/Build/Dependencies.py", line 1321, in cythonize_one
      raise CompileError(None, pyx_file)
  Cython.Compiler.Errors.CompileError: external/pyclipper/pyclipper.pyx
  Compiling external/pyclipper/pyclipper.pyx because it changed.
  [1/1] Cythonizing external/pyclipper/pyclipper.pyx
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Hatch Order Issues

Hello,

I've been investigating using your library over the course of the last few weeks and am very impressed at what you've put together.

However, I am a little confused by the output and hope you could clarify some things. I am slicing a pretty basic part and doing output like so:

# Create/wipe folder
if not os.path.exists("LayerFiles"):
    os.makedirs("LayerFiles")
else:
    for f in glob.glob("LayerFiles/*"):
        os.remove(f)

# Generate new output
for i in tqdm(range(len(layers)), desc="Generating Plots"):
    fig, ax = plt.subplots()
    PowderBedFusion.visualize.plot(
        layers[i], plot3D=False, plotOrderLine=False, plotHatches=True, plotContours=True, handle=(fig, ax))
    fig.savefig("LayerFiles/Layer{}.png".format(i), bbox_inches='tight')
    plt.cla()
    plt.close(fig)

Whenever I use the basic hatcher, I get the following for a layer:
image

I would expect the colors to range from red to purple (or similar) across the entire part in a smooth progression. This seems to be the case for the top-right of the part, but this seems to fall apart drastically starting at the stripe just left of the maximum diagonal, and I can't really find any rhyme or reason as to why this occurs (edit: doesn't seem to occur for near-horizontal hatch directions).

Along a related vein, I have been experimenting with the implementation of island scanning that comes with the library. It gives me output like the following:
image

While this doesn't look too bad, it seems like the top-right of the bottom few islands would be burned before the bottom-left of the respective islands; the color increment just looks like that would occur. That's not really a criminal issue, but leads up to something else I tried.

I tried to modify the implementation of island scanning as follows to implement a random island order instead:

# Went from this...
for i in np.arange(0, numIslands):
            for j in np.arange(0, numIslands):

# ---------------------------
# To this...
# Generate random order
island_order = np.empty((numIslands ** 2, 2), dtype=int)
idx = 0
for i in np.arange(0, numIslands):
    for j in np.arange(0, numIslands):
        island_order[idx] = np.array([i, j])
        idx += 1
np.random.shuffle(island_order)

# Iterate through islands and gen hatches
for island_coords in island_order:
    i, j = island_coords[0], island_coords[1]

This seems to be all well and good, and runs without crashing. However, I'm confused, because the output looks the same as your implementation of it:
image

I've double-checked that the modified code is being run, that the values of i/j are set correctly, and that the output is regenerated from the modified code. Ideally the "heatmap" progression would jump from island to island at random, but unfortunately it seems like that's just top to bottom.

Whether that's related to the first issue or not, I'm unsure. I'm hoping you can comment on if this is an issue with the library itself, the way you interface with matplotlib, or an issue with how I've hooked into pyslm.

For reference, here is the part I'm testing with. GitHub didn't let me upload a raw .STL so I zipped it.
Parameter_quality_nut_2.zip

Thank you for your work and for your input! I'm hoping to potentially link this into a larger architecture with some real machines if pyslm ends up fitting my use case well, just currently trying to get my bearings with how the library works.

Unexpected Slicing and Hatching result

Hey,

For some models i got an unexpected result after using the slicing and hatching algorithm. I used a slightly modified version of your "example_3d_multithread.py" script as a template to visualise the unexpected results for you:

expected Result:
GoodResult

unexpected Result:
BadResult

As you can see some areas are closed incorrectly in some layers within the model. I dont know exactly how to fix this problem and if this is an issue with the model itself (model should be watertight), the slicing algorithm or the hatching algorithm. Maybe you have some ideas. You can find the used source code and the *.stl file below.

ScriptAndModel.zip

"""
A simple example showing how to use PySLM for generating slices across a 3D model.
THhs example takes advantage of the multi-processing module to run across multiple threads.
"""
import pyslm
import pyslm.visualise
from pyslm import hatching as hatching
import numpy as np
import time

from multiprocessing import Manager
from multiprocessing.pool import Pool
from multiprocessing import set_start_method

def calculateLayer(input):
    # Typically the hatch angle is globally rotated per layer by usually 66.7 degrees per layer
    d = input[0]
    zid= input[1]

    layerThickness = d['layerThickness']
    solidPart = d['part']

    # Create a StripeHatcher object for performing any hatching operations
    myHatcher = hatching.Hatcher()

    # Set the base hatching parameters which are generated within Hatcher
    myHatcher.hatchAngle            = 45 + zid * 66.7
    myHatcher.volumeOffsetHatch     = 0.07
    myHatcher.spotCompensation      = 0.1
    myHatcher.numInnerContours      = 0
    myHatcher.numOuterContours      = 1
    myHatcher.hatchDistance         = 0.12
    myHatcher.hatchSortMethod       = hatching.AlternateSort()

    # Slice the boundary
    geomSlice = solidPart.getVectorSlice(zid*layerThickness)

    # Hatch the boundary using myHatcher
    layer = myHatcher.hatch(geomSlice)

    if layer:
        # The layer height is set in integer increment of microns to ensure no rounding error during manufacturing
        layer.z = int(zid*layerThickness * 1000)
        layer.layerId = int(zid)

        return layer
    else:
        return None

def main():
    set_start_method("spawn")

    # Imports the part and sets the geometry to  an STL file (frameGuide.stl)
    solidPart = pyslm.Part('bridge')
    solidPart.setGeometry('bridge_slm_cad.stl')

    solidPart.origin[0]     = 0.0
    solidPart.origin[1]     = 0.0
    solidPart.scaleFactor   = 1.0
    solidPart.rotation      = [0.0, 0.0, 0.0]
    solidPart.dropToPlatform()
    print(solidPart.boundingBox)

    # Set the layer thickness
    layerThickness = 0.03 # [mm]

    #Perform the hatching operations
    print('Hatching Started')

    layers = []

    p = Pool(processes=4)

    d = Manager().dict()
    d['part'] = solidPart
    d['layerThickness'] = layerThickness

    # Rather than give the z position, we give a z index to calculate the z from.
    numLayers = solidPart.boundingBox[5] / layerThickness
    z = np.arange(0, numLayers).tolist()

    # The layer id and manager shared dict are zipped into a list of tuple pairs
    processList = list(zip([d] * len(z), z))

    startTime = time.time()

    # uncomment to test the time processing in single process
    #for pc in processList:
    #   calculateLayer(pc)

    layers = p.map(calculateLayer, processList)

    print('Multiprocessing time {:.1f} s'.format(time.time()-startTime))
    p.close()

    print('Completed Hatching')
    
    return layers


if __name__ == '__main__':
    layers = main()
    
    for k in range(164, 171, 1):
        pyslm.visualise.plotSequential(layers[k])

For some other models i also have something like this for example:

  • defective small contours and a incorrectly closed area
    BadResult_02

ClipperException: The path is invalid for clipping

Hello,

numpyArray.txt
I am using pyslm version = '0.4.2'

If i try to hatch a sliced contour (numpy array is attached within the *.txt file) with the following hatching settings i always got an ClipperException error:

Traceback (most recent call last):

  File "C:\Users\MarcelHeuser\AppData\Local\Temp\ipykernel_6728\2481062967.py", line 18, in <cell line: 18>
    layer = myHatcher.hatch([npArray])

  File "C:\Developer\venvTEST\lib\site-packages\pyslm\hatching\hatching.py", line 929, in hatch
    clippedPaths = self.clipLines(paths, hatches)

  File "C:\Developer\venvTEST\lib\site-packages\pyslm\hatching\hatching.py", line 432, in clipLines
    pc.AddPath(BaseHatcher.scaleToClipper(boundary), pyclipper.PT_CLIP, True)

  File "external\pyclipper\pyclipper.pyx", line 616, in pyclipper.Pyclipper.AddPath

ClipperException: The path is invalid for clipping

I have extracted this contour from a sliced geometry. You can use the code below to reproduce the error.

import numpy as np
from pyslm import hatching as hatching

# load numpy array
npArray = np.load("numpyArray.txt")

# generate Hatcher
myHatcher = hatching.Hatcher()

# Set the base hatching parameters
myHatcher.hatchAngle        = 66.7
myHatcher.volumeOffsetHatch = 0.08
myHatcher.spotCompensation  = 0.025
myHatcher.numInnerContours  = 0
myHatcher.numOuterContours  = 1
myHatcher.hatchDistance     = 0.12
myHatcher.hatchingEnabled   = True
myHatcher.hatchSortMethod   = hatching.AlternateSort()

# Hatch the geomSlice
layer = myHatcher.hatch([npArray])

Do you know what could be the reason for the error?

Best regards,
Marcel

Facing error while running the code

zsh: command not found: import
zsh: command not found: import
zsh: command not found: import
from: can't read /var/mail/pyslm
zsh: number expected
zsh: number expected

Found when I ruined example after installing PythonSLM
% pip install PythonSLM
Requirement already satisfied: PythonSLM in /opt/anaconda3/lib/python3.9/site-packages (0.4.2)
Requirement already satisfied: triangle in /opt/anaconda3/lib/python3.9/site-packages (from PythonSLM) (20200424)
Requirement already satisfied: numpy in /opt/anaconda3/lib/python3.9/site-packages (from PythonSLM) (1.20.3)
Requirement already satisfied: setuptools in /opt/anaconda3/lib/python3.9/site-packages (from PythonSLM) (58.0.4)
Requirement already satisfied: shapely in /opt/anaconda3/lib/python3.9/site-packages (from PythonSLM) (1.8.0)
Requirement already satisfied: trimesh in /opt/anaconda3/lib/python3.9/site-packages (from PythonSLM) (3.9.35)
Requirement already satisfied: cython in /opt/anaconda3/lib/python3.9/site-packages (from PythonSLM) (0.29.24)

Please help me out

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.