porting to smesh 8.3

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
looo
Posts: 2915
Joined: Mon Nov 11, 2013 5:29 pm

porting to smesh 8.3

Postby looo » Thu Mar 29, 2018 9:52 am

as pyocct uses a newer smesh than freecad, and therefor if both libraries are installed in the same environment both libraries are not working properly.
So I would like to use smesh as an external library. But therefor we have to port to the newer smesh.

As I am not very comfortable with c++ I will put here some question to solve problems that come up during the porting.

What has been done so far:
- build external smesh as a conda-package https://github.com/LaughlinResearch/SMESH
- switch cmake options to use external smesh:

Code: Select all

      -D FREECAD_USE_EXTERNAL_SMESH=ON \
      -D SMESH_INCLUDE_DIR=$PREFIX/include/smesh \
- make some modification to freecad: https://github.com/looooo/FreeCAD/tree/smeah8.3
.
.
.
Last edited by looo on Tue Apr 03, 2018 9:21 am, edited 1 time in total.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
looo
Posts: 2915
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Postby looo » Thu Mar 29, 2018 9:56 am

So first problem:

Code: Select all

~/projects/FreeCAD/src/Mod/MeshPart/App/Mesher.cpp:413:55: error: invalid use of incomplete type ‘class SMESHDS_Mesh’
     SMDS_FaceIteratorPtr aFaceIter = mesh->GetMeshDS()->facesIterator();
https://github.com/looooo/FreeCAD/blob/ ... p#L413L414
please help with my conda-packaging efforts: https://liberapay.com/looooo/
wmayer
Site Admin
Posts: 14892
Joined: Thu Feb 19, 2009 10:32 am

Re: porting to smesh 8.3

Postby wmayer » Thu Mar 29, 2018 12:33 pm

Look at the external smesh lib and check which header offers the class SMESHDS_Mesh. This header must then be included in Mesher.cpp
looo
Posts: 2915
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Postby looo » Thu Mar 29, 2018 12:39 pm

thanks, it seems to be a problem with definitions. HAVE_NETGEN wasn't set if FREECAD_USE_EXTERNAL_SMESH was enabled. Also I don't know if
BUILD_FEM_NETGEN should be enabled or not.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
looo
Posts: 2915
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Postby looo » Thu Mar 29, 2018 1:33 pm

next one:

~/projects/FreeCAD/src/Mod/Fem/App/HypothesisPy.cpp:147:5: error: ‘class SMESH_Hypothesis’ has no member named ‘SetParameters’

any ideas where SMESH_Hypothesis::SetParameters is defined?
please help with my conda-packaging efforts: https://liberapay.com/looooo/
looo
Posts: 2915
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Postby looo » Thu Mar 29, 2018 2:38 pm

I think I found this one, and it is not defined anymore in smesh8.3.

It seems everything is compiling now. But there is one linker problem, introduced by a workaround:

Code: Select all

CMakeFiles/Fem.dir/FemMesh.cpp.o: In function `Fem::FemMesh::getGenerator()':
FemMesh.cpp:(.text+0xe09): undefined reference to `Fem::FemMesh::_mesh_gen'
collect2: error: ld returned 1 exit status
this belongs to this workaround:
https://github.com/looooo/FreeCAD/commi ... 8736b0R491
please help with my conda-packaging efforts: https://liberapay.com/looooo/
User avatar
kkremitzki
Posts: 1768
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: porting to smesh 8.3

Postby kkremitzki » Thu Mar 29, 2018 5:01 pm

I was interested in tackling this during GSoC if I get in but I'm glad you're tackling it in advance! I can help on the "getting this into Debian" part as well as following along with your work on it.
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
looo
Posts: 2915
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Postby looo » Thu Mar 29, 2018 5:28 pm

I was interested in tackling this during GSoC if I get in but I'm glad you're tackling it in advance! I can help on the "getting this into Debian" part as well as following along with your work on it.
I guess there is way too much work for the summer anyway ;) I started this because I want to use pyocct and freecad together.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
looo
Posts: 2915
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Postby looo » Fri Mar 30, 2018 5:00 am

I solved my last problem by defining the static member to 0 in the cpp file. So now FreeCAD compiles, but meshing a cube results in a crash:

Code: Select all

#0  /lib/x86_64-linux-gnu/libc.so.6(+0x354b0) [0x7f4858e8f4b0]
#1  0x7f47d5d926a7 in Standard_Transient::DecrementRefCounter() const from ~/env/cmake/../lib/libTKernel.so.7+0x7
#2  0x7f479c380982 in netgen::OCCGeometry::~OCCGeometry() from ~/env/cmake/../lib/./libocc.so+0xe2
#3  0x7f47c07bb40e in NETGENPlugin_Mesher::Compute() from ~/env/cmake/../lib/libNETGENPlugin.so+0x3fe
#4  0x7f47c07c7934 in NETGENPlugin_NETGEN_2D::Compute(SMESH_Mesh&, TopoDS_Shape const&) from ~/env/cmake/../lib/libNETGENPlugin.so+0xa4
#5  0x7f47c05478c3 in SMESH_subMesh::ComputeStateEngine(SMESH_subMesh::compute_event) from ~/env/cmake/../lib/libSMESH.so+0x1173
#6  0x7f47c049a225 in SMESH_Gen::Compute(SMESH_Mesh&, TopoDS_Shape const&, int, MeshDimension, std::set<int, std::less<int>, std::allocator<int> >*) from ~/env/cmake/../lib/libSMESH.so+0x6d5
#7  0x7f47c0e8fac9 in MeshPart::Mesher::createMesh() const from ~/work/Mod/MeshPart/MeshPart.so+0x1279
#8  0x7f47c0e83281 in MeshPart::Module::meshFromShape(Py::Tuple const&, Py::Dict const&) from ~/work/Mod/MeshPart/MeshPart.so+0xe81
#9  0x7f47c0e7e95b in Py::ExtensionModule<MeshPart::Module>::invoke_method_keyword(void*, Py::Tuple const&, Py::Dict const&) from ~/work/Mod/MeshPart/MeshPart.so+0x2b
Before I dive into smesh, are there any critical occt7.2.0 changes we made to smesh. Maybe the 8.3 needs to see some updates too.
please help with my conda-packaging efforts: https://liberapay.com/looooo/
looo
Posts: 2915
Joined: Mon Nov 11, 2013 5:29 pm

Re: porting to smesh 8.3

Postby looo » Sat Mar 31, 2018 6:52 pm

I have two problems right now:

- StdMeshers_TrianglePreference.hxx is missing, so a workaround has to be found. (commenting out doesn't work)
https://github.com/looooo/FreeCAD/commi ... f55fd9R391

- the other problem is quite strange. It's reported some libs are missing if I use debug-builds of smesh and netgen:

Code: Select all

Nicht definierter Verweis auf `SMESH_Mesh::AddHypothesis(TopoDS_Shape const&, int, std::string*)'
All works if I use release builds of netgen and smesh. No idea whats wrong here.
please help with my conda-packaging efforts: https://liberapay.com/looooo/