This subroutine reads the number of nodes and triangles from a given binary stl file.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=PathLen), | intent(in) | :: | filename | name of the binary stl file |
||
integer, | intent(out) | :: | nNodes | number of nodes in the file |
||
integer, | intent(out) | :: | nTris | number of triangles in the file |
subroutine tem_size_stlb( filename, nNodes, nTris )
! ---------------------------------------------------------------------------
!> name of the binary stl file
character(len=PathLen),intent(in) :: filename
!> number of nodes in the file
integer,intent(out) :: nNodes
!> number of triangles in the file
integer,intent(out) :: nTris
! ---------------------------------------------------------------------------
character(len=LabelLen) :: header
integer :: stlUnit
integer :: ierr
logical :: file_exists
! ---------------------------------------------------------------------------
stlUnit = newUnit()
inquire(file = trim(filename), exist = file_exists)
if( .not. file_exists) then
write(logUnit(0),*) trim(filename)//" file was not found. Dying..."
call tem_abort()
endif
open(unit = stlUnit, file = trim(filename), access = 'stream', &
& action = 'read', status = 'old', iostat = ierr)
if(ierr .ne. 0)then
write(logUnit(0),*) "Error opening file "//trim(filename)
call tem_abort()
end if
read(stlUnit) header
read(stlUnit) nTris
nNodes = nTris * 3
close(stlUnit)
end subroutine tem_size_stlb