Sanitize facets normals, make them consistent.
Facets connectivity and normals must be already computed.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(file_stl_object), | intent(inout) | :: | self | File STL. |
pure subroutine sanitize_normals(self)
!< Sanitize facets normals, make them consistent.
!<
!< @note Facets connectivity and normals must be already computed.
class(file_stl_object), intent(inout) :: self !< File STL.
logical, allocatable :: facet_checked(:) !< List of facets checked.
integer(I4P) :: f, ff !< Counter.
if (self%facets_number>0) then
allocate(facet_checked(1:self%facets_number))
facet_checked = .false.
f = 1
facet_checked(f) = .true.
do
ff = 0
if (self%facet(f)%fcon_edge_12>0.and.(.not.facet_checked(self%facet(f)%fcon_edge_12))) then
call self%facet(f)%make_normal_consistent(edge_dir='edge_12', other=self%facet(self%facet(f)%fcon_edge_12))
facet_checked(self%facet(f)%fcon_edge_12) = .true.
ff = self%facet(f)%fcon_edge_12
endif
if (self%facet(f)%fcon_edge_23>0.and.(.not.facet_checked(self%facet(f)%fcon_edge_23))) then
call self%facet(f)%make_normal_consistent(edge_dir='edge_23', other=self%facet(self%facet(f)%fcon_edge_23))
facet_checked(self%facet(f)%fcon_edge_23) = .true.
ff = self%facet(f)%fcon_edge_23
endif
if (self%facet(f)%fcon_edge_31>0.and.(.not.facet_checked(self%facet(f)%fcon_edge_31))) then
call self%facet(f)%make_normal_consistent(edge_dir='edge_31', other=self%facet(self%facet(f)%fcon_edge_31))
facet_checked(self%facet(f)%fcon_edge_31) = .true.
ff = self%facet(f)%fcon_edge_31
endif
if (ff==0) then
exit
else
f = ff
endif
enddo
endif
call self%compute_volume
if (self%volume < 0) call self%reverse_normals
endsubroutine sanitize_normals