Commit b9c0cbbd by Graham, Aaron

### 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
 ... ... @@ -132,6 +132,9 @@ TYPE :: PolygonType !> @copybrief Geom_Poly::rotateClockwise !> @copydetails Geom_Poly::rotateClockwise PROCEDURE,PASS :: rotateClockwise !> @copybrief Geom_Poly::averageVertexDistance !> @copydetails Geom_Poly::averageVertexDistance PROCEDURE,PASS :: averageVertexDistance ENDTYPE PolygonType INTERFACE Polygonize ... ... @@ -447,7 +450,7 @@ ENDSUBROUTINE clear_PolygonType ! !------------------------------------------------------------------------------- !> @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 !> polygon would be concentric circles, where the smaller circle is the !> subregion of the larger one. ... ... @@ -1531,7 +1534,7 @@ ENDSUBROUTINE intersectLine_PolygonType ! !------------------------------------------------------------------------------- !> @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. !> @param thisPoly The polygon type to be intersected. !> @param thatPoly The polygon type to intersect with the polygon. ... ... @@ -2188,4 +2191,32 @@ FUNCTION rotateClockwise(this,nrotations) RESULT(new) 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
 ... ... @@ -50,6 +50,7 @@ REGISTER_SUBTEST('%subtractSubVolume',testSubtractSubVol) REGISTER_SUBTEST('Operator(==)',testEquivalence) REGISTER_SUBTEST('Assignment(=)',testAssignment) REGISTER_SUBTEST('RotateClockwise',testRotateClockwise) REGISTER_SUBTEST('averageVertexDistance',testAverageVertexDistance) FINALIZE_TEST() ! ... ... @@ -3079,4 +3080,24 @@ SUBROUTINE 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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!