[Bug, SOLVED] Multiple elliptic cuts on different depth levels
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
[Bug, SOLVED] Multiple elliptic cuts on different depth levels
There appears to be a bug in the TechDraw module, when a part contains several elliptic cuts overlapping on different depth levels. Everything works fine, if there's only one elliptic cut in the projected part, but something seems to break if there are several ellipses. I hope the attached files shed some light to my not-so-clear explanation. If the part happens to be more complicated, everything may become really unintelligible in the TechDraw workbench.
Best regards,
Aapo
An example of a simple part triggering the problem, made with the PartDesign workbench: A problem occurs in the TechDraw workbench, and one part of the projected ellipses becomes a circle with weird radius and center.
Best regards,
Aapo
An example of a simple part triggering the problem, made with the PartDesign workbench: A problem occurs in the TechDraw workbench, and one part of the projected ellipses becomes a circle with weird radius and center.
- Attachments
-
- FreeCAD_techdraw_bug.fcstd
- (64.15 KiB) Downloaded 74 times
Last edited by aapo on Wed Nov 14, 2018 10:01 am, edited 2 times in total.
Re: [Bug?] Multiple elliptic cuts on different depth levels
Hi aapo, and welcome to FreeCAD! Thanks for your report too!
Please attach the version info from your copy of FreeCAD - there's a nice writeup in the Help forum about how to get the right info in the proper format.
Please attach the version info from your copy of FreeCAD - there's a nice writeup in the Help forum about how to get the right info in the proper format.
Re: [Bug?] Multiple elliptic cuts on different depth levels
Thanks! And sorry about forgetting to post the version information. It's below, and I also tested with a recent Windows build from the website, and the same happened with that. Copy-paste from the about dialog:
EDIT: Hmm, I noticed that I've accidentally built against OCE 6.9 on Linux, instead of the OCCT 7.3 I should have. I'll rebuild and retest with the old libraries removed, but as I mentioned, the bug happened on the newest Windows build on the FreeCAD website, too.
OS: Debian GNU/Linux testing (buster)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15099 (Git)
Build type: Release
Branch: master
Hash: 1538a14eca0879be3d223930f7e5f78d4a24691c
Python version: 2.7.15+
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.9.1.oce-0.18
Locale: English/UnitedStates (en_US)
EDIT: Hmm, I noticed that I've accidentally built against OCE 6.9 on Linux, instead of the OCCT 7.3 I should have. I'll rebuild and retest with the old libraries removed, but as I mentioned, the bug happened on the newest Windows build on the FreeCAD website, too.
OS: Debian GNU/Linux testing (buster)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15099 (Git)
Build type: Release
Branch: master
Hash: 1538a14eca0879be3d223930f7e5f78d4a24691c
Python version: 2.7.15+
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.9.1.oce-0.18
Locale: English/UnitedStates (en_US)
Re: [Bug?] Multiple elliptic cuts on different depth levels
I tested again on Linux with OCC version 7.3.0, and the same problem occurs.
OS: Debian GNU/Linux testing (buster)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15099 (Git)
Build type: Release
Branch: master
Hash: 1538a14eca0879be3d223930f7e5f78d4a24691c
Python version: 2.7.15+
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
OS: Debian GNU/Linux testing (buster)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15099 (Git)
Build type: Release
Branch: master
Hash: 1538a14eca0879be3d223930f7e5f78d4a24691c
Python version: 2.7.15+
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedStates (en_US)
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [Bug?] Multiple elliptic cuts on different depth levels
Fix is building now. The problem was in the routine that tries to determine if a BSpline should be treated as a Circle.
Thanks for catching this one.
wf
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [Bug?] Multiple elliptic cuts on different depth levels
git commit 408c31634f merged to master branch.
- wandererfan
- Veteran
- Posts: 6326
- Joined: Tue Nov 06, 2012 5:42 pm
- Contact:
Re: [Bug?] Multiple elliptic cuts on different depth levels
Thanks for the fix! I can confirm that the fix in github also works for me, and I get basically the same, expected result after rebuilding.
Re: [Bug?] Multiple elliptic cuts on different depth levels
I'll revisit this subject slightly, as I believe there's another bug in the TechDraw module. With the same FCSTD example file as above, if one selects "Iso Count = 1" from the UI, the ellipses are again malformed:
I wrote a small patch, where the crucial matter are the lines containing the checks for GeomAPI_ProjectPointOnCurve.NbPoint():. As per https://www.opencascade.com/doc/occt-7. ... 831c9c114b the NbPoints() in GeomAPI_ProjectPointOnCurve always returns zero in failures (and apparently the class makes an expection with failed call to NearestPoint()?). Anyway, please feel free to use only this part of the patch or some other method to fix the problem, there are unnecessary changes in the patch as I poked at the problem. With the patch, the ellipses are again ok with more ISO points using "Iso Count = 1". I believe this bug affected many more cases, where the splines were small pieces or otherwise difficult for GeomAPI_ProjectPointOnCurve, which caused weird artifacts in some of my more complicated drawings.
Here is the full patch. On an unrelated note, the git head build of FreeCAD TechDraw cannot make any dimensions for me; it always says "Select an object first" even though I have object and edge selected. Is this perhaps being fixed?
EDIT: I guess the proper way to fix this would be to catch the exception with
but I was a bit lazy.
I wrote a small patch, where the crucial matter are the lines containing the checks for GeomAPI_ProjectPointOnCurve.NbPoint():
Code: Select all
@@ -739,9 +736,9 @@ TopoDS_Edge BSpline::isCircle2(bool& arc)
projm.Init(pm, curve, f, l);
// get projected points
- gp_Pnt pc1 = proj1.NearestPoint();
- gp_Pnt pc2 = proj2.NearestPoint();
- gp_Pnt pcm = projm.NearestPoint();
+ gp_Pnt pc1 = (proj1.NbPoints()>0)?proj1.NearestPoint():p1;
+ gp_Pnt pc2 = (proj2.NbPoints()>0)?proj2.NearestPoint():p2;
+ gp_Pnt pcm = (projm.NbPoints()>0)?projm.NearestPoint():pm;
// make 2 circles and find their radii
gce_MakeCirc gce_circ1 = gce_MakeCirc(s,pc1,pcm); //3 point circle
Here is the full patch. On an unrelated note, the git head build of FreeCAD TechDraw cannot make any dimensions for me; it always says "Select an object first" even though I have object and edge selected. Is this perhaps being fixed?
EDIT: I guess the proper way to fix this would be to catch the exception with
Code: Select all
try {
...
} catch(const StdFail_NotDone &e) {
... some cleanup ...
}
Re: [Bug?] Multiple elliptic cuts on different depth levels
It turns out that just catching the exception and returning an empty TopoDS_Edge on failure is enough, just like earlier in the same function if there are not enough poles on the spline. So I wrote a minimal patch to catch the exception, this will also fix the bug with just a few changes:
Code: Select all
diff --git a/src/Mod/TechDraw/App/Geometry.cpp b/src/Mod/TechDraw/App/Geometry.cpp
index 0ceb5dac3..000b3fd6e 100644
--- a/src/Mod/TechDraw/App/Geometry.cpp
+++ b/src/Mod/TechDraw/App/Geometry.cpp
@@ -739,9 +739,14 @@ TopoDS_Edge BSpline::isCircle2(bool& arc)
projm.Init(pm, curve, f, l);
// get projected points
- gp_Pnt pc1 = proj1.NearestPoint();
- gp_Pnt pc2 = proj2.NearestPoint();
- gp_Pnt pcm = projm.NearestPoint();
+ gp_Pnt pc1, pc2, pcm;
+ try {
+ pc1 = proj1.NearestPoint();
+ pc2 = proj2.NearestPoint();
+ pcm = projm.NearestPoint();
+ } catch(const StdFail_NotDone &e) {
+ return result;
+ }
// make 2 circles and find their radii
gce_MakeCirc gce_circ1 = gce_MakeCirc(s,pc1,pcm); //3 point circle