KDClass Module



Variables

Type Visibility Attributes Name Initial
integer, public :: BoxIndex
integer, public :: LastLevel = -1
integer, public :: depth
integer, public :: NumOfObjsIndx
integer, public :: NumOfKDtreePoints
integer, public, parameter :: side_L = 4
integer, public, parameter :: side_R = 0
integer, public, parameter :: ON_PLANE = 0
integer, public, parameter :: POINTS_KDTREE = 0
integer, public, parameter :: TRIANGLES_KDTREE_SAH = 1
integer, public, parameter :: TRIANGLES_KDTREE_MEDIAN = 2
integer, public, parameter :: START_ = 2
integer, public, parameter :: END_ = 0
integer, public, parameter :: PLANAR_ = 1
integer, public, parameter :: ONLYLEFT = 0
integer, public, parameter :: ONLYRIGHT = 1
integer, public, parameter :: BOTH = 2
integer, public, parameter :: ODD = 1
integer, public, parameter :: EVEN = 2
integer, public, parameter :: BREADTHFIRST = 1
integer, public, parameter :: DEPTHFIRST = 0
real(kind=rp), public, parameter :: C_TRANSVERSE = 1.0_RP
real(kind=rp), public, parameter :: C_INTERSECT = 1.5_RP
real(kind=rp), public, parameter :: C_1 = 1.2_RP
real(kind=rp), public, parameter :: C_2 = 2.0_RP
integer, public, parameter, dimension(8) :: vertices_x = (/1, 4, 5, 8, 2, 3, 6, 7/)
integer, public, parameter, dimension(8) :: vertices_y = (/1, 2, 6, 5, 3, 4, 7, 8/)
integer, public, parameter, dimension(8) :: vertices_z = (/1, 2, 3, 4, 5, 6, 7, 8/)

Derived Types

type, public ::  Event

Components

Type Visibility Attributes Name Initial
real(kind=rp), public :: plane
real(kind=rp), public :: median
integer, public :: eType
integer, public :: index
integer, public :: axis

type, public ::  KDtree

Components

Type Visibility Attributes Name Initial
class(KDtree), public, pointer :: child_L
class(KDtree), public, pointer :: child_R
class(KDtree), public, pointer :: parent
type(Object_type), public, dimension(:), allocatable :: ObjectsList
real(kind=rp), public, dimension(3,8) :: vertices
integer, public :: NumOfObjs
integer, public :: level
integer, public :: axis
integer, public :: index
integer, public :: Min_n_of_Objs
integer, public :: which_KDtree
integer, public :: MaxAxis
integer, public :: SIDE
integer, public :: N_L
integer, public :: N_R
integer, public :: N_B
integer, public :: HalfEvents
integer, public :: NumThreads
integer, public :: STLNum
logical, public :: isLast
logical, public :: Split
logical, public :: built_R = .false.
logical, public :: built_L = .false.
integer, public, dimension(NDIM) :: NumOfEvents
real(kind=rp), public :: S
real(kind=rp), public :: SplitCost
real(kind=rp), public :: SplittingPlane
type(Event), public, dimension(:,:), allocatable :: Events
integer, public, dimension(:), allocatable :: ObjsIndeces

Type-Bound Procedures

procedure, public :: construct => KDtree_construct
procedure, public :: SetUpRoot => KDtree_SetUpRoot
procedure, public :: FindLeaf => KDtree_FindLeaf
procedure, public :: plot => KDtree_plot
procedure, public :: plotBlock => KDtree_plotBlock
procedure, public :: Destruct => KD_treeDestruct
procedure, public :: GetArea => KD_treeGetArea
procedure, public :: BuildChild => KDtree_BuildChild
procedure, public :: EvaluateCostSAH => KDtree_EvaluateCostSAH
procedure, public :: EvaluateCostMEDIAN => KDtree_EvaluateCostMEDIAN
procedure, public :: SaveObjsIndeces => KDtree_SaveObjsIndeces
procedure, public :: SavePointsIndeces => KDtree_SavePointsIndeces

type, public ::  DepthFirst_type

Components

Type Visibility Attributes Name Initial
type(KDtree), public, pointer :: taskTree
type(Event), public, dimension(:,:), allocatable :: taskEvents
logical, public :: active = .false.

type, public ::  taskPart_dim_type

Components

Type Visibility Attributes Name Initial
real(kind=RP), public :: splittingPlane
integer, public :: N_L
integer, public :: N_R
integer, public :: N_P
integer, public :: ChunkDim
integer, public :: Starting_index
integer, public :: Values2Check

