Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Futility
Futility
Commits
b9c0cbbd
Commit
b9c0cbbd
authored
Jul 28, 2021
by
Graham, Aaron
Browse files
Merge branch 'geom_routines' into 'master'
Geom routines See merge request futility/Futility!342
parents
49023b78
a13fd5fe
Pipeline
#156742
passed with stage
in 1 minute and 58 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/Geom_Poly.f90
View file @
b9c0cbbd
...
@@ -132,6 +132,9 @@ TYPE :: PolygonType
...
@@ -132,6 +132,9 @@ TYPE :: PolygonType
!> @copybrief Geom_Poly::rotateClockwise
!> @copybrief Geom_Poly::rotateClockwise
!> @copydetails Geom_Poly::rotateClockwise
!> @copydetails Geom_Poly::rotateClockwise
PROCEDURE
,
PASS
::
rotateClockwise
PROCEDURE
,
PASS
::
rotateClockwise
!> @copybrief Geom_Poly::averageVertexDistance
!> @copydetails Geom_Poly::averageVertexDistance
PROCEDURE
,
PASS
::
averageVertexDistance
ENDTYPE
PolygonType
ENDTYPE
PolygonType
INTERFACE
Polygonize
INTERFACE
Polygonize
...
@@ -447,7 +450,7 @@ ENDSUBROUTINE clear_PolygonType
...
@@ -447,7 +450,7 @@ ENDSUBROUTINE clear_PolygonType
!
!
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!> @brief This function checks if a polygon has any associated polygon
!> @brief This function checks if a polygon has any associated polygon
!> subregions. If it does not have any, they polygon type is simple
!> subregions. If it does not have any, they polygon type is simple
!> (e.g. a circle, square, triangle, etc...). An example of a non-simple
!> (e.g. a circle, square, triangle, etc...). An example of a non-simple
!> polygon would be concentric circles, where the smaller circle is the
!> polygon would be concentric circles, where the smaller circle is the
!> subregion of the larger one.
!> subregion of the larger one.
...
@@ -1531,7 +1534,7 @@ ENDSUBROUTINE intersectLine_PolygonType
...
@@ -1531,7 +1534,7 @@ ENDSUBROUTINE intersectLine_PolygonType
!
!
!-------------------------------------------------------------------------------
!-------------------------------------------------------------------------------
!> @brief This subroutine calculates the points where a given polygon intersects
!> @brief This subroutine calculates the points where a given polygon intersects
!> with another given polygon. If there is no intersection, points is
!> with another given polygon. If there is no intersection, points is
!> returned unallocated.
!> returned unallocated.
!> @param thisPoly The polygon type to be intersected.
!> @param thisPoly The polygon type to be intersected.
!> @param thatPoly The polygon type to intersect with the polygon.
!> @param thatPoly The polygon type to intersect with the polygon.
...
@@ -2188,4 +2191,32 @@ FUNCTION rotateClockwise(this,nrotations) RESULT(new)
...
@@ -2188,4 +2191,32 @@ FUNCTION rotateClockwise(this,nrotations) RESULT(new)
ENDFUNCTION
rotateClockwise
ENDFUNCTION
rotateClockwise
!
!
!-------------------------------------------------------------------------------
!> @brief Calculates the average distance of all vertexes from a point
!> @param this the polygon
!> @param point the point to calculate distance from; optional, defaults to [0.0, 0.0]
!> @returns avearge_distance the average distance
!>
FUNCTION
averageVertexDistance
(
this
,
point
)
RESULT
(
average_distance
)
CLASS
(
PolygonType
),
INTENT
(
IN
)
::
this
TYPE
(
PointType
),
INTENT
(
IN
),
OPTIONAL
::
point
REAL
(
SRK
)
::
average_distance
!
TYPE
(
PointType
)
::
origin
IF
(
PRESENT
(
point
))
THEN
REQUIRE
(
point
%
dim
>=
2
)
REQUIRE
(
ALLOCATED
(
point
%
coord
))
CALL
origin
%
init
(
COORD
=
point
%
coord
(
1
:
2
))
ELSE
CALL
origin
%
init
(
COORD
=
[
0.0_SRK
,
0.0_SRK
])
ENDIF
average_distance
=
0.0_SRK
IF
(
this
%
nVert
<=
0
)
RETURN
average_distance
=
SUM
(
Distance
(
this
%
vert
,
origin
))
/
this
%
nVert
ENDFUNCTION
averageVertexDistance
!
ENDMODULE
Geom_Poly
ENDMODULE
Geom_Poly
unit_tests/testGeom_Poly/testGeom_Poly.f90
View file @
b9c0cbbd
...
@@ -50,6 +50,7 @@ REGISTER_SUBTEST('%subtractSubVolume',testSubtractSubVol)
...
@@ -50,6 +50,7 @@ REGISTER_SUBTEST('%subtractSubVolume',testSubtractSubVol)
REGISTER_SUBTEST
(
'Operator(==)'
,
testEquivalence
)
REGISTER_SUBTEST
(
'Operator(==)'
,
testEquivalence
)
REGISTER_SUBTEST
(
'Assignment(=)'
,
testAssignment
)
REGISTER_SUBTEST
(
'Assignment(=)'
,
testAssignment
)
REGISTER_SUBTEST
(
'RotateClockwise'
,
testRotateClockwise
)
REGISTER_SUBTEST
(
'RotateClockwise'
,
testRotateClockwise
)
REGISTER_SUBTEST
(
'averageVertexDistance'
,
testAverageVertexDistance
)
FINALIZE_TEST
()
FINALIZE_TEST
()
!
!
...
@@ -3079,4 +3080,24 @@ SUBROUTINE testRotateClockwise()
...
@@ -3079,4 +3080,24 @@ SUBROUTINE testRotateClockwise()
ENDSUBROUTINE
testRotateClockwise
ENDSUBROUTINE
testRotateClockwise
!
!
!-------------------------------------------------------------------------------
SUBROUTINE
testAverageVertexDistance
()
TYPE
(
PointType
)
::
testPoint
TYPE
(
PolygonType
)
::
testPoly
COMPONENT_TEST
(
'Default Origin'
)
testPoly
%
nVert
=
4
ALLOCATE
(
testPoly
%
vert
(
4
))
CALL
testPoly
%
vert
(
1
)
%
init
(
DIM
=
2
,
COORD
=
[
SQRT
(
0.5_SRK
),
SQRT
(
0.5_SRK
)])
CALL
testPoly
%
vert
(
2
)
%
init
(
DIM
=
2
,
COORD
=
2.0_SRK
*
[
SQRT
(
0.5_SRK
),
SQRT
(
0.5_SRK
)])
CALL
testPoly
%
vert
(
3
)
%
init
(
DIM
=
2
,
COORD
=
3.0_SRK
*
[
SQRT
(
0.5_SRK
),
SQRT
(
0.5_SRK
)])
CALL
testPoly
%
vert
(
4
)
%
init
(
DIM
=
2
,
COORD
=
4.0_SRK
*
[
SQRT
(
0.5_SRK
),
SQRT
(
0.5_SRK
)])
ASSERT_APPROXEQA
(
testPoly
%
averageVertexDistance
(),
2.5_SRK
,
'distance'
)
COMPONENT_TEST
(
'Provided Origin'
)
CALL
testPoint
%
init
(
DIM
=
2
,
COORD
=
[
SQRT
(
2.0_SRK
),
SQRT
(
2.0_SRK
)])
ASSERT_APPROXEQA
(
testPoly
%
averageVertexDistance
(
testPoint
),
1.0_SRK
,
'distance'
)
ENDSUBROUTINE
testAverageVertexDistance
!
ENDPROGRAM
testGeom_Poly
ENDPROGRAM
testGeom_Poly
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment