file_stl_object Derived Type

type, public :: file_stl_object

type~~file_stl_object~~InheritsGraph type~file_stl_object file_stl_object vector_R8P vector_R8P vector_R8P->type~file_stl_object bmin, bmax type~facet_object facet_object vector_R8P->type~facet_object normal, vertex_1, vertex_2, vertex_3, E12, E13, bb type~aabb_object aabb_object vector_R8P->type~aabb_object bmin, bmax type~facet_object->type~file_stl_object facet type~facet_object->type~aabb_object facet type~aabb_tree_object aabb_tree_object type~aabb_tree_object->type~file_stl_object aabb type~aabb_node_object aabb_node_object type~aabb_node_object->type~aabb_tree_object node type~aabb_object->type~aabb_node_object aabb
Help


FOSSIL STL file class.


Source Code


Components

TypeVisibility AttributesNameInitial
character(len=:), public, allocatable:: file_name

File name

integer(kind=I4P), public :: file_unit =0

File unit.

character(len=FRLEN), public :: header

File header.

integer(kind=I4P), public :: facets_number =0

Facets number.

type(facet_object), public, allocatable:: facet(:)

Facets.

type(aabb_tree_object), public :: aabb

AABB tree.

type(vector_R8P), public :: bmin

Minimum point of STL.

type(vector_R8P), public :: bmax

Maximum point of STL.

real(kind=R8P), public :: volume =0._R8P

Volume bounded by STL surface.

logical, public :: is_ascii =.true.

Sentinel to check if file is ASCII.

logical, public :: is_open =.false.

Sentinel to check if file is open.


Type-Bound Procedures

procedure, public, pass(self) :: analize

Analize STL.

  • private pure subroutine analize(self)

    Analize STL.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

procedure, public, pass(self) :: build_connectivity

Build facets connectivity.

  • private pure subroutine build_connectivity(self)

    Build facets connectivity.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

procedure, public, pass(self) :: close_file

Close file.

  • private subroutine close_file(self)

    Close file.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

procedure, public, pass(self) :: compute_metrix

Compute facets metrix.

  • private pure subroutine compute_metrix(self)

    Compute facets metrix.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

procedure, public, pass(self) :: compute_normals

Compute facets normals by means of vertices data.

  • private elemental subroutine compute_normals(self)

    Compute facets normals by means of vertices data.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

procedure, public, pass(self) :: compute_volume

Compute volume bounded by STL surface.

  • private elemental subroutine compute_volume(self)

    Compute volume bounded by STL surface.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

procedure, public, pass(self) :: create_aabb_tree

Create the AABB tree.

  • private subroutine create_aabb_tree(self, refinement_levels)

    Create AABB tree.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    integer(kind=I4P), intent(in), optional :: refinement_levels

    Total number of refinement levels used.

procedure, public, pass(self) :: destroy

Destroy file.

  • private elemental subroutine destroy(self)

    Destroy file.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

procedure, public, pass(self) :: distance

Compute the (minimum) distance from point to triangulated surface.

  • private pure function distance(self, point, is_signed, sign_algorithm, is_square_root)

    Compute the (minimum) distance from a point to the triangulated surface.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(in) :: self

    File STL.

    type(vector_R8P), intent(in) :: point

    Point coordinates.

    logical, intent(in), optional :: is_signed

    Sentinel to trigger signed distance.

    character(len=*), intent(in), optional :: sign_algorithm

    Algorithm used for "point in polyhedron" test.

    logical, intent(in), optional :: is_square_root

    Sentinel to trigger square-root distance.

    Return Value real(kind=R8P)

    Minimum distance from point to the triangulated surface.

procedure, public, pass(self) :: initialize

Initialize file.

  • private elemental subroutine initialize(self, skip_destroy, file_name, is_ascii)

    Initialize file.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    logical, intent(in), optional :: skip_destroy

    Flag to skip destroy file.

    character(len=*), intent(in), optional :: file_name

    File name.

    logical, intent(in), optional :: is_ascii

    Sentinel to check if file is ASCII.

