utils.files.input.ScannedObject
- class utils.files.input.ScannedObject(vertices, faces=None)
Bases:
object
This class is used to manage the data of the 3D object.
- Parameters:
vertices – List of verticesm Ndarray of shape (n,2)
faces – List of faces, Ndarray of shape (n,2)
- Variables:
vertices – List of vertices, Ndarray of shape (n,2)
faces – List of faces, Ndarray of shape (n,2)
x – List of x values of the vertices
y – List of y values of the vertices
z – List of z values of the vertices
- Static method from_xyz_file():
Creates a ScannedObject from a .xyz file
- Static method from_obj_file():
Creates a ScannedObject from a .obj file
- Method get_x():
Returns the x values of the vertices
- Method get_y():
Returns the y values of the vertices
- Method get_z():
Returns the z values of the vertices
- Method get_vertices():
Returns the vertices
- Method get_faces():
Returns the faces
- Method get_discrete_vertices():
Returns the discrete vertices
- Method get_data():
Returns the data
- Method export:
Exports the data to a file
- Raises:
FacesNotGiven – If no faces was given
ResultFileNotGiven – If no result file was given
Methods
Export the object in a file.
Export the object in a file.
Create an Object from an STL file.
Create an Object from a binary STL file.
Create an Object from a file.
Create an Object from an OBJ file.
Create an Object from a list of triangles.
Create an Object from an XYZ file.
Get the data of the object.
Discretize the vertices using the method specified in the settings.
Discretize the vertices of the object using a split method.
Discretize the vertices of the object using a length method.
Get the faces of the object.
Get the vertices of the object.
Get the x coordinates of the object.
Get the y coordinates of the object.
Get the z coordinates of the object.
Check if the object has faces.
Normalise the object.
Update the object from the faces.
Attributes
authorised_extensions
- export_obj(file_path)
Export the object in a file.
- Parameters:
file_path – Path of the file
- export_xyz(file_path: str, separator: str = '\t')
Export the object in a file.
- Parameters:
file_path – Path of the file
separator – chars used to separate the values
- static from_ascii_stl_file(file_path: str, ratio: float = 1, normalised: str = '') ScannedObject
Create an Object from an STL file.
- Parameters:
file_path – Path to the STL file
ratio – Ratio to apply to the vertices
normalised – the axis to normalise
- Returns:
A ScannedObject
- static from_binary_stl_file(file_path: str, ratio: float = 1, normalised: str = '') ScannedObject
Create an Object from a binary STL file.
- Parameters:
file_path – Path to the STL file
ratio – Ratio to apply to the vertices
normalised – the axis to normalise
- Returns:
A ScannedObject
- static from_file(file_path: str, ratio: float = 1, normalised: str = '') ScannedObject
Create an Object from a file.
- Parameters:
file_path – Path to the file
ratio – Ratio to apply to the vertices
normalised – the axis to normalise
- Returns:
A ScannedObject
- static from_obj_file(file_path: str, ratio: float = 1, normalised: str = '') ScannedObject
Create an Object from an OBJ file.
- Parameters:
file_path – Path to the OBJ file
ratio – Ratio to apply to the vertices
normalised – the axis to normalise
- Returns:
A ScannedObject
- static from_triangles(triangles: list, normalised: str = '') ScannedObject
Create an Object from a list of triangles.
- Parameters:
triangles – List of triangles
vertices – List of vertices
- Returns:
A ScannedObject
- static from_xyz_file(file_path: str, delimiter: str = ' ', ratio: float = 1, normalised: str = '') ScannedObject
Create an Object from an XYZ file.
- Parameters:
file_path – Path to the XYZ file
delimiter – The delimiter used in the xyz file.
normalised – the axis to normalise
- Returns:
A ScannedObject
- get_data() dict
Get the data of the object.
- Returns:
Data of the object
- get_discrete_vertices(step: float = 1) list
Discretize the vertices using the method specified in the settings.
- Parameters:
step – Step of the discretization
- Returns:
Discretized vertices
- get_discrete_vertices_1(step: float = 1) list
Discretize the vertices of the object using a split method. This implementation will split the object at every step interval.
- Parameters:
step – Step of the discretization
- Returns:
Discretized vertices
- get_discrete_vertices_2(step: float = 1) list
Discretize the vertices of the object using a length method. This implementation will split the object when difference between the first and last point of a slice is greater or equal then the step interval.
- Parameters:
step – Step of the discretization
- Returns:
Discretized vertices
- get_faces(resolved: bool = False) list
Get the faces of the object. If the faces are not resolved, the faces will be returned as a list of indices of the vertices. else, the faces will be returned as a list of vertices.
- Parameters:
resolved – If the faces should be resolved
- Returns:
faces
- get_vertices(sort: bool = False) list
Get the vertices of the object. :param sort: Sort the vertices by z coordinate
- Returns:
vertices
- get_x() list
Get the x coordinates of the object. return: x coordinates
- get_y() list
Get the y coordinates of the object. return: y coordinates
- get_z() list
Get the z coordinates of the object. return: z coordinates
- has_faces() bool
Check if the object has faces.
- Returns:
True if the object has faces, False otherwise
- normalise(axis: str = 'z')
Normalise the object.
- Parameters:
axis – Axis to normalise
- update_from_faces(faces: list)
Update the object from the faces. This will reconstruct the vertices from the faces, it is assumed that the faces are given as a list of vertices.
- Parameters:
faces – Faces to update the object from