FreeCAD 0.18.4 fails to build with vtk 9.0

Having trouble installing or compiling FreeCAD? Get help here.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

Re: FreeCAD 0.18.4 fails to build with vtk 9.0

Post by hobbes1069 »

I tested building with vtk 9.0 and I think I got the CMake stuff mostly worked out as it failed during compiling for obvious reasons.

I wanted to make sure i didn't mess anything up for vtk < 9.0 so I did a standard build in Fedora Rawhide and ran into this:

Code: Select all

builddir/build/BUILD/freecad/src/Mod/Part/App/GeometryPyImp.cpp: In member function 'PyObject* Part::GeometryPy::getExtensionOfType(PyObject*)':
/builddir/build/BUILD/freecad/src/Mod/Part/App/GeometryPyImp.cpp:273:134: error: call of overloaded 'Tuple(size_t)' is ambiguous
  273 |                 PyObject* cpy = static_cast<GeometryExtensionPy *>(ext->getPyObject())->copy(Py::new_reference_to(Py::Tuple(size_t(0))));
      |                                                                                                                                      ^
In file included from /usr/include/CXX/Objects.hxx:42,
                 from /builddir/build/BUILD/freecad/src/Base/GeometryPyCXX.h:27,
                 from /builddir/build/BUILD/freecad/src/Mod/Part/App/GeometryPyImp.cpp:40:
/usr/include/CXX/Python3/Objects.hxx:2260:18: note: candidate: 'Py::Tuple::Tuple(int)'
 2260 |         explicit Tuple( int size=0 )
      |                  ^~~~~
/usr/include/CXX/Python3/Objects.hxx:2247:18: note: candidate: 'Py::Tuple::Tuple(PyObject*, bool)'
 2247 |         explicit Tuple( PyObject *pyob, bool owned = false )
      |                  ^~~~~
/usr/include/CXX/Python3/Objects.hxx:2234:11: note: candidate: 'Py::Tuple::Tuple(const Py::Tuple&)'
 2234 |     class Tuple: public Sequence
      |           ^~~~~
/usr/include/CXX/Python3/Objects.hxx:2234:11: note: candidate: 'Py::Tuple::Tuple(Py::Tuple&&)'
/builddir/build/BUILD/freecad/src/Mod/Part/App/GeometryPyImp.cpp: In member function 'PyObject* Part::GeometryPy::getExtensionOfName(PyObject*)':
/builddir/build/BUILD/freecad/src/Mod/Part/App/GeometryPyImp.cpp:307:130: error: call of overloaded 'Tuple(size_t)' is ambiguous
  307 |             PyObject* cpy = static_cast<GeometryExtensionPy *>(ext->getPyObject())->copy(Py::new_reference_to(Py::Tuple(size_t(0))));
      |                                                                                                                                  ^
In file included from /usr/include/CXX/Objects.hxx:42,
                 from /builddir/build/BUILD/freecad/src/Base/GeometryPyCXX.h:27,
                 from /builddir/build/BUILD/freecad/src/Mod/Part/App/GeometryPyImp.cpp:40:
/usr/include/CXX/Python3/Objects.hxx:2260:18: note: candidate: 'Py::Tuple::Tuple(int)'
 2260 |         explicit Tuple( int size=0 )
      |                  ^~~~~
/usr/include/CXX/Python3/Objects.hxx:2247:18: note: candidate: 'Py::Tuple::Tuple(PyObject*, bool)'
 2247 |         explicit Tuple( PyObject *pyob, bool owned = false )
      |                  ^~~~~
/usr/include/CXX/Python3/Objects.hxx:2234:11: note: candidate: 'Py::Tuple::Tuple(const Py::Tuple&)'
 2234 |     class Tuple: public Sequence
      |           ^~~~~
