Skip to content

Commit 2f46d42

Browse files
Merge pull request #147 from compas-dev/igl_functions
Igl functions
2 parents e44a382 + c1bf22d commit 2f46d42

File tree

22 files changed

+264
-129
lines changed

22 files changed

+264
-129
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Unreleased
1111

1212
**Added**
1313
* Documentation updates
14+
* rdp libigl function
1415

1516
**Changed**
1617

docs/examples/01_planar_slicing_simple.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The first step is to import the required functions:
2626
from compas_slicer.slicers import PlanarSlicer
2727
from compas_slicer.post_processing import generate_brim
2828
from compas_slicer.post_processing import generate_raft
29-
from compas_slicer.post_processing import simplify_paths_rdp
29+
from compas_slicer.post_processing import simplify_paths_rdp_igl
3030
from compas_slicer.post_processing import seams_smooth
3131
from compas_slicer.print_organization import PlanarPrintOrganizer
3232
from compas_slicer.print_organization import set_extruder_toggle
@@ -106,14 +106,14 @@ that are offset from the bottom layer, to improve adhesion to the build plate
106106
raft_layers=1)
107107
108108
Depending on the amount of faces that your input mesh has, a very large amount of
109-
points can be generated. ``simplify_paths_rdp`` is a function that removes points
109+
points can be generated. ``simplify_paths_rdp`` or ``simplify_paths_rdp_igl`` are functions that remove points
110110
that do not have a high impact on the final shape of the polyline. Increase the
111111
threshold value to remove more points, decrease it to remove less. For more
112112
information on how the algorithm works see: `Ramer–Douglas–Peucker algorithm <https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm>`_
113113

114114
.. code-block:: python
115115
116-
simplify_paths_rdp(slicer, threshold=0.6)
116+
simplify_paths_rdp_igl(slicer, threshold=0.6)
117117
118118
Currently the 'seam' between different layers of our shape is a 'hard seam',
119119
the printer would move up almost vertically to move to the next layer.
@@ -213,7 +213,7 @@ The completed final script can be found below:
213213
from compas_slicer.slicers import PlanarSlicer
214214
from compas_slicer.post_processing import generate_brim
215215
from compas_slicer.post_processing import generate_raft
216-
from compas_slicer.post_processing import simplify_paths_rdp
216+
from compas_slicer.post_processing import simplify_paths_rdp_igl
217217
from compas_slicer.post_processing import seams_smooth
218218
from compas_slicer.print_organization import PlanarPrintOrganizer
219219
from compas_slicer.print_organization import set_extruder_toggle
@@ -277,7 +277,7 @@ The completed final script can be found below:
277277
# Simplify the paths by removing points with a certain threshold
278278
# change the threshold value to remove more or less points
279279
# ==========================================================================
280-
simplify_paths_rdp(slicer, threshold=0.6)
280+
simplify_paths_rdp_igl(slicer, threshold=0.6)
281281
282282
# ==========================================================================
283283
# Smooth the seams between layers

docs/examples/02_curved_slicing_simple.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Imports and initialization
2929
import logging
3030
import compas_slicer.utilities as utils
3131
from compas_slicer.slicers import InterpolationSlicer
32-
from compas_slicer.post_processing import simplify_paths_rdp
32+
from compas_slicer.post_processing import simplify_paths_rdp_igl
3333
from compas_slicer.pre_processing import InterpolationSlicingPreprocessor
3434
from compas_slicer.print_organization import set_extruder_toggle, set_linear_velocity_by_range
3535
from compas_slicer.print_organization import add_safety_printpoints
@@ -104,7 +104,7 @@ options are available for all slicers.
104104
# post processing
105105
generate_brim(slicer, layer_width=3.0, number_of_brim_offsets=5)
106106
seams_smooth(slicer, smooth_distance=10)
107-
simplify_paths_rdp(slicer, threshold=1.0)
107+
simplify_paths_rdp_igl(slicer, threshold=1.0)
108108
slicer.printout_info()
109109
utils.save_to_json(slicer.to_data(), OUTPUT_PATH, 'curved_slicer.json')
110110
@@ -166,7 +166,7 @@ The completed final script can be found below:
166166
import logging
167167
import compas_slicer.utilities as utils
168168
from compas_slicer.slicers import InterpolationSlicer
169-
from compas_slicer.post_processing import simplify_paths_rdp
169+
from compas_slicer.post_processing import simplify_paths_rdp_igl
170170
from compas_slicer.pre_processing import InterpolationSlicingPreprocessor
171171
from compas_slicer.print_organization import set_extruder_toggle, set_linear_velocity_by_range
172172
from compas_slicer.print_organization import add_safety_printpoints
@@ -217,7 +217,7 @@ The completed final script can be found below:
217217
generate_brim(slicer, layer_width=3.0, number_of_brim_offsets=5)
218218
seams_smooth(slicer, smooth_distance=10)
219219
220-
simplify_paths_rdp(slicer, threshold=1.0)
220+
simplify_paths_rdp_igl(slicer, threshold=0.5)
221221
slicer.printout_info()
222222
utils.save_to_json(slicer.to_data(), OUTPUT_PATH, 'curved_slicer.json')
223223

