Niels Horn's Blog
Random thoughts, tips & tricks about Slackware-Linux, Lego and Star WarsFreeCAD 0.12.5284 and OpenCASCADE 6.5.2 - Working together on Slackware
January 5th, 2012 by Niels Horn in FreeCAD, OpenCASCADE, Slackware
FreeCAD and OpenCASCADE
Building a new version of FreeCAD and OpenCASCADE is always a lot of fun…
These two projects are constantly evolving, but almost never 'in sync'.
In December a new version of the OpenCASCADE library was released - 6.5.2. It solves several bugs and looked like a good reason to build a newer version of FreeCAD in the process. And this is where the fun begins!
Building OpenCASCADE
Building the new version of OpenCASCADE was straightforward. I just needed to update the patch to get it to build with SlackBuilds.org's version of ftgl and test my patience - as it takes more than two hours to build on my Virtual machine. But after some fiddling around, I had a package.
Time to do some testing and trying to build FreeCAD against it!
Building FreeCAD
I decided to try the latest "stable" version of FreeCAD - 0.12.5284. The FreeCAD developers have not created any new source tarballs for a while, so I had to get the SVN revision 5284. I uploaded the tarball I created from that revision to my site so that everyone can create the same stable version.
I soon noticed that they solved all the problems I had with building against OpenCASCADE 6.5.1 some time ago, so I was able to remove that patch.
But then I ran against a new problem:
error: no matching function for call to 'BRepBuilderAPI_MakeFace::BRepBuilderAPI_MakeFace(Handle_Geom_Plane&, double, double&, double, double&)'
Reading the release notes of 6.5.2 I found out that the BRepBuilderAPI_MakeFace function now needs an extra parameter:
BRepLib_MakeFace has been modified to accept tolerance value for resolution of degenerated
edges. This tolerance parameter has no default value (to ensure that the client code takes care of
passing some meaningful value, not just Precision::Confusion), so some porting overheads
are expected.
So, it doesn't have a default value. But what was the default before?
I read through the documentation and found that previously the default was Precision::Confusion()
:
A default tolerance (Precision::Confusion()) is given to the face,
this tolerance may be increased during construction of the face
using various algorithms.
I tried to add this default to the function call and … it worked!
Trying to compile the rest of FreeCAD I found several other locations in the source with the same problem, resulting in this patch:
--- FreeCAD-0.12.5284/src/Mod/Part/App/AppPartPy.cpp 2012-01-02 16:32:09.000000000 -0200 +++ FreeCAD-0.12.5284_patched/src/Mod/Part/App/AppPartPy.cpp 2012-01-02 21:36:18.000000000 -0200 @@ -492,7 +492,7 @@ d.SetCoord(vec.x, vec.y, vec.z); } Handle_Geom_Plane aPlane = new Geom_Plane(p, d); - BRepBuilderAPI_MakeFace Face(aPlane, 0.0, length, 0.0, width); + BRepBuilderAPI_MakeFace Face(aPlane, 0.0, length, 0.0, width, Precision::Confusion()); return new TopoShapeFacePy(new TopoShape((Face.Face()))); } catch (Standard_DomainError) { --- FreeCAD-0.12.5284/src/Mod/Part/App/GeometrySurfacePyImp.cpp 2012-01-02 16:32:09.000000000 -0200 +++ FreeCAD-0.12.5284_patched/src/Mod/Part/App/GeometrySurfacePyImp.cpp 2012-01-02 22:08:47.000000000 -0200 @@ -79,7 +79,7 @@ s->Bounds(u1,u2,v1,v2); if (!PyArg_ParseTuple(args, "|dddd", &u1,&u2,&v1,&v2)) return 0; - BRepBuilderAPI_MakeFace mkBuilder(s, u1, u2, v1, v2); + BRepBuilderAPI_MakeFace mkBuilder(s, u1, u2, v1, v2, Precision::Confusion()); TopoDS_Shape sh = mkBuilder.Shape(); return new TopoShapeFacePy(new TopoShape(sh)); } --- FreeCAD-0.12.5284/src/Mod/Part/App/Geometry.cpp 2012-01-02 16:32:09.000000000 -0200 +++ FreeCAD-0.12.5284_patched/src/Mod/Part/App/Geometry.cpp 2012-01-02 22:37:08.000000000 -0200 @@ -1252,7 +1252,7 @@ Handle_Geom_Surface s = Handle_Geom_Surface::DownCast(handle()); Standard_Real u1,u2,v1,v2; s->Bounds(u1,u2,v1,v2); - BRepBuilderAPI_MakeFace mkBuilder(s, u1, u2, v1, v2); + BRepBuilderAPI_MakeFace mkBuilder(s, u1, u2, v1, v2, Precision::Confusion()); return mkBuilder.Shape(); } --- FreeCAD-0.12.5284/src/Mod/Part/App/PrimitiveFeature.cpp 2012-01-02 16:32:09.000000000 -0200 +++ FreeCAD-0.12.5284_patched/src/Mod/Part/App/PrimitiveFeature.cpp 2012-01-02 22:40:21.000000000 -0200 @@ -191,7 +191,7 @@ gp_Pnt pnt(0.0,0.0,0.0); gp_Dir dir(0.0,0.0,1.0); Handle_Geom_Plane aPlane = new Geom_Plane(pnt, dir); - BRepBuilderAPI_MakeFace mkFace(aPlane, 0.0, L, 0.0, W); + BRepBuilderAPI_MakeFace mkFace(aPlane, 0.0, L, 0.0, W, Precision::Confusion()); const char *error=0; switch (mkFace.Error()) --- FreeCAD-0.12.5284/src/Mod/Part/App/TopoShape.cpp 2012-01-02 16:32:09.000000000 -0200 +++ FreeCAD-0.12.5284_patched/src/Mod/Part/App/TopoShape.cpp 2012-01-03 00:19:12.000000000 -0200 @@ -1338,7 +1338,7 @@ double u1,u2,v1,v2; surf->Bounds(u1,u2,v1,v2); - BRepBuilderAPI_MakeFace mkBuilder(surf, umin, umax, v1, v2); + BRepBuilderAPI_MakeFace mkBuilder(surf, umin, umax, v1, v2, Precision::Confusion()); return mkBuilder.Face(); } @@ -1391,7 +1391,7 @@ Standard_Real u1,u2,v1,v2; mySurface->Bounds(u1,u2,v1,v2); - BRepBuilderAPI_MakeFace mkBuilder(mySurface, u1, u2, v1, v2); + BRepBuilderAPI_MakeFace mkBuilder(mySurface, u1, u2, v1, v2, Precision::Confusion()); return mkBuilder.Shape(); } @@ -1443,7 +1443,7 @@ mkSweep.Perform(tol, Standard_False, GeomAbs_C1, BSplCLib::MaxDegree(), 1000); const Handle_Geom_Surface& surf = mkSweep.Surface(); - BRepBuilderAPI_MakeFace mkBuilder(surf, umin, umax, vmin, vmax); + BRepBuilderAPI_MakeFace mkBuilder(surf, umin, umax, vmin, vmax, Precision::Confusion()); return mkBuilder.Face(); } --- FreeCAD-0.12.5284/src/Mod/Part/App/TopoShapeFacePyImp.cpp 2012-01-02 16:32:09.000000000 -0200 +++ FreeCAD-0.12.5284_patched/src/Mod/Part/App/TopoShapeFacePyImp.cpp 2012-01-03 00:24:40.000000000 -0200 @@ -135,7 +135,7 @@ return -1; } - BRepBuilderAPI_MakeFace mkFace(S); + BRepBuilderAPI_MakeFace mkFace(S, Precision::Confusion()); if (bound) { Py::List list(bound); for (Py::List::iterator it = list.begin(); it != list.end(); ++it) {
With this patch I was able to build FreeCAD successfully on Slackware and now I'm happy playing around with it, discovering the new features
Where to get it
I submitted the new scripts to SlackBuilds.org, where they are waiting in the pending queue to be approved.
In the mean time, pre-built packages for Slackware (both 32- and 64-bits) can be downloaded from my site.