compute_vertex_scale Function

private pure function compute_vertex_scale(me, bounding_box) result(scale)

Compute the scale factor for the vertices (for writing to a file).

Type Bound

stl_file

Arguments

Type IntentOptional Attributes Name
class(stl_file), intent(in) :: me
real(kind=wp), intent(in), optional :: bounding_box

scale vertices so that model fits in a box of this size (if <=0, no scaling is done)

Return Value real(kind=wp)

scale factor


Called by

proc~~compute_vertex_scale~~CalledByGraph proc~compute_vertex_scale stl_file%compute_vertex_scale proc~write_ascii_stl_file stl_file%write_ascii_stl_file proc~write_ascii_stl_file->proc~compute_vertex_scale proc~write_binary_stl_file stl_file%write_binary_stl_file proc~write_binary_stl_file->proc~compute_vertex_scale

Source Code

    pure function compute_vertex_scale(me,bounding_box) result(scale)

    implicit none

    class(stl_file),intent(in)    :: me
    real(wp),intent(in),optional  :: bounding_box  !! scale vertices so that model fits in a
                                                   !! box of this size (if <=0, no scaling is done)
    real(wp)                      :: scale         !! scale factor

    real(wp) :: max_value  !! largest absolute value of any vertex coordinate
    integer  :: i          !! counter

    scale = one
    if (present(bounding_box)) then
        if (bounding_box>zero) then
            max_value = -huge(one)
            do i = 1, size(me%plates)
                max_value = max(max_value, maxval(abs(me%plates(i)%v1)),&
                                           maxval(abs(me%plates(i)%v2)),&
                                           maxval(abs(me%plates(i)%v3)) )
            end do
            scale = bounding_box / max_value
        end if
    end if

    end function compute_vertex_scale