/usr/include/CXX/Python3/Objects.hxx:2234:11: note: candidate: 'Py::Tuple::Tuple(Py::Tuple&&)'
/builddir/build/BUILD/freecad/src/Mod/Part/App/GeometryPyImp.cpp: In member function 'PyObject* Part::GeometryPy::getExtensions(PyObject*)':
/builddir/build/BUILD/freecad/src/Mod/Part/App/GeometryPyImp.cpp:441:41: error: call of overloaded 'Tuple(size_t)' is ambiguous
  441 |                 Py::Tuple args(size_t(0));
      |                                         ^
wmayer
Founder
Posts: 20306
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD 0.18.4 fails to build with vtk 9.0

Post by wmayer »

Here is a branch where I can build smesh with vtk9: https://github.com/wwmayer/FreeCAD/comm ... fa8f90411e

Now there are open several FIXME's. But I don't know what to do.
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

Re: FreeCAD 0.18.4 fails to build with vtk 9.0

Post by hobbes1069 »

I still would like an answer to my questions I asked earlier...

https://forum.freecadweb.org/viewtopic. ... 10#p408172

But for now I'll go ahead and commit my changes to the fork.

https://github.com/hobbes1069/FreeCAD/c ... d72f952645

Thanks,
Richard
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: FreeCAD 0.18.4 fails to build with vtk 9.0

Post by qingfeng.xia »

After upgrade to Ubuntu 20.04, vtk-dev is broken ,so I can not compile freecad-daily any more, so I build my vtk9. When I built freecad upstream master latest 0.19, I run into problem with SalomeMesh, I know there are already some in-progress work to upgrade salome mesh, I hope once salomemesh updated it may solve the problem. ‘

vtkAbstractCellLinks*’ to ‘vtkCellLinks*’

Code: Select all

/usr/local/include/vtk-9.0/vtkSmartPointer.h:195:3: note: candidate is: ‘vtkSmartPointer<ArrayType>::operator T*() const [with T = vtkAbstractCellLinks]’ <near match>
  195 |   operator T*() const noexcept { return static_cast<T*>(this->Object); }
      |   ^~~~~~~~
/usr/local/include/vtk-9.0/vtkSmartPointer.h:195:3: note:   no known conversion from ‘vtkAbstractCellLinks*’ to ‘vtkCellLinks*’
/opt/FreeCAD/src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh.cpp: In member function ‘void SMDS_Mesh::dumpGrid(std::string)’:
/opt/FreeCAD/src/3rdParty/salomesmesh/src/SMDS/SMDS_Mesh.cpp:4771:51: error: invalid conversion from ‘vtkAbstractCellLinks*’ to ‘vtkCellLinks*’ [-fpermissive]
 4771 |         vtkCellLinks *links = myGrid->GetCellLinks();
      |                               ~~~~~~~~~~~~~~~~~~~~^~
      |                                                   |
      |                                                   vtkAbstractCellLinks*
make[2]: *** [src/3rdParty/salomesmesh/CMakeFiles/SMDS.dir/build.make:167: src/3rdParty/salomesmesh/CMakeFiles/SMDS.dir/src/SMDS/SMDS_Mesh.cpp.o] Error 1

Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: FreeCAD 0.18.4 fails to build with vtk 9.0

Post by looo »

wmayer wrote: Sat Jun 13, 2020 1:55 pm Here is a branch where I can build smesh with vtk9: https://github.com/wwmayer/FreeCAD/comm ... fa8f90411e

Now there are open several FIXME's. But I don't know what to do.

I see 4 different issues.

1.

Code: Select all

#ifdef VTK_CELL_ARRAY_V2
//FIXME: vtk9
#else
  pts[0] = node->getVtkId();
#endif
2.

Code: Select all

#ifdef VTK_CELL_ARRAY_V2
      vtkIdType oldLoc; //FIXME: vtk9
#else
      vtkIdType oldLoc = this->Locations->GetValue(j);
#endif
3.

Code: Select all

#ifdef VTK_CELL_ARRAY_V2
//FIXME: vtk9
#else
          pts[i] = localClonedNodeIds[oldpt];
#endif
4.

Code: Select all