procedure, public, pass(self) :: is_point_inside_polyhedron_ri

Determinate is point is inside or not STL facets by ray intersect.

  • private pure function is_point_inside_polyhedron_ri(self, point) result(is_inside)

    Determinate is a point is inside or not to a polyhedron described by STL facets by means ray intersections count.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(in) :: self

    File STL.

    type(vector_R8P), intent(in) :: point

    Point coordinates.

    Return Value logical

    Check result.

procedure, public, pass(self) :: is_point_inside_polyhedron_sa

Determinate is point is inside or not STL facets by solid angle.

  • private pure function is_point_inside_polyhedron_sa(self, point) result(is_inside)

    Determinate is a point is inside or not to a polyhedron described by STL facets by means of the solid angle criteria.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(in) :: self

    File STL.

    type(vector_R8P), intent(in) :: point

    Point coordinates.

    Return Value logical

    Check result.

procedure, public, pass(self) :: load_from_file

Load from file.

  • private subroutine load_from_file(self, file_name, is_ascii, guess_format, disable_analysis)

    Load from file.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    character(len=*), intent(in), optional :: file_name

    File name.

    logical, intent(in), optional :: is_ascii

    Sentinel to check if file is ASCII.

    logical, intent(in), optional :: guess_format

    Sentinel to try to guess format directly from file.

    logical, intent(in), optional :: disable_analysis

    Sentinel to disable STL analysis.

generic, public :: mirror => mirror_by_normal, mirror_by_matrix

Mirror facets.

  • private elemental subroutine mirror_by_normal(self, normal, recompute_metrix)

    Mirror facets given normal of mirroring plane.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    type(vector_R8P), intent(in) :: normal

    Normal of mirroring plane.

    logical, intent(in), optional :: recompute_metrix

    Sentinel to activate metrix recomputation.

  • private pure subroutine mirror_by_matrix(self, matrix, recompute_metrix)

    Mirror facet given matrix (of mirroring).

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    real(kind=R8P), intent(in) :: matrix(3,3)

    Mirroring matrix.

    logical, intent(in), optional :: recompute_metrix

    Sentinel to activate metrix recomputation.

procedure, public, pass(self) :: open_file

Open file, once initialized.

  • private subroutine open_file(self, file_action, guess_format)

    Open file, once initialized.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    character(len=*), intent(in) :: file_action

    File action, "read" or "write".

    logical, intent(in), optional :: guess_format

    Sentinel to try to guess format directly from file.

procedure, public, pass(self) :: reverse_normals

Reverse facets normals.

  • private elemental subroutine reverse_normals(self)

    Reverse facets normals.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

procedure, public, pass(self) :: resize

Resize (scale) facets by x or y or z or vectorial factors.

  • private elemental subroutine resize(self, x, y, z, factor, recompute_metrix)

    Resize (scale) facets by x or y or z or vectorial factors.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    real(kind=R8P), intent(in), optional :: x

    Factor along x axis.

    real(kind=R8P), intent(in), optional :: y

    Factor along y axis.

    real(kind=R8P), intent(in), optional :: z

    Factor along z axis.

    type(vector_R8P), intent(in), optional :: factor

    Vectorial factor.

    logical, intent(in), optional :: recompute_metrix

    Sentinel to activate metrix recomputation.

generic, public :: rotate => rotate_by_axis_angle, rotate_by_matrix

Rotate facets.

  • private elemental subroutine rotate_by_axis_angle(self, axis, angle, recompute_metrix)

    Rotate facets given axis and angle.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    type(vector_R8P), intent(in) :: axis

    Axis of rotation.

    real(kind=R8P), intent(in) :: angle

    Angle of rotation.

    logical, intent(in), optional :: recompute_metrix

    Sentinel to activate metrix recomputation.

  • private pure subroutine rotate_by_matrix(self, matrix, recompute_metrix)

    Rotate facet given matrix (of ratation).

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    real(kind=R8P), intent(in) :: matrix(3,3)

    Rotation matrix.

    logical, intent(in), optional :: recompute_metrix

    Sentinel to activate metrix recomputation.