docs/examples/03_planar_slicing_vertical_sorting.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ the default method. The example below demonstrates how planar paths can be sorte
2828
from compas_slicer.pre_processing import move_mesh_to_point
2929
from compas_slicer.slicers import PlanarSlicer
3030
from compas_slicer.post_processing import generate_brim
31-
from compas_slicer.post_processing import simplify_paths_rdp
31+
from compas_slicer.post_processing import simplify_paths_rdp_igl
3232
from compas_slicer.post_processing import sort_into_vertical_layers
3333
from compas_slicer.post_processing import reorder_vertical_layers
3434
from compas_slicer.post_processing import seams_smooth
@@ -69,7 +69,7 @@ the default method. The example below demonstrates how planar paths can be sorte
6969
7070
# Post-processing
7171
generate_brim(slicer, layer_width=3.0, number_of_brim_offsets=5)
72-
simplify_paths_rdp(slicer, threshold=0.7)
72+
simplify_paths_rdp_igl(slicer, threshold=0.7)
7373
seams_smooth(slicer, smooth_distance=10)
7474
slicer.printout_info()
7575
save_to_json(slicer.to_data(), OUTPUT_DIR, 'slicer_data.json')

docs/examples/04_gcode_generation.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ to materialize them in a typical desktop 3D printer. The gcode generation is sti
1616
from compas_slicer.pre_processing import move_mesh_to_point
1717
from compas_slicer.slicers import PlanarSlicer
1818
from compas_slicer.post_processing import generate_brim
19-
from compas_slicer.post_processing import simplify_paths_rdp
19+
from compas_slicer.post_processing import simplify_paths_rdp_igl
2020
from compas_slicer.post_processing import seams_smooth
2121
from compas_slicer.print_organization import PlanarPrintOrganizer
2222
from compas_slicer.print_organization import set_extruder_toggle
@@ -49,7 +49,7 @@ to materialize them in a typical desktop 3D printer. The gcode generation is sti
4949
slicer = PlanarSlicer(compas_mesh, slicer_type="cgal", layer_height=4.5)
5050
slicer.slice_model()
5151
generate_brim(slicer, layer_width=3.0, number_of_brim_offsets=4)
52-
simplify_paths_rdp(slicer, threshold=0.6)
52+
simplify_paths_rdp_igl(slicer, threshold=0.6)
5353
seams_smooth(slicer, smooth_distance=10)
5454
slicer.printout_info()
5555
save_to_json(slicer.to_data(), OUTPUT_DIR, 'slicer_data.json')

docs/examples/05_non_planar_slicing_on_custom_base.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ vertex of the mesh. In this case we create a scalar field with the distance of e
2222
from compas.datastructures import Mesh
2323
import os
2424
import compas_slicer.utilities as slicer_utils
25-
from compas_slicer.post_processing import simplify_paths_rdp
25+
from compas_slicer.post_processing import simplify_paths_rdp_igl
2626
from compas_slicer.slicers import ScalarFieldSlicer
2727
import compas_slicer.utilities as utils
2828
from compas_slicer.print_organization import ScalarFieldPrintOrganizer
@@ -57,11 +57,10 @@ vertex of the mesh. In this case we create a scalar field with the distance of e
5757
# --- Slice model by generating contours of scalar field
5858
slicer = ScalarFieldSlicer(mesh, u, no_of_isocurves=50)
5959
slicer.slice_model()
60-
# simplify_paths_rdp(slicer, threshold=0.3)
6160
slicer_utils.save_to_json(slicer.to_data(), OUTPUT_PATH, 'isocontours.json') # save results to json
6261
6362
# --- Print organization calculations (i.e. generation of printpoints with fabrication-related information)
64-
simplify_paths_rdp(slicer, threshold=0.3)
63+
simplify_paths_rdp_igl(slicer, threshold=0.3)
6564
print_organizer = ScalarFieldPrintOrganizer(slicer, parameters={}, DATA_PATH=DATA_PATH)
6665
print_organizer.create_printpoints()
6766

