[Open3D WARNING] Write PCD failed: unable to open file.
- Dominant language
- C++
- Stars
- 14k
- Forks
- 2.6k
- Avg merge
- 5d 18h
- Merged PRs (30d)
- 6
Description
### Checklist
- [X] I have searched for [similar issues](https://github.com/isl-org/Open3D/issues).
- [X] For Python issues, I have tested with the [latest development wheel](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [X] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `master` branch).
### Describe the issue
I am trying to save a numpy array of shape [n, 4]. I am using the function o3d.t.io.write_point_cloud(str(i) + "_output.pcd", pcd) and am receiving the error message [Open3D WARNING] Write PCD failed: unable to open file.. I don't understand why the function is trying to open a file, I am trying to save something not read something. I am able to use o3d.io.write_point_cloud for my input point clouds with shape [n, 3] but it doesn't work with [n, 4].
### Steps to reproduce the bug
```python
import numpy as np
import open3d as o3d
def fld_calculator(eps1, eps2):
# Calculates the fld class according to the FLD diagram
# Return:
# TODO: Other Classes
# 1 --> Crack
# 0 --> Safe
if eps1 < -0.34:
AssertionError("The point has invalid eps1 value: " + str(eps1))
elif -0.34 <= eps1 < 0:
control = -0.98823529411765 * eps1 + 0.221
elif 0 <= eps1 < 0.02:
control = -0.15 * eps1 + 0.221
elif 0.02 <= eps1 < 0.066:
control = 0.71739130434783 * eps1 + 0.20365217391304
elif 0.066 <= eps1 < 0.097:
control = 0.74193548387097 * eps1 + 0.20203225806452
elif 0.097 <= eps1 < 0.17:
control = 0.65753424657534 * eps1 + 0.21021917808219
elif 0.17 <= eps1 < 0.256:
control = 0.48837209302326 * eps1 + 0.23897674418605
elif 0.256 < eps1 < 0.291:
control = 0.11428571428571 * eps1 + 0.33474285714286
else:
AssertionError("The point has invalid eps1 value: " + str(eps1))
return float(int(eps2 > control))
def read_input(i, part='Die'):
file = open(
"./data/Input/Geometry_Set_" + str(i) + "/" + part + str(
i) + "_meshed.set").readlines()
start = 0
end = 0
mesh_array = []
for line in file:
if '*NODE' in line:
start = 1
continue
if '*ELEMENT_SHELL' in line:
break
if start == 1:
x_coordinate = round(float(line[8:24]), 4)
y_coordinate = round(float(line[24:40]), 4)
z_coordinate = round(float(line[40:56]), 4)
mesh_array.append((x_coordinate, y_coordinate, z_coordinate))
pass
mesh_array = np.asarray(mesh_array)
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(mesh_array)
o3d.io.write_point_cloud("./data/Input/" + str(i) + "_input.pcd", pcd)
return np.array(mesh_array)
def read_output(i):
x_strain_file = open("./data/Output/Strain_Set_" + str(
i) + "/x_strain").readlines()
y_strain_file = open(
"./data/Output/Strain_Set_" + str(
i) + "/y_strain").readlines()
xy_strain_file = open(
"./data/Output/Strain_Set_" + str(
i) + "/xy_strain").readlines()
# FLD FILE lesen
read_coordinate = 0
read_strain_x = 0
node_dict_array = []
keys = ['node_id', 'coordinates', 'x_strain', 'y_strain', 'xy_strain']
for line in x_strain_file:
if '*NODE' in line:
read_coordinate = 1
continue
if '*END' in line:
read_coordinate = 0
if '$RESULT OF Lower Ipt X-strain' in line:
read_strain_x = 1
continue
if read_coordinate:
new_dictionary_input = dict.fromkeys(keys, None)
node_id = int(line[0:8])
x_coordinate = round(float(line[8:24]), 4)
y_coordinate = round(float(line[24:40]), 4)
z_coordinate = round(float(line[40:56]), 4)
new_dictionary_input['node_id'] = node_id
new_dictionary_input['coordinates'] = (x_coordinate, y_coordinate, z_coordinate)
node_dict_array.append(new_dictionary_input)
# print("New Dictionary created: " + str(new_dictionary_input))
pass
if read_strain_x:
node_id = int(line[0:10])
x_strain = float(line[10:20])
for d in node_dict_array:
if d['node_id'] == node_id:
d['x_strain'] = x_strain
# print("Dictionary" + str(d) + "has new x_strain_value:" + str(x_strain))
read_strain_y = 0
for line in y_strain_file:
if '$RESULT OF Lower Ipt Y-strain' in line:
read_strain_y = 1
continue
if read_strain_y:
node_id = int(line[0:10])
y_strain = float(line[10:20])
for d in node_dict_array:
if d['node_id'] == node_id:
d['y_strain'] = y_strain
# print("Dictionary" + str(d) + "has new y_strain_value:" + str(y_strain))
read_strain_xy = 0
for line in xy_strain_file:
if '$RESULT OF Lower Ipt XY-strain' in line:
read_strain_xy = 1
continue
if read_strain_xy:
node_id = int(line[0:10])
xy_strain = float(line[10:20])
for d in node_dict_array:
if d['node_id'] == node_id:
d['xy_strain'] = xy_strain
# print("Dictionary" + str(d) + "has new xy_strain_value:" + str(xy_strain))
output_array = []
for d in node_dict_array:
x_strain = d['x_strain']
y_strain = d['y_strain']
xy_strain = d['xy_strain']
eps_1 = ((x_strain + y_strain) / 2) + np.sqrt(((x_strain - y_strain) / 2) ** 2 + (xy_strain / 2) ** 2)
eps_2 = ((x_strain + y_strain) / 2) - np.sqrt(((x_strain - y_strain) / 2) ** 2 + (xy_strain / 2) ** 2)
fld_class = fld_calculator(eps_1, eps_2)
point_to_add = list(d['coordinates'])
point_to_add.append(fld_class)
'''
if fld_class:
point_to_add.append([1.0, 0.0, 0.0])
else:
point_to_add.append([0.0, 1.0, 0.0])
'''
output_array.append(point_to_add)
output_array = np.asarray(output_array)
xyz = output_array[:, 0:3]
i = [[i] for i in output_array[:,3]]
pcd = o3d.t.geometry.PointCloud()
pcd.point["positions"] = o3d.core.Tensor(xyz)
pcd.point["classes"] = o3d.core.Tensor(i)
o3d.t.io.write_point_cloud(str(i) + "_output.pcd", pcd)
return np.array(output_array, dtype=object)
if __name__ == '__main__':
for i in range(999):
read_input(i+1)
print('Input ' + str(i+1) + ' is read')
read_output(i+1)
print('Output ' + str(i+1) + ' is read')
```
### Error message
[Open3D WARNING] Write PCD failed: unable to open file.
### Expected behavior
I expected the file to be saved.
### Open3D, Python and System information
```markdown
- Operating system: JupyterLab
- Python version: Python 3.8
- Open3D version: output from python: Latest
- System architecture: ??
- Is this a remote workstation?: yes
- How did you install Open3D?: pip
```
### Additional information
_No response_
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.