procedure, public, pass(self) :: sanitize_normals

Sanitize facets normals, make them consistent.

  • private pure subroutine sanitize_normals(self)

    Sanitize facets normals, make them consistent.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

procedure, public, pass(self) :: save_into_file

Save into file.

  • private subroutine save_into_file(self, file_name, is_ascii)

    Save into file.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    character(len=*), intent(in), optional :: file_name

    File name.

    logical, intent(in), optional :: is_ascii

    Sentinel to check if file is ASCII.

procedure, public, pass(self) :: statistics

Return STL statistics.

  • private pure function statistics(self, prefix) result(stats)

    Return STL statistics.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(in) :: self

    File STL.

    character(len=*), intent(in), optional :: prefix

    Lines prefix.

    Return Value character(len=:), allocatable

    STL statistics.

procedure, public, pass(self) :: translate

Translate facet given vectorial delta.

  • private elemental subroutine translate(self, x, y, z, delta, recompute_metrix)

    Translate facets x or y or z or vectorial delta increments.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    real(kind=R8P), intent(in), optional :: x

    Increment along x axis.

    real(kind=R8P), intent(in), optional :: y

    Increment along y axis.

    real(kind=R8P), intent(in), optional :: z

    Increment along z axis.

    type(vector_R8P), intent(in), optional :: delta

    Vectorial increment.

    logical, intent(in), optional :: recompute_metrix

    Sentinel to activate metrix recomputation.

generic, public :: assignment(=) => file_stl_assign_file_stl

Overload =.

procedure, private, pass(lhs) :: file_stl_assign_file_stl

Operator =.

procedure, private, pass(self) :: allocate_facets

Allocate facets.

  • private elemental subroutine allocate_facets(self)

    Allocate facets.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

procedure, private, pass(self) :: load_facets_number_from_file

Load facets number from file.

procedure, private, pass(self) :: load_header_from_file

Load header from file.

procedure, private, pass(self) :: mirror_by_normal

Mirror facets given normal of mirroring plane.

  • private elemental subroutine mirror_by_normal(self, normal, recompute_metrix)

    Mirror facets given normal of mirroring plane.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    type(vector_R8P), intent(in) :: normal

    Normal of mirroring plane.

    logical, intent(in), optional :: recompute_metrix

    Sentinel to activate metrix recomputation.

procedure, private, pass(self) :: mirror_by_matrix

Mirror facets given matrix.

  • private pure subroutine mirror_by_matrix(self, matrix, recompute_metrix)

    Mirror facet given matrix (of mirroring).

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    real(kind=R8P), intent(in) :: matrix(3,3)

    Mirroring matrix.

    logical, intent(in), optional :: recompute_metrix

    Sentinel to activate metrix recomputation.

procedure, private, pass(self) :: rotate_by_axis_angle

Rotate facets given axis and angle.

  • private elemental subroutine rotate_by_axis_angle(self, axis, angle, recompute_metrix)

    Rotate facets given axis and angle.

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    type(vector_R8P), intent(in) :: axis

    Axis of rotation.

    real(kind=R8P), intent(in) :: angle

    Angle of rotation.

    logical, intent(in), optional :: recompute_metrix

    Sentinel to activate metrix recomputation.

procedure, private, pass(self) :: rotate_by_matrix

Rotate facets given matrix.

  • private pure subroutine rotate_by_matrix(self, matrix, recompute_metrix)

    Rotate facet given matrix (of ratation).

    Arguments

    Type IntentOptional AttributesName
    class(file_stl_object), intent(inout) :: self

    File STL.

    real(kind=R8P), intent(in) :: matrix(3,3)

    Rotation matrix.

    logical, intent(in), optional :: recompute_metrix

    Sentinel to activate metrix recomputation.

