Skip to content

Commit

Permalink
Merging surfaces also fixes the header vertex count and face count
Browse files Browse the repository at this point in the history
  • Loading branch information
dipterix committed Jan 24, 2025
1 parent 212ad88 commit 715ccad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ieegio
Title: File IO for Intracranial Electroencephalography
Version: 0.0.3.9001
Version: 0.0.3.9002
Language: en-US
Encoding: UTF-8
Authors@R:
Expand Down
25 changes: 23 additions & 2 deletions R/aaa-generics-surface.R
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,29 @@ fix_surface_class <- function(x) {
cls <- class(x)
cls <- c(contain_classes, cls[!cls %in% remove_classes])
class(x) <- unique(cls)

# also fix the internal header
if("ieegio_surface_contains_geometry" %in% contain_classes) {
geometry <- .subset2(x, "geometry")
nverts <- ncol(geometry$vertices)
if(length(geometry$faces)) {
type <- "tris"
nfaces <- ncol(geometry$faces)
} else {
type <- "points"
nfaces <- 0L
}
x$header <- structure(
class = "basic_geometry",
list(
internal = list(
num_vertices_expected = nverts,
num_faces_expected = nfaces
),
mesh_face_type = type
)
)
}
x
}

Expand Down Expand Up @@ -465,8 +488,6 @@ merge.ieegio_surface <- function(
# make dense x and make sure face starts from 1
x <- sparse_to_dense_geometry(x)

x_matrix_world <- x$geometry$transforms

get_transform <- function(z, idx) {
transforms <- z$geometry$transforms
if(is.na(idx) || !length(transforms)) {
Expand Down

0 comments on commit 715ccad

Please sign in to comment.