#ifdef VTK_CELL_ARRAY_V2
//FIXME: vtk9
  this->Links = SMDS_CellLinks::New();
  //this->Links->Allocate(this->GetNumberOfPoints());
  this->Links->Register(this);
  //this->Links->BuildLinks(this, this->Connectivity);
  this->Links->Delete();
#else
  this->Links = SMDS_CellLinks::New();
  this->Links->Allocate(this->GetNumberOfPoints());
  this->Links->Register(this);
  this->Links->BuildLinks(this, this->Connectivity);
  this->Links->Delete();
#endif
User avatar
hobbes1069
Posts: 291
Joined: Wed Nov 09, 2011 3:49 pm
Location: Southaven, MS

Re: FreeCAD 0.18.4 fails to build with vtk 9.0

Post by hobbes1069 »

Has anyone asked VTK upstream what the v9 equivalent is to these?
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: FreeCAD 0.18.4 fails to build with vtk 9.0

Post by looo »

hobbes1069 wrote: Mon Oct 12, 2020 12:23 pm Has anyone asked VTK upstream what the v9 equivalent is to these?
I don't think so. The only relevant topic I found was this one:
https://discourse.vtk.org/t/upcoming-ch ... array/2066

As we are quite stuck with this issue, it's a good idea to ask upstream how to proceed.
wmayer
Founder
Posts: 20306
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD 0.18.4 fails to build with vtk 9.0

Post by wmayer »

I again had a look at the vtk9 source code and it looks the recipe to port smesh code is to use the overloaded version of vtkUnstructuredGrid::GetCellPoints().

For vtk8 or earlier the smesh code is of this form:

Code: Select all

  vtkIdType npts = 0;
  vtkIdType* pts = 0;
  grid->GetCellPoints(myVtkID, npts, pts);
  pts[0] = node->getVtkId();
which used

Code: Select all

void GetCellPoints(vtkIdType cellId, vtkIdType& npts, vtkIdType*& pts)
In vtk9 the 3rd argument has become const so that in the calling instance it's not possible any more to modify the array.

In vtk8 & vtk9 we still have this overloaded version:

Code: Select all

void GetCellPoints(vtkIdType cellId, vtkIdList* ptIds) override;
In the vtk9 code I found an example how to modify an element in the list. The above code has to be changed to

Code: Select all

  vtkNew<vtkIdList> cellPoints;
  grid->GetCellPoints(myVtkID, cellPoints.GetPointer());
  cellPoints->SetId(0, node->getVtkId());
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: FreeCAD 0.18.4 fails to build with vtk 9.0

Post by looo »

wmayer wrote: Mon Oct 12, 2020 2:13 pm I again had a look at the vtk9 source code and it looks the recipe to port smesh code is to use the overloaded version of vtkUnstructuredGrid::GetCellPoints().
Some light at the end of the tunnel. :)

Does this solves all four of the fixme's?
wmayer
Founder
Posts: 20306
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: FreeCAD 0.18.4 fails to build with vtk 9.0

Post by wmayer »

All FIXME's are solved now but in one case I am not sure if it's the right way:

Code: Select all


void SMDS_UnstructuredGrid::BuildLinks()
{
  // Remove the old links if they are already built
  if (this->Links)
    {
    this->Links->UnRegister(this);
    }

#ifdef VTK_CELL_ARRAY_V2
  this->Links = SMDS_CellLinks::New();
  GetLinks()->Allocate(this->GetNumberOfPoints());
  GetLinks()->Register(this);
//FIXME: vtk9
  GetLinks()->BuildLinks(this); // <<<<<<<<<< ============== this->Connectivity cannot be passed any more
  GetLinks()->Delete();
#else
  this->Links = SMDS_CellLinks::New();
  this->Links->Allocate(this->GetNumberOfPoints());
  this->Links->Register(this);
  this->Links->BuildLinks(this, this->Connectivity);
  this->Links->Delete();
#endif
}
Anyway the branch https://github.com/wwmayer/FreeCAD/tree/smesh_vtk9.0 is ready for testing...
Post Reply