Compute the scale factor for the vertices (for writing to a file).
Type | Intent | Optional | 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) |
scale factor
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