Unconnected meshes of finite elements

Hello everyone. I’m working on a finite elements software. It basically works like this for now: I have a 3D model of a structure (a cube in a .step file), and I want to mesh it. I have a vtkUnstructuredGrid that represents the structure, and I want to mesh it with quadrilateral and triangular elements. I’m using gmsh to do the meshing, and I’m using the following code to do it:
gmsh.initialize()
gmsh.merge(“grid.stl”)
gmsh.model.mesh.createTopology()
gmsh.model.mesh.createGeometry()
gmsh.model.mesh.createFaces()
gmsh.model.mesh.createEdges()
gmsh.model.occ.synchronize()
gmsh.model.geo.synchronize()
if meshType == 6:

    gmsh.option.setNumber('Mesh.Algorithm', meshType) 
    gmsh.option.setNumber('Mesh.MeshSizeMin', meshSize) 
    gmsh.option.setNumber('Mesh.MeshSizeMax', meshSize) 
elif meshType == 8:
    # Caso o tipo de malha seja quadrangular
    gmsh.option.setNumber('Mesh.Algorithm', meshType) 
    gmsh.option.setNumber('Mesh.MeshSizeMin', meshSize)
    gmsh.option.setNumber('Mesh.MeshSizeMax', meshSize) 
    gmsh.option.setNumber('Mesh.RecombineAll', 1) 
    gmsh.option.setNumber('Mesh.RecombinationAlgorithm', 3)
    gmsh.option.setNumber("Mesh.SubdivisionAlgorithm", 1)
gmsh.model.geo.synchronize() 
gmsh.model.occ.synchronize() 
gmsh.model.mesh.generate(2) 
gmsh.write("mesh.vtk")
gmsh.finalize()

after that, I read the mesh with the vtkDataSetReader and create a new vtk structure (mapper, actor, etc) with the mesh. The problem is that the mesh is not being created correctly, like in the images that I’m uploaded.
I appreciate any help or suggestions! Thank you.