110     logical :: initialized = .false.
 
  111     real(kind=
dp) :: box_min(3) = huge(0.0_dp)
 
  112     real(kind=
dp) :: box_max(3) = -huge(0.0_dp)
 
  113     real(kind=
dp) :: center(3) = 0.0_dp
 
  114     real(kind=
dp) :: diameter = huge(0.0_dp)
 
  115     real(kind=
dp) :: surface_area = 0.0_dp
 
  136     generic :: 
operator(.lt.) => less
 
  137     generic :: 
operator(.gt.) => greater
 
 
  184    class(*), 
intent(in) :: object
 
  185    real(kind=
dp), 
intent(in), 
optional :: padding
 
  191       call box%init(object%get_min(), object%get_max())
 
  214       call neko_error(
"get_aabb: Unsupported object type")
 
  217    if (
present(padding)) 
then 
  218       call box%add_padding(padding)
 
 
  229    class(
aabb_t), 
intent(inout) :: this
 
  230    real(kind=
dp), 
intent(in) :: padding
 
  231    real(kind=
dp) :: box_min(3), box_max(3)
 
  233    box_min = this%box_min - padding * (this%diameter)
 
  234    box_max = this%box_max + padding * (this%diameter)
 
  236    call this%init(box_min, box_max)
 
 
  247    type(
point_t), 
intent(in) :: object
 
  251    real(kind=
dp) :: box_min(3), box_max(3)
 
  253    box_min = huge(0.0_dp)
 
  254    box_max = -huge(0.0_dp)
 
  255    box_min = min(box_min, object%x)
 
  256    box_max = 
max(box_max, object%x)
 
  257    call box%init(box_min, box_max)
 
 
  275    real(kind=
dp) :: box_min(3), box_max(3)
 
  277    box_min = huge(0.0_dp); box_max = -huge(0.0_dp)
 
  279    do i = 1, object%n_points()
 
  281       box_min = min(box_min, pi%x)
 
  282       box_max = 
max(box_max, pi%x)
 
  285    call box%init(box_min, box_max)
 
 
  297    type(
mesh_t), 
intent(in) :: object
 
  303    do i = 1, object%nelv
 
  304       temp_box = 
get_aabb(object%elements(i))
 
  305       box = 
merge(box, temp_box)
 
 
  325    do i = 1, object%nelv
 
  327       box = 
merge(box, temp_box)
 
 
  347    do i = 1, object%nelv
 
  349       box = 
merge(box, temp_box)
 
 
  362  subroutine aabb_init(this, lower_left_front, upper_right_back)
 
  363    class(
aabb_t), 
intent(inout) :: this
 
  364    real(kind=
dp), 
dimension(3), 
intent(in) :: lower_left_front
 
  365    real(kind=
dp), 
dimension(3), 
intent(in) :: upper_right_back
 
  367    this%initialized = .true.
 
  368    this%box_min = lower_left_front
 
  369    this%box_max = upper_right_back
 
  370    this%center = (this%box_min + this%box_max) / 2.0_dp
 
  371    this%diameter = norm2(this%box_max - this%box_min)
 
  373    this%surface_area = this%calculate_surface_area()
 
 
  383    class(
aabb_t), 
intent(in) :: this
 
  384    real(kind=
dp), 
dimension(3) :: min
 
 
  391    class(
aabb_t), 
intent(in) :: this
 
  392    real(kind=
dp), 
dimension(3) :: 
max 
 
  399    class(
aabb_t), 
intent(in) :: this
 
  400    real(kind=
dp) :: width
 
  402    width = this%box_max(1) - this%box_min(1)
 
 
  407    class(
aabb_t), 
intent(in) :: this
 
  408    real(kind=
dp) :: depth
 
  410    depth = this%box_max(2) - this%box_min(2)
 
 
  415    class(
aabb_t), 
intent(in) :: this
 
  416    real(kind=
dp) :: height
 
  418    height = this%box_max(3) - this%box_min(3)
 
 
  423    class(
aabb_t), 
intent(in) :: this
 
  424    real(kind=
dp) :: diameter
 
  426    diameter = this%diameter
 
 
  431    class(
aabb_t), 
intent(in) :: this
 
  432    real(kind=
dp) :: surface_area
 
  434    surface_area = this%surface_area
 
 
  439    class(
aabb_t), 
intent(in) :: this
 
  440    real(kind=
dp), 
dimension(3) :: center
 
 
  447    class(
aabb_t), 
intent(in) :: this
 
  448    real(kind=
dp), 
dimension(3) :: diagonal
 
  450    diagonal = this%box_max - this%box_min
 
 
  459    class(
aabb_t), 
intent(in) :: this
 
  460    class(
aabb_t), 
intent(in) :: other
 
  461    logical :: is_overlapping
 
  463    if (.not. this%initialized .or. .not. other%initialized) 
then 
  465       is_overlapping = .false.
 
  467       is_overlapping = all(this%box_min .le. other%box_max) .and. &
 
  468            all(this%box_max .ge. other%box_min)
 
 
  475    class(
aabb_t), 
intent(in) :: this
 
  476    class(
aabb_t), 
intent(in) :: other
 
  477    logical :: is_contained
 
  483    is_contained = all(this%box_min .le. other%box_min) .and. &
 
  484         all(this%box_max .ge. other%box_max)
 
 
  490    class(
aabb_t), 
intent(in) :: this
 
  491    real(kind=
dp), 
dimension(3), 
intent(in) :: p
 
  492    logical :: is_contained
 
  498    is_contained = all(p .ge. this%box_min) .and. all(p .le. this%box_max)
 
 
  507    class(
aabb_t), 
intent(in) :: box1
 
  508    class(
aabb_t), 
intent(in) :: box2
 
  511    real(kind=
dp), 
dimension(3) :: box_min, box_max
 
  513    box_min = min(box1%box_min, box2%box_min)
 
  514    box_max = 
