[Solved]Geom_BSplineCurve::Segment error

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
davecoventry
Posts: 286
Joined: Mon Dec 09, 2013 8:11 pm
Location: Johannesburg
Contact:

[Solved]Geom_BSplineCurve::Segment error

Post by davecoventry »

I'm getting a Geom_BSplineCurve::Segment error when I try to generate a view in the Drawing Workbench.

Is there any way of finding the component which is causing the error? I have around 500 components in the compound collection.

Is there possibly a debug mode that would give me an idea of where in my model the error occurs, either by printing out on the console or are there error logs?

OS: Debian GNU/Linux 9.7 (stretch)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15103 (Git)
Build type: Release
Branch: master
Hash: cd34f3d12789e2a3d7818e2b16aca7da3870a406
Python version: 2.7.13
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Locale: English/SouthAfrica (en_ZA)
Last edited by davecoventry on Wed Sep 25, 2019 6:37 am, edited 1 time in total.
~ Dave
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Geom_BSplineCurve::Segment error

Post by Joel_graff »

davecoventry wrote: Fri Jun 07, 2019 11:12 am Is there possibly a debug mode that would give me an idea of where in my model the error occurs, either by printing out on the console or are there error logs?
Have you enabled the Report View panel? (View -> Panels -> Report View)
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
User avatar
davecoventry
Posts: 286
Joined: Mon Dec 09, 2013 8:11 pm
Location: Johannesburg
Contact:

Re: Geom_BSplineCurve::Segment error

Post by davecoventry »

Thanks.

I'll try that.

Edit: The Report panel remains blank.
~ Dave
User avatar
davecoventry
Posts: 286
Joined: Mon Dec 09, 2013 8:11 pm
Location: Johannesburg
Contact:

Re: Geom_BSplineCurve::Segment error

Post by davecoventry »

This problem continues to cause me problems.

I have partially solved it by incrementally adding elements to my compound part until the error occurs, but this is time consuming.

With my last model, however, I solved the errors in the plan and side elevation, only to find that the end elevation had multiple errors which occurred seemingly arbitrarily. ie. if found that the compound which had previously been error free were now reporting errors.

If there was some way to identify an element that was giving problems, this would help a lot.
~ Dave
User avatar
davecoventry
Posts: 286
Joined: Mon Dec 09, 2013 8:11 pm
Location: Johannesburg
Contact:

Re: Geom_BSplineCurve::Segment error

Post by davecoventry »

Just to add that I've just seen these errors in the CLI:

Code: Select all

Exception (Mon Sep 23 09:28:21 2019): GeomAPI_ProjectPointOnCurve::LowerDistanceParameter In bool Part::GeomCurve::closestParameter(const Vector3d&, double&) const in src/Mod/Part/App/Geometry.cpp:548 
Exception (Mon Sep 23 09:28:21 2019): GeomAPI_ProjectPointOnCurve::LowerDistanceParameter In bool Part::GeomCurve::closestParameter(const Vector3d&, double&) const in src/Mod/Part/App/Geometry.cpp:548 
Exception (Mon Sep 23 09:28:22 2019): GeomAPI_ProjectPointOnCurve::LowerDistanceParameter In bool Part::GeomCurve::closestParameter(const Vector3d&, double&) const in src/Mod/Part/App/Geometry.cpp:548 
Exception (Mon Sep 23 09:28:22 2019): GeomAPI_ProjectPointOnCurve::LowerDistanceParameter In bool Part::GeomCurve::closestParameter(const Vector3d&, double&) const in src/Mod/Part/App/Geometry.cpp:548 
They may be a clue if I knew what I was looking for.

OS: Debian GNU/Linux 9.9 (stretch)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.15103 (Git)
Build type: Release
Branch: master
Hash: cd34f3d12789e2a3d7818e2b16aca7da3870a406
Python version: 2.7.13
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Locale: English/SouthAfrica (en_ZA)
~ Dave
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Geom_BSplineCurve::Segment error

Post by Joel_graff »

That certainly may be a clue. The function triggering the error is:

Code: Select all

