def __init__(self, vertices=None, normals=None, indices=None, colors=None, uvs=None, file_name=None, center_position=None, type=MeshType.faces): self._vertices = NumPyUtil.immutableNDArray(vertices) self._normals = NumPyUtil.immutableNDArray(normals) self._indices = NumPyUtil.immutableNDArray(indices) self._colors = NumPyUtil.immutableNDArray(colors) self._uvs = NumPyUtil.immutableNDArray(uvs) self._vertex_count = len( self._vertices) if self._vertices is not None else 0 self._face_count = len( self._indices) if self._indices is not None else 0 self._type = type self._file_name = file_name # original center position self._center_position = center_position self._convex_hull = None # type: scipy.spatial.qhull.ConvexHull self._convex_hull_vertices = None self._convex_hull_lock = threading.Lock()
def __init__(self, vertices=None, normals=None, indices=None, colors=None, uvs=None, file_name=None, center_position=None): self._vertices = NumPyUtil.immutableNDArray(vertices) self._normals = NumPyUtil.immutableNDArray(normals) self._indices = NumPyUtil.immutableNDArray(indices) self._colors = NumPyUtil.immutableNDArray(colors) self._uvs = NumPyUtil.immutableNDArray(uvs) self._vertex_count = len(self._vertices) if self._vertices is not None else 0 self._face_count = len(self._indices) if self._indices is not None else 0 self._type = MeshType.faces self._file_name = file_name # original center position self._center_position = center_position self._convex_hull = None # type: scipy.spatial.qhull.ConvexHull self._convex_hull_vertices = None self._convex_hull_lock = threading.Lock()
def invertNormals(self) -> None: if self._normals is not None: mirror = Matrix() mirror.setToIdentity() mirror.scaleByFactor(-1.0) self._normals = transformNormals(self._normals, mirror) if self._indices is not None: new_indices = [] for face in self._indices: new_indices.append([face[1], face[0], face[2]]) self._indices = NumPyUtil.immutableNDArray(new_indices) else: new_vertices = [] num_vertices = len(self._vertices) for i in range(0, num_vertices, 3): new_vertices.append(self._vertices[i + 1]) new_vertices.append(self._vertices[i]) new_vertices.append(self._vertices[i + 2]) self._vertices = NumPyUtil.immutableNDArray(new_vertices)
def __init__(self, vertices=None, normals=None, indices=None, colors=None, uvs=None, file_name=None, center_position=None, zero_position=None, type = MeshType.faces, attributes=None): self._vertices = NumPyUtil.immutableNDArray(vertices) self._normals = NumPyUtil.immutableNDArray(normals) self._indices = NumPyUtil.immutableNDArray(indices) self._colors = NumPyUtil.immutableNDArray(colors) self._uvs = NumPyUtil.immutableNDArray(uvs) self._vertex_count = len(self._vertices) if self._vertices is not None else 0 self._face_count = len(self._indices) if self._indices is not None else 0 self._type = type self._file_name = file_name # type: str # original center position self._center_position = center_position # original zero position, is changed after transformation if zero_position is not None: self._zero_position = zero_position else: self._zero_position = Vector(0, 0, 0) # type: Vector self._convex_hull = None # type: Optional[scipy.spatial.ConvexHull] self._convex_hull_vertices = None # type: Optional[numpy.ndarray] self._convex_hull_lock = threading.Lock() self._attributes = {} if attributes is not None: for key, attribute in attributes.items(): new_value = {} for attribute_key, attribute_value in attribute.items(): if attribute_key == "value": new_value["value"] = NumPyUtil.immutableNDArray(attribute_value) else: new_value[attribute_key] = attribute_value self._attributes[key] = new_value
def __init__(self, vertices=None, normals=None, indices=None, colors=None, uvs=None, file_name=None, center_position=None, zero_position=None, type = MeshType.faces, attributes=None): self._application = None # Initialize this later otherwise unit tests break self._vertices = NumPyUtil.immutableNDArray(vertices) self._normals = NumPyUtil.immutableNDArray(normals) self._indices = NumPyUtil.immutableNDArray(indices) self._colors = NumPyUtil.immutableNDArray(colors) self._uvs = NumPyUtil.immutableNDArray(uvs) self._vertex_count = len(self._vertices) if self._vertices is not None else 0 self._face_count = len(self._indices) if self._indices is not None else 0 self._type = type self._file_name = file_name # type: Optional[str] # original center position self._center_position = center_position # original zero position, is changed after transformation if zero_position is not None: self._zero_position = zero_position else: self._zero_position = Vector(0, 0, 0) # type: Vector self._convex_hull = None # type: Optional[scipy.spatial.ConvexHull] self._convex_hull_vertices = None # type: Optional[numpy.ndarray] self._convex_hull_lock = threading.Lock() self._attributes = {} if attributes is not None: for key, attribute in attributes.items(): new_value = {} for attribute_key, attribute_value in attribute.items(): if attribute_key == "value": new_value["value"] = NumPyUtil.immutableNDArray(attribute_value) else: new_value[attribute_key] = attribute_value self._attributes[key] = new_value
def __init__(self, vertices=None, normals=None, indices=None, colors=None, uvs=None, file_name=None, center_position=None, zero_position=None, type = MeshType.faces, attributes=None): self._application = None # Initialize this later otherwise unit tests break self._vertices = NumPyUtil.immutableNDArray(vertices) self._normals = NumPyUtil.immutableNDArray(normals) self._indices = NumPyUtil.immutableNDArray(indices) self._colors = NumPyUtil.immutableNDArray(colors) self._uvs = NumPyUtil.immutableNDArray(uvs) self._vertex_count = len(self._vertices) if self._vertices is not None else 0 self._face_count = len(self._indices) if self._indices is not None else 0 self._type = type self._file_name = file_name # type: Optional[str] if file_name: from UM.Application import Application self._application = Application.getInstance() self._application.getController().getScene().addWatchedFile(file_name) # original center position self._center_position = center_position # original zero position, is changed after transformation if zero_position is not None: self._zero_position = zero_position else: self._zero_position = Vector(0, 0, 0) # type: Vector self._convex_hull = None # type: Optional[scipy.spatial.ConvexHull] self._convex_hull_vertices = None # type: Optional[numpy.ndarray] self._convex_hull_lock = threading.Lock() self._attributes = {} if attributes is not None: for key, attribute in attributes.items(): new_value = {} for attribute_key, attribute_value in attribute.items(): if attribute_key == "value": new_value["value"] = NumPyUtil.immutableNDArray(attribute_value) else: new_value[attribute_key] = attribute_value self._attributes[key] = new_value
def __init__(self, points=None): self._points = NumPyUtil.immutableNDArray(points)
def __init__(self, points: Optional[Union[numpy.ndarray, List]] = None): if points is not None: self._points = NumPyUtil.immutableNDArray(points) else: self._points = NumPyUtil.immutableNDArray([])
def __init__(self, points = None): self._points = NumPyUtil.immutableNDArray(points)