docs/examples/06_attributes_transfer.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ barycentric coordinates.
2525
from compas.geometry import Point, Vector, distance_point_plane, normalize_vector
2626
from compas.datastructures import Mesh
2727
import compas_slicer.utilities as slicer_utils
28-
from compas_slicer.post_processing import simplify_paths_rdp
28+
from compas_slicer.post_processing import simplify_paths_rdp_igl
2929
from compas_slicer.slicers import PlanarSlicer
3030
import compas_slicer.utilities.utils as utils
3131
from compas_slicer.utilities.attributes_transfer import transfer_mesh_attributes_to_printpoints
@@ -77,7 +77,7 @@ barycentric coordinates.
7777
# --------------- Slice mesh
7878
slicer = PlanarSlicer(mesh, slicer_type="default", layer_height=5.0)
7979
slicer.slice_model()
80-
simplify_paths_rdp(slicer, threshold=1.0)
80+
simplify_paths_rdp_igl(slicer, threshold=1.0)
8181
slicer_utils.save_to_json(slicer.to_data(), OUTPUT_PATH, 'slicer_data.json')
8282
8383
# --------------- Create printpoints

docs/installation.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,17 @@ Make sure you are in the correct environment and type:
107107
.. code-block:: bash
108108
109109
pip install numpy==1.19.3
110+
111+
Fractions error
112+
-----------
113+
.. code-block:: bash
114+
115+
ImportError: cannot import name 'gcd' from 'fractions' (C:\ProgramData\Anaconda3\envs\compas_slicer\lib\fractions.py)
116+
117+
This issue can be solved, as explained here: https://stackoverflow.com/questions/66174862/import-error-cant-import-name-gcd-from-fractions
118+
by typing the following command (make sure you are in the correct environment)
119+
120+
.. code-block:: bash
121+
122+
conda install -c conda-forge networkx=2.5
123+

examples/1_planar_slicing_simple/example_1_planar_slicing_simple.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from compas_slicer.slicers import PlanarSlicer
88
from compas_slicer.post_processing import generate_brim
99
from compas_slicer.post_processing import generate_raft
10-
from compas_slicer.post_processing import simplify_paths_rdp
10+
from compas_slicer.post_processing import simplify_paths_rdp_igl
1111
from compas_slicer.post_processing import seams_smooth
1212
from compas_slicer.print_organization import PlanarPrintOrganizer
1313
from compas_slicer.print_organization import set_extruder_toggle
@@ -72,7 +72,7 @@ def main():
7272
# Simplify the paths by removing points with a certain threshold
7373
# change the threshold value to remove more or less points
7474
# ==========================================================================
75-
simplify_paths_rdp(slicer, threshold=0.6)
75+
simplify_paths_rdp_igl(slicer, threshold=0.6)
7676

7777
# ==========================================================================
7878
# Smooth the seams between layers

examples/2_curved_slicing/ex2_curved_slicing_advanced.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44
import compas_slicer.utilities as utils
55
from compas_slicer.slicers import InterpolationSlicer
6-
from compas_slicer.post_processing import simplify_paths_rdp
6+
from compas_slicer.post_processing import simplify_paths_rdp_igl
77
from compas_slicer.pre_processing import InterpolationSlicingPreprocessor
88
from compas_slicer.pre_processing import create_mesh_boundary_attributes
99
from compas_slicer.print_organization import InterpolationPrintOrganizer
@@ -86,7 +86,7 @@ def main():
8686
generate_brim(slicer, layer_width=3.0, number_of_brim_offsets=5)
8787

8888
seams_smooth(slicer, smooth_distance=0.1)
89-
simplify_paths_rdp(slicer, threshold=0.25)
89+
simplify_paths_rdp_igl(slicer, threshold=0.25)
9090
utils.save_to_json(slicer.to_data(), OUTPUT_PATH, 'curved_slicer_%d.json' % i)
9191
slicers.append(slicer)
9292

0 commit comments

Comments
 (0)