Base::Vector3d GeomCurve::pointAtParameter(double u) const
{
    Handle(Geom_Curve) c = Handle(Geom_Curve)::DownCast(handle());
    GeomLProp_CLProps prop(c,u,0,Precision::Confusion());

    const gp_Pnt &point=prop.Value();

    return Base::Vector3d(point.X(),point.Y(),point.Z());
}
Specifically, the exception is thrown when it tries to construct the Vector on return (the last line of the function). The function itself is calculating the point given a curve parameter and it appears that the point values are not being calculated correctly (maybe NaN or null values, idk). There's a lot of casting magic going on in that function and my c++ is rusty, so I really can't say what's going on.

With a complex model, the error could be caused by a series of complex relationships and may be quite hard to distinguish. The best way to approach it is to try to reproduce the behavior with a minimum of elements, but, again, that can be difficult to do when you're not sure exactly what's causing it.

The only other thing I can think to do is to 'bisect' the model until the error disappears. Basically, delete half of the model and test for the error. If it recurs, delete half again... repeat until it's gone. That may or may not be feasible in this case, though.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: Geom_BSplineCurve::Segment error

Post by vocx »

davecoventry wrote: Mon Sep 23, 2019 8:01 am ...
Version: 0.18.15103 (Git)
...
Python version: 2.7.13
Qt version: 4.8.7
...
OCC version: 6.8.0.oce-0.17
First of all, don't use the Drawing Workbench because it is outdated. You should use TechDraw Workbench which is actually maintained and actively developed.

Second, you are using an old combination of FreeCAD libraries. The current stable FreeCAD is 0.18.3. It seems you are using a version compiled for Python 2 and Qt4, while the preferred combination today is Python 3 and Qt5.

And more important than that, is that you are using OCE 6.8 as your geometry kernel. This is the library that actually creates shapes on your screen. It provides such Geom_BSplineCurve objects.

You should be using OCCT 7.3 which is the current version. OCCT is the official OpenCASCADE version while OCE is a community edition. FreeCAD no longer recommends the OCE version, because it is outdated. OCCT 7.x includes bug fixes and new features. Maybe your problem goes away simply by using the newer OCCT libraries.

Did you install FreeCAD from Debian's repository? Repositories may have outdated software. In Linux you can try the latest AppImage, as described in Download, or you may compile the source yourself as described in CompileOnUnix. For Ubuntu, the FreeCAD daily packages are also good, although currently they are broken so I'd advise you to use the AppImage.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
User avatar
davecoventry
Posts: 286
Joined: Mon Dec 09, 2013 8:11 pm
Location: Johannesburg
Contact:

Re: Geom_BSplineCurve::Segment error

Post by davecoventry »

Thanks guys.

@Joel_graph: I've used the technique of dividing the structure up and rebuilding the compound, but the error is inconsistent and I think I've built a compound which eliminates it and then it appears again when I compound two ostensibly error free compounds. It's quite a complex model, so the process is time consuming and ultimately fruitless.

@vocx, thanks! I have been using the github repositories which I update sporadically. I'll start using the Appimages now.
~ Dave
User avatar
davecoventry
Posts: 286
Joined: Mon Dec 09, 2013 8:11 pm
Location: Johannesburg
Contact:

Re: Geom_BSplineCurve::Segment error

Post by davecoventry »

OS: Debian GNU/Linux 9 (stretch) (openbox)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.18272 (Git) AppImage
Build type: Release
Branch: master
Hash: 88637aeb202b481a16cbd82c8767a0cc2745cfe1
Python version: 3.7.3
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/South Africa (en_ZA)

Nice! :D
~ Dave
User avatar
Joel_graff
Veteran
Posts: 1949
Joined: Fri Apr 28, 2017 4:23 pm
Contact:

Re: Geom_BSplineCurve::Segment error

Post by Joel_graff »

Let us know if it works. @vocx has a good point. I never think to look at the individual library versions, myself. It's caught me a few times, too.
FreeCAD Trails workbench for transportation engineering: https://www.github.com/joelgraff/freecad.trails

pivy_trackers 2D coin3D library: https://www.github.com/joelgraff/pivy_trackers
Post Reply