コード例 #1
0
    def to_stl(self, filepath, precision=None, binary=False, **kwargs):
        """Write a mesh to an STL file.

        Parameters
        ----------
        filepath : str
            The path to the file.
        precision : str, optional
            Rounding precision for the vertex coordinates.
            Defaults to the value of :attr:`compas.PRECISION`.
        binary : bool, optional
            If True, the file will be written in binary format.
            ASCII otherwise.

        Returns
        -------
        None

        Notes
        -----
        STL files only support triangle faces.
        It is the user's responsibility to convert all faces of a mesh to triangles.
        For example, with :func:`compas.datastructures.mesh_quads_to_triangles`.

        """
        stl = STL(filepath, precision)
        stl.write(self, binary=binary, **kwargs)
コード例 #2
0
    def to_stl(self, filepath, precision=None, binary=False, **kwargs):
        """Write a mesh to an STL file.

        Parameters
        ----------
        filepath : str
            The path to the file.
        precision : str, optional
            Rounding precision for the vertex coordinates.
            Default is ``"3f"``.
        binary : bool, optional
            When ``False``, the file will be written in ASCII encoding,
            when ``True``, binary.  Default is ``False``.

        Returns
        -------
        None

        Notes
        -----
        STL files only support triangle faces.
        It is your responsibility to convert all faces of your mesh to triangles.
        For example, with :func:`compas.datastructures.mesh_quads_to_triangles`.
        """
        stl = STL(filepath, precision)
        stl.write(self, binary=binary, **kwargs)
コード例 #3
0
    def to_stl(self, filepath, precision=None, **kwargs):
        """Write a mesh to an STL file.

        Parameters
        ----------
        filepath : str
            The path to the file.
        precision : str, optional
            Rounding precision for the vertex coordinates.
            Default is ``"3f"``.

        Returns
        -------
        None

        Notes
        -----
        STL files only support triangle faces.
        However, the writer does not perform any checks
        and will just treat every face as a triangle.
        It is your responsibility to convert all faces of your mesh to triangles.
        For example, with :func:`compas.datastructures.mesh_quads_to_triangles`.
        """
        stl = STL(filepath, precision)
        stl.write(self, **kwargs)
コード例 #4
0
def test_binary_detection(ascii_stl, binary_stl, binary_stl_with_ascii_header):
    stl = STL(ascii_stl)
    assert len(stl.parser.vertices) > 0

    stl = STL(binary_stl)
    assert len(stl.parser.vertices) > 0

    stl = STL(binary_stl_with_ascii_header)
    assert len(stl.parser.vertices) > 0
コード例 #5
0
ファイル: mesh.py プロジェクト: rjodon-compas-forks/compas
    def from_stl(cls, filepath):
        """Construct a mesh object from the data described in a STL file.

        Parameters
        ----------
        filepath : str
            The path to the file.

        Returns
        -------
        Mesh :
            A mesh object.

        Note
        ----
        There are a few sample files available for testing and debugging:

        * cube_ascii.stl
        * cube_binary.stl

        Examples
        --------
        >>>
        """
        stl = STL(filepath)
        vertices = stl.parser.vertices
        faces = stl.parser.faces
        mesh = cls.from_vertices_and_faces(vertices, faces)
        return mesh
コード例 #6
0
ファイル: mesh.py プロジェクト: yishizu/compas
    def from_stl(cls, filepath, precision=None):
        """Construct a mesh object from the data described in a STL file.

        Parameters
        ----------
        filepath : str
            The path to the file.
        precision: str, optional
            The precision of the geometric map that is used to connect the lines.

        Returns
        -------
        Mesh :
            A mesh object.

        Note
        ----
        There are a few sample files available for testing and debugging:

        * cube_ascii.stl
        * cube_binary.stl

        Examples
        --------
        >>>
        """
        stl = STL(filepath, precision)
        vertices = stl.parser.vertices
        faces = stl.parser.faces
        mesh = cls.from_vertices_and_faces(vertices, faces)
        return mesh
コード例 #7
0
    def from_stl(cls, filepath, precision=None):
        """Construct a mesh object from the data described in a STL file.

        Parameters
        ----------
        filepath : str
            The path to the file.
        precision: str, optional
            The precision of the geometric map that is used to connect the lines.

        Returns
        -------
        :class:`compas.datastructures.Mesh`
            A mesh object.

        """
        stl = STL(filepath, precision)
        vertices = stl.parser.vertices
        faces = stl.parser.faces
        mesh = cls.from_vertices_and_faces(vertices, faces)
        return mesh
コード例 #8
0
ファイル: trimesh.py プロジェクト: tetov/compas_cgal
 def from_stl(cls, filepath, precision='3f'):
     """Construct a triangle mesh from the data in an STL file."""
     stl = STL(filepath, precision)
     return cls(stl.parser.vertices, stl.parser.faces)