Torus/Cylinder Union Problem

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
Trygon
Posts: 8
Joined: Sun Feb 19, 2017 3:47 pm

Torus/Cylinder Union Problem

Post by Trygon »

I have been having trouble importing an OpenSCAD model into FreeCAD (it renders with no issues in OpenSCAD). I have isolated the problem to a union between a cylinder and torus:
test01_scad1.png
test01_scad1.png (9.3 KiB) Viewed 1361 times
test01_scad2.png
test01_scad2.png (26.54 KiB) Viewed 1361 times
I have tried importing the OpenSCAD script into both V16 and V17 of FreeCAD with different results:
test01_v16.png
test01_v16.png (15.79 KiB) Viewed 1361 times
test01_v17.png
test01_v17.png (9.96 KiB) Viewed 1361 times
The OpenSCAD script is attached.

Any help appreciated, thanks.

====================

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6706 (Git)
Build type: Release
Branch: releases/FreeCAD-0-16
Hash: f86a4e411ff7848dea98d7242f43b7774bee8fa0
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10235 (Git)
Build type: Release
Branch: master
Hash: e5fe3d8e107bc604bc868922d82f5fb3611cdd93
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
Attachments
test01.scad
(195 Bytes) Downloaded 19 times
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Torus/Cylinder Union Problem

Post by DeepSOIC »

Hi!
From the screenshot, it looks like the surface of the torus is touching the top face of the cylinder. Tangent intersections are known to be a problem for Boolean operations, and it's best to avoid them.

You can try to increase the height of the cylinder, do the fusion, and cut away the protruding part of the cylinder afterwards. Or simply move the torus by an insignificant distance like 1um, that may fix it.
Trygon
Posts: 8
Joined: Sun Feb 19, 2017 3:47 pm

Re: Torus/Cylinder Union Problem

Post by Trygon »

Hi DeepSOIC,

Thanks for your thoughts, yes the torus is coincident with the end surface of the cylinder. I tried your idea of extending the cylinder then cutting it back:
test02_scad2.png
test02_scad2.png (11.02 KiB) Viewed 1345 times
It looks better, but unfortunately the cut for the cube fails (both in v16 & v17):
test02_v16.png
test02_v16.png (14.7 KiB) Viewed 1345 times
:(
Attachments
test02_v17.FCStd
(31.34 KiB) Downloaded 24 times
test02.scad
(292 Bytes) Downloaded 19 times
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Torus/Cylinder Union Problem

Post by DeepSOIC »

Try using another cylinder to chop the top off. Tangent intersections are a problem, but coincident geometry is usually tolerated rather good. It works for me on:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10665 (Git)
Build type: Release
Branch: master
Hash: 47847513a85ff6615774ef628230f79e37471daf
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
cylinder-fuse-torus.png
cylinder-fuse-torus.png (282.71 KiB) Viewed 1342 times
cylinder-fuse-torus.FCStd
(28.88 KiB) Downloaded 21 times
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Torus/Cylinder Union Problem

Post by DeepSOIC »

I just tried it on your file. At first it failed, but force recompute made it work. (see Macro ForceRecompute)
Trygon
Posts: 8
Joined: Sun Feb 19, 2017 3:47 pm

Re: Torus/Cylinder Union Problem

Post by Trygon »

OK I will look at forcing a recomputation thanks.

Your file worked for me too, as does a modified version that cuts off the top of the cylinder using a cube:
cylinder-fuse-torus2_1.png
cylinder-fuse-torus2_1.png (4.32 KiB) Viewed 1333 times
cylinder-fuse-torus2_2.png
cylinder-fuse-torus2_2.png (8.78 KiB) Viewed 1333 times
However an OpenSCAD version with the cut performed with a cylinder of the same radius fails:
test03_v17.png
test03_v17.png (4.86 KiB) Viewed 1333 times
...but recompute may fix as you suggest.
Attachments
test03.scad
(291 Bytes) Downloaded 18 times
cylinder-fuse-torus2.FCStd
(31.71 KiB) Downloaded 22 times
Trygon
Posts: 8
Joined: Sun Feb 19, 2017 3:47 pm

Re: Torus/Cylinder Union Problem

Post by Trygon »

Yes you are right, forcing a recompute (v17: pick "Mark to recompute" from context menu) does fix the model, but it has to be saved and then re-opened first; oddly importing the OpenSCAD script and immediately forcing a recompute does not work.

Also my first OpenSCAD script that unions a cylinder of the correct size directly with the torus cannot be fixed by forcing a recompute.

All your help is much appreciated.

-Trygon
jmaustpc
Veteran
Posts: 11207
Joined: Tue Jul 26, 2011 6:28 am
Location: Australia

Re: Torus/Cylinder Union Problem

Post by jmaustpc »

Trygon wrote:oddly importing the OpenSCAD script and immediately forcing a recompute does not work.
The recompute only fixes something if the underlying cause of the problem is changed, and then it can be repaired/recreated by recompute.

Note that this sort of issue with tangent and coplanar surfaces and booleans is often a weakness in the OCC/OCE CAD kernel used by FreeCAD, and your two different FreeCAD versions have been compiled with different OCC versions. Both versions are now out of date, you generally have to compile more recent versions and then FreeCAD yourself if you want a newer version of OCC than the version offered for your o/s. Tangent and coplanar surfaces are best to avoid in your model, as DeepSOIC said.
Post Reply