type, public ::  taskSAH_type

Components

Type Visibility Attributes Name Initial
real(kind=RP), public :: SplitCost
real(kind=RP), public :: splittingPlane
integer, public :: axis
integer, public :: SIDE
logical, public :: split = .false.

type, public ::  taskPart_type

Components

Type Visibility Attributes Name Initial
type(taskPart_dim_type), public, dimension(NDIM) :: taskPartDim

Functions

public function AxisIndex(i) result(axis)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: i

Return Value integer

public function FindAxis(this) result(FirstAxis)

Arguments

Type IntentOptional Attributes Name
type(KDtree), intent(in) :: this

Return Value integer

public function computeSplittingCost(S, S_L, S_R, N_L, N_R) result(SplittingCost)

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in) :: S
real(kind=rp), intent(in) :: S_L
real(kind=rp), intent(in) :: S_R
integer, intent(in) :: N_L
integer, intent(in) :: N_R

Return Value real(kind=rp)

public function EventIsLess(EventA, EventB) result(IsLess)

Arguments

Type IntentOptional Attributes Name
type(Event), intent(in) :: EventA
type(Event), intent(in) :: EventB

Return Value logical

public function TrinagleIntersectBox(vertices, Triangle) result(inside)

Arguments

Type IntentOptional Attributes Name
real(kind=rp), intent(in) :: vertices(:,:)
type(Object_type), intent(in) :: Triangle

Return Value logical


Subroutines

public recursive subroutine Plot_leaves(tree, STLNum, funit, which_KDtree)

Arguments

Type IntentOptional Attributes Name
type(KDtree), intent(inout) :: tree
integer, intent(in) :: STLNum
integer, intent(in) :: funit
integer, intent(in) :: which_KDtree

public subroutine KDtree_plot(this, lvl)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout), target :: this
integer, intent(in), optional :: lvl

public subroutine KDtree_plotBlock(this, ObjectsList, STLNum, PlotObjs)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout) :: this
type(Object_type), intent(in) :: ObjectsList(:)
integer, intent(in) :: STLNum
logical, intent(in) :: PlotObjs

public subroutine KDtree_SetUpRoot(this, stl, Vertices, PointList)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout) :: this
type(STLfile), intent(in) :: stl
real(kind=RP), intent(in) :: Vertices(:,:)
type(point_type), intent(in), optional :: PointList(:)

public subroutine KDtree_construct(this, stl, Vertices, isPlot, Min_n_of_Objs, PointList, lvl)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout) :: this
type(STLfile), intent(in) :: stl
real(kind=RP), intent(in) :: Vertices(:,:)
logical, intent(in) :: isPlot
integer, intent(in) :: Min_n_of_Objs
type(point_type), intent(in), optional :: PointList(:)
integer, intent(in), optional :: lvl

public subroutine KDtree_FindLeaf(this, Point, tree, RIGHTCHILD)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout), target :: this
real(kind=rp), intent(in) :: Point(:)
type(KDtree), intent(inout), pointer :: tree
logical, intent(in) :: RIGHTCHILD

public recursive subroutine KD_treeDestruct(this, isChild)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout) :: this
logical, intent(in) :: isChild

public subroutine KD_treeGetArea(tree)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout) :: tree

public subroutine GetEvents(tree, Events, NumThreads)

Arguments

Type IntentOptional Attributes Name
type(KDtree), intent(inout) :: tree
type(Event), intent(inout) :: Events(:,:)
integer, intent(out) :: NumThreads

public subroutine GetPointsEvents(tree, Events, PointList, NumThreads)

Arguments

Type IntentOptional Attributes Name
type(KDtree), intent(inout) :: tree
type(Event), intent(inout) :: Events(:,:)
type(point_type), intent(in) :: PointList(:)
integer, intent(out) :: NumThreads

public recursive subroutine KDtree_buildTRIANGLES_BreadthFirst(this, Events, ObjsIndx, level, Depth_First)

Arguments

Type IntentOptional Attributes Name
type(KDtree), intent(inout), target :: this
type(Event), intent(inout), allocatable :: Events(:,:)
integer, intent(inout) :: ObjsIndx(:)
integer, intent(in) :: level
type(DepthFirst_type), intent(inout) :: Depth_First(:)

public recursive subroutine KDtree_buildTRIANGLES_DepthFirst(this, Events, ObjsIndx)

Arguments

Type IntentOptional Attributes Name
type(KDtree), intent(inout), target :: this
type(Event), intent(inout), allocatable :: Events(:,:)
integer, intent(inout) :: ObjsIndx(:)