max(box1%box_max, box2%box_max)
 
  516    call merged%init(box_min, box_max)
 
 
  521    class(
aabb_t), 
intent(in) :: box1
 
  522    class(
aabb_t), 
intent(in) :: box2
 
  523    type(
aabb_t) :: intersected
 
  525    real(kind=
dp), 
dimension(3) :: box_min, box_max
 
  527    box_min = 
max(box1%box_min, box2%box_min)
 
  528    box_max = min(box1%box_max, box2%box_max)
 
  530    call intersected%init(box_min, box_max)
 
 
  539    class(
aabb_t), 
intent(in) :: this
 
  540    real(kind=
dp) :: surface_area
 
  542    surface_area = 2.0 * ( &
 
  543         this%get_width() * this%get_height() &
 
  544         + this%get_width() * this%get_depth() &
 
  545         + this%get_height() * this%get_depth())
 
 
  554    class(
aabb_t), 
intent(in) :: this
 
  555    class(
aabb_t), 
intent(in) :: other
 
  559    if (.not. this%initialized .or. .not. other%initialized) 
then 
  564    aabb_less = this%box_min(1) .lt. other%box_min(1)
 
  565    equal = this%box_min(1) .le. other%box_min(1)
 
  568       aabb_less = this%box_min(2) .lt. other%box_min(2)
 
  569       equal = this%box_min(2) .le. other%box_min(2)
 
  572       aabb_less = this%box_min(3) .lt. other%box_min(3)
 
  573       equal = this%box_min(3) .le. other%box_min(3)
 
  576       aabb_less = this%box_max(1) .lt. other%box_max(1)
 
  577       equal = this%box_max(1) .le. other%box_max(1)
 
  580       aabb_less = this%box_max(2) .lt. other%box_max(2)
 
  581       equal = this%box_max(2) .le. other%box_max(2)
 
  584       aabb_less = this%box_max(3) .lt. other%box_max(3)
 
 
  591    class(
aabb_t), 
intent(in) :: this
 
  592    class(
aabb_t), 
intent(in) :: other
 
  596    if (.not. this%initialized .or. .not. other%initialized) 
then 
  602    equal = this%box_min(1) .ge. other%box_min(1)
 
  606       equal = this%box_min(2) .ge. other%box_min(2)
 
  610       equal = this%box_min(3) .ge. other%box_min(3)
 
  614       equal = this%box_max(1) .ge. other%box_max(1)
 
  618       equal = this%box_max(2) .ge. other%box_max(2)
 
 
Axis Aligned Bounding Box (aabb) implementation in Fortran.
 
pure real(kind=dp) function, dimension(3) aabb_get_max(this)
Get the maximum point of the aabb.
 
pure real(kind=dp) function aabb_get_surface_area(this)
Get the surface area of the aabb.
 
pure real(kind=dp) function aabb_get_diameter(this)
Get the diameter length of the aabb.
 
subroutine add_padding(this, padding)
Add padding to the aabb.
 
logical function aabb_contains_point(this, p)
Check if this aabb contains a point.
 
subroutine aabb_init(this, lower_left_front, upper_right_back)
Initialize the aabb.
 
type(aabb_t) function get_aabb_point(object)
Get the aabb of a point.
 
type(aabb_t) function get_aabb_tri_mesh(object)
Get the aabb of a triangular mesh.
 
logical function aabb_overlaps(this, other)
Check if two aabbs are overlapping.
 
type(aabb_t) function get_aabb_mesh(object)
Get the aabb of a mesh.
 
type(aabb_t) function intersection_aabb(box1, box2)
Get the intersection of two aabbs.
 
pure real(kind=dp) function aabb_get_height(this)
Get the height of the aabb. Also known as the z-axis length.
 
pure logical function aabb_greater(this, other)
Greater than comparison operator.
 
type(aabb_t) function, public get_aabb(object, padding)
Construct the aabb of a predefined object.
 
logical function aabb_contains_other(this, other)
Check if this aabb contains another aabb.
 
pure real(kind=dp) function calculate_surface_area(this)
Calculate the surface area of the aabb.
 
pure logical function aabb_less(this, other)
Less than comparison operator.
 
type(aabb_t) function get_aabb_element(object)
Get the aabb of an arbitrary element.
 
type(aabb_t) function get_aabb_tet_mesh(object)
Get the aabb of a tetrahedral mesh.
 
pure real(kind=dp) function, dimension(3) aabb_get_center(this)
Get the center of the aabb.
 
pure real(kind=dp) function aabb_get_width(this)
Get the width of the aabb. Also known as the x-axis length.
 
pure real(kind=dp) function, dimension(3) aabb_get_diagonal(this)
Get the diagonal of the aabb.
 
type(aabb_t) function merge_aabb(box1, box2)
Merge two aabbs.
 
pure real(kind=dp) function aabb_get_depth(this)
Get the depth of the aabb. Also known as the y-axis length.
 
pure real(kind=dp) function, dimension(3) aabb_get_min(this)
Get the minimum point of the aabb.
 
Defines a hexahedron element.
 
integer, parameter, public dp
 
Defines a quadrilateral element.
 
Defines a tetrahedral mesh.
 
Defines a tetrahedral element.
 
Defines a triangular surface mesh.
 
Defines a triangular element.
 
Axis Aligned Bounding Box (aabb) data structure.
 
Base type for an element.
 
A point in  with coordinates .