Commit 40f47289 authored by aarograh's avatar aarograh
Browse files

Add LineType .APPROXEQA. operator and new addVertex interface to GraphType

parent eb482f2b
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -146,10 +146,13 @@ TYPE :: GraphType
    !> @copybrief Geom_Graph::insertVertex_coords
    !> @copydetails Geom_Graph::insertVertex_coords
    PROCEDURE,PASS,PRIVATE :: insertVertex_coords
    !> @copybrief Geom_Graph::insertVertex_coords_array
    !> @copydetails Geom_Graph::insertVertex_coords_array
    PROCEDURE,PASS,PRIVATE :: insertVertex_coords_array
    !> @copybrief Geom_Graph::insertVertex_point
    !> @copydetails Geom_Graph::insertVertex_point
    PROCEDURE,PASS,PRIVATE :: insertVertex_point
    GENERIC :: insertVertex => insertVertex_coords,insertVertex_point
    GENERIC :: insertVertex => insertVertex_coords,insertVertex_point,insertVertex_coords_array
    !> @copybrief Geom_Graph::defineLinearEdge_coords
    !> @copydetails Geom_Graph::defineLinearEdge_coords
    PROCEDURE,PASS,PRIVATE :: defineLinearEdge_coords
@@ -544,6 +547,23 @@ SUBROUTINE insertVertex_point(this,point)
  CALL this%insertVertex(point%coord)

ENDSUBROUTINE insertVertex_point
!
!-------------------------------------------------------------------------------
!> @brief Inserts an array of new vertexex into a graph object
!> @param this the graph to modify
!> @param coord the coordinates of the new vertex to add
!>
SUBROUTINE insertVertex_coords_array(this,coords)
  CLASS(GraphType),INTENT(INOUT) :: this
  REAL(SRK),INTENT(IN) :: coords(:,:)
  !
  INTEGER(SIK) :: i

  DO i = 1,SIZE(coords,DIM=2)
    CALL this%insertVertex_coords(coords(:,i))
  ENDDO !i

ENDSUBROUTINE insertVertex_coords_array
  !
  !-------------------------------------------------------------------------------
  !> @brief Inserts a new vertex into a graph object
+25 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ PRIVATE !Default contents of module to private
! List of Public items
PUBLIC :: LineType
PUBLIC :: OPERATOR(==)
PUBLIC :: OPERATOR(.APPROXEQA.)

!> @brief Type for a Line
!>
@@ -77,6 +78,15 @@ INTERFACE OPERATOR(==)
  !> @copydetails Geom_Line::isequal_LineType
  MODULE PROCEDURE isequal_LineType
ENDINTERFACE

!> @brief Generic interface for 'is approximately equal to' operator .APPROXEQA.)
!>
!> Adds 'is approximately equal to' capability for Line types
INTERFACE OPERATOR(.APPROXEQA.)
  !> @copybrief Geom_Line::approxequal_LineType
  !> @copydetails Geom_Line::approxequal_LineType
  MODULE PROCEDURE approxequal_LineType
ENDINTERFACE
!
!===============================================================================
CONTAINS
@@ -518,4 +528,19 @@ ELEMENTAL FUNCTION isequal_LineType(l0,l1) RESULT(bool)
  IF(l0%p1 == l1%p1) bool=l0%p2 == l1%p2
ENDFUNCTION isequal_LineType
!
!-------------------------------------------------------------------------------
!> @brief Defines the 'is equal to' operation between two lines e.g. @c
!>        l0 .APPROXEQA. l1
!> @param p0 the first line
!> @param p1 the second line
!> @returns @c bool the boolean result of the operation
!>
!> Function is elemental so it can be used on an array of lines.
ELEMENTAL FUNCTION approxequal_LineType(l0,l1) RESULT(bool)
  TYPE(LineType),INTENT(IN) :: l0,l1
  LOGICAL(SBK) :: bool
  bool=.FALSE.
  IF(l0%p1 .APPROXEQA. l1%p1) bool=l0%p2 .APPROXEQA. l1%p2
ENDFUNCTION approxequal_LineType
!
ENDMODULE Geom_Line