public subroutine ComputeSplitSurface_L(tree, SplittingPlane, axis, S_L)

Arguments

Type IntentOptional Attributes Name
type(KDtree), intent(in) :: tree
real(kind=rp), intent(in) :: SplittingPlane
integer, intent(in) :: axis
real(kind=rp), intent(out) :: S_L

public subroutine ComputeSplitSurface_R(tree, SplittingPlane, axis, S_R)

Arguments

Type IntentOptional Attributes Name
type(KDtree), intent(in) :: tree
real(kind=rp), intent(in) :: SplittingPlane
integer, intent(in) :: axis
real(kind=rp), intent(out) :: S_R

public subroutine KDtree_EvaluateCostSAH(this, Events)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout) :: this
type(Event), intent(in) :: Events(:,:)

public subroutine KDtree_EvaluateCostMEDIAN(this, Events)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout) :: this
type(Event), intent(in) :: Events(:,:)

public subroutine Event_ClassifyObjs(this, tree, child_L, child_R, ObjsIndx)

Arguments

Type IntentOptional Attributes Name
type(Event), intent(in) :: this(:)
type(KDtree), intent(inout) :: tree
type(KDtree), intent(inout) :: child_L
type(KDtree), intent(inout) :: child_R
integer, intent(inout) :: ObjsIndx(:)

public subroutine KDtree_BuildChild(this, child, side)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout) :: this
type(KDtree), intent(inout) :: child
integer, intent(in) :: side

public subroutine Event_BuildLists(this, tree, child_L, child_R, ObjsIndx, Events_L, Events_R)

Arguments

Type IntentOptional Attributes Name
type(Event), intent(in) :: this(:,:)
type(KDtree), intent(in) :: tree
type(KDtree), intent(inout) :: child_L
type(KDtree), intent(inout) :: child_R
integer, intent(inout) :: ObjsIndx(:)
type(Event), intent(inout) :: Events_L(:,:)
type(Event), intent(inout) :: Events_R(:,:)

public subroutine KDtree_SaveObjsIndeces(this, Events)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout) :: this
type(Event), intent(in) :: Events(:,:)

public subroutine Event_Construct(this, ObjectsList, tree, axis)

Arguments

Type IntentOptional Attributes Name
type(Event), intent(inout) :: this(:)
type(Object_type), intent(in) :: ObjectsList(:)
type(KDtree), intent(inout) :: tree
integer, intent(in) :: axis

public recursive subroutine KDtree_buildPoints_BreadthFirst(this, Events, ObjsIndx, level, Depth_First)

Arguments

Type IntentOptional Attributes Name
type(KDtree), intent(inout), target :: this
type(Event), intent(inout), allocatable :: Events(:,:)
integer, intent(inout) :: ObjsIndx(:)
integer, intent(in) :: level
type(DepthFirst_type), intent(inout) :: Depth_First(:)

public recursive subroutine KDtree_buildPoints_DepthFirst(this, Events, ObjsIndx)

Arguments

Type IntentOptional Attributes Name
type(KDtree), intent(inout), target :: this
type(Event), intent(inout), allocatable :: Events(:,:)
integer, intent(inout) :: ObjsIndx(:)

public subroutine KDtree_SavePointsIndeces(this, Events)

Arguments

Type IntentOptional Attributes Name
class(KDtree), intent(inout) :: this
type(Event), intent(in) :: Events(:,:)

public subroutine Points_Event_ClassifyObjs(this, tree, child_L, child_R, ObjsIndx)

Arguments

Type IntentOptional Attributes Name
type(Event), intent(in) :: this(:)
type(KDtree), intent(inout) :: tree
type(KDtree), intent(inout) :: child_L
type(KDtree), intent(inout) :: child_R
integer, intent(inout) :: ObjsIndx(:)

public subroutine Points_Event_construct(this, tree, axis, PointList)

Arguments

Type IntentOptional Attributes Name
type(Event), intent(inout) :: this(:)
type(KDtree), intent(inout) :: tree
integer, intent(in) :: axis
type(point_type), intent(in) :: PointList(:)

public recursive subroutine QsortEvents(Events, startIdx, endIdx)

Arguments

Type IntentOptional Attributes Name
type(Event), intent(inout) :: Events(:)
integer, intent(in) :: startIdx
integer, intent(in) :: endIdx

public subroutine swapEvents(EventA, EventB)

Arguments

Type IntentOptional Attributes Name
type(Event), intent(inout) :: EventA
type(Event), intent(inout) :: EventB