# VTK-9.0.3-1 is asserting with a simple cube FEM in FreeCAD

**URL:** https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749
**Category:** Support
**Created:** [October 1, 2021, 6:30pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749 "2021-10-01T18:30:36Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 1, 2021, 6:30pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/1 "2021-10-01T18:30:36Z")

</div>

I’m not sure where to report a bug/issue, so here I am.

Full description of the issue is here:  
[https://forum.freecadweb.org/viewtopic.php?f=18&t=62566&p=537350#p537350](https://forum.freecadweb.org/viewtopic.php?f=18&t=62566&p=537350#p537350)

How should I proceed ?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [October 4, 2021, 8:52am UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/2 "2021-10-04T08:52:56Z")

</div>

please share the failing dataset.

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 4, 2021, 4:48pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/3 "2021-10-04T16:48:26Z")

</div>

I’m a new user. Discourse will not allow me to upload an attachment.

I uploaded the FreeCAD file to this bug report.  
[https://bugzilla.redhat.com/show\_bug.cgi?id=2009878](https://bugzilla.redhat.com/show_bug.cgi?id=2009878)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [October 5, 2021, 9:39am UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/4 "2021-10-05T09:39:30Z")

</div>

> You are not authorized to access bug #2009878.

please share using discourse, I’ve set your permissions so you can upload.

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 5, 2021, 3:26pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/5 "2021-10-05T15:26:37Z")

</div>

Description of problem:

VTK is firing an assert on a simple FreeCAD FEM.

Version-Release number of selected component (if applicable):

dnf list vtk  
Installed Packages  
vtk.x86\_64 9.0.3-1.fc34

dnf list freecad  
Installed Packages  
freecad.x86\_64 1:0.19.2-1.fc34

How reproducible:

Multiple computers, multiple users, every time.

Steps to Reproduce:

1. Start FreeCAD
2. Draw a simple 3D cube in Part workbench
3. Perform a FEM

See attached FreeCAD source file.

Complete details here: [gmsh fails on simple cube - FreeCAD Forum](https://forum.freecadweb.org/viewtopic.php?f=18&t=62566) See post #13, posted at Wed Sep 29, 2021 3:12 pm

Actual results:

2021-10-01 19:43:25.760 ( 48.164s) [2BB67640] vtkCellArray.cxx:551 ERR| vtkCellArray (0x56322fccc390): Invalid location.  
FreeCAD: /home/user/Programs/FreeCAD/sourcecode/src/3rdParty/salomesmesh/src/SMDS/SMDS\_VtkEdge.cpp:119: virtual int SMDS\_VtkEdge::NbNodes() const: Assertion `nbPoints \>= 2’ failed.  
Aborted

Expected results:

A successful mesh.

Additional info:

VTK-7 is reported to work by several users. VTK-8 or 7 is available on FC33, but not FC34 and VTK is not straight forward to build on FC34 due to compiler issues.

I am in the process of reporting this issue to the VTK group. In the meantime, a good work around would be to build VTK-7 or 8 and make it available as a downgrade on FC34.

[FEM Test.FCStd](https://discourse.vtk.org/uploads/short-url/uLR5QnmcHZPsCckOc5omDKCWchP.FCStd) (8.8 KB)

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [October 5, 2021, 3:34pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/6 "2021-10-05T15:34:13Z")

</div>

There is no FCStd reader in VTK and your steps to reproduce are using FreeCAD, not VTK, are you sure this is a VTK issue ?

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 5, 2021, 3:52pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/7 "2021-10-05T15:52:36Z")

</div>

The error occurs when VTK is called while generating a mesh in FreeCAD. You’d need to install FreeCAD-0.19 and run the example in order to experience the error.

Is it a VTK problem ? VTK-7 and VTK-8 both work fine with FreeCAD-0.19 with this example. VTK-9 does not.

I appreciate your attention to my problem.

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 5, 2021, 4:00pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/8 "2021-10-05T16:00:11Z")

</div>

What would the extension of the input file be ? Maybe I can capture it mid process and send it to you.

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [October 5, 2021, 7:36pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/9 "2021-10-05T19:36:30Z")

</div>

> [@linux\_guy](#):
>
> Is it a VTK problem ? VTK-7 and VTK-8 both work fine with FreeCAD-0.19 with this example. VTK-9 does not.

No idea, it can be a misuse of VTK that used to work before, it can be a VTK bug. Without a minimal example to reproduce in VTK, it is down to FreeCAD developpers to figure out what is not working from a VTK user point of view.

file extension should .vtk or .vtp/u/r/i/s/m, maybe ? But since FreeCAD is using VTK they must be creating this cube using VTK directly, not using file from disk.

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 5, 2021, 7:41pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/10 "2021-10-05T19:41:43Z")

</div>

I’m looking at source code right now.

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 5, 2021, 7:47pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/11 "2021-10-05T19:47:02Z")

</div>

I just cloned vtk-master from github. [GitHub - Kitware/VTK: Mirror of Visualization Toolkit repository](https://github.com/Kitware/VTK)

How do I pull vtk-7 and vtk-8 so I can compare the code ? I don’t see marked release versions ?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [October 5, 2021, 7:58pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/13 "2021-10-05T19:58:17Z")

</div>

they are tagged.

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 5, 2021, 8:05pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/14 "2021-10-05T20:05:29Z")

</div>

I’ll check again.

---

<div class="post-metadata">

### Author: ![Aron\_Helser](https://discourse.vtk.org/user_avatar/discourse.vtk.org/aron_helser/32/14_2.png) [@Aron\_Helser](https://discourse.vtk.org/u/Aron_Helser)
#### Post date: [October 5, 2021, 8:16pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/15 "2021-10-05T20:16:15Z")

</div>

The main repo of vtk is at [https://gitlab.kitware.com/vtk/vtk/](https://gitlab.kitware.com/vtk/vtk/) - the github clone may not have all the older tags.

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 5, 2021, 8:19pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/16 "2021-10-05T20:19:46Z")

</div>

Ahhh ! That makes sense. Thanks for the tip.

I cannot find the nbPoints\>=2 assert in the master code branch. I’m using $grep -r “nbPoints\>=2” \* and $grep -r “nbPoints” \*

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)
#### Post date: [October 5, 2021, 8:22pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/17 "2021-10-05T20:22:30Z")

</div>

> [@linux\_guy](#):
>
> FreeCAD: /home/user/Programs/FreeCAD/sourcecode/src/3rdParty/salomesmesh/src/SMDS/SMDS\_VtkEdge.cpp:119: virtual int SMDS\_VtkEdge::NbNodes() const: Assertion `nbPoints \>= 2’ failed.

This assert is not from vtk source code, [FreeCAD: SMDS\_VtkEdge Class Reference](https://freecad.github.io/API/d8/d41/classSMDS__VtkEdge.html)

> <https://github.com/FreeCAD/FreeCAD/blob/main/src/3rdParty/salomesmesh/src/SMDS/SMDS_VtkEdge.cpp#L119>

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 5, 2021, 8:23pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/18 "2021-10-05T20:23:13Z")

</div>

Right.

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 5, 2021, 8:25pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/19 "2021-10-05T20:25:24Z")

</div>

src/3rdParty/salomesmesh/src/SMDS/SMDS\_VtkEdge.cpp: int nbPoints = grid-\>GetCell(myVtkID)-\>GetNumberOfPoints();  
src/3rdParty/salomesmesh/src/SMDS/SMDS\_VtkEdge.cpp: assert(nbPoints \>= 2);  
src/3rdParty/salomesmesh/src/SMDS/SMDS\_VtkEdge.cpp: return nbPoints;

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 5, 2021, 8:29pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/20 "2021-10-05T20:29:45Z")

</div>

Does anything about this look suspicious to you ?

Line 115:

```auto
int SMDS_VtkEdge::NbNodes() const
{
vtkUnstructuredGrid* grid = SMDS_Mesh::_meshList[myMeshId]->getGrid();
int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints();
assert(nbPoints >= 2);
return nbPoints;
}
```

Why would the code work with vtk-7,8 and return a good mesh and yet not work with vtk-9 ? FreeCAD-0.19 is passing the same meshlist to each version of vtk. Something must have changed in vtk-9 ?

---

<div class="post-metadata">

### Author: ![linux\_guy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/linux_guy/32/4029_2.png) [@linux\_guy](https://discourse.vtk.org/u/linux_guy)
#### Post date: [October 5, 2021, 8:53pm UTC](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749/21 "2021-10-05T20:53:24Z")

</div>

I am going to build vtk-7 and 8 and test with them.

[Next page](https://discourse.vtk.org/t/vtk-9-0-3-1-is-asserting-with-a-simple-cube-fem-in-freecad/6749.md?page=2)
