SVG creation in Cadquery

205 views
Skip to first unread message

Raub Camaioni

unread,
Oct 9, 2023, 7:47:34 PM10/9/23
to CadQuery
Loving cadquery,

I created some code to convert SVGs to Cadquery Faces. 
I am experiencing some issues with missing faces during the cutting process. 
Some viewers don't show holes: viewstl.com always show a complete model.
image shows: svg, viewstl.com, meshlab
faces_missing.jpg
I would expect OCCT to handle simple cuts out of a block. 
I must be doing something wrong.
I have produced the cutting objects by lofting and thickening, both show the same error. 

How would an experienced cadquery dev isolate the issue?
I could isolate the problem cuts and find the minimal code to reproduce error. 
I want to check with community first to see if there is a known error/bug. 

Any methods to improve cut quality/speed?
I preform each cut individually and reduce them to the same solid. 
Preforming cuts with compound objects can sometimes fail on complex objects.

I have a wide range of SVG cuts that exhibit this problem.
Sometimes reducing the fidelity of the SVG can fix the problem. 

Things that might cause the issue? (guessing)
Duplicate points in the wire definition.
Cut boundaries very close to each other. 
The missing back face are always accompanied by missing side faces. 

-Raub
face_1696808239_blobs.stl
solid_1696808239_blobs.stl

Jeremy Wright

unread,
Oct 10, 2023, 9:33:25 AM10/10/23
to Raub Camaioni, CadQuery
Do you know if viewstl.com repairs the meshes automatically? That could be why it shows a complete model when meshlab doesn't.

Can you isolate one profile from the SVG that doesn't show the back faces and try cutting it by itself out of a block to see if the problem persists? Shapes in CadQuery have an isValid() function that you can call to see if there is a problem with the shape before exporting. Self-intersecting geometry and invalid wires used for cutting would be two suspects I would look at.

--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cadquery/94d3b5c6-ca60-4791-b6ad-ad9f0e89dcd9n%40googlegroups.com.

Raub Camaioni

unread,
Oct 10, 2023, 8:47:59 PM10/10/23
to CadQuery
There was self-intersection geometry.  The SVG files were created poorly. 

I use the following algorithm to "repair" the face. 
-turn list of self-intersecting points into multiple individual faces
-calculate total area of all faces
-remove faces less than 1% total size

depends on python shapely
lineString = LineString(self_intersection_points)
unary = unary_union(lineString)
polygons = list(polygonize(unary))
total_area01 = sum([p.area for p in polygons]) * .01
polygons = filter(polygons, lambda p: p.area < total_area01)

Is there a list of standard 3D model / 2D Face repair algorithms?
Any plan on repair algorithms in cadquery?

My problem is solved.
The faces are properly cut and meshlab / other viewers render correctly.  
meshlab_fixed.jpg

Thank you, 
Raub Camaioni

Jeremy Wright

unread,
Oct 11, 2023, 9:37:47 AM10/11/23
to Raub Camaioni, CadQuery
>  Any plan on repair algorithms in cadquery?

There are PRs here and there to fix things like improper edge ordering and other bugs. If there are built-in repair functions within OpenCASCADE those are good candidates to be wrapped into CadQuery, but I don't know of any specific efforts right now to search those out and include them.

We have issue labels for issues that are related to kernel and modelling bugs, i.e. https://github.com/CadQuery/cadquery/labels/OCC%20kernel%20issue



Reply all
Reply to author
Forward
0 new messages