procedure, private, pass(self) :: save_header_into_file

Save header into file.

procedure, private, pass(self) :: save_trailer_into_file

Save trailer into file.

Source Code

type :: file_stl_object
   !< FOSSIL STL file class.
   character(len=:), allocatable   :: file_name       !< File name
   integer(I4P)                    :: file_unit=0     !< File unit.
   character(FRLEN)                :: header          !< File header.
   integer(I4P)                    :: facets_number=0 !< Facets number.
   type(facet_object), allocatable :: facet(:)        !< Facets.
   type(aabb_tree_object)          :: aabb            !< AABB tree.
   type(vector_R8P)                :: bmin            !< Minimum point of STL.
   type(vector_R8P)                :: bmax            !< Maximum point of STL.
   real(R8P)                       :: volume=0._R8P   !< Volume bounded by STL surface.
   logical                         :: is_ascii=.true. !< Sentinel to check if file is ASCII.
   logical                         :: is_open=.false. !< Sentinel to check if file is open.
   contains
      ! public methods
      procedure, pass(self) :: analize                         !< Analize STL.
      procedure, pass(self) :: build_connectivity              !< Build facets connectivity.
      procedure, pass(self) :: close_file                      !< Close file.
      procedure, pass(self) :: compute_metrix                  !< Compute facets metrix.
      procedure, pass(self) :: compute_normals                 !< Compute facets normals by means of vertices data.
      procedure, pass(self) :: compute_volume                  !< Compute volume bounded by STL surface.
      procedure, pass(self) :: create_aabb_tree                !< Create the AABB tree.
      procedure, pass(self) :: destroy                         !< Destroy file.
      procedure, pass(self) :: distance                        !< Compute the (minimum) distance from point to triangulated surface.
      procedure, pass(self) :: initialize                      !< Initialize file.
      procedure, pass(self) :: is_point_inside_polyhedron_ri   !< Determinate is point is inside or not STL facets by ray intersect.
      procedure, pass(self) :: is_point_inside_polyhedron_sa   !< Determinate is point is inside or not STL facets by solid angle.
      procedure, pass(self) :: load_from_file                  !< Load from file.
      generic               :: mirror => mirror_by_normal, &
                                         mirror_by_matrix      !< Mirror facets.
      procedure, pass(self) :: open_file                       !< Open file, once initialized.
      procedure, pass(self) :: reverse_normals                 !< Reverse facets normals.
      procedure, pass(self) :: resize                          !< Resize (scale) facets by x or y or z or vectorial factors.
      generic               :: rotate => rotate_by_axis_angle, &
                                         rotate_by_matrix      !< Rotate facets.
      procedure, pass(self) :: sanitize_normals                !< Sanitize facets normals, make them consistent.
      procedure, pass(self) :: save_into_file                  !< Save into file.
      procedure, pass(self) :: statistics                      !< Return STL statistics.
      procedure, pass(self) :: translate                       !< Translate facet given vectorial delta.
      ! operators
      generic :: assignment(=) => file_stl_assign_file_stl       !< Overload `=`.
      procedure, pass(lhs),  private :: file_stl_assign_file_stl !< Operator `=`.
      ! private methods
      procedure, pass(self), private :: allocate_facets              !< Allocate facets.
      procedure, pass(self), private :: load_facets_number_from_file !< Load facets number from file.
      procedure, pass(self), private :: load_header_from_file        !< Load header from file.
      procedure, pass(self), private :: mirror_by_normal             !< Mirror facets given normal of mirroring plane.
      procedure, pass(self), private :: mirror_by_matrix             !< Mirror facets given matrix.
      procedure, pass(self), private :: rotate_by_axis_angle         !< Rotate facets given axis and angle.
      procedure, pass(self), private :: rotate_by_matrix             !< Rotate facets given matrix.
      procedure, pass(self), private :: save_header_into_file        !< Save header into file.
      procedure, pass(self), private :: save_trailer_into_file       !< Save trailer into file.
endtype file_stl_object