Read in all STL files from disk which are specified in the config file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(tem_stlData_type), | intent(inout) | :: | stl_data |
stl data of current spatial object |
subroutine tem_read_stlFiles( stl_data )
! ---------------------------------------------------------------------------!
!> stl data of current spatial object
type( tem_stlData_type ), intent(inout) :: stl_data
! ---------------------------------------------------------------------------!
!local variable
integer :: nodeOffset !< Offset in the nodelist for multiple STLs
integer :: triOffset !< Offset in the trilist for multiple STLs
integer :: iFile, ierr
integer :: nNodes
integer :: nTris !< total number of triangles loaded
! ---------------------------------------------------------------------------!
write(logunit(1),*) " Reading in STL Headers ..."
! Read headerfiles to determine number of nodes and tris
do iFile = 1, size(stl_data%head)
select case( stl_data%head(iFile)%fileformat )
case( stl_ascii )
call stla_size( trim(stl_data%head(iFile)%filename), &
& stl_data%head(iFile)%nSolids, &
& stl_data%head(iFile)%nNodes, &
& stl_data%head(iFile)%nTris, &
& stl_data%head(iFile)%nTexts)
case( stl_bin )
call tem_size_stlb( stl_data%head(iFile)%filename, &
& stl_data%head(iFile)%nNodes, &
& stl_data%head(iFile)%nTris)
end select
end do
!Sum over all read in STL Files to generate one list of elements in the end
nTris = 0
nNodes = 0
do iFile = 1, size(stl_data%head)
nTris = nTris + stl_data%head(iFile)%nTris
nNodes = nNodes + stl_data%head(iFile)%nNodes
end do
write(logunit(5),"(A,I0)") " Total number of triangles: ", nTris
write(logunit(5),"(A,I0)") " Total number of nodes: ", nNodes
!allocate node and triangle arrays
stl_data%nNodes = nNodes
stl_data%nTris = nTris
allocate(stl_data%nodes(1:3,nNodes))
allocate(stl_data%tri_node(1:3,nTris))
! Read in node values from STL files to stl_data%nodes
! Store three nodes position of each triangle to stl_date%tri_node
write(logunit(1),*) " Reading in STL Files ..."
nodeOffset = 1
triOffset = 1
do iFile = 1, size(stl_data%head)
select case(stl_data%head(iFile)%fileformat)
case(stl_ascii)
call stla_read(input_file_name = trim(stl_data%head(iFile)%filename), &
& node_num = stl_data%head(iFile)%nNodes, &
& face_num = stl_data%head(iFile)%nTris, &
& node_xyz = stl_data%nodes(1:3,nodeOffset:nodeOffset+stl_data%head(iFile)%nNodes-1), &
& face_node = stl_data%tri_node(1:3,triOffset:triOffset+stl_data%head(iFile)%nTris-1), &
& ierror = ierr)
case(stl_bin)
call tem_read_stlb(filename = stl_data%head(iFile)%filename, &
& nNodesRead = stl_data%head(iFile)%nNodes, &
& nTrisRead = stl_data%head(iFile)%nTris, &
& nodes = stl_data%nodes(1:3,nodeOffset:nodeOffset+stl_data%head(iFile)%nNodes-1), &
& tri_node = stl_data%tri_node(1:3,triOffset:triOffset+stl_data%head(iFile)%nTris-1), &
& ierror = ierr)
end select
stl_data%tri_node(1:3,triOffset:triOffset+stl_data%head(iFile)%nTris-1) = &
& stl_data%tri_node(1:3,triOffset:triOffset+stl_data%head(iFile)%nTris-1) + (nodeOffset-1)
nodeOffset = nodeOffset + stl_data%head(iFile)%nNodes
triOffset = triOffset + stl_data%head(iFile)%nTris
end do
write(logunit(1),*) " Done."
end subroutine tem_read_stlFiles