The polyhedron's nodes, made again (if shown).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(Polyhedron), | intent(inout) | :: | self |
subroutine make_polyhedron(self) class(Polyhedron), intent(inout) :: self type(c_ptr) :: group real(wp) :: rgba(4), sphere(4) real(wp), allocatable :: v(:,:), normals(:,:), colors(:,:), segments(:,:) integer, allocatable :: idx(:,:) integer :: i, k, m if (.not. c_associated(self%nodes%contents)) return group = vkf_switch_create() if (iand(self%mode, POLY_FACES) /= 0 .and. size(self%tri, 2) > 0) then rgba = self%face_color_ if (allocated(self%vertex_colors_)) rgba = [1.0_wp, 1.0_wp, 1.0_wp, 1.0_wp] rgba(4) = rgba(4) * self%opacity_ call vertices_sphere(self%v, sphere(1:3), sphere(4)) if (.not. self%lit_) then if (allocated(self%vertex_colors_)) then call add(group, surface_node(self%v, self%tri, rgba, colors=self%vertex_colors_)) else call add(group, surface_node(self%v, self%tri, rgba)) end if else if (self%smooth_) then ! shared vertices, normals averaged normals = vertex_normals(self%v, self%tri) if (allocated(self%vertex_colors_)) then call add(group, surface_node(self%v, self%tri, rgba, normals, self%vertex_colors_, self%two_sided_, & sphere)) else call add(group, surface_node(self%v, self%tri, rgba, normals, two_sided=self%two_sided_, & sphere=sphere)) end if else ! flat: each triangle its own vertices m = size(self%tri, 2) allocate(v(3, 3 * m), normals(3, 3 * m), idx(3, m)) do k = 1, m do i = 1, 3 v(:, 3 * (k - 1) + i) = self%v(:, self%tri(i, k)) end do normals(:, 3 * k - 2) = unit_normal(v(:, 3 * k - 2), v(:, 3 * k - 1), v(:, 3 * k)) normals(:, 3 * k - 1) = normals(:, 3 * k - 2) normals(:, 3 * k) = normals(:, 3 * k - 2) idx(:, k) = [3 * k - 2, 3 * k - 1, 3 * k] end do if (allocated(self%vertex_colors_)) then allocate(colors(4, 3 * m)) do k = 1, m do i = 1, 3 colors(:, 3 * (k - 1) + i) = self%vertex_colors_(:, self%tri(i, k)) end do end do call add(group, surface_node(v, idx, rgba, normals, colors, self%two_sided_, sphere)) else call add(group, surface_node(v, idx, rgba, normals, two_sided=self%two_sided_, sphere=sphere)) end if end if end if if (iand(self%mode, POLY_EDGES) /= 0 .and. size(self%edge, 2) > 0) then allocate(segments(3, 2 * size(self%edge, 2))) do k = 1, size(self%edge, 2) segments(:, 2 * k - 1) = self%v(:, self%edge(1, k)) segments(:, 2 * k) = self%v(:, self%edge(2, k)) end do call add(group, line_node(segments, self%line_color_, self%width_, .true.)) end if if (iand(self%mode, POLY_VERTICES) /= 0 .and. size(self%v, 2) > 0) & call add(group, marker_node(self%v, self%point_color_, self%point_size_, MARKER_DISK, 0.0_wp, c_null_ptr)) call self%nodes%replace(group) end subroutine make_polyhedron