Description:
When calling mesh.write_voxels() with mesh=True and a voxelized mesh, the function crashes with:
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'list'
Steps to reproduce:
- Create an RVE using examples/RVE_generation/create_rve.py.
- Add mesh=True in ms.write_voxels(mesh=True).
Observed behavior:
The function fails at this line in api.py: "Values": [int(val) for val in self.mesh.voxel_dict.values()],
if mesh:
structure['Mesh'] = {
"Nodes": {
"Description": 'Nodal coordinates',
"Type": 'float',
"Shape": self.mesh.nodes.shape,
"Values": [list(val) for val in self.mesh.nodes],
},
"Voxels": {
"Description": 'Node list per voxel',
"Type": 'int',
"Shape": (len(self.mesh.voxel_dict.keys()), 8),
"Values": [int(val) for val in self.mesh.voxel_dict.values()],
}
}
Expected behavior:
write_voxels() should correctly serialize the node connectivity for each voxel in JSON.
Proposed fix:
Replace:
"Values": [int(val) for val in self.mesh.voxel_dict.values()],
with:
"Values": [list(val) for val in self.mesh.voxel_dict.values()],. This ensures the 8-node connectivity of each voxel is preserved in the JSON output.
System
- Kanapy version:
v6.5.3-post1-46-g82139362
- Python version:
3.10.18
Description:
When calling mesh.write_voxels() with mesh=True and a voxelized mesh, the function crashes with:
Steps to reproduce:
Observed behavior:
The function fails at this line in api.py:
"Values": [int(val) for val in self.mesh.voxel_dict.values()],Expected behavior:
write_voxels() should correctly serialize the node connectivity for each voxel in JSON.
Proposed fix:
Replace:
"Values": [int(val) for val in self.mesh.voxel_dict.values()],with:
"Values": [list(val) for val in self.mesh.voxel_dict.values()],. This ensures the 8-node connectivity of each voxel is preserved in the JSON output.System
v6.5.3-post1-46-g821393623.10.18