geometry/0000755000176200001440000000000014751753072012120 5ustar liggesusersgeometry/tests/0000755000176200001440000000000013432270466013256 5ustar liggesusersgeometry/tests/testthat/0000755000176200001440000000000014751753072015122 5ustar liggesusersgeometry/tests/testthat/test-pol2cart.R0000644000176200001440000000614513432317404017744 0ustar liggesuserscontext("pol2cart") test_that("pol2cart works correctly", { t <- c(0, 0.5, 1)*pi r <- 1 C <- pol2cart(t, r) expect_equal(C[,"x"], c(1, 0, -1)) expect_equal(C[,"y"], c(0, 1, 0)) t <- c(0, 1, 1)*pi/4 r <- sqrt(2)*c(0, 1, 2) C <- pol2cart(t, r) expect_equal(C[,"x"], c(0, 1, 2)) expect_equal(C[,"y"], c(0, 1, 2)) t <- c(0, 1, 1)*pi/4 r <- sqrt(2)*c(0, 1, 2) z <- c(0, 1, 2) C <- pol2cart(t, r, z) expect_equal(C[,"x"], c(0, 1, 2)) expect_equal(C[,"y"], c(0, 1, 2)) expect_equal(C[,"z"], z) t <- 0 r <- c(0, 1, 2) z <- c(0, 1, 2) C <- pol2cart (t, r, z) expect_equal (C[,"x"], c(0, 1, 2)) expect_equal (C[,"y"], c(0, 0, 0)) expect_equal (C[,"z"], z) t <- c(1, 1, 1)*pi/4 r <- 1 z <- c(0, 1, 2) C <- pol2cart (t, r, z) expect_equal(C[,"x"], c(1, 1, 1)/sqrt(2)) expect_equal(C[,"y"], c(1, 1, 1)/sqrt(2)) expect_equal(C[,"z"], z) t <- 0 r <- c(1, 2, 3) z <- 1 C <- pol2cart (t, r, z) expect_equal(C[,"x"], c(1, 2, 3)) expect_equal(C[,"y"], c(0, 0, 0)/sqrt (2)) expect_equal(C[,"z"], c(1, 1, 1)) P <- rbind(c(theta=0, r=0), c(pi/4, sqrt(2)), c(pi/4, 2*sqrt(2))) C <- rbind(c(x=0, y=0), c(1, 1), c(2, 2)) expect_equal(pol2cart(P), C) ## %!test ## %! P <- c(0, 0, 0 pi/4, sqrt(2), 1 pi/4, 2*sqrt(2), 2) ## %! C <- c(0, 0, 0 1, 1, 1 2, 2, 2) ## %! expect_equal (pol2cart (P), C, sqrt (eps)) ## %!test ## %! r <- ones (1, 1, 1, 2) ## %! r(1, 1, 1, 2) <- 2 ## %! t <- pi/2 * r ## %! c(x, y) <- pol2cart (t, r) ## %! X <- zeros (1, 1, 1, 2) ## %! X(1, 1, 1, 2) <- -2 ## %! Y <- zeros (1, 1, 1, 2) ## %! Y(1, 1, 1, 1) <- 1 ## %! expect_equal (C[,"x"], X, 2*eps) ## %! expect_equal (C[,"y"], Y, 2*eps) ## %!test ## %! c(t, r, Z) <- meshgrid (c(0, pi/2), c(1, 2), c(0, 1)) ## %! c(x, y, z) <- pol2cart (t, r, Z) ## %! X <- zeros(2, 2, 2) ## %! X(:, 1, 1) <- c(1 2) ## %! X(:, 1, 2) <- c(1 2) ## %! Y <- zeros(2, 2, 2) ## %! Y(:, 2, 1) <- c(1 2) ## %! Y(:, 2, 2) <- c(1 2) ## %! expect_equal (C[,"x"], X, eps) ## %! expect_equal (C[,"y"], Y, eps) ## %! expect_equal (z, Z) ## Test input validation expect_error(pol2cart()) expect_error(pol2cart(1,2,3,4)) expect_error(pol2cart(list(1,2,3)), regexp="input must be matrix with 2 or 3 columns") ## %expect_error pol2cart (ones (3,3,2)) ## %expect_error pol2cart (c(1)) ## %expect_error pol2cart (c(1,2,3,4)) ## %expect_error pol2cart ({1,2,3}, c(1,2,3)) ## %expect_error pol2cart (c(1,2,3), {1,2,3}) ## %expect_error pol2cart (ones (3,3,3), ones (3,2,3)) ## %expect_error pol2cart ({1,2,3}, c(1,2,3), c(1,2,3)) ## %expect_error pol2cart (c(1,2,3), {1,2,3}, c(1,2,3)) ## %expect_error pol2cart (c(1,2,3), c(1,2,3), {1,2,3}) ## %expect_error pol2cart (ones (3,3,3), 1, ones (3,2,3)) ## %expect_error pol2cart (ones (3,3,3), ones (3,2,3), 1) }) geometry/tests/testthat/test-tsearch-tsearchn-comparison.R0000644000176200001440000000073514662314120023621 0ustar liggesuserscontext("Comparison of tsearch and tsearchn") test_that("tsearch and tsearchn give the same results", { set.seed(1) X <- runif(50) Y <- runif(50) T <- delaunayn(cbind(X, Y)) XI <- runif(1000) YI <- runif(1000) out <- tsearch(X, Y, T, XI, YI) outn <- tsearchn(cbind(X, Y), T, cbind(XI, YI), fast=FALSE) expect_equal(na.omit(out), na.omit(outn$idx)) out <- tsearch(X, Y, T, XI, YI, TRUE) expect_equal(na.omit(outn$p), na.omit(out$p), tolerance=1e-12) }) geometry/tests/testthat/test-convhulln.R0000644000176200001440000001107714664417655020247 0ustar liggesuserscontext("convhulln") test_that("convhulln works on a cube", { ## Cube with unit length edges, centred on the origin ps <- rbox(0, C=0.5) ts <- convhulln(ps) ## Expect 12 facets, since faceted output is produced by default expect_equal(nrow(ts), 12) ## When "FA" is specified area and volume should be returned ts <- convhulln(ps, "FA") expect_equal(length(ts), 4) expect_equal(ts$area, 6) expect_equal(ts$vol, 1) ## When "n" is specified normals should be returned ts <- convhulln(ps, "n") expect_equal(length(ts), 3) ## There are 12 normals, one for each facet. There are 6 *unique* ## normals, since for each face of the cube there are two triangular ## facets with the same normal expect_equal(ts$normals, rbind(c( 0, 0, -1, -0.5), c( 0, 0, -1, -0.5), c( 0, -1, 0, -0.5), c( 0, -1, 0, -0.5), c( 1, 0, 0, -0.5), c( 1, 0, 0, -0.5), c( -1, 0, 0, -0.5), c( -1, 0, 0, -0.5), c( 0, 1, 0, -0.5), c( 0, 1, 0, -0.5), c( 0, 0, 1, -0.5), c( 0, 0, 1, -0.5))) }) test_that("convhulln works on a cube with output.options", { ## Cube with unit length edges, centred on the origin ps <- rbox(0, C=0.5) ts <- convhulln(ps) ## Expect 12 facets, since faceted output is produced by default expect_equal(nrow(ts), 12) ## When "FA" is specified area and volume should be returned ts <- convhulln(ps, output.options="FA") expect_equal(length(ts), 4) expect_equal(ts$area, 6) expect_equal(ts$vol, 1) ## When "n" is specified normals should be returned ts <- convhulln(ps, output.options="n") expect_equal(length(ts), 3) ## There are 12 normals, one for each facet. There are 6 *unique* ## normals, since for each face of the cube there are two triangular ## facets with the same normal expect_equal(ts$normals, rbind(c( 0, 0, -1, -0.5), c( 0, 0, -1, -0.5), c( 0, -1, 0, -0.5), c( 0, -1, 0, -0.5), c( 1, 0, 0, -0.5), c( 1, 0, 0, -0.5), c( -1, 0, 0, -0.5), c( -1, 0, 0, -0.5), c( 0, 1, 0, -0.5), c( 0, 1, 0, -0.5), c( 0, 0, 1, -0.5), c( 0, 0, 1, -0.5))) ts <- convhulln(ps, output.options=TRUE) expect_equal(length(ts), 5) }) test_that("convhulln can run on an example with 3000 points", { set.seed(1) ps <- matrix(rnorm(3000), ncol=3) ps <- sqrt(3)*ps/drop(sqrt((ps^2) %*% rep(1,3))) ts <- convhulln(ps) expect_identical(nrow(ts), 1996L) ts.full <- convhulln(ps, "FA") expect_equal(ts.full$area, 37.47065, tolerance=0.001) expect_equal(ts.full$vol, 21.50165, tolerance=0.001) }) ## Qhull 8.0.2 no longer complains about duplicated points being passed to qhullNewQhull ## test_that("convhulln throws an error with duplicated points", { ## load(file.path(system.file(package="geometry"), "extdata", "ordination.Rdata")) ## expect_error(out <- convhulln(ordination), "QH6114 qhull precision error: initial simplex is not convex") ## }) test_that("If the input matrix contains NAs, convhulln should return an error", { ps <- matrix(rnorm(999), ncol=3) ps <- sqrt(3)*ps/drop(sqrt((ps^2) %*% rep(1,3))) ps <- rbind(ps, NA) expect_error(convhulln(ps)) }) test_that("If there are not enough points to construct a simplex, an error is thrown", { expect_error(convhulln(diag(4))) }) test_that("Output to file works", { ## To prevent regression in package betapart fname <- path.expand(file.path(tempdir(), "vert.txt")) unlink(fname) tr <- rbind(c(3,1),c(2,1),c(4,3),c(4,2)) convhulln(tr, paste0("Fx TO '", fname, "'")) expect_true(file.exists(fname)) vert <- scan(fname, quiet=TRUE) expect_equal(vert, c(4, 2, 1, 0, 3)) }) test_that("Output of non-triangulated facets works", { X1 <- matrix(c( 1, 1, 1, 1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, -1, 3, 0, 0), ncol=3, byrow = TRUE) ts1 <- convhulln(X1, return.non.triangulated.facets = TRUE) tbl1 <- table(rowSums(!is.na(ts1))) expect_equal(names(tbl1), c("3", "4")) expect_equal(as.numeric(tbl1), c(4, 5)) }) geometry/tests/testthat/test-tsearch.R0000644000176200001440000001320614664423323017651 0ustar liggesuserscontext("tsearch") test_that("tsearch gives the expected output", { x <- c(-1, -1, 1) y <- c(-1, 1, -1) p <- cbind(x, y) tri <- matrix(c(1, 2, 3), 1, 3) ## Should be in triangle #1 ts <- tsearch(x, y, tri, -1, -1) expect_equal(ts, 1) ## Should be in triangle #1 ts <- tsearch(x, y, tri, 1, -1) expect_equal(ts, 1) ## Should be in triangle #1 ts <- tsearch(x, y, tri, -1, 1) expect_equal(ts, 1) ## Centroid ts <- tsearch(x, y, tri, -1/3, -1/3) expect_equal(ts, 1) ## Should be outside triangle #1, so should return NA ts <- tsearch(x, y, tri, 1, 1) expect_true(is.na(ts)) }) test_that("tsearch can deal with faulty input", { x <- c(-1, -1, 1) y <- c(-1, 1, -1) p <- cbind(x, y) tri <- matrix(c(1, 2, 3), 1, 3) ## NULLs and NAs ## expect_error(tsearch(x, y, tri, NA, NA)) expect_error(tsearch(x, y, NA, -1, 1)) expect_error(tsearch(NA, NA, tri, -1, 1)) expect_error(tsearch(x, y, tri, NULL, NULL)) expect_error(tsearch(x, y, NULL, -1, 1)) expect_error(tsearch(NULL, NULL, tri, -1, 1)) ## Wrong number of columns expect_error(tsearch(p, 0, tri, -1, 1)) ## Non-integer triangulation expect_error(tsearch(x, y, matrix(runif(15), 5, 3), -1, 1), regexp="does not have integer elements") ## Wrong number of columns in triangulation expect_error(tsearch(x, y, matrix(1:4, 4, 2), -1, 1)) ## Mismatch in x and y lengths expect_error(tsearch(x, y[-1], tri, -1, 1)) ## Mismatch in xi and yi lengths expect_error(tsearch(x, y, tri, c(-1, 1), 1)) ## A subtle one! This gives numeric(0) as the final arguments and ## should give idx with no elements and a 0x3 matrix for p ps <- matrix(0, 0, 2) expect_equal(tsearch(x, y, tri, ps[,1], ps[,2], bary=TRUE), list(idx=integer(0), p=matrix(0, 0, 3))) }) ## See ## http://totologic.blogspot.co.uk/2014/01/accurate-point-in-triangle-test.html ## for inspiration for the test below test_that("tsearch gives the expected output when computer precision problem arise", { # ==== Hand made test ==== x1 <- 1/10 y1 <- 1/9 x2 <- 100/8 y2 <- 100/3 P <- rbind(c(x1, y1), c(x2, y2), c(100/4, 100/9), c(-100/8, 100/6)) # And a single point p(x, y) lying exactly on the segment [p1, p2] : xi <- x1 + (3/7)*(x2 - x1) yi <- y1 + (3/7)*(y2 - y1) # Should always give triangle 2 since this is the lastest tested tri1 <- rbind(1:3, c(1, 2, 4)) ts <- tsearch(P[,1], P[,2], tri1, xi, yi) expect_equal(ts, 2) tri2 <- rbind(c(1, 2, 4), 1:3) ts <- tsearch(P[,1], P[,2], tri2, xi, yi) expect_equal(ts, 2) # The same but with only one triangle P <- rbind(c(x1, y1), c(x2, y2), c(100/4, 100/9)) tri <- matrix(c(1, 2, 3), 1, 3) ts <- tsearch(P[,1], P[,2], tri, xi, yi) expect_equal(ts, 1) tri <- matrix(c(3, 2, 1), 1, 3) ts <- tsearch(P[,1], P[,2], tri, xi, yi) expect_equal(ts, 1) # The same but with the other triangle P <- rbind(c(x2, y2), c(100/4, 100/9), c(-100/8, 100/6)) tri <- matrix(c(1, 2, 3), 1, 3) ts <- tsearch(P[,1], P[,2], tri, xi, yi) expect_equal(ts, 1) tri <- matrix(c(3, 2, 1), 1, 3) ts <- tsearch(P[,1], P[,2], tri, xi, yi) expect_equal(ts, 1) # Another test x <- c(6.89, 7.15, 7.03) y <- c(7.76, 7.75, 8.35) tri <- matrix(c(1, 2, 3), 1, 3) ts <- tsearch(x, y, tri, 7.125, 7.875) expect_equal(ts, 1) # ==== Test known to bug in former code ==== x <- c(278287.03, 278286.89, 278287.15, 278287.3) y <- c(602248.35, 602247.76, 602247.75, 602248.35) xi = 278287.125 yi = 602247.875 # Should always give triangle 2 but here it does not work tri = rbind(c(3,1,4), c(3,1,2)) ts <- tsearch(x, y, tri, xi, yi) expect_equal(ts, 2) tri = rbind(c(1,2,3), c(1,3,4)) ts <- tsearch(x, y, tri, xi, yi) expect_equal(ts, 1) # This is because the buffer epsilon is 1.0e-12. x <- c(278287.03, 278287.15, 278287.3) y <- c(602248.35, 602247.75, 602248.35) tri <- matrix(c(1, 2, 3), 1, 3) ts <- tsearch(x, y, tri, xi, yi) expect_true(is.na(ts)) #expect_equal(ts, 1) #With epsilon = 1.0e-10 it works. }) test_that("no regression on Issue #39", { ## See https://github.com/davidcsterratt/geometry/issues/39 ## vertices P <- rbind( c(373.8112, 4673.726), #31 c(222.9705, 4280.085), #32 c(291.0508, 4476.996), #42 c(553.4783, 4523.605), #43 c(222.6388, 4023.920), #44 c(445.2401, 4370.940), #48 c(81.54986, 4125.393)) #61 ## I found this error on my system with Ubuntu 16.04, R 3.4.1 and ## `geometry_0.4.2`. `geometry_0.4.0` gave the same error). The error ## persists on Windows 10 with R 3.6.1. ## triangulation T <- rbind( c(3, 2, 6), c(5, 2, 7), c(4, 1, 3)) ## data data <- rbind( c(221.6, 4171.8), c(250.4, 4311.8), c(496.6, 4516.2), c(254.0, 4294.8), c(199.4, 4072.6)) ## With bug returns NA for datapoints 3 and 5 expect_equal(tsearch(P[,1], P[,2],T, data[,1], data[,2]), c(2, 1, 3, 1, 2)) data2 <- rbind( c(221.6, 4171.8), c(250.4, 4311.8), c(496.6, 4516.2), c(254.0, 4294.8), c(199.4, 4072.0)) #note that only the Y coordinate of datapoint 5 was changed expect_equal(tsearch(P[,1], P[,2],T, data2[,1], data2[,2]), c(2, 1, 3, 1, 2)) }) test_that("no regression on Issue #57", { load(file.path(system.file(package="geometry"), "extdata", "issue57-tsearch.RData")) dn <- delaunayn(P, options = "") tri <- tsearch(P[, "XCoord"], P[, "YCoord"], dn, Pi[, "XCoord"], Pi[, "YCoord"], bary = T) tri2 <- tsearch(P[, "XCoord"], P[, "YCoord"], dn, Pi[, "XCoord"], Pi[, "YCoord"], bary = T, method = "orig") ## trimesh(dn, P[,"XCoord"], P[, "YCoord"]) ## points(P[,"XCoord"], P[,"YCoord"], col='red') expect_equal(tri, tri2) }) geometry/tests/testthat/test-polyarea.R0000644000176200001440000000050514662314120020022 0ustar liggesuserscontext("polyarea") test_that("ployarea computes the area of two identical squares", { x <- c(1, 1, 3, 3, 1) y <- c(1, 3, 3, 1, 1) expect_equal(polyarea(cbind(x, x), cbind(y, y)), c(4, 4)) expect_equal(polyarea(cbind(x, x), cbind(y, y), 1), c(4, 4)) expect_equal(polyarea(rbind(x, x), rbind(y, y), 2), c(4, 4)) }) geometry/tests/testthat/test-inhulln.R0000644000176200001440000000226014662314120017657 0ustar liggesuserscontext("inhulln") test_that("inhulln gives the expected output", { ## Basic test x <- c(-1, -1, 1) y <- c(-1, 1, -1) p <- cbind(x, y) ch <- convhulln(p) ## Should be in hull pin <- inhulln(ch, cbind(-0.5, -0.5)) expect_true(pin) ## Should be outside hull pout <- inhulln(ch, cbind(1, 1)) expect_false(pout) ## Erroneous input is caught safely expect_error(inhulln(1, 2), "Convex hull has no convhulln attribute") expect_error(inhulln(ch, rbind(1, 1)), "Number of columns in test points p (1) not equal to dimension of hull (2).", fixed=TRUE) expect_error(inhulln(ch, cbind(1, 1, 1)), "Number of columns in test points p (3) not equal to dimension of hull (2).", fixed=TRUE) ## Test cube p <- rbox(n=0, D=3, C=1) ch <- convhulln(p) tp <- cbind(seq(-1.9, 1.9, by=0.2), 0, 0) pin <- inhulln(ch, tp) ## Points on x-axis should be in box only between -1 and 1 expect_equal(pin, tp[,1] < 1 & tp[,1] > -1) ## Test hypercube p <- rbox(n=0, D=4, C=1) ch <- convhulln(p) tp <- cbind(seq(-1.9, 1.9, by=0.2), 0, 0, 0) pin <- inhulln(ch, tp) ## Points on x-axis should be in box only between -1 and 1 expect_equal(pin, tp[,1] < 1 & tp[,1] > -1) }) geometry/tests/testthat/test-extprod3d.R0000644000176200001440000000143113432317404020123 0ustar liggesusers## Based on Octave tests for cross.m ## http://hg.savannah.gnu.org/hgweb/octave/file/c2ef0eddf6bc/scripts/linear-algebra/cross.m context("extprod3d") test_that("extprod3d gives the expected output", { x <- c(1, 0, 0) y <- c(0, 1, 0) r <- c(0, 0, 1) expect_equal(extprod3d(x, y), r) expect_equal(extprod3d(x, y, drop=FALSE), t(r)) x <- c(1, 2, 3) y <- c(4, 5, 6) r <- c((2*6-3*5), (3*4-1*6), (1*5-2*4)) expect_equal(extprod3d(x, y), r) x <- rbind(c(1, 0, 0), c(0, 1, 0), c(0, 0, 1)) y <- rbind(c(0, 1, 0), c(0, 0, 1), c(1, 0, 0)) r <- rbind(c(0, 0, 1), c(1, 0, 0), c(0, 1, 0)) expect_equal(extprod3d(x, y), r) ##error extprod3d (0,0) ##error extprod3d () }) geometry/tests/testthat/test-halfspacen.R0000644000176200001440000000534013432317404020316 0ustar liggesuserscontext("halfspacen") test_that("halfspacen works on a cube", { ## Cube with unit length edges, centred on the origin ps <- rbox(0, C=0.5) ## Convex hull. When "n" is specified normals should be returned ch <- convhulln(ps, "n") ## Intersections of half planes ## These points should be the same as the orginal points pn <- halfspacen(ch$normals, c(0, 0, 0)) ## Convex hull of these points should have same characteristics as original cube ts <- convhulln(pn, "FA") expect_equal(ts$area, 6) expect_equal(ts$vol, 1) ## If the feasible point is outwith the normlas to the cube, an ## error should be thrown expect_error(halfspacen(ch$normals, c(1, 1, 1))) }) test_that("halfspacen works on a cube with non triangulated facets", { ## Cube with unit length edges, centred on the origin ps <- rbox(0, C=0.5) ## Convex hull. When "n" is specified normals should be returned ch <- convhulln(ps, "n", return.non.triangulated.facets=TRUE) ## Intersections of half planes ## These points should be the same as the orginal points pn <- halfspacen(ch$normals, c(0, 0, 0)) ## Convex hull of these points should have same characteristics as original cube ts <- convhulln(pn, "FA") expect_equal(ts$area, 6) expect_equal(ts$vol, 1) ## If the feasible point is outwith the normlas to the cube, an ## error should be thrown expect_error(halfspacen(ch$normals, c(1, 1, 1))) }) test_that("halfspacen can compute volume of intersection of halfspaces", { ## Cube with unit length edges, centred on the origin ps1 <- rbox(0, C=0.5) ## Cube with unit length edges, centred on the (0.5, 0.5, 0.5) ps2 <- rbox(0, C=0.5) + 0.5 ## Convex hulls with normals ch1 <- convhulln(ps1, "n", return.non.triangulated.facets=TRUE) ch2 <- convhulln(ps2, "n", return.non.triangulated.facets=TRUE) ## Intersection of merged halfspaces pn <- halfspacen(rbind(ch1$normals, ch2$normals), c(0.25, 0.25, 0.25)) ## Convex hull of these points should be cube with vertices at ## intersection of cubes, i.e. a cube of length 0.5 ts <- convhulln(pn, "FA") expect_equal(ts$area, 6*0.5^2) expect_equal(ts$vol, 1*0.5^3) }) test_that("halfspacen can do the round trip on an example with 3000 points", { set.seed(1) ps <- matrix(rnorm(3000), ncol=3) ps <- sqrt(3)*ps/drop(sqrt((ps^2) %*% rep(1,3))) ch <- convhulln(ps, "n FA") pn <- halfspacen(ch$normals, c(0, 0, 0)) chn <- convhulln(pn, "n FA") expect_equal(ch$area, chn$area) expect_equal(ch$vol, chn$vol) }) test_that("halfspacen throws an error when the feasible point is not clearly inside the halfspace", { load(file.path(system.file(package="geometry"), "extdata", "halfspacen.RData")) expect_error(halfspacen(normals, fp), "QH6023 qhull input error") }) geometry/tests/testthat/test-distmesh2d.R0000644000176200001440000000122313432317404020254 0ustar liggesuserscontext("distmesh2d") test_that("distmesh2d can create a mesh on an ellipse", { bbox <- 2*matrix(c(-1,1,-1/2,1/2),2,2) ## Ellipse fd1 <- function(p,ra2=1/1.,rb2=1/2,xc2=0,yc2=0, ...){ if (!is.matrix(p)) p <- t(as.matrix(p)) return(sqrt(((p[,1]-xc2)/ra2)^2+((p[,2]-yc2)/rb2)^2)-1) } ## Solve using distmesh2d() fh <- function(p,...) rep(1,nrow(p)) ## This is the original line, which throws a warning. New one does ## too, but runs faster p <- ## distmesh2d(fd=fd1,fh=fh,p=NULL,h0=0.05,bbox=bbox,maxiter=1000, ## plot=FALSE) expect_warning(p <- distmesh2d(fd=fd1,fh=fh,p=NULL,h0=0.05,bbox=bbox,maxiter=10, plot=FALSE)) }) geometry/tests/testthat/test-cart2pol.R0000644000176200001440000000574113432317404017745 0ustar liggesuserscontext("cart2pol") test_that("cart2pol works correctly", { x <- c(0, 1, 2) y <- 0 P <- cart2pol (x, y) expect_equal (P[,"theta"], c(0, 0, 0)) expect_equal (P[,"r"], x) x <- c(0, 1, 2) y <- c(0, 1, 2) P <- cart2pol(x, y) expect_equal (P[,"theta"], c(0, pi/4, pi/4)) expect_equal (P[,"r"], sqrt (2)*c(0, 1, 2)) x <- c(0, 1, 2) y <- c(0, 1, 2) z <- c(0, 1, 2) P <- cart2pol (x, y, z) expect_equal (P[,"theta"], c(0, pi/4, pi/4)) expect_equal (P[,"r"], sqrt (2)*c(0, 1, 2)) expect_equal (P[,"z"], z) x <- c(0, 1, 2) y <- 0 z <- 0 P <- cart2pol (x, y, z) expect_equal (P[,"theta"], c(0, 0, 0)) expect_equal (P[,"r"], x) expect_equal (P[,"z"], c(0, 0, 0)) x <- 0 y <- c(0, 1, 2) z <- 0 P <- cart2pol (x, y, z) expect_equal (P[,"theta"], c(0, 1, 1)*pi/2) expect_equal (P[,"r"], y) expect_equal (P[,"z"], c(0, 0, 0)) x <- 0 y <- 0 z <- c(0, 1, 2) P <- cart2pol (x, y, z) expect_equal (P[,"theta"], c(0, 0, 0)) expect_equal (P[,"r"], c(0, 0, 0)) expect_equal (P[,"z"], z) C <- rbind(c(x=0, y=0), c(1, 1), c( 2, 2)) P <- rbind(c(theta=0, r=0), c(pi/4, sqrt(2)), c(pi/4, 2*sqrt(2))) expect_equal(cart2pol(C), P) ## %!test ## %! C <- c(0, 0, 0 1, 1, 1 2, 2, 2) ## %! P <- c(0, 0, 0 pi/4, sqrt(2), 1 pi/4, 2*sqrt(2), 2) ## %! expect_equal (cart2pol (C), P) ## %!test ## %! x <- zeros (1, 1, 1, 2) ## %! x(1, 1, 1, 2) <- sqrt (2) ## %! y <- x ## %! c(P[,"theta"], r) <- cart2pol (x, y) ## %! T <- zeros (1, 1, 1, 2) ## %! T(1, 1, 1, 2) <- pi/4 ## %! R <- zeros (1, 1, 1, 2) ## %! R(1, 1, 1, 2) <- 2 ## %! expect_equal (P[,"theta"], T) ## %! expect_equal (P[,"r"], R) ## %!test ## %! c(x, y, Z) <- meshgrid (c(0, 1), c(0, 1), c(0, 1)) ## %! c(t, r, z) <- cart2pol (x, y, Z) ## %! T(:, :, 1) <- c(0, 0 pi/2, pi/4) ## %! T(:, :, 2) <- T(:, :, 1) ## %! R <- sqrt (x.^2 + y.^2) ## %! expect_equal (t, T) ## %! expect_equal (P[,"r"], R) ## %! expect_equal (z, Z) ## Test input validation expect_error(cart2pol()) expect_error(cart2pol(1,2,3,4)) expect_error(cart2pol(list(1,2,3)), regexp="input must be matrix with 2 or 3 columns") ## expect_error cart2pol (ones (3,3,2)) ## expect_error cart2pol (c(1)) ## expect_error cart2pol (c(1,2,3,4)) ## expect_error cart2pol ({1,2,3}, c(1,2,3)) ## expect_error cart2pol (c(1,2,3), {1,2,3}) ## expect_error cart2pol (ones (3,3,3), ones (3,2,3)) ## expect_error cart2pol ({1,2,3}, c(1,2,3), c(1,2,3)) ## expect_error cart2pol (c(1,2,3), {1,2,3}, c(1,2,3)) ## expect_error cart2pol (c(1,2,3), c(1,2,3), {1,2,3}) ## expect_error cart2pol (ones (3,3,3), 1, ones (3,2,3)) ## expect_error cart2pol (ones (3,3,3), ones (3,2,3), 1) }) geometry/tests/testthat/test-parallel.R0000644000176200001440000000125614662314120020006 0ustar liggesuserscontext("Interaction with parallel package") library(parallel) test_that("delaunayn can be called with mc.apply", { ## mc.cores must be 1 on Windows. Otherwise use only 2 cores to comply ## with CRAN guidelines. mc.cores <- ifelse(Sys.info()[1] == "Windows", 1, 2) ## Set seed for replicability set.seed(1) ## Create points and try standard Delaunay Triangulation N <- 100000 P <- matrix(runif(2*N), N, 2) T <- delaunayn(P) expect_identical(nrow(T), 199966L) ## Now try out the parallel version. Ts <- mclapply(list(P, P, P, P), delaunayn, mc.cores=mc.cores) expect_length(Ts, 4) expect_identical(nrow(Ts[[1]]), 199966L) expect_identical(Ts[[1]], T) }) geometry/tests/testthat/test-delaunayn.R0000644000176200001440000001304614664554667020222 0ustar liggesuserscontext("delaunayn") test_that("delaunayn produces the correct output", { ## Create points that, when passed to Qhull with the Qt option, ## would give degenerate simplices - thanks to Bill Denney for ## example ps <- as.matrix(rbind(data.frame(a=0, b=0, d=0), merge(merge(data.frame(a=c(-1, 1)), data.frame(b=c(-1, 1))), data.frame(d=c(-1, 1))))) ts <- delaunayn(ps) expect_type(ts, "integer") expect_identical(dim(ts), c(12L, 4L)) ## With output.options=TRUE, there should be a trinagulation, areas and ## neighbours and the sum of the ares should be 8 ts.full <- delaunayn(ps, output.options=TRUE) expect_equal(ts, ts.full$tri, check.attributes=FALSE) expect_equal(length(ts.full$areas), nrow(ts.full$tri)) expect_equal(length(ts.full$neighbours), nrow(ts.full$tri)) expect_equal(sum(ts.full$area), 8) ## With full output, there should be a trinagulation, areas and ## neighbours and the sum of the ares should be 8 ## full will be deprecated in a future version ts.full <- delaunayn(ps, full=TRUE) expect_equal(ts, ts.full$tri, check.attributes=FALSE) expect_equal(length(ts.full$areas), nrow(ts.full$tri)) expect_equal(length(ts.full$neighbours), nrow(ts.full$tri)) expect_equal(sum(ts.full$area), 8) ## tsearchn shouldn't return a "degnerate simplex" error. expect_silent(tsearchn(ps, ts, cbind(1, 2, 4))) ## If the input matrix contains NAs, delaunayn should return an error ps <- rbind(ps, NA) expect_error(delaunayn(ps)) }) test_that("In the case of just one triangle, delaunayn returns a matrix", { pc <- rbind(c(0, 0), c(0, 1), c(1, 0)) pct <- delaunayn(pc) expect_type(pct, "integer") expect_identical(dim(pct), c(1L, 3L)) ## With no options it should also produce a triangulation. This ## mirrors the behaviour of octave and matlab pct <- delaunayn(pc, "") expect_type(pct, "integer") expect_identical(dim(pct), c(1L, 3L)) pct.full <- delaunayn(pc, output.options=TRUE) expect_equal(pct.full$areas, 0.5) }) test_that("In the case of a degenerate triangle, delaunayn returns a matrix with zero rows", { pc <- rbind(c(0, 0), c(0, 1), c(0, 2)) pct <- delaunayn(pc) expect_type(pct, "integer") expect_identical(dim(pct), c(0L, 3L)) pct.full <- delaunayn(pc, output.options=TRUE) expect_equal(length(pct.full$areas), 0) expect_equal(length(pct.full$neighbours), 0) }) test_that("In the case of just one tetrahaedron, delaunayn returns a matrix", { pc <- rbind(c(0, 0, 0), c(0, 1, 0), c(1, 0, 0), c(0, 0, 1)) pct <- delaunayn(pc) expect_type(pct, "integer") expect_identical(dim(pct), c(1L, 4L)) pct.full <- delaunayn(pc, output.options=TRUE) expect_equal(pct.full$areas, 1/6) }) test_that("Output to file works", { ps <- matrix(rnorm(3000), ncol=3) ps <- sqrt(3)*ps/drop(sqrt((ps^2) %*% rep(1, 3))) fname <- path.expand(file.path(tempdir(), "test1.txt")) pst <- delaunayn(ps, paste0("QJ TO '", fname, "'")) expect_true(file.exists(fname)) }) test_that("The QJ option can give degenerate simplices", { ## Create degenerate simplex - thanks to Bill Denney for example ps <- as.matrix(rbind(data.frame(a=0, b=0, d=0), merge(merge(data.frame(a=c(-1, 1)), data.frame(b=c(-1, 1))), data.frame(d=c(-1, 1))))) ## The QJ option leads to on simplex being very small ts <- delaunayn(ps, "QJ") expect_warning(tsearchn(ps, ts, cbind(1, 2, 4))) }) test_that("A square is triangulated", { ## This doesn't work if the Qz option isn't supplied square <- rbind(c(0, 0), c(0, 1), c(1, 0), c(1, 1)) expect_equal(delaunayn(square), rbind(c(4, 2, 1), c(4, 3, 1)), check.attributes=FALSE) expect_error(delaunayn(square, ""), "QH6239 Qhull precision error: initial Delaunay input sites are cocircular or cospherical") }) test_that("No regression on issue 11: All points in a box far from the origin are triangulated", { ## Generate set of randomly generated points in a 40 unit square, ## 250,000 from the origin set.seed(2) p <- geometry::rbox(4000, D=2, 20) + 250000 ## Triangulate t <- delaunayn(p) ## Count how many of the points aren't in the triangulation - should be zero expect_equal(length(setdiff(seq(1,nrow(p)), unique(c(t[,1], t[,2], t[,3])))), 0) ## Plotting: in the plot below, untriangulated points appear in red ## Basted on Jean-Romain's example in https://github.com/davidcsterratt/geometry/issues/11 ## x <- p[,1] ## y <- p[,2] ## plot(x, y, cex = 0.1, col = "red") ## trimesh(t, x, y, add = T) }) test_that("No regression on issue 12: All points in a small box with different x and y distances to the origin are triangulated", { ## Generate set of randomly generated points in a 40 unit square, ## with x distance of 5E5 from the origin and y distance 5E6 from ## the orgin. Note that the mean x and y values relative to the ## width of the window are quite different to each other. set.seed(2) p <- geometry::rbox(4000, D=2, 20) + 5E5 p[,2] <- p[,2] + 5E6 ## Expect warnings without the correct options expect_warning(delaunayn(p), "points missing from triangulation") expect_warning(delaunayn(p, options="Qt Qc Qz Qbb"), "points missing from triangulation") expect_warning(delaunayn(p, options="Qt Qc Qz QbB"), "points missing from triangulation") ## Centring the points does allow triangulation p.centred <- cbind(p[,1] - mean(p[,1]), p[,2] - mean(p[,2])) delaunayn(p.centred) }) geometry/tests/testthat/test-cart2sph.R0000644000176200001440000000377113432317404017746 0ustar liggesuserscontext("cart2sph") test_that("cart2sph works correctly", { x <- c(0, 1, 2) y <- c(0, 1, 2) z <- c(0, 1, 2) Ps <- cart2sph(x, y, z) expect_equal(Ps[,"theta"], c(0, pi/4, pi/4)) expect_equal(Ps[,"phi"], c(0, 1, 1)*atan(sqrt(0.5))) expect_equal(Ps[,"r"], c(0, 1, 2)*sqrt(3)) x <- 0 y <- c(0, 1, 2) z <- c(0, 1, 2) Ps <- cart2sph(x, y, z) expect_equal(Ps[,"theta"], c(0, 1, 1)*pi/2) expect_equal(Ps[,"phi"], c(0, 1, 1)*pi/4) expect_equal(Ps[,"r"], c(0, 1, 2)*sqrt(2)) x <- c(0, 1, 2) y <- 0 z <- c(0, 1, 2) Ps <- cart2sph(x, y, z) expect_equal(Ps[,"theta"], c(0, 0, 0)) expect_equal(Ps[,"phi"], c(0, 1, 1)*pi/4) expect_equal(Ps[,"r"], c(0, 1, 2)*sqrt(2)) x <- c(0, 1, 2) y <- c(0, 1, 2) z <- 0 Ps <- cart2sph(x, y, z) expect_equal(Ps[,"theta"], c(0, 1, 1)*pi/4) expect_equal(Ps[,"phi"], c(0, 0, 0)) expect_equal(Ps[,"r"], c(0, 1, 2)*sqrt(2)) C <- rbind(c(0, 0, 0), c(1, 0, 1), c(2, 0, 2)) S <- rbind(c(theta=0, phi=0, r=0), c(0, pi/4, sqrt(2)), c(0, pi/4, 2*sqrt(2))) expect_equal(cart2sph(C), S) }) test_that("cart2sph error validation works correctly", { expect_error(cart2sph()) expect_error(cart2sph(1,2)) expect_error(cart2sph(1,2,3,4)) expect_error(cart2sph(list(1, 2, 3)), regexp="input must be matrix with 3 columns") expect_error(cart2sph(array(1, c(3,3,2))), regexp="matrix input must have 3 columns") expect_error(cart2sph(cbind(1,2,3,4)), regexp=c("matrix input must have 3 columns")) expect_error(cart2sph(list(1,2,3), c(1,2,3), c(1,2,3)), regexp="numeric arrays of the same size") expect_error(cart2sph(c(1,2,3), list(1,2,3), c(1,2,3), regexp="numeric arrays of the same size")) expect_error(cart2sph(c(1,2,3), c(1,2,3), list(1,2,3)), regexp="numeric arrays of the same size") expect_error(cart2sph(array(1, c(3, 3, 3)), 1, array(1, c(3,3,2))), regexp="matrices of the same size") expect_error(cart2sph(array(1, c(3, 3, 3)), array(1, c(3,3,2)), 1), regexp="matrices of the same size") }) geometry/tests/testthat/test-tsearchn.R0000644000176200001440000001002713525562746020035 0ustar liggesuserscontext("tsearchn") test_that("tsearchn gives the expected output", { ## Simple example x <- c(-1, -1, 1) y <- c(-1, 1, -1) p <- cbind(x, y) tri <- matrix(c(1, 2, 3), 1, 3) ## Should be in triangle #1 ts <- tsearchn(p, tri, cbind(-1, -1),fast=FALSE) expect_equal(ts$idx, 1) expect_equal(ts$p, cbind(1, 0, 0)) ## Should be in triangle #1 ts <- tsearchn(p, tri, cbind(1, -1), fast=FALSE) expect_equal(ts$idx, 1) expect_equal(ts$p, cbind(0, 0, 1)) ## Should be in triangle #1 ts <- tsearchn(p, tri, cbind(-1, 1), fast=FALSE) expect_equal(ts$idx, 1) expect_equal(ts$p, cbind(0, 1, 0)) ## Centroid ts <- tsearchn(p, tri, cbind(-1/3, -1/3), fast=FALSE) expect_equal(ts$idx, 1) expect_equal(ts$p, cbind(1/3, 1/3, 1/3)) ## Should be outside triangle #1, so should return NA ts <- tsearchn(p, tri, cbind(1, 1), fast=FALSE) expect_true(is.na(ts$idx)) expect_true(all(is.na(ts$p))) ## Create a mesh with a zero-area element (degenerate simplex) p <- cbind(c(-1, -1, 0, 1, 2), c(-1, 1, 0, 0, 0)) tri <- rbind(c(1, 2, 3), c(3, 4, 5)) ## Look for one point in one of the simplices and a point outwith the ## simplices. This forces tsearchn to look in all simplices. It ## shouldn't fail on the degenerate simplex. expect_warning(ts <- tsearchn(p, tri, rbind(c(-0.5, 0), c(3, 1)), fast=FALSE)) expect_equal(ts$idx, c(1, NA)) ts <- tsearchn(p, tri, rbind(c(-0.5, 0), c(3, 1)), fast=TRUE) expect_equal(ts$idx, c(1, NA)) }) context("tsearchn_delaunayn") test_that("tsearchn gives the expected output", { ## Erroneous input is caught safely. Force ## tsearchn_delaunayn to be called tfake <- matrix(1:3, 1, 3) class(tfake) <- "delaunayn" expect_error(suppressWarnings(tsearchn(NA, tfake, matrix(1:2, 1, 2))), "Delaunay triangulation has no delaunayn attribute") x <- cbind(c(-1, -1, 1), c(-1, 1, -1)) dt <- delaunayn(x, output.options=TRUE) ## Should be in triangle #1 xi <- cbind(-1, 1) expect_warning(ts <- tsearchn(NA, dt, xi)) expect_equal(ts$idx, 1) expect_equal(bary2cart(x[dt$tri[ts$idx,],], ts$p), xi) ## Centroid xi <- cbind(-1/3, -1/3) expect_warning(ts <- tsearchn(NA, dt, xi)) expect_equal(ts$idx, 1) expect_equal(ts$p, cbind(1/3, 1/3, 1/3)) ## Should be outside triangle #1, so should return NA xi <- cbind(1, 1) expect_warning(ts <- tsearchn(NA, dt, xi)) expect_true(is.na(ts$idx)) expect_true(all(is.na(ts$p))) ## Check mutliple points work xi <- rbind(c(-1, 1), c(-1/3, -1/3)) expect_warning(ts <- tsearchn(NA, dt, xi)) expect_equal(ts$idx, c(1, 1)) expect_equal(do.call(rbind, lapply(1:2, function(i) { bary2cart(x[dt$tri[ts$idx[i],],], ts$p[i,]) })), xi) ## Test against original version p <- cbind(c(0, 0, 1, 1, 0.5), c(0, 1, 1, 0, 0.5)) dt <- delaunayn(p, "FA") ## Interesting error, as default options are 'nixed dt <- delaunayn(p, output.options=TRUE) xi <- c(0.1, 0.5, 0.9, 0.5) yi <- c(0.5, 0.9, 0.5, 0.1) expect_warning(ts <- tsearchn(NA, dt, cbind(xi, yi))) expect_equal(ts$idx, tsearch(p[,1], p[,2], dt$tri, xi, yi, method="orig")) ## 3D test x <- rbox(D=3, B=1) dt <- delaunayn(x, output.options=TRUE) xi <- rbind(c(0.5, 0.5, 0.5), c(-0.5, -0.5, -0.5), c(0.9, 0, 0)) expect_warning(ts <- tsearchn(NA, dt, xi)) expect_equal(do.call(rbind, lapply(1:3, function(i) { bary2cart(x[dt$tri[ts$idx[i],],], ts$p[i,]) })), xi) ## 4D test ## ## This does not work yet. The "best" facet is not always the correct facet. ## x <- rbox(D=4, B=1) ## dt <- delaunayn(x, output.options=TRUE) ## xi <- rbind(c(0.5, 0.5, 0.5, 0.5), ## c(-0.49, -0.49, -0.49, -0.49), ## c(0.9, 0, 0, 0)) ## ts <- tsearchn(dt, NA, xi) ## expect_equal(do.call(rbind, lapply(1:3, function(i) { ## bary2cart(x[dt$tri[ts$idx[i],],], ts$p[i,]) ## })), xi) ## We don't need to test when creating a mesh with a zero-area ## element (degenerate simplex), as these shouldn't be produced by ## qhull. }) geometry/tests/testthat/test-sph2cart.R0000644000176200001440000000447313432317404017746 0ustar liggesuserscontext("sph2cart") test_that("sph2cart works correctly", { t <- c(0, 0, 0) p <- c(0, 0, 0) r <- c(0, 1, 2) C <- sph2cart (t, p, r) expect_equal(C[,"x"], r) expect_equal(C[,"y"], c(0, 0, 0)) expect_equal(C[,"z"], c(0, 0, 0)) t <- 0 p <- c(0, 0, 0) r <- c(0, 1, 2) C <- sph2cart(t, p, r) expect_equal(C[,"x"], r) expect_equal(C[,"y"], c(0, 0, 0)) expect_equal(C[,"z"], c(0, 0, 0)) t <- c(0, 0, 0) p <- 0 r <- c(0, 1, 2) C <- sph2cart (t, p, r) expect_equal(C[,"x"], r) expect_equal(C[,"y"], c(0, 0, 0)) expect_equal(C[,"z"], c(0, 0, 0)) t <- c(0, 0.5, 1)*pi p <- c(0, 0, 0) r <- 1 C <- sph2cart(t, p, r) expect_equal(C[,"x"], c(1, 0, -1)) expect_equal(C[,"y"], c(0, 1, 0)) expect_equal(C[,"z"], c(0, 0, 0)) C <- sph2cart(c(0, 0, 0), 0, 1) expect_equal(C[,"x"], c(1, 1, 1)) expect_equal(C[,"y"], c(0, 0, 0)) expect_equal(C[,"z"], c(0, 0, 0)) S <- rbind(c(0, 0, 1), c(0.5*pi, 0, 1), c(pi, 0, 1)) C <- rbind(c(x=1, y=0, z=0), c(0, 1, 0), c(-1, 0, 0)) expect_equal(sph2cart(S), C) }) # FIXME: to implement #! c(t, p, r) <- meshgrid (c(0, pi/2), c(0, pi/2), c(0, 1)) #! c(x, y, z) <- sph2cart (t, p, r) #! X <- zeros(2, 2, 2) #! X(1, 1, 2) <- 1 #! Y <- zeros(2, 2, 2) #! Y(1, 2, 2) <- 1 #! Z <- zeros(2, 2, 2) #! Z(2, :, 2) <- c(1 1) #! expect_equal(x, X, eps) #! expect_equal(y, Y, eps) #! expect_equal(z, Z) test_that("sph2cart error validation works correctly", { expect_error(sph2cart()) expect_error(sph2cart(1,2)) expect_error(sph2cart(1,2,3,4)) expect_error(sph2cart(list(1, 2, 3)), regexp="input must be matrix with 3 columns") expect_error(sph2cart(array(1, c(3,3,2))), regexp="matrix input must have 3 columns") expect_error(sph2cart(cbind(1,2,3,4)), regexp=c("matrix input must have 3 columns")) expect_error(sph2cart(list(1,2,3), c(1,2,3), c(1,2,3)), regexp="numeric arrays of the same size") expect_error(sph2cart(c(1,2,3), list(1,2,3), c(1,2,3), regexp="numeric arrays of the same size")) expect_error(sph2cart(c(1,2,3), c(1,2,3), list(1,2,3)), regexp="numeric arrays of the same size") expect_error(sph2cart(array(1, c(3, 3, 3)), 1, array(1, c(3,3,2))), regexp="matrices of the same size") expect_error(sph2cart(array(1, c(3, 3, 3)), array(1, c(3,3,2)), 1), regexp="matrices of the same size") }) geometry/tests/testthat/test-intersectn.R0000644000176200001440000002131113462263674020400 0ustar liggesuserstest_that("intersectn can run on overlapping triangles", { ## Make star of David from isosceles triangles of length 3 ps1 <- rbind(c(0, sqrt(3)), c(3/2, -sqrt(3)/2), c(-3/2, -sqrt(3)/2)) ps2 <- ps1 ps2[,2] <- -ps2[,2] expect_equal(feasible.point(convhulln(ps1, output.options=TRUE), convhulln(ps2, output.options=TRUE)), c(0, 0)) is <- intersectn(ps1, ps2) isa <- intersectn(ps1, ps2, autoscale=TRUE) ## Intersecting area is same as 6 isosceles triangles of length 1, which have ## area sqrt(3)/4 ## expect_equal(is$ch$vol, sqrt(3)/4*6) expect_equal(isa$ch$vol, sqrt(3)/4*6) ## Another overlapping example ps2 <- ps1 ps2[,2] <- ps2[,2]+2 is <- intersectn(ps1, ps2) ## Now make one element of feasible point negative ps3 <- ps1 ps4 <- ps1 ps4[,2] <- -ps4[,2] ps3[,2] <- ps3[,2] - 10 ps4[,2] <- ps4[,2] - 10 expect_equal(feasible.point(convhulln(ps3, output.options=TRUE), convhulln(ps4, output.options=TRUE)), c(0, -10)) expect_equal(intersectn(ps3, ps4)$ch$vol, sqrt(3)/4*6) }) test_that("intersectn gives zero volume on non-overlapping triangles", { ps1 <- rbind(c(0, sqrt(3)), c(3/2, -sqrt(3)/2), c(-3/2, -sqrt(3)/2)) ps2 <- ps1 ps2[,2] <- ps2[,2] + 3 expect_equal(feasible.point(convhulln(ps1, "n"), convhulln(ps2, "n")), NA) is <- intersectn(ps1, ps2) expect_equal(is$ch$vol, 0) }) test_that("intersectn gives zero volume on non-overlapping triangles", { ps1 <- rbind(c(0, sqrt(3)), c(3/2, -sqrt(3)/2), c(-3/2, -sqrt(3)/2)) ps2 <- ps1 ps2[,2] <- ps2[,2] + 3 expect_equal(feasible.point(convhulln(ps1, "n"), convhulln(ps2, "n")), NA) is <- intersectn(ps1, ps2) expect_equal(is$ch$vol, 0) }) test_that("feasible.point works on a 3D example", { ## These tetrahedra do not overlap ps1 <- rbind(c( 0.5000000, -0.5000000, 0.5000000), c(-0.1018942, 0.1848312, -0.1260239), c( 0.5000000, -0.5000000, -0.5000000), c(-0.5000000, -0.5000000, -0.5000000)) ps2 <- rbind(c( 0.7581575, 0.6352585, 0.32876), c( 1.0000000, 0.0000000, 1.00000), c( 0.0000000, 0.0000000, 1.00000), c( 1.0000000, 0.0000000, 0.00000)) expect_equal(feasible.point(convhulln(ps1, "n"), convhulln(ps2, "n")), NA) }) test_that("intersectn can run on overlapping tetrahedra", { ## Make star of David from isocelese triangles of length 3 ps1 <- rbind(c(0, sqrt(3), 0), c(3/2, -sqrt(3)/2, 0), c(-3/2, -sqrt(3)/2, 0), c(0, 0, 3*sqrt(2/3))) ch1 <- convhulln(ps1, "FA") expect_equal(ch1$vol, sqrt(2)/12*27) ps2 <- ps1 ## By shifting tetrahedron up by half of its height, we should make ## something with 1/8 of the volume ps2[,3] <- ps2[,3] + 3/2*sqrt(2/3) is <- intersectn(ps1, ps2) expect_equal(is$ch$vol, sqrt(2)/12*27/8) }) test_that("intersectn can run on tetrahedra with a common point", { ps1 <- rbind(c(-0.4015654, -0.1084358, -0.3727391), c( 0.2384763, 0.3896078, -0.4447473), c( 0.5000000, -0.5000000, -0.5000000), c(-0.5000000, -0.5000000, -0.5000000)) ps2 <- rbind(c(-0.1392469, 0.03303547, -0.2436112), c( 0.3434195, -0.20338201, -0.4638141), c(-0.5000000, 0.50000000, -0.5000000), c(-0.5000000, -0.50000000, -0.5000000)) is <- intersectn(ps1, ps2) }) test_that("intersectn can compute the volume of overlapping delaunay triangulations of boxes", { ## Volume of overlap should be 1/8 ps1 <- rbox(2, B=0.5, C=0.5) ps2 <- rbox(2, B=0.5, C=0.5) + 0.5 dt1 <- delaunayn(ps1) dt2 <- delaunayn(ps2) vol <- 0 for (i in 1:nrow(dt1)) { for (j in 1:nrow(dt2)) { is <- intersectn(ps1[dt1[i,],], ps2[dt2[j,],]) vol <- vol + is$ch$vol } } expect_equal(vol, 0.125, tol=0.0001) }) test_that("intersectn can deal with some input that caused errors before fixing Issue #34", { ## Issue 34: https://github.com/davidcsterratt/geometry/issues/34 ps1 <- rbind( c(500.9656357388012111187, 843268.9656357388012111, 5.5), c(658.9656357388012111187, 843109.9656357388012111, 10.0), c(576.9656357388012111187, 843174.9656357388012111, 2.0), c(795.9656357388012111187, 843235.9656357388012111, 20.0)) ps2 <- rbind( c(707.9656400000000076034, 843153.9656399999512359, 12.000000000000000000000), c(645.6795799999999871943, 843166.4228499999735504, 10.200630000000000308091), c(631.6632399999999734064, 843182.9680800000205636, 8.772800000000000153477), c(707.9656400000000076034, 843153.9656399999512359, 12.000000000000000000000), c(608.9447900000000117871, 843172.7368899999419227, 7.772330000000000183036), c(607.9656400000000076034, 843173.9656399999512359, 7.669999999999999928946)) ## Before Issue #34 was fixed this threw an error: ## Received error code 2 from qhull. Qhull error: ## qhull precision warning: ## The initial hull is narrow (cosine of min. angle is 1.0000000000000002). ## expect_error(intersectn(ps1, ps2, tol=1E-4, return.chs=FALSE, options="Tv"), ".*The initial hull is narrow.*") ## This threw an error in Rev aab45b7311b6 out <- intersectn(ps1, ps2, tol=1E-4, return.chs=FALSE) }) test_that("intersectn works on rotated boxes", { rot <- function(theta) {return(rbind(c(cos(theta), sin(theta)), c(-sin(theta), cos(theta))))} ## Area of octogan created by two squares at 45 deg to each other sq <- rbox(C=1, D=2, n=0) expect_equal(intersectn(sq%*%rot(pi/4), sq)$ch$vol, 8*(sqrt(2) - 1)) rot4 <- function(theta) {return(rbind(c(cos(theta), sin(theta), 0, 0), c(-sin(theta), cos(theta), 0, 0), c(0, 0, 1, 0), c(0, 0, 0 ,1)))} ## Area of hyperoctoid created by two hypercubes at 45 deg to each other hc <- rbox(C=1, D=4, n=0) expect_equal(intersectn(hc%*%rot4(pi/4), hc)$ch$vol, 4*8*(sqrt(2) - 1)) }) test_that("intersectn works in 4D", { load(file.path(system.file(package="geometry"), "extdata", "intersectn4D.RData")) chi <- convhulln(seti, output.options=TRUE) chj <- convhulln(setj, output.options=TRUE) chij <- intersectn(seti, setj) chji <- intersectn(setj, seti) expect_equal(chij$ch$vol, chji$ch$vol) expect_true(chi$vol >= chij$ch$vol) expect_equal(chj$vol, chij$ch$vol) }) test_that("no regression on issue 35", { ## This gave an error in version 0.4.1 ## See https://github.com/davidcsterratt/geometry/issues/35 load(file.path(system.file(package="geometry"), "extdata", "issue35-intersectn.RData")) ch <- intersectn(seti, setj) expect_true(ch$ch$vol > 0) cha <- intersectn(seti, setj, autoscale=TRUE) expect_true(cha$ch$vol > 0) expect_equal(ch$ch$vol, cha$ch$vol) }) test_that("no regression on issue 35", { ## This is an example that requires various combinations of flags to ## be provided to lpSolve::lp ## ## Also testing a scaled version, which was easier to fixed with the ## set of flags used originally. ## https://github.com/davidcsterratt/geometry/issues/35 load(file.path(system.file(package="geometry"), "extdata", "error_15_620.RData")) ch <- intersectn(p1, p1) expect_true(ch$ch$vol > 0) cha <- intersectn(p1, p1, autoscale=TRUE) expect_true(cha$ch$vol > 0) expect_equal(ch$ch$vol, cha$ch$vol) zfac <- 10 p1[,3] <- p1[,3]*zfac p2[,3] <- p2[,3]*zfac ch <- intersectn(p1, p1) expect_true(ch$ch$vol > 0) cha <- intersectn(p1, p1, autoscale=TRUE) expect_true(cha$ch$vol > 0) expect_equal(ch$ch$vol, cha$ch$vol) }) test_that("intersectn doesn't crash on some input", { ## This is an example causes a crash if flag SCALE_GEOMETRIC (4) is ## given to lpSolve::lp in feasible.point() load(file.path(system.file(package="geometry"), "extdata", "overlap260-5034.RData")) ch <- intersectn(p1, p2) cha <- intersectn(p1, p2, autoscale=TRUE) expect_equal(ch$ch$vol, cha$ch$vol) }) test_that("intersectn doesn't crash on input that causes a crash with scale=7 on some processors", { ## This is an example causes a crash on some processors if flag SCALE_CURTISREID (7) is ## given to lpSolve::lp in feasible.point() load(file.path(system.file(package="geometry"), "extdata", "save-overlap32-176.RData")) intersectn(p1, p2, tol=1E-3) load(file.path(system.file(package="geometry"), "extdata", "save-overlap68-557.RData")) intersectn(p1, p2, tol=1E-3) }) test_that("intersectn doesn't crash on input that causes a crash with EQUILIBRIATE=1 on some processors", { ## This is an example causes a crash on some processors if flag ## EQUILIBRIATE is given to lpSolve::lp in feasible.point() load(file.path(system.file(package="geometry"), "extdata", "save-overlap149-9428.RData")) intersectn(p1, p2, tol=1E-3) }) geometry/tests/testthat.R0000644000176200001440000000005213432270466015236 0ustar liggesuserslibrary(testthat) test_check("geometry") geometry/tests/spelling.R0000644000176200001440000000024113432270466015213 0ustar liggesusersif(requireNamespace('spelling', quietly = TRUE)) spelling::spell_check_test(vignettes = TRUE, error = FALSE, skip_on_cran = TRUE) geometry/MD50000644000176200001440000003221614751753072012434 0ustar liggesusers9087749cf71bc7122189ca675372b1d9 *DESCRIPTION 068b549a6e5e2c90a18f87356b4f00a4 *NAMESPACE eb31eec68df1b606d75f57adeb3ed912 *NEWS d100f679b938110d96307291fce64c41 *R/RcppExports.R 9c6b34a4cc5fd5384ff9576db63347e0 *R/Unique.R 6676c6f07f0bcf0743181ad81a5b13bc *R/cart2pol.R 422a3c2ca63eb50396f478d6ba49c445 *R/cart2sph.R 89a8d43655515d1c3c79a2e962fe1ab0 *R/convhulln.R 8f98d65db1398d025604e04570125e7e *R/delaunayn.R f67b6e054d55c085ef68f4fde78db0d8 *R/distmesh2d.R 58839184c5c9f16e927f689276f9521b *R/distmeshnd.R f02e89ee5fbbee42592d159bb119ee29 *R/dotprod.R 53e68a5fd3ffa96307ac3eec3ed15241 *R/entry.value.R 75b95b74ee13f9fc9f74214416e2512c *R/extprod3d.R 13663e9698eeef3705b2cf444b55df42 *R/halfspacen.R 5f62c32fecf8cefacd30b5df31fde42f *R/inhulln.R 9a409fbef9b11d787e3b27b57d6b6dd5 *R/intersectn.R c2917f4499966c4bff5722c3a20ee293 *R/matmax.R 7953e067c808a844a6c25661b1f1fb19 *R/matmin.R 8845a9403edba64246177b1dab548d13 *R/matorder.R 7e77a7bbe9672e5a0efb27c33d0e47b7 *R/matsort.R 7d2a5c12b42717a5ccdf00af6b2acd06 *R/mesh.dcircle.R 2c454daede65e5c6a297c26c0de3bdc8 *R/mesh.diff.R c5a88a07fa0bb752e0b0fbc6a645e583 *R/mesh.drectangle.R 2ae969c5c662d5c4467ef4e7b6896fbd *R/mesh.dsphere.R 51f8458e619561296c18480dd9999be9 *R/mesh.hunif.R 019be320da1d80cd299776aba8e99e9e *R/mesh.intersect.R 4b471fb760c3b594a694cb8c8f2da59a *R/mesh.union.R f5863ae2279fab13fcca746122d3fb46 *R/pol2cart.R fcb8ec599d4463dc3e54287a670a1fab *R/polyarea.R c12ac336deb0b3be98a34eedb85bb61c *R/qhull-options.R 1c1c60e6a45ddb705e6480e965ab73d9 *R/rbox.R 979d55326e8f9e1029e95bd5651dc207 *R/sph2cart.R 95f3f780f786fa8dd704c89a9a0a0398 *R/surf.tri.R babfa6ca9e4b76b0353281b26426dfa0 *R/tetramesh.R 0255bc872693f2a7d519c67bf89217b2 *R/trimesh.R d0a05bf107df68a7a13fdfc16f3ab4c1 *R/trisplinter.R bd79225e1f0911ec27614d244b9df7a3 *R/tsearch.R 5bcde801b6cdd84aeb1d9fd51f5d2206 *build/vignette.rds 29a536ff14c26f87f9db8a06086d57eb *demo/00Index 2c2720d298e89a313a8963f5edc84fe6 *demo/intersectn.R 3128acf4b0156e6c2b2d1e8ed9e3fcac *inst/WORDLIST af3ca7a8ec4eb7c3808e7e4b0e7b9d20 *inst/doc/LICENSE-NOTES a17aa14b2581ee880ad40d5d1ad0c138 *inst/doc/MODIFIED.txt 74b4f6b9894c15d5da15f00fb59bcedb *inst/doc/qhull-eg.R e4da12d940671662c95f27cc01da1ddb *inst/doc/qhull-eg.Rnw 525f6d48677f96b423db7c9f29812cf8 *inst/doc/qhull-eg.pdf 7f91e2f84c11dd41a932b6d03a63ae3d *inst/doc/qhull/Announce.txt 0c45b9e641ac0592e3eda32dac223b9a *inst/doc/qhull/COPYING.txt 1ad9811271fd30b546ff4f5d3d0e4cc6 *inst/doc/qhull/File_id.diz 916939bb1fee5b8ca7826fbcf7b53232 *inst/doc/qhull/README.txt dfc60c06612b894244510f7efa338c08 *inst/doc/qhull/REGISTER.txt 4b18ce3564cef2b9954e0c13163abfbd *inst/doc/qhull/html/index.html 59e9b69f186c9e715192df9e146ebd21 *inst/doc/qhull/html/normal_voronoi_knauss_oesterle.jpg 5f502b6a0e08493f4ef5ced79ddb5a77 *inst/doc/qhull/html/qconvex.html fbd0d63639d5aa801f85e37f75c5d392 *inst/doc/qhull/html/qdelau_f.html 28dd1530388b4de8badc95b12b1d9bef *inst/doc/qhull/html/qdelaun.html bb51e7810cc49e5aff1b910bc3126713 *inst/doc/qhull/html/qh--4d.gif 687f459f95e958da6c3ff0c83cafcf46 *inst/doc/qhull/html/qh--cone.gif dc51084bc7ba1f235c71d40c771ce9c8 *inst/doc/qhull/html/qh--dt.gif 829df3fbc9a3f36dbdb6389f768b5570 *inst/doc/qhull/html/qh--geom.gif 0587393a4591c5fbcd040af9a4f510c7 *inst/doc/qhull/html/qh--half.gif 0515fcc283b7dfeeaa7169218722880e *inst/doc/qhull/html/qh--rand.gif 012717a06d2274995a039dbc931d10aa *inst/doc/qhull/html/qh-code.html ca6ae4c704d8be67d50b71ce137768a4 *inst/doc/qhull/html/qh-eg.html 378b30492679846a65c50da8d1bd9962 *inst/doc/qhull/html/qh-faq.html 189ccc476db023a2ef3d5f74a301842a *inst/doc/qhull/html/qh-get.html c572d9a92948eb7f3333ff153c844b7f *inst/doc/qhull/html/qh-impre.html 8d37fbeae5ba5dc5f8d673ca589d07eb *inst/doc/qhull/html/qh-optc.html 14922021d64987023bb90e3b628eceff *inst/doc/qhull/html/qh-optf.html eb0cb51f5497a0b57098213858fc665b *inst/doc/qhull/html/qh-optg.html b7f55169f381cfab737188ded5aa3fa3 *inst/doc/qhull/html/qh-opto.html e4c732d38d8389c55fa63955a7e644c8 *inst/doc/qhull/html/qh-optp.html b5a6d0038f4522eb94b4b87804e1d2f9 *inst/doc/qhull/html/qh-optq.html 008e3a59ba0a8c98d4671f8a751f5e6e *inst/doc/qhull/html/qh-optt.html 30454c2fa7db3ea2a72bf72ded9d6447 *inst/doc/qhull/html/qh-quick.html 6aa82b4c2709dd98df2aff103fb944b5 *inst/doc/qhull/html/qhalf.html e8992f5b2de07cbf48583e1f6b9ad5e9 *inst/doc/qhull/html/qhull-cpp.xml 35d88647a340615dcd1bd842a565475c *inst/doc/qhull/html/qhull.html fc4b6d8b5abec935f14dd71369718e9f *inst/doc/qhull/html/qhull.man 5e213194265bc30a85ef692ac37d7836 *inst/doc/qhull/html/qhull.txt 8550cf46dbd89d8068969bf225600f16 *inst/doc/qhull/html/qvoron_f.html f8369a8be58b5f738e7421e367881db2 *inst/doc/qhull/html/qvoronoi.html 03b90e4e5eb3ed77f57a3063694f801d *inst/doc/qhull/html/rbox.html 4cbad586d2136f611dbaf7f47128cc86 *inst/doc/qhull/html/rbox.man 61cd54c422366e1ef1db2babdb3daff9 *inst/doc/qhull/html/rbox.txt b0e7f903d9fe9008ff87baabe3c57b64 *inst/doc/qhull/index.html 70edf8a33ab665ac8d181b0f0a7c5496 *inst/extdata/error_15_620.RData ccb784cef19f015690156d6780ad1a6e *inst/extdata/halfspacen.RData 58ce4b940b18d18c73c8d6a2e9f911ef *inst/extdata/intersectn4D.RData 758b6dfb5a56d69ee98f6474793e1eba *inst/extdata/issue35-intersectn.RData 6d8d5e35f877f39179969b2e5a793841 *inst/extdata/issue57-tsearch.RData f3bce9787d6a1583475c384de6041ca7 *inst/extdata/ordination.Rdata 4f62407c45fc0dbc915fc76e289f04eb *inst/extdata/overlap260-5034.RData 845b30a0f674ce6f53afda166c81c131 *inst/extdata/save-overlap149-9428.RData bbb03765b5230d3f247478cc86c80379 *inst/extdata/save-overlap32-176.RData c80140a229d66996a43c5bdaeba9ef7d *inst/extdata/save-overlap68-557.RData 120f155140c555c5b001863ccde95627 *man/Unique.Rd 07fe105f12d5ca8f759c262e2e957477 *man/bary2cart.Rd 970ab4a4e47777dfd940103ff2b23985 *man/cart2bary.Rd 0a8e16e3e143df04b6ef8875b9433a49 *man/cart2pol.Rd b51e6d8148da25fac20a3c1d8fd05303 *man/cart2sph.Rd 9b80ae9a1b822833c73cfffd1aca77f4 *man/convhulln.Rd b0d7fec3ad46a86f33a9f217a7a722f5 *man/delaunayn.Rd ada20b0e85ad504dd3c5ac9f487b511a *man/distmesh2d.Rd 15bbc0b6a76439450d957b4130f19726 *man/distmeshnd.Rd d0e930cee46465b667cc89e57beed520 *man/dot.Rd afff3cc2ac7de8b6ceda27ef8431aaf2 *man/entry.value.Rd 6b4b104a8b8e185e0e15ab4e650c9a6d *man/extprod3d.Rd a347008f8c0116f3634986d4c86e7b27 *man/feasible.point.Rd 593b6ddb499d3354dc486a1c4a0e6fe2 *man/halfspacen.Rd c8fd1fadfa33cb0a7bb18e102719328c *man/inhulln.Rd 7fcb5537b976dba7490b46dba00f139b *man/intersectn.Rd 1c60bf8b2f2ade2f4d1c640c7bc5c4c9 *man/matmax.Rd cb5183b698da11fa5690176793b1cfe9 *man/mesh.dcircle.Rd 4f11eee330ec96bd13383003e2648fa2 *man/mesh.diff.Rd a187c0aed06dac008908a53d5d1b52f4 *man/mesh.drectangle.Rd 6289e1380af8c9da6901ae4e9b137dd9 *man/mesh.dsphere.Rd b08538f269bdda5767085f1b3c31274e *man/mesh.hunif.Rd 16aadfcf20aa49101e47abcd754b0b60 *man/pol2cart.Rd 462775b2834730b47871d60a0bbb9be8 *man/polyarea.Rd 0c7bac3dc3ba975ac9fad2935e7b5d05 *man/rbox.Rd d90c27c663cc7691a3b918d061903a71 *man/sph2cart.Rd 41c20ea09b7956e3f5d8cbf777305b37 *man/surf.tri.Rd 2d672ec9d2497f941103d4ae5d3034e9 *man/tetramesh.Rd b51abc8a985602501e0c3816b2218e0a *man/to.mesh3d.Rd fa42ae047747c7605cbe6e0298cde115 *man/trimesh.Rd 8e2cbb2206ba988c4dde2298573ac198 *man/tsearch.Rd b61620430d94896c9caba6fc026c08e6 *man/tsearchn.Rd bf9376b598a1adace8c07e6fc5a3e76f *src/Makevars 016587028ca03860d1055fecfbc2f8e3 *src/QuadTree.cpp 142aeeb7f52a33ab71d3e5075e2e388c *src/QuadTree.h 0ac63fec329ebed7be67d5e5e92a89b2 *src/Rconvhulln.c 0f03f1357a95a4b83dcf1146fc351d59 *src/RcppExports.cpp e25e79ab57d6d2f9c968feaf8bde820b *src/Rdelaunayn.c b6287f38e608ad7c37adf9f48e5f106f *src/Rgeometry.c 8acf1c1bc44b83391141acfc86110efe *src/Rgeometry.h 3fe2e4e7a286bfa60915c8ad39e71ceb *src/Rhalfspacen.c eb79fb47cc16340b0e261d45c0cd5409 *src/Rinhulln.c 09a5802c8f61d9e73e1809e30190107a *src/Rtsearch.cpp 552312654c3fc22ca2911a61936d5a77 *src/Rtsearch_orig.c 132f1ddd370877642193ac318285c63a *src/Rtsearchn.c 876c09adad390e33d27f72fbb6dc520d *src/geom2_r.c b5bfc1b056f16945579951686dc2c428 *src/geom_r.c cfde24c128897c30273de690cfb8ad20 *src/geom_r.h 023f4e70e66fe514f68d6a5ffab2201f *src/geometry_init.c 37a6859600a9ea0f040ccf9e15a9ecc4 *src/global_r.c d04d6bb90395474fc978ce7cc6e13915 *src/io_r.c ebd7597c25e31f815e819da068e9914f *src/io_r.h b6910ea39f0797da7489f4421c9b88ea *src/libqhull_r.c a14a634963717e60cba5b904939388d0 *src/libqhull_r.h 8275d12edcabef504d1a39db3680bd09 *src/mem_r.c 61b477889f291ecfc36e9d4d3f9fa8d7 *src/mem_r.h 746094f172d5e194a3b6c857a554e397 *src/merge_r.c 905850f71545d3b4d2d3d0811035eb3d *src/merge_r.h 3e5c51d6c3a002eb661060b51be47fef *src/poly2_r.c f28a42b955f615484659d25f4d40bc72 *src/poly_r.c 73b0c0b388910469d2faae58a39ebca6 *src/poly_r.h 52fcd7e36336fd312c022fce2c45edf5 *src/qhull_ra.h 09c81cd16e87e5db473438003ccd848b *src/qset_r.c 10c15020e692682c0a5dcbd0d78c2cc0 *src/qset_r.h f498e0602fba35e60a1080f3918b99c4 *src/random_r.c a1fe43bed99882c8c850ea6f0ae15ecd *src/random_r.h f38529b9bb49238666b5b7ab044e4b49 *src/rboxlib_r.c f4651d79b4ad50819541cf9092f793f6 *src/stat_r.c ee0baf81125db01bf0bc29f4c2a3c33f *src/stat_r.h 27987c9ca25ddb728b7de06abeffd039 *src/user_r.c 560946c6d1a20ac71211e1d76f3b5f78 *src/user_r.h d18307a2d9a08ae0518527cbb782d901 *src/usermem_r.c 61cd83f3c0639f8e6933f5a15b6c229c *src/userprintf_r.c cc32478b6848d9938c0c5c2832e4869b *src/userprintf_rbox_r.c 0622a97a2aaa3c342f09636052c2d7f5 *tests/spelling.R 56604df63c661b6ff144cbaa297a33ea *tests/testthat.R bb752ab1be8abd752e160eb4f6447da4 *tests/testthat/test-cart2pol.R ff43d4c55f592fdaf2f7448d7e4f8c0c *tests/testthat/test-cart2sph.R 6656a757cfa9231683e457e9fdb2a336 *tests/testthat/test-convhulln.R a1c6b576e28d85965c6bc2a956de7048 *tests/testthat/test-delaunayn.R 2cb0f78866e8c8721a7b480e30fb6716 *tests/testthat/test-distmesh2d.R 039e347fe28ddf0ccbd4f2cb8a475a55 *tests/testthat/test-extprod3d.R 97b50a3013ad39c4c9ab324aa169e785 *tests/testthat/test-halfspacen.R e2c95479bf74aa684ecbba9bbe7043d6 *tests/testthat/test-inhulln.R 7c5dbfcf2f9bad68a5c3349374e9441a *tests/testthat/test-intersectn.R f31602e6034e476ca45ae37dc1174c88 *tests/testthat/test-parallel.R f281e943e2b03f9779a928d579d1c212 *tests/testthat/test-pol2cart.R 2d4dfa8755e18a70a0684185285cb0f2 *tests/testthat/test-polyarea.R 17a871068bdea2a3060b7453d747ab74 *tests/testthat/test-sph2cart.R 97b23669d29291f045958d43f72caeb5 *tests/testthat/test-tsearch-tsearchn-comparison.R 7caf7a903cd201929495683eedd3a69a *tests/testthat/test-tsearch.R 3a847edb84b447e6cd7f6c52e141230e *tests/testthat/test-tsearchn.R af3ca7a8ec4eb7c3808e7e4b0e7b9d20 *vignettes/LICENSE-NOTES a17aa14b2581ee880ad40d5d1ad0c138 *vignettes/MODIFIED.txt 68a2cd14c4b008ba087a727ca09b5bc4 *vignettes/qhull-eg-002.pdf d58115b01fb59320488283b1e5bdca89 *vignettes/qhull-eg-004.pdf e4da12d940671662c95f27cc01da1ddb *vignettes/qhull-eg.Rnw 7f91e2f84c11dd41a932b6d03a63ae3d *vignettes/qhull/Announce.txt 0c45b9e641ac0592e3eda32dac223b9a *vignettes/qhull/COPYING.txt 1ad9811271fd30b546ff4f5d3d0e4cc6 *vignettes/qhull/File_id.diz 916939bb1fee5b8ca7826fbcf7b53232 *vignettes/qhull/README.txt dfc60c06612b894244510f7efa338c08 *vignettes/qhull/REGISTER.txt 4b18ce3564cef2b9954e0c13163abfbd *vignettes/qhull/html/index.html 59e9b69f186c9e715192df9e146ebd21 *vignettes/qhull/html/normal_voronoi_knauss_oesterle.jpg 5f502b6a0e08493f4ef5ced79ddb5a77 *vignettes/qhull/html/qconvex.html fbd0d63639d5aa801f85e37f75c5d392 *vignettes/qhull/html/qdelau_f.html 28dd1530388b4de8badc95b12b1d9bef *vignettes/qhull/html/qdelaun.html bb51e7810cc49e5aff1b910bc3126713 *vignettes/qhull/html/qh--4d.gif 687f459f95e958da6c3ff0c83cafcf46 *vignettes/qhull/html/qh--cone.gif dc51084bc7ba1f235c71d40c771ce9c8 *vignettes/qhull/html/qh--dt.gif 829df3fbc9a3f36dbdb6389f768b5570 *vignettes/qhull/html/qh--geom.gif 0587393a4591c5fbcd040af9a4f510c7 *vignettes/qhull/html/qh--half.gif 0515fcc283b7dfeeaa7169218722880e *vignettes/qhull/html/qh--rand.gif 012717a06d2274995a039dbc931d10aa *vignettes/qhull/html/qh-code.html ca6ae4c704d8be67d50b71ce137768a4 *vignettes/qhull/html/qh-eg.html 378b30492679846a65c50da8d1bd9962 *vignettes/qhull/html/qh-faq.html 189ccc476db023a2ef3d5f74a301842a *vignettes/qhull/html/qh-get.html c572d9a92948eb7f3333ff153c844b7f *vignettes/qhull/html/qh-impre.html 8d37fbeae5ba5dc5f8d673ca589d07eb *vignettes/qhull/html/qh-optc.html 14922021d64987023bb90e3b628eceff *vignettes/qhull/html/qh-optf.html eb0cb51f5497a0b57098213858fc665b *vignettes/qhull/html/qh-optg.html b7f55169f381cfab737188ded5aa3fa3 *vignettes/qhull/html/qh-opto.html e4c732d38d8389c55fa63955a7e644c8 *vignettes/qhull/html/qh-optp.html b5a6d0038f4522eb94b4b87804e1d2f9 *vignettes/qhull/html/qh-optq.html 008e3a59ba0a8c98d4671f8a751f5e6e *vignettes/qhull/html/qh-optt.html 30454c2fa7db3ea2a72bf72ded9d6447 *vignettes/qhull/html/qh-quick.html 6aa82b4c2709dd98df2aff103fb944b5 *vignettes/qhull/html/qhalf.html e8992f5b2de07cbf48583e1f6b9ad5e9 *vignettes/qhull/html/qhull-cpp.xml 35d88647a340615dcd1bd842a565475c *vignettes/qhull/html/qhull.html fc4b6d8b5abec935f14dd71369718e9f *vignettes/qhull/html/qhull.man 5e213194265bc30a85ef692ac37d7836 *vignettes/qhull/html/qhull.txt 8550cf46dbd89d8068969bf225600f16 *vignettes/qhull/html/qvoron_f.html f8369a8be58b5f738e7421e367881db2 *vignettes/qhull/html/qvoronoi.html 03b90e4e5eb3ed77f57a3063694f801d *vignettes/qhull/html/rbox.html 4cbad586d2136f611dbaf7f47128cc86 *vignettes/qhull/html/rbox.man 61cd54c422366e1ef1db2babdb3daff9 *vignettes/qhull/html/rbox.txt b0e7f903d9fe9008ff87baabe3c57b64 *vignettes/qhull/index.html geometry/R/0000755000176200001440000000000014744661717012327 5ustar liggesusersgeometry/R/sph2cart.R0000644000176200001440000000524413433536400014165 0ustar liggesusers## Copyright (C) 2017 David Sterratt ## Copyright (C) 2000-2017 Kai Habel ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it){ ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for (more details.){ ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ##' Transform spherical coordinates to Cartesian coordinates ##' ##' The inputs \code{theta}, \code{phi}, and \code{r} must be the same ##' shape, or scalar. If called with a single matrix argument then ##' each row of \code{S} represents the spherical coordinate ##' (\code{theta}, \code{phi}, \code{r}). ##' ##' @param theta describes the angle relative to the positive x-axis. ##' @param phi is the angle relative to the xy-plane. ##' @param r is the distance to the origin \code{(0, 0, 0)}. ##' ##' If only a single return argument is requested then return a matrix ##' \code{C} where each row represents one Cartesian coordinate ##' (\code{x}, \code{y}, \code{z}). ##' @seealso \code{\link{cart2sph}}, \code{\link{pol2cart}}, \code{\link{cart2pol}} ##' @author Kai Habel ##' @author David Sterratt ##' @export sph2cart <- function(theta, phi=NULL, r=NULL) { if ((is.null(phi) & !is.null(r)) | (is.null(r) & !is.null(phi))) { stop("There should be 3 arguments (theta, phi, r) or one argument (theta)") } if (is.null(phi) & is.null(r)) { if (!(is.numeric(theta))) { stop("input must be matrix with 3 columns [theta, phi, r]") } if (!(is.matrix(theta) & (ncol(theta) == 3))) { stop("matrix input must have 3 columns [theta, phi, r]") } r <- theta[,3] phi <- theta[,2] theta <- theta[,1] } else { if (!is.numeric(theta) | !is.numeric(phi) | !is.numeric (r)) stop("theta, phi, r must be numeric arrays of the same size, or scalar") if ( !(((length(theta) == length(phi)) | (length(theta) == 1) | (length(phi) == 1)) & ((length(theta) == length(r)) | (length(theta) == 1) | (length(r) == 1)) & ((length(phi) == length(r)) | (length(phi) == 1) | (length(r) == 1)))) { stop("theta, phi, r must be matrices of the same size, or scalar") } } x <- r*cos(phi)*cos(theta) y <- r*cos(phi)*sin(theta) z <- r*sin(phi) return(cbind(x, y, z)) } geometry/R/mesh.intersect.R0000644000176200001440000000014513432317337015372 0ustar liggesusers"mesh.intersect" <- function (p, regionA, regionB, ...) matmax(regionA(p, ...), regionB(p, ...)) geometry/R/RcppExports.R0000644000176200001440000000047714744661717014753 0ustar liggesusers# Generated by using Rcpp::compileAttributes() -> do not edit by hand # Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393 #' @importFrom Rcpp sourceCpp C_tsearch <- function(x, y, elem, xi, yi, bary = FALSE, eps = 1.0e-12) { .Call('_geometry_C_tsearch', PACKAGE = 'geometry', x, y, elem, xi, yi, bary, eps) } geometry/R/halfspacen.R0000644000176200001440000000700514662314120014536 0ustar liggesusers##' Compute halfspace intersection about a point ##' ##' @param p An \eqn{M}-by-\eqn{N+1} matrix. Each row of \code{p} ##' represents a halfspace by a \eqn{N}-dimensional normal to a ##' hyperplane and the offset of the hyperplane. ##' @param fp A \dQuote{feasible} point that is within the space ##' contained within all the halfspaces. ##' @param options String containing extra options, separated by ##' spaces, for the underlying Qhull command; see Qhull ##' documentation at \url{../doc/qhull/html/qhalf.html}. ##' ##' @return A \eqn{N}-column matrix containing the intersection ##' points of the hyperplanes \url{../doc/qhull/html/qhalf.html}. ##' ##' @author David Sterratt ##' @note \code{halfspacen} was introduced in geometry 0.4.0, and is ##' still under development. It is worth checking results for ##' unexpected behaviour. ##' @seealso \code{\link{convhulln}} ##' @references \cite{Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., ##' \dQuote{The Quickhull algorithm for convex hulls,} \emph{ACM ##' Trans. on Mathematical Software,} Dec 1996.} ##' ##' \url{http://www.qhull.org} ##' @examples ##' p <- rbox(0, C=0.5) # Generate points on a unit cube centered around the origin ##' ch <- convhulln(p, "n") # Generate convex hull, including normals to facets, with "n" option ##' # Intersections of half planes ##' # These points should be the same as the orginal points ##' pn <- halfspacen(ch$normals, c(0, 0, 0)) ##' ##' @export ##' @useDynLib geometry halfspacen <- function (p, fp, options = "Tv") { tmp_stdout <- tempfile("Rf") tmp_stderr <- tempfile("Rf") on.exit(c(tmp_stdout, tmp_stderr)) ## Input sanitisation options <- paste(options, collapse=" ") ## Coerce the input to be matrix if (is.data.frame(p)) { p <- as.matrix(p) } ## Make sure we have real-valued input storage.mode(p) <- "double" ## We need to check for NAs in the input, as these will crash the C ## code. if (any(is.na(p))) { stop("The first argument should not contain any NAs") } ## Check dimensions if (ncol(p) - 1 != length(as.vector(fp))) { stop("Dimension of hyperspace is ", ncol(p) - 1, " but dimension of fixed point is ", length(as.vector(fp))) } ## In geometry 0.4.0, we tried to get around halspacen fails because ## of similar hyperplanes, by removing the most similar ones (i.e. ## those that had very acute angles to one another). However, this ## was ugly and turned out to unreliable , so it has been removed in ## geometry 0.4.1 and above. Users are recommended to supply the ## QJ option in ## The fixed point is passed as an option out <- tryCatch(.Call("C_halfspacen", p, as.character(paste(options, paste0("H",paste(fp, collapse=",")))), tmp_stdout, tmp_stderr, PACKAGE="geometry"), error=function(e) { if (grepl("^Received error code 2 from qhull.", e$message)) { e$message <- paste(e$message, "\nTry calling halfspacen with options=\"Tv QJ\"") } return(e) }) if (inherits(out, "error")) { stop(out$message) } return(out) } ## If there is an error, it could be because of two very similar halfspaces. ## n1 = ch1$normals[1,1:3] ## n2 = ch2$normals[1,1:3] ## d1 = ch1$normals[1,4] ## d2 = ch2$normals[1,4] ## solve(rbind(n1, n2, extprod3d(n1, n2)), c(d1, d2, 0)) ## sqrt(sum(solve(rbind(n1, n2, extprod3d(n1, n2)), c(-d1, -d2, 0))^2)) ## dot(n1+ n2, extprod3d(n1, n2)) geometry/R/matsort.R0000644000176200001440000000114013432317337014124 0ustar liggesusers"matsort" <- function (...) { x = cbind(...) if(!is.numeric(x)) stop("Input should by numeric.") res = array(dim = c(nrow(x), 0)) if (!is.matrix(drop(x))) return(x) else if (ncol(x) > 30) return(t(apply(x, 1, sort))) else while (is.matrix(drop(x))) { imc = max.col(x) x = t(x) imx = nrow(x) * (1:ncol(x) - 1) + imc xmax = x[imx] x = t(matrix(x[-imx], ncol = ncol(x))) res = cbind(res, xmax) } res = cbind(res, x) colnames(res) = NULL rownames(res) = NULL return(res) } geometry/R/tsearch.R0000644000176200001440000003036614662314120014071 0ustar liggesusers##' Search for the enclosing Delaunay convex hull ##' ##' For \code{t <- delaunay(cbind(x, y))}, where \code{(x, y)} is a 2D set of ##' points, \code{tsearch(x, y, t, xi, yi)} finds the index in \code{t} ##' containing the points \code{(xi, yi)}. For points outside the convex hull ##' the index is \code{NA}. ##' ##' @param x X-coordinates of triangulation points ##' @param y Y-coordinates of triangulation points ##' @param t Triangulation, e.g. produced by \code{t <- ##' delaunayn(cbind(x, y))} ##' @param xi X-coordinates of points to test ##' @param yi Y-coordinates of points to test ##' @param bary If \code{TRUE} return barycentric coordinates as well ##' as index of triangle. ##' @param method One of \code{"quadtree"} or \code{"orig"}. The ##' Quadtree algorithm is much faster and new from version ##' 0.4.0. The \code{orig} option uses the tsearch algorithm adapted ##' from Octave code. Its use is deprecated and it may be removed ##' from a future version of the package. ##' @return If \code{bary} is \code{FALSE}, the index in \code{t} containing the points ##' \code{(xi, yi)}. For points outside the convex hull the index is \code{NA}. ##' If \code{bary} is \code{TRUE}, a list containing: ##' \describe{ ##' \item{list("idx")}{the index in \code{t} containing the points \code{(xi, yi)}} ##' \item{list("p")}{a 3-column matrix containing the barycentric coordinates with ##' respect to the enclosing triangle of each point \code{(xi, yi)}.} ##' } ##' @author Jean-Romain Roussel (Quadtree algorithm), David Sterratt (Octave-based implementation) ##' @note The original Octave function is Copyright (C) 2007-2012 ##' David Bateman ##' @seealso \code{\link{tsearchn}}, \code{\link{delaunayn}} ##' @export tsearch <- function(x, y, t, xi, yi, bary=FALSE, method="quadtree") { xtxt = deparse(substitute(x)) ytxt = deparse(substitute(y)) xitxt = deparse(substitute(xi)) yitxt = deparse(substitute(yi)) ttxt = deparse(substitute(t)) if (!is.vector(x)) {stop(paste(xtxt, "is not a vector"))} if (!is.vector(y)) {stop(paste(ytxt, "is not a vector"))} if (!is.matrix(t)) {stop(paste(ttxt, "is not a matrix"))} if (!is.vector(xi)) {stop(paste(xitxt, "is not a vector"))} if (!is.vector(yi)) {stop(paste(yitxt, "is not a vector"))} if (length(x) != length(y)) { stop(paste(xtxt, "is not same length as", ytxt)) } if (length(xi) != length(yi)) { stop(paste(xitxt, "is not same length as", yitxt)) } if (ncol(t) != 3) { stop(paste(ttxt, "does not have three columns")) } if (any(as.integer(t) != t)) { stop(paste(ttxt, "does not have integer elements")) } if (length(x) == 0) {stop(paste(xtxt, "is empty"))} if (length(y) == 0) {stop(paste(ytxt, "is empty"))} if (any(is.na(x))) {stop(paste(xtxt, "contains NAs"))} if (any(is.na(y))) {stop(paste(ytxt, "contains NAs"))} if (length(x) < 3 | length(y) < 3) { stop("A triangulation should have at least 3 points") } storage.mode(t) <- "integer" if (max(t) > length(x)) { stop(paste(ttxt, "has indexes greater than the number of points")) } if (min(t) <= 0) { stop(paste(ttxt, "has indexes which refer to non-existing points")) } if (length(xi) == 0 | length(yi) == 0) { if (!bary) return (integer(0)) else return (list(idx = integer(0), p = matrix(0,0,3))) } if (method == "quadtree") { out <- C_tsearch(x, y, t, xi, yi, bary) } else { out <- .Call("C_tsearch_orig", x, y, t, xi, yi, bary, PACKAGE="geometry") } if (bary) { names(out) <- c("idx", "p") } return(out) } ##' Search for the enclosing Delaunay convex hull ##' ##' For \code{t = delaunayn(x)}, where \code{x} is a set of points in \eqn{N} ##' dimensions, \code{tsearchn(x, t, xi)} finds the index in \code{t} ##' containing the points \code{xi}. For points outside the convex hull, ##' \code{idx} is \code{NA}. \code{tsearchn} also returns the barycentric ##' coordinates \code{p} of the enclosing triangles. ##' ##' If \code{x} is \code{NA} and the \code{t} is a ##' \code{delaunayn} object produced by ##' \code{\link{delaunayn}} with the \code{full} option, then use the ##' Qhull library to perform the search. Please note that this is ##' experimental in geometry version 0.4.0 and is only partly tested ##' for 3D hulls, and does not yet work for hulls of 4 dimensions and ##' above. ##' ##' @param x An \eqn{N}-column matrix, in which each row represents a ##' point in \eqn{N}-dimensional space. ##' @param t A matrix with \eqn{N+1} columns. A row of \code{t} ##' contains indices into \code{x} of the vertices of an ##' \eqn{N}-dimensional simplex. \code{t} is usually the output of ##' delaunayn. ##' @param xi An \eqn{M}-by-\eqn{N} matrix. The rows of \code{xi} ##' represent \eqn{M} points in \eqn{N}-dimensional space whose ##' positions in the mesh are being sought. ##' @param ... Additional arguments ##' @return A list containing: ##' \describe{ ##' \item{\code{idx}}{An \eqn{M}-long vector containing the indices ##' of the row of \code{t} in which each point in \code{xi} is found.} ##' \item{\code{p}}{An \eqn{M}-by-\eqn{N+1} matrix containing the ##' barycentric coordinates with respect to the enclosing simplex ##' of each point in \code{xi}.}} ##' @author David Sterratt ##' @note Based on the Octave function Copyright (C) 2007-2012 David ##' Bateman. ##' @seealso \code{\link{tsearch}}, \code{\link{delaunayn}} ##' @export tsearchn <- function(x, t, xi, ...) { if (any(is.na(x)) && inherits(t, "delaunayn")) { return(tsearchn_delaunayn(t, xi)) } fast <- TRUE if (!is.null(list(...)$fast) & is.logical(list(...)$fast)) fast <- list(...)$fast ## Check input if (!is.matrix(x)) {stop(paste(deparse(substitute(x)), "is not a matrix"))} if (!is.matrix(t)) {stop(paste(deparse(substitute(t)), "is not a matrix"))} if (!is.matrix(xi)) {stop(paste(deparse(substitute(xi)), "is not a matrix"))} n <- dim(x)[2] # Number of dimensions if (n==2 && fast) { return(tsearch(x[,1], x[,2], t, xi[,1], xi[,2], bary=TRUE)) } nt <- dim(t)[1] # Number of simplexes m <- dim(x)[1] # Number of points in simplex grid mi <- dim(xi)[1] # Number of points to search for ## If there are no points to search for, return an empty index ## vector and an empty coordinate matrix if (mi==0) { return(list(idx=c(), p=matrix(0, 0, n + 1))) } idx <- rep(NA, mi) p <- matrix(NA, mi, n + 1) ## Indicies of points that still need to be searched for ni <- 1:mi degenerate.simplices <- c() ## Go through each simplex in turn for (i in 1:nt) { ## Only calculate the Barycentric coordinates for points that have not ## already been found in a simplex. b <- suppressWarnings(cart2bary(x[t[i,],], xi[ni,,drop=FALSE])) if (is.null(b)) { degenerate.simplices <- c(degenerate.simplices, i) } else { ## Our points xi are in the current triangle if (all(b >= 0) && ## all (b <= 1)). However as we impose that sum(b,2) == 1 we only ## need to test all(b>=0). Note that we need to add a small margin ## for rounding errors intri <- apply(b >= -1e-12, 1, all) ## Set the simplex indicies of the points that have been found to ## this simplex idx[ni[intri]] <- i ## Set the baryocentric coordinates of the points that have been found p[ni[intri],] <- b[intri,] ## Remove these points from the search list ni <- ni[!intri] ## If there are no more points to search for, give up if (length(ni) == 0) { break } } } if (length(degenerate.simplices) > 0) { warning(paste("Degenerate simplices:", toString(degenerate.simplices))) } return(list(idx=idx, p=p)) } ##' Conversion of Cartesian to Barycentric coordinates. ##' ##' Given the Cartesian coordinates of one or more points, compute ##' the barycentric coordinates of these points with respect to a ##' simplex. ##' ##' Given a reference simplex in \eqn{N} dimensions represented by a ##' \eqn{N+1}-by-\eqn{N} matrix an arbitrary point \eqn{P} in ##' Cartesian coordinates, represented by a 1-by-\eqn{N} row vector, can be ##' written as ##' \deqn{P = \beta X} ##' where \eqn{\beta} is an \eqn{N+1} vector of the barycentric coordinates. ##' A criterion on \eqn{\beta} is that ##' \deqn{\sum_i\beta_i = 1} ##' Now partition the simplex into its first \eqn{N} rows \eqn{X_N} and ##' its \eqn{N+1}th row \eqn{X_{N+1}}. Partition the barycentric ##' coordinates into the first \eqn{N} columns \eqn{\beta_N} and the ##' \eqn{N+1}th column \eqn{\beta_{N+1}}. This allows us to write ##' \deqn{P_{N+1} - X_{N+1} = \beta_N X_N + \beta_{N+1} X_{N+1} - X_{N+1}} ##' which can be written ##' \deqn{P_{N+1} - X_{N+1} = \beta_N(X_N - 1_N X_{N+1})} ##' where \eqn{1_N} is an \eqn{N}-by-1 matrix of ones. We can then solve ##' for \eqn{\beta_N}: ##' \deqn{\beta_N = (P_{N+1} - X_{N+1})(X_N - 1_N X_{N+1})^{-1}} ##' and compute ##' \deqn{\beta_{N+1} = 1 - \sum_{i=1}^N\beta_i} ##' This can be generalised for multiple values of ##' \eqn{P}, one per row. ##' ##' @param X Reference simplex in \eqn{N} dimensions represented by a ##' \eqn{N+1}-by-\eqn{N} matrix ##' @param P \eqn{M}-by-\eqn{N} matrix in which each row is the Cartesian ##' coordinates of a point. ##' @return \eqn{M}-by-\eqn{N+1} matrix in which each row is the ##' barycentric coordinates of corresponding row of \code{P}. If the ##' simplex is degenerate a warning is issued and the function returns ##' \code{NULL}. ##' @author David Sterratt ##' @note Based on the Octave function by David Bateman. ##' @examples ##' ## Define simplex in 2D (i.e. a triangle) ##' X <- rbind(c(0, 0), ##' c(0, 1), ##' c(1, 0)) ##' ## Cartesian coordinates of points ##' P <- rbind(c(0.5, 0.5), ##' c(0.1, 0.8)) ##' ## Plot triangle and points ##' trimesh(rbind(1:3), X) ##' text(X[,1], X[,2], 1:3) # Label vertices ##' points(P) ##' cart2bary(X, P) ##' @seealso \code{\link{bary2cart}} ##' @export cart2bary <- function(X, P) { M <- nrow(P) N <- ncol(P) if (ncol(X) != N) { stop("Simplex X must have same number of columns as point matrix P") } if (nrow(X) != (N+1)) { stop("Simplex X must have N columns and N+1 rows") } X1 <- X[1:N,] - (matrix(1,N,1) %*% X[N+1,,drop=FALSE]) if (rcond(X1) < .Machine$double.eps) { warning("Degenerate simplex") return(NULL) } Beta <- (P - matrix(X[N+1,], M, N, byrow=TRUE)) %*% solve(X1) Beta <- cbind(Beta, 1 - apply(Beta, 1, sum)) return(Beta) } ##' Conversion of Barycentric to Cartesian coordinates ##' ##' Given the barycentric coordinates of one or more points with ##' respect to a simplex, compute the Cartesian coordinates of these ##' points. ##' ##' @param X Reference simplex in \eqn{N} dimensions represented by a ##' \eqn{N+1}-by-\eqn{N} matrix ##' @param Beta \eqn{M} points in barycentric coordinates with ##' respect to the simplex \code{X} represented by a ##' \eqn{M}-by-\eqn{N+1} matrix ##' @return \eqn{M}-by-\eqn{N} matrix in which each row is the ##' Cartesian coordinates of corresponding row of \code{Beta} ##' @examples ##' ## Define simplex in 2D (i.e. a triangle) ##' X <- rbind(c(0, 0), ##' c(0, 1), ##' c(1, 0)) ##' ## Cartesian cooridinates of points ##' beta <- rbind(c(0, 0.5, 0.5), ##' c(0.1, 0.8, 0.1)) ##' ## Plot triangle and points ##' trimesh(rbind(1:3), X) ##' text(X[,1], X[,2], 1:3) # Label vertices ##' P <- bary2cart(X, beta) ##' points(P) ##' @seealso \code{\link{cart2bary}} ##' @author David Sterratt ##' @export bary2cart <- function(X, Beta) { return(Beta %*% X) } tsearchn_delaunayn <- function(t, xi) { warning("tsearchn using the Qhull library is currently an experimental feature. It has been tested somewhat for 3D triangulations, but it does not work reliably for 4D triangulations. See https://github.com/davidcsterratt/geometry/issues/6") ts <- .Call("C_tsearchn", t, xi) p <- do.call(rbind, lapply(1:nrow(xi), function(i) { cart2bary(ts$P[t$tri[ts$idx[i],],], xi[i,,drop=FALSE]) })) ## C_tsearchn will return the *best* facet. Need to check it is ## actually in the triangulation outwith_facet_inds <- which(apply(p < 0, 1, any)) idx <- ts$idx idx[outwith_facet_inds] <- NA p[outwith_facet_inds,] <- NA return(list(idx=idx, p=p, P=ts$P)) } geometry/R/dotprod.R0000644000176200001440000000224613432317337014116 0ustar liggesusers##' If \code{x} and \code{y} are matrices, calculate the dot-product ##' along the first non-singleton dimension. If the optional argument ##' \code{d} is given, calculate the dot-product along this ##' dimension. ##' ##' @title Compute the dot product of two vectors ##' @param x Matrix of vectors ##' @param y Matrix of vectors ##' @param d Dimension along which to calculate the dot product ##' @return Vector with length of \code{d}th dimension ##' @author David Sterratt ##' @keywords arith math array ##' @export dot <- function(x, y, d=NULL) { if (is.vector(x)) x <- matrix(x, ncol = 1) if (is.vector(y)) y <- matrix(y, ncol = 1) ndim <- length(dim(x)) ## Determine dimension along which to sum if (is.null(d)) { di <- which(dim(x) > 1) if (length(di == 0)) { d <- 1 } else { d <- di[1] } } ## Check size of d if (d > ndim) { stop("d is larger than the number of dimensions of the data") } ## Use rowSums and colSums as they are more efficient than apply if (ndim == 2) { if (d == 2) { return(rowSums(x*y)) } if (d == 1) { return(colSums(x*y)) } } return(apply(x*y, d, sum)) } geometry/R/trisplinter.R0000644000176200001440000000046313432317337015021 0ustar liggesusers"trisplinter" <- function(T,p,threshold=sqrt(.Machine$double.eps)){ rownorm2 = function(x) drop(sqrt((x^2)%*%c(1,1))) d1 = p[T[,1],] - p[T[,2],] d2 = p[T[,2],] - p[T[,3],] d1 = d1 / rownorm2(d1) d2 = d2 / rownorm2(d2) ar = d1[,1]*d2[,2] - d1[,2]*d2[,1] return(abs(ar) < threshold) } geometry/R/mesh.dcircle.R0000644000176200001440000000220113432317337014772 0ustar liggesusers##' Signed distance from points \code{p} to boundary of circle to ##' allow easy definition of regions in \code{\link{distmesh2d}}. ##' ##' @title Circle distance function ##' @param p A matrix with 2 columns (3 in \code{mesh.dsphere}), each row ##' representing a point in the plane. ##' @param radius radius of circle ##' @param ... additional arguments (not used) ##' @return A vector of length \code{nrow(p)} containing the signed ##' distances to the circle ##' @author Raoul Grasman; translated from original Matlab sources of Per-Olof ##' Persson. ##' @seealso \code{\link{distmesh2d}}, \code{\link{mesh.drectangle}}, ##' \code{\link{mesh.diff}}, \code{\link{mesh.intersect}}, ##' \code{\link{mesh.union}} ##' @references \url{http://persson.berkeley.edu/distmesh/} ##' ##' \cite{P.-O. Persson, G. Strang, A Simple Mesh Generator in MATLAB. SIAM ##' Review, Volume 46 (2), pp. 329-345, June 2004} ##' @keywords arith math ##' @examples ##' ##' example(distmesh2d) ##' @export mesh.dcircle <- function (p, radius = 1, ...) { if (!is.matrix(p)) p <- t(as.matrix(p)) return(sqrt((p^2) %*% c(1, 1)) - radius) } geometry/R/mesh.hunif.R0000644000176200001440000000136313432317337014506 0ustar liggesusers##' Uniform desired edge length function of position to allow easy ##' definition of regions when passed as the \code{fh} argument of ##' \code{\link{distmesh2d}} or \code{\link{distmeshnd}}. ##' ##' @title Uniform desired edge length ##' @param p A \code{n}-by-\code{m} matrix, each row representing a ##' point in an \code{m}-dimensional space. ##' @param ... additional arguments (not used) ##' @return Vector of ones of length \code{n}. ##' @author Raoul Grasman; translated from original Matlab sources of Per-Olof ##' Persson. ##' @seealso \code{\link{distmesh2d}} and \code{\link{distmeshnd}}. ##' @export mesh.hunif <- function (p, ...) { if (!is.matrix(p)) stop("Input `p' should be matrix.") return(rep(1, nrow(p))) } geometry/R/extprod3d.R0000644000176200001440000000235714664604470014367 0ustar liggesusers##' Compute external- or \sQuote{cross}- product of 3D vectors. ##' ##' Computes the external product ##' \deqn{ \left(x_2 y_3 - x_3 y_2,\; ##' x_3 y_1 - x_1 y_3,\; ##' x_1 y_2 - x_2 y_1 \right) }{ ##' (x2 * y3 - x3 * y2, ##' x3 * y1 - x1 * y3, ##' x1 * y2 - x2 * y1) } ##' of the 3D vectors in \bold{x} and \bold{y}. ##' ##' @param x \code{n}-by-3 matrix. Each row is one \bold{x}-vector ##' @param y \code{n}-by-3 matrix. Each row is one \bold{y}-vector ##' @param drop logical. If \code{TRUE} and if the inputs are one row ##' matrices or vectors, then delete the dimensions of the array ##' returned. ##' @return If \code{n} is greater than 1 or \code{drop} is ##' \code{FALSE}, \code{n}-by-3 matrix; if \code{n} is 1 and ##' \code{drop} is \code{TRUE}, a vector of length 3. ##' @author Raoul Grasman ##' @keywords arith math array ##' @seealso \code{\link[base]{drop}} ##' @export extprod3d <-function (x, y, drop=TRUE) { x = matrix(x, ncol = 3) y = matrix(y, ncol = 3) z = cbind(x[, 2] * y[, 3] - x[, 3] * y[, 2], x[, 3] * y[, 1] - x[, 1] * y[, 3], x[, 1] * y[, 2] - x[, 2] * y[, 1]) if (drop) { return(drop(z)) } return(z) } geometry/R/distmesh2d.R0000644000176200001440000002273314662314120014505 0ustar liggesusers##' A simple mesh generator for non-convex regions ##' ##' An unstructured simplex requires a choice of mesh points (vertex nodes) and ##' a triangulation. This is a simple and short algorithm that improves the ##' quality of a mesh by relocating the mesh points according to a relaxation ##' scheme of forces in a truss structure. The topology of the truss is reset ##' using Delaunay triangulation. A (sufficiently smooth) user supplied signed ##' distance function (\code{fd}) indicates if a given node is inside or ##' outside the region. Points outside the region are projected back to the ##' boundary. ##' ##' This is an implementation of original Matlab software of Per-Olof Persson. ##' ##' Excerpt (modified) from the reference below: ##' ##' \sQuote{The algorithm is based on a mechanical analogy between a triangular ##' mesh and a 2D truss structure. In the physical model, the edges of the ##' Delaunay triangles of a set of points correspond to bars of a truss. Each ##' bar has a force-displacement relationship \eqn{f(\ell, \ell_{0})}{F(L,L0)} ##' depending on its current length \eqn{\ell}{L} and its unextended length ##' \eqn{\ell_{0}}{L0}.} ##' ##' \sQuote{External forces on the structure come at the boundaries, on which ##' external forces have normal orientations. These external forces are just ##' large enough to prevent nodes from moving outside the boundary. The ##' position of the nodes are the unknowns, and are found by solving for a ##' static force equilibrium. The hope is that (when \code{fh = function(p) ##' return(rep(1,nrow(p)))}), the lengths of all the bars at equilibrium will ##' be nearly equal, giving a well-shaped triangular mesh.} ##' ##' See the references below for all details. Also, see the comments in the ##' source file. ##' ##' @param fd Vectorized signed distance function, for example ##' \code{\link{mesh.dcircle}} or \code{\link{mesh.diff}}, accepting ##' an \code{n}-by-\code{2} matrix, where \code{n} is arbitrary, as ##' the first argument. ##' @param fh Vectorized function, for example ##' \code{\link{mesh.hunif}}, that returns desired edge length as a ##' function of position. Accepts an \code{n}-by-\code{2} matrix, ##' where \code{n} is arbitrary, as its first argument. ##' @param h0 Initial distance between mesh nodes. (Ignored of ##' \code{p} is supplied) ##' @param bbox Bounding box \code{cbind(c(xmin,xmax), c(ymin,ymax))} ##' @param p An \code{n}-by-\code{2} matrix. The rows of \code{p} ##' represent locations of starting mesh nodes. ##' @param pfix \code{nfix}-by-2 matrix with fixed node positions. ##' @param \dots parameters to be passed to \code{fd} and/or \code{fh} ##' @param dptol Algorithm stops when all node movements are smaller ##' than \code{dptol} ##' @param ttol Controls how far the points can move (relatively) ##' before a retriangulation with \code{\link{delaunayn}}. ##' @param Fscale \dQuote{Internal pressure} in the edges. ##' @param deltat Size of the time step in Euler's method. ##' @param geps Tolerance in the geometry evaluations. ##' @param deps Stepsize \eqn{\Delta x} in numerical derivative ##' computation for distance function. ##' @param maxiter Maximum iterations. ##' @param plot logical. If \code{TRUE} (default), the mesh is ##' plotted as it is generated. ##' @return \code{n}-by-\code{2} matrix with node positions. ##' @section Wishlist : \itemize{ \item Implement in C/Fortran ##' \item Implement an \code{n}D version as provided in the Matlab ##' package \item Translate other functions of the Matlab package } ##' @author Raoul Grasman ##' @seealso \code{\link[interp]{tri.mesh}}, \code{\link{delaunayn}}, ##' \code{\link{mesh.dcircle}}, \code{\link{mesh.drectangle}}, ##' \code{\link{mesh.diff}}, \code{\link{mesh.union}}, ##' \code{\link{mesh.intersect}} ##' @references \url{http://persson.berkeley.edu/distmesh/} ##' ##' \cite{P.-O. Persson, G. Strang, A Simple Mesh Generator in MATLAB. SIAM ##' Review, Volume 46 (2), pp. 329-345, June 2004} ##' @keywords math optimize dplot graphs ##' @examples ##' ##' # examples distmesh2d ##' fd <- function(p, ...) sqrt((p^2)%*%c(1,1)) - 1 ##' # also predefined as `mesh.dcircle' ##' fh <- function(p,...) rep(1,nrow(p)) ##' bbox <- matrix(c(-1,1,-1,1),2,2) ##' p <- distmesh2d(fd,fh,0.2,bbox, maxiter=100) ##' # this may take a while: ##' # press Esc to get result of current iteration ##' ##' # example with non-convex region ##' fd <- function(p, ...) mesh.diff(p , mesh.drectangle, mesh.dcircle, radius=.3) ##' # fd defines difference of square and circle ##' ##' p <- distmesh2d(fd,fh,0.05,bbox,radius=0.3,maxiter=4) ##' p <- distmesh2d(fd,fh,0.05,bbox,radius=0.3, maxiter=10) ##' # continue on previous mesh ##' @export distmesh2d <- function(fd, fh, h0, bbox, p=NULL, pfix=array(0,dim=c(0,2)), ..., dptol=0.001, ttol=0.1, Fscale=1.2, deltat=0.2, geps=0.001*h0, deps=sqrt(.Machine$double.eps)*h0, maxiter=1000, plot=TRUE) { rownorm2 = function(x) drop(sqrt((x^2)%*%c(1, 1))) if(any(apply(bbox, 2, diff)==0)) stop("Supplied bounding box has zero area.") if(is.null(p)) { #%1 generate initial grid y = seq(bbox[1, 2],bbox[2, 2], by=h0*sqrt(3)/2) x = seq(bbox[1, 1], bbox[2, 1], by=h0) x = matrix(x,length(y),length(x),byrow=TRUE) x[seq(2,length(y),by=2),] = x[seq(2,length(y),by=2),] + h0/2 p = cbind(c(x),y) #%2 remove nodes outside boundary specified by fd (points evaluated negative are # considered to lie inside the boundary) p = p[fd(p, ...) < geps,] } ## For density control nfix <- nrow(pfix) count <- 0 densityctrlfreq <- 30 count2 <- 0 r0 = 1 / fh(p, ...)^2 # acceptance probability p = rbind(pfix, p[stats::runif(nrow(p)) ttol) { pold = p T = delaunayn(p) # generate a Delaunay triangulation pmid = (p[T[, 1],] + p[T[, 2],] + p[T[, 3],])/3 # calculate average of node locations as centers T = T[fd(pmid, ...) < (-geps), 1:3] # remove triangles with center outside region #%4 describe edges by uniqe pairs of nodes #bars = unique(rbind(T[, -1],T[, -2],T[, -3]), MARGIN=1); #bars = bars[order(bars[, 1],bars[, 2]),]; bars = rbind(T[, -3], T[, -2], T[, -1]) # select unique edges #too slow: bars = unique(matsort(bars), MARGIN=1) bars = Unique(matsort(bars)) # order the edges according to the node indices #%5 Graphical display if (plot) trimesh(T, p, asp=1) # a la Matlab } #%6 compute force F on the basis of edge lenghts barvec = p[bars[, 1],] - p[bars[, 2],] # bar vectors L = rownorm2(barvec) # their lengths # calculate desired lengths L0 by use of fh hbars = fh((p[bars[, 1],] + p[bars[, 2],])/2, ...) L0 = hbars * Fscale * sqrt(sum(L^2)/sum(hbars^2)) ###################################################### # Original Matlab code # % Density control - remove points that are too close # if mod(count,densityctrlfreq)==0 & any(L0>2*L) # p(setdiff(reshape(bars(L0>2*L,:),[],1),1:nfix),:)=[]; # N=size(p,1); pold=inf; # continue; # end ###################################################### # R translation # Density control - remove points that are too close tmp1 <- (count %% densityctrlfreq) tmp2 <- any(L0 > (2*L)) if (tmp1 == 0 & tmp2) { count2 <- count2 + 1 # reshape(bars(L0>2*L,:),[],1) tmp3 <- c(bars[L0 > (2*L),]) up <- which(duplicated(tmp3) == TRUE, arr.ind=TRUE) p <- p[-up,] N <- length(p[,1]) pold <- 1/.Machine$double.eps } ###################################################### F = drop(L0 - L) F[F < 0] = 0 Fvec = barvec * (F/L) Ftot = matrix(0, N, 2) ii = bars[, c(1, 1, 2, 2)] jj = rep(1, length(F)) %o% c(1, 2, 1, 2) s = c(cbind(Fvec, -Fvec)) ns = length(s) Ftot[1:(2*N)] = rowsum(s, ii[1:ns] + ns*(jj[1:ns] - 1)) # sum all forces on each node if (nrow(pfix) > 0) Ftot[1:nrow(pfix),] = 0 # Force = 0 at fixed points p = p + deltat*Ftot; #%7 excercise normal force at boundary: move overshoot points to nearest boundary point d = fd(p); ix= d > 0; # find points outside dgradx= (fd(cbind(p[ix, 1]+deps, p[ix, 2]),...) - d[ix])/deps; # Numerical dgrady= (fd(cbind(p[ix, 1], p[ix, 2]+deps),...) - d[ix])/deps; # gradient p[ix,] = p[ix,] - cbind(d[ix]*dgradx, d[ix]*dgrady); # Project back to boundary #%8 test for convergence if(max(rownorm2(deltat*Ftot[d < (-geps),])/h0) < dptol | iter>=maxiter) break; iter = iter + 1 } message(sprintf("Number of density control ops = %d",count2)) message(sprintf("Number of iterations = %d",iter)) if (iter >= maxiter) warning(" Maximum iterations reached. Relaxation process not \n completed") return(p) } geometry/R/matorder.R0000644000176200001440000000027013432317337014253 0ustar liggesusers"matorder" <- function (...) { x = cbind(...) if(!is.numeric(x)) stop("Input should be numeric.") do.call("order", lapply(1:ncol(x), function(i) x[, i])) } geometry/R/mesh.diff.R0000644000176200001440000000274113432317337014306 0ustar liggesusers##' Compute the signed distances from points \code{p} to a region ##' defined by the difference, union or intersection of regions ##' specified by the functions \code{regionA} and \code{regionB}. ##' \code{regionA} and \code{regionB} must accept a matrix \code{p} ##' with 2 columns as their first argument, and must return a vector ##' of length \code{nrow(p)} containing the signed distances of the ##' supplied points in \code{p} to their respective regions. ##' ##' @title Difference, union and intersection operation on two regions ##' @return A vector of length \code{nrow(p)} containing the signed ##' distances to the boundary of the region. ##' @author Raoul Grasman; translated from original Matlab sources of Per-Olof ##' Persson. ##' @param p A matrix with 2 columns (3 in \code{mesh.dsphere}), each row ##' representing a point in the plane. ##' @param regionA vectorized function describing region A in the ##' union / intersection / difference ##' @param regionB vectorized function describing region B in the ##' union / intersection / difference ##' @param ... additional arguments passed to \code{regionA} and ##' \code{regionB} ##' @aliases mesh.diff mesh.union mesh.intersect ##' @seealso \code{\link{distmesh2d}}, \code{\link{mesh.dcircle}}, ##' \code{\link{mesh.drectangle}} \code{\link{mesh.dsphere}} ##' @export mesh.diff mesh.union mesh.intersect mesh.diff <-function (p, regionA, regionB, ...) { return(matmax(regionA(p, ...), -regionB(p, ...))) } geometry/R/intersectn.R0000644000176200001440000002632713476414562014635 0ustar liggesusers##' Compute convex hull of intersection of two sets of points ##' @param ps1 First set of points ##' @param ps2 Second set of points ##' @param tol Tolerance used to determine if a feasible point lies ##' within the convex hulls of both points and to round off the ##' points generated by the halfspace intersection, which sometimes ##' produces points very close together. ##' @param return.chs If \code{TRUE} (default) return the convex hulls ##' of the first and second sets of points, as well as the convex ##' hull of the intersection. ##' @param options Options passed to \code{\link{halfspacen}}. By ##' default this is \code{Tv}. ##' @param fp Coordinates of feasible point, i.e. a point known to lie ##' in the hulls of \code{ps1} and \code{ps2}. The feasible point is ##' required for \code{\link{halfspacen}} to find the intersection. ##' \code{intersectn} tries to find the feasible point automatically ##' using the linear program in \code{\link{feasible.point}}, but ##' currently the linear program fails on some examples where there ##' is an obvious solution. This option overrides the automatic ##' search for a feasible point ##' @param autoscale \emph{Experimental in v0.4.2} Automatically scale ##' the points to lie in a sensible numeric range. May help to ##' correct some numerical issues. ##' @return List containing named elements: \code{ch1}, the convex ##' hull of the first set of points, with volumes, areas and normals ##' (see \code{\link{convhulln}}; \code{ch2}, the convex hull of the ##' first set of points, with volumes, areas and normals; \code{ps}, ##' the intersection points of convex hulls \code{ch1} and ##' \code{ch2}; and \code{ch}, the convex hull of the intersection ##' points, with volumes, areas and normals. ##' @export ##' @examples ##' # Two overlapping boxes ##' ps1 <- rbox(0, C=0.5) ##' ps2 <- rbox(0, C=0.5) + 0.5 ##' out <- intersectn(ps1, ps2) ##' message("Volume of 1st convex hull: ", out$ch1$vol) ##' message("Volume of 2nd convex hull: ", out$ch2$vol) ##' message("Volume of intersection convex hull: ", out$ch$vol) ##' @author David Sterratt ##' @note \code{intersectn} was introduced in geometry 0.4.0, and is ##' still under development. It is worth checking results for ##' unexpected behaviour. ##' @seealso \code{\link{convhulln}}, \code{\link{halfspacen}}, ##' \code{\link{inhulln}}, \code{\link{feasible.point}} ##' @importFrom utils packageDescription intersectn <- function(ps1, ps2, tol=0, return.chs=TRUE, options="Tv", fp=NULL, autoscale=FALSE) { distinct <- any(apply(ps1, 2, min) > apply(ps2, 2, max)) || any(apply(ps1, 2, max) < apply(ps2, 2, min)) if (distinct & !return.chs) { return(list(ch=list(vol=0))) } ch1 <- convhulln(ps1, "n FA") ch2 <- convhulln(ps2, "n FA") if (distinct) { return(list(ch1=ch1, ch2=ch2, ch=list(vol=0))) } ch1s <- ch1 ch2s <- ch2 if (autoscale) { pmean <- colMeans(rbind(ps1, ps2)) ch1s <- convhulln(t(t(ps1) - pmean), "n FA") ch2s <- convhulln(t(t(ps2) - pmean), "n FA") if (!is.null(fp)) { fp <- fp - pmean } } ## Find feasible point in which points could overlap if (is.null(fp)) { fp <-tryCatch(feasible.point(ch1s, ch2s, tol=tol), error=function(e){ stop("feasible.point() failed with error ", e$message, "\n", "If you can find a feasible point (i.e. point that lies in both hulls)\n", "for this input, supply this with the \"fp\" option.\n", "Otherwise, report bug, including inputs to intersectn() at\n", utils::packageDescription("geometry", fields="BugReports"), "\n", "or to ", utils::packageDescription("geometry", fields="Maintainer")) }) if (all(is.na(fp))) { if (return.chs) { return(list(ch1=ch1, ch2=ch2, ch=list(vol=0))) } return(list(ch=list(vol=0))) } } else { ## fp supplied if (!is.numeric(fp)) { stop("fp should be numeric") } if (length(fp) != ncol(ps1)) { stop("fp should have same dimension as ps1 and ps2") } } ## Find intersections of halfspaces about feasible point. Catch error ## (code QH6023) when fixed point is not in intersection, due to ## precision issue. ps <- tryCatch(halfspacen(rbind(ch1s$normals, ch2s$normals), fp, options=options), error=function(e) { if (grepl("QH6023", e$message)) { return(NA) } errmess <- e$message if (!grepl("QJ", options)) { errmess <- paste(errmess, "\nTry calling intersectn with options=\"Tv QJ\"") } stop(errmess) }) if (all(is.na(ps)) || is.null(ps)) { if (return.chs) { return(list(ch1=ch1, ch2=ch2, ch=list(vol=0))) } return(list(ch=list(vol=0))) } if (autoscale) { ps <- t(t(ps) + pmean) } ## Occasionally the halfspace creates points very close together. We ## can impose a tolerance to merge them if (tol != 0) { ps <- round(ps, ceiling(-log10(abs(tol/2)))) ps <- ps[!duplicated(ps),] } ch <- convhulln(ps, "n FA") ## Check for gross volume errors if ((ch$vol > ch1$vol * (1 + 1E-4))) { warning("Volume of final intersection hull is bigger than first of the original hulls\n", "ch1 vol = ", ch1$vol, "\n", "ch vol = ", ch$vol, "\n", "Returning ch1") ch <- ch1 } if ((ch$vol > ch2$vol * (1 + 1E-4))) { warning("Volume of final intersection hull is bigger than first of the original hulls\n", "ch2 vol = ", ch2$vol, "\n", "ch vol = ", ch$vol, "\n", "Returning ch2") ch <- ch2 } if (return.chs) { out <- list(ch1=ch1, ch2=ch2, ps=ps, ch=ch) class(out) <- "intersectn" return(out) } return(list(ch=ch)) } ##' Find point in intersection of convex hulls ##' ##' Find point that lies somewhere in interesction of two convex ##' hulls. If such a point does not exist, return \code{NA}. The ##' feasible point is found using a linear program similar to the one ##' suggested at \url{../doc/qhull/html/qhalf.html#notes} ##' ##' @param ch1 First convex hull with normals ##' @param ch2 Second convex hull with normals ##' @param tol The point must be at least this far within the facets ##' of both convex hulls ##' @export feasible.point <- function(ch1, ch2, tol=0) { N <- ncol(ch1$p) # Number of dimensions M <- nrow(ch1$normals) + nrow(ch2$normals) # Total number of normals ## Find the point that bounds all points from below. Becuase ## lpSolve::lp() implicitly gives solutions in the positive ## quadrant, we need to subtract p0 from the search point, and then ## add it to the optimised solution. This will ensure that solutions ## not in the positive quadrant are found. p0 <- apply(rbind(ch1$p, ch2$p), 2, min) objective.in <- c(rep(0, N), 1) const.mat <- rbind(cbind(ch1$normals[,-(N + 1)], 1), cbind(ch2$normals[,-(N + 1)], 1), c(rep(0, N), -1)) ## p0 is incorporated into the matrix here const.rhs <- -c(const.mat[1:M, 1:N] %*% cbind(p0) + c(ch1$normals[,N + 1], ch2$normals[,N + 1]), tol) const.dir <- c(rep("<", length(const.rhs))) ## Scaling: The scale option of lpSolve::lp() determines options ## used for scaling, and is crucial to avoid errors in some edge ## cases. For list of options, see: ## http://lpsolve.sourceforge.net/5.1/set_scaling.htm ## http://lpsolve.sourceforge.net/5.1/scaling.htm ## See also https://github.com/davidcsterratt/geometry/issues/35 ## ## After testing on 10,000+ examples, it appears that to get ## maxiumum coverage, in some cases multiple combinations of options ## need to be tried. This code cycles through options, starting with ## the combinations most likely to work. ## DYNUPDATE == 0 may also work, but DYNUPDATE == 1 may work better ## for some 4D examples DYNUPDATE <- 1 ## Both options may help for (POWER2 in 0:1) { ## Both options may help for (QUADRATIC in 0:1) { ## 1 (SCALE_EXTREME) and 3 (SCALE_EXTREME) didn't work well in ## tests ## ## 4 (SCALE_GEOMETRIC) on one example (included in tests) caused ## some sort of infinite loop or race condition leading to the ## process up 100% ## ## 2 (SCALE_RANGE) and 7 (SCALE_CURTISREID) seem to work OK for ## most cases. SCALE_CURTISREID (with the 5.6.13 version of ## lpSolve, at least) has caused some sort of infinite loop or ## race condition leading to the process up 100% on 2 out of ## millions of intersections computed on some processors, hence ## it is put as the second option. for (MAIN in c(2, 7)) { ## Both options may help for (LOGARITHMIC in 0:1) { ## Equilibriate seemed to help for some cases, but caused a ## crash in the example of inst/extdata EQUILIBRIATE <- 0 scale <- MAIN + QUADRATIC * 8 + LOGARITHMIC * 16 + POWER2 * 32 + EQUILIBRIATE * 64 + DYNUPDATE * 256 opt <- lpSolve::lp(direction = "max", objective.in, const.mat, const.dir, const.rhs, scale=scale) ## See http://lpsolve.sourceforge.net/5.5/solve.htm for status codes ## Infeasible solution if (opt$status == 2) return(NA) ## Optimal if (opt$status == 0) return(opt$solution[1:N] + p0) } } } } ## Debugging output if (!is.null(getOption("geometry.debug"))) { opt <- linprog::writeMps("feasible-point.mps", cvec=objective.in, bvec=const.rhs, Amat=const.mat, "Feasible point") writeLines(gsub("_ ", "_", readLines("feasible-point-tmp.mps")), "feasible-point.mps") message("Debugging output saved to feasible-point.mps\n", "Test on command line by running\n", " lp_solve -max -fmps feasible-point.mps") } stop("lpSolve::lp() returned error code ", opt$status, "\n", "See http://lpsolve.sourceforge.net/5.5/solve.htm for explanation of errors.\n", "Rescaling your problem may help") } ##' @method plot intersectn ##' @export plot.intersectn <- function(x, y, ...) { args <- list(...) add <- FALSE if ("add" %in% names(args)) { add <- args$add args$add <- NULL } xlim <- ylim <- NULL if ("xlim" %in% names(args)) { xlim <- args$xlim args$xlim <- NULL } if ("ylim" %in% names(args)) { ylim <- args$ylim args$xlim <- NULL } if (ncol(x$p) == 2) { if (!add) { p <- rbind(x$ch1$p, x$ch2$p) if (is.null(xlim)) xlim <- range(p[,1]) if (is.null(ylim)) ylim <- range(p[,2]) plot.new() do.call(plot.window, c(list(xlim=xlim, ylim=ylim), args)) } plot(x$ch1, add=TRUE, lty=2) plot(x$ch2, add=TRUE, lty=2) plot(x$ch, add=TRUE, lwd=2) } } geometry/R/Unique.R0000644000176200001440000000234713432317337013713 0ustar liggesusers##' Extract Unique Rows ##' ##' \sQuote{Unique} returns a vector, data frame or array like 'x' but with ##' duplicate elements removed. ##' ##' ##' @param X Numerical matrix. ##' @param rows.are.sets If \sQuote{\code{TRUE}}, rows are treated as sets - ##' i.e., to define uniqueness, the order of the rows does not matter. ##' @return Matrix of the same number of columns as \code{x}, with the unique ##' rows in \code{x} sorted according to the columns of \code{x}. If ##' \code{rows.are.sets = TRUE} the rows are also sorted. ##' @note \sQuote{\code{Unique}} is (under circumstances) much quicker than the ##' more generic base function \sQuote{\code{unique}}. ##' @author Raoul Grasman ##' @keywords arith math array ##' @examples ##' ##' # `Unique' is faster than `unique' ##' x = matrix(sample(1:(4*8),4*8),ncol=4) ##' y = x[sample(1:nrow(x),3000,TRUE), ] ##' gc(); system.time(unique(y)) ##' gc(); system.time(Unique(y)) ##' ##' # ##' z = Unique(y) ##' x[matorder(x),] ##' z[matorder(z),] ##' ##' @export "Unique" <- function (X, rows.are.sets = FALSE) { if (rows.are.sets) X = matsort(X) X = X[matorder(X), ] dX = apply(X, 2, diff) uniq = c(TRUE, ((dX^2) %*% rep(1, ncol(dX))) > 0) X = X[uniq, ] return(X) } geometry/R/polyarea.R0000644000176200001440000000375413511174150014254 0ustar liggesusers## Copyright (C) 1999, 2006, 2007, 2009 David M. Doolin ## bugs and limitations: ## Probably ought to be an optional check to make sure that ## traversing the vertices doesn't make any sides cross ## (Is simple closed curve the technical definition of this?). ##' Determines area of a polygon by triangle method. The variables ##' \code{x} and \code{y} define the vertex pairs, and must therefore ##' have the same shape. They can be either vectors or arrays. If ##' they are arrays then the columns of \code{x} and \code{y} are ##' treated separately and an area returned for each. ##' ##' If the optional \code{dim} argument is given, then \code{polyarea} ##' works along this dimension of the arrays \code{x} and \code{y}. ##' ##' @title Determines area of a polygon by triangle method. ##' @param x X coordinates of vertices. ##' @param y Y coordinates of vertices. ##' @param d Dimension of array to work along. ##' @return Area(s) of polygon(s). ##' @author David Sterratt based on the octave sources by David M. Doolin ##' @export ##' @importFrom magic shift ashift ##' @examples ##' x <- c(1, 1, 3, 3, 1) ##' y <- c(1, 3, 3, 1, 1) ##' polyarea(x, y) ##' polyarea(cbind(x, x), cbind(y, y)) ## c(4, 4) ##' polyarea(cbind(x, x), cbind(y, y), 1) ## c(4, 4) ##' polyarea(rbind(x, x), rbind(y, y), 2) ## c(4, 4) polyarea <- function(x, y, d=1) { if (is.vector(x) & is.vector(y)) { if (length(x) == length(y)) { a <- abs(sum(x*(shift(y, -1) - shift(y, 1))))/2 } else { stop("x and y must have the same shape") } } else { if (is.array(x) & is.array(y)) { if (length(dim(x)) != 2) { stop("Arrays must have two dimensions.") } if (all(dim(x) == dim(y))) { v <- c(0, 0) v[d] <- 1 a <- abs(apply(x*(ashift(y, -v) - ashift(y, v)), 3 - d, sum))/2 } else { stop("x and y must have the same shape") } } else { stop("x and y must be of same type") } } names(a) <- NULL return(a) } geometry/R/matmax.R0000644000176200001440000000246313432317337013733 0ustar liggesusers##' Row-wise matrix functions ##' ##' Compute maximum or minimum of each row, or sort each row of a matrix, or a ##' set of (equal length) vectors. ##' ##' ##' @aliases matmax matmin matsort matorder ##' @param \dots A numeric matrix or a set of numeric vectors (that are ##' column-wise bind together into a matrix with \code{cbind}). ##' @return \code{matmin} and \code{matmax} return a vector of length ##' \code{nrow(cbind(...))}. \code{matsort} returns a matrix of dimension ##' \code{dim(cbind(...))} with in each row of \code{cbind(...)} sorted. ##' \code{matsort(x)} is a lot faster than, e.g., \code{t(apply(x,1,sort))}, ##' if \code{x} is tall (i.e., \code{nrow(x)}>>\code{ncol(x)} and ##' \code{ncol(x)}<30. If \code{ncol(x)}>30 then \code{matsort} simply calls ##' `\code{t(apply(x,1,sort))}'. \code{matorder} returns a permutation which ##' rearranges its first argument into ascending order, breaking ties by ##' further arguments. ##' @author Raoul Grasman ##' @keywords array arith ##' @examples ##' ##' example(Unique) ##' ##' @export matmax matmin matsort matorder "matmax" <- function (...) { x = cbind(...) if(!is.numeric(x)) stop("Input should by numeric.") if (!is.matrix(drop(x))) x = t(x) x[1:nrow(x) + nrow(x) * (max.col(x) - 1)] } geometry/R/mesh.dsphere.R0000644000176200001440000000202413432317337015022 0ustar liggesusers##' Signed distance from points \code{p} to boundary of sphere to ##' allow easy definition of regions in \code{\link{distmeshnd}}. ##' ##' @title Sphere distance function ##' @param p A matrix with 2 columns (3 in \code{mesh.dsphere}), each row ##' representing a point in the plane. ##' @param radius radius of sphere ##' @param ... additional arguments (not used) ##' @return A vector of length \code{nrow(p)} containing the signed ##' distances to the sphere ##' @author Raoul Grasman; translated from original Matlab sources of Per-Olof ##' Persson. ##' @seealso \code{\link{distmeshnd}} ##' @references \url{http://persson.berkeley.edu/distmesh/} ##' ##' \cite{P.-O. Persson, G. Strang, A Simple Mesh Generator in MATLAB. SIAM ##' Review, Volume 46 (2), pp. 329-345, June 2004} ##' @keywords arith math ##' @examples ##' ##' example(distmeshnd) ##' @export "mesh.dsphere" <- function (p, radius = 1, ...) { if (!is.matrix(p)) p = t(as.matrix(p)) sqrt((p^2) %*% rep(1, ncol(p))) - radius } geometry/R/surf.tri.R0000644000176200001440000001147214662314120014211 0ustar liggesusers##' Find surface triangles from tetrahedral mesh ##' ##' Find surface triangles from tetrahedral mesh typically obtained ##' with \code{\link{delaunayn}}. ##' ##' \code{surf.tri} and \code{\link{convhulln}} serve a similar purpose in 3D, ##' but \code{surf.tri} also works for non-convex meshes obtained e.g. with ##' \code{\link{distmeshnd}}. It also does not produce currently unavoidable ##' diagnostic output on the console as \code{convhulln} does at the Rterm ##' console--i.e., \code{surf.tri} is silent. ##' ##' @param p An \code{n}-by-\code{3} matrix. The rows of \code{p} represent ##' \code{n} points in \code{dim}-dimensional space. ##' @param t Matrix with 4 columns, interpreted as output of ##' \code{\link{delaunayn}}. ##' @return An \code{m}-by-\code{3} index matrix of which each row defines a ##' triangle. The indices refer to the rows in \code{p}. ##' @note \code{surf.tri} was based on Matlab code for mesh of Per-Olof Persson ##' (\url{http://persson.berkeley.edu/distmesh/}). ##' @author Raoul Grasman ##' @seealso \code{\link[interp]{tri.mesh}}, \code{\link{convhulln}}, ##' \code{\link{surf.tri}}, \code{\link{distmesh2d}} ##' @keywords math optimize dplot ##' @examples ##' ##' \dontrun{ ##' # more extensive example of surf.tri ##' ##' # url's of publically available data: ##' data1.url = "http://neuroimage.usc.edu/USCPhantom/mesh_data.bin" ##' data2.url = "http://neuroimage.usc.edu/USCPhantom/CT_PCS_trans.bin" ##' ##' meshdata = R.matlab::readMat(url(data1.url)) ##' elec = R.matlab::readMat(url(data2.url))$eeg.ct2pcs/1000 ##' brain = meshdata$mesh.brain[,c(1,3,2)] ##' scalp = meshdata$mesh.scalp[,c(1,3,2)] ##' skull = meshdata$mesh.skull[,c(1,3,2)] ##' tbr = t(surf.tri(brain, delaunayn(brain))) ##' tsk = t(surf.tri(skull, delaunayn(skull))) ##' tsc = t(surf.tri(scalp, delaunayn(scalp))) ##' rgl::triangles3d(brain[tbr,1], brain[tbr,2], brain[tbr,3],col="gray") ##' rgl::triangles3d(skull[tsk,1], skull[tsk,2], skull[tsk,3],col="white", alpha=0.3) ##' rgl::triangles3d(scalp[tsc,1], scalp[tsc,2], scalp[tsc,3],col="#a53900", alpha=0.6) ##' rgl::view3d(-40,30,.4,zoom=.03) ##' lx = c(-.025,.025); ly = -c(.02,.02); ##' rgl::spheres3d(elec[,1],elec[,3],elec[,2],radius=.0025,col='gray') ##' rgl::spheres3d( lx, ly,.11,radius=.015,col="white") ##' rgl::spheres3d( lx, ly,.116,radius=.015*.7,col="brown") ##' rgl::spheres3d( lx, ly,.124,radius=.015*.25,col="black") ##' } ##' ##' @export "surf.tri" <- function(p,t){ # original by Per-Olof Persson (c) 2005 for MATLAB # ported to R and modified for efficiency by Raoul Grasman (c) 2005 # construct all faces faces = rbind(t[,-4], t[,-3], t[,-2], t[,-1]); node4 = rbind(t[, 4], t[, 3], t[, 2], t[, 1]); # #original translated from MATLAB: # # select the faces that occur only once --> these are the surface boundary faces # faces = t(apply(faces,1,sort)); # sort each row # foo = apply(faces,1,function(x) do.call("paste",as.list(x,sep=" "))); # makes a string from each row # vec = table(foo); # tabulates the number of occurences of each string # ix = sapply(names(vec[vec==1]),function(b) which(b==foo)) # obtain indices of faces with single occurence # tri = faces[ix,]; # node4 = node4[ix]; # we wish to achieve # > faces = t(apply(faces,1,sort)); # but this is much too slow, we therefore use max.col and the fact # that there are only 3 columns in faces i.max = 3*(1:nrow(faces)-1) + max.col(faces) i.min = 3*(1:nrow(faces)-1) + max.col(-faces) faces = t(faces) faces = cbind(faces[i.min], faces[-c(i.max,i.min)], faces[i.max]) ix = order(faces[,1], faces[,2], faces[,3]) # Next, we wish to detect duplicated rows in faces, that is, # > qx = duplicated(faces[ix,],MARGIN=1) # logical indicating duplicates # but this is also much to slow, we therefore use the fact that # faces[ix,] has the duplicate rows ordered beneath each other # and the fact that each row occurs exactly once or twice fo = apply(faces[ix,],2,diff) dup = (abs(fo) %*% rep(1,3)) == 0 # a row of only zeros indicates duplicate dup = c(FALSE,dup) # first is never a duplicate qx = diff(dup)==0 # only zero if two consecutive elems are not duplicates qx = c(qx, !dup[length(dup)]) # last row is either non-duplicate or should not be selected tri = faces[ix[qx],] # ix[qx] are indices of singly occuring faces node4 = node4[ix[qx]] # compute face orientations v1 = p[tri[,2],] - p[tri[,1],]; # edge vectors v2 = p[tri[,3],] - p[tri[,1],]; v3 = p[node4,] - p[tri[,1],]; ix = which( apply(extprod3d(v1,v2) * v3, 1, sum) > 0 ) tri[ix,c(2,3)] = tri[ix,c(3,2)] rownames(tri) = NULL tri } geometry/R/mesh.drectangle.R0000644000176200001440000000327013432317337015504 0ustar liggesusers##' Signed distance from points \code{p} to boundary of rectangle to ##' allow easy definition of regions in \code{\link{distmesh2d}}. ##' ##' @title Rectangle distance function ##' @param p A matrix with 2 columns, each row representing a point in ##' the plane. ##' @param x1 lower left corner of rectangle ##' @param y1 lower left corner of rectangle ##' @param x2 upper right corner of rectangle ##' @param y2 upper right corner of rectangle ##' @param \dots additional arguments (not used) ##' @return a vector of length \code{nrow(p)} containing the signed distances ##' @author Raoul Grasman; translated from original Matlab sources of Per-Olof ##' Persson. ##' @seealso \code{\link{distmesh2d}}, \code{\link{mesh.drectangle}}, ##' \code{\link{mesh.diff}}, \code{\link{mesh.intersect}}, ##' \code{\link{mesh.union}} ##' @references \url{http://persson.berkeley.edu/distmesh/} ##' ##' \cite{P.-O. Persson, G. Strang, A Simple Mesh Generator in MATLAB. SIAM ##' Review, Volume 46 (2), pp. 329-345, June 2004} ##' @keywords arith math ##' @examples ##' example(distmesh2d) ##' @export mesh.drectangle <- function (p, x1 = -1/2, y1 = -1/2, x2 = 1/2, y2 = 1/2, ...) { if (!is.matrix(p)) p = t(as.matrix(p)) d1 = y1 - p[, 2] d2 = -y2 + p[, 2] d3 = x1 - p[, 1] d4 = -x2 + p[, 1] d5 = sqrt(d1^2 + d3^2) d6 = sqrt(d1^2 + d4^2) d7 = sqrt(d2^2 + d3^2) d8 = sqrt(d2^2 + d4^2) matmin = function(...) apply(cbind(...), 1, min) d = -matmin(matmin(matmin(-d1, -d2), -d3), -d4) ix = d1 > 0 & d3 > 0 d[ix] = d5[ix] ix = d1 > 0 & d4 > 0 d[ix] = d6[ix] ix = d2 > 0 & d3 > 0 d[ix] = d7[ix] ix = d2 > 0 & d4 > 0 d[ix] = d8[ix] return(d) } geometry/R/convhulln.R0000644000176200001440000002147414664576025014470 0ustar liggesusers##' Compute smallest convex hull that encloses a set of points ##' ##' Returns information about the smallest convex complex of a set of ##' input points in \eqn{N}-dimensional space (the convex hull of the ##' points). By default, indices to points forming the facets of the ##' hull are returned; optionally normals to the facets and the ##' generalised surface area and volume can be returned. This function ##' interfaces the \href{http://www.qhull.org}{Qhull} library. ##' ##' @param p An \eqn{M}-by-\eqn{N} matrix. The rows of \code{p} ##' represent \eqn{M} points in \eqn{N}-dimensional space. ##' ##' @param options String containing extra options for the underlying ##' Qhull command; see details below and Qhull documentation at ##' \url{../doc/qhull/html/qconvex.html#synopsis}. ##' ##' @param output.options String containing Qhull options to generate ##' extra output. Currently \code{n} (normals) and \code{FA} ##' (generalised areas and volumes) are supported; see ##' \sQuote{Value} for details. If \code{output.options} is ##' \code{TRUE}, select all supported options. ##' ##' @param return.non.triangulated.facets logical defining whether the ##' output facets should be triangulated; \code{FALSE} by default. ##' ##' @return By default (\code{return.non.triangulated.facets} is ##' \code{FALSE}), return an \eqn{M}-by-\eqn{N} matrix in which each ##' row contains the indices of the points in \code{p} forming an ##' \eqn{N-1}-dimensional facet. e.g In 3 dimensions, there are 3 ##' indices in each row describing the vertices of 2-dimensional ##' triangles. ##' ##' If \code{return.non.triangulated.facets} is \code{TRUE} then the ##' number of columns equals the maximum number of vertices in a ##' facet, and each row defines a polygon corresponding to a facet ##' of the convex hull with its vertices followed by \code{NA}s ##' until the end of the row. ##' ##' If the \code{output.options} or \code{options} argument contains ##' \code{FA} or \code{n}, return a list with class \code{convhulln} ##' comprising the named elements: ##' \describe{ ##' \item{\code{p}}{The points passed to \code{convnhulln}} ##' \item{\code{hull}}{The convex hull, represented as a matrix indexing \code{p}, as ##' described above} ##' \item{\code{area}}{If \code{FA} is specified, the generalised area of ##' the hull. This is the surface area of a 3D hull or the length of ##' the perimeter of a 2D hull. ##' See \url{../doc/qhull/html/qh-optf.html#FA}.} ##' \item{\code{vol}}{If \code{FA} is specified, the generalised volume of ##' the hull. This is volume of a 3D hull or the area of a 2D hull. ##' See \url{../doc/qhull/html/qh-optf.html#FA}. } ##' \item{\code{normals}}{If \code{n} is specified, this is a matrix ##' hyperplane normals with offsets. See \url{../doc/qhull/html/qh-opto.html#n}.} ##' } ##' ##' @note This function was originally a port of the ##' \href{https://octave.org/}{Octave} convhulln function written ##' by Kai Habel. ##' ##' See further notes in \code{\link{delaunayn}}. ##' ##' @author Raoul Grasman, Robert B. Gramacy, Pavlo Mozharovskyi and ##' David Sterratt \email{david.c.sterratt@@ed.ac.uk} ##' @seealso \code{\link{intersectn}}, \code{\link{delaunayn}}, ##' \code{\link{surf.tri}}, \code{\link[interp]{convex.hull}} ##' @references \cite{Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., ##' \dQuote{The Quickhull algorithm for convex hulls,} \emph{ACM ##' Trans. on Mathematical Software,} Dec 1996.} ##' ##' \url{http://www.qhull.org} ##' @keywords math dplot graphs ##' @examples ##' ## Points in a sphere ##' ps <- matrix(rnorm(3000), ncol=3) ##' ps <- sqrt(3)*ps/drop(sqrt((ps^2) %*% rep(1, 3))) ##' ts.surf <- t(convhulln(ps)) # see the qhull documentations for the options ##' \dontrun{ ##' rgl::triangles3d(ps[ts.surf,1],ps[ts.surf,2],ps[ts.surf,3],col="blue",alpha=.2) ##' for(i in 1:(8*360)) rgl::view3d(i/8) ##' } ##' ##' ## Square ##' pq <- rbox(0, C=0.5, D=2) ##' # Return indices only ##' convhulln(pq) ##' # Return convhulln object with normals, generalised area and volume ##' ch <- convhulln(pq, output.options=TRUE) ##' plot(ch) ##' ##' ## Cube ##' pc <- rbox(0, C=0.5, D=3) ##' # Return indices of triangles on surface ##' convhulln(pc) ##' # Return indices of squares on surface ##' convhulln(pc, return.non.triangulated.facets=TRUE) ##' @export ##' @useDynLib geometry convhulln <- function (p, options = "Tv", output.options=NULL, return.non.triangulated.facets = FALSE) { tmp_stdout <- tempfile("Rf") tmp_stderr <- tempfile("Rf") on.exit(unlink(c(tmp_stdout, tmp_stderr))) ## Combine and check options options <- tryCatch(qhull.options(options, output.options, supported_output.options <- c("n", "FA")), error=function(e) {stop(e)}) ## Coerce the input to be matrix if (is.data.frame(p)) { p <- as.matrix(p) } ## Make sure we have real-valued input storage.mode(p) <- "double" ## We need to check for NAs in the input, as these will crash the C ## code. if (any(is.na(p))) { stop("The first argument should not contain any NAs") } if (!return.non.triangulated.facets){ ## It is essential that delaunayn is called with either the QJ or Qt ## option. Otherwise it may return a non-triangulated structure, i.e ## one with more than dim+1 points per structure, where dim is the ## dimension in which the points p reside. if (!grepl("Qt", options) & !grepl("QJ", options)) { options <- paste(options, "Qt") } } out <- tryCatch( .Call("C_convhulln", p, as.character(options), as.integer(return.non.triangulated.facets), tmp_stdout, tmp_stderr, PACKAGE="geometry"), error=function(e) { message = e$message if (grepl("QH6271", e$message)) { message("You may be able to avoid the following error by adding \"Qbb\" to the \"options\" argument of convhulln() For example: options=\"", options, " Qbb\" If this does not work, please add to the issue at https://github.com/davidcsterratt/geometry/issues/58 ") } stop(e) }) # Remove NULL elements out[which(sapply(out, is.null))] <- NULL if (is.null(out$area) & is.null(out$vol) & is.null(out$normals)) { attr(out$hull, "convhulln") <- attr(out, "convhulln") return(out$hull) } class(out) <- "convhulln" out$p <- p return(out) } ##' @importFrom graphics plot ##' @method plot convhulln ##' @export plot.convhulln <- function(x, y, ...) { if (ncol(x$p) < 2 || ncol(x$p) > 3) stop("Only 2D and 3D convhullns can be plotted") args <- list(...) add <- FALSE if ("add" %in% names(args)) { add <- args$add args$add <- NULL } if (ncol(x$p) == 2) { if (!add) { plot(x$p[,1], x$p[,2], ...) } m <- x$hull p <- x$p do.call(segments, c(list(p[m[,1],1],p[m[,1],2],p[m[,2],1],p[m[,2],2]), args)) } if (ncol(x$p) == 3) { if(requireNamespace("rgl") == FALSE) stop("The rgl package is required for tetramesh") if (!add) rgl::clear3d() if (ncol(x$hull) == 3) { do.call(rgl::triangles3d, c(list(x$p[t(x$hull),1], x$p[t(x$hull),2], x$p[t(x$hull),3]), args)) } else { stop("At present only convhullns with triangulated facets can be plotted") } } } ##' Convert convhulln object to RGL mesh ##' ##' @param x \code{\link{convhulln}} object ##' @param ... Arguments to \code{\link[rgl]{qmesh3d}} or ##' \code{\link[rgl]{tmesh3d}} ##' @return \code{\link[rgl]{mesh3d}} object, which can be displayed ##' in RGL with \code{\link[rgl]{dot3d}}, \code{\link[rgl]{wire3d}} ##' or \code{\link[rgl]{shade3d}} ##' ##' @seealso \code{\link[rgl]{as.mesh3d}} ##' @export to.mesh3d <- function(x, ...) UseMethod("to.mesh3d") ##' @importFrom graphics plot ##' @method to.mesh3d convhulln ##' @export to.mesh3d.convhulln <- function(x, ...) { if(requireNamespace("rgl") == FALSE) stop("The rgl package is required for as.mesh.convhulln") if (ncol(x$p) != 3) { stop("Only convex hulls of points in 3D can be turned into meshes") } if (ncol(x$hull) == 4) { stop("At present only convhulls with triangulated facets can be converted to mesh3d") ## return(rgl::qmesh3d(t(x$p), t(x$hull), homogeneous=FALSE, ...)) } if (ncol(x$hull) == 3) { return(rgl::tmesh3d(t(x$p), t(x$hull), homogeneous=FALSE, ...)) } stop("Facets of hull must be triangles or quadrilaterals") } ## LocalWords: dQuote Qhull param itemize Kai Habel delaunayn Pavlo ## LocalWords: Grasman Gramacy Mozharovskyi Sterratt seealso tri ps ## LocalWords: interp distmesh intersectn Dobkin Huhdanpaa emph Tv ## LocalWords: Quickhull ACM dplot convhulln qhull rnorm ncol sqrt ## LocalWords: dontrun useDynLib tmp_stdout tmp_stderr tempdir sanitisation NAs na ## LocalWords: QJ grepl importFrom convhulls args requireNamespace ## LocalWords: rgl tetramesh eqn href sQuote hyperplane rbox ## LocalWords: convulln convhullns geometry/R/distmeshnd.R0000644000176200001440000001706314662314120014601 0ustar liggesusers##' A simple mesh generator for non-convex regions in n-D space ##' ##' An unstructured simplex requires a choice of mesh points (vertex nodes) and ##' a triangulation. This is a simple and short algorithm that improves the ##' quality of a mesh by relocating the mesh points according to a relaxation ##' scheme of forces in a truss structure. The topology of the truss is reset ##' using Delaunay triangulation. A (sufficiently smooth) user supplied signed ##' distance function (\code{fd}) indicates if a given node is inside or ##' outside the region. Points outside the region are projected back to the ##' boundary. ##' ##' This is an implementation of original Matlab software of Per-Olof Persson. ##' ##' Excerpt (modified) from the reference below: ##' ##' \sQuote{The algorithm is based on a mechanical analogy between a triangular ##' mesh and a n-D truss structure. In the physical model, the edges of the ##' Delaunay triangles of a set of points correspond to bars of a truss. Each ##' bar has a force-displacement relationship \eqn{f(\ell, \ell_{0})}{F(L,L0)} ##' depending on its current length \eqn{\ell}{L} and its unextended length ##' \eqn{\ell_{0}}{L0}.} ##' ##' \sQuote{External forces on the structure come at the boundaries, on which ##' external forces have normal orientations. These external forces are just ##' large enough to prevent nodes from moving outside the boundary. The ##' position of the nodes are the unknowns, and are found by solving for a ##' static force equilibrium. The hope is that (when \code{fh = function(p) ##' return(rep(1,nrow(p)))}), the lengths of all the bars at equilibrium will ##' be nearly equal, giving a well-shaped triangular mesh.} ##' ##' See the references below for all details. Also, see the comments in the ##' source file of \code{distmesh2d}. ##' ##' @param fdist Vectorized signed distance function, for example ##' \code{\link{mesh.dsphere}}, accepting an \code{m}-by-\code{n} ##' matrix, where \code{m} is arbitrary, as the first argument. ##' @param fh Vectorized function, for example \code{\link{mesh.hunif}}, ##' that returns desired edge length as a function of position. ##' Accepts an \code{m}-by-\code{n} matrix, where \code{n} is ##' arbitrary, as its first argument. ##' @param h Initial distance between mesh nodes. ##' @param box \code{2}-by-\code{n} matrix that specifies the bounding box. ##' (See \link{distmesh2d} for an example.) ##' @param pfix \code{nfix}-by-2 matrix with fixed node positions. ##' @param \dots parameters that are passed to \code{fdist} and \code{fh} ##' @param ptol Algorithm stops when all node movements are smaller than ##' \code{dptol} ##' @param ttol Controls how far the points can move (relatively) before a ##' retriangulation with \code{\link{delaunayn}}. ##' @param deltat Size of the time step in Euler's method. ##' @param geps Tolerance in the geometry evaluations. ##' @param deps Stepsize \eqn{\Delta x} in numerical derivative computation for ##' distance function. ##' @return \code{m}-by-\code{n} matrix with node positions. ##' @section Wishlist : \itemize{ \item Implement in C/Fortran \item Translate ##' other functions of the Matlab package } ##' @author Raoul Grasman; translated from original Matlab sources of Per-Olof ##' Persson. ##' @seealso \code{\link{distmesh2d}}, \code{\link[interp]{tri.mesh}}, ##' \code{\link{delaunayn}}, \code{\link{mesh.dsphere}}, ##' \code{\link{mesh.hunif}},\cr \code{\link{mesh.diff}}, ##' \code{\link{mesh.union}}, \code{\link{mesh.intersect}} ##' @references \url{http://persson.berkeley.edu/distmesh/} ##' ##' \cite{P.-O. Persson, G. Strang, A Simple Mesh Generator in MATLAB. SIAM ##' Review, Volume 46 (2), pp. 329-345, June 2004} ##' @keywords math optimize dplot graphs ##' @examples ##' ##' \dontrun{ ##' # examples distmeshnd ##' require(rgl) ##' ##' fd = function(p, ...) sqrt((p^2)%*%c(1,1,1)) - 1 ##' # also predefined as `mesh.dsphere' ##' fh = function(p,...) rep(1,nrow(p)) ##' # also predefined as `mesh.hunif' ##' bbox = matrix(c(-1,1),2,3) ##' p = distmeshnd(fd,fh,0.2,bbox, maxiter=100) ##' # this may take a while: ##' # press Esc to get result of current iteration ##' } ##' ##' @export "distmeshnd" <- function (fdist, fh, h, box, pfix = array(dim = c(0, ncol(box))), ..., ptol = 0.001, ttol = 0.1, deltat = 0.1, geps = 0.1 * h, deps = sqrt(.Machine$double.eps) * h) { # %DISTMESHND N-D Mesh Generator using Distance Functions. dim = ncol(as.matrix(box)) L0mult = 1 + 0.4/2^(dim - 1) rownorm2 = function(x) drop(sqrt((x^2) %*% rep(1, ncol(x)))) # %1. Create initial distribution in bounding box if (dim == 1) { p = seq(box[1], box[2], by = h) } else { cbox = lapply(1:dim, function(ii) seq(box[1, ii], box[2, ii], by = h)) p = do.call("expand.grid", cbox) p = as.matrix(p) } # %2. Remove points outside the region, apply the rejection method p = p[fdist(p, ...) < geps, ] r0 = fh(p, ...) p = rbind(pfix, p[stats::runif(nrow(p)) < min(r0)^dim/r0^dim, ]) N = nrow(p) if (N <= dim + 1) stop("Not enough starting points inside boundary (is h0 too large?).") on.exit(return(invisible(p))) message("Press esc if the mesh seems fine but the algorithm hasn't converged.") utils::flush.console() count = 0 p0 = 1/.Machine$double.eps # mimick Matlab call ``localpairs=nchoosek(1:dim+1,2)'': localpairs = as.matrix(expand.grid(1:(dim + 1), 1:(dim + 1))) localpairs = localpairs[lower.tri(matrix(TRUE, dim + 1, dim + 1)), 2:1] while (TRUE) { if (max(rownorm2(p - p0)) > ttol * h) { # %3. Retriangulation by Delaunay: p0 = p t = delaunayn(p) pmid = matrix(0, nrow(t), dim) for (ii in 1:(dim + 1)) pmid = pmid + p[t[, ii], ]/(dim + 1) t = t[fdist(pmid, ...) < (-geps), ] pair = array(dim = c(0, 2)) for (ii in 1:nrow(localpairs)) { pair = rbind(pair, t[, localpairs[ii, ]]) } # %4. Describe each edge by a unique pair of nodes pair = Unique(pair, TRUE); # base-function `unique' is way too slow if (dim == 2) { trimesh(t, p[, 1:2]) } else if (dim == 3) { if (count%%5 == 0) { tetramesh(t, p) } } else { message("Retriangulation #", 15) utils::flush.console() } count = count + 1 } bars = p[pair[, 1], ] - p[pair[, 2], ] L = rownorm2(bars) L0 = fh((p[pair[, 1], ] + p[pair[, 2], ])/2, ...) L0 = L0 * L0mult * (sum(L^dim)/sum(L0^dim))^(1/dim) F = L0 - L F[F < 0] = 0 Fbar = cbind(bars, -bars) * matrix(F/L, nrow = nrow(bars), ncol = 2 * dim) ii = pair[, t(matrix(1:2, 2, dim))] jj = rep(1, nrow(pair)) %o% c(1:dim, 1:dim) s = c(Fbar) ns = length(s) dp = matrix(0, N, dim) dp[1:(dim * N)] = rowsum(s, ii[1:ns] + ns * (jj[1:ns] - 1)) if (nrow(pfix) > 0) dp[1:nrow(pfix), ] = 0 p = p + deltat * dp d = fdist(p, ...) ix = d > 0 gradd = matrix(0, sum(ix), dim) for (ii in 1:dim) { a = rep(0, dim) a[ii] = deps d1x = fdist(p[ix, ] + rep(1, sum(ix)) %o% a, ...) gradd[, ii] = (d1x - d[ix])/deps } p[ix, ] = p[ix, ] - (d[ix] %o% rep(1, dim)) * gradd maxdp = max(deltat * rownorm2(dp[d < (-geps), ])) if (maxdp < ptol * h) break } } geometry/R/qhull-options.R0000644000176200001440000000175514662314120015256 0ustar liggesusersqhull.options <- function(options, output.options, supported_output.options, full=FALSE) { if (full) { if (!is.null(output.options)) { stop("full and output.options should not be specified together") } output.options = TRUE ## Enable message in 0.4.1 ## Turn to warning in 0.4.7 message("delaunayn: \"full\" option is deprecated; adding \"Fa\" and \"Fn\" to options. Please update your code to use \"output.options=TRUE\" or set \"output.options\" to a string containing desired QHull options.") } if (is.null(output.options)) { output.options <- "" } if (is.logical(output.options)) { if (output.options) { output.options <- paste(supported_output.options, collapse=" ") } else { output.options <- "" } } if (!is.character(output.options)) { stop("output.options must be a string, logical or NULL") } ## Input sanitisation options <- paste(options, output.options, collapse=" ") return(options) } geometry/R/cart2sph.R0000644000176200001440000000511714662314120014162 0ustar liggesusers## Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2009, 2017 Kai Habel ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or (at ## your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## This file has been adapted for R by David C Sterratt ##' Transform Cartesian to spherical coordinates ##' ##' If called with a single matrix argument then each row of \code{c} ##' represents the Cartesian coordinate (\code{x}, \code{y}, \code{z}). ##' ##' @param x x-coordinates or matrix with three columns ##' @param y y-coordinates (optional, if \code{x}) is a matrix ##' @param z z-coordinates (optional, if \code{x}) is a matrix ##' @return Matrix with columns: ##' \item{\code{theta}}{the angle relative to the positive x-axis} ##' \item{\code{phi}}{the angle relative to the xy-plane} ##' \item{\code{r}}{the distance to the origin \code{(0, 0, 0)}} ##' @seealso \code{\link{sph2cart}}, \code{\link{cart2pol}}, ##' \code{\link{pol2cart}} ##' @author Kai Habel ##' @author David Sterratt ##' @export cart2sph <- function(x, y=NULL, z=NULL) { if ((is.null(y) & !is.null(z)) | (is.null(z) & !is.null(y))) { stop("There should be 3 arguments (x, y, z) or one argument (x)") } if (is.null(y) & is.null(z)) { if (!(is.numeric(x))) { stop("input must be matrix with 3 columns [x, y, z]") } if (!(is.matrix(x) & ncol(x) == 3)) { stop("matrix input must have 3 columns [x, y, z]") } z <- x[,3] y <- x[,2] x <- x[,1] } else { if (!is.numeric(x) | !is.numeric(y) | !is.numeric (z)) stop("x, y, z must be numeric arrays of the same size, or scalar") if ( !(((length(x) == length(y)) | (length(x) == 1) | (length(y) == 1)) & ((length(x) == length(z)) | (length(x) == 1) | (length(z) == 1)) & ((length(y) == length(z)) | (length(y) == 1) | (length(z) == 1)))) { stop("x, y, z must be matrices of the same size, or scalar") } } theta <- atan2(y, x) phi <- atan2(z, sqrt(x^2 + y^2)) r <- sqrt(x^2 + y^2 + z^2) return(cbind(theta, phi, r)) } geometry/R/mesh.union.R0000644000176200001440000000014113432317337014516 0ustar liggesusers"mesh.union" <- function (p, regionA, regionB, ...) matmin(regionA(p, ...), regionB(p, ...)) geometry/R/trimesh.R0000644000176200001440000000326713432317337014122 0ustar liggesusers##' \code{trimesh(T, p)} displays the triangles defined in the m-by-3 ##' matrix \code{T} and points \code{p} as a mesh. Each row of ##' \code{T} specifies a triangle by giving the 3 indices of its ##' points in \code{X}. ##' ##' @title Display triangles mesh (2D) ##' @param T T is a \code{m}-by-3 matrix. A row of \code{T} contains ##' indices into \code{X} of the vertices of a triangle. \code{T} is ##' usually the output of \code{\link{delaunayn}}. ##' @param p A vector or a matrix. ##' @param p2 if \code{p} is not a matrix \code{p} and \code{p2} are bind to a ##' matrix with \code{cbind}. ##' @param add Add to existing plot in current active device? ##' @param axis Draw axes? ##' @param boxed Plot box? ##' @param \dots Parameters to the rendering device. See the \link[rgl]{rgl} ##' package. ##' @author Raoul Grasman ##' @seealso \code{\link{tetramesh}}, \code{\link[rgl]{rgl}}, ##' \code{\link{delaunayn}}, \code{\link{convhulln}}, ##' \code{\link{surf.tri}} ##' @keywords hplot ##' @examples ##' #example trimesh ##' p = cbind(x=rnorm(30), y=rnorm(30)) ##' tt = delaunayn(p) ##' trimesh(tt,p) ##' @export ##' @importFrom graphics box plot.new plot.window segments trimesh <- function(T, p, p2, add=FALSE, axis=FALSE, boxed=FALSE, ...){ if(!is.matrix(p)){ p = cbind(p,p2) # automatically generates error if p2 not present } xlim = range(p[,1]) ylim = range(p[,2]) if(!add){ plot.new() plot.window(xlim, ylim, ...) } if(boxed){ box() } if(axis) { axis(1) axis(2) } m = rbind(T[,-1], T[, -2], T[, -3]) segments(p[m[,1],1],p[m[,1],2],p[m[,2],1],p[m[,2],2], ...) return(invisible(list(T = T, p = p))) } geometry/R/cart2pol.R0000644000176200001440000000557113433536400014170 0ustar liggesusers## Copyright (C) 2000-2017 Kai Habel ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## This file has been adapted for R by David C Sterratt ##' Transform Cartesian coordinates to polar or cylindrical coordinates. ##' ##' The inputs \code{x}, \code{y} (, and \code{z}) must be the same shape, or ##' scalar. If called with a single matrix argument then each row of \code{C} ##' represents the Cartesian coordinate (\code{x}, \code{y} (, \code{z})). ##' ##' @param x x-coordinates or matrix with three columns ##' @param y y-coordinates (optional, if \code{x}) is a matrix ##' @param z z-coordinates (optional, if \code{x}) is a matrix ##' @return A matrix \code{P} where each row represents one ##' polar/(cylindrical) coordinate (\code{theta}, \code{r}, (, ##' \code{z})). ##' @seealso \code{\link{pol2cart}}, \code{\link{cart2sph}}, ##' \code{\link{sph2cart}} ##' @author Kai Habel ##' @author David Sterratt ##' @export cart2pol <- function(x, y=NULL, z=NULL) { if (is.null(y) & is.null(z)) { if (!(is.numeric(x))) { stop("input must be matrix with 2 or 3 columns") } if (!(is.numeric (x) & is.matrix (x) & (ncol(x) == 2 | ncol(x) == 3))) { stop("matrix input must have 2 or 3 columns [X, Y (, Z)]"); } if (ncol(x) == 3) { z <- x[,3] } y <- x[,2] x <- x[,1] } else { if (is.null(z)) { if (!is.numeric (x) | !is.numeric (y)) { stop("X, Y must be numeric arrays of the same size, or scalar") } if ( !((length(x) == length(y)) | (length(x) == 1) | (length(y) == 1))) { stop("X, Y must be numeric arrays of the same size, or scalar") } } else { if (! is.numeric (x) | ! is.numeric (y) | ! is.numeric (z)) { stop("X, Y, Z must be numeric arrays of the same size, or scalar") } if ( !(((length(x) == length(y)) | (length(x) == 1) | (length(y) == 1)) & ((length(x) == length(z)) | (length(x) == 1) | (length(z) == 1)) & ((length(y) == length(z)) | (length(y) == 1) | (length(z) == 1)))) { stop("x, y, z must be matrices of the same size, or scalar") } } } theta <- atan2 (y, x) r <- sqrt(x^2 + y^2) if (is.null(z)) { return(cbind(theta=theta, r=r)) } return(cbind(theta=theta, r=r, z=z)) } geometry/R/rbox.R0000644000176200001440000000134213432317337013411 0ustar liggesusers##' Default is corners of a hypercube. ##' @title Generate various point distributions ##' @param n number of random points in hypercube ##' @param D number of dimensions of hypercube ##' @param B bounding box coordinate - faces will be \code{-B} and \code{B} from origin ##' @param C add a unit hypercube to the output - faces will be \code{-C} and \code{C} from origin ##' @return Matrix of points ##' @author David Sterratt ##' @export rbox <- function(n=3000, D=3, B=0.5, C=NA) { P <- matrix(0, 0, D) if (!is.na(C)) { P <- rbind(P, as.matrix(do.call(expand.grid, rep(list(c(-C, C)), D)))) } if (n > 0) { P <- rbind(P, matrix(stats::runif(n=n*D, min=-B, max=B), n, D)) } return(P) } geometry/R/pol2cart.R0000644000176200001440000000567513433536400014175 0ustar liggesusers## Copyright (C) 2000-2017 Kai Habel ## ## This file is part of Octave. ## ## Octave is free software; you can redistribute it and/or modify it ## under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 3 of the License, or ## (at your option) any later version. ## ## Octave is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Octave; see the file COPYING. If not, see ## . ## This file has been adapted for R by David C Sterratt ##' Transform polar or cylindrical coordinates to Cartesian coordinates. ##' ##' The inputs \code{theta}, \code{r}, (and \code{z}) must be the same shape, or ##' scalar. If called with a single matrix argument then each row of \code{P} ##' represents the polar/(cylindrical) coordinate (\code{theta}, \code{r} ##' (, \code{z})). ##' ##' @param theta describes the angle relative to the positive x-axis. ##' @param r is the distance to the z-axis (0, 0, z). ##' @param z (optional) is the z-coordinate ##' @return a matrix \code{C} where each row represents one Cartesian ##' coordinate (\code{x}, \code{y} (, \code{z})). ##' @seealso \code{\link{cart2pol}}, \code{\link{sph2cart}}, ##' \code{\link{cart2sph}} ##' @author Kai Habel ##' @author David Sterratt ##' @export pol2cart <- function(theta, r=NULL, z=NULL) { if (is.null(r) & is.null(z)) { if (!(is.numeric(theta))) { stop("input must be matrix with 2 or 3 columns") } if (!(is.numeric (theta) & is.matrix (theta) & (ncol(theta) == 2 | ncol(theta) == 3))) { stop("matrix input must have 2 or 3 columns [THETA, R (, Z)]"); } if (ncol(theta) == 3) { z <- theta[,3] } r <- theta[,2] theta <- theta[,1] } else { if (is.null(z)) { if (!is.numeric (theta) | !is.numeric (r)) { stop("THETA, R must be numeric arrays of the same size, or scalar") } if ( !((length(theta) == length(r)) | (length(theta) == 1) | (length(r) == 1))) { stop("THETA, Y must be numeric arrays of the same size, or scalar") } } else { if (! is.numeric (theta) | ! is.numeric (r) | ! is.numeric (z)) { stop("THETA, R, Z must be numeric arrays of the same size, or scalar") } if ( !(((length(theta) == length(r)) | (length(theta) == 1) | (length(r) == 1)) & ((length(theta) == length(z)) | (length(theta) == 1) | (length(z) == 1)) & ((length(r) == length(z)) | (length(r) == 1) | (length(z) == 1)))) { stop("theta, r, z must be matrices of the same size, or scalar") } } } x <- r*cos(theta) y <- r*sin(theta) if (is.null(z)) { return(cbind(x=x, y=y)) } return(cbind(x=x, y=y, z=z)) } geometry/R/entry.value.R0000644000176200001440000000403113433536400014704 0ustar liggesusers##' Retrieve or set a list of array element values ##' ##' \code{entry.value} retrieves or sets the values in an array \code{a} at the ##' positions indicated by the rows of a matrix \code{idx}. ##' ##' ##' @aliases entry.value entry.value<- ##' @param a An array. ##' @param idx Numerical matrix with the same number of columns as the number ##' of dimensions of \code{a}. Each row indices a cell in \code{a} of which ##' the value is to be retrieved or set. ##' @param value An array of length \code{nrow(idx)}. ##' @return \code{entry.value(a,idx)} returns a vector of values at the ##' indicated cells. \code{entry.value(a,idx) <- val} changes the indicated ##' cells of \code{a} to \code{val}. ##' @author Raoul Grasman ##' @keywords arith math array ##' @examples ##' ##' a = array(1:(4^4),c(4,4,4,4)) ##' entry.value(a,cbind(1:4,1:4,1:4,1:4)) ##' entry.value(a,cbind(1:4,1:4,1:4,1:4)) <- 0 ##' ##' entry.value(a, as.matrix(expand.grid(1:4,1:4,1:4,1:4))) ##' # same as `c(a[1:4,1:4,1:4,1:4])' which is same as `c(a)' ##' ##' @export entry.value entry.value<- "entry.value" <- function (a, idx) { if (!is.array(a)) stop("First argument `", deparse(substitute(a)), "' should be an array.") if (!is.matrix(idx)) stop("Second argument `", substitute(idx), "' should be a matrix.") n <- length(dim(a)) if (n != ncol(idx)) stop("Number of columns in", deparse(substitute(idx)), "is incompatible is dimension of", deparse(substitute(a))) a[(idx - 1) %*% c(1, cumprod(dim(a))[-n]) + 1] } "entry.value<-" <- function (a, idx, value) { if (!is.array(a)) stop("First argument `", deparse(substitute(a)), "' should be an array.") if (!is.matrix(idx)) stop("Second argument `", substitute(idx), "' should be a matrix.") n <- length(dim(a)) if (n != ncol(idx)) stop("Number of columns in", deparse(substitute(idx)), "is incompatible is dimension of", deparse(substitute(a))) a[(idx - 1) %*% c(1, cumprod(dim(a))[-n]) + 1] <- value return(a) } geometry/R/tetramesh.R0000644000176200001440000000356414662314120014434 0ustar liggesusers##' \code{tetramesh(T, X, col)} uses the \link[rgl]{rgl} package to ##' display the tetrahedrons defined in the m-by-4 matrix T as mesh. ##' Each row of \code{T} specifies a tetrahedron by giving the 4 ##' indices of its points in \code{X}. ##' ##' @title Render tetrahedron mesh (3D) ##' @param T T is a \code{m}-by-3 matrix in trimesh and \code{m}-by-4 in ##' tetramesh. A row of \code{T} contains indices into \code{X} of the vertices ##' of a triangle/tetrahedron. \code{T} is usually the output of delaunayn. ##' @param X X is an n-by-2/n-by-3 matrix. The rows of X represent \code{n} ##' points in 2D/3D space. ##' @param col The tetrahedron colour. See rgl documentation for details. ##' @param clear Should the current rendering device be cleared? ##' @param \dots Parameters to the rendering device. See the \link[rgl]{rgl} ##' package. ##' @author Raoul Grasman ##' @seealso \code{\link{trimesh}}, \code{\link[rgl]{rgl}}, \code{\link{delaunayn}}, ##' \code{\link{convhulln}}, \code{\link{surf.tri}} ##' @keywords hplot ##' @examples ##' \dontrun{ ##' # example delaunayn ##' d = c(-1,1) ##' pc = as.matrix(rbind(expand.grid(d,d,d),0)) ##' tc = delaunayn(pc) ##' ##' # example tetramesh ##' clr = rep(1,3) %o% (1:nrow(tc)+1) ##' rgl::view3d(60,fov=20) ##' rgl::light3d(270,60) ##' tetramesh(tc,pc,alpha=0.7,col=clr) ##' } ##' @export tetramesh <- function (T, X, col = grDevices::heat.colors(nrow(T)), clear = TRUE, ...) { if(requireNamespace("rgl") == FALSE) stop("the rgl package is required for tetramesh") if (!is.numeric(T) | !is.numeric(T)) stop("`T' and `X' should both be numeric.") if (ncol(T) != 4) stop("Expect first arg `T' to have 4 columns.") if (ncol(X) != 3) stop("Expect second arg `X' to have 3 columns.") t = t(rbind(T[, -1], T[, -2], T[, -3], T[, -4])) if (clear) rgl::clear3d() rgl::triangles3d(X[t, 1], X[t, 2], X[t, 3], col = col, ...) } geometry/R/matmin.R0000644000176200001440000000033113432317337013721 0ustar liggesusers"matmin" <- function (...) { x = cbind(...) if(!is.numeric(x)) stop("Input should by numeric.") if (!is.matrix(drop(x))) x = t(x) x[1:nrow(x) + nrow(x) * (max.col(-x) - 1)] } geometry/R/inhulln.R0000644000176200001440000000261514227215261014110 0ustar liggesusers##' Test if points lie in convex hull ##' ##' Tests if a set of points lies within a convex hull, returning a ##' boolean vector in which each element is \code{TRUE} if the ##' corresponding point lies within the hull and \code{FALSE} if it ##' lies outwith the hull or on one of its facets. ##' ##' @param ch Convex hull produced using \code{\link{convhulln}} ##' @param p An \eqn{M}-by-\eqn{N} matrix of points to test. The rows ##' of \code{p} represent \eqn{M} points in \eqn{N}-dimensional ##' space. ##' @return A boolean vector with \eqn{M} elements ##' @author David Sterratt ##' @note \code{inhulln} was introduced in geometry 0.4.0, and is ##' still under development. It is worth checking results for ##' unexpected behaviour. ##' @seealso \code{\link{convhulln}}, \code{point.in.polygon} in \pkg{sp} ##' @export ##' @examples ##' p <- cbind(c(-1, -1, 1), c(-1, 1, -1)) ##' ch <- convhulln(p) ##' ## First point should be in the hull; last two outside ##' inhulln(ch, rbind(c(-0.5, -0.5), ##' c( 1 , 1), ##' c(10 , 0))) ##' ##' ## Test hypercube ##' p <- rbox(D=4, B=1) ##' ch <- convhulln(p) ##' tp <- cbind(seq(-1.9, 1.9, by=0.2), 0, 0, 0) ##' pin <- inhulln(ch, tp) ##' ## Points on x-axis should be in box only betw,een -1 and 1 ##' pin == (tp[,1] < 1 & tp[,1] > -1) inhulln <- function(ch, p) { return(.Call("C_inhulln", ch, p, PACKAGE="geometry")) } geometry/R/delaunayn.R0000644000176200001440000002052614664554667014445 0ustar liggesusers##' Delaunay triangulation in N dimensions ##' ##' The Delaunay triangulation is a tessellation of the convex hull of ##' the points such that no \eqn{N}-sphere defined by the \eqn{N}- ##' triangles contains any other points from the set. ##' ##' @param p An \eqn{M}-by-\eqn{N} matrix whose rows represent \eqn{M} ##' points in \eqn{N}-dimensional space. ##' ##' @param options String containing extra control options for the ##' underlying Qhull command; see the Qhull documentation ##' (\url{../doc/qhull/html/qdelaun.html}) for the available ##' options. ##' ##' The \code{Qbb} option is always passed to Qhull. The remaining ##' default options are \code{Qcc Qc Qt Qz} for \eqn{N<4} and ##' \code{Qcc Qc Qt Qx} for \eqn{N>=4}. If neither of the \code{QJ} ##' or \code{Qt} options are supplied, the \code{Qt} option is ##' passed to Qhull. The \code{Qt} option ensures all Delaunay ##' regions are simplical (e.g., triangles in 2D). See ##' \url{../doc/qhull/html/qdelaun.html} for more details. Contrary ##' to the Qhull documentation, no degenerate (zero area) regions ##' are returned with the \code{Qt} option since the R function ##' removes them from the triangulation. ##' ##' \emph{If \code{options} is specified, the default options are ##' overridden.} It is recommended to use \code{output.options} for ##' options controlling the outputs. ##' ##' @param output.options String containing Qhull options to control ##' output. Currently \code{Fn} (neighbours) and \code{Fa} (areas) ##' are supported. Causes an object of return value for details. If ##' \code{output.options} is \code{TRUE}, select all supported ##' options. ##' ##' @param full Deprecated and will be removed in a future release. ##' Adds options \code{Fa} and \code{Fn}. ##' ##' @return If \code{output.options} is \code{NULL} (the default), ##' return the Delaunay triangulation as a matrix with \eqn{M} rows ##' and \eqn{N+1} columns in which each row contains a set of ##' indices to the input points \code{p}. Thus each row describes a ##' simplex of dimension \eqn{N}, e.g. a triangle in 2D or a ##' tetrahedron in 3D. ##' ##' If the \code{output.options} argument is \code{TRUE} or is a ##' string containing \code{Fn} or \code{Fa}, return a list with ##' class \code{delaunayn} comprising the named elements: ##' \describe{ ##' \item{\code{tri}}{The Delaunay triangulation described above} ##' \item{\code{areas}}{If \code{TRUE} or if \code{Fa} is specified, an ##' \eqn{M}-dimensional vector containing the generalised area of ##' each simplex (e.g. in 2D the areas of triangles; in 3D the volumes ##' of tetrahedra). See \url{../doc/qhull/html/qh-optf.html#Fa}.} ##' \item{\code{neighbours}}{If \code{TRUE} or if \code{Fn} is specified, ##' a list of neighbours of each simplex. Note that a negative number ##' corresponds to "facet" (="edge" in 2D or "face" in 3D) that has no ##' neighbour, as will be the case for some simplices on the boundary ##' of the triangulation. ##' See \url{../doc/qhull/html/qh-optf.html#Fn}} ##' } ##' ##' @note This function interfaces the Qhull library and is a port ##' from Octave (\url{https://octave.org/}) to R. Qhull computes ##' convex hulls, Delaunay triangulations, halfspace intersections ##' about a point, Voronoi diagrams, furthest-site Delaunay ##' triangulations, and furthest-site Voronoi diagrams. It runs in ##' 2D, 3D, 4D, and higher dimensions. It implements the ##' Quickhull algorithm for computing the convex hull. Qhull handles ##' round-off errors from floating point arithmetic. It computes ##' volumes, surface areas, and approximations to the convex ##' hull. See the Qhull documentation included in this distribution ##' (the doc directory \url{../doc/qhull/index.html}). ##' ##' Qhull does not support constrained Delaunay triangulations, triangulation ##' of non-convex surfaces, mesh generation of non-convex objects, or ##' medium-sized inputs in 9D and higher. A rudimentary algorithm for mesh ##' generation in non-convex regions using Delaunay triangulation is ##' implemented in \link{distmesh2d} (currently only 2D). ##' @author Raoul Grasman and Robert B. Gramacy; based on the ##' corresponding Octave sources of Kai Habel. ##' @seealso \code{\link[interp]{tri.mesh}}, \code{\link{convhulln}}, ##' \code{\link{surf.tri}}, \code{\link{distmesh2d}} ##' @references \cite{Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., ##' \dQuote{The Quickhull algorithm for convex hulls,} \emph{ACM Trans. on ##' Mathematical Software,} Dec 1996.} ##' ##' \url{http://www.qhull.org} ##' @keywords math dplot graphs ##' @examples ##' ##' # example delaunayn ##' d <- c(-1,1) ##' pc <- as.matrix(rbind(expand.grid(d,d,d),0)) ##' tc <- delaunayn(pc) ##' ##' # example tetramesh ##' \dontrun{ ##' rgl::view3d(60) ##' rgl::light3d(120,60) ##' tetramesh(tc,pc, alpha=0.9) ##' } ##' ##' tc1 <- delaunayn(pc, output.options="Fa") ##' ## sum of generalised areas is total volume of cube ##' sum(tc1$areas) ##' ##' @export ##' @useDynLib geometry delaunayn <- function(p, options=NULL, output.options=NULL, full=FALSE) { tmp_stdout <- tempfile("Rf") tmp_stderr <- tempfile("Rf") on.exit(unlink(c(tmp_stdout, tmp_stderr))) ## Coerce the input to be matrix if (is.data.frame(p)) { p <- as.matrix(p) } ## Make sure we have real-valued input storage.mode(p) <- "double" ## We need to check for NAs in the input, as these will crash the C ## code. if (any(is.na(p))) { stop("The first argument should not contain any NAs") } ## Default options defult.options <- "Qt Qc Qx" if (ncol(p) < 4) { default.options <- "Qt Qc Qz" } if (is.null(options)) { options <- default.options } ## Combine and check options options <- tryCatch(qhull.options(options, output.options, supported_output.options <- c("Fa", "Fn"), full=full), error=function(e) {stop(e)}) ## It is essential that delaunayn is called with either the QJ or Qt ## option. Otherwise it may return a non-triangulated structure, i.e ## one with more than dim+1 points per structure, where dim is the ## dimension in which the points p reside. if (!grepl("Qt", options) & !grepl("QJ", options)) { options <- paste(options, "Qt") } out <- .Call("C_delaunayn", p, as.character(options), tmp_stdout, tmp_stderr, PACKAGE="geometry") ## Check for points missing from triangulation, but not in the case ## of a degenerate trianguation (zero rows in output) if (nrow(out$tri) > 0) { missing.points <- length(setdiff(seq(1,nrow(p)), unique(as.vector(out$tri)))) if (missing.points > 0) { warning(paste0(missing.points, " points missing from triangulation. It is possible that setting the 'options' argument of delaunayn may help. For example: options = \"", default.options, " Qbb\" options = \"", default.options, " QbB\" If these options do not work, try shifting the centre of the points to the origin by subtracting the mean coordinates from every point.")) } } # Remove NULL elements out[which(sapply(out, is.null))] <- NULL if (is.null(out$areas) & is.null(out$neighbours)) { attr(out$tri, "delaunayn") <- attr(out$tri, "delaunayn") return(out$tri) } class(out) <- "delaunayn" out$p <- p return(out) } ##' @importFrom graphics plot ##' @method plot delaunayn ##' @export plot.delaunayn <- function(x, y, ...) { if (ncol(x$p) < 2 || ncol(x$p) > 3) stop("Only 2D and 3D convhullns can be plotted") args <- list(...) add <- FALSE if ("add" %in% names(args)) { add <- args$add args$add <- NULL } if (ncol(x$p) == 2) { if (!add) { plot(x$p[,1], x$p[,2], ...) } m <- Unique(rbind(x$tri[,1:2], x$tri[,2:3], x$tri[,c(1,3)])) p <- x$p do.call(segments, c(list(p[m[,1],1],p[m[,1],2],p[m[,2],1],p[m[,2],2]), args)) } if (ncol(x$p) == 3) { do.call(tetramesh, c(list(x$tri, x$p), args)) } } ## LocalWords: param Qhull Fn delaunayn Qbb Qcc Qc Qz Qx QJ itemize ## LocalWords: tri Voronoi Quickhull distmesh Grasman Gramacy Kai ## LocalWords: Habel seealso interp convhulln Dobkin Huhdanpaa ACM ## LocalWords: dQuote emph dplot pc tc tetramesh dontrun useDynLib # LocalWords: eqn url math tmp stdout tempfile stderr unlink NAs na # LocalWords: tryCatch qhull grepl sapply attr importFrom convhullns # LocalWords: args rbind geometry/demo/0000755000176200001440000000000013430240556013033 5ustar liggesusersgeometry/demo/00Index0000644000176200001440000000007713300625475014174 0ustar liggesusersintersectn Demonstration of intersection of 2D convex hulls geometry/demo/intersectn.R0000644000176200001440000000135313430240556015336 0ustar liggesuserslibrary(geometry) ## 2D example ps1 <- rbind(c(0, sqrt(3)), c(3/2, -sqrt(3)/2), c(-3/2, -sqrt(3)/2)) ps2 <- ps1 ps2[,2] <- -ps2[,2] is <- intersectn(ps1, ps2) plot(is, asp=1) ## 3D example ps1a <- rbox(2, C=0.5) dt1a <- delaunayn(ps1a) ps1b <- rbox(2, C=0.5) + 2 dt1b <- delaunayn(ps1b) ps1 <- rbind(ps1a, ps1b) dt1 <- rbind(dt1a, dt1b + nrow(ps1a)) tetramesh(dt1, ps1, alpha=0.5, col="yellow") ps2 <- rbox(2, C=0.5) + 0.5 dt2 <- delaunayn(ps2) tetramesh(dt2, ps2, alpha=0.5, col="red", clear=FALSE) vol <- 0 for (i in 1:nrow(dt1)) { for (j in 1:nrow(dt2)) { is <- intersectn(ps1[dt1[i,],], ps2[dt2[j,],]) vol <- vol + is$ch$vol } } message(paste("Volume of overlap should be 0.125. It is:", vol)) geometry/NEWS0000644000176200001440000005054014751717775012635 0ustar liggesusersCHANGES IN VERSION 0.5.2 - Released 2025/02/08 BUG FIX * Issue #75: More sanitiser issues https://github.com/davidcsterratt/geometry/issues/76 This update resolves another issue with memory sanitisation observed when compiling in an UBSAN environment. Thanks to Brian Ripley for running the tests and reporting the error, and Tomas Kalibera for suggesting and testing the fix. CHANGES IN VERSION 0.5.1 - Released 2025/01/09 BUG FIX * Issue #75: Sanitiser issues https://github.com/davidcsterratt/geometry/issues/75 This update resolves issues with memory sanitisation observed when compiling in an UBSAN environment. Thanks to Brian Ripley for running the tests and reporting the error, and Tomas Kalibera for providing the fix. CHANGES IN VERSION 0.5.0 - Released 2024/08/31 CODE IMPROVEMENTS * Issue #37: Incorporate Qhull 8.0.2 https://github.com/davidcsterratt/geometry/issues/37 This update of Qhull resolves or addresses a number of issues (#11, #12) relating to points spanning a small distance compared to their mean distance to the origin MINOR API CHANGE * Issue #12: QH6227 impossible to triangulate a dataset far from the origin https://github.com/davidcsterratt/geometry/issues/12 This particular error was fixed by the fix for #37, but some points were still missing from the triangulation, when the points are far from the origin. Delaunayn now throws a warning about points missing from the triangulation, and suggests passing options to deluanayn that may help, or centering the input data before passing it to delaunayn. Thanks to Jean-Romain the orignal report, and C. B. Barber for extensive advice on Qhull. BUG FIXES * Fix for Issue #71: noRemap CRAN chack https://github.com/davidcsterratt/geometry/issues/71 Thanks to the CRAN maintainers for reporting this and Jean-Romain Roussel for providing the fix. * Fix for Issue #11: Wrong triangulation for a specific dataset https://github.com/davidcsterratt/geometry/issues/11 Thanks to Jean-Romain the report and C. B. Barber for help debugging * Fix for Issues #57 and #46: tsearch fails on points far from the origin https://github.com/davidcsterratt/geometry/issues/57 https://github.com/davidcsterratt/geometry/issues/46 Thanks to Wayne Jones for the report and Jean-Romain for the fix * Issue #58: convhulln() receives QH6271 qhull precision error https://github.com/davidcsterratt/geometry/issues/58 convhulln() now issues advice about options to avoid this error. Thanks to GitHub user Huangmp1996 for the report CHANGES IN VERSION 0.4.7 - Released 2023/02/03 BUG FIXES * Fix for Issue #67: Compiled code should not call sprintf() https://github.com/davidcsterratt/geometry/issues/67 Thanks to the CRAN maintainers for reporting this. Update uses snprintf() function. * PR #64: Replace rgl.* with *3d https://github.com/davidcsterratt/geometry/pull/64 Thanks to Duncan Murdoch for replacing rgl.* functions with *3d functions * Issue #60: Negative neighbour IDs reported by delaunayn https://github.com/davidcsterratt/geometry/issues/60 Provide documentation to explain that the Qhull "Fn" option returns negative IDs. API CHANGE * Issue #29: Make behaviour of convhulln() and delaunayn() more consistent https://github.com/davidcsterratt/geometry/issues/29 Issue message to indicate full option to delaunayn is dprecated NEW FEATURE * Issue #29: Make behaviour of convhulln() and delaunayn() more consistent https://github.com/davidcsterratt/geometry/issues/29 plot.delaunayn() to plot triangulations CHANGES IN VERSION 0.4.6.1 - Released 2022/07/04 BUG FIXES * Fix for Issue #66: Replace the tripack package with the interp package https://github.com/davidcsterratt/geometry/issues/66 The Thanks to the CRAN maintainers for replacing references to the suggested tripack package with interp CHANGES IN VERSION 0.4.6 - Released 2022/04/18 BUG FIXES * PR #49: Update tests for testthat v3 compatibility https://github.com/davidcsterratt/geometry/pull/49 Thanks to Hugo Gruson for providing the pull request * PR #50: Reorder documentation lines https://github.com/davidcsterratt/geometry/pull/50 Thanks to Hugo Gruson for providing the pull request * PR #54: Fix typo https://github.com/davidcsterratt/geometry/pull/54 Thanks to Hugh Gruson for providing the pull request OTHER CHANGES * Fix for Issue #61: Legacy macros need replaced https://github.com/davidcsterratt/geometry/issues/61 Thanks to the Brian Ripley and the CRAN team for the alert CHANGES IN VERSION 0.4.5 - Released 2019/12/02 BUG FIX * Fix for Issue #47: Install failure with gcc 10 https://github.com/davidcsterratt/geometry/issues/47 Thanks to Brian Ripley for pointing this out CHANGES IN VERSION 0.4.4 - Released 2019/08/27 BUG FIX * Fix for Issue #45: LTO error https://github.com/davidcsterratt/retistruct/issues/45 Thanks to Brian Ripley for pointing this out and providing the fix CHANGES IN VERSION 0.4.3 - Released 2019/08/21 BUG FIXES * Fix for Issue #39: tsearchn() returns NA for some points within triangle https://github.com/davidcsterratt/geometry/issues/39 tsearchn() failed (=return NA) for some points that lie within the triangulation. Thanks to Jan Lause (https://github.com/jlause) for reporting the bug and Jean-Romain Roussel for providing the fix. * Fix for Issue #40: memory misuse in src/Rtsearchn.c https://github.com/davidcsterratt/geometry/issues/40 In src/Rtsearchn.c 'idmap' was allocated with max_facet_id elements but then a value to idmap[max_facet_id] was assigned, which was one element beyond the end of that allocation, potentially clobbering the memory allocation system. Thanks to Bill Dunlap (https://github.com/BillDunlap) for reporting this, and the suggested fix. * Fix for Issue #44: R_tmpnam()/free() causes crash in TERR https://github.com/davidcsterratt/geometry/issues/44 Because TERR (https://docs.tibco.com/products/tibco-enterprise-runtime-for-r) is not compiled with gcc (it uses either the Intel or Microsoft C++ compiler) on Windows, calling free() in a package's DLL for memory allocated with malloc() in TERR's own DLL causes a crash. The R API function R_tmpnam() causes this problem in the geometry package. Thanks to Bill Dunlap (https://github.com/BillDunlap) for reporting this, and the suggested fix. ENHANCEMENT * Fix for Issue #42: Improve error reporting from Qhull https://github.com/davidcsterratt/geometry/issues/42 Full error from Qhull is now returned, rather than just the first two lines. CHANGES IN VERSION 0.4.2 - Released 2019/07/05 BUG FIX * Fix for Issue #35: intersectn() reports zero volume for some overlapping 4D hulls https://github.com/davidcsterratt/geometry/issues/35 intersectn() failed on a particular example. Modifying the scale option given to lpSolve::lp in feasible.point() has fixed this problem. feasible.point() also now returns the lpSolve::lp() error message when it fails, rather than failing silently as before. Thanks to Maxime Logez for reporting the bug and Sam Buttrey, lpSolve maintainer, for insights into lpSolve. CHANGES IN VERSION 0.4.1 - Released 2019/03/27 BUG FIXES * Fix for Issue #34: intersectn() fails when overlapping region is not in positive quadrant https://github.com/davidcsterratt/geometry/issues/34 intersectn() would return no intersecting hull for input hulls whose overlapping region did not overlap with the postive quadrant (i.e. the region where all coordinates are non-negative). Thanks to Maxime Logez for reporting the bug. * Fix for Issue #33: nonsensical results from intersectn() in 4D https://github.com/davidcsterratt/geometry/issues/33 intersectn() gave demonstrably wrong results in some cases. This was Because of some heuristic (non-Qhull) code in halfspacen which was designed to get round cases in which Qhull fails with options "Tv" because the hull is very narrow. The solution is to remove the heuristic method, and also to fix Issue #34 (above). Before Issue #34 was fixed, it was found that adding the "QJ" option could also help, and this is now suggested in the error message about narrow hulls. Thanks to Maxime Logez for reporting the bug and supplying a reproducible example, now included in tests. CHANGES IN VERSION 0.4.0 - Released 2019/02/18 LICENSE CHANGES * Following requests by the CRAN maintainers and disucssion on the r-package-devel email list, the entire package is now released under GPL (>= 3). https://github.com/davidcsterratt/geometry/issues/27 API CHANGES * Default options to delaunayn have been changed https://github.com/davidcsterratt/geometry/issues/4 The Qc and Qz or Qx options have been added as defaults, making the default options "Qbb Qc Qt Qz" for 3 dimensions or less and "Qbb Qc Qt Qx" for 4 or more dimensions. This brings the R implementation into line with Octave, and very similar to matlab and scipy.spatial.Delaunayn . * New argument "output.options" for convhulln() and delaunayn(). https://github.com/davidcsterratt/geometry/issues/29 Qhull options which affect output should be put in this string, e.g. delaunayn(ps, output.options="Fn Fa") * The "full" option to delaunayn() is deprecated https://github.com/davidcsterratt/geometry/issues/29 Use output.options=TRUE instead. In geometry 0.4.0 using "full" does not give a message or warning; this will happen in future versions * distmesh2d() has a plot option https://github.com/davidcsterratt/geometry/issues/15 The new plot option (TRUE by default) allows plotting to during mesh generation to be suspended, which is useful for running tests. The use of cat() has been replaced by message(), meaning messages can be supressed, for example during tests. * extprod3d() has a "drop" option https://github.com/davidcsterratt/geometry/issues/16 Setting drop=FALSE guarantees that the output of extprod3d() is an array rather than a vector, even when presented with two vectors. NEW FUNCTIONS * New function inhulln() to test if points are in a hull https://github.com/davidcsterratt/geometry/issues/1 * New function halfspacen() to compute intersection points of halfspaces about an interior point https://github.com/davidcsterratt/geometry/issues/25 * New function intersectn() to compute intersection of convex hulls of two sets of points https://github.com/davidcsterratt/geometry/issues/26 * Functions cart2sph, sph2cart, cart2pol, pol2cart ported from Octave https://github.com/davidcsterratt/geometry/issues/14 NEW FEATURES * convhulln() can produce non-triangulated output https://github.com/davidcsterratt/geometry/issues/22 Thanks to Pavlo Mozharovskyi for pushing code to achive this * delaunayn() and convhulln() throw Qhull error messages when Qhull fails https://github.com/davidcsterratt/geometry/issues/28 BUG FIXES * Fix for Issue #6072: distmesh2d - convergence problem (https://r-forge.r-project.org/tracker/?func=detail&atid=4552&aid=6072&group_id=1149) Some parts of the original Matlab implementation of distmesh2d were omitted during the translation to R. The effect is not obvious on some problems, except for long convergence times due to excessive iterations - some do not converge at all. Graham Griffiths made changes to the code which appears to have fixed the problem as example problems now appear to run significantly faster - even faster than those I have run using Matlab. Graham's example code is now included in a test. Thanks to Graham Griffiths for reporting this problem and supplying the fix. * Fix for Issue #30: Move qhull docs to vignettes https://github.com/davidcsterratt/geometry/issues/30 This is a change in response to the way R deals with inst/doc, which broke the included Qhull docs. CODE IMPROVEMENTS * The 2D tsearch C code has been replaced by a much more efficient QuadTree algorithm written in C++ by Jean-Romain Roussel. The speedup with uniformly distribued mesh points and search points is of the order of 40x. Many thanks to Jean-Romain for the contribution. https://github.com/davidcsterratt/geometry/issues/9 https://github.com/davidcsterratt/geometry/pull/8 * The new reentrant Qhull library (current version v7.2.1) is used, as a precursor to allowing Qhull objects to be returned and operated on https://github.com/davidcsterratt/geometry/issues/3 * convhulln() now returns a pointer to the qhull object representing the hull. https://github.com/davidcsterratt/geometry/issues/2 This is used in the inhull() implementation * delaunayn() now returns a pointer to the qhull object representing the triangulation https://github.com/davidcsterratt/geometry/issues/7 * tsearchn() can take an delaunay object, which should give fast performance https://github.com/davidcsterratt/geometry/issues/6 NOTE: This feature is experimental and has only been tested on 3D triangulations * Test added for polyarea() Thanks to Toby Hocking for suggesting adding one CHANGES IN VERSION 0.3-6 - Released 2015/09/04 CODE IMPROVEMENTS * As per CRAN policies, the title in the DESCRIPTION file is now in title case. BUG FIXES * Fix for Issue #5738: segfault when run from directory lacking write permission (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=5738&group_id=1149&atid=4552) Using "." as a temporary directory can cause problems if it is not writeable. Now the geometry package uses tempdir(), which R should guarantee to exist. Thanks to Laura Riggi for reporting this problem. * Put Robert B. Gramacy back in the author list, after he was accidentally omitted when changing to the Authors@R format on 2014/10/29 (version 0.3-5). Thanks to Robert B. Gramacy for reporting this, and apologies for the error. CHANGES IN VERSION 0.3-5 - Released 2014/11/06 API CHANGES * The default Qhull option to the delaunayn() function is now "Qt" rather than "QJ" and degenerate (zero-area) simplices are removed from the triangulation, so that all simplicies are non-degenerate. This is a follow-up to issue #2009: delaunayn can return degenerate simplicies by default (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1993&group_id=1149&atid=4552). Thanks to Rolf Turner for alerting me to the issue. * delaunayn() now throws an error if the number of points is less than the number of dimensions + 1. FEATURES * delaunayn() with the "full" option also returns the areas of facets. This is a byproduct of the API change above. BUG FIXES * Fix for Issue #2789: inline functions min/max generate linker error (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=2789&group_id=1149&atid=4552) Thanks to Bernd Bischl for reporting the problem and suggesting the fix. * Partial Fix for Issue #5738: segfault when run from directory lacking write permission (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=5738&group_id=1149&atid=4552) An error is now thrown, rather than a segfault. The underlying problem still needs to be dealth with. DOCUMENTATION IMPROVEMENTS * The meanings of "area" and "vol" in the convhulln return value have been clarified. Thanks to Michael Cole for raising the issue. * The documentation of "cart2bary" and "bary2cart" has been corrected and improved. Thanks to Francisco Mendoza Torres for raising the issue. * HTML documentation has been for validation errors with HTML tidy. Thanks to Kurt Hornik and the CRAN maintainers for alerting me to the problem. CODE IMPROVEMENTS * Tests are now all done using the testthat framework. * There is now a test to make sure output to file works. Thanks to Brian Ripley for identifying the problem while testing the pacakge for CRAN. CHANGES IN VERSION 0.3-4 - Released 2014/03/04 BUG FIXES * Fix for Issue #5406: Compilation flags in Makevars (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=5406&group_id=1149&atid=4552) Thanks to Kurt Hornik and the CRAN maintainers for alerting me to the problem. CHANGES IN VERSION 0.3-3 - Released 2013/04/18 BUG FIXES * The License has been changed to GPL (>= 3) + file LICENSE and the LICENSE file made clearer. Thanks to Kurt Hornik and the CRAN maintainers for alerting me to the problem and helping with a solution. * Fix for Issue #1993: Error in solve.default in tsearchn (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1993&group_id=1149&atid=4552) Thanks to Bill Denny for reporting this and suggesting a way forward with a fix. Thanks to John Drake for alerting me to the recurrence of the problem and Jon Clayden on the R-devel list for pointing out the correct way of testing for ill-conditioned matrices. * Fix for Issue #2009: delaunayn can return degenerate simplicies by default (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1993&group_id=1149&atid=4552) This is a follow-on of #1993, so thanks to Bill Denny for highlighting the issue. * Fix for Issue #2007: Qt option given to Qhull (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=2007&group_id=1149&atid=4552) * The use of the multicore package in tests has been replaced by use of the parallel package. Thanks to Kurk Hornik for pointing this out. * Removed non-API call to R_TempDir. Thanks to Kurk Hornik for pointing this out. CHANGES IN VERSION 0.3-2 - Released 2012/05/12 BUG FIXES * Fix for Issue #1968: convhulln crash with T0 option (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1968&group_id=1149&atid=4552) Thanks to Thomas Kirschstein, Oskar Knapik and Uwe Ligges for reporting this and to Duncan Murdoch for help on the r-devel mailing list. * Fix for Issue #1983: NA in an input to delaunayn crashes R (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1983&group_id=1149&atid=4552) Thanks to Bill Denny for reporting this and suggestiong a way forward with a fix. CHANGES IN VERSION 0.3-1 - Released 2012/05/01 BUG FIXES * Fix for Issue #1964: R crashes when using convhulln/delaunayn (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1964&group_id=1149&atid=4552). Thanks to Thomas Kirschstein, Oskar Knapik and Paolo Piras for reporting this. CHANGES IN VERSION 0.3-0 - Released 2012/04/17 NEW FEATURES * New function dot() to compute dot product. Syntax is shared with Octave dot() function. * New function polyarea() to compute area of polygons. Syntax is shared with Octave polyarea() function. BUG FIXES * Fix for Issue #1578: convhulln crashes when running 2 instances of R in the same directory: output to qhull_out.txt removed (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1578&group_id=1149&atid=4552). Thanks to Francois Rousset and Bernd Bischl for reporting this. * Fix for Issue #1923: Compilation on Windows 64 doesn't work (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1923&group_id=1149&atid=4552) * Fix for Issue #1924: Silent operation is not supported (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1924&group_id=1149&atid=4552) Thanks to Raphael Leblois for reporting this. * Fix for Issue #1930: delaunayn should always return a matrix (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1930&group_id=1149&atid=4552) * Fix for Issue #1915: geometry segfaults during tests (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1915&group_id=1149&atid=4552) * Fix for Issue #1947: convhulln crash when Qhull error reported (https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1947&group_id=1149&atid=4552). Thanks to Petr Savicky for reporting this. OTHER CHANGES * Updated to qhull version 2011.2. * The default qhull option "QJ" for delaunayn() has been replaced by "Qt". One or other option is always provided to the qhull code (see https://r-forge.r-project.org/tracker/index.php?func=detail&aid=1915&group_id=1149&atid=4552). * Documentation improvements. * Added some tests. CHANGES IN VERSION 0.2-0 - Released 2011/09/09 NEW FEATURES * The tsearch and tsearchn functions have been ported from Octave. These functions have the same syntax as the Octave versions, though it also possible to get tsearch to output barycentric coordinates. tsearch only works for 2D simplexes (i.e. triangles), but is fast because it is written in C. By default, tsearchn uses the fast tsearch function when presented with 2D data. NEW MAINTAINER * David Sterratt has taken over from Bobby Gramacy. Thank-you to Bobby for his work on the package. geometry/vignettes/0000755000176200001440000000000014751720222014117 5ustar liggesusersgeometry/vignettes/qhull-eg.Rnw0000644000176200001440000000603313431000557016323 0ustar liggesusers%\VignetteIndexEntry{Qhull examples} \documentclass{article} \usepackage{Sweave} \SweaveOpts{echo=TRUE} \usepackage{hyperref} \usepackage[british]{babel} \title{Qhull examples} \author{David C. Sterratt} \begin{document} \maketitle This document presents examples of the \texttt{geometry} package functions which implement functions using the \href{http://www.qhull.org}{Qhull library}. \section{Convex hulls in 2D} \label{qhull-eg:sec:convex-hull-2d} \subsection{Calling \texttt{convhulln} with one argument} \label{qhull-eg:sec:call-convh-with} With one argument, convhulln returns the indices of the points of the convex hull. <<>>= library(geometry) ps <-matrix(rnorm(30), , 2) ch <- convhulln(ps) head(ch) @ \subsection{Calling \texttt{convhulln} with \texttt{options}} \label{qhull-eg:sec:call-convh-with} We can supply Qhull options to \texttt{convhulln}; in this case it returns an object of class \texttt{convhulln} which is also a list. For example \texttt{FA} returns the generalised \texttt{area} and \texttt{vol}ume. Confusingly in 2D the generalised area is the length of the perimeter, and the generalised volume is the area. <<>>= ps <-matrix(rnorm(30), , 2) ch <- convhulln(ps, options="FA") print(ch$area) print(ch$vol) @ A \texttt{convhulln} object can also be plotted. <>= plot(ch) @ We can also find the normals to the ``facets'' of the convex hull: <<>>= ch <- convhulln(ps, options="n") head(ch$normals) @ Here the first two columns and the $x$ and $y$ direction of the normal, and the third column defines the position at which the face intersects that normal. \subsection{Testing if points are inside a convex hull with \texttt{inhulln}} \label{qhull-eg:sec:testing-if-points} The function \texttt{inhulln} can be used to test if points are inside a convex hull. Here the function \texttt{rbox} is a handy way to create points at random locations. <>= tp <- rbox(n=200, D=2, B=4) in_ch <- inhulln(ch, tp) plot(tp[!in_ch,], col="gray") points(tp[in_ch,], col="red") plot(ch, add=TRUE) @ \section{Delaunay triangulation in 2D} \label{qhull-eg:sec:dela-triang-2d} \subsection{Calling \texttt{delaunayn} with one argument} \label{qhull-eg:sec:call-delaunayn-with} With one argument, a set of points, \texttt{delaunayn} returns the indices of the points at each vertex of each triangle in the triangulation. <>= ps <- rbox(n=10, D=2) dt <- delaunayn(ps) head(dt) trimesh(dt, ps) points(ps) @ \subsection{Calling \texttt{delaunayn} with \texttt{options}} \label{qhull-eg:sec:call-dela-with} We can supply Qhull options to \texttt{delaunayn}; in this case it returns an object of class \texttt{delaunayn} which is also a list. For example \texttt{Fa} returns the generalised \texttt{area} of each triangle. In 2D the generalised area is the actual area; in 3D it would be the volume. <<>>= dt2 <- delaunayn(ps, options="Fa") print(dt2$areas) dt2 <- delaunayn(ps, options="Fn") print(dt2$neighbours) @ \end{document} % LocalWords: Qhull convhulln ps rnorm ume inhulln rbox tp gray dt % LocalWords: delaunayn trimesh Fn geometry/vignettes/qhull/0000755000176200001440000000000014751753072015255 5ustar liggesusersgeometry/vignettes/qhull/REGISTER.txt0000644000176200001440000000167613431000556017236 0ustar liggesusersDear Qhull User We would like to find out how you are using our software. Think of Qhull as a new kind of shareware: you share your science and successes with us, and we share our software and support with you. If you use Qhull, please send us a note telling us what you are doing with it. We need to know: (1) What you are working on - an abstract of your work would be fine. (2) How Qhull has helped you, for example, by increasing your productivity or allowing you to do things you could not do before. If Qhull had a direct bearing on your work, please tell us about this. We encourage you to cite Qhull in your publications. To cite Qhull, please use Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., "The Quickhull algorithm for convex hulls," ACM Trans. on Mathematical Software, 22(4):469-483, Dec 1996, http://www.qhull.org. Please send e-mail to bradb@shore.net Thank you! geometry/vignettes/qhull/File_id.diz0000644000176200001440000000063113431000556017302 0ustar liggesusersQhull 2015.2 - Qhull computes convex hulls, Delaunay triangulations, halfspace inter- sections about a point, Voronoi diagrams, furthest-site Delaunay triangulations, and furthest-site Voronoi diagrams. Qhull works with 2-d, 3-d, 4-d, 5-d, and higher dimensions. It computes volumes, surface areas, and approximations. It runs in a command window under Windows 95/NT/XP/7. www.qhull.org, freeware. geometry/vignettes/qhull/README.txt0000644000176200001440000005253113431000556016743 0ustar liggesusersName qhull, rbox 2015.2 2016/01/18 Convex hull, Delaunay triangulation, Voronoi diagrams, Halfspace intersection Documentation: html/index.htm Available from: (git@github.com:qhull/qhull.git) News and a paper: Version 1 (simplicial only): Purpose Qhull is a general dimension convex hull program that reads a set of points from stdin, and outputs the smallest convex set that contains the points to stdout. It also generates Delaunay triangulations, Voronoi diagrams, furthest-site Voronoi diagrams, and halfspace intersections about a point. Rbox is a useful tool in generating input for Qhull; it generates hypercubes, diamonds, cones, circles, simplices, spirals, lattices, and random points. Qhull produces graphical output for Geomview. This helps with understanding the output. Environment requirements Qhull and rbox should run on all 32-bit and 64-bit computers. Use an ANSI C or C++ compiler to compile the program. The software is self-contained. It comes with examples and test scripts. Qhull's C++ interface uses the STL. The C++ test program uses QTestLib from the Qt Framework. Qhull's C++ interface may change without notice. Eventually, it will move into the qhull shared library. Qhull is copyrighted software. Please read COPYING.txt and REGISTER.txt before using or distributing Qhull. To cite Qhull, please use Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., "The Quickhull algorithm for convex hulls," ACM Trans. on Mathematical Software, 22(4):469-483, Dec 1996, http://www.qhull.org. To modify Qhull, particularly the C++ interface Qhull is on GitHub (http://github.com/qhull/qhull, git@github.com:qhull/qhull.git) For internal documentation, see html/qh-code.htm To install Qhull Qhull is precompiled for Windows 32-bit, otherwise it needs compilation. Qhull includes Makefiles for gcc and other targets, CMakeLists.txt for CMake, .sln/.vcproj/.vcxproj files for Microsoft Visual Studio, and .pro files for Qt Creator. It compiles under Windows with mingw. Install and build instructions follow. See the end of this document for a list of distributed files. ----------------- Installing Qhull on Windows 10, 8, 7 (32- or 64-bit), Windows XP, and Windows NT The zip file contains rbox.exe, qhull.exe, qconvex.exe, qdelaunay.exe, qhalf.exe, qvoronoi.exe, testqset.exe, user_eg*.exe, documentation files, and source files. Qhull.exe and user-eg3.exe are compiled with the reentrant library while the other executables use the non-reentrant library. To install Qhull: - Unzip the files into a directory (e.g., named 'qhull') - Click on QHULL-GO or open a command window into Qhull's bin directory. - Test with 'rbox D4 | qhull' To uninstall Qhull - Delete the qhull directory To learn about Qhull: - Execute 'qconvex' for a synopsis and examples. - Execute 'rbox 10 | qconvex' to compute the convex hull of 10 random points. - Execute 'rbox 10 | qconvex i TO file' to write results to 'file'. - Browse the documentation: qhull\html\index.htm - If an error occurs, Windows sends the error to stdout instead of stderr. Use 'TO xxx' to send normal output to xxx To improve the command window - Double-click the window bar to increase the size of the window - Right-click the window bar - Select Properties - Check QuickEdit Mode Select text with right-click or Enter Paste text with right-click - Change Font to Lucinda Console - Change Layout to Screen Buffer Height 999, Window Size Height 55 - Change Colors to Screen Background White, Screen Text Black - Click OK - Select 'Modify shortcut that started this window', then OK If you use qhull a lot, install a bash shell such as MSYS (www.mingw.org/wiki/msys), Road Bash (www.qhull.org/bash), or Cygwin (www.cygwin.com). ----------------- Installing Qhull on Unix with gcc To build Qhull, static libraries, shared library, and C++ interface - Download and extract Qhull (either GitHub, .tgz file, or .zip file) - make - export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH The Makefiles may be edited for other compilers. If 'testqset' exits with an error, qhull is broken A simple Makefile for Qhull is in src/libqhull and src/libqhull_r. To build the Qhull executables and libqhullstatic - Extract Qhull from qhull...tgz or qhull...zip - cd src/libqhull_r # cd src/libqhull - make ----------------- Installing Qhull with CMake 2.6 or later See CMakeLists.txt for examples and further build instructions To build Qhull, static libraries, shared library, and C++ interface - Download and extract Qhull (either GitHub, .tgz file, or .zip file) - cd build - cmake --help # List build generators - make -G "" .. && cmake .. - cmake .. - make - make install The ".." is important. It refers to the parent directory (i.e., qhull/) On Windows, CMake installs to C:/Program Files/qhull. 64-bit generators have a "Win64" tag. If creating a qhull package, please include a pkg-config file based on build/qhull*.pc.in If cmake fails with "No CMAKE_C_COMPILER could be found" - cmake was not able to find the build environment specified by -G "..." ----------------- Installing Qhull with Qt To build Qhull, including its C++ test (qhulltest) - Download and extract Qhull (either GitHub, .tgz file, or .zip file) - Load src/qhull-all.pro into QtCreator - Build ------------------- Working with Qhull's C++ interface See html/qh-code.htm#cpp for calling Qhull from C++ programs See html/qh-code.htm#reentrant for converting from Qhull-2012 Examples of using the C++ interface user_eg3_r.cpp qhulltest/*_test.cpp Qhull's C++ interface is likely to change. Stay current with GitHub. To clone Qhull's next branch from http://github.com/qhull/qhull git init git clone git@github.com:qhull/qhull.git cd qhull git checkout next ... git pull origin next Compile qhullcpp and libqhullstatic_r with the same compiler. Both libraries use the C routines setjmp() and longjmp() for error handling. They must be compiled with the same compiler. ------------------- Calling Qhull from C programs See html/qh-code.htm#library for calling Qhull from C programs See html/qh-code.htm#reentrant for converting from Qhull-2012 Warning: You will need to understand Qhull's data structures and read the code. Most users will find it easier to call Qhull as an external command. The new, reentrant 'C' code (src/libqhull_r), passes a pointer to qhT to most Qhull routines. This allows multiple instances of Qhull to run at the same time. It simplifies the C++ interface. The non-reentrant 'C' code (src/libqhull) looks unusual. It refers to Qhull's global data structure, qhT, through a 'qh' macro (e.g., 'qh ferr'). This allows the same code to use static memory or heap memory. If qh_QHpointer is defined, qh_qh is a pointer to an allocated qhT; otherwise qh_qh is a global static data structure of type qhT. ------------------ Compiling Qhull with Microsoft Visual C++ To compile 32-bit Qhull with Microsoft Visual C++ 2010 and later - Download and extract Qhull (either GitHub, .tgz file, or .zip file) - Load solution build/qhull-32.sln - Build target 'Win32' - Project qhulltest requires Qt for DevStudio (http://www.qt.io) Set the QTDIR environment variable to your Qt directory (e.g., c:/qt/5.2.0/5.2.0/msvc2012) If QTDIR is incorrect, precompile will fail with 'Can not locate the file specified' To compile 64-bit Qhull with Microsoft Visual C++ 2010 and later - 64-bit Qhull has larger data structures due to 64-bit pointers - Download and extract Qhull (either GitHub, .tgz file, or .zip file) - Load solution build/qhull-64.sln - Build target 'Win32' - Project qhulltest requires Qt for DevStudio (http://www.qt.io) Set the QTDIR environment variable to your Qt directory (e.g., c:/qt/5.2.0/5.2.0/msvc2012_64) If QTDIR is incorrect, precompile will fail with 'Can not locate the file specified' To compile Qhull with Microsoft Visual C++ 2005 (vcproj files) - Download and extract Qhull (either GitHub, .tgz file, or .zip file) - Load solution build/qhull.sln - Build target 'win32' (not 'x64') - Project qhulltest requires Qt for DevStudio (http://www.qt.io) Set the QTDIR environment variable to your Qt directory (e.g., c:/qt/4.7.4) If QTDIR is incorrect, precompile will fail with 'Can not locate the file specified' ----------------- Compiling Qhull with Qt Creator Qt (http://www.qt.io) is a C++ framework for Windows, Linux, and Macintosh Qhull uses QTestLib to test qhull's C++ interface (see src/qhulltest/) To compile Qhull with Qt Creator - Download and extract Qhull (either GitHub, .tgz file, or .zip file) - Download the Qt SDK - Start Qt Creator - Load src/qhull-all.pro - Build ----------------- Compiling Qhull with mingw on Windows To compile Qhull with MINGW - Download and extract Qhull (either GitHub, .tgz file, or .zip file) - Install Road Bash (http://www.qhull.org/bash) or install MSYS (http://www.mingw.org/wiki/msys) - Install MINGW-w64 (http://sourceforge.net/projects/mingw-w64). Mingw is included with Qt SDK. - make ----------------- Compiling Qhull with cygwin on Windows To compile Qhull with cygwin - Download and extract Qhull (either GitHub, .tgz file, or .zip file) - Install cygwin (http://www.cygwin.com) - Include packages for gcc, make, ar, and ln - make ----------------- Compiling from Makfile without gcc The file, qhull-src.tgz, contains documentation and source files for qhull and rbox. To unpack the tgz file - tar zxf qhull-src.tgz - cd qhull - Use qhull/Makefile Simpler Makefiles are qhull/src/libqhull/Makefile and qhull/src/libqhull_r/Makefile Compiling qhull and rbox with Makefile - in Makefile, check the CC, CCOPTS1, PRINTMAN, and PRINTC defines - the defaults are gcc and enscript - CCOPTS1 should include the ANSI flag. It defines __STDC__ - in user.h, check the definitions of qh_SECticks and qh_CPUclock. - use '#define qh_CLOCKtype 2' for timing runs longer than 1 hour - type: make - this builds: qhull qconvex qdelaunay qhalf qvoronoi rbox libqhull.a libqhull_r.a - type: make doc - this prints the man page - See also qhull/html/index.htm - if your compiler reports many errors, it is probably not a ANSI C compiler - you will need to set the -ansi switch or find another compiler - if your compiler warns about missing prototypes for fprintf() etc. - this is ok, your compiler should have these in stdio.h - if your compiler warns about missing prototypes for memset() etc. - include memory.h in qhull_a.h - if your compiler reports "global.c: storage size of 'qh_qh' isn't known" - delete the initializer "={0}" in global.c, stat.c and mem.c - if your compiler warns about "stat.c: improper initializer" - this is ok, the initializer is not used - if you have trouble building libqhull.a with 'ar' - try 'make -f Makefile.txt qhullx' - if the code compiles, the qhull test case will automatically execute - if an error occurs, there's an incompatibility between machines - If you can, try a different compiler - You can turn off the Qhull memory manager with qh_NOmem in mem.h - You can turn off compiler optimization (-O2 in Makefile) - If you find the source of the problem, please let us know - to install the programs and their man pages: - define MANDIR and BINDIR - type 'make install' - if you have Geomview (www.geomview.org) - try 'rbox 100 | qconvex G >a' and load 'a' into Geomview - run 'q_eg' for Geomview examples of Qhull output (see qh-eg.htm) ------------------ Compiling on other machines and compilers Qhull may compile with Borland C++ 5.0 bcc32. A Makefile is included. Execute 'cd src/libqhull; make -f Mborland'. If you use the Borland IDE, set the ANSI option in Options:Project:Compiler:Source:Language-compliance. Qhull may compile with Borland C++ 4.02 for Win32 and DOS Power Pack. Use 'cd src/libqhull; make -f Mborland -D_DPMI'. Qhull 1.0 compiles with Borland C++ 4.02. For rbox 1.0, use "bcc32 -WX -w- -O2-e -erbox -lc rbox.c". Use the same options for Qhull 1.0. [D. Zwick] If you have troubles with the memory manager, you can turn it off by defining qh_NOmem in mem.h. ----------------- Distributed files README.txt // Instructions for installing Qhull REGISTER.txt // Qhull registration COPYING.txt // Copyright notice QHULL-GO.lnk // Windows icon for eg/qhull-go.bat Announce.txt // Announcement CMakeLists.txt // CMake build file (2.6 or later) CMakeModules/CheckLFS.cmake // enables Large File Support in cmake File_id.diz // Package descriptor index.htm // Home page Makefile // Makefile for gcc and other compilers qhull*.md5sum // md5sum for all files bin/* // Qhull executables and dll (.zip only) build/qhull*.pc.in // pkg-config templates for qhull_r, qhull, and qhull_p build/qhull-32.sln // 32-bit DevStudio solution and project files (2010 and later) build/*-32.vcxproj build/qhull-64.sln // 64-bit DevStudio solution and project files (2010 and later) build/*-64.vcxproj build/qhull.sln // DevStudio solution and project files (2005 and 2009) build/*.vcproj eg/* // Test scripts and geomview files from q_eg html/index.htm // Manual html/qh-faq.htm // Frequently asked questions html/qh-get.htm // Download page html/qhull-cpp.xml // C++ style notes as a Road FAQ (www.qhull.org/road) src/Changes.txt // Change history for Qhull and rbox src/qhull-all.pro // Qt project eg/ q_eg // shell script for Geomview examples (eg.01.cube) q_egtest // shell script for Geomview test examples q_test // shell script to test qhull q_test-ok.txt // output from q_test qhulltest-ok.txt // output from qhulltest (Qt only) make-vcproj.sh // bash shell script to create vcproj and vcxprog files qhull-zip.sh // bash shell script for distribution files rbox consists of (bin, html): rbox.exe // Win32 executable (.zip only) rbox.htm // html manual rbox.man // Unix man page rbox.txt qhull consists of (bin, html): qconvex.exe // Win32 executables and dlls (.zip download only) qhull.exe // Built with the reentrant library (about 2% slower) qdelaunay.exe qhalf.exe qvoronoi.exe qhull_r.dll qhull-go.bat // command window qconvex.htm // html manual qdelaun.htm qdelau_f.htm qhalf.htm qvoronoi.htm qvoron_f.htm qh-eg.htm qh-code.htm qh-impre.htm index.htm qh-opt*.htm qh-quick.htm qh--*.gif // images for manual normal_voronoi_knauss_oesterle.jpg qhull.man // Unix man page qhull.txt bin/ msvcr80.dll // Visual C++ redistributable file (.zip download only) src/ qhull/unix.c // Qhull and rbox applications using non-reentrant libqhullstatic.a rbox/rbox.c qconvex/qconvex.c qhalf/qhalf.c qdelaunay/qdelaunay.c qvoronoi/qvoronoi.c qhull/unix_r.c // Qhull and rbox applications using reentrant libqhullstatic_r.a rbox/rbox_r.c qconvex/qconvex_r.c // Qhull applications built with reentrant libqhull_r/Makefile qhalf/qhalf_r.c qdelaunay/qdelaun_r.c qvoronoi/qvoronoi_r.c user_eg/user_eg_r.c // example of using qhull_r.dll from a user program user_eg2/user_eg2_r.c // example of using libqhullstatic_r.a from a user program user_eg3/user_eg3_r.cpp // example of Qhull's C++ interface libqhullcpp with libqhullstatic_r.a qhulltest/qhulltest.cpp // Test of Qhull's C++ interface using Qt's QTestLib qhull-*.pri // Include files for Qt projects testqset_r/testqset_r.c // Test of reentrant qset_r.c and mem_r.c testqset/testqset.c // Test of non-rentrant qset.c and mem.c src/libqhull libqhull.pro // Qt project for non-rentrant, shared library (qhull.dll) index.htm // design documentation for libqhull qh-*.htm qhull-exports.def // Export Definition file for Visual C++ Makefile // Simple gcc Makefile for qhull and libqhullstatic.a Mborland // Makefile for Borland C++ 5.0 libqhull.h // header file for qhull user.h // header file of user definable constants libqhull.c // Quickhull algorithm with partitioning user.c // user re-definable functions usermem.c userprintf.c userprintf_rbox.c qhull_a.h // include files for libqhull/*.c geom.c // geometric routines geom2.c geom.h global.c // global variables io.c // input-output routines io.h mem.c // memory routines, this is stand-alone code mem.h merge.c // merging of non-convex facets merge.h poly.c // polyhedron routines poly2.c poly.h qset.c // set routines, this only depends on mem.c qset.h random.c // utilities w/ Park & Miller's random number generator random.h rboxlib.c // point set generator for rbox stat.c // statistics stat.h src/libqhull_r libqhull_r.pro // Qt project for rentrant, shared library (qhull_r.dll) index.htm // design documentation for libqhull_r qh-*_r.htm qhull-exports_r.def // Export Definition file for Visual C++ Makefile // Simple gcc Makefile for qhull and libqhullstatic.a libqhull_r.h // header file for qhull user_r.h // header file of user definable constants libqhull_r.c // Quickhull algorithm wi_r.hpartitioning user_r.c // user re-definable functions usermem.c userprintf.c userprintf_rbox.c qhull_ra.h // include files for libqhull/*_r.c geom_r.c // geometric routines geom2.c geom_r.h global_r.c // global variables io_r.c // input-output routines io_r.h mem_r.c // memory routines, this is stand-alone code mem.h merge_r.c // merging of non-convex facets merge.h poly_r.c // polyhedron routines poly2.c poly_r.h qset_r.c // set routines, this only depends on mem_r.c qset.h random_r.c // utilities w/ Park & Miller's random number generator random.h rboxlib_r.c // point set generator for rbox stat_r.c // statistics stat.h src/libqhullcpp/ libqhullcpp.pro // Qt project for renentrant, static C++ library Qhull.cpp // Calls libqhull_r.c from C++ Qhull.h qt-qhull.cpp // Supporting methods for Qt Coordinates.cpp // input classes Coordinates.h PointCoordinates.cpp PointCoordinates.h RboxPoints.cpp // call rboxlib.c from C++ RboxPoints.h QhullFacet.cpp // data structure classes QhullFacet.h QhullHyperplane.cpp QhullHyperplane.h QhullPoint.cpp QhullPoint.h QhullQh.cpp QhullRidge.cpp QhullRidge.h QhullVertex.cpp QhullVertex.h QhullFacetList.cpp // collection classes QhullFacetList.h QhullFacetSet.cpp QhullFacetSet.h QhullIterator.h QhullLinkedList.h QhullPoints.cpp QhullPoints.h QhullPointSet.cpp QhullPointSet.h QhullSet.cpp QhullSet.h QhullSets.h QhullVertexSet.cpp QhullVertexSet.h functionObjects.h // supporting classes QhullError.cpp QhullError.h QhullQh.cpp QhullQh.h QhullStat.cpp QhullStat.h RoadError.cpp // Supporting base classes RoadError.h RoadLogEvent.cpp RoadLogEvent.h usermem_r-cpp.cpp // Optional override for qh_exit() to throw an error src/libqhullstatic/ libqhullstatic.pro // Qt project for non-reentrant, static library src/libqhullstatic_r/ libqhullstatic_r.pro // Qt project for reentrant, static library src/qhulltest/ qhulltest.pro // Qt project for test of C++ interface Coordinates_test.cpp // Test of each class PointCoordinates_test.cpp Qhull_test.cpp QhullFacet_test.cpp QhullFacetList_test.cpp QhullFacetSet_test.cpp QhullHyperplane_test.cpp QhullLinkedList_test.cpp QhullPoint_test.cpp QhullPoints_test.cpp QhullPointSet_test.cpp QhullRidge_test.cpp QhullSet_test.cpp QhullVertex_test.cpp QhullVertexSet_test.cpp RboxPoints_test.cpp RoadTest.cpp // Run multiple test files with QTestLib RoadTest.h ----------------- Authors: C. Bradford Barber Hannu Huhdanpaa (Version 1.0) bradb@shore.net hannu@qhull.org Qhull 1.0 and 2.0 were developed under NSF grants NSF/DMS-8920161 and NSF-CCR-91-15793 750-7504 at the Geometry Center and Harvard University. If you find Qhull useful, please let us know. geometry/vignettes/qhull/html/0000755000176200001440000000000014664417655016230 5ustar liggesusersgeometry/vignettes/qhull/html/qconvex.html0000644000176200001440000006620114664417655020606 0ustar liggesusers qconvex -- convex hull Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options

[cone]qconvex -- convex hull

The convex hull of a set of points is the smallest convex set containing the points. See the detailed introduction by O'Rourke ['94]. See Description of Qhull and How Qhull adds a point.

Example: rbox 10 D3 | qconvex s o TO result
Compute the 3-d convex hull of 10 random points. Write a summary to the console and the points and facets to 'result'.
 
Example: rbox c | qconvex n
Print the normals for each facet of a cube.
 
Example: rbox c | qconvex i Qt
Print the triangulated facets of a cube.
 
Example: rbox y 500 W0 | qconvex
Compute the convex hull of a simplex with 500 points on its surface.
 
Example: rbox x W1e-12 1000 | qconvex QR0
Compute the convex hull of 1000 points near the surface of a randomly rotated simplex. Report the maximum thickness of a facet.
 
Example: rbox 1000 s | qconvex s FA
Compute the convex hull of 1000 cospherical points. Verify the results and print a summary with the total area and volume.
 
Example: rbox d D12 | qconvex QR0 FA
Compute the convex hull of a 12-d diamond. Randomly rotate the input. Note the large number of facets and the small volume.
 
Example: rbox c D7 | qconvex FA TF1000
Compute the convex hull of the 7-d hypercube. Report on progress every 1000 facets. Computing the convex hull of the 9-d hypercube takes too much time and space.
 
Example: rbox c d D2 | qconvex Qc s f Fx | more
Dump all fields of all facets for a square and a diamond. Also print a summary and a list of vertices. Note the coplanar points.
 

Except for rbox, all of the qhull programs compute a convex hull.

By default, Qhull merges coplanar facets. For example, the convex hull of a cube's vertices has six facets.

If you use 'Qt' (triangulated output), all facets will be simplicial (e.g., triangles in 2-d). For the cube example, it will have 12 facets. Some facets may be degenerate and have zero area.

If you use 'QJ' (joggled input), all facets will be simplicial. The corresponding vertices will be slightly perturbed and identical points will be joggled apart. Joggled input is less accurate that triangulated output.See Merged facets or joggled input.

The output for 4-d convex hulls may be confusing if the convex hull contains non-simplicial facets (e.g., a hypercube). See Why are there extra points in a 4-d or higher convex hull?

The 'qconvex' program is equivalent to 'qhull'. It disables the following Qhull options: d v H Qbb Qf Qg Qm Qr Qu Qv Qx Qz TR E V Fp Gt Q0,etc.

Copyright © 1995-2020 C.B. Barber


»qconvex synopsis

qconvex -- compute the convex hull.
    input (stdin): dimension, number of points, point coordinates
    comments start with a non-numeric character

options:
    Qt   - triangulated output
    QJ   - joggled input instead of merged facets
    Tv   - verify result: structure, convexity, and point inclusion
    .    - concise list of all options
    -    - one-line description of each option
    -?   - this message
    -V   - version

output options (subset):
    s    - summary of results (default)
    i    - vertices incident to each facet
    n    - normals with offsets
    p    - vertex coordinates (if 'Qc', includes coplanar points)
    FA   - report total area and volume
    FS   - total area and volume
    Fx   - extreme points (convex hull vertices)
    G    - Geomview output (2-d, 3-d, and 4-d)
    m    - Mathematica output (2-d and 3-d)
    o    - OFF format (dim, n, points, facets)
    QVn  - print facets that include point n, -n if not
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes

examples:
    rbox c D2 | qconvex s n                    rbox c D2 | qconvex i
    rbox c D2 | qconvex o                      rbox 1000 s | qconvex s Tv FA
    rbox c d D2 | qconvex s Qc Fx              rbox y 1000 W0 | qconvex Qc s n
    rbox y 1000 W0 | qconvex s QJ              rbox d G1 D12 | qconvex QR0 FA Pp
    rbox c D7 | qconvex FA TF1000

»qconvex input

The input data on stdin consists of:

  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qconvex < data.txt), a pipe (e.g., rbox 10 | qconvex), or the 'TI' option (e.g., qconvex TI data.txt).

Comments start with a non-numeric character. Error reporting is simpler if there is one point per line. Dimension and number of points may be reversed.

Here is the input for computing the convex hull of the unit cube. The output is the normals, one per facet.

rbox c > data

3 RBOX c
8
  -0.5   -0.5   -0.5
  -0.5   -0.5    0.5
  -0.5    0.5   -0.5
  -0.5    0.5    0.5
   0.5   -0.5   -0.5
   0.5   -0.5    0.5
   0.5    0.5   -0.5
   0.5    0.5    0.5

qconvex s n < data


Convex hull of 8 points in 3-d:

  Number of vertices: 8
  Number of facets: 6
  Number of non-simplicial facets: 6

Statistics for: RBOX c | QCONVEX s n

  Number of points processed: 8
  Number of hyperplanes created: 11
  Number of distance tests for qhull: 35
  Number of merged facets: 6
  Number of distance tests for merging: 84
  CPU seconds to compute hull (after input): 0.081

4
6
     0      0     -1   -0.5
     0     -1      0   -0.5
     1      0      0   -0.5
    -1      0      0   -0.5
     0      1      0   -0.5
     0      0      1   -0.5

»qconvex outputs

These options control the output of qconvex. They may be used individually or together.

 
Vertices
Fx
list extreme points (i.e., vertices). The first line is the number of extreme points. Each point is listed, one per line. The cube example has eight vertices. In 2-d, extreme points are in counter-clockwise order.
Fv
list vertices for each facet. The first line is the number of facets. Each remaining line starts with the number of vertices. For the cube example, each facet has four vertices.
i
list vertices for each facet. The first line is the number of facets. The remaining lines list the vertices for each facet. The facets are oriented. In 4-d and higher, triangulate non-simplicial facets by adding an extra point.
 
 
Coordinates
o
print vertices and facets of the convex hull in OFF format. The first line is the dimension. The second line is the number of vertices, facets, and ridges. The vertex coordinates are next, followed by the facets. Each facet starts with the number of vertices. Simplicial and 3-d facets are oriented. The cube example has four vertices per facet.
Ft
print a triangulation of the convex hull in OFF format. The first line is the dimension. The second line is the number of vertices and added points, followed by the number of facets and the number of ridges. The vertex coordinates are next, followed by the centrum coordinates. There is one centrum for each non-simplicial facet. The cube example has six centrums, one per square. Each facet starts with the number of vertices or centrums. In the cube example, each facet uses two vertices and one centrum.
p
print vertex coordinates. The first line is the dimension and the second line is the number of vertices. The following lines are the coordinates of each vertex. The cube example has eight vertices.
Qc p
print coordinates of vertices and coplanar points. The first line is the dimension. The second line is the number of vertices and coplanar points. The coordinates are next, one line per point. Use 'Qc Qi p' to print the coordinates of all points.
 
 
Facets
Fn
list neighboring facets for each facet. The first line is the number of facets. Each remaining line starts with the number of neighboring facets. The cube example has four neighbors per facet.
FN
list neighboring facets for each point. The first line is the total number of points. Each remaining line starts with the number of neighboring facets. Each vertex of the cube example has three neighboring facets. Use 'Qc Qi FN' to include coplanar and interior points.
Fa
print area for each facet. The first line is the number of facets. Facet area follows, one line per facet. For the cube example, each facet has area one.
FI
list facet IDs. The first line is the number of facets. The IDs follow, one per line.
 
 
Coplanar and interior points
Fc
list coplanar points for each facet. The first line is the number of facets. The remaining lines start with the number of coplanar points. A coplanar point is assigned to one facet.
Qi Fc
list interior points for each facet. The first line is the number of facets. The remaining lines start with the number of interior points. A coplanar point is assigned to one facet.
FP
print distance to nearest vertex for coplanar points. The first line is the number of coplanar points. Each remaining line starts with the point ID of a vertex, followed by the point ID of a coplanar point, its facet, and distance. Use 'Qc Qi FP' for coplanar and interior points.
 
 
Hyperplanes
n
print hyperplane for each facet. The first line is the dimension. The second line is the number of facets. Each remaining line is the hyperplane's coefficients followed by its offset.
Fo
print outer plane for each facet. The output plane is above all points. The first line is the dimension. The second line is the number of facets. Each remaining line is the outer plane's coefficients followed by its offset.
Fi
print inner plane for each facet. The inner plane of a facet is below its vertices. The first line is the dimension. The second line is the number of facets. Each remaining line is the inner plane's coefficients followed by its offset.
 
 
General
s
print summary for the convex hull. Use 'Fs' and 'FS' if you need numeric data.
FA
compute total area and volume for 's' and 'FS'
m
Mathematica output for the convex hull in 2-d or 3-d.
FM
Maple output for the convex hull in 2-d or 3-d.
G
Geomview output for the convex hull in 2-d, 3-d, or 4-d.
 
 
Scaling and rotation
Qbk:n
scale k'th coordinate to lower bound.
QBk:n
scale k'th coordinate to upper bound.
QbB
scale input to unit cube centered at the origin.
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
Qbk:0Bk:0
remove k'th coordinate from input. This computes the convex hull in one lower dimension.

»qconvex controls

These options provide additional control:

Qt
triangulated output. Qhull triangulates non-simplicial facets. It may produce degenerate facets of zero area.
QJ
joggle the input instead of merging facets. This guarantees simplicial facets (e.g., triangles in 3-d). It is less accurate than triangulated output ('Qt').
Qc
keep coplanar points
Qi
keep interior points
f
facet dump. Print the data structure for each facet.
QVn
select facets containing point n as a vertex,
QGn
select facets that are visible from point n (marked 'good'). Use -n for the remainder.
PDk:0
select facets with a negative coordinate for dimension k
TFn
report progress after constructing n facets
Tv
verify result
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
Qs
search all points for the initial simplex. If Qhull can not construct an initial simplex, it reports a descriptive message. Usually, the point set is degenerate and one or more dimensions should be removed ('Qbk:0Bk:0'). If not, use option 'Qs'. It performs an exhaustive search for the best initial simplex. This is expensive is high dimensions.

»qconvex graphics

Display 2-d, 3-d, and 4-d convex hulls with Geomview ('G').

Display 2-d and 3-d convex hulls with Mathematica ('m').

To view 4-d convex hulls in 3-d, use 'Pd0d1d2d3' to select the positive octant and 'GrD2' to drop dimension 2.

»qconvex notes

Qhull always computes a convex hull. The convex hull may be used for other geometric structures. The general technique is to transform the structure into an equivalent convex hull problem. For example, the Delaunay triangulation is equivalent to the convex hull of the input sites after lifting the points to a paraboloid.

»qconvex conventions

The following terminology is used for convex hulls in Qhull. See Qhull's data structures.

  • point - d coordinates
  • vertex - extreme point of the input set
  • ridge - d-1 vertices between two neighboring facets
  • hyperplane - halfspace defined by a unit normal and offset
  • coplanar point - a nearly incident point to a hyperplane
  • centrum - a point on the hyperplane for testing convexity
  • facet - a facet with vertices, ridges, coplanar points, neighboring facets, and hyperplane
  • simplicial facet - a facet with d vertices, d ridges, and d neighbors
  • non-simplicial facet - a facet with more than d vertices
  • good facet - a facet selected by 'QVn', etc.

»qconvex options

qconvex -- compute the convex hull
    http://www.qhull.org

input (stdin):
    first lines: dimension and number of points (or vice-versa).
    other lines: point coordinates, best if one point per line
    comments:    start with a non-numeric character

options:
    Qc   - keep coplanar points with nearest facet
    Qi   - keep interior points with nearest facet
    QJ   - joggled input instead of merged facets
    Qt   - triangulated output

Qhull control options:
    Qa   - allow input with fewer or more points than coordinates
    Qbk:n   - scale coord k so that low bound is n
      QBk:n - scale coord k so that upper bound is n (QBk is 0.5)
    QbB  - scale input to unit cube centered at the origin
    Qbk:0Bk:0 - remove k-th coordinate from input
    QJn  - randomly joggle input in range [-n,n]
    QRn  - random rotation (n=seed, n=0 time, n=-1 time/no rotate)
    Qs   - search all points for the initial simplex

Qhull extra options:
    QGn  - good facet if visible from point n, -n for not visible
    QVn  - good facet if it includes point n, -n if not
    Qw   - allow option warnings
    Q12  - allow wide facets and wide dupridge
    Q14  - merge pinched vertices that create a dupridge

T options:
    TFn  - report summary when n or more facets created
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes
    Ts   - statistics
    Tv   - verify result: structure, convexity, and in-circle test
    Tz   - send all output to stdout

Trace options:
    T4   - trace at level n, 4=all, 5=mem/gauss, -1= events
    Ta   - annotate output with message codes
    TAn  - stop qhull after adding n vertices
     TCn - stop qhull after building cone for point n
     TVn - stop qhull after adding point n, -n for before
    Tc   - check frequently during execution
    Tf   - flush each qh_fprintf for debugging segfaults
    TPn  - turn on tracing when point n added to hull
     TMn - turn on tracing at merge n
     TWn - trace merge facets when width > n

Precision options:
    Cn   - radius of centrum (roundoff added).  Merge facets if non-convex
     An  - cosine of maximum angle.  Merge facets if cosine > n or non-convex
           C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge
    Rn   - randomly perturb computations by a factor of [1-n,1+n]
    Un   - max distance below plane for a new, coplanar point
    Wn   - min facet width for outside point (before roundoff)

Output formats (may be combined; if none, produces a summary to stdout):
    f    - facet dump
    G    - Geomview output (see below)
    i    - vertices incident to each facet
    m    - Mathematica output (2-d and 3-d)
    n    - normals with offsets
    o    - OFF file format (dim, points and facets)
    p    - point coordinates
    s    - summary (stderr)

More formats:
    Fa   - area for each facet
    FA   - compute total area and volume for option 's'
    Fc   - count plus coplanar points for each facet
           use 'Qc' (default) for coplanar and 'Qi' for interior
    FC   - centrum for each facet
    Fd   - use cdd format for input (homogeneous with offset first)
    FD   - use cdd format for numeric output (offset first)
    FF   - facet dump without ridges
    Fi   - inner plane for each facet
    FI   - ID for each facet
    Fm   - merge count for each facet (511 max)
    FM   - Maple output (2-d and 3-d)
    Fn   - count plus neighboring facets for each facet
    FN   - count plus neighboring facets for each point
    Fo   - outer plane (or max_outside) for each facet
    FO   - options and precision constants
    FP   - nearest vertex for each coplanar point
    FQ   - command used for qconvex
    Fs   - summary: #int (8), dimension, #points, tot vertices, tot facets,
                      output: #vertices, #facets, #coplanars, #nonsimplicial
                    #real (2), max outer plane, min vertex
    FS   - sizes:   #int (0)
                    #real (2) tot area, tot volume
    Ft   - triangulation with centrums for non-simplicial facets (OFF format)
    Fv   - count plus vertices for each facet
    FV   - average of vertices (a feasible point for 'H')
    Fx   - extreme points (in order for 2-d)

Geomview output (2-d, 3-d, and 4-d)
    Ga   - all points as dots
     Gp  -  coplanar points and vertices as radii
     Gv  -  vertices as spheres
    Gc   - centrums
    GDn  - drop dimension n in 3-d and 4-d output
    Gh   - hyperplane intersections
    Gi   - inner planes only
     Gn  -  no planes
     Go  -  outer planes only
    Gr   - ridges

Print options:
    PAn  - keep n largest facets by area
    Pdk:n - drop facet if normal[k] <= n (default 0.0)
    PDk:n - drop facet if normal[k] >= n
    PFn  - keep facets whose area is at least n
    Pg   - print good facets (needs 'QGn' or 'QVn')
    PG   - print neighbors of good facets
    PMn  - keep n facets with most merges
    Po   - force output.  If error, output neighborhood of facet
    Pp   - do not report precision problems

    .    - list of all options
    -    - one line descriptions of all options
    -?   - help with examples
    -V   - version

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qh-get.html0000644000176200001440000001352714664417655020313 0ustar liggesusers Qhull Downloads

Up: Qhull Home Page (www.qhull.org)


[CONE] Qhull Downloads

  • Qhull Home Page

    Qhull computes the convex hull, Delaunay triangulation, Voronoi diagram, halfspace intersection about a point, furthest-site Delaunay triangulation, and furthest-site Voronoi diagram. It runs in 2-d, 3-d, 4-d, and higher dimensions. It implements the Quickhull algorithm for computing the convex hull. Qhull handles roundoff errors from floating point arithmetic. It can approximate a convex hull.

    Visit Qhull News for news, bug reports, change history, and users. If you use Qhull 2003.1 or 2009.1, please upgrade or apply poly.c-qh_gethash.patch.

  • Download: Qhull 2020.2 for Windows 10, 8, 7, XP, and NT (3.3 MB, readme, md5sum, contents)

    Type: console programs for Windows (32- or 64-bit)

    Includes 32-bit executables, documentation, and sources files. It runs in a command window. Qhull may be compiled for 64-bits.

  • GitHub Qhull (git@github.com:qhull/qhull.git)

    Type: git repository for Qhull. See current Changes.txt

    Includes documentation, source files, C++ interface, and test programs. It builds with gcc, mingw, CMake, DevStudio, and Qt Creator.

  • Download: Qhull 2020.2 for Unix (1.3 MB, readme, md5sum, contents)

    Type: C/C++ source code for 32-bit and 64-bit architectures.

    Includes documentation, source files, Makefiles, CMakeLists.txt, DevStudio projects, and Qt projects. Includes C++ support.

    Download and search sites for pre-built packages include

  • The Quickhull algorithm for convex hulls (PDF, 307K)

    Type: PDF on ACM Digital Library (from this page only)

    Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., "The Quickhull algorithm for convex hulls," ACM Transactions on Mathematical Software, 22(4):469-483, Dec 1996 [abstract].

  • Download: Qhull version 1.0 (92K)

    Type: C source code for 32-bit architectures

    Version 1.0 is a fifth the size of version 2.4. It computes convex hulls and Delaunay triangulations. If a precision error occurs, it stops with an error message. It reports an initialization error for inputs made with 0/1 coordinates.

    Version 1.0 compiles on a PC with Borland C++ 4.02 for Win32 and DOS Power Pack. The options for rbox are "bcc32 -WX -w- -O2-e -erbox -lc rbox.c". The options for qhull are the same. [D. Zwick]

  • Sept. 3, 2020 22:14 EDT md5sum for Qhull 2020.2 downloads
    4f68ebb4700849a548b332de500d42e9 *qhull-2020.2/qhull-2020.2-zip.md5sum
    ed767244864488d5e9a22dfa788663a9 *qhull-2020.2/qhull-2020-src-8.0.2-tgz.md5sum
    7ed0bcce474bf12f6fbb5b4093760f3d *qhull-2020.2.zip
    295f7332269a38279478f555cc185296 *qhull-2020-src-8.0.2.tgz
    

Up: Qhull Home Page (www.qhull.org)


[HOME] The Geometry Center Home Page

Comments to: qhull@qhull.org
geometry/vignettes/qhull/html/qh--cone.gif0000644000176200001440000000560213431000556020304 0ustar liggesusersGIF87addç[~.TopPZ OXa>Uj3.OšP*$?C1Lk5k4'#?9$k)KTRn(7+-aV_"/*&%Z—@‹®˜K\!£µ©JZ W‘=:5€¨ÅÊÇQƒ7]/F@(Y()]/D_¤½­)$&Kb>2;<}M7%,'X{-NY zvsUu*$j(f2?…S=Q"9-\N…:?€I^œCÕ×Ö]œB\šAOz1L[!<6^caþþþqpmüüü¶µ´_‚0úúúT^"öööS\!ôôôñòñ86Oq*1.$ìììPBCK$4''´Á¸T¤VÛÜÛF†EO†:PœR’‘W.OšQ(%M–Oª¯®k5?9LX >9&!608&U3+j>=}IU_"L`#E-“Ÿ—$!ðïïT‹;QBG˜cZ{-2i*b>P‡:3-2-O™P6%ikj3Q($q ‚MY $j)put(D\01#:{O]œC%.;B/)*"+{~{M5R\!QZ %FK33<520[éêê@G3PD{7àâá%k)LSS€Š†Mq,-a.6/21.]›B$#Xz[<=>9$g+<7Ls.ÿÿÿHPýýý_ƒ0Z*F?÷÷÷DŒ^I.óóóQt,#TQM4=ííí;$$G˜dQBA‚GCH;{K3=)&Q*&8[1/GŽP*H˜˜–T£VS£Ub0:)QŸSN™PEd#ÒÓÒ'34Uw,>8¢¦¦Ne%\ZT'&U^"¿¿¿ ::9s;!d*ÇÏÊE•a=~L0+)*Ô,ddþe H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—‰„Ú“%-s_ù Æ&˜ 5Mâ"#[ uÄ-[º4S’ "ÍE’¤NUª«rá"Ш—P:zõª:u„¶v¶#ˆ©gËV=‹Im 6RÚf$Bª„Õ¿€ÿfÕÚÕ™Þ‹I^ü·DšSø:\1‰ ƘWýÙìçO/`”%î…9sç?§‘ ب¹VçÂ6«ÓæÛ\аvØéõlÙr©Ö¾½ÙMZ».!·*íàgë·àfÍµä ‰îœ{lᄈþ'[Cá v„¤J«—ô ¤dÓP 0ù|AnëÕOúÅÿ—¦‹P°ö N~êAÒ©L3ßjö€ ‚™±°à)B2ŸnöÙlÍ}âU“hâ¨8°I€Qa"ÞèU% bâ8 ƒÖGFs þ&œ\«hrã/§À¢£†k˜—\(Æ(¤Œy"*Úè¸âõ±fiböÍ) þ²‰h éà€»}fiœb!§hƒ&šRðUh漉Y ‰|’È)d¢’æ¡ÇáaKLåçb“ òÉ ƒ4sЇ¢‰†ƒ-Rææ£}ÓŒ¤”~¢@˜‘ªäy^þPN$tsUñÉ­·*Bd™¥‰6yØv²>×Ýb(€k®qÄÑŠ¯¬îÈ¥^ UìŒÀá°¬©4;‹’¿jÓÀâ8Ö—C¢ŒÂ%»­Í6;ŽŽÑ»gPø’NjêqTÐ,‡º‹Â$Å„úþ…€¿þ& °Àq€ó„¦h6@APQÒpcÚö;ˆLÜlŸ‚¢k¬ÑCMÀ0ü1$Œzë TT`rÀLx°²¦\”Wӧئk4Uä`JšjI¼PÇ*½âÒ. ½îl% cŠ)˜ÒŒTD µPh¹/q£îµF«ƒCØ`ƒÝŒfCªþ¯Úp±Æ½+‘ÉÛ´+I#u×rä/¯|›°JG|, $L ùæÖÔÀ:|²è­Üi†ktʘúª£Âæ›s‚D-µÌP²è¢ ümšhúýòJ=øÕðܰOC6´ÓÞ 8¸ï<ïhÈç¤JŸê›tñ9tž|-HÑ<V¯ôZá„ÏU‚ `‡6'Û'C Ž+ñ„6¾2"M)uBVú"‚M×HÐ>°qñK^˜à¸bàOGòœIÜ7c­4@†æ–…n¯qy³„|õ‡5È@%C`— «Ri`PåÈœ)´çAÚ™à ŽKßÁ1”ìB_þÒx€(D!ÄÌÉ®†Û³ÝΆ¶C¥Áe(¨¤q!‘ˆÈ@··¼ïU ‡J s’Êù©4¸âiŠRl1~Þ£ØÄx…&m0¢K%¡Ãi D+>€>øA,LðFÚÍOŽ«@éV–†ý$=ajD9†HIQ°ñàÁ#€ƒBÖ"OË]¾Å*1JP$ŠYáUZh‹¦ƒ P…| KU„@‹oaÔæ¥#FœÐ$C8w¾10 •–´$9h9ËZªâ¼(ä ÍF_¥á.*I0Uù0”e@&÷PËfÒR–(Åì¶h;³=AG©XCLkѪÑþ(Ã7ËIÒ€œåd¦*j)HBn±JˆZ1Р X0‚Œ$ €Ä4‡2,@Ÿ]€-@NðÀ)H?RN¾1޳šÒà zªá€Q‡¤1‡ŒbÔ¢¶ØÃF*R‘z´§<¸åi² )âXBI †J¨Á «€.@€6ÔÀ¢7eÀnÑž†”¤$åG¡¹EPšì>³ã)?ÂT<àa• ê ¨ª¬Z4äxÆ3ªÁÕ°úÔ¯$Mçå°30š¡¿ÉÔ0…)À•| @d½ N¼‚ЀÆ34Ë×>ÈR ufAkhC@m#´À1J Æ:¶•þ,([ƒ7Pc³šÍ-4: ZföV&õà è¯gÁ óŒhcÙȶŸÄØ,n¥›ÙÍòv ¾u&3…êA„>®Wu€¨H¸±\Ø6·ªåƒ^uKÝÜêµ³¡=§oÉêA@mÚ°@KI‚ :¼5®TmÃqtà XxÌ`ë5Á€è«X½*V ¸1zÀ¡îº ¥–$ d…€ma£Äy(01Âàà+øÁ ÆÂ¸úW r 4k³ž€†:„#%¡¸ÂNpŽŸÅ6@‡'Âã¿ØÅXúU‘÷ƒ[¨(a“  ¹ÈŠMœ‡${¢Nn°þ“¥ÜÀö”»É3Aí‹Õ¾$ æØ˜Ålä2·Àêe¯f¥+å.|6´ôM^;¥¦^$f È@NpäÛàÏc¨î u[hš3ëT^B/ñ ˆ*Aþ@ÎQbKczÓÓ…F§MËÑÒ hV„°_ÊÐÂË{>r.Z°ÌÆZ¯îí•3Ô¦ÃûÁ³žÃ|âaÆ/.4XA g³¶Â?.Ð."=éj›0NpF *û Ñ„…€[ tBÈ«ÎÃ Îæuë §¦ì;ŽHÔû DÈ—üïháÉ^`·XGk»YX OH®¡ç4üá Ž¸o0¹ÉN"ô §ÎøAš@î\8Âášù@…ªbôZå ‘¾s‘¿›N.p™|ÙpЂ¿ÓV„›è¡Ç @OÜB±à—¡^\à„ÊPF&¸ž)¡ !»Ú×Îö¶»ýíp—E@;geometry/vignettes/qhull/html/qh-opto.html0000644000176200001440000003705514664417655020517 0ustar liggesusers Qhull output options

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull output options

This section lists the output options for Qhull. These options are indicated by lower case characters. See Formats, Print, and Geomview for other output options.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Output options

Qhull prints its output to standard out. All output is printed text. The default output is a summary (option 's'). Other outputs may be specified as follows.

f
print all fields of all facets
i
print vertices incident to each facet
m
print Mathematica output (2-d and 3-d)
n
print hyperplane normals with offsets
o
print OFF file format (dim, points and facets)
p
print vertex and point coordinates
s
print summary to stderr
 
 
Related options
F
additional input/output formats
Ft
print triangulation with added points
G
Geomview output
P
Print options
 

»f - print all fields of all facets

Print all fields of facetT for all facets. The facet is the primary data structure for Qhull.

Option 'f' is for debugging. Most of the fields are available via the 'F' options. If you need specialized information from Qhull, you can use the Qhull library or C++ interface.

Use the 'FF' option to print the facets but not the ridges.

»i - print vertices incident to each facet

The first line is the number of facets. The remaining lines list the vertices for each facet, one facet per line. The indices are 0-relative indices of the corresponding input points. The facets are oriented. Option 'Fv' displays an unoriented list of vertices with a vertex count per line. Options 'o' and 'Ft' displays coordinates for each vertex prior to the vertices for each facet.

Simplicial facets (e.g., triangles in 3-d) consist of d vertices. Non-simplicial facets in 3-d consist of 4 or more vertices. For example, a facet of a cube consists of 4 vertices. Use option 'Qt' to triangulate non-simplicial facets.

For 4-d and higher convex hulls and 3-d and higher Delaunay triangulations, d vertices are listed for all facets. A non-simplicial facet is triangulated with its centrum and each ridge. The index of the centrum is higher than any input point. Use option 'Fv' to list the vertices of non-simplicial facets as is. Use option 'Ft' to print the coordinates of the centrums as well as those of the input points. The centrum indices for option 'i' are one more than the centrum indices for option 'Ft'.

For halfspace intersection (qhalf), a "facet" is an intersection point and a "point" is a halfspace. Option 'i' lists the non-redundant halfspaces incident to each intersection point. The first line is the number of non-redundant halfspaces. Each remaining line lists the incident, non-redundant halfspaces for that intersection point.

»m - print Mathematica output

Qhull writes a Mathematica file for 2-d and 3-d convex hulls, 2-d and 3-d halfspace intersections, and 2-d Delaunay triangulations. Qhull produces a list of objects that you can assign to a variable in Mathematica, for example: "list= << <outputfilename> ". If the object is 2-d, it can be visualized by "Show[Graphics[list]] ". For 3-d objects the command is "Show[Graphics3D[list]] ". Now the object can be manipulated by commands of the form "Show[%, <parametername> -> <newvalue>]".

For Delaunay triangulation orthogonal projection is better. This can be specified, for example, by "BoxRatios: Show[%, BoxRatios -> {1, 1, 1e-8}]". To see the meaningful side of the 3-d object used to visualize 2-d Delaunay, you need to change the viewpoint: "Show[%, ViewPoint -> {0, 0, -1}]". By specifying different viewpoints you can slowly rotate objects.

For halfspace intersections, Qhull produces the dual convex hull.

See Is Qhull available for Mathematica? for URLs.

»n - print hyperplane normals with offsets

The first line is the dimension plus one. The second line is the number of facets. The remaining lines are the normals for each facet, one normal per line. The facet's offset follows its normal coefficients.

The normals point outward, i.e., the convex hull satisfies Ax <= -b where A is the matrix of coefficients and b is the vector of offsets.

A point is inside or below a hyperplane if its distance to the hyperplane is negative. A point is outside or above a hyperplane if its distance to the hyperplane is positive. Otherwise a point is on or coplanar to the hyperplane.

If cdd output is specified ('FD'), Qhull prints the command line, the keyword "begin", the number of facets, the dimension (plus one), the keyword "real", and the normals for each facet. The facet's negative offset precedes its normal coefficients (i.e., if the origin is an interior point, the offset is positive). Qhull ends the output with the keyword "end".

»o - print OFF file format

The output is:

  • The first line is the dimension
  • The second line is the number of points, the number of facets, and the number of ridges.
  • All of the input points follow, one per line.
  • Then Qhull prints the vertices for each facet. Each facet is on a separate line. The first number is the number of vertices. The remainder is the indices of the corresponding points. The vertices are oriented in 2-d, 3-d, and in simplicial facets.

Option 'Ft' prints the same information with added points for non-simplicial facets.

Option 'i' displays vertices without the point coordinates. Option 'p' displays the point coordinates without vertex and facet information.

In 3-d, Geomview can load the file directly if you delete the first line (e.g., by piping through 'tail +2').

For Voronoi diagrams (qvoronoi), option 'o' prints Voronoi vertices and Voronoi regions instead of input points and facets. The first vertex is the infinity vertex [-10.101, -10.101, ...]. Then, option 'o' lists the vertices in the Voronoi region for each input site. The regions appear in site ID order. In 2-d, the vertices of a Voronoi region are sorted by adjacency (non-oriented). In 3-d and higher, the Voronoi vertices are sorted by index. See the 'FN' option for listing Voronoi regions without listing Voronoi vertices.

If you are using the Qhull library, options 'v o' have the side effect of reordering the neighbors for a vertex.

»p - print vertex and point coordinates

The first line is the dimension. The second line is the number of vertices. The remaining lines are the vertices, one vertex per line. A vertex consists of its point coordinates

With the 'Gc' and 'Gi' options, option 'p' also prints coplanar and interior points respectively.

For qvoronoi, it prints the coordinates of each Voronoi vertex.

For qdelaunay, it prints the input sites as lifted to a paraboloid. For qhalf it prints the dual points. For both, option 'p' is the same as the first section of option 'o'.

Use 'Fx' to list the point ids of the extreme points (i.e., vertices).

If a subset of the facets is selected ('Pdk', 'PDk', 'Pg' options), option 'p' only prints vertices and points associated with those facets.

If cdd-output format is selected ('FD'), the first line is "begin". The second line is the number of vertices, the dimension plus one, and "real". The vertices follow with a leading "1". Output ends with "end".

»s - print summary to stderr

The default output of Qhull is a summary to stderr. Options 'FS' and 'Fs' produce the same information for programs. Note: Windows 95 and 98 treats stderr the same as stdout. Use option 'TO file' to separate stderr and stdout.

The summary lists the number of input points, the dimension, the number of vertices in the convex hull, and the number of facets in the convex hull. It lists the number of selected ("good") facets for options 'Pg', 'Pdk', qdelaunay, or qvoronoi (Delaunay triangulations only use the lower half of a convex hull). It lists the number of coplanar points. For Delaunay triangulations without 'Qc', it lists the total number of coplanar points. It lists the number of simplicial facets in the output.

The terminology depends on the output structure.

The summary lists these statistics:

  • number of points processed by Qhull
  • number of hyperplanes created
  • number of distance tests (not counting statistics, summary, and checking)
  • number of merged facets (if any)
  • number of distance tests for merging (if any)
  • CPU seconds to compute the hull
  • the maximum joggle for 'QJ'
    or, the probability of precision errors for 'QJ TRn'
  • total area and volume (if computed, see 'FS' 'FA' 'Fa' 'PAn')
  • max. distance of a point above a facet (if non-zero)
  • max. distance of a vertex below a facet (if non-zero)

The statistics include intermediate hulls. For example 'rbox d D4 | qhull' reports merged facets even though the final hull is simplicial.

Qhull starts counting CPU seconds after it has read and projected the input points. It stops counting before producing output. In the code, CPU seconds measures the execution time of function qhull() in libqhull.c. If the number of CPU seconds is clearly wrong, check qh_SECticks in user.h.

The last two figures measure the maximum distance from a point or vertex to a facet. They are not printed if less than roundoff or if not merging. They account for roundoff error in computing the distance (c.f., option 'Rn'). Use 'Fs' to report the maximum outer and inner plane.

A number may appear in parentheses after the maximum distance (e.g., 2.1x). It is the ratio between the maximum distance and the worst-case distance due to merging two simplicial facets. It should be small for 2-d, 3-d, and 4-d, and for higher dimensions with 'Qx'. It is not printed if less than 0.05.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qh--rand.gif0000644000176200001440000000744313431000556020311 0ustar liggesusersGIF87addç=*2-E>,^0GI*c‹cNk_(*&Ø×Ö^?DN2A…>L0Be(E@Io¥Jn¥I6-LFƒ‡uBm+‘Ž:DU2 )VT!‹~_ Iƒ!F>99=;`G #(5"nW]„hl¦§¡AN aˆ]üüüøøø/D"E4fŽesjaEPF[I*1'RVv *fFŽBƒFIML4L*:#_@DK2-fmoM+²±³U9+$DN=}uuUL&??=%)F$B‚U<;?|[ÌÊÉ5?4>-E;K8‚7'F …‘ƒ4j{ov=eF5z4tzet+UGTF8l7:TMX}<ëëç9[BO:#'*UlC63(ng*7f".b-d”-2hA3„GŽ„F`XeHETH:^N+Sie?`:3ZK2M[]L…©¬©ÞÝÝ4\";'†Mk_hI;VK<:iG[.“‡†[vR<4-BFtydV>J1#'6@9E :&jc,C89T'yeUe•-t@CcV2ht:-;?¼²±3RRRsBGJ>E-GT*zqEfŽfr…)>L!RfO>yE|wJZ|ZL(Z)04@*+…†‹7..Q2FIMT`)3 8‚87€7b‘3%:ÿÿÿ(/W,M3ilDg^xc`õõõž˜™V;8@B@`JOïïï2A=ˆ›tjZˆAu‰*…G·¹·`Ye5(N‘+\hÔ,ddþ‰ H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0c†|&3¥²Êéª2ˆÁ­*ÒjÎÄ©³W<}œ(Æ)C†jW„^”6&ß•+ŒÊ•»’o£mkÊu†J&§NOU¡)U¢²mÊ^»¢‹¡5>è§Z´œäkK‘ÈãÌ Â†A6FæôøKù”.•-Óeޱ>}ccbnËŒ[~)ÿŤ+.f…W¶„ý9ôhl·äŒP²D5e9[®½FxmÜšÚ´iƒ+R$ ¤ÐåxñýWŽ.wà 1'ã(íÆ Áþõ&ºùHPG›J£ìË9[¦OÐgûöÁqà Ä€ÿù7·dЍ`*Œ,ãÚk $ÁˆõݧO凙2>(ÐAcöÖÌ9ò „,Ú,‘‡~(Ï)%Žh¢SLô’„U’„ ºà§<$Èc ²x`¥"È¢Å$„ÑáäqÊ‚AˆIYˆ3˜P¨$‘ÄØä'ÏÖ¸‘@¯\©'–Z’@£çœ5$™râB½ )Ó5 $±Æ8ŽÉ3L8ëd↵쩩•7jq5çpË-§T3¨S.ì’AÁ4Äþn^4›ÀÁŽndb›öje-ÌSƧÔü’Ç9Kœ‚I5˜¤š… ÛÀ´Œ›‰lŽ TšÉ:ë€p„ß~ î¸ãŠ{DºÌR@l“G±¹œƒ…7l’ê)î4âR„š|óF>Ùn›É¶ádZ®•á"LîÃÌ¢ÎçHaÇ9.¤º‹*®ôŒ3̘@Ê$°S©¶ (aîÂ,›ÛÇŒEô…Æ.TÓjJŒcÂþ OÀÚÂqÄÊH+lîaÄìôºu་+%óóP°‰3Öœœ‰%–´¬ôØÔÒ O;͆Ô.`‡’4!Oa7ä!J×Ë’ðþÁ|ïmI7¤sԻ쒪 r¤ÔÀóW;œÁpTi‚½2›0ؾÛå" ,I’‘½¡Œ@N!nJþݨ ­‡€Æpå É3¼€:RL‚¢¸….´¾‰-œóÜÃfñ îp_ÜÅü@Ò/Œãoóœq yèBÃ\nPO‹ìêbq6‚’¸Ã ðxÃ'˜·Š[ƒ·(F6G±%âx„¼:œ%‘$W‚&ÞQ€à´À>ÂÑ2TIŽdKØË"Y€:€j_#H–A g¼ÁK(Ã. Ê'  —°\æäx¦±’¿ÈE÷q‹@Ã$•ð‚(0_¼Äæ1šÀ( ÒŠGÂÙXY†df7 <òqƒ%˜äÒüÄ1°IOzö¢ :þÈT#W&(¼ ¬”G2sñ‹_PãÆH+LâŒvø ¢Œ¨DiQŒl„a‚µhÆ%¶ xô£ õh.â±…\Ѐ$Ø+NÀÒ,´$ßhG2\QÖ´¦ø¨))M =K„A] ÀЌ¢õ¨E,ð‡K¤ ¥P}éHˆà…vlá 8½©MñáK`öPSG€J2ÀA/@ÖÊÖ¶²—ð ÚR©ŠdUBN·šÕœn³›{Ð….è€ ðÐ ¸ÑP¸õ±NhÆø)Е¥v ɼ ½öõ³ø¸g>9¥„Kö°f°ÇbÛXȶU ŠPþ0Úp \\–%A…¶°½î´´h‚E3jZÃ’!sà VËXÀµkeƒ"šq`œ¡²·-I9¨0Sßjõ·¢$%€jܨB¹Êe®s¡; E$"À°.mm UÜ’¤æàÁ¼Ë_œ>¡MÀF"ÈÐ<´€¹ËEo"âàÚYØâm¨®uQÐÕ¾#YÃìPO^fÓâäå6!£„pƒ-@ñ‰Sœâv0ø±(H„",Ž3œ¡ÆéhÃVÚR ‹d S(E‡‡üa®£ P±ŠS¼dn,²2ŽÃmŒã3Tªu( #BÑÛ"{9Ä£lÂ#’Ëd¯Xʼn¨Ãþcá¡TyÊ5ŽÃŽ[š†’ü€® 2˜?ü3 “hA™•lfM¨¹­p˜n:ÞüæÖ¤ÄoXÓ ÆÇ¦[ñŽIxú¼Mnr8´°VØBq06£W>dÁc8 *x _Ðþ(Æ;îa ^ÁÌ]·c îêJØßñ80Ò± ]°Å$>B)Ü}Ómjáǵ¼Zæ†CN0C›'üï s<àh`¶IþÁîP‚÷·37Ä!NˆGßè=‚%`KÝÛ\àéðAºSR @ôä5uE¾ò{¼£ÓªUî`{Ìan0‡{á{s œÐR ¨ŠP~·¦+h¼‹~_<„ð„Ú;í醈pÀ­Nw £¡,¹B(˜t¡ €ì+‡Â#`3ÀØp „/rƒD˜¡ sï¸äŒì\ë\gÆ~³zϱþèÂ…èG/zmðà «°…ª>y>¡-¡u(¨gl÷¨@î!®{ÝB £èƒè…ßah£ü(%lQr;ߨhp‡¬Y² ®‡Ây¾€5>þ0ïÞó~÷¾@„üàûâ ÈG¾láæb»?U´K€ $ƒ ´¨ ¾¯ûÝ÷Þs@~Äç…~üpz…aãVc|pò×Çp X@ Ÿð ˆÀcç}þq½ €Ágz˜|… ¶nÏ ¸ÐÂîpèÀÎð Ù0ý§xtè 1|<ȃ…¶ Î׸ãb€Hp®»·¹Gx0|£  Vàƒh€_`J TfnÃ{1Ñ „Jœà Rhƒá€Ãצ§…th–Pm ް Ž BP6PHP‚X+ þ°xE (zs°ƒ‰’x€Va@|èjà@Pc€ ƒ(ˆõ€ € ž§ˆƒ¢Y8‰‘ø”Ð ¶@$0 š¨j@R±¡8ˆJ¸ “À†ŠXvâ7s(‰•š` ð@ ÑÀ‹¸¨‹Rñ‰„è‹„È|‘ˆŠhªðˆ¯H ƒ` f䀋à {€Ò¨0€€ ¢Ø‹è@3pŠ+Ø@ _p@̨Ñà ÞŽ‹@ì(0}m v€Ó põpvÂXtïÀ 0ƒ  ä°IéHÑ(G@<„! •€.) ’ þJ( vÜx°à   8P$铉Òè– ’¯Á’.‘0‰.ˆ\ ïˆð1à“éh•)”›Ø ðŽð1×/‰È“’p°“@!)’nù–Y[ ” r_)Û –X“È€ è€b Ž p —Ñ€~à n@w‰yù’}‰ z` ýÐ’{ „é–‡©˜AÐ vù˜Ñ6 ™ÈÀ—¹š˜Ù hЇÃÐ A ì K¤y% /I ¬y™™²¡·ù¹i@° ô0›‹)œÎ `›Å¹%{ Ø™0 20šÓùàžâ9žäYžß;geometry/vignettes/qhull/html/qh--4d.gif0000644000176200001440000001042413431000556017665 0ustar liggesusersGIF87addç>JJIQbKƒSNJILX\ZZZXXXVVSRQEF,GGHHMHKKJIQ]\NfOOdP[¨bV„ZPW[VVWZ¦aX¤_Y¢`W¢^QRRW˜^Y.Z.+J^_J†Q\]:<HHUVDFSdZOP:G?nZKLJKIJGH)KKMQJJJQE65GFIMHZf\©bTUTSSSTQTUMUW¡]XŸ^Y›_LKV\V›\RIRW=WV•\W5W;OO#5HS3SW+WZ%Z6IJHI4K‰QK‡QUq[;=N!NK,AMMOOJMx!7IBA+LL89EF*J\qK(D67?POLLHFE[ZZDD4ONM8ITTSW SSRRF1LRRQQPPONNSDRMLL5)OLJKJLIKJJLHK-IJN,MIRKJMGF!\K4JJT€\DE<"LL8:78DE(DwVNP\[ZNP\YZEDMOKMCCWUUO%JMKKLKJIL|JIHINHGF\©c[©bZ§a0LLNaOQ…U<>ZXRSSW¡^V¡]VGWKJW^FES9T@E[!\K7LP+Q\]!KJ9;NONoUSTNOOPDDNODIHKLJUe57FE,1DYZY[¤aY¤_TTTT|WOVO$JIOPOGTJJJILLLSjVJJJKHKLDL; LS`VK@K0ONJˆPN€TRxX;<:<BC$EDLOpAEA@QQM68DC)GF\[[IEEXWWCDI>@UUTPOOOONJdjNMMMMLMKLV“[AQIHLKKIL}JIILCK:MMK‰P\[KxZ;=KJWG$PDPPHHTgY 7GÔ,ddþ9r$ ÁFǘۖäܹ†I BtØðáÉ-F¼˜±b’b™BŠ —’'Mš<™²åÊ—.Kœy0Â’(ãÒQä¸ÑãΞ;5JìH1×H‘»X¢\ÊE©J•Ma.•9f#²HDI$@(Ï C}zÚ‘ÏÑ᜺Œ“¥Û§)aÐ4x• Ž ã®ô ö+ѽDž8› êÔ·maª-)·ªãº5´Z£O²—ùv¤s6éb¨Ÿ†1°´éÓêtȺµë×°c³¦³kW&Û™Òryµ›÷+ßMyïî=¼¸ïã¯N+7}3JWÙУÃPû6ÉàÄÇ®]¸÷ì¿—þ‹·e›ôóÒ=ܶm[WÓáÝoïŽ>rñâe9ȉ¾?l£ÕÙ¶ÀwñmgŸÇõöÊ\Aæ˜#:´…1~eXe™uÔRÁÕáZˆMÕ˜At5ø`#@0£f?YÖb…q6Òî|ÈThŠyH‰ šÈ£#”ÇâX}&–Œ"‰ é(šŽ#Zåã\7¥ã"‘iV’!µÓ“!zÈÖh ô#]hÕ•XZ¾8ä#í@ -î°u˜9ÆD~|:"‹ Wø×_.ìÙFÌœTp—àw2ºhx}ò©3« ]/íšI;s¶£hvõ-*xÉEʧ&ÌPh)lÆC‹þ…Ê9'-s4*·~ú[©¦âgÇJ¬êZ)4ÌI {™|1+-‰>Š ¨óÝ×+ŸK˜'ì9­.‹²œÎꩳŽB‹«‚3 Tn‰göhfÛXéf‘»,-;ˆ´7óÎá$žcByî¹ê– Yƒ²\ñ\›B àê¼eè"$â”±, ûÚ)f˜qýk®#3”+pÀ2„åeòÎZƒâ¬2’⤱¬ãدžsÌq¹?²#šè„p@°l g´a4"áqˆ8‡˜1k%µÞi1ˆLî9m¤v¨*[:ÅÎY7m4`tuX÷"â rH ³²Þ³ôE«àÕ½.,ll3þ3´˜qHb‹6 Ö±6ÚÙ̪ÅÛáÆ=î®t›*K¥­¥ƒS„vàc‹ri‡.Û´T"MwSÀ«­¼FÎçZŸãÁ6‰0³ÎØs¶;!ÕÈáâˆsFÛÝy1Eã«?êŽë¦êàCé0€con½àäˆäË3ÆœÄç òªs¡€´ÔŒ3ÎÛÜñÍ6Ç_®I¹Ñøç¯Hgú!K[Ó¸ARôaO Dêd¢haVêƒ_ßGÁöá,ûË þŽs0-€Á[ZJP‚!ÀÅS»ÑKnÑ-ZP‚/¤ ûä! ÚÐhoÈÄxñA¦…PþÀèC ‚. 0f0 Z¸¬ ÎPc2¤¡ÍŽqC.¡Å‡Ð%©«˜4¨€‹y51†OÜXÕTQƒõ:B·(@@¡„kq†“æ‰ ˜q^Ì‹”&§¹BæîzFs‡.Vq8à‰Ÿ@E0@5/pÇ_¨Äg…"4!}‚!GÊëqλAùÈà!b \FÜP¸›óiò>àDNŠ^‚?:Ç(«§¹QriG÷ÐÖÊH!n„ „ÿxN€ ½Ì¦/¹œZ Ò¦Ô\tÁe:’™ÌlB0â& ÌËÖĦ6ç‰ 'Jq}0þ´YlñF ¾Ôð!éøÃC ã,Q"§ºq ¤ a/K0QTH”„%°§FÓ¨ qô3ƒ·8B9ç(À’~ÐRc;xá†OÀá ½hE-jј’P£hÌg¹zñÑ Š¢œÕ¢Iè ¬bph‚U‘›Òô©NÅ(Ni¸Fså@=ÕŸ/ZP¡vUŸà%E-šUDu¦Q½iN7*?;x4«ø[T‚Öu„PUÁEcŠÖšÖ´Ü4M„QLݕҘa@èÊJtº2mhãå5Ã}ÍoGæi­vÂÊ]<«*XaxŸ÷9àèEýÂTO:3>#L`B2”!^ /âï†4Ä¡þ­û@xÞ^ðÂ-H‘]t>Á²Áí8*È­|3vã-Ø4\A=¨ca EìaýþGÒÝ÷}Þç}ß÷O°Ì$}€~ê—MíU Ë7/cà4sRÝp“à РLÀÈø7'àlý·}ñæ¶@o~´¦ŸÀLå°Zé×qøGÝÀ 8(Hp êÀ=ø@¸Ëâdm±–‚¸‚ßçsÀžÇoýÖ€7'â  °ƒÑ—…Z¸… ˜´0]p{oÇf°{z7d}¨£à Ü„ߨ>¨Œ´pä°˜p‚Ï(€K¸„*ªPYLÕ€½D Wx ÞhŽäØêà £ðƒåøÉ 0+&7 A0‚°¦‚ñ˜„ðȪPÚTVøˆ H0 ÿx©zÝø‘@‹sò D€ úg€pI€IþoÁP)z‰ 9Ž9éy ÿh#©zXD@ Ëb>° 1É‚ðHoÒˆ 5© 3Øq;é‘åH’X•A‰Ýà ž`Fs°”ò¸”ô•”e‘ꇌj}Ð0 k}ÑÐ0/˜Ð и{pQ<—ˆ§8vo©–yЊoé?°,A &p—™— àS{iŠ…÷c©–£à“k‰7°,€˜Š™yO¹cÀÈW}ùW“©–Èà É –b0/FÀ™©wðð É‹>6vZù“:¹•¬è9 F0/”ðR –1©„H‘gÙK4I“ÊÙœôt›Ð¹•L`ŒV}/G ÂþIœMiœ, É •PÉœâ)ž5™MÐÙ@É›ê©Yù“O ’³‚ Ú9Üù’Lù}幜ýÙœQY‘éI’ÕiY0ýˆ è`ËòõyŸÜ¹„e  äi‘þY‘ª0 W©“íiŽÙ/ð•†ù MÉ”ø‘ßG‘úŸæ¹œªPš0:–9 N0—ËR¡ 𚃘 ÁÀ—‘é—1Zš’˜ z@ …¹,ž£;Ê£f(y5¤1ê U À€ƒZ ¦` MꤻgBd¡YT£/Ð¡ `:ˆyI¦}v¦0j¿¹,ô™£nú¦fø£¤×g J þѧ ØÙ  nZ¢cɨ0Ùû•Îy¡Ú¡š›¸ÉžL   Ÿ³‰ú‹ ~Jª ‘𠺢¨ëy©šêÀ 7ª£ê'zª1©¢ʪ•J¨*ƒ*"ª¤¡ ê¨&Zœ?Ú«-:ž/J§o9 ž`£ËB lЬ|ú‰PZ›¤)­k—I:+6À¦¡ ­Û:ˆ&ðÞ:¥àª–`Й‰§æ銋Ю$ô®jè`Fʦöz¯Ÿè§Rº¯üZ‰Êà w:¢K°ŸØ 1¤媘 HЇZ«¡j¯Êš«Ëú±& ¾­ {‡åЩf´¤ ±Ÿ˜¯e;geometry/vignettes/qhull/html/qh--geom.gif0000644000176200001440000000047613431000556020313 0ustar liggesusersGIF87a((òóóóLLL¿¿¿æææ,((þºÜþ0ÊIÙ¸8ëÍûŠ'Ž\Bª®lë²§‰’4‡_ ì@}Ÿ9@,òD¿gWl:{dPpZŸ¶N°©^^ãFÊÍ„Ÿ¼aŠ!›¿a5¶­–gpœ˜'°n}~Ciƒlƒ|Ui~WˆuJŠOŽ_~‰–•LVq˜‘Aš„Lrœ—€ e¢¥…œPn“kŽqŒŒŸ2¡¢‹g†;·[h›„k¿v‚k½hµÆ¨¸e^¤Òj¦§™£¦|tн®¥ÞÇJxpÝFÉÌÊåæSïzÔÍ|î–âÒc©–ô+•œ@]¾ ë  ’€#ÄÑØWÃÄŠ¥TØø Æ(^ˆI2E;geometry/vignettes/qhull/html/qh-faq.html0000644000176200001440000015664714664417655020316 0ustar liggesusers Qhull FAQ

Up: Home page for Qhull (local)
Up: Qhull Wiki and FAQ (local)
Up: Qhull manual: contents
To: Imprecision in Qhull
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: FAQ: contents


[4-d cube] Frequently Asked Questions about Qhull

If your question does not appear here, see:

Qhull is a general dimension code for computing convex hulls, Delaunay triangulations, halfspace intersections about a point, Voronoi diagrams, furthest-site Delaunay triangulations, and furthest-site Voronoi diagrams. These structures have applications in science, engineering, statistics, and mathematics. For a detailed introduction, see O'Rourke ['94], Computational Geometry in C.

There are separate programs for each application of Qhull. These programs disable experimental and inappropriate options. If you prefer, you may use Qhull directly. All programs run the same code.

Version 2019.1 adds an experimental option for vertex merging of nearly adjacent vertices ('Q14'). It may resolve topological issues such as "dupridges" with more than two facet neighbors.

Version 2015.1 introduced the reentrant library. It should be used for all code that calls Qhull. The 'qhull' program is built with the reentrant library.

Version 3.1 added triangulated output ('Qt'). It may be used for Delaunay triangulations instead of using joggled input ('QJ').

Brad Barber, Arlington MA, 2019/02/11

Copyright © 1998-2020 C.B. Barber


»FAQ: contents

Within each category, the most recently asked questions are first.

  • Startup questions
    • How do I run Qhull from Windows?
    • How do I enter points for Qhull?
    • How do I learn to use Qhull?
  • Convex hull questions
    • How do I report just the area and volume of a convex hull?
    • Why are there extra points in a 4-d or higher convex hull?
    • How do I report duplicate vertices?
  • Delaunay triangulation questions
    • How do I get rid of nearly flat Delaunay triangles?
    • How do I find the Delaunay triangle or Voronoi region that is closest to a point?
    • How do I compute the Delaunay triangulation of a non-convex object?
    • How do I mesh a volume from a set of triangulated surface points?
    • Can Qhull produce a triangular mesh for an object?
    • For 3-d Delaunay triangulations, how do I report the triangles of each tetrahedron?
    • How do I construct a 3-d Delaunay triangulation?
    • How do I get the triangles for a 2-d Delaunay triangulation and the vertices of its Voronoi diagram?
    • Can Qhull triangulate a hundred 16-d points?
  • Voronoi diagram questions
    • See also "Delaunay diagram questions". Qhull computes the Voronoi diagram from the Delaunay triagulation.
    • How do I compute the volume of a Voronoi region?
    • How do I get the radii of the empty spheres for each Voronoi vertex?
    • What is the Voronoi diagram of a square?
    • How do I construct the Voronoi diagram of cospherical points?
    • Can Qhull compute the unbounded rays of the Voronoi diagram?
  • Approximation questions
    • How do I approximate data with a simplex?
  • Halfspace questions
    • How do I compute the intersection of halfspaces with Qhull?
  • Qhull library questions
    • Is Qhull available for Mathematica, Matlab, or Maple?
    • Why are there too few ridges?
    • Can Qhull use coordinates without placing them in a data file?
    • How large are Qhull's data structures?
    • Can Qhull construct convex hulls and Delaunay triangulations one point at a time?
    • How do I visit the ridges of a Delaunay triangulation?
    • How do I visit the Delaunay facets?
    • When is a point outside or inside a facet?
    • How do I find the facet that is closest to a point?
    • How do I find the Delaunay triangle or Voronoi region that is closest to a point?
    • How do I list the vertices?
    • How do I test code that uses the Qhull library?
    • When I compute a plane equation from a facet, I sometimes get an outward-pointing normal and sometimes an inward-pointing normal

»Startup questions

»How do I run Qhull from Windows?

Qhull is a console program. You will first need a command window (i.e., a "command prompt"). You can double click on 'eg\Qhull-go.bat'.

  • Type 'qconvex', 'qdelaunay', 'qhalf', 'qvoronoi, 'qhull', and 'rbox' for a synopsis of each program.
  • Type 'rbox c D2 | qconvex s i' to compute the convex hull of a square.
  • Type 'rbox c D2 | qconvex s i TO results.txt' to write the results to the file 'results.txt'. A summary is still printed on the the console.
  • Type 'rbox c D2' to see the input format for qconvex.
  • Type 'qconvex < data.txt s i TO results.txt' to read input data from 'data.txt'.
  • If you want to enter data by hand, type 'qconvex s i TO results.txt' to read input data from the console. Type in the numbers and end with a ctrl-D.

If you regularly use Qhull on a Windows host, install a bash shell such as

  • Git for Windows (wiki, based on MSYS2) -- Git for Windows v2.21 requires arguments for 'qhull', otherwise it waits for stdin. Use 'qhull --help' for a usage note instead of 'qhull'.
  • MSYS2 (wiki)
  • Cygwin

If you use Windows XP or Windows 8, you may use

»How do I enter points for Qhull?

Qhull takes its data from standard input (stdin). For example, create a file named 'data.txt' with the following contents:

2  #sample 2-d input
5  #number of points
1 2  #coordinates of points
-1.1 3
3 2.2
4 5
-10 -10

Then call qconvex with 'qconvex < data.txt'. It will print a summary of the convex hull. Use 'qconvex < data.txt o' to print the vertices and edges. See also input format.

You can generate sample data with rbox. For example, 'rbox 10' generates 10 random points in 3-d. Use a pipe ('|') to run rbox and qhull together, e.g.,

rbox c | qconvex o

computes the convex hull of a cube.

»How do I learn to use Qhull?

First read:

Look at Qhull's on-line documentation:

  • 'rbox' lists all of the options for generating point sets
  • 'qconvex --help' gives a synopsis of qconvex and its options
  • 'qconvex -' lists all of the options for qconvex
  • 'qconvex .' gives a concise list of options
  • 'qdelaunay', 'qhalf', 'qvoronoi', and 'qhull' also have a synopsis and options

Then try out the Qhull programs on small examples.

  • 'rbox c' -- lists the vertices of a cube
  • 'rbox c D2 | qconvex' -- is the convex hull of a square
  • 'rbox c D2 | qconvex o' -- lists the vertices and facets of a square
  • 'rbox c | qconvex' -- is the convex hull of a cube
  • 'rbox c | qconvex o' -- lists the vertices and facets of a cube
  • 'rbox c | qconvex Qt o' -- triangulates the cube
  • 'rbox c | qconvex QJ o' -- joggles the input and triangulates the cube
  • 'rbox c D4 | qconvex' -- is the convex hull of a hypercube

  • 'rbox 6 s D2 t | qconvex p Fx' -- is the convex hull of 6 random, cocircular points. Option 'p' lists the points while option 'Fx' lists the vertices in order.

  • 'rbox d D2 c G2 | qdelaunay' -- is the Delaunay triangulation of a diamond and a square. The diamond's vertices are cocircular.
  • 'rbox d D2 c G2 | qdelaunay o' -- lists the input sites projected to a paraboloid and the Delaunay regions. The region with 4 vertices is the diamond.
  • 'rbox d D2 c G2 | qdelaunay o Qt' -- the cocircular diamond is triangulated as two Delaunay regions.
  • 'rbox d D2 c G2 | qdelaunay o QJ' -- the input is joggled and the diamond is triangulated.

  • 'rbox d D2 c G2 | qvoronoi o' -- is the Voronoi regions for a diamond and a square. The Voronoi vertex for the diamond is the origin (0,0). Unbounded regions are represented by the first vertex (-10.101 -10.101)
  • 'rbox d D2 c G2 | qvoronoi Fv' -- shows the Voronoi diagram for the previous example. Each line is one edge of the diagram. The first number is 4, the next two numbers list a pair of input sites, and the last two numbers list the corresponding pair of Voronoi vertices.
  • 'rbox d D2 c G2 | qvoronoi o Qt' -- the cocircular Delaunay region is triangulated. Instead of one Voronoi vertex for the diamond, there are two Voronoi vertices (0,0) and (0,0).

Install Geomview if you are running SGI Irix, Solaris, SunOS, Linux, HP, IBM RS/6000, DEC Alpha, or Next. You can then visualize the output of Qhull. Qhull comes with Geomview examples.

Then try Qhull with a small example of your application. Work out the results by hand. Then experiment with Qhull's options to find the ones that you need.

You will need to decide how Qhull should handle precision problems. It can triangulate the output ('Qt'), joggle the input ('QJ'), or merge facets (the default).

  • With triangulated output, Qhull merges facets and triangulates the result.
  • With joggle, Qhull produces simplicial (i.e., triangular) output by joggling the input. After joggle, no points are cocircular or cospherical.
  • With facet merging, Qhull produces a better approximation than joggle, nor does it modify the input.
  • See Merged facets or joggled input.

»Convex hull questions

»How do I report just the area and volume of a convex hull?

Use option 'FS' or 'FA'. The area is the area of the surface of the convex hull, while the volume is the total volume of the convex hull.

For example,

rbox 10 | qconvex FS
0
2 2.192915621644613 0.2027867899638665

rbox 10 | qconvex FA

Convex hull of 10 points in 3-d:

  Number of vertices: 10
  Number of facets: 16

Statistics for: RBOX 10 | QCONVEX FA

  Number of points processed: 10
  Number of hyperplanes created: 28
  Number of distance tests for qhull: 44
  CPU seconds to compute hull (after input):  0
  Total facet area:   2.1929156
  Total volume:       0.20278679

In 2-d, the convex hull is a polygon. Its surface is the edges of a polygon. So in 2-d, the 'area' is the length of the polygon's edges, while the 'volume' is the area of the polygon.

For example the convex hull of a square,

rbox c D2 | qconvex FS
0
2      4      1

rbox c D2 | qconvex FA

Convex hull of 4 points in 2-d:

  Number of vertices: 4
  Number of facets: 4

Statistics for: rbox c D2 | qconvex FA

  Number of points processed: 4
  Number of hyperplanes created: 6
  Number of distance tests for qhull: 5
  CPU seconds to compute hull (after input):  0
  Total facet area:    4
  Total volume:        1

»Why are there extra points in a 4-d or higher convex hull?

Options 'i' (in 4-D and higher) and 'Ft' (in 3-D and higher) use "extra" points for non-simplicial facets (e.g., a face of a cube or hypercube). These points are not part of the convex hull. Options 'i' and 'Ft' triangulate non-simplicial facets using the facet's centrum.

For example, Qhull reports the following for one facet of the convex hull of a hypercube. The facets of a 4-D hypercube are 3-d cubes. Option 'Pd0:0.5' returns the facet along the positive-x axis. Point 17 represents the centrum of this facet. The facet's vertices are eight points: point 8 to point 15

rbox c D4 | qconvex i Pd0:0.5
12
17 13 14 15
17 13 12 14
17 11 13 15
17 14 11 15
17 10 11 14
17 14 12 8
17 12 13 8
17 10 14 8
17 11 10 8
17 13 9 8
17 9 11 8
17 11 9 13

rbox c D4 | qconvex Fx Pd0:0.5
8
8
9
10
11
12
13
14
15

The 4-d hypercube has 16 vertices; so point "17" was added by qconvex. Qhull adds the point in order to report a simplicial decomposition of the facet. The point corresponds to the "centrum" which Qhull computes to test for convexity.

Triangulate the output ('Qt') to avoid the extra points. Since the hypercube is 4-d, each simplicial facet is a tetrahedron.

C:\qhull3.1>rbox c D4 | qconvex i Pd0:0.5 Qt
9
9 13 14 15
12 9 13 14
9 11 13 15
11 9 14 15
9 10 11 14
12 9 14 8
9 12 13 8
9 10 14 8
10 9 11 8

Use the 'Fv' option to print the vertices of simplicial and non-simplicial facets. For example, here is the same hypercube facet with option 'Fv' instead of 'i':

C:\qhull>rbox c D4 | qconvex Pd0:0.5 Fv
1
8 9 10 12 11 13 14 15 8

The coordinates of the extra point are printed with the 'Ft' option. For centrums, option 'Ft' uses indices one less than option 'i'. In this case, point 16 represents the centrum of the facet.

rbox c D4 | qconvex Pd0:0.5 Ft
4
17 12 3
  -0.5   -0.5   -0.5   -0.5
  -0.5   -0.5   -0.5    0.5
  -0.5   -0.5    0.5   -0.5
  -0.5   -0.5    0.5    0.5
  -0.5    0.5   -0.5   -0.5
  -0.5    0.5   -0.5    0.5
  -0.5    0.5    0.5   -0.5
  -0.5    0.5    0.5    0.5
   0.5   -0.5   -0.5   -0.5
   0.5   -0.5   -0.5    0.5
   0.5   -0.5    0.5   -0.5
   0.5   -0.5    0.5    0.5
   0.5    0.5   -0.5   -0.5
   0.5    0.5   -0.5    0.5
   0.5    0.5    0.5   -0.5
   0.5    0.5    0.5    0.5
   0.5      0      0      0
4 16 13 14 15
4 16 13 12 14
4 16 11 13 15
4 16 14 11 15
4 16 10 11 14
4 16 14 12 8
4 16 12 13 8
4 16 10 14 8
4 16 11 10 8
4 16 13 9 8
4 16 9 11 8
4 16 11 9 13

»How do I report duplicate vertices?

There's no direct way. You can use option 'FP' to report the distance to the nearest vertex for coplanar input points. Select the minimum distance for a duplicated vertex, and locate all input sites less than this distance.

For Delaunay triangulations, all coplanar points are nearly incident to a vertex. If you want a report of coincident input sites, do not use option 'QJ'. By adding a small random quantity to each input coordinate, it prevents coincident input sites.

»Delaunay triangulation questions

»How do I get rid of nearly flat Delaunay triangles?

Nearly flat triangles occur when boundary points are nearly collinear or coplanar. They also occur for nearly coincident points. Both events can easily occur when using joggle. For example (rbox 10 W0 D2 | qdelaunay QJ Fa) lists the areas of the Delaunay triangles of 10 points on the boundary of a square. Some of these triangles are nearly flat. This occurs when one point is joggled inside of two other points. In this case, nearly flat triangles do not occur with triangulated output (rbox 10 W0 D2 | qdelaunay Qt Fa).

Another example, (rbox c P0 P0 D2 | qdelaunay QJ Fa), computes the areas of the Delaunay triangles for the unit square and two instances of the origin. Four of the triangles have an area of 0.25 while two have an area of 2.0e-11. The later are due to the duplicated origin. With triangulated output (rbox c P0 P0 D2 | qdelaunay Qt Fa) there are four triangles of equal area.

Nearly flat triangles also occur without using joggle. For example, (rbox c P0 P0,0.4999999999 | qdelaunay Fa), computes the areas of the Delaunay triangles for the unit square, a nearly collinear point, and the origin. One triangle has an area of 3.3e-11.

Unfortunately, none of Qhull's merging options remove nearly flat Delaunay triangles due to nearly collinear or coplanar boundary points. The merging options concern the empty circumsphere property of Delaunay triangles. This is independent of the area of the Delaunay triangles. Qhull does handle nearly coincident points.

If you are calling Qhull from a program, you can merge slivers into an adjacent facet. In d dimensions with simplicial facets (e.g., from 'Qt'), each facet has d+1 neighbors. Each neighbor shares d vertices of the facet's d+1 vertices. Let the other vertex be the opposite vertex. For each neighboring facet, if its circumsphere includes the opposite.vertex, the two facets can be merged. [M. Treacy]

You can handle collinear or coplanar boundary points by enclosing the points in a box. For example, (rbox c P0 P0,0.4999999999 c G1 | qdelaunay Fa), surrounds the previous points with [(1,1), (1,-1), (-1,-1), (-1, 1)]. Its Delaunay triangulation does not include a nearly flat triangle. The box also simplifies the graphical output from Qhull.

Without joggle, Qhull lists coincident points as "coplanar" points. For example, (rbox c P0 P0 D2 | qdelaunay Fa), ignores the duplicated origin and lists four triangles of size 0.25. Use 'Fc' to list the coincident points (e.g., rbox c P0 P0 D2 | qdelaunay Fc).

There is no easy way to determine coincident points with joggle. Joggle removes all coincident, cocircular, and cospherical points before running Qhull. Instead use facet merging (the default) or triangulated output ('Qt').

»How do I compute the Delaunay triangulation of a non-convex object?

A similar question is "How do I mesh a volume from a set of triangulated surface points?"

This is an instance of the constrained Delaunay Triangulation problem. Qhull does not handle constraints. The boundary of the Delaunay triangulation is always convex. But if the input set contains enough points, the triangulation will include the boundary. The number of points needed depends on the input.

Shewchuk has developed a theory of constrained Delaunay triangulations. See his paper at the 1998 Computational Geometry Conference. Using these ideas, constraints could be added to Qhull. They would have many applications.

There is a large literature on mesh generation and many commercial offerings. For pointers see Owen's International Meshing Roundtable and Schneiders' Finite Element Mesh Generation page.

»Can Qhull produce a triangular mesh for an object?

Yes for convex objects, no for non-convex objects. For non-convex objects, it triangulates the concavities. Unless the object has many points on its surface, triangles may cross the surface.

»For 3-d Delaunay triangulations, how do I report the triangles of each tetrahedron?

For points in general position, a 3-d Delaunay triangulation generates tetrahedron. Each face of a tetrahedron is a triangle. For example, the 3-d Delaunay triangulation of random points on the surface of a cube, is a cellular structure of tetrahedron.

Use triangulated output ('qdelaunay Qt i') or joggled input ('qdelaunay QJ i') to generate the Delaunay triangulation. Option 'i' reports each tetrahedron. The triangles are every combination of 3 vertices. Each triangle is a "ridge" of the Delaunay triangulation.

For example,

        rbox 10 | qdelaunay Qt i
        14
        9 5 8 7
        0 9 8 7
        5 3 8 7
        3 0 8 7
        5 4 8 1
        4 6 8 1
        2 9 5 8
        4 2 5 8
        4 2 9 5
        6 2 4 8
        9 2 0 8
        2 6 0 8
        2 4 9 1
        2 6 4 1

is the Delaunay triangulation of 10 random points. Ridge 9-5-8 occurs twice. Once for tetrahedron 9 5 8 7 and the other for tetrahedron 2 9 5 8.

You can also use the Qhull library to generate the triangles. See 'How do I visit the ridges of a Delaunay triangulation?'

»How do I construct a 3-d Delaunay triangulation?

For 3-d Delaunay triangulations with cospherical input sites, use triangulated output ('Qt') or joggled input ('QJ'). Otherwise option 'i' will triangulate non-simplicial facets with the facet's centrum.

If you want non-simplicial output for cospherical sites, use option 'Fv' or 'o'. For option 'o', ignore the last coordinate. It is the lifted coordinate for the corresponding convex hull in 4-d.

The following example is a cube inside a tetrahedron. The 8-vertex facet is the cube. Ignore the last coordinates.

C:\qhull>rbox r y c G0.1 | qdelaunay Fv
4
12 20 44
   0.5      0      0 0.3055555555555555
   0    0.5      0 0.3055555555555555
   0      0    0.5 0.3055555555555555
  -0.5   -0.5   -0.5 0.9999999999999999
  -0.1   -0.1   -0.1 -6.938893903907228e-018
  -0.1   -0.1    0.1 -6.938893903907228e-018
  -0.1    0.1   -0.1 -6.938893903907228e-018
  -0.1    0.1    0.1 -6.938893903907228e-018
   0.1   -0.1   -0.1 -6.938893903907228e-018
   0.1   -0.1    0.1 -6.938893903907228e-018
   0.1    0.1   -0.1 -6.938893903907228e-018
   0.1    0.1    0.1 -6.938893903907228e-018
4 2 11 1 0
4 10 1 0 3
4 11 10 1 0
4 2 9 0 3
4 9 11 2 0
4 7 2 1 3
4 11 7 2 1
4 8 10 0 3
4 9 8 0 3
5 8 9 10 11 0
4 10 6 1 3
4 6 7 1 3
5 6 8 10 4 3
5 6 7 10 11 1
4 5 9 2 3
4 7 5 2 3
5 5 8 9 4 3
5 5 6 7 4 3
8 5 6 8 7 9 10 11 4
5 5 7 9 11 2

If you want simplicial output use options 'Qt i' or 'QJ i', e.g.,

rbox r y c G0.1 | qdelaunay Qt i
31
2 11 1 0
11 10 1 0
9 11 2 0
11 7 2 1
8 10 0 3
9 8 0 3
10 6 1 3
6 7 1 3
5 9 2 3
7 5 2 3
9 8 10 11
8 10 11 0
9 8 11 0
6 8 10 4
8 6 10 3
6 8 4 3
6 7 10 11
10 6 11 1
6 7 11 1
8 5 4 3
5 8 9 3
5 6 4 3
6 5 7 3
5 9 10 11
8 5 9 10
7 5 10 11
5 6 7 10
8 5 10 4
5 6 10 4
5 9 11 2
7 5 11 2

»How do I get the triangles for a 2-d Delaunay triangulation and the vertices of its Voronoi diagram?

To compute the Delaunay triangles indexed by the indices of the input sites, use

rbox 10 D2 | qdelaunay Qt i

To compute the Voronoi vertices and the Voronoi region for each input site, use

rbox 10 D2 | qvoronoi o

To compute each edge ("ridge") of the Voronoi diagram for each pair of adjacent input sites, use

rbox 10 D2 | qvoronoi Fv

To compute the area and volume of the Voronoi region for input site 5 (site 0 is the first one), use

rbox 10 D2 | qvoronoi QV5 p | qconvex s FS

To compute the lines ("hyperplanes") that define the Voronoi region for input site 5, use

rbox 10 D2 | qvoronoi QV5 p | qconvex n

or

rbox 10 D2 | qvoronoi QV5 Fi Fo

To list the extreme points of the input sites use

rbox 10 D2 | qdelaunay Fx

You will get the same point ids with

rbox 10 D2 | qconvex Fx

»Can Qhull triangulate a hundred 16-d points?

No. This is an immense structure. A triangulation of 19, 16-d points has 43 simplices. If you add one point at a time, the triangulation increased as follows: 43, 189, 523, 1289, 2830, 6071, 11410, 20487. The last triangulation for 26 points used 13 megabytes of memory. When Qhull uses virtual memory, it becomes too slow to use.

»Voronoi diagram questions

»How do I compute the volume of a Voronoi region?

For each Voronoi region, compute the convex hull of the region's Voronoi vertices. The volume of each convex hull is the volume of the corresponding Vornoi region.

For example, to compute the volume of the bounded Voronoi region about [0,0,0]: output the origin's Voronoi vertices and compute the volume of their convex hull. The last number from option 'FS' is the volume.

rbox P0 10 | qvoronoi QV0 p | qhull FS
0
2 1.448134756744281 0.1067973560800857

For another example, see How do I get the triangles for a 2-d Delaunay triangulation and the vertices of its Voronoi diagram?

This approach is slow if you are using the command line. A faster approcach is to call Qhull from a program. The fastest method is Clarkson's hull program. It computes the volume for all Voronoi regions.

An unbounded Voronoi region does not have a volume.

»How do I get the radii of the empty spheres for each Voronoi vertex?

Use option 'Fi' to list each bisector (i.e. Delaunay ridge). Then compute the minimum distance for each Voronoi vertex.

There's other ways to get the same information. Let me know if you find a better method.

»What is the Voronoi diagram of a square?

Consider a square,

C:\qhull>rbox c D2
2 RBOX c D2
4
  -0.5   -0.5
  -0.5    0.5
   0.5   -0.5
   0.5    0.5

There's two ways to compute the Voronoi diagram: with facet merging or with joggle. With facet merging, the result is:

C:\qhull>rbox c D2 | qvoronoi Qz

Voronoi diagram by the convex hull of 5 points in 3-d:

  Number of Voronoi regions and at-infinity: 5
  Number of Voronoi vertices: 1
  Number of facets in hull: 5

Statistics for: RBOX c D2 | QVORONOI Qz

  Number of points processed: 5
  Number of hyperplanes created: 7
  Number of distance tests for qhull: 8
  Number of merged facets: 1
  Number of distance tests for merging: 29
  CPU seconds to compute hull (after input):  0

C:\qhull>rbox c D2 | qvoronoi Qz o
2
2 5 1
-10.101 -10.101
     0      0
2 0 1
2 0 1
2 0 1
2 0 1
0

C:\qhull>rbox c D2 | qvoronoi Qz Fv
4
4 0 1 0 1
4 0 2 0 1
4 1 3 0 1
4 2 3 0 1

There is one Voronoi vertex at the origin and rays from the origin along each of the coordinate axes. The last line '4 2 3 0 1' means that there is a ray that bisects input points #2 and #3 from infinity (vertex 0) to the origin (vertex 1). Option 'Qz' adds an artificial point since the input is cocircular. Coordinates -10.101 indicate the vertex at infinity.

With triangulated output, the Voronoi vertex is duplicated:

C:\qhull3.1>rbox c D2 | qvoronoi Qt Qz

Voronoi diagram by the convex hull of 5 points in 3-d:

  Number of Voronoi regions and at-infinity: 5
  Number of Voronoi vertices: 2
  Number of triangulated facets: 1

Statistics for: RBOX c D2 | QVORONOI Qt Qz

  Number of points processed: 5
  Number of hyperplanes created: 7
  Number of facets in hull: 6
  Number of distance tests for qhull: 8
  Number of distance tests for merging: 33
  Number of distance tests for checking: 30
  Number of merged facets: 1
  CPU seconds to compute hull (after input): 0.05

C:\qhull3.1>rbox c D2 | qvoronoi Qt Qz o
2
3 5 1
-10.101 -10.101
     0      0
     0      0
3 2 0 1
2 1 0
2 2 0
3 2 0 1
0

C:\qhull3.1>rbox c D2 | qvoronoi Qt Qz Fv
4
4 0 2 0 2
4 0 1 0 1
4 1 3 0 1
4 2 3 0 2

With joggle, the input is no longer cocircular and the Voronoi vertex is split into two:

C:\qhull>rbox c D2 | qvoronoi Qt Qz

C:\qhull>rbox c D2 | qvoronoi QJ o
2
3 4 1
-10.101 -10.101
-4.71511718558304e-012 -1.775812830118184e-011
9.020340030474472e-012 -4.02267108512433e-012
2 0 1
3 2 1 0
3 2 0 1
2 2 0

C:\qhull>rbox c D2 | qvoronoi QJ Fv
5
4 0 2 0 1
4 0 1 0 1
4 1 2 1 2
4 1 3 0 2
4 2 3 0 2

Note that the Voronoi diagram includes the same rays as before plus a short edge between the two vertices.

»How do I construct the Voronoi diagram of cospherical points?

Three-dimensional terrain data can be approximated with cospherical points. The Delaunay triangulation of cospherical points is the same as their convex hull. If the points lie on the unit sphere, the facet normals are the Voronoi vertices [via S. Fortune].

For example, consider the points {[1,0,0], [-1,0,0], [0,1,0], ...}. Their convex hull is:

rbox d G1 | qconvex o
3
6 8 12
     0      0     -1
     0      0      1
     0     -1      0
     0      1      0
    -1      0      0
     1      0      0
3 3 1 4
3 1 3 5
3 0 3 4
3 3 0 5
3 2 1 5
3 1 2 4
3 2 0 4
3 0 2 5

The facet normals are:

rbox d G1 | qconvex n
4
8
-0.5773502691896258  0.5773502691896258  0.5773502691896258 -0.5773502691896258
 0.5773502691896258  0.5773502691896258  0.5773502691896258 -0.5773502691896258
-0.5773502691896258  0.5773502691896258 -0.5773502691896258 -0.5773502691896258
 0.5773502691896258  0.5773502691896258 -0.5773502691896258 -0.5773502691896258
 0.5773502691896258 -0.5773502691896258  0.5773502691896258 -0.5773502691896258
-0.5773502691896258 -0.5773502691896258  0.5773502691896258 -0.5773502691896258
-0.5773502691896258 -0.5773502691896258 -0.5773502691896258 -0.5773502691896258
 0.5773502691896258 -0.5773502691896258 -0.5773502691896258 -0.5773502691896258

If you drop the offset from each line (the last number), each line is the Voronoi vertex for the corresponding facet. The neighboring facets for each point define the Voronoi region for each point. For example:

rbox d G1 | qconvex FN
6
4 7 3 2 6
4 5 0 1 4
4 7 4 5 6
4 3 1 0 2
4 6 2 0 5
4 7 3 1 4

The Voronoi vertices {7, 3, 2, 6} define the Voronoi region for point 0. Point 0 is [0,0,-1]. Its Voronoi vertices are

-0.5773502691896258  0.5773502691896258 -0.5773502691896258
 0.5773502691896258  0.5773502691896258 -0.5773502691896258
-0.5773502691896258 -0.5773502691896258 -0.5773502691896258
 0.5773502691896258 -0.5773502691896258 -0.5773502691896258

In this case, the Voronoi vertices are oriented, but in general they are unordered.

By taking the dual of the Delaunay triangulation, you can construct the Voronoi diagram. For cospherical points, the convex hull vertices for each facet, define the input sites for each Voronoi vertex. In 3-d, the input sites are oriented. For example:

rbox d G1 | qconvex i
8
3 1 4
1 3 5
0 3 4
3 0 5
2 1 5
1 2 4
2 0 4
0 2 5

The convex hull vertices for facet 0 are {3, 1, 4}. So Voronoi vertex 0 (i.e., [-0.577, 0.577, 0.577]) is the Voronoi vertex for input sites {3, 1, 4} (i.e., {[0,1,0], [0,0,1], [-1,0,0]}).

»Can Qhull compute the unbounded rays of the Voronoi diagram?

Use 'Fo' to compute the separating hyperplanes for unbounded Voronoi regions. The corresponding ray goes to infinity from the Voronoi vertices. The midpoint between input sites replaces the Voronoi vertex at infinity. Alternatively, if you enclose the input sites in a large enough box, the outermost bounded regions will represent the unbounded regions of the original points.

If you do not box the input sites, you can identify the unbounded regions. They list '0' as a vertex. Vertex 0 represents "infinity". Each unbounded ray includes vertex 0 in option 'Fv. See Voronoi graphics and Voronoi notes.

»Approximation questions

»How do I approximate data with a simplex

Qhull may be used to help select a simplex that approximates a data set. It will take experimentation. Geomview will help to visualize the results. This task may be difficult to do in 5-d and higher. Use rbox options 'x' and 'y' to produce random distributions within a simplex. Your methods work if you can recover the simplex.

Use Qhull's precision options to get a first approximation to the hull, say with 10 to 50 facets. For example, try 'C0.05' to remove small facets after constructing the hull. Use 'W0.05' to ignore points within 0.05 of a facet. Use 'PA5' to print the five largest facets by area.

Then use other methods to fit a simplex to this data. Remove outlying vertices with few nearby points. Look for large facets in different quadrants. You can use option 'Pd0d1d2' to print all the facets in a quadrant.

In 4-d and higher, use the outer planes (option 'Fo' or 'facet->maxoutside') since the hyperplane of an approximate facet may be below many of the input points.

For example, consider fitting a cube to 1000 uniformly random points in the unit cube. In this case, the first try was good:

rbox 1000 | qconvex W0.05 C0.05 PA6 Fo
4
6
0.35715408374381 0.08706467018177928 -0.9299788727015564 -0.5985514741284483
0.995841591359023 -0.02512604712761577 0.08756829720435189 -0.5258834069202866
0.02448099521570909 -0.02685210459017302 0.9993396046151313 -0.5158104982631999
-0.9990223929415094 -0.01261133513150079 0.04236994958247349 -0.509218270408407
-0.0128069014364698 -0.9998380680115362 0.01264203427283151 -0.5002512653670584
0.01120895057872914 0.01803671994177704 -0.9997744926535512 -0.5056824072956361

»Halfspace questions

»How do I compute the intersection of halfspaces with Qhull?

Qhull computes the halfspace intersection about a point. The point must be inside all of the halfspaces. Given a point, a duality turns a halfspace intersection problem into a convex hull problem.

Use linear programming if you do not know a point in the interior of the halfspaces. See the notes for qhalf. You will need a linear programming code. This may require a fair amount of work to implement.

»Qhull library questions

»Is Qhull available for Mathematica, Matlab, or Maple?

MATLAB

Z. You of MathWorks added qhull to MATLAB 6. See functions convhulln, delaunayn, griddatan, tsearchn, and voronoin. V. Brumberg update MATLAB R14 for Qhull 2003.1 and triangulated output.

Engwirda wrote mesh2d for unstructured mesh generation in MATLAB. It is based on the iterative method of Persson and generally results in better quality meshes than delaunay refinement.

Mathematica and Maple

See qh-math for a Delaunay interface to Mathematica. It includes projects for CodeWarrior on the Macintosh and Visual C++ on Win32 PCs.

See Mathematica ('m') and Maple ('FM') output options.

»Why are there too few ridges?

The following sample code may produce fewer ridges than expected:
  facetT *facetp;
  ridgeT *ridge, **ridgep;

  FORALLfacets {
    printf("facet f%d\n", facet->id);
    FOREACHridge_(facet->ridges) {
      printf("   ridge r%d between f%d and f%d\n", ridge->id, ridge->top->id, ridge->bottom->id);
    }
  }

Qhull does not create ridges for simplicial facets. Instead it computes ridges from facet->neighbors. To make ridges for a simplicial facet, use qh_makeridges() in merge.c. Use facet->visit_id to visit each ridge once (instead of twice). For example,

  facetT *facet, *neighbor;
  ridgeT *ridge, **ridgep;

  qh visit_id++;
  FORALLfacets {
    printf("facet f%d\n", facet->id);
    qh_makeridges(facet);
    facet->visitId= qh visit_id;
    FOREACHridge_(facet->ridges) {
        neighbor= otherfacet_(ridge, visible);
        if (neighbor->visitid != qh visit_id)
            printf("   ridge r%d between f%d and f%d\n", ridge->id, ridge->top->id, ridge->bottom->id);
    }
  }

»Can Qhull use coordinates without placing them in a data file?

You may call Qhull from a program. Please use the reentrant Qhull library (libqhullstatic_r.a, libqhull_r.so, or qhull_r.dll). See user_eg.c and "Qhull-template" in user_r.c for examples.. See Qhull code for an introduction to Qhull's reentrant library and its C++ interface.

Hint: Start with a small example for which you know the answer.

»How large are Qhull's data structures?

Qhull uses a general-dimension data structure. The size depends on the dimension. Use option 'Ts' to print out the memory statistics [e.g., 'rbox D2 10 | qconvex Ts'].

Qhull's data structures use many pointers. For 64-bit code, pointers are twice the size of integers. For 64-bit code, Qhull uses 50% more memory. It there is not enough memory in the computer's level 1 and level 2 caches, Qhull will run slower as it retrieves data from main memory. A future version of Qhull will include memory and performance improvements for 64-bit code.

»Can Qhull construct convex hulls and Delaunay triangulations one point at a time?

The Qhull library may be used to construct convex hulls and Delaunay triangulations one point at a time. It may not be used for deleting points or moving points.

Qhull is designed for batch processing. Neither Clarkson's randomized incremental algorithm nor Qhull are designed for on-line operation. For many applications, it is better to reconstruct the convex hull or Delaunay triangulation from scratch for each new point.

With random point sets and on-line processing, Clarkson's algorithm should run faster than Qhull. Clarkson uses the intermediate facets to reject new, interior points, while Qhull, when used on-line, visits every facet to reject such points. If used on-line for n points, Clarkson may take O(n) times as much memory as the average off-line case, while Qhull's space requirement does not change.

If you triangulate the output before adding all the points (option 'Qt' and procedure qh_triangulate), you must set option 'Q11'. It duplicates the normals of triangulated facets and recomputes the centrums. This should be avoided for regular use since triangulated facets are not clearly convex with their neighbors. It appears to work most of the time, but fails for cases that Qhull normally handles well [see the test call to qh_triangulate in qh_addpoint].

»How do I visit the ridges of a Delaunay triangulation?

To visit the ridges of a Delaunay triangulation, visit each facet. Each ridge will appear twice since it belongs to two facets. In pseudo-code:

    for each facet of the triangulation
        if the facet is Delaunay (i.e., part of the lower convex hull)
            for each ridge of the facet
                if the ridge's neighboring facet has not been visited
                    ... process a ridge of the Delaunay triangulation ...

In undebugged, C code:

    qh visit_id++;
    FORALLfacets_(facetlist)
        if (!facet->upperdelaunay) {
            facet->visitid= qh visit_id;
            qh_makeridges(facet);
            FOREACHridge_(facet->ridges) {
                neighbor= otherfacet_(ridge, facet);
                if (neighbor->visitid != qh visit_id) {
                    /* Print ridge here with facet-id and neighbor-id */
                    /*fprintf(fp, "f%d\tf%d\t",facet->id,neighbor->ID);*/
                    FOREACHvertex_(ridge->vertices)
                        fprintf(fp,"%d ",qh_pointid (vertex->point) );
                    qh_printfacetNvertex_simplicial (fp, facet, format);
                    fprintf(fp," ");
                    if(neighbor->upperdelaunay)
                        fprintf(fp," -1 -1 -1 -1 ");
                    else
                        qh_printfacetNvertex_simplicial (fp, neighbor, format);
                    fprintf(fp,"\n");
                }
            }
        }
    }

»How do I visit the Delaunay regions?

Qhull constructs a Delaunay triangulation by lifting the input sites to a paraboloid. The Delaunay triangulation corresponds to the lower convex hull of the lifted points. To visit each facet of the lower convex hull, use:

    facetT *facet;

    ...
    FORALLfacets {
        if (!facet->upperdelaunay) {
            ... only facets for Delaunay regions ...
        }
    }

»When is a point outside or inside a facet?

A point is outside of a facet if it is clearly outside the facet's outer plane. The outer plane is defined by an offset (facet->maxoutside) from the facet's hyperplane.

    facetT *facet;
    pointT *point;
    realT dist;

    ...
    qh_distplane(point, facet, &dist);
    if (dist > facet->maxoutside + 2 * qh DISTround) {
        /* point is clearly outside of facet */
    }

A point is inside of a facet if it is clearly inside the facet's inner plane. The inner plane is computed as the maximum distance of a vertex to the facet. It may be computed for an individual facet, or you may use the maximum over all facets. For example:

    facetT *facet;
    pointT *point;
    realT dist;

    ...
    qh_distplane(point, facet, &dist);
    if (dist < qh min_vertex - 2 * qh DISTround) {
        /* point is clearly inside of facet */
    }

Both tests include two qh.DISTrounds because the computation of the furthest point from a facet may be off by qh.DISTround and the computation of the current distance to the facet may be off by qh.DISTround.

»How do I find the facet that is closest to a point?

See Locate facet with qh_findbestfacet. For Delaunay triangulations, qh_findbestfacet returns the Delaunay triangle or adjacent triangle that contains the point.

Use qh_findbestfacet(). For example,

    coordT point[ DIM ];
    boolT isoutside;
    realT bestdist;
    facetT *facet;

    ... set coordinates for point ...

    facet= qh_findbestfacet (point, qh_ALL, &bestdist, &isoutside);

    /* 'facet' or an adjacent facet is the closest facet to 'point' */

qh_findbestfacet() performs a directed search for the facet furthest below the point. If the point lies inside this facet, qh_findbestfacet() performs an exhaustive search of all facets. An exhaustive search may be needed because a facet on the far side of a lens-shaped distribution may be closer to a point than all of the facet's neighbors. The exhaustive search may be skipped for spherical distributions.

Also see, 'How do I find the Delaunay triangle that is closest to a point?'

»How do I find the Delaunay triangle or Voronoi region that is closest to a point?

A Delaunay triangulation subdivides the plane, or in general dimension, subdivides space. Given a point, how do you determine the subdivision containing the point? Or, given a set of points, how do you determine the subdivision containing each point of the set? Efficiency is important -- an exhaustive search of the subdivision is too slow.

First compute the Delaunay triangle with qh_new_qhull() in user_r.c or Qhull::runQhull(). Lift the point to the paraboloid by summing the squares of the coordinates. Use qh_findbestfacet [poly2_r.c] to find the closest Delaunay facet or adjacent facet. Determine the closest vertex to find the corresponding Voronoi region. Do not use options 'Qbb', 'QbB', 'Qbk:n', or 'QBk:n' since these scale the last coordinate. Optimizations of qh_findbestfacet() should be possible for Delaunay triangulations.

You first need to lift the point to the paraboloid (i.e., the last coordinate is the sum of the squares of the point's coordinates). The routine, qh_setdelaunay() [geom2.c], lifts an array of points to the paraboloid. The following excerpt is from findclosest() in user_eg.c.

    coordT point[ DIM + 1];  /* one extra coordinate for lifting the point */
    boolT isoutside;
    realT bestdist;
    facetT *facet;

    ... set coordinates for point[] ...

    qh_setdelaunay (DIM+1, 1, point);
    facet= qh_findbestfacet (point, qh_ALL, &bestdist, &isoutside);
    /* 'facet' or an adjacent facet is the closest Delaunay triangle to 'point' */

The returned facet either contains the point, or an adjacent facet contains the point, or it is the closest Delaunay triangle along the convex hull of the input set.

Point location is an active research area in Computational Geometry. For a practical approach, see Mucke, et al, "Fast randomized point location without preprocessing in two- and three-dimensional Delaunay triangulations," Computational Geometry '96, p. 274-283, May 1996. For an introduction to planar point location see [O'Rourke '93]. Also see, 'How do I find the facet that is closest to a point?'

To locate the closest Voronoi region, determine the closest vertex of the closest Delaunay triangle.

    realT dist, bestdist= REALmax;
        vertexT *bestvertex= NULL, *vertex, **vertexp;

    /* 'facet' is the closest Delaunay triangle to 'point' */

    FOREACHvertex_( facet->vertices ) {
        dist= qh_pointdist( point, vertex->point, DIM );
        if (dist < bestdist) {
            bestdist= dist;
            bestvertex= vertex;
        }
    }
    /* 'bestvertex' represents the Voronoi region closest to 'point'.  The corresponding
       input site is 'bestvertex->point' */

»How do I list the vertices?

To list the vertices (i.e., extreme points) of the convex hull use

    vertexT *vertex;

    FORALLvertices {
      ...
      // vertex->point is the coordinates of the vertex
      // qh_pointid(vertex->point) is the point ID of the vertex
      ...
    }
    

»How do I test code that uses the Qhull library?

Compare the output from your program with the output from the Qhull program. Use option 'T1' or 'T4' to trace what Qhull is doing. Prepare a small example for which you know the output. Run the example through the Qhull program and your code. Compare the trace outputs. If you do everything right, the two trace outputs should be almost the same. The trace output will also guide you to the functions that you need to review.

»When I compute a plane equation from a facet, I sometimes get an outward-pointing normal and sometimes an inward-pointing normal

Qhull orients simplicial facets, and prints oriented output for 'i', 'Ft', and other options. The orientation depends on both the vertex order and the flag facet->toporient.

Qhull does not orient non-simplicial facets. Instead it orients the facet's ridges. These are printed with the 'Qt' and 'Ft' option. The facet's hyperplane is oriented.


Up:Home page for Qhull (local)
Up: Qhull Wiki and FAQ (local)
Up: Qhull manual: contents
To: Imprecision in Qhull
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: FAQ: contents


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/rbox.txt0000644000176200001440000001214213431000556017716 0ustar liggesusers rbox(1) rbox(1) NAME rbox - generate point distributions for qhull SYNOPSIS Command "rbox" (w/o arguments) lists the options. DESCRIPTION rbox generates random or regular points according to the options given, and outputs the points to stdout. The points are generated in a cube, unless 's' or given. The format of the output is the following: first line contains the dimension and a comment, second line contains the num- ber of points, and the following lines contain the points, one point per line. Points are represented by their coor- dinate values. EXAMPLES rbox 10 10 random points in the unit cube centered at the origin. rbox 10 s D2 10 random points on a 2-d circle. rbox 100 W0 100 random points on the surface of a cube. rbox 1000 s D4 1000 random points on a 4-d sphere. rbox c D5 O0.5 a 5-d hypercube with one corner at the origin. rbox d D10 a 10-d diamond. rbox x 1000 r W0 100 random points on the surface of a fixed simplex rbox y D12 a 12-d simplex. rbox l 10 10 random points along a spiral rbox l 10 r 10 regular points along a spiral plus two end points rbox 1000 L10000 D4 s 1000 random points on the surface of a narrow lens. rbox c G2 d G3 a cube with coordinates +2/-2 and a diamond with Geometry Center August 10, 1998 1 rbox(1) rbox(1) coordinates +3/-3. rbox 64 M3,4 z a rotated, {0,1,2,3} x {0,1,2,3} x {0,1,2,3} lat- tice (Mesh) of integer points. rbox P0 P0 P0 P0 P0 5 copies of the origin in 3-d. Try 'rbox P0 P0 P0 P0 P0 | qhull QJ'. r 100 s Z1 G0.1 two cospherical 100-gons plus another cospherical point. 100 s Z1 a cone of points. 100 s Z1e-7 a narrow cone of points with many precision errors. OPTIONS n number of points Dn dimension n-d (default 3-d) Bn bounding box coordinates (default 0.5) l spiral distribution, available only in 3-d Ln lens distribution of radius n. May be used with 's', 'r', 'G', and 'W'. Mn,m,r lattice (Mesh) rotated by {[n,-m,0], [m,n,0], [0,0,r], ...}. Use 'Mm,n' for a rigid rotation with r = sqrt(n^2+m^2). 'M1,0' is an orthogonal lattice. For example, '27 M1,0' is {0,1,2} x {0,1,2} x {0,1,2}. s cospherical points randomly generated in a cube and projected to the unit sphere x simplicial distribution. It is fixed for option 'r'. May be used with 'W'. y simplicial distribution plus a simplex. Both 'x' and 'y' generate the same points. Wn restrict points to distance n of the surface of a sphere or a cube c add a unit cube to the output c Gm add a cube with all combinations of +m and -m to the output Geometry Center August 10, 1998 2 rbox(1) rbox(1) d add a unit diamond to the output. d Gm add a diamond made of 0, +m and -m to the output Cn,r,m add n nearly coincident points within radius r of m points Pn,m,r add point [n,m,r] to the output first. Pad coordi- nates with 0.0. n Remove the command line from the first line of out- put. On offset the data by adding n to each coordinate. t use time in seconds as the random number seed (default is command line). tn set the random number seed to n. z generate integer coordinates. Use 'Bn' to change the range. The default is 'B1e6' for six-digit coordinates. In R^4, seven-digit coordinates will overflow hyperplane normalization. Zn s restrict points to a disk about the z+ axis and the sphere (default Z1.0). Includes the opposite pole. 'Z1e-6' generates degenerate points under single precision. Zn Gm s same as Zn with an empty center (default G0.5). r s D2 generate a regular polygon r s Z1 G0.1 generate a regular cone BUGS Some combinations of arguments generate odd results. Report bugs to qhull_bug@qhull.org, other correspon- dence to qhull@qhull.org SEE ALSO qhull(1) AUTHOR C. Bradford Barber bradb@shore.net Geometry Center August 10, 1998 3 geometry/vignettes/qhull/html/qhull-cpp.xml0000644000176200001440000002726213431000557020644 0ustar liggesusers

Qhull C++ -- C++ interface to Qhull

Copyright (c) 2009-2018, C.B. Barber

This draft document records some of the design decisions for Qhull C++. Convert it to HTML by road-faq.xsl from road-faq. Please send comments and suggestions to bradb@shore.net

Help
.
Qhull's collection APIs are modeled on Qt's collection API (QList, QVector, QHash) w/o QT_STRICT_ITERATORS. They support STL and Qt programming.

Some of Qhull's collection classes derive from STL classes. If so, please avoid additional STL functions and operators added by inheritance. These collection classes may be rewritten to derive from Qt classes instead. See Road's .

Qhull's collection API (where applicable). For documentation, see Qt's QList, QMap, QListIterator, QMapIterator, QMutableListIterator, and QMutableMapIterator
  • STL types [list, qlinkedlist, qlist, qvector, vector] -- const_iterator, iterator
  • STL types describing iterators [list, qlinkedlist, qlist, qvector, vector] -- const_pointer, const_reference, difference_type, pointer, reference, size_type, value_type. Pointer and reference types not defined if unavailable (not needed for <algorithm>)
  • const_iterator, iterator types -- difference_type, iterator_category, pointer, reference, value_type
  • Qt types [qlinkedlist, qlist, qvector] -- ConstIterator, Iterator, QhullclassIterator, MutableQhullclassIterator. Qt's foreach requires const_iterator.
  • Types for sets/maps [hash_map, QHash] -- key_compare, key_type, mapped_type
  • Constructor -- default constructor, copy constructor, assignment operator, destructor
  • Conversion -- to/from/as corresponding C, STL, and Qt constructs. Include toQList and toStdVector (may be filtered, e.g., QhullFacetSet). Do not define fromStdList and fromQList if container is not reference counted (i.e., acts like a value)
  • Get/set -- configuration options for class
  • STL-style iterator - begin, constBegin, constEnd, end, key, value, =, *, [], ->, ++, --, +, -, ==, !=, <, <=, >, >=, const_iterator(iterator), iterator COMPARE const_iterator. An iterator is an abstraction of a pointer. It is not aware of its container.
  • Java-style iterator [qiterator.h] - countRemaining, findNext, findPrevious, hasNext, hasPrevious, next, peekNext, peekPrevious, previous, toBack, toFront, = Coordinates
  • Mutable Java-style iterator adds - insert, remove, setValue, value
  • Element access -- back, first, front, last
  • Element access w/ index -- [], at (const& only), constData, data, mid, value
  • Read-only - (int)count, empty, isEmpty, (size_t)size. Count() and size() may be filtered. If so, they may be zero when !empty().
  • Read-only for sets/maps - capacity, key, keys, reserve, resize, values
  • Operator - ==, !=, +, +=, <<
  • Read-write -- append, clear, erase, insert, move, prepend, pop_back, pop_front, push_back, push_front, removeAll, removeAt, removeFirst, removeLast, replace, swap, takeAt, takeFirst, takeLast
  • Read-write for sets/maps -- insertMulti, squeeze, take, unite
  • Search -- contains(const T &), count(const T &), indexOf, lastIndexOf
  • Search for sets/maps -- constFind, lowerBound, upperBound
  • Stream I/O -- stream <<
STL list and vector -- For unfiltered access to each element.
  • Apache: Creating your own containers -- requirements for STL containers. Iterators should define the types from 'iterator_traits'.
  • STL types -- allocator_type, const_iterator, const_pointer, const_reference, const_reverse_iterator, difference_type, iterator, iterator_category, pointer, reference, reverse_iterator, size_type, value_type
  • STL constructors -- MyType(), MyType(count), MyType(count, value), MyType(first, last), MyType(MyType&),
  • STL getter/setters -- at (random_access only), back, begin, capacity, end, front, rbegin, rend, size, max_size
  • STL predicates -- empty
  • STL iterator types -- const_pointer, const_reference, difference_type, iterator_category, pointer, reference, value_type
  • STL iterator operators -- *, -<, ++, --, +=, -=, +, -, [], ==, !=, <, >, >=, <=
  • STL operators -- =, [] (random_access only), ==, !=, <, >, <=, >=
  • STL modifiers -- assign, clear, erase, insert, pop_back, push_back, reserve, resize, swap
Qt Qlist -- For unfiltered access to each element
  • Additional Qt types -- ConstIterator, Iterator, QListIterator, QMutableListIterator
  • Additional Qt get/set -- constBegin, constEnd, count, first, last, value (random_access only)
  • Additional Qt predicates -- isEmpty
  • Additional Qt -- mid (random_access only)
  • Additional Qt search -- contains, count(T&), indexOf (random_access only), lastIndeOf (random_access only)
  • Additional Qt modifiers -- append, insert(index,value) (random_access only), move (random_access only), pop_front, prepend, push_front, removeAll, removeAt (random_access only), removeFirst, removeLast, replace, swap by index, takeAt, takeFirst, takeLast
  • Additional Qt operators -- +, <<, +=, stream << and >>
  • Unsupported types by Qt -- allocator_type, const_reverse_iterator, reverse_iterator
  • Unsupported accessors by Qt -- max_size, rbegin, rend
  • Unsupported constructors by Qt -- multi-value constructors
  • unsupported modifiers by Qt -- assign, muli-value inserts, STL's swaps
STL map and Qt QMap. These use nearly the same API as list and vector classes. They add the following.
  • STL types -- key_compare, key_type, mapped_type
  • STL search -- equal_range, find, lower_bound, upper_bound
  • Qt removes -- equal_range, key_compare
  • Qt renames -- lowerBound, upperBound
  • Qt adds -- constFind, insertMulti, key, keys, take, uniqueKeys, unite, values
  • Not applicable to map and QMap -- at, back, pop_back, pop_front, push_back, push_front, swap
  • Not applicable to QMap -- append, first, last, lastIndexOf, mid, move, prepend, removeAll, removeAt, removeFirst, removeLast, replace, squeeze, takeAt, takeFirst, takeLast
  • Not applicable to map -- assign
Qt QHash. STL extensions provide similar classes, e.g., Microsoft's stdext::hash_set. THey are nearly the same as QMap
  • Not applicable to Qhash -- lowerBound, unite, upperBound,
  • Qt adds -- squeeze
  • check... -- Throw error on failure
  • try... -- Return false on failure. Do not throw errors.
  • ...Temporarily -- lifetime depends on source. e.g., toByteArrayTemporarily
  • ...p -- indicates pointer-to.
  • end... -- points to one beyond the last available
  • private functions -- No syntactic indication. They may become public later on.
  • Error messages -- Preceed error messages with the name of the class throwing the error (e.g. "ClassName: ..."). If this is an internal error, use "ClassName inconsistent: ..."
  • parameter order -- qhRunId, dimension, coordinates, count.
  • toClass -- Convert into a Class object (makes a deep copy)
  • qRunId -- Requires Qh installed. Some routines allow 0 for limited info (e.g., operator<<)
  • Disable methods in derived classes -- If the default constructor, copy constructor, or copy assignment is disabled, it should be also disabled in derived classes (better error messages).
  • Constructor order -- default constructor, other constructors, copy constructor, copy assignment, destructor
geometry/vignettes/qhull/html/qh-code.html0000644000176200001440000023100414664417655020436 0ustar liggesusers Qhull code

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Imprecision in Qhull
To: Qhull code: contents


[4-d cube] Qhull code

This section discusses the code for Qhull.

Copyright © 1995-2020 C.B. Barber


»Qhull code: contents


»Reentrant Qhull

Qhull-2015 introduces reentrant Qhull (libqhull_r). Reentrant Qhull uses a qhT* argument instead of global data structures. The qhT* pointer is the first argument to most Qhull routines. It allows multiple instances of Qhull to run at the same time. It simplifies the C++ interface to Qhull.

New code should be written with libqhull_r. Existing users of libqhull should consider converting to libqhull_r. Although libqhull will be supported indefinitely, improvements may not be implemented. Reentrant qhull is 1-2% slower than non-reentrant qhull.

Note: Reentrant Qhull is not thread safe. Do not invoke Qhull routines with the same qhT* pointer from multiple threads.

»How to convert code to reentrant Qhull

C++ users need to convert to libqhull_r. The new C++ interface does a better, but not perfect, job of hiding Qhull's C data structures. The previous C++ interface was unusual due to Qhull's global data structures.

All other users should consider converting to libqhull_r. The conversion is straight forward. Most of the changes may be made with global search and replace. The resulting files may be checked via eg/make-qhull_qh.sh. It performs the inverse mapping for comparison with non-reentrant code.

For example, even though the original conversion of libqhull to libqhull_r required thousands of changes, the first run of reentrant Qhull (unix_r.c) produced the same output, and nearly the same log files, as the original, non-reentrant Qhull (unix.c). The original conversion was made without the help of eg/make-qhull_qh.sh. Conversion errors almost always produce compiler errors.

Suggestions to help with conversion.

  • Qhull 2019.1 introduced eg/make-qhull_qh.sh. It simplifies the task of checking the consistency of reentrant and non-reentrant C code for Qhull.
  • Compare qconvex_r.c with qconvex.c. Define a qhT object and a pointer it. The qhT* pointer is the first argument to most Qhull functions. Clear qh_qh-<NOerrext before calling qh_initflags(). Invoke QHULL_LIB_CHECK to check for a compatible Qhull library.
  • Compare user_eg2_r.c with user_eg2.c
  • Compare user_eg_r.c with user_eg.c. If you use qhT before invoking qh_init_A, call qh_zero() to clear the qhT object. user_eg_r.c includes multiple Qhull runs.
  • Review user_eg3_r.cpp. As with the other programs, invoke QHULL_LIB_CHECK. Simple C++ programs should compile as is.
  • Compare QhullFacet.cpp with the same file in Qhull-2012.1. UsingLibQhull was replaced with the macro QH_TRY_() and 'qh_qh-<NOerrext= true'.
  • For detailed notes on libqhull_r, see "libqhull_r (reentrant Qhull)" and "Source code changes for libqhull_r" in Changes.txt.
  • For detailed notes on libqhullcpp, see "C++ interface" and following sections in Changes.txt.
  • For regexps and conversion notes, see README_r.txt (unedited).

Suggestions for updating src/libqhull/* from src/libqhull_r/*:

  • Make edits to libqhull_r/* instead of libqhull/*. The reverse update is more difficult, as desribed above.
  • Use 'eg/make-qhull_qh.sh libqhull_r' to automatically convert libqhull_r/* to qhull_qh/*
  • Compare src/qhull_qh/ to src/libqhull/ using Beyond Compare (www.scootersoftware.com) or another directory comparison utility.
  • Configure Beyond Compare for expected differences:
    • Rules > Importance > Unimportant text
      '$Id: ', '$DateTime: ', 'char qh_version'
    • When updating 'Unimportant text', select 'Use for all files in parent session' and, optionally, 'Updated session defaults'
    • Select 'Minor' to ignore unimportant text
    • Review Rules > Importance > Mark grammar elements. Be sure to include 'Comment'
  • Almost all unmodified lines should be identical.
  • Use 'Diffs' view to review diffs, and 'All' view to copy diffs. Otherwise wrong lines may be changed
  • Copy modified lines as needed.
  • Be careful of removing true differences, such as those involiving
    • DEFqhT
    • oldqhA, oldqhB
    • qh_QHpointer
    • qh_last_random
    • qh_rand_r
    • qhmem
    • qhstat, qhstatT
    • rbox_inuse
    • rboxT
    • "renentrant" vs. "non-reentrant"

»Qhull on 64-bit computers

Qhull compiles for 64-bit hosts. Since the size of a pointer on a 64-bit host is double the size on a 32-bit host, memory consumption increases about 50% for simplicial facets and up-to 100% for non-simplicial facets. If the convex hull does not fit in the computer's level 1 and level 2 cache memory, Qhull will run slower as it retrieves data from main memory.

If your data fits in 32-bits, run Qhull as 32-bit code. It will use less memory and run faster.

You can check memory consumption with option Ts. It includes the size of each data structure:

  • 32-bit -- merge 24 ridge 20 vertex 28 facet 88 normal 24 ridge vertices 16 facet vertices or neighbors 20
  • 64-bit -- merge 32 ridge 32 vertex 48 facet 120 normal 32 ridge vertices 40 facet vertices or neighbors 48

For Qhull 2015, the maximum identifier for ridges, vertices, and facets was increased from 24-bits to 32-bits. This allows for larger convex hulls, but may increase the size of the corresponding data structures. The sizes for Qhull 2012.1 were

  • 32-bit -- merge 24 ridge 16 vertex 24 facet 88
  • 64-bit -- merge 32 ridge 32 vertex 40 facet 120

»Calling Qhull from C++ programs

Qhull 2015 uses reentrant Qhull for its C++ interface. If you used the C++ interface from qhull 2012.1, you may need to adjust how you initialize and use the Qhull classes. See How to convert code to reentrant Qhull.

Qhull's C++ interface allows you to explore the results of running Qhull. It provides access to Qhull's data structures. Most of the classes derive from the corresponding qhull data structure. For example, QhullFacet is an instance of Qhull's facetT.

You can retain most of the data in Qhull and use the C++ interface to explore its results. Each object contains a reference to Qhull's data structure (via QhullQh), making the C++ representation less memory efficient.

Besides using the C++ interface, you can also use libqhull_r directly. For example, the FOREACHfacet_(...) macro will visit each facet in turn.

The C++ interface to Qhull is incomplete. You may need to extend the interface. If so, you will need to understand Qhull's data structures and read the code.

The C++ interface is not documented. You will need to read the code and review user_eg3 and Qhull's test program qhulltest. Please consider documenting the C++ interface with Doxygen or another javadoc-style processor.

user_eg3 demonstrates the C++ interface. For example, user_eg3 eg-100 prints the facets generated by Qhull.

    RboxPoints rbox;
    rbox.appendPoints("100");
    Qhull qhull;
    qhull.runQhull(rbox, "");
    cout << qhull.facetList();

The C++ iterface for RboxPoints redefines the fprintf() calls in rboxlib.c. Instead of writing its output to stdout, RboxPoints appends the output to a std::vector.

  • Run Qhull with option 'Ta' to annotate the output with qh_fprintf() identifiers.
  • Redefine qh_fprintf() for these identifiers.
  • See RboxPoints.cpp for an example.

The same technique may be used for calling Qhull from C++. The class QhullUser provides a starting point. See user_eg3 eg-fifo for a demonstration of Voronoi diagrams.

Since the C++ interface uses reentrant Qhull, multiple threads may run Qhull at the same time. Each thread is one run of Qhull.

Do not have two threads accessing the same Qhull instance. Qhull is not thread-safe.

»CoordinateIterator

A CoordinateIterator or ConstCoordinateIterator [RboxPoints.cpp] is a std::vector<realT>::iterator for Rbox and Qhull coordinates. It is the result type of RboxPoints.coordinates().

Qhull does not use CoordinateIterator for its data structures. A point in Qhull is an array of reals instead of a std::vector. See QhullPoint.

»Qhull

Qhull is the top-level class for running Qhull. It initializes Qhull, runs the computation, and records errors. It provides access to the global data structure QhullQh, Qhull's facets, and vertices.

»QhullError

QhullError is derived from std::exception. It reports errors from Qhull and captures the output to stderr.

If error handling is not set up, Qhull exits with a code from 1 to 5. The codes are defined by qh_ERR* in libqhull_r.h. The exit is via qh_exit() in usermem_r.c. The C++ interface does not report the captured output in QhullError. Call Qhull::setErrorStream to send output to cerr instead.

»QhullFacet

A QhullFacet is a facet of the convex hull, a region of the Delaunay triangulation, a vertex of a Voronoi diagram, or an intersection of the halfspace intersection about a point. A QhullFacet has a set of QhullVertex, a set of QhullRidge, and a set of neighboring QhullFacets.

»QhullFacetList

A QhullFacetList is a linked list of QhullFacet. The result of Qhull.runQhull is a QhullFacetList stored in QhullQh.

»QhullFacetSet

A QhullFacetSet is a QhullSet of QhullFacet. QhullFacetSet may be ordered or unordered. The neighboring facets of a QhullFacet is a QhullFacetSet. The neighbors of a QhullFacet is a QhullFacetSet. The neighbors are ordered for simplicial facets, matching the opposite vertex of the facet.

»QhullIterator

QhullIterator contains macros for defining Java-style iterator templates from a STL-style iterator template.

»QhullLinkedList

A QhullLinkedLIst is a template for linked lists with next and previous pointers. QhullFacetList and QhullVertexList are QhullLinkedLists.

»QhullPoint

A QhullPoint is an array of point coordinates, typically doubles. The length of the array is QhullQh.hull_dim. The identifier of a QhullPoint is its 0-based index from QhullQh.first_point followed by QhullQh.other_points.

»QhullPointSet

A QhullPointSet is a QhullSet of QhullPoint. The QhullPointSet of a QhullFacet is its coplanar points.

»QhullQh

QhullQh is the root of Qhull's data structure. It contains initialized constants, sets, buffers, and variables. It contains an array and a set of QhullPoint, a list of QhullFacet, and a list of QhullVertex. The points are the input to Qhull. The facets and vertices are the result of running Qhull.

Qhull's functions access QhullQh through the global variable, qh_qh. The global data structures, qh_stat and qh_mem, record statistics and manage memory respectively.

»QhullRidge

A QhullRidge represents the edge between two QhullFacet's. It is always simplicial with qh.hull_dim-1 QhullVertex)'s.

»QhullRidgeSet

A QhullRidgeSet is a QhullSet of QhullRidge. Each QhullFacet contains a QhullRidgeSet.

»QhullSet

A QhullSet is a set of pointers to objects. QhullSets may be ordered or unordered. They are the core data structure for Qhull.

»QhullVertex

A QhullVertex is a vertex of the convex hull. A simplicial QhullFacet has qh.hull_dim-1 vertices. A QhullVertex contains a QhullPoint. It may list its neighboring QhullFacet's.

»QhullVertexList

A QhullVertexList is a QhullLinkedList of QhullVertex. The global data structure, QhullQh contains a QhullVertexList of all the vertices.

»QhullVertexSet

A QhullVertexSet is a QhullSet of QhullVertex. The QhullVertexSet of a QhullFacet is the vertices of the facet. It is ordered for simplicial facets and unordered for non-simplicial facets.

»RboxPoints

RboxPoints is a std::vector of point coordinates (QhullPoint). Its iterator is CoordinateIterator.

RboxPoints.appendPoints() appends points from a variety of distributions such as uniformly distributed within a cube and random points on a sphere. It can also append a cube's vertices or specific points.

»Cpp questions for Qhull

Developing C++ code requires many conventions, idioms, and technical details. The following questions have either mystified the author or do not have a clear answer. See also C++ and Perl Guidelines and 'QH110nn FIX' notes in the code. Please add notes to Qhull Wiki.
  • QH11028 FIX: Should return reference, but get reference to temporary
    iterator Coordinates::operator++() { return iterator(++i); }
  • size() as size_t, size_type, or int
  • Should all containers have a reserve()?
  • Qhull.feasiblePoint interface
  • How to avoid copy constructor while logging, maybeThrowQhullMessage()
  • How to configure Qhull output. Trace and results should go to stdout/stderr
  • Qhull and RboxPoints messaging. e.g., ~Qhull, hasQhullMessage(). Rename them as QhullErrorMessage?
  • How to add additional output to an error message, e.g., qh_setprint
  • Is idx the best name for an index? It's rather cryptic, but BSD strings.h defines index().
  • Qhull::feasiblePoint Qhull::useOutputStream as field or getter?
  • Define virtual functions for user customization of Qhull (e.g., qh_fprintf, qh_memfree,etc.)
  • Figure out RoadError::global_log. clearQhullMessage currently clearGlobalLog
  • Should the false QhullFacet be NULL or empty? e.g., QhullFacet::tricoplanarOwner() and QhullFacetSet::end()
  • Should output format for floats be predefined (qh_REAL_1, 2.2g, 10.7g) or as currently set for stream
  • Should cout << !point.defined() be blank or 'undefined'
  • Infinite point as !defined()
  • qlist and qlinkedlist define pointer, reference, size_type, difference_type, const_pointer, const_reference for the class but not for iterator and const_iterator vector.h --
    reference operator[](difference_type _Off) const
  • When forwarding an implementation is base() an approriate name (e.g., Coordinates::iterator::base() as std::vector::iterator).
  • When forwarding an implementation, does not work "returning address of temporary"
  • Also --, +=, and -=
    iterator       &operator++() { return iterator(i++); }
  • if vector inheritance is bad, is QhullVertexSet OK?
  • Should QhullPointSet define pointer and reference data types?

»Calling Qhull from C programs

Warning: Qhull was not designed for calling from C programs. You may find the C++ interface easier to use. You will need to understand the data structures and read the code. Most users will find it easier to call Qhull as an external command.

For examples of calling Qhull, see GNU Octave's computational geometry code, and Qhull's user_eg_r.c, user_eg2_r.c, and user_r.c. To see how Qhull calls its library, read unix_r.c, qconvex.c, qdelaun.c, qhalf.c, and qvoronoi.c. The '*_r.c' files are reentrant, otherwise they are non-reentrant. Either version may be used. New code should use reentrant Qhull.

See Functions (local) for internal documentation of Qhull. The documentation provides an overview and index. To use the library you will need to read and understand the code. For most users, it is better to write data to a file, call the qhull program, and read the results from the output file.

If you use non-reentrant Qhull, be aware of the macros "qh" and "qhstat", e.g., "qh hull_dim". They are defined in libqhull.h. They allow the global data structures to be pre-allocated (faster access) or dynamically allocated (allows multiple copies).

Qhull's Makefile produces a library, libqhull_r.a, for inclusion in your programs. First review libqhull_r.h. This defines the data structures used by Qhull and provides prototypes for the top-level functions. Most users will only need libqhull_r.h in their programs. For example, the Qhull program is defined with libqhull_r.h and unix_r.c. To access all functions, use qhull_ra.h. Include the file with "#include <libqhull_r/qhull_ra.h>". This avoids potential name conflicts.

Qhull provides build/qhull.pc.in for pkg-config support and CMakeLists.txt for CMake. Using back-ticks, you can compile your C program with Qhull. For example:

  	gcc `pkg-config --cflags --libs qhull_r` -o my_app my_app.c

If you use the Qhull library, you are on your own as far as bugs go. Start with small examples for which you know the output. If you get a bug, try to duplicate it with the Qhull program. The 'Tc' option will catch many problems as they occur. When an error occurs, use 'T4 TPn' to trace from the last point added to the hull. Compare your trace with the trace output from the Qhull program.

Errors in the Qhull library are more likely than errors in the Qhull program. These are usually due to feature interactions that do not occur in the Qhull program. Please report all errors that you find in the Qhull library. Please include suggestions for improvement.

»How to avoid exit(), fprintf(), stderr, and stdout

Qhull sends output to qh.fout and errors, log messages, and summaries to qh.ferr. qh.fout is normally stdout and qh.ferr is stderr. qh.fout may be redefined by option 'TO' or the caller. qh.ferr may be redirected to qh.fout by option 'Tz'.

Qhull does not use stderr, stdout, fprintf(), or exit() directly.

Qhull reports errors via qh_errexit() by writting a message to qh.ferr and invoking longjmp(). This returns the caller to the corresponding setjmp() (c.f., QH_TRY_ in QhullQh.h). If qh_errexit() is not available, Qhull functions call qh_exit(). qh_exit() normally calls exit(), but may be redefined by the user. An example is libqhullcpp/usermem_r-cpp.cpp. It redefines qh_exit() as a 'throw'.

If qh_meminit() or qh_new_qhull() is called with ferr==NULL, then they set ferr to stderr. Otherwise the Qhull libraries use qh->ferr and qh->qhmem.ferr for error output.

If an error occurs before qh->ferr is initialized, Qhull invokes qh_fprintf_stderr(). The user may redefine this function along with qh_exit(), qh_malloc(), and qh_free().

The Qhull libraries write output via qh_fprintf() [userprintf_r.c]. Otherwise, the Qhull libraries do not use stdout, fprintf(), or printf(). Like qh_exit(), the user may redefine qh_fprintf().

»sets and quick memory allocation

You can use mem_r.c and qset_r.c individually. Mem_r.c implements quick-fit memory allocation. It is faster than malloc/free in applications that allocate and deallocate lots of memory.

qset_r.c implements sets and related collections. It's the inner loop of Qhull, so speed is more important than abstraction. Set iteration is particularly fast. qset_r.c just includes the functions needed for Qhull.

»Delaunay triangulations and point indices

Here some unchecked code to print the point indices of each Delaunay triangle. Use option 'QJ' if you want to avoid non-simplicial facets. Note that upper Delaunay regions are skipped. These facets correspond to the furthest-site Delaunay triangulation.

  facetT *facet;
  vertexT *vertex, **vertexp;

  FORALLfacets {
    if (!facet->upperdelaunay) {
      printf ("%d", qh_setsize (facet->vertices);
      FOREACHvertex_(facet->vertices)
        printf (" %d", qh_pointid (vertex->point));
      printf ("\n");
    }
  }

»locate a facet with qh_findbestfacet()

The routine qh_findbestfacet in poly2_r.c is particularly useful. It uses a directed search to locate the facet that is furthest below a point.

For Delaunay triangulations, this facet is either the Delaunay triangle or a neighbor of the Delaunay triangle that contains the lifted point. Qhull determines the Delaunay triangulation by projecting the input sites to a paraboloid. The convex hull matches the Delaunay triangulation at the input sites, but does not match along the edges. See this image by F. Drielsma. A point is green or yellow depending upon the facet returned by qh_findbestfacet. For points near an edge, the circumcircles overlap and the adjacent facet may be returned.

For convex hulls, the distance of a point to the convex hull is either the distance to this facet or the distance to a subface of the facet.

Warning: If triangulated output ('Qt') and the best facet was triangulated, qh_findbestfacet() returns one of the corresponding 'tricoplanar' facets. The actual best facet may be a different tricoplanar facet from the same set of facets.

See qh_nearvertex() in poly2.c for sample code to visit each tricoplanar facet. To identify the correct tricoplanar facet, see Devillers, et. al., ['01] and Mucke, et al ['96]. If you implement this test in general dimension, please notify qhull@qhull.org.

qh_findbestfacet performs an exhaustive search if its directed search returns a facet that is above the point. This occurs when the point is inside the hull or if the curvature of the convex hull is less than the curvature of a sphere centered at the point (e.g., a point near a lens-shaped convex hull). When the later occurs, the distance function is bimodal and a directed search may return a facet on the far side of the convex hull.

Algorithms that retain the previously constructed hulls usually avoid an exhaustive search for the best facet. You may use a hierarchical decomposition of the convex hull [Dobkin and Kirkpatrick '90].

To use qh_findbestfacet with Delaunay triangulations, lift the point to a paraboloid by summing the squares of its coordinates (see qh_setdelaunay in geom2_r.c). Do not scale the input with options 'Qbk', 'QBk', 'QbB' or 'Qbb'. See Mucke, et al ['96] for a good point location algorithm.

The intersection of a ray with the convex hull may be found by locating the facet closest to a distant point on the ray. Intersecting the ray with the facet's hyperplane gives a new point to test.

»on-line construction with qh_addpoint()

The Qhull library may be used for the on-line construction of convex hulls, Delaunay triangulations, and halfspace intersections about a point. It may be slower than implementations that retain intermediate convex hulls (e.g., Clarkson's hull program). These implementations always use a directed search. For the on-line construction of convex hulls and halfspace intersections, Qhull may use an exhaustive search (qh_findbestfacet).

You may use qh_findbestfacet and qh_addpoint (libqhull.c) to add a point to a convex hull. Do not modify the point's coordinates since qh_addpoint does not make a copy of the coordinates. For Delaunay triangulations, you need to lift the point to a paraboloid by summing the squares of the coordinates (see qh_setdelaunay in geom2.c). Do not scale the input with options 'Qbk', 'QBk', 'QbB' or 'Qbb'. Do not deallocate the point's coordinates. You need to provide a facet that is below the point (qh_findbestfacet).

You can not delete points. Another limitation is that Qhull uses the initial set of points to determine the maximum roundoff error (via the upper and lower bounds for each coordinate).

For many applications, it is better to rebuild the hull from scratch for each new point. This is especially true if the point set is small or if many points are added at a time.

Calling qh_addpoint from your program may be slower than recomputing the convex hull with qh_qhull. This is especially true if the added points are not appended to the qh first_point array. In this case, Qhull must search a set to determine a point's ID. [R. Weber]

See user_eg.c for examples of the on-line construction of convex hulls, Delaunay triangulations, and halfspace intersections. The outline is:

initialize qhull with an initial set of points
qh_qhull();

for each additional point p
   append p to the end of the point array or allocate p separately
   lift p to the paraboloid by calling qh_setdelaunay
   facet= qh_findbestfacet (p, !qh_ALL, &bestdist, &isoutside);
   if (isoutside)
      if (!qh_addpoint (point, facet, False))
         break;  /* user requested an early exit with 'TVn' or 'TCn' */

call qh_check_maxout() to compute outer planes
terminate qhull

»Constrained Delaunay triangulation

With a fair amount of work, Qhull is suitable for constrained Delaunay triangulation. See Shewchuk, ACM Symposium on Computational Geometry, Minneapolis 1998.

Here's a quick way to add a constraint to a Delaunay triangulation: subdivide the constraint into pieces shorter than the minimum feature separation. You will need an independent check of the constraint in the output since the minimum feature separation may be incorrect. [H. Geron]

»Tricoplanar facets and option 'Qt'

Option 'Qt' triangulates non-simplicial facets (e.g., a square facet in 3-d or a cubical facet in 4-d). All facets share the same apex (i.e., the first vertex in facet->vertices). For each triangulated facet, Qhull sets facet->tricoplanar true and copies facet->center, facet->normal, facet->offset, and facet->maxoutside. One of the facets owns facet->normal; its facet->keepcentrum is true. If facet->isarea is false, facet->triowner points to the owning facet.

Qhull sets facet->degenerate if the facet's vertices belong to the same ridge of the non-simplicial facet.

To visit each tricoplanar facet of a non-simplicial facet, either visit all neighbors of the apex or recursively visit all neighbors of a tricoplanar facet. The tricoplanar facets will have the same facet->center.

See qh_detvridge for an example of ignoring tricoplanar facets.

»Voronoi vertices of a region

The following code iterates over all Voronoi vertices for each Voronoi region. Qhull computes Voronoi vertices from the convex hull that corresponds to a Delaunay triangulation. An input site corresponds to a vertex of the convex hull and a Voronoi vertex corresponds to an adjacent facet. A facet is "upperdelaunay" if it corresponds to a Voronoi vertex "at-infinity". Qhull uses qh_printvoronoi in io.c for 'qvoronoi o'

/* please review this code for correctness */
qh_setvoronoi_all();
FORALLvertices {
   site_id = qh_pointid (vertex->point);
   if (qh hull_dim == 3)
      qh_order_vertexneighbors(vertex);
   infinity_seen = 0;
   FOREACHneighbor_(vertex) {
      if (neighbor->upperdelaunay) {
        if (!infinity_seen) {
          infinity_seen = 1;
          ... process a Voronoi vertex "at infinity" ...
        }
      }else {
        voronoi_vertex = neighbor->center;
        ... your code goes here ...
      }
   }
}

»Voronoi vertices of a ridge

Qhull uses qh_printvdiagram() in io.c to print the ridges of a Voronoi diagram for option 'Fv'. The helper function qh_eachvoronoi() does the real work. It calls the callback 'printvridge' for each ridge of the Voronoi diagram.

You may call qh_printvdiagram2(), qh_eachvoronoi(), or qh_eachvoronoi_all() with your own function. If you do not need the total number of ridges, you can skip the first call to qh_printvdiagram2(). See qh_printvridge() and qh_printvnorm() in io.c for examples.

»vertex neighbors of a vertex

To visit all of the vertices that share an edge with a vertex:

  • Generate neighbors for each vertex with qh_vertexneighbors in poly2.c.
  • For simplicial facets, visit the vertices of each neighbor
  • For non-simplicial facets,
    • Generate ridges for neighbors with qh_makeridges in merge.c.
    • Generate ridges for a vertex with qh_vertexridges in merge.c.
    • Visit the vertices of these ridges.

For non-simplicial facets, the ridges form a simplicial decomposition of the (d-2)-faces between each pair of facets -- if you need 1-faces, you probably need to generate the full face graph of the convex hull.

»How to debug Qhull

Qhull continually checks its execution, so most errors will stop Qhull with an error message. Additional checking occurs for verified output ('Tv'), check frequently ('Tc'), check for duplicate ridges ('Q15'), and tracing at level 4 ('T4').

If Qhull detects an error, it writes a descriptive error message to stderr, and exits with an exit status code (see following). The C++ interface captures the message in Qhull::qhullMessage. If Qhull::setErrorStream was called, it writes the error message to Qhull::errorStream.

If a Qhull segfault occurs, turn on tracing with option 'T4' and flush output (qh_fprintf) with option 'Tf'. See core dumps and segfaults.

If Qhull never finishes, is Qhull running slow or was there an infinite loop?

  • If you are running Qhull under Git for Windows or MSYS2, 'qhull' waits for stdin instead of displaying a help message. Use 'qhull --help' instead.
  • Turn on monitoring with option 'TFn'. Qhull normally takes approximately the same amount of time per point. If the output is too large, it will slow down due to main memory or virtual memory.
  • If there are large, non-simplicial facets, see "quadradic running time" in Limitations of merged facets.
  • See Performance and infinite loops for further suggestions.

If a Qhull error occurs, try to simplify the problem.

  • If new to Qhull, start with short examples that you can work out by hand. Your problem may be due to misunderstanding Qhull's output, or an incompatibility between your program and the Qhull libraries.
  • Can you produce the input that triggers the problem? The input to Qhull includes the dimension, number of points, point coordinates, and Qhull options. Qhull is usually deterministic for a particular build.
  • Can you duplicate the problem using one of the Qhull programs (e.g., 'qhull' or 'qconvex')?
  • Does a shorter output trigger the problem?
  • Can you turn on tracing with option 'T4'? If too much output occurs, use the trace options to reduce the trace output.
  • The test program, 'eg/qtest.sh', repeats a qhull run for intermittent errors. It can log a qhull run to 'qhull.log' and a reduced log, 'qhull-step.log'.

If the segfault, infinite loop, or internal error was due to Qhull, please report the error to 'bradb@shore.net. Please include the input data (i.e., point coordinates) that triggered the error.

»Qhull errors

Qhull errors start with 'QH6...' and Qhull warnings start with 'QH7...'. The error message and error code are arguments to a qh_fprintf call. After printing the error message, Qhull exits with an exit status code. The exit status code indicates the type of error:

  • qh_ERRinput (1) -- badly formed options or input. Badly formed options are reported as Qhull warnings. Unless option 'Qw' is specified, Qhull reports error QH6035 or QH6037 and exits with qh_ERRinput. Inconsistent options typically report an error.
    The input to Qhull specifies the dimension and number of points. If the input contains fewer or more points than coordinates, Qhull reports error QH6410 and exits with qh_ERRinput. If option 'Qa' is specified, it reports warning QH7073 and continues execution.
  • qh_ERRsingular (2) -- singular input data. If the input data is singular or flat (e.g., a line segment in 2-d), Qhull reports error QH6114, QH6379, or QH6154. Qhull calls qh_printhelp_singular to print an explanation of the error. It exits qhull with qh_ERRsingular.
  • qh_ERRprec (3) -- precision error. By default, Qhull handles precision errors by merging. If merging is not possible, or if a precision error is identified after Qhull finishes, Qhull reports an error and calls qh_printhelp_degenerate. It exits qhull with qh_ERRprec.
  • qh_ERRmem (4) -- memory error. If Qhull runs out of memory, it reports an error and exits qhull with qh_ERRmem.
  • qh_ERRQhull (5) -- internal error. If Qhull detects an internal error, it reports the error and calls qh_printhelp_internal. It exits qhull with qh_ERRQhull.
  • qh_ERRother (6) -- other errors. If Qhull identifies an error while reporting another error, it prints "qhull error while handling previous error" and exits Qhull with qh_ERRother. The same exit code is used for vertex id overflow and missing exitcode for qh_errexit.
  • qh_ERRtopology (7) -- topology error. If Qhull cannot recover from a topology error, it reports the error and calls qh_printhelp_topology. It exits qhull with qh_ERRtopology.
  • qh_ERRwide (8) -- wide facet error. If Qhull produces an extra-wide facet, it reports the error and calls qh_printhelp_wide. It exits qhull with qh_ERRwide.
  • qh_ERRdebug (9) -- debug. Use qh_ERRdebug for exits from debugging code.

»Qhull infinite loops

Except for list traversals, most loops in Qhull are limited by a count or the size of set. Linked lists of facets and vertices terminate with a sentinel whose next element is NULL. If a programming error inserts a link to a previous facet or vertex, an infinite loop occurs on the next traversal. Qhull periodically checks and corrects its linked lists for infinite loops (qh_checklists).

»Qhull trace options

Qhull's trace options are the key to debugging Qhull. They describe an execution of Qhull at various levels of detail, with various options to control what is traced.

  • Level 0 ('T-1') -- Key events are prefixed with '[QH00nn]'
  • Level 1 ('T1') -- Main steps in the program are prefixed with '[QH1nnn]'.
    [QH1049]qh_addpoint -- When Qhull adds a point, it logs information about the point, the convex hull so far, and changes since the previous qh_addpoint.
  • Level 2 ('T2') -- Minor steps in the program are prefixed with '[QH2nnn]'.
  • Level 3 ('T3') -- Merge and other events are prefixed with '[QH3nnn]'.
  • Level 4 ('T4') -- Detailed trace of Qhull execution.
  • Level 5 ('T5') -- Memory allocations and Guassian elimination. Memory allocations are prefixed with "qh_mem " followed by address, sequence number, alloc/free, short/long, etc. If you sort by address and sequence number, each allocate should be paired with its free.

These options select when tracing starts or stops. It limits the amount of tracing, especially in high dimensions.

  • 'TAn' -- stop Qhull after adding n vertices
  • 'TCn' -- stop Qhull after building cone for point n
  • 'TMn' -- turn on tracing at merge n. When Qhull reports an error, it reports "Last merge was #nnn".
  • 'TPn' -- turn on tracing when point n is added to hull or point n is referenced. When Qhull reports an error, it reports "Last point added to hull was pnnn".
  • 'TVn' -- stop Qhull after adding point n, -n for before
  • 'TWn' -- trace merge facets when width > n

Additional logging by facet id (fnnn), ridge id (rnnn) or vertex id (vnnn), may be enabled by setting qh.tracefacet_id, qh.traceridge_id, or qh.tracevertex_id in global_r.c/qh_initqhull_start2.

»Qhull core dumps and segfaults

If a segfault occurs, use option 'Tf' to flush output after every qh_fprintf. Logging will be significantly slower than normal.

The following debugging plan usually identifies the error

  1. Trace execution at level 1 with flush after each qh_fprintf and output to stdout ('T1 Tf Tz').
  2. Repeat at level 4 after the last qh_addpoint (QH1049, 'TPn'). Add line numbers to the log by piping the output through 'grep -n .'.
    • If there is too much level 4 output, repeat at level 2 to find the last qh_mergefacet (QH2081) and then trace at level 4 from the last merge ('TMn').
    • If there is still too much level 4 output, identify one of the last level 3 events and add debugging to the corresponding trace3 call. Be sure to mark the code for removal. For example
        if (facetA->id==4675)
          qh->IStracing= 4; /* DEBUG */
        trace3((qh, qh->ferr, 3020, "qh_triangulate_facet: triangulate facet f%d\n", facetA->id));
      
  3. Identify the location of the failure using a build of Qhull with debug symbols.
  4. Use the debugger to find relevant facet ids, ridge ids, and vertex ids. These identifiers will appear in the level 4 log.

»eg/qtest.sh for intermittent errors and logging

For intermittent errors, use 'rbox' to generate random test cases, and eg/qtest.sh to invoke multiple runs of qhull. When a failing case is found, rerun eg/qtest.sh with the test case identifier. It produces qhull.log and the corresponding reduced log, qhull-step.log. These logs include line numbers generated by 'grep -n .'

qtest.sh provides the following options

  • N qhull runs (qtest.sh -N 'rbox c | qhull')
    execute the qhull command N times with rotated input 'QR1', 'QR2', ...
  • N random qhull runs (qtest.sh N 'rbox c | qhull')
    execute the qhull command N times with random rotations 'QRn', ...

  • N 'rbox|qhull' runs (qtest.sh -N 'rbox-opts' 'qhull-opts')
    execute rbox and qhull N times with random inputs 't1', 't2', ...
  • N random 'rbox|qhull' runs (qtest.sh N 'rbox-opts' 'qhull-opts')
    execute rbox and qhull N times with random inputs 'tnnn', ...

  • Run qhull command (qtest.sh run 'rbox c | qhull')
    execute a qhull command line
  • Run qhull QRnnn (qtest.sh run QRnnn 'rbox | qhull')
    execute a qhull command line with QRnnn rotated input
  • Run rbox tnnn | qhull (qtest.sh run t... 'rbox-opts' 'qhull-opts')
    execute rbox and qhull commands with tnnn random input

  • Log qhull command (qtest.sh log 'rbox c | qhull')
    trace (T4) a qhull command line to qhull.log and qhull-step.log
  • Log qhull QRnnn (qtest.sh QRnnn 'rbox | qhull')
    trace (T4) a qhull command line with QRnnn rotated input to qhull.log and qhull-step.log
  • Log rbox tnnn | qhull (qtest.sh tnnn 'rbox-opts' 'qhull-opts')
    trace (T4) rbox and qhull commands with tnnn random input to qhull.log and qhull-step.log

  • Grep qhull.log for events (qtest.sh grep)
    grep qhull.log for $QH_GREP excluding $QH_GREPX to stdout
  • Grep qhull.log for regexp (qtest.sh grep 'include-regexp')
    grep qhull.log for regexp|$QH_GREP excluding $QH_GREPX to stdout
  • Grep qhull.log for include and exclude regexps (qtest.sh grep 'include-regexp' 'exclude-regexp')
    grep qhull.log for include|$QH_GREP excluding exclude|$QH_GREPX to stdout

  • Grep logfile for merge events (qtest.sh grep-merge logfile)
    grep logfile for merge events to stdout, see #grep-merge in qtest.sh

  • Grep logfile for step events (qtest.sh grep-merge logfile)
    grep logfile for step events to stdout, same as qhull-step.log

  • Verbose logging (qtest.sh -v ...)
    prepend log with command and environment variables

»Memory errors

Qhull checks memory usage before exiting. To locate memory that is not freed ("QH7079 qhull internal warning (main): did not free ..."):
  1. Run qhull with memory tracing 'T5'.
    See 'Level 5' in Qhull trace options (above)
  2. Sort lines that start with 'qh_mem'. It matches qh_memalloc with the corresponding qh_memfree.
  3. For long allocations, sort lines that contain -- qh_mem.*long:
  4. Replace -- qh_mem.*alloc.*\nqh_mem.*free.* -- with 'Match' (Textpad supports internal newlines in match expressions).
  5. Sort by column 25 (n...). It shows unallocated actions. Long allocations are in execution order. Short and quick allocations are in execution order.
  6. For example: qh_mem 0000000000537440 n 10053 alloc long: 128 bytes (tot 484800 cnt 1209)
  7. To check quick vs. long allocations -- grep "qh_mem .*alloc " qhull.log | sed -e 's/^.*long/long/' -e 's/^.*short/short/' -e 's/^.*quick/quick/' -e 's/bytes.*/bytes/' | sort | uniq -c >x.1

Option 'Ts' reports numerous memory statistics.

»Qhull debugging tips

  • qh_printlists in poly2_r.c -- called during qh_addpoint. Easily inserted into existing code and a good location for debugging code.
  • qh_fprintf in user_r.c -- called for all Qhull output, including trace logs. A good location for reasonably efficient debugging code. The debugging code may refer to a facet, ridge, or vertex by setting qh.tracefacet_id, qh.traceridge_id, or qh.tracevertex_id in global_r.c/qh_initqhull_start2.
  • qh_tracemerge in merge_r.c -- called after each merge. It is a good location for debugging code.

»Performance of Qhull

Empirically, Qhull's performance is balanced in the sense that the average case happens on average. This may always be true if the precision of the input is limited to at most O(log n) bits. Empirically, the maximum number of vertices occurs at the end of constructing the hull.

Let n be the number of input points, v be the number of output vertices, and f_v be the maximum number of facets for a convex hull of v vertices. If both conditions hold, Qhull runs in O(n log v) in 2-d and 3-d and O(n f_v/v) otherwise. The function f_v increases rapidly with dimension. It is O(v^floor(d/2) / floor(d/2)!).

The time complexity for merging is unknown. The default options 'C-0' (2-d, 3-d, 4-d) and 'Qx' (5-d and higher) handle precision problems due to floating-point arithmetic. They are optimized for simplicial outputs.

When running large data sets, you should monitor Qhull's performance with the 'TFn' option. The time per facet is approximately constant. In high-d with many merged facets, the size of the ridge sets grows rapidly. For example the product of 8-d simplices contains 18 facets and 500,000 ridges. This will increase the time needed per facet.

Additional detail is provided by QH1049 in the level-1 trace ('T1'). For each qh_addpoint, it provides vertex id, facet count, outside point count, CPU time for the previous point, deltas for facets/hyperplanes/distplanes, and the number of retries due to merged pinched vertices. For example:

[QH1049]qh_addpoint: add p260(v176) to hull of 286 facets (1.4e-12 above f830) and 2 outside at 1.192 CPU secs. Previous p710(v175) delta 0.007 CPU, 2 facets, 3 hyperplanes, 443 distplanes, 0 retries

As dimension increases, the number of facets and ridges in a convex hull grows rapidly for the same number of vertices. For example, the convex hull of 300 cospherical points in 6-d has 30,000 facets.

If Qhull appears to stop processing facets, check the memory usage of Qhull. If more than 5-10% of Qhull is in virtual memory, its performance will degrade rapidly.

When building hulls in 20-d and higher, you can follow the progress of Qhull with option 'T1'. It reports each major event in processing a point.

To reduce memory requirements, recompile Qhull for single-precision reals (REALfloat in user.h). Single-precision does not work with joggle ('QJ'). Check qh_MEMalign in user.h and the match between free list sizes and data structure sizes (see the end of the statistics report from 'Ts'). If free list sizes do not match, you may be able to use a smaller qh_MEMalign. Setting qh_COMPUTEfurthest saves a small amount of memory, as does clearing qh_MAXoutside (both in user.h).

Shewchuk is working on a 3-d version of his triangle program. It is optimized for 3-d simplicial Delaunay triangulation and uses less memory than Qhull.

To reduce the size of the Qhull executable, consider qh_NOtrace and qh_KEEPstatistics 0 in user.h. By changing user.c you can also remove the input/output code in io.c. If you don't need facet merging, then version 1.01 of Qhull is much smaller. It contains some bugs that prevent Qhull from initializing in simple test cases. It is slower in high dimensions.

The precision options, 'Vn', 'Wn', 'Un'. 'A-n', 'C-n', 'An', 'Cn', and 'Qx', may have large effects on Qhull performance. You will need to experiment to find the best combination for your application.

The verify option ('Tv') checks every point after the hull is complete. If facet merging is used, it checks that every point is inside every facet. This can take a very long time if there are many points and many facets. You can interrupt the verify without losing your output. If facet merging is not used and there are many points and facets, Qhull uses a directed search instead of an exhaustive search. This should be fast enough for most point sets. Directed search is not used for facet merging because directed search was already used for updating the facets' outer planes.

The check-frequently option ('Tc') becomes expensive as the dimension increases. The verify option ('Tv') performs many of the same checks before outputting the results.

Options 'Q0' (no pre-merging), 'Q3' (no checks for redundant vertices), 'Q5' (no updates for outer planes), and 'Q8' (no near-interior points) increase Qhull's speed. The corresponding operations may not be needed in your application.

In 2-d and 3-d, a partial hull may be faster to produce. Option 'QgGn' only builds facets visible to point n. Option 'QgVn' only builds facets that contain point n. In higher-dimensions, this does not reduce the number of facets.

User.h includes a number of performance-related constants. Changes may improve Qhull performance on your data sets. To understand their effect on performance, you will need to read the corresponding code.

GNU gprof reports that the dominate cost for 3-d convex hull of cosperical points is qh_distplane(), mainly called from qh_findbestnew(). The dominate cost for 3-d Delaunay triangulation is creating new facets in qh_addpoint(), while qh_distplane() remains the most expensive function.

»eg/q_benchmark for optimizing Qhull

eg/q_benchmark and eg/qtest.sh make multiple runs of Qhull for testing, benchmarking, and debugging. They help test and analyze intermittent errors, performance issues, and precision issues. Each release updates eg/q_benchmark-ok.txt.

Qhull 2019.1 is 15% larger than Qhull 2015.2 due to enhanced error reporting, tracing, and facet merging. The increased code size may increase startup times.

Qhull is single threaded. Gcc's gprof works well for profiling Qhull performance.

  • Recompile Qhull with '-pg' added to CC_OPTS1 in qhull's Makefile. Check for optimization ('-O3').
  • Execute a performance test of Qhull
    • See "=== Timing test cases ===" in 'eg/q_benchmark'.
  • Check for gmon.out from gcc's '-pg' option -- ls -l gmon.out
  • Run gprof -- gprof qhull >gprof.txt # gprof qhull.exe >gprof.txt
  • Review gprof.txt
    • The first section gives results by function, the second section, results by caller
  • Sample runs
    rbox 500000 s >r.x; time qhull TI r.x
    
    AIR2-/local/qhull/bin> time qhull TI r.x
    
    Convex hull of 500000 points in 3-d:
    
      Number of vertices: 500000
      Number of facets: 999996
    
    Statistics for: rbox 500000 s | qhull TI r.x
    
      Number of points processed: 500000
      Number of hyperplanes created: 2827999
      Number of distance tests for qhull: 24786928
      CPU seconds to compute hull (after input): 4.852
    
    
    [4]     62.8    0.02    2.11  499996         qh_addpoint [4]
                    0.01    0.83  499996/499996      qh_buildcone [5]
                    0.04    0.56  499996/499996      qh_partitionvisible [7]
                    0.01    0.28  499996/499996      qh_premerge [13]
                    0.04    0.13  499996/499996      qh_findhorizon [19]
    
    # 2015.2
    Statistics for: rbox 500000 s | qhull TI c:/bash/local/qhull/bin/r.x
      Number of vertices: 500000
      Number of facets: 999996
      Number of points processed: 500000
      Number of hyperplanes created: 2827999
      Number of distance tests for qhull: 24786929
      CPU seconds to compute hull (after input): 4.477
    real    0m6.334s
    user    0m0.016s
    sys     0m0.015s
    

»Enhancements to Qhull

There are many ways in which Qhull can be improved.

Top Suggestions
 - Document the C++ interface using Doxygen
 - Construct the full Voronoi Diagram using the C++ interface.  See "To do" in Changes.txt
 - Optimize for 64-bit code
   Custom facetT for simplicial facets
   32-bit indices for facets and vertices
 - Bulk qh_addpoint with a custom point partition
 - Full-dimensional flats
   Add points at right angles like 'Qz'
   Ignore added facets in output (cf. f.upperDelaunay and f.good)
 - Per-vertex joggle
   Joggle by random flip of low-order and adjustable-order bits in mantissa
   Allows consistent triangulations across distributed partitions
   Detect integer input data and automatically translate to the origin
 - Develop a theory for merging Qhull's non-simplicial facets
   A merge creates constraints on subsequent merges, what are these constraints?
   Identify topological errors in qh_findbest_test (merge_r.c)f
   Prevent duplicate ridges (Q15-check-duplicates) or facets with the same vertices
   Preserve facet-ridge orientation for nonsimplicial facets (ridge top/bot)
   Produce conformant triangulations for nonsimplicial facets (option 'Qt', QH2088)
   Should vertex merge account for facet orientation?
   Rationalize the merge options qh_RATIOtwisted, qh_WIDEdupridge, etc.
   Should wide merges be proportional to qh.ONEmerge or f.maxoutside?
   Can dupridges be avoided with geometric and topological constraints?
   Review coplanar tests across sharp ridges (coplanar horizon, qh_test_appendmerge, qh_check_maxout)
 - Improve Qhull's computations, particularly qh_setfacetplane for hyperplanes
   Toronto, N., McCarthy, J., "Practically accurate floating-point math,", Computing in
   Science & Engineering, IEEE, July/August 2014, p. 80-95.
 - Octave creates endpoints for unbounded ridges, for drawing Delaunay/Voronoi diagrams [M. Voss]
 - Option to select bounded Voronoi regions [A. Uzunovic]
 - Review Qhull performance.  qh_next_vertexmerge and qh_check_maxout are slower than expected
   Compare to Peterka et al and Li and Snoeyink, particularly 64-bit vs. 32-bit
 - Use Gaussian distribution for random cospherical points in rbox
 - Implement dimension reduction via Johnson-Lindenstrauss flattening
 - Implement bulk qh_addpoint via a subset of the facets, perhaps a box about qh.interior_point
   Allow qh_triangulate to run after each increment [coldfix, scipy #4974]
 - Write incremental addPoint with bucketed inputs and facet search (CGAL)
 - Compute hyperplanes in parallel (cf. qh_setfactplane)
 - Create Voronoi volumes and topology in parallel
 - Implement Delaunay to Voronoi tesselation [Peterka et al, 2014, www.mcs.anl.gov/papers/P5154-0614.pdf]
 - Integrate 4dview with Geomview 1.9.5
 - Use coverage testing to expand Qhull's test programs
 - Add RPM and Debian builds to Qhull (CMake's CPackRMP and CPackDeb).
 - Create a mirror/archive web site for old and new Qhull builds
 - Constrain delaunay triangulations via Shewchuk's algorithm (ACM Symp. Comp. Geo., 1998)

-----------
To do for a furture version of the C++ interface
 - Document C++ using Doxygen conventions (//! and //!<)
 - Add defineAs() to each object
 - Add Qtest::toString() functions for QhullPoint and others.  QByteArray and qstrdup()
 - Add toQVector() for Qt container support.  QVector is preferred over QList
 - Add mutable Java-style iterators for containers.  Limited due to memory-allocation issues.
 - Should Qhull manage the output formats for doubles?  QH11010 FIX: user_r.h defines qh_REAL_1 as %6.8g
 - Allocate memory for QhullSet using Qhull.qhmem.  Create default constructors for QhullVertexSet etc.  Also mid() etc.
 - Add interior point for automatic translation?
 - Write a program with concurrent Qhull
 - Write QhullStat and QhullStat_test
 - Add QList and vector instance of facetT*, etc.
 - Generalize QhullPointSetIterator
 - qh-code.html: Document changes to C++ interface.
      Organize C++ documentation into collection classes, etc.
 - Review all C++ classes and C++ tests
 - QhullVertexSet uses QhullSetBase::referenceSetT() to free its memory.   Probably needed elsewhere
 - The Boost Graph Library provides C++ classes for graph data structures. It may help
   enhance Qhull's C++ interface [Dr. Dobb's 9/00 p. 29-38; OOPSLA 99 p. 399-414].

[May 2020] Suggestions
- Check that the midpoint for Voronoi option 'Fo' is not a Voronoi vertex (rbox c D2 P0 | qvoronoi Fo)
- How to detect degenerate hyperplanes for Voronoi option 'Fo' and 'Fi'?
  qh_sethyperplane_gauss reports nearzero for axis parallel hyperplanes.
- Add a 'Tv' test for Voronoi option 'Fo' that does not use midpoints

[May 2019] Suggestions
------------
Precision issues
- Improve handling of data with positive, integer coordinates, particularly for Delaunay triangulation
  eg Sterratt's github issue #25
  Add a warning that available precision is reduced
  Add an option to automatically translate the data to the origin
- Review qh.MAXcoplanar ('Un'), it varies by dimension compared to qh.ONEmerge

Topology issues
- Need theory for facet merging, vertex merging, and topological errors
- Does qh_triangulate produce a consistent orientation if qh_renamevertex is not called?

Facet and vertex merging
- Reduce the overhead of qh.NEWtentative ('Q14') and improve the speed of facet and vertex merging
- Review MRGconcavecoplanar and early out for isconcave in qh_test_nonsimplicial_merge
- Review user_r.h ratios and precision constants for merging
  Pre-compute derived precision values (e.g., qh_detmaxoutside)
- Use a fixed target instead of a relative wide-max ratio.
  Why should qh.MAXoutside increase when qh.max_outside increases dramatically
  Why should a slow but steady increase in qh.max_outside be OK?
  Define an option to specify wide-max ratio -- 100x is borderline, bad cases can produce 400x,
- Add statistics for dupridge matching in qh_matchneighbor and qh_matchdupridge.  Report as a "precision problem"
- Collect statistics for MRGdegen and MRGredundant
- In qh_all_merges, why is isreduce set when qh.POSTmerging && qh.hull_dim >= 4?
- In qh_forcedmerges and qh_initmergesets, remove assumption that qh.facet_mergeset is the last temporary set
- Review comparisons for qh_compare_anglemerge and qh_compare_facetmerge (after developing a theory)

Other
- Add a version flag to 'rbox' (cf. global_r.c/qh_version).  Currently, the release date is part of its help prompt.
- Review effect of qh.GOODclosest on qh_buildcone_onlygood ('Qg', QH11030 FIX).  qh_findgood preserves old value if didn't find a good facet.  See qh_findgood_all for disabling
- Review the rules for -REALmax -- they look inconsistent.
  Why REALmax/2 and -REALmax/2?  The comments say 'avoid underflow'.  When was it introduced?
- Review comment in qh_matchnewfacets -- "do not allocate memory after qh.hash_table (need to free it cleanly)"
- Chase circular dependencies when compiling qhulltest with Microsoft Devstudio
  Warning MSB8017 A circular dependency has been detected while executing custom build commands for item "moc\Coordinates_test.moc". This may cause incremental build to work incorrectly.        qhulltest-64    C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets   209
- Add 'design:' documentation for poly2_r.c/qh_triangulate
  Consider splitting up
- Geomview for 4-d merge is difficult to understand.  Not able to see the convexity of the edges
- Review memory sizes (mem_r.c/qh_memsize) and quick allocations for 64-bit code
- Review Qhull's collection API conventions, http://www.qhull.org/road/road-faq/xml/qhull-cpp.xml
  See http://gnuwin32.sourceforge.net/packages.html and https://google-styleguide.googlecode.com/svn/trunk/cppguide.html

[Jan 2019] Suggestions
- Optimize poly_r.c/qh_update_vertexneighbors for qh_triangulate. qh_setunique and qh_setcompact are slow
- The size of maxpoints in qh_initialvertices/qh_maxsimplex should be d+3 unique points to help avoid QH6154
- Review coordT vs. realT.  Should parameters and variables be coordT when they are distances or coordinates?
  'coordT' is defined as 'realT'
  Having computations as 'double' with coordinates stored as 'float' requires many type conversions
  Expressions are often computed as 'double' anyway
  Source code sometimes uses 'coordT' and sometimes 'realT'
- Need a separate, hash check for duplicate ridge vertices in a facet list -- faster than current qh_checkfacet
- Add joggle for 'almost incident' vertices (order of 100), may clean up Qt as well, projected to hyperplane
- Consider using r.mergevertex2 to optimize qh_postmerge
- Report two facets with same ridge vertices, opposite orientation (topology error)
  add warning (see QH7084) for duplicate ridge with opposite orientation (only two facets in the list)
- Check 'qh_NOmerge' compiler option

[Jan 2016] Suggestions
------------
 - Add a post-merge pass for Delaunay slivers.  Merge into a neighbor with a circumsphere that includes the opposite point. [M. Treacy]
 - Option to add a bounding box for Delaunay triangulations, e,g., nearly coincident points
 - Rescale output to match 'QbB' on input [J. Metz, 1/30/2014 12:21p]
 - Run through valgrind
 - Notes to compgeom on conformant triangulation and Voronoi volume
 - Implement weighted Delaunay triangulation and weighted Voronoi diagram [A. Liebscher]
   e.g., Sugihara, "Three-dimensional convex hull as a fruitful source of diagrams," Theoretical Computer Science, 2000, 235:325-337
 - testqset: test qh_setdelnth and move-to-front
 - Makefile: Re-review gcc/g++ warnings.  OK in 2011.
 - Break up -Wextra into its components or figure out how to override -Wunused-but-set-variable
   unused-but-set-variable is reporting incorrectly.  All instances are annotated.

 - Can countT be defined as 'int', 'unsigned int', or 64-bit int?
   countT is currently defined as 'int' in qset_r.h
   Vertex ID and ridge ID perhaps should be countT, They are currently 'unsigned'
   Check use of 'int' vs. countT in all cpp code
   Check use of 'int' vs. countT in all c code
   qset_r.h defines countT -- duplicates code in user_r.h -- need to add to qset.h/user.h
   countT -1 used as a flag in Coordinates.mid(), QhullFacet->id()
   Also QhullPoints indexOf and lastIndexOf
   Also QhullPointSet indexOf and lastIndexOf
   Coordinates.indexOf assumes countT is signed (from end)
   Coordinates.lastIndexOf assumes countT is signed (from end)
   All error messages with countT are wrong, convert to int?
   RboxPoints.qh_fprintf_rbox, etc. message 9393 assumes countT but may be int, va_arg(args, countT);  Need to split

[Jan 2010] Suggestions
 - Generate vcproj from qtpro files
   cd qtpro && qmake -spec win32-msvc2005 -tp vc -recursive
   sed -i 's/C\:\/bash\/local\/qhull\/qtpro\///' qhull-all.sln
   Change qhullcpp to libqhull.dll
   Allow both builds on same host (keep /tmp separate)
 - C++ class for access to statistics, accumulate vs. add
 - Add dialog box to RoadError-- a virtual function?
 - Option 'Gt' does not make visible all facets of the mesh example, rbox 32 M1,0,1 | qhull d Gt
 - Merge small volume boundary cells into unbounded regions [Dominik Szczerba]
 - Postmerge with merge options
 - Add modify operators and MutablePointCoordinateIterator to PointCoordinates
 - Fix option Qt for conformant triangulations of merged facets
 - Investigate flipped facet -- rbox 100 s D3 t1263080158 | qhull R1e-3 Tcv Qc
 - Add doc comments to c++ code
 - Measure performance of Qhull, seconds per point by dimension
 - Report potential wraparound of 64-bit ints -- e.g., a large set or points

Documentation
- Qhull::addPoint().  Problems with qh_findbestfacet and otherpoints see
   qh-code.html#inc on-line construction with qh_addpoint()
- How to handle 64-bit possible loss of data.  WARN64, ptr_intT, size_t/int
- Show custom of qh_fprintf
- cat x.x | grep 'qh_mem ' | sort | awk '{ print $2; }' | uniq -c | grep -vE ' (2|4|6|8|10|12|14|16|20|64|162)[^0-9]'
- qtpro/qhulltest contains .pro and Makefile.  Remove Makefiles by setting shadow directory to ../../tmp/projectname
- Rules for use of qh_qh and multi processes
    UsingQhull
    errorIfAnotherUser
    ~QhullPoints() needs ownership of qh_qh
    Does !qh_pointer work?
    When is qh_qh required?  Minimize the time.
   qhmem, qhstat.ferr
   qhull_inuse==1 when qhull globals active [not useful?]
   rbox_inuse==1 when rbox globals active
   - Multithreaded -- call largest dimension for infinityPoint() and origin()
 - Better documentation for qhmem totshort, freesize, etc.
 - how to change .h, .c, and .cpp to text/html.  OK in Opera
 - QhullVertex.dimension() is not quite correct, epensive
 - Check globalAngleEpsilon
 - Deprecate save_qhull()

[Dec 2003] Here is a partial list:
 - fix finddelaunay() in user_eg.c for tricoplanar facets
 - write a BGL, C++ interface to Qhull
     http://www.boost.org/libs/graph/doc/table_of_contents.html
 - change qh_save_qhull to swap the qhT structure instead of using pointers
 - change error handling and tracing to be independent of 'qh ferr'
 - determine the maximum width for a given set of parameters
 - prove that directed search locates all coplanar facets
 - in high-d merging, can a loop of facets become disconnected?
 - find a way to improve inner hulls in 5-d and higher
 - determine the best policy for facet visibility ('Vn')
 - determine the limitations of 'Qg'

Precision improvements:
 - For 'Qt', resolve cross-linked, butterfly ridges.
     May allow retriangulation in qh_addpoint().
 - for Delaunay triangulations ('d' or 'v') under joggled input ('QJ'),
     remove vertical facets whose lowest vertex may be coplanar with convex hull
 - review use of 'Qbb' with 'd QJ'.  Is MAXabs_coord better than MAXwidth?
 - check Sugihara and Iri's better in-sphere test [Canadian
     Conf. on Comp. Geo., 1989; Univ. of Tokyo RMI 89-05]
 - replace centrum with center of mass and facet area
 - handle numeric overflow in qh_normalize and elsewhere
 - merge flipped facets into non-flipped neighbors.
     currently they merge into best neighbor (appears ok)
 - determine min norm for Cramer's rule (qh_sethyperplane_det).  It looks high.
 - improve facet width for very narrow distributions

New features:
 - implement Matlab's tsearch() using Qhull
 - compute volume of Voronoi regions.  You need to determine the dual face
   graph in all dimensions [see Clarkson's hull program]
 - compute alpha shapes [see Clarkson's hull program]
 - implement deletion of Delaunay vertices
      see Devillers, ACM Symposium on Computational Geometry, Minneapolis 1999.
 - compute largest empty circle [see O'Rourke, chapter 5.5.3] [Hase]
 - list redundant (i.e., coincident) vertices [Spitz]
 - implement Mucke, et al, ['96] for point location in Delaunay triangulations
 - implement convex hull of moving points
 - implement constrained Delaunay diagrams
      see Shewchuk, ACM Symposium on Computational Geometry, Minneapolis 1998.
 - estimate outer volume of hull
 - automatically determine lower dimensional hulls
 - allow "color" data for input points
      need to insert a coordinate for Delaunay triangulations

Input/output improvements:
 - Support the VTK Visualization Toolkit, http://www.kitware.com/vtk.html
 - generate output data array for Qhull library [Gautier]
 - need improved DOS window with screen fonts, scrollbar, cut/paste
 - generate Geomview output for Voronoi ridges and unbounded rays
 - generate Geomview output for halfspace intersection
 - generate Geomview display of furthest-site Voronoi diagram
 - use 'GDn' to view 5-d facets in 4-d
 - convert Geomview output for other 3-d viewers
 - add interactive output option to avoid recomputing a hull
 - orient vertex neighbors for 'Fv' in 3-d and 2-d
 - track total number of ridges for summary and logging

Performance improvements:
 - GPU hardware acceleration, particularly for qh_setplane [D. Reese]
 - optimize Qhull for 2-d Delaunay triangulations
 -   use O'Rourke's '94 vertex->duplicate_edge
 -   add bucketing
 -   better to specialize all of the code (ca. 2-3x faster w/o meSrging)
 - use updated LU decomposition to speed up hyperplane construction
 -        [Gill et al. 1974, Math. Comp. 28:505-35]
 - construct hyperplanes from the corresponding horizon/visible facets
 - for merging in high d, do not use vertex->neighbors

Please let us know about your applications and improvements.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Imprecision in Qhull
To: Qhull code: contents


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see Changes.txt

geometry/vignettes/qhull/html/qh-optp.html0000644000176200001440000002377114664417655020520 0ustar liggesusers Qhull print options (P)

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull print options (P)

This section lists the print options for Qhull. These options are indicated by 'P' followed by a letter. See Output, Geomview, and Format for other output options.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Print options

Po
force output despite precision problems
Po
if error, output neighborhood of facet
Pp
do not report precision problems
 
 
Selection options
PAn
print n largest facets by area
Pdk:n
print facets with normal[k] >= n (default 0.0)
PDk:n
print facets with normal[k] <= n
PFn
print facets whose area is at least n
Pg
print good facets only (needs 'QGn' or 'QVn')
PG
print neighbors of good facets
PMn
print n facets with most merges

»PAn - keep n largest facets by area

The n largest facets are marked good for printing. This may be useful for approximating a hull. Unless 'PG' is set, 'Pg' is automatically set.

»Pdk:n - print facet if normal[k] >= n

For a given output, print only those facets with normal[k] >= n and drop the others. For example, 'Pd0:0.5' prints facets with normal[0] >= 0.5 . The default value of n is zero. For example in 3-d, 'Pd0d1d2' prints facets in the positive octant.

If no facets match, use option 'Pg' to print the closest facet.

On Windows 95, do not combine multiple options. A 'd' is considered part of a number. For example, use 'Pd0:0.5 Pd1:0.5' instead of 'Pd0:0.5d1:0.5'.

»PDk:n - print facet if normal[k] <= n

For a given output, print only those facets with normal[k] <= n and drop the others. For example, 'PD0:0.5' prints facets with normal[0] <= 0.5 . The default value of n is zero. For example in 3-d, 'PD0D1D2' displays facets in the negative octant.

If no facets match, use option 'Pg' to print the closest facet.

In 2-d, 'd G PD2' displays the Delaunay triangulation instead of the corresponding paraboloid.

Be careful of placing 'Dk' or 'dk' immediately after a real number. Some compilers treat the 'D' as a double precision exponent.

»PFn - keep facets whose area is at least n

The facets with area at least n are marked good for printing. This may be useful for approximating a hull. Unless 'PG' is set, 'Pg' is automatically set.

»Pg - print good facets

Qhull can mark facets as "good". This is used to

  • mark the lower convex hull for Delaunay triangulations and Voronoi diagrams
  • mark the facets that are visible from a point (option 'QGn')
  • mark the facets that contain a point (option 'QVn').
  • indicate facets with a large enough area (options 'PAn' and 'PFn')
  • indicate facets with many merges (option 'PMn')

Option 'Pg' only prints good facets that also meet 'Pdk' and 'PDk' options. It is automatically set for options 'd', 'PAn', 'PFn', 'PMn', 'QGn', and 'QVn'.

»PG - print neighbors of good facets

Option 'PG' can be used with or without option 'Pg' to print the neighbors of good facets. For example, options 'QGn' and 'QVn' print the horizon facets for point n.

»PMn - keep n facets with most merges

The n facets with the most merges are marked good for printing. This may be useful for approximating a hull. Unless 'PG' is set, 'Pg' is automatically set.

Use option 'Fm' to print merges per facet.

»Po - force output despite precision problems

Use options 'Po' and 'Q0' if you can not merge facets, triangulate the output ('Qt'), or joggle the input (QJ).

Option 'Po' can not force output when duplicate ridges or duplicate facets occur. It may produce erroneous results. For these reasons, merged facets, joggled input, or exact arithmetic are better.

If you need a simplicial Delaunay triangulation, use joggled input 'QJ' or triangulated output 'Ft'.

Option 'Po' may be used without 'Q0' to remove some steps from Qhull or to output the neighborhood of an error.

Option 'Po' may be used with option 'Q5') to skip qh_check_maxout (i.e., do not determine the maximum outside distance). This can save a significant amount of time.

If option 'Po' is used,

  • most precision errors allow Qhull to continue.
  • verify ('Tv') does not check coplanar points.
  • points are not partitioned into flipped facets and a flipped facet is always visible to a point. This may delete flipped facets from the output.

»Po - if error, output neighborhood of facet

If an error occurs before the completion of Qhull and tracing is not active, 'Po' outputs a neighborhood of the erroneous facets (if any). It uses the current output options.

See 'Po' - force output despite precision problems.

»Pp - do not report precision problems

With option 'Pp', Qhull does not print statistics about precision problems, and it removes some of the warnings. It removes the narrow hull warning.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qvoronoi.html0000644000176200001440000007022114664417655020774 0ustar liggesusers qvoronoi -- Voronoi diagram Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options

[voronoi]qvoronoi -- Voronoi diagram

The Voronoi diagram is the nearest-neighbor map for a set of points. Each region contains those points that are nearer one input site than any other input site. It has many useful properties and applications. See the survey article by Aurenhammer ['91] and the detailed introduction by O'Rourke ['94]. The Voronoi diagram is the dual of the Delaunay triangulation.

Example: rbox 10 D3 | qvoronoi s o TO result
Compute the 3-d Voronoi diagram of 10 random points. Write a summary to the console and the Voronoi vertices and regions to 'result'. The first vertex of the result indicates unbounded regions.
 
Example: rbox r y c G0.1 D2 | qvoronoi s o TO result
Compute the 2-d Voronoi diagram of a triangle and a small square. Write a summary to the console and Voronoi vertices and regions to 'result'. Report a single Voronoi vertex for cocircular input sites. The first vertex of the result indicates unbounded regions. The origin is the Voronoi vertex for the square.
 
Example: rbox r y c G0.1 D2 | qvoronoi Fv TO result
Compute the 2-d Voronoi diagram of a triangle and a small square. Write a summary to the console and the Voronoi ridges to 'result'. Each ridge is the perpendicular bisector of a pair of input sites. Vertex "0" indicates unbounded ridges. Vertex "8" is the Voronoi vertex for the square.
 
Example: rbox r y c G0.1 D2 | qvoronoi Fi
Print the bounded, separating hyperplanes for the 2-d Voronoi diagram of a triangle and a small square. Note the four hyperplanes (i.e., lines) for Voronoi vertex "8". It is at the origin.

Qhull computes the Voronoi diagram via the Delaunay triangulation. Each Voronoi vertex is the circumcenter of a facet of the Delaunay triangulation. Each Voronoi region corresponds to a vertex (i.e., input site) of the Delaunay triangulation.

Qhull outputs the Voronoi vertices for each Voronoi region. With option 'Fv', it lists all ridges of the Voronoi diagram with the corresponding pairs of input sites. With options 'Fi' and 'Fo', it lists the bounded and unbounded separating hyperplanes. You can also output a single Voronoi region for further processing [see graphics].

Use option 'Qz' if the input is circular, cospherical, or nearly so. It improves precision by adding a point "at infinity," above the corresponding paraboloid.

See Qhull FAQ (local) - Delaunay and Voronoi diagram questions.

The 'qvonoroi' program is equivalent to 'qhull v Qbb'. It disables the following Qhull options: d n v Qbb QbB Qf Qg Qm Qr Qv Qx Qz TR E V Fa FA FC FD FS Ft FV Gt Q0,etc.

Copyright © 1995-2020 C.B. Barber

Voronoi image by KOOK Architecture, Silvan Oesterle and Michael Knauss.


»qvoronoi synopsis

qvoronoi -- compute the Voronoi diagram.
    input (stdin): dimension, number of points, point coordinates
    comments start with a non-numeric character

options (qvoronoi.html):
    Qu   - compute furthest-site Voronoi diagram
    Tv   - verify result: structure, convexity, and in-circle test
    .    - concise list of all options
    -    - one-line description of all options
    -?   - this message
    -V   - version

output options (subset):
    Fi   - separating hyperplanes for bounded regions, 'Fo' for unbounded
    FN   - count and Voronoi vertices for each Voronoi region
    Fv   - Voronoi diagram as Voronoi vertices between adjacent input sites
    G    - Geomview output (2-d only)
    o    - OFF file format (dim, Voronoi vertices, and Voronoi regions)
    p    - Voronoi vertices
    QVn  - Voronoi vertices for input point n, -n if not
    s    - summary of results (default)
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes

examples:
rbox c P0 D2 | qvoronoi s o         rbox c P0 D2 | qvoronoi Fi
rbox c P0 D2 | qvoronoi Fo          rbox c P0 D2 | qvoronoi Fv
rbox c P0 D2 | qvoronoi s Qu Fv     rbox c P0 D2 | qvoronoi Qu Fo
rbox c G1 d D2 | qvoronoi s p       rbox c P0 D2 | qvoronoi s Fv QV0

»qvoronoi input

The input data on stdin consists of:
  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qvoronoi < data.txt), a pipe (e.g., rbox 10 | qvoronoi), or the 'TI' option (e.g., qvoronoi TI data.txt).

For example, this is four cocircular points inside a square. Their Voronoi diagram has nine vertices and eight regions. Notice the Voronoi vertex at the origin, and the Voronoi vertices (on each axis) for the four sides of the square.

rbox s 4 W0 c G1 D2 > data
2 RBOX s 4 W0 c D2
8
-0.4941988586954018 -0.07594397977563715
-0.06448037284989526 0.4958248496365813
0.4911154367094632 0.09383830681375946
-0.348353580869097 -0.3586778257652367
    -1     -1
    -1      1
     1     -1
     1      1

qvoronoi s p < data


Voronoi diagram by the convex hull of 8 points in 3-d:

  Number of Voronoi regions: 8
  Number of Voronoi vertices: 9
  Number of non-simplicial Voronoi vertices: 1

Statistics for: RBOX s 4 W0 c D2 | QVORONOI s p

  Number of points processed: 8
  Number of hyperplanes created: 18
  Number of facets in hull: 10
  Number of distance tests for qhull: 33
  Number of merged facets: 2
  Number of distance tests for merging: 102
  CPU seconds to compute hull (after input): 0.094

2
9
4.217546450968612e-17 1.735507986399734
-8.402566836762659e-17 -1.364368854147395
0.3447488772716865 -0.6395484723719818
1.719446929853986 2.136555906154247e-17
0.4967882915039657 0.68662371396699
-1.729928876283549 1.343733067524222e-17
-0.8906163241424728 -0.4594150543829102
-0.6656840313875723 0.5003013793414868
-7.318364664277155e-19 -1.188217818408333e-16

» qvoronoi outputs

These options control the output of Voronoi diagrams.

 
Voronoi vertices
p
print the coordinates of the Voronoi vertices. The first line is the dimension. The second line is the number of vertices. Each remaining line is a Voronoi vertex.
Fn
list the neighboring Voronoi vertices for each Voronoi vertex. The first line is the number of Voronoi vertices. Each remaining line starts with the number of neighboring vertices. Negative vertices (e.g., -1) indicate vertices outside of the Voronoi diagram. In the circle-in-box example, the Voronoi vertex at the origin has four neighbors.
FN
list the Voronoi vertices for each Voronoi region. The first line is the number of Voronoi regions. Each remaining line starts with the number of Voronoi vertices. Negative indices (e.g., -1) indicate vertices outside of the Voronoi diagram. In the circle-in-box example, the four bounded regions are defined by four Voronoi vertices.
 
 
Voronoi regions
o
print the Voronoi regions in OFF format. The first line is the dimension. The second line is the number of vertices, the number of input sites, and "1". The third line represents the vertex-at-infinity. Its coordinates are "-10.101". The next lines are the coordinates of the Voronoi vertices. Each remaining line starts with the number of Voronoi vertices in a Voronoi region. In 2-d, the vertices are listed in adjacency order (unoriented). In 3-d and higher, the vertices are listed in numeric order. In the circle-in-square example, each bounded region includes the Voronoi vertex at the origin. Lines consisting of 0 indicate coplanar input sites or 'Qz'.
Fi
print separating hyperplanes for inner, bounded Voronoi regions. The first number is the number of separating hyperplanes. Each remaining line starts with 3+dim. The next two numbers are adjacent input sites. The next dim numbers are the coefficients of the separating hyperplane. The last number is its offset. Use 'Tv' to verify that the hyperplanes are perpendicular bisectors. It will list relevant statistics to stderr.
Fo
print separating hyperplanes for outer, unbounded Voronoi regions. The first number is the number of separating hyperplanes. Each remaining line starts with 3+dim. The next two numbers are adjacent input sites on the convex hull. The next dim numbers are the coefficients of the separating hyperplane. The last number is its offset.
 
 
Input sites
Fv
list ridges of Voronoi vertices for pairs of input sites. The first line is the number of ridges. Each remaining line starts with two plus the number of Voronoi vertices in the ridge. The next two numbers are two adjacent input sites. The remaining numbers list the Voronoi vertices. As with option 'o', a 0 indicates the vertex-at-infinity and an unbounded, separating hyperplane. The perpendicular bisector (separating hyperplane) of the input sites is a flat through these vertices. In the circle-in-square example, the ridge for each edge of the square is unbounded.
Fc
list coincident input sites for each Voronoi vertex. The first line is the number of vertices. The remaining lines start with the number of coincident sites and deleted vertices. Deleted vertices indicate highly degenerate input (see'Fs'). A coincident site is assigned to one Voronoi vertex. Do not use 'QJ' with 'Fc'; the joggle will separate coincident sites.
FP
print coincident input sites with distance to nearest site (i.e., vertex). The first line is the number of coincident sites. Each remaining line starts with the point ID of an input site, followed by the point ID of a coincident point, its vertex, and distance. Includes deleted vertices which indicate highly degenerate input (see'Fs'). Do not use 'QJ' with 'FP'; the joggle will separate coincident sites.
 
 
General
s
print summary of the Voronoi diagram. Use 'Fs' for numeric data.
i
list input sites for each Delaunay region. Use option 'Pp' to avoid the warning. The first line is the number of regions. The remaining lines list the input sites for each region. The regions are oriented. In the circle-in-square example, the cocircular region has four edges. In 3-d and higher, report cospherical sites by adding extra points.
G
Geomview output for 2-d Voronoi diagrams.

» qvoronoi controls

These options provide additional control:

Qu
compute the furthest-site Voronoi diagram.
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
QVn
select Voronoi vertices for input site n
Qz
add a point above the paraboloid to reduce precision errors. Use it for nearly cocircular/cospherical input (e.g., 'rbox c | qvoronoi Qz').
Tv
verify result
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
TFn
report progress after constructing n facets
PDk:1
include upper and lower facets in the output. Set k to the last dimension (e.g., 'PD2:1' for 2-d inputs).
f
facet dump. Print the data structure for each facet (i.e., Voronoi vertex).

» qvoronoi graphics

In 2-d, Geomview output ('G') displays a Voronoi diagram with extra edges to close the unbounded Voronoi regions. To view the unbounded rays, enclose the input points in a square.

You can also view individual Voronoi regions in 3-d. To view the Voronoi region for site 3 in Geomview, execute

qvoronoi <data QV3 p | qconvex s G >output

The qvoronoi command returns the Voronoi vertices for input site 3. The qconvex command computes their convex hull. This is the Voronoi region for input site 3. Its hyperplane normals (qconvex 'n') are the same as the separating hyperplanes from options 'Fi' and 'Fo' (up to roundoff error).

See the Delaunay and Voronoi examples for 2-d and 3-d examples. Turn off normalization (on Geomview's 'obscure' menu) when comparing the Voronoi diagram with the corresponding Delaunay triangulation.

»qvoronoi notes

You can simplify the Voronoi diagram by enclosing the input sites in a large square or cube. This is particularly recommended for cocircular or cospherical input data.

See Voronoi graphics for computing the convex hull of a Voronoi region.

Voronoi diagrams do not include facets that are coplanar with the convex hull of the input sites. A facet is coplanar if the last coefficient of its normal is nearly zero (see qh_ZEROdelaunay).

Unbounded regions can be confusing. For example, 'rbox c | qvoronoi Qz o' produces the Voronoi regions for the vertices of a cube centered at the origin. All regions are unbounded. The output is

3
2 9 1
-10.101 -10.101 -10.101
     0      0      0
2 0 1
2 0 1
2 0 1
2 0 1
2 0 1
2 0 1
2 0 1
2 0 1
0

The first line is the dimension. The second line is the number of vertices and the number of regions. There is one region per input point plus a region for the point-at-infinity added by option 'Qz'. The next two lines lists the Voronoi vertices. The first vertex is the infinity vertex. It is indicate by the coordinates -10.101. The second vertex is the origin. The next nine lines list the regions. Each region lists two vertices -- the infinity vertex and the origin. The last line is "0" because no region is associated with the point-at-infinity. A "0" would also be listed for nearly incident input sites.

To use option 'Fv', add an interior point. For example,

rbox c P0 | qvoronoi Fv
20
5 0 7 1 3 5
5 0 3 1 4 5
5 0 5 1 2 3
5 0 1 1 2 4
5 0 6 2 3 6
5 0 2 2 4 6
5 0 4 4 5 6
5 0 8 5 3 6
5 1 2 0 2 4
5 1 3 0 1 4
5 1 5 0 1 2
5 2 4 0 4 6
5 2 6 0 2 6
5 3 4 0 4 5
5 3 7 0 1 5
5 4 8 0 6 5
5 5 6 0 2 3
5 5 7 0 1 3
5 6 8 0 6 3
5 7 8 0 3 5

The output consists of 20 ridges and each ridge lists a pair of input sites and a triplet of Voronoi vertices. The first eight ridges connect the origin ('P0'). The remainder list the edges of the cube. Each edge generates an unbounded ray through the midpoint. The corresponding separating planes ('Fo') follow each pair of coordinate axes.

Options 'Qt' (triangulated output) and 'QJ' (joggled input) are deprecated. They may produce unexpected results. If you use these options, cocircular and cospherical input sites will produce duplicate or nearly duplicate Voronoi vertices. See also Merged facets or joggled input.

»qvoronoi conventions

The following terminology is used for Voronoi diagrams in Qhull. The underlying structure is a Delaunay triangulation from a convex hull in one higher dimension. Facets of the Delaunay triangulation correspond to vertices of the Voronoi diagram. Vertices of the Delaunay triangulation correspond to input sites. They also correspond to regions of the Voronoi diagram. See convex hull conventions, Delaunay conventions, and Qhull's data structures.

  • input site - a point in the input (one dimension lower than a point on the convex hull)
  • point - a point has d+1 coordinates. The last coordinate is the sum of the squares of the input site's coordinates
  • coplanar point - a nearly incident input site
  • vertex - a point on the paraboloid. It corresponds to a unique input site.
  • point-at-infinity - a point added above the paraboloid by option 'Qz'
  • Delaunay facet - a lower facet of the paraboloid. The last coefficient of its normal is clearly negative.
  • Voronoi vertex - the circumcenter of a Delaunay facet
  • Voronoi region - the Voronoi vertices for an input site. The region of Euclidean space nearest to an input site.
  • Voronoi diagram - the graph of the Voronoi regions. It includes the ridges (i.e., edges) between the regions.
  • vertex-at-infinity - the Voronoi vertex that indicates unbounded Voronoi regions in 'o' output format. Its coordinates are -10.101.
  • good facet - a Voronoi vertex with optional restrictions by 'QVn', etc.

»qvoronoi options

qvoronoi -- compute the Voronoi diagram
    http://www.qhull.org

input (stdin):
    first lines: dimension and number of points (or vice-versa).
    other lines: point coordinates, best if one point per line
    comments:    start with a non-numeric character

options:
    Qu   - compute furthest-site Voronoi diagram

Qhull control options:
    Qa   - allow input with fewer or more points than coordinates
    QRn  - random rotation (n=seed, n=0 time, n=-1 time/no rotate)
    Qs   - search all points for the initial simplex
    Qz   - add point-at-infinity to Voronoi diagram

Qhull extra options:
    QGn  - Voronoi vertices if visible from point n, -n if not
    QVn  - Voronoi vertices for input point n, -n if not
    Qw   - allow option warnings
    Q12  - allow wide facets and wide dupridge
    Q14  - merge pinched vertices that create a dupridge

T options:
    TFn  - report summary when n or more facets created
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes
    Ts   - statistics
    Tv   - verify result: structure, convexity, and in-circle test
    Tz   - send all output to stdout

Trace options:
    T4   - trace at level n, 4=all, 5=mem/gauss, -1= events
    Ta   - annotate output with message codes
    TAn  - stop qhull after adding n vertices
     TCn - stop qhull after building cone for point n
     TVn - stop qhull after adding point n, -n for before
    Tc   - check frequently during execution
    Tf   - flush each qh_fprintf for debugging segfaults
    TPn  - turn on tracing when point n added to hull
     TMn - turn on tracing at merge n
     TWn - trace merge facets when width > n

Precision options:
    Cn   - radius of centrum (roundoff added).  Merge facets if non-convex
     An  - cosine of maximum angle.  Merge facets if cosine > n or non-convex
           C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge
    Rn   - randomly perturb computations by a factor of [1-n,1+n]
    Wn   - min facet width for non-coincident point (before roundoff)

Output formats (may be combined; if none, summary to stdout):
    p    - Voronoi vertices
    s    - summary to stderr
    f    - facet dump
    i    - Delaunay regions (use 'Pp' to avoid warning)
    o    - OFF format (dim, Voronoi vertices, and Voronoi regions)

More formats:
    Fc   - count plus coincident points (by Voronoi vertex)
    Fd   - use cdd format for input (homogeneous with offset first)
    FD   - use cdd format for output (offset first)
    FF   - facet dump without ridges
    Fi   - separating hyperplanes for bounded Voronoi regions
    FI   - ID for each Voronoi vertex
    Fm   - merge count for each Voronoi vertex (511 max)
    Fn   - count plus neighboring Voronoi vertices for each Voronoi vertex
    FN   - count and Voronoi vertices for each Voronoi region
    Fo   - separating hyperplanes for unbounded Voronoi regions
    FO   - options and precision constants
    FP   - nearest point and distance for each coincident point
    FQ   - command used for qvoronoi
    Fs   - summary: #int (8), dimension, #points, tot vertices, tot facets,
                    for output: #Voronoi regions, #Voronoi vertices,
                                #coincident points, #non-simplicial regions
                    #real (2), max outer plane and min vertex
    Fv   - Voronoi diagram as Voronoi vertices between adjacent input sites
    Fx   - extreme points of Delaunay triangulation (on convex hull)

Geomview output (2-d only)
    Ga   - all points as dots
     Gp  -  coplanar points and vertices as radii
     Gv  -  vertices as spheres
    Gc   - centrums
    GDn  - drop dimension n in 3-d and 4-d output
    Gh   - hyperplane intersections
    Gi   - inner planes only
     Gn  -  no planes
     Go  -  outer planes only
    Gr   - ridges

Print options:
    PAn  - keep n largest Voronoi vertices by 'area'
    Pdk:n - drop facet if normal[k] <= n (default 0.0)
    PDk:n - drop facet if normal[k] >= n
    PFn  - keep Voronoi vertices whose 'area' is at least n
    Pg   - print good Voronoi vertices (needs 'QGn' or 'QVn')
    PG   - print neighbors of good Voronoi vertices
    PMn  - keep n Voronoi vertices with most merges
    Po   - force output.  If error, output neighborhood of facet
    Pp   - do not report precision problems

    .    - list of all options
    -    - one line descriptions of all options
    -?   - help with examples
    -V   - version

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/rbox.html0000644000176200001440000002302514664417655020072 0ustar liggesusers rbox -- generate point distributions

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • outputs • examples • notes • options


[CONE]rbox -- generate point distributions

rbox generates random or regular points according to the options given, and outputs the points to stdout. The points are generated in a cube, unless 's', 'x', or 'y' are given.

»rbox synopsis

rbox- generate various point distributions.  Default is random in cube.

args (any order, space separated):
  3000    number of random points in cube, lens, spiral, sphere or grid
  D3      dimension 3-d
  c       add a unit cube to the output ('c G2.0' sets size)
  d       add a unit diamond to the output ('d G2.0' sets size)
  l       generate a regular 3-d spiral
  r       generate a regular polygon, ('r s Z1 G0.1' makes a cone)
  s       generate cospherical points
  x       generate random points in simplex, may use 'r' or 'Wn'
  y       same as 'x', plus simplex
  Cn,r,m  add n nearly coincident points within radius r of m points
  Pn,m,r  add point [n,m,r] first, pads with 0

  Ln      lens distribution of radius n.  Also 's', 'r', 'G', 'W'.
  Mn,m,r  lattice (Mesh) rotated by [n,-m,0], [m,n,0], [0,0,r], ...
          '27 M1,0,1' is {0,1,2} x {0,1,2} x {0,1,2}.  Try 'M3,4 z'.
  W0.1    random distribution within 0.1 of the cube's or sphere's surface
  Z0.5 s  random points in a 0.5 disk projected to a sphere
  Z0.5 s G0.6 same as Z0.5 within a 0.6 gap

  Bn      bounding box coordinates, default 0.5
  h       output as homogeneous coordinates for cdd
  n       remove command line from the first line of output
  On      offset coordinates by n
  t       use time as the random number seed (default is command line)
  tn      use n as the random number seed
  z       print integer coordinates, default 'Bn' is 1e+06

»rbox outputs

The format of the output is the following: first line contains the dimension and a comment, second line contains the number of points, and the following lines contain the points, one point per line. Points are represented by their coordinate values.

For example, rbox c 10 D2 generates

2 RBOX c 10 D2
14
-0.4999921736307369 -0.3684622117955817
0.2556053225468894 -0.0413498678629751
0.0327672376602583 -0.2810408135699488
-0.452955383763607 0.17886471718444
0.1792964061529342 0.4346928963760779
-0.1164979223315585 0.01941637230982666
0.3309653464993139 -0.4654278894564396
-0.4465383649305798 0.02970019358182344
0.1711493843897706 -0.4923018137852678
-0.1165843490665633 -0.433157762450313
  -0.5   -0.5
  -0.5    0.5
   0.5   -0.5
   0.5    0.5

»rbox examples

       rbox 10
              10 random points in the unit cube centered  at  the
              origin.

       rbox 10 s D2
              10 random points on a 2-d circle.

       rbox 100 W0
              100 random points on the surface of a cube.

       rbox 1000 s D4
              1000 random points on a 4-d sphere.

       rbox c D5 O0.5
              a 5-d hypercube with one corner at the origin.

       rbox d D10
              a 10-d diamond.

       rbox x 1000 r W0
              100 random points on the surface of a fixed simplex

       rbox y D12
              a 12-d simplex.

       rbox l 10
              10 random points along a spiral

       rbox l 10 r
              10 regular points  along  a  spiral  plus  two  end
              points

       rbox 1000 L10000 D4 s
              1000 random points on the surface of a narrow lens.

           rbox 1000 L100000 s G1e-6
                  1000 random points near the edge of a narrow lens

       rbox c G2 d G3
              a cube with coordinates +2/-2 and  a  diamond  with
              coordinates +3/-3.

       rbox 64 M3,4 z
              a  rotated,  {0,1,2,3} x {0,1,2,3} x {0,1,2,3} lat-
              tice (Mesh) of integer points.

       rbox P0 P0 P0 P0 P0
              5 copies of the origin in 3-d.  Try 'rbox P0 P0  P0
              P0 P0 | qhull QJ'.

       r 100 s Z1 G0.1
              two  cospherical  100-gons plus another cospherical
              point.

       100 s Z1
              a cone of points.

       100 s Z1e-7
              a narrow cone of points with many precision errors.

»rbox notes

Some combinations of arguments generate odd results.

»rbox options

       n      number of points

       Dn     dimension n-d (default 3-d)

       Bn     bounding box coordinates (default 0.5)

       l      spiral distribution, available only in 3-d

       Ln     lens  distribution  of  radius n.  May be used with
              's', 'r', 'G', and 'W'.

       Mn,m,r lattice  (Mesh)  rotated  by  {[n,-m,0],   [m,n,0],
              [0,0,r],  ...}.   Use  'Mm,n'  for a rigid rotation
              with r = sqrt(n^2+m^2).  'M1,0'  is  an  orthogonal
              lattice.   For  example,  '27  M1,0'  is  {0,1,2} x
              {0,1,2} x {0,1,2}.

       s      cospherical points randomly generated in a cube and
              projected to the unit sphere

       x      simplicial  distribution.   It  is fixed for option
              'r'.  May be used with 'W'.

       y      simplicial distribution plus a simplex.   Both  'x'
              and 'y' generate the same points.

       Wn     restrict  points  to distance n of the surface of a
              sphere or a cube

       c      add a unit cube to the output

       c Gm   add a cube with all combinations of +m  and  -m  to
              the output

       d      add a unit diamond to the output.

       d Gm   add a diamond made of 0, +m and -m to the output

       Cn,r,m add n nearly coincident points within radius r of m points

       Pn,m,r add point [n,m,r] to the output first.  Pad coordi-
              nates with 0.0.

       n      Remove the command line from the first line of out-
              put.

       On     offset the data by adding n to each coordinate.

       t      use  time  in  seconds  as  the  random number seed
              (default is command line).

       tn     set the random number seed to n.

       z      generate integer coordinates.  Use 'Bn'  to  change
              the  range.   The  default  is 'B1e6' for six-digit
              coordinates.  In R^4, seven-digit coordinates  will
              overflow hyperplane normalization.

       Zn s   restrict points to a disk about the z+ axis and the
              sphere (default Z1.0).  Includes the opposite pole.
              'Z1e-6'  generates  degenerate  points under single
              precision.

       Zn Gm s
              same as Zn with an empty center (default G0.5).

       r s D2 generate a regular polygon

       r s Z1 G0.1
              generate a regular cone

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • outputs • examples • notes • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: August 12, 1998

geometry/vignettes/qhull/html/qh--half.gif0000644000176200001440000000475113431000556020276 0ustar liggesusersGIF87addç.=-/HO%#-ZdbQ?qR0^S;D6gE2hTN;BGG•PZLL‰9 \%+'/<>lN..hPHyJJH‰FNOJ91BWƒ.\pX`NNOIGUM8N™o44II‚&B;¡X[@@XC2[:8']eqH8L‹PY\;.X_l)TKK‡eo|$.%HJO}84‰@CSSSQQQ¡YkMMM‹k”jRcmO1WgLKLSHI‰i’dEMOg'h7/BBfpR0>>7JJ…7:0IBd48‘RW43#¢Zk$5'-19D`'=AgK46OS*-u&LHHGF?Og;4€bˆ9UYWKzvZ~EEQ™TeFG}FHH362-<,–SXBBo.3#rS1‰HUXO?=JVžVYA,Z*6,`@)MMŠ`T@EBaAOS<=7-0[[\Ž-g+.{JJ€7YRSSG#Y:VY‡=8NOOfK?KMLn9rWN:i-FF|yNK/=-OV] (¢!‹¦Ie^¨:tœQJ\ (òéQ†ˆ-P/\ DuÕeÊHbÊ1É“<`Æâ%kV/k¸bŒFØ·`·Ê:דZ‹ðö4€ WMÙ2sˤ½+ÑÇ&¾ˆ·Ð 'a‡¶DHAŒØ/àË 7Lò†²gÅs òbK³Bxn=S~æ%ôÜ­¦~UýÙu/bDC[µeÑ€aë¨ÁQoÕ"øð¡CÇ‹' ÃÎ>N¹‹k×®gëÝÇ ê”Gþ¥¸žýZ îºm OYˆ6ò×#©¾‡=åMå˻ФÛ;X)íˆb_XøÁwM1pÄfËaaÙ‘K;ÆÙÇD~שbMlõ‰%…:K< Ïì5Cá5p|ƒf.\׃̡Ɍrœxfƒ 8K=f _VRÄ'Y@0mî‘r )F¦ˆah6Ý[#ÌrB ‘šjø‰ä5‘øáG1!!\ÊqÂ$´,Ó[–Gé‚—Q<æƒg#¨F%'¢–Fã%zwíHÙ†ƒà`†žG¶y*^òGØ“|9²ÈÇ5B¢[ÂÑ(a4<3`{Ú`JŠ^^xלŸ"f:%𩤗þÎ&hªomPN dx£ ’‘€ãe ¥©Õ­b­p†.5Ô Ë)₯~€W4 A¬Xf(›,²? Ó´à€ÉoׂµÚj«K9ç€[Z³; :ÛÖ«Kx,mœ\‘Sn ›.²gÜ`‰—ÑNÁU ”»A:GüÃ.XrŽ—àÀAS980dª Ðñ¶=P1¾‚“ žB“±HkÀ'{F&[Å’à`’E È0ÌкL:É&ì‰XGN_¬ÅmÜ‘ˆÈ”D,þ¦J¯ÒIg`òÓÄq 8Z€s$d‘EŽ09Ðð§ìv²ìDGþÙ{ÇÁZhAÛ´QЏ/ÙЧö}ÀÎÝÊ&R6ß“_8„³ÝB“/³}jLy 6ŒMùÞÇh昳E&»sà!1ë  v:7˜NöÞ¢Š&™ÐÆÝR±xÜ›œ(Ñ0(qw({Oþ»ÉWXŒ*m@BøÑÜq"K ƒò Ã5 '¸C=õF<6Ù÷Ý·Éç(N/æšh°Á%Š{G<^‘½…‹˜ßü:P=‘¡ “ÓÞþ €ÿõ"s æx òk%žS`<ÞÁ@k傯ßô&8½3$+¦Ó`ã ‡ÿýoþS@ JXÀ̬f*T!§ Îpz†Êq (äPF8|Ø‹~¢DŒF&¾±æ%1+l„ôœ(CêAñ»ÈŸïö7„rñƒ½XÂXB^ %1(ÄW\@±4D4<à<àsä[ìˆG<ÎÁ$âU24’†dãüŒ s┇H#ñ ·Ó¹bJ[¬äÿAŒO€X‰,LÀŒO*ð‡” )M‰Êbž²ÄYÙ°€…3Ý1Á81†A" à|*±… ^Æ_³¤ô€1ÇYÌ4Ò Ì¬E%&!Ë9 cšÄ¸B&9ÇŒ ¿þŒáôILrú ÀA-Ò‰…JãdÄ;ß9k”ð]/I3%ƒŸþÌ( 0p‚ 5h'q€…ƒzàE6 “ 0c¥ Qhull control options (Q)

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull control options (Q)

This section lists the control options for Qhull. These options are indicated by 'Q' followed by a letter.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Qhull control options

Qa
allow input with fewer or more points than coordinates
Qc
keep coplanar points with nearest facet
Qi
keep interior points with nearest facet
QJ
joggled input to avoid precision problems
Qt
triangulated output
Qu
compute upper hull for furthest-site Delaunay triangulation
Qw
allow warnings about Qhull options
 
 
Precision handling
Qbb
scale last coordinate to [0,m] for Delaunay
Qs
search all points for the initial simplex
Qv
test vertex neighbors for convexity
Qx
exact pre-merges (allows coplanar facets)
Qz
add a point-at-infinity for Delaunay triangulations
 
 
Transform input
Qbk:n
scale coord[k] to low bound of n (default -0.5)
Qbk:0Bk:0
drop dimension k from input
QbB
scale input to fit the unit cube
QBk:n
scale coord[k] to upper bound of n (default 0.5)
QRn
random rotation (n=seed, n=0 time, n=-1 time/no rotate)
 
 
Select facets
Qg
only build good facets (needs 'QGn', 'QVn', or 'Pdk')
QGn
good facet if visible from point n, -n for not visible
QVn
good facet if it includes point n, -n if not
 
 
Experimental
Qf
partition point to furthest outside facet
Qm
process points only if they would increase the max. outer plane
Qr
process random outside points instead of furthest one
Q0
do not pre-merge facets with 'C-0' or 'Qx'
Q1
merge by mergetype/angle instead of mergetype/distance
Q2
merge all non-convex at once instead of independent sets
Q3
do not merge redundant vertices
Q4
avoid merging old facets into new facets
Q5
do not correct outer planes at end of qhull
Q6
do not pre-merge concave or coplanar facets
Q7
process facets depth-first instead of breadth-first
Q8
ignore near-interior points
Q9
process furthest of furthest points
Q10
no special processing for narrow distributions
Q11
copy normals and recompute centrums for tricoplanar facets
Q12
allow wide facets and wide dupridge
Q14
merge pinched vertices that create a dupridge
Q15
check for duplicate ridges with the same vertices

»Qa - allow input with fewer or more points than coordinates

Option 'Qa' (qh.ALLOWshort) allows input with fewer or more points than coordinates. Qhull's input starts with the number of points and the dimension, d. The coordinates follow, d coordinates per point.

With option 'Qa', there may be fewer or more points than coordinates. This simplifies exploring an input point set by adjusting the number of points.

»Qbb - scale the last coordinate to [0,m] for Delaunay

After scaling with option 'Qbb', the lower bound of the last coordinate will be 0 and the upper bound will be the maximum width of the other coordinates. Scaling happens after projecting the points to a paraboloid and scaling other coordinates.

Option 'Qbb' is automatically set for qdelaunay and qvoronoi. Option 'Qbb' is automatically set for joggled input 'QJ'.

Option 'Qbb' should be used for Delaunay triangulations with integer coordinates. Since the last coordinate is the sum of squares, it may be much larger than the other coordinates. For example, rbox 10000 D2 B1e8 | qhull d has precision problems while rbox 10000 D2 B1e8 | qhull d Qbb is OK.

»QbB - scale the input to fit the unit cube

After scaling with option 'QbB', the lower bound will be -0.5 and the upper bound +0.5 in all dimensions. For different bounds change qh_DEFAULTbox in user.h (0.5 is best for Geomview).

For Delaunay and Voronoi diagrams, scaling happens after projection to the paraboloid. Under precise arithmetic, scaling does not change the topology of the convex hull. Scaling may reduce precision errors if coordinate values vary widely.

»Qbk:n - scale coord[k] to low bound

After scaling, the lower bound for dimension k of the input points will be n. 'Qbk' scales coord[k] to -0.5.

»QBk:n - scale coord[k] to upper bound

After scaling, the upper bound for dimension k of the input points will be n. 'QBk' scales coord[k] to 0.5.

»Qbk:0Bk:0 - drop dimension k from the input points

Drop dimension k from the input points. For example, 'Qb1:0B1:0' deletes the y-coordinate from all input points. This allows the user to take convex hulls of sub-dimensional objects. It happens before the Delaunay and Voronoi transformation. It happens after the halfspace transformation for both the data and the feasible point.

»Qc - keep coplanar points with nearest facet

During construction of the hull, a point is coplanar if it is between 'Wn' above and 'Un' below a facet's hyperplane. A different definition is used for output from Qhull.

For output, a coplanar point is above the minimum vertex (i.e., above the inner plane). With joggle ('QJ'), a coplanar point includes points within one joggle of the inner plane.

With option 'Qc', output formats 'p', 'f', 'Gp', 'Fc', 'FN', and 'FP' will print the coplanar points. With options 'Qc Qi' these outputs include the interior points.

For Delaunay triangulations (qdelaunay or qvoronoi), a coplanar point is a point that is nearly incident to a vertex. All input points are either vertices of the triangulation or coplanar.

Qhull stores coplanar points with a facet. While constructing the hull, it retains all points within qh_RATIOnearInside (user.h) of a facet. In qh_check_maxout(), it uses these points to determine the outer plane for each facet. With option 'Qc', qh_check_maxout() retains points above the minimum vertex for the hull. Other points are removed. If qh_RATIOnearInside is wrong or if options 'Q5 Q8' are set, a coplanar point may be missed in the output (see Qhull limitations).

»Qf - partition point to furthest outside facet

After adding a new point to the convex hull, Qhull partitions the outside points and coplanar points of the old, visible facets. Without the 'f' option and merging, it assigns a point to the first facet that it is outside ('Wn'). When merging, it assigns a point to the first facet that is more than several times outside (see qh_DISToutside in user.h).

If option 'Qf' is selected, Qhull performs a directed search (no merging) or an exhaustive search (merging) of new facets. Option 'Qf' may reduce precision errors if pre-merging does not occur.

Option 'Q9' processes the furthest of all furthest points.

»Qg - only build good facets (needs 'QGn' 'QVn' or 'Pdk')

Qhull has several options for defining and printing good facets. With the 'Qg' option, Qhull will only build those facets that it needs to determine the good facets in the output. Outside points that are not above good facets are ignored. This may speed up Qhull in 2-d and 3-d. It is useful for furthest-site Delaunay triangulations (qdelaunay Qu, invoke with 'qhull d Qbb Qu Qg'). It is not effective in higher dimensions because many facets see a given point and contain a given vertex. It may not work for all combinations of options.

See 'QGn', 'QVn', and 'Pdk' for defining good facets, and 'Pg' and 'PG' for printing good facets and their neighbors. If pre-merging ('C-n') is not used and there are coplanar facets, then 'Qg Pg' may produce a different result than 'Pg'.

Option Qg disables renaming vertices due to duplicate ridges. See ('Q14' merge-pinched-vertices).

»QGn - good facet if visible from point n, -n for not visible

With option 'QGn', a facet is good (see 'Qg' and 'Pg') if it is visible from point n. If n < 0, a facet is good if it is not visible from point n. Point n is not added to the hull (unless 'TCn' or 'TPn').

With rbox, use the 'Pn,m,r' option to define your point; it will be point 0 ('QG0').

»Qi - keep interior points with nearest facet

Normally Qhull ignores points that are clearly interior to the convex hull. With option 'Qi', Qhull treats interior points the same as coplanar points. Option 'Qi' does not retain coplanar points. You will probably want 'Qc' as well.

Option 'Qi' is automatically set for 'qdelaunay Qc' and 'qvoronoi Qc'. If you use 'qdelaunay Qi' or 'qvoronoi Qi', option 's' reports all nearly incident points while option 'Fs' reports the number of interior points (should always be zero).

With option 'Qi', output formats 'p', 'f','Gp', 'Fc', 'FN', and 'FP' include interior points.

»QJ or QJn - joggled input to avoid precision errors

Option 'QJ' or 'QJn' joggles each input coordinate by adding a random number in the range [-n,n]. If a precision error occurs, It tries again. If precision errors still occur, Qhull increases n ten-fold and tries again. The maximum value for increasing n is 0.01 times the maximum width of the input. Option 'QJ' selects a default value for n. The header file user_r.h defines these parameters and a maximum number of retries. See Merged facets or joggled input.

On repeated joggles, Qhull errors (QH6010) if the joggle is greater than 0.1 or one quarter of the maximum coordinate width.

Users of joggled input should consider converting to triangulated output ('Qt'). Triangulated output is approximately 1000 times more accurate than joggled input.

Option 'QJ' also sets 'Qbb' for Delaunay triangulations and Voronoi diagrams. It does not set 'Qbb' if 'Qbk:n' or 'QBk:n' are set.

If 'QJn' is set, Qhull does not merge facets unless requested to. All facets are simplicial (triangular in 2-d). This may be important for your application. You may also use triangulated output ('Qt') or Option 'Ft'.

Qhull adjusts the outer and inner planes for 'QJn' ('Fs'). They are increased by sqrt(d)*n to account for the maximum distance between a joggled point and the corresponding input point.

Coplanar points ('Qc', option '_near-inside') require an additional sqrt(d)*n since vertices and coplanar points may be joggled in opposite directions.

For Delaunay triangulations (qdelaunay), joggle happens before lifting the input sites to a paraboloid. Instead of 'QJ', you may use triangulated output ('Qt')

This option is deprecated for Voronoi diagrams (qvoronoi). It triangulates cospherical points, leading to duplicated Voronoi vertices.

By default, 'QJn' uses a fixed random number seed. To use time as the random number seed, select 'QR-1'. The summary ('s') will show the selected seed as 'QR-n'.

With 'QJn', Qhull does not error on degenerate hyperplane computations. Except for Delaunay and Voronoi computations, Qhull does not error on coplanar points.

Use option 'FO' to display the selected options. Option 'FO' displays the joggle and the joggle seed. If Qhull restarts, it will redisplay the options.

Use option 'TRn' to estimate the probability that Qhull will fail for a given 'QJn'.

If your application incrementally adds points with qh_addpoint, facet merging for precision problems is disabled by default. You can reduce the probability of failure by joggling the point's coordinates before calling qh_addpoint. See qh_joggleinput for sample code.

»Qm - only process points that increase the maximum outer plane

Qhull reports the maximum outer plane in its summary ('s'). With option 'Qm', Qhull does not process points that are below the current, maximum outer plane. This is equivalent to always adjusting 'Wn ' to the maximum distance of a coplanar point to a facet. It is ignored for points above the upper convex hull of a Delaunay triangulation. Option 'Qm' is no longer important for merging.

»Qr - process random outside points instead of furthest ones

Normally, Qhull processes the furthest point of a facet's outside points. Option 'Qr' instead selects a random outside point for processing. This makes Qhull equivalent to the randomized incremental algorithms.

The original randomization algorithm by Clarkson and Shor ['89] used a conflict list which is equivalent to Qhull's outside set. Later randomized algorithms retained the previously constructed facets.

To compare Qhull to the randomized algorithms with option 'Qr', compare "hyperplanes constructed" and "distance tests". Qhull does not report CPU time because the randomization is inefficient.

»QRn - random rotation

Option 'QRn' randomly rotates the input. For Delaunay triangulations (qdelaunay or qvoronoi), it rotates the lifted points about the last axis.

If n=0, use time as the random number seed. If n>0, use n as the random number seed. If n=-1, don't rotate but use time as the random number seed. If n<-1, don't rotate but use n as the random number seed.

If set, the summary option ('s') displays the corresponding 'QRn' option after "Statistics for: ..."

»Qs - search all points for the initial simplex

Qhull constructs an initial simplex from d+1 points. It selects points with the maximum and minimum coordinates and non-zero determinants. If this fails, it searches all other points. In 8-d and higher, Qhull selects points with the minimum x or maximum coordinate (see qh_initialvertices in poly2.c ). It rejects points with nearly zero determinants. This should work for almost all input sets.

If Qhull can not construct an initial simplex, it reports a descriptive message. Usually, the point set is degenerate and one or more dimensions should be removed ('Qbk:0Bk:0'). If not, use option 'Qs'. It performs an exhaustive search for the best initial simplex. This is expensive is high dimensions.

»Qt - triangulated output

By default, qhull merges facets to handle precision errors. This produces non-simplicial facets (e.g., the convex hull of a cube has 6 square facets). Each facet is non-simplicial because it has four vertices.

Use option 'Qt' to triangulate all non-simplicial facets before generating results. Alternatively, use joggled input ('QJ') to prevent non-simplical facets. Unless 'Pp' is set, qhull produces a warning if 'QJ' and 'Qt' are used together.

For Delaunay triangulations (qdelaunay), triangulation occurs after lifting the input sites to a paraboloid and computing the convex hull.

Option 'Qt' is deprecated for Voronoi diagrams (qvoronoi). It triangulates cospherical points, leading to duplicated Voronoi vertices.

Option 'Qt' may produce degenerate facets with zero area.

Facet area and hull volumes may differ with and without 'Qt'. The triangulations are different and different triangles may be ignored due to precision errors.

With sufficient merging, the ridges of a non-simplicial facet may share more than two neighboring facets. If so, their triangulation ('Qt') will fail since two facets have the same vertex set.

»Qu - compute upper hull for furthest-site Delaunay triangulation

When computing a Delaunay triangulation (qdelaunay or qvoronoi), Qhull computes both the the convex hull of points on a paraboloid. It normally prints facets of the lower hull. These correspond to the Delaunay triangulation. With option 'Qu', Qhull prints facets of the upper hull. These correspond to the furthest-site Delaunay triangulation and the furthest-site Voronoi diagram.

Option 'qhull d Qbb Qu Qg' may improve the speed of option 'Qu'. If you use the Qhull library, a faster method is 1) use Qhull to compute the convex hull of the input sites; 2) take the extreme points (vertices) of the convex hull; 3) add one interior point (e.g., 'FV', the average of d extreme points); 4) run 'qhull d Qbb Qu' or 'qhull v Qbb Qu' on these points.

»Qv - test vertex neighbors for convexity

Normally, Qhull tests all facet neighbors for convexity. Non-neighboring facets which share a vertex may not satisfy the convexity constraint. This occurs when a facet undercuts the centrum of another facet. They should still be convex. Option 'Qv' extends Qhull's convexity testing to all neighboring facets of each vertex. The extra testing occurs after the hull is constructed..

»QVn - good facet if it includes point n, -n if not

With option 'QVn', a facet is good ('Qg', 'Pg') if one of its vertices is point n. If n<0, a good facet does not include point n.

If options 'PG' and 'Qg' are not set, option 'Pg' (print only good) is automatically set.

Option 'QVn' behaves oddly with options 'Fx' and 'qvoronoi Fv'.

If used with option 'Qg' (only process good facets), point n is either in the initial simplex or it is the first point added to the hull. Options 'QVn Qg' require either 'QJ' or 'Q0' (no merging).

»Qw - allow warnings about Qhull options

Option 'Qw' allows warning about unknown, malformed, or incompatible Qhull options. If 'Qw' is not specified, option warnings produce a 'Qhull option error' and return exit status qh_ERRinput (1).

»Qx - exact pre-merges (allows coplanar facets)

Option 'Qx' performs exact merges while building the hull. Options 'Qx' and 'C-0' are set by default in 5-d and higher. To disable this default, set option 'C-0' or another pre-merge option. Use option 'Q0' to disable all merging, including 'Qx' and 'C-0'.

The "exact" pre-merges are merging a point into a coplanar horizon facet (defined by 'Vn', 'Un', and 'C-n'), merging concave facets, merging duplicate ridges, and merging flipped facets. Coplanar merges and angle coplanar merges ('A-n') are not performed. Superfluous vertices are allowed. Concavity testing is delayed until a merge occurs.

After the hull is built, all coplanar merges are performed (defined by 'C-n' and 'A-n'), then post-merges are performed (defined by 'Cn' and 'An'). Superfluous vertices are removed.

If facet progress is logged ('TFn'), Qhull reports each phase and prints intermediate summaries and statistics ('Ts').

Without 'Qx' in 5-d and higher, options 'C-n' and 'A-n' may merge too many facets. Facets become increasingly wide.

Option 'Qx' may report a wide facet. With 'Qx', coplanar facets are not merged. This can produce a "dent" in an intermediate hull. If a point is partitioned into a dent and it is below the surrounding facets but above other facets, one or more wide facets will occur. In practice, this is unlikely. To observe this effect, run Qhull with option 'Q6' which doesn't pre-merge concave facets. A concave facet makes a large dent in the intermediate hull.

Option 'Qx' may set an outer plane below one of the input points. A coplanar point may be assigned to the wrong facet because of a "dent" in an intermediate hull. After constructing the hull, Qhull double checks all outer planes with qh_check_maxout in poly2.c . If a coplanar point is assigned to the wrong facet, qh_check_maxout may reach a local maximum instead of locating all coplanar facets. This appears to be unlikely.

»Qz - add a point-at-infinity for Delaunay triangulations

Option 'Qz' adds a point above the paraboloid of lifted sites for a Delaunay triangulation. It allows the Delaunay triangulation of cospherical sites. It reduces precision errors for nearly cospherical sites.

»Q0 - no merging with C-0 and Qx

Turn off default merge options 'C-0' and 'Qx'.

With 'Q0' and without other pre-merge options, Qhull ignores precision issues while constructing the convex hull. This may lead to precision errors. If so, a descriptive warning is generated. See Precision issues.

»Q1 - merge by mergetype/angle instead of mergetype/distance

Qhull merges coplanar facets first, then concave and flipped facets. Within a merge-type, it merges coplanar facets by distance first.

With option 'Q1', Qhull merges coplanar facets by angle instead of by distance.

»Q2 - merge all non-convex at once instead of independent sets

With 'Q2', Qhull merges all facets at once instead of performing merges in independent sets. This may make the facets wider.

»Q3 - do not merge redundant vertices

With 'Q3', Qhull does not remove redundant vertices. In 6-d and higher, Qhull never removes redundant vertices (since vertices are highly interconnected). Option 'Q3' may be faster, but it may result in wider facets. Its effect is easiest to see in 3-d and 4-d.

»Q4 - avoid merging old facets into new facets

With 'Q4', Qhull avoids merges of an old facet into a new facet. This sometimes improves facet width and sometimes makes it worse. See qh_merge_nonconvex. It is not supported for qh_merge_twisted.

»Q5 - do not correct outer planes at end of qhull

When merging facets or approximating a hull, Qhull tests coplanar points and outer planes after constructing the hull. It does this by performing a directed search (qh_findbest in geom.c). It includes points that are just inside the hull.

With options 'Q5' or 'Po', Qhull does not test outer planes. The maximum outer plane is used instead. Coplanar points ('Qc') are defined by 'Un'. An input point may be outside of the maximum outer plane (this appears to be unlikely). An interior point may be above 'Un' from a hyperplane.

Option 'Q5' may be used if outer planes are not needed. Outer planes are needed for options 's', 'G', 'Go', 'Fs', 'Fo', 'FF', and 'f'.

»Q6 - do not pre-merge concave or coplanar facets

With 'Q6', Qhull does not pre-merge concave or coplanar facets. This demonstrates the effect of "dents" when using 'Qx'.

»Q7 - depth-first processing instead of breadth-first

With 'Q7', Qhull processes facets in depth-first order instead of breadth-first order. This may increase the locality of reference in low dimensions. If so, Qhull may be able to use virtual memory effectively.

In 5-d and higher, many facets are visible from each unprocessed point. So each iteration may access a large proportion of allocated memory. This makes virtual memory ineffectual. Once real memory is used up, Qhull will spend most of its time waiting for I/O.

Under 'Q7', Qhull runs slower and the facets may be wider.

»Q8 - ignore near-interior points

With 'Q8' and merging, Qhull does not process interior points that are near to a facet (as defined by qh_RATIOnearInside in user.h). This avoids partitioning steps. It may miss a coplanar point when adjusting outer hulls in qh_check_maxout(). The best value for qh_RATIOnearInside is not known. Options 'Q8 Qc' may be sufficient.

»Q9 - process furthest of furthest points

With 'Q9', Qhull processes the furthest point of all outside sets. This may reduce precision problems. The furthest point of all outside sets is not necessarily the furthest point from the convex hull.

»Q10 - no special processing for narrow distributions

With 'Q10', Qhull does not special-case narrow distributions. See Limitations of merged facets for more information.

»Q11 - copy normals and recompute centrums for tricoplanar facets

Option 'Qt' triangulates non-simplicial facets into "tricoplanar" facets. Normally tricoplanar facets share the same normal, centrum, and Voronoi vertex. They can not be merged or replaced. With option 'Q11', Qhull duplicates the normal and Voronoi vertex. It recomputes the centrum.

Use 'Q11' if you use the Qhull library to add points incrementally and call qh_triangulate() after each point. Otherwise, Qhull will report an error when it tries to merge and replace a tricoplanar facet.

With sufficient merging and new points, option 'Q11' may lead to precision problems such as duplicate ridges and concave facets. For example, if qh_triangulate() is added to qh_addpoint(), RBOX 1000 s W1e-12 t1001813667 P0 | QHULL d Q11 Tv, reports an error due to a duplicate ridge.

»Q12 - allow wide facets and wide dupridge

Option 'Q12' (qh.ALLOWwide) disables error exits due to wide facets and wide dupridge. With 'Q12', Qhull may produce arbitrarily wide facets. A facet is 'wide' if there is a wide gap between its outer plane (f.maxoutside above all points) and its inner plane (below its vertices). A wide facet is typically due to multiple topological and geometric problems that Qhull cannot resolve. As Qhull merges facets, they become increasingly wide, making further problems more likely.

A 'dupridge' is a ridge with more than two neighboring facets. A dupridge is a loop in the facet topology. A convex hull should never have dupridges, but with imprecise arithmetic, they may occur. Dupridges may occur in 3-D and higher. They are more likely for nearly adjacent points in 4-D and higher.

Qhull handles dupridges by merging all but one pair of facets (qh_matchdupridge in poly2_r.c) or by dropping one of its vertices as a coplanar point (qh_getpinchedmerges in merge_r.c). If vertices are too far apart and a merge would produce an wide facet, qh_check_dupridge reports an error. The corresponding error exit is disabled by 'Q12'.

To demonstrate the problem, use rbox option 'Cn,r,m' to generate nearly adjacent points. For Delaunay triangulations, a bounding box may alleviate this error (e.g., rbox 500 C1,1E-13 c G1 | qhull d). This avoids the ill-defined edge between upper and lower convex hulls. For more information, see "Nearly adjacent vertices within 1e-13" in Limitations of merged facets.

Errors disabled by 'Q12' return an error status of qh_ERRwide (8). Wide facets are defined by constants in user_r.h (qh_WIDE... and qh_RATIO...).

»Q14 - merge pinched vertices due to a dupridge

A ridge in Qhull is the d-1 simplex between two neighboring facets. For example in 3-d, a ridge is the edge shared by two neighboring polygons. With non-simplicial facets, Qhull may create a "dupridge", a ridge with four or more neighboring facets. In effect, the surface of the convex hull forms a loop that crosses itself at the dupridge. Qhull resolves a dupridge by merging a pair of facets. With experimental option, 'Q14' it may resolve a dupridge by merging a pair of vertices.

In 3-d and higher, nearly adjacent vertices may lead to dupridges (see "Nearly adjacent vertices within 1e-13" in Imprecision in Qhull). With option 'Q14', Qhull merges nearly adjacent vertices when they create a dupridge.

»Q15 - check for duplicate ridges with the same vertices

Option 'Q15' (qh.CHECKduplicates) checks for duplicate ridges after each merge (qh_maybe_duplicateridges, qh_checkfacet). Duplicate ridges have the same vertices. It is a topological error for convex hulls. Qhull resolves a duplicate ridge by merging vertices and partitioning the deleted vertex as a coplanar point (qh_renamevertex).

Option 'Q15' does not prevent duplicate ridges for non-neighboring facets, nor does it prevent other topological errors such as inconsistent facet orientation. Resolving a duplicate ridge may itself lead to topological errors and wide facets.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qhalf.html0000644000176200001440000007167614664417655020232 0ustar liggesusers qhalf -- halfspace intersection about a point

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


[halfspace]qhalf -- halfspace intersection about a point

The intersection of a set of halfspaces is a polytope. The polytope may be unbounded. See Preparata & Shamos ['85] for a discussion. In low dimensions, halfspace intersection may be used for linear programming.

Example: rbox c | qconvex FV n | qhalf Fp

Print the intersection of the facets of a cube. rbox c generates the vertices of a cube. qconvex FV returns a feasible point for halfspace intersection. This feasible or interior point, qconvex FV, is the average of the cube's vertices (i.e., the origin). qconvex n returns the halfspaces that define the cube. qhalf Fp computes the intersection of the halfspaces about the feasible point. The intersection is the vertices of the original cube.

Example: rbox c | qconvex FQ n | qhalf H0.1,0.1,0.1

Compute the intersection of the facets of a cube and print a summary ('s'). Option 'FQ' prints the qconvex command as an input comment for the summary. 'qhalf Hn,n,n' specifies the feasible point as [0.1, 0.1, 0.1]. 'qhalf H0' would specify the feasible point as the origin.

Example: rbox c d G0.55 | qconvex FQ FV n | qhalf Fp

Print the intersection of the facets of a cube and a diamond. There are 24 facets and 14 intersection points. Four facets define each diamond vertex. Six facets define each cube vertex.

Example: rbox c d G0.55 | qconvex FQ FV n | qhalf Fp Qt

Same as above except triangulate before computing the intersection points. Three facets define each intersection point. There are two duplicates of the diamond and four duplicates of the cube.

Example: rbox 10 s t10 | qconvex FQ FV n | qhalf Fp Fn

Print the intersection of the facets of the convex hull of 10 cospherical points. Include the intersection points and the neighboring intersections. As in the previous examples, the intersection points are nearly the same as the original input points.

In Qhull, a halfspace is defined by the points on or below a hyperplane. The distance of each point to the hyperplane is less than or equal to zero.

Qhull computes a halfspace intersection by the geometric duality between points and halfspaces. See halfspace examples, qhalf notes, and option 'p' of qhalf outputs.

Qhalf's outputs are the intersection points (Fp) and the neighboring intersection points (Fn). For random inputs, halfspace intersections are usually defined by more than d halfspaces. See the sphere example.

The identity pipeline for Qhull starts with points, produces the halfspaces for their convex hull, and intersects these halfspaces, returning the original points. For example, 'rbox c' is the unit cube.

	rbox c | qconvex FV n | qhalf Fp
	3
	8
	  -0.5    0.5    0.5
	   0.5    0.5    0.5
	  -0.5    0.5   -0.5
	   0.5    0.5   -0.5
	   0.5   -0.5    0.5
	  -0.5   -0.5    0.5
	   0.5   -0.5   -0.5
	  -0.5   -0.5   -0.5

You can try triangulated output ('Qt') and joggled input ('QJ'). It demonstrates that triangulated output is more accurate than joggled input.

If you use 'Qt' (triangulated output), all halfspace intersections are simplicial (e.g., three halfspaces per intersection in 3-d). In 3-d, if more than three halfspaces intersect at the same point, triangulated output will produce duplicate intersections, one for each additional halfspace. See the third example, or add 'Qt' to the sphere example.

If you use 'QJ' (joggled input), all halfspace intersections are simplicial. This may lead to nearly identical intersections. For example, either replace 'Qt' with 'QJ' above, or add 'QJ' to the sphere example. See Merged facets or joggled input.

The 'qhalf' program is equivalent to 'qhull H'. It disables the following Qhull options: d n v Qbb QbB Qf Qg Qm Qr Qv Qx Qz TR E V Fa FA FC FD FS Ft FV Gt Q0,etc.

Copyright © 1995-2020 C.B. Barber


»qhalf synopsis

qhalf -- halfspace intersection about a point.
    input (stdin): [dimension, 1, interior point]
                       dimension+1, number of halfspaces, coefficients+offset
    comments start with a non-numeric character

options:
    Hn,n - specify coordinates of interior point
    Qt   - triangulated output
    QJ   - joggled input instead of merged facets
    Tv   - verify result: structure, convexity, and redundancy
    .    - concise list of all options
    -    - one-line description of each option
    -?   - this message
    -V   - version

output options (subset):
    s    - summary of results (default)
    Fp   - intersection coordinates
    Fv   - non-redundant halfspaces incident to each intersection
    Fx   - non-redundant halfspaces
    G    - Geomview output (dual convex hull)
    m    - Mathematica output (dual convex hull)
    o    - OFF file format (dual convex hull)
    QVn  - print intersections for halfspace n, -n if not
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes

examples:
    rbox d | qconvex FQ n | qhalf s H0,0,0 Fp
    rbox c | qconvex FQ FV n | qhalf s i
    rbox c | qconvex FQ FV n | qhalf s o

»qhalf input

The input data on stdin consists of:

  • [optional] feasible point
    • dimension
    • 1
    • coordinates of feasible point
  • dimension + 1
  • number of halfspaces
  • halfspace coefficients followed by offset

Use I/O redirection (e.g., qhalf < data.txt), a pipe (e.g., rbox c | qconvex FV n | qhalf), or the 'TI' option (e.g., qhalf TI data.txt).

Qhull needs a feasible point to compute the halfspace intersection. A feasible point is clearly inside all of the halfspaces. A point is inside a halfspace if its distance to the corresponding hyperplane is negative.

The feasible point may be listed at the beginning of the input (as shown above). If not, option 'Hn,n' defines the feasible point as [n,n,0,...] where 0 is the default coordinate (e.g., 'H0' is the origin). Use linear programming if you do not know the feasible point (see halfspace notes),

The input to qhalf is a set of halfspaces that are defined by their hyperplanes. Each halfspace is defined by d coefficients followed by a signed offset. This defines a linear inequality. The coefficients define a vector that is normal to the halfspace. The vector may have any length. If it has length one, the offset is the distance from the origin to the halfspace's boundary. Points in the halfspace have a negative distance to the hyperplane. The distance from the feasible point to each halfspace is likewise negative.

The halfspace format is the same as Qhull's output options 'n', 'Fo', and 'Fi'. Use option 'Fd' to use cdd format for the halfspaces.

For example, here is the input for computing the intersection of halfplanes that form a cube.

rbox c | qconvex FQ FV n TO data

RBOX c | QCONVEX FQ FV n
3 1
     0      0      0
4
6
     0      0     -1   -0.5
     0     -1      0   -0.5
     1      0      0   -0.5
    -1      0      0   -0.5
     0      1      0   -0.5
     0      0      1   -0.5

qhalf s Fp < data


Halfspace intersection by the convex hull of 6 points in 3-d:

  Number of halfspaces: 6
  Number of non-redundant halfspaces: 6
  Number of intersection points: 8

Statistics for: RBOX c | QCONVEX FQ FV n | QHALF s Fp

  Number of points processed: 6
  Number of hyperplanes created: 11
  Number of distance tests for qhull: 11
  Number of merged facets: 1
  Number of distance tests for merging: 45
  CPU seconds to compute hull (after input):  0

3
3
8
  -0.5    0.5    0.5
   0.5    0.5    0.5
  -0.5    0.5   -0.5
   0.5    0.5   -0.5
   0.5   -0.5    0.5
  -0.5   -0.5    0.5
  -0.5   -0.5   -0.5
   0.5   -0.5   -0.5

»qhalf outputs

The following options control the output for halfspace intersection.

 
Intersections
FN
list intersection points for each halfspace. The first line is the number of halfspaces. Each remaining line starts with the number of intersection points. Redundant halfspaces have 0 intersection points. For the cube example, each halfspace has four intersection points.
Fn
list neighboring intersections for each intersection point. The first line is the number of intersection points. Each following line starts with the number of neighboring intersections. For the cube example, each intersection point has three neighboring intersections.

In 3-d, a non-simplicial intersection has more than three neighboring intersections. For random data (e.g., the sphere example), non-simplicial intersections are the norm. Option 'Qt' produces three neighboring intersections per intersection by duplicating the intersection points. Option QJ' produces three neighboring intersections per intersection by joggling the hyperplanes and hence their intersections.

Fp
print intersection coordinates. The first line is the dimension and the second line is the number of intersection points. The following lines are the coordinates of each intersection point. The "infinity" point, [-10.101,-10.101,...] (qh_INFINITE), indicates an unbounded intersection.
FI
list intersection IDs. The first line is the number of intersections. The IDs follow, one per line.
 
 
Halfspaces
Fx
list non-redundant halfspaces. The first line is the number of non-redundant halfspaces. The other lines list one halfspace per line. A halfspace is non-redundant if it defines a facet of the intersection. Redundant halfspaces are ignored. For the cube example, none of the halfspaces are redundant.
Fv
list non-redundant halfspaces incident to each intersection point. The first line is the number of non-redundant halfspaces. Each remaining line starts with the number of non-redundant halfspaces incident to that point. For the cube example, each intersection point is incident to three halfspaces.
i
list non-redundant halfspaces incident to each intersection point. The first line is the number of intersection points. Each remaining line lists the incident, non-redundant halfspaces for that intersection point. For the cube example, each intersection point is incident to three halfspaces.
Fc
list coplanar halfspaces for each intersection point. The first line is the number of intersection points. Each remaining line starts with the number of coplanar halfspaces. A coplanar halfspace is listed for one intersection point even though it is coplanar to multiple intersection points.
Qi Fc
list redundant halfspaces for each intersection point. The first line is the number of intersection points. Each remaining line starts with the number of redundant halfspaces. Use options 'Qc Qi Fc' to list coplanar and redundant halfspaces.
 
 
General
s
print summary for the halfspace intersection. Use 'Fs' if you need numeric data.
o
print vertices and facets of the dual convex hull. The first line is the dimension. The second line is the number of vertices, facets, and ridges. The vertex coordinates are next, followed by the facets, one per line.
p
print vertex coordinates of the dual convex hull. Each vertex corresponds to a non-redundant halfspace. Its coordinates are the negative of the hyperplane's coefficients divided by the offset plus the inner product of the coefficients and the feasible point (-c/(b+a.p). Options 'p Qc' includes coplanar halfspaces. Options 'p Qi' includes redundant halfspaces.
m
Mathematica output for the dual convex hull in 2-d or 3-d.
FM
Maple output for the dual convex hull in 2-d or 3-d.
G
Geomview output for the dual convex hull in 2-d, 3-d, or 4-d.

»qhalf controls

These options provide additional control:

Qt
triangulated output. If a 3-d intersection is defined by more than three hyperplanes, Qhull produces duplicate intersections -- one for each extra hyperplane.
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
QJ
joggle the input instead of merging facets. In 3-d, this guarantees that each intersection is defined by three hyperplanes.
f
facet dump. Print the data structure for each intersection (i.e., facet)
TFn
report summary after constructing n intersections
QVn
select intersection points for halfspace n (marked 'good')
QGn
select intersection points that are visible to halfspace n (marked 'good'). Use -n for the remainder.
Qbk:0Bk:0
remove the k-th coordinate from the input. This computes the halfspace intersection in one lower dimension.
Tv
verify result
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
Qs
search all points for the initial simplex. If Qhull can not construct an initial simplex, it reports a descriptive message. Usually, the point set is degenerate and one or more dimensions should be removed ('Qbk:0Bk:0'). If not, use option 'Qs'. It performs an exhaustive search for the best initial simplex. This is expensive is high dimensions.

»qhalf graphics

To view the results with Geomview, compute the convex hull of the intersection points ('qhull FQ H0 Fp | qhull G'). See Halfspace examples.

»qhalf notes

See halfspace intersection for precision issues related to qhalf.

If you do not know a feasible point for the halfspaces, use linear programming to find one. Assume, n halfspaces defined by: aj*x1+bj*x2+cj*x3+dj<=0, j=1..n. Perform the following linear program:

max(x5) aj*x1+bj*x2+cj*x3+dj*x4+x5<=0, j=1..n

Then, if [x1,x2,x3,x4,x5] is an optimal solution with x4>0 and x5>0 we get:

aj*(x1/x4)+bj*(x2/x4)+cj*(x3/x4)+dj<=(-x5/x4) j=1..n and (-x5/x4)<0,

and conclude that the point [x1/x4,x2/x4,x3/x4] is inside all the halfspaces. Since x5 is optimal, this feasible point is "clearly inside" the halfspaces (good for precision errors).

After finding a feasible point, the rest of the intersection algorithm is from Preparata & Shamos ['85, p. 316, "A simple case ..."]. Translate the halfspaces so that the feasible point is the origin. Calculate the dual polytope. The dual polytope is the convex hull of the vertices dual to the original faces in regard to the unit sphere (i.e., halfspaces at distance d from the origin are dual to vertices at distance 1/d). Then calculate the resulting polytope, which is the dual of the dual polytope, and translate the origin back to the feasible point [S. Spitz, S. Teller, D. Strawn].

»qhalf conventions

The following terminology is used for halfspace intersection in Qhull. This is the hardest structure to understand. The underlying structure is a convex hull with one vertex per non-redundant halfspace. See convex hull conventions and Qhull's data structures.

  • feasible or interior point - a point in the intersection of the halfspaces. Qhull needs a feasible point to compute the intersection. See halfspace input.
  • halfspace - d coordinates for the normal and a signed offset. The distance to the feasible point is negative.
  • non-redundant halfspace - a halfspace that defines an output facet
  • vertex - a dual vertex in the convex hull corresponding to a non-redundant halfspace
  • coplanar point - the dual point corresponding to a similar halfspace
  • interior point - the dual point corresponding to a redundant halfspace
  • intersection point- the intersection of d or more non-redundant halfspaces
  • facet - a dual facet in the convex hull corresponding to an intersection point
  • non-simplicial facet - more than d halfspaces intersect at a point
  • good facet - an intersection point that satisfies restriction 'QVn', etc.

»qhalf options

qhalf -- compute the intersection of halfspaces about a point
    http://www.qhull.org

input (stdin):
    optional interior point: dimension, 1, coordinates
    first lines: dimension+1 and number of halfspaces
    other lines: halfspace coefficients followed by offset
    comments:    start with a non-numeric character

options:
    Hn,n - specify coordinates of interior point
    Qc   - keep coplanar halfspaces
    Qi   - keep other redundant halfspaces
    QJ   - joggled input instead of merged facets
    Qt   - triangulated output

Qhull control options:
    Qa   - allow input with fewer or more points than coordinates
    Qbk:0Bk:0 - remove k-th coordinate from input
    QJn  - randomly joggle input in range [-n,n]
    QRn  - random rotation (n=seed, n=0 time, n=-1 time/no rotate)
    Qs   - search all halfspaces for the initial simplex

Qhull extra options:
    QGn  - print intersection if visible to halfspace n, -n for not
    QVn  - print intersections for halfspace n, -n if not
    Qw   - allow option warnings
    Q12  - allow wide facets and wide dupridge
    Q14  - merge pinched vertices that create a dupridge

T options:
    TFn  - report summary when n or more facets created
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes
    Ts   - statistics
    Tv   - verify result: structure, convexity, and in-circle test
    Tz   - send all output to stdout

Trace options:
    T4   - trace at level n, 4=all, 5=mem/gauss, -1= events
    Ta   - annotate output with message codes
    TAn  - stop qhull after adding n vertices
     TCn - stop qhull after building cone for point n
     TVn - stop qhull after adding point n, -n for before
    Tc   - check frequently during execution
    Tf   - flush each qh_fprintf for debugging segfaults
    TPn - turn on tracing when point n added to hull
     TMn  - turn on tracing at merge n
     TWn - trace merge facets when width > n

Precision options:
    Cn   - radius of centrum (roundoff added).  Merge facets if non-convex
     An  - cosine of maximum angle.  Merge facets if cosine > n or non-convex
           C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge
    Rn   - randomly perturb computations by a factor of [1-n,1+n]
    Un   - max distance below plane for a new, coplanar halfspace
    Wn   - min facet width for outside halfspace (before roundoff)

Output formats (may be combined; if none, produces a summary to stdout):
    f    - facet dump
    G    - Geomview output (dual convex hull)
    i    - non-redundant halfspaces incident to each intersection
    m    - Mathematica output (dual convex hull)
    o    - OFF format (dual convex hull: dimension, points, and facets)
    p    - vertex coordinates of dual convex hull (coplanars if 'Qc' or 'Qi')
    s    - summary (stderr)

More formats:
    Fc   - count plus redundant halfspaces for each intersection
         -   Qc (default) for coplanar and Qi for other redundant
    Fd   - use cdd format for input (homogeneous with offset first)
    FF   - facet dump without ridges
    FI   - ID of each intersection
    Fm   - merge count for each intersection (511 max)
    FM   - Maple output (dual 2-d or 3-d convex hull)
    Fn   - count plus neighboring intersections for each intersection
    FN   - count plus intersections for each halfspace
    FO   - options and precision constants
    Fp   - dim, count, and intersection coordinates
    FP   - nearest halfspace and distance for each redundant halfspace
    FQ   - command used for qhalf
    Fs   - summary: #int (8), dim, #halfspaces, #non-redundant, #intersections
                      output: #non-redundant, #intersections, #coplanar
                                  halfspaces, #non-simplicial intersections
                    #real (2), max outer plane, min vertex
    Fv   - count plus non-redundant halfspaces for each intersection
    Fx   - non-redundant halfspaces

Geomview output (2-d, 3-d and 4-d; dual convex hull)
    Ga   - all points (i.e., transformed halfspaces) as dots
     Gp  -  coplanar points and vertices as radii
     Gv  -  vertices (i.e., non-redundant halfspaces) as spheres
    Gc   - centrums
    GDn  - drop dimension n in 3-d and 4-d output
    Gh   - hyperplane intersections
    Gi   - inner planes (i.e., halfspace intersections) only
     Gn  -  no planes
     Go  -  outer planes only
    Gr   - ridges

Print options:
    PAn  - keep n largest facets (i.e., intersections) by area
    Pdk:n- drop facet if normal[k] <= n (default 0.0)
    PDk:n- drop facet if normal[k] >= n
    PFn  - keep facets whose area is at least n
    Pg   - print good facets (needs 'QGn' or 'QVn')
    PG   - print neighbors of good facets
    PMn  - keep n facets with most merges
    Po   - force output.  If error, output neighborhood of facet
    Pp   - do not report precision problems

    .    - list of all options
    -    - one line descriptions of all options
    -?   - help with examples
    -V   - version

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qh-optc.html0000644000176200001440000002771414664417655020504 0ustar liggesusers Qhull precision options

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull precision options

This section lists the precision options for Qhull. These options are indicated by an upper-case letter followed by a number.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Precision options

Most users will not need to set these options. They are best used for approximating a convex hull. They may also be used for testing Qhull's handling of precision errors.

Qhull uses the default option 'C-0' for 2-d, 3-d and 4-d, and 'Qx' for 5-d and higher. These options use facet merging to handle precision errors. You may also use joggled input 'QJ' to avoid precision problems. For more information see Imprecision in Qhull.

 
General
Cn
centrum radius for post-merging
C-n
centrum radius for pre-merging
An
cosine of maximum angle for post-merging
A-n
cosine of maximum angle for pre-merging
Qx
exact pre-merges (allows coplanar facets)
C-0
handle all precision errors
Wn
min distance above plane for outside points
 
Experimental
Un
max distance below plane for a new, coplanar point
En
max roundoff error for distance computation
Vn
min distance above plane for a visible facet
Rn
randomly perturb computations by a factor of [1-n,1+n]

»A-n - cosine of maximum angle for pre-merging.

Pre-merging occurs while Qhull constructs the hull. It is indicated by 'C-n', 'A-n', or 'Qx'.

If the angle between a pair of facet normals is greater than n, Qhull merges one of the facets into a neighbor. It selects the facet that is closest to a neighboring facet.

For example, option 'A-0.99' merges facets during the construction of the hull. If the cosine of the angle between facets is greater than 0.99, one or the other facet is merged. Qhull accounts for the maximum roundoff error.

If 'A-n' is set without 'C-n', then 'C-0' is automatically set.

In 5-d and higher, you should set 'Qx' along with 'A-n'. It skips merges of coplanar facets until after the hull is constructed and before 'An' and 'Cn' are checked.

»An - cosine of maximum angle for post-merging.

Post merging occurs after the hull is constructed. For example, option 'A0.99' merges a facet if the cosine of the angle between facets is greater than 0.99. Qhull accounts for the maximum roundoff error.

If 'An' is set without 'Cn', then 'C0' is automatically set.

»C-0 - handle all precision errors

Qhull handles precision errors by merging facets. The default option 'C-0' handles all precision errors in 2-d, 3-d, and 4-d. It may be used in higher dimensions, but sometimes the facet width grows rapidly. In 5-d and higher, the default option is 'Qx'. Use 'QJ' to joggle the input instead of merging facets. Use 'Q0' to turn both options off.

Qhull optimizes 'C-0' ("_zero-centrum") by testing vertices instead of centrums for adjacent simplices. This may be slower in higher dimensions if merges decrease the number of processed points. The optimization may be turned off by setting a small value such as 'C-1e-30'. See How Qhull handles imprecision.

»C-n - centrum radius for pre-merging

Pre-merging occurs while Qhull constructs the hull. It is indicated by 'C-n', 'A-n', or 'Qx'.

The centrum of a facet is a point on the facet for testing facet convexity. It is the average of the vertices projected to the facet's hyperplane. Two adjacent facets are convex if each centrum is clearly below the other facet.

If adjacent facets are non-convex, one of the facets is merged into a neighboring facet. Qhull merges the facet that is closest to a neighboring facet.

For option 'C-n', n is the centrum radius. For example, 'C-0.001' merges facets whenever the centrum is less than 0.001 from a neighboring hyperplane. Qhull accounts for roundoff error when testing the centrum.

In 5-d and higher, you should set 'Qx' along with 'C-n'. It skips merges of coplanar facets until after the hull is constructed and before 'An' and 'Cn' are checked.

»Cn - centrum radius for post-merging

Post-merging occurs after Qhull constructs the hull. It is indicated by 'Cn' or 'An'.

For option 'Cn', n is the centrum radius. For example, 'C0.001' merges facets when the centrum is less than 0.001 from a neighboring hyperplane. Qhull accounts for roundoff error when testing the centrum.

Both pre-merging and post-merging may be defined. If only post-merging is used ('Q0' with 'Cn'), Qhull may fail to produce a hull due to precision errors during the hull's construction.

»En - max roundoff error for distance computations

This allows the user to change the maximum roundoff error computed by Qhull. The value computed by Qhull may be overly pessimistic. If 'En' is set too small, then the output may not be convex. The statistic "max. distance of a new vertex to a facet" (from option 'Ts') is a reasonable upper bound for the actual roundoff error.

»Rn - randomly perturb computations

This option perturbs every distance, hyperplane, and angle computation by up to (+/- n * max_coord). It simulates the effect of roundoff errors. Unless 'En' is explicitly set, it is adjusted for 'Rn'. The command 'qhull Rn' will generate a convex hull despite the perturbations. See the Examples section for an example.

Options 'Rn C-n' have the effect of 'W2n' and 'C-2n'. To use time as the random number seed, use option 'QR-1'.

»Un - max distance for a new, coplanar point

This allows the user to set coplanarity. When pre-merging ('C-n', 'A-n' or 'Qx'), Qhull merges a new point into any coplanar facets. The default value for 'Un' is 'Vn'.

»Vn - min distance for a visible facet

This allows the user to set facet visibility. When adding a point to the convex hull, Qhull determines all facets that are visible from the point. A facet is visible if the distance from the point to the facet is greater than 'Vn'.

Without merging, the default value for 'Vn' is the roundoff error ('En'). With merging, the default value is the pre-merge centrum ('C-n') in 2-d or 3-d, or three times that in other dimensions. If the outside width is specified with option 'Wn', the maximum, default value for 'Vn' is 'Wn'.

Qhull warns if 'Vn' is greater than 'Wn' and furthest outside ('Qf') is not selected; this combination usually results in flipped facets (i.e., reversed normals).

»Wn - min distance above plane for outside points

Points are added to the convex hull only if they are clearly outside of a facet. A point is outside of a facet if its distance to the facet is greater than 'Wn'. Without pre-merging, the default value for 'Wn' is 'En'. If the user specifies pre-merging and does not set 'Wn', than 'Wn' is set to the maximum of 'C-n' and maxcoord*(1 - A-n).

This option is good for approximating a convex hull.

Options 'Qc' and 'Qi' use the minimum vertex to distinguish coplanar points from interior points.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qh-optf.html0000644000176200001440000010131314664417655020473 0ustar liggesusers Qhull format options (F)

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull format options (F)

This section lists the format options for Qhull. These options are indicated by 'F' followed by a letter. See Output, Print, and Geomview for other output options.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Additional input & output formats

These options allow for automatic processing of Qhull output. Options 'i', 'o', 'n', and 'p' may also be used.

FA
compute total area and volume for option 's'
Fd
use cdd format for input (offset first)
FD
use cdd format for normals (offset first)
FM
print Maple output (2-d and 3-d)
FO
print options to stderr or stdout
FQ
print command for qhull and input
Fs
print summary -- dim, #points, total vertices and facets, #vertices, #facets, max outer and inner plane
FS
print sizes -- total area and volume
FV
print average vertex (interior point for 'qhalf')
 
 
Facets, points, and vertices
Fa
print area for each facet
Fc
print coplanar points for each facet
FC
print centrum for each facet
FF
print facets w/o ridges
Fi
print inner planes for each facet
FI
print ID for each facet
Fm
print merge count for each facet (511 max)
Fn
print neighboring facets for each facet
FN
print neighboring facets for each point
Fo
print outer planes for each facet
FP
print nearest vertex for coplanar points
Ft
print triangulation with added points
Fv
print vertices for each facet
Fx
print extreme points (i.e., vertices) of convex hull
 
 
Delaunay, Voronoi, and halfspace
FC
print Voronoi vertex ("center") for each facet
Fi
print separating hyperplanes for inner, bounded Voronoi regions
Fo
print separating hyperplanes for outer, unbounded Voronoi regions
Fp
print points at halfspace intersections
Fv
print Voronoi diagram as ridges for each input pair
Fx
print extreme input sites of Delaunay triangulation or Voronoi diagram

»Fa - print area for each facet

The first line is the number of facets. The remaining lines are the area for each facet, one facet per line. See 'FA' and 'FS' for computing the total area and volume.

Use 'PAn' for printing the n largest facets. Use option 'PFn' for printing facets larger than n.

For Delaunay triangulations, the area is the area of each Delaunay triangle. For Voronoi vertices, the area is the area of the dual facet to each vertex.

Qhull uses the centrum and ridges to triangulate non-simplicial facets. The area for non-simplicial facets is the sum of the areas for each triangle. It is an approximation of the actual area. The ridge's vertices are projected to the facet's hyperplane. If a vertex is far below a facet (qh_WIDEcoplanar in user.h), the corresponding triangles are ignored.

For non-simplicial facets, vertices are often below the facet's hyperplane. If so, the approximation is less than the actual value and it may be significantly less or 0.0.

»FA - compute total area and volume for option 's'

With option 'FA', Qhull includes the total area and volume in the summary ('s'). Option 'FS' also includes the total area and volume. If facets are merged, the area and volume are approximations. Option 'FA' is automatically set for options 'Fa', 'PAn', and 'PFn'.

With 'qdelaunay s FA', Qhull computes the total area of the Delaunay triangulation. This equals the volume of the convex hull of the data points. With options 'qdelaunay Qu s FA', Qhull computes the total area of the furthest-site Delaunay triangulation. This equals of the total area of the Delaunay triangulation.

See 'Fa' for further details. Option 'FS' also computes the total area and volume.

»Fc - print coplanar points for each facet

The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of coplanar points followed by the point ids.

By default, option 'Fc' reports coplanar points ('Qc'). You may also use option 'Qi'. Options 'Qi Fc' prints interior points while 'Qci Fc' prints both coplanar and interior points.

Each coplanar point or interior point is assigned to the facet it is furthest above (resp., least below).

For halfspace intersection (qhalf), a "facet" is an intersection point and a "point" is a halfspace. Option 'Fc' lists the coplanar halfspaces for each intersection point. The first line is the number of intersection points. Each remaining line starts with the number of coplanar halfspaces. A coplanar halfspace is listed for one intersection point even though it is coplanar to multiple intersection points. Options "Fc Qi" list the redundant halfspaces for each intersection point.

Use 'Qc p' to print vertex and coplanar point coordinates. Use 'Fv' to print vertices.

»FC - print centrum or Voronoi vertex for each facet

The output starts with the dimension followed by the number of facets. Then each facet centrum is printed, one per line. For qvoronoi, Voronoi vertices are printed instead.

»Fd - use cdd format for input

The input starts with comments. The first comment is reported in the summary. Data starts after a "begin" line. The next line is the number of points followed by the dimension plus one and "real" or "integer". Then the points are listed with a leading "1" or "1.0". The data ends with an "end" line.

For halfspaces ('qhalf Fd'), the input format is the same. Each halfspace starts with its offset. The signs of the offset and coefficients are the opposite of Qhull's convention. The first two lines of the input may be an interior point in 'FV' format.

»FD - use cdd format for normals

Option 'FD' prints normals ('n', 'Fo', 'Fi') or points ('p') in cdd format. The first line is the command line that invoked Qhull. Data starts with a "begin" line. The next line is the number of normals or points followed by the dimension plus one and "real". Then the normals or points are listed with the offset before the coefficients. The offset for points is 1.0. For normals, the offset and coefficients use the opposite sign from Qhull. The data ends with an "end" line.

»FF - print facets w/o ridges

Option 'FF' prints all fields of all facets (as in 'f') without printing the ridges. This is useful in higher dimensions where a facet may have many ridges. For simplicial facets, options 'FF' and 'f ' are equivalent.

»Fi - print inner planes for each facet

The first line is the dimension plus one. The second line is the number of facets. The remainder is one inner plane per line. The format is the same as option 'n'.

The inner plane is a plane that is below the facet's vertices. It is an offset from the facet's hyperplane. It includes a roundoff error for computing the vertex distance.

Note that the inner planes for Geomview output ('Gi') include an additional offset for vertex visualization and roundoff error.

»Fi - print separating hyperplanes for inner, bounded Voronoi regions

With qvoronoi, 'Fi' prints the separating hyperplanes for inner, bounded regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the number of indices and floats. The first pair of indices indicates an adjacent pair of input sites. The next d floats are the normalized coefficients for the hyperplane, and the last float is the offset. The hyperplane is oriented toward 'QVn' (if defined), or the first input site of the pair (the point is below the hyperplane).

Use 'Fo' for unbounded regions, and 'Fv' for the corresponding Voronoi vertices.

Use 'Tv' to verify that the hyperplanes are perpendicular bisectors. It will list relevant statistics to stderr. The hyperplane is a perpendicular bisector if the midpoint of the input sites lies on the plane, all Voronoi vertices in the ridge lie on the plane, and the angle between the input sites and the plane is ninety degrees. This is true if all statistics are zero. Roundoff and computation errors make these non-zero. The deviations appear to be largest when the corresponding Delaunay triangles are large and thin; for example, the Voronoi diagram of nearly cospherical points.

»FI - print ID for each facet

Print facet identifiers. These are used internally and listed with options 'f' and 'FF'. Options 'Fn' and 'FN' use facet identifiers for negative indices.

»Fm - print merge count for each facet

The first line is the number of facets. The remainder is the number of merges for each facet, one per line. At most 511 merges are reported for a facet. See 'PMn' for printing the facets with the most merges.

»FM - print Maple output

Qhull writes a Maple file for 2-d and 3-d convex hulls, 2-d and 3-d halfspace intersections, and 2-d Delaunay triangulations. Qhull produces a 2-d or 3-d plot.

Warning: This option has not been tested in Maple.

[From T. K. Abraham with help from M. R. Feinberg and N. Platinova.] The following steps apply while working within the Maple worksheet environment :

  1. Generate the data and store it as an array . For example, in 3-d, data generated in Maple is of the form : x[i],y[i],z[i]

  2. Create a single variable and assign the entire array of data points to this variable. Use the "seq" command within square brackets as shown in the following example. (The square brackets are essential for the rest of the steps to work.)

    >data:=[seq([x[i],y[i],z[i]],i=1..n)]:# here n is the number of data points

  3. Next we need to write the data to a file to be read by qhull. Before writing the data to a file, make sure that the qhull executable files and the data file lie in the same subdirectory. If the executable files are stored in the "C:\qhull3.1\" subdirectory, then save the file in the same subdirectory, say "C:\qhull3.1\datafile.txt". For the sake of integrity of the data file , it is best to first ensure that the data file does not exist before writing into the data file. This can be done by running a delete command first . To write the data to the file, use the "writedata" and the "writedata[APPEND]" commands as illustrated in the following example :

    >system("del c:\\qhull3.1\\datafile.txt");#To erase any previous versions of the file
    >writedata("c:\\qhull3.1\\datafile.txt ",[3, nops(data)]);#writing in qhull format
    >writedata[APPEND]("c:\\ qhull3.1\\datafile.txt ", data);#writing the data points

  4. Use the 'FM' option to produce Maple output. Store the output as a ".mpl" file. For example, using the file we created above, we type the following (in DOS environment)

    qconvex s FM <datafile.txt >dataplot.mpl

  5. To read 3-d output in Maple, we use the 'read' command followed by a 'display3d' command. For example (in Maple environment):

    >with (plots):
    >read `c:\\qhull3.1\\dataplot.mpl`:#IMPORTANT - Note that the punctuation mark used is ' and NOT '. The correct punctuation mark is the one next to the key for "1" (not the punctuation mark near the enter key)
    > qhullplot:=%:
    > display3d(qhullplot);

For Delaunay triangulation orthogonal projection is better.

For halfspace intersections, Qhull produces the dual convex hull.

See Is Qhull available for Maple? for other URLs.

»Fn - print neighboring facets for each facet

The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of neighbors followed by an index for each neighbor. The indices match the other facet output formats.

For simplicial facets, each neighbor is opposite the corresponding vertex (option 'Fv'). Do not compare to option 'i'. Option 'i' orients facets by reversing the order of two vertices. For non-simplicial facets, the neighbors are unordered.

A negative index indicates an unprinted facet due to printing only good facets ('Pg', qdelaunay, qvoronoi). It is the negation of the facet's ID (option 'FI'). For example, negative indices are used for facets "at infinity" in the Delaunay triangulation.

For halfspace intersection (qhalf), a "facet" is an intersection point. Option 'Fn' lists the neighboring intersection points for each intersection point.

»FN - print neighboring facets for each point

The first line is the number of points. Then each point is printed, one per line. For unassigned points (either interior or coplanar), the line is "0". For assigned coplanar points ('Qc'), the line is "1" followed by the index of the facet that is furthest below the point. For assigned interior points ('Qi'), the line is "1" followed by the index of the facet that is least above the point. For vertices that do not belong to good facet, the line is "0"

For vertices of good facets, the line is the number of neighboring facets followed by the facet indices. The indices correspond to the other 'F' formats. In 4-d and higher, the facets are sorted by index. In 3-d, the facets are in adjacency order (not oriented).

A negative index indicates an unprinted facet due to printing only good facets (qdelaunay, qvoronoi, 'Pdk', 'Pg'). It is the negation of the facet's ID (' FI'). For example, negative indices are used for facets "at infinity" in the Delaunay triangulation.

For Voronoi vertices, option 'FN' lists the vertices of the Voronoi region for each input site. Option 'FN' lists the regions in site ID order. Option 'FN' corresponds to the second half of option 'o'. To convert from 'FN' to 'o', replace negative indices with zero and increment non-negative indices by one.

For halfspace intersection (qhalf), a "facet" is an intersection point and a "point" is a halfspace. Option 'FN' lists the intersection points for each halfspace. The first line is the number of halfspaces. Each remaining line starts with the number of intersection points for this halfspace. Redundant halfspaces have 0 intersection points.

If you are using the Qhull library or C++ interface, option 'FN' has the side effect of reordering the neighbors for a vertex

»Fo - print outer planes for each facet

The first line is the dimension plus one. The second line is the number of facets. The remainder is one outer plane per line. The format is the same as option 'n'.

The outer plane is a plane that is above all points. It is an offset from the facet's hyperplane. It includes a roundoff error for computing the point distance. When testing the outer plane (e.g., 'Tv'), another roundoff error should be added for the tested point.

If outer planes are not checked ('Q5') or not computed (!qh_MAXoutside), the maximum, computed outside distance is used instead. This can be much larger than the actual outer planes.

Note that the outer planes for Geomview output ('G') include an additional offset for vertex/point visualization, 'lines closer,' and roundoff error.

»Fo - print separating hyperplanes for outer, unbounded Voronoi regions

With qvoronoi, 'Fo' prints the separating hyperplanes for outer, unbounded regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the number of indices and floats. The first pair of indices indicates an adjacent pair of input sites. The next d floats are the normalized coefficients for the hyperplane, and the last float is the offset. The hyperplane is oriented toward 'QVn' (if defined), or the first input site of the pair (the point is below the hyperplane).

Option 'Fo' gives the separating hyperplanes for the unbounded regions of the Voronoi diagram. The midpoint between each pair of input sites is used in place of the vertex at infinity.

If the midpoint happens to be a Voronoi vertex, the hyperplane is degenerate (e.g., 'rbox c P0 D2 | qvoronoi p Fo').

Use 'Fi' for bounded regions, and 'Fv' for the corresponding Voronoi vertices.

»FO - print list of selected options

Lists selected options and default values to stderr. Additional 'FO's are printed to stdout.

»Fp - print points at halfspace intersections

The first line is the number of intersection points. The remainder is one intersection point per line. A intersection point is the intersection of d or more halfspaces from 'qhalf'. It corresponds to a facet of the dual polytope. The "infinity" point, [-10.101,-10.101,...] (qh_INFINITE), indicates an unbounded intersection.

If [x,y,z] are the dual facet's normal coefficients and b<0 is its offset, the halfspace intersection occurs at [x/-b,y/-b,z/-b] plus the interior point. If b>=0, the halfspace intersection is unbounded.

»FP - print nearest vertex for coplanar points

The output starts with the number of coplanar points. Then each coplanar point is printed one per line. Each line is the point ID of the closest vertex, the point ID of the coplanar point, the corresponding facet ID, and the distance. Sort the lines to list the coplanar points nearest to each vertex.

Use options 'Qc' and/or 'Qi' with 'FP'. Options 'Qc FP' prints coplanar points while 'Qci FP' prints coplanar and interior points. Option 'Qc' is automatically selected if 'Qi' is not selected.

For Delaunay triangulations (qdelaunay or qvoronoi), a coplanar point is nearly incident to a vertex. The distance is the distance in the original point set.

If imprecision problems are severe, Qhull will delete input sites when constructing the Delaunay triangulation. Option 'FP' will list these points along with coincident points.

If there are many coplanar or coincident points and non-simplicial facets are triangulated ('Qt'), option 'FP' may be inefficient. It redetermines the original vertex set for each coplanar point.

»FQ - print command for qhull and input

Prints qhull and input command, e.g., 'rbox 10 s | qhull FQ'. Option 'FQ' may be repeated multiple times.

»Fs - print summary

The first line consists of number of integers ("10") followed by the:

  • dimension
  • number of points
  • number of vertices
  • number of facets
  • number of vertices selected for output
  • number of facets selected for output
  • number of coplanar points for selected facets
  • number of nonsimplicial or merged facets selected for output
  • number of deleted vertices
  • number of triangulated facets ('Qt')

The second line consists of the number of reals ("2") followed by the:

  • maximum offset to an outer plane
  • minimum offset to an inner plane.
Roundoff and joggle are included.

For Delaunay triangulations and Voronoi diagrams, the number of deleted vertices should be zero. If greater than zero, then the input is highly degenerate and coplanar points are not necessarily coincident points. For example, 'RBOX 1000 s W1e-13 t995138628 | QHULL d Qbb' reports deleted vertices; the input is nearly cospherical.

Later versions of Qhull may produce additional integers or reals.

»FS - print sizes

The first line consists of the number of integers ("0"). The second line consists of the number of reals ("2"), followed by the total facet area, and the total volume. Later versions of Qhull may produce additional integers or reals.

The total volume measures the volume of the intersection of the halfspaces defined by each facet. It is computed from the facet area. Both area and volume are approximations for non-simplicial facets. See option 'Fa' for further notes. Option 'FA' also computes the total area and volume.

»Ft - print triangulation

Prints a triangulation with added points for non-simplicial facets. The output is

  • The first line is the dimension
  • The second line is the number of points, the number of facets, and the number of ridges.
  • All of the input points follow, one per line.
  • The centrums follow, one per non-simplicial facet
  • Then the facets follow as a list of point indices preceded by the number of points. The simplices are oriented.

For convex hulls with simplicial facets, the output is the same as option 'o'.

The added points are the centrums of the non-simplicial facets. Except for large facets, the centrum is the average vertex coordinate projected to the facet's hyperplane. Large facets may use an old centrum to avoid recomputing the centrum after each merge. In either case, the centrum is clearly below neighboring facets. See Precision issues.

The new simplices will not be clearly convex with their neighbors and they will not satisfy the Delaunay property. They may even have a flipped orientation. Use triangulated input ('Qt') for Delaunay triangulations.

For Delaunay triangulations with simplicial facets, the output is the same as option 'o' without the lifted coordinate. Since 'Ft' is invalid for merged Delaunay facets, option 'Ft' is not available for qdelaunay or qvoronoi. It may be used with joggled input ('QJ') or triangulated output ('Qt'), for example, rbox 10 c G 0.01 | qhull d QJ Ft

If you add a point-at-infinity with 'Qz', it is printed after the input sites and before any centrums. It will not be used in a Delaunay facet.

»Fv - print vertices for each facet

The first line is the number of facets. Then each facet is printed, one per line. Each line is the number of vertices followed by the corresponding point ids. Vertices are listed in the order they were added to the hull (the last one added is the first listed).

Option 'i' also lists the vertices, but it orients facets by reversing the order of two vertices. Option 'i' triangulates non-simplicial, 4-d and higher facets by adding vertices for the centrums.

For halfspace intersection (qhalf), a "facet" is an intersection point and a "point" is a halfspace. Option 'Fv' lists the non-redundant halfspaces incident to each intersection point. The first line is the number of non-redundant halfspaces. Each remaining line starts with the number of non-redundant halfspaces incident to that point.

»Fv - print Voronoi diagram

With qvoronoi, 'Fv' prints the Voronoi diagram or furthest-site Voronoi diagram. The first line is the number of ridges. Then each ridge is printed, one per line. The first number is the count of indices. The second pair of indices indicates a pair of input sites. The remaining indices list the corresponding ridge of Voronoi vertices. Vertex 0 is the vertex-at-infinity. It indicates an unbounded ray.

All vertices of a ridge are coplanar. If the ridge is unbounded, add the midpoint of the pair of input sites. The unbounded ray is directed from the Voronoi vertices to infinity.

Use 'Fo' for separating hyperplanes of outer, unbounded regions. Use 'Fi' for separating hyperplanes of inner, bounded regions.

Option 'Fv' does not list ridges that require more than one midpoint. For example, the Voronoi diagram of cospherical points lists zero ridges (e.g., 'rbox 10 s | qvoronoi Fv Qz'). Other examples are the Voronoi diagrams of a rectangular mesh (e.g., 'rbox 27 M1,0 | qvoronoi Fv') or a point set with a rectangular corner (e.g., 'rbox P4,4,4 P4,2,4 P2,4,4 P4,4,2 10 | qvoronoi Fv'). Both cases miss unbounded rays at the corners. To determine these ridges, surround the points with a large cube (e.g., 'rbox 10 s c G2.0 | qvoronoi Fv Qz'). The cube needs to be large enough to bound all Voronoi regions of the original point set. Please report any other cases that are missed. If you can formally describe these cases or write code to handle them, please send email to qhull@qhull.org.

»FV - print average vertex

The average vertex is the average of all vertex coordinates. It is an interior point for halfspace intersection. The first line is the dimension and "1"; the second line is the coordinates. For example,

qconvex FV n | qhalf Fp

prints the extreme points of the original point set (roundoff included).

»Fx - print extreme points (vertices) of convex hulls and Delaunay triangulations

The first line is the number of points. The following lines give the index of the corresponding points. The first point is '0'.

In 2-d, the extreme points (vertices) are listed in counter-clockwise order (by qh_ORIENTclock in user.h).

In 3-d and higher convex hulls, the extreme points (vertices) are sorted by index. This is the same order as option 'p' when it doesn't include coplanar or interior points.

For Delaunay triangulations, 'Fx' lists the extreme points of the input sites (i.e., the vertices of their convex hull). The points are unordered.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qh-quick.html0000644000176200001440000004536014664417655020650 0ustar liggesusers Qhull quick reference

Up: Home page for Qhull (local)
Up: Qhull manual
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull code
To: Qhull files (local)
To: GeomGlobalIoMemMergePolyQhullSetStatUser


[cone] Qhull quick reference

This section lists all programs and options in Qhull.

Copyright © 1995-2020 C.B. Barber

 


Qhull programs

» ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

qconvex -- convex hull
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
qdelaunay -- Delaunay triangulation
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
qdelaunay Qu -- furthest-site Delaunay triangulation
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
qhalf -- halfspace intersection about a point
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
qvoronoi -- Voronoi diagram
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
qvoronoi Qu -- furthest-site Voronoi diagram
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
rbox -- generate point distributions for qhull
synopsis • outputs • examples • notes • options
 
qhull -- convex hull and related structures
synopsis • input • outputs • controls • options
 
Qhull options

» ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

'd' delaunay 'f' facet-dump 'G' Geomview 'H' Halfspace
'i' incidences 'm' mathematica 'n' normals 'o' OFF-format
'p' points 's' summary 'v' voronoi
 
'Fa' Farea 'FA' FArea-total 'Fc' Fcoplanars 'FC' FCentrums
'Fd' Fd-cdd-in 'FD' FD-cdd-out 'FF' FFacets-xridge 'Fi' Finner
'Fi' Finner-bounded 'FI' FIDs 'Fm' Fmerges 'FM' FMaple
'Fn' Fneighbors 'FN' FNeigh-vertex 'Fo' Fouter 'Fo' Fouter-unbounded
'FO' FOptions 'Fp' Fpoint-intersect 'FP' FPoint-near 'FQ' FQhull
'Fs' Fsummary 'FS' FSize 'Ft' Ftriangles 'Fv' Fvertices
'Fv' Fvoronoi 'FV' FVertex-ave 'Fx' Fxtremes
 
'Ga' Gall-points 'Gc' Gcentrums 'GDn' GDrop-dim 'Gh' Ghyperplanes
'Gi' Ginner 'Gn' Gno-planes 'Go' Gouter 'Gp' Gpoints
'Gr' Gridges 'Gt' Gtransparent 'Gv' Gvertices
 
'PAn' PArea-keep 'Pdk:n' Pdrop-low 'PDk:n' Pdrop-high 'PFn' PFacet-area-keep
'Pg' Pgood 'PG' PGood-neighbors 'PMn' PMerge-keep 'Po' Poutput-forced
'Po' Poutput-error 'Pp' Pprecision-not
 
'Qa' Qallow-short 'Qbk:n' Qbound-low 'QBk:n' QBound-high 'QbB' QbB-scale-box
'Qbb' Qbb-scale-last 'Qbk:0Bk:0' Qbound-drop 'Qc' Qcoplanar 'Qi' Qinterior
'QJn' QJoggle 'QRn' QRotate 'Qs' Qsearch-all 'Qt' Qtriangulate
'Qu' QupperDelaunay 'Qw' Qwarn-allow 'Qx' Qxact-merge 'Qz' Qzinfinite
 
'Qf' Qfurthest 'Qg' Qgood-only 'QGn' QGood-point 'Qm' Qmax-outside
'Qr' Qrandom 'Qv' Qvertex-neighbors 'QVn' QVertex-good
'Q0' Q0-no-premerge 'Q1' Q1-angle-merge 'Q2' Q2-no-independent 'Q3' Q3-no-redundant
'Q4' Q4-no-old 'Q5' Q5-no-check-out 'Q6' Q6-no-concave 'Q7' Q7-depth-first
'Q8' Q8-no-near-interior 'Q9' Q9-pick-furthest 'Q10' Q10-no-narrow 'Q11' Q11-trinormals
'Q12' Q12-allow-wide 'Q14' Q14-merge-pinched 'Q15' Q15-duplicate-ridges
 
'TFn' TFacet-log 'TI file' TInput-file 'TO file' TOutput-file 'Ts' Tstatistics
'Tv' Tverify 'Tz' Tz-stdout
 
'T4' T4-trace 'Ta' Tannotate 'TAn' TAdd-stop 'Tc' Tcheck-often
'TCn' TCone-stop 'Tf' Tflush 'TMn' TMerge-trace 'TPn' TPoint-trace
'TRn' TRerun 'TV-n' TVertex-stop-before 'TVn' TVertex-stop-after 'TWn' TWide-trace
 
'A-n' Angle-max-pre 'An' Angle-max-post 'C-0' Centrum-roundoff 'C-n' Centrum-size-pre
'Cn' Centrum-size-post 'En' Error-round 'Rn' Random-dist 'Un' Ucoplanar-max
'Vn' Visible-min 'Wn' Wide-outside


Up: Home page for Qhull (local)
Up: Qhull manual
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull code
To: Qhull files (local)
To: GeomGlobalIoMemMergePolyQhullSetStatUser


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qh-optg.html0000644000176200001440000002607714664417655020511 0ustar liggesusers Qhull Geomview options (G)

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull Geomview options (G)

This section lists the Geomview options for Qhull. These options are indicated by 'G' followed by a letter. See Output, Print, and Format for other output options.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Geomview output options

Geomview is the graphical viewer for visualizing Qhull output in 2-d, 3-d and 4-d.

Geomview displays each facet of the convex hull. The color of a facet is determined by the coefficients of the facet's normal equation. For imprecise hulls, Geomview displays the inner and outer hull. Geomview can also display points, ridges, vertices, coplanar points, and facet intersections.

For 2-d Delaunay triangulations, Geomview displays the corresponding paraboloid. Geomview displays the 2-d Voronoi diagram. For halfspace intersections, it displays the dual convex hull.

G
display Geomview output
GDn
drop dimension n in 3-d and 4-d output
Gt
display transparent 3-d Delaunay triangulation
 
 
Specific
Ga
display all points as dots
Gc
display centrums (2-d, 3-d)
Gh
display hyperplane intersections
Gi
display inner planes only (2-d, 3-d)
Gn
do not display planes
Go
display outer planes only (2-d, 3-d)
Gp
display coplanar points and vertices as radii
Gr
display ridges (3-d)
Gv
display vertices as spheres

»G - produce output for viewing with Geomview

By default, option 'G' displays edges in 2-d, outer planes in 3-d, and ridges in 4-d.

A ridge can be explicit or implicit. An explicit ridge is a (d-1)-dimensional simplex between two facets. In 4-d, the explicit ridges are triangles. An implicit ridge is the topological intersection of two neighboring facets. It is the union of explicit ridges.

For non-simplicial 4-d facets, the explicit ridges can be quite complex. When displaying a ridge in 4-d, Qhull projects the ridge's vertices to one of its facets' hyperplanes. Use 'Gh' to project ridges to the intersection of both hyperplanes. This usually results in a cleaner display.

For 2-d Delaunay triangulations, Geomview displays the corresponding paraboloid. Geomview displays the 2-d Voronoi diagram. For halfspace intersections, it displays the dual convex hull.

»Ga - display all points as dots

Each input point is displayed as a green dot.

»Gc - display centrums (3-d)

The centrum is defined by a green radius sitting on a blue plane. The plane corresponds to the facet's hyperplane. If you sight along a facet's hyperplane, you will see that all neighboring centrums are below the facet. The radius is defined by 'C-n' or 'Cn'.

»GDn - drop dimension n in 3-d and 4-d output

The result is a 2-d or 3-d object. In 4-d, this corresponds to viewing the 4-d object from the nth axis without perspective. It's best to view 4-d objects in pieces. Use the 'Pdk' 'Pg' 'PG' 'QGn' and 'QVn' options to select a few facets. If one of the facets is perpendicular to an axis, then projecting along that axis will show the facet exactly as it is in 4-d. If you generate many facets, use Geomview's ginsu module to view the interior

To view multiple 4-d dimensions at once, output the object without 'GDn' and read it with Geomview's ndview. As you rotate the object in one set of dimensions, you can see how it changes in other sets of dimensions.

For additional control over 4-d objects, output the object without 'GDn' and read it with Geomview's 4dview. You can slice the object along any 4-d plane. You can also flip the halfspace that's deleted when slicing. By combining these features, you can get some interesting cross sections.

»Gh - display hyperplane intersections (3-d, 4-d)

In 3-d, the intersection is a black line. It lies on two neighboring hyperplanes, c.f., the blue squares associated with centrums ('Gc'). In 4-d, the ridges are projected to the intersection of both hyperplanes. If you turn on edges (Geomview's 'appearances' menu), each triangle corresponds to one ridge. The ridges may overlap each other.

»Gi - display inner planes only (2-d, 3-d)

The inner plane of a facet is below all of its vertices. It is parallel to the facet's hyperplane. The inner plane's color is the opposite of the outer plane's color, i.e., [1-r,1-g,1-b] . Its edges are determined by the vertices.

»Gn - do not display planes

By default, Geomview displays the precise plane (no merging) or both inner and output planes (if merging). If merging, Geomview does not display the inner plane if the the difference between inner and outer is too small.

»Go - display outer planes only (2-d, 3-d)

The outer plane of a facet is above all input points. It is parallel to the facet's hyperplane. Its color is determined by the facet's normal, and its edges are determined by the vertices.

»Gp - display coplanar points and vertices as radii

Coplanar points ('Qc'), interior points ('Qi'), outside points ('TCn' or 'TVn'), and vertices are displayed as red and yellow radii. The radii are perpendicular to the corresponding facet. Vertices are aligned with an interior point. The radii define a ball which corresponds to the imprecision of the point. The imprecision is the maximum of the roundoff error, the centrum radius, and maxcoord * (1 - A-n). It is at least 1/20'th of the maximum coordinate, and ignores post merging if pre-merging is done.

If 'Gv' (print vertices as spheres) is also selected, option 'Gp' displays coplanar points as radii. Select options Qc' and/or 'Qi'. Options 'Qc Gpv' displays coplanar points while 'Qci Gpv' displays coplanar and interior points. Option 'Qc' is automatically selected if 'Qi' is not selected with options 'Gpv'.

»Gr - display ridges (3-d)

A ridge connects the two vertices that are shared by neighboring facets. It is displayed in green. A ridge is the topological edge between two facets while the hyperplane intersection is the geometric edge between two facets. Ridges are always displayed in 4-d.

»Gt - transparent 3-d Delaunay

A 3-d Delaunay triangulation looks like a convex hull with interior facets. Option 'Gt' removes the outside ridges to reveal the outermost facets. It automatically sets options 'Gr' and 'GDn'. See example eg.17f.delaunay.3.

»Gv - display vertices as spheres (2-d, 3-d)

The radius of the sphere corresponds to the imprecision of the data. See 'Gp' for determining the radius.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qh-eg.html0000644000176200001440000007472714664417655020140 0ustar liggesusers Examples of Qhull

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull examples: contents


[halfspace] Examples of Qhull

This section of the Qhull manual will introduce you to Qhull and its options. Each example is a file for viewing with Geomview. You will need to use a Unix computer with a copy of Geomview.

If you are not running Unix, you can view pictures for some of the examples. To understand Qhull without Geomview, try the examples in Programs and Programs/input. You can also try small examples that you compute by hand. Use rbox to generate examples.

To generate the Geomview examples, execute the shell script eg/q_eg. It uses rbox. The shell script eg/q_egtest generates test examples, and eg/q_test exercises the code. Test and log Qhull with eg/qtest.sh. eg/q_benchmark is a benchmark of Qhull precision and performance. If you find yourself viewing the inside of a 3-d example, use Geomview's normalization option on the 'obscure' menu.

Copyright © 1995-2020 C.B. Barber


»Qhull examples: contents



»2-d and 3-d examples

»rbox c D3 | qconvex G >eg.01.cube

The first example is a cube in 3-d. The color of each facet indicates its normal. For example, normal [0,0,1] along the Z axis is (r=0.5, g=0.5, b=1.0). With the 'Dn' option in rbox, you can generate hypercubes in any dimension. Above 7-d the number of intermediate facets grows rapidly. Use 'TFn' to track qconvex's progress. Note that each facet is a square that qconvex merged from coplanar triangles.

»rbox c d G3.0 | qconvex G >eg.02.diamond.cube

The second example is a cube plus a diamond ('d') scaled by rbox's 'G' option. In higher dimensions, diamonds are much simpler than hypercubes.

»rbox s 100 D3 | qconvex G >eg.03.sphere

The rbox s option generates random points and projects them to the d-sphere. All points should be on the convex hull. Notice that random points look more clustered than you might expect. You can get a smoother distribution by merging facets and printing the vertices, e.g., rbox 1000 s | qconvex A-0.95 p | qconvex G >eg.99.

»rbox s 100 D2 | qconvex G >eg.04.circle

In 2-d, there are many ways to generate a convex hull. One of the earliest algorithms, and one of the fastest, is the 2-d Quickhull algorithm [c.f., Preparata & Shamos '85]. It was the model for Qhull.

»rbox 10 l | qconvex G >eg.05.spiral

One rotation of a spiral.

»rbox 1000 D2 | qconvex C-0.03 Qc Gapcv >eg.06.merge.square

This demonstrates how Qhull handles precision errors. Option 'C-0.03' requires a clearly convex angle between adjacent facets. Otherwise, Qhull merges the facets.

This is the convex hull of random points in a square. The facets have thickness because they must be outside all points and must include their vertices. The colored lines represent the original points and the spheres represent the vertices. Floating in the middle of each facet is the centrum. Each centrum is at least 0.03 below the planes of its neighbors. This guarantees that the facets are convex.

»rbox 1000 D3 | qconvex G >eg.07.box

Here's the same distribution but in 3-d with Qhull handling machine roundoff errors. Note the large number of facets.

»rbox c G0.4 s 500 | qconvex G >eg.08a.cube.sphere

The sphere is just barely poking out of the cube. Try the same distribution with randomization turned on ('Qr'). This turns Qhull into a randomized incremental algorithm. To compare Qhull and randomization, look at the number of hyperplanes created and the number of points partitioned. Don't compare CPU times since Qhull's implementation of randomization is inefficient. The number of hyperplanes and partitionings indicate the dominant costs for Qhull. With randomization, you'll notice that the number of facets created is larger than before. This is especially true as you increase the number of points. It is because the randomized algorithm builds most of the sphere before it adds the cube's vertices.

»rbox d G0.6 s 500 | qconvex G >eg.08b.diamond.sphere

This is a combination of the diamond distribution and the sphere.

»rbox 100 L3 G0.5 s | qconvex G >eg.09.lens

Each half of the lens distribution lies on a sphere of radius three. A directed search for the furthest facet below a point (e.g., qh_findbest in geom.c) may fail if started from an arbitrary facet. For example, if the first facet is on the opposite side of the lens, a directed search will report that the point is inside the convex hull even though it is outside. This problem occurs whenever the curvature of the convex hull is less than a sphere centered at the test point.

To prevent this problem, Qhull does not use directed search all the time. When Qhull processes a point on the edge of the lens, it partitions the remaining points with an exhaustive search instead of a directed search (see qh_findbestnew in geom2.c).

»How Qhull adds a point

»rbox 100 s P0.5,0.5,0.5 | qconvex Ga QG0 >eg.10a.sphere.visible

The next 4 examples show how Qhull adds a point. The point [0.5,0.5,0.5] is at one corner of the bounding box. Qhull adds a point using the beneath-beyond algorithm. First Qhull finds all of the facets that are visible from the point. Qhull will replace these facets with new facets.

»rbox 100 s P0.5,0.5,0.5|qconvex Ga QG-0 >eg.10b.sphere.beyond

These are the facets that are not visible from the point. Qhull will keep these facets.

»rbox 100 s P0.5,0.5,0.5 | qconvex PG Ga QG0 >eg.10c.sphere.horizon

These facets are the horizon facets; they border the visible facets. The inside edges are the horizon ridges. Each horizon ridge will form the base for a new facet.

»rbox 100 s P0.5,0.5,0.5 | qconvex Ga QV0 PgG >eg.10d.sphere.cone

This is the cone of points from the new point to the horizon facets. Try combining this image with eg.10c.sphere.horizon and eg.10a.sphere.visible.

»rbox 100 s P0.5,0.5,0.5 | qconvex Ga >eg.10e.sphere.new

This is the convex hull after [0.5,0.5,0.5] has been added. Note that in actual practice, the above sequence would never happen. Unlike the randomized algorithms, Qhull always processes a point that is furthest in an outside set. A point like [0.5,0.5,0.5] would be one of the first points processed.

»rbox 100 s P0.5,0.5,0.5 | qhull Ga QV0g Q0 >eg.14.sphere.corner

The 'QVn', 'QGn' and 'Pdk' options define good facets for Qhull. In this case 'QV0' defines the 0'th point [0.5,0.5,0.5] as the good vertex, and 'Qg' tells Qhull to only build facets that might be part of a good facet. This technique reduces output size in low dimensions. It does not work with facet merging (turned off with 'Q0')

»Triangulated output or joggled input

»rbox 500 W0 | qconvex QR0 Qc Gvp >eg.15a.surface

This is the convex hull of 500 points on the surface of a cube. Note the large, non-simplicial facet for each face. Qhull merges non-convex facets.

If the facets were not merged, Qhull would report precision problems. For example, turn off facet merging with option 'Q0'. Qhull may report concave facets, flipped facets, or other precision errors:

rbox 500 W0 | qhull QR0 Q0

»rbox 500 W0 | qconvex QR0 Qt Qc Gvp >eg.15b.triangle

Like the previous examples, this is the convex hull of 500 points on the surface of a cube. Option 'Qt' triangulates the non-simplicial facets. Triangulated output is particularly helpful for Delaunay triangulations.

»rbox 500 W0 | qconvex QR0 QJ5e-2 Qc Gvp >eg.15c.joggle

This is the convex hull of 500 joggled points on the surface of a cube. The option 'QJ5e-2' sets a very large joggle to make the effect visible. Notice that all of the facets are triangles. If you rotate the cube, you'll see red-yellow lines for coplanar points.

With option 'QJ', Qhull joggles the input to avoid precision problems. It adds a small random number to each input coordinate. If a precision error occurs, it increases the joggle and tries again. It repeats this process until no precision problems occur.

Joggled input is a simple solution to precision problems in computational geometry. Qhull can also merge facets to handle precision problems. See Merged facets or joggled input.

»Delaunay and Voronoi diagrams

»qdelaunay Qt <eg.data.17 GnraD2 >eg.17a.delaunay.2

The input file, eg.data.17, consists of a square, 15 random points within the outside half of the square, and 6 co-circular points centered on the square.

The Delaunay triangulation is the triangulation with empty circumcircles. The input for this example is unusual because it includes six co-circular points. Every triangular subset of these points has the same circumcircle. Option 'Qt' triangulates the co-circular facet.

»qdelaunay <eg.data.17 GnraD2 >eg.17b.delaunay.2i

This is the same example without triangulated output ('Qt'). qdelaunay merges the non-unique Delaunay triangles into a hexagon.

»qdelaunay <eg.data.17 Ga >eg.17c.delaunay.2-3

This is how Qhull generated both diagrams. Use Geomview's 'obscure' menu to turn off normalization, and Geomview's 'cameras' menu to turn off perspective. Then load this object with one of the previous diagrams.

The points are lifted to a paraboloid by summing the squares of each coordinate. These are the light blue points. Then the convex hull is taken. That's what you see here. If you look up the Z-axis, you'll see that points and edges coincide.

»qvoronoi QJ <eg.data.17 Gna >eg.17d.voronoi.2

The Voronoi diagram is the dual of the Delaunay triangulation. Here you see the original sites and the Voronoi vertices. Notice the each vertex is equidistant from three sites. The edges indicate the Voronoi region for a site. Qhull does not draw the unbounded edges. Instead, it draws extra edges to close the unbounded Voronoi regions. You may find it helpful to enclose the input points in a square. You can compute the unbounded rays from option 'Fo'.

Instead of triangulated output ('Qt'), this example uses joggled input ('QJ'). Normally, you should use neither 'QJ' nor 'Qt' for Voronoi diagrams.

»qvoronoi <eg.data.17 Gna >eg.17e.voronoi.2i

This looks the same as the previous diagrams, but take a look at the data. Run 'qvoronoi p <eg/eg.data.17'. This prints the Voronoi vertices.

With 'QJ', there are four nearly identical Voronoi vertices within 10^-11 of the origin. Option 'QJ' joggled the input. After the joggle, the cocircular input sites are no longer cocircular. The corresponding Voronoi vertices are similar but not identical.

This example does not use options 'Qt' or 'QJ'. The cocircular input sites define one Voronoi vertex near the origin.

Option 'Qt' would triangulate the corresponding Delaunay region into four triangles. Each triangle is assigned the same Voronoi vertex.

» rbox c G0.1 d | qdelaunay Gt Qz <eg.17f.delaunay.3

This is the 3-d Delaunay triangulation of a small cube inside a prism. Since the outside ridges are transparent, it shows the interior of the outermost facets. If you slice open the triangulation with Geomview's ginsu, you will see that the innermost facet is a cube. Note the use of 'Qz' to add a point "at infinity". This avoids a degenerate input due to cospherical points.

»rbox 10 D2 d | qdelaunay Qu G >eg.18a.furthest.2-3

The furthest-site Voronoi diagram contains Voronoi regions for points that are furthest from an input site. It is the dual of the furthest-site Delaunay triangulation. You can determine the furthest-site Delaunay triangulation from the convex hull of the lifted points (eg.17c.delaunay.2-3). The upper convex hull (blue) generates the furthest-site Delaunay triangulation.

»rbox 10 D2 d | qdelaunay Qu Pd2 G >eg.18b.furthest-up.2-3

This is the upper convex hull of the preceding example. The furthest-site Delaunay triangulation is the projection of the upper convex hull back to the input points. The furthest-site Voronoi vertices are the circumcenters of the furthest-site Delaunay triangles.

»rbox 10 D2 d | qvoronoi Qu Gv >eg.18c.furthest.2

This shows an incomplete furthest-site Voronoi diagram. It only shows regions with more than two vertices. The regions are artificially truncated. The actual regions are unbounded. You can print the regions' vertices with 'qvoronoi Qu o'.

Use Geomview's 'obscure' menu to turn off normalization, and Geomview's 'cameras' menu to turn off perspective. Then load this with the upper convex hull.

»rbox 10 D3 | qvoronoi QV5 p | qconvex G >eg.19.voronoi.region.3

This shows the Voronoi region for input site 5 of a 3-d Voronoi diagram.

»Facet merging for imprecision

»rbox r s 20 Z1 G0.2 | qconvex G >eg.20.cone

There are two things unusual about this cone. One is the large flat disk at one end and the other is the rectangles about the middle. That's how the points were generated, and if those points were exact, this is the correct hull. But rbox used floating point arithmetic to generate the data. So the precise convex hull should have been triangles instead of rectangles. By requiring convexity, Qhull has recovered the original design.

»rbox 200 s | qhull Q0 R0.01 Gav Po >eg.21a.roundoff.errors

This is the convex hull of 200 cospherical points with precision errors ignored ('Q0'). To demonstrate the effect of roundoff error, we've added a random perturbation ('R0.01') to every distance and hyperplane calculation. Qhull, like all other convex hull algorithms with floating point arithmetic, makes inconsistent decisions and generates wildly wrong results. In this case, one or more facets are flipped over. These facets have the wrong color. You can also turn on 'normals' in Geomview's appearances menu and turn off 'facing normals'. There should be some white lines pointing in the wrong direction. These correspond to flipped facets.

Different machines may not produce this picture. If your machine generated a long error message, decrease the number of points or the random perturbation ('R0.01'). If it did not report flipped facets, increase the number of points or perturbation.

»rbox 200 s | qconvex Qc R0.01 Gpav >eg.21b.roundoff.fixed

Qhull handles the random perturbations and returns an imprecise sphere. In this case, the output is a weak approximation to the points. This is because a random perturbation of 'R0.01' is equivalent to losing all but 1.8 digits of precision. The outer planes float above the points because Qhull needs to allow for the maximum roundoff error.

If you start with a smaller random perturbation, you can use joggle ('QJn') to avoid precision problems. You need to set n significantly larger than the random perturbation. For example, try 'rbox 200 s | qconvex Qc R1e-4 QJ1e-1'.

»rbox 1000 s| qconvex C0.01 Qc Gcrp >eg.22a.merge.sphere.01

»rbox 1000 s| qconvex C-0.01 Qc Gcrp >eg.22b.merge.sphere.-01

»rbox 1000 s| qconvex C0.05 Qc Gcrpv >eg.22c.merge.sphere.05

»rbox 1000 s| qconvex C-0.05 Qc Gcrpv >eg.22d.merge.sphere.-05

The next four examples compare post-merging and pre-merging ('Cn' vs. 'C-n'). Qhull uses '-' as a flag to indicate pre-merging.

Post-merging happens after the convex hull is built. During post-merging, Qhull repeatedly merges an independent set of non-convex facets. For a given set of parameters, the result is about as good as one can hope for.

Pre-merging does the same thing as post-merging, except that it happens after adding each point to the convex hull. With pre-merging, Qhull guarantees a convex hull, but the facets are wider than those from post-merging. If a pre-merge option is not specified, Qhull handles machine round-off errors.

You may see coplanar points appearing slightly outside the facets of the last example. This is becomes Geomview moves line segments forward toward the viewer. You can avoid the effect by setting 'lines closer' to '0' in Geomview's camera menu.

»rbox 1000 | qconvex s Gcprvah C0.1 Qc >eg.23.merge.cube

Here's the 3-d imprecise cube with all of the Geomview options. There's spheres for the vertices, radii for the coplanar points, dots for the interior points, hyperplane intersections, centrums, and inner and outer planes. The radii are shorter than the spheres because this uses post-merging ('C0.1') instead of pre-merging.

»4-d objects

With Qhull and Geomview you can develop an intuitive sense of 4-d surfaces. When you get into trouble, think of viewing the surface of a 3-d sphere in a 2-d plane.

»rbox 5000 D4 | qconvex s GD0v Pd0:0.5 C-0.02 C0.1 >eg.24.merge.cube.4d-in-3d

Here's one facet of the imprecise cube in 4-d. It is projected into 3-d (the 'GDn' option drops dimension n). Each ridge consists of two triangles between this facet and the neighboring facet. In this case, Geomview displays the topological ridges, i.e., as triangles between three vertices. That is why the cube looks lopsided.

»rbox 5000 D4 | qconvex s C-0.02 C0.1 Gh >eg.30.4d.merge.cube

Here is the equivalent in 4-d of the imprecise square and imprecise cube. It's the imprecise convex hull of 5000 random points in a hypercube. It's a full 4-d object so Geomview's ginsu does not work. If you view it in Geomview, you'll be inside the hypercube. To view 4-d objects directly, either load the 4dview module or the ndview module. For 4dview, you must have started Geomview in the same directory as the object. For ndview, initialize a set of windows with the prefab menu, and load the object through Geomview. The 4dview module includes an option for slicing along any hyperplane. If you do this in the x, y, or z plane, you'll see the inside of a hypercube.

The 'Gh' option prints the geometric intersections between adjacent facets. Note the strong convexity constraint for post-merging ('C0.1'). It deletes the small facets.

»rbox 20 D3 | qdelaunay G >eg.31.4d.delaunay

The Delaunay triangulation of 3-d sites corresponds to a 4-d convex hull. You can't see 4-d directly but each facet is a 3-d object that you can project to 3-d. This is exactly the same as projecting a 2-d facet of a soccer ball onto a plane.

Here we see all of the facets together. You can use Geomview's ndview to look at the object from several directions. Try turning on edges in the appearance menu. You'll notice that some edges seem to disappear. That's because the object is actually two sets of overlapping facets.

You can slice the object apart using Geomview's 4dview. With 4dview, try slicing along the w axis to get a single set of facets and then slice along the x axis to look inside. Another interesting picture is to slice away the equator in the w dimension.

»rbox 30 s D4 | qconvex s G Pd0d1d2D3

This is the positive octant of the convex hull of 30 4-d points. When looking at 4-d, it's easier to look at just a few facets at once. If you picked a facet that was directly above you, then that facet looks exactly the same in 3-d as it looks in 4-d. If you pick several facets, then you need to imagine that the space of a facet is rotated relative to its neighbors. Try Geomview's ndview on this example.

»Halfspace intersections

»rbox 10 r s Z1 G0.3 | qconvex G >eg.33a.cone

»rbox 10 r s Z1 G0.3 | qconvex FV n | qhalf G >eg.33b.cone.dual

»rbox 10 r s Z1 G0.3 | qconvex FV n | qhalf Fp | qconvex G >eg.33c.cone.halfspace

These examples illustrate halfspace intersection. The first picture is the convex hull of two 20-gons plus an apex. The second picture is the dual of the first. Try loading both at once. Each vertex of the second picture corresponds to a facet or halfspace of the first. The vertices with four edges correspond to a facet with four neighbors. Similarly the facets correspond to vertices. A facet's normal coefficients divided by its negative offset is the vertice's coordinates. The coordinates are the intersection of the original halfspaces.

The third picture shows how Qhull can go back and forth between equivalent representations. It starts with a cone, generates the halfspaces that define each facet of the cone, and then intersects these halfspaces. Except for roundoff error, the third picture is a duplicate of the first.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull examples: contents


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qdelaun.html0000644000176200001440000006747314664417655020570 0ustar liggesusers qdelaunay -- Delaunay triangulation Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options

[delaunay]qdelaunay -- Delaunay triangulation

The Delaunay triangulation is the triangulation with empty circumspheres. It has many useful properties and applications. See the survey article by Aurenhammer ['91] and the detailed introduction by O'Rourke ['94].

Example: rbox r y c G0.1 D2 | qdelaunay s Fv TO result
Compute the 2-d Delaunay triangulation of a triangle and a small square. Write a summary to the console and unoriented regions to 'result'. Merge regions for cocircular input sites (i.e., the square).
 
Example: rbox r y c G0.1 D2 | qdelaunay s Fv Qt
Compute the 2-d Delaunay triangulation of a triangle and a small square. Write a summary and unoriented regions to the console. Produce triangulated output.
 
Example: rbox 10 D2 | qdelaunay QJ s i TO result
Compute the 2-d Delaunay triangulation of 10 random points. Joggle the input to guarantee triangular output. Write a summary to the console and the regions to 'result'.

Qhull computes the Delaunay triangulation by computing a convex hull. It lifts the input sites to a paraboloid by adding the sum of the squares of the coordinates. It scales the height of the paraboloid to improve numeric precision ('Qbb'). It computes the convex hull of the lifted sites, and projects the lower convex hull to the input.

Each region of the Delaunay triangulation corresponds to a facet of the lower half of the convex hull. Facets of the upper half of the convex hull correspond to the furthest-site Delaunay triangulation. See the examples, Delaunay and Voronoi diagrams.

See Qhull FAQ (local) - Delaunay and Voronoi diagram questions.

By default, qdelaunay merges cocircular and cospherical regions. For example, the Delaunay triangulation of a square inside a diamond ('rbox D2 c d G4 | qdelaunay') contains one region for the square.

Use option 'Qz' if the input is circular, cospherical, or nearly so. It improves precision by adding a point "at infinity," above the corresponding paraboloid.

If you use 'Qt' (triangulated output), all Delaunay regions will be simplicial (e.g., triangles in 2-d). Some regions may be degenerate and have zero area. Triangulated output identifies coincident points.

If you use 'QJ' (joggled input), all Delaunay regions will be simplicial (e.g., triangles in 2-d). Coincident points will create small regions since the points are joggled apart. Joggled input is less accurate than triangulated output ('Qt'). See Merged facets or joggled input.

The output for 3-d Delaunay triangulations may be confusing if the input contains cospherical data. See the FAQ item Why are there extra points in a 4-d or higher convex hull? Avoid these problems with triangulated output ('Qt') or joggled input ('QJ').

The 'qdelaunay' program is equivalent to 'qhull d Qbb'. It disables the following Qhull options: d n v H U Qb QB Qc Qf Qg Qi Qm Qr Qv Qx TR E V FC Fi Fo Fp Ft FV Q0,etc.

Copyright © 1995-2020 C.B. Barber


»qdelaunay synopsis

qdelaunay -- compute the Delaunay triangulation.
    input (stdin): dimension, number of points, point coordinates
    comments start with a non-numeric character

options:
    Qu   - furthest-site Delaunay triangulation
    Qt   - triangulated output
    QJ   - joggled input instead of merged facets
    Tv   - verify result: structure, convexity, and in-circle test
    .    - concise list of all options
    -    - one-line description of each option
    -?   - this message
    -V   - version

output options (subset):
    s    - summary of results (default)
    i    - vertices incident to each Delaunay region
    Fx   - extreme points (vertices of the convex hull)
    G    - Geomview output (2-d and 3-d points lifted to a paraboloid)
    m    - Mathematica output (2-d inputs lifted to a paraboloid)
    o    - OFF format (shows the points lifted to a paraboloid)
    QVn  - print Delaunay regions that include point n, -n if not
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes

examples:
    rbox c P0 D2 | qdelaunay s o          rbox c P0 D2 | qdelaunay i
    rbox c P0 D2 | qdelaunay Fv           rbox c P0 D2 | qdelaunay s Qu Fv
    rbox c G1 d D2 | qdelaunay s i        rbox c G1 d D2 | qdelaunay Qt
    rbox M3,4 z 100 D2 | qdelaunay s      rbox M3,4 z 100 D2 | qdelaunay s Qt

»qdelaunay input

The input data on stdin consists of:

  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qdelaunay < data.txt), a pipe (e.g., rbox 10 | qdelaunay), or the 'TI' option (e.g., qdelaunay TI data.txt).

For example, this is four cocircular points inside a square. Its Delaunay triangulation contains 8 triangles and one four-sided figure.

rbox s 4 W0 c G1 D2 > data
2 RBOX s 4 W0 c D2
8
-0.4941988586954018 -0.07594397977563715
-0.06448037284989526 0.4958248496365813
0.4911154367094632 0.09383830681375946
-0.348353580869097 -0.3586778257652367
    -1     -1
    -1      1
     1     -1
     1      1

qdelaunay s i < data


Delaunay triangulation by the convex hull of 8 points in 3-d

  Number of input sites: 8
  Number of Delaunay regions: 9
  Number of non-simplicial Delaunay regions: 1

Statistics for: RBOX s 4 W0 c D2 | QDELAUNAY s i

  Number of points processed: 8
  Number of hyperplanes created: 18
  Number of facets in hull: 10
  Number of distance tests for qhull: 33
  Number of merged facets: 2
  Number of distance tests for merging: 102
  CPU seconds to compute hull (after input): 0.028

9
1 7 5
6 3 4
2 3 6
7 2 6
2 7 1
0 5 4
3 0 4
0 1 5
1 0 3 2

»qdelaunay outputs

These options control the output of Delaunay triangulations:

Delaunay regions
i
list input sites for each Delaunay region. The first line is the number of regions. The remaining lines list the input sites for each region. The regions are oriented. In 3-d and higher, report cospherical sites by adding extra points. Use triangulated output ('Qt') to avoid non-simpicial regions. For the circle-in-square example, eight Delaunay regions are triangular and the ninth has four input sites.
Fv
list input sites for each Delaunay region. The first line is the number of regions. Each remaining line starts with the number of input sites. The regions are unoriented. For the circle-in-square example, eight Delaunay regions are triangular and the ninth has four input sites.
Fn
list neighboring regions for each Delaunay region. The first line is the number of regions. Each remaining line starts with the number of neighboring regions. Negative indices (e.g., -1) indicate regions outside of the Delaunay triangulation. For the circle-in-square example, the four regions on the square are neighbors to the region-at-infinity.
FN
list the Delaunay regions for each input site. The first line is the total number of input sites. Each remaining line starts with the number of Delaunay regions. Negative indices (e.g., -1) indicate regions outside of the Delaunay triangulation. For the circle-in-square example, each point on the circle belongs to four Delaunay regions. Use 'Qc FN' to include coincident input sites and deleted vertices.
Fa
print area for each Delaunay region. The first line is the number of regions. The areas follow, one line per region. For the circle-in-square example, the cocircular region has area 0.4.
 
 
Input sites
Fc
list coincident input sites for each Delaunay region. The first line is the number of regions. The remaining lines start with the number of coincident sites and deleted vertices. Deleted vertices indicate highly degenerate input (see'Fs'). A coincident site is assigned to one Delaunay region. Do not use 'QJ' with 'Fc'; the joggle will separate coincident sites.
FP
print coincident input sites with distance to nearest site (i.e., vertex). The first line is the number of coincident sites. Each remaining line starts with the point ID of an input site, followed by the point ID of a coincident point, its region, and distance. Includes deleted vertices which indicate highly degenerate input (see'Fs'). Do not use 'QJ' with 'FP'; the joggle will separate coincident sites.
Fx
list extreme points of the input sites. These points are on the boundary of the convex hull. The first line is the number of extreme points. Each point is listed, one per line. The circle-in-square example has four extreme points.
 
 
General
FA
compute total area for 's' and 'FS'
o
print lower facets of the corresponding convex hull (a paraboloid)
m
Mathematica output for the lower facets of the paraboloid (2-d triangulations).
FM
Maple output for the lower facets of the paraboloid (2-d triangulations).
G
Geomview output for the paraboloid (2-d or 3-d triangulations).
s
print summary for the Delaunay triangulation. Use 'Fs' and 'FS' for numeric data.

»qdelaunay controls

These options provide additional control:

Qt
triangulated output. Qhull triangulates non-simplicial facets. It may produce degenerate facets of zero area.
QJ
joggle the input to avoid cospherical and coincident sites. It is less accurate than triangulated output ('Qt').
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
Qu
compute the furthest-site Delaunay triangulation.
Qz
add a point above the paraboloid to reduce precision errors. Use it for nearly cocircular/cospherical input (e.g., 'rbox c | qdelaunay Qz'). The point is printed for options 'Ft' and 'o'.
QVn
select facets adjacent to input site n (marked 'good').
Tv
verify result.
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
TFn
report progress after constructing n facets
PDk:1
include upper and lower facets in the output. Set k to the last dimension (e.g., 'PD2:1' for 2-d inputs).
f
facet dump. Print the data structure for each facet (i.e., Delaunay region).

»qdelaunay graphics

For 2-d and 3-d Delaunay triangulations, Geomview ('qdelaunay G') displays the corresponding convex hull (a paraboloid).

To view a 2-d Delaunay triangulation, use 'qdelaunay GrD2' to drop the last dimension and view ridges. This is the same as viewing the hull without perspective (see Geomview's 'cameras' menu).

To view a 3-d Delaunay triangulation, use 'qdelaunay GrD3' to drop the last dimension and view ridges. You may see extra edges. These are interior edges that Geomview moves towards the viewer (see 'lines closer' in Geomview's camera options). Use option 'Gt' to make the outer ridges transparent in 3-d. See Delaunay and Voronoi examples.

For 2-d Delaunay triangulations, Mathematica ('m') and Maple ('FM') output displays the lower facets of the corresponding convex hull (a paraboloid).

For 2-d, furthest-site Delaunay triangulations, Maple and Mathematica output ('Qu m') displays the upper facets of the corresponding convex hull (a paraboloid).

»qdelaunay notes

You can simplify the Delaunay triangulation by enclosing the input sites in a large square or cube. This is particularly recommended for cocircular or cospherical input data.

A non-simplicial Delaunay region indicates nearly cocircular or cospherical input sites. To avoid non-simplicial regions either triangulate the output ('Qt') or joggle the input ('QJ'). Triangulated output is more accurate than joggled input. Alternatively, use an exact arithmetic code.

Delaunay triangulations do not include facets that are coplanar with the convex hull of the input sites. A facet is coplanar if the last coefficient of its normal is nearly zero (see qh_ZEROdelaunay).

See Imprecision issues :: Delaunay triangulations for a discussion of precision issues. Deleted vertices indicate highly degenerate input. They are listed in the summary output and option 'Fs'.

To compute the Delaunay triangulation of points on a sphere, compute their convex hull. If the sphere is the unit sphere at the origin, the facet normals are the Voronoi vertices of the input. The points may be restricted to a hemisphere. [S. Fortune]

The 3-d Delaunay triangulation of regular points on a half spiral (e.g., 'rbox 100 l | qdelaunay') has quadratic size, while the Delaunay triangulation of random 3-d points is approximately linear for reasonably sized point sets.

With the Qhull library, you can use qh_findbestfacet in poly2.c to locate the facet or adjacent facet that contains a point. First lift the point to the paraboloid (i.e., the last coordinate is the sum of the squares of the point's coordinates -- qh_setdelaunay). Do not use options 'Qbb', 'QbB', 'Qbk:n', or 'QBk:n' since these scale the last coordinate. See locate a facet with qh_findbestfacet()

If a point is interior to the convex hull of the input set, it is interior to the adjacent vertices of the Delaunay triangulation. This is demonstrated by the following pipe for point 0:

    qdelaunay <data s FQ QV0 p | qconvex s Qb3:0B3:0 p

The first call to qdelaunay returns the neighboring points of point 0 in the Delaunay triangulation. The second call to qconvex returns the vertices of the convex hull of these points (after dropping the lifted coordinate). If point 0 is interior to the original point set, it is interior to the reduced point set.

»qdelaunay conventions

The following terminology is used for Delaunay triangulations in Qhull for dimension d. The underlying structure is the lower facets of a convex hull in dimension d+1. For further information, see data structures and convex hull conventions.

  • input site - a point in the input (one dimension lower than a point on the convex hull)
  • point - a point has d+1 coordinates. The last coordinate is the sum of the squares of the input site's coordinates
  • coplanar point - a coincident input site or a deleted vertex. Deleted vertices indicate highly degenerate input.
  • vertex - a point on the paraboloid. It corresponds to a unique input site.
  • point-at-infinity - a point added above the paraboloid by option 'Qz'
  • lower facet - a facet corresponding to a Delaunay region. The last coefficient of its normal is clearly negative.
  • upper facet - a facet corresponding to a furthest-site Delaunay region. The last coefficient of its normal is clearly positive.
  • Delaunay region - a lower facet projected to the input sites
  • upper Delaunay region - an upper facet projected to the input sites
  • non-simplicial facet - more than d input sites are cocircular or cospherical
  • good facet - a Delaunay region with optional restrictions by 'QVn', etc.

»qdelaunay options

qdelaunay -- compute the Delaunay triangulation
    http://www.qhull.org

input (stdin):
    first lines: dimension and number of points (or vice-versa).
    other lines: point coordinates, best if one point per line
    comments:    start with a non-numeric character

options:
    QJ   - joggled input instead of merged facets
    Qt   - triangulated output
    Qu   - compute furthest-site Delaunay triangulation

Qhull control options:
    Qa   - allow input with fewer or more points than coordinates
    QJn  - randomly joggle input in range [-n,n]
    QRn  - random rotation (n=seed, n=0 time, n=-1 time/no rotate)
    Qs   - search all points for the initial simplex
    Qz   - add point-at-infinity to Delaunay triangulation

Qhull extra options:
    QGn  - print Delaunay region if visible from point n, -n if not
    QVn  - print Delaunay regions that include point n, -n if not
    Qw   - allow option warnings
    Q12  - allow wide facets and wide dupridge
    Q14  - merge pinched vertices that create a dupridge

T options:
    TFn  - report summary when n or more facets created
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes
    Ts   - statistics
    Tv   - verify result: structure, convexity, and in-circle test
    Tz   - send all output to stdout

Trace options:
    T4   - trace at level n, 4=all, 5=mem/gauss, -1= events
    Ta   - annotate output with message codes
    TAn  - stop qhull after adding n vertices
     TCn - stop qhull after building cone for point n
     TVn - stop qhull after adding point n, -n for before
    Tc   - check frequently during execution
    Tf   - flush each qh_fprintf for debugging segfaults
    TPn  - turn on tracing when point n added to hull
     TMn - turn on tracing at merge n
     TWn - trace merge facets when width > n

Precision options:
    Cn   - radius of centrum (roundoff added).  Merge facets if non-convex
     An  - cosine of maximum angle.  Merge facets if cosine > n or non-convex
           C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge
    Rn   - randomly perturb computations by a factor of [1-n,1+n]
    Wn   - min facet width for outside point (before roundoff)

Output formats (may be combined; if none, produces a summary to stdout):
    f    - facet dump
    G    - Geomview output (see below)
    i    - vertices incident to each Delaunay region
    m    - Mathematica output (2-d only, lifted to a paraboloid)
    o    - OFF format (dim, points, and facets as a paraboloid)
    p    - point coordinates (lifted to a paraboloid)
    s    - summary (stderr)

More formats:
    Fa   - area for each Delaunay region
    FA   - compute total area for option 's'
    Fc   - count plus coincident points for each Delaunay region
    Fd   - use cdd format for input (homogeneous with offset first)
    FD   - use cdd format for numeric output (offset first)
    FF   - facet dump without ridges
    FI   - ID of each Delaunay region
    Fm   - merge count for each Delaunay region (511 max)
    FM   - Maple output (2-d only, lifted to a paraboloid)
    Fn   - count plus neighboring region for each Delaunay region
    FN   - count plus neighboring region for each point
    FO   - options and precision constants
    FP   - nearest point and distance for each coincident point
    FQ   - command used for qdelaunay
    Fs   - summary: #int (8), dimension, #points, tot vertices, tot facets,
                    output: #vertices, #Delaunay regions,
                                #coincident points, #non-simplicial regions
                    #real (2), max outer plane, min vertex
    FS   - sizes:   #int (0)
                    #real (2), tot area, 0
    Fv   - count plus vertices for each Delaunay region
    Fx   - extreme points of Delaunay triangulation (on convex hull)

Geomview output (2-d and 3-d points lifted to a paraboloid)
    Ga   - all points as dots
     Gp  -  coplanar points and vertices as radii
     Gv  -  vertices as spheres
    Gc   - centrums
    GDn  - drop dimension n in 3-d and 4-d output
    Gh   - hyperplane intersections
    Gi   - inner planes only
     Gn  -  no planes
     Go  -  outer planes only
    Gr   - ridges
    Gt   - transparent outer ridges to view 3-d Delaunay

Print options:
    PAn  - keep n largest Delaunay regions by area
    Pdk:n - drop facet if normal[k] <= n (default 0.0)
    PDk:n - drop facet if normal[k] >= n
    PFn  - keep Delaunay regions whose area is at least n
    Pg   - print good Delaunay regions (needs 'QGn' or 'QVn')
    PG   - print neighbors of good regions (needs 'QGn' or 'QVn')
    PMn  - keep n Delaunay regions with most merges
    Po   - force output.  If error, output neighborhood of facet
    Pp   - do not report precision problems

    .    - list of all options
    -    - one line descriptions of all options
    -?   - help with examples
    -V   - version

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/normal_voronoi_knauss_oesterle.jpg0000644000176200001440000005656413431000556025256 0ustar liggesusersÿØÿàJFIFÿþ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 80 ÿÛC   %# , #&')*)-0-(0%()(ÿÛC   (((((((((((((((((((((((((((((((((((((((((((((((((((ÿÀ8 "ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?Í9ÉäÒdúšyšLVä Éõ4dúšv(Å7'ÔÑÏ©§b´ÜŸSFO©§b´Þ}MúšvÚ1@ Éõ4dúšvÚ1@ çÔÒóêiqFÚnO©£'ÔӶѶ€sêhçÔÓ±FÚo>¦Ž}M;mh¼úš2}M;m óêhçÔÕí2ÀßNêÒÇ1FÒË4Ÿv4QÉ? ú‘U¦…¡•ã|nSƒŠ@E“êhçÔӶѶ˜ çÔÒóêiqFÚnO©£ŸSNÛ@Þ}M9êiÛhÅ7ŸSFO©§bŒPr}MúšvÚ1@ Éõ4¼úš\QŠN}M&O©§m£m'>¦“ŸSNÅ äúš2}M;mh¹>¦Ž}M;b€Î:š^}M.(Å7ŸSG>¦Š1@ Éõ4£9š]´ r(Ärh©äÒb ŧâ—ÈèÅIŠ1@\ŽŒSð=(Å3SñF(˜£üQŠe§âŒPE?b€EIIŠe§â—€¹(ÅIéFqúÜìƒkÑã÷ÚtKô$9>ê*ž•qöëŽnlþSêÑgÿÀOBµ©bŸlYtgé©Å,q{N^/Ì‚¿ð:ã,o$Óõ$ºŒÚ~d=Hù”ýA"£©GIEXž8ÁW‹Á*‰"cÝO¯¸äpj,U’2Š““ÆQOÅ.GŠ1OÅ QŠ~)p=(:)ø¥Àô ñE?b€Š*LJ0(Ð^Åm¾Ê)e‘‚7•€Xªàœ³÷…s>#Õ®Á†;Ÿ³BÜ­”B¤{íä©4Ô®:†Ó.rÊ"ŽURÞKÈ¢B$ü™Ï@O#µSÅexNém5ppLB šFÀ?»K{’´QLi,n²C ÊH½¨íM;‰¢,QŠ“bªÂ"Å©qF(°bŒT¸£X±F*]´b‹(ÅKŠ6Ñ`"Å.*LQŠ,X£&)qE€‹ r*M´äQ`%#šMµ1^M&Ú‹mj]´m ¶Ñ¶¥ÛFÚ‹m©vѶ€"ÛFÚ—mh-´m©vѶ€"Åj]´m ¶ÑŠ—mh-´m©HÅ:+­-ôk{·–hüÛ‰`ó±º0T)œÇ‘ž)7a؃m«R[²F²‚²@ÿrXÎäo¡ýºÔ[i(ÛRí£m#´u'sü7ÿ’Òדhí·Vµ÷Ìãú×­…ÀÔŸûšeÑÿÈ.?­xõ³yw–ïýÙýk)nËEÒ;WMáËØ¯mN¨¸TcºÞSÏ”ÿáØOp+Ÿ6Ï*ú1­0¬9v§¸Ž«L[½+Z*ð’cÊ\! )ŒõËtÆ0AéÐÖ½ÅóË3áÛÉ|Ñ7–Jþðþ§­eøõu³Ó’Wûe­œ-q㇑—yõ€LwË륎b&”[­ºÈbÞvnb[8éœÍ$ßAØÝ½X#•¦Öux<îé}¢Cì6ü£èXVtºöŸoņœ×ÿ=od8úˆÓüY…sx£ìö¿ª^Äa’飶=`€£?U\õ5»á:6©ø¾[‚­c`{ùŒ¿¼qþê}Z¹k+I¯o µ¶C$óȱƣø˜œùšêÔžLW’¯ýô¨¥2V[hIqó£úKáÖQá;ÒçÈß'¶QÇô¬›©Œò–è¿Â=?úôy¹¢CÕï¤ÿY;Gf‡Øí Eð*é¼'<);sºö$LöÂ9l~kù À¼ìºgÑž6½“ýéËÿŽ"ƺý D^¶ø¥»yÏÓþ€i¡2¶Ú6Ô»hÛZE¶µ:ÆÎÁUK1èɦ\4V¤‹©á‡U‘ÀoûçïÀP2=´mª“kZtyØó\Þ\{Tþ-‚?ï“Tfñ-¬¡ŒzÊÆF–ÑùƒJàm* ($žÂ–tÃý*H­ûâgOÐOá\¬ú¾£8!ï%U=V,D§êÔ:v›q¨LÉk;Fé$cµPy˜ð+…ކm[N‹…š[†ì!ˆãól~€ÔÏx– &ÔàŽÏ~fBÇ€ƒê ö¬¯¶Zhãn•‹›ßâ½uùPÿÓ5?úçÐ £§ØÝë:¤vðî–âfË;œã¹f>€rM&ØÎÊvK‹K È¢H–æ å;Uƒ23þ®ÜG¼6ö6d½µª”Wn®Äå›Û' íUöÕ-„E¶µ.Ú6ÓÚP¼Š“m(^EJW“I¶¦+Í&ÚE¶µ.Ú6Ð[hÛRí£mE¶µ.Ú6Ð[hÛRí£mE¶µ.Ú6Ð[hÛRí£mE¶µ.ÚÀ&€9Ÿßþ…`°Ì¬;O©þ_….œ>ÑàÍZß½¬ðÝ(ôtmÿ¡%gk,­ßª(P²‘íÇô­_$Ô`7ÝXÏHÃ;äUóªγ½ÕË·C+OÔ.ô»‰ÈóbûÃèÊx5ÑØë–¸[¥Ÿâh[ù•ýGÒ¼¨K ›ÎWa6woÏ9­ËØî”,€E7B?…¾ž”\L’ÚHöWûޤ2·ÐŽ E}«7ö|ï¢AgæØ;%È’+²îÀ”nÈÆx#që\ׇµK6þóZ4«çBÜ« óÁèqߨ¢áçð÷‰n~ÎÁžÞgŒ‡.H*ø# ÓnàEwâíd“¸·1ÊŒ³…USòœ È>•ËC¢ß07I¥ÜÿÏH3,ê„î_¨'ØWAâË(mÞÇSÓÃ2âQ´“ ½{ŽÞ£ŸZóûˆ¼›™£?ÀÅ#RÆŽÏRÒnOwm²îбs5¹Þï«ÿ›ám9uOiÖrq ³/š}#¹üƆê{ibžÒiaY^6*ÃåäWSá]íz“ÛÞÃiíÜÚÃ~Ëdy¨, sœŒóœÐ„sÚÞ±.£â[ýT5Äï(_öIà~X¦êíöÜ^)ÜB¬r/÷p0º~?QTn`’Úy`9£bŽÕHàƒO·­î$`7!fVCцOl;•è«76áZZ Qò>ã§ÿ®³#’æîá`³„™¶ŒòsÓð§p:¿ H4‹[ÍzFÖËäÚ“Þwÿ?•aY±™œáÎõ8=Û'¶hø®H¬Åž9H•Û4í˶;ã…ç¦ eØÃ<‘Í,l|Ç“ŒôÉÉéSæö*Ë¢kÇ÷#x\3.ñêfŸ§Ï¨L#·BFF÷è¨=Xô­ø Õ&}ZÖ6‚æG·ƒÉå ȧæ‘ÐdŸaÖº½^×BŽ4µx5;ö_”ù[líóÞ8ßoöŸò9¦€ÑÔtí:K¹5-JðÁ¥q¹ A–4TFÌçtÚ««§Ï¥­m…ž¢\Fòe䙓 FzäœÔž½k˵ Û­Féîoç’âwêòŸ§°ö®ÇQSeáM>3Ãß$oÿlÑr?6‘¿ïšb%›^±ˆ–{†ÿeB)üO#þùªøŠàñoo#±lÈÃóÂÿ㵊1T"ÅÎ¥}r¥g»™õEmˆà+úU5P£ ¤Å c1F*Õ•œ÷³ˆmbi$<àv¤öõ¦$²Ñ¿ÔywÚˆÿ–¤fû#øÏ¹ãëHm´¤‚»Ö$k{vŽ%½›ýÑØ´ Ô:Ž©%Ô"ÚÖÖÅNVÞ3Æ}Xõf÷?¥U¹š[©Þk‰Y\åÎI¨ñ@ DiQ³1ÀP2I¯BÓìW@°{U ê3ö§À:ˆöïïôªÓÆ—o£:í ×6‘‘þ©:ˆõ쿟aZ~§ÜЕÄô"ÛFÚ—mjÉ"ÛFÚ—mh-´¡y&ÚP¼Ð¤rhÅHW“FÚ`GŠLT»hÛ@bŒT»hÛ@â“.Ú6Ðx£&Ú6ÐX¥ÅI¶´(ÅI¶´)Q7º¯÷ˆ?m6Fò£y?çš—ü†¥'°Ñç—‘JÚ˜~ÐÇ0''æuæµ4Ɇ‘®øz{ø^%[£‡*AÆW#ÝHb?­rºœ2\kæÞ/#ùqªŽçbŠˆ[\iÀ}¦2m& ù‘ˑѕ‡â+/"ȵëÒõ»û5´ï>ÌER^‚A?Ï·ù÷®Óâ˯4’2ÿ¦A Ô2öËÆ í»w=«Ž’6™u8 õ˜H±Üe— =Çùô®·Äî'ÔÖàr.­¡ºVõÜ€?þ>ó®ŒóŒfºMJ诇ü3¨‘ žÂ^…X8Ïá)ü© ¹i©[Ù–²Õ¤ÒowpïFGÝ•ÚSùŒŽõÊøÃK—I×î ‘–Dp²Ç2}ÙQ†C¯±«º´‚X”m*ÈØaÔ}A­M<Ãâ-*Û@»eKÕRÚmÃ3'01þëqFúÐõ–Sû¸sòÇÒ”­•Î:ƒNòd„g£š&hÝ`«9zÓed‰q3ªÐ£êJéÃó«v^MíÍÌ2Ü ‹x yVÒÜV ɈëÁ=æ±în%òZY¤w–OÝ©c’ðüM?²µ¾¿i2¨eFùÁèPýìûmÍ;é<%ªÏ}yu CZrÚLÒ1¶=ÁwsÝËÉ$š«3´·œåŽXš·¡X½¯¿³mãvHÄÑ(9VFè ÔW6——.—pK€¶T*#õ¦€‰T³PK€zë¬Ç’iy:™f’K‹¦ q)Üä è vp;.Ú6Õ¥bH±F*]´m¦",Râ¤ÛFÚ‹ r*M´äP¸äÒb¤#“F(˜£üQŠf(Å?¸ ñF*LRb€ŠLT˜£)qRb“ÌRb¤Å b©êí³M¹oúfÃóZÓh¼»V¹¸xííW¬Ó8DÙ5‰q¨iÚÌ7:v—sö›¹"&"¸UvR`ÉÎNÒ ãÖ¦MlR]O<»²>·©ttÿE€ÿÓGùr>ŠþUÏ隥ޚX[Éû¦ûñ8Üõ§â{¡=”p+L³M)8ÿZ[OÑv×½sõš(ô}v[moÂ>¼>M´¡e³ N(û¶†Ðq‘Ž1ÍVñ/Št}<› €uSnÅWMµCi§ÂÃûË÷ä ÷5Ëj~/Ö5› ,îdK LþîÖÑDQ•î Ž[×'=é]Œô $Aá›Vö?ì»ÍFÒ1‹M)Vfµ9‘ÝÉbW€HÉqç×ú¥—%Ž;¹EŽ«òàžrs.IÛ!P¶I;€ÁÏ#«V©>…ªÃs§Ê`¸‰¹c’Hî×Òºm{I´ñ•γᘖ+Ô]÷–*0L±ê{áç·C¨Ʀ³ÛêRÙÞC$2Áò*È0Jއñ랇5ÒøoCžå…¼(|ù†d$ãbŽpIèRON;ñT¼?zë1xžÕ¦±‡Ù]ÁÄsÑ?¼ƒ©SÁí‚s]—Š’çKÝ£éÐÌÖò"I-Ú®Màa¹H#8ž~<Ó GWÓí¡¹ÓmyVeT¹Ô"`¯&Ñ€ªÿVdÇ&³¬.µ»xvhÚ«jÙ$ZH7¡…ò ÿwwÖ³^ÆíQ›ì³à ÿ«?áU£P†sµTr}ý½;ô/Þ®­m{g}§ÛÚMy°ù¶¨ÑÈ|µóHÚNÐ2ª0¬¨àT…dŠEš )"ô#úQIà}NâOø~+‹‰¤ŽG2Èåð® 㟭ex2äÛjöÖ·5²’äE¤ð*Ö©¢X'¼7³ùed7ÆCòþY¤äÒlv(ÅA§kQk?iYGh-™…rìÊÀòÄõ9Sеk'pjÃ1@Š~(šb$ÛÉ£ò94˜§`¶´üQŠn(Å;b€Š1NÅ b—ìQŠfÚ\S±F(° ÛXþ.ñ ørÂ×ìÐÄ÷·EÊ4©¸F«´dÇRzƒÒ·íÐ5ÄJà °?ZòŸˆ· úý­«±&ÚÍgûïûÆý_…DßB¢aêšö«qçêWs\Ê:;G öV’Úxç¶s±0taÙÈ?>^gÛÏrz=IíI-Ì00ŠÜ,ÎNF_p£úÔ Øñ1„Mk¬D i:Ê—žß§÷Ob Ü;a±Ó5ÌÞÚµ´ƒÑ?1J>ìƒÔéÔè´TŽí¯¼>v‹}UEÅn‘Ü®v¯¶ïš3õS\$k&ŸzÏ,Äa†L2tÈÇ+íêH΋À¿é6þ#ÓO?jÓ$u¯Ñ r¾[œIlÇón^ÕÕ|=K›OÛÉunEµ³rëþ­a,OM¥K~1\þ½¢ëÚoï§·Ÿì ߺ¹·­Øg‚2¿®h2i3{ ›,G·?á]„z£i_t9‹Ž8ìMÆîwn†3!?]Í\Þ™¦_kWŠº-œ—3?úÛd^ûc°ïý3C×ü-¡ÙkWz¿‰u5žàCio&Ĩ4IÀû¨ ÷¤3–Ðô¿øLµmÊÚID?iµF¿*à0RÌxÉ5v}#Ã^ÍñÇö¥ú ý‚ÊCå÷äêà8úÓ|SñPÔµâ‹Ë·Ò®&én¾_š ä¶9,}IÍpŽè59#–1»+g¿8ÿêï~#ë -œúqŽÂÆÎdxlí”$càצ9©|V‘é¾$¶ñ‹òi÷¶kŽˆÿÄŸð=;+Š `ŽEBJ’¥O¨9ÅwzM®xSðñ‡7ðFnì\ä#ý¥\€:(·Ä¿. NÎ5ºÄ)¨DGQ¼ÃþûßXšl1¸¸Ôn“u½ºí@ßòÒSÐ~Oÿ^·Îë_øg¥…þÛ¤^=›n £z1ÿd2°ükYž4Km.ÍÙ­†òßßcüGë×ñö¡¼“Å^;ùRê–q™ôægÎŒs-¾G9ºêEqþóBñóéÓ<3ÁpÛ û5vúu•®¼ZðõÌ:F­fÂæâÜ+ìG™b¬vœd®8ÆztäžêÐL‹,L¹êñ¶T{`Œ¯4;]O¨E摱ÈR‹÷W<äàŠê|u¡Ùß„ñFŸyfšuÃùW‹b ºÆ\"ÖûÃ8î;W?奼 ¤rº©É–P2Fy ×ý){×gþ 2â&ÂEw…‡÷C ʯxºØÙø«VHÁ¹W¸joèr\CáŠ=?O߸\ÊLyoECþÛOåW|uö{¿\_ÚÎ+ÿô˜Ô®Ö!ºõ#œ†ã­bí%¿†ð°û6£]î» 9úo ‘øýbd*pýu¥Â?… I-<ÉlîL#Í Yåq¹_ŸzϽ×ÞXl¢·Q7ñ"1o,ÿtNO¯P?:jVÐ-sTð¥‰GRx«I{ ÿ«Ì§ýžŸ™þ™¬K½YnïcŠÞÝYƒgi”Ô/ÓÔ`WSáMûZñäŸréÖß<î ô@}N?“ÚšacOÃ0OIªMM+’¶6Ì2ÇY\Ÿùfž¸ª„ý?k´±™/í žÕd)0%U—æàF> ×ž¿ØìÉóŸÎ˜uŽ GûÎx_Ö»(u+ÀÖÓGåÁ¨“öUBsobK†ë–'¯ñNö®o\ÚÇa™«ÝA`˜Î%9dÖï‹ì-òš5ƒ]Éÿ?g>ˆ:þf¸É¥Éq#M!9%Îyÿ?:^ãØ·ªêšŽ®âevó éùc_¢Ž?:¥Šu%m€Ùð{ìÕn"í-¹?аþŒÕÖí®#ÃòyZýƒvghü JÔŠî±U1¸£Šv)@欑ØäÑŠSE£Q@(ÅPŠ1EbŒQE¨o."²µ{‹†"1ÂÕÛû£üñRM,VÐ<÷,RêGV=”{šò-Å:Ž¥¨4ʱ%ºü±CõkéžçÔÔÊVÐiä'™îáH4ôË:¨-pN2qÓer"·ŠòO‡Q±¾Ñ] ˆŒ|Ç 9t dU/ j×3ø†Â9—jùÏË‘…ù#éYx–ëÃñÛA%¼7Ú]Ÿ7¶’$Þźö8# ØÖMÜ´ˆ¦•u,¾š kÍŨ9`?¿Ÿâ_åúÖ\kŒHÄ$`ä³tÿëÖ®½cŽ–zÿ†$žãJ¸lG3cu»÷ŠAëúëWCMVÆ-fîQ¤Ù¸>jH…³ŽI…G,¾Ý­+Etë¹­ŒVÀËs‰íÌ —Ï~ð'‚8íZ.Ò´t½ms\óšñáY¯4›B2³žÆB+`1rÄqTäñ/Ù#>·’Ö#ÃO!ßq/¯=EüI¬;è/–F¸ÓY‰F 6H¨Ç*Frnr Œè£ñ>‘â½SÃò$…m$·fkvîU9=þõcÙ[êÞÕdWÖNœPÿËÏúáרãi£ðªvÚl:¤–“ìKv‰·M|ÄÜò>éã¡ãž1Òµ<}g=ö‘áK¬ÅçMg$MûÅå–y8¿ («Öü`4mEXš(†¬¯s;E_-´3Œð;ƒë^u¯Ü&£©\\]ÝO³ÝÌ Š€ò°9Ú3Ç+oâ^—7Ø|2Û¡#LŽåÞ ™ãŽà‘‘\Ιi-ÿ•a$ðvÄá‰ù{©ã§_åR¸4纷qçÆÖ¨ªætlˆñœpy§_\éòÝMr’Z‘Ëq+äŸ`þu'ˆ¡:=¥¶™bë4F¯&xòO1©ÁÁÚc\×94bM’ò‘À¦ã^ÆÖαêRFTgýØ&ýô ]ÑîÓJû>½k%ÕÍÅ”«´³l*X}æëzu®VcY ÿ±£O7oÉÂåàýÌàgê§i RÒܯˆ¯ì´•K}+ÄyŸNû:„Û0ùÂ;‰®=z×›I Züs]éÈ"ÔW-sh¼ 1Õãþ«Û·:O \Ý%…Î’A:¾‡?ö€[ahdz(Ü=H…ã‹5Ò|w{-‹4Vr2êÏÇÉ  mÛ HlÂ+娈 $÷¿_Ê›ç3#>3" çÔdWDÃ-Áx¬õ—ͺÜŽUàÎg‘ßË›X~Õ!ë®AXÿà1õoÇj¡ Ö-¥¸×.ž@ûdŸ¼ öúÖ׆…Þ™ks$ý–ôO ˆC€êŠsc9ÀÊþuPj?ÚQ%µÜÞMÎ?s&v«û2Žzç.#ºÓï \#Ãv‡ tÛô=èÙ4}KD»³Z[+W/eu` %d•Heš,}Ö ÀàŒrFpxæäÔ4yðé–ÿÚÚ”’æõ1L>Xÿ‹p[¿j¹e`uI<dZ8V8_R¸]¤*)bìÿ÷Ìcq\óxºÏN¸¹“ÃP†Y&-%åéó¦~I;Wî§>€Ÿz@h;[ÖdmSÄwdµ`O|Ûqu#žŠ1W!Ô¼(ðå߮©{o1KÈÕ¶2%{à°æ¹{¯í »ƒ}ªßHc— ‹d”ÿ³‚x>üS¡º@’ D ß-¹ˆúöü)ˆõ/èKia©CáMjÛP¸º˜ ¼‹k %Z2 Éò=ÅrºÎ‚‰·ûBÙ´;’ÛD¬kG#²¿,¿†ÿ¸gý¡_Í}ãä$õíÏzí´_k¶j`º–;ô ƒow–vQÛpù€Çðç·JCDð–£>¡Q@‚ÝÙw‡‡ÉdIî+±Ô/ †Ê=EÞ,!Îç?zwîíõÇO@j¯»coá}GRÓôÕÓšgŽÖî%=K‚Ãp£…<©Írz¥ÍÔltdWPê¤R¤du?‰ªB5亵€îfaÕ# õsÀü3YwÚÔ’£E#Ö8²ªÞ?y¿ ÈyLolã ì>‚™T#¡ðv‘'‰Ó\uÆ¿¨ßjBþöîYnÁâF==€è°â½wGÐõ4Ï?”÷~²ÑÒO5'F‘ŒX@©ÊÅy˜Òíî.#|ÚãqRHÏ9#¡ú€~´ ­«Ý2\Ë ¤ ǘ#ÉÀÈúgúØMÊ£Ö0ÜÀ~}i43Íô{tÓ¨IzÖño³’5/:Xãh'ŒŠÉòð <öæN€4 îk­>0¿³GIt ÛÊ_ÊÊÒ Æc¹IàsÐõ¬ù>"ëÈÇÊ:dôK¶R?ñÊwb9ój6îÍÉc(ËóÚµìm§Ô,…ï—3ģɑ,pGÈxä}zzÔÖ¿]¹žþh­ vùŽ2=‡Sø çu/jI!†ÖÓû7ý§\ËŽçs?+Î5­dêWF¦i÷X±g•½O|z —1¤vÞ#ñ¾’êi¶“_*sºà˜âfþöÁó7°$}+Ô5Í[Z_&YØ[E¼ G÷Fâjœv±Çþ½Ô¿üóVÿ þj8dœ¬h¡?,pŒŒþMADöЩ;™$uRÇs@ÏSŒþŸejW™”–k“‘WåAôÿëb» + O7Ä7±iq8â"7ÎãÚ1ÈúœVøŠ )|Ÿi+“À¼D·ÝF6§à?!__5¢Ýk×0hšcr¿hYÇû™¹üéö:½•ƒ±ð†æMÞÕõ,~ïÝSrk õnšç^º—SÔ[“¶ûoÏä*+Æ»».™- _õpãb¨öAÏãŠm®¤Ú†®.×T¼¸ÔbùÌžc@Æè‡PSƒžàVá¿Ñõ©Ù|K<:f¶É„Õbä7΀mÏûkõ"¸|˜&O(&È Íò`çŒc-×é]v—cuâ o¡ºO+I€í7òü‚ßcÿÏð*[ŸªølézÊYO¢ÜÍs; <Ãʸøâòó¼¸ Þµï5{_ÆÐÇoa?‰söxÁŽÇÛyÉi? µeâx<'ac£Y½ö¡£\³nÔÞ\2–RÀ9òÈÏ òyÍpZþ„ú=âŸ4]Ú\6ÞíyY÷ö>£±£¨Vz¹Ô­$‡Q•çbLŽÎ²EÉ;Àa󯪞GQß•’iÌ¿j´·x&¢¸´”¨z€r? §1H²BÛNC/ÕŠñ^ÙÕ YíØï¹³Çüµ‹ÐúéÑì‰ÉÕt„6W“Åyb˜bù_2ÙÚNvúñÁ¬½*ÿWÑõK}NÇ\[°uhpÙö;}}êÆÉô˘55ÖêÍ›á8Üv8íßµ[ºðäÑÜýº vkGÄG'É´žÍœp¾ø¥`:ŸˆVú÷…ô_ÃÖR gVŽke_ø÷}ÌþXö&F+ì=«Í~ÇsËwg-»™~y¯Xðs‰ä“E¼·šúÒ}>YeB Ç$ˆ ŠwAÜ0Ç‘Šu,ôi*31ódÿÇÙ¿•qM½ÄðßÇ2O T@Š¥›;Áè9þël<#â´Ás—:]Ü)Ey±À %ÈOaõ«?ð–ëL«sâY@s¼Go•=Ð>¸®wYŠýµ äòI†W[µÞTô 9ΠŠ7„¼#¦ª×z”–·V‰æÅ¦Û\¤¯#‚1¸FÕûÄIÆ1Ö¹Ý [ÄW^"Õ®§K[Y~Ósr§_?,h¼HÀô=ª„—–7°\ƒsmå¸`Í!Î{0ãõ®¿â#Ý2XÛHÈÍjª÷«vcV.ØêOLÿ³@_ˆwW—kºe“$³7dŽf NNàÃæúõ©uIu‰îtÚÌ–’ :?1GQº?½œwåSœ?ïç#¾jü×—z»Íe¹¤E¨_]8‰.¡ýÔëþÓ0à€2NAÀ*î§¥|?Ðõ{.G×5k«yŒ$ÛÈ‘Äì:ã4=½¡x°]_½íõœ wdŸe†8ÔÆ²ÂÊG”9ÇÝ'‚?•Ë?E™¯VÃR’Í|¶·Ô®ÆÈ y€`ò=tRø›Ã6Ò=½„¬Ì6˜&{«™&±ºx'ŒUh~)_Ítñ¥¦¥«qö¶ˆY1жAÏ”®{ü=ñ ÓRæÞÅ.lÔdÍÄn¹'Óv}J¡‰¨é.Ók6—VýOŸ_0Ëž§>+^ëǾ'¶¾µmjåo¬Ëƒæ ˜æNãnvž;Wõ=sÖú¤É©èkm"«­Î Û"žC˜Xl'§ÝÙÏ­ Äÿñ0‹uÑ0[’»# ¸ è28÷Ï5 Æ—)·y­Hºˆq¾r½ŽåûÊ©÷®œxfêëO{Ï ê6ú¤lÞd®O‘,iÑw#ãß;I&‘¥ÞGË}=ì¶ì®mô茿09!äáPvêx¦#S^T‹âmâ}Ø4}#É Œí)gý «ŠÓ㜠KKn FľcÏGHù¾¼t®âæ ‹ÍWXÔõ‹­?N¸¹È•`?j†pv•_” 3Ï5ƒu¬hð¶ú†®Ãîý®_*ô?Æ‹\ ivZ¾¿lšØ–Qn‚K‰¾ÞˆÔå·)Rí÷‡ZÕÖ¼N5OßC«#ÙFdòàÜò00Œ¼ |ó\Γã uE²¾²²·Ñ®¢x&†ÚŒ…l îêHÏ|ÕÍkL–åf°„º®h¥òûiŒ«ö”~™W%m‡¹³©46ž|±ûÙOáÐ~"€9ÅŽ$ú éü1¥_ÚÜÉwqnÐÛI @d!I;”Œ)ç±üë{Oµ´Óú'Ìÿžóïø þ¥wi´ŒYRNM5Åq´wQÜU’;¹¤¥=M%QPÞÇ,°à—ÊfàÉ·qQÜ‘“øŠœñ>®]šÂÍñÚi·û#Þ¹øÿtŒìÛЃŒ~5¼Þº‰·ZÞZÜŽNÉ3©b?CUN‰ª‹„‰´§2?ÝÛàý$cô¬®]‚ßÄ:­º…Kë‰ §zÿãÙýIkwm{!‚}Êw”óöHÚþøÀ?•Y—LÓ´¨Ëk³°¸-,ä?ј«ùÖ6£â÷ío¥4:E¹á–Øy“8ÿjN¿–*t·«h°Š7Ô/.´Û‡#ý Ê’ÉÀ|¿R~µ¨Mu£Â!¤ÃÝóg9ã™*™ô®®m·òd’Br^v-“ë…¦Iw#Œ,Áû¨¥òµ+½2`ï>±xa ÿ3ï4‡õñ¨ÛS´ˆ[1FNÖ ì-þóqíÀ¦¬ÒÙÌî<Ÿ™O*ÿˆïïÔT­’O½°ËªÞ'ñ(ô?Ð÷ fv§yqk!H¡X[ø„ciüúŸÎ«ÙÛÝêWQ[XÃ-ÅÄØÛJK1#ÐWY¢xN]OMMG_¸HÑ”(Šú㆔q«ûÞý¥ÖaHê³Ñ\ñ «ÆØ1AÏ7¶Tã±5Bï ØMšf«j— Û–K™|”×dy=»µcëÝÞ£ª]ÞÈê²ÜÊÒ¨3–9ëŒÓmæ˜@ÒÞÊò 8E$‚ÇÓé@Gü%Ñ‹§Ãc£ù±[À±“Ï1ù¿3ô£Yšñ|%m<÷³5Ìú„¤LÒ|ácsã-úW/eln¥’öîLZ¡ùŸ¡f싞ÿÈ~·ñXÆ“á˜cv1½¬—XïûÉþH(³øA!Ô®ÞäšÝe$´›Ë#Âêsô;kÎ- ·iʓΕT²£.#ùœsÿUt¿nžˆöpἫ¸ä…³ë´‘ü«„’êx&Êùi"·PeH=© “,“4ŒKlùØÿŸZÑI£ñ›$s ŽúÄcwÅœ²àžÝ@ôÎ* íÚ|×1©Á‘Dq×ÐŒ‘ô#µgéwZj qlÛ)üÑø Ío¼Sa³h‡ím8SÇ?÷Î*+-ZãZÕuùå¯ Ü äaƒ#¦G_JÞÛèÞ×u»<,W°¥•ª±™2¯àãØŠâ¼?pmešá91ª¸÷ïÝ” …Þ?é¢,Ãÿ<2\É,öPžKoBèO¹ÎW¿¥.·Ú]Ì#æ6;¢÷Vä~•á—†¤ñ_‹ ÓŒ’Ggƒ=Üáöù0¯,Ùý>¦€=Â_gð_€î|PåáÕõ…{=,2«´QÿÃdvük€µˆÚÅ%ïŸÒ0ÄLi8f9ñýkSâˆÆ~/TÒäŠ-&ÍE­”œnß窔³ZÁ=´s@â+öd`AÆN2}Û9ü¨"ÞúDcxäÇ" ïÏ ý)fþ̸ÚdG²“ (<Èò}¾ðüÍ\mY“Mšò¤©ŽD ŽÞ[aà÷¬+ó傲+ᔌõÀض‹P³ŠD‰aÔ¬2ÅÞ>¥~òŸ|W[ek¥ÛøvÇSñÜÚjƒö%2ዃ’ £c§ë^o1X–u ²«`ölàô¯AñV áðÍÌ+w˜ZI<Æ;³œ‚=ròzÒ-Kâ>]l¬4{k[HÿÕ™G˜Š{ƒ øã5‰®ëšÞ© e¯§¯É$ ÛR3êãiê+2òÆÊâØµ¼ÒÃ"Dr®ì@À0* w¨ÚX&d2Ÿ-™¸;çéÔzS`;v6ZýÄXY.o!ùˆÎvÆÌWZ†ìÚ:G9¶"9X_[¸ ‚?,VÎ6‡w§­…ÉírÈ^O çr¯†^B®UÀéà š[ˆRH,ïbs8Ìv׸¶œýäbLoÿrO¥rwQCæÄöò»H"DÚGÄŽÕÝhW3ëš I ø‡C}«óMå“ÜŽ }GñW.›=¹oí "µUb0Næ$ÀUí#TmòÝ.)MÄldo¼ß€àøšÚ¿Ó Ô#‹Z³0ZXJGÚBÛKÝ@î­É\vÈíš»c­Cw*Ú[HnLkÿ‡g…8ê@îqVïbŠ-Gûn’ëAÖÔ,öasä¸ûÊ= Ÿ™OáØ×y¥ø[HÓb‰ØµèuFÙR2©¦®&rz~›{¨ËåÚ$Ó7,mêGOÄ×O§øBÖÛçÔçûÃm×ñjßk†ò„Q†Ò8†Õý**ÕG¹%㳈ŧÁª Aó«u5$’Iɤ¢©$„£Q@¨¢—¸ õ4”Òy4f€E3p¤ßï@oŠÞÒêîáKÃor™Æö諞Ù&¸í[Äú¥ú4Jºu‘9òm ÿyÏ'ô®®íôë­$Ú_ÜÜ[fmì#>`˜ü£’zÖ Ä¾ÓÆF©Ýz5ÔÂ5?M™²m7fZZ©†ÙâÜÛ¤ë×,Ì~ ×5~‚ù±`/QÏEòüåü×~Fºcâ¸àãNÑ4›FxŒ®?¥Wºñ–¹:í:Œ±'÷a0?ï)X vøqâ\+Ed¯ ËFqPûHü¨<c_ÑlxÎÏ<Êÿ÷ÊëMº½¸ºm×3Ë3zÈåëM[é’1™º!ÿ,äÓþù9¥a ¿`ðm€c6»©_“Ë% Œ7ýü<Ó-bab¶öXŒäzzV,ú½b†K(Ze6ëf)ú…Î?V|­z>Ô¯k¨E†e …—Øç£tèi ì[Á—í£´Ë­3Sw”ÈEµê €0>ö\×?á_Y‚nt{È#þòB\ßC#õªíذ{;5€)ŠÝN$°fùˆãóU­üS«Úö+Û‹`?ç“lÿëÓ%´’K¨ uu9fbËʨêHú]®›(°ø}­jò'•& ÃK¶û¨Né8ôÙøQµñ·‰†›n&¼Ó]8Ž(®bIrù‰Ü9É ~¶Ï‹´[ø‡õ°ºrA!hïì`Ve`y†L¼>aH9µ´Ú…äB±–`3¸z\ÒÁk&§pòH|›ÎÀ«^Ê=IôúŸZë|Oá RÈYÊZØé »×Q´mÖ¥z–±ÿdóÐW#«ê‹pÚ×rÙC÷œ³žîÞçôéLjË/îÔyv±ü°Ä‡;}ÉîOs]ÄHÔýŽÍF%Ó4ûP}v´j[òf™®.Ƶêð'ßžeŒc¹'ÖºÏÝ™þ)ê±¢4½ËY”A’È>N?,þŸî_¼< Ž ôÊ‘úæ«xçKKjPD…Z˜˜Û‚ᣞiCÃàÍÍi8—[ÿŸ„?êûûÞ¦ºÛÿЏÑt;ÍJÛKÖ`ž7G]NÕe"Tl8ÃŒ‚½é\,p Ó¸ìÍ,àž cŸÄv÷Å>7´@D Î%f¾€~µÚÿmx T´S¬xQÐf»LºUЕ<$œ$v=ª¼>ðÖ¡yš?Œìå€8imoà{iÂg¼cŽ˜<ÐÏý’ DðÜŠ±OuoöÜ“ÂÍ'Üç¦Õñ¯?Óâž8ïc–'ˆù{TFNáßó®›âMä’x†úúâØÅ0”ÇjŽ ðùι I&3Í+eÏ [;}ÿ::ÑÏ¥]jÚ„‘yJÐ3@Í,ª€Á\yêJôWѯ<ðÉ´ÛU„xÄ8{ÂfDh-Ý@IçwSõö48în¬%Ög)£h£PÔ½$‘þe>ø^=¯9ñ׊um{Ä—š½ü’Åö§&$VÊ*TŽ:PètÖдɮo"Ì’‚0¤0*?„‘ÉëŽÂ°c¼–æÞñ„‡ÏÝç§#¨ü¿•\ðö¡ý¡é•Ágmö“¹æ ñ“ýÖè ÏØloÊ\EäMo!IâdzcÓ¯Nž”X™%ºYd…9ÑfR¿+ ŽyyÏPjeÕä™;·KØW/PŒÉ´z,«‡_ÀS&‘¨ÝiPEkm$ïnïC;&r¬£©yÕ™#4r´6¢ Èß‘ãô¤2ák •+§Cqà`‘„ˆÞêÜýöéa’Æ5|)2î_¸À[¡³§èð[ ó¿'rüÀTz ­†Ÿ9,,äÞàq Ÿ,€zã†úÖ¼êa™ãlnF ‘ÐÓHMšzÌQ<–7D-Þˆêßø\}?—Ðøfib{ ÷‹‹mÏoÎr½Yî?ˆ{Šâ d`ò tÏ5ö›õ³‘«iEX·wˆ}Ö÷ÇCì}VÌ[vh¦Gsõ¤ö£l7%?盼Ÿý£ukrÑL”u-74f€@ëMÍ(<Š®[“I¿š›šij.…©¥ª"ôÆz˜¿­@ÑÆ3°'©C·?__ÆšÒTM%&¯¸Ê·Zm¼¤–Ž6> l?˜ãô¬›­FL2:{8Ü?1þ¶ÏïQ<žõ« îrsÙ]D yeÐuhÎáúU—ÙJÊNHù‡~ãñªW)ÙóQ$ÿ|dþ}ZVhg(Òš¦=ÍlÜé–ÏŸ-žÿ}¯ô?βn´Ë•$ÂRqÿLÏ?‘æ•ÂÅYd³²r’/ÞŒúoQUoN©w§Üi]ɶÔ ‰â‘%ˆcÉÉÛž¾œÓ£¶ž[‘ FVêÛ†6Ôšv«¤jz”Á¦é÷³Ú—vܪ@ ‰‰ÀîxíùÔ´·)W~/†pñO¦CsE¹È€}úb²€Òï$ÿK‹ensÁ•1[z€.f™až÷O[¢ ;Í×ä%µE>›áèX ­GP¼dã˶€B€w9•+Ü SX:@Èc†Ú5µ¶rŒÂ"F ¶SÎ=É®DÛØÉÔÙ²v@ÜþdW¤ê—3i¶qëö'íºÌKmui*dÂßóÎEèU¹!¸Ïl+“Ö4==¬XÐÜ6•+ìd”’ö²|·8?ðà0÷ ˆ¼]{á[›{-9a—L¸‚6– •ó"» òêÇLi­ h>5>oƒçþÉÖÏ/¢^Kû¹O"S×ýÆçÞ°u‹cyá½6åFé-­Ê`øSó§O«Â±¬“H²F ¹äƒ•ÁO·­nx?Iº°ø¥ÙjÖóZ½µâÉǵ¼¸È8 cRÐÓ8ãòNeUurÛ·‚sšÛºÔîïm?Óã‚{ô#eã¯ïHîçz`°'Þƒo/xßò¦dþã~TX.Ôîô]BYe ygt¦+ËYI)qê¿pzƒƒW®ôÙ¼)©Å©h,·þÔÁdã*ÉÕà˜Œ½s׀ó^7Àß•t½0ĦæÖKëU¼¹íU°UFG˜§¢¸äƒèx&“CLæõkÆÒ¦èq,zeʉÐJ¥ÁÏ HÆW‘Ð~µSûm¤³’;:Æo˜|‹Œ‘ßî‘è+¡»Ñt¿²McˆìeKk†ò%xä\!8!°¤s€x'½V³ðÍ¡‘¤msJ–8×{(iöÜvp3Þ€%Ñ¥¶Ã:¬ƒNHØî-!“pVÀm§Ów~¸ô«uœ^Ý«ë7>f³{km>áü³µ¿Ž~zËÆ}«_úcèÚv·â9®bº’=ðIÜ¿šŠ‹Ï¡9ƼÚöîëP»–æîy'¸•‹;¹É&…Ýç†õ«ú´Û©››½*ãÌŒ“ßË‘ù8ª·^°ÕWÃ^'ÒîJ «mzÆÎlÿÀþBIôjçôóqmq«´*°b„ 0ô>Ô“Û¯!€mˆ±(­ÔÀÐë^×ô^u]*êÚ3ÒVŒ˜ÛÜ8àþŸp'…á—–èÉ;#úÖ‡õŸi“¤õìm#B䬇ЧFüEuÞ§o41Ûj· °€´òivѪ.„…À/êWõÅ08­I’Îí_Pš+t™Ÿƒ½;uêkªÐ‡ÚígÐtë››=bÒO6ÈÈã:n ã©ÉÀèz}yõÒô‹™Ãâ8·ÿ/0ìĶP?÷„§9ücó¬Bo´ÏŠ˜Û Qž¥.ñÚèo ¸ÿ„#C€¼{æg¹;!~äyÏ^±XbÅÿŠ{uÿçù `TV#¨"·´©~×föÙÌ‹ó'ÔvüGPµŸöX—ïÝÇÿF?Ò§·6öî.'Þ ¤XÁ÷4:“[º\’M£ÞEº³e¿·aÔ2›ôÁü+ K˜'™ä‡1bB8Æ>±WôKçê–ÓÈ3í®FCÃ~„Ó¹|bi’âÝBÛÜ ž57Uÿ€¶åÿ€ÔJÔå ‚ÿMfÌšdÅã'«A!ý?öÐÔ ÔЙnZ9ãb®¤2°êï]üZš?‘âHÓtn¦¯÷'ò9õ¹¯:V­¿ ê˦_‘t¾e…ʘnc=¨ëšîo!6× pè@dqÑÔò}EF¦‹8^(¦Ñ¥6k$3ÙKÿ=íO8ëéÛ‘P«U¦Id5=Z««T€Ó`Pyjp<Š¬Ç“Q±§Ö£jc‰ªF¨ØPmPµLG DÕаV˜ËHeV-YaL+@Y*&J¶Â£eÍ+ ¦ÉQ:UÖŽ˜c¤dçµ@ÖþµÚ*‰á  cjòʱEwsµUFI5¹u—o.›§²½Üƒmݺ;ƧÓÔ÷úWAø"œ@vK"ìÿ×o¦}kœ¸ÐrcmÃõ¤Ð#•6À[ˆ”7n'×Ò¦Ò¤“L¾K˜H|e^7YŒ2°îÈ­9ìdˆœ¡â´|-gšãU¿@l´ð$e?òÒC÷ñ<Ÿ`jl;—á¾²ðu¼Z\¶hµÔ ›Rµ‘÷2Bßr0ØáÔa·cïb±¥{5Ôû¤šg.ÍŽ¤×Eá– a>‹¬¤ƒJœ™"” µ¤ØâEÁèËÜ{E†rU;O¸Ô®ÒÚÎ#$­Û ¹' ÔÕøôIÚeF’4BØ2à^™ý*ö¹/ج›LÑâ´q‰îXbK“ïýÕô_Ï&˜ŠwÚ…¶…–Z,‚k×./ÇaÝ"ô­Ôû åpêH`sšºm0~bM(µQü9¤2«Ç¬³„Ï#zŽÇÖ¬ÉäË4’”娷OSOòˆè(òý@¢Â¹fÃQ¹°™$µšUÚs´¶TûÒ»ëi´¿ijji0T—ìaDÐʰ<6ì{gœó^r#ôÍZ°¹žÆàKàŽ£=EkÞø[øå¾ð­ìå°Ëº[®Ëˆ‡}ðŸ˜}FG½r¶úuåÅêYÛÛÉ%ӶʼnGÌO¦+Ò¼@¾𾺿ñ+»¸ÔB¥ÇŸÛ@Ce6ò:úÕ˜¾$ÛÞê,ú¦˜-İ›s{jÁ®£øƒ°ù®y>¢˜/%¯`k{GŽëÄλf¸_™,Áê©êþ§µrv÷³Áz—‘LâåÌgæÝœç5Òx‹ÃX·öòǨé37ÎÒºãª?û'ðÍsRY·ð΄Kâ¨!ÕìÄÚtj‚gê¨ÿSpˆî¿_c‘ÜU+ˆóÀv±Ä Hš‰Uý¥ž*¿†ufÑ/Ýoa3é—Iä]ÃÙã>ž„u±Üi9Ò!dívQ] ëi”q+/)VÊ@þ7=Ï®¯l¤òè°\ÎKHãDUÃG¥hÅ!Ž•€Î0qÒ¡{|äÅk©µÏ\iQIÈ]§Ú²ît™cÉEÜ=«³ò}©µxY~òâ™å×qq§Ç0!Ð}GZʸЈɉ‰ö4¬9Ï.*´'²–Ã!…CŒi é>$Æe¿Ñîü·Òàr}þaý+6ù<⻟7Dð¬þ¶VÝcþ5ÎÚY4ì6Š,!<=¨ßè—ÖŠQ¶kiW|S/÷]O.Õ±ªéºuß•u§E5›I“-£üËÿa³’§Ðò=MOk§,77­ZûQËÔ.aÇ£ÂÎ ýkZ)fŠÆ;8äd·ŒåxÚzðzŠ˜¦;Rm§`1dÒa?püªÒil¿v4aì+¢(=) Q`9f³T?<~«@·‹Æ¿•tÍzŠ…ì¢~¨ÓŠ,?öXOü³ï±@zÆ+Yôïî9Æ¡{9ÓøCj¯aÙ]ÅsmòKnSèi’Ûï‘ÝRĸà}*\22}Å;4L¬©Õr=G4ä—5k4×E~ª3ë@ I+ªðn« rM¥êÃO¾Â³±Iü2/¸ ~B¹# q¿M,ñýå8õ€ömF9n-ÍÀúÙ…½è^…±òJ?ÙuÁÏøÖrµGàíy5?ιýäÖ‘y©žfµ<ïÿz3ó}7z ›P¶{ Ù-݃å\tu<†QV™,zµJ­ÈªˆÕ2E0¹`ŽM5–¥#“HE1Ȧ°â§e¦ ¦•«SJÒ¹ZiZ²V˜V€ )M+V ÓJÐrµ-Z)Ldö  ¥i¥jÑJB”ìB´›*ÖÊM´€¬c¤òêÉZB´ ¯³m©öR„  ÛhÙV‚RùtÂåM´†<Õ¿..\¥åŸJ<¢{Uß.”ÊFC«¾]&Êæ|–ªë†PG½d_è+*“Êݽ+§ÙI²•‚æn£¦5ׄü9 Éj× *†É²•â™ofF+P§µ0§µ ”ŒtÒ˜«…)Œ”ÂåFLÔ~_5q’£+E†A²›²¬m¤ÛE€ƒe O¶´¬}´ÍXÛK¶€¨Ð†#5^]>&þ§ÔVžÚ]´¬0¤ÓX«ÌUi-gª=¹®›`ô¤1Ú‹ÎS$0Á÷¥à×K%šH0ÊÔUIt˜ÛîeOµ+ÊZôºF« õ¯ßŒüËÙ׸5é”ðI¦iÿfBÖ¤µ›?v3É„ÿ¸OÄgšó‰t»ˆùŒîú×Ià‹öf—CÔÑ¢‚àî‚V,Rއ=ïõ=ñKaîj!©£<ŠˆÇ$2¼S!Y#b¬§±jDê*È5Jòx¦íúÑE0jB=PJŸJB§=(¢€©ô4݇Ҋ( JiCØQE4§µ4§µPJnÃéE›¥4Æ} Plö¤ÙíElö¥Ø}(¢€e.ßj( oµ¥P!vJO,ú( aô¤1ûQEgµ'—E€B‡Ò˜c4QLC qÒ˜Pú( cZ>:TMÏJ( òý©6CE B‡Ò“Ë>”Q@ÃèivŸJ( 'µ;gµPì>†”!ô¢ŠB'=)á=¨¢˜,~Õ*Ä3÷J(  =ªeŽ(¢€?ÿÙgeometry/vignettes/qhull/html/rbox.man0000644000176200001440000001044513431000556017656 0ustar liggesusers.\" This is the Unix manual page for rbox, written in nroff, the standard .\" manual formatter for Unix systems. To format it, type .\" .\" nroff -man rbox.man .\" .\" This will print a formatted copy to standard output. If you want .\" to ensure that the output is plain ascii, free of any control .\" characters that nroff uses for underlining etc, pipe the output .\" through "col -b": .\" .\" nroff -man rbox.man | col -b .\" .TH rbox 1 "August 10, 1998" "Geometry Center" .SH NAME rbox \- generate point distributions for qhull .SH SYNOPSIS Command "rbox" (w/o arguments) lists the options. .SH DESCRIPTION .PP rbox generates random or regular points according to the options given, and outputs the points to stdout. The points are generated in a cube, unless 's' or 'k' option is given. The format of the output is the following: first line contains the dimension and a comment, second line contains the number of points, and the following lines contain the points, one point per line. Points are represented by their coordinate values. .SH EXAMPLES .TP rbox 10 10 random points in the unit cube centered at the origin. .TP rbox 10 s D2 10 random points on a 2\[hy]d circle. .TP rbox 100 W0 100 random points on the surface of a cube. .TP rbox 1000 s D4 1000 random points on a 4\[hy]d sphere. .TP rbox c D5 O0.5 a 5\[hy]d hypercube with one corner at the origin. .TP rbox d D10 a 10\[hy]d diamond. .TP rbox x 1000 r W0 100 random points on the surface of a fixed simplex .TP rbox y D12 a 12\[hy]d simplex. .TP rbox l 10 10 random points along a spiral .TP rbox l 10 r 10 regular points along a spiral plus two end points .TP rbox 1000 L10000 D4 s 1000 random points on the surface of a narrow lens. .TP rbox c G2 d G3 a cube with coordinates +2/\-2 and a diamond with coordinates +3/\-3. .TP rbox 64 M3,4 z a rotated, {0,1,2,3} x {0,1,2,3} x {0,1,2,3} lattice (Mesh) of integer points. 'rbox 64 M1,0' is orthogonal. .TP rbox P0 P0 P0 P0 P0 5 copies of the origin in 3\-d. Try 'rbox P0 P0 P0 P0 P0 | qhull QJ'. .TP r 100 s Z1 G0.1 two cospherical 100\-gons plus another cospherical point. .TP 100 s Z1 a cone of points. .TP 100 s Z1e\-7 a narrow cone of points with many precision errors. .SH OPTIONS .TP n number of points .TP Dn dimension n\[hy]d (default 3\[hy]d) .TP Bn bounding box coordinates (default 0.5) .TP l spiral distribution, available only in 3\[hy]d .TP Ln lens distribution of radius n. May be used with 's', 'r', 'G', and 'W'. .TP Mn,m,r lattice (Mesh) rotated by {[n,\-m,0], [m,n,0], [0,0,r], ...}. Use 'Mm,n' for a rigid rotation with r = sqrt(n^2+m^2). 'M1,0' is an orthogonal lattice. For example, '27 M1,0' is {0,1,2} x {0,1,2} x {0,1,2}. '27 M3,4 z' is a rotated integer lattice. .TP s cospherical points randomly generated in a cube and projected to the unit sphere .TP x simplicial distribution. It is fixed for option 'r'. May be used with 'W'. .TP y simplicial distribution plus a simplex. Both 'x' and 'y' generate the same points. .TP Wn restrict points to distance n of the surface of a sphere or a cube .TP c add a unit cube to the output .TP c Gm add a cube with all combinations of +m and \-m to the output .TP d add a unit diamond to the output. .TP d Gm add a diamond made of 0, +m and \-m to the output .TP Cn,r,m add n nearly coincident points within radius r of m points .TP Pn,m,r add point [n,m,r] to the output first. Pad coordinates with 0.0. .TP n Remove the command line from the first line of output. .TP On offset the data by adding n to each coordinate. .TP t use time in seconds as the random number seed (default is command line). .TP tn set the random number seed to n. .TP z generate integer coordinates. Use 'Bn' to change the range. The default is 'B1e6' for six\[hy]digit coordinates. In R^4, seven\[hy]digit coordinates will overflow hyperplane normalization. .TP Zn s restrict points to a disk about the z+ axis and the sphere (default Z1.0). Includes the opposite pole. 'Z1e\-6' generates degenerate points under single precision. .TP Zn Gm s same as Zn with an empty center (default G0.5). .TP r s D2 generate a regular polygon .TP r s Z1 G0.1 generate a regular cone .SH BUGS Some combinations of arguments generate odd results. Report bugs to qhull_bug@qhull.org, other correspondence to qhull@qhull.org .SH SEE ALSO qhull(1) .SH AUTHOR .nf C. Bradford Barber bradb@shore.net .fi geometry/vignettes/qhull/html/qvoron_f.html0000644000176200001440000004251114664417655020752 0ustar liggesusers qvoronoi Qu -- furthest-site Voronoi diagram Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options

[delaunay]qvoronoi Qu -- furthest-site Voronoi diagram

The furthest-site Voronoi diagram is the furthest-neighbor map for a set of points. Each region contains those points that are further from one input site than any other input site. See the survey article by Aurenhammer ['91] and the brief introduction by O'Rourke ['94]. The furthest-site Voronoi diagram is the dual of the furthest-site Delaunay triangulation.

Example: rbox 10 D2 | qvoronoi Qu s o TO result
Compute the 2-d, furthest-site Voronoi diagram of 10 random points. Write a summary to the console and the Voronoi regions and vertices to 'result'. The first vertex of the result indicates unbounded regions. Almost all regions are unbounded.
Example: rbox r y c G1 D2 | qvoronoi Qu s Fn TO result
Compute the 2-d furthest-site Voronoi diagram of a square and a small triangle. Write a summary to the console and the Voronoi vertices for each input site to 'result'. The origin is the only furthest-site Voronoi vertex. The negative indices indicate vertices-at-infinity.

Qhull computes the furthest-site Voronoi diagram via the furthest-site Delaunay triangulation. Each furthest-site Voronoi vertex is the circumcenter of an upper facet of the Delaunay triangulation. Each furthest-site Voronoi region corresponds to a vertex of the Delaunay triangulation (i.e., an input site).

See Qhull FAQ (local) - Delaunay and Voronoi diagram questions.

The 'qvonoroi' program is equivalent to 'qhull v Qbb'. It disables the following Qhull options: d n m v H U Qb QB Qc Qf Qg Qi Qm Qr Qv Qx TR E V Fa FA FC Fp FS Ft FV Gt Q0,etc.

Copyright © 1995-2020 C.B. Barber


»furthest-site qvoronoi synopsis

See qvoronoi synopsis. The same program is used for both constructions. Use option 'Qu' for furthest-site Voronoi diagrams.

»furthest-site qvoronoi input

The input data on stdin consists of:

  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qvoronoi Qu < data.txt), a pipe (e.g., rbox 10 | qvoronoi Qu), or the 'TI' option (e.g., qvoronoi TI data.txt Qu).

For example, this is a square containing four random points. Its furthest-site Voronoi diagram has on vertex and four unbounded, separating hyperplanes (i.e., the coordinate axes)

rbox c 4 D2 > data
2 RBOX c 4 D2
8
-0.4999921736307369 -0.3684622117955817
0.2556053225468894 -0.0413498678629751
0.0327672376602583 -0.2810408135699488
-0.452955383763607 0.17886471718444
  -0.5   -0.5
  -0.5    0.5
   0.5   -0.5
   0.5    0.5

qvoronoi Qu s Fo < data


Furthest-site Voronoi vertices by the convex hull of 8 points in 3-d:

  Number of Voronoi regions: 8
  Number of Voronoi vertices: 1
  Number of non-simplicial Voronoi vertices: 1

Statistics for: RBOX c 4 D2 | QVORONOI Qu s Fo

  Number of points processed: 8
  Number of hyperplanes created: 20
  Number of facets in hull: 11
  Number of distance tests for qhull: 34
  Number of merged facets: 1
  Number of distance tests for merging: 107
  CPU seconds to compute hull (after input):  0

4
5 4 5      0      1      0
5 4 6      1      0      0
5 5 7      1      0      0
5 6 7      0      1      0

» furthest-site qvoronoi outputs

These options control the output of furthest-site Voronoi diagrams.

 
furthest-site Voronoi vertices
p
print the coordinates of the furthest-site Voronoi vertices. The first line is the dimension. The second line is the number of vertices. Each remaining line is a furthest-site Voronoi vertex. The points-in-square example has one furthest-site Voronoi vertex at the origin.
Fn
list the neighboring furthest-site Voronoi vertices for each furthest-site Voronoi vertex. The first line is the number of Voronoi vertices. Each remaining line starts with the number of neighboring vertices. Negative indices (e.g., -1) indicate vertices outside of the Voronoi diagram. In the points-in-square example, the Voronoi vertex at the origin has four neighbors-at-infinity.
FN
list the furthest-site Voronoi vertices for each furthest-site Voronoi region. The first line is the number of Voronoi regions. Each remaining line starts with the number of Voronoi vertices. Negative indices (e.g., -1) indicate vertices outside of the Voronoi diagram. In the points-in-square example, all regions share the Voronoi vertex at the origin.
 
 
furthest-site Voronoi regions
o
print the furthest-site Voronoi regions in OFF format. The first line is the dimension. The second line is the number of vertices, the number of input sites, and "1". The third line represents the vertex-at-infinity. Its coordinates are "-10.101". The next lines are the coordinates of the furthest-site Voronoi vertices. Each remaining line starts with the number of Voronoi vertices in a Voronoi region. In 2-d, the vertices are listed in adjacency order (unoriented). In 3-d and higher, the vertices are listed in numeric order. In the points-in-square example, each unbounded region includes the Voronoi vertex at the origin. Lines consisting of 0 indicate interior input sites.
Fi
print separating hyperplanes for inner, bounded furthest-site Voronoi regions. The first number is the number of separating hyperplanes. Each remaining line starts with 3+dim. The next two numbers are adjacent input sites. The next dim numbers are the coefficients of the separating hyperplane. The last number is its offset. The are no bounded, separating hyperplanes for the points-in-square example.
Fo
print separating hyperplanes for outer, unbounded furthest-site Voronoi regions. The first number is the number of separating hyperplanes. Each remaining line starts with 3+dim. The next two numbers are adjacent input sites on the convex hull. The next dim numbers are the coefficients of the separating hyperplane. The last number is its offset. The points-in-square example has four unbounded, separating hyperplanes.
 
 
Input sites
Fv
list ridges of furthest-site Voronoi vertices for pairs of input sites. The first line is the number of ridges. Each remaining line starts with two plus the number of Voronoi vertices in the ridge. The next two numbers are two adjacent input sites. The remaining numbers list the Voronoi vertices. As with option 'o', a 0 indicates the vertex-at-infinity and an unbounded, separating hyperplane. The perpendicular bisector (separating hyperplane) of the input sites is a flat through these vertices. In the points-in-square example, the ridge for each edge of the square is unbounded.
 
 
General
s
print summary of the furthest-site Voronoi diagram. Use 'Fs' for numeric data.
i
list input sites for each furthest-site Delaunay region. Use option 'Pp' to avoid the warning. The first line is the number of regions. The remaining lines list the input sites for each region. The regions are oriented. In the points-in-square example, the square region has four input sites. In 3-d and higher, report cospherical sites by adding extra points.
G
Geomview output for 2-d furthest-site Voronoi diagrams.

» furthest-site qvoronoi controls

These options provide additional control:

Qu
must be used.
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
QVn
select furthest-site Voronoi vertices for input site n
Tv
verify result
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
TFn
report progress after constructing n facets
PDk:1
include upper and lower facets in the output. Set k to the last dimension (e.g., 'PD2:1' for 2-d inputs).
f
facet dump. Print the data structure for each facet (i.e., furthest-site Voronoi vertex).

» furthest-site qvoronoi graphics

In 2-d, Geomview output ('G') displays a furthest-site Voronoi diagram with extra edges to close the unbounded furthest-site Voronoi regions. All regions will be unbounded. Since the points-in-box example has only one furthest-site Voronoi vertex, the Geomview output is one point.

See the Delaunay and Voronoi examples for a 2-d example. Turn off normalization (on Geomview's 'obscure' menu) when comparing the furthest-site Voronoi diagram with the corresponding Voronoi diagram.

»furthest-site qvoronoi notes

See Voronoi notes.

»furthest-site qvoronoi conventions

The following terminology is used for furthest-site Voronoi diagrams in Qhull. The underlying structure is a furthest-site Delaunay triangulation from a convex hull in one higher dimension. Upper facets of the Delaunay triangulation correspond to vertices of the furthest-site Voronoi diagram. Vertices of the furthest-site Delaunay triangulation correspond to input sites. They also define regions of the furthest-site Voronoi diagram. All vertices are extreme points of the input sites. See qconvex conventions, furthest-site delaunay conventions, and Qhull's data structures.

  • input site - a point in the input (one dimension lower than a point on the convex hull)
  • point - a point has d+1 coordinates. The last coordinate is the sum of the squares of the input site's coordinates
  • vertex - a point on the upper facets of the paraboloid. It corresponds to a unique input site.
  • furthest-site Delaunay facet - an upper facet of the paraboloid. The last coefficient of its normal is clearly positive.
  • furthest-site Voronoi vertex - the circumcenter of a furthest-site Delaunay facet
  • furthest-site Voronoi region - the region of Euclidean space further from an input site than any other input site. Qhull lists the furthest-site Voronoi vertices that define each furthest-site Voronoi region.
  • furthest-site Voronoi diagram - the graph of the furthest-site Voronoi regions with the ridges (edges) between the regions.
  • infinity vertex - the Voronoi vertex for unbounded furthest-site Voronoi regions in 'o' output format. Its coordinates are -10.101.
  • good facet - an furthest-site Voronoi vertex with optional restrictions by 'QVn', etc.

»furthest-site qvoronoi options

See qvoronoi options. The same program is used for both constructions. Use option 'Qu' for furthest-site Voronoi diagrams.

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qhull.txt0000644000176200001440000014070013431000557020074 0ustar liggesusers qhull(1) qhull(1) NAME qhull - convex hull, Delaunay triangulation, Voronoi dia- gram, halfspace intersection about a point, hull volume, facet area SYNOPSIS qhull- compute convex hulls and related structures input (stdin): dimension, #points, point coordinates first comment (non-numeric) is listed in the summary halfspace: use dim plus one with offsets after coefficients options (qh-quick.htm): d - Delaunay triangulation by lifting points to a paraboloid v - Voronoi diagram via the Delaunay triangulation H1,1 - Halfspace intersection about [1,1,0,...] d Qu - Furthest-site Delaunay triangulation (upper convex hull) v Qu - Furthest-site Voronoi diagram QJ - Joggle the input to avoid precision problems . - concise list of all options - - one-line description of all options Output options (subset): FA - compute total area and volume Fx - extreme points (convex hull vertices) G - Geomview output (2-d, 3-d and 4-d) Fp - halfspace intersection coordinates m - Mathematica output (2-d and 3-d) n - normals with offsets o - OFF file format (if Voronoi, outputs regions) TO file- output results to file, may be enclosed in single quotes f - print all fields of all facets s - summary of results (default) Tv - verify result: structure, convexity, and point inclusion p - vertex coordinates i - vertices incident to each facet example: rbox 1000 s | qhull Tv s FA - html manual: index.htm - installation: README.txt - see also: COPYING.txt, REGISTER.txt, Changes.txt - WWW: - GIT: - mirror: - news: - Geomview: - news group: - FAQ: - email: qhull@qhull.org - bug reports: qhull_bug@qhull.org Geometry Center 2003/12/30 1 qhull(1) qhull(1) The sections are: - INTRODUCTION - DESCRIPTION, a description of Qhull - IMPRECISION, how Qhull handles imprecision - OPTIONS - Input and output options - Additional input/output formats - Precision options - Geomview options - Print options - Qhull options - Trace options - BUGS - E-MAIL - SEE ALSO - AUTHORS - ACKNOWLEGEMENTS This man page briefly describes all Qhull options. Please report any mismatches with Qhull's html manual (qh- man.htm). INTRODUCTION Qhull is a general dimension code for computing convex hulls, Delaunay triangulations, Voronoi diagram, furthest- site Voronoi diagram, furthest-site Delaunay triangula- tions, and halfspace intersections about a point. It implements the Quickhull algorithm for computing the con- vex hull. Qhull handles round-off errors from floating point arithmetic. It can approximate a convex hull. The program includes options for hull volume, facet area, partial hulls, input transformations, randomization, trac- ing, multiple output formats, and execution statistics. The program can be called from within your application. You can view the results in 2-d, 3-d and 4-d with Geomview. DESCRIPTION The format of input is the following: first line contains the dimension, second line contains the number of input points, and point coordinates follow. The dimension and number of points can be reversed. Comments and line breaks are ignored. A comment starts with a non-numeric character and continues to the end of line. The first comment is reported in summaries and statistics. Error reporting is better if there is one point per line. The default printout option is a short summary. There are many other output formats. Geometry Center 2003/12/30 2 qhull(1) qhull(1) Qhull implements the Quickhull algorithm for convex hull. This algorithm combines the 2-d Quickhull algorithm with the n-d beneath-beyond algorithm [c.f., Preparata & Shamos '85]. It is similar to the randomized algorithms of Clarkson and others [Clarkson et al. '93]. The main advantages of Quickhull are output sensitive performance, reduced space requirements, and automatic handling of pre- cision problems. The data structure produced by Qhull consists of vertices, ridges, and facets. A vertex is a point of the input set. A ridge is a set of d vertices and two neighboring facets. For example in 3-d, a ridge is an edge of the polyhedron. A facet is a set of ridges, a set of neighboring facets, a set of incident vertices, and a hyperplane equation. For simplicial facets, the ridges are defined by the vertices and neighboring facets. When Qhull merges two facets, it produces a non-simplicial facet. A non-simplicial facet has more than d neighbors and may share more than one ridge with a neighbor. IMPRECISION Since Qhull uses floating point arithmetic, roundoff error may occur for each calculation. This causes problems for most geometric algorithms. Qhull automatically sets option 'C-0' in 2-d, 3-d, and 4-d, or option 'Qx' in 5-d and higher. These options han- dle precision problems by merging facets. Alternatively, use option 'QJ' to joggle the input. With 'C-0', Qhull merges non-convex facets while con- structing the hull. The remaining facets are clearly con- vex. With 'Qx', Qhull merges coplanar horizon facets, flipped facets, concave facets and duplicated ridges. It merges coplanar facets after constructing the hull. With 'Qx', coplanar points may be missed, but it appears to be unlikely. To guarantee triangular output, joggle the input with option 'QJ'. Facet merging will not occur. OPTIONS To get a list of the most important options, execute 'qhull' by itself. To get a complete list of options, execute 'qhull -'. To get a complete, concise list of options, execute 'qhull .'. Options can be in any order. Capitalized options take an argument (except 'PG' and 'F' options). Single letters are used for output formats and precision constants. The other options are grouped into menus for other output for- mats ('F'), Geomview output ('G'), printing ('P'), Qhull Geometry Center 2003/12/30 3 qhull(1) qhull(1) control ('Q'), and tracing ('T'). Main options: default Compute the convex hull of the input points. Report a summary of the result. d Compute the Delaunay triangulation by lifting the input points to a paraboloid. The 'o' option prints the input points and facets. The 'QJ' option guarantees triangular output. The 'Ft' option prints a triangulation. It adds points (the centrums) to non-simplicial facets. v Compute the Voronoi diagram from the Delaunay tri- angulation. The 'p' option prints the Voronoi ver- tices. The 'o' option prints the Voronoi vertices and the vertices in each Voronoi region. It lists regions in site id order. The 'Fv' option prints each ridge of the Voronoi diagram. The first or zero'th vertex indicates the infinity vertex. Its coordinates are qh_INFINITE (-10.101). It indi- cates unbounded Voronoi regions or degenerate Delaunay triangles. Hn,n,... Compute halfspace intersection about [n,n,0,...]. The input is a set of halfspaces defined in the same format as 'n', 'Fo', and 'Fi'. Use 'Fp' to print the intersection points. Use 'Fv' to list the intersection points for each halfspace. The other output formats display the dual convex hull. The point [n,n,n,...] is a feasible point for the halfspaces, i.e., a point that is inside all of the halfspaces (Hx+b <= 0). The default coordinate value is 0. The input may start with a feasible point. If so, use 'H' by itself. The input starts with a feasi- ble point when the first number is the dimension, the second number is "1", and the coordinates com- plete a line. The 'FV' option produces a feasible point for a convex hull. d Qu Compute the furthest-site Delaunay triangulation from the upper convex hull. The 'o' option prints the input points and facets. The 'QJ' option guar- antees triangular otuput. You can also use facets. v Qu Compute the furthest-site Voronoi diagram. The 'p' option prints the Voronoi vertices. The 'o' option prints the Voronoi vertices and the vertices in Geometry Center 2003/12/30 4 qhull(1) qhull(1) each Voronoi region. The 'Fv' option prints each ridge of the Voronoi diagram. The first or zero'th vertex indicates the infinity vertex at infinity. Its coordinates are qh_INFINITE (-10.101). It indicates unbounded Voronoi regions and degenerate Delaunay triangles. Qt Triangulated output. Input/Output options: f Print out all facets and all fields of each facet. G Output the hull in Geomview format. For imprecise hulls, Geomview displays the inner and outer hull. Geomview can also display points, ridges, vertices, coplanar points, and facet intersections. See below for a list of options. For Delaunay triangulations, 'G' displays the cor- responding paraboloid. For halfspace intersection, 'G' displays the dual polytope. i Output the incident vertices for each facet. Qhull prints the number of facets followed by the ver- tices of each facet. One facet is printed per line. The numbers are the 0-relative indices of the corresponding input points. The facets are oriented. In 4-d and higher, Qhull triangulates non-simpli- cial facets. Each apex (the first vertex) is a created point that corresponds to the facet's cen- trum. Its index is greater than the indices of the input points. Each base corresponds to a simpli- cial ridge between two facets. To print the ver- tices without triangulation, use option 'Fv'. m Output the hull in Mathematica format. Qhull writes a Mathematica file for 2-d and 3-d convex hulls and for 2-d Delaunay triangulations. Qhull produces a list of objects that you can assign to a variable in Mathematica, for example: "list= << ". If the object is 2-d, it can be visualized by "Show[Graphics[list]] ". For 3-d objects the command is "Show[Graphics3D[list]]". n Output the normal equation for each facet. Qhull prints the dimension (plus one), the number of facets, and the normals for each facet. The facet's offset follows its normal coefficients. o Output the facets in OFF file format. Qhull prints the dimension, number of points, number of facets, and number of ridges. Then it prints the Geometry Center 2003/12/30 5 qhull(1) qhull(1) coordinates of the input points and the vertices for each facet. Each facet is on a separate line. The first number is the number of vertices. The remainder are the indices of the corresponding points. The vertices are oriented in 2-d, 3-d, and in simplicial facets. For 2-d Voronoi diagrams, the vertices are sorted by adjacency, but not oriented. In 3-d and higher, the Voronoi vertices are sorted by index. See the 'v' option for more information. p Output the coordinates of each vertex point. Qhull prints the dimension, the number of points, and the coordinates for each vertex. With the 'Gc' and 'Gi' options, it also prints coplanar and interior points. For Voronoi diagrams, it prints the coor- dinates of each Voronoi vertex. s Print a summary to stderr. If no output options are specified at all, a summary goes to stdout. The summary lists the number of input points, the dimension, the number of vertices in the convex hull, the number of facets in the convex hull, the number of good facets (if 'Pg'), and statistics. The last two statistics (if needed) measure the maximum distance from a point or vertex to a facet. The number in parenthesis (e.g., 2.1x) is the ratio between the maximum distance and the worst-case distance due to merging two simplicial facets. Precision options An Maximum angle given as a cosine. If the angle between a pair of facet normals is greater than n, Qhull merges one of the facets into a neighbor. If 'n' is negative, Qhull tests angles after adding each point to the hull (pre-merging). If 'n' is posi- tive, Qhull tests angles after constructing the hull (post-merging). Both pre- and post-merging can be defined. Option 'C0' or 'C-0' is set if the corresponding 'Cn' or 'C-n' is not set. If 'Qx' is set, then 'A- n' and 'C-n' are checked after the hull is con- structed and before 'An' and 'Cn' are checked. Cn Centrum radius. If a centrum is less than n below a neighboring facet, Qhull merges one of the facets. If 'n' is negative or '-0', Qhull tests and merges facets after adding each point to the hull. This is called "pre-merging". If 'n' is Geometry Center 2003/12/30 6 qhull(1) qhull(1) positive, Qhull tests for convexity after con- structing the hull ("post-merging"). Both pre- and post-merging can be defined. For 5-d and higher, 'Qx' should be used instead of 'C-n'. Otherwise, most or all facets may be merged together. En Maximum roundoff error for distance computations. Rn Randomly perturb distance computations up to +/- n * max_coord. This option perturbs every distance, hyperplane, and angle computation. To use time as the random number seed, use option 'QR-1'. Vn Minimum distance for a facet to be visible. A facet is visible if the distance from the point to the facet is greater than 'Vn'. Without merging, the default value for 'Vn' is the round-off error ('En'). With merging, the default value is the pre-merge centrum ('C-n') in 2-d or 3--d, or three times that in other dimensions. If the outside width is specified ('Wn'), the maximum, default value for 'Vn' is 'Wn'. Un Maximum distance below a facet for a point to be coplanar to the facet. The default value is 'Vn'. Wn Minimum outside width of the hull. Points are added to the convex hull only if they are clearly outside of a facet. A point is outside of a facet if its distance to the facet is greater than 'Wn'. The normal value for 'Wn' is 'En'. If the user specifies pre-merging and does not set 'Wn', than 'Wn' is set to the premerge 'Cn' and maxco- ord*(1-An). Additional input/output formats Fa Print area for each facet. For Delaunay triangula- tions, the area is the area of the triangle. For Voronoi diagrams, the area is the area of the dual facet. Use 'PAn' for printing the n largest facets, and option 'PFn' for printing facets larger than 'n'. The area for non-simplicial facets is the sum of the areas for each ridge to the centrum. Vertices far below the facet's hyperplane are ignored. The reported area may be significantly less than the actual area. Geometry Center 2003/12/30 7 qhull(1) qhull(1) FA Compute the total area and volume for option 's'. It is an approximation for non-simplicial facets (see 'Fa'). Fc Print coplanar points for each facet. The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of coplanar points followed by the point ids. Option 'Qi' includes the interior points. Each coplanar point (interior point) is assigned to the facet it is furthest above (resp., least below). FC Print centrums for each facet. The output starts with the dimension followed by the number of facets. Then each facet centrum is printed, one per line. Fd Read input in cdd format with homogeneous points. The input starts with comments. The first comment is reported in the summary. Data starts after a "begin" line. The next line is the number of points followed by the dimension+1 and "real" or "integer". Then the points are listed with a leading "1" or "1.0". The data ends with an "end" line. For halfspaces ('Fd Hn,n,...'), the input format is the same. Each halfspace starts with its offset. The sign of the offset is the opposite of Qhull's convention. FD Print normals ('n', 'Fo', 'Fi') or points ('p') in cdd format. The first line is the command line that invoked Qhull. Data starts with a "begin" line. The next line is the number of normals or points followed by the dimension+1 and "real". Then the normals or points are listed with the offset before the coefficients. The offset for points is 1.0. The offset for normals has the opposite sign. The data ends with an "end" line. FF Print facets (as in 'f') without printing the ridges. Fi Print inner planes for each facet. The inner plane is below all vertices. Fi Print separating hyperplanes for bounded, inner regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the num- ber of indices and floats. The first pair lists adjacent input sites, the next d floats are the normalized coefficients for the hyperplane, and the Geometry Center 2003/12/30 8 qhull(1) qhull(1) last float is the offset. The hyperplane is ori- ented toward verify that the hyperplanes are per- pendicular bisectors. Use 'Fo' for unbounded regions, and 'Fv' for the corresponding Voronoi vertices. FI Print facet identifiers. Fm Print number of merges for each facet. At most 511 merges are reported for a facet. See 'PMn' for printing the facets with the most merges. FM Output the hull in Maple format. See 'm' Fn Print neighbors for each facet. The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of neighbors followed by an index for each neighbor. The indices match the other facet output formats. A negative index indicates an unprinted facet due to printing only good facets ('Pg'). It is the negation of the facet's id (option 'FI'). For example, negative indices are used for facets "at infinity" in the Delaunay triangulation. FN Print vertex neighbors or coplanar facet for each point. The first line is the number of points. Then each point is printed, one per line. If the point is coplanar, the line is "1" followed by the facet's id. If the point is not a selected vertex, the line is "0". Otherwise, each line is the num- ber of neighbors followed by the corresponding facet indices (see 'Fn'). Fo Print outer planes for each facet in the same for- mat as 'n'. The outer plane is above all points. Fo Print separating hyperplanes for unbounded, outer regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the num- ber of indices and floats. The first pair lists adjacent input sites, the next d floats are the normalized coefficients for the hyperplane, and the last float is the offset. The hyperplane is ori- ented toward verify that the hyperplanes are per- pendicular bisectors. Use 'Fi' for bounded regions, and 'Fv' for the corresponding Voronoi vertices. FO List all options to stderr, including the default values. Additional 'FO's are printed to stdout. Fp Print points for halfspace intersections (option 'Hn,n,...'). Each intersection corresponds to a Geometry Center 2003/12/30 9 qhull(1) qhull(1) facet of the dual polytope. The "infinity" point [-10.101,-10.101,...] indicates an unbounded intersection. FP For each coplanar point ('Qc') print the point id of the nearest vertex, the point id, the facet id, and the distance. FQ Print command used for qhull and input. Fs Print a summary. The first line consists of the number of integers ("7"), followed by the dimen- sion, the number of points, the number of vertices, the number of facets, the number of vertices selected for output, the number of facets selected for output, the number of coplanar points selected for output. The second line consists of the number of reals ("2"), followed by the maxmimum offset to an outer plane and and minimum offset to an inner plane. Roundoff is included. Later versions of Qhull may produce additional integers or reals. FS Print the size of the hull. The first line con- sists of the number of integers ("0"). The second line consists of the number of reals ("2"), fol- lowed by the total facet area, and the total vol- ume. Later versions of Qhull may produce addi- tional integers or reals. The total volume measures the volume of the inter- section of the halfspaces defined by each facet. Both area and volume are approximations for non- simplicial facets. See option 'Fa'. Ft Print a triangulation with added points for non- simplicial facets. The first line is the dimension and the second line is the number of points and the number of facets. The points follow, one per line, then the facets follow as a list of point indices. With option points include the point-at-infinity. Fv Print vertices for each facet. The first line is the number of facets. Then each facet is printed, one per line. Each line is the number of vertices followed by the corresponding point ids. Vertices are listed in the order they were added to the hull (the last one is first). Fv Print all ridges of a Voronoi diagram. The first line is the number of ridges. Then each ridge is printed, one per line. A line starts with the num- ber of indices. The first pair lists adjacent Geometry Center 2003/12/30 10 qhull(1) qhull(1) input sites, the remaining indices list Voronoi vertices. Vertex '0' indicates the vertex-at- infinity (i.e., an unbounded ray). In 3-d, the vertices are listed in order. See 'Fi' and 'Fo' for separating hyperplanes. FV Print average vertex. The average vertex is a fea- sible point for halfspace intersection. Fx List extreme points (vertices) of the convex hull. The first line is the number of points. The other lines give the indices of the corresponding points. The first point is '0'. In 2-d, the points occur in counter-clockwise order; otherwise they occur in input order. For Delaunay triangulations, 'Fx' lists the extreme points of the input sites. The points are unordered. Geomview options G Produce a file for viewing with Geomview. Without other options, Qhull displays edges in 2-d, outer planes in 3-d, and ridges in 4-d. A ridge can be explicit or implicit. An explicit ridge is a dim-1 dimensional simplex between two facets. In 4-d, the explicit ridges are triangles. When displaying a ridge in 4-d, Qhull projects the ridge's vertices to one of its facets' hyperplanes. Use 'Gh' to project ridges to the intersection of both hyper- planes. Ga Display all input points as dots. Gc Display the centrum for each facet in 3-d. The centrum is defined by a green radius sitting on a blue plane. The plane corresponds to the facet's hyperplane. The radius is defined by 'C-n' or 'Cn'. GDn Drop dimension n in 3-d or 4-d. The result is a 2-d or 3-d object. Gh Display hyperplane intersections in 3-d and 4-d. In 3-d, the intersection is a black line. It lies on two neighboring hyperplanes (c.f., the blue squares associated with centrums ('Gc')). In 4-d, the ridges are projected to the intersection of both hyperplanes. Gi Display inner planes in 2-d and 3-d. The inner plane of a facet is below all of its vertices. It is parallel to the facet's hyperplane. The inner plane's color is the opposite (1-r,1-g,1-b) of the Geometry Center 2003/12/30 11 qhull(1) qhull(1) outer plane. Its edges are determined by the ver- tices. Gn Do not display inner or outer planes. By default, Geomview displays the precise plane (no merging) or both inner and output planes (merging). Under merging, Geomview does not display the inner plane if the the difference between inner and outer is too small. Go Display outer planes in 2-d and 3-d. The outer plane of a facet is above all input points. It is parallel to the facet's hyperplane. Its color is determined by the facet's normal, and its edges are determined by the vertices. Gp Display coplanar points and vertices as radii. A radius defines a ball which corresponds to the imprecision of the point. The imprecision is the maximum of the roundoff error, the centrum radius, and maxcoord * (1-An). It is at least 1/20'th of the maximum coordinate, and ignores post-merging if pre-merging is done. Gr Display ridges in 3-d. A ridge connects the two vertices that are shared by neighboring facets. Ridges are always displayed in 4-d. Gt A 3-d Delaunay triangulation looks like a convex hull with interior facets. Option 'Gt' removes the outside ridges to reveal the outermost facets. It automatically sets options 'Gr' and 'GDn'. Gv Display vertices as spheres. The radius of the sphere corresponds to the imprecision of the data. See 'Gp' for determining the radius. Print options PAn Only the n largest facets are marked good for printing. Unless 'PG' is set, 'Pg' is automati- cally set. Pdk:n Drop facet from output if normal[k] <= n. The option 'Pdk' uses the default value of 0 for n. PDk:n Drop facet from output if normal[k] >= n. The option 'PDk' uses the default value of 0 for n. PFn Only facets with area at least 'n' are marked good for printing. Unless 'PG' is set, 'Pg' is automat- ically set. Geometry Center 2003/12/30 12 qhull(1) qhull(1) Pg Print only good facets. A good facet is either visible from a point (the 'QGn' option) or includes a point (the 'QVn' option). It also meets the requirements of 'Pdk' and 'PDk' options. Option 'Pg' is automatically set for options 'PAn' and 'PFn'. PG Print neighbors of good facets. PMn Only the n facets with the most merges are marked good for printing. Unless 'PG' is set, 'Pg' is automatically set. Po Force output despite precision problems. Verify ('Tv') does not check coplanar points. Flipped facets are reported and concave facets are counted. If 'Po' is used, points are not partitioned into flipped facets and a flipped facet is always visible to a point. Also, if an error occurs before the completion of Qhull and tracing is not active, 'Po' outputs a neighborhood of the erroneous facets (if any). Pp Do not report precision problems. Qhull control options Qbk:0Bk:0 Drop dimension k from the input points. This allows the user to take convex hulls of sub-dimen- sional objects. It happens before the Delaunay and Voronoi transformation. QbB Scale the input points to fit the unit cube. After scaling, the lower bound will be -0.5 and the upper bound +0.5 in all dimensions. For Delaunay and Voronoi diagrams, scaling happens after projection to the paraboloid. Under precise arithmetic, scal- ing does not change the topology of the convex hull. Qbb Scale the last coordinate to [0, m] where m is the maximum absolute value of the other coordinates. For Delaunay and Voronoi diagrams, scaling happens after projection to the paraboloid. It reduces roundoff error for inputs with integer coordinates. Under precise arithmetic, scaling does not change the topology of the convex hull. Qbk:n Scale the k'th coordinate of the input points. After scaling, the lower bound of the input points will be n. 'Qbk' scales to -0.5. Geometry Center 2003/12/30 13 qhull(1) qhull(1) QBk:n Scale the k'th coordinate of the input points. After scaling, the upper bound will be n. 'QBk' scales to +0.5. Qc Keep coplanar points with the nearest facet. Out- put formats 'p', 'f', 'Gp', 'Fc', 'FN', and 'FP' will print the points. Qf Partition points to the furthest outside facet. Qg Only build good facets. With the 'Qg' option, Qhull will only build those facets that it needs to determine the good facets in the output. See 'QGn', 'QVn', and 'PdD' for defining good facets, and 'Pg' and 'PG' for printing good facets and their neighbors. QGn A facet is good (see 'Qg' and 'Pg') if it is visi- ble from point n. If n < 0, a facet is good if it is not visible from point n. Point n is not added to the hull (unless 'TCn' or 'TPn'). With rbox, use the 'Pn,m,r' option to define your point; it will be point 0 (QG0). Qi Keep interior points with the nearest facet. Out- put formats 'p', 'f', 'Gp', 'FN', 'FP', and 'Fc' will print the points. QJn Joggle each input coordinate by adding a random number in [-n,n]. If a precision error occurs, then qhull increases n and tries again. It does not increase n beyond a certain value, and it stops after a certain number of attempts [see user.h]. Option 'QJ' selects a default value for n. The output will be simplicial. For Delaunay triangula- tions, 'QJn' sets 'Qbb' to scale the last coordi- nate (not if 'Qbk:n' or 'QBk:n' is set). 'QJn' is deprecated for Voronoi diagrams. See also 'Qt'. Qm Only process points that would otherwise increase max_outside. Other points are treated as coplanar or interior points. Qr Process random outside points instead of furthest ones. This makes Qhull equivalent to the random- ized incremental algorithms. CPU time is not reported since the randomization is inefficient. QRn Randomly rotate the input points. If n=0, use time as the random number seed. If n>0, use n as the random number seed. If n=-1, don't rotate but use time as the random number seed. For Delaunay tri- angulations ('d' and 'v'), rotate about the last axis. Geometry Center 2003/12/30 14 qhull(1) qhull(1) Qs Search all points for the initial simplex. Qt Triangulated output. Triangulate non-simplicial facets. 'Qt' is deprecated for Voronoi diagrams. See also 'QJn' Qv Test vertex neighbors for convexity after post- merging. To use the 'Qv' option, you also need to set a merge option (e.g., 'Qx' or 'C-0'). QVn A good facet (see 'Qg' and 'Pg') includes point n. If n<0, then a good facet does not include point n. The point is either in the initial simplex or it is the first point added to the hull. Option 'QVn' may not be used with merging. Qx Perform exact merges while building the hull. The "exact" merges are merging a point into a coplanar facet (defined by 'Vn', 'Un', and 'C-n'), merging concave facets, merging duplicate ridges, and merg- ing flipped facets. Coplanar merges and angle coplanar merges ('A-n') are not performed. Concav- ity testing is delayed until a merge occurs. After the hull is built, all coplanar merges are performed (defined by 'C-n' and 'A-n'), then post- merges are performed (defined by 'Cn' and 'An'). Qz Add a point "at infinity" that is above the paraboloid for Delaunay triangulations and Voronoi diagrams. This reduces precision problems and allows the triangulation of cospherical points. Qhull experiments and speedups Q0 Turn off pre-merging as a default option. With 'Q0'/'Qx' and without explicit pre-merge options, Qhull ignores precision issues while constructing the convex hull. This may lead to precision errors. If so, a descriptive warning is generated. Q1 With 'Q1', Qhull sorts merges by type (coplanar, angle coplanar, concave) instead of by angle. Q2 With 'Q2', Qhull merges all facets at once instead of using independent sets of merges and then retesting. Q3 With 'Q3', Qhull does not remove redundant ver- tices. Q4 With 'Q4', Qhull avoids merges of an old facet into a new facet. Q5 With 'Q5', Qhull does not correct outer planes at the end. The maximum outer plane is used instead. Geometry Center 2003/12/30 15 qhull(1) qhull(1) Q6 With 'Q6', Qhull does not pre-merge concave or coplanar facets. Q7 With 'Q7', Qhull processes facets in depth-first order instead of breadth-first order. Q8 With 'Q8' and merging, Qhull does not retain near- interior points for adjusting outer planes. 'Qc' will probably retain all points that adjust outer planes. Q9 With 'Q9', Qhull processes the furthest of all out- side sets at each iteration. Q10 With 'Q10', Qhull does not use special processing for narrow distributions. Q11 With 'Q11', Qhull copies normals and recomputes centrums for tricoplanar facets. Q12 With 'Q12', Qhull does not report a very wide merge due to a duplicated ridge with nearly coincident vertices Q14 With 'Q14', Qhull does not rename vertices that create a duplicate ridge Trace options Tn Trace at level n. Qhull includes full execution tracing. 'T-1' traces events. 'T1' traces the overall execution of the program. 'T2' and 'T3' trace overall execution and geometric and topologi- cal events. 'T4' traces the algorithm. 'T5' includes information about memory allocation and Gaussian elimination. Ta Annotate output with codes that identify the corresponding qh_fprintf() statement. Tc Check frequently during execution. This will catch most inconsistency errors. TCn Stop Qhull after building the cone of new facets for point n. The output for 'f' includes the cone and the old hull. See also 'TVn'. TFn Report progress whenever more than n facets are created During post-merging, 'TFn' reports progress after more than n/2 merges. TI file Input data from 'file'. The filename may not include spaces or quotes. TO file Output results to 'file'. The name may be enclosed in single quotes. TPn Turn on tracing when point n is added to the hull. Trace partitions of point n. If used with TWn, turn off tracing after adding point n to the hull. TRn Rerun qhull n times. Usually used with 'QJn' to determine the probability that a given joggle will fail. Ts Collect statistics and print to stderr at the end of execution. Tv Verify the convex hull. This checks the topologi- cal structure, facet convexity, and point inclu- sion. If precision problems occurred, facet con- vexity is tested whether or not 'Tv' is selected. Option 'Tv' does not check point inclusion if Geometry Center 2003/12/30 16 qhull(1) qhull(1) forcing output with 'Po', or if 'Q5' is set. For point inclusion testing, Qhull verifies that all points are below all outer planes (facet->max- outside). Point inclusion is exhaustive if merging or if the facet-point product is small enough; oth- erwise Qhull verifies each point with a directed search (qh_findbest). Point inclusion testing occurs after producing out- put. It prints a message to stderr unless option 'Pp' is used. This allows the user to interrupt Qhull without changing the output. TVn Stop Qhull after adding point n. If n < 0, stop Qhull before adding point n. Output shows the hull at this time. See also 'TCn' TMn Turn on tracing at n'th merge. TWn Trace merge facets when the width is greater than n. Tz Redirect stderr to stdout. BUGS Please report bugs to Brad Barber at qhull_bug@qhull.org. If Qhull does not compile, it is due to an incompatibility between your system and ours. The first thing to check is that your compiler is ANSI standard. If it is, check the man page for the best options, or find someone to help you. If you locate the cause of your problem, please send email since it might help others. If Qhull compiles but crashes on the test case (rbox D4), there's still incompatibility between your system and ours. Typically it's been due to mem.c and memory align- ment. You can use qh_NOmem in mem.h to turn off memory management. Please let us know if you figure out how to fix these problems. If you do find a problem, try to simplify it before reporting the error. Try different size inputs to locate the smallest one that causes an error. You're welcome to hunt through the code using the execution trace as a guide. This is especially true if you're incorporating Qhull into your own program. When you do report an error, please attach a data set to the end of your message. This allows us to see the error for ourselves. Qhull is maintained part-time. Geometry Center 2003/12/30 17 qhull(1) qhull(1) E-MAIL Please send correspondence to qhull@qhull.org and report bugs to qhull_bug@qhull.org. Let us know how you use Qhull. If you mention it in a paper, please send the reference and an abstract. If you would like to get Qhull announcements (e.g., a new version) and news (any bugs that get fixed, etc.), let us know and we will add you to our mailing list. If you would like to communicate with other Qhull users, we will add you to the qhull_users alias. For Internet news about geometric algorithms and convex hulls, look at comp.graph- ics.algorithms and sci.math.num-analysis SEE ALSO rbox(1) Barber, C. B., D.P. Dobkin, and H.T. Huhdanpaa, "The Quickhull Algorithm for Convex Hulls," ACM Trans. on Math- ematical Software, 22(4):469-483, Dec. 1996. http://portal.acm.org/citation.cfm?doid=235815.235821 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.117.405 Clarkson, K.L., K. Mehlhorn, and R. Seidel, "Four results on randomized incremental construction," Computational Geometry: Theory and Applications, vol. 3, p. 185-211, 1993. Preparata, F. and M. Shamos, Computational Geometry, Springer-Verlag, New York, 1985. AUTHORS C. Bradford Barber Hannu Huhdanpaa bradb@shore.net hannu@qhull.org ACKNOWLEDGEMENTS A special thanks to Albert Marden, Victor Milenkovic, the Geometry Center, Harvard University, and Endocardial Solu- tions, Inc. for supporting this work. Qhull 1.0 and 2.0 were developed under National Science Foundation grants NSF/DMS-8920161 and NSF-CCR-91-15793 750-7504. David Dobkin Geometry Center 2003/12/30 18 qhull(1) qhull(1) guided the original work at Princeton University. If you find it useful, please let us know. The Geometry Center was supported by grant DMS-8920161 from the National Science Foundation, by grant DOE/DE-FG02-92ER25137 from the Department of Energy, by the University of Minnesota, and by Minnesota Technology, Inc. Qhull is available from http://www.qhull.org Geometry Center 2003/12/30 19 geometry/vignettes/qhull/html/qh-optt.html0000644000176200001440000003151714664417655020521 0ustar liggesusers Qhull trace options (T)

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull trace options (T)

This section lists the trace options for Qhull. These options are indicated by 'T' followed by a letter.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Trace options

 
General
Ta
annotate output with message codes
TFn
report progress whenever n or more facets created
TI file
input data from a file
TO file
output results to a file
Ts
print statistics
Tv
verify result: structure, convexity, and point inclusion
Tz
output error information to stdout instead of stderr
 
 
Debugging
T4
trace at level n, 4=all, 5=mem/gauss, -1= events
TAn
stop after adding n vertices
Tc
check frequently during execution
TCn
stop qhull after building cone for point n
Tf
flush each qh_fprintf for debugging segfaults
TMn
turn on tracing at merge n
TPn
turn on tracing when point n added to hull
TRn
rerun qhull n times for QJn statitics
TV-n
stop qhull before adding point n
TVn
stop qhull after adding point n
TWn
trace merge facets when width > n

»Ta - annotate output with message codes

With option 'Ta', Qhull annotates output with message codes. Programmers may use these codes to trap the corresponding print statements.

»TAn - stop Qhull after adding n vertices

With option 'TAn', Qhull stops after adding n vertices. See option 'TVn' to stop after adding point n.

»Tc - check frequently during execution

Qhull includes frequent checks of its data structures. Option 'Tc' will catch most inconsistency errors. It is slow and should not be used for production runs. Option 'Tv' performs the same checks after the hull is constructed. Tracing ('T4') adds additional calls to qh_checkconvex, qh_checkpolygon, and qh_checkfacet.

»TCn - stop qhull after building cone for point n

Qhull builds a cone from the point to its horizon facets. Option 'TCn' stops Qhull just after building the cone. The output for 'f' includes the cone and the old hull.'.

»Tf - flush each qh_fprintf for debugging segfaults

Option 'Tf' flushes each qh_fprintf for debugging segfaults.

See option 'Tz' for redirecting stderr.

»TFn - report summary whenever n or more facets created

Option 'TFn' reports progress whenever more than n facets are created. The test occurs just before adding a new point to the hull. During post-merging, 'TFn' reports progress after more than n/2 merges.

»TI file - input data from file

Input data from 'file' instead of stdin. The filename may be enclosed in single quotes. If the filename does not contain spaces, TIfile is OK.

You may use I/O redirection instead (e.g., 'rbox 10 | qdelaunay >results').

»TMn - turn on tracing at merge n

Turn on tracing at n'th merge.

»Tn - trace at level n

Qhull includes full execution tracing. 'T-1' traces events. 'T1' traces the overall execution of the program. 'T2' and 'T3' trace overall execution, and geometric, topological, and merge events. 'T4' is the detailed trace of Qhull. 'T5' adds information about memory allocation and Gaussian elimination. 'T1' is useful for logging progress of Qhull in high dimensions. See Debugging Qhull.

Option 'Tn' can produce large amounts of output. Use options 'TPn', 'TWn', and 'TMn' to selectively turn on tracing. Since all errors report the last processed point, option 'TPn' is particularly useful.

Different executions of the same program may produce different traces and different results. The reason is that Qhull uses hashing to match ridges of non-simplicial facets. For performance reasons, the hash computation uses memory addresses which may change across executions.

»TO file - output results to file

Redirect stdout to 'file'. The filename may be enclosed in single quotes. If the filename does not contain spaces, TOfile is OK. Unix and Windows NT users may use I/O redirection instead of 'TO' (e.g., 'rbox 10 | qdelaunay >results').

Windows95 users should always use 'TO file'. If they use I/O redirection, error output is not sent to the console. Qhull uses single quotes instead of double quotes because a missing double quote can freeze Windows95 (e.g., do not run, rbox 10 | qhull TO "x)

»TPn - turn on tracing when point n added to hull

Option 'TPn' turns on tracing when point n is added to the hull. It also traces partitions of point n. This option reduces the output size when tracing. It is the normal method to determine the cause of a Qhull error. All Qhull errors report the last point added.

Use option 'TP-1' to turn on tracing after qh_buildhull and qh_postmerge.

Use options 'TPn TVn' to trace the addition of point n to the convex hull and stop when done.

If used with option 'TWn', 'TPn' turns off tracing after adding point n to the hull. Use options 'TPn TWn' to trace the addition of point n to the convex hull, partitions of point n, and wide merges.

»TRn - rerun qhull n times for QJn statitics

Option 'TRn' reruns Qhull n times. It is used with 'QJn' to determine the probability that a given joggle will fail. The summary ('s') lists the failure rate and the precision errors that occurred. Option 'Ts' will report statistics for all of the runs. Trace and output options only apply to the last run. An event trace, 'T-1' reports events for all runs.

Tracing applies to the last run of Qhull. If an error is reported, the options list the run number as "_run". To trace this run, set 'TRn' to the same value.

»Ts - print statistics

Option 'Ts' collects statistics and prints them to stderr. For Delaunay triangulations, the angle statistics are restricted to the lower or upper envelope.

»Tv - verify result: structure, convexity, and point inclusion

Option 'Tv' checks the topological structure, flipped facets, and point inclusion. Facet convexity is tested if not merging or if 2-D/3-D and a merged facet. If precision problems occur, flipped facet tests and facet convexity tests occur whether or not 'Tv' is selected. Option 'Tv' does not check point inclusion if forcing output with 'Po', or if 'Q5' is set.

The convex hull of a set of points is the smallest polytope that includes the points. Option 'Tv' tests point inclusion. Qhull verifies that all points are below all outer planes (facet->maxoutside). Point inclusion is exhaustive if merging or if the facet-point product is small enough; otherwise Qhull verifies each point with a directed search (qh_findbest). To force an exhaustive test when using option 'C-0' (default), use 'C-1e-30' instead.

Point inclusion testing occurs after producing output. It prints a message to stderr unless option 'Pp' is used. This allows the user to interrupt Qhull without changing the output.

With 'qvoronoi Fi', option 'Tv' collects statistics that verify all Voronoi vertices lie on the separating hyperplane, and all separating hyperplanes are perpendicular bisectors.

»TV-n - stop qhull before adding point n

Qhull adds one point at a time to the convex hull. See how Qhull adds a point. Option 'TV-n' stops Qhull just before adding a new point. Output shows the hull at this time.

»TVn - stop qhull after adding point n

Option 'TVn' stops Qhull after it has added point n and before it deletes the visible facets. If facet merges lead to vertex merges, 'TVn' stops after vertex merges and deleting visible facets. Output shows the hull at this time. See option 'TAn' to stop after adding n vertices.

»TWn - trace merge facets when width > n

Along with TMn, this option allows the user to determine the cause of a wide merge.

»Tz - send all output to stdout

Redirect stderr to stdout. See option 'Tf' for flushing writes.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qh-impre.html0000644000176200001440000011567514664417655020657 0ustar liggesusers Imprecision in Qhull

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull imprecision: contents


[4-d cube] Imprecision in Qhull

This section of the Qhull manual discusses the problems caused by coplanar points and why Qhull uses the default options 'C-0' or 'Qx'. If you ignore precision issues with option 'Q0', the output from Qhull can be arbitrarily bad. Qhull avoids most precision problems if you merge facets (the default) or joggle the input ('QJ').

Use option 'Tv' to verify the output from Qhull. It verifies that adjacent facets are clearly convex. It verifies that all points are on or below all facets.

Qhull automatically tests for convexity if it detects precision errors while constructing the hull.

Copyright © 1995-2020 C.B. Barber


»Qhull imprecision: contents


»Precision problems

Since Qhull uses floating point arithmetic, roundoff error occurs with each calculation. This causes problems for geometric algorithms. Other floating point codes for convex hulls, Delaunay triangulations, and Voronoi diagrams also suffer from these problems. Qhull handles most of them.

There are several kinds of precision errors:

  • Representation error occurs when there are not enough digits to represent a number, e.g., 1/3.
  • Measurement error occurs when the input coordinates are from measurements.
  • Roundoff error occurs when a calculation is rounded to a fixed number of digits, e.g., a floating point calculation.
  • Approximation error occurs when the user wants an approximate result because the exact result contains too much detail.
  • Topological error occurs when the topology of mathematical convex hulls is broken by facet merging or vertex merging.

Under imprecision, calculations may return erroneous results. For example, roundoff error can turn a small, positive number into a small, negative number. See Milenkovic ['93] for a discussion of strict robust geometry. Qhull does not meet Milenkovic's criterion for accuracy. Qhull's error bound is empirical instead of theoretical.

Qhull 1.0 checked for precision errors but did not handle them. The output could contain concave facets, facets with inverted orientation ("flipped" facets), more than two facets adjacent to a ridge, and two facets with exactly the same set of vertices.

Qhull 2.4 and later automatically handles errors due to machine round-off. Option 'C-0' or 'Qx' is set by default. In 5-d and higher, the output is clearly convex but an input point could be outside of the hull. This may be corrected by using option 'C-0', but then the output may contain wide facets.

Qhull 2.5 and later provides option 'QJ' to joggled input. Each input coordinate is modified by a small, random quantity. If a precision error occurs, a larger modification is tried. When no precision errors occur, Qhull is done.

Joggled input avoids merged facets and the topological issues that may arise. If your application is sensitive to errors, consider joggled input and the corresponding flag, qh_NOmerge.

Qhull 3.1 and later provides option 'Qt' for triangulated output. Non-simplicial facets are triangulated. The facets may have zero area. Triangulated output is particularly useful for Delaunay triangulations.

Qhull 2019.1 includes an experimental option ('Q14') to merge nearly adjacent vertices due to duplicated ridges. If reports a topological error if merging fails to resolve the issue. Further work is needed.

By handling round-off errors, Qhull can provide a variety of output formats. For example, it can return the halfspace that defines each facet ('n'). The halfspaces include roundoff error. If the halfspaces were exact, their intersection would return the original extreme points. With imprecise halfspaces and exact arithmetic, nearly incident points may be returned for an original extreme point. By handling roundoff error, Qhull returns one intersection point for each of the original extreme points. Qhull may split or merge an extreme point, but this appears to be unlikely.

The following pipe implements the identity function for extreme points (with roundoff):

qconvex FV n | qhalf Fp

Bernd Gartner published his Miniball algorithm ["Fast and robust smallest enclosing balls", Algorithms - ESA '99, LNCS 1643]. It uses floating point arithmetic and a carefully designed primitive operation. It is practical to 20-D or higher, and identifies at least two points on the convex hull of the input set. Like Qhull, it is an incremental algorithm that processes points furthest from the intermediate result and ignores points that are close to the intermediate result.

»Merged facets or joggled input

This section discusses the choice between merged facets and joggled input. By default, Qhull uses merged facets to handle precision problems. With option 'QJ', the input is joggled. See examples of joggled input and triangulated output.

  • Use merged facets (the default) when you want non-simplicial output (e.g., the faces of a cube).
  • Use joggled input ('QJ') when you need clearly-convex, simplicial output.
  • Use joggled input if your code is sensitive to errors. Joggled input handles all inputs, even highly degenerate inputs such as 100 identical points. If you compile with qh_NOmerge, Qhull does not contain code for merging facets. It uses joggled input instead.
  • Otherwise, use merged facets and triangulated output ('Qt') when you want simplicial output and coplanar facets (e.g., triangles for a Delaunay triangulation).

The choice between merged facets and joggled input depends on the application. Both run about the same speed. Joggled input may be faster if the initial joggle is sufficiently large to avoid precision errors. Although less precise, joggled input is more reliable than merged facets. A future version of Qhull will provide per vertex joggle.

Use merged facets (the default, 'C-0') or triangulated output ('Qt') if

  • Your application supports non-simplicial facets, or it allows degenerate, simplicial facets (option 'Qt').
  • You do not want the input modified.
  • Your input coordinates start with the same five or more digits (i.e., it is shifted relative to the origin). This reduces the available precision.
  • You use single precision arithmetic (realT).
  • You want to set additional options for approximating the hull.

Use joggled input ('QJ') if

  • Your application needs clearly convex, simplicial output
  • Your application supports perturbed input points and narrow triangles.
  • Seven significant digits is sufficient accuracy.
  • Your application is sensitive to errors.

You may use both techniques or combine joggle with post-merging ('Cn').

Other researchers have used techniques similar to joggled input. Sullivan and Beichel [ref?] randomly perturb the input before computing the Delaunay triangulation. Corkum and Wyllie [news://comp.graphics, 1990] randomly rotate a polytope before testing point inclusion. Edelsbrunner and Mucke [Symp. Comp. Geo., 1988] and Yap [J. Comp. Sys. Sci., 1990] symbolically perturb the input to remove singularities.

Merged facets ('C-0') handles precision problems directly. If a precision problem occurs, Qhull merges one of the offending facets into one of its neighbors. With multiple merges, topological problems may lead to severe precision problems, or prevent Qhull from continuing. Otherwise, Qhull will either fix the problem or attempt to merge the last remaining facets.

»Joggled input

Joggled input is a simple work-around for precision problems in computational geometry ["joggle: to shake or jar slightly," Amer. Heritage Dictionary]. Other names are jostled input or random perturbation. Qhull joggles the input by modifying each coordinate by a small random quantity. If a precision problem occurs, Qhull joggles the input with a larger quantity and the algorithm is restarted. This process continues until no precision problems occur. Unless all inputs incur precision problems, Qhull will terminate. Qhull adjusts the inner and outer planes to account for the joggled input.

Neither joggle nor merged facets has an upper bound for the width of the output facets, but both methods work well in practice. Joggled input is easier to justify. Precision errors occur when the points are nearly singular. For example, four points may be coplanar or three points may be collinear. Consider a line and an incident point. A precision error occurs if the point is within some epsilon of the line. Now joggle the point away from the line by a small, uniformly distributed, random quantity. If the point is changed by more than epsilon, the precision error is avoided. The probability of this event depends on the maximum joggle. Once the maximum joggle is larger than epsilon, doubling the maximum joggle will halve the probability of a precision error.

With actual data, an analysis would need to account for each point changing independently and other computations. It is easier to determine the probabilities empirically ('TRn') . For example, consider computing the convex hull of the unit cube centered on the origin. The arithmetic has 16 significant decimal digits.

Convex hull of unit cube

joggle error prob.
1.0e-15 0.983
2.0e-15 0.830
4.0e-15 0.561
8.0e-15 0.325
1.6e-14 0.185
3.2e-14 0.099
6.4e-14 0.051
1.3e-13 0.025
2.6e-13 0.010
5.1e-13 0.004
1.0e-12 0.002
2.0e-12 0.001

A larger joggle is needed for multiple points. Since the number of potential singularities increases, the probability of one or more precision errors increases. Here is an example.

Convex hull of 1000 points on unit cube

joggle error prob.
1.0e-12 0.870
2.0e-12 0.700
4.0e-12 0.450
8.0e-12 0.250
1.6e-11 0.110
3.2e-11 0.065
6.4e-11 0.030
1.3e-10 0.010
2.6e-10 0.008
5.1e-09 0.003

Other distributions behave similarly. No distribution should behave significantly worse. In Euclidean space, the probability measure of all singularities is zero. With floating point numbers, the probability of a singularity is non-zero. With sufficient digits, the probability of a singularity is extremely small for random data. For a sufficiently large joggle, all data is nearly random data.

Qhull uses an initial joggle of 30,000 times the maximum roundoff error for a distance computation. This avoids most potential singularities. If a failure occurs, Qhull retries at the initial joggle (in case bad luck occurred). If it occurs again, Qhull increases the joggle by ten-fold and tries again. This process repeats until the joggle is a hundredth of the width of the input points. Qhull reports an error after 100 attempts. This should never happen with double-precision arithmetic. Once the probability of success is non-zero, the probability of success increases about ten-fold at each iteration. The probability of repeated failures becomes extremely small.

Merged facets produces a significantly better approximation. Empirically, the maximum separation between inner and outer facets is about 30 times the maximum roundoff error for a distance computation. This is about 2,000 times better than joggled input. Most applications though will not notice the difference.

»Delaunay triangulations

Programs that use Delaunay triangulations traditionally assume a triangulated input. By default, qdelaunay merges regions with cocircular or cospherical input sites. If you want a simplicial triangulation use triangulated output ('Qt') or joggled input ('QJ').

For Delaunay triangulations, triangulated output should produce good results. All points are within roundoff error of a paraboloid. If two points are nearly incident, one will be a coplanar point. So all points are clearly separated and convex. If qhull reports deleted vertices, the triangulation may contain serious precision faults. Deleted vertices are reported in the summary ('s', 'Fs'

You should use option 'Qbb' with Delaunay triangulations. It scales the last coordinate and may reduce roundoff error. It is automatically set for qdelaunay, qvoronoi, and option 'QJ'.

Edelsbrunner, H, Geometry and Topology for Mesh Generation, Cambridge University Press, 2001. Good mathematical treatise on Delaunay triangulation and mesh generation for 2-d and 3-d surfaces. The chapter on surface simplification is particularly interesting. It is similar to facet merging in Qhull.

Veron and Leon published an algorithm for shape preserving polyhedral simplification with bounded error [Computers and Graphics, 22.5:565-585, 1998]. It remove nodes using front propagation and multiple remeshing.

»Halfspace intersection

The identity pipe for Qhull reveals some precision questions for halfspace intersections. The identity pipe creates the convex hull of a set of points and intersects the facets' hyperplanes. It should return the input points, but narrow distributions may drop points while offset distributions may add points. It may be better to normalize the input set about the origin. For example, compare the first results with the later two results: [T. Abraham]

rbox 100 s t | tee r | qconvex FV n | qhalf Fp | cat - r | /bin/sort -n | tail
rbox 100 L1e5 t | tee r | qconvex FV n | qhalf Fp | cat - r | /bin/sort -n | tail
rbox 100 s O10 t | tee r | qconvex FV n | qhalf Fp | cat - r | /bin/sort -n | tail

»Merged facets

Qhull detects precision problems when computing distances. A precision problem occurs if the distance computation is less than the maximum roundoff error. Qhull treats the result of a hyperplane computation as if it were exact.

Qhull handles precision problems by merging non-convex facets. The result of merging two facets is a thick facet defined by an inner plane and an outer plane. The inner and outer planes are offsets from the facet's hyperplane. The inner plane is clearly below the facet's vertices. At the end of Qhull, the outer planes are clearly above all input points. Any exact convex hull must lie between the inner and outer planes.

Qhull tests for convexity by computing a point for each facet. This point is called the facet's centrum. It is the arithmetic center of the facet's vertices projected to the facet's hyperplane. For simplicial facets with d vertices, the centrum is equivalent to the centroid or center of gravity.

Two neighboring facets are convex if each centrum is clearly below the other hyperplane. The 'Cn' or 'C-n' options sets the centrum's radius to n . A centrum is clearly below a hyperplane if the computed distance from the centrum to the hyperplane is greater than the centrum's radius plus two maximum roundoff errors. Two are required because the centrum can be the maximum roundoff error above its hyperplane and the distance computation can be high by the maximum roundoff error.

With the 'C-n' or 'A-n' options, Qhull merges non-convex facets while constructing the hull. The remaining facets are clearly convex. With the 'Qx' option, Qhull merges coplanar facets after constructing the hull. While constructing the hull, it merges coplanar horizon facets, flipped facets, concave facets and duplicated ridges. With 'Qx', coplanar points may be missed, but it appears to be unlikely.

If the user sets the 'An' or 'A-n' option, then all neighboring facets are clearly convex and the maximum (exact) cosine of an angle is n.

If 'C-0' or 'Qx' is used without other precision options (default), Qhull tests vertices instead of centrums for adjacent simplices. In 3-d, if simplex abc is adjacent to simplex bcd, Qhull tests that vertex a is clearly below simplex bcd , and vertex d is clearly below simplex abc. When building the hull, Qhull tests vertices if the horizon is simplicial and no merges occur.

»How Qhull merges facets

If two facets are not clearly convex, then Qhull removes one or the other facet by merging the facet into a neighbor. It selects the merge which minimizes the distance from the neighboring hyperplane to the facet's vertices. Qhull also performs merges when a facet has fewer than d neighbors (called a degenerate facet), when a facet's vertices are included in a neighboring facet's vertices (called a redundant facet), when a facet's orientation is flipped, or when a ridge occurs between more than two facets.

Qhull performs merges in a series of passes sorted by merge angle. Each pass merges those facets which haven't already been merged in that pass. After a pass, Qhull checks for redundant vertices. For example, if a vertex has only two neighbors in 3-d, the vertex is redundant and Qhull merges it into an adjacent vertex.

Merging two simplicial facets creates a non-simplicial facet of d+1 vertices. Additional merges create larger facets. When merging facet A into facet B, Qhull retains facet B's hyperplane. It merges the vertices, neighbors, and ridges of both facets. It recomputes the centrum if a wide merge has not occurred (qh_WIDEcoplanar) and the number of extra vertices is smaller than a constant (qh_MAXnewcentrum).

If a topological error occurs, such as more than two neighbors for a newly created ridge, Qhull may merge nearly adjacent vertices.

»Limitations of merged facets

  • Uneven dimensions -- If one coordinate has a larger absolute value than other coordinates, it may dominate the effect of roundoff errors on distance computations. The same issue occurs if one coordinate has a narrow range of values compared to another coordinate. You may use option 'QbB' to scale points to the unit cube. For Delaunay triangulations and Voronoi diagrams, qdelaunay and qvoronoi always set option 'Qbb'. It scales the last coordinate to [0,m] where m is the maximum width of the other coordinates. Option 'Qbb' is needed for Delaunay triangulations of integer coordinates and nearly cocircular points.

    For example, compare

            rbox 1000 W0 t | qconvex Qb2:-1e-14B2:1e-14
    
    with
            rbox 1000 W0 t | qconvex
    
    The distributions are the same but the first is compressed to a 2e-14 slab.

  • Post-merging of coplanar facets -- In 5-d and higher, the default option 'Qx' delays merging of coplanar facets until post-merging. This may allow "dents" to occur in the intermediate convex hulls. A point may be poorly partitioned and force a poor approximation. See option 'Qx' for further discussion.

    This is difficult to produce in 5-d and higher. Option 'Q6' turns off merging of concave facets. This is similar to 'Qx'. It may lead to serious precision errors, for example,

            rbox 10000 W1e-13  | qhull Q6  Tv
    

  • Maximum facet width -- Qhull reports the maximum outer plane and inner planes (if more than roundoff error apart). There is no upper bound for either figure. This is an area for further research. Qhull does a good job of post-merging in all dimensions. Qhull does a good job of pre-merging in 2-d, 3-d, and 4-d. With the 'Qx' option, it does a good job in higher dimensions. In 5-d and higher, Qhull does poorly at detecting redundant vertices.

    In the summary ('s'), look at the ratio between the maximum facet width and the maximum width of a single merge, e.g., "(3.4x)". Qhull usually reports a ratio of four or lower in 3-d and six or lower in 4-d. If it reports a ratio greater than 10, this may indicate an implementation error. Narrow distributions (see following) may produce wide facets.

    For example, if special processing for narrow distributions is turned off ('Q10'), qhull may produce a wide facet:

             rbox 1000 L100000 s G1e-16 t1002074964 | qhull Tv Q10
    

  • Narrow distribution -- In 3-d, a narrow distribution may result in a poor approximation. For example, if you do not use qdelaunay nor option 'Qbb', the furthest-site Delaunay triangulation of nearly cocircular points may produce a poor approximation:
             rbox s 5000 W1e-13 D2 t1002151341 | qhull d Qt
             rbox 1000 s W1e-13 t1002231672 | qhull d Tv
    

    During construction of the hull, a point may be above two facets with opposite orientations that span the input set. Even though the point may be nearly coplanar with both facets, and can be distant from the precise convex hull of the input sites. Additional facets leave the point distant from a facet. To fix this problem, add option 'Qbb' (it scales the last coordinate). Option 'Qbb' is automatically set for qdelaunay and qvoronoi.

    Qhull generates a warning if the initial simplex is narrow. For narrow distributions, Qhull changes how it processes coplanar points -- it does not make a point coplanar until the hull is finished. Use option 'Q10' to try Qhull without special processing for narrow distributions. For example, special processing is needed for:

             rbox 1000 L100000 s G1e-16 t1002074964 | qhull Tv Q10
    

    You may turn off the warning message by reducing qh_WARNnarrow in user.h or by setting option 'Pp'.

    Similar problems occur for distributions with a large flat facet surrounded with many small facet at a sharp angle to the large facet. Qhull 3.1 fixes most of these problems, but a poor approximation can occur. A point may be left outside of the convex hull ('Tv'). Examples include the furthest-site Delaunay triangulation of nearly cocircular points plus the origin, and the convex hull of a cone of nearly cocircular points. The width of the band is 10^-13.

            rbox s 1000 W1e-13 P0 D2 t996799242 | qhull d Tv
            rbox 1000 s Z1 G1e-13 t1002152123 | qhull Tv
            rbox 1000 s Z1 G1e-13 t1002231668 | qhull Tv
    

  • Quadratic running time -- If the output contains large, non-simplicial facets, the running time for Qhull may be quadratic in the size of the triangulated output. For example, rbox 1000 s W1e-13 c G2 | qhull d is 4 times faster for 500 points. The convex hull contains two large nearly spherical facets and many nearly coplanar facets. Each new point retriangulates the spherical facet and repartitions the remaining points into all of the nearly coplanar facets. In this case, quadratic running time is avoided if you use qdelaunay, add option 'Qbb', or add the origin ('P0') to the input.

  • Nearly adjacent vertices within 1e-13 -- Multiple, nearly adjacent vertices within a 1e-13 ball in the unit cube may lead to topological errors and wide facets. The experimental option 'Q14' for Qhull 2019.1 merges nearly adjacent vertices to resolve dupridges. A dupridge is a topological error where multiple facets meet at the same ridge. Further improvements are needed, primarily for 4-D and higher. For example, the Delaunay triangulation of 400 pairs of nearly adjacent 5-D points frequently fails with a topological error (eg/qtest.sh 10 '400 C1,2e-13 D5' 'Q14 d Qbb').

    For Delaunay triangulations, the problem typically occurs for extreme points of the input set (i.e., on the edge between the upper and lower convex hull). After multiple facet merges, four facets may share a "dupridge" and must be merged. Some of these facets may be twisted relative to each other, leading to a very wide merged facet. If so, error QH6271 is reported. It may be overriden with option 'Q12'.

    A "dupridge" may occur when the horizon facets for a new point is "pinched" (i.e., two vertices are nearly adjacent). If a subridge (e.g., a line segment in 3-d) is shared by two horizon facets, the four corresponding new facets meet at the same ridge, called a "dupridge". In poly_r.c, qh_matchnewfacets calls qh_matchneighbor. qh_matchneighbor identifies dupridges for matching by qh_matchdupridge. In merge_r.c, qh_mark_dupridges identifies facets for merging across a dupridge. If vertices are nearly adjacent, qh_merge_pinchedvertices merges the vertices, otherwise qh_forcedmerges merges the facets. qh_forcedmerges checks for wide merges with qh_check_dupridge.

    It is easy to generate nearly adjacent or coincident points with rbox option 'Cn,r,m'. It generates n points within an r ball for each of m input sites. For example, the following examples successfully merge pinched vertices. Substantially smaller or larger balls do not lead to pinched horizons.

            rbox 2000 C1,1e-13 D4 s t | qhull Q14
            rbox 500 C1,1e-13 t | qhull Q14 d Qbb
    
    For Delaunay triangulations, a bounding box may alleviate this issue (e.g., rbox 500 C1,1E-13 D4 t c G1.0 | qhull Q14 d Qbb). The Delaunay triangulation of a regular mesh is likewise sensitive to nearly adjacent vertices.
            rbox 2000 M3,4,5 D4 C1,1e-8 | qhull Q14 d Qbb
    

  • Topological errors -- Merging facets and vertices may lead to topological errors that do not occur for mathematical, convex hulls. Qhull merges redundant or degenerate facets. With option 'Q14', Qhull tries to correct "dupridges" by merging vertices or facets (see previous issue). It corrects some instances of dupridges. Qhull reports a "Qhull topology error" if a topological error leads to a wide facet or if Qhull fails to create a cone of new facets. It leaves other cases as is. The orientation of nonsimplicial facets is ill-defined. Ridges may have the same vertices. Adjacent nonsimplicial facets may have incompatible triangulations. These problems may be addressed in future releases of Qhull.

  • Facet with zero-area -- It is possible for a zero-area facet to be convex with its neighbors. This can occur if the hyperplanes of neighboring facets are above the facet's centrum, and the facet's hyperplane is above the neighboring centrums. Qhull computes the facet's hyperplane so that it passes through the facet's vertices. The vertices can be collinear.

  • No more facets -- Qhull reports an error if there are d+1 facets left and two of the facets are not clearly convex. This typically occurs when the convexity constraints are too strong or the input points are degenerate. The former is more likely in 5-d and higher -- especially with option 'C-n'.

  • Deleted cone -- Lots of merging can end up deleting all of the new facets for a point. This is a rare event that has only been seen while debugging the code.

  • Triangulated output leads to precision problems -- With sufficient merging, the ridges of a non-simplicial facet may have serious topological and geometric problems. A ridge may be between more than two neighboring facets. If so, their triangulation ('Qt') will fail since two facets have the same vertex set. Furthermore, a triangulated facet may have flipped orientation compared to its neighbors.
  • The triangulation process detects degenerate facets with only two neighbors. These are marked degenerate. They have zero area.

  • Coplanar points -- Option 'Qc' is determined by qh_check_maxout() after constructing the hull. Qhull needs to retain all possible coplanar points in the facets' coplanar sets. This depends on qh_RATIOnearInside in user.h. Furthermore, the cutoff for a coplanar point is arbitrarily set at the minimum vertex. If coplanar points are important to your application, remove the interior points by hand (set 'Qc Qi') or make qh_RATIOnearInside sufficiently large.

  • Maximum roundoff error -- Qhull computes the maximum roundoff error from the maximum coordinates of the point set. Usually the maximum roundoff error is a reasonable choice for all distance computations. The maximum roundoff error could be computed separately for each point or for each distance computation. This is expensive and it conflicts with option 'C-n'.

  • All flipped or upper Delaunay -- When a lot of merging occurs for Delaunay triangulations, a new point may lead to no good facets. For example, try a strong convexity constraint:
            rbox 1000 s t993602376 | qdelaunay C-1e-3
    

»Exact arithmetic

Exact arithmetic may be used instead of floating point. Singularities such as coplanar points can either be handled directly or the input can be symbolically perturbed. Using exact arithmetic is slower than using floating point arithmetic and the output may take more space. Chaining a sequence of operations increases the time and space required. Some operations are difficult to do.

CGAL includes a practical implementation of symbolic perturbation. It uses the BOOST library to generate dimension-specific, C++ data structures. It makes good use of 64-bit memory. Input sites may be added incrementally. It is the fastest 64-bit code available.

Clarkson's hull program and Shewchuk's triangle program are practical implementations of exact arithmetic.

Clarkson limits the input precision to about fifteen digits. This reduces the number of nearly singular computations. When a determinant is nearly singular, he uses exact arithmetic to compute a precise result.

»Approximating a convex hull

Qhull may be used for approximating a convex hull. This is particularly valuable in 5-d and higher where hulls can be immense. You can use 'Qx C-n' to merge facets as the hull is being constructed. Then use 'Cn' and/or 'An' to merge small facets during post-processing. You can print the n largest facets with option 'PAn'. You can print facets whose area is at least n with option 'PFn'. You can output the outer planes and an interior point with 'FV Fo' and then compute their intersection with 'qhalf'.

To approximate a convex hull in 6-d and higher, use post-merging with 'Wn' (e.g., qhull W1e-1 C1e-2 TF2000). Pre-merging with a convexity constraint (e.g., qhull Qx C-1e-2) often produces a poor approximation or terminates with a simplex. Option 'QbB' may help to spread out the data.

You will need to experiment to determine a satisfactory set of options. Use rbox to generate test sets quickly and Geomview to view the results. You will probably want to write your own driver for Qhull using the Qhull library. For example, you could select the largest facet in each quadrant.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull imprecision: contents


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/index.html0000644000176200001440000013142414664417655020232 0ustar liggesusers Qhull manual

Up: Home page for Qhull (local)
Up: News about Qhull
Up: Qhull Wiki and FAQ (local)
To: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[random-fixed] Qhull manual

Qhull is a general dimension code for computing convex hulls, Delaunay triangulations, halfspace intersections about a point, Voronoi diagrams, furthest-site Delaunay triangulations, and furthest-site Voronoi diagrams. These structures have applications in science, engineering, statistics, and mathematics. See Fukuda's introduction to convex hulls, Delaunay triangulations, Voronoi diagrams, and linear programming. For a detailed introduction, see O'Rourke ['94], Computational Geometry in C.

There are six programs. Except for rbox, they use the same code. Each program includes instructions and examples.

  • qconvex -- convex hulls
  • qdelaunay -- Delaunay triangulations and furthest-site Delaunay triangulations
  • qhalf -- halfspace intersections about a point
  • qhull -- all structures with additional options
  • qvoronoi -- Voronoi diagrams and furthest-site Voronoi diagrams
  • rbox -- generate point distributions for qhull

Qhull implements the Quickhull algorithm for computing the convex hull. Qhull includes options for hull volume, facet area, multiple output formats, and graphical output. It can approximate a convex hull.

Qhull handles roundoff errors from floating point arithmetic. It generates a convex hull with "thick" facets. A facet's outer plane is clearly above all of the points; its inner plane is clearly below the facet's vertices. Any exact convex hull must lie between the inner and outer plane.

Qhull uses merged facets, triangulated output, or joggled input. Triangulated output triangulates non-simplicial, merged facets. Joggled input also guarantees simplicial output, but it is less accurate than merged facets. For merged facets, Qhull reports the maximum outer and inner plane.

Brad Barber, Arlington, MA

Copyright © 1995-2020 C.B. Barber


»Qhull manual: contents

»When to use Qhull

Qhull constructs convex hulls, Delaunay triangulations, halfspace intersections about a point, Voronoi diagrams, furthest-site Delaunay triangulations, and furthest-site Voronoi diagrams.

For convex hulls and halfspace intersections, Qhull may be used for 2-d up to 8-d. For Voronoi diagrams and Delaunay triangulations, Qhull may be used for 2-d up to 7-d. In higher dimensions, the size of the output grows rapidly and Qhull does not work well with virtual memory. If n is the size of the input and d is the dimension (d>=3), the size of the output and execution time grows by n^(floor(d/2) [see Performance]. For example, do not try to build a 16-d convex hull of 1000 points. It will have on the order of 1,000,000,000,000,000,000,000,000 facets.

On a 1.7 GHz i7, Qhull computes the 2-d convex hull of 3,000,000 evenly spaced, cocircular points in 4.7 seconds. It computes the 2-d Delaunay triangulation and 3-d convex hull of 600,000 points in 5.9 seconds. It computes the 3-d Delaunay triangulation and 4-d convex hull of 120,000 points in 4.6 seconds. It computes the 4-d Delaunay triangulation and 5-d convex hull of 30,000 points in 5.1 seconds. It computes the 5-d Delaunay triangulation and 6-d convex hull of 6,000 points in 7.8 seconds. It computes the 6-d Delaunay triangulation and 7-d convex hull of 1,000 points in 7.6 seconds. It computes the 7-d Delaunay triangulation and 8-d convex hull of 300 points in 8.6 seconds. It computes the 8-d Delaunay triangulation and 9-d convex hull of 120 points in 5.7 seconds. It computes the 9-d Delaunay triangulation and 10-d convex hull of 70 points in 4.8 seconds. The 10-d convex hull of 70 cospherical points has about 375,000 facets.

Qhull does not support constrained Delaunay triangulations, triangulation of non-convex surfaces, mesh generation of non-convex objects, or medium-sized inputs in 9-D and higher.

This is a big package with many options. For 32-bit code, it is one of the fastest available. It is the only 3-d and higher code that handles precision problems due to floating point arithmetic. For example, it implements the identity function for extreme points (see Imprecision in Qhull).

Qhull does not handle all precision problems (Limitations of merged facets). For example, errors may occur for the 4-D Delaunay triangulation of nearly adjacent points in the unit cube. If every input site has a nearly adjacent point within a 10^-13 ball, precision errors and topological errors are likely to occur. A bounding box may alleviate these errors. Nearly adjacent points within substantially smaller or larger balls are OK.

Joggled input, option 'QJn', is an alternative to merged facets (Merged facets or joggled input). It randomly perturbs the input. If precision problems occur, Qhull restarts with a larger, random perturbation. Joggled input is a simple solution without the limitations of merged facets. For example, Qhull constructs a convex hull even if all of the input points are identical.

If you need a short code for convex hull, Delaunay triangulation, or Voronoi volumes consider Clarkson's hull program. If you need 2-d Delaunay triangulations consider Shewchuk's triangle program. It is much faster than Qhull and it allows constraints. Both programs use exact arithmetic. They are in http://www.netlib.org/voronoi/.

If your input is in general position (i.e., no coplanar or colinear points), Tomilov's quickhull.hpp (documentation-ru), or Qhull version 1.0 may meet your needs. Both programs detect precision problems, but do not handle them.

CGAL is a library of efficient and reliable geometric algorithms. It uses C++ templates and the Boost library to produce dimension-specific code. This allows more efficient use of memory than Qhull's general-dimension code. For 64-bit code, CGAL uses significantly less memory than Qhull and runs faster. CGAL simulates arbitrary precision while Qhull handles round-off error with thick facets. Compare the two approaches with Robustness Issues in CGAL, and Imprecision in Qhull.

Leda is a library for writing computational geometry programs and other combinatorial algorithms. It includes routines for computing 3-d convex hulls, 2-d Delaunay triangulations, and 3-d Delaunay triangulations. It provides rational arithmetic and graphical output. It runs on most platforms.

If your problem is in high dimensions with a few, non-simplicial facets, try Fukuda's cdd. It is much faster than Qhull for these distributions.

Custom software for 2-d and 3-d convex hulls may be faster than Qhull. Custom software should use less memory. Qhull uses general-dimension data structures and code. The data structures support non-simplicial facets.

Qhull is not suitable for mesh generation or triangulation of arbitrary surfaces. You may use Qhull if the surface is convex or completely visible from an interior point (e.g., a star-shaped polyhedron). First, project each site to a sphere that is centered at the interior point. Then, compute the convex hull of the projected sites. The facets of the convex hull correspond to a triangulation of the surface. For mesh generation of arbitrary surfaces, see Schneiders' Finite Element Mesh Generation.

Qhull is not suitable for constrained Delaunay triangulations. With a lot of work, you can write a program that uses Qhull to add constraints by adding additional points to the triangulation.

Qhull is not suitable for the subdivision of arbitrary objects. Use qdelaunay to subdivide a convex object.

»Description of Qhull

»definition

The convex hull of a point set P is the smallest convex set that contains P. If P is finite, the convex hull defines a matrix A and a vector b such that for all x in P, Ax+b <= [0,...].

Qhull computes the convex hull in 2-d, 3-d, 4-d, and higher dimensions. Qhull represents a convex hull as a list of facets. Each facet has a set of vertices, a set of neighboring facets, and a halfspace. A halfspace is defined by a unit normal and an offset (i.e., a row of A and an element of b).

Qhull accounts for round-off error. It returns "thick" facets defined by two parallel hyperplanes. The outer planes contain all input points. The inner planes exclude all output vertices. See Imprecise convex hulls.

Qhull may be used for the Delaunay triangulation or the Voronoi diagram of a set of points. It may be used for the intersection of halfspaces.

»input format

The input data on stdin consists of:

  • first line contains the dimension
  • second line contains the number of input points
  • remaining lines contain point coordinates

For example:

    3  #sample 3-d input
    5
    0.4 -0.5 1.0
    1000 -1e-5 -100
    0.3 0.2 0.1
    1.0 1.0 1.0
    0 0 0

Input may be entered by hand. End the input with a control-D (^D) character.

To input data from a file, use I/O redirection or 'TI file'. The filename may not include spaces or quotes.

A comment starts with a non-numeric character and continues to the end of line. The first comment is reported in summaries and statistics. With multiple qhull commands, use option 'FQ' to place a comment in the output.

The dimension and number of points can be reversed. Comments and line breaks are ignored. Error reporting is better if there is one point per line.

»option format

Use options to specify the output formats and control Qhull. The qhull program takes all options. The other programs use a subset of the options. They disallow experimental and inappropriate options.

  • qconvex == qhull
  • qdelaunay == qhull d Qbb
  • qhalf == qhull H
  • qvoronoi == qhull v Qbb

Single letters are used for output formats and precision constants. The other options are grouped into menus for formats ('F'), Geomview ('G'), printing ('P'), Qhull control ('Q'), and tracing ('T'). The menu options may be listed together (e.g., 'GrD3' for 'Gr' and 'GD3'). Options may be in any order. Capitalized options take a numeric argument (except for 'PG' and 'F' options). Use option 'FO' to print the selected options.

Qhull uses zero-relative indexing. If there are n points, the index of the first point is 0 and the index of the last point is n-1.

The default options are:

  • summary output ('s')
  • merged facets ('C-0' in 2-d, 3-d, 4-d; 'Qx' in 5-d and up)

Except for bounding box ('Qbk:n', etc.), drop facets ('Pdk:n', etc.), and Qhull command ('FQ'), only the last occurence of an option counts. Bounding box and drop facets may be repeated for each dimension. Option 'FQ' may be repeated any number of times.

The Unix tcsh and ksh shells make it easy to try out different options. In Windows 95, use a command window with doskey and a window scroller (e.g., peruse).

»output format

To write the results to a file, use I/O redirection or 'TO file'. Windows 95 users should use 'TO file' or the console. If a filename is surrounded by single quotes, it may include spaces.

The default output option is a short summary ('s') to stdout. There are many others (see output and formats). You can list vertex incidences, vertices and facets, vertex coordinates, or facet normals. You can view Qhull objects with Geomview, Mathematica, or Maple. You can print the internal data structures. You can call Qhull from your application (see Qhull library).

For example, 'qhull o' lists the vertices and facets of the convex hull.

Error messages and additional summaries ('s') go to stderr. Unless redirected, stderr is the console.

»algorithm

Qhull implements the Quickhull algorithm for convex hull [Barber et al. '96]. This algorithm combines the 2-d Quickhull algorithm with the n-d beneath-beyond algorithm [c.f., Preparata & Shamos '85]. It is similar to the randomized algorithms of Clarkson and others [Clarkson & Shor '89; Clarkson et al. '93; Mulmuley '94]. For a demonstration, see How Qhull adds a point. The main advantages of Quickhull are output sensitive performance (in terms of the number of extreme points), reduced space requirements, and floating-point error handling.

»data structures

Qhull produces the following data structures for dimension d:

  • A coordinate is a real number in floating point format.
  • A point is an array of d coordinates. With option 'QJ', the coordinates are joggled by a small amount.
  • A vertex is an input point.
  • A hyperplane is d normal coefficients and an offset. The length of the normal is one. The hyperplane defines a halfspace. If V is a normal, b is an offset, and x is a point inside the convex hull, then Vx+b <0.
  • An outer plane is a positive offset from a hyperplane. When Qhull is done, all points will be below all outer planes.
  • An inner plane is a negative offset from a hyperplane. When Qhull is done, all vertices will be above the corresponding inner planes.
  • An orientation is either 'top' or 'bottom'. It is the topological equivalent of a hyperplane's geometric orientation.
  • A simplicial facet is a set of d neighboring facets, a set of d vertices, a hyperplane equation, an inner plane, an outer plane, and an orientation. For example in 3-d, a simplicial facet is a triangle.
  • A centrum is a point on a facet's hyperplane. A centrum is the average of a facet's vertices. Neighboring facets are convex if each centrum is below the neighbor facet's hyperplane.
  • A ridge is a set of d-1 vertices, two neighboring facets, and an orientation. For example in 3-d, a ridge is a line segment.
  • A non-simplicial facet is a set of ridges, a hyperplane equation, a centrum, an outer plane, and an inner plane. The ridges determine a set of neighboring facets, a set of vertices, and an orientation. Qhull produces a non-simplicial facet when it merges two facets together. For example, a cube has six non-simplicial facets.

For examples, use option 'f'. See polyhedron operations (local) for further design documentation.

»Imprecision in Qhull

See Imprecision in Qhull and Merged facets or joggled input

»Examples of Qhull

See Examples of Qhull. Most of these examples require Geomview. Some of the examples have pictures .

»Options for using Qhull

See Qhull options.

»Qhull code and internals

See Qhull code.

»Geomview, Qhull's graphical viewer

Geomview is an interactive geometry viewing program. Geomview provides a good visualization of Qhull's 2-d and 3-d results.

Qhull includes Examples of Qhull that may be viewed with Geomview.

Geomview can help visulalize a 3-d Delaunay triangulation or the surface of a 4-d convex hull, Use option 'QVn' to select the 3-D facets adjacent to a vertex.

You may use Geomview to create movies that animate your objects (c.f., How can I create a video animation?). Geomview helped create the mathematical videos "Not Knot", "Outside In", and "The Shape of Space" from the Geometry Center.

»Installing Geomview

Geomview is an open source project under SourceForge.

For build instructions see Downloading Geomview. Geomview builds under Linux, Unix, Macintosh OS X, and Windows.

Geomview has installable packages for Debian and Ubuntu. The OS X build needs Xcode, an X11 SDK, and Lesstif or Motif. The Windows build uses Cygwin (see Building Geomview below for instructions).

If using Xforms (e.g., for Geomview's External Modules), install the 'libXpm-devel' package from cygwin and move the xforms directory into your geomview directory, e.g.,
mv xforms-1.2.4 geomview-1.9.5/xforms

Geomview's ndview provides multiple views into 4-d and higher objects. This module is out-of-date (geomview-users: 4dview). Download NDview-sgi.tar.Z at newpieces and 4dview at Geomview/modules.

»Using Geomview

Use Geomview to view Examples of Qhull. You can spin the convex hull, fly a camera through its facets, and see how Qhull produces thick facets in response to round-off error.

Follow these instructions to view 'eg,01.cube' from Examples of Qhull

  1. Launch an XTerm command shell
    • If needed, start the X terminal server, Use 'xinit' or 'startx' in /usr/X11R6/bin
      xinit -- -multiwindow -clipboard
      startx
    • Start an XTerm command shell. In Windows, click the Cygwin/bash icon on your desktop.
    • Set the DISPLAY variable, e.g.,
      export DISPLAY=:0
      export DISPLAY=:0 >>~/.bashenv
  2. Use Qhull's Geomview options to create a geomview object
    • rbox c D3 | qconvex G >eg.01.cube
    • On windows, convert the output to Unix text format with 'd2u'
      rbox c D3 | qconvex G | d2u >eg.01.cube
      d2u eg.*
  3. Run Geomview
    • Start Geomview with your example
      ./geomview eg.01.cube
    • Follow the instructions in Gemoview Tutorial
    • Geomview creates the Geomview control panel with Targets and External Module, the Geomview toolbar with buttons for controlling Geomview, and the Geomview camera window showing a cube.
    • Clear the camera window by selecting your object in the Targets list and 'Edit > Delete' or 'dd'
    • Load the Geomview files panel. Select 'Open' in the 'File' menu.
    • Set 'Filter' in the files panel to your example directory followed by '/*' (e.g., '/usr/local/qhull-2015.2/eg/*')
    • Click 'Filter' in the files panel to view your examples in the 'Files' list.
    • Load another example into the camera window by selecting it and clicking 'OK'.
    • Review the instructions for Interacting with Geomview
    • When viewing multiple objects at once, you may want to turn off normalization. In the 'Inspect > Apperance' control panel, set 'Normalize' to 'None'.

Geomview defines GCL (a textual API for controlling Geomview) and OOGL (a textual file format for defining objects).

  • To control Geomview, you may use any program that reads and writes from stdin and stdout. For example, it could report Qhull's information about a vertex identified by a double-click 'pick' event.
  • GCL command language for controlling Geomview
  • OOGL file format for defining objects (tutorial).
  • External Modules for interacting with Geomview via GCL
  • Interact with your objects via pick commands in response to right-mouse double clicks. Enable pick events with the interest command.

»Building Geomview for Windows

Compile Geomview under Cygwin. For detailed instructions, see Building Savi and Geomview under Windows. These instructions are somewhat out-of-date. Updated instructions follow.

How to compile Geomview under 32-bit Cygwin (October 2015)

  1. Note: L. Wood has run into multiple issues with Geomview on Cygwin. He recommends Virtualbox/Ubuntu and a one-click install of geomview via the Ubuntu package. See his Savi/Geomview link above.
  2. Install 32-bit Cygwin as follows. For additional guidance, see Cygwin's Installing and Updating Cygwin Packages and Setup cygwin.
    • Launch the cygwin installer.
    • Select a mirror from Cygwin mirrors (e.g., http://mirrors.kernel.org/sourceware/cygwin/ in California).
    • Select the packages to install. Besides the cygwin packages listed in the Savi/Windows instructions consider adding
      • Default -- libXm-devel (required for /usr/include/Xm/Xm.h)
      • Devel -- bashdb, gcc-core (in place of gcc), gdb
      • Lib -- libGL-devel, libGLU1 (required, obsolete), libGLU-devel (required, obsolete), libjpeg-devel(XForms), libXext-devel (required), libXpm-devel (Xforms) libGL and lib
      • Math -- bc
      • Net -- autossh, inetutils, openssh
      • System -- chere
      • Utils -- dos2unix (required for qhull), keychain
      • If installing perl, ActiveState Perl may be a better choice than cygwin's perl. Perl is not used by Geomview or Qhull.
      • Cygwin Package Search -- Search for cygwin programs and packages
    • Click 'Next' to download and install the packages.
    • If the download is incomplete, try again.
    • If you try again after a successful install, cygwin will uninstall and reinstall all modules..
    • Click on the 'Cywin Terminal' icon on the Desktop. It sets up a user directory in /home from /etc/skel/...
    • Mount your disk drives
      mount c: /c # Ignore the warning /c does not exist
  3. Consider installing the Road Bash scripts (/etc/road-*) from Road. They define aliases and functions for Unix command shells (Unix, Linux, Mac OS X, Windows),
    • Download Road Bash and unzip the downloaded file
    • Copy .../bash/etc/road-* to the Cywin /etc directory (by default, C:\cygwin\etc).
    • Using the cygwin terminal, convert the road scripts to Unix format
      d2u /etc/road-*
    • Try it
      source /etc/road-home.bashrc
    • Install it
      cp /etc/road-home.bashrc ~/.bashrc
  4. Launch the X terminal server from 'Start > All programs > Cygwin-X > Xwin Server'. Alternatively, run 'startx'
  5. Launch an XTerm shell
    • Right click the Cywin icon on the system tray in the Windows taskbar.
    • Select 'System Tools > XTerm'
  6. Download and extract Geomview -- Downloading Geomview
  7. Compile Geomview
    • ./configure
    • make
  8. If './configure' fails, check 'config.log' at the failing step. Look carefully for missing libraries, etc. The Geomview FAQ contains suggestions (e.g., "configure claims it can't find OpenGl").
  9. If 'make' fails, read the output carefully for error messages. Usually it is a missing include file or package. Locate and install the missing cygwin packages (Cygwin Package Search).

»What to do if something goes wrong

Please report bugs to qhull_bug@qhull.org. Please report if Qhull crashes. Please report if Qhull generates an "internal error". Please report if Qhull produces a poor approximate hull in 2-d, 3-d or 4-d. Please report documentation errors. Please report missing or incorrect links.

If you do not understand something, try a small example. The rbox program is an easy way to generate test cases. The Geomview program helps to visualize the output from Qhull.

If Qhull does not compile, it is due to an incompatibility between your system and ours. The first thing to check is that your compiler is ANSI standard. Qhull produces a compiler error if __STDC__ is not defined. You may need to set a flag (e.g., '-A' or '-ansi').

If Qhull compiles but crashes on the test case (rbox D4), there's still incompatibility between your system and ours. Sometimes it is due to memory management. This can be turned off with qh_NOmem in mem.h. Please let us know if you figure out how to fix these problems.

If you doubt the output from Qhull, add option 'Tv'. It checks that every point is inside the outer planes of the convex hull. It checks that every facet is convex with its neighbors. It checks the topology of the convex hull.

Qhull resolves most precision issues. It reports a precision error for lower dimensional inputs. It may report a precision error for non-simplicial facets with multiple merges or nearly adjacent vertices. See Limitations of merged facets for more information.

Qhull reports precision errors if you turn off merged facets with option 'Q0'. This can get as bad as facets with flipped orientation or two facets with the same vertices. You'll get a long help message if you run into such a case. They are easy to generate with rbox.

If you do find a problem, try to simplify it before reporting the error. Try different size inputs to locate the smallest one that causes an error. You're welcome to hunt through the code using the execution trace ('T4') as a guide. This is especially true if you're incorporating Qhull into your own program.

When you report an error, please attach a data set to the end of your message. Include the options that you used with Qhull, the results of option 'FO', and any messages generated by Qhull. This allows me to see the error for myself. Qhull is maintained part-time.

»Email

Please send correspondence to Brad Barber at qhull@qhull.org and report bugs to qhull_bug@qhull.org . Let me know how you use Qhull. If you mention it in a paper, please send a reference and abstract.

If you would like to get Qhull announcements (e.g., a new version) and news (any bugs that get fixed, etc.), let us know and we will add you to our mailing list. For Internet news about geometric algorithms and convex hulls, look at comp.graphics.algorithms and sci.math.num-analysis. For Qhull news look at qhull-news.html.

»Authors

   C. Bradford Barber                    Hannu Huhdanpaa
   bradb@shore.net                       hannu@qhull.org

»Acknowledgments

A special thanks to David Dobkin for his guidance. A special thanks to Albert Marden, Victor Milenkovic, the Geometry Center, and Harvard University for supporting this work.

A special thanks to Mark Phillips, Robert Miner, and Stuart Levy for running the Geometry Center web site long after the Geometry Center closed. Stuart moved the web site to the University of Illinois at Champaign-Urbana. Mark and Robert are founders of Geometry Technologies. Mark, Stuart, and Tamara Munzner are the original authors of Geomview.

A special thanks to Endocardial Solutions, Inc. of St. Paul, Minnesota for their support of the code documentation (src/libqhull_r/index.html, local). They use Qhull to build 3-d models of heart chambers.

Qhull 1.0 and 2.0 were developed under National Science Foundation grants NSF/DMS-8920161 and NSF-CCR-91-15793 750-7504. If you find it useful, please let us know.

The Geometry Center was supported by grant DMS-8920161 from the National Science Foundation, by grant DOE/DE-FG02-92ER25137 from the Department of Energy, by the University of Minnesota, and by Minnesota Technology, Inc.

»References

Aurenhammer, F., "Voronoi diagrams -- A survey of a fundamental geometric data structure," ACM Computing Surveys, 1991, 23:345-405.

Barber, C. B., D.P. Dobkin, and H.T. Huhdanpaa, "The Quickhull Algorithm for Convex Hulls," ACM Transactions on Mathematical Software, 22(4):469-483, Dec 1996, www.qhull.org [http://portal.acm.org; http://citeseerx.ist.psu.edu].

Clarkson, K.L. and P.W. Shor, "Applications of random sampling in computational geometry, II", Discrete Computational Geometry, 4:387-421, 1989

Clarkson, K.L., K. Mehlhorn, and R. Seidel, "Four results on randomized incremental construction," Computational Geometry: Theory and Applications, vol. 3, p. 185-211, 1993.

Devillers, et. al., "Walking in a triangulation," ACM Symposium on Computational Geometry, June 3-5,2001, Medford MA.

Dobkin, D.P. and D.G. Kirkpatrick, "Determining the separation of preprocessed polyhedra--a unified approach," in Proc. 17th Inter. Colloq. Automata Lang. Program., in Lecture Notes in Computer Science, Springer-Verlag, 443:400-413, 1990.

Edelsbrunner, H, Geometry and Topology for Mesh Generation, Cambridge University Press, 2001.

Gartner, B., "Fast and robust smallest enclosing balls", Algorithms - ESA '99, LNCS 1643.

Golub, G.H. and van Loan, C.F., Matric Computations, Baltimore, Maryland, USA: John Hopkins Press, 1983

Fortune, S., "Computational geometry," in R. Martin, editor, Directions in Geometric Computation, Information Geometers, 47 Stockers Avenue, Winchester, SO22 5LB, UK, ISBN 1-874728-02-X, 1993.

Milenkovic, V., "Robust polygon modeling," Computer-Aided Design, vol. 25, p. 546-566, September 1993.

Mucke, E.P., I. Saias, B. Zhu, Fast randomized point location without preprocessing in Two- and Three-dimensional Delaunay Triangulations, ACM Symposium on Computational Geometry, p. 274-283, 1996 [GeomDir].

Mulmuley, K., Computational Geometry, An Introduction Through Randomized Algorithms, Prentice-Hall, NJ, 1994.

O'Rourke, J., Computational Geometry in C, Cambridge University Press, 1994.

Preparata, F. and M. Shamos, Computational Geometry, Springer-Verlag, New York, 1985.


Up: Home page for Qhull (local)
Up:News about Qhull
Up: Qhull Wiki and FAQ (local)
To: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
Dn: Imprecision in Qhull
Dn: Description of Qhull examples
Dn: Qhull code


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qdelau_f.html0000644000176200001440000004425214664417655020705 0ustar liggesusers qdelaunay Qu -- furthest-site Delaunay triangulation Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options

[delaunay]qdelaunay Qu -- furthest-site Delaunay triangulation

The furthest-site Delaunay triangulation corresponds to the upper facets of the Delaunay construction. Its vertices are the extreme points of the input sites. It is the dual of the furthest-site Voronoi diagram.

Example: rbox 10 D2 | qdelaunay Qu Qt s i TO result
Compute the 2-d, furthest-site Delaunay triangulation of 10 random points. Triangulate the output. Write a summary to the console and the regions to 'result'.
 
Example: rbox 10 D2 | qdelaunay Qu QJ s i TO result
Compute the 2-d, furthest-site Delaunay triangulation of 10 random points. Joggle the input to guarantee triangular output. Write a summary to the console and the regions to 'result'.
 
Example: rbox r y c G1 D2 | qdelaunay Qu s Fv TO result
Compute the 2-d, furthest-site Delaunay triangulation of a triangle inside a square. Write a summary to the console and unoriented regions to 'result'. Merge regions for cocircular input sites (e.g., the square). The square is the only furthest-site Delaunay region.

As with the Delaunay triangulation, Qhull computes the furthest-site Delaunay triangulation by lifting the input sites to a paraboloid. The lower facets correspond to the Delaunay triangulation while the upper facets correspond to the furthest-site triangulation. Neither triangulation includes "vertical" facets (i.e., facets whose last hyperplane coefficient is nearly zero). Vertical facets correspond to input sites that are coplanar to the convex hull of the input. An example is points on the boundary of a lattice.

By default, qdelaunay merges cocircular and cospherical regions. For example, the furthest-site Delaunay triangulation of a square inside a diamond ('rbox D2 c d G4 | qdelaunay Qu') consists of one region (the diamond).

If you use 'Qt' (triangulated output), all furthest-site Delaunay regions will be simplicial (e.g., triangles in 2-d). Some regions may be degenerate and have zero area.

If you use 'QJ' (joggled input), all furthest-site Delaunay regions will be simplicial (e.g., triangles in 2-d). Joggled input is less accurate than triangulated output ('Qt'). See Merged facets or joggled input.

The output for 3-d, furthest-site Delaunay triangulations may be confusing if the input contains cospherical data. See the FAQ item Why are there extra points in a 4-d or higher convex hull? Avoid these problems with triangulated output ('Qt') or joggled input ('QJ').

The 'qdelaunay' program is equivalent to 'qhull d Qbb'. It disables the following Qhull options: d n v H U Qb QB Qc Qf Qg Qi Qm Qr Qv Qx TR E V FC Fi Fo Fp Ft FV Q0,etc.

Copyright © 1995-2020 C.B. Barber


»furthest-site qdelaunay synopsis

See qdelaunay synopsis. The same program is used for both constructions. Use option 'Qu' for furthest-site Delaunay triangulations.

»furthest-site qdelaunay input

The input data on stdin consists of:

  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qdelaunay Qu < data.txt), a pipe (e.g., rbox 10 | qdelaunay Qu), or the 'TI' option (e.g., qdelaunay Qu TI data.txt).

For example, this is a square containing four random points. Its furthest-site Delaunay triangulation contains one square.

rbox c 4 D2 > data
2 RBOX c 4 D2
8
-0.4999921736307369 -0.3684622117955817
0.2556053225468894 -0.0413498678629751
0.0327672376602583 -0.2810408135699488
-0.452955383763607 0.17886471718444
  -0.5   -0.5
  -0.5    0.5
   0.5   -0.5
   0.5    0.5

qdelaunay Qu i < data


Furthest-site Delaunay triangulation by the convex hull of 8 points in 3-d:

  Number of input sites: 8
  Number of Delaunay regions: 1
  Number of non-simplicial Delaunay regions: 1

Statistics for: RBOX c 4 D2 | QDELAUNAY s Qu i

  Number of points processed: 8
  Number of hyperplanes created: 20
  Number of facets in hull: 11
  Number of distance tests for qhull: 34
  Number of merged facets: 1
  Number of distance tests for merging: 107
  CPU seconds to compute hull (after input): 0.02

1
7 6 4 5

»furthest-site qdelaunay outputs

These options control the output of furthest-site Delaunay triangulations:

furthest-site Delaunay regions
i
list input sites for each furthest-site Delaunay region. The first line is the number of regions. The remaining lines list the input sites for each region. The regions are oriented. In 3-d and higher, report cospherical sites by adding extra points. For the points-in-square example, the square is the only furthest-site Delaunay region.
Fv
list input sites for each furthest-site Delaunay region. The first line is the number of regions. Each remaining line starts with the number of input sites. The regions are unoriented. For the points-in-square example, the square is the only furthest-site Delaunay region.
Ft
print a triangulation of the furthest-site Delaunay regions in OFF format. The first line is the dimension. The second line is the number of input sites and added points, followed by the number of simplices and the number of ridges. The input coordinates are next, followed by the centrum coordinates. There is one centrum for each non-simplicial furthest-site Delaunay region. Each remaining line starts with dimension+1. The simplices are oriented. For the points-in-square example, the square has a centrum at the origin. It splits the square into four triangular regions.
Fn
list neighboring regions for each furthest-site Delaunay region. The first line is the number of regions. Each remaining line starts with the number of neighboring regions. Negative indices (e.g., -1) indicate regions outside of the furthest-site Delaunay triangulation. For the points-in-square example, the four neighboring regions are outside of the triangulation. They belong to the regular Delaunay triangulation.
FN
list the furthest-site Delaunay regions for each input site. The first line is the total number of input sites. Each remaining line starts with the number of furthest-site Delaunay regions. Negative indices (e.g., -1) indicate regions outside of the furthest-site Delaunay triangulation. For the points-in-square example, the four random points belong to no region while the square's vertices belong to region 0 and three regions outside of the furthest-site Delaunay triangulation.
Fa
print area for each furthest-site Delaunay region. The first line is the number of regions. The areas follow, one line per region. For the points-in-square example, the square has unit area.
 
 
Input sites
Fx
list extreme points of the input sites. These points are vertices of the furthest-point Delaunay triangulation. They are on the boundary of the convex hull. The first line is the number of extreme points. Each point is listed, one per line. The points-in-square example has four extreme points.
 
 
General
FA
compute total area for 's' and 'FS'. This is the same as the area of the convex hull.
o
print upper facets of the corresponding convex hull (a paraboloid)
m
Mathematica output for the upper facets of the paraboloid (2-d triangulations).
FM
Maple output for the upper facets of the paraboloid (2-d triangulations).
G
Geomview output for the paraboloid (2-d or 3-d triangulations).
s
print summary for the furthest-site Delaunay triangulation. Use 'Fs' and 'FS' for numeric data.

»furthest-site qdelaunay controls

These options provide additional control:

Qu
must be used for furthest-site Delaunay triangulation.
Qt
triangulated output. Qhull triangulates non-simplicial facets. It may produce degenerate facets of zero area.
QJ
joggle the input to avoid cospherical and coincident sites. It is less accurate than triangulated output ('Qt').
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
QVn
select facets adjacent to input site n (marked 'good').
Tv
verify result.
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
TFn
report progress after constructing n facets
PDk:1
include upper and lower facets in the output. Set k to the last dimension (e.g., 'PD2:1' for 2-d inputs).
f
facet dump. Print the data structure for each facet (i.e., furthest-site Delaunay region).

»furthest-site qdelaunay graphics

See Delaunay graphics. They are the same except for Mathematica and Maple output.

»furthest-site qdelaunay notes

The furthest-site Delaunay triangulation does not record coincident input sites. Use qdelaunay instead.

qdelaunay Qu does not work for purely cocircular or cospherical points (e.g., rbox c | qdelaunay Qu). Instead, use qdelaunay Qz -- when all points are vertices of the convex hull of the input sites, the Delaunay triangulation is the same as the furthest-site Delaunay triangulation.

A non-simplicial, furthest-site Delaunay region indicates nearly cocircular or cospherical input sites. To avoid non-simplicial regions triangulate the output ('Qt') or joggle the input ('QJ'). Joggled input is less accurate than triangulated output. You may also triangulate non-simplicial regions with option 'Ft'. It adds the centrum to non-simplicial regions. Alternatively, use an exact arithmetic code.

Furthest-site Delaunay triangulations do not include facets that are coplanar with the convex hull of the input sites. A facet is coplanar if the last coefficient of its normal is nearly zero (see qh_ZEROdelaunay).

»furthest-site qdelaunay conventions

The following terminology is used for furthest-site Delaunay triangulations in Qhull. The underlying structure is the upper facets of a convex hull in one higher dimension. See convex hull conventions, Delaunay conventions, and Qhull's data structures

  • input site - a point in the input (one dimension lower than a point on the convex hull)
  • point - d+1 coordinates. The last coordinate is the sum of the squares of the input site's coordinates
  • vertex - a point on the paraboloid. It corresponds to a unique input site.
  • furthest-site Delaunay facet - an upper facet of the paraboloid. The last coefficient of its normal is clearly positive.
  • furthest-site Delaunay region - a furthest-site Delaunay facet projected to the input sites
  • non-simplicial facet - more than d points are cocircular or cospherical
  • good facet - a furthest-site Delaunay facet with optional restrictions by 'QVn', etc.

»furthest-site qdelaunay options

See qdelaunay options. The same program is used for both constructions. Use option 'Qu' for furthest-site Delaunay triangulations.

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/html/qh--dt.gif0000644000176200001440000000727413431000556017776 0ustar liggesusersGIF87addç^+!6o$08%BL&7„Go$Z5 #4hWIC"H4i9;QW5 Fw;†<5!aU2qIc<%b<$WWLNM7YXo].XRPZ6pD_J*_:$ ÁSwHJ [_>F=D-QQEwR<:‰:<…€:AHbYN0G<@AP&FvW73TN2V1#C&IHHR5U )5x O-WW?!DY g&¯!2›-+‚BuP('z="Nh[L!O &H]I[J+(pBO&AO%,’<ŠH)F'PL:MN,(EA@'zNVNT&9CG*FA-ž-£.IJ8‹9CuDM1 pIKeLMmS0RUSXXb=$WXjOAz;McuUCn@v!NhCTTL5(_2;‚5’5;ˆ;<†<=„=?€?A|A=‚=@|@AzABxBDtD$$GnGHlHIjIN`NU1O^OP\PQZQRXRSVSTTTD$*PYF_> 7_>‰ EQBL69O`FeIT!U[\: f1 V>EyJN+§'Q3!/,R1M4”&H*b?AO&n2!H*[8"I9.W:Y"F%R-P%!\Vd?$MM!]EYK5f<.G09;?#3@%FoHJgL© R0u@UUb?%c=&\CVV^fÔ,ddþk H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(SªÜˆÁÇÊ— U%JÒÇ%Ì›‰ì¨RAD"j}„à|iÏŽ H‘&*tèÉpÒò$KJÕ'+Dœ’´%ML6TÃà”Ä‹VÎð¼ÊÖ)¬Û ÓÈö9»±È9i¯Þl˜öö­Oš6éR´2AÎ+1Ú®Cº¸Ââu+e*Xb¸ bÄp±Í@ãÏŽ#;f¬”S •Úšð*—7Ĉ% 9ôèÛ­&)’Z¡³ ¤q)Lƒ%Ò£k+G.z]ܲ½ Ú.œÐb&T¨ˆCZ¹dܶ?þÿ­0uNuëa íXØyŸü»ø-”_¦NçJ.cÄD3Mcì`¡,ž‚´-¶Ôig­ÆkDðЦNÚµ¡sá8_(hõÛ„4ä¢Áz|ÕšbáFwöѨÔUÌ5ÔtÀ934 ‡;lÈæârê ]:!.(ÂÉ 1 8MádpâðdŠ˜ÀF{ÍÕèžv¨šcÓTñÅ6Û@â„ZíÜ\ÉÅ&t£ˆlaÒ÷X&XUdÁ&›_¬P¢SÎùŠ `pAÝéYxb6·áÀ1Ä¡ÛdÁ8Y åÉÀÕ!Æ |pACþîãN4`Íw¦h$³.Û¸ŸÃÃŽ*Zñ8‚Hà '®ÖñL7(¢Xs">™ $ ²9DÓœN]9 ØH³Æ ®®¡G¬îô0 µ¸¥™L¶Ù:Á;ÌHJ ³à$çЇ¬«w*Ò îdïb„J/¨Õ[Œ2.Á" ( à𒄯ü ^upñ DcB4Ѷ÷¡Ó|:„ËÚjì½à€;/`Œˆ(Ø14¯¨òȯc0ÂFR¥«1¿¼Í§Okkï½Êèx+…œANI<¾ÂÇ ¿24wö`B«l”ØBí2ÌQoóŽ쬠LS±È þÆrÆ“dEǬ ðJØÐˆL65¸t£G'zX"¯Óq¿]ù6³ãFsTÂ÷(­Ð"P+ ôrÆ'&…Cø+‡=¶ÈZŒF€Np»ý´Ë›ˆ‰1Æ`‘΋´ (3ÀP)¦˜dËê­ ­¸ÈÌ C…$è AÉ _´óæÚ…߆CÌM·”*Ð  ¬RË(hRC % =k OÿJ #…ÚhRÀ-Lˆ|NƒšùèŽ@ D hE-tÀ‚^¬Í+‰ÎA8jpb›žl  ºÐÅΰ M<ã ÃhÌ2G·b¯0ýj‘ƒ^@@þ0¨EÇà5™y3@€&` Ѐt‰h½–‚V@7š  XÄ@nÀ‚R±8`EêŠ0à¯{à@ t ƒ î ¨@F<ÀŠ` ‘À©Ñ͸DàRQ˜Q°8£óذ"â!q#ãB6æ;2åšà 4Ad¨îµ'$`sP€Íj1R˜Ñ3ÈGrª"ɸ¤âÖR =èበ e(I Œg   $PDÀŽ$ÀQðÄN«½ £Ð¥@pi’ qk&(Äá ¨ã'•©Lw0bÅþ0„'° CL! aøƒ1ˆ”‚.H*b!N“ ®ˆG,¢4ƶD8`ŽwL¦25QŒ2xM@!!þ¦ O,`eÈÄh1‹P,"Y„ZÕAtuÁ›- €jhÃ%Š‘€c0"…vø…0´¡<@ŒøÅ/¾!„¢®È H1X¤â$Ï»)0'ª¸l<§ñ¤„$˜`Ma¤ð¸€0>ÀTm,Àé8*&¸éX¸`ˆ§@H!X’Ø5ÈÂ)Y_шlp£@€" )ø@r=ðK aÅ"iZ’Fµ‘¶˜±Å h,â¢Ù¨f lÞ¸‘Ãþð ]XC«8„@x ƒ‚Ìâ'é%p¾†aÖøH 6ˆÃ`Ö DáÄ'&¯’Ã+Œ|@¨*I‚À ¾å„-p€Ôãàзý¯%¦Ð$›xÉãMþ'1…)à®$ ÒÚ‘T·Ë^Þn66‡<ÀÌ6ox‘B](#¦h9 B‹S ä_÷½.Þð„8˜UÅø€0­dAwP Ã%P€†T™ E‰…#[iÐ!zXÁžá#súÌÀmšP†0(Ã-¨*úEg”ø@±õ ž¥±Ðzq0@Ê|ë·º D2à‹C˜bj0dH´P5¦Ä/hð ¡ÀP±€v(Ðdp~FÖ‡*A <#]È0S - Cþ¬U. ¨ «€½ >à}0xj~˜­ )‡4 ……j£ð È#l—¸‰_Å€á ÈIaˆˆ¨¬D‘C‡À£ Ÿ€­ˆ7¡C„È€eÁ>£pz 0ÕU-Ph ˆ _±‚$Ñ *W…PX²p1„ø<СX «0t$‹µ0]®hލ#ÇS Ì´ È8Ÿ r|(/PŽ*Ñ<2lß á†¥0aµ ÁV ´Ð„˜¸¦ ¦À>òØ/PQX–AÐ…³P…@!1k(¨N’Ô~7Qgp¡À þ¸¬5€µP …'A «°7|#÷ˆ®p‰1àhÍC 4Y5P | /@e! ¡ i“ÍseÑq8°ˆ|c Ù´P ¦v¬Ð<8y•°p KY 5ˆ a 5°„¦°UW9²A|Ó¬0c¡0¦6—¡“ƒ1¡à“F È€’€É´”KÉ#@t‹):€¥ r“™™š¹™œÙ™žù™ šš;geometry/vignettes/qhull/html/qhull.man0000644000176200001440000011247513431000557020040 0ustar liggesusers.\" This is the Unix manual page for qhull, written in nroff, the standard .\" manual formatter for Unix systems. To format it, type .\" .\" nroff -man qhull.man .\" .\" This will print a formatted copy to standard output. If you want .\" to ensure that the output is plain ASCII, free of any control .\" characters that nroff uses for underlining etc, pipe the output .\" through "col -b": .\" .\" nroff -man qhull.man | col -b .\" .\" Warning: a leading quote "'" or dot "." will not format correctly .\" .TH qhull 1 "2003/12/30" "Geometry Center" .SH NAME qhull \- convex hull, Delaunay triangulation, Voronoi diagram, halfspace intersection about a point, hull volume, facet area .SH SYNOPSIS .nf qhull- compute convex hulls and related structures input (stdin): dimension, #points, point coordinates first comment (non-numeric) is listed in the summary halfspace: use dim plus one with offsets after coefficients options (qh-quick.htm): d - Delaunay triangulation by lifting points to a paraboloid v - Voronoi diagram via the Delaunay triangulation H1,1 - Halfspace intersection about [1,1,0,...] d Qu - Furthest-site Delaunay triangulation (upper convex hull) v Qu - Furthest-site Voronoi diagram Qt - triangulated output QJ - Joggle the input to avoid precision problems . - concise list of all options - - one-line description of all options Output options (subset): FA - compute total area and volume Fx - extreme points (convex hull vertices) G - Geomview output (2-d, 3-d and 4-d) Fp - halfspace intersection coordinates m - Mathematica output (2-d and 3-d) n - normals with offsets o - OFF file format (if Voronoi, outputs regions) TO file- output results to file, may be enclosed in single quotes f - print all fields of all facets s - summary of results (default) Tv - verify result: structure, convexity, and point inclusion p - vertex coordinates (centers for Voronoi) i - vertices incident to each facet example: rbox 1000 s | qhull Tv s FA .fi - html manual: index.htm - installation: README.txt - see also: COPYING.txt, REGISTER.txt, Changes.txt - WWW: - GIT: - mirror: - news: - Geomview: - news group: - FAQ: - email: qhull@qhull.org - bug reports: qhull_bug@qhull.org The sections are: - INTRODUCTION - DESCRIPTION, a description of Qhull - IMPRECISION, how Qhull handles imprecision - OPTIONS - Input and output options - Additional input/output formats - Precision options - Geomview options - Print options - Qhull options - Trace options - BUGS - E-MAIL - SEE ALSO - AUTHORS - ACKNOWLEGEMENTS This man page briefly describes all Qhull options. Please report any mismatches with Qhull's html manual (index.htm). .PP .SH INTRODUCTION Qhull is a general dimension code for computing convex hulls, Delaunay triangulations, Voronoi diagram, furthest\[hy]site Voronoi diagram, furthest\[hy]site Delaunay triangulations, and halfspace intersections about a point. It implements the Quickhull algorithm for computing the convex hull. Qhull handles round\[hy]off errors from floating point arithmetic. It can approximate a convex hull. The program includes options for hull volume, facet area, partial hulls, input transformations, randomization, tracing, multiple output formats, and execution statistics. The program can be called from within your application. You can view the results in 2\[hy]d, 3\[hy]d and 4\[hy]d with Geomview. .PP .SH DESCRIPTION .PP The format of input is the following: first line contains the dimension, second line contains the number of input points, and point coordinates follow. The dimension and number of points can be reversed. Comments and line breaks are ignored. A comment starts with a non\[hy]numeric character and continues to the end of line. The first comment is reported in summaries and statistics. Error reporting is better if there is one point per line. .PP The default printout option is a short summary. There are many other output formats. .PP Qhull implements the Quickhull algorithm for convex hull. This algorithm combines the 2\[hy]d Quickhull algorithm with the n\[hy]d beneath\[hy]beyond algorithm [c.f., Preparata & Shamos '85]. It is similar to the randomized algorithms of Clarkson and others [Clarkson et al. '93]. The main advantages of Quickhull are output sensitive performance, reduced space requirements, and automatic handling of precision problems. .PP The data structure produced by Qhull consists of vertices, ridges, and facets. A vertex is a point of the input set. A ridge is a set of d vertices and two neighboring facets. For example in 3\[hy]d, a ridge is an edge of the polyhedron. A facet is a set of ridges, a set of neighboring facets, a set of incident vertices, and a hyperplane equation. For simplicial facets, the ridges are defined by the vertices and neighboring facets. When Qhull merges two facets, it produces a non\[hy]simplicial facet. A non\[hy]simplicial facet has more than d neighbors and may share more than one ridge with a neighbor. .PP .SH IMPRECISION .PP Since Qhull uses floating point arithmetic, roundoff error may occur for each calculation. This causes problems for most geometric algorithms. .PP Qhull automatically sets option 'C\-0' in 2\[hy]d, 3\[hy]d, and 4\[hy]d, or option 'Qx' in 5\[hy]d and higher. These options handle precision problems by merging facets. Alternatively, use option 'QJ' to joggle the input. .PP With 'C\-0', Qhull merges non\[hy]convex facets while constructing the hull. The remaining facets are clearly convex. With 'Qx', Qhull merges coplanar horizon facets, flipped facets, concave facets and duplicated ridges. It merges coplanar facets after constructing the hull. With 'Qx', coplanar points may be missed, but it appears to be unlikely. .PP To guarantee triangular output, joggle the input with option 'QJ'. Facet merging will not occur. .SH OPTIONS .PP To get a list of the most important options, execute 'qhull' by itself. To get a complete list of options, execute 'qhull \-'. To get a complete, concise list of options, execute 'qhull .'. Options can be in any order. Capitalized options take an argument (except 'PG' and 'F' options). Single letters are used for output formats and precision constants. The other options are grouped into menus for other output formats ('F'), Geomview output ('G'), printing ('P'), Qhull control ('Q'), and tracing ('T'). .TP Main options: .TP default Compute the convex hull of the input points. Report a summary of the result. .TP d Compute the Delaunay triangulation by lifting the input points to a paraboloid. The 'o' option prints the input points and facets. The 'QJ' option guarantees triangular output. The 'Ft' option prints a triangulation. It adds points (the centrums) to non\[hy]simplicial facets. .TP v Compute the Voronoi diagram from the Delaunay triangulation. The 'p' option prints the Voronoi vertices. The 'o' option prints the Voronoi vertices and the vertices in each Voronoi region. It lists regions in site ID order. The 'Fv' option prints each ridge of the Voronoi diagram. The first or zero'th vertex indicates the infinity vertex. Its coordinates are qh_INFINITE (\-10.101). It indicates unbounded Voronoi regions or degenerate Delaunay triangles. .TP Hn,n,... Compute halfspace intersection about [n,n,0,...]. The input is a set of halfspaces defined in the same format as 'n', 'Fo', and 'Fi'. Use 'Fp' to print the intersection points. Use 'Fv' to list the intersection points for each halfspace. The other output formats display the dual convex hull. The point [n,n,n,...] is a feasible point for the halfspaces, i.e., a point that is inside all of the halfspaces (Hx+b <= 0). The default coordinate value is 0. The input may start with a feasible point. If so, use 'H' by itself. The input starts with a feasible point when the first number is the dimension, the second number is "1", and the coordinates complete a line. The 'FV' option produces a feasible point for a convex hull. .TP d Qu Compute the furthest\[hy]site Delaunay triangulation from the upper convex hull. The 'o' option prints the input points and facets. The 'QJ' option guarantees triangular otuput. You can also use 'Ft' to triangulate via the centrums of non\[hy]simplicial facets. .TP v Qu Compute the furthest\[hy]site Voronoi diagram. The 'p' option prints the Voronoi vertices. The 'o' option prints the Voronoi vertices and the vertices in each Voronoi region. The 'Fv' option prints each ridge of the Voronoi diagram. The first or zero'th vertex indicates the infinity vertex at infinity. Its coordinates are qh_INFINITE (\-10.101). It indicates unbounded Voronoi regions and degenerate Delaunay triangles. .PP .TP Input/Output options: .TP f Print out all facets and all fields of each facet. .TP G Output the hull in Geomview format. For imprecise hulls, Geomview displays the inner and outer hull. Geomview can also display points, ridges, vertices, coplanar points, and facet intersections. See below for a list of options. For Delaunay triangulations, 'G' displays the corresponding paraboloid. For halfspace intersection, 'G' displays the dual polytope. .TP i Output the incident vertices for each facet. Qhull prints the number of facets followed by the vertices of each facet. One facet is printed per line. The numbers are the 0\[hy]relative indices of the corresponding input points. The facets are oriented. In 4d and higher, Qhull triangulates non\[hy]simplicial facets. Each apex (the first vertex) is a created point that corresponds to the facet's centrum. Its index is greater than the indices of the input points. Each base corresponds to a simplicial ridge between two facets. To print the vertices without triangulation, use option 'Fv'. .TP m Output the hull in Mathematica format. Qhull writes a Mathematica file for 2\[hy]d and 3\[hy]d convex hulls and for 2\[hy]d Delaunay triangulations. Qhull produces a list of objects that you can assign to a variable in Mathematica, for example: "list= << ". If the object is 2\[hy]d, it can be visualized by "Show[Graphics[list]] ". For 3\[hy]d objects the command is "Show[Graphics3D[list]]". .TP n Output the normal equation for each facet. Qhull prints the dimension (plus one), the number of facets, and the normals for each facet. The facet's offset follows its normal coefficients. .TP o Output the facets in OFF file format. Qhull prints the dimension, number of points, number of facets, and number of ridges. Then it prints the coordinates of the input points and the vertices for each facet. Each facet is on a separate line. The first number is the number of vertices. The remainder are the indices of the corresponding points. The vertices are oriented in 2\[hy]d, 3\[hy]d, and in simplicial facets. For 2\[hy]d Voronoi diagrams, the vertices are sorted by adjacency, but not oriented. In 3\[hy]d and higher, the Voronoi vertices are sorted by index. See the 'v' option for more information. .TP p Output the coordinates of each vertex point. Qhull prints the dimension, the number of points, and the coordinates for each vertex. With the 'Gc' and 'Gi' options, it also prints coplanar and interior points. For Voronoi diagrams, it prints the coordinates of each Voronoi vertex. .TP s Print a summary to stderr. If no output options are specified at all, a summary goes to stdout. The summary lists the number of input points, the dimension, the number of vertices in the convex hull, the number of facets in the convex hull, the number of good facets (if 'Pg'), and statistics. The last two statistics (if needed) measure the maximum distance from a point or vertex to a facet. The number in parenthesis (e.g., 2.1x) is the ratio between the maximum distance and the worst\[hy]case distance due to merging two simplicial facets. .PP .TP Precision options .TP An Maximum angle given as a cosine. If the angle between a pair of facet normals is greater than n, Qhull merges one of the facets into a neighbor. If 'n' is negative, Qhull tests angles after adding each point to the hull (pre\[hy]merging). If 'n' is positive, Qhull tests angles after constructing the hull (post\[hy]merging). Both pre\[hy] and post\[hy]merging can be defined. Option 'C0' or 'C\-0' is set if the corresponding 'Cn' or 'C\-n' is not set. If 'Qx' is set, then 'A\-n' and 'C\-n' are checked after the hull is constructed and before 'An' and 'Cn' are checked. .TP Cn Centrum radius. If a centrum is less than n below a neighboring facet, Qhull merges one of the facets. If 'n' is negative or '\-0', Qhull tests and merges facets after adding each point to the hull. This is called "pre\[hy]merging". If 'n' is positive, Qhull tests for convexity after constructing the hull ("post\[hy]merging"). Both pre\[hy] and post\[hy]merging can be defined. For 5\[hy]d and higher, 'Qx' should be used instead of 'C\-n'. Otherwise, most or all facets may be merged together. .TP En Maximum roundoff error for distance computations. .TP Rn Randomly perturb distance computations up to +/\- n * max_coord. This option perturbs every distance, hyperplane, and angle computation. To use time as the random number seed, use option 'QR\-1'. .TP Vn Minimum distance for a facet to be visible. A facet is visible if the distance from the point to the facet is greater than 'Vn'. Without merging, the default value for 'Vn' is the round\[hy]off error ('En'). With merging, the default value is the pre\[hy]merge centrum ('C\-n') in 2\[hy]d or 3\[hy]d, or three times that in other dimensions. If the outside width is specified ('Wn'), the maximum, default value for 'Vn' is 'Wn'. .TP Un Maximum distance below a facet for a point to be coplanar to the facet. The default value is 'Vn'. .TP Wn Minimum outside width of the hull. Points are added to the convex hull only if they are clearly outside of a facet. A point is outside of a facet if its distance to the facet is greater than 'Wn'. The normal value for 'Wn' is 'En'. If the user specifies pre\[hy]merging and does not set 'Wn', than 'Wn' is set to the premerge 'Cn' and maxcoord*(1\-An). .PP .TP Additional input/output formats .TP Fa Print area for each facet. For Delaunay triangulations, the area is the area of the triangle. For Voronoi diagrams, the area is the area of the dual facet. Use 'PAn' for printing the n largest facets, and option 'PFn' for printing facets larger than 'n'. The area for non\[hy]simplicial facets is the sum of the areas for each ridge to the centrum. Vertices far below the facet's hyperplane are ignored. The reported area may be significantly less than the actual area. .TP FA Compute the total area and volume for option 's'. It is an approximation for non\[hy]simplicial facets (see 'Fa'). .TP Fc Print coplanar points for each facet. The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of coplanar points followed by the point ids. Option 'Qi' includes the interior points. Each coplanar point (interior point) is assigned to the facet it is furthest above (resp., least below). .TP FC Print centrums for each facet. The output starts with the dimension followed by the number of facets. Then each facet centrum is printed, one per line. .TP Fd Read input in cdd format with homogeneous points. The input starts with comments. The first comment is reported in the summary. Data starts after a "begin" line. The next line is the number of points followed by the dimension+1 and "real" or "integer". Then the points are listed with a leading "1" or "1.0". The data ends with an "end" line. For halfspaces ('Fd Hn,n,...'), the input format is the same. Each halfspace starts with its offset. The sign of the offset is the opposite of Qhull's convention. .TP FD Print normals ('n', 'Fo', 'Fi') or points ('p') in cdd format. The first line is the command line that invoked Qhull. Data starts with a "begin" line. The next line is the number of normals or points followed by the dimension+1 and "real". Then the normals or points are listed with the offset before the coefficients. The offset for points is 1.0. The offset for normals has the opposite sign. The data ends with an "end" line. .TP FF Print facets (as in 'f') without printing the ridges. .TP Fi Print inner planes for each facet. The inner plane is below all vertices. .TP Fi Print separating hyperplanes for bounded, inner regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the number of indices and floats. The first pair lists adjacent input sites, the next d floats are the normalized coefficients for the hyperplane, and the last float is the offset. The hyperplane is oriented toward 'QVn' (if defined), or the first input site of the pair. Use 'Tv' to verify that the hyperplanes are perpendicular bisectors. Use 'Fo' for unbounded regions, and 'Fv' for the corresponding Voronoi vertices. .TP FI Print facet identifiers. .TP Fm Print number of merges for each facet. At most 511 merges are reported for a facet. See 'PMn' for printing the facets with the most merges. .TP FM Output the hull in Maple format. Qhull writes a Maple file for 2\[hy]d and 3\[hy]d convex hulls and for 2\[hy]d Delaunay triangulations. Qhull produces a '.mpl' file for displaying with display3d(). .TP Fn Print neighbors for each facet. The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of neighbors followed by an index for each neighbor. The indices match the other facet output formats. A negative index indicates an unprinted facet due to printing only good facets ('Pg'). It is the negation of the facet's ID (option 'FI'). For example, negative indices are used for facets "at infinity" in the Delaunay triangulation. .TP FN Print vertex neighbors or coplanar facet for each point. The first line is the number of points. Then each point is printed, one per line. If the point is coplanar, the line is "1" followed by the facet's ID. If the point is not a selected vertex, the line is "0". Otherwise, each line is the number of neighbors followed by the corresponding facet indices (see 'Fn'). .TP Fo Print outer planes for each facet in the same format as 'n'. The outer plane is above all points. .TP Fo Print separating hyperplanes for unbounded, outer regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the number of indices and floats. The first pair lists adjacent input sites, the next d floats are the normalized coefficients for the hyperplane, and the last float is the offset. The hyperplane is oriented toward 'QVn' (if defined), or the first input site of the pair. Use 'Tv' to verify that the hyperplanes are perpendicular bisectors. Use 'Fi' for bounded regions, and 'Fv' for the corresponding Voronoi vertices. .TP FO List all options to stderr, including the default values. Additional 'FO's are printed to stdout. .TP Fp Print points for halfspace intersections (option 'Hn,n,...'). Each intersection corresponds to a facet of the dual polytope. The "infinity" point [\-10.101,\-10.101,...] indicates an unbounded intersection. .TP FP For each coplanar point ('Qc') print the point ID of the nearest vertex, the point ID, the facet ID, and the distance. .TP FQ Print command used for qhull and input. .TP Fs Print a summary. The first line consists of the number of integers ("8"), followed by the dimension, the number of points, the number of vertices, the number of facets, the number of vertices selected for output, the number of facets selected for output, the number of coplanar points selected for output, number of simplicial, unmerged facets in output The second line consists of the number of reals ("2"), followed by the maxmimum offset to an outer plane and and minimum offset to an inner plane. Roundoff is included. Later versions of Qhull may produce additional integers or reals. .TP FS Print the size of the hull. The first line consists of the number of integers ("0"). The second line consists of the number of reals ("2"), followed by the total facet area, and the total volume. Later versions of Qhull may produce additional integers or reals. The total volume measures the volume of the intersection of the halfspaces defined by each facet. Both area and volume are approximations for non\[hy]simplicial facets. See option 'Fa'. .TP Ft Print a triangulation with added points for non\[hy]simplicial facets. The first line is the dimension and the second line is the number of points and the number of facets. The points follow, one per line, then the facets follow as a list of point indices. With option 'Qz', the points include the point\[hy]at\[hy]infinity. .TP Fv Print vertices for each facet. The first line is the number of facets. Then each facet is printed, one per line. Each line is the number of vertices followed by the corresponding point ids. Vertices are listed in the order they were added to the hull (the last one is first). .TP Fv Print all ridges of a Voronoi diagram. The first line is the number of ridges. Then each ridge is printed, one per line. A line starts with the number of indices. The first pair lists adjacent input sites, the remaining indices list Voronoi vertices. Vertex '0' indicates the vertex\[hy]at\[hy]infinity (i.e., an unbounded ray). In 3\[hy]d, the vertices are listed in order. See 'Fi' and 'Fo' for separating hyperplanes. .TP FV Print average vertex. The average vertex is a feasible point for halfspace intersection. .TP Fx List extreme points (vertices) of the convex hull. The first line is the number of points. The other lines give the indices of the corresponding points. The first point is '0'. In 2\[hy]d, the points occur in counter\[hy]clockwise order; otherwise they occur in input order. For Delaunay triangulations, 'Fx' lists the extreme points of the input sites. The points are unordered. .PP .TP Geomview options .TP G Produce a file for viewing with Geomview. Without other options, Qhull displays edges in 2\[hy]d, outer planes in 3\[hy]d, and ridges in 4\[hy]d. A ridge can be explicit or implicit. An explicit ridge is a dim\-1 dimensional simplex between two facets. In 4\[hy]d, the explicit ridges are triangles. When displaying a ridge in 4\[hy]d, Qhull projects the ridge's vertices to one of its facets' hyperplanes. Use 'Gh' to project ridges to the intersection of both hyperplanes. .TP Ga Display all input points as dots. .TP Gc Display the centrum for each facet in 3\[hy]d. The centrum is defined by a green radius sitting on a blue plane. The plane corresponds to the facet's hyperplane. The radius is defined by 'C\-n' or 'Cn'. .TP GDn Drop dimension n in 3\[hy]d or 4\[hy]d. The result is a 2\[hy]d or 3\[hy]d object. .TP Gh Display hyperplane intersections in 3\[hy]d and 4\[hy]d. In 3\[hy]d, the intersection is a black line. It lies on two neighboring hyperplanes (c.f., the blue squares associated with centrums ('Gc')). In 4\[hy]d, the ridges are projected to the intersection of both hyperplanes. .TP Gi Display inner planes in 2\[hy]d and 3\[hy]d. The inner plane of a facet is below all of its vertices. It is parallel to the facet's hyperplane. The inner plane's color is the opposite (1\-r,1\-g,1\-b) of the outer plane. Its edges are determined by the vertices. .TP Gn Do not display inner or outer planes. By default, Geomview displays the precise plane (no merging) or both inner and output planes (merging). Under merging, Geomview does not display the inner plane if the the difference between inner and outer is too small. .TP Go Display outer planes in 2\[hy]d and 3\[hy]d. The outer plane of a facet is above all input points. It is parallel to the facet's hyperplane. Its color is determined by the facet's normal, and its edges are determined by the vertices. .TP Gp Display coplanar points and vertices as radii. A radius defines a ball which corresponds to the imprecision of the point. The imprecision is the maximum of the roundoff error, the centrum radius, and maxcoord * (1\-An). It is at least 1/20'th of the maximum coordinate, and ignores post\[hy]merging if pre\[hy]merging is done. .TP Gr Display ridges in 3\[hy]d. A ridge connects the two vertices that are shared by neighboring facets. Ridges are always displayed in 4\[hy]d. .TP Gt A 3\[hy]d Delaunay triangulation looks like a convex hull with interior facets. Option 'Gt' removes the outside ridges to reveal the outermost facets. It automatically sets options 'Gr' and 'GDn'. .TP Gv Display vertices as spheres. The radius of the sphere corresponds to the imprecision of the data. See 'Gp' for determining the radius. .PP .TP Print options .TP PAn Only the n largest facets are marked good for printing. Unless 'PG' is set, 'Pg' is automatically set. .TP Pdk:n Drop facet from output if normal[k] <= n. The option 'Pdk' uses the default value of 0 for n. .TP PDk:n Drop facet from output if normal[k] >= n. The option 'PDk' uses the default value of 0 for n. .TP PFn Only facets with area at least 'n' are marked good for printing. Unless 'PG' is set, 'Pg' is automatically set. .TP Pg Print only good facets. A good facet is either visible from a point (the 'QGn' option) or includes a point (the 'QVn' option). It also meets the requirements of 'Pdk' and 'PDk' options. Option 'Pg' is automatically set for options 'PAn' and 'PFn'. .TP PG Print neighbors of good facets. .TP PMn Only the n facets with the most merges are marked good for printing. Unless 'PG' is set, 'Pg' is automatically set. .TP Po Force output despite precision problems. Verify ('Tv') does not check coplanar points. Flipped facets are reported and concave facets are counted. If 'Po' is used, points are not partitioned into flipped facets and a flipped facet is always visible to a point. Also, if an error occurs before the completion of Qhull and tracing is not active, 'Po' outputs a neighborhood of the erroneous facets (if any). .TP Pp Do not report precision problems. .PP .TP Qhull control options .TP Qbk:0Bk:0 Drop dimension k from the input points. This allows the user to take convex hulls of sub\[hy]dimensional objects. It happens before the Delaunay and Voronoi transformation. .TP QbB Scale the input points to fit the unit cube. After scaling, the lower bound will be \-0.5 and the upper bound +0.5 in all dimensions. For Delaunay and Voronoi diagrams, scaling happens after projection to the paraboloid. Under precise arithmetic, scaling does not change the topology of the convex hull. .TP Qbb Scale the last coordinate to [0, m] where m is the maximum absolute value of the other coordinates. For Delaunay and Voronoi diagrams, scaling happens after projection to the paraboloid. It reduces roundoff error for inputs with integer coordinates. Under precise arithmetic, scaling does not change the topology of the convex hull. .TP Qbk:n Scale the k'th coordinate of the input points. After scaling, the lower bound of the input points will be n. 'Qbk' scales to \-0.5. .TP QBk:n Scale the k'th coordinate of the input points. After scaling, the upper bound will be n. 'QBk' scales to +0.5. .TP Qc Keep coplanar points with the nearest facet. Output formats 'p', 'f', 'Gp', 'Fc', 'FN', and 'FP' will print the points. .TP Qf Partition points to the furthest outside facet. .TP Qg Only build good facets. With the 'Qg' option, Qhull will only build those facets that it needs to determine the good facets in the output. See 'QGn', 'QVn', and 'PdD' for defining good facets, and 'Pg' and 'PG' for printing good facets and their neighbors. .TP QGn A facet is good (see 'Qg' and 'Pg') if it is visible from point n. If n < 0, a facet is good if it is not visible from point n. Point n is not added to the hull (unless 'TCn' or 'TPn'). With rbox, use the 'Pn,m,r' option to define your point; it will be point 0 (QG0). .TP Qi Keep interior points with the nearest facet. Output formats 'p', 'f', 'Gp', 'FN', 'FP', and 'Fc' will print the points. .TP QJn Joggle each input coordinate by adding a random number in [\-n,n]. If a precision error occurs, then qhull increases n and tries again. It does not increase n beyond a certain value, and it stops after a certain number of attempts [see user.h]. Option 'QJ' selects a default value for n. The output will be simplicial. For Delaunay triangulations, 'QJn' sets 'Qbb' to scale the last coordinate (not if 'Qbk:n' or 'QBk:n' is set). \'QJn' is deprecated for Voronoi diagrams. See also 'Qt'. .TP Qm Only process points that would otherwise increase max_outside. Other points are treated as coplanar or interior points. .TP Qr Process random outside points instead of furthest ones. This makes Qhull equivalent to the randomized incremental algorithms. CPU time is not reported since the randomization is inefficient. .TP QRn Randomly rotate the input points. If n=0, use time as the random number seed. If n>0, use n as the random number seed. If n=\-1, don't rotate but use time as the random number seed. For Delaunay triangulations ('d' and 'v'), rotate about the last axis. .TP Qs Search all points for the initial simplex. .TP Qt Triangulated output. Triangulate all non\[hy]simplicial facets. \'Qt' is deprecated for Voronoi diagrams. See also 'Qt'. .TP Qv Test vertex neighbors for convexity after post\[hy]merging. To use the 'Qv' option, you also need to set a merge option (e.g., 'Qx' or 'C\-0'). .TP QVn A good facet (see 'Qg' and 'Pg') includes point n. If n<0, then a good facet does not include point n. The point is either in the initial simplex or it is the first point added to the hull. Option 'QVn' may not be used with merging. .TP Qx Perform exact merges while building the hull. The "exact" merges are merging a point into a coplanar facet (defined by 'Vn', 'Un', and 'C\-n'), merging concave facets, merging duplicate ridges, and merging flipped facets. Coplanar merges and angle coplanar merges ('A\-n') are not performed. Concavity testing is delayed until a merge occurs. After the hull is built, all coplanar merges are performed (defined by 'C\-n' and 'A\-n'), then post\[hy]merges are performed (defined by 'Cn' and 'An'). .TP Qz Add a point "at infinity" that is above the paraboloid for Delaunay triangulations and Voronoi diagrams. This reduces precision problems and allows the triangulation of cospherical points. .PP .TP Qhull experiments and speedups .TP Q0 Turn off pre\[hy]merging as a default option. With 'Q0'/'Qx' and without explicit pre\[hy]merge options, Qhull ignores precision issues while constructing the convex hull. This may lead to precision errors. If so, a descriptive warning is generated. .TP Q1 With 'Q1', Qhull sorts merges by type (coplanar, angle coplanar, concave) instead of by angle. .TP Q2 With 'Q2', Qhull merges all facets at once instead of using independent sets of merges and then retesting. .TP Q3 With 'Q3', Qhull does not remove redundant vertices. .TP Q4 With 'Q4', Qhull avoids merges of an old facet into a new facet. .TP Q5 With 'Q5', Qhull does not correct outer planes at the end. The maximum outer plane is used instead. .TP Q6 With 'Q6', Qhull does not pre\[hy]merge concave or coplanar facets. .TP Q7 With 'Q7', Qhull processes facets in depth\[hy]first order instead of breadth\[hy]first order. .TP Q8 With 'Q8' and merging, Qhull does not retain near\[hy]interior points for adjusting outer planes. 'Qc' will probably retain all points that adjust outer planes. .TP Q9 With 'Q9', Qhull processes the furthest of all outside sets at each iteration. .TP Q10 With 'Q10', Qhull does not use special processing for narrow distributions. .TP Q11 With 'Q11', Qhull copies normals and recompute centrums for tricoplanar facets. .TP Q12 With 'Q12', Qhull does not report a very wide merge due to a duplicated ridge with nearly coincident vertices Q14 With 'Q14', Qhull does not rename vertices that create a duplicate ridge .PP .TP Trace options .TP Tn Trace at level n. Qhull includes full execution tracing. 'T\-1' traces events. 'T1' traces the overall execution of the program. 'T2' and 'T3' trace overall execution and geometric and topological events. 'T4' traces the algorithm. 'T5' includes information about memory allocation and Gaussian elimination. .TP Ta Annotate output with codes that identify the corresponding qh_fprintf() statement. .TP Tc Check frequently during execution. This will catch most inconsistency errors. .TP TCn Stop Qhull after building the cone of new facets for point n. The output for 'f' includes the cone and the old hull. See also 'TVn'. .TP TFn Report progress whenever more than n facets are created During post\[hy]merging, 'TFn' reports progress after more than n/2 merges. .TP TI file Input data from 'file'. The filename may not include spaces or quotes. .TP TO file Output results to 'file'. The name may be enclosed in single quotes. .TP TPn Turn on tracing when point n is added to the hull. Trace partitions of point n. If used with TWn, turn off tracing after adding point n to the hull. .TP TRn Rerun qhull n times. Usually used with 'QJn' to determine the probability that a given joggle will fail. .TP Ts Collect statistics and print to stderr at the end of execution. .TP Tv Verify the convex hull. This checks the topological structure, facet convexity, and point inclusion. If precision problems occurred, facet convexity is tested whether or not 'Tv' is selected. Option 'Tv' does not check point inclusion if forcing output with 'Po', or if 'Q5' is set. For point inclusion testing, Qhull verifies that all points are below all outer planes (facet\->maxoutside). Point inclusion is exhaustive if merging or if the facet\[hy]point product is small enough; otherwise Qhull verifies each point with a directed search (qh_findbest). Point inclusion testing occurs after producing output. It prints a message to stderr unless option 'Pp' is used. This allows the user to interrupt Qhull without changing the output. .TP TVn Stop Qhull after adding point n. If n < 0, stop Qhull before adding point n. Output shows the hull at this time. See also 'TCn' .TP TMn Turn on tracing at n'th merge. .TP TWn Trace merge facets when the width is greater than n. .TP Tz Redirect stderr to stdout. .PP .SH BUGS Please report bugs to Brad Barber at qhull_bug@qhull.org. If Qhull does not compile, it is due to an incompatibility between your system and ours. The first thing to check is that your compiler is ANSI standard. If it is, check the man page for the best options, or find someone to help you. If you locate the cause of your problem, please send email since it might help others. If Qhull compiles but crashes on the test case (rbox D4), there's still incompatibility between your system and ours. Typically it's been due to mem.c and memory alignment. You can use qh_NOmem in mem.h to turn off memory management. Please let us know if you figure out how to fix these problems. If you do find a problem, try to simplify it before reporting the error. Try different size inputs to locate the smallest one that causes an error. You're welcome to hunt through the code using the execution trace as a guide. This is especially true if you're incorporating Qhull into your own program. When you do report an error, please attach a data set to the end of your message. This allows us to see the error for ourselves. Qhull is maintained part\[hy]time. .PP .SH E\[hy]MAIL Please send correspondence to qhull@qhull.org and report bugs to qhull_bug@qhull.org. Let us know how you use Qhull. If you mention it in a paper, please send the reference and an abstract. If you would like to get Qhull announcements (e.g., a new version) and news (any bugs that get fixed, etc.), let us know and we will add you to our mailing list. If you would like to communicate with other Qhull users, we will add you to the qhull_users alias. For Internet news about geometric algorithms and convex hulls, look at comp.graphics.algorithms and sci.math.num\-analysis .SH SEE ALSO rbox(1) Barber, C. B., D.P. Dobkin, and H.T. Huhdanpaa, "The Quickhull Algorithm for Convex Hulls," ACM Trans. on Mathematical Software, 22(4):469\[en]483, Dec. 1996. http://portal.acm.org/citation.cfm?doid=235815.235821 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.117.405 Clarkson, K.L., K. Mehlhorn, and R. Seidel, "Four results on randomized incremental construction," Computational Geometry: Theory and Applications, vol. 3, p. 185\[en]211, 1993. Preparata, F. and M. Shamos, Computational Geometry, Springer\[hy]Verlag, New York, 1985. .PP .SH AUTHORS .nf C. Bradford Barber Hannu Huhdanpaa bradb@shore.net hannu@qhull.org .fi .SH ACKNOWLEDGEMENTS A special thanks to Albert Marden, Victor Milenkovic, the Geometry Center, Harvard University, and Endocardial Solutions, Inc. for supporting this work. Qhull 1.0 and 2.0 were developed under National Science Foundation grants NSF/DMS\[hy]8920161 and NSF\[hy]CCR\[hy]91\[hy]15793 750\[hy]7504. David Dobkin guided the original work at Princeton University. If you find it useful, please let us know. The Geometry Center is supported by grant DMS\[hy]8920161 from the National Science Foundation, by grant DOE/DE\[hy]FG02\[hy]92ER25137 from the Department of Energy, by the University of Minnesota, and by Minnesota Technology, Inc. Qhull is available from http://www.qhull.org geometry/vignettes/qhull/html/qhull.html0000644000176200001440000004560014664417655020250 0ustar liggesusers qhull -- convex hull and related structures

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • options


[cone]qhull -- convex hull and related structures

The convex hull of a set of points is the smallest convex set containing the points. The Delaunay triangulation and furthest-site Delaunay triangulation are equivalent to a convex hull in one higher dimension. Halfspace intersection about a point is equivalent to a convex hull by polar duality.

The qhull program provides options to build these structures and to experiment with the process. Use the qconvex, qdelaunay, qhalf, and qvoronoi programs to build specific structures. You may use qhull instead. It takes the same options and uses the same code.

Example: rbox 1000 D3 | qhull C-1e-4 FO Ts
Compute the 3-d convex hull of 1000 random points. Centrums must be 10^-4 below neighboring hyperplanes. Print the options and precision constants. When done, print statistics. These options may be used with any of the Qhull programs.
 
Example: rbox 1000 D3 | qhull d Qbb R1e-4 Q0
Compute the 3-d Delaunay triangulation of 1000 random points. Randomly perturb all calculations by [0.9999,1.0001]. Do not correct precision problems. This leads to serious precision errors.

Use the following equivalences when calling qhull:

By default, Qhull merges coplanar facets. For example, the convex hull of a cube's vertices has six facets.

If you use 'Qt' (triangulated output), all facets will be simplicial (e.g., triangles in 2-d). For the cube example, it will have 12 facets. Some facets may be degenerate and have zero area.

If you use 'QJ' (joggled input), all facets will be simplicial. The corresponding vertices will be slightly perturbed. Joggled input is less accurate that triangulated output.See Merged facets or joggled input.

The output for 4-d convex hulls may be confusing if the convex hull contains non-simplicial facets (e.g., a hypercube). See Why are there extra points in a 4-d or higher convex hull?

Copyright © 1995-2020 C.B. Barber


»qhull synopsis

qhull -- compute convex hulls and related structures.
    input (stdin): dimension, number of points, point coordinates
    comments start with a non-numeric character
    halfspace: use dim+1 and put offsets after coefficients

options:
    d    - Delaunay triangulation by lifting points to a paraboloid
    d Qu - furthest-site Delaunay triangulation (upper convex hull)
    v    - Voronoi diagram as the dual of the Delaunay triangulation
    v Qu - furthest-site Voronoi diagram
    H1,1 - Halfspace intersection about [1,1,0,...] via polar duality
    Qt   - triangulated output
    QJ   - joggled input instead of merged facets
    Tv   - verify result: structure, convexity, and point inclusion
    .    - concise list of all options
    -    - one-line description of each option
    -?   - this message
    -V   - version

Output options (subset):
    s    - summary of results (default)
    i    - vertices incident to each facet
    n    - normals with offsets
    p    - vertex coordinates (if 'Qc', includes coplanar points)
           if 'v', Voronoi vertices
    FA   - report total area and volume
    Fp   - halfspace intersections
    FS   - total area and volume
    Fx   - extreme points (convex hull vertices)
    G    - Geomview output (2-d, 3-d and 4-d)
    m    - Mathematica output (2-d and 3-d)
    o    - OFF format (if 'v', outputs Voronoi regions)
    QVn  - print facets that include point n, -n if not
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes

examples:
    rbox D4 | qhull Tv                        rbox 1000 s | qhull Tv s FA
    rbox 10 D2 | qhull d QJ s i TO result     rbox 10 D2 | qhull v Qbb Qt p
    rbox 10 D2 | qhull d Qu QJ m              rbox 10 D2 | qhull v Qu QJ o
    rbox c d D2 | qhull Qc s f Fx | more      rbox c | qhull FV n | qhull H Fp
    rbox d D12 | qhull QR0 FA                 rbox c D7 | qhull FA TF1000
    rbox y 1000 W0 | qhull Qc                 rbox c | qhull n

»qhull input

The input data on stdin consists of:

  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qhull < data.txt), a pipe (e.g., rbox 10 | qhull), or the 'TI' option (e.g., qhull TI data.txt).

Comments start with a non-numeric character. Error reporting is simpler if there is one point per line. Dimension and number of points may be reversed. For halfspace intersection, an interior point may be prepended (see qhalf input).

Here is the input for computing the convex hull of the unit cube. The output is the normals, one per facet.

rbox c > data

3 RBOX c
8
  -0.5   -0.5   -0.5
  -0.5   -0.5    0.5
  -0.5    0.5   -0.5
  -0.5    0.5    0.5
   0.5   -0.5   -0.5
   0.5   -0.5    0.5
   0.5    0.5   -0.5
   0.5    0.5    0.5

qhull s n < data


Convex hull of 8 points in 3-d:

  Number of vertices: 8
  Number of facets: 6
  Number of non-simplicial facets: 6

Statistics for: RBOX c | QHULL s n

  Number of points processed: 8
  Number of hyperplanes created: 11
  Number of distance tests for qhull: 35
  Number of merged facets: 6
  Number of distance tests for merging: 84
  CPU seconds to compute hull (after input): 0.081

4
6
     0      0     -1   -0.5
     0     -1      0   -0.5
     1      0      0   -0.5
    -1      0      0   -0.5
     0      1      0   -0.5
     0      0      1   -0.5

»qhull outputs

These options control the output of qhull. They may be used individually or together.

 
General
qhull
compute the convex hull of the input points. See qconvex.
qhull d Qbb
compute the Delaunay triangulation by lifting the points to a paraboloid. Use option 'Qbb' to scale the paraboloid and improve numeric precision. See qdelaunay.
qhull v Qbb
compute the Voronoi diagram by computing the Delaunay triangulation. Use option 'Qbb' to scale the paraboloid and improve numeric precision. See qvoronoi.
qhull H
compute the halfspace intersection about a point via polar duality. The point is below the hyperplanes that defines the halfspace. See qhalf.

For a full list of output options see

»qhull controls

For a full list of control options see

»qhull options

qhull -- compute convex hulls and related structures.
    http://www.qhull.org

input (stdin):
    first lines: dimension and number of points (or vice-versa).
    other lines: point coordinates, best if one point per line
    comments:    start with a non-numeric character
    halfspaces:  use dim plus one and put offset after coefficients.
                 May be preceded by a single interior point ('H').

options:
    d    - Delaunay triangulation by lifting points to a paraboloid
    d Qu - furthest-site Delaunay triangulation (upper convex hull)
    Hn,n,... - halfspace intersection about point [n,n,0,...]
    Qc   - keep coplanar points with nearest facet
    Qi   - keep interior points with nearest facet
    QJ   - joggled input instead of merged facets
    Qt   - triangulated output
    v    - Voronoi diagram (dual of the Delaunay triangulation)
    v Qu - furthest-site Voronoi diagram

Qhull control options:
    Qa   - allow input with fewer or more points than coordinates
    Qbk:n   - scale coord k so that low bound is n
      QBk:n - scale coord k so that upper bound is n (QBk is 0.5)
    QbB  - scale input to unit cube centered at the origin
    Qbb  - scale last coordinate to [0,m] for Delaunay triangulations
    Qbk:0Bk:0 - remove k-th coordinate from input
    QJn  - randomly joggle input in range [-n,n]
    QRn  - random rotation (n=seed, n=0 time, n=-1 time/no rotate)
    Qs   - search all points for the initial simplex
    Qu   - for 'd' or 'v', compute upper hull without point at-infinity
              returns furthest-site Delaunay triangulation
    QVn  - good facet if it includes point n, -n if not
    Qx   - exact pre-merges (skips coplanar and angle-coplanar facets)
    Qz   - add point-at-infinity to Delaunay triangulation

Qhull extra options:
    Qf   - partition point to furthest outside facet
    Qg   - only build good facets (needs 'QGn', 'QVn', or 'PdD')
    QGn  - good facet if visible from point n, -n for not visible
    Qm   - only process points that would increase max_outside
    Qr   - process random outside points instead of furthest ones
    Qv   - test vertex neighbors for convexity
    Qw   - allow option warnings
    Q0   - turn off default premerge with 'C-0'/'Qx'
    Q1   - merge by mergetype/angle instead of mergetype/distance
    Q2   - merge all coplanar facets instead of merging independent sets
    Q3   - do not merge redundant vertices
    Q4   - avoid old->new merges
    Q5   - do not correct outer planes at end of qhull
    Q6   - do not pre-merge concave or coplanar facets
    Q7   - depth-first processing instead of breadth-first
    Q8   - do not process near-inside points
    Q9   - process furthest of furthest points
    Q10  - no special processing for narrow distributions
    Q11  - copy normals and recompute centrums for tricoplanar facets
    Q12  - allow wide facets and wide dupridge
    Q14  - merge pinched vertices that create a dupridge
    Q15  - check for duplicate ridges with the same vertices

T options:
    TFn  - report summary when n or more facets created
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes
    Ts   - statistics
    Tv   - verify result: structure, convexity, and point inclusion
    Tz   - send all output to stdout

Trace options:
    T4   - trace at level n, 4=all, 5=mem/gauss, -1= events
    Ta   - annotate output with message codes
    TAn  - stop qhull after adding n vertices
     TCn - stop qhull after building cone for point n
     TVn - stop qhull after adding point n, -n for before
    Tc   - check frequently during execution
    Tf   - flush each qh_fprintf for debugging segfaults
    TPn  - turn on tracing when point n added to hull
     TP-1  turn on tracing after qh_buildhull and qh_postmerge
     TMn - turn on tracing at merge n
     TWn - trace merge facets when width > n
    TRn  - rerun qhull n times for statistics to adjust 'QJn'

Precision options:
    Cn   - radius of centrum (roundoff added).  Merge facets if non-convex
     An  - cosine of maximum angle.  Merge facets if cosine > n or non-convex
           C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge
    En   - max roundoff error for distance computation
    Rn   - randomly perturb computations by a factor of [1-n,1+n]
    Vn   - min distance above plane for a visible facet (default 3C-n or En)
    Un   - max distance below plane for a new, coplanar point (default Vn)
    Wn   - min facet width for outside point (before roundoff, default 2Vn)

Output formats (may be combined; if none, produces a summary to stdout):
    f    - facet dump
    G    - Geomview output (see below)
    i    - vertices incident to each facet
    m    - Mathematica output (2-d and 3-d)
    n    - normals with offsets
    o    - OFF format (dim, points and facets; Voronoi regions)
    p    - vertex coordinates or Voronoi vertices (coplanar points if 'Qc')
    s    - summary (stderr)

More formats:
    Fa   - area for each facet
    FA   - compute total area and volume for option 's'
    Fc   - count plus coplanar points for each facet
           use 'Qc' (default) for coplanar and 'Qi' for interior
    FC   - centrum or Voronoi center for each facet
    Fd   - use cdd format for input (homogeneous with offset first)
    FD   - use cdd format for numeric output (offset first)
    FF   - facet dump without ridges
    Fi   - inner plane for each facet
           for 'v', separating hyperplanes for bounded Voronoi regions
    FI   - ID of each facet
    Fm   - merge count for each facet (511 max)
    FM   - Maple output (2-d and 3-d)
    Fn   - count plus neighboring facets for each facet
    FN   - count plus neighboring facets for each point
    Fo   - outer plane (or max_outside) for each facet
           for 'v', separating hyperplanes for unbounded Voronoi regions
    FO   - options and precision constants
    Fp   - dim, count, and intersection coordinates (halfspace only)
    FP   - nearest vertex and distance for each coplanar point
    FQ   - command used for qhull
    Fs   - summary: #int (8), dimension, #points, tot vertices, tot facets,
                      output: #vertices, #facets, #coplanars, #nonsimplicial
                    #real (2), max outer plane, min vertex
    FS   - sizes:   #int (0)
                    #real (2) tot area, tot volume
    Ft   - triangulation with centrums for non-simplicial facets (OFF format)
    Fv   - count plus vertices for each facet
           for 'v', Voronoi diagram as Voronoi vertices for pairs of sites
    FV   - average of vertices (a feasible point for 'H')
    Fx   - extreme points (in order for 2-d)

Geomview output (2-d, 3-d, and 4-d; 2-d Voronoi)
    Ga   - all points as dots
     Gp  -  coplanar points and vertices as radii
     Gv  -  vertices as spheres
    Gc   - centrums
    GDn  - drop dimension n in 3-d and 4-d output
    Gh   - hyperplane intersections
    Gi   - inner planes only
     Gn  -  no planes
     Go  -  outer planes only
    Gr   - ridges
    Gt   - for 3-d 'd', transparent outer ridges

Print options:
    PAn  - keep n largest facets by area
    Pdk:n - drop facet if normal[k] <= n (default 0.0)
    PDk:n - drop facet if normal[k] >= n
    PFn  - keep facets whose area is at least n
    Pg   - print good facets (needs 'QGn' or 'QVn')
    PG   - print neighbors of good facets
    PMn  - keep n facets with most merges
    Po   - force output.  If error, output neighborhood of facet
    Pp   - do not report precision problems

    .    - list of all options
    -    - one line descriptions of all options
    -?   - help with examples
    -V   - version

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/vignettes/qhull/index.html0000644000176200001440000003603314664417655017266 0ustar liggesusers Qhull code for Convex Hull, Delaunay Triangulation, Voronoi Diagram, and Halfspace Intersection about a Point URL: http://www.qhull.orgNewsScholarImagesGitHub
To: DownloadReadmeManualProgramsOptionsFAQCodeFunctions


Qhull

[CONE]
Qhull computes the convex hull, Delaunay triangulation, Voronoi diagram, halfspace intersection about a point, furthest-site Delaunay triangulation, and furthest-site Voronoi diagram. The source code runs in 2-d, 3-d, 4-d, and higher dimensions. Qhull implements the Quickhull algorithm for computing the convex hull. It handles roundoff errors from floating point arithmetic. It computes volumes, surface areas, and approximations to the convex hull.

Qhull does not support triangulation of non-convex surfaces, mesh generation of non-convex objects, medium-sized inputs in 9-D and higher, alpha shapes, weighted Voronoi diagrams, Voronoi volumes, or constrained Delaunay triangulations,

If you call Qhull from your program, please use reentrant Qhull (libqhull_r or libqhullstatic_r). If you use Qhull 2003.1, please upgrade or apply poly.c-qh_gethash.patch.


Introduction

Qhull Documentation and Support

Related URLs

FAQs and Newsgroups


The program includes options for input transformations, randomization, tracing, multiple output formats, and execution statistics. The program can be called from within your application.

You can view the results in 2-d, 3-d and 4-d with Geomview. An alternative is VTK.

For an article about Qhull, download from ACM or CiteSeer:

Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., "The Quickhull algorithm for convex hulls," ACM Trans. on Mathematical Software, 22(4):469-483, Dec 1996, http://www.qhull.org

Abstract:

The convex hull of a set of points is the smallest convex set that contains the points. This article presents a practical convex hull algorithm that combines the two-dimensional Quickhull Algorithm with the general dimension Beneath-Beyond Algorithm. It is similar to the randomized, incremental algorithms for convex hull and Delaunay triangulation. We provide empirical evidence that the algorithm runs faster when the input contains non-extreme points, and that it uses less memory.

Computational geometry algorithms have traditionally assumed that input sets are well behaved. When an algorithm is implemented with floating point arithmetic, this assumption can lead to serious errors. We briefly describe a solution to this problem when computing the convex hull in two, three, or four dimensions. The output is a set of "thick" facets that contain all possible exact convex hulls of the input. A variation is effective in five or more dimensions.


Up: Past Software Projects of the Geometry Center
URL: http://www.qhull.orgNewsScholarImagesGitHub
To: DownloadReadmeManualProgramsOptionsFAQCodeFunctions


[HOME] The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: May 17 1995 --- geometry/vignettes/qhull/COPYING.txt0000644000176200001440000000314313431000557017112 0ustar liggesusers Qhull, Copyright (c) 1993-2018 C.B. Barber Arlington, MA and The National Science and Technology Research Center for Computation and Visualization of Geometric Structures (The Geometry Center) University of Minnesota email: qhull@qhull.org This software includes Qhull from C.B. Barber and The Geometry Center. Qhull is copyrighted as noted above. Qhull is free software and may be obtained via http from www.qhull.org. It may be freely copied, modified, and redistributed under the following conditions: 1. All copyright notices must remain intact in all files. 2. A copy of this text file must be distributed along with any copies of Qhull that you redistribute; this includes copies that you have modified, or copies of programs or other software products that include Qhull. 3. If you modify Qhull, you must include a notice giving the name of the person performing the modification, the date of modification, and the reason for such modification. 4. When distributing modified versions of Qhull, or other software products that include Qhull, you must provide notice that the original source code may be obtained as noted above. 5. There is no warranty or other guarantee of fitness for Qhull, it is provided solely "as is". Bug reports or fixes may be sent to qhull_bug@qhull.org; the authors may or may not act on them as they desire. geometry/vignettes/qhull/Announce.txt0000644000176200001440000000420713431000557017552 0ustar liggesusers Qhull 2015.2 2016/01/18 http://www.qhull.org git@github.com:qhull/qhull.git http://www.geomview.org Qhull computes convex hulls, Delaunay triangulations, Voronoi diagrams, furthest-site Voronoi diagrams, and halfspace intersections about a point. It runs in 2-d, 3-d, 4-d, or higher. It implements the Quickhull algorithm for computing convex hulls. Qhull handles round-off errors from floating point arithmetic. It can approximate a convex hull. The program includes options for hull volume, facet area, partial hulls, input transformations, randomization, tracing, multiple output formats, and execution statistics. The program can be called from within your application. You can view the results in 2-d, 3-d and 4-d with Geomview. To download Qhull: http://www.qhull.org/download git@github.com:qhull/qhull.git Download qhull-96.ps for: Barber, C. B., D.P. Dobkin, and H.T. Huhdanpaa, "The Quickhull Algorithm for Convex Hulls," ACM Trans. on Mathematical Software, 22(4):469-483, Dec. 1996. http://portal.acm.org/citation.cfm?doid=235815.235821 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.117.405 Abstract: The convex hull of a set of points is the smallest convex set that contains the points. This article presents a practical convex hull algorithm that combines the two-dimensional Quickhull Algorithm with the general dimension Beneath-Beyond Algorithm. It is similar to the randomized, incremental algorithms for convex hull and Delaunay triangulation. We provide empirical evidence that the algorithm runs faster when the input contains non-extreme points, and that it uses less memory. Computational geometry algorithms have traditionally assumed that input sets are well behaved. When an algorithm is implemented with floating point arithmetic, this assumption can lead to serious errors. We briefly describe a solution to this problem when computing the convex hull in two, three, or four dimensions. The output is a set of "thick" facets that contain all possible exact convex hulls of the input. A variation is effective in five or more dimensions. geometry/vignettes/LICENSE-NOTES0000644000176200001440000000042314664417655016031 0ustar liggesusersAll files in src/ apart from Rgeometry.c, Rgeometry.h, Rconvhulln.c, Rdelaunayn.c Rtsearchn.c, Rtsearch_orig.c, Rtsearch.cpp, RcppExports.cpp, Rinhulln.c, Rhalfspacen.c and geometry_init.c are taken from or based on Qhull (http://www.qhull.org/), and covered by COPYING.txt. geometry/vignettes/qhull-eg-002.pdf0000644000176200001440000000703313431000557016626 0ustar liggesusers%PDF-1.4 %âãÏÓ\r 1 0 obj << /CreationDate (D:20190212155337) /ModDate (D:20190212155337) /Title (R Graphics Output) /Producer (R 3.5.2) /Creator (R) >> endobj 2 0 obj << /Type /Catalog /Pages 3 0 R >> endobj 3 0 obj << /Type /Pages /Kids [ ] /Count 0 /MediaBox [0 0 432 432] >> endobj 4 0 obj << /ProcSet [/PDF /Text] /Font <<>> /ExtGState << >> /ColorSpace << /sRGB 5 0 R >> >> endobj 5 0 obj [/ICCBased 6 0 R] endobj 6 0 obj << /Alternate /DeviceRGB /N 3 /Length 2596 /Filter /FlateDecode >> stream xœ–wTSهϽ7½P’Š”ÐkhRH ½H‘.*1 JÀ"6DTpDQ‘¦2(à€£C‘±"Š…Q±ëDÔqp–Id­ß¼yïÍ›ß÷~kŸ½ÏÝgï}ÖºüƒÂLX € ¡Xáçň‹g` ðlàp³³BøF™|ØŒl™ø½º ùû*Ó?ŒÁÿŸ”¹Y"1P˜ŒçòøÙ\É8=Wœ%·Oɘ¶4MÎ0JÎ"Y‚2V“sò,[|ö™e9ó2„<ËsÎâeðäÜ'ã9¾Œ‘`çø¹2¾&cƒtI†@Æoä±|N6(’Ü.æsSdl-c’(2‚-ãyàHÉ_ðÒ/XÌÏËÅÎÌZ.$§ˆ&\S†“‹áÏÏMç‹ÅÌ07#â1Ø™YárfÏüYym²";Ø8980m-m¾(Ô]ü›’÷v–^„îDøÃöW~™ °¦eµÙú‡mi]ëP»ý‡Í`/в¾u}qº|^RÄâ,g+«ÜÜ\KŸk)/èïúŸC_|ÏR¾Ýïåaxó“8’t1C^7nfz¦DÄÈÎâpù 柇øþuü$¾ˆ/”ED˦L L–µ[Ȉ™B†@øŸšøÃþ¤Ù¹–‰ÚøЖX¥!@~(* {d+Ðï} ÆGù͋љ˜ûÏ‚þ}W¸LþÈ$ŽcGD2¸QÎìšüZ4 E@ê@èÀ¶À¸àA(ˆq`1à‚D €µ ”‚­`'¨u 4ƒ6ptcà48.Ë`ÜR0ž€)ð Ì@„…ÈR‡t CȲ…XäCP”%CBH@ë R¨ª†ê¡fè[è(tº C· Qhúz#0 ¦ÁZ°l³`O8Ž„ÁÉð28.‚·À•p|î„O×àX ?§€:¢‹0ÂFB‘x$ !«¤i@Ú¤¹ŠH‘§È[EE1PL” Ê…⢖¡V¡6£ªQP¨>ÔUÔ(j õMFk¢ÍÑÎèt,:‹.FW ›Ðè³èô8úƒ¡cŒ1ŽL&³³³ÓŽ9…ÆŒa¦±X¬:ÖëŠ År°bl1¶ {{{;Ž}ƒ#âtp¶8_\¡8áú"ãEy‹.,ÖXœ¾øøÅ%œ%Gщ1‰-‰ï9¡œÎôÒ€¥µK§¸lî.îžoo’ïÊ/çO$¹&•'=JvMÞž<™âžR‘òTÀT ž§ú§Ö¥¾N MÛŸö)=&½=—‘˜qTH¦ û2µ3ó2‡³Ì³Š³¤Ëœ—í\6% 5eCÙ‹²»Å4ÙÏÔ€ÄD²^2šã–S“ó&7:÷Hžrž0o`¹ÙòMË'ò}ó¿^ZÁ]Ñ[ [°¶`t¥çÊúUЪ¥«zWë¯.Z=¾Æo͵„µik(´.,/|¹.f]O‘VÑš¢±õ~ë[‹ŠEÅ76¸l¨ÛˆÚ(Ø8¸iMKx%K­K+Jßoæn¾ø•ÍW•_}Ú’´e°Ì¡lÏVÌVáÖëÛÜ·(W.Ï/Û²½scGÉŽ—;—ì¼PaWQ·‹°K²KZ\Ù]ePµµê}uJõHWM{­fí¦Ú×»y»¯ìñØÓV§UWZ÷n¯`ïÍz¿úΣ†Š}˜}9û6F7öÍúº¹I£©´éÃ~á~éˆ}ÍŽÍÍ-š-e­p«¤uò`ÂÁËßxÓÝÆl«o§·—‡$‡›øíõÃA‡{°Ž´}gø]mµ£¤ê\Þ9Õ•Ò%íŽë>x´·Ç¥§ã{Ëï÷Ó=Vs\åx٠‰¢ŸN柜>•uêééäÓc½Kz=s­/¼oðlÐÙóç|Ïé÷ì?yÞõü± ÎŽ^d]ìºäp©sÀ~ ãû:;‡‡º/;]îž7|âŠû•ÓW½¯ž»píÒÈü‘áëQ×oÞH¸!½É»ùèVú­ç·snÏÜYs}·äžÒ½Šûš÷~4ý±]ê =>ê=:ð`Áƒ;cܱ'?eÿô~¼è!ùaÅ„ÎDó#ÛGÇ&}'/?^øxüIÖ“™§Å?+ÿ\ûÌäÙw¿xü20;5þ\ôüÓ¯›_¨¿ØÿÒîeïtØôýW¯f^—¼Qsà-ëmÿ»˜w3¹ï±ï+?˜~èùôñî§ŒOŸ~÷„óûendstream endobj 7 0 obj << /Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [ 45/minus 96/quoteleft 144/dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron /space] >> endobj xref 0 8 0000000000 65535 f 0000000021 00000 n 0000000163 00000 n 0000000212 00000 n 0000000289 00000 n 0000000390 00000 n 0000000423 00000 n 0000003118 00000 n trailer << /Size 8 /Info 1 0 R /Root 2 0 R >> startxref 3375 %%EOF geometry/vignettes/MODIFIED.txt0000644000176200001440000000162314664417655016062 0ustar liggesusersmodified function file line# date by reason ================= ==== ===== ==== == ====== qh_exit usermem_r.c 45 2012/04/03 David Sterratt To fix warnings about exit being called qh_printf_stderr usermem_r.c 71 2024/08/26 David Sterratt Use REprintf to print error messages qh_printf_stderr usermem_r.c 74 2024/08/26 David Sterratt Use REprintf to print error messages qh_option global_r.c 2234 2024/08/26 David Sterratt Use snprintf instead of sprintf qh_option global_r.c 2236 2024/08/26 David Sterratt Use snprintf instead of sprintf qh_option global_r.c 2238 2024/08/26 David Sterratt Use snprintf instead of sprintf qh_rboxpoints2 rboxlib_r.c 375 2024/08/26 David Sterratt Use snprintf instead of sprintf geometry/vignettes/.install_extras0000644000176200001440000000004114662727570017165 0ustar liggesusersLICENSE-NOTES MODIFIED.txt qhull$geometry/vignettes/qhull-eg-004.pdf0000644000176200001440000001415213431000557016630 0ustar liggesusers%PDF-1.4 %âãÏÓ\r 1 0 obj << /CreationDate (D:20190212154401) /ModDate (D:20190212154401) /Title (R Graphics Output) /Producer (R 3.5.2) /Creator (R) >> endobj 2 0 obj << /Type /Catalog /Pages 3 0 R >> endobj 7 0 obj << /Type /Page /Parent 3 0 R /Contents 8 0 R /Resources 4 0 R >> endobj 8 0 obj << /Length 2195 /Filter /FlateDecode >> stream xœ¥[Ë®\·ÜÏWœìÀ¦ÙÝ|nm$ $€¢ x!Y(Á")@~?Uäܹcyr­©,4Ò‡C²Ùªî>v|Øñöøpzq|8êL¹=R)GOÝŸ3U?>þxüp¼?}óé/üöøîå)§^êqýùò»?óëñŸÓ«×G>þv²ã{üy{²œr>þtúöáôÍ Ë=üžÊÀ7óþ‡¹§6ÇòmïŽßþô»ãá-†>ž~ÿð«Ó³¥Ùލ‘† Ógá<ë9*Lo%?Â{šÂê>Jšýp›©•û§÷™ {Ÿ5•vÿì€äFÁâ=yŽ^zí°ð4B8:$ƒG¸¶•”'7ŠÿþéµQ7-J².Ƚ¦Qˆ¿ ³ Ó'öÐŒw/È=’ÃN3ÌF¸uÏP9 Ã:‹rë­¦hë E¸u3§à½EÊÂÙ½dn> ìEѹê©Bk¼¥ŒÝK¥ä—ÇQ6?àY ›(´áÞkÊíp¼€»§ÃÏY@ð=™àiÂ`h‚‡ŸS´Î=’›tõ÷Û[æ}šš`ëA Ø ¬U‰/XÀÜ¥LQø'›±‰HU\ŒÌ¨H¯¸É¨ƒ.ÊH®Lw{¼|)¶"&Sáá2¦¢sÔô …/©šröÊy o&Ü»`Lf QÎî3sõ0¸Kez/tÏÆ³+žÊCù$“ÁXä*9ºˆ‘*|ÍhÉ?9àpïc¦.X\ À1:Ï&E¨èg‡'8øÙÞVˆŠÖaõN'µ÷¯î•Ên¿¢¬>á.`2@³¡ˆ®mOkCr•l0q.Ø»!®:´nÏpÿê¾l…Q¶) $Èr“"œÃYu@‹˜ä`‚ä-ž?ØtŠœLLb1@á­ot¥ R 9§º㆑þ‰… y¬áâ¼ [2Æ÷ÂûV©“Ç„DDè*qv‡½+~Þó ì„eSQZ8« ¥…òI›‡¡“„Áì'ñòÖ(Aaº­ø@Õ] 5L´…(ygl\ZqÐÑPw%¾cuˆÎŠvq *ÏœG¥ò{ß‹c¡ìÊêmˆZ3H‘N!”Ñ]– 5c‡¨¼ˆ  syȪE¸‡ËÐx„¨P$¨H' kÄ÷k<üsé¸ö‘Š`oØõÔòÁL¼ôìŒñZÂ'V¾H!ϙמ¥¬" `‘ÁMJ ŒÜŽ* T5ʆEˆŠà}A ò˜¬¬^ÓLÌ´ArQŒÊН uÏËá(×à åÉä4dËZ¡4]Ád°”ØAr*~<$H_ƒ¿"åéÜ—§’âî±¹k)›h+Kè>%kça×ÁL§rïcÐu«±2ˆgÌQ­–,ÃæëÔ¨»M€Ý¹él™;KP¦œ1±Ê´ƒ ÆÊˆû¬RzÖ™ìšB„RÅ¢Àéf§èH~€j,š„ÈÑ’à&”éíž×_YÂT%Í*'-à© Ó=F)ðöXÜ>¾)¡=/ʼ*u;4¶I8fXB0ª É c¢Ë¥êá¾51¼‘<€‚ÔLÅOí]RIr‡w]©å!Á¸†'XMUô›ys Ü“³ð±Rž ö26ïu N ZÉkø2T–Éuå쫊µŠý ®È+3I¢€¢†¦±{‘*Þ–3‰)ñ X¬úŽ­ŠÚÔ²EµÒÙ7¦RR„±¡‹ÖJùq,4€“Rf¸-æjejp²¶'k•ŠhÊJ, •W³âž&Rx³1°!¾¡¥váåÛ„»ÍRZ›ïÑ7ÅÞ[æn4QTœ4 *ÕG¸I"ªš¥,«5/¹ ÏQUm Nê­)ËIûlZ9 ìL™FKpÝ„áÒÑ ÝÅÈÎ:LÄBãJÕf[~Šº[Ù „hPÁDXE_W°+¦ ¶‚JHE_V@Ý*mB¦§/ ¥QŒ•1™5c0WD¯Òš§1ÐÞÞy.ʽC×™Y…”†°È«ÜN­ËŠÎ¶•0€”V;ÓñâJ;åŽøàšµ²XÎ~¬ž†¤W2˜¹©öïÚó®#)ypnr7-WôÍÌ«*€ˆ‰*,P™ÔVÊØã@|Pz[€K,H¡„FV™»­ËS<4›l&ýT„/ JÁ) œ†¼3²Tò4[ˆ†˜Një©¶eÓˆ'[#êjï¸×_®;½sÆÌ«Ï_ïôî«`÷‘¿QÌ*íÇŸŽ—Ÿ ï§¶2…=g<‡ÏOã,ƒÔv??>ÇÞÅeõýx5~½ËîžÆ)¼uø7ŸnþÓ›÷­Ÿe»šXóåc?·ÖVë¶©¯ ¥{¹—gçõÀ^Mö/ŸÌ 3yšœ¿|.ãn»^øŽuWïƒ]ͽx¿P0 eûîüzÓêÐ>Šú³áÕ†¾ŸžFWó _†ÏOãl‘‚ã}??^OçÁ.ãûñiü¼Çñ«Ý]üê´__ 8¯Cûc õí«~v2ó7çÆí»~v6íç,õÍË~~2étüïÛ~v2[J‡Ýºî³eJÞÒÙvÿøÈÒ÷lx>‹ÿç_~¹œÐÿmŠ«ÜK\FáVÿý¯W¿ùçû¿¾ùÇWÇëW_Ùë;Žmk£6.m¤?ÿ-¿üÖ}oÒ˜à_¿€¬ƒw°§H*õÂÖ˜›eaC›äj©†±EaAÊKæUy¢›Pªn«zS–•^c6Oœ=‡„àÙ‡Ule7ÂÍJ%x‡#†(©=' Ò!dáëÕ ¥æç5/µ2’Þäɫɘ5R¥.bæý.Ó-¥½‚Øo7á5ÞAÞ­¤ª·•…î.°òù7ÆJKá÷…ØÐÂ<_Ÿ*·ãóoüâ7^œþ U¶ýendstream endobj 3 0 obj << /Type /Pages /Kids [ 7 0 R ] /Count 1 /MediaBox [0 0 432 432] >> endobj 4 0 obj << /ProcSet [/PDF /Text] /Font << /F1 10 0 R /F2 11 0 R >> /ExtGState << >> /ColorSpace << /sRGB 5 0 R >> >> endobj 5 0 obj [/ICCBased 6 0 R] endobj 6 0 obj << /Alternate /DeviceRGB /N 3 /Length 2596 /Filter /FlateDecode >> stream xœ–wTSهϽ7½P’Š”ÐkhRH ½H‘.*1 JÀ"6DTpDQ‘¦2(à€£C‘±"Š…Q±ëDÔqp–Id­ß¼yïÍ›ß÷~kŸ½ÏÝgï}ÖºüƒÂLX € ¡Xáçň‹g` ðlàp³³BøF™|ØŒl™ø½º ùû*Ó?ŒÁÿŸ”¹Y"1P˜ŒçòøÙ\É8=Wœ%·Oɘ¶4MÎ0JÎ"Y‚2V“sò,[|ö™e9ó2„<ËsÎâeðäÜ'ã9¾Œ‘`çø¹2¾&cƒtI†@Æoä±|N6(’Ü.æsSdl-c’(2‚-ãyàHÉ_ðÒ/XÌÏËÅÎÌZ.$§ˆ&\S†“‹áÏÏMç‹ÅÌ07#â1Ø™YárfÏüYym²";Ø8980m-m¾(Ô]ü›’÷v–^„îDøÃöW~™ °¦eµÙú‡mi]ëP»ý‡Í`/в¾u}qº|^RÄâ,g+«ÜÜ\KŸk)/èïúŸC_|ÏR¾Ýïåaxó“8’t1C^7nfz¦DÄÈÎâpù 柇øþuü$¾ˆ/”ED˦L L–µ[Ȉ™B†@øŸšøÃþ¤Ù¹–‰ÚøЖX¥!@~(* {d+Ðï} ÆGù͋љ˜ûÏ‚þ}W¸LþÈ$ŽcGD2¸QÎìšüZ4 E@ê@èÀ¶À¸àA(ˆq`1à‚D €µ ”‚­`'¨u 4ƒ6ptcà48.Ë`ÜR0ž€)ð Ì@„…ÈR‡t CȲ…XäCP”%CBH@ë R¨ª†ê¡fè[è(tº C· Qhúz#0 ¦ÁZ°l³`O8Ž„ÁÉð28.‚·À•p|î„O×àX ?§€:¢‹0ÂFB‘x$ !«¤i@Ú¤¹ŠH‘§È[EE1PL” Ê…⢖¡V¡6£ªQP¨>ÔUÔ(j õMFk¢ÍÑÎèt,:‹.FW ›Ðè³èô8úƒ¡cŒ1ŽL&³³³ÓŽ9…ÆŒa¦±X¬:ÖëŠ År°bl1¶ {{{;Ž}ƒ#âtp¶8_\¡8áú"ãEy‹.,ÖXœ¾øøÅ%œ%Gщ1‰-‰ï9¡œÎôÒ€¥µK§¸lî.îžoo’ïÊ/çO$¹&•'=JvMÞž<™âžR‘òTÀT ž§ú§Ö¥¾N MÛŸö)=&½=—‘˜qTH¦ û2µ3ó2‡³Ì³Š³¤Ëœ—í\6% 5eCÙ‹²»Å4ÙÏÔ€ÄD²^2šã–S“ó&7:÷Hžrž0o`¹ÙòMË'ò}ó¿^ZÁ]Ñ[ [°¶`t¥çÊúUЪ¥«zWë¯.Z=¾Æo͵„µik(´.,/|¹.f]O‘VÑš¢±õ~ë[‹ŠEÅ76¸l¨ÛˆÚ(Ø8¸iMKx%K­K+Jßoæn¾ø•ÍW•_}Ú’´e°Ì¡lÏVÌVáÖëÛÜ·(W.Ï/Û²½scGÉŽ—;—ì¼PaWQ·‹°K²KZ\Ù]ePµµê}uJõHWM{­fí¦Ú×»y»¯ìñØÓV§UWZ÷n¯`ïÍz¿úΣ†Š}˜}9û6F7öÍúº¹I£©´éÃ~á~éˆ}ÍŽÍÍ-š-e­p«¤uò`ÂÁËßxÓÝÆl«o§·—‡$‡›øíõÃA‡{°Ž´}gø]mµ£¤ê\Þ9Õ•Ò%íŽë>x´·Ç¥§ã{Ëï÷Ó=Vs\åx٠‰¢ŸN柜>•uêééäÓc½Kz=s­/¼oðlÐÙóç|Ïé÷ì?yÞõü± ÎŽ^d]ìºäp©sÀ~ ãû:;‡‡º/;]îž7|âŠû•ÓW½¯ž»píÒÈü‘áëQ×oÞH¸!½É»ùèVú­ç·snÏÜYs}·äžÒ½Šûš÷~4ý±]ê =>ê=:ð`Áƒ;cܱ'?eÿô~¼è!ùaÅ„ÎDó#ÛGÇ&}'/?^øxüIÖ“™§Å?+ÿ\ûÌäÙw¿xü20;5þ\ôüÓ¯›_¨¿ØÿÒîeïtØôýW¯f^—¼Qsà-ëmÿ»˜w3¹ï±ï+?˜~èùôñî§ŒOŸ~÷„óûendstream endobj 9 0 obj << /Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences [ 45/minus 96/quoteleft 144/dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron /space] >> endobj 10 0 obj << /Type /Font /Subtype /Type1 /Name /F1 /BaseFont /ZapfDingbats >> endobj 11 0 obj << /Type /Font /Subtype /Type1 /Name /F2 /BaseFont /Helvetica /Encoding 9 0 R >> endobj xref 0 12 0000000000 65535 f 0000000021 00000 n 0000000163 00000 n 0000002559 00000 n 0000002642 00000 n 0000002766 00000 n 0000002799 00000 n 0000000212 00000 n 0000000292 00000 n 0000005494 00000 n 0000005751 00000 n 0000005835 00000 n trailer << /Size 12 /Info 1 0 R /Root 2 0 R >> startxref 5932 %%EOF geometry/src/0000755000176200001440000000000014751720222012676 5ustar liggesusersgeometry/src/Rtsearchn.c0000644000176200001440000001156214664417655015020 0ustar liggesusers/* Copyright (C) 2017 Andreas Stahel This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include #include #include #include #include "Rgeometry.h" #include "qhull_ra.h" SEXP C_tsearchn(const SEXP dt, const SEXP p) { int debug = 0; /* Get the qh object from the delaunayn object */ SEXP ptr, tag; qhT *qh; tag = PROTECT(Rf_allocVector(STRSXP, 1)); SET_STRING_ELT(tag, 0, Rf_mkChar("delaunayn")); ptr = PROTECT(Rf_getAttrib(dt, tag)); if (ptr == R_NilValue) { Rf_error("Delaunay triangulation has no delaunayn attribute"); } qh = R_ExternalPtrAddr(ptr); UNPROTECT(2); /* Check input matrix */ if(!Rf_isMatrix(p) || !Rf_isReal(p)){ Rf_error("Second argument should be a real matrix."); } unsigned int dim, n; dim = Rf_ncols(p) + 1; n = Rf_nrows(p); if(dim <= 0 || n <= 0){ Rf_error("Invalid input matrix."); } if (dim != qh->hull_dim) Rf_error("Invalid input matrix."); /* Construct map from facet id to index */ facetT *facet; /* Count the number of facets so we know how much space to allocate in R */ int nf = 0; /* Number of facets */ int max_facet_id = 0; int exitcode = 0; FORALLfacets { if (!facet->upperdelaunay) { nf++; if (facet->id > max_facet_id) max_facet_id = facet->id; /* Double check. Non-simplicial facets will cause segfault below */ if (!facet->simplicial) { Rprintf("Qhull returned non-simplicial facets -- try delaunayn with different options"); exitcode = 1; break; } } } int *idmap = (int *) R_alloc(max_facet_id + 1, sizeof(int)); int i = 0; FORALLfacets { if (!facet->upperdelaunay) { i++; if (debug & 1) Rprintf("Facet id %d; index %d\n;", facet->id, i); if (facet->id < 1 || facet->id > max_facet_id) { Rf_error("facet_id %d (at index %d) is not in {1,...,%d}", facet->id, i, max_facet_id); } idmap[facet->id] = i; } } /* Make space for output */ SEXP retlist, retnames; /* Return list and names */ int retlen = 2; /* Length of return list */ SEXP idx, points; idx = PROTECT(Rf_allocVector(INTSXP, n)); int *iidx = INTEGER(idx); points = PROTECT(Rf_allocMatrix(REALSXP, qh->num_points, dim - 1)); int j, k; /* Output points */ pointT *point; pointT *pointtemp; if (debug & 2) Rprintf("%d POINTS\n", qh->num_points); i = 0; FORALLpoints { for (k=0; k<(dim - 1); k++) { REAL(points)[i+k*qh->num_points] = point[k]; if (debug & 2) Rprintf("%f ", point[k]); } i++; if (debug & 2) Rprintf("\n"); } /* Run through the matrix using qh_findbestfacet to determine whether in hull or not */ boolT isoutside; realT bestdist; vertexT *vertex, **vertexp; /* The name point is reserved for use with FORALLpoints */ coordT *testpoint; testpoint = (coordT *) R_alloc(dim, sizeof(coordT)); for(i=0; i < n; i++) { if (debug) Rprintf("\nTestpoint\n"); for(k=0; k < (dim - 1); k++) { testpoint[k] = REAL(p)[i+n*k]; /* could have been pt_array = REAL(p) if p had been transposed */ if (debug) Rprintf(" %f", testpoint[k]); } if (debug) Rprintf("\n"); qh_setdelaunay(qh, dim, 1, testpoint); facet = qh_findbestfacet(qh, testpoint, qh_ALL, &bestdist, &isoutside); if (facet->tricoplanar) { exitcode = 1; break; } if (debug) Rprintf("Facet id %d; index %d\n", facet->id, idmap[facet->id]); /* Convert facet id to id of triangle */ iidx[i] = idmap[facet->id]; /* /\* Return vertices of triangle *\/ */ j = 0; FOREACHvertex_ (facet->vertices) { for (j=0; jpoint[j]); } if (debug) Rprintf("\n"); } } retlist = PROTECT(Rf_allocVector(VECSXP, retlen)); retnames = PROTECT(Rf_allocVector(VECSXP, retlen)); SET_VECTOR_ELT(retlist, 0, idx); SET_VECTOR_ELT(retnames, 0, Rf_mkChar("idx")); SET_VECTOR_ELT(retlist, 1, points); SET_VECTOR_ELT(retnames, 1, Rf_mkChar("P")); Rf_setAttrib(retlist, R_NamesSymbol, retnames); UNPROTECT(4); if (exitcode) Rf_error("findDelaunay: not implemented for triangulated, non-simplicial Delaunay regions (tricoplanar facet, f%d).", facet->id); return retlist; } geometry/src/global_r.c0000644000176200001440000024332614740034715014640 0ustar liggesusers /*

  ---------------------------------

   global_r.c
   initializes all the globals of the qhull application

   see README

   see libqhull_r.h for qh.globals and function prototypes

   see qhull_ra.h for internal functions

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/global_r.c#19 $$Change: 3037 $
   $DateTime: 2020/09/03 17:28:32 $$Author: bbarber $
 */

#include "qhull_ra.h"

/*========= qh->definition -- globals defined in libqhull_r.h =======================*/

/*----------------------------------

  qh_version
    version string by year and date
    qh_version2 for Unix users and -V

    the revision increases on code changes only

  notes:
    change date:    Changes.txt, Announce.txt, index.htm, README.txt,
                    qhull-news.html, Eudora signatures, CMakeLists.txt
    change version: README.txt, qh-get.htm, File_id.diz, Makefile.txt, CMakeLists.txt
    check that CMakeLists.txt @version is the same as qh_version2
    change year:    Copying.txt
    check download size
    recompile user_eg_r.c, rbox_r.c, libqhull_r.c, qconvex_r.c, qdelaun_r.c qvoronoi_r.c, qhalf_r.c, testqset_r.c
*/

const char qh_version[]= "2020.2.r 2020/08/31";
const char qh_version2[]= "qhull_r 8.0.2 (2020.2.r 2020/08/31)";

/*---------------------------------

  qh_appendprint(qh, printFormat )
    append printFormat to qh.PRINTout unless already defined
*/
void qh_appendprint(qhT *qh, qh_PRINT format) {
  int i;

  for (i=0; i < qh_PRINTEND; i++) {
    if (qh->PRINTout[i] == format && format != qh_PRINTqhull)
      break;
    if (!qh->PRINTout[i]) {
      qh->PRINTout[i]= format;
      break;
    }
  }
} /* appendprint */

/*---------------------------------

  qh_checkflags(qh, commandStr, hiddenFlags )
    errors if commandStr contains hiddenFlags
    hiddenFlags starts and ends with a space and is space delimited (checked)

  notes:
    ignores first word (e.g., "qconvex i")
    use qh_strtol/strtod since strtol/strtod may or may not skip trailing spaces

  see:
    qh_initflags() initializes Qhull according to commandStr
*/
void qh_checkflags(qhT *qh, char *command, char *hiddenflags) {
  char *s= command, *t, *chkerr; /* qh_skipfilename is non-const */
  char key, opt, prevopt;
  char chkkey[]=  "   ";    /* check one character options ('s') */
  char chkopt[]=  "    ";   /* check two character options ('Ta') */
  char chkopt2[]= "     ";  /* check three character options ('Q12') */
  boolT waserr= False;

  if (*hiddenflags != ' ' || hiddenflags[strlen(hiddenflags)-1] != ' ') {
    qh_fprintf(qh, qh->ferr, 6026, "qhull internal error (qh_checkflags): hiddenflags must start and end with a space: \"%s\"\n", hiddenflags);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  if (strpbrk(hiddenflags, ",\n\r\t")) {
    qh_fprintf(qh, qh->ferr, 6027, "qhull internal error (qh_checkflags): hiddenflags contains commas, newlines, or tabs: \"%s\"\n", hiddenflags);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  while (*s && !isspace(*s))  /* skip program name */
    s++;
  while (*s) {
    while (*s && isspace(*s))
      s++;
    if (*s == '-')
      s++;
    if (!*s)
      break;
    key= *s++;
    chkerr= NULL;
    if (key == 'T' && (*s == 'I' || *s == 'O')) {  /* TI or TO 'file name' */
      s= qh_skipfilename(qh, ++s);
      continue;
    }
    chkkey[1]= key;
    if (strstr(hiddenflags, chkkey)) {
      chkerr= chkkey;
    }else if (isupper(key)) {
      opt= ' ';
      prevopt= ' ';
      chkopt[1]= key;
      chkopt2[1]= key;
      while (!chkerr && *s && !isspace(*s)) {
        opt= *s++;
        if (isalpha(opt)) {
          chkopt[2]= opt;
          if (strstr(hiddenflags, chkopt))
            chkerr= chkopt;
          if (prevopt != ' ') {
            chkopt2[2]= prevopt;
            chkopt2[3]= opt;
            if (strstr(hiddenflags, chkopt2))
              chkerr= chkopt2;
          }
        }else if (key == 'Q' && isdigit(opt) && prevopt != 'b'
              && (prevopt == ' ' || islower(prevopt))) {
            if (isdigit(*s)) {  /* Q12 */
              chkopt2[2]= opt;
              chkopt2[3]= *s++;
              if (strstr(hiddenflags, chkopt2))
                chkerr= chkopt2;
            }else {
              chkopt[2]= opt;
              if (strstr(hiddenflags, chkopt))
                chkerr= chkopt;
            }
        }else {
          qh_strtod(s-1, &t);
          if (s < t)
            s= t;
        }
        prevopt= opt;
      }
    }
    if (chkerr) {
      *chkerr= '\'';
      chkerr[strlen(chkerr)-1]=  '\'';
      qh_fprintf(qh, qh->ferr, 6029, "qhull option error: option %s is not used with this program.\n             It may be used with qhull.\n", chkerr);
      waserr= True;
    }
  }
  if (waserr)
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
} /* checkflags */

/*---------------------------------

  qh_clear_outputflags(qh)
    Clear output flags for QhullPoints
*/
void qh_clear_outputflags(qhT *qh) {
  int i,k;

  qh->ANNOTATEoutput= False;
  qh->DOintersections= False;
  qh->DROPdim= -1;
  qh->FORCEoutput= False;
  qh->GETarea= False;
  qh->GOODpoint= 0;
  qh->GOODpointp= NULL;
  qh->GOODthreshold= False;
  qh->GOODvertex= 0;
  qh->GOODvertexp= NULL;
  qh->IStracing= 0;
  qh->KEEParea= False;
  qh->KEEPmerge= False;
  qh->KEEPminArea= REALmax;
  qh->PRINTcentrums= False;
  qh->PRINTcoplanar= False;
  qh->PRINTdots= False;
  qh->PRINTgood= False;
  qh->PRINTinner= False;
  qh->PRINTneighbors= False;
  qh->PRINTnoplanes= False;
  qh->PRINToptions1st= False;
  qh->PRINTouter= False;
  qh->PRINTprecision= True;
  qh->PRINTridges= False;
  qh->PRINTspheres= False;
  qh->PRINTstatistics= False;
  qh->PRINTsummary= False;
  qh->PRINTtransparent= False;
  qh->SPLITthresholds= False;
  qh->TRACElevel= 0;
  qh->TRInormals= False;
  qh->USEstdout= False;
  qh->VERIFYoutput= False;
  for (k=qh->input_dim+1; k--; ) {  /* duplicated in qh_initqhull_buffers and qh_clear_outputflags */
    qh->lower_threshold[k]= -REALmax;
    qh->upper_threshold[k]= REALmax;
    qh->lower_bound[k]= -REALmax;
    qh->upper_bound[k]= REALmax;
  }

  for (i=0; i < qh_PRINTEND; i++) {
    qh->PRINTout[i]= qh_PRINTnone;
  }

  if (!qh->qhull_commandsiz2)
      qh->qhull_commandsiz2= (int)strlen(qh->qhull_command); /* WARN64 */
  else {
      qh->qhull_command[qh->qhull_commandsiz2]= '\0';
  }
  if (!qh->qhull_optionsiz2)
    qh->qhull_optionsiz2= (int)strlen(qh->qhull_options);  /* WARN64 */
  else {
    qh->qhull_options[qh->qhull_optionsiz2]= '\0';
    qh->qhull_optionlen= qh_OPTIONline;  /* start a new line */
  }
} /* clear_outputflags */

/*---------------------------------

  qh_clock()
    return user CPU time in 100ths (qh_SECtick)
    only defined for qh_CLOCKtype == 2

  notes:
    use first value to determine time 0
    from Stevens '92 8.15
*/
unsigned long qh_clock(qhT *qh) {

#if (qh_CLOCKtype == 2)
  struct tms time;
  static long clktck;  /* initialized first call and never updated */
  double ratio, cpu;
  unsigned long ticks;

  if (!clktck) {
    if ((clktck= sysconf(_SC_CLK_TCK)) < 0) {
      qh_fprintf(qh, qh->ferr, 6030, "qhull internal error (qh_clock): sysconf() failed.  Use qh_CLOCKtype 1 in user_r.h\n");
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }
  }
  if (times(&time) == -1) {
    qh_fprintf(qh, qh->ferr, 6031, "qhull internal error (qh_clock): times() failed.  Use qh_CLOCKtype 1 in user_r.h\n");
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  ratio= qh_SECticks / (double)clktck;
  ticks= time.tms_utime * ratio;
  return ticks;
#else
  qh_fprintf(qh, qh->ferr, 6032, "qhull internal error (qh_clock): use qh_CLOCKtype 2 in user_r.h\n");
  qh_errexit(qh, qh_ERRqhull, NULL, NULL); /* never returns */
  return 0;
#endif
} /* clock */

/*---------------------------------

  qh_freebuffers()
    free up global memory buffers

  notes:
    must match qh_initbuffers()
*/
void qh_freebuffers(qhT *qh) {

  trace5((qh, qh->ferr, 5001, "qh_freebuffers: freeing up global memory buffers\n"));
  /* allocated by qh_initqhull_buffers */
  qh_setfree(qh, &qh->other_points);
  qh_setfree(qh, &qh->del_vertices);
  qh_setfree(qh, &qh->coplanarfacetset);
  qh_memfree(qh, qh->NEARzero, qh->hull_dim * (int)sizeof(realT));
  qh_memfree(qh, qh->lower_threshold, (qh->input_dim+1) * (int)sizeof(realT));
  qh_memfree(qh, qh->upper_threshold, (qh->input_dim+1) * (int)sizeof(realT));
  qh_memfree(qh, qh->lower_bound, (qh->input_dim+1) * (int)sizeof(realT));
  qh_memfree(qh, qh->upper_bound, (qh->input_dim+1) * (int)sizeof(realT));
  qh_memfree(qh, qh->gm_matrix, (qh->hull_dim+1) * qh->hull_dim * (int)sizeof(coordT));
  qh_memfree(qh, qh->gm_row, (qh->hull_dim+1) * (int)sizeof(coordT *));
  qh->NEARzero= qh->lower_threshold= qh->upper_threshold= NULL;
  qh->lower_bound= qh->upper_bound= NULL;
  qh->gm_matrix= NULL;
  qh->gm_row= NULL;

  if (qh->line)                /* allocated by qh_readinput, freed if no error */
    qh_free(qh->line);
  if (qh->half_space)
    qh_free(qh->half_space);
  if (qh->temp_malloc)
    qh_free(qh->temp_malloc);
  if (qh->feasible_point)      /* allocated by qh_readfeasible */
    qh_free(qh->feasible_point);
  if (qh->feasible_string)     /* allocated by qh_initflags */
    qh_free(qh->feasible_string);
  qh->line= qh->feasible_string= NULL;
  qh->half_space= qh->feasible_point= qh->temp_malloc= NULL;
  /* usually allocated by qh_readinput */
  if (qh->first_point && qh->POINTSmalloc) {
    qh_free(qh->first_point);
    qh->first_point= NULL;
  }
  if (qh->input_points && qh->input_malloc) { /* set by qh_joggleinput */
    qh_free(qh->input_points);
    qh->input_points= NULL;
  }
  trace5((qh, qh->ferr, 5002, "qh_freebuffers: finished\n"));
} /* freebuffers */


/*---------------------------------

  qh_freebuild(qh, allmem )
    free global memory used by qh_initbuild and qh_buildhull
    if !allmem,
      does not free short memory (e.g., facetT, freed by qh_memfreeshort)

  design:
    free centrums
    free each vertex
    for each facet
      free ridges
      free outside set, coplanar set, neighbor set, ridge set, vertex set
      free facet
    free hash table
    free interior point
    free merge sets
    free temporary sets
*/
void qh_freebuild(qhT *qh, boolT allmem) {
  facetT *facet, *previousfacet= NULL;
  vertexT *vertex, *previousvertex= NULL;
  ridgeT *ridge, **ridgep, *previousridge= NULL;
  mergeT *merge, **mergep;
  int newsize;
  boolT freeall;

  /* free qhT global sets first, includes references from qh_buildhull */
  trace5((qh, qh->ferr, 5004, "qh_freebuild: free global sets\n"));
  FOREACHmerge_(qh->facet_mergeset)  /* usually empty */
    qh_memfree(qh, merge, (int)sizeof(mergeT));
  FOREACHmerge_(qh->degen_mergeset)  /* usually empty */
    qh_memfree(qh, merge, (int)sizeof(mergeT));
  FOREACHmerge_(qh->vertex_mergeset)  /* usually empty */
    qh_memfree(qh, merge, (int)sizeof(mergeT));
  qh->facet_mergeset= NULL;  /* temp set freed by qh_settempfree_all */
  qh->degen_mergeset= NULL;  /* temp set freed by qh_settempfree_all */
  qh->vertex_mergeset= NULL;  /* temp set freed by qh_settempfree_all */
  qh_setfree(qh, &(qh->hash_table));
  trace5((qh, qh->ferr, 5003, "qh_freebuild: free temporary sets (qh_settempfree_all)\n"));
  qh_settempfree_all(qh);
  trace1((qh, qh->ferr, 1005, "qh_freebuild: free memory from qh_inithull and qh_buildhull\n"));
  if (qh->del_vertices)
    qh_settruncate(qh, qh->del_vertices, 0);
  if (allmem) {
    while ((vertex= qh->vertex_list)) {
      if (vertex->next)
        qh_delvertex(qh, vertex);
      else {
        qh_memfree(qh, vertex, (int)sizeof(vertexT)); /* sentinel */
        qh->newvertex_list= qh->vertex_list= NULL;
        break;
      }
      previousvertex= vertex; /* in case of memory fault */
      QHULL_UNUSED(previousvertex)
    }
  }else if (qh->VERTEXneighbors) {
    FORALLvertices
      qh_setfreelong(qh, &(vertex->neighbors));
  }
  qh->VERTEXneighbors= False;
  qh->GOODclosest= NULL;
  if (allmem) {
    FORALLfacets {
      FOREACHridge_(facet->ridges)
        ridge->seen= False;
    }
    while ((facet= qh->facet_list)) {
      if (!facet->newfacet || !qh->NEWtentative || qh_setsize(qh, facet->ridges) > 1) { /* skip tentative horizon ridges */
        trace4((qh, qh->ferr, 4095, "qh_freebuild: delete the previously-seen ridges of f%d\n", facet->id));
        FOREACHridge_(facet->ridges) {
          if (ridge->seen)
            qh_delridge(qh, ridge);
          else
            ridge->seen= True;
          previousridge= ridge; /* in case of memory fault */
          QHULL_UNUSED(previousridge)
        }
      }
      qh_setfree(qh, &(facet->outsideset));
      qh_setfree(qh, &(facet->coplanarset));
      qh_setfree(qh, &(facet->neighbors));
      qh_setfree(qh, &(facet->ridges));
      qh_setfree(qh, &(facet->vertices));
      if (facet->next)
        qh_delfacet(qh, facet);
      else {
        qh_memfree(qh, facet, (int)sizeof(facetT));
        qh->visible_list= qh->newfacet_list= qh->facet_list= NULL;
      }
      previousfacet= facet; /* in case of memory fault */
      QHULL_UNUSED(previousfacet)
    }
  }else {
    freeall= True;
    if (qh_setlarger_quick(qh, qh->hull_dim + 1, &newsize))
      freeall= False;
    FORALLfacets {
      qh_setfreelong(qh, &(facet->outsideset));
      qh_setfreelong(qh, &(facet->coplanarset));
      if (!facet->simplicial || freeall) {
        qh_setfreelong(qh, &(facet->neighbors));
        qh_setfreelong(qh, &(facet->ridges));
        qh_setfreelong(qh, &(facet->vertices));
      }
    }
  }
  /* qh internal constants */
  qh_memfree(qh, qh->interior_point, qh->normal_size);
  qh->interior_point= NULL;
} /* freebuild */

/*---------------------------------

  qh_freeqhull(qh, allmem )

  free global memory and set qhT to 0
  if !allmem,
    does not free short memory (freed by qh_memfreeshort unless qh_NOmem)

notes:
  sets qh.NOerrexit in case caller forgets to
  Does not throw errors

see:
  see qh_initqhull_start2()
  For libqhull_r, qhstatT is part of qhT

design:
  free global and temporary memory from qh_initbuild and qh_buildhull
  free buffers
*/
void qh_freeqhull(qhT *qh, boolT allmem) {

  qh->NOerrexit= True;  /* no more setjmp since called at exit and ~QhullQh */
  trace1((qh, qh->ferr, 1006, "qh_freeqhull: free global memory\n"));
  qh_freebuild(qh, allmem);
  qh_freebuffers(qh);
  trace1((qh, qh->ferr, 1061, "qh_freeqhull: clear qhT except for qh.qhmem and qh.qhstat\n"));
  /* memset is the same in qh_freeqhull() and qh_initqhull_start2() */
  memset((char *)qh, 0, sizeof(qhT)-sizeof(qhmemT)-sizeof(qhstatT));
  qh->NOerrexit= True;
} /* freeqhull */

/*---------------------------------

  qh_init_A(qh, infile, outfile, errfile, argc, argv )
    initialize memory and stdio files
    convert input options to option string (qh.qhull_command)

  notes:
    infile may be NULL if qh_readpoints() is not called

    errfile should always be defined.  It is used for reporting
    errors.  outfile is used for output and format options.

    argc/argv may be 0/NULL

    called before error handling initialized
    qh_errexit() may not be used
*/
void qh_init_A(qhT *qh, FILE *infile, FILE *outfile, FILE *errfile, int argc, char *argv[]) {
  qh_meminit(qh, errfile);
  qh_initqhull_start(qh, infile, outfile, errfile);
  qh_init_qhull_command(qh, argc, argv);
} /* init_A */

/*---------------------------------

  qh_init_B(qh, points, numpoints, dim, ismalloc )
    initialize globals for points array

    points has numpoints dim-dimensional points
      points[0] is the first coordinate of the first point
      points[1] is the second coordinate of the first point
      points[dim] is the first coordinate of the second point

    ismalloc=True
      Qhull will call qh_free(points) on exit or input transformation
    ismalloc=False
      Qhull will allocate a new point array if needed for input transformation

    qh.qhull_command
      is the option string.
      It is defined by qh_init_B(), qh_qhull_command(), or qh_initflags

  returns:
    if qh.PROJECTinput or (qh.DELAUNAY and qh.PROJECTdelaunay)
      projects the input to a new point array

        if qh.DELAUNAY,
          qh.hull_dim is increased by one
        if qh.ATinfinity,
          qh_projectinput adds point-at-infinity for Delaunay tri.

    if qh.SCALEinput
      changes the upper and lower bounds of the input, see qh_scaleinput

    if qh.ROTATEinput
      rotates the input by a random rotation, see qh_rotateinput
      if qh.DELAUNAY
        rotates about the last coordinate

  notes:
    called after points are defined
    qh_errexit() may be used
*/
void qh_init_B(qhT *qh, coordT *points, int numpoints, int dim, boolT ismalloc) {
  qh_initqhull_globals(qh, points, numpoints, dim, ismalloc);
  if (qh->qhmem.LASTsize == 0)
    qh_initqhull_mem(qh);
  /* mem_r.c and qset_r.c are initialized */
  qh_initqhull_buffers(qh);
  qh_initthresholds(qh, qh->qhull_command);
  if (qh->PROJECTinput || (qh->DELAUNAY && qh->PROJECTdelaunay))
    qh_projectinput(qh);
  if (qh->SCALEinput)
    qh_scaleinput(qh);
  if (qh->ROTATErandom >= 0) {
    qh_randommatrix(qh, qh->gm_matrix, qh->hull_dim, qh->gm_row);
    if (qh->DELAUNAY) {
      int k, lastk= qh->hull_dim-1;
      for (k=0; k < lastk; k++) {
        qh->gm_row[k][lastk]= 0.0;
        qh->gm_row[lastk][k]= 0.0;
      }
      qh->gm_row[lastk][lastk]= 1.0;
    }
    qh_gram_schmidt(qh, qh->hull_dim, qh->gm_row);
    qh_rotateinput(qh, qh->gm_row);
  }
} /* init_B */

/*---------------------------------

  qh_init_qhull_command(qh, argc, argv )
    build qh.qhull_command from argc/argv
    Calls qh_exit if qhull_command is too short

  returns:
    a space-delimited string of options (just as typed)

  notes:
    makes option string easy to input and output

    argc/argv may be 0/NULL
*/
void qh_init_qhull_command(qhT *qh, int argc, char *argv[]) {

  if (!qh_argv_to_command(argc, argv, qh->qhull_command, (int)sizeof(qh->qhull_command))){
    /* Assumes qh.ferr is defined. */
    qh_fprintf(qh, qh->ferr, 6033, "qhull input error: more than %d characters in command line.\n",
          (int)sizeof(qh->qhull_command));
    qh_exit(qh_ERRinput);  /* error reported, can not use qh_errexit */
  }
} /* init_qhull_command */

/*---------------------------------

  qh_initflags(qh, commandStr )
    set flags and initialized constants from commandStr
    calls qh_exit() if qh.NOerrexit

  returns:
    sets qh.qhull_command to command if needed

  notes:
    ignores first word (e.g., 'qhull' in "qhull d")
    use qh_strtol/strtod since strtol/strtod may or may not skip trailing spaces

  see:
    qh_initthresholds() continues processing of 'Pdn' and 'PDn'
    'prompt' in unix_r.c for documentation

  design:
    for each space-delimited option group
      if top-level option
        check syntax
        append appropriate option to option string
        set appropriate global variable or append printFormat to print options
      else
        for each sub-option
          check syntax
          append appropriate option to option string
          set appropriate global variable or append printFormat to print options
*/
void qh_initflags(qhT *qh, char *command) {
  int k, i, lastproject;
  char *s= command, *t, *prev_s, *start, key, *lastwarning= NULL;
  boolT isgeom= False, wasproject;
  realT r;

  if(qh->NOerrexit){
    qh_fprintf(qh, qh->ferr, 6245, "qhull internal error (qh_initflags): qh.NOerrexit was not cleared before calling qh_initflags().  It should be cleared after setjmp().  Exit qhull.\n");
    qh_exit(qh_ERRqhull);
  }
#ifdef qh_RANDOMdist
  qh->RANDOMfactor= qh_RANDOMdist;
  qh_option(qh, "Random-qh_RANDOMdist", NULL, &qh->RANDOMfactor);
  qh->RANDOMdist= True;
#endif
  if (command <= &qh->qhull_command[0] || command > &qh->qhull_command[0] + sizeof(qh->qhull_command)) {
    if (command != &qh->qhull_command[0]) {
      *qh->qhull_command= '\0';
      strncat(qh->qhull_command, command, sizeof(qh->qhull_command)-strlen(qh->qhull_command)-1);
    }
    while (*s && !isspace(*s))  /* skip program name */
      s++;
  }
  while (*s) {
    while (*s && isspace(*s))
      s++;
    if (*s == '-')
      s++;
    if (!*s)
      break;
    prev_s= s;
    switch (*s++) {
    case 'd':
      qh_option(qh, "delaunay", NULL, NULL);
      qh->DELAUNAY= True;
      break;
    case 'f':
      qh_option(qh, "facets", NULL, NULL);
      qh_appendprint(qh, qh_PRINTfacets);
      break;
    case 'i':
      qh_option(qh, "incidence", NULL, NULL);
      qh_appendprint(qh, qh_PRINTincidences);
      break;
    case 'm':
      qh_option(qh, "mathematica", NULL, NULL);
      qh_appendprint(qh, qh_PRINTmathematica);
      break;
    case 'n':
      qh_option(qh, "normals", NULL, NULL);
      qh_appendprint(qh, qh_PRINTnormals);
      break;
    case 'o':
      qh_option(qh, "offFile", NULL, NULL);
      qh_appendprint(qh, qh_PRINToff);
      break;
    case 'p':
      qh_option(qh, "points", NULL, NULL);
      qh_appendprint(qh, qh_PRINTpoints);
      break;
    case 's':
      qh_option(qh, "summary", NULL, NULL);
      qh->PRINTsummary= True;
      break;
    case 'v':
      qh_option(qh, "voronoi", NULL, NULL);
      qh->VORONOI= True;
      qh->DELAUNAY= True;
      break;
    case 'A':
      if (!isdigit(*s) && *s != '.' && *s != '-') {
        qh_fprintf(qh, qh->ferr, 7002, "qhull input warning: no maximum cosine angle given for option 'An'.  A1.0 is coplanar\n");
        lastwarning= s-1;
      }else {
        if (*s == '-') {
          qh->premerge_cos= -qh_strtod(s, &s);
          qh_option(qh, "Angle-premerge-", NULL, &qh->premerge_cos);
          qh->PREmerge= True;
        }else {
          qh->postmerge_cos= qh_strtod(s, &s);
          qh_option(qh, "Angle-postmerge", NULL, &qh->postmerge_cos);
          qh->POSTmerge= True;
        }
        qh->MERGING= True;
      }
      break;
    case 'C':
      if (!isdigit(*s) && *s != '.' && *s != '-') {
        qh_fprintf(qh, qh->ferr, 7003, "qhull input warning: no centrum radius given for option 'Cn'\n");
        lastwarning= s-1;
      }else {
        if (*s == '-') {
          qh->premerge_centrum= -qh_strtod(s, &s);
          qh_option(qh, "Centrum-premerge-", NULL, &qh->premerge_centrum);
          qh->PREmerge= True;
        }else {
          qh->postmerge_centrum= qh_strtod(s, &s);
          qh_option(qh, "Centrum-postmerge", NULL, &qh->postmerge_centrum);
          qh->POSTmerge= True;
        }
        qh->MERGING= True;
      }
      break;
    case 'E':
      if (*s == '-') {
        qh_fprintf(qh, qh->ferr, 6363, "qhull option error: expecting a positive number for maximum roundoff 'En'.  Got '%s'\n", s-1);
        qh_errexit(qh, qh_ERRinput, NULL, NULL);
      }else if (!isdigit(*s)) {
        qh_fprintf(qh, qh->ferr, 7005, "qhull option warning: no maximum roundoff given for option 'En'\n");
        lastwarning= s-1;
      }else {
        qh->DISTround= qh_strtod(s, &s);
        qh_option(qh, "Distance-roundoff", NULL, &qh->DISTround);
        qh->SETroundoff= True;
      }
      break;
    case 'H':
      start= s;
      qh->HALFspace= True;
      qh_strtod(s, &t);
      while (t > s)  {
        if (*t && !isspace(*t)) {
          if (*t == ',')
            t++;
          else {
            qh_fprintf(qh, qh->ferr, 6364, "qhull option error: expecting 'Hn,n,n,...' for feasible point of halfspace intersection. Got '%s'\n", start-1);
            qh_errexit(qh, qh_ERRinput, NULL, NULL);
          }
        }
        s= t;
        qh_strtod(s, &t);
      }
      if (start < t) {
        if (!(qh->feasible_string= (char *)calloc((size_t)(t-start+1), (size_t)1))) {
          qh_fprintf(qh, qh->ferr, 6034, "qhull error: insufficient memory for 'Hn,n,n'\n");
          qh_errexit(qh, qh_ERRmem, NULL, NULL);
        }
        strncpy(qh->feasible_string, start, (size_t)(t-start));
        qh_option(qh, "Halfspace-about", NULL, NULL);
        qh_option(qh, qh->feasible_string, NULL, NULL);
      }else
        qh_option(qh, "Halfspace", NULL, NULL);
      break;
    case 'R':
      if (!isdigit(*s)) {
        qh_fprintf(qh, qh->ferr, 7007, "qhull option warning: missing random perturbation for option 'Rn'\n");
        lastwarning= s-1;
      }else {
        qh->RANDOMfactor= qh_strtod(s, &s);
        qh_option(qh, "Random-perturb", NULL, &qh->RANDOMfactor);
        qh->RANDOMdist= True;
      }
      break;
    case 'V':
      if (!isdigit(*s) && *s != '-') {
        qh_fprintf(qh, qh->ferr, 7008, "qhull option warning: missing visible distance for option 'Vn'\n");
        lastwarning= s-1;
      }else {
        qh->MINvisible= qh_strtod(s, &s);
        qh_option(qh, "Visible", NULL, &qh->MINvisible);
      }
      break;
    case 'U':
      if (!isdigit(*s) && *s != '-') {
        qh_fprintf(qh, qh->ferr, 7009, "qhull option warning: missing coplanar distance for option 'Un'\n");
        lastwarning= s-1;
      }else {
        qh->MAXcoplanar= qh_strtod(s, &s);
        qh_option(qh, "U-coplanar", NULL, &qh->MAXcoplanar);
      }
      break;
    case 'W':
      if (*s == '-') {
        qh_fprintf(qh, qh->ferr, 6365, "qhull option error: expecting a positive number for outside width 'Wn'.  Got '%s'\n", s-1);
        qh_errexit(qh, qh_ERRinput, NULL, NULL);
      }else if (!isdigit(*s)) {
        qh_fprintf(qh, qh->ferr, 7011, "qhull option warning: missing outside width for option 'Wn'\n");
        lastwarning= s-1;
      }else {
        qh->MINoutside= qh_strtod(s, &s);
        qh_option(qh, "W-outside", NULL, &qh->MINoutside);
        qh->APPROXhull= True;
      }
      break;
    /************  sub menus ***************/
    case 'F':
      while (*s && !isspace(*s)) {
        switch (*s++) {
        case 'a':
          qh_option(qh, "Farea", NULL, NULL);
          qh_appendprint(qh, qh_PRINTarea);
          qh->GETarea= True;
          break;
        case 'A':
          qh_option(qh, "FArea-total", NULL, NULL);
          qh->GETarea= True;
          break;
        case 'c':
          qh_option(qh, "Fcoplanars", NULL, NULL);
          qh_appendprint(qh, qh_PRINTcoplanars);
          break;
        case 'C':
          qh_option(qh, "FCentrums", NULL, NULL);
          qh_appendprint(qh, qh_PRINTcentrums);
          break;
        case 'd':
          qh_option(qh, "Fd-cdd-in", NULL, NULL);
          qh->CDDinput= True;
          break;
        case 'D':
          qh_option(qh, "FD-cdd-out", NULL, NULL);
          qh->CDDoutput= True;
          break;
        case 'F':
          qh_option(qh, "FFacets-xridge", NULL, NULL);
          qh_appendprint(qh, qh_PRINTfacets_xridge);
          break;
        case 'i':
          qh_option(qh, "Finner", NULL, NULL);
          qh_appendprint(qh, qh_PRINTinner);
          break;
        case 'I':
          qh_option(qh, "FIDs", NULL, NULL);
          qh_appendprint(qh, qh_PRINTids);
          break;
        case 'm':
          qh_option(qh, "Fmerges", NULL, NULL);
          qh_appendprint(qh, qh_PRINTmerges);
          break;
        case 'M':
          qh_option(qh, "FMaple", NULL, NULL);
          qh_appendprint(qh, qh_PRINTmaple);
          break;
        case 'n':
          qh_option(qh, "Fneighbors", NULL, NULL);
          qh_appendprint(qh, qh_PRINTneighbors);
          break;
        case 'N':
          qh_option(qh, "FNeighbors-vertex", NULL, NULL);
          qh_appendprint(qh, qh_PRINTvneighbors);
          break;
        case 'o':
          qh_option(qh, "Fouter", NULL, NULL);
          qh_appendprint(qh, qh_PRINTouter);
          break;
        case 'O':
          if (qh->PRINToptions1st) {
            qh_option(qh, "FOptions", NULL, NULL);
            qh_appendprint(qh, qh_PRINToptions);
          }else
            qh->PRINToptions1st= True;
          break;
        case 'p':
          qh_option(qh, "Fpoint-intersect", NULL, NULL);
          qh_appendprint(qh, qh_PRINTpointintersect);
          break;
        case 'P':
          qh_option(qh, "FPoint-nearest", NULL, NULL);
          qh_appendprint(qh, qh_PRINTpointnearest);
          break;
        case 'Q':
          qh_option(qh, "FQhull", NULL, NULL);
          qh_appendprint(qh, qh_PRINTqhull);
          break;
        case 's':
          qh_option(qh, "Fsummary", NULL, NULL);
          qh_appendprint(qh, qh_PRINTsummary);
          break;
        case 'S':
          qh_option(qh, "FSize", NULL, NULL);
          qh_appendprint(qh, qh_PRINTsize);
          qh->GETarea= True;
          break;
        case 't':
          qh_option(qh, "Ftriangles", NULL, NULL);
          qh_appendprint(qh, qh_PRINTtriangles);
          break;
        case 'v':
          /* option set in qh_initqhull_globals */
          qh_appendprint(qh, qh_PRINTvertices);
          break;
        case 'V':
          qh_option(qh, "FVertex-average", NULL, NULL);
          qh_appendprint(qh, qh_PRINTaverage);
          break;
        case 'x':
          qh_option(qh, "Fxtremes", NULL, NULL);
          qh_appendprint(qh, qh_PRINTextremes);
          break;
        default:
          s--;
          qh_fprintf(qh, qh->ferr, 7012, "qhull option warning: unknown 'F' output option 'F%c', skip to next space\n", (int)s[0]);
          lastwarning= s-1;
          while (*++s && !isspace(*s));
          break;
        }
      }
      break;
    case 'G':
      isgeom= True;
      qh_appendprint(qh, qh_PRINTgeom);
      while (*s && !isspace(*s)) {
        switch (*s++) {
        case 'a':
          qh_option(qh, "Gall-points", NULL, NULL);
          qh->PRINTdots= True;
          break;
        case 'c':
          qh_option(qh, "Gcentrums", NULL, NULL);
          qh->PRINTcentrums= True;
          break;
        case 'h':
          qh_option(qh, "Gintersections", NULL, NULL);
          qh->DOintersections= True;
          break;
        case 'i':
          qh_option(qh, "Ginner", NULL, NULL);
          qh->PRINTinner= True;
          break;
        case 'n':
          qh_option(qh, "Gno-planes", NULL, NULL);
          qh->PRINTnoplanes= True;
          break;
        case 'o':
          qh_option(qh, "Gouter", NULL, NULL);
          qh->PRINTouter= True;
          break;
        case 'p':
          qh_option(qh, "Gpoints", NULL, NULL);
          qh->PRINTcoplanar= True;
          break;
        case 'r':
          qh_option(qh, "Gridges", NULL, NULL);
          qh->PRINTridges= True;
          break;
        case 't':
          qh_option(qh, "Gtransparent", NULL, NULL);
          qh->PRINTtransparent= True;
          break;
        case 'v':
          qh_option(qh, "Gvertices", NULL, NULL);
          qh->PRINTspheres= True;
          break;
        case 'D':
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7004, "qhull option warning: missing dimension for option 'GDn'\n");
            lastwarning= s-2;
          }else {
            if (qh->DROPdim >= 0) {
              qh_fprintf(qh, qh->ferr, 7013, "qhull option warning: can only drop one dimension.  Previous 'GD%d' ignored\n",
                   qh->DROPdim);
              lastwarning= s-2;
            }
            qh->DROPdim= qh_strtol(s, &s);
            qh_option(qh, "GDrop-dim", &qh->DROPdim, NULL);
          }
          break;
        default:
          s--;
          qh_fprintf(qh, qh->ferr, 7014, "qhull option warning: unknown 'G' geomview option 'G%c', skip to next space\n", (int)s[0]);
          lastwarning= s-1;
          while (*++s && !isspace(*s));
          break;
        }
      }
      break;
    case 'P':
      while (*s && !isspace(*s)) {
        switch (*s++) {
        case 'd': case 'D':  /* see qh_initthresholds() */
          key= s[-1];
          i= qh_strtol(s, &s);
          r= 0;
          if (*s == ':') {
            s++;
            r= qh_strtod(s, &s);
          }
          if (key == 'd')
            qh_option(qh, "Pdrop-facets-dim-less", &i, &r);
          else
            qh_option(qh, "PDrop-facets-dim-more", &i, &r);
          break;
        case 'g':
          qh_option(qh, "Pgood-facets", NULL, NULL);
          qh->PRINTgood= True;
          break;
        case 'G':
          qh_option(qh, "PGood-facet-neighbors", NULL, NULL);
          qh->PRINTneighbors= True;
          break;
        case 'o':
          qh_option(qh, "Poutput-forced", NULL, NULL);
          qh->FORCEoutput= True;
          break;
        case 'p':
          qh_option(qh, "Pprecision-ignore", NULL, NULL);
          qh->PRINTprecision= False;
          break;
        case 'A':
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7006, "qhull option warning: missing facet count for keep area option 'PAn'\n");
            lastwarning= s-2;
          }else {
            qh->KEEParea= qh_strtol(s, &s);
            qh_option(qh, "PArea-keep", &qh->KEEParea, NULL);
            qh->GETarea= True;
          }
          break;
        case 'F':
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7010, "qhull option warning: missing facet area for option 'PFn'\n");
            lastwarning= s-2;
          }else {
            qh->KEEPminArea= qh_strtod(s, &s);
            qh_option(qh, "PFacet-area-keep", NULL, &qh->KEEPminArea);
            qh->GETarea= True;
          }
          break;
        case 'M':
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7090, "qhull option warning: missing merge count for option 'PMn'\n");
            lastwarning= s-2;
          }else {
            qh->KEEPmerge= qh_strtol(s, &s);
            qh_option(qh, "PMerge-keep", &qh->KEEPmerge, NULL);
          }
          break;
        default:
          s--;
          qh_fprintf(qh, qh->ferr, 7015, "qhull option warning: unknown 'P' print option 'P%c', skip to next space\n", (int)s[0]);
          lastwarning= s-1;
          while (*++s && !isspace(*s));
          break;
        }
      }
      break;
    case 'Q':
      lastproject= -1;
      while (*s && !isspace(*s)) {
        switch (*s++) {
        case 'a':
          qh_option(qh, "Qallow-short", NULL, NULL);
          qh->ALLOWshort= True;
          break;
        case 'b': case 'B':  /* handled by qh_initthresholds */
          key= s[-1];
          if (key == 'b' && *s == 'B') {
            s++;
            r= qh_DEFAULTbox;
            qh->SCALEinput= True;
            qh_option(qh, "QbBound-unit-box", NULL, &r);
            break;
          }
          if (key == 'b' && *s == 'b') {
            s++;
            qh->SCALElast= True;
            qh_option(qh, "Qbbound-last", NULL, NULL);
            break;
          }
          k= qh_strtol(s, &s);
          r= 0.0;
          wasproject= False;
          if (*s == ':') {
            s++;
            if ((r= qh_strtod(s, &s)) == 0.0) {
              t= s;            /* need true dimension for memory allocation */
              while (*t && !isspace(*t)) {
                if (toupper(*t++) == 'B'
                 && k == qh_strtol(t, &t)
                 && *t++ == ':'
                 && qh_strtod(t, &t) == 0.0) {
                  qh->PROJECTinput++;
                  trace2((qh, qh->ferr, 2004, "qh_initflags: project dimension %d\n", k));
                  qh_option(qh, "Qb-project-dim", &k, NULL);
                  wasproject= True;
                  lastproject= k;
                  break;
                }
              }
            }
          }
          if (!wasproject) {
            if (lastproject == k && r == 0.0)
              lastproject= -1;  /* doesn't catch all possible sequences */
            else if (key == 'b') {
              qh->SCALEinput= True;
              if (r == 0.0)
                r= -qh_DEFAULTbox;
              qh_option(qh, "Qbound-dim-low", &k, &r);
            }else {
              qh->SCALEinput= True;
              if (r == 0.0)
                r= qh_DEFAULTbox;
              qh_option(qh, "QBound-dim-high", &k, &r);
            }
          }
          break;
        case 'c':
          qh_option(qh, "Qcoplanar-keep", NULL, NULL);
          qh->KEEPcoplanar= True;
          break;
        case 'f':
          qh_option(qh, "Qfurthest-outside", NULL, NULL);
          qh->BESToutside= True;
          break;
        case 'g':
          qh_option(qh, "Qgood-facets-only", NULL, NULL);
          qh->ONLYgood= True;
          break;
        case 'i':
          qh_option(qh, "Qinterior-keep", NULL, NULL);
          qh->KEEPinside= True;
          break;
        case 'm':
          qh_option(qh, "Qmax-outside-only", NULL, NULL);
          qh->ONLYmax= True;
          break;
        case 'r':
          qh_option(qh, "Qrandom-outside", NULL, NULL);
          qh->RANDOMoutside= True;
          break;
        case 's':
          qh_option(qh, "Qsearch-initial-simplex", NULL, NULL);
          qh->ALLpoints= True;
          break;
        case 't':
          qh_option(qh, "Qtriangulate", NULL, NULL);
          qh->TRIangulate= True;
          break;
        case 'T':
          qh_option(qh, "QTestPoints", NULL, NULL);
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7091, "qhull option warning: missing number of test points for option 'QTn'\n");
            lastwarning= s-2;
          }else {
            qh->TESTpoints= qh_strtol(s, &s);
            qh_option(qh, "QTestPoints", &qh->TESTpoints, NULL);
          }
          break;
        case 'u':
          qh_option(qh, "QupperDelaunay", NULL, NULL);
          qh->UPPERdelaunay= True;
          break;
        case 'v':
          qh_option(qh, "Qvertex-neighbors-convex", NULL, NULL);
          qh->TESTvneighbors= True;
          break;
        case 'x':
          qh_option(qh, "Qxact-merge", NULL, NULL);
          qh->MERGEexact= True;
          break;
        case 'z':
          qh_option(qh, "Qz-infinity-point", NULL, NULL);
          qh->ATinfinity= True;
          break;
        case '0':
          qh_option(qh, "Q0-no-premerge", NULL, NULL);
          qh->NOpremerge= True;
          break;
        case '1':
          if (!isdigit(*s)) {
            qh_option(qh, "Q1-angle-merge", NULL, NULL);
            qh->ANGLEmerge= True;
            break;
          }
          switch (*s++) {
          case '0':
            qh_option(qh, "Q10-no-narrow", NULL, NULL);
            qh->NOnarrow= True;
            break;
          case '1':
            qh_option(qh, "Q11-trinormals Qtriangulate", NULL, NULL);
            qh->TRInormals= True;
            qh->TRIangulate= True;
            break;
          case '2':
            qh_option(qh, "Q12-allow-wide", NULL, NULL);
            qh->ALLOWwide= True;
            break;
          case '4':
#ifndef qh_NOmerge
            qh_option(qh, "Q14-merge-pinched-vertices", NULL, NULL);
            qh->MERGEpinched= True;
#else
            /* ignore 'Q14' for q_benchmark testing of difficult cases for Qhull */
            qh_fprintf(qh, qh->ferr, 7099, "qhull option warning: option 'Q14-merge-pinched' disabled due to qh_NOmerge\n");
#endif
            break;
          case '7':
            qh_option(qh, "Q15-check-duplicates", NULL, NULL);
            qh->CHECKduplicates= True;
            break;
          default:
            s--;
            qh_fprintf(qh, qh->ferr, 7016, "qhull option warning: unknown 'Q' qhull option 'Q1%c', skip to next space\n", (int)s[0]);
            lastwarning= s-1;
            while (*++s && !isspace(*s));
            break;
          }
          break;
        case '2':
          qh_option(qh, "Q2-no-merge-independent", NULL, NULL);
          qh->MERGEindependent= False;
          goto LABELcheckdigit;
          break; /* no gcc warnings */
        case '3':
          qh_option(qh, "Q3-no-merge-vertices", NULL, NULL);
          qh->MERGEvertices= False;
        LABELcheckdigit:
          if (isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7017, "qhull option warning: can not follow '1', '2', or '3' with a digit.  'Q%c%c' skipped\n", *(s-1), *s);
            lastwarning= s-2;
            s++;
          }
          break;
        case '4':
          qh_option(qh, "Q4-avoid-old-into-new", NULL, NULL);
          qh->AVOIDold= True;
          break;
        case '5':
          qh_option(qh, "Q5-no-check-outer", NULL, NULL);
          qh->SKIPcheckmax= True;
          break;
        case '6':
          qh_option(qh, "Q6-no-concave-merge", NULL, NULL);
          qh->SKIPconvex= True;
          break;
        case '7':
          qh_option(qh, "Q7-no-breadth-first", NULL, NULL);
          qh->VIRTUALmemory= True;
          break;
        case '8':
          qh_option(qh, "Q8-no-near-inside", NULL, NULL);
          qh->NOnearinside= True;
          break;
        case '9':
          qh_option(qh, "Q9-pick-furthest", NULL, NULL);
          qh->PICKfurthest= True;
          break;
        case 'G':
          i= qh_strtol(s, &t);
          if (qh->GOODpoint) {
            qh_fprintf(qh, qh->ferr, 7018, "qhull option warning: good point already defined for option 'QGn'.  Ignored\n");
            lastwarning= s-2;
          }else if (s == t) {
            qh_fprintf(qh, qh->ferr, 7019, "qhull option warning: missing good point id for option 'QGn'.  Ignored\n");
            lastwarning= s-2;
          }else if (i < 0 || *s == '-') {
            qh->GOODpoint= i-1;
            qh_option(qh, "QGood-if-dont-see-point", &i, NULL);
          }else {
            qh->GOODpoint= i+1;
            qh_option(qh, "QGood-if-see-point", &i, NULL);
          }
          s= t;
          break;
        case 'J':
          if (!isdigit(*s) && *s != '-')
            qh->JOGGLEmax= 0.0;
          else {
            qh->JOGGLEmax= (realT) qh_strtod(s, &s);
            qh_option(qh, "QJoggle", NULL, &qh->JOGGLEmax);
          }
          break;
        case 'R':
          if (!isdigit(*s) && *s != '-') {
            qh_fprintf(qh, qh->ferr, 7020, "qhull option warning: missing random seed for option 'QRn'\n");
            lastwarning= s-2;
          }else {
            qh->ROTATErandom= i= qh_strtol(s, &s);
            if (i > 0)
              qh_option(qh, "QRotate-id", &i, NULL );
            else if (i < -1)
              qh_option(qh, "QRandom-seed", &i, NULL );
          }
          break;
        case 'V':
          i= qh_strtol(s, &t);
          if (qh->GOODvertex) {
            qh_fprintf(qh, qh->ferr, 7021, "qhull option warning: good vertex already defined for option 'QVn'.  Ignored\n");
            lastwarning= s-2;
          }else if (s == t) {
            qh_fprintf(qh, qh->ferr, 7022, "qhull option warning: no good point id given for option 'QVn'.  Ignored\n");
            lastwarning= s-2;
          }else if (i < 0) {
            qh->GOODvertex= i - 1;
            qh_option(qh, "QV-good-facets-not-point", &i, NULL);
          }else {
            qh_option(qh, "QV-good-facets-point", &i, NULL);
            qh->GOODvertex= i + 1;
          }
          s= t;
          break;
        case 'w':
          qh_option(qh, "Qwarn-allow", NULL, NULL);
          qh->ALLOWwarning= True;
          break;
        default:
          s--;
          qh_fprintf(qh, qh->ferr, 7023, "qhull option warning: unknown 'Q' qhull option 'Q%c', skip to next space\n", (int)s[0]);
          lastwarning= s-1;
          while (*++s && !isspace(*s));
          break;
        }
      }
      break;
    case 'T':
      while (*s && !isspace(*s)) {
        if (isdigit(*s) || *s == '-')
          qh->IStracing= qh_strtol(s, &s);
        else switch (*s++) {
        case 'a':
          qh_option(qh, "Tannotate-output", NULL, NULL);
          qh->ANNOTATEoutput= True;
          break;
        case 'c':
          qh_option(qh, "Tcheck-frequently", NULL, NULL);
          qh->CHECKfrequently= True;
          break;
        case 'f':
          qh_option(qh, "Tflush", NULL, NULL);
          qh->FLUSHprint= True;
          break;
        case 's':
          qh_option(qh, "Tstatistics", NULL, NULL);
          qh->PRINTstatistics= True;
          break;
        case 'v':
          qh_option(qh, "Tverify", NULL, NULL);
          qh->VERIFYoutput= True;
          break;
        case 'z':
          if (qh->ferr == qh_FILEstderr) {
            /* The C++ interface captures the output in qh_fprint_qhull() */
            qh_option(qh, "Tz-stdout", NULL, NULL);
            qh->USEstdout= True;
          }else if (!qh->fout) {
            qh_fprintf(qh, qh->ferr, 7024, "qhull option warning: output file undefined(stdout).  Option 'Tz' ignored.\n");
            lastwarning= s-2;
          }else {
            qh_option(qh, "Tz-stdout", NULL, NULL);
            qh->USEstdout= True;
            qh->ferr= qh->fout;
            qh->qhmem.ferr= qh->fout;
          }
          break;
        case 'C':
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7025, "qhull option warning: missing point id for cone for trace option 'TCn'\n");
            lastwarning= s-2;
          }else {
            i= qh_strtol(s, &s);
            qh_option(qh, "TCone-stop", &i, NULL);
            qh->STOPcone= i + 1;
          }
          break;
        case 'F':
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7026, "qhull option warning: missing frequency count for trace option 'TFn'\n");
            lastwarning= s-2;
          }else {
            qh->REPORTfreq= qh_strtol(s, &s);
            qh_option(qh, "TFacet-log", &qh->REPORTfreq, NULL);
            qh->REPORTfreq2= qh->REPORTfreq/2;  /* for tracemerging() */
          }
          break;
        case 'I':
          while (isspace(*s))
            s++;
          t= qh_skipfilename(qh, s);
          {
            char filename[qh_FILENAMElen];

            qh_copyfilename(qh, filename, (int)sizeof(filename), s, (int)(t-s));   /* WARN64 */
            s= t;
            if (!freopen(filename, "r", stdin)) {
              qh_fprintf(qh, qh->ferr, 6041, "qhull option error: cannot open 'TI' file \"%s\"\n", filename);
              qh_errexit(qh, qh_ERRinput, NULL, NULL);
            }else {
              qh_option(qh, "TInput-file", NULL, NULL);
              qh_option(qh, filename, NULL, NULL);
            }
          }
          break;
        case 'O':
          while (isspace(*s))
            s++;
          t= qh_skipfilename(qh, s);
          {
            char filename[qh_FILENAMElen];

            qh_copyfilename(qh, filename, (int)sizeof(filename), s, (int)(t-s));  /* WARN64 */
            if (!qh->fout) {
              qh_fprintf(qh, qh->ferr, 7092, "qhull option warning: qh.fout was not set by caller of qh_initflags.  Cannot use option 'TO' to redirect output.  Ignoring option 'TO'\n");
              lastwarning= s-2;
            }else if (!freopen(filename, "w", qh->fout)) {
              qh_fprintf(qh, qh->ferr, 6044, "qhull option error: cannot open file \"%s\" for writing as option 'TO'.  It is already in use or read-only\n", filename);
              qh_errexit(qh, qh_ERRinput, NULL, NULL);
            }else {
              qh_option(qh, "TOutput-file", NULL, NULL);
              qh_option(qh, filename, NULL, NULL);
            }
            s= t;
          }
          break;
        case 'A':
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7093, "qhull option warning: missing count of added points for trace option 'TAn'\n");
            lastwarning= s-2;
          }else {
            i= qh_strtol(s, &t);
            qh->STOPadd= i + 1;
            qh_option(qh, "TA-stop-add", &i, NULL);
          }
          s= t;
          break;
        case 'P':
          if (*s == '-') {
            if (s[1] == '1' && !isdigit(s[2])) {
              s += 2;
              qh->TRACEpoint= qh_IDunknown; /* qh_buildhull done */
              qh_option(qh, "Trace-point", &qh->TRACEpoint, NULL);
            }else {
              qh_fprintf(qh, qh->ferr, 7100, "qhull option warning: negative point id for trace option 'TPn'.  Expecting 'TP-1' for tracing after qh_buildhull and qh_postmerge\n");
              lastwarning= s-2;
              while (isdigit(*(++s)))
                ; /* skip digits */
            }
          }else if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7029, "qhull option warning: missing point id or -1 for trace option 'TPn'\n");
            lastwarning= s-2;
          }else {
            qh->TRACEpoint= qh_strtol(s, &s);
            qh_option(qh, "Trace-point", &qh->TRACEpoint, NULL);
          }
          break;
        case 'M':
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7030, "qhull option warning: missing merge id for trace option 'TMn'\n");
            lastwarning= s-2;
          }else {
            qh->TRACEmerge= qh_strtol(s, &s);
            qh_option(qh, "Trace-merge", &qh->TRACEmerge, NULL);
          }
          break;
        case 'R':
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7031, "qhull option warning: missing rerun count for trace option 'TRn'\n");
            lastwarning= s-2;
          }else {
            qh->RERUN= qh_strtol(s, &s);
            qh_option(qh, "TRerun", &qh->RERUN, NULL);
          }
          break;
        case 'V':
          i= qh_strtol(s, &t);
          if (s == t) {
            qh_fprintf(qh, qh->ferr, 7032, "qhull option warning: missing furthest point id for trace option 'TVn'\n");
            lastwarning= s-2;
          }else if (i < 0) {
            qh->STOPpoint= i - 1;
            qh_option(qh, "TV-stop-before-point", &i, NULL);
          }else {
            qh->STOPpoint= i + 1;
            qh_option(qh, "TV-stop-after-point", &i, NULL);
          }
          s= t;
          break;
        case 'W':
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7033, "qhull option warning: missing max width for trace option 'TWn'\n");
            lastwarning= s-2;
          }else {
            qh->TRACEdist= (realT) qh_strtod(s, &s);
            qh_option(qh, "TWide-trace", NULL, &qh->TRACEdist);
          }
          break;
        default:
          s--;
          qh_fprintf(qh, qh->ferr, 7034, "qhull option warning: unknown 'T' trace option 'T%c', skip to next space\n", (int)s[0]);
          lastwarning= s-2;
          while (*++s && !isspace(*s));
          break;
        }
      }
      break;
    default:
      qh_fprintf(qh, qh->ferr, 7094, "qhull option warning: unknown option '%c'(%x)\n",
        (int)s[-1], (int)s[-1]);
      lastwarning= s-2;
      break;
    }
    if (s-1 == prev_s && *s && !isspace(*s)) {
      qh_fprintf(qh, qh->ferr, 7036, "qhull option warning: missing space after option '%c'(%x), reserved for sub-options, ignoring '%c' options to next space\n",
               (int)*prev_s, (int)*prev_s, (int)*prev_s);
      lastwarning= s-1;
      while (*s && !isspace(*s))
        s++;
    }
  }
  if (qh->STOPcone && qh->JOGGLEmax < REALmax/2) {
    qh_fprintf(qh, qh->ferr, 7078, "qhull option warning: 'TCn' (stopCone) ignored when used with 'QJn' (joggle)\n");
    lastwarning= command;
  }
  if (isgeom && !qh->FORCEoutput && qh->PRINTout[1]) {
    qh_fprintf(qh, qh->ferr, 7037, "qhull option warning: additional output formats ('Fc',etc.) are not compatible with Geomview ('G').  Use option 'Po' to override\n");
    lastwarning= command;
  }
  if (lastwarning && !qh->ALLOWwarning) {
    qh_fprintf(qh, qh->ferr, 6035, "qhull option error: see previous warnings, use 'Qw' to override: '%s' (last offset %d)\n",
          command, (int)(lastwarning-command));
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  trace4((qh, qh->ferr, 4093, "qh_initflags: option flags initialized\n"));
  /* set derived values in qh_initqhull_globals */
} /* initflags */


/*---------------------------------

  qh_initqhull_buffers(qh)
    initialize global memory buffers

  notes:
    must match qh_freebuffers()
*/
void qh_initqhull_buffers(qhT *qh) {
  int k;

  qh->TEMPsize= (qh->qhmem.LASTsize - SETbasesize)/SETelemsize;
  if (qh->TEMPsize <= 0 || qh->TEMPsize > qh->qhmem.LASTsize)
    qh->TEMPsize= 8;  /* e.g., if qh_NOmem */
  qh->other_points= qh_setnew(qh, qh->TEMPsize);
  qh->del_vertices= qh_setnew(qh, qh->TEMPsize);
  qh->coplanarfacetset= qh_setnew(qh, qh->TEMPsize);
  qh->NEARzero= (realT *)qh_memalloc(qh, qh->hull_dim * (int)sizeof(realT));
  qh->lower_threshold= (realT *)qh_memalloc(qh, (qh->input_dim+1) * (int)sizeof(realT));
  qh->upper_threshold= (realT *)qh_memalloc(qh, (qh->input_dim+1) * (int)sizeof(realT));
  qh->lower_bound= (realT *)qh_memalloc(qh, (qh->input_dim+1) * (int)sizeof(realT));
  qh->upper_bound= (realT *)qh_memalloc(qh, (qh->input_dim+1) * (int)sizeof(realT));
  for (k=qh->input_dim+1; k--; ) {  /* duplicated in qh_initqhull_buffers and qh_clear_outputflags */
    qh->lower_threshold[k]= -REALmax;
    qh->upper_threshold[k]= REALmax;
    qh->lower_bound[k]= -REALmax;
    qh->upper_bound[k]= REALmax;
  }
  qh->gm_matrix= (coordT *)qh_memalloc(qh, (qh->hull_dim+1) * qh->hull_dim * (int)sizeof(coordT));
  qh->gm_row= (coordT **)qh_memalloc(qh, (qh->hull_dim+1) * (int)sizeof(coordT *));
} /* initqhull_buffers */

/*---------------------------------

  qh_initqhull_globals(qh, points, numpoints, dim, ismalloc )
    initialize globals
    if ismalloc
      points were malloc'd and qhull should free at end

  returns:
    sets qh.first_point, num_points, input_dim, hull_dim and others
    seeds random number generator (seed=1 if tracing)
    modifies qh.hull_dim if ((qh.DELAUNAY and qh.PROJECTdelaunay) or qh.PROJECTinput)
    adjust user flags as needed
    also checks DIM3 dependencies and constants

  notes:
    do not use qh_point() since an input transformation may move them elsewhere
    qh_initqhull_start() sets default values for non-zero globals
    consider duplicate error checks in qh_readpoints.  It is called before qh_initqhull_globals

  design:
    initialize points array from input arguments
    test for qh.ZEROcentrum
      (i.e., use opposite vertex instead of cetrum for convexity testing)
    initialize qh.CENTERtype, qh.normal_size,
      qh.center_size, qh.TRACEpoint/level,
    initialize and test random numbers
    qh_initqhull_outputflags() -- adjust and test output flags
*/
void qh_initqhull_globals(qhT *qh, coordT *points, int numpoints, int dim, boolT ismalloc) {
  int seed, pointsneeded, extra= 0, i, randi, k;
  realT randr;
  realT factorial;

  time_t timedata;

  trace0((qh, qh->ferr, 13, "qh_initqhull_globals: for %s | %s\n", qh->rbox_command,
      qh->qhull_command));
  if (numpoints < 1 || numpoints > qh_POINTSmax) {
    qh_fprintf(qh, qh->ferr, 6412, "qhull input error (qh_initqhull_globals): expecting between 1 and %d points.  Got %d %d-d points\n",
      qh_POINTSmax, numpoints, dim);
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
    /* same error message in qh_readpoints */
  }
  qh->POINTSmalloc= ismalloc;
  qh->first_point= points;
  qh->num_points= numpoints;
  qh->hull_dim= qh->input_dim= dim;
  if (!qh->NOpremerge && !qh->MERGEexact && !qh->PREmerge && qh->JOGGLEmax > REALmax/2) {
    qh->MERGING= True;
    if (qh->hull_dim <= 4) {
      qh->PREmerge= True;
      qh_option(qh, "_pre-merge", NULL, NULL);
    }else {
      qh->MERGEexact= True;
      qh_option(qh, "Qxact-merge", NULL, NULL);
    }
  }else if (qh->MERGEexact)
    qh->MERGING= True;
  if (qh->NOpremerge && (qh->MERGEexact || qh->PREmerge))
    qh_fprintf(qh, qh->ferr, 7095, "qhull option warning: 'Q0-no-premerge' ignored due to exact merge ('Qx') or pre-merge ('C-n' or 'A-n')\n");
  if (!qh->NOpremerge && qh->JOGGLEmax > REALmax/2) {
#ifdef qh_NOmerge
    qh->JOGGLEmax= 0.0;
#endif
  }
  if (qh->TRIangulate && qh->JOGGLEmax < REALmax/2 && !qh->PREmerge && !qh->POSTmerge && qh->PRINTprecision)
    qh_fprintf(qh, qh->ferr, 7038, "qhull option warning: joggle ('QJ') produces simplicial output (i.e., triangles in 2-D).  Unless merging is requested, option 'Qt' has no effect\n");
  if (qh->JOGGLEmax < REALmax/2 && qh->DELAUNAY && !qh->SCALEinput && !qh->SCALElast) {
    qh->SCALElast= True;
    qh_option(qh, "Qbbound-last-qj", NULL, NULL);
  }
  if (qh->MERGING && !qh->POSTmerge && qh->premerge_cos > REALmax/2
  && qh->premerge_centrum == 0.0) {
    qh->ZEROcentrum= True;
    qh->ZEROall_ok= True;
    qh_option(qh, "_zero-centrum", NULL, NULL);
  }
  if (qh->JOGGLEmax < REALmax/2 && REALepsilon > 2e-8 && qh->PRINTprecision)
    qh_fprintf(qh, qh->ferr, 7039, "qhull warning: real epsilon, %2.2g, is probably too large for joggle('QJn')\nRecompile with double precision reals(see user_r.h).\n",
          REALepsilon);
#ifdef qh_NOmerge
  if (qh->MERGING) {
    qh_fprintf(qh, qh->ferr, 6045, "qhull option error: merging not installed (qh_NOmerge) for 'Qx', 'Cn' or 'An')\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
#endif
  if (qh->DELAUNAY && qh->KEEPcoplanar && !qh->KEEPinside) {
    qh->KEEPinside= True;
    qh_option(qh, "Qinterior-keep", NULL, NULL);
  }
  if (qh->VORONOI && !qh->DELAUNAY) {
    qh_fprintf(qh, qh->ferr, 6038, "qhull internal error (qh_initqhull_globals): if qh.VORONOI is set, qh.DELAUNAY must be set.  Qhull constructs the Delaunay triangulation in order to compute the Voronoi diagram\n");
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  if (qh->DELAUNAY && qh->HALFspace) {
    qh_fprintf(qh, qh->ferr, 6046, "qhull option error: can not use Delaunay('d') or Voronoi('v') with halfspace intersection('H')\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
    /* same error message in qh_readpoints */
  }
  if (!qh->DELAUNAY && (qh->UPPERdelaunay || qh->ATinfinity)) {
    qh_fprintf(qh, qh->ferr, 6047, "qhull option error: use upper-Delaunay('Qu') or infinity-point('Qz') with Delaunay('d') or Voronoi('v')\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  if (qh->UPPERdelaunay && qh->ATinfinity) {
    qh_fprintf(qh, qh->ferr, 6048, "qhull option error: can not use infinity-point('Qz') with upper-Delaunay('Qu')\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  if (qh->MERGEpinched && qh->ONLYgood) {
    qh_fprintf(qh, qh->ferr, 6362, "qhull option error: can not use merge-pinched-vertices ('Q14') with good-facets-only ('Qg')\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  if (qh->MERGEpinched && qh->hull_dim == 2) {
    trace2((qh, qh->ferr, 2108, "qh_initqhull_globals: disable qh.MERGEpinched for 2-d.  It has no effect"))
    qh->MERGEpinched= False;
  }
  if (qh->SCALElast && !qh->DELAUNAY && qh->PRINTprecision)
    qh_fprintf(qh, qh->ferr, 7040, "qhull option warning: option 'Qbb' (scale-last-coordinate) is normally used with 'd' or 'v'\n");
  qh->DOcheckmax= (!qh->SKIPcheckmax && (qh->MERGING || qh->APPROXhull));
  qh->KEEPnearinside= (qh->DOcheckmax && !(qh->KEEPinside && qh->KEEPcoplanar)
                          && !qh->NOnearinside);
  if (qh->MERGING)
    qh->CENTERtype= qh_AScentrum;
  else if (qh->VORONOI)
    qh->CENTERtype= qh_ASvoronoi;
  if (qh->TESTvneighbors && !qh->MERGING) {
    qh_fprintf(qh, qh->ferr, 6049, "qhull option error: test vertex neighbors('Qv') needs a merge option\n");
    qh_errexit(qh, qh_ERRinput, NULL ,NULL);
  }
  if (qh->PROJECTinput || (qh->DELAUNAY && qh->PROJECTdelaunay)) {
    qh->hull_dim -= qh->PROJECTinput;
    if (qh->DELAUNAY) {
      qh->hull_dim++;
      if (qh->ATinfinity)
        extra= 1;
    }
  }
  if (qh->hull_dim <= 1) {
    qh_fprintf(qh, qh->ferr, 6050, "qhull error: dimension %d must be > 1\n", qh->hull_dim);
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  for (k=2, factorial=1.0; k < qh->hull_dim; k++)
    factorial *= k;
  qh->AREAfactor= 1.0 / factorial;
  trace2((qh, qh->ferr, 2005, "qh_initqhull_globals: initialize globals.  input_dim %d, numpoints %d, malloc? %d, projected %d to hull_dim %d\n",
        qh->input_dim, numpoints, ismalloc, qh->PROJECTinput, qh->hull_dim));
  qh->normal_size= qh->hull_dim * (int)sizeof(coordT);
  qh->center_size= qh->normal_size - (int)sizeof(coordT);
  pointsneeded= qh->hull_dim+1;
  if (qh->hull_dim > qh_DIMmergeVertex) {
    qh->MERGEvertices= False;
    qh_option(qh, "Q3-no-merge-vertices-dim-high", NULL, NULL);
  }
  if (qh->GOODpoint)
    pointsneeded++;
#ifdef qh_NOtrace
  if (qh->IStracing || qh->TRACEmerge || qh->TRACEpoint != qh_IDnone || qh->TRACEdist < REALmax/2) {
      qh_fprintf(qh, qh->ferr, 6051, "qhull option error: tracing is not installed (qh_NOtrace in user_r.h).  Trace options 'Tn', 'TMn', 'TPn' and 'TWn' mostly removed.  Continue with 'Qw' (allow warning)\n");
      if (!qh->ALLOWwarning)
        qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
#endif
  if (qh->RERUN > 1) {
    qh->TRACElastrun= qh->IStracing; /* qh_build_withrestart duplicates next conditional */
    if (qh->IStracing && qh->IStracing != -1) {
      qh_fprintf(qh, qh->ferr, 8162, "qh_initqhull_globals: trace last of TR%d runs at level %d\n", qh->RERUN, qh->IStracing);
      qh->IStracing= 0;
    }
  }else if (qh->TRACEpoint != qh_IDnone || qh->TRACEdist < REALmax/2 || qh->TRACEmerge) {
    qh->TRACElevel= (qh->IStracing ? qh->IStracing : 3);
    qh->IStracing= 0;
  }
  if (qh->ROTATErandom == 0 || qh->ROTATErandom == -1) {
    seed= (int)time(&timedata);
    if (qh->ROTATErandom  == -1) {
      seed= -seed;
      qh_option(qh, "QRandom-seed", &seed, NULL );
    }else
      qh_option(qh, "QRotate-random", &seed, NULL);
    qh->ROTATErandom= seed;
  }
  seed= qh->ROTATErandom;
  if (seed == INT_MIN)    /* default value */
    seed= 1;
  else if (seed < 0)
    seed= -seed;
  qh_RANDOMseed_(qh, seed);
  randr= 0.0;
  for (i=1000; i--; ) {
    randi= qh_RANDOMint;
    randr += randi;
    if (randi > qh_RANDOMmax) {
      qh_fprintf(qh, qh->ferr, 8036, "\
qhull configuration error (qh_RANDOMmax in user_r.h): random integer %d > qh_RANDOMmax (%.8g)\n",
               randi, qh_RANDOMmax);
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
  }
  qh_RANDOMseed_(qh, seed);
  randr= randr/1000;
  if (randr < qh_RANDOMmax * 0.1
  || randr > qh_RANDOMmax * 0.9)
    qh_fprintf(qh, qh->ferr, 8037, "\
qhull configuration warning (qh_RANDOMmax in user_r.h): average of 1000 random integers (%.2g) is much different than expected (%.2g).  Is qh_RANDOMmax (%.2g) wrong?\n",
             randr, qh_RANDOMmax * 0.5, qh_RANDOMmax);
  qh->RANDOMa= 2.0 * qh->RANDOMfactor/qh_RANDOMmax;
  qh->RANDOMb= 1.0 - qh->RANDOMfactor;
  if (qh_HASHfactor < 1.1) {
    qh_fprintf(qh, qh->ferr, 6052, "qhull internal error (qh_initqhull_globals): qh_HASHfactor %d must be at least 1.1.  Qhull uses linear hash probing\n",
      qh_HASHfactor);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  if (numpoints+extra < pointsneeded) {
    qh_fprintf(qh, qh->ferr, 6214, "qhull input error: not enough points(%d) to construct initial simplex (need %d)\n",
            numpoints, pointsneeded);
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  qh_initqhull_outputflags(qh);
} /* initqhull_globals */

/*---------------------------------

  qh_initqhull_mem(qh )
    initialize mem_r.c for qhull
    qh.hull_dim and qh.normal_size determine some of the allocation sizes
    if qh.MERGING,
      includes ridgeT
    calls qh_user_memsizes (user_r.c) to add up to 10 additional sizes for quick allocation
      (see numsizes below)

  returns:
    mem_r.c already for qh_memalloc/qh_memfree (errors if called beforehand)

  notes:
    qh_produceoutput() prints memsizes

*/
void qh_initqhull_mem(qhT *qh) {
  int numsizes;
  int i;

  numsizes= 8+10;
  qh_meminitbuffers(qh, qh->IStracing, qh_MEMalign, numsizes,
                     qh_MEMbufsize, qh_MEMinitbuf);
  qh_memsize(qh, (int)sizeof(vertexT));
  if (qh->MERGING) {
    qh_memsize(qh, (int)sizeof(ridgeT));
    qh_memsize(qh, (int)sizeof(mergeT));
  }
  qh_memsize(qh, (int)sizeof(facetT));
  i= SETbasesize + (qh->hull_dim - 1) * SETelemsize;  /* ridge.vertices */
  qh_memsize(qh, i);
  qh_memsize(qh, qh->normal_size);        /* normal */
  i += SETelemsize;                 /* facet.vertices, .ridges, .neighbors */
  qh_memsize(qh, i);
  qh_user_memsizes(qh);
  qh_memsetup(qh);
} /* initqhull_mem */

/*---------------------------------

  qh_initqhull_outputflags
    initialize flags concerned with output

  returns:
    adjust user flags as needed

  see:
    qh_clear_outputflags() resets the flags

  design:
    test for qh.PRINTgood (i.e., only print 'good' facets)
    check for conflicting print output options
*/
void qh_initqhull_outputflags(qhT *qh) {
  boolT printgeom= False, printmath= False, printcoplanar= False;
  int i;

  trace3((qh, qh->ferr, 3024, "qh_initqhull_outputflags: %s\n", qh->qhull_command));
  if (!(qh->PRINTgood || qh->PRINTneighbors)) {
    if (qh->DELAUNAY || qh->KEEParea || qh->KEEPminArea < REALmax/2 || qh->KEEPmerge
        || (!qh->ONLYgood && (qh->GOODvertex || qh->GOODpoint))) {
      qh->PRINTgood= True;
      qh_option(qh, "Pgood", NULL, NULL);
    }
  }
  if (qh->PRINTtransparent) {
    if (qh->hull_dim != 4 || !qh->DELAUNAY || qh->VORONOI || qh->DROPdim >= 0) {
      qh_fprintf(qh, qh->ferr, 6215, "qhull option error: transparent Delaunay('Gt') needs 3-d Delaunay('d') w/o 'GDn'\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    qh->DROPdim= 3;
    qh->PRINTridges= True;
  }
  for (i=qh_PRINTEND; i--; ) {
    if (qh->PRINTout[i] == qh_PRINTgeom)
      printgeom= True;
    else if (qh->PRINTout[i] == qh_PRINTmathematica || qh->PRINTout[i] == qh_PRINTmaple)
      printmath= True;
    else if (qh->PRINTout[i] == qh_PRINTcoplanars)
      printcoplanar= True;
    else if (qh->PRINTout[i] == qh_PRINTpointnearest)
      printcoplanar= True;
    else if (qh->PRINTout[i] == qh_PRINTpointintersect && !qh->HALFspace) {
      qh_fprintf(qh, qh->ferr, 6053, "qhull option error: option 'Fp' is only used for \nhalfspace intersection('Hn,n,n').\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }else if (qh->PRINTout[i] == qh_PRINTtriangles && (qh->HALFspace || qh->VORONOI)) {
      qh_fprintf(qh, qh->ferr, 6054, "qhull option error: option 'Ft' is not available for Voronoi vertices ('v') or halfspace intersection ('H')\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }else if (qh->PRINTout[i] == qh_PRINTcentrums && qh->VORONOI) {
      qh_fprintf(qh, qh->ferr, 6055, "qhull option error: option 'FC' is not available for Voronoi vertices('v')\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }else if (qh->PRINTout[i] == qh_PRINTvertices) {
      if (qh->VORONOI)
        qh_option(qh, "Fvoronoi", NULL, NULL);
      else
        qh_option(qh, "Fvertices", NULL, NULL);
    }
  }
  if (printcoplanar && qh->DELAUNAY && qh->JOGGLEmax < REALmax/2) {
    if (qh->PRINTprecision)
      qh_fprintf(qh, qh->ferr, 7041, "qhull option warning: 'QJ' (joggle) will usually prevent coincident input sites for options 'Fc' and 'FP'\n");
  }
  if (printmath && (qh->hull_dim > 3 || qh->VORONOI)) {
    qh_fprintf(qh, qh->ferr, 6056, "qhull option error: Mathematica and Maple output is only available for 2-d and 3-d convex hulls and 2-d Delaunay triangulations\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  if (printgeom) {
    if (qh->hull_dim > 4) {
      qh_fprintf(qh, qh->ferr, 6057, "qhull option error: Geomview output is only available for 2-d, 3-d and 4-d\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    if (qh->PRINTnoplanes && !(qh->PRINTcoplanar + qh->PRINTcentrums
     + qh->PRINTdots + qh->PRINTspheres + qh->DOintersections + qh->PRINTridges)) {
      qh_fprintf(qh, qh->ferr, 6058, "qhull option error: no output specified for Geomview\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    if (qh->VORONOI && (qh->hull_dim > 3 || qh->DROPdim >= 0)) {
      qh_fprintf(qh, qh->ferr, 6059, "qhull option error: Geomview output for Voronoi diagrams only for 2-d\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    /* can not warn about furthest-site Geomview output: no lower_threshold */
    if (qh->hull_dim == 4 && qh->DROPdim == -1 &&
        (qh->PRINTcoplanar || qh->PRINTspheres || qh->PRINTcentrums)) {
      qh_fprintf(qh, qh->ferr, 7042, "qhull option warning: coplanars, vertices, and centrums output not available for 4-d output(ignored).  Could use 'GDn' instead.\n");
      qh->PRINTcoplanar= qh->PRINTspheres= qh->PRINTcentrums= False;
    }
  }
  if (!qh->KEEPcoplanar && !qh->KEEPinside && !qh->ONLYgood) {
    if ((qh->PRINTcoplanar && qh->PRINTspheres) || printcoplanar) {
      if (qh->QHULLfinished) {
        qh_fprintf(qh, qh->ferr, 7072, "qhull output warning: ignoring coplanar points, option 'Qc' was not set for the first run of qhull.\n");
      }else {
        qh->KEEPcoplanar= True;
        qh_option(qh, "Qcoplanar", NULL, NULL);
      }
    }
  }
  qh->PRINTdim= qh->hull_dim;
  if (qh->DROPdim >=0) {    /* after Geomview checks */
    if (qh->DROPdim < qh->hull_dim) {
      qh->PRINTdim--;
      if (!printgeom || qh->hull_dim < 3)
        qh_fprintf(qh, qh->ferr, 7043, "qhull option warning: drop dimension 'GD%d' is only available for 3-d/4-d Geomview\n", qh->DROPdim);
    }else
      qh->DROPdim= -1;
  }else if (qh->VORONOI) {
    qh->DROPdim= qh->hull_dim-1;
    qh->PRINTdim= qh->hull_dim-1;
  }
} /* qh_initqhull_outputflags */

/*---------------------------------

  qh_initqhull_start(qh, infile, outfile, errfile )
    allocate memory if needed and call qh_initqhull_start2()
*/
void qh_initqhull_start(qhT *qh, FILE *infile, FILE *outfile, FILE *errfile) {

  qh_initstatistics(qh);
  qh_initqhull_start2(qh, infile, outfile, errfile);
} /* initqhull_start */

/*---------------------------------

  qh_initqhull_start2(qh, infile, outfile, errfile )
    start initialization of qhull
    initialize statistics, stdio, default values for global variables
    assumes qh is allocated
  notes:
    report errors elsewhere, error handling and g_qhull_output [Qhull.cpp, QhullQh()] not in initialized
  see:
    qh_maxmin() determines the precision constants
    qh_freeqhull()
*/
void qh_initqhull_start2(qhT *qh, FILE *infile, FILE *outfile, FILE *errfile) {
  time_t timedata;
  int seed;

  qh_CPUclock; /* start the clock(for qh_clock).  One-shot. */
  /* memset is the same in qh_freeqhull() and qh_initqhull_start2() */
  memset((char *)qh, 0, sizeof(qhT)-sizeof(qhmemT)-sizeof(qhstatT));   /* every field is 0, FALSE, NULL */
  qh->NOerrexit= True;
  qh->DROPdim= -1;
  qh->ferr= errfile;
  qh->fin= infile;
  qh->fout= outfile;
  qh->furthest_id= qh_IDunknown;
#ifndef qh_NOmerge
  qh->JOGGLEmax= REALmax;
#else
  qh->JOGGLEmax= 0.0;  /* Joggle ('QJ') if qh_NOmerge */
#endif
  qh->KEEPminArea= REALmax;
  qh->last_low= REALmax;
  qh->last_high= REALmax;
  qh->last_newhigh= REALmax;
  qh->last_random= 1; /* reentrant only */
  qh->lastcpu= 0.0;
  qh->max_outside= 0.0;
  qh->max_vertex= 0.0;
  qh->MAXabs_coord= 0.0;
  qh->MAXsumcoord= 0.0;
  qh->MAXwidth= -REALmax;
  qh->MERGEindependent= True;
  qh->MINdenom_1= fmax_(1.0/REALmax, REALmin); /* used by qh_scalepoints */
  qh->MINoutside= 0.0;
  qh->MINvisible= REALmax;
  qh->MAXcoplanar= REALmax;
  qh->outside_err= REALmax;
  qh->premerge_centrum= 0.0;
  qh->premerge_cos= REALmax;
  qh->PRINTprecision= True;
  qh->PRINTradius= 0.0;
  qh->postmerge_cos= REALmax;
  qh->postmerge_centrum= 0.0;
  qh->ROTATErandom= INT_MIN;
  qh->MERGEvertices= True;
  qh->totarea= 0.0;
  qh->totvol= 0.0;
  qh->TRACEdist= REALmax;
  qh->TRACEpoint= qh_IDnone;    /* recompile to trace a point, or use 'TPn' */
  qh->tracefacet_id= UINT_MAX;  /* recompile to trace a facet, set to UINT_MAX when done, see userprintf_r.c/qh_fprintf */
  qh->traceridge_id= UINT_MAX;  /* recompile to trace a ridge, set to UINT_MAX when done, see userprintf_r.c/qh_fprintf */
  qh->tracevertex_id= UINT_MAX; /* recompile to trace a vertex, set to UINT_MAX when done, see userprintf_r.c/qh_fprintf */
  seed= (int)time(&timedata);
  qh_RANDOMseed_(qh, seed);
  qh->run_id= qh_RANDOMint;
  if(!qh->run_id)
      qh->run_id++;  /* guarantee non-zero */
  qh_option(qh, "run-id", &qh->run_id, NULL);
  strcat(qh->qhull, "qhull");
} /* initqhull_start2 */

/*---------------------------------

  qh_initthresholds(qh, commandString )
    set thresholds for printing and scaling from commandString

  returns:
    sets qh.GOODthreshold or qh.SPLITthreshold if 'Pd0D1' used

  see:
    qh_initflags(), 'Qbk' 'QBk' 'Pdk' and 'PDk'
    qh_inthresholds()

  design:
    for each 'Pdn' or 'PDn' option
      check syntax
      set qh.lower_threshold or qh.upper_threshold
    set qh.GOODthreshold if an unbounded threshold is used
    set qh.SPLITthreshold if a bounded threshold is used
*/
void qh_initthresholds(qhT *qh, char *command) {
  realT value;
  int idx, maxdim, k;
  char *s= command; /* non-const due to strtol */
  char *lastoption, *lastwarning= NULL;
  char key;

  maxdim= qh->input_dim;
  if (qh->DELAUNAY && (qh->PROJECTdelaunay || qh->PROJECTinput))
    maxdim++;
  while (*s) {
    if (*s == '-')
      s++;
    if (*s == 'P') {
      lastoption= s++;
      while (*s && !isspace(key= *s++)) {
        if (key == 'd' || key == 'D') {
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7044, "qhull option warning: no dimension given for Print option 'P%c' at: %s.  Ignored\n",
                    key, s-1);
            lastwarning= lastoption;
            continue;
          }
          idx= qh_strtol(s, &s);
          if (idx >= qh->hull_dim) {
            qh_fprintf(qh, qh->ferr, 7045, "qhull option warning: dimension %d for Print option 'P%c' is >= %d.  Ignored\n",
                idx, key, qh->hull_dim);
            lastwarning= lastoption;
            continue;
          }
          if (*s == ':') {
            s++;
            value= qh_strtod(s, &s);
            if (fabs((double)value) > 1.0) {
              qh_fprintf(qh, qh->ferr, 7046, "qhull option warning: value %2.4g for Print option 'P%c' is > +1 or < -1.  Ignored\n",
                      value, key);
              lastwarning= lastoption;
              continue;
            }
          }else
            value= 0.0;
          if (key == 'd')
            qh->lower_threshold[idx]= value;
          else
            qh->upper_threshold[idx]= value;
        }
      }
    }else if (*s == 'Q') {
      lastoption= s++;
      while (*s && !isspace(key= *s++)) {
        if (key == 'b' && *s == 'B') {
          s++;
          for (k=maxdim; k--; ) {
            qh->lower_bound[k]= -qh_DEFAULTbox;
            qh->upper_bound[k]= qh_DEFAULTbox;
          }
        }else if (key == 'b' && *s == 'b')
          s++;
        else if (key == 'b' || key == 'B') {
          if (!isdigit(*s)) {
            qh_fprintf(qh, qh->ferr, 7047, "qhull option warning: no dimension given for Qhull option 'Q%c'\n",
                    key);
            lastwarning= lastoption;
            continue;
          }
          idx= qh_strtol(s, &s);
          if (idx >= maxdim) {
            qh_fprintf(qh, qh->ferr, 7048, "qhull option warning: dimension %d for Qhull option 'Q%c' is >= %d.  Ignored\n",
                idx, key, maxdim);
            lastwarning= lastoption;
            continue;
          }
          if (*s == ':') {
            s++;
            value= qh_strtod(s, &s);
          }else if (key == 'b')
            value= -qh_DEFAULTbox;
          else
            value= qh_DEFAULTbox;
          if (key == 'b')
            qh->lower_bound[idx]= value;
          else
            qh->upper_bound[idx]= value;
        }
      }
    }else {
      while (*s && !isspace(*s))
        s++;
    }
    while (isspace(*s))
      s++;
  }
  for (k=qh->hull_dim; k--; ) {
    if (qh->lower_threshold[k] > -REALmax/2) {
      qh->GOODthreshold= True;
      if (qh->upper_threshold[k] < REALmax/2) {
        qh->SPLITthresholds= True;
        qh->GOODthreshold= False;
        break;
      }
    }else if (qh->upper_threshold[k] < REALmax/2)
      qh->GOODthreshold= True;
  }
  if (lastwarning && !qh->ALLOWwarning) {
    qh_fprintf(qh, qh->ferr, 6036, "qhull option error: see previous warnings, use 'Qw' to override: '%s' (last offset %d)\n",
      command, (int)(lastwarning-command));
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
} /* initthresholds */

/*---------------------------------

  qh_lib_check( qhullLibraryType, qhTsize, vertexTsize, ridgeTsize, facetTsize, setTsize, qhmemTsize )
    Report error if library does not agree with caller

  notes:
    NOerrors -- qh_lib_check can not call qh_errexit()
*/
void qh_lib_check(int qhullLibraryType, int qhTsize, int vertexTsize, int ridgeTsize, int facetTsize, int setTsize, int qhmemTsize) {
    int last_errcode= qh_ERRnone;

#if defined(_MSC_VER) && defined(_DEBUG) && defined(QHULL_CRTDBG)  /* user_r.h */
    /*_CrtSetBreakAlloc(744);*/  /* Break at memalloc {744}, or 'watch' _crtBreakAlloc */
    _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) );
    _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG );
    _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDERR );
    _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG );
    _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR );
    _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG );
    _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDERR );
#endif

    if (qhullLibraryType==QHULL_NON_REENTRANT) { /* 0 */
      qh_fprintf_stderr(6257, "qh_lib_check: Incorrect qhull library called.  Caller uses non-reentrant Qhull with a static qhT.  Qhull library is reentrant.\n");
      last_errcode= 6257;
    }else if (qhullLibraryType==QHULL_QH_POINTER) { /* 1 */
      qh_fprintf_stderr(6258, "qh_lib_check: Incorrect qhull library called.  Caller uses non-reentrant Qhull with a dynamic qhT via qh_QHpointer.  Qhull library is reentrant.\n");
      last_errcode= 6258;
    }else if (qhullLibraryType != QHULL_REENTRANT) { /* 2 */
      qh_fprintf_stderr(6262, "qh_lib_check: Expecting qhullLibraryType QHULL_NON_REENTRANT(0), QHULL_QH_POINTER(1), or QHULL_REENTRANT(2).  Got %d\n", qhullLibraryType);
      last_errcode= 6262;
    }
    if (qhTsize != (int)sizeof(qhT)) {
      qh_fprintf_stderr(6249, "qh_lib_check: Incorrect qhull library called.  Size of qhT for caller is %d, but for qhull library is %d.\n", qhTsize, (int)sizeof(qhT));
      last_errcode= 6249;
    }
    if (vertexTsize != (int)sizeof(vertexT)) {
      qh_fprintf_stderr(6250, "qh_lib_check: Incorrect qhull library called.  Size of vertexT for caller is %d, but for qhull library is %d.\n", vertexTsize, (int)sizeof(vertexT));
      last_errcode= 6250;
    }
    if (ridgeTsize != (int)sizeof(ridgeT)) {
      qh_fprintf_stderr(6251, "qh_lib_check: Incorrect qhull library called.  Size of ridgeT for caller is %d, but for qhull library is %d.\n", ridgeTsize, (int)sizeof(ridgeT));
      last_errcode= 6251;
    }
    if (facetTsize != (int)sizeof(facetT)) {
      qh_fprintf_stderr(6252, "qh_lib_check: Incorrect qhull library called.  Size of facetT for caller is %d, but for qhull library is %d.\n", facetTsize, (int)sizeof(facetT));
      last_errcode= 6252;
    }
    if (setTsize && setTsize != SETbasesize) {
      qh_fprintf_stderr(6253, "qh_lib_check: Incorrect qhull library called.  Size of setT for caller is %d, but for qhull library is %d.\n", setTsize, SETbasesize);
      last_errcode= 6253;
    }
    if (qhmemTsize && qhmemTsize != sizeof(qhmemT)) {
      qh_fprintf_stderr(6254, "qh_lib_check: Incorrect qhull library called.  Size of qhmemT for caller is %d, but for qhull library is %d.\n", qhmemTsize, sizeof(qhmemT));
      last_errcode= 6254;
    }
    if (last_errcode) {
      qh_fprintf_stderr(6259, "qhull internal error (qh_lib_check): Cannot continue due to QH%d.  '%s' is not reentrant (e.g., qhull.so) or out-of-date.  Exit with %d\n",
            last_errcode, qh_version2, last_errcode - 6200);
      qh_exit(last_errcode - 6200);  /* can not use qh_errexit(), must be less than 255 */
    }
} /* lib_check */

/*---------------------------------

  qh_option(qh, option, intVal, realVal )
    add an option description to qh.qhull_options

  notes:
    NOerrors -- qh_option can not call qh_errexit() [qh_initqhull_start2]
    will be printed with statistics ('Ts') and errors
    strlen(option) < 40
*/
void qh_option(qhT *qh, const char *option, int *i, realT *r) {
  char buf[200];
  int buflen, remainder;

  if (strlen(option) > sizeof(buf)-30-30) {
    qh_fprintf(qh, qh->ferr, 6408, "qhull internal error (qh_option): option (%d chars) has more than %d chars.  May overflow temporary buffer.  Option '%s'\n",
        (int)strlen(option), (int)sizeof(buf)-30-30, option);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  snprintf(buf, 199, "  %s", option);
  if (i)
    snprintf(buf+strlen(buf), 22, " %d", *i);
  if (r)
    snprintf(buf+strlen(buf), 11, " %2.2g", *r);
  buflen= (int)strlen(buf);   /* WARN64 */
  qh->qhull_optionlen += buflen;
  remainder= (int)(sizeof(qh->qhull_options) - strlen(qh->qhull_options)) - 1;    /* WARN64 */
  maximize_(remainder, 0);
  if (qh->qhull_optionlen >= qh_OPTIONline && remainder > 0) {
    strncat(qh->qhull_options, "\n", (unsigned int)remainder);
    --remainder;
    qh->qhull_optionlen= buflen;
  }
  if (buflen > remainder) {
    trace1((qh, qh->ferr, 1058, "qh_option: option would overflow qh.qhull_options. Truncated '%s'\n", buf));
  }
  strncat(qh->qhull_options, buf, (unsigned int)remainder);
} /* option */

/*---------------------------------

  qh_zero( qh, errfile )
    Initialize and zero Qhull's memory for qh_new_qhull()

  notes:
    Not needed in global_r.c because static variables are initialized to zero
*/
void qh_zero(qhT *qh, FILE *errfile) {
    memset((char *)qh, 0, sizeof(qhT));   /* every field is 0, FALSE, NULL */
    qh->NOerrexit= True;
    qh_meminit(qh, errfile);
} /* zero */

geometry/src/RcppExports.cpp0000644000176200001440000000237514744661717015721 0ustar  liggesusers// Generated by using Rcpp::compileAttributes() -> do not edit by hand
// Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#include 

using namespace Rcpp;

#ifdef RCPP_USE_GLOBAL_ROSTREAM
Rcpp::Rostream&  Rcpp::Rcout = Rcpp::Rcpp_cout_get();
Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get();
#endif

// C_tsearch
SEXP C_tsearch(NumericVector x, NumericVector y, IntegerMatrix elem, NumericVector xi, NumericVector yi, bool bary, double eps);
RcppExport SEXP _geometry_C_tsearch(SEXP xSEXP, SEXP ySEXP, SEXP elemSEXP, SEXP xiSEXP, SEXP yiSEXP, SEXP barySEXP, SEXP epsSEXP) {
BEGIN_RCPP
    Rcpp::RObject rcpp_result_gen;
    Rcpp::RNGScope rcpp_rngScope_gen;
    Rcpp::traits::input_parameter< NumericVector >::type x(xSEXP);
    Rcpp::traits::input_parameter< NumericVector >::type y(ySEXP);
    Rcpp::traits::input_parameter< IntegerMatrix >::type elem(elemSEXP);
    Rcpp::traits::input_parameter< NumericVector >::type xi(xiSEXP);
    Rcpp::traits::input_parameter< NumericVector >::type yi(yiSEXP);
    Rcpp::traits::input_parameter< bool >::type bary(barySEXP);
    Rcpp::traits::input_parameter< double >::type eps(epsSEXP);
    rcpp_result_gen = Rcpp::wrap(C_tsearch(x, y, elem, xi, yi, bary, eps));
    return rcpp_result_gen;
END_RCPP
}
geometry/src/geom_r.h0000644000176200001440000001765714664417655014357 0ustar  liggesusers/*
  ---------------------------------

  geom_r.h
    header file for geometric routines

   see qh-geom_r.htm and geom_r.c

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/geom_r.h#2 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#ifndef qhDEFgeom
#define qhDEFgeom 1

#include "libqhull_r.h"

/* ============ -macros- ======================== */

/*----------------------------------

  fabs_(a)
    returns the absolute value of a
*/
#define fabs_( a ) ((( a ) < 0 ) ? -( a ):( a ))

/*----------------------------------

  fmax_(a,b)
    returns the maximum value of a and b
*/
#define fmax_( a,b )  ( ( a ) < ( b ) ? ( b ) : ( a ) )

/*----------------------------------

  fmin_(a,b)
    returns the minimum value of a and b
*/
#define fmin_( a,b )  ( ( a ) > ( b ) ? ( b ) : ( a ) )

/*----------------------------------

  maximize_(maxval, val)
    set maxval to val if val is greater than maxval
*/
#define maximize_( maxval, val ) { if (( maxval ) < ( val )) ( maxval )= ( val ); }

/*----------------------------------

  minimize_(minval, val)
    set minval to val if val is less than minval
*/
#define minimize_( minval, val ) { if (( minval ) > ( val )) ( minval )= ( val ); }

/*----------------------------------

  det2_(a1, a2,
        b1, b2)

    compute a 2-d determinate
*/
#define det2_( a1,a2,b1,b2 ) (( a1 )*( b2 ) - ( a2 )*( b1 ))

/*----------------------------------

  det3_(a1, a2, a3,
       b1, b2, b3,
       c1, c2, c3)

    compute a 3-d determinate
*/
#define det3_( a1,a2,a3,b1,b2,b3,c1,c2,c3 ) ( ( a1 )*det2_( b2,b3,c2,c3 ) \
                - ( b1 )*det2_( a2,a3,c2,c3 ) + ( c1 )*det2_( a2,a3,b2,b3 ) )

/*----------------------------------

  dX( p1, p2 )
  dY( p1, p2 )
  dZ( p1, p2 )

    given two indices into rows[],

    compute the difference between X, Y, or Z coordinates
*/
#define dX( p1,p2 )  ( *( rows[p1] ) - *( rows[p2] ))
#define dY( p1,p2 )  ( *( rows[p1]+1 ) - *( rows[p2]+1 ))
#define dZ( p1,p2 )  ( *( rows[p1]+2 ) - *( rows[p2]+2 ))
#define dW( p1,p2 )  ( *( rows[p1]+3 ) - *( rows[p2]+3 ))

/*============= prototypes in alphabetical order, infrequent at end ======= */

#ifdef __cplusplus
extern "C" {
#endif

void    qh_backnormal(qhT *qh, realT **rows, int numrow, int numcol, boolT sign, coordT *normal, boolT *nearzero);
void    qh_distplane(qhT *qh, pointT *point, facetT *facet, realT *dist);
facetT *qh_findbest(qhT *qh, pointT *point, facetT *startfacet,
                     boolT bestoutside, boolT isnewfacets, boolT noupper,
                     realT *dist, boolT *isoutside, int *numpart);
facetT *qh_findbesthorizon(qhT *qh, boolT ischeckmax, pointT *point,
                     facetT *startfacet, boolT noupper, realT *bestdist, int *numpart);
facetT *qh_findbestnew(qhT *qh, pointT *point, facetT *startfacet, realT *dist,
                     boolT bestoutside, boolT *isoutside, int *numpart);
void    qh_gausselim(qhT *qh, realT **rows, int numrow, int numcol, boolT *sign, boolT *nearzero);
realT   qh_getangle(qhT *qh, pointT *vect1, pointT *vect2);
pointT *qh_getcenter(qhT *qh, setT *vertices);
pointT *qh_getcentrum(qhT *qh, facetT *facet);
coordT  qh_getdistance(qhT *qh, facetT *facet, facetT *neighbor, coordT *mindist, coordT *maxdist);
void    qh_normalize(qhT *qh, coordT *normal, int dim, boolT toporient);
void    qh_normalize2(qhT *qh, coordT *normal, int dim, boolT toporient,
            realT *minnorm, boolT *ismin);
pointT *qh_projectpoint(qhT *qh, pointT *point, facetT *facet, realT dist);

void    qh_setfacetplane(qhT *qh, facetT *newfacets);
void    qh_sethyperplane_det(qhT *qh, int dim, coordT **rows, coordT *point0,
              boolT toporient, coordT *normal, realT *offset, boolT *nearzero);
void    qh_sethyperplane_gauss(qhT *qh, int dim, coordT **rows, pointT *point0,
             boolT toporient, coordT *normal, coordT *offset, boolT *nearzero);
boolT   qh_sharpnewfacets(qhT *qh);

/*========= infrequently used code in geom2_r.c =============*/

coordT *qh_copypoints(qhT *qh, coordT *points, int numpoints, int dimension);
void    qh_crossproduct(int dim, realT vecA[3], realT vecB[3], realT vecC[3]);
realT   qh_determinant(qhT *qh, realT **rows, int dim, boolT *nearzero);
realT   qh_detjoggle(qhT *qh, pointT *points, int numpoints, int dimension);
void    qh_detmaxoutside(qhT *qh);
void    qh_detroundoff(qhT *qh);
realT   qh_detsimplex(qhT *qh, pointT *apex, setT *points, int dim, boolT *nearzero);
realT   qh_distnorm(int dim, pointT *point, pointT *normal, realT *offsetp);
realT   qh_distround(qhT *qh, int dimension, realT maxabs, realT maxsumabs);
realT   qh_divzero(realT numer, realT denom, realT mindenom1, boolT *zerodiv);
realT   qh_facetarea(qhT *qh, facetT *facet);
realT   qh_facetarea_simplex(qhT *qh, int dim, coordT *apex, setT *vertices,
          vertexT *notvertex,  boolT toporient, coordT *normal, realT *offset);
pointT *qh_facetcenter(qhT *qh, setT *vertices);
facetT *qh_findgooddist(qhT *qh, pointT *point, facetT *facetA, realT *distp, facetT **facetlist);
vertexT *qh_furthestnewvertex(qhT *qh, unsigned int unvisited, facetT *facet, realT *maxdistp /* qh.newvertex_list */);
vertexT *qh_furthestvertex(qhT *qh, facetT *facetA, facetT *facetB, realT *maxdistp, realT *mindistp);
void    qh_getarea(qhT *qh, facetT *facetlist);
boolT   qh_gram_schmidt(qhT *qh, int dim, realT **rows);
boolT   qh_inthresholds(qhT *qh, coordT *normal, realT *angle);
void    qh_joggleinput(qhT *qh);
realT  *qh_maxabsval(realT *normal, int dim);
setT   *qh_maxmin(qhT *qh, pointT *points, int numpoints, int dimension);
realT   qh_maxouter(qhT *qh);
void    qh_maxsimplex(qhT *qh, int dim, setT *maxpoints, pointT *points, int numpoints, setT **simplex);
realT   qh_minabsval(realT *normal, int dim);
int     qh_mindiff(realT *vecA, realT *vecB, int dim);
boolT   qh_orientoutside(qhT *qh, facetT *facet);
void    qh_outerinner(qhT *qh, facetT *facet, realT *outerplane, realT *innerplane);
coordT  qh_pointdist(pointT *point1, pointT *point2, int dim);
void    qh_printmatrix(qhT *qh, FILE *fp, const char *string, realT **rows, int numrow, int numcol);
void    qh_printpoints(qhT *qh, FILE *fp, const char *string, setT *points);
void    qh_projectinput(qhT *qh);
void    qh_projectpoints(qhT *qh, signed char *project, int n, realT *points,
             int numpoints, int dim, realT *newpoints, int newdim);
void    qh_rotateinput(qhT *qh, realT **rows);
void    qh_rotatepoints(qhT *qh, realT *points, int numpoints, int dim, realT **rows);
void    qh_scaleinput(qhT *qh);
void    qh_scalelast(qhT *qh, coordT *points, int numpoints, int dim, coordT low,
                   coordT high, coordT newhigh);
void    qh_scalepoints(qhT *qh, pointT *points, int numpoints, int dim,
                realT *newlows, realT *newhighs);
boolT   qh_sethalfspace(qhT *qh, int dim, coordT *coords, coordT **nextp,
              coordT *normal, coordT *offset, coordT *feasible);
coordT *qh_sethalfspace_all(qhT *qh, int dim, int count, coordT *halfspaces, pointT *feasible);
coordT  qh_vertex_bestdist(qhT *qh, setT *vertices);
coordT  qh_vertex_bestdist2(qhT *qh, setT *vertices, vertexT **vertexp, vertexT **vertexp2);
pointT *qh_voronoi_center(qhT *qh, int dim, setT *points);

#ifdef __cplusplus
} /* extern "C"*/
#endif

#endif /* qhDEFgeom */



geometry/src/libqhull_r.c0000644000176200001440000021516714664417655015233 0ustar  liggesusers/*
  ---------------------------------

   libqhull_r.c
   Quickhull algorithm for convex hulls

   qhull() and top-level routines

   see qh-qhull_r.htm, libqhull_r.h, unix_r.c

   see qhull_ra.h for internal functions

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/libqhull_r.c#17 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#include "qhull_ra.h"

/*============= functions in alphabetic order after qhull() =======*/

/*---------------------------------

  qh_qhull(qh)
    compute DIM3 convex hull of qh.num_points starting at qh.first_point
    qh->contains all global options and variables

  returns:
    returns polyhedron
      qh.facet_list, qh.num_facets, qh.vertex_list, qh.num_vertices,

    returns global variables
      qh.hulltime, qh.max_outside, qh.interior_point, qh.max_vertex, qh.min_vertex

    returns precision constants
      qh.ANGLEround, centrum_radius, cos_max, DISTround, MAXabs_coord, ONEmerge

  notes:
    unless needed for output
      qh.max_vertex and qh.min_vertex are max/min due to merges

  see:
    to add individual points to either qh.num_points
      use qh_addpoint()

    if qh.GETarea
      qh_produceoutput() returns qh.totarea and qh.totvol via qh_getarea()

  design:
    record starting time
    initialize hull and partition points
    build convex hull
    unless early termination
      update facet->maxoutside for vertices, coplanar, and near-inside points
    error if temporary sets exist
    record end time
*/

void qh_qhull(qhT *qh) {
  int numoutside;

  qh->hulltime= qh_CPUclock;
  if (qh->RERUN || qh->JOGGLEmax < REALmax/2)
    qh_build_withrestart(qh);
  else {
    qh_initbuild(qh);
    qh_buildhull(qh);
  }
  if (!qh->STOPadd && !qh->STOPcone && !qh->STOPpoint) {
    if (qh->ZEROall_ok && !qh->TESTvneighbors && qh->MERGEexact)
      qh_checkzero(qh, qh_ALL);
    if (qh->ZEROall_ok && !qh->TESTvneighbors && !qh->WAScoplanar) {
      trace2((qh, qh->ferr, 2055, "qh_qhull: all facets are clearly convex and no coplanar points.  Post-merging and check of maxout not needed.\n"));
      qh->DOcheckmax= False;
    }else {
      qh_initmergesets(qh /* qh.facet_mergeset,degen_mergeset,vertex_mergeset */);
      if (qh->MERGEexact || (qh->hull_dim > qh_DIMreduceBuild && qh->PREmerge))
        qh_postmerge(qh, "First post-merge", qh->premerge_centrum, qh->premerge_cos,
             (qh->POSTmerge ? False : qh->TESTvneighbors)); /* calls qh_reducevertices */
      else if (!qh->POSTmerge && qh->TESTvneighbors)
        qh_postmerge(qh, "For testing vertex neighbors", qh->premerge_centrum,
             qh->premerge_cos, True);                       /* calls qh_test_vneighbors */
      if (qh->POSTmerge)
        qh_postmerge(qh, "For post-merging", qh->postmerge_centrum,
             qh->postmerge_cos, qh->TESTvneighbors);
      if (qh->visible_list == qh->facet_list) {            /* qh_postmerge was called */
        qh->findbestnew= True;
        qh_partitionvisible(qh, !qh_ALL, &numoutside /* qh.visible_list */);
        qh->findbestnew= False;
        qh_deletevisible(qh /* qh.visible_list */);        /* stops at first !f.visible */
        qh_resetlists(qh, False, qh_RESETvisible /* qh.visible_list newvertex_list qh.newfacet_list */);
      }
      qh_all_vertexmerges(qh, -1, NULL, NULL);
      qh_freemergesets(qh);
    }
    if (qh->TRACEpoint == qh_IDunknown && qh->TRACElevel > qh->IStracing) {
      qh->IStracing= qh->TRACElevel;
      qh_fprintf(qh, qh->ferr, 2112, "qh_qhull: finished qh_buildhull and qh_postmerge, start tracing (TP-1)\n");
    }
    if (qh->DOcheckmax){
      if (qh->REPORTfreq) {
        qh_buildtracing(qh, NULL, NULL);
        qh_fprintf(qh, qh->ferr, 8115, "\nTesting all coplanar points.\n");
      }
      qh_check_maxout(qh);
    }
    if (qh->KEEPnearinside && !qh->maxoutdone)
      qh_nearcoplanar(qh);
  }
  if (qh_setsize(qh, qh->qhmem.tempstack) != 0) {
    qh_fprintf(qh, qh->ferr, 6164, "qhull internal error (qh_qhull): temporary sets not empty(%d) at end of Qhull\n",
             qh_setsize(qh, qh->qhmem.tempstack));
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  qh->hulltime= qh_CPUclock - qh->hulltime;
  qh->QHULLfinished= True;
  trace1((qh, qh->ferr, 1036, "Qhull: algorithm completed\n"));
} /* qhull */

/*---------------------------------

  qh_addpoint(qh, furthest, facet, checkdist )
    add point (usually furthest point) above facet to hull
    if checkdist,
      check that point is above facet.
      if point is not outside of the hull, uses qh_partitioncoplanar()
      assumes that facet is defined by qh_findbestfacet()
    else if facet specified,
      assumes that point is above facet (major damage if below)
    for Delaunay triangulations,
      Use qh_setdelaunay() to lift point to paraboloid and scale by 'Qbb' if needed
      Do not use options 'Qbk', 'QBk', or 'QbB' since they scale the coordinates.

  returns:
    returns False if user requested an early termination
      qh.visible_list, newfacet_list, delvertex_list, NEWfacets may be defined
    updates qh.facet_list, qh.num_facets, qh.vertex_list, qh.num_vertices
    clear qh.maxoutdone (will need to call qh_check_maxout() for facet->maxoutside)
    if unknown point, adds a pointer to qh.other_points
      do not deallocate the point's coordinates

  notes:
    called from qh_initbuild, qh_buildhull, and qh_addpoint
    tail recursive call if merged a pinchedvertex due to a duplicated ridge
      no more than qh.num_vertices calls (QH6296)
    assumes point is near its best facet and not at a local minimum of a lens
      distributions.  Use qh_findbestfacet to avoid this case.
    uses qh.visible_list, qh.newfacet_list, qh.delvertex_list, qh.NEWfacets
    if called from a user application after qh_qhull and 'QJ' (joggle),
      facet merging for precision problems is disabled by default

  design:
    exit if qh.STOPadd vertices 'TAn'
    add point to other_points if needed
    if checkdist
      if point not above facet
        partition coplanar point
        exit
    exit if pre STOPpoint requested
    find horizon and visible facets for point
    build cone of new facets to the horizon
    exit if build cone fails due to qh.ONLYgood
    tail recursive call if build cone fails due to pinched vertices
    exit if STOPcone requested
    merge non-convex new facets
    if merge found, many merges, or 'Qf'
       use qh_findbestnew() instead of qh_findbest()
    partition outside points from visible facets
    delete visible facets
    check polyhedron if requested
    exit if post STOPpoint requested
    reset working lists of facets and vertices
*/
boolT qh_addpoint(qhT *qh, pointT *furthest, facetT *facet, boolT checkdist) {
  realT dist, pbalance;
  facetT *replacefacet, *newfacet;
  vertexT *apex;
  boolT isoutside= False;
  int numpart, numpoints, goodvisible, goodhorizon, apexpointid;

  qh->maxoutdone= False;
  if (qh_pointid(qh, furthest) == qh_IDunknown)
    qh_setappend(qh, &qh->other_points, furthest);
  if (!facet) {
    qh_fprintf(qh, qh->ferr, 6213, "qhull internal error (qh_addpoint): NULL facet.  Need to call qh_findbestfacet first\n");
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  qh_detmaxoutside(qh);
  if (checkdist) {
    facet= qh_findbest(qh, furthest, facet, !qh_ALL, !qh_ISnewfacets, !qh_NOupper,
                        &dist, &isoutside, &numpart);
    zzadd_(Zpartition, numpart);
    if (!isoutside) {
      zinc_(Znotmax);  /* last point of outsideset is no longer furthest. */
      facet->notfurthest= True;
      qh_partitioncoplanar(qh, furthest, facet, &dist, qh->findbestnew);
      return True;
    }
  }
  qh_buildtracing(qh, furthest, facet);
  if (qh->STOPpoint < 0 && qh->furthest_id == -qh->STOPpoint-1) {
    facet->notfurthest= True;
    return False;
  }
  qh_findhorizon(qh, furthest, facet, &goodvisible, &goodhorizon);
  if (qh->ONLYgood && !qh->GOODclosest && !(goodvisible+goodhorizon)) {
    zinc_(Znotgood);
    facet->notfurthest= True;
    /* last point of outsideset is no longer furthest.  This is ok
        since all points of the outside are likely to be bad */
    qh_resetlists(qh, False, qh_RESETvisible /* qh.visible_list newvertex_list qh.newfacet_list */);
    return True;
  }
  apex= qh_buildcone(qh, furthest, facet, goodhorizon, &replacefacet);
  /* qh.newfacet_list, visible_list, newvertex_list */
  if (!apex) {
    if (qh->ONLYgood)
      return True; /* ignore this furthest point, a good new facet was not found */
    if (replacefacet) {
      if (qh->retry_addpoint++ >= qh->num_vertices) {
        qh_fprintf(qh, qh->ferr, 6296, "qhull internal error (qh_addpoint): infinite loop (%d retries) of merging pinched vertices due to dupridge for point p%d, facet f%d, and %d vertices\n",
          qh->retry_addpoint, qh_pointid(qh, furthest), facet->id, qh->num_vertices);
        qh_errexit(qh, qh_ERRqhull, facet, NULL);
      }
      /* retry qh_addpoint after resolving a dupridge via qh_merge_pinchedvertices */
      return qh_addpoint(qh, furthest, replacefacet, True /* checkdisk */);
    }
    qh->retry_addpoint= 0;
    return True; /* ignore this furthest point, resolved a dupridge by making furthest a coplanar point */
  }
  if (qh->retry_addpoint) {
    zinc_(Zretryadd);
    zadd_(Zretryaddtot, qh->retry_addpoint);
    zmax_(Zretryaddmax, qh->retry_addpoint);
    qh->retry_addpoint= 0;
  }
  apexpointid= qh_pointid(qh, apex->point);
  zzinc_(Zprocessed);
  if (qh->STOPcone && qh->furthest_id == qh->STOPcone-1) {
    facet->notfurthest= True;
    return False;  /* visible_list etc. still defined */
  }
  qh->findbestnew= False;
  if (qh->PREmerge || qh->MERGEexact) {
    qh_initmergesets(qh /* qh.facet_mergeset,degen_mergeset,vertex_mergeset */);
    qh_premerge(qh, apexpointid, qh->premerge_centrum, qh->premerge_cos /* qh.newfacet_list */);
    if (qh_USEfindbestnew)
      qh->findbestnew= True;
    else {
      FORALLnew_facets {
        if (!newfacet->simplicial) {
          qh->findbestnew= True;  /* use qh_findbestnew instead of qh_findbest*/
          break;
        }
      }
    }
  }else if (qh->BESToutside)
    qh->findbestnew= True;
  if (qh->IStracing >= 4)
    qh_checkpolygon(qh, qh->visible_list);
  qh_partitionvisible(qh, !qh_ALL, &numpoints /* qh.visible_list */);
  qh->findbestnew= False;
  qh->findbest_notsharp= False;
  zinc_(Zpbalance);
  pbalance= numpoints - (realT) qh->hull_dim /* assumes all points extreme */
                * (qh->num_points - qh->num_vertices)/qh->num_vertices;
  wadd_(Wpbalance, pbalance);
  wadd_(Wpbalance2, pbalance * pbalance);
  qh_deletevisible(qh /* qh.visible_list */);
  zmax_(Zmaxvertex, qh->num_vertices);
  qh->NEWfacets= False;
  if (qh->IStracing >= 4) {
    if (qh->num_facets < 200)
      qh_printlists(qh);
    qh_printfacetlist(qh, qh->newfacet_list, NULL, True);
    qh_checkpolygon(qh, qh->facet_list);
  }else if (qh->CHECKfrequently) {
    if (qh->num_facets < 1000)
      qh_checkpolygon(qh, qh->facet_list);
    else
      qh_checkpolygon(qh, qh->newfacet_list);
  }
  if (qh->STOPpoint > 0 && qh->furthest_id == qh->STOPpoint-1 && qh_setsize(qh, qh->vertex_mergeset) > 0)
    return False;
  qh_resetlists(qh, True, qh_RESETvisible /* qh.visible_list newvertex_list qh.newfacet_list */);
  if (qh->facet_mergeset) {
    /* vertex merges occur after facet merges (qh_premerge) and qh_resetlists */
    qh_all_vertexmerges(qh, apexpointid, NULL, NULL);
    qh_freemergesets(qh);
  }
  /* qh_triangulate(qh); to test qh.TRInormals */
  if (qh->STOPpoint > 0 && qh->furthest_id == qh->STOPpoint-1)
    return False;
  trace2((qh, qh->ferr, 2056, "qh_addpoint: added p%d to convex hull with point balance %2.2g\n",
    qh_pointid(qh, furthest), pbalance));
  return True;
} /* addpoint */

/*---------------------------------

  qh_build_withrestart(qh)
    allow restarts due to qh.JOGGLEmax while calling qh_buildhull()
       qh_errexit always undoes qh_build_withrestart()
    qh.FIRSTpoint/qh.NUMpoints is point array
       it may be moved by qh_joggleinput
*/
void qh_build_withrestart(qhT *qh) {
  int restart;
  vertexT *vertex, **vertexp;

  qh->ALLOWrestart= True;
  while (True) {
    restart= setjmp(qh->restartexit); /* simple statement for CRAY J916 */
    if (restart) {       /* only from qh_joggle_restart() */
      qh->last_errcode= qh_ERRnone;
      zzinc_(Zretry);
      wmax_(Wretrymax, qh->JOGGLEmax);
      /* QH7078 warns about using 'TCn' with 'QJn' */
      qh->STOPcone= qh_IDunknown; /* if break from joggle, prevents normal output */
      FOREACHvertex_(qh->del_vertices) {
        if (vertex->point && !vertex->partitioned)
          vertex->partitioned= True; /* avoid error in qh_freebuild -> qh_delvertex */
      }
    }
    if (!qh->RERUN && qh->JOGGLEmax < REALmax/2) {
      if (qh->build_cnt > qh_JOGGLEmaxretry) {
        qh_fprintf(qh, qh->ferr, 6229, "qhull input error: %d attempts to construct a convex hull with joggled input.  Increase joggle above 'QJ%2.2g' or modify qh_JOGGLE... parameters in user_r.h\n",
           qh->build_cnt, qh->JOGGLEmax);
        qh_errexit(qh, qh_ERRinput, NULL, NULL);
      }
      if (qh->build_cnt && !restart)
        break;
    }else if (qh->build_cnt && qh->build_cnt >= qh->RERUN)
      break;
    qh->STOPcone= 0;
    qh_freebuild(qh, True);  /* first call is a nop */
    qh->build_cnt++;
    if (!qh->qhull_optionsiz)
      qh->qhull_optionsiz= (int)strlen(qh->qhull_options);   /* WARN64 */
    else {
      qh->qhull_options[qh->qhull_optionsiz]= '\0';
      qh->qhull_optionlen= qh_OPTIONline;  /* starts a new line */
    }
    qh_option(qh, "_run", &qh->build_cnt, NULL);
    if (qh->build_cnt == qh->RERUN) {
      qh->IStracing= qh->TRACElastrun;  /* duplicated from qh_initqhull_globals */
      if (qh->TRACEpoint != qh_IDnone || qh->TRACEdist < REALmax/2 || qh->TRACEmerge) {
        qh->TRACElevel= (qh->IStracing? qh->IStracing : 3);
        qh->IStracing= 0;
      }
      qh->qhmem.IStracing= qh->IStracing;
    }
    if (qh->JOGGLEmax < REALmax/2)
      qh_joggleinput(qh);
    qh_initbuild(qh);
    qh_buildhull(qh);
    if (qh->JOGGLEmax < REALmax/2 && !qh->MERGING)
      qh_checkconvex(qh, qh->facet_list, qh_ALGORITHMfault);
  }
  qh->ALLOWrestart= False;
} /* qh_build_withrestart */

/*---------------------------------

  qh_buildcone(qh, furthest, facet, goodhorizon, &replacefacet )
    build cone of new facets from furthest to the horizon
    goodhorizon is count of good, horizon facets from qh_find_horizon

  returns:
    returns apex of cone with qh.newfacet_list and qh.first_newfacet (f.id)
    returns NULL if qh.ONLYgood and no good facets
    returns NULL and retryfacet if merging pinched vertices will resolve a dupridge
      a horizon vertex was nearly adjacent to another vertex
      will retry qh_addpoint
    returns NULL if resolve a dupridge by making furthest a coplanar point
      furthest was nearly adjacent to an existing vertex
    updates qh.degen_mergeset (MRGridge) if resolve a dupridge by merging facets
    updates qh.newfacet_list, visible_list, newvertex_list
    updates qh.facet_list, vertex_list, num_facets, num_vertices

  notes:
    called by qh_addpoint
    see qh_triangulate, it triangulates non-simplicial facets in post-processing

  design:
    make new facets for point to horizon
    compute balance statistics
    make hyperplanes for point
    exit if qh.ONLYgood and not good (qh_buildcone_onlygood)
    match neighboring new facets
    if dupridges
      exit if !qh.IGNOREpinched and dupridge resolved by coplanar furthest
      retry qh_buildcone if !qh.IGNOREpinched and dupridge resolved by qh_buildcone_mergepinched
      otherwise dupridges resolved by merging facets
    update vertex neighbors and delete interior vertices
*/
vertexT *qh_buildcone(qhT *qh, pointT *furthest, facetT *facet, int goodhorizon, facetT **retryfacet) {
  vertexT *apex;
  realT newbalance;
  int numnew;

  *retryfacet= NULL;
  qh->first_newfacet= qh->facet_id;
  qh->NEWtentative= (qh->MERGEpinched || qh->ONLYgood); /* cleared by qh_attachnewfacets or qh_resetlists */
  apex= qh_makenewfacets(qh, furthest /* qh.newfacet_list visible_list, attaches new facets if !qh.NEWtentative */);
  numnew= (int)(qh->facet_id - qh->first_newfacet);
  newbalance= numnew - (realT)(qh->num_facets - qh->num_visible) * qh->hull_dim / qh->num_vertices;
  /* newbalance statistics updated below if the new facets are accepted */
  if (qh->ONLYgood) { /* qh.MERGEpinched is false by QH6362 */
    if (!qh_buildcone_onlygood(qh, apex, goodhorizon /* qh.newfacet_list */)) {
      facet->notfurthest= True;
      return NULL;
    }
  }else if(qh->MERGEpinched) {
#ifndef qh_NOmerge
    if (qh_buildcone_mergepinched(qh, apex, facet, retryfacet /* qh.newfacet_list */))
      return NULL;
#else
    qh_fprintf(qh, qh->ferr, 6375, "qhull option error (qh_buildcone): option 'Q14' (qh.MERGEpinched) is not available due to qh_NOmerge\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
#endif
  }else {
    /* qh_makenewfacets attached new facets to the horizon */
    qh_matchnewfacets(qh); /* ignore returned value.  qh_forcedmerges will merge dupridges if any */
    qh_makenewplanes(qh /* qh.newfacet_list */);
    qh_update_vertexneighbors_cone(qh);
  }
  wadd_(Wnewbalance, newbalance);
  wadd_(Wnewbalance2, newbalance * newbalance);
  trace2((qh, qh->ferr, 2067, "qh_buildcone: created %d newfacets for p%d(v%d) new facet balance %2.2g\n",
    numnew, qh_pointid(qh, furthest), apex->id, newbalance));
  return apex;
} /* buildcone */

#ifndef qh_NOmerge
/*---------------------------------

  qh_buildcone_mergepinched(qh, apex, facet, maxdupdist, &retryfacet )
    build cone of new facets from furthest to the horizon
    maxdupdist>0.0 for merging dupridges (qh_matchdupridge)

  returns:
    returns True if merged a pinched vertex and deleted the cone of new facets
      if retryfacet is set
        a dupridge was resolved by qh_merge_pinchedvertices
        retry qh_addpoint
      otherwise
        apex/furthest was partitioned as a coplanar point
        ignore this furthest point
    returns False if no dupridges or if dupridges will be resolved by MRGridge
    updates qh.facet_list, qh.num_facets, qh.vertex_list, qh.num_vertices

  notes:
    only called from qh_buildcone with qh.MERGEpinched

  design:
    match neighboring new facets
    if matching detected dupridges with a wide merge (qh_RATIOtrypinched)
      if pinched vertices (i.e., nearly adjacent)
        delete the cone of new facets
        delete the apex and reset the facet lists
        if coplanar, pinched apex
          partition the apex as a coplanar point
        else
           repeatedly merge the nearest pair of pinched vertices and subsequent facet merges
        return True
      otherwise
        MRGridge are better than vertex merge, but may report an error
    attach new facets
    make hyperplanes for point
    update vertex neighbors and delete interior vertices
*/
boolT qh_buildcone_mergepinched(qhT *qh, vertexT *apex, facetT *facet, facetT **retryfacet) {
  facetT *newfacet, *nextfacet;
  pointT *apexpoint;
  coordT maxdupdist;
  int apexpointid;
  boolT iscoplanar;

  *retryfacet= NULL;
  maxdupdist= qh_matchnewfacets(qh);
  if (maxdupdist > qh_RATIOtrypinched * qh->ONEmerge) { /* one or more dupridges with a wide merge */
    if (qh->IStracing >= 4 && qh->num_facets < 1000)
      qh_printlists(qh);
    qh_initmergesets(qh /* qh.facet_mergeset,degen_mergeset,vertex_mergeset */);
    if (qh_getpinchedmerges(qh, apex, maxdupdist, &iscoplanar /* qh.newfacet_list, qh.vertex_mergeset */)) {
      for (newfacet=qh->newfacet_list; newfacet && newfacet->next; newfacet= nextfacet) {
        nextfacet= newfacet->next;
        qh_delfacet(qh, newfacet);
      }
      apexpoint= apex->point;
      apexpointid= qh_pointid(qh, apexpoint);
      qh_delvertex(qh, apex);
      qh_resetlists(qh, False, qh_RESETvisible /* qh.visible_list newvertex_list qh.newfacet_list */);
      if (iscoplanar) {
        zinc_(Zpinchedapex);
        facet->notfurthest= True;
        qh_partitioncoplanar(qh, apexpoint, facet, NULL, qh->findbestnew);
      }else {
        qh_all_vertexmerges(qh, apexpointid, facet, retryfacet);
      }
      qh_freemergesets(qh); /* errors if not empty */
      return True;
    }
    /* MRGridge are better than vertex merge, but may report an error */
    qh_freemergesets(qh);
  }
  qh_attachnewfacets(qh /* qh.visible_list */);
  qh_makenewplanes(qh /* qh.newfacet_list */);
  qh_update_vertexneighbors_cone(qh);
  return False;
} /* buildcone_mergepinched */
#endif /* !qh_NOmerge */

/*---------------------------------

  qh_buildcone_onlygood(qh, apex, goodhorizon )
    build cone of good, new facets from apex and its qh.newfacet_list to the horizon
    goodhorizon is count of good, horizon facets from qh_find_horizon

  returns:
    False if a f.good facet or a qh.GOODclosest facet is not found
    updates qh.facet_list, qh.num_facets, qh.vertex_list, qh.num_vertices

  notes:
    called from qh_buildcone
    QH11030 FIX: Review effect of qh.GOODclosest on qh_buildcone_onlygood ('Qg').  qh_findgood preserves old value if didn't find a good facet.  See qh_findgood_all for disabling

  design:
    make hyperplanes for point
    if qh_findgood fails to find a f.good facet or a qh.GOODclosest facet
      delete cone of new facets
      return NULL (ignores apex)
    else
      attach cone to horizon
      match neighboring new facets
*/
boolT qh_buildcone_onlygood(qhT *qh, vertexT *apex, int goodhorizon) {
  facetT *newfacet, *nextfacet;

  qh_makenewplanes(qh /* qh.newfacet_list */);
  if(qh_findgood(qh, qh->newfacet_list, goodhorizon) == 0) {
    if (!qh->GOODclosest) {
      for (newfacet=qh->newfacet_list; newfacet && newfacet->next; newfacet= nextfacet) {
        nextfacet= newfacet->next;
        qh_delfacet(qh, newfacet);
      }
      qh_delvertex(qh, apex);
      qh_resetlists(qh, False /*no stats*/, qh_RESETvisible /* qh.visible_list newvertex_list qh.newfacet_list */);
      zinc_(Znotgoodnew);
      /* !good outside points dropped from hull */
      return False;
    }
  }
  qh_attachnewfacets(qh /* qh.visible_list */);
  qh_matchnewfacets(qh); /* ignore returned value.  qh_forcedmerges will merge dupridges if any */
  qh_update_vertexneighbors_cone(qh);
  return True;
} /* buildcone_onlygood */

/*---------------------------------

  qh_buildhull(qh)
    construct a convex hull by adding outside points one at a time

  returns:

  notes:
    may be called multiple times
    checks facet and vertex lists for incorrect flags
    to recover from STOPcone, call qh_deletevisible and qh_resetlists

  design:
    check visible facet and newfacet flags
    check newfacet vertex flags and qh.STOPcone/STOPpoint
    for each facet with a furthest outside point
      add point to facet
      exit if qh.STOPcone or qh.STOPpoint requested
    if qh.NARROWhull for initial simplex
      partition remaining outside points to coplanar sets
*/
void qh_buildhull(qhT *qh) {
  facetT *facet;
  pointT *furthest;
  vertexT *vertex;
  int id;

  trace1((qh, qh->ferr, 1037, "qh_buildhull: start build hull\n"));
  FORALLfacets {
    if (facet->visible || facet->newfacet) {
      qh_fprintf(qh, qh->ferr, 6165, "qhull internal error (qh_buildhull): visible or new facet f%d in facet list\n",
                   facet->id);
      qh_errexit(qh, qh_ERRqhull, facet, NULL);
    }
  }
  FORALLvertices {
    if (vertex->newfacet) {
      qh_fprintf(qh, qh->ferr, 6166, "qhull internal error (qh_buildhull): new vertex f%d in vertex list\n",
                   vertex->id);
      qh_errprint(qh, "ERRONEOUS", NULL, NULL, NULL, vertex);
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }
    id= qh_pointid(qh, vertex->point);
    if ((qh->STOPpoint>0 && id == qh->STOPpoint-1) ||
        (qh->STOPpoint<0 && id == -qh->STOPpoint-1) ||
        (qh->STOPcone>0 && id == qh->STOPcone-1)) {
      trace1((qh, qh->ferr, 1038,"qh_buildhull: stop point or cone P%d in initial hull\n", id));
      return;
    }
  }
  qh->facet_next= qh->facet_list;      /* advance facet when processed */
  while ((furthest= qh_nextfurthest(qh, &facet))) {
    qh->num_outside--;  /* if ONLYmax, furthest may not be outside */
    if (qh->STOPadd>0 && (qh->num_vertices - qh->hull_dim - 1 >= qh->STOPadd - 1)) {
      trace1((qh, qh->ferr, 1059, "qh_buildhull: stop after adding %d vertices\n", qh->STOPadd-1));
      return;
    }
    if (!qh_addpoint(qh, furthest, facet, qh->ONLYmax))
      break;
  }
  if (qh->NARROWhull) /* move points from outsideset to coplanarset */
    qh_outcoplanar(qh /* facet_list */ );
  if (qh->num_outside && !furthest) {
    qh_fprintf(qh, qh->ferr, 6167, "qhull internal error (qh_buildhull): %d outside points were never processed.\n", qh->num_outside);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  trace1((qh, qh->ferr, 1039, "qh_buildhull: completed the hull construction\n"));
} /* buildhull */


/*---------------------------------

  qh_buildtracing(qh, furthest, facet )
    trace an iteration of qh_buildhull() for furthest point and facet
    if !furthest, prints progress message

  returns:
    tracks progress with qh.lastreport, lastcpu, lastfacets, lastmerges, lastplanes, lastdist
    updates qh.furthest_id (-3 if furthest is NULL)
    also resets visit_id, vertext_visit on wrap around

  see:
    qh_tracemerging()

  design:
    if !furthest
      print progress message
      exit
    if 'TFn' iteration
      print progress message
    else if tracing
      trace furthest point and facet
    reset qh.visit_id and qh.vertex_visit if overflow may occur
    set qh.furthest_id for tracing
*/
void qh_buildtracing(qhT *qh, pointT *furthest, facetT *facet) {
  realT dist= 0;
  double cpu;
  int total, furthestid;
  time_t timedata;
  struct tm *tp;
  vertexT *vertex;

  qh->old_randomdist= qh->RANDOMdist;
  qh->RANDOMdist= False;
  if (!furthest) {
    time(&timedata);
    tp= localtime(&timedata);
    cpu= (double)qh_CPUclock - (double)qh->hulltime;
    cpu /= (double)qh_SECticks;
    total= zzval_(Ztotmerge) - zzval_(Zcyclehorizon) + zzval_(Zcyclefacettot);
    qh_fprintf(qh, qh->ferr, 8118, "\n\
At %02d:%02d:%02d & %2.5g CPU secs, qhull has created %d facets and merged %d.\n\
 The current hull contains %d facets and %d vertices.  Last point was p%d\n",
      tp->tm_hour, tp->tm_min, tp->tm_sec, cpu, qh->facet_id -1,
      total, qh->num_facets, qh->num_vertices, qh->furthest_id);
    return;
  }
  furthestid= qh_pointid(qh, furthest);
#ifndef qh_NOtrace
  if (qh->TRACEpoint == furthestid) {
    trace1((qh, qh->ferr, 1053, "qh_buildtracing: start trace T%d for point TP%d above facet f%d\n", qh->TRACElevel, furthestid, facet->id));
    qh->IStracing= qh->TRACElevel;
    qh->qhmem.IStracing= qh->TRACElevel;
  }else if (qh->TRACEpoint != qh_IDnone && qh->TRACEdist < REALmax/2) {
    qh->IStracing= 0;
    qh->qhmem.IStracing= 0;
  }
#endif
  if (qh->REPORTfreq && (qh->facet_id-1 > qh->lastreport + (unsigned int)qh->REPORTfreq)) {
    qh->lastreport= qh->facet_id-1;
    time(&timedata);
    tp= localtime(&timedata);
    cpu= (double)qh_CPUclock - (double)qh->hulltime;
    cpu /= (double)qh_SECticks;
    total= zzval_(Ztotmerge) - zzval_(Zcyclehorizon) + zzval_(Zcyclefacettot);
    zinc_(Zdistio);
    qh_distplane(qh, furthest, facet, &dist);
    qh_fprintf(qh, qh->ferr, 8119, "\n\
At %02d:%02d:%02d & %2.5g CPU secs, qhull has created %d facets and merged %d.\n\
 The current hull contains %d facets and %d vertices.  There are %d\n\
 outside points.  Next is point p%d(v%d), %2.2g above f%d.\n",
      tp->tm_hour, tp->tm_min, tp->tm_sec, cpu, qh->facet_id -1,
      total, qh->num_facets, qh->num_vertices, qh->num_outside+1,
      furthestid, qh->vertex_id, dist, getid_(facet));
  }else if (qh->IStracing >=1) {
    cpu= (double)qh_CPUclock - (double)qh->hulltime;
    cpu /= (double)qh_SECticks;
    qh_distplane(qh, furthest, facet, &dist);
    qh_fprintf(qh, qh->ferr, 1049, "qh_addpoint: add p%d(v%d) %2.2g above f%d to hull of %d facets, %d merges, %d outside at %4.4g CPU secs.  Previous p%d(v%d) delta %4.4g CPU, %d facets, %d merges, %d hyperplanes, %d distplanes, %d retries\n",
      furthestid, qh->vertex_id, dist, getid_(facet), qh->num_facets, zzval_(Ztotmerge), qh->num_outside+1, cpu, qh->furthest_id, qh->vertex_id - 1,
      cpu - qh->lastcpu, qh->num_facets - qh->lastfacets,  zzval_(Ztotmerge) - qh->lastmerges, zzval_(Zsetplane) - qh->lastplanes, zzval_(Zdistplane) - qh->lastdist, qh->retry_addpoint);
    qh->lastcpu= cpu;
    qh->lastfacets= qh->num_facets;
    qh->lastmerges= zzval_(Ztotmerge);
    qh->lastplanes= zzval_(Zsetplane);
    qh->lastdist= zzval_(Zdistplane);
  }
  zmax_(Zvisit2max, (int)qh->visit_id/2);
  if (qh->visit_id > (unsigned int) INT_MAX) { /* 31 bits */
    zinc_(Zvisit);
    if (!qh_checklists(qh, qh->facet_list)) {
      qh_fprintf(qh, qh->ferr, 6370, "qhull internal error: qh_checklists failed on reset of qh.visit_id %u\n", qh->visit_id);
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }
    qh->visit_id= 0;
    FORALLfacets
      facet->visitid= 0;
  }
  zmax_(Zvvisit2max, (int)qh->vertex_visit/2);
  if (qh->vertex_visit > (unsigned int) INT_MAX) { /* 31 bits */
    zinc_(Zvvisit);
    if (qh->visit_id && !qh_checklists(qh, qh->facet_list)) {
      qh_fprintf(qh, qh->ferr, 6371, "qhull internal error: qh_checklists failed on reset of qh.vertex_visit %u\n", qh->vertex_visit);
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }
    qh->vertex_visit= 0;
    FORALLvertices
      vertex->visitid= 0;
  }
  qh->furthest_id= furthestid;
  qh->RANDOMdist= qh->old_randomdist;
} /* buildtracing */

/*---------------------------------

  qh_errexit2(qh, exitcode, facet, otherfacet )
    return exitcode to system after an error
    report two facets

  returns:
    assumes exitcode non-zero

  see:
    normally use qh_errexit() in user_r.c(reports a facet and a ridge)
*/
void qh_errexit2(qhT *qh, int exitcode, facetT *facet, facetT *otherfacet) {
  qh->tracefacet= NULL;  /* avoid infinite recursion through qh_fprintf */
  qh->traceridge= NULL;
  qh->tracevertex= NULL;
  qh_errprint(qh, "ERRONEOUS", facet, otherfacet, NULL, NULL);
  qh_errexit(qh, exitcode, NULL, NULL);
} /* errexit2 */


/*---------------------------------

  qh_findhorizon(qh, point, facet, goodvisible, goodhorizon )
    given a visible facet, find the point's horizon and visible facets
    for all facets, !facet-visible

  returns:
    returns qh.visible_list/num_visible with all visible facets
      marks visible facets with ->visible
    updates count of good visible and good horizon facets
    updates qh.max_outside, qh.max_vertex, facet->maxoutside

  see:
    similar to qh_delpoint()

  design:
    move facet to qh.visible_list at end of qh.facet_list
    for all visible facets
     for each unvisited neighbor of a visible facet
       compute distance of point to neighbor
       if point above neighbor
         move neighbor to end of qh.visible_list
       else if point is coplanar with neighbor
         update qh.max_outside, qh.max_vertex, neighbor->maxoutside
         mark neighbor coplanar (will create a samecycle later)
         update horizon statistics
*/
void qh_findhorizon(qhT *qh, pointT *point, facetT *facet, int *goodvisible, int *goodhorizon) {
  facetT *neighbor, **neighborp, *visible;
  int numhorizon= 0, coplanar= 0;
  realT dist;

  trace1((qh, qh->ferr, 1040, "qh_findhorizon: find horizon for point p%d facet f%d\n",qh_pointid(qh, point),facet->id));
  *goodvisible= *goodhorizon= 0;
  zinc_(Ztotvisible);
  qh_removefacet(qh, facet);  /* visible_list at end of qh->facet_list */
  qh_appendfacet(qh, facet);
  qh->num_visible= 1;
  if (facet->good)
    (*goodvisible)++;
  qh->visible_list= facet;
  facet->visible= True;
  facet->f.replace= NULL;
  if (qh->IStracing >=4)
    qh_errprint(qh, "visible", facet, NULL, NULL, NULL);
  qh->visit_id++;
  FORALLvisible_facets {
    if (visible->tricoplanar && !qh->TRInormals) {
      qh_fprintf(qh, qh->ferr, 6230, "qhull internal error (qh_findhorizon): does not work for tricoplanar facets.  Use option 'Q11'\n");
      qh_errexit(qh, qh_ERRqhull, visible, NULL);
    }
    if (qh_setsize(qh, visible->neighbors) == 0) {
      qh_fprintf(qh, qh->ferr, 6295, "qhull internal error (qh_findhorizon): visible facet f%d does not have neighbors\n", visible->id);
      qh_errexit(qh, qh_ERRqhull, visible, NULL);
    }
    visible->visitid= qh->visit_id;
    FOREACHneighbor_(visible) {
      if (neighbor->visitid == qh->visit_id)
        continue;
      neighbor->visitid= qh->visit_id;
      zzinc_(Znumvisibility);
      qh_distplane(qh, point, neighbor, &dist);
      if (dist > qh->MINvisible) {
        zinc_(Ztotvisible);
        qh_removefacet(qh, neighbor);  /* append to end of qh->visible_list */
        qh_appendfacet(qh, neighbor);
        neighbor->visible= True;
        neighbor->f.replace= NULL;
        qh->num_visible++;
        if (neighbor->good)
          (*goodvisible)++;
        if (qh->IStracing >=4)
          qh_errprint(qh, "visible", neighbor, NULL, NULL, NULL);
      }else {
        if (dist >= -qh->MAXcoplanar) {
          neighbor->coplanarhorizon= True;
          zzinc_(Zcoplanarhorizon);
          qh_joggle_restart(qh, "coplanar horizon");
          coplanar++;
          if (qh->MERGING) {
            if (dist > 0) {
              maximize_(qh->max_outside, dist);
              maximize_(qh->max_vertex, dist);
#if qh_MAXoutside
              maximize_(neighbor->maxoutside, dist);
#endif
            }else
              minimize_(qh->min_vertex, dist);  /* due to merge later */
          }
          trace2((qh, qh->ferr, 2057, "qh_findhorizon: point p%d is coplanar to horizon f%d, dist=%2.7g < qh->MINvisible(%2.7g)\n",
              qh_pointid(qh, point), neighbor->id, dist, qh->MINvisible));
        }else
          neighbor->coplanarhorizon= False;
        zinc_(Ztothorizon);
        numhorizon++;
        if (neighbor->good)
          (*goodhorizon)++;
        if (qh->IStracing >=4)
          qh_errprint(qh, "horizon", neighbor, NULL, NULL, NULL);
      }
    }
  }
  if (!numhorizon) {
    qh_joggle_restart(qh, "empty horizon");
    qh_fprintf(qh, qh->ferr, 6168, "qhull topology error (qh_findhorizon): empty horizon for p%d.  It was above all facets.\n", qh_pointid(qh, point));
    if (qh->num_facets < 100) {
      qh_printfacetlist(qh, qh->facet_list, NULL, True);
    }
    qh_errexit(qh, qh_ERRtopology, NULL, NULL);
  }
  trace1((qh, qh->ferr, 1041, "qh_findhorizon: %d horizon facets(good %d), %d visible(good %d), %d coplanar\n",
       numhorizon, *goodhorizon, qh->num_visible, *goodvisible, coplanar));
  if (qh->IStracing >= 4 && qh->num_facets < 100)
    qh_printlists(qh);
} /* findhorizon */

/*---------------------------------

  qh_joggle_restart(qh, reason )
    if joggle ('QJn') and not merging, restart on precision and topology errors
*/
void qh_joggle_restart(qhT *qh, const char *reason) {

  if (qh->JOGGLEmax < REALmax/2) {
    if (qh->ALLOWrestart && !qh->PREmerge && !qh->MERGEexact) {
      trace0((qh, qh->ferr, 26, "qh_joggle_restart: qhull restart because of %s\n", reason));
      /* May be called repeatedly if qh->ALLOWrestart */
      longjmp(qh->restartexit, qh_ERRprec);
    }
  }
} /* qh_joggle_restart */

/*---------------------------------

  qh_nextfurthest(qh, visible )
    returns next furthest point and visible facet for qh_addpoint()
    starts search at qh.facet_next

  returns:
    removes furthest point from outside set
    NULL if none available
    advances qh.facet_next over facets with empty outside sets

  design:
    for each facet from qh.facet_next
      if empty outside set
        advance qh.facet_next
      else if qh.NARROWhull
        determine furthest outside point
        if furthest point is not outside
          advance qh.facet_next(point will be coplanar)
    remove furthest point from outside set
*/
pointT *qh_nextfurthest(qhT *qh, facetT **visible) {
  facetT *facet;
  int size, idx, loopcount= 0;
  realT randr, dist;
  pointT *furthest;

  while ((facet= qh->facet_next) != qh->facet_tail) {
    if (!facet || loopcount++ > qh->num_facets) {
      qh_fprintf(qh, qh->ferr, 6406, "qhull internal error (qh_nextfurthest): null facet or infinite loop detected for qh.facet_next f%d facet_tail f%d\n",
        getid_(facet), getid_(qh->facet_tail));
      qh_printlists(qh);
      qh_errexit2(qh, qh_ERRqhull, facet, qh->facet_tail);
    }
    if (!facet->outsideset) {
      qh->facet_next= facet->next;
      continue;
    }
    SETreturnsize_(facet->outsideset, size);
    if (!size) {
      qh_setfree(qh, &facet->outsideset);
      qh->facet_next= facet->next;
      continue;
    }
    if (qh->NARROWhull) {
      if (facet->notfurthest)
        qh_furthestout(qh, facet);
      furthest= (pointT *)qh_setlast(facet->outsideset);
#if qh_COMPUTEfurthest
      qh_distplane(qh, furthest, facet, &dist);
      zinc_(Zcomputefurthest);
#else
      dist= facet->furthestdist;
#endif
      if (dist < qh->MINoutside) { /* remainder of outside set is coplanar for qh_outcoplanar */
        qh->facet_next= facet->next;
        continue;
      }
    }
    if (!qh->RANDOMoutside && !qh->VIRTUALmemory) {
      if (qh->PICKfurthest) {
        qh_furthestnext(qh /* qh.facet_list */);
        facet= qh->facet_next;
      }
      *visible= facet;
      return ((pointT *)qh_setdellast(facet->outsideset));
    }
    if (qh->RANDOMoutside) {
      int outcoplanar= 0;
      if (qh->NARROWhull) {
        FORALLfacets {
          if (facet == qh->facet_next)
            break;
          if (facet->outsideset)
            outcoplanar += qh_setsize(qh, facet->outsideset);
        }
      }
      randr= qh_RANDOMint;
      randr= randr/(qh_RANDOMmax+1);
      randr= floor((qh->num_outside - outcoplanar) * randr);
      idx= (int)randr;
      FORALLfacet_(qh->facet_next) {
        if (facet->outsideset) {
          SETreturnsize_(facet->outsideset, size);
          if (!size)
            qh_setfree(qh, &facet->outsideset);
          else if (size > idx) {
            *visible= facet;
            return ((pointT *)qh_setdelnth(qh, facet->outsideset, idx));
          }else
            idx -= size;
        }
      }
      qh_fprintf(qh, qh->ferr, 6169, "qhull internal error (qh_nextfurthest): num_outside %d is too low\nby at least %d, or a random real %g >= 1.0\n",
              qh->num_outside, idx+1, randr);
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }else { /* VIRTUALmemory */
      facet= qh->facet_tail->previous;
      if (!(furthest= (pointT *)qh_setdellast(facet->outsideset))) {
        if (facet->outsideset)
          qh_setfree(qh, &facet->outsideset);
        qh_removefacet(qh, facet);
        qh_prependfacet(qh, facet, &qh->facet_list);
        continue;
      }
      *visible= facet;
      return furthest;
    }
  }
  return NULL;
} /* nextfurthest */

/*---------------------------------

  qh_partitionall(qh, vertices, points, numpoints )
    partitions all points in points/numpoints to the outsidesets of facets
    vertices= vertices in qh.facet_list(!partitioned)

  returns:
    builds facet->outsideset
    does not partition qh.GOODpoint
    if qh.ONLYgood && !qh.MERGING,
      does not partition qh.GOODvertex

  notes:
    faster if qh.facet_list sorted by anticipated size of outside set

  design:
    initialize pointset with all points
    remove vertices from pointset
    remove qh.GOODpointp from pointset (unless it's qh.STOPcone or qh.STOPpoint)
    for all facets
      for all remaining points in pointset
        compute distance from point to facet
        if point is outside facet
          remove point from pointset (by not reappending)
          update bestpoint
          append point or old bestpoint to facet's outside set
      append bestpoint to facet's outside set (furthest)
    for all points remaining in pointset
      partition point into facets' outside sets and coplanar sets
*/
void qh_partitionall(qhT *qh, setT *vertices, pointT *points, int numpoints){
  setT *pointset;
  vertexT *vertex, **vertexp;
  pointT *point, **pointp, *bestpoint;
  int size, point_i, point_n, point_end, remaining, i, id;
  facetT *facet;
  realT bestdist= -REALmax, dist, distoutside;

  trace1((qh, qh->ferr, 1042, "qh_partitionall: partition all points into outside sets\n"));
  pointset= qh_settemp(qh, numpoints);
  qh->num_outside= 0;
  pointp= SETaddr_(pointset, pointT);
  for (i=numpoints, point= points; i--; point += qh->hull_dim)
    *(pointp++)= point;
  qh_settruncate(qh, pointset, numpoints);
  FOREACHvertex_(vertices) {
    if ((id= qh_pointid(qh, vertex->point)) >= 0)
      SETelem_(pointset, id)= NULL;
  }
  id= qh_pointid(qh, qh->GOODpointp);
  if (id >=0 && qh->STOPcone-1 != id && -qh->STOPpoint-1 != id)
    SETelem_(pointset, id)= NULL;
  if (qh->GOODvertexp && qh->ONLYgood && !qh->MERGING) { /* matches qhull()*/
    if ((id= qh_pointid(qh, qh->GOODvertexp)) >= 0)
      SETelem_(pointset, id)= NULL;
  }
  if (!qh->BESToutside) {  /* matches conditional for qh_partitionpoint below */
    distoutside= qh_DISToutside; /* multiple of qh.MINoutside & qh.max_outside, see user_r.h */
    zval_(Ztotpartition)= qh->num_points - qh->hull_dim - 1; /*misses GOOD... */
    remaining= qh->num_facets;
    point_end= numpoints;
    FORALLfacets {
      size= point_end/(remaining--) + 100;
      facet->outsideset= qh_setnew(qh, size);
      bestpoint= NULL;
      point_end= 0;
      FOREACHpoint_i_(qh, pointset) {
        if (point) {
          zzinc_(Zpartitionall);
          qh_distplane(qh, point, facet, &dist);
          if (dist < distoutside)
            SETelem_(pointset, point_end++)= point;
          else {
            qh->num_outside++;
            if (!bestpoint) {
              bestpoint= point;
              bestdist= dist;
            }else if (dist > bestdist) {
              qh_setappend(qh, &facet->outsideset, bestpoint);
              bestpoint= point;
              bestdist= dist;
            }else
              qh_setappend(qh, &facet->outsideset, point);
          }
        }
      }
      if (bestpoint) {
        qh_setappend(qh, &facet->outsideset, bestpoint);
#if !qh_COMPUTEfurthest
        facet->furthestdist= bestdist;
#endif
      }else
        qh_setfree(qh, &facet->outsideset);
      qh_settruncate(qh, pointset, point_end);
    }
  }
  /* if !qh->BESToutside, pointset contains points not assigned to outsideset */
  if (qh->BESToutside || qh->MERGING || qh->KEEPcoplanar || qh->KEEPinside || qh->KEEPnearinside) {
    qh->findbestnew= True;
    FOREACHpoint_i_(qh, pointset) {
      if (point)
        qh_partitionpoint(qh, point, qh->facet_list);
    }
    qh->findbestnew= False;
  }
  zzadd_(Zpartitionall, zzval_(Zpartition));
  zzval_(Zpartition)= 0;
  qh_settempfree(qh, &pointset);
  if (qh->IStracing >= 4)
    qh_printfacetlist(qh, qh->facet_list, NULL, True);
} /* partitionall */


/*---------------------------------

  qh_partitioncoplanar(qh, point, facet, dist, allnew )
    partition coplanar point to a facet
    dist is distance from point to facet
    if dist NULL,
      searches for bestfacet and does nothing if inside
    if allnew (qh.findbestnew)
      searches new facets instead of using qh_findbest()

  returns:
    qh.max_ouside updated
    if qh.KEEPcoplanar or qh.KEEPinside
      point assigned to best coplanarset
    qh.repart_facetid==0 (for detecting infinite recursion via qh_partitionpoint)

  notes:
    facet->maxoutside is updated at end by qh_check_maxout

  design:
    if dist undefined
      find best facet for point
      if point sufficiently below facet (depends on qh.NEARinside and qh.KEEPinside)
        exit
    if keeping coplanar/nearinside/inside points
      if point is above furthest coplanar point
        append point to coplanar set (it is the new furthest)
        update qh.max_outside
      else
        append point one before end of coplanar set
    else if point is clearly outside of qh.max_outside and bestfacet->coplanarset
    and bestfacet is more than perpendicular to facet
      repartition the point using qh_findbest() -- it may be put on an outsideset
    else
      update qh.max_outside
*/
void qh_partitioncoplanar(qhT *qh, pointT *point, facetT *facet, realT *dist, boolT allnew) {
  facetT *bestfacet;
  pointT *oldfurthest;
  realT bestdist, angle, nearest, dist2= 0.0;
  int numpart= 0;
  boolT isoutside, oldfindbest, repartition= False;

  trace4((qh, qh->ferr, 4090, "qh_partitioncoplanar: partition coplanar point p%d starting with f%d dist? %2.2g, allnew? %d, gh.repart_facetid f%d\n",
    qh_pointid(qh, point), facet->id, (dist ? *dist : 0.0), allnew, qh->repart_facetid));
  qh->WAScoplanar= True;
  if (!dist) {
    if (allnew)
      bestfacet= qh_findbestnew(qh, point, facet, &bestdist, qh_ALL, &isoutside, &numpart);
    else
      bestfacet= qh_findbest(qh, point, facet, qh_ALL, !qh_ISnewfacets, qh->DELAUNAY,
                          &bestdist, &isoutside, &numpart);
    zinc_(Ztotpartcoplanar);
    zzadd_(Zpartcoplanar, numpart);
    if (!qh->DELAUNAY && !qh->KEEPinside) { /*  for 'd', bestdist skips upperDelaunay facets */
      if (qh->KEEPnearinside) {
        if (bestdist < -qh->NEARinside) {
          zinc_(Zcoplanarinside);
          trace4((qh, qh->ferr, 4062, "qh_partitioncoplanar: point p%d is more than near-inside facet f%d dist %2.2g allnew? %d\n",
                  qh_pointid(qh, point), bestfacet->id, bestdist, allnew));
          qh->repart_facetid= 0;
          return;
        }
      }else if (bestdist < -qh->MAXcoplanar) {
          trace4((qh, qh->ferr, 4063, "qh_partitioncoplanar: point p%d is inside facet f%d dist %2.2g allnew? %d\n",
                  qh_pointid(qh, point), bestfacet->id, bestdist, allnew));
        zinc_(Zcoplanarinside);
        qh->repart_facetid= 0;
        return;
      }
    }
  }else {
    bestfacet= facet;
    bestdist= *dist;
  }
  if(bestfacet->visible){
    qh_fprintf(qh, qh->ferr, 6405, "qhull internal error (qh_partitioncoplanar): cannot partition coplanar p%d of f%d into visible facet f%d\n",
        qh_pointid(qh, point), facet->id, bestfacet->id);
    qh_errexit2(qh, qh_ERRqhull, facet, bestfacet);
  }
  if (bestdist > qh->max_outside) {
    if (!dist && facet != bestfacet) { /* can't be recursive from qh_partitionpoint since facet != bestfacet */
      zinc_(Zpartangle);
      angle= qh_getangle(qh, facet->normal, bestfacet->normal);
      if (angle < 0) {
        nearest= qh_vertex_bestdist(qh, bestfacet->vertices);
        /* typically due to deleted vertex and coplanar facets, e.g.,
        RBOX 1000 s Z1 G1e-13 t1001185205 | QHULL Tv */
        zinc_(Zpartcorner);
        trace2((qh, qh->ferr, 2058, "qh_partitioncoplanar: repartition coplanar point p%d from f%d as an outside point above corner facet f%d dist %2.2g with angle %2.2g\n",
          qh_pointid(qh, point), facet->id, bestfacet->id, bestdist, angle));
        repartition= True;
      }
    }
    if (!repartition) {
      if (bestdist > qh->MAXoutside * qh_RATIOcoplanaroutside) {
        nearest= qh_vertex_bestdist(qh, bestfacet->vertices);
        if (facet->id == bestfacet->id) {
          if (facet->id == qh->repart_facetid) {
            qh_fprintf(qh, qh->ferr, 6404, "Qhull internal error (qh_partitioncoplanar): infinite loop due to recursive call to qh_partitionpoint.  Repartition point p%d from f%d as a outside point dist %2.2g nearest vertices %2.2g\n",
              qh_pointid(qh, point), facet->id, bestdist, nearest);
            qh_errexit(qh, qh_ERRqhull, facet, NULL);
          }
          qh->repart_facetid= facet->id; /* reset after call to qh_partitionpoint */
        }
        if (point == qh->coplanar_apex) {
          /* otherwise may loop indefinitely, the point is well above a facet, yet near a vertex */
          qh_fprintf(qh, qh->ferr, 6425, "Qhull topology error (qh_partitioncoplanar): can not repartition coplanar point p%d from f%d as outside point above f%d.  It previously failed to form a cone of facets, dist %2.2g, nearest vertices %2.2g\n",
            qh_pointid(qh, point), facet->id, bestfacet->id, bestdist, nearest);
          qh_errexit(qh, qh_ERRtopology, facet, NULL);
        }
        if (nearest < 2 * qh->MAXoutside * qh_RATIOcoplanaroutside) {
          zinc_(Zparttwisted);
          qh_fprintf(qh, qh->ferr, 7085, "Qhull precision warning: repartition coplanar point p%d from f%d as an outside point above twisted facet f%d dist %2.2g nearest vertices %2.2g\n",
            qh_pointid(qh, point), facet->id, bestfacet->id, bestdist, nearest);
        }else {
          zinc_(Zparthidden);
          qh_fprintf(qh, qh->ferr, 7086, "Qhull precision warning: repartition coplanar point p%d from f%d as an outside point above hidden facet f%d dist %2.2g nearest vertices %2.2g\n",
            qh_pointid(qh, point), facet->id, bestfacet->id, bestdist, nearest);
        }
        repartition= True;
      }
    }
    if (repartition) {
      oldfindbest= qh->findbestnew;
      qh->findbestnew= False;
      qh_partitionpoint(qh, point, bestfacet);
      qh->findbestnew= oldfindbest;
      qh->repart_facetid= 0;
      return;
    }
    qh->repart_facetid= 0;
    qh->max_outside= bestdist;
    if (bestdist > qh->TRACEdist || qh->IStracing >= 3) {
      qh_fprintf(qh, qh->ferr, 3041, "qh_partitioncoplanar: == p%d from f%d increases qh.max_outside to %2.2g of f%d last p%d\n",
                     qh_pointid(qh, point), facet->id, bestdist, bestfacet->id, qh->furthest_id);
      qh_errprint(qh, "DISTANT", facet, bestfacet, NULL, NULL);
    }
  }
  if (qh->KEEPcoplanar + qh->KEEPinside + qh->KEEPnearinside) {
    oldfurthest= (pointT *)qh_setlast(bestfacet->coplanarset);
    if (oldfurthest) {
      zinc_(Zcomputefurthest);
      qh_distplane(qh, oldfurthest, bestfacet, &dist2);
    }
    if (!oldfurthest || dist2 < bestdist)
      qh_setappend(qh, &bestfacet->coplanarset, point);
    else
      qh_setappend2ndlast(qh, &bestfacet->coplanarset, point);
  }
  trace4((qh, qh->ferr, 4064, "qh_partitioncoplanar: point p%d is coplanar with facet f%d (or inside) dist %2.2g\n",
          qh_pointid(qh, point), bestfacet->id, bestdist));
} /* partitioncoplanar */

/*---------------------------------

  qh_partitionpoint(qh, point, facet )
    assigns point to an outside set, coplanar set, or inside set (i.e., dropt)
    if qh.findbestnew
      uses qh_findbestnew() to search all new facets
    else
      uses qh_findbest()

  notes:
    after qh_distplane(), this and qh_findbest() are most expensive in 3-d

  design:
    find best facet for point
      (either exhaustive search of new facets or directed search from facet)
    if qh.NARROWhull
      retain coplanar and nearinside points as outside points
    if point is outside bestfacet
      if point above furthest point for bestfacet
        append point to outside set (it becomes the new furthest)
        if outside set was empty
          move bestfacet to end of qh.facet_list (i.e., after qh.facet_next)
        update bestfacet->furthestdist
      else
        append point one before end of outside set
    else if point is coplanar to bestfacet
      if keeping coplanar points or need to update qh.max_outside
        partition coplanar point into bestfacet
    else if near-inside point
      partition as coplanar point into bestfacet
    else is an inside point
      if keeping inside points
        partition as coplanar point into bestfacet
*/
void qh_partitionpoint(qhT *qh, pointT *point, facetT *facet) {
  realT bestdist, previousdist;
  boolT isoutside, isnewoutside= False;
  facetT *bestfacet;
  int numpart;

  if (qh->findbestnew)
    bestfacet= qh_findbestnew(qh, point, facet, &bestdist, qh->BESToutside, &isoutside, &numpart);
  else
    bestfacet= qh_findbest(qh, point, facet, qh->BESToutside, qh_ISnewfacets, !qh_NOupper,
                          &bestdist, &isoutside, &numpart);
  zinc_(Ztotpartition);
  zzadd_(Zpartition, numpart);
  if(bestfacet->visible){
    qh_fprintf(qh, qh->ferr, 6293, "qhull internal error (qh_partitionpoint): cannot partition p%d of f%d into visible facet f%d\n",
      qh_pointid(qh, point), facet->id, bestfacet->id);
    qh_errexit2(qh, qh_ERRqhull, facet, bestfacet);
  }
  if (qh->NARROWhull) {
    if (qh->DELAUNAY && !isoutside && bestdist >= -qh->MAXcoplanar)
      qh_joggle_restart(qh, "nearly incident point (narrow hull)");
    if (qh->KEEPnearinside) {
      if (bestdist >= -qh->NEARinside)
        isoutside= True;
    }else if (bestdist >= -qh->MAXcoplanar)
      isoutside= True;
  }

  if (isoutside) {
    if (!bestfacet->outsideset
    || !qh_setlast(bestfacet->outsideset)) { /* empty outside set */
      qh_setappend(qh, &(bestfacet->outsideset), point);
      if (!qh->NARROWhull || bestdist > qh->MINoutside)
        isnewoutside= True;
#if !qh_COMPUTEfurthest
      bestfacet->furthestdist= bestdist;
#endif
    }else {
#if qh_COMPUTEfurthest
      zinc_(Zcomputefurthest);
      qh_distplane(qh, oldfurthest, bestfacet, &previousdist);
      if (previousdist < bestdist)
        qh_setappend(qh, &(bestfacet->outsideset), point);
      else
        qh_setappend2ndlast(qh, &(bestfacet->outsideset), point);
#else
      previousdist= bestfacet->furthestdist;
      if (previousdist < bestdist) {
        qh_setappend(qh, &(bestfacet->outsideset), point);
        bestfacet->furthestdist= bestdist;
        if (qh->NARROWhull && previousdist < qh->MINoutside && bestdist >= qh->MINoutside)
          isnewoutside= True;
      }else
        qh_setappend2ndlast(qh, &(bestfacet->outsideset), point);
#endif
    }
    if (isnewoutside && qh->facet_next != bestfacet) {
      if (bestfacet->newfacet) {
        if (qh->facet_next->newfacet)
          qh->facet_next= qh->newfacet_list; /* make sure it's after qh.facet_next */
      }else {
        qh_removefacet(qh, bestfacet);  /* make sure it's after qh.facet_next */
        qh_appendfacet(qh, bestfacet);
        if(qh->newfacet_list){
          bestfacet->newfacet= True;
        }
      }
    }
    qh->num_outside++;
    trace4((qh, qh->ferr, 4065, "qh_partitionpoint: point p%d is outside facet f%d newfacet? %d, newoutside? %d (or narrowhull)\n",
          qh_pointid(qh, point), bestfacet->id, bestfacet->newfacet, isnewoutside));
  }else if (qh->DELAUNAY || bestdist >= -qh->MAXcoplanar) { /* for 'd', bestdist skips upperDelaunay facets */
    if (qh->DELAUNAY)
      qh_joggle_restart(qh, "nearly incident point");
    /* allow coplanar points with joggle, may be interior */
    zzinc_(Zcoplanarpart);
    if ((qh->KEEPcoplanar + qh->KEEPnearinside) || bestdist > qh->max_outside)
      qh_partitioncoplanar(qh, point, bestfacet, &bestdist, qh->findbestnew);
    else {
      trace4((qh, qh->ferr, 4066, "qh_partitionpoint: point p%d is coplanar to facet f%d (dropped)\n",
          qh_pointid(qh, point), bestfacet->id));
    }
  }else if (qh->KEEPnearinside && bestdist >= -qh->NEARinside) {
    zinc_(Zpartnear);
    qh_partitioncoplanar(qh, point, bestfacet, &bestdist, qh->findbestnew);
  }else {
    zinc_(Zpartinside);
    trace4((qh, qh->ferr, 4067, "qh_partitionpoint: point p%d is inside all facets, closest to f%d dist %2.2g\n",
          qh_pointid(qh, point), bestfacet->id, bestdist));
    if (qh->KEEPinside)
      qh_partitioncoplanar(qh, point, bestfacet, &bestdist, qh->findbestnew);
  }
} /* partitionpoint */

/*---------------------------------

  qh_partitionvisible(qh, allpoints, numoutside )
    partitions outside points in visible facets (qh.visible_list) to qh.newfacet_list
    if keeping coplanar/near-inside/inside points
      partitions coplanar points; repartitions if 'allpoints' (not used)
    1st neighbor (if any) of visible facets points to a horizon facet or a new facet

  returns:
    updates outside sets and coplanar sets of qh.newfacet_list
    updates qh.num_outside (count of outside points)
    does not truncate f.outsideset, f.coplanarset, or qh.del_vertices (see qh_deletevisible)

  notes:
    called by qh_qhull, qh_addpoint, and qh_all_vertexmerges
    qh.findbest_notsharp should be clear (extra work if set)

  design:
    for all visible facets with outside set or coplanar set
      select a newfacet for visible facet
      if outside set
        partition outside set into new facets
      if coplanar set and keeping coplanar/near-inside/inside points
        if allpoints
          partition coplanar set into new facets, may be assigned outside
        else
          partition coplanar set into coplanar sets of new facets
    for each deleted vertex
      if allpoints
        partition vertex into new facets, may be assigned outside
      else
        partition vertex into coplanar sets of new facets
*/
void qh_partitionvisible(qhT *qh, boolT allpoints, int *numoutside /* qh.visible_list */) {
  facetT *visible, *newfacet;
  pointT *point, **pointp;
  int delsize, coplanar=0, size;
  vertexT *vertex, **vertexp;

  trace3((qh, qh->ferr, 3042, "qh_partitionvisible: partition outside and coplanar points of visible and merged facets f%d into new facets f%d\n",
    qh->visible_list->id, qh->newfacet_list->id));
  if (qh->ONLYmax)
    maximize_(qh->MINoutside, qh->max_vertex);
  *numoutside= 0;
  FORALLvisible_facets {
    if (!visible->outsideset && !visible->coplanarset)
      continue;
    newfacet= qh_getreplacement(qh, visible);
    if (!newfacet)
      newfacet= qh->newfacet_list;
    if (!newfacet->next) {
      qh_fprintf(qh, qh->ferr, 6170, "qhull topology error (qh_partitionvisible): all new facets deleted as\n       degenerate facets. Can not continue.\n");
      qh_errexit(qh, qh_ERRtopology, NULL, NULL);
    }
    if (visible->outsideset) {
      size= qh_setsize(qh, visible->outsideset);
      *numoutside += size;
      qh->num_outside -= size;
      FOREACHpoint_(visible->outsideset)
        qh_partitionpoint(qh, point, newfacet);
    }
    if (visible->coplanarset && (qh->KEEPcoplanar + qh->KEEPinside + qh->KEEPnearinside)) {
      size= qh_setsize(qh, visible->coplanarset);
      coplanar += size;
      FOREACHpoint_(visible->coplanarset) {
        if (allpoints) /* not used */
          qh_partitionpoint(qh, point, newfacet);
        else
          qh_partitioncoplanar(qh, point, newfacet, NULL, qh->findbestnew);
      }
    }
  }
  delsize= qh_setsize(qh, qh->del_vertices);
  if (delsize > 0) {
    trace3((qh, qh->ferr, 3049, "qh_partitionvisible: partition %d deleted vertices as coplanar? %d points into new facets f%d\n",
      delsize, !allpoints, qh->newfacet_list->id));
    FOREACHvertex_(qh->del_vertices) {
      if (vertex->point && !vertex->partitioned) {
        if (!qh->newfacet_list || qh->newfacet_list == qh->facet_tail) {
          qh_fprintf(qh, qh->ferr, 6284, "qhull internal error (qh_partitionvisible): all new facets deleted or none defined.  Can not partition deleted v%d.\n", vertex->id);
          qh_errexit(qh, qh_ERRqhull, NULL, NULL);
        }
        if (allpoints) /* not used */
          /* [apr'2019] infinite loop if vertex recreates the same facets from the same horizon
             e.g., qh_partitionpoint if qh.DELAUNAY with qh.MERGEindependent for all mergetype, ../eg/qtest.sh t427764 '1000 s W1e-13 D3' 'd' */
          qh_partitionpoint(qh, vertex->point, qh->newfacet_list);
        else
          qh_partitioncoplanar(qh, vertex->point, qh->newfacet_list, NULL, qh_ALL); /* search all new facets */
        vertex->partitioned= True;
      }
    }
  }
  trace1((qh, qh->ferr, 1043,"qh_partitionvisible: partitioned %d points from outsidesets, %d points from coplanarsets, and %d deleted vertices\n", *numoutside, coplanar, delsize));
} /* partitionvisible */

/*---------------------------------

  qh_printsummary(qh, fp )
    prints summary to fp

  notes:
    not in io_r.c so that user_eg.c can prevent io_r.c from loading
    qh_printsummary and qh_countfacets must match counts
    updates qh.facet_visit to detect infinite loop

  design:
    determine number of points, vertices, and coplanar points
    print summary
*/
void qh_printsummary(qhT *qh, FILE *fp) {
  realT ratio, outerplane, innerplane;
  double cpu;
  int size, id, nummerged, numpinched, numvertices, numcoplanars= 0, nonsimplicial=0, numdelaunay= 0;
  facetT *facet;
  const char *s;
  int numdel= zzval_(Zdelvertextot);
  int numtricoplanars= 0;
  boolT goodused;

  size= qh->num_points + qh_setsize(qh, qh->other_points);
  numvertices= qh->num_vertices - qh_setsize(qh, qh->del_vertices);
  id= qh_pointid(qh, qh->GOODpointp);
  if (!qh_checklists(qh, qh->facet_list) && !qh->ERREXITcalled) {
    qh_fprintf(qh, fp, 6372, "qhull internal error: qh_checklists failed at qh_printsummary\n");
    if (qh->num_facets < 4000)
      qh_printlists(qh);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  if (qh->DELAUNAY && qh->ERREXITcalled) {
    /* update f.good and determine qh.num_good as in qh_findgood_all */
    FORALLfacets {
      if (facet->visible)
        facet->good= False; /* will be deleted */
      else if (facet->good) {
        if (facet->normal && !qh_inthresholds(qh, facet->normal, NULL))
          facet->good= False;
        else
          numdelaunay++;
      }
    }
    qh->num_good= numdelaunay;
  }
  FORALLfacets {
    if (facet->coplanarset)
      numcoplanars += qh_setsize(qh, facet->coplanarset);
    if (facet->good) {
      if (facet->simplicial) {
        if (facet->keepcentrum && facet->tricoplanar)
          numtricoplanars++;
      }else if (qh_setsize(qh, facet->vertices) != qh->hull_dim)
        nonsimplicial++;
    }
  }
  if (id >=0 && qh->STOPcone-1 != id && -qh->STOPpoint-1 != id)
    size--;
  if (qh->STOPadd || qh->STOPcone || qh->STOPpoint)
    qh_fprintf(qh, fp, 9288, "\nEarly exit due to 'TAn', 'TVn', 'TCn', 'TRn', or precision error with 'QJn'.");
  goodused= False;
  if (qh->ERREXITcalled)
    ; /* qh_findgood_all not called */
  else if (qh->UPPERdelaunay) {
    if (qh->GOODvertex || qh->GOODpoint || qh->SPLITthresholds)
      goodused= True;
  }else if (qh->DELAUNAY) {
    if (qh->GOODvertex || qh->GOODpoint || qh->GOODthreshold)
      goodused= True;
  }else if (qh->num_good > 0 || qh->GOODthreshold)
    goodused= True;
  nummerged= zzval_(Ztotmerge) - zzval_(Zcyclehorizon) + zzval_(Zcyclefacettot);
  if (qh->VORONOI) {
    if (qh->UPPERdelaunay)
      qh_fprintf(qh, fp, 9289, "\n\
Furthest-site Voronoi vertices by the convex hull of %d points in %d-d:\n\n", size, qh->hull_dim);
    else
      qh_fprintf(qh, fp, 9290, "\n\
Voronoi diagram by the convex hull of %d points in %d-d:\n\n", size, qh->hull_dim);
    qh_fprintf(qh, fp, 9291, "  Number of Voronoi regions%s: %d\n",
              qh->ATinfinity ? " and at-infinity" : "", numvertices);
    if (numdel)
      qh_fprintf(qh, fp, 9292, "  Total number of deleted points due to merging: %d\n", numdel);
    if (numcoplanars - numdel > 0)
      qh_fprintf(qh, fp, 9293, "  Number of nearly incident points: %d\n", numcoplanars - numdel);
    else if (size - numvertices - numdel > 0)
      qh_fprintf(qh, fp, 9294, "  Total number of nearly incident points: %d\n", size - numvertices - numdel);
    qh_fprintf(qh, fp, 9295, "  Number of%s Voronoi vertices: %d\n",
              goodused ? " 'good'" : "", qh->num_good);
    if (nonsimplicial)
      qh_fprintf(qh, fp, 9296, "  Number of%s non-simplicial Voronoi vertices: %d\n",
              goodused ? " 'good'" : "", nonsimplicial);
  }else if (qh->DELAUNAY) {
    if (qh->UPPERdelaunay)
      qh_fprintf(qh, fp, 9297, "\n\
Furthest-site Delaunay triangulation by the convex hull of %d points in %d-d:\n\n", size, qh->hull_dim);
    else
      qh_fprintf(qh, fp, 9298, "\n\
Delaunay triangulation by the convex hull of %d points in %d-d:\n\n", size, qh->hull_dim);
    qh_fprintf(qh, fp, 9299, "  Number of input sites%s: %d\n",
              qh->ATinfinity ? " and at-infinity" : "", numvertices);
    if (numdel)
      qh_fprintf(qh, fp, 9300, "  Total number of deleted points due to merging: %d\n", numdel);
    if (numcoplanars - numdel > 0)
      qh_fprintf(qh, fp, 9301, "  Number of nearly incident points: %d\n", numcoplanars - numdel);
    else if (size - numvertices - numdel > 0)
      qh_fprintf(qh, fp, 9302, "  Total number of nearly incident points: %d\n", size - numvertices - numdel);
    qh_fprintf(qh, fp, 9303, "  Number of%s Delaunay regions: %d\n",
              goodused ? " 'good'" : "", qh->num_good);
    if (nonsimplicial)
      qh_fprintf(qh, fp, 9304, "  Number of%s non-simplicial Delaunay regions: %d\n",
              goodused ? " 'good'" : "", nonsimplicial);
  }else if (qh->HALFspace) {
    qh_fprintf(qh, fp, 9305, "\n\
Halfspace intersection by the convex hull of %d points in %d-d:\n\n", size, qh->hull_dim);
    qh_fprintf(qh, fp, 9306, "  Number of halfspaces: %d\n", size);
    qh_fprintf(qh, fp, 9307, "  Number of non-redundant halfspaces: %d\n", numvertices);
    if (numcoplanars) {
      if (qh->KEEPinside && qh->KEEPcoplanar)
        s= "similar and redundant";
      else if (qh->KEEPinside)
        s= "redundant";
      else
        s= "similar";
      qh_fprintf(qh, fp, 9308, "  Number of %s halfspaces: %d\n", s, numcoplanars);
    }
    qh_fprintf(qh, fp, 9309, "  Number of intersection points: %d\n", qh->num_facets - qh->num_visible);
    if (goodused)
      qh_fprintf(qh, fp, 9310, "  Number of 'good' intersection points: %d\n", qh->num_good);
    if (nonsimplicial)
      qh_fprintf(qh, fp, 9311, "  Number of%s non-simplicial intersection points: %d\n",
              goodused ? " 'good'" : "", nonsimplicial);
  }else {
    qh_fprintf(qh, fp, 9312, "\n\
Convex hull of %d points in %d-d:\n\n", size, qh->hull_dim);
    qh_fprintf(qh, fp, 9313, "  Number of vertices: %d\n", numvertices);
    if (numcoplanars) {
      if (qh->KEEPinside && qh->KEEPcoplanar)
        s= "coplanar and interior";
      else if (qh->KEEPinside)
        s= "interior";
      else
        s= "coplanar";
      qh_fprintf(qh, fp, 9314, "  Number of %s points: %d\n", s, numcoplanars);
    }
    qh_fprintf(qh, fp, 9315, "  Number of facets: %d\n", qh->num_facets - qh->num_visible);
    if (goodused)
      qh_fprintf(qh, fp, 9316, "  Number of 'good' facets: %d\n", qh->num_good);
    if (nonsimplicial)
      qh_fprintf(qh, fp, 9317, "  Number of%s non-simplicial facets: %d\n",
              goodused ? " 'good'" : "", nonsimplicial);
  }
  if (numtricoplanars)
      qh_fprintf(qh, fp, 9318, "  Number of triangulated facets: %d\n", numtricoplanars);
  qh_fprintf(qh, fp, 9319, "\nStatistics for: %s | %s",
                      qh->rbox_command, qh->qhull_command);
  if (qh->ROTATErandom != INT_MIN)
    qh_fprintf(qh, fp, 9320, " QR%d\n\n", qh->ROTATErandom);
  else
    qh_fprintf(qh, fp, 9321, "\n\n");
  qh_fprintf(qh, fp, 9322, "  Number of points processed: %d\n", zzval_(Zprocessed));
  qh_fprintf(qh, fp, 9323, "  Number of hyperplanes created: %d\n", zzval_(Zsetplane));
  if (qh->DELAUNAY)
    qh_fprintf(qh, fp, 9324, "  Number of facets in hull: %d\n", qh->num_facets - qh->num_visible);
  qh_fprintf(qh, fp, 9325, "  Number of distance tests for qhull: %d\n", zzval_(Zpartition)+
      zzval_(Zpartitionall)+zzval_(Znumvisibility)+zzval_(Zpartcoplanar));
#if 0  /* NOTE: must print before printstatistics() */
  {realT stddev, ave;
  qh_fprintf(qh, fp, 9326, "  average new facet balance: %2.2g\n",
          wval_(Wnewbalance)/zval_(Zprocessed));
  stddev= qh_stddev(zval_(Zprocessed), wval_(Wnewbalance),
                                 wval_(Wnewbalance2), &ave);
  qh_fprintf(qh, fp, 9327, "  new facet standard deviation: %2.2g\n", stddev);
  qh_fprintf(qh, fp, 9328, "  average partition balance: %2.2g\n",
          wval_(Wpbalance)/zval_(Zpbalance));
  stddev= qh_stddev(zval_(Zpbalance), wval_(Wpbalance),
                                 wval_(Wpbalance2), &ave);
  qh_fprintf(qh, fp, 9329, "  partition standard deviation: %2.2g\n", stddev);
  }
#endif
  if (nummerged) {
    qh_fprintf(qh, fp, 9330,"  Number of distance tests for merging: %d\n",zzval_(Zbestdist)+
          zzval_(Zcentrumtests)+zzval_(Zvertextests)+zzval_(Zdistcheck)+zzval_(Zdistzero));
    qh_fprintf(qh, fp, 9331,"  Number of distance tests for checking: %d\n",zzval_(Zcheckpart)+zzval_(Zdistconvex));
    qh_fprintf(qh, fp, 9332,"  Number of merged facets: %d\n", nummerged);
  }
  numpinched= zzval_(Zpinchduplicate) + zzval_(Zpinchedvertex);
  if (numpinched)
    qh_fprintf(qh, fp, 9375,"  Number of merged pinched vertices: %d\n", numpinched);
  if (!qh->RANDOMoutside && qh->QHULLfinished) {
    cpu= (double)qh->hulltime;
    cpu /= (double)qh_SECticks;
    wval_(Wcpu)= cpu;
    qh_fprintf(qh, fp, 9333, "  CPU seconds to compute hull (after input): %2.4g\n", cpu);
  }
  if (qh->RERUN) {
    if (!qh->PREmerge && !qh->MERGEexact)
      qh_fprintf(qh, fp, 9334, "  Percentage of runs with precision errors: %4.1f\n",
           zzval_(Zretry)*100.0/qh->build_cnt);  /* careful of order */
  }else if (qh->JOGGLEmax < REALmax/2) {
    if (zzval_(Zretry))
      qh_fprintf(qh, fp, 9335, "  After %d retries, input joggled by: %2.2g\n",
         zzval_(Zretry), qh->JOGGLEmax);
    else
      qh_fprintf(qh, fp, 9336, "  Input joggled by: %2.2g\n", qh->JOGGLEmax);
  }
  if (qh->totarea != 0.0)
    qh_fprintf(qh, fp, 9337, "  %s facet area:   %2.8g\n",
            zzval_(Ztotmerge) ? "Approximate" : "Total", qh->totarea);
  if (qh->totvol != 0.0)
    qh_fprintf(qh, fp, 9338, "  %s volume:       %2.8g\n",
            zzval_(Ztotmerge) ? "Approximate" : "Total", qh->totvol);
  if (qh->MERGING) {
    qh_outerinner(qh, NULL, &outerplane, &innerplane);
    if (outerplane > 2 * qh->DISTround) {
      qh_fprintf(qh, fp, 9339, "  Maximum distance of point above facet: %2.2g", outerplane);
      ratio= outerplane/(qh->ONEmerge + qh->DISTround);
      /* don't report ratio if MINoutside is large */
      if (ratio > 0.05 && 2* qh->ONEmerge > qh->MINoutside && qh->JOGGLEmax > REALmax/2)
        qh_fprintf(qh, fp, 9340, " (%.1fx)\n", ratio);
      else
        qh_fprintf(qh, fp, 9341, "\n");
    }
    if (innerplane < -2 * qh->DISTround) {
      qh_fprintf(qh, fp, 9342, "  Maximum distance of vertex below facet: %2.2g", innerplane);
      ratio= -innerplane/(qh->ONEmerge+qh->DISTround);
      if (ratio > 0.05 && qh->JOGGLEmax > REALmax/2)
        qh_fprintf(qh, fp, 9343, " (%.1fx)\n", ratio);
      else
        qh_fprintf(qh, fp, 9344, "\n");
    }
  }
  qh_fprintf(qh, fp, 9345, "\n");
} /* printsummary */


geometry/src/random_r.h0000644000176200001440000000206214664417655014670 0ustar  liggesusers/*
  ---------------------------------

  random_r.h
    header file for random and utility routines

   see qh-geom_r.htm and random_r.c

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/random_r.h#3 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#ifndef qhDEFrandom
#define qhDEFrandom 1

#include "libqhull_r.h"

/*============= prototypes in alphabetical order ======= */

#ifdef __cplusplus
extern "C" {
#endif

int     qh_argv_to_command(int argc, char *argv[], char* command, int max_size);
int     qh_argv_to_command_size(int argc, char *argv[]);
int     qh_rand(qhT *qh);
void    qh_srand(qhT *qh, int seed);
realT   qh_randomfactor(qhT *qh, realT scale, realT offset);
void    qh_randommatrix(qhT *qh, realT *buffer, int dim, realT **row);
int     qh_strtol(const char *s, char **endp);
double  qh_strtod(const char *s, char **endp);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* qhDEFrandom */



geometry/src/geom_r.c0000644000176200001440000013251114664417655014335 0ustar  liggesusers/*
  ---------------------------------

   geom_r.c
   geometric routines of qhull

   see qh-geom_r.htm and geom_r.h

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/geom_r.c#5 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $

   infrequent code goes into geom2_r.c
*/

#include "qhull_ra.h"

/*---------------------------------

  qh_distplane(qh, point, facet, dist )
    return distance from point to facet

  returns:
    dist
    if qh.RANDOMdist, joggles result

  notes:
    dist > 0 if point is above facet (i.e., outside)
    does not error (for qh_sortfacets, qh_outerinner)
    for nearly coplanar points, the returned values may be duplicates
      for example pairs of nearly incident points, rbox 175 C1,2e-13 t1538759579 | qhull d T4
      622 qh_distplane: e-014  # count of two or more duplicate values for unique calls
      258 qh_distplane: e-015
      38 qh_distplane: e-016
      40 qh_distplane: e-017
      6 qh_distplane: e-018
      5 qh_distplane: -e-018
      33 qh_distplane: -e-017
         3153 qh_distplane: -2.775557561562891e-017  # duplicated value for 3153 unique calls
      42 qh_distplane: -e-016
      307 qh_distplane: -e-015
      1271 qh_distplane: -e-014
      13 qh_distplane: -e-013

  see:
    qh_distnorm in geom2_r.c
    qh_distplane [geom_r.c], QhullFacet::distance, and QhullHyperplane::distance are copies
*/
void qh_distplane(qhT *qh, pointT *point, facetT *facet, realT *dist) {
  coordT *normal= facet->normal, *coordp, randr;
  int k;

  switch (qh->hull_dim){
  case 2:
    *dist= facet->offset + point[0] * normal[0] + point[1] * normal[1];
    break;
  case 3:
    *dist= facet->offset + point[0] * normal[0] + point[1] * normal[1] + point[2] * normal[2];
    break;
  case 4:
    *dist= facet->offset+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3];
    break;
  case 5:
    *dist= facet->offset+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3]+point[4]*normal[4];
    break;
  case 6:
    *dist= facet->offset+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3]+point[4]*normal[4]+point[5]*normal[5];
    break;
  case 7:
    *dist= facet->offset+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3]+point[4]*normal[4]+point[5]*normal[5]+point[6]*normal[6];
    break;
  case 8:
    *dist= facet->offset+point[0]*normal[0]+point[1]*normal[1]+point[2]*normal[2]+point[3]*normal[3]+point[4]*normal[4]+point[5]*normal[5]+point[6]*normal[6]+point[7]*normal[7];
    break;
  default:
    *dist= facet->offset;
    coordp= point;
    for (k=qh->hull_dim; k--; )
      *dist += *coordp++ * *normal++;
    break;
  }
  zzinc_(Zdistplane);
  if (!qh->RANDOMdist && qh->IStracing < 4)
    return;
  if (qh->RANDOMdist) {
    randr= qh_RANDOMint;
    *dist += (2.0 * randr / qh_RANDOMmax - 1.0) *
      qh->RANDOMfactor * qh->MAXabs_coord;
  }
#ifndef qh_NOtrace
  if (qh->IStracing >= 4) {
    qh_fprintf(qh, qh->ferr, 8001, "qh_distplane: ");
    qh_fprintf(qh, qh->ferr, 8002, qh_REAL_1, *dist);
    qh_fprintf(qh, qh->ferr, 8003, "from p%d to f%d\n", qh_pointid(qh, point), facet->id);
  }
#endif
  return;
} /* distplane */


/*---------------------------------

  qh_findbest(qh, point, startfacet, bestoutside, qh_ISnewfacets, qh_NOupper, dist, isoutside, numpart )
    find facet that is furthest below a point
    for upperDelaunay facets
      returns facet only if !qh_NOupper and clearly above

  input:
    starts search at 'startfacet' (can not be flipped)
    if !bestoutside(qh_ALL), stops at qh.MINoutside

  returns:
    best facet (reports error if NULL)
    early out if isoutside defined and bestdist > qh.MINoutside
    dist is distance to facet
    isoutside is true if point is outside of facet
    numpart counts the number of distance tests

  see also:
    qh_findbestnew()

  notes:
    If merging (testhorizon), searches horizon facets of coplanar best facets because
    after qh_distplane, this and qh_partitionpoint are the most expensive in 3-d
      avoid calls to distplane, function calls, and real number operations.
    caller traces result
    Optimized for outside points.   Tried recording a search set for qh_findhorizon.
    Made code more complicated.

  when called by qh_partitionvisible():
    indicated by qh_ISnewfacets
    qh.newfacet_list is list of simplicial, new facets
    qh_findbestnew set if qh_sharpnewfacets returns True (to use qh_findbestnew)
    qh.bestfacet_notsharp set if qh_sharpnewfacets returns False

  when called by qh_findfacet(), qh_partitionpoint(), qh_partitioncoplanar(),
                 qh_check_bestdist(), qh_addpoint()
    indicated by !qh_ISnewfacets
    returns best facet in neighborhood of given facet
      this is best facet overall if dist >= -qh.MAXcoplanar
        or hull has at least a "spherical" curvature

  design:
    initialize and test for early exit
    repeat while there are better facets
      for each neighbor of facet
        exit if outside facet found
        test for better facet
    if point is inside and partitioning
      test for new facets with a "sharp" intersection
      if so, future calls go to qh_findbestnew()
    test horizon facets
*/
facetT *qh_findbest(qhT *qh, pointT *point, facetT *startfacet,
                     boolT bestoutside, boolT isnewfacets, boolT noupper,
                     realT *dist, boolT *isoutside, int *numpart) {
  realT bestdist= -REALmax/2 /* avoid underflow */;
  facetT *facet, *neighbor, **neighborp;
  facetT *bestfacet= NULL, *lastfacet= NULL;
  int oldtrace= qh->IStracing;
  unsigned int visitid= ++qh->visit_id;
  int numpartnew=0;
  boolT testhorizon= True; /* needed if precise, e.g., rbox c D6 | qhull Q0 Tv */

  zinc_(Zfindbest);
#ifndef qh_NOtrace
  if (qh->IStracing >= 4 || (qh->TRACElevel && qh->TRACEpoint >= 0 && qh->TRACEpoint == qh_pointid(qh, point))) {
    if (qh->TRACElevel > qh->IStracing)
      qh->IStracing= qh->TRACElevel;
    qh_fprintf(qh, qh->ferr, 8004, "qh_findbest: point p%d starting at f%d isnewfacets? %d, unless %d exit if > %2.2g,",
             qh_pointid(qh, point), startfacet->id, isnewfacets, bestoutside, qh->MINoutside);
    qh_fprintf(qh, qh->ferr, 8005, " testhorizon? %d, noupper? %d,", testhorizon, noupper);
    qh_fprintf(qh, qh->ferr, 8006, " Last qh_addpoint p%d,", qh->furthest_id);
    qh_fprintf(qh, qh->ferr, 8007, " Last merge #%d, max_outside %2.2g\n", zzval_(Ztotmerge), qh->max_outside);
  }
#endif
  if (isoutside)
    *isoutside= True;
  if (!startfacet->flipped) {  /* test startfacet before testing its neighbors */
    *numpart= 1;
    qh_distplane(qh, point, startfacet, dist);  /* this code is duplicated below */
    if (!bestoutside && *dist >= qh->MINoutside
    && (!startfacet->upperdelaunay || !noupper)) {
      bestfacet= startfacet;
      goto LABELreturn_best;
    }
    bestdist= *dist;
    if (!startfacet->upperdelaunay) {
      bestfacet= startfacet;
    }
  }else
    *numpart= 0;
  startfacet->visitid= visitid;
  facet= startfacet;
  while (facet) {
    trace4((qh, qh->ferr, 4001, "qh_findbest: neighbors of f%d, bestdist %2.2g f%d\n",
                facet->id, bestdist, getid_(bestfacet)));
    lastfacet= facet;
    FOREACHneighbor_(facet) {
      if (!neighbor->newfacet && isnewfacets)
        continue;
      if (neighbor->visitid == visitid)
        continue;
      neighbor->visitid= visitid;
      if (!neighbor->flipped) {  /* code duplicated above */
        (*numpart)++;
        qh_distplane(qh, point, neighbor, dist);
        if (*dist > bestdist) {
          if (!bestoutside && *dist >= qh->MINoutside
          && (!neighbor->upperdelaunay || !noupper)) {
            bestfacet= neighbor;
            goto LABELreturn_best;
          }
          if (!neighbor->upperdelaunay) {
            bestfacet= neighbor;
            bestdist= *dist;
            break; /* switch to neighbor */
          }else if (!bestfacet) {
            bestdist= *dist;
            break; /* switch to neighbor */
          }
        } /* end of *dist>bestdist */
      } /* end of !flipped */
    } /* end of FOREACHneighbor */
    facet= neighbor;  /* non-NULL only if *dist>bestdist */
  } /* end of while facet (directed search) */
  if (isnewfacets) {
    if (!bestfacet) { /* startfacet is upperdelaunay (or flipped) w/o !flipped newfacet neighbors */
      bestdist= -REALmax/2;
      bestfacet= qh_findbestnew(qh, point, qh->newfacet_list, &bestdist, bestoutside, isoutside, &numpartnew);
      testhorizon= False; /* qh_findbestnew calls qh_findbesthorizon */
    }else if (!qh->findbest_notsharp && bestdist < -qh->DISTround) {
      if (qh_sharpnewfacets(qh)) {
        /* seldom used, qh_findbestnew will retest all facets */
        zinc_(Zfindnewsharp);
        bestfacet= qh_findbestnew(qh, point, bestfacet, &bestdist, bestoutside, isoutside, &numpartnew);
        testhorizon= False; /* qh_findbestnew calls qh_findbesthorizon */
        qh->findbestnew= True;
      }else
        qh->findbest_notsharp= True;
    }
  }
  if (!bestfacet)
    bestfacet= qh_findbestlower(qh, lastfacet, point, &bestdist, numpart); /* lastfacet is non-NULL because startfacet is non-NULL */
  if (testhorizon) /* qh_findbestnew not called */
    bestfacet= qh_findbesthorizon(qh, !qh_IScheckmax, point, bestfacet, noupper, &bestdist, &numpartnew);
  *dist= bestdist;
  if (isoutside && bestdist < qh->MINoutside)
    *isoutside= False;
LABELreturn_best:
  zadd_(Zfindbesttot, *numpart);
  zmax_(Zfindbestmax, *numpart);
  (*numpart) += numpartnew;
  qh->IStracing= oldtrace;
  return bestfacet;
}  /* findbest */


/*---------------------------------

  qh_findbesthorizon(qh, qh_IScheckmax, point, startfacet, qh_NOupper, &bestdist, &numpart )
    search coplanar and better horizon facets from startfacet/bestdist
    ischeckmax turns off statistics and minsearch update
    all arguments must be initialized, including *bestdist and *numpart
    qh.coplanarfacetset used to maintain current search set, reset whenever best facet is substantially better
  returns(ischeckmax):
    best facet
    updates f.maxoutside for neighbors of searched facets (if qh_MAXoutside)
  returns(!ischeckmax):
    best facet that is not upperdelaunay or newfacet (qh.first_newfacet)
    allows upperdelaunay that is clearly outside
  returns:
    bestdist is distance to bestfacet
    numpart -- updates number of distance tests

  notes:
    called by qh_findbest if point is not outside a facet (directed search)
    called by qh_findbestnew if point is not outside a new facet
    called by qh_check_maxout for each point in hull
    called by qh_check_bestdist for each point in hull (rarely used)

    no early out -- use qh_findbest() or qh_findbestnew()
    Searches coplanar or better horizon facets

  when called by qh_check_maxout() (qh_IScheckmax)
    startfacet must be closest to the point
      Otherwise, if point is beyond and below startfacet, startfacet may be a local minimum
      even though other facets are below the point.
    updates facet->maxoutside for good, visited facets
    may return NULL

    searchdist is qh.max_outside + 2 * DISTround
      + max( MINvisible('Vn'), MAXcoplanar('Un'));
    This setting is a guess.  It must be at least max_outside + 2*DISTround
    because a facet may have a geometric neighbor across a vertex

  design:
    for each horizon facet of coplanar best facets
      continue if clearly inside
      unless upperdelaunay or clearly outside
         update best facet
*/
facetT *qh_findbesthorizon(qhT *qh, boolT ischeckmax, pointT* point, facetT *startfacet, boolT noupper, realT *bestdist, int *numpart) {
  facetT *bestfacet= startfacet;
  realT dist;
  facetT *neighbor, **neighborp, *facet;
  facetT *nextfacet= NULL; /* optimize last facet of coplanarfacetset */
  int numpartinit= *numpart, coplanarfacetset_size, numcoplanar= 0, numfacet= 0;
  unsigned int visitid= ++qh->visit_id;
  boolT newbest= False; /* for tracing */
  realT minsearch, searchdist;  /* skip facets that are too far from point */
  boolT is_5x_minsearch;

  if (!ischeckmax) {
    zinc_(Zfindhorizon);
  }else {
#if qh_MAXoutside
    if ((!qh->ONLYgood || startfacet->good) && *bestdist > startfacet->maxoutside)
      startfacet->maxoutside= *bestdist;
#endif
  }
  searchdist= qh_SEARCHdist; /* an expression, a multiple of qh.max_outside and precision constants */
  minsearch= *bestdist - searchdist;
  if (ischeckmax) {
    /* Always check coplanar facets.  Needed for RBOX 1000 s Z1 G1e-13 t996564279 | QHULL Tv */
    minimize_(minsearch, -searchdist);
  }
  coplanarfacetset_size= 0;
  startfacet->visitid= visitid;
  facet= startfacet;
  while (True) {
    numfacet++;
    is_5x_minsearch= (ischeckmax && facet->nummerge > 10 && qh_setsize(qh, facet->neighbors) > 100);  /* QH11033 FIX: qh_findbesthorizon: many tests for facets with many merges and neighbors.  Can hide coplanar facets, e.g., 'rbox 1000 s Z1 G1e-13' with 4400+ neighbors */
    trace4((qh, qh->ferr, 4002, "qh_findbesthorizon: test neighbors of f%d bestdist %2.2g f%d ischeckmax? %d noupper? %d minsearch %2.2g is_5x? %d searchdist %2.2g\n",
                facet->id, *bestdist, getid_(bestfacet), ischeckmax, noupper,
                minsearch, is_5x_minsearch, searchdist));
    FOREACHneighbor_(facet) {
      if (neighbor->visitid == visitid)
        continue;
      neighbor->visitid= visitid;
      if (!neighbor->flipped) {  /* neighbors of flipped facets always searched via nextfacet */
        qh_distplane(qh, point, neighbor, &dist); /* duplicate qh_distpane for new facets, they may be coplanar */
        (*numpart)++;
        if (dist > *bestdist) {
          if (!neighbor->upperdelaunay || ischeckmax || (!noupper && dist >= qh->MINoutside)) {
            if (!ischeckmax) {
              minsearch= dist - searchdist;
              if (dist > *bestdist + searchdist) {
                zinc_(Zfindjump);  /* everything in qh.coplanarfacetset at least searchdist below */
                coplanarfacetset_size= 0;
              }
            }
            bestfacet= neighbor;
            *bestdist= dist;
            newbest= True;
          }
        }else if (is_5x_minsearch) {
          if (dist < 5 * minsearch)
            continue; /* skip this neighbor, do not set nextfacet.  dist is negative */
        }else if (dist < minsearch)
          continue;  /* skip this neighbor, do not set nextfacet.  If ischeckmax, dist can't be positive */
#if qh_MAXoutside
        if (ischeckmax && dist > neighbor->maxoutside)
          neighbor->maxoutside= dist;
#endif
      } /* end of !flipped, need to search neighbor */
      if (nextfacet) {
        numcoplanar++;
        if (!coplanarfacetset_size++) {
          SETfirst_(qh->coplanarfacetset)= nextfacet;
          SETtruncate_(qh->coplanarfacetset, 1);
        }else
          qh_setappend(qh, &qh->coplanarfacetset, nextfacet); /* Was needed for RBOX 1000 s W1e-13 P0 t996547055 | QHULL d Qbb Qc Tv
                                                 and RBOX 1000 s Z1 G1e-13 t996564279 | qhull Tv  */
      }
      nextfacet= neighbor;
    } /* end of EACHneighbor */
    facet= nextfacet;
    if (facet)
      nextfacet= NULL;
    else if (!coplanarfacetset_size)
      break;
    else if (!--coplanarfacetset_size) {
      facet= SETfirstt_(qh->coplanarfacetset, facetT);
      SETtruncate_(qh->coplanarfacetset, 0);
    }else
      facet= (facetT *)qh_setdellast(qh->coplanarfacetset);
  } /* while True, i.e., "for each facet in qh.coplanarfacetset" */
  if (!ischeckmax) {
    zadd_(Zfindhorizontot, *numpart - numpartinit);
    zmax_(Zfindhorizonmax, *numpart - numpartinit);
    if (newbest)
      zinc_(Znewbesthorizon);
  }
  trace4((qh, qh->ferr, 4003, "qh_findbesthorizon: p%d, newbest? %d, bestfacet f%d, bestdist %2.2g, numfacet %d, coplanarfacets %d, numdist %d\n",
    qh_pointid(qh, point), newbest, getid_(bestfacet), *bestdist, numfacet, numcoplanar, *numpart - numpartinit));
  return bestfacet;
}  /* findbesthorizon */

/*---------------------------------

  qh_findbestnew(qh, point, startfacet, dist, isoutside, numpart )
    find best newfacet for point
    searches all of qh.newfacet_list starting at startfacet
    searches horizon facets of coplanar best newfacets
    searches all facets if startfacet == qh.facet_list
  returns:
    best new or horizon facet that is not upperdelaunay
    early out if isoutside and not 'Qf'
    dist is distance to facet
    isoutside is true if point is outside of facet
    numpart is number of distance tests

  notes:
    Always used for merged new facets (see qh_USEfindbestnew)
    Avoids upperdelaunay facet unless (isoutside and outside)

    Uses qh.visit_id, qh.coplanarfacetset.
    If share visit_id with qh_findbest, coplanarfacetset is incorrect.

    If merging (testhorizon), searches horizon facets of coplanar best facets because
    a point maybe coplanar to the bestfacet, below its horizon facet,
    and above a horizon facet of a coplanar newfacet.  For example,
      rbox 1000 s Z1 G1e-13 | qhull
      rbox 1000 s W1e-13 P0 t992110337 | QHULL d Qbb Qc

    qh_findbestnew() used if
       qh_sharpnewfacets -- newfacets contains a sharp angle
       if many merges, qh_premerge found a merge, or 'Qf' (qh.findbestnew)

  see also:
    qh_partitionall() and qh_findbest()

  design:
    for each new facet starting from startfacet
      test distance from point to facet
      return facet if clearly outside
      unless upperdelaunay and a lowerdelaunay exists
         update best facet
    test horizon facets
*/
facetT *qh_findbestnew(qhT *qh, pointT *point, facetT *startfacet,
           realT *dist, boolT bestoutside, boolT *isoutside, int *numpart) {
  realT bestdist= -REALmax/2;
  facetT *bestfacet= NULL, *facet;
  int oldtrace= qh->IStracing, i;
  unsigned int visitid= ++qh->visit_id;
  realT distoutside= 0.0;
  boolT isdistoutside; /* True if distoutside is defined */
  boolT testhorizon= True; /* needed if precise, e.g., rbox c D6 | qhull Q0 Tv */

  if (!startfacet || !startfacet->next) {
    if (qh->MERGING) {
      qh_fprintf(qh, qh->ferr, 6001, "qhull topology error (qh_findbestnew): merging has formed and deleted a cone of new facets.  Can not continue.\n");
      qh_errexit(qh, qh_ERRtopology, NULL, NULL);
    }else {
      qh_fprintf(qh, qh->ferr, 6002, "qhull internal error (qh_findbestnew): no new facets for point p%d\n",
              qh->furthest_id);
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }
  }
  zinc_(Zfindnew);
  if (qh->BESToutside || bestoutside)
    isdistoutside= False;
  else {
    isdistoutside= True;
    distoutside= qh_DISToutside; /* multiple of qh.MINoutside & qh.max_outside, see user_r.h */
  }
  if (isoutside)
    *isoutside= True;
  *numpart= 0;
#ifndef qh_NOtrace
  if (qh->IStracing >= 4 || (qh->TRACElevel && qh->TRACEpoint >= 0 && qh->TRACEpoint == qh_pointid(qh, point))) {
    if (qh->TRACElevel > qh->IStracing)
      qh->IStracing= qh->TRACElevel;
    qh_fprintf(qh, qh->ferr, 8008, "qh_findbestnew: point p%d facet f%d. Stop? %d if dist > %2.2g,",
             qh_pointid(qh, point), startfacet->id, isdistoutside, distoutside);
    qh_fprintf(qh, qh->ferr, 8009, " Last qh_addpoint p%d, qh.visit_id %d, vertex_visit %d,",  qh->furthest_id, visitid, qh->vertex_visit);
    qh_fprintf(qh, qh->ferr, 8010, " Last merge #%d\n", zzval_(Ztotmerge));
  }
#endif
  /* visit all new facets starting with startfacet, maybe qh->facet_list */
  for (i=0, facet=startfacet; i < 2; i++, facet= qh->newfacet_list) {
    FORALLfacet_(facet) {
      if (facet == startfacet && i)
        break;
      facet->visitid= visitid;
      if (!facet->flipped) {
        qh_distplane(qh, point, facet, dist);
        (*numpart)++;
        if (*dist > bestdist) {
          if (!facet->upperdelaunay || *dist >= qh->MINoutside) {
            bestfacet= facet;
            if (isdistoutside && *dist >= distoutside)
              goto LABELreturn_bestnew;
            bestdist= *dist;
          }
        }
      } /* end of !flipped */
    } /* FORALLfacet from startfacet or qh->newfacet_list */
  }
  if (testhorizon || !bestfacet) /* testhorizon is always True.  Keep the same code as qh_findbest */
    bestfacet= qh_findbesthorizon(qh, !qh_IScheckmax, point, bestfacet ? bestfacet : startfacet,
                                        !qh_NOupper, &bestdist, numpart);
  *dist= bestdist;
  if (isoutside && *dist < qh->MINoutside)
    *isoutside= False;
LABELreturn_bestnew:
  zadd_(Zfindnewtot, *numpart);
  zmax_(Zfindnewmax, *numpart);
  trace4((qh, qh->ferr, 4004, "qh_findbestnew: bestfacet f%d bestdist %2.2g for p%d f%d bestoutside? %d \n",
    getid_(bestfacet), *dist, qh_pointid(qh, point), startfacet->id, bestoutside));
  qh->IStracing= oldtrace;
  return bestfacet;
}  /* findbestnew */

/* ============ hyperplane functions -- keep code together [?] ============ */

/*---------------------------------

  qh_backnormal(qh, rows, numrow, numcol, sign, normal, nearzero )
    given an upper-triangular rows array and a sign,
    solve for normal equation x using back substitution over rows U

  returns:
     normal= x

     if will not be able to divzero() when normalized(qh.MINdenom_2 and qh.MINdenom_1_2),
       if fails on last row
         this means that the hyperplane intersects [0,..,1]
         sets last coordinate of normal to sign
       otherwise
         sets tail of normal to [...,sign,0,...], i.e., solves for b= [0...0]
         sets nearzero

  notes:
     assumes numrow == numcol-1

     see Golub & van Loan, 1983, Eq. 4.4-9 for "Gaussian elimination with complete pivoting"

     solves Ux=b where Ax=b and PA=LU
     b= [0,...,0,sign or 0]  (sign is either -1 or +1)
     last row of A= [0,...,0,1]

     1) Ly=Pb == y=b since P only permutes the 0's of   b

  design:
    for each row from end
      perform back substitution
      if near zero
        use qh_divzero for division
        if zero divide and not last row
          set tail of normal to 0
*/
void qh_backnormal(qhT *qh, realT **rows, int numrow, int numcol, boolT sign,
        coordT *normal, boolT *nearzero) {
  int i, j;
  coordT *normalp, *normal_tail, *ai, *ak;
  realT diagonal;
  boolT waszero;
  int zerocol= -1;

  normalp= normal + numcol - 1;
  *normalp--= (sign ? -1.0 : 1.0);
  for (i=numrow; i--; ) {
    *normalp= 0.0;
    ai= rows[i] + i + 1;
    ak= normalp+1;
    for (j=i+1; j < numcol; j++)
      *normalp -= *ai++ * *ak++;
    diagonal= (rows[i])[i];
    if (fabs_(diagonal) > qh->MINdenom_2)
      *(normalp--) /= diagonal;
    else {
      waszero= False;
      *normalp= qh_divzero(*normalp, diagonal, qh->MINdenom_1_2, &waszero);
      if (waszero) {
        zerocol= i;
        *(normalp--)= (sign ? -1.0 : 1.0);
        for (normal_tail= normalp+2; normal_tail < normal + numcol; normal_tail++)
          *normal_tail= 0.0;
      }else
        normalp--;
    }
  }
  if (zerocol != -1) {
    *nearzero= True;
    trace4((qh, qh->ferr, 4005, "qh_backnormal: zero diagonal at column %d.\n", i));
    zzinc_(Zback0);
    qh_joggle_restart(qh, "zero diagonal on back substitution");
  }
} /* backnormal */

/*---------------------------------

  qh_gausselim(qh, rows, numrow, numcol, sign )
    Gaussian elimination with partial pivoting

  returns:
    rows is upper triangular (includes row exchanges)
    flips sign for each row exchange
    sets nearzero if pivot[k] < qh.NEARzero[k], else clears it

  notes:
    if nearzero, the determinant's sign may be incorrect.
    assumes numrow <= numcol

  design:
    for each row
      determine pivot and exchange rows if necessary
      test for near zero
      perform gaussian elimination step
*/
void qh_gausselim(qhT *qh, realT **rows, int numrow, int numcol, boolT *sign, boolT *nearzero) {
  realT *ai, *ak, *rowp, *pivotrow;
  realT n, pivot, pivot_abs= 0.0, temp;
  int i, j, k, pivoti, flip=0;

  *nearzero= False;
  for (k=0; k < numrow; k++) {
    pivot_abs= fabs_((rows[k])[k]);
    pivoti= k;
    for (i=k+1; i < numrow; i++) {
      if ((temp= fabs_((rows[i])[k])) > pivot_abs) {
        pivot_abs= temp;
        pivoti= i;
      }
    }
    if (pivoti != k) {
      rowp= rows[pivoti];
      rows[pivoti]= rows[k];
      rows[k]= rowp;
      *sign ^= 1;
      flip ^= 1;
    }
    if (pivot_abs <= qh->NEARzero[k]) {
      *nearzero= True;
      if (pivot_abs == 0.0) {   /* remainder of column == 0 */
#ifndef qh_NOtrace
        if (qh->IStracing >= 4) {
          qh_fprintf(qh, qh->ferr, 8011, "qh_gausselim: 0 pivot at column %d. (%2.2g < %2.2g)\n", k, pivot_abs, qh->DISTround);
          qh_printmatrix(qh, qh->ferr, "Matrix:", rows, numrow, numcol);
        }
#endif
        zzinc_(Zgauss0);
        qh_joggle_restart(qh, "zero pivot for Gaussian elimination");
        goto LABELnextcol;
      }
    }
    pivotrow= rows[k] + k;
    pivot= *pivotrow++;  /* signed value of pivot, and remainder of row */
    for (i=k+1; i < numrow; i++) {
      ai= rows[i] + k;
      ak= pivotrow;
      n= (*ai++)/pivot;   /* divzero() not needed since |pivot| >= |*ai| */
      for (j= numcol - (k+1); j--; )
        *ai++ -= n * *ak++;
    }
  LABELnextcol:
    ;
  }
  wmin_(Wmindenom, pivot_abs);  /* last pivot element */
  if (qh->IStracing >= 5)
    qh_printmatrix(qh, qh->ferr, "qh_gausselem: result", rows, numrow, numcol);
} /* gausselim */


/*---------------------------------

  qh_getangle(qh, vect1, vect2 )
    returns the dot product of two vectors
    if qh.RANDOMdist, joggles result

  notes:
    the angle may be > 1.0 or < -1.0 because of roundoff errors

*/
realT qh_getangle(qhT *qh, pointT *vect1, pointT *vect2) {
  realT angle= 0, randr;
  int k;

  for (k=qh->hull_dim; k--; )
    angle += *vect1++ * *vect2++;
  if (qh->RANDOMdist) {
    randr= qh_RANDOMint;
    angle += (2.0 * randr / qh_RANDOMmax - 1.0) *
      qh->RANDOMfactor;
  }
  trace4((qh, qh->ferr, 4006, "qh_getangle: %4.4g\n", angle));
  return(angle);
} /* getangle */


/*---------------------------------

  qh_getcenter(qh, vertices )
    returns arithmetic center of a set of vertices as a new point

  notes:
    allocates point array for center
*/
pointT *qh_getcenter(qhT *qh, setT *vertices) {
  int k;
  pointT *center, *coord;
  vertexT *vertex, **vertexp;
  int count= qh_setsize(qh, vertices);

  if (count < 2) {
    qh_fprintf(qh, qh->ferr, 6003, "qhull internal error (qh_getcenter): not defined for %d points\n", count);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  center= (pointT *)qh_memalloc(qh, qh->normal_size);
  for (k=0; k < qh->hull_dim; k++) {
    coord= center+k;
    *coord= 0.0;
    FOREACHvertex_(vertices)
      *coord += vertex->point[k];
    *coord /= count;  /* count>=2 by QH6003 */
  }
  return(center);
} /* getcenter */


/*---------------------------------

  qh_getcentrum(qh, facet )
    returns the centrum for a facet as a new point

  notes:
    allocates the centrum
*/
pointT *qh_getcentrum(qhT *qh, facetT *facet) {
  realT dist;
  pointT *centrum, *point;

  point= qh_getcenter(qh, facet->vertices);
  zzinc_(Zcentrumtests);
  qh_distplane(qh, point, facet, &dist);
  centrum= qh_projectpoint(qh, point, facet, dist);
  qh_memfree(qh, point, qh->normal_size);
  trace4((qh, qh->ferr, 4007, "qh_getcentrum: for f%d, %d vertices dist= %2.2g\n",
          facet->id, qh_setsize(qh, facet->vertices), dist));
  return centrum;
} /* getcentrum */


/*---------------------------------

  qh_getdistance(qh, facet, neighbor, mindist, maxdist )
    returns the min and max distance to neighbor of non-neighbor vertices in facet

  returns:
    the max absolute value

  design:
    for each vertex of facet that is not in neighbor
      test the distance from vertex to neighbor
*/
coordT qh_getdistance(qhT *qh, facetT *facet, facetT *neighbor, coordT *mindist, coordT *maxdist) {
  vertexT *vertex, **vertexp;
  coordT dist, maxd, mind;

  FOREACHvertex_(facet->vertices)
    vertex->seen= False;
  FOREACHvertex_(neighbor->vertices)
    vertex->seen= True;
  mind= 0.0;
  maxd= 0.0;
  FOREACHvertex_(facet->vertices) {
    if (!vertex->seen) {
      zzinc_(Zbestdist);
      qh_distplane(qh, vertex->point, neighbor, &dist);
      if (dist < mind)
        mind= dist;
      else if (dist > maxd)
        maxd= dist;
    }
  }
  *mindist= mind;
  *maxdist= maxd;
  mind= -mind;
  if (maxd > mind)
    return maxd;
  else
    return mind;
} /* getdistance */


/*---------------------------------

  qh_normalize(qh, normal, dim, toporient )
    normalize a vector and report if too small
    does not use min norm

  see:
    qh_normalize2
*/
void qh_normalize(qhT *qh, coordT *normal, int dim, boolT toporient) {
  qh_normalize2(qh, normal, dim, toporient, NULL, NULL);
} /* normalize */

/*---------------------------------

  qh_normalize2(qh, normal, dim, toporient, minnorm, ismin )
    normalize a vector and report if too small
    qh.MINdenom/MINdenom1 are the upper limits for divide overflow

  returns:
    normalized vector
    flips sign if !toporient
    if minnorm non-NULL,
      sets ismin if normal < minnorm

  notes:
    if zero norm
       sets all elements to sqrt(1.0/dim)
    if divide by zero (divzero())
       sets largest element to   +/-1
       bumps Znearlysingular

  design:
    computes norm
    test for minnorm
    if not near zero
      normalizes normal
    else if zero norm
      sets normal to standard value
    else
      uses qh_divzero to normalize
      if nearzero
        sets norm to direction of maximum value
*/
void qh_normalize2(qhT *qh, coordT *normal, int dim, boolT toporient,
            realT *minnorm, boolT *ismin) {
  int k;
  realT *colp, *maxp, norm= 0, temp, *norm1, *norm2, *norm3;
  boolT zerodiv;

  norm1= normal+1;
  norm2= normal+2;
  norm3= normal+3;
  if (dim == 2)
    norm= sqrt((*normal)*(*normal) + (*norm1)*(*norm1));
  else if (dim == 3)
    norm= sqrt((*normal)*(*normal) + (*norm1)*(*norm1) + (*norm2)*(*norm2));
  else if (dim == 4) {
    norm= sqrt((*normal)*(*normal) + (*norm1)*(*norm1) + (*norm2)*(*norm2)
               + (*norm3)*(*norm3));
  }else if (dim > 4) {
    norm= (*normal)*(*normal) + (*norm1)*(*norm1) + (*norm2)*(*norm2)
               + (*norm3)*(*norm3);
    for (k=dim-4, colp=normal+4; k--; colp++)
      norm += (*colp) * (*colp);
    norm= sqrt(norm);
  }
  if (minnorm) {
    if (norm < *minnorm)
      *ismin= True;
    else
      *ismin= False;
  }
  wmin_(Wmindenom, norm);
  if (norm > qh->MINdenom) {
    if (!toporient)
      norm= -norm;
    *normal /= norm;
    *norm1 /= norm;
    if (dim == 2)
      ; /* all done */
    else if (dim == 3)
      *norm2 /= norm;
    else if (dim == 4) {
      *norm2 /= norm;
      *norm3 /= norm;
    }else if (dim >4) {
      *norm2 /= norm;
      *norm3 /= norm;
      for (k=dim-4, colp=normal+4; k--; )
        *colp++ /= norm;
    }
  }else if (norm == 0.0) {
    temp= sqrt(1.0/dim);
    for (k=dim, colp=normal; k--; )
      *colp++= temp;
  }else {
    if (!toporient)
      norm= -norm;
    for (k=dim, colp=normal; k--; colp++) { /* k used below */
      temp= qh_divzero(*colp, norm, qh->MINdenom_1, &zerodiv);
      if (!zerodiv)
        *colp= temp;
      else {
        maxp= qh_maxabsval(normal, dim);
        temp= ((*maxp * norm >= 0.0) ? 1.0 : -1.0);
        for (k=dim, colp=normal; k--; colp++)
          *colp= 0.0;
        *maxp= temp;
        zzinc_(Znearlysingular);
        /* qh_joggle_restart ignored for Znearlysingular, normal part of qh_sethyperplane_gauss */
        trace0((qh, qh->ferr, 1, "qh_normalize: norm=%2.2g too small during p%d\n",
               norm, qh->furthest_id));
        return;
      }
    }
  }
} /* normalize */


/*---------------------------------

  qh_projectpoint(qh, point, facet, dist )
    project point onto a facet by dist

  returns:
    returns a new point

  notes:
    if dist= distplane(point,facet)
      this projects point to hyperplane
    assumes qh_memfree_() is valid for normal_size
*/
pointT *qh_projectpoint(qhT *qh, pointT *point, facetT *facet, realT dist) {
  pointT *newpoint, *np, *normal;
  int normsize= qh->normal_size;
  int k;
  void **freelistp; /* used if !qh_NOmem by qh_memalloc_() */

  qh_memalloc_(qh, normsize, freelistp, newpoint, pointT);
  np= newpoint;
  normal= facet->normal;
  for (k=qh->hull_dim; k--; )
    *(np++)= *point++ - dist * *normal++;
  return(newpoint);
} /* projectpoint */


/*---------------------------------

  qh_setfacetplane(qh, facet )
    sets the hyperplane for a facet
    if qh.RANDOMdist, joggles hyperplane

  notes:
    uses global buffers qh.gm_matrix and qh.gm_row
    overwrites facet->normal if already defined
    updates Wnewvertex if PRINTstatistics
    sets facet->upperdelaunay if upper envelope of Delaunay triangulation

  design:
    copy vertex coordinates to qh.gm_matrix/gm_row
    compute determinate
    if nearzero
      recompute determinate with gaussian elimination
      if nearzero
        force outside orientation by testing interior point
*/
void qh_setfacetplane(qhT *qh, facetT *facet) {
  pointT *point;
  vertexT *vertex, **vertexp;
  int normsize= qh->normal_size;
  int k,i, oldtrace= 0;
  realT dist;
  void **freelistp; /* used if !qh_NOmem by qh_memalloc_() */
  coordT *coord, *gmcoord;
  pointT *point0= SETfirstt_(facet->vertices, vertexT)->point;
  boolT nearzero= False;

  zzinc_(Zsetplane);
  if (!facet->normal)
    qh_memalloc_(qh, normsize, freelistp, facet->normal, coordT);
#ifndef qh_NOtrace
  if (facet == qh->tracefacet) {
    oldtrace= qh->IStracing;
    qh->IStracing= 5;
    qh_fprintf(qh, qh->ferr, 8012, "qh_setfacetplane: facet f%d created.\n", facet->id);
    qh_fprintf(qh, qh->ferr, 8013, "  Last point added to hull was p%d.", qh->furthest_id);
    if (zzval_(Ztotmerge))
      qh_fprintf(qh, qh->ferr, 8014, "  Last merge was #%d.", zzval_(Ztotmerge));
    qh_fprintf(qh, qh->ferr, 8015, "\n\nCurrent summary is:\n");
      qh_printsummary(qh, qh->ferr);
  }
#endif
  if (qh->hull_dim <= 4) {
    i= 0;
    if (qh->RANDOMdist) {
      gmcoord= qh->gm_matrix;
      FOREACHvertex_(facet->vertices) {
        qh->gm_row[i++]= gmcoord;
        coord= vertex->point;
        for (k=qh->hull_dim; k--; )
          *(gmcoord++)= *coord++ * qh_randomfactor(qh, qh->RANDOMa, qh->RANDOMb);
      }
    }else {
      FOREACHvertex_(facet->vertices)
       qh->gm_row[i++]= vertex->point;
    }
    qh_sethyperplane_det(qh, qh->hull_dim, qh->gm_row, point0, facet->toporient,
                facet->normal, &facet->offset, &nearzero);
  }
  if (qh->hull_dim > 4 || nearzero) {
    i= 0;
    gmcoord= qh->gm_matrix;
    FOREACHvertex_(facet->vertices) {
      if (vertex->point != point0) {
        qh->gm_row[i++]= gmcoord;
        coord= vertex->point;
        point= point0;
        for (k=qh->hull_dim; k--; )
          *(gmcoord++)= *coord++ - *point++;
      }
    }
    qh->gm_row[i]= gmcoord;  /* for areasimplex */
    if (qh->RANDOMdist) {
      gmcoord= qh->gm_matrix;
      for (i=qh->hull_dim-1; i--; ) {
        for (k=qh->hull_dim; k--; )
          *(gmcoord++) *= qh_randomfactor(qh, qh->RANDOMa, qh->RANDOMb);
      }
    }
    qh_sethyperplane_gauss(qh, qh->hull_dim, qh->gm_row, point0, facet->toporient,
                facet->normal, &facet->offset, &nearzero);
    if (nearzero) {
      if (qh_orientoutside(qh, facet)) {
        trace0((qh, qh->ferr, 2, "qh_setfacetplane: flipped orientation due to nearzero gauss and interior_point test.  During p%d\n", qh->furthest_id));
      /* this is part of using Gaussian Elimination.  For example in 5-d
           1 1 1 1 0
           1 1 1 1 1
           0 0 0 1 0
           0 1 0 0 0
           1 0 0 0 0
           norm= 0.38 0.38 -0.76 0.38 0
         has a determinate of 1, but g.e. after subtracting pt. 0 has
         0's in the diagonal, even with full pivoting.  It does work
         if you subtract pt. 4 instead. */
      }
    }
  }
  facet->upperdelaunay= False;
  if (qh->DELAUNAY) {
    if (qh->UPPERdelaunay) {     /* matches qh_triangulate_facet and qh.lower_threshold in qh_initbuild */
      if (facet->normal[qh->hull_dim -1] >= qh->ANGLEround * qh_ZEROdelaunay)
        facet->upperdelaunay= True;
    }else {
      if (facet->normal[qh->hull_dim -1] > -qh->ANGLEround * qh_ZEROdelaunay)
        facet->upperdelaunay= True;
    }
  }
  if (qh->PRINTstatistics || qh->IStracing || qh->TRACElevel || qh->JOGGLEmax < REALmax) {
    qh->old_randomdist= qh->RANDOMdist;
    qh->RANDOMdist= False;
    FOREACHvertex_(facet->vertices) {
      if (vertex->point != point0) {
        boolT istrace= False;
        zinc_(Zdiststat);
        qh_distplane(qh, vertex->point, facet, &dist);
        dist= fabs_(dist);
        zinc_(Znewvertex);
        wadd_(Wnewvertex, dist);
        if (dist > wwval_(Wnewvertexmax)) {
          wwval_(Wnewvertexmax)= dist;
          if (dist > qh->max_outside) {
            qh->max_outside= dist;  /* used by qh_maxouter(qh) */
            if (dist > qh->TRACEdist)
              istrace= True;
          }
        }else if (-dist > qh->TRACEdist)
          istrace= True;
        if (istrace) {
          qh_fprintf(qh, qh->ferr, 3060, "qh_setfacetplane: ====== vertex p%d(v%d) increases max_outside to %2.2g for new facet f%d last p%d\n",
                qh_pointid(qh, vertex->point), vertex->id, dist, facet->id, qh->furthest_id);
          qh_errprint(qh, "DISTANT", facet, NULL, NULL, NULL);
        }
      }
    }
    qh->RANDOMdist= qh->old_randomdist;
  }
#ifndef qh_NOtrace
  if (qh->IStracing >= 4) {
    qh_fprintf(qh, qh->ferr, 8017, "qh_setfacetplane: f%d offset %2.2g normal: ",
             facet->id, facet->offset);
    for (k=0; k < qh->hull_dim; k++)
      qh_fprintf(qh, qh->ferr, 8018, "%2.2g ", facet->normal[k]);
    qh_fprintf(qh, qh->ferr, 8019, "\n");
  }
#endif
  qh_checkflipped(qh, facet, NULL, qh_ALL);
  if (facet == qh->tracefacet) {
    qh->IStracing= oldtrace;
    qh_printfacet(qh, qh->ferr, facet);
  }
} /* setfacetplane */


/*---------------------------------

  qh_sethyperplane_det(qh, dim, rows, point0, toporient, normal, offset, nearzero )
    given dim X dim array indexed by rows[], one row per point,
        toporient(flips all signs),
        and point0 (any row)
    set normalized hyperplane equation from oriented simplex

  returns:
    normal (normalized)
    offset (places point0 on the hyperplane)
    sets nearzero if hyperplane not through points

  notes:
    only defined for dim == 2..4
    rows[] is not modified
    solves det(P-V_0, V_n-V_0, ..., V_1-V_0)=0, i.e. every point is on hyperplane
    see Bower & Woodworth, A programmer's geometry, Butterworths 1983.

  derivation of 3-d minnorm
    Goal: all vertices V_i within qh.one_merge of hyperplane
    Plan: exactly translate the facet so that V_0 is the origin
          exactly rotate the facet so that V_1 is on the x-axis and y_2=0.
          exactly rotate the effective perturbation to only effect n_0
             this introduces a factor of sqrt(3)
    n_0 = ((y_2-y_0)*(z_1-z_0) - (z_2-z_0)*(y_1-y_0)) / norm
    Let M_d be the max coordinate difference
    Let M_a be the greater of M_d and the max abs. coordinate
    Let u be machine roundoff and distround be max error for distance computation
    The max error for n_0 is sqrt(3) u M_a M_d / norm.  n_1 is approx. 1 and n_2 is approx. 0
    The max error for distance of V_1 is sqrt(3) u M_a M_d M_d / norm.  Offset=0 at origin
    Then minnorm = 1.8 u M_a M_d M_d / qh.ONEmerge
    Note that qh.one_merge is approx. 45.5 u M_a and norm is usually about M_d M_d

  derivation of 4-d minnorm
    same as above except rotate the facet so that V_1 on x-axis and w_2, y_3, w_3=0
     [if two vertices fixed on x-axis, can rotate the other two in yzw.]
    n_0 = det3_(...) = y_2 det2_(z_1, w_1, z_3, w_3) = - y_2 w_1 z_3
     [all other terms contain at least two factors nearly zero.]
    The max error for n_0 is sqrt(4) u M_a M_d M_d / norm
    Then minnorm = 2 u M_a M_d M_d M_d / qh.ONEmerge
    Note that qh.one_merge is approx. 82 u M_a and norm is usually about M_d M_d M_d
*/
void qh_sethyperplane_det(qhT *qh, int dim, coordT **rows, coordT *point0,
          boolT toporient, coordT *normal, realT *offset, boolT *nearzero) {
  realT maxround, dist;
  int i;
  pointT *point;


  if (dim == 2) {
    normal[0]= dY(1,0);
    normal[1]= dX(0,1);
    qh_normalize2(qh, normal, dim, toporient, NULL, NULL);
    *offset= -(point0[0]*normal[0]+point0[1]*normal[1]);
    *nearzero= False;  /* since nearzero norm => incident points */
  }else if (dim == 3) {
    normal[0]= det2_(dY(2,0), dZ(2,0),
                     dY(1,0), dZ(1,0));
    normal[1]= det2_(dX(1,0), dZ(1,0),
                     dX(2,0), dZ(2,0));
    normal[2]= det2_(dX(2,0), dY(2,0),
                     dX(1,0), dY(1,0));
    qh_normalize2(qh, normal, dim, toporient, NULL, NULL);
    *offset= -(point0[0]*normal[0] + point0[1]*normal[1]
               + point0[2]*normal[2]);
    maxround= qh->DISTround;
    for (i=dim; i--; ) {
      point= rows[i];
      if (point != point0) {
        dist= *offset + (point[0]*normal[0] + point[1]*normal[1]
               + point[2]*normal[2]);
        if (dist > maxround || dist < -maxround) {
          *nearzero= True;
          break;
        }
      }
    }
  }else if (dim == 4) {
    normal[0]= - det3_(dY(2,0), dZ(2,0), dW(2,0),
                        dY(1,0), dZ(1,0), dW(1,0),
                        dY(3,0), dZ(3,0), dW(3,0));
    normal[1]=   det3_(dX(2,0), dZ(2,0), dW(2,0),
                        dX(1,0), dZ(1,0), dW(1,0),
                        dX(3,0), dZ(3,0), dW(3,0));
    normal[2]= - det3_(dX(2,0), dY(2,0), dW(2,0),
                        dX(1,0), dY(1,0), dW(1,0),
                        dX(3,0), dY(3,0), dW(3,0));
    normal[3]=   det3_(dX(2,0), dY(2,0), dZ(2,0),
                        dX(1,0), dY(1,0), dZ(1,0),
                        dX(3,0), dY(3,0), dZ(3,0));
    qh_normalize2(qh, normal, dim, toporient, NULL, NULL);
    *offset= -(point0[0]*normal[0] + point0[1]*normal[1]
               + point0[2]*normal[2] + point0[3]*normal[3]);
    maxround= qh->DISTround;
    for (i=dim; i--; ) {
      point= rows[i];
      if (point != point0) {
        dist= *offset + (point[0]*normal[0] + point[1]*normal[1]
               + point[2]*normal[2] + point[3]*normal[3]);
        if (dist > maxround || dist < -maxround) {
          *nearzero= True;
          break;
        }
      }
    }
  }
  if (*nearzero) {
    zzinc_(Zminnorm);
    /* qh_joggle_restart not needed, will call qh_sethyperplane_gauss instead */
    trace0((qh, qh->ferr, 3, "qh_sethyperplane_det: degenerate norm during p%d, use qh_sethyperplane_gauss instead.\n", qh->furthest_id));
  }
} /* sethyperplane_det */


/*---------------------------------

  qh_sethyperplane_gauss(qh, dim, rows, point0, toporient, normal, offset, nearzero )
    given(dim-1) X dim array of rows[i]= V_{i+1} - V_0 (point0)
    set normalized hyperplane equation from oriented simplex

  returns:
    normal (normalized)
    offset (places point0 on the hyperplane)

  notes:
    if nearzero
      orientation may be incorrect because of incorrect sign flips in gausselim
    solves [V_n-V_0,...,V_1-V_0, 0 .. 0 1] * N == [0 .. 0 1]
        or [V_n-V_0,...,V_1-V_0, 0 .. 0 1] * N == [0]
    i.e., N is normal to the hyperplane, and the unnormalized
        distance to [0 .. 1] is either 1 or   0

  design:
    perform gaussian elimination
    flip sign for negative values
    perform back substitution
    normalize result
    compute offset
*/
void qh_sethyperplane_gauss(qhT *qh, int dim, coordT **rows, pointT *point0,
                boolT toporient, coordT *normal, coordT *offset, boolT *nearzero) {
  coordT *pointcoord, *normalcoef;
  int k;
  boolT sign= toporient, nearzero2= False;

  qh_gausselim(qh, rows, dim-1, dim, &sign, nearzero);
  for (k=dim-1; k--; ) {
    if ((rows[k])[k] < 0)
      sign ^= 1;
  }
  if (*nearzero) {
    zzinc_(Znearlysingular);
    /* qh_joggle_restart ignored for Znearlysingular, normal part of qh_sethyperplane_gauss */
    trace0((qh, qh->ferr, 4, "qh_sethyperplane_gauss: nearly singular or axis parallel hyperplane during p%d.\n", qh->furthest_id));
    qh_backnormal(qh, rows, dim-1, dim, sign, normal, &nearzero2);
  }else {
    qh_backnormal(qh, rows, dim-1, dim, sign, normal, &nearzero2);
    if (nearzero2) {
      zzinc_(Znearlysingular);
      trace0((qh, qh->ferr, 5, "qh_sethyperplane_gauss: singular or axis parallel hyperplane at normalization during p%d.\n", qh->furthest_id));
    }
  }
  if (nearzero2)
    *nearzero= True;
  qh_normalize2(qh, normal, dim, True, NULL, NULL);
  pointcoord= point0;
  normalcoef= normal;
  *offset= -(*pointcoord++ * *normalcoef++);
  for (k=dim-1; k--; )
    *offset -= *pointcoord++ * *normalcoef++;
} /* sethyperplane_gauss */



geometry/src/Rgeometry.h0000644000176200001440000000167014662314120015025 0ustar  liggesusers/* This file is included via Makevars in all C files */
#include 
#include 
#include 

/* The following fixes a problem R check has with stderr. I tried
   redefining as NULL to prevent output, but a FILE handle is needed
   by qh_new_qhull() due to a call to freopen() somewhere in the
   library. Qhull already defines a dummy stderr qh_FILEstderr in
   libqhull_r.h */
#undef stderr
#define stderr qh_FILEstderr

/* PI has been defined by the R header files, but the Qhull package
   defines it again, so undefine it here. */
#undef PI

/* Size of error string to pass back to R from QH */
#define ERRSTRSIZE 1000

#include "qhull_ra.h"

void freeQhull(qhT *qh);
void qhullFinalizer(SEXP ptr);
boolT hasPrintOption(qhT *qh, qh_PRINT format);
int qhullNewQhull(qhT *qh, const SEXP p, char* cmd, const SEXP options, const SEXP tmp_stdout, const SEXP tmp_stderr, unsigned int* pdim, unsigned int* pn, char errstr[1000]);
geometry/src/QuadTree.cpp0000644000176200001440000001355314664422665015140 0ustar  liggesusers/*
  This program is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by the
  Free Software Foundation; either version 3 of the License, or (at your
  option) any later version.
  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  for more details.
  You should have received a copy of the GNU General Public License
  along with this program. If not, see  .
*/

// Originally written for package lidR by Jean-Romain Roussel
// Author: Jean-Romain Roussel
// 3 may 2017: copy from package lidR to package geometry by Jean-Romain Roussel to operate in fast tsearch funtion

#include "QuadTree.h"
#include 
#include 

Point::Point(){}
Point::Point(const double x, const double y) : x(x), y(y), id(0) {}
Point::Point(const double x, const double y, const int id) : x(x), y(y), id(id) {}

BoundingBox::BoundingBox(){}
BoundingBox::BoundingBox(const Point center, const Point half_res) : center(center), half_res(half_res) {}

bool BoundingBox::contains(const Point& p, const double eps)
{
  if(p.x >= center.x - half_res.x - eps &&
     p.x <= center.x + half_res.x + eps &&
     p.y >= center.y - half_res.y - eps &&
     p.y <= center.y + half_res.y + eps)
    return true;
  else
    return false;
}

bool BoundingBox::intersects(const BoundingBox& b)
{

  if(center.x - half_res.x <= b.center.x + b.half_res.x &&
     center.x + half_res.x >= b.center.x - b.half_res.x &&
     center.y - half_res.y <= b.center.y + b.half_res.y &&
     center.y + half_res.y >= b.center.y - b.half_res.y)
  {
    return true;
  }
  else
    return false;
}

QuadTree::QuadTree(const BoundingBox boundary, const int parent_depth, const double eps)
{
  MAX_DEPTH = 6;
  EPSILON = eps;

  depth = parent_depth + 1;
  this->boundary = boundary;

  NE = 0;
  NW = 0;
  SE = 0;
  SW = 0;
}

QuadTree::~QuadTree()
{
  delete NE;
  delete NW;
  delete SE;
  delete SW;
}

QuadTree* QuadTree::create(const std::vector& x, const std::vector& y, const double eps = 1.0e-12)
{
  int n = x.size();

  double xmin = x[0];
  double ymin = y[0];
  double xmax = x[0];
  double ymax = y[0];

  for(int i = 0 ; i < n ; i++)
  {
    if(x[i] < xmin)
      xmin = x[i];
    else if(x[i] > xmax)
      xmax = x[i];

    if(y[i] < ymin)
      ymin = y[i];
    else if(y[i] > ymax)
      ymax = y[i];
  }

  double xrange = xmax - xmin;
  double yrange = ymax - ymin;
  double range = xrange > yrange ? xrange/2 : yrange/2;

  Point bcenter((xmin+xmax)/2, (ymin+ymax)/2);
  Point brange(range, range);
  BoundingBox bbox(bcenter, brange);

  QuadTree *tree = new QuadTree(bbox, 0, eps);

  for(int i = 0 ; i < n ; i++)
  {
    Point p(x[i], y[i], i);

    if (!tree->insert(p))
    {
      delete tree;
      return nullptr;
    }
  }

  return tree;
}

bool QuadTree::insert(const Point& p)
{
  if(!boundary.contains(p, EPSILON))
    return false;

  if(depth == MAX_DEPTH)
  {
    points.push_back(p);
    return true;
  }

  if(NW == 0)
    subdivide();

  if(NW->insert(p))
    return true;
  if(NE->insert(p))
    return true;
  if(SW->insert(p))
    return true;
  if(SE->insert(p))
    return true;

  return false;
}

void QuadTree::subdivide()
{
  double half_res_half = boundary.half_res.x * 0.5;

  Point p(half_res_half, half_res_half);
  Point pNE(boundary.center.x + half_res_half, boundary.center.y + half_res_half);
  Point pNW(boundary.center.x - half_res_half, boundary.center.y + half_res_half);
  Point pSE(boundary.center.x + half_res_half, boundary.center.y - half_res_half);
  Point pSW(boundary.center.x - half_res_half, boundary.center.y - half_res_half);

  NE = new QuadTree(BoundingBox(pNE, p), depth, EPSILON);
  NW = new QuadTree(BoundingBox(pNW, p), depth, EPSILON);
  SE = new QuadTree(BoundingBox(pSE, p), depth, EPSILON);
  SW = new QuadTree(BoundingBox(pSW, p), depth, EPSILON);
}

void QuadTree::range_lookup(const BoundingBox bb, std::vector& res, const int method)
{
  if(!boundary.intersects(bb))
    return;

  if(depth == MAX_DEPTH)
  {
    switch(method)
    {
    case 1: getPointsSquare(bb, points, res);
      break;

    case 2: getPointsCircle(bb, points, res);
      break;
    }
  }

  if(NW == 0)
    return;

  NE->range_lookup(bb, res, method);
  NW->range_lookup(bb, res, method);
  SE->range_lookup(bb, res, method);
  SW->range_lookup(bb, res, method);

  return;
}

void QuadTree::rect_lookup(const double xc, const double yc, const double half_width, const double half_height, std::vector& res)
{
  range_lookup(BoundingBox(Point(xc, yc), Point(half_width, half_height)), res, 1);
  return;
}


void QuadTree::circle_lookup(const double cx, const double cy, const double range, std::vector& res)
{
  range_lookup(BoundingBox(Point(cx, cy), Point(range, range)), res, 2);
  return;
}

void QuadTree::getPointsSquare(const BoundingBox bb, std::vector& points, std::vector& res)
{
  for(std::vector::iterator it = points.begin(); it != points.end(); it++)
  {
    if(in_rect(bb, *it))
      res.push_back(&(*it));
  }
  return;
}

void QuadTree::getPointsCircle(const BoundingBox bb, std::vector& points, std::vector& res)
{
  for(std::vector::iterator it = points.begin(); it != points.end(); it++)
  {
    if(in_circle(bb.center, (*it), bb.half_res.x))
      res.push_back(&(*it));
  }
  return;
}

bool QuadTree::in_circle(const Point& p1, const Point& p2, const double r)
{
  double A = p1.x - p2.x;
  double B = p1.y - p2.y;
  double d = sqrt(A*A + B*B);

  return(d <= r);
}

bool QuadTree::in_rect(const BoundingBox& bb, const Point& p)
{
  double A = bb.center.x - p.x;
  double B = bb.center.y - p.y;
  A = A < 0 ? -A : A;
  B = B < 0 ? -B : B;

  return(A <= bb.half_res.x && B <= bb.half_res.y);
}
geometry/src/random_r.c0000644000176200001440000001470314664417655014670 0ustar  liggesusers/*
  ---------------------------------

   random_r.c and utilities
     Park & Miller's minimimal standard random number generator
     argc/argv conversion

     Used by rbox.  Do not use 'qh' 
*/

#include "libqhull_r.h"
#include "random_r.h"

#include 
#include 
#include 

#ifdef _MSC_VER  /* Microsoft Visual C++ -- warning level 4 */
#pragma warning( disable : 4706)  /* assignment within conditional function */
#pragma warning( disable : 4996)  /* function was declared deprecated(strcpy, localtime, etc.) */
#endif

/*---------------------------------

  qh_argv_to_command( argc, argv, command, max_size )

    build command from argc/argv
    max_size is at least

  returns:
    a space-delimited string of options (just as typed)
    returns false if max_size is too short

  notes:
    silently removes
    makes option string easy to input and output
    matches qh_argv_to_command_size
    argc may be 0
*/
int qh_argv_to_command(int argc, char *argv[], char* command, int max_size) {
  int i, remaining;
  char *s;
  *command= '\0';  /* max_size > 0 */

  if (argc) {
    if ((s= strrchr( argv[0], '\\')) /* get filename w/o .exe extension */
    || (s= strrchr( argv[0], '/')))
        s++;
    else
        s= argv[0];
    if ((int)strlen(s) < max_size)   /* WARN64 */
        strcpy(command, s);
    else
        goto error_argv;
    if ((s= strstr(command, ".EXE"))
    ||  (s= strstr(command, ".exe")))
        *s= '\0';
  }
  for (i=1; i < argc; i++) {
    s= argv[i];
    remaining= max_size - (int)strlen(command) - (int)strlen(s) - 2;   /* WARN64 */
    if (!*s || strchr(s, ' ')) {
      char *t= command + strlen(command);
      remaining -= 2;
      if (remaining < 0) {
        goto error_argv;
      }
      *t++= ' ';
      *t++= '"';
      while (*s) {
        if (*s == '"') {
          if (--remaining < 0)
            goto error_argv;
          *t++= '\\';
        }
        *t++= *s++;
      }
      *t++= '"';
      *t= '\0';
    }else if (remaining < 0) {
      goto error_argv;
    }else {
      strcat(command, " ");
      strcat(command, s);
    }
  }
  return 1;

error_argv:
  return 0;
} /* argv_to_command */

/*---------------------------------

  qh_argv_to_command_size( argc, argv )

    return size to allocate for qh_argv_to_command()

  notes:
    only called from rbox with qh_errexit not enabled
    caller should report error if returned size is less than 1
    argc may be 0
    actual size is usually shorter
*/
int qh_argv_to_command_size(int argc, char *argv[]) {
    int count= 1; /* null-terminator if argc==0 */
    int i;
    char *s;

    for (i=0; i0 && strchr(argv[i], ' ')) {
        count += 2;  /* quote delimiters */
        for (s=argv[i]; *s; s++) {
          if (*s == '"') {
            count++;
          }
        }
      }
    }
    return count;
} /* argv_to_command_size */

/*---------------------------------

  qh_rand()
  qh_srand(qh, seed )
    generate pseudo-random number between 1 and 2^31 -2

  notes:
    For qhull and rbox, called from qh_RANDOMint(),etc. [user_r.h]

    From Park & Miller's minimal standard random number generator
      Communications of the ACM, 31:1192-1201, 1988.
    Does not use 0 or 2^31 -1
      this is silently enforced by qh_srand()
    Can make 'Rn' much faster by moving qh_rand to qh_distplane
*/

/* Global variables and constants */

#define qh_rand_a 16807
#define qh_rand_m 2147483647
#define qh_rand_q 127773  /* m div a */
#define qh_rand_r 2836    /* m mod a */

int qh_rand(qhT *qh) {
    int lo, hi, test;
    int seed= qh->last_random;

    hi= seed / qh_rand_q;  /* seed div q */
    lo= seed % qh_rand_q;  /* seed mod q */
    test= qh_rand_a * lo - qh_rand_r * hi;
    if (test > 0)
        seed= test;
    else
        seed= test + qh_rand_m;
    qh->last_random= seed;
    /* seed= seed < qh_RANDOMmax/2 ? 0 : qh_RANDOMmax;  for testing */
    /* seed= qh_RANDOMmax;  for testing */
    return seed;
} /* rand */

void qh_srand(qhT *qh, int seed) {
    if (seed < 1)
        qh->last_random= 1;
    else if (seed >= qh_rand_m)
        qh->last_random= qh_rand_m - 1;
    else
        qh->last_random= seed;
} /* qh_srand */

/*---------------------------------

qh_randomfactor(qh, scale, offset )
  return a random factor r * scale + offset

notes:
  qh.RANDOMa/b are defined in global_r.c
  qh_RANDOMint requires 'qh'
*/
realT qh_randomfactor(qhT *qh, realT scale, realT offset) {
    realT randr;

    randr= qh_RANDOMint;
    return randr * scale + offset;
} /* randomfactor */

/*---------------------------------

  qh_randommatrix(qh, buffer, dim, rows )
    generate a random dim X dim matrix in range [-1,1]
    assumes buffer is [dim+1, dim]

  returns:
    sets buffer to random numbers
    sets rows to rows of buffer
    sets row[dim] as scratch row

  notes:
    qh_RANDOMint requires 'qh'
*/
void qh_randommatrix(qhT *qh, realT *buffer, int dim, realT **rows) {
    int i, k;
    realT **rowi, *coord, realr;

    coord= buffer;
    rowi= rows;
    for (i=0; i < dim; i++) {
        *(rowi++)= coord;
        for (k=0; k < dim; k++) {
            realr= qh_RANDOMint;
            *(coord++)= 2.0 * realr/(qh_RANDOMmax+1) - 1.0;
        }
    }
    *rowi= coord;
} /* randommatrix */

/*---------------------------------

  qh_strtol( s, endp) qh_strtod( s, endp)
    internal versions of strtol() and strtod()
    does not skip trailing spaces
  notes:
    some implementations of strtol()/strtod() skip trailing spaces
*/
double qh_strtod(const char *s, char **endp) {
  double result;

  result= strtod(s, endp);
  if (s < (*endp) && (*endp)[-1] == ' ')
    (*endp)--;
  return result;
} /* strtod */

int qh_strtol(const char *s, char **endp) {
  int result;

  result= (int) strtol(s, endp, 10);     /* WARN64 */
  if (s< (*endp) && (*endp)[-1] == ' ')
    (*endp)--;
  return result;
} /* strtol */
geometry/src/user_r.h0000644000176200001440000010744214664417655014376 0ustar  liggesusers/*
  ---------------------------------

   user_r.h
   user redefinable constants

   for each source file, user_r.h is included first

   see qh-user_r.htm.  see COPYING for copyright information.

   See user_r.c for sample code.

   before reading any code, review libqhull_r.h for data structure definitions

Sections:
   ============= qhull library constants ======================
   ============= data types and configuration macros ==========
   ============= performance related constants ================
   ============= memory constants =============================
   ============= joggle constants =============================
   ============= conditional compilation ======================
   ============= merge constants ==============================
   ============= Microsoft DevStudio ==========================

Code flags --
  NOerrors -- the code does not call qh_errexit()
  WARN64 -- the code may be incompatible with 64-bit pointers

*/

#include 
#include 
#include 

#ifndef qhDEFuser
#define qhDEFuser 1

/* Derived from Qt's corelib/global/qglobal.h */
#if !defined(SAG_COM) && !defined(__CYGWIN__) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
#   define QHULL_OS_WIN
#elif defined(__MWERKS__) && defined(__INTEL__) /* Metrowerks discontinued before the release of Intel Macs */
#   define QHULL_OS_WIN
#endif

/*============================================================*/
/*============= qhull library constants ======================*/
/*============================================================*/

/*----------------------------------

  FILENAMElen -- max length for TI and TO filenames

*/

#define qh_FILENAMElen 500

/*----------------------------------

  msgcode -- Unique message codes for qh_fprintf

  If add new messages, assign these values and increment in user.h and user_r.h
  See QhullError.h for 10000 error codes.
  Cannot use '0031' since it would be octal

  def counters =  [31/32/33/38, 1067, 2113, 3079, 4097, 5006,
     6429, 7027/7028/7035/7068/7070/7102, 8163, 9428, 10000, 11034]

  See: qh_ERR* [libqhull_r.h]
*/

#define MSG_TRACE0     0   /* always include if logging ('Tn') */
#define MSG_TRACE1  1000
#define MSG_TRACE2  2000
#define MSG_TRACE3  3000
#define MSG_TRACE4  4000
#define MSG_TRACE5  5000
#define MSG_ERROR   6000   /* errors written to qh.ferr */
#define MSG_WARNING 7000
#define MSG_STDERR  8000   /* log messages Written to qh.ferr */
#define MSG_OUTPUT  9000
#define MSG_QHULL_ERROR 10000 /* errors thrown by QhullError.cpp (QHULLlastError is in QhullError.h) */
#define MSG_FIX    11000   /* Document as 'QH11... FIX: ...' */
#define MSG_MAXLEN  3000   /* qh_printhelp_degenerate() in user_r.c */


/*----------------------------------

  qh_OPTIONline -- max length of an option line 'FO'
*/
#define qh_OPTIONline 80

/*============================================================*/
/*============= data types and configuration macros ==========*/
/*============================================================*/

/*----------------------------------

  realT
    set the size of floating point numbers

  qh_REALdigits
    maximimum number of significant digits

  qh_REAL_1, qh_REAL_2n, qh_REAL_3n
    format strings for printf

  qh_REALmax, qh_REALmin
    maximum and minimum (near zero) values

  qh_REALepsilon
    machine roundoff.  Maximum roundoff error for addition and multiplication.

  notes:
   Select whether to store floating point numbers in single precision (float)
   or double precision (double).

   Use 'float' to save about 8% in time and 25% in space.  This is particularly
   helpful if high-d where convex hulls are space limited.  Using 'float' also
   reduces the printed size of Qhull's output since numbers have 8 digits of
   precision.

   Use 'double' when greater arithmetic precision is needed.  This is needed
   for Delaunay triangulations and Voronoi diagrams when you are not merging
   facets.

   If 'double' gives insufficient precision, your data probably includes
   degeneracies.  If so you should use facet merging (done by default)
   or exact arithmetic (see imprecision section of manual, qh-impre.htm).
   You may also use option 'Po' to force output despite precision errors.

   You may use 'long double', but many format statements need to be changed
   and you may need a 'long double' square root routine.  S. Grundmann
   (sg@eeiwzb.et.tu-dresden.de) has done this.  He reports that the code runs
   much slower with little gain in precision.

   WARNING: on some machines,    int f(){realT a= REALmax;return (a == REALmax);}
      returns False.  Use (a > REALmax/2) instead of (a == REALmax).

   REALfloat =   1      all numbers are 'float' type
             =   0      all numbers are 'double' type
*/
#define REALfloat 0

#if (REALfloat == 1)
#define realT float
#define REALmax FLT_MAX
#define REALmin FLT_MIN
#define REALepsilon FLT_EPSILON
#define qh_REALdigits 8   /* maximum number of significant digits */
#define qh_REAL_1 "%6.8g "
#define qh_REAL_2n "%6.8g %6.8g\n"
#define qh_REAL_3n "%6.8g %6.8g %6.8g\n"

#elif (REALfloat == 0)
#define realT double
#define REALmax DBL_MAX
#define REALmin DBL_MIN
#define REALepsilon DBL_EPSILON
#define qh_REALdigits 16    /* maximum number of significant digits */
#define qh_REAL_1 "%6.16g "
#define qh_REAL_2n "%6.16g %6.16g\n"
#define qh_REAL_3n "%6.16g %6.16g %6.16g\n"

#else
#error unknown float option
#endif

/*----------------------------------

  countT
    The type for counts and identifiers (e.g., the number of points, vertex identifiers)
    Currently used by C++ code-only.  Decided against using it for setT because most sets are small.

    Defined as 'int' for C-code compatibility and QH11026

    QH11026 FIX: countT may be defined as a 'unsigned int', but several code issues need to be solved first.  See countT in Changes.txt
*/

#ifndef DEFcountT
#define DEFcountT 1
typedef int countT;
#endif
#define COUNTmax INT_MAX

/*----------------------------------

  qh_POINTSmax
    Maximum number of points for qh.num_points and point allocation in qh_readpoints
*/
#define qh_POINTSmax (INT_MAX-16)

/*----------------------------------

  qh_CPUclock
    define the clock() function for reporting the total time spent by Qhull
    returns CPU ticks as a 'long int'
    qh_CPUclock is only used for reporting the total time spent by Qhull

  qh_SECticks
    the number of clock ticks per second

  notes:
    looks for CLOCKS_PER_SEC, CLOCKS_PER_SECOND, or assumes microseconds
    to define a custom clock, set qh_CLOCKtype to 0

    if your system does not use clock() to return CPU ticks, replace
    qh_CPUclock with the corresponding function.  It is converted
    to 'unsigned long' to prevent wrap-around during long runs.  By default,
     defines clock_t as 'long'

   Set qh_CLOCKtype to

     1          for CLOCKS_PER_SEC, CLOCKS_PER_SECOND, or microsecond
                Note:  may fail if more than 1 hour elapsed time

     2          use qh_clock() with POSIX times() (see global_r.c)
*/
#define qh_CLOCKtype 1  /* change to the desired number */

#if (qh_CLOCKtype == 1)

#if defined(CLOCKS_PER_SECOND)
#define qh_CPUclock    ((unsigned long)clock())  /* return CPU clock, may be converted to approximate double */
#define qh_SECticks CLOCKS_PER_SECOND

#elif defined(CLOCKS_PER_SEC)
#define qh_CPUclock    ((unsigned long)clock())  /* return CPU clock, may be converted to approximate double */
#define qh_SECticks CLOCKS_PER_SEC

#elif defined(CLK_TCK)
#define qh_CPUclock    ((unsigned long)clock())  /* return CPU clock, may be converted to approximate double */
#define qh_SECticks CLK_TCK

#else
#define qh_CPUclock    ((unsigned long)clock())  /* return CPU clock, may be converted to approximate double */
#define qh_SECticks 1E6
#endif

#elif (qh_CLOCKtype == 2)
#define qh_CPUclock    qh_clock()  /* return CPU clock, may be converted to approximate double */
#define qh_SECticks 100

#else /* qh_CLOCKtype == ? */
#error unknown clock option
#endif

/*----------------------------------

  qh_RANDOMtype, qh_RANDOMmax, qh_RANDOMseed
    define random number generator

    qh_RANDOMint generates a random integer between 0 and qh_RANDOMmax.
    qh_RANDOMseed sets the random number seed for qh_RANDOMint

  Set qh_RANDOMtype (default 5) to:
    1       for random() with 31 bits (UCB)
    2       for rand() with RAND_MAX or 15 bits (system 5)
    3       for rand() with 31 bits (Sun)
    4       for lrand48() with 31 bits (Solaris)
    5       for qh_rand(qh) with 31 bits (included with Qhull, requires 'qh')

  notes:
    Random numbers are used by rbox to generate point sets.  Random
    numbers are used by Qhull to rotate the input ('QRn' option),
    simulate a randomized algorithm ('Qr' option), and to simulate
    roundoff errors ('Rn' option).

    Random number generators differ between systems.  Most systems provide
    rand() but the period varies.  The period of rand() is not critical
    since qhull does not normally use random numbers.

    The default generator is Park & Miller's minimal standard random
    number generator [CACM 31:1195 '88].  It is included with Qhull.

    If qh_RANDOMmax is wrong, qhull will report a warning and Geomview
    output will likely be invisible.
*/
#define qh_RANDOMtype 5   /* *** change to the desired number *** */

#if (qh_RANDOMtype == 1)
#define qh_RANDOMmax ((realT)0x7fffffffUL)  /* 31 bits, random()/MAX */
#define qh_RANDOMint random()
#define qh_RANDOMseed_(qh, seed) srandom(seed);

#elif (qh_RANDOMtype == 2)
#ifdef RAND_MAX
#define qh_RANDOMmax ((realT)RAND_MAX)
#else
#define qh_RANDOMmax ((realT)32767)   /* 15 bits (System 5) */
#endif
#define qh_RANDOMint  rand()
#define qh_RANDOMseed_(qh, seed) srand((unsigned int)seed);

#elif (qh_RANDOMtype == 3)
#define qh_RANDOMmax ((realT)0x7fffffffUL)  /* 31 bits, Sun */
#define qh_RANDOMint  rand()
#define qh_RANDOMseed_(qh, seed) srand((unsigned int)seed);

#elif (qh_RANDOMtype == 4)
#define qh_RANDOMmax ((realT)0x7fffffffUL)  /* 31 bits, lrand38()/MAX */
#define qh_RANDOMint lrand48()
#define qh_RANDOMseed_(qh, seed) srand48(seed);

#elif (qh_RANDOMtype == 5)  /* 'qh' is an implicit parameter */
#define qh_RANDOMmax ((realT)2147483646UL)  /* 31 bits, qh_rand/MAX */
#define qh_RANDOMint qh_rand(qh)
#define qh_RANDOMseed_(qh, seed) qh_srand(qh, seed);
/* unlike rand(), never returns 0 */

#else
#error: unknown random option
#endif

/*----------------------------------

  qh_ORIENTclock
    0 for inward pointing normals by Geomview convention
*/
#define qh_ORIENTclock 0

/*----------------------------------

  qh_RANDOMdist
    define for random perturbation of qh_distplane and qh_setfacetplane (qh.RANDOMdist, 'QRn')

  For testing qh.DISTround.  Qhull should not depend on computations always producing the same roundoff error 

  #define qh_RANDOMdist 1e-13
*/

/*============================================================*/
/*============= joggle constants =============================*/
/*============================================================*/

/*----------------------------------

  qh_JOGGLEdefault
    default qh.JOGGLEmax is qh.DISTround * qh_JOGGLEdefault

  notes:
    rbox s r 100 | qhull QJ1e-15 QR0 generates 90% faults at distround 7e-16
    rbox s r 100 | qhull QJ1e-14 QR0 generates 70% faults
    rbox s r 100 | qhull QJ1e-13 QR0 generates 35% faults
    rbox s r 100 | qhull QJ1e-12 QR0 generates 8% faults
    rbox s r 100 | qhull QJ1e-11 QR0 generates 1% faults
    rbox s r 100 | qhull QJ1e-10 QR0 generates 0% faults
    rbox 1000 W0 | qhull QJ1e-12 QR0 generates 86% faults
    rbox 1000 W0 | qhull QJ1e-11 QR0 generates 20% faults
    rbox 1000 W0 | qhull QJ1e-10 QR0 generates 2% faults
    the later have about 20 points per facet, each of which may interfere

    pick a value large enough to avoid retries on most inputs
*/
#define qh_JOGGLEdefault 30000.0

/*----------------------------------

  qh_JOGGLEincrease
    factor to increase qh.JOGGLEmax on qh_JOGGLEretry or qh_JOGGLEagain
*/
#define qh_JOGGLEincrease 10.0

/*----------------------------------

  qh_JOGGLEretry
    if ZZretry = qh_JOGGLEretry, increase qh.JOGGLEmax

notes:
try twice at the original value in case of bad luck the first time
*/
#define qh_JOGGLEretry 2

/*----------------------------------

  qh_JOGGLEagain
    every following qh_JOGGLEagain, increase qh.JOGGLEmax

  notes:
    1 is OK since it's already failed qh_JOGGLEretry times
*/
#define qh_JOGGLEagain 1

/*----------------------------------

  qh_JOGGLEmaxincrease
    maximum qh.JOGGLEmax due to qh_JOGGLEincrease
    relative to qh.MAXwidth

  notes:
    qh.joggleinput will retry at this value until qh_JOGGLEmaxretry
*/
#define qh_JOGGLEmaxincrease 1e-2

/*----------------------------------

  qh_JOGGLEmaxretry
    stop after qh_JOGGLEmaxretry attempts
*/
#define qh_JOGGLEmaxretry 50

/*============================================================*/
/*============= performance related constants ================*/
/*============================================================*/

/*----------------------------------

  qh_HASHfactor
    total hash slots / used hash slots.  Must be at least 1.1.

  notes:
    =2 for at worst 50% occupancy for qh.hash_table and normally 25% occupancy
*/
#define qh_HASHfactor 2

/*----------------------------------

  qh_VERIFYdirect
    with 'Tv' verify all points against all facets if op count is smaller

  notes:
    if greater, calls qh_check_bestdist() instead
*/
#define qh_VERIFYdirect 1000000

/*----------------------------------

  qh_INITIALsearch
     if qh_INITIALmax, search points up to this dimension
*/
#define qh_INITIALsearch 6

/*----------------------------------

  qh_INITIALmax
    if dim >= qh_INITIALmax, use min/max coordinate points for initial simplex

  notes:
    from points with non-zero determinants
    use option 'Qs' to override (much slower)
*/
#define qh_INITIALmax 8

/*============================================================*/
/*============= memory constants =============================*/
/*============================================================*/

/*----------------------------------

  qh_MEMalign
    memory alignment for qh_meminitbuffers() in global_r.c

  notes:
    to avoid bus errors, memory allocation must consider alignment requirements.
    malloc() automatically takes care of alignment.   Since mem_r.c manages
    its own memory, we need to explicitly specify alignment in
    qh_meminitbuffers().

    A safe choice is sizeof(double).  sizeof(float) may be used if doubles
    do not occur in data structures and pointers are the same size.  Be careful
    of machines (e.g., DEC Alpha) with large pointers.

    If using gcc, best alignment is [fmax_() is defined in geom_r.h]
              #define qh_MEMalign fmax_(__alignof__(realT),__alignof__(void *))
*/
#define qh_MEMalign ((int)(fmax_(sizeof(realT), sizeof(void *))))

/*----------------------------------

  qh_MEMbufsize
    size of additional memory buffers

  notes:
    used for qh_meminitbuffers() in global_r.c
*/
#define qh_MEMbufsize 0x10000       /* allocate 64K memory buffers */

/*----------------------------------

  qh_MEMinitbuf
    size of initial memory buffer

  notes:
    use for qh_meminitbuffers() in global_r.c
*/
#define qh_MEMinitbuf 0x20000      /* initially allocate 128K buffer */

/*----------------------------------

  qh_INFINITE
    on output, indicates Voronoi center at infinity
*/
#define qh_INFINITE  -10.101

/*----------------------------------

  qh_DEFAULTbox
    default box size (Geomview expects 0.5)

  qh_DEFAULTbox
    default box size for integer coorindate (rbox only)
*/
#define qh_DEFAULTbox 0.5
#define qh_DEFAULTzbox 1e6

/*============================================================*/
/*============= conditional compilation ======================*/
/*============================================================*/

/*----------------------------------

  __cplusplus
    defined by C++ compilers

  __MSC_VER
    defined by Microsoft Visual C++

  __MWERKS__ && __INTEL__
    defined by Metrowerks when compiling for Windows (not Intel-based Macintosh)

  __MWERKS__ && __POWERPC__
    defined by Metrowerks when compiling for PowerPC-based Macintosh

  __STDC__
    defined for strict ANSI C
*/

/*----------------------------------

  qh_COMPUTEfurthest
    compute furthest distance to an outside point instead of storing it with the facet
    =1 to compute furthest

  notes:
    computing furthest saves memory but costs time
      about 40% more distance tests for partitioning
      removes facet->furthestdist
*/
#define qh_COMPUTEfurthest 0

/*----------------------------------

  qh_KEEPstatistics
    =0 removes most of statistic gathering and reporting

  notes:
    if 0, code size is reduced by about 4%.
*/
#define qh_KEEPstatistics 1

/*----------------------------------

  qh_MAXoutside
    record outer plane for each facet
    =1 to record facet->maxoutside

  notes:
    this takes a realT per facet and slightly slows down qhull
    it produces better outer planes for geomview output
*/
#define qh_MAXoutside 1

/*----------------------------------

  qh_NOmerge
    disables facet merging if defined
    For MSVC compiles, use qhull_r-exports-nomerge.def instead of qhull_r-exports.def

  notes:
    This saves about 25% space, 30% space in combination with qh_NOtrace, 
    and 36% with qh_NOtrace and qh_KEEPstatistics 0

    Unless option 'Q0' is used
      qh_NOmerge sets 'QJ' to avoid precision errors

  see:
    qh_NOmem in mem_r.h

    see user_r.c/user_eg.c for removing io_r.o

  #define qh_NOmerge
*/

/*----------------------------------

  qh_NOtrace
    no tracing if defined
    disables 'Tn', 'TMn', 'TPn' and 'TWn'
    override with 'Qw' for qh_addpoint tracing and various other items

  notes:
    This saves about 15% space.
    Removes all traceN((...)) code and substantial sections of qh.IStracing code

  #define qh_NOtrace
*/

#if 0  /* sample code */
    exitcode= qh_new_qhull(qhT *qh, dim, numpoints, points, ismalloc,
                      flags, outfile, errfile);
    qh_freeqhull(qhT *qh, !qh_ALL); /* frees long memory used by second call */
    qh_memfreeshort(qhT *qh, &curlong, &totlong);  /* frees short memory and memory allocator */
#endif

/*----------------------------------

  qh_QUICKhelp
    =1 to use abbreviated help messages, e.g., for degenerate inputs
*/
#define qh_QUICKhelp    0

/*============================================================*/
/*============= merge constants ==============================*/
/*============================================================*/
/*
   These constants effect facet merging.  You probably will not need
   to modify them.  They effect the performance of facet merging.
*/

/*----------------------------------

  qh_BESTcentrum
     if > 2*dim+n vertices, qh_findbestneighbor() tests centrums (faster)
     else, qh_findbestneighbor() tests all vertices (much better merges)

  qh_BESTcentrum2
     if qh_BESTcentrum2 * DIM3 + BESTcentrum < #vertices tests centrums
*/
#define qh_BESTcentrum 20
#define qh_BESTcentrum2 2

/*----------------------------------

  qh_BESTnonconvex
    if > dim+n neighbors, qh_findbestneighbor() tests nonconvex ridges.

  notes:
    It is needed because qh_findbestneighbor is slow for large facets
*/
#define qh_BESTnonconvex 15

/*----------------------------------

  qh_COPLANARratio
    for 3-d+ merging, qh.MINvisible is n*premerge_centrum

  notes:
    for non-merging, it's DISTround
*/
#define qh_COPLANARratio 3

/*----------------------------------

  qh_DIMmergeVertex
    max dimension for vertex merging (it is not effective in high-d)
*/
#define qh_DIMmergeVertex 6

/*----------------------------------

  qh_DIMreduceBuild
     max dimension for vertex reduction during build (slow in high-d)
*/
#define qh_DIMreduceBuild 5

/*----------------------------------

  qh_DISToutside
    When is a point clearly outside of a facet?
    Stops search in qh_findbestnew or qh_partitionall
    qh_findbest uses qh.MINoutside since since it is only called if no merges.

  notes:
    'Qf' always searches for best facet
    if !qh.MERGING, same as qh.MINoutside.
    if qh_USEfindbestnew, increase value since neighboring facets may be ill-behaved
      [Note: Zdelvertextot occurs normally with interior points]
            RBOX 1000 s Z1 G1e-13 t1001188774 | QHULL Tv
    When there is a sharp edge, need to move points to a
    clearly good facet; otherwise may be lost in another partitioning.
    if too big then O(n^2) behavior for partitioning in cone
    if very small then important points not processed
    Needed in qh_partitionall for
      RBOX 1000 s Z1 G1e-13 t1001032651 | QHULL Tv
    Needed in qh_findbestnew for many instances of
      RBOX 1000 s Z1 G1e-13 t | QHULL Tv

  See:
    qh_DISToutside -- when is a point clearly outside of a facet
    qh_SEARCHdist -- when is facet coplanar with the best facet?
    qh_USEfindbestnew -- when to use qh_findbestnew for qh_partitionpoint()
*/
#define qh_DISToutside ((qh_USEfindbestnew ? 2 : 1) * \
     fmax_((qh->MERGING ? 2 : 1)*qh->MINoutside, qh->max_outside))

/*----------------------------------

  qh_MAXcheckpoint
    Report up to qh_MAXcheckpoint errors per facet in qh_check_point ('Tv')
*/
#define qh_MAXcheckpoint 10

/*----------------------------------

  qh_MAXcoplanarcentrum
    if pre-merging with qh.MERGEexact ('Qx') and f.nummerge > qh_MAXcoplanarcentrum
      use f.maxoutside instead of qh.centrum_radius for coplanarity testing

  notes:
    see qh_test_nonsimplicial_merges
    with qh.MERGEexact, a coplanar ridge is ignored until post-merging
    otherwise a large facet with many merges may take all the facets
*/
#define qh_MAXcoplanarcentrum 10

/*----------------------------------

  qh_MAXnewcentrum
    if <= dim+n vertices (n approximates the number of merges),
      reset the centrum in qh_updatetested() and qh_mergecycle_facets()

  notes:
    needed to reduce cost and because centrums may move too much if
    many vertices in high-d
*/
#define qh_MAXnewcentrum 5

/*----------------------------------

  qh_MAXnewmerges
    if >n newmerges, qh_merge_nonconvex() calls qh_reducevertices_centrums.

  notes:
    It is needed because postmerge can merge many facets at once
*/
#define qh_MAXnewmerges 2

/*----------------------------------

  qh_RATIOconcavehorizon
    ratio of horizon vertex distance to max_outside for concave, twisted new facets in qh_test_nonsimplicial_merge
    if too small, end up with vertices far below merged facets
*/
#define qh_RATIOconcavehorizon 20.0

/*----------------------------------

  qh_RATIOconvexmerge
    ratio of vertex distance to qh.min_vertex for clearly convex new facets in qh_test_nonsimplicial_merge

  notes:
    must be convex for MRGtwisted
*/
#define qh_RATIOconvexmerge 10.0

/*----------------------------------

  qh_RATIOcoplanarapex
    ratio of best distance for coplanar apex vs. vertex merge in qh_getpinchedmerges

  notes:
    A coplanar apex always works, while a vertex merge may fail
*/
#define qh_RATIOcoplanarapex 3.0

/*----------------------------------

  qh_RATIOcoplanaroutside
    qh.MAXoutside ratio to repartition a coplanar point in qh_partitioncoplanar and qh_check_maxout

  notes:
    combines several tests, see qh_partitioncoplanar

*/
#define qh_RATIOcoplanaroutside 30.0

/*----------------------------------

  qh_RATIOmaxsimplex
    ratio of max determinate to estimated determinate for searching all points in qh_maxsimplex

  notes:
    As each point is added to the simplex, the max determinate is should approximate the previous determinate * qh.MAXwidth
    If maxdet is significantly less, the simplex may not be full-dimensional.
    If so, all points are searched, stopping at 10 times qh_RATIOmaxsimplex
*/
#define qh_RATIOmaxsimplex 1.0e-3

/*----------------------------------

  qh_RATIOnearinside
    ratio of qh.NEARinside to qh.ONEmerge for retaining inside points for
    qh_check_maxout().

  notes:
    This is overkill since do not know the correct value.
    It effects whether 'Qc' reports all coplanar points
    Not used for 'd' since non-extreme points are coplanar, nearly incident points
*/
#define qh_RATIOnearinside 5

/*----------------------------------

  qh_RATIOpinchedsubridge
    ratio to qh.ONEmerge to accept vertices in qh_findbest_pinchedvertex
    skips search of neighboring vertices
    facet width may increase by this ratio
*/
#define qh_RATIOpinchedsubridge 10.0

/*----------------------------------

  qh_RATIOtrypinched
    ratio to qh.ONEmerge to try qh_getpinchedmerges in qh_buildcone_mergepinched
    otherwise a duplicate ridge will increase facet width by this amount
*/
#define qh_RATIOtrypinched 4.0

/*----------------------------------

  qh_RATIOtwisted
    maximum ratio to qh.ONEmerge to merge twisted facets in qh_merge_twisted
*/
#define qh_RATIOtwisted 20.0

/*----------------------------------

  qh_SEARCHdist
    When is a facet coplanar with the best facet?
    qh_findbesthorizon: all coplanar facets of the best facet need to be searched.
        increases minsearch if ischeckmax and more than 100 neighbors (is_5x_minsearch)
  See:
    qh_DISToutside -- when is a point clearly outside of a facet
    qh_SEARCHdist -- when is facet coplanar with the best facet?
    qh_USEfindbestnew -- when to use qh_findbestnew for qh_partitionpoint()
*/
#define qh_SEARCHdist ((qh_USEfindbestnew ? 2 : 1) * \
      (qh->max_outside + 2 * qh->DISTround + fmax_( qh->MINvisible, qh->MAXcoplanar)));

/*----------------------------------

  qh_USEfindbestnew
     Always use qh_findbestnew for qh_partitionpoint, otherwise use
     qh_findbestnew if merged new facet or sharpnewfacets.

  See:
    qh_DISToutside -- when is a point clearly outside of a facet
    qh_SEARCHdist -- when is facet coplanar with the best facet?
    qh_USEfindbestnew -- when to use qh_findbestnew for qh_partitionpoint()
*/
#define qh_USEfindbestnew (zzval_(Ztotmerge) > 50)

/*----------------------------------

  qh_MAXnarrow
    max. cosine in initial hull that sets qh.NARROWhull

  notes:
    If qh.NARROWhull, the initial partition does not make
    coplanar points.  If narrow, a coplanar point can be
    coplanar to two facets of opposite orientations and
    distant from the exact convex hull.

    Conservative estimate.  Don't actually see problems until it is -1.0
*/
#define qh_MAXnarrow -0.99999999

/*----------------------------------

  qh_WARNnarrow
    max. cosine in initial hull to warn about qh.NARROWhull

  notes:
    this is a conservative estimate.
    Don't actually see problems until it is -1.0.  See qh-impre.htm
*/
#define qh_WARNnarrow -0.999999999999999

/*----------------------------------

  qh_WIDEcoplanar
    n*MAXcoplanar or n*MINvisible for a WIDEfacet

    if vertex is further than qh.WIDEfacet from the hyperplane
    then its ridges are not counted in computing the area, and
    the facet's centrum is frozen.

  notes:
    qh.WIDEfacet= max(qh.MAXoutside,qh_WIDEcoplanar*qh.MAXcoplanar,
    qh_WIDEcoplanar * qh.MINvisible);
*/
#define qh_WIDEcoplanar 6

/*----------------------------------

  qh_WIDEduplicate
    merge ratio for errexit from qh_forcedmerges due to duplicate ridge
    Override with option Q12-allow-wide

  Notes:
    Merging a duplicate ridge can lead to very wide facets.
*/
#define qh_WIDEduplicate 100

/*----------------------------------

  qh_WIDEdupridge
    Merge ratio for selecting a forced dupridge merge

  Notes:
    Merging a dupridge can lead to very wide facets.
*/
#define qh_WIDEdupridge 50

/*----------------------------------

  qh_WIDEmaxoutside
    Precision ratio for maximum increase for qh.max_outside in qh_check_maxout
    Precision errors while constructing the hull, may lead to very wide facets when checked in qh_check_maxout
    Nearly incident points in 4-d and higher is the most likely culprit
    Skip qh_check_maxout with 'Q5' (no-check-outer)
    Do not error with option 'Q12' (allow-wide)
    Do not warn with options 'Q12 Pp'
*/
#define qh_WIDEmaxoutside 100

/*----------------------------------

  qh_WIDEmaxoutside2
    Precision ratio for maximum qh.max_outside in qh_check_maxout
    Skip qh_check_maxout with 'Q5' no-check-outer
    Do not error with option 'Q12' allow-wide
*/
#define qh_WIDEmaxoutside2 (10*qh_WIDEmaxoutside)


/*----------------------------------

  qh_WIDEpinched
    Merge ratio for distance between pinched vertices compared to current facet width for qh_getpinchedmerges and qh_next_vertexmerge
    Reports warning and merges duplicate ridges instead
    Enable these attempts with option Q14 merge-pinched-vertices

  notes:
    Merging pinched vertices should prevent duplicate ridges (see qh_WIDEduplicate)
    Merging the duplicate ridges may be better than merging the pinched vertices
    Found up to 45x ratio for qh_pointdist -- for ((i=1; i<20; i++)); do rbox 175 C1,6e-13 t | qhull d T4 2>&1 | tee x.1 | grep  -E 'QH|non-simplicial|Statis|pinched'; done
    Actual distance to facets is a third to a tenth of the qh_pointdist (T1)
*/
#define qh_WIDEpinched 100

/*----------------------------------

  qh_ZEROdelaunay
    a zero Delaunay facet occurs for input sites coplanar with their convex hull
    the last normal coefficient of a zero Delaunay facet is within
        qh_ZEROdelaunay * qh.ANGLEround of 0

  notes:
    qh_ZEROdelaunay does not allow for joggled input ('QJ').

    You can avoid zero Delaunay facets by surrounding the input with a box.

    Use option 'PDk:-n' to explicitly define zero Delaunay facets
      k= dimension of input sites (e.g., 3 for 3-d Delaunay triangulation)
      n= the cutoff for zero Delaunay facets (e.g., 'PD3:-1e-12')
*/
#define qh_ZEROdelaunay 2

/*============================================================*/
/*============= Microsoft DevStudio ==========================*/
/*============================================================*/

/*
   Finding Memory Leaks Using the CRT Library
   https://msdn.microsoft.com/en-us/library/x98tx3cf(v=vs.100).aspx

   Reports enabled in qh_lib_check for Debug window and stderr

   From 2005=>msvcr80d, 2010=>msvcr100d, 2012=>msvcr110d

   Watch: {,,msvcr80d.dll}_crtBreakAlloc  Value from {n} in the leak report
   _CrtSetBreakAlloc(689); // qh_lib_check() [global_r.c]

   Examples
     http://free-cad.sourceforge.net/SrcDocu/d2/d7f/MemDebug_8cpp_source.html
     https://github.com/illlust/Game/blob/master/library/MemoryLeak.cpp
*/
#if 0   /* off (0) by default for QHULL_CRTDBG */
#define QHULL_CRTDBG
#endif

#if defined(_MSC_VER) && defined(_DEBUG) && defined(QHULL_CRTDBG)
#define _CRTDBG_MAP_ALLOC
#include 
#include 
#endif

#endif /* qh_DEFuser */
geometry/src/qset_r.c0000644000176200001440000010652714740034715014355 0ustar  liggesusers/*
  ---------------------------------

   qset_r.c
   implements set manipulations needed for quickhull

   see qh-set_r.htm and qset_r.h

   Be careful of strict aliasing (two pointers of different types
   that reference the same location).  The last slot of a set is
   either the actual size of the set plus 1, or the NULL terminator
   of the set (i.e., setelemT).

   Only reference qh for qhmem or qhstat.  Otherwise the matching code in qset.c will bring in qhT

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/qset_r.c#8 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#include "libqhull_r.h" /* for qhT and QHULL_CRTDBG */
#include "qset_r.h"
#include "mem_r.h"
#include 
#include 
/*** uncomment here and qhull_ra.h
     if string.h does not define memcpy()
#include 
*/

#ifndef qhDEFlibqhull
typedef struct ridgeT ridgeT;
typedef struct facetT facetT;
void    qh_errexit(qhT *qh, int exitcode, facetT *, ridgeT *);
void    qh_fprintf(qhT *qh, FILE *fp, int msgcode, const char *fmt, ... );
#  ifdef _MSC_VER  /* Microsoft Visual C++ -- warning level 4 */
#  pragma warning( disable : 4127)  /* conditional expression is constant */
#  pragma warning( disable : 4706)  /* assignment within conditional function */
#  endif
#endif

/*=============== internal macros ===========================*/

/*============ functions in alphabetical order ===================*/

/*----------------------------------

  qh_setaddnth(qh, setp, nth, newelem )
    adds newelem as n'th element of sorted or unsorted *setp

  notes:
    *setp and newelem must be defined
    *setp may be a temp set
    nth=0 is first element
    errors if nth is out of bounds

  design:
    expand *setp if empty or full
    move tail of *setp up one
    insert newelem
*/
void qh_setaddnth(qhT *qh, setT **setp, int nth, void *newelem) {
  int oldsize, i;
  setelemT *sizep;          /* avoid strict aliasing */
  setelemT *oldp, *newp;

  if (!*setp || (sizep= SETsizeaddr_(*setp))->i==0) {
    qh_setlarger(qh, setp);
    sizep= SETsizeaddr_(*setp);
  }
  oldsize= sizep->i - 1;
  if (nth < 0 || nth > oldsize) {
    qh_fprintf(qh, qh->qhmem.ferr, 6171, "qhull internal error (qh_setaddnth): nth %d is out-of-bounds for set:\n", nth);
    qh_setprint(qh, qh->qhmem.ferr, "", *setp);
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  sizep->i++;
  oldp= (setelemT *)SETelemaddr_(*setp, oldsize, void);   /* NULL */
  newp= oldp+1;
  for (i=oldsize-nth+1; i--; )  /* move at least NULL  */
    (newp--)->p= (oldp--)->p;       /* may overwrite *sizep */
  newp->p= newelem;
} /* setaddnth */


/*----------------------------------

  setaddsorted( setp, newelem )
    adds an newelem into sorted *setp

  notes:
    *setp and newelem must be defined
    *setp may be a temp set
    nop if newelem already in set

  design:
    find newelem's position in *setp
    insert newelem
*/
void qh_setaddsorted(qhT *qh, setT **setp, void *newelem) {
  int newindex=0;
  void *elem, **elemp;

  FOREACHelem_(*setp) {          /* could use binary search instead */
    if (elem < newelem)
      newindex++;
    else if (elem == newelem)
      return;
    else
      break;
  }
  qh_setaddnth(qh, setp, newindex, newelem);
} /* setaddsorted */


/*---------------------------------

  qh_setappend(qh, setp, newelem )
    append newelem to *setp

  notes:
    *setp may be a temp set
    *setp and newelem may be NULL

  design:
    expand *setp if empty or full
    append newelem to *setp

*/
void qh_setappend(qhT *qh, setT **setp, void *newelem) {
  setelemT *sizep;  /* Avoid strict aliasing.  Writing to *endp may overwrite *sizep */
  setelemT *endp;
  int count;

  if (!newelem)
    return;
  if (!*setp || (sizep= SETsizeaddr_(*setp))->i==0) {
    qh_setlarger(qh, setp);
    sizep= SETsizeaddr_(*setp);
  }
  count= (sizep->i)++ - 1;
  endp= (setelemT *)SETelemaddr_(*setp, count, void);
  (endp++)->p= newelem;
  endp->p= NULL;
} /* setappend */

/*---------------------------------

  qh_setappend_set(qh, setp, setA )
    appends setA to *setp

  notes:
    *setp can not be a temp set
    *setp and setA may be NULL

  design:
    setup for copy
    expand *setp if it is too small
    append all elements of setA to *setp
*/
void qh_setappend_set(qhT *qh, setT **setp, setT *setA) {
  int sizeA, size;
  setT *oldset;
  setelemT *sizep;

  if (!setA)
    return;
  SETreturnsize_(setA, sizeA);
  if (!*setp)
    *setp= qh_setnew(qh, sizeA);
  sizep= SETsizeaddr_(*setp);
  if (!(size= sizep->i))
    size= (*setp)->maxsize;
  else
    size--;
  if (size + sizeA > (*setp)->maxsize) {
    oldset= *setp;
    *setp= qh_setcopy(qh, oldset, sizeA);
    qh_setfree(qh, &oldset);
    sizep= SETsizeaddr_(*setp);
  }
  if (sizeA > 0) {
    sizep->i= size+sizeA+1;   /* memcpy may overwrite */
    memcpy((char *)&((*setp)->e[size].p), (char *)&(setA->e[0].p), (size_t)(sizeA+1) * SETelemsize);
  }
} /* setappend_set */


/*---------------------------------

  qh_setappend2ndlast(qh, setp, newelem )
    makes newelem the next to the last element in *setp

  notes:
    *setp must have at least one element
    newelem must be defined
    *setp may be a temp set

  design:
    expand *setp if empty or full
    move last element of *setp up one
    insert newelem
*/
void qh_setappend2ndlast(qhT *qh, setT **setp, void *newelem) {
    setelemT *sizep;  /* Avoid strict aliasing.  Writing to *endp may overwrite *sizep */
    setelemT *endp, *lastp;
    int count;

    if (!*setp || (sizep= SETsizeaddr_(*setp))->i==0) {
        qh_setlarger(qh, setp);
        sizep= SETsizeaddr_(*setp);
    }
    count= (sizep->i)++ - 1;
    endp= (setelemT *)SETelemaddr_(*setp, count, void); /* NULL */
    lastp= endp-1;
    *(endp++)= *lastp;
    endp->p= NULL;    /* may overwrite *sizep */
    lastp->p= newelem;
} /* setappend2ndlast */

/*---------------------------------

  qh_setcheck(qh, set, typename, id )
    check set for validity
    report errors with typename and id

  design:
    checks that maxsize, actual size, and NULL terminator agree
*/
void qh_setcheck(qhT *qh, setT *set, const char *tname, unsigned int id) {
  int maxsize, size;
  int waserr= 0;

  if (!set)
    return;
  SETreturnsize_(set, size);
  maxsize= set->maxsize;
  if (size > maxsize || !maxsize) {
    qh_fprintf(qh, qh->qhmem.ferr, 6172, "qhull internal error (qh_setcheck): actual size %d of %s%d is greater than max size %d\n",
             size, tname, id, maxsize);
    waserr= 1;
  }else if (set->e[size].p) {
    qh_fprintf(qh, qh->qhmem.ferr, 6173, "qhull internal error (qh_setcheck): %s%d(size %d max %d) is not null terminated.\n",
             tname, id, size-1, maxsize);
    waserr= 1;
  }
  if (waserr) {
    qh_setprint(qh, qh->qhmem.ferr, "ERRONEOUS", set);
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
} /* setcheck */


/*---------------------------------

  qh_setcompact(qh, set )
    remove internal NULLs from an unsorted set

  returns:
    updated set

  notes:
    set may be NULL
    it would be faster to swap tail of set into holes, like qh_setdel

  design:
    setup pointers into set
    skip NULLs while copying elements to start of set
    update the actual size
*/
void qh_setcompact(qhT *qh, setT *set) {
  int size;
  void **destp, **elemp, **endp, **firstp;

  if (!set)
    return;
  SETreturnsize_(set, size);
  destp= elemp= firstp= SETaddr_(set, void);
  endp= destp + size;
  while (1) {
    if (!(*destp++= *elemp++)) {
      destp--;
      if (elemp > endp)
        break;
    }
  }
  qh_settruncate(qh, set, (int)(destp-firstp));   /* WARN64 */
} /* setcompact */


/*---------------------------------

  qh_setcopy(qh, set, extra )
    make a copy of a sorted or unsorted set with extra slots

  returns:
    new set

  design:
    create a newset with extra slots
    copy the elements to the newset

*/
setT *qh_setcopy(qhT *qh, setT *set, int extra) {
  setT *newset;
  int size;

  if (extra < 0)
    extra= 0;
  SETreturnsize_(set, size);
  newset= qh_setnew(qh, size+extra);
  SETsizeaddr_(newset)->i= size+1;    /* memcpy may overwrite */
  memcpy((char *)&(newset->e[0].p), (char *)&(set->e[0].p), (size_t)(size+1) * SETelemsize);
  return(newset);
} /* setcopy */


/*---------------------------------

  qh_setdel(set, oldelem )
    delete oldelem from an unsorted set

  returns:
    returns oldelem if found
    returns NULL otherwise

  notes:
    set may be NULL
    oldelem must not be NULL;
    only deletes one copy of oldelem in set

  design:
    locate oldelem
    update actual size if it was full
    move the last element to the oldelem's location
*/
void *qh_setdel(setT *set, void *oldelem) {
  setelemT *sizep;
  setelemT *elemp;
  setelemT *lastp;

  if (!set)
    return NULL;
  elemp= (setelemT *)SETaddr_(set, void);
  while (elemp->p != oldelem && elemp->p)
    elemp++;
  if (elemp->p) {
    sizep= SETsizeaddr_(set);
    if (!(sizep->i)--)         /*  if was a full set */
      sizep->i= set->maxsize;  /*     *sizep= (maxsize-1)+ 1 */
    lastp= (setelemT *)SETelemaddr_(set, sizep->i-1, void);
    elemp->p= lastp->p;      /* may overwrite itself */
    lastp->p= NULL;
    return oldelem;
  }
  return NULL;
} /* setdel */


/*---------------------------------

  qh_setdellast( set )
    return last element of set or NULL

  notes:
    deletes element from set
    set may be NULL

  design:
    return NULL if empty
    if full set
      delete last element and set actual size
    else
      delete last element and update actual size
*/
void *qh_setdellast(setT *set) {
  int setsize;  /* actually, actual_size + 1 */
  int maxsize;
  setelemT *sizep;
  void *returnvalue;

  if (!set || !(set->e[0].p))
    return NULL;
  sizep= SETsizeaddr_(set);
  if ((setsize= sizep->i)) {
    returnvalue= set->e[setsize - 2].p;
    set->e[setsize - 2].p= NULL;
    sizep->i--;
  }else {
    maxsize= set->maxsize;
    returnvalue= set->e[maxsize - 1].p;
    set->e[maxsize - 1].p= NULL;
    sizep->i= maxsize;
  }
  return returnvalue;
} /* setdellast */


/*---------------------------------

  qh_setdelnth(qh, set, nth )
    deletes nth element from unsorted set
    0 is first element

  returns:
    returns the element (needs type conversion)

  notes:
    errors if nth invalid

  design:
    setup points and check nth
    delete nth element and overwrite with last element
*/
void *qh_setdelnth(qhT *qh, setT *set, int nth) {
  void *elem;
  setelemT *sizep;
  setelemT *elemp, *lastp;

  sizep= SETsizeaddr_(set);
  if ((sizep->i--)==0)         /*  if was a full set */
    sizep->i= set->maxsize;    /*    *sizep= (maxsize-1)+ 1 */
  if (nth < 0 || nth >= sizep->i) {
    qh_fprintf(qh, qh->qhmem.ferr, 6174, "qhull internal error (qh_setdelnth): nth %d is out-of-bounds for set:\n", nth);
    qh_setprint(qh, qh->qhmem.ferr, "", set);
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  elemp= (setelemT *)SETelemaddr_(set, nth, void); /* nth valid by QH6174 */
  lastp= (setelemT *)SETelemaddr_(set, sizep->i-1, void);
  elem= elemp->p;
  elemp->p= lastp->p;      /* may overwrite itself */
  lastp->p= NULL;
  return elem;
} /* setdelnth */

/*---------------------------------

  qh_setdelnthsorted(qh, set, nth )
    deletes nth element from sorted set

  returns:
    returns the element (use type conversion)

  notes:
    errors if nth invalid

  see also:
    setnew_delnthsorted

  design:
    setup points and check nth
    copy remaining elements down one
    update actual size
*/
void *qh_setdelnthsorted(qhT *qh, setT *set, int nth) {
  void *elem;
  setelemT *sizep;
  setelemT *newp, *oldp;

  sizep= SETsizeaddr_(set);
  if (nth < 0 || (sizep->i && nth >= sizep->i-1) || nth >= set->maxsize) {
    qh_fprintf(qh, qh->qhmem.ferr, 6175, "qhull internal error (qh_setdelnthsorted): nth %d is out-of-bounds for set:\n", nth);
    qh_setprint(qh, qh->qhmem.ferr, "", set);
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  newp= (setelemT *)SETelemaddr_(set, nth, void);
  elem= newp->p;
  oldp= newp+1;
  while (((newp++)->p= (oldp++)->p))
    ; /* copy remaining elements and NULL */
  if ((sizep->i--)==0)         /*  if was a full set */
    sizep->i= set->maxsize;  /*     *sizep= (max size-1)+ 1 */
  return elem;
} /* setdelnthsorted */


/*---------------------------------

  qh_setdelsorted( set, oldelem )
    deletes oldelem from sorted set

  returns:
    returns oldelem if it was deleted

  notes:
    set may be NULL

  design:
    locate oldelem in set
    copy remaining elements down one
    update actual size
*/
void *qh_setdelsorted(setT *set, void *oldelem) {
  setelemT *sizep;
  setelemT *newp, *oldp;

  if (!set)
    return NULL;
  newp= (setelemT *)SETaddr_(set, void);
  while(newp->p != oldelem && newp->p)
    newp++;
  if (newp->p) {
    oldp= newp+1;
    while (((newp++)->p= (oldp++)->p))
      ; /* copy remaining elements */
    sizep= SETsizeaddr_(set);
    if ((sizep->i--)==0)    /*  if was a full set */
      sizep->i= set->maxsize;  /*     *sizep= (max size-1)+ 1 */
    return oldelem;
  }
  return NULL;
} /* setdelsorted */


/*---------------------------------

  qh_setduplicate(qh, set, elemsize )
    duplicate a set of elemsize elements

  notes:
    use setcopy if retaining old elements

  design:
    create a new set
    for each elem of the old set
      create a newelem
      append newelem to newset
*/
setT *qh_setduplicate(qhT *qh, setT *set, int elemsize) {
  void          *elem, **elemp, *newElem;
  setT          *newSet;
  int           size;

  if (!(size= qh_setsize(qh, set)))
    return NULL;
  newSet= qh_setnew(qh, size);
  FOREACHelem_(set) {
    newElem= qh_memalloc(qh, elemsize);
    memcpy(newElem, elem, (size_t)elemsize);
    qh_setappend(qh, &newSet, newElem);
  }
  return newSet;
} /* setduplicate */


/*---------------------------------

  qh_setendpointer( set )
    Returns pointer to NULL terminator of a set's elements
    set can not be NULL

*/
void **qh_setendpointer(setT *set) {

  setelemT *sizep= SETsizeaddr_(set);
  int n= sizep->i;
  return (n ? &set->e[n-1].p : &sizep->p);
} /* qh_setendpointer */

/*---------------------------------

  qh_setequal( setA, setB )
    returns 1 if two sorted sets are equal, otherwise returns 0

  notes:
    either set may be NULL

  design:
    check size of each set
    setup pointers
    compare elements of each set
*/
int qh_setequal(setT *setA, setT *setB) {
  void **elemAp, **elemBp;
  int sizeA= 0, sizeB= 0;

  if (setA) {
    SETreturnsize_(setA, sizeA);
  }
  if (setB) {
    SETreturnsize_(setB, sizeB);
  }
  if (sizeA != sizeB)
    return 0;
  if (!sizeA)
    return 1;
  elemAp= SETaddr_(setA, void);
  elemBp= SETaddr_(setB, void);
  if (!memcmp((char *)elemAp, (char *)elemBp, (size_t)(sizeA * SETelemsize)))
    return 1;
  return 0;
} /* setequal */


/*---------------------------------

  qh_setequal_except( setA, skipelemA, setB, skipelemB )
    returns 1 if sorted setA and setB are equal except for skipelemA & B

  returns:
    false if either skipelemA or skipelemB are missing

  notes:
    neither set may be NULL

    if skipelemB is NULL,
      can skip any one element of setB

  design:
    setup pointers
    search for skipelemA, skipelemB, and mismatches
    check results
*/
int qh_setequal_except(setT *setA, void *skipelemA, setT *setB, void *skipelemB) {
  void **elemA, **elemB;
  int skip=0;

  elemA= SETaddr_(setA, void);
  elemB= SETaddr_(setB, void);
  while (1) {
    if (*elemA == skipelemA) {
      skip++;
      elemA++;
    }
    if (skipelemB) {
      if (*elemB == skipelemB) {
        skip++;
        elemB++;
      }
    }else if (*elemA != *elemB) {
      skip++;
      if (!(skipelemB= *elemB++))
        return 0;
    }
    if (!*elemA)
      break;
    if (*elemA++ != *elemB++)
      return 0;
  }
  if (skip != 2 || *elemB)
    return 0;
  return 1;
} /* setequal_except */


/*---------------------------------

  qh_setequal_skip( setA, skipA, setB, skipB )
    returns 1 if sorted setA and setB are equal except for elements skipA & B

  returns:
    false if different size

  notes:
    neither set may be NULL

  design:
    setup pointers
    search for mismatches while skipping skipA and skipB
*/
int qh_setequal_skip(setT *setA, int skipA, setT *setB, int skipB) {
  void **elemA, **elemB, **skipAp, **skipBp;

  elemA= SETaddr_(setA, void);
  elemB= SETaddr_(setB, void);
  skipAp= SETelemaddr_(setA, skipA, void);
  skipBp= SETelemaddr_(setB, skipB, void);
  while (1) {
    if (elemA == skipAp)
      elemA++;
    if (elemB == skipBp)
      elemB++;
    if (!*elemA)
      break;
    if (*elemA++ != *elemB++)
      return 0;
  }
  if (*elemB)
    return 0;
  return 1;
} /* setequal_skip */


/*---------------------------------

  qh_setfree(qh, setp )
    frees the space occupied by a sorted or unsorted set

  returns:
    sets setp to NULL

  notes:
    set may be NULL

  design:
    free array
    free set
*/
void qh_setfree(qhT *qh, setT **setp) {
  int size;
  void **freelistp;  /* used if !qh_NOmem by qh_memfree_() */

  if (*setp) {
    size= SETbasesize + ((*setp)->maxsize)*SETelemsize;
    if (size <= qh->qhmem.LASTsize) {
      qh_memfree_(qh, *setp, size, freelistp);
    }else
      qh_memfree(qh, *setp, size);
    *setp= NULL;
  }
} /* setfree */


/*---------------------------------

  qh_setfree2(qh, setp, elemsize )
    frees the space occupied by a set and its elements

  notes:
    set may be NULL

  design:
    free each element
    free set
*/
void qh_setfree2(qhT *qh, setT **setp, int elemsize) {
  void          *elem, **elemp;

  FOREACHelem_(*setp)
    qh_memfree(qh, elem, elemsize);
  qh_setfree(qh, setp);
} /* setfree2 */



/*---------------------------------

  qh_setfreelong(qh, setp )
    frees a set only if it's in long memory

  returns:
    sets setp to NULL if it is freed

  notes:
    set may be NULL

  design:
    if set is large
      free it
*/
void qh_setfreelong(qhT *qh, setT **setp) {
  int size;

  if (*setp) {
    size= SETbasesize + ((*setp)->maxsize)*SETelemsize;
    if (size > qh->qhmem.LASTsize) {
      qh_memfree(qh, *setp, size);
      *setp= NULL;
    }
  }
} /* setfreelong */


/*---------------------------------

  qh_setin( set, setelem )
    returns 1 if setelem is in a set, 0 otherwise

  notes:
    set may be NULL or unsorted

  design:
    scans set for setelem
*/
int qh_setin(setT *set, void *setelem) {
  void *elem, **elemp;

  FOREACHelem_(set) {
    if (elem == setelem)
      return 1;
  }
  return 0;
} /* setin */


/*---------------------------------

  qh_setindex(set, atelem )
    returns the index of atelem in set.
    returns -1, if not in set or maxsize wrong

  notes:
    set may be NULL and may contain nulls.
    NOerrors returned (qh_pointid, QhullPoint::id)

  design:
    checks maxsize
    scans set for atelem
*/
int qh_setindex(setT *set, void *atelem) {
  void **elem;
  int size, i;

  if (!set)
    return -1;
  SETreturnsize_(set, size);
  if (size > set->maxsize)
    return -1;
  elem= SETaddr_(set, void);
  for (i=0; i < size; i++) {
    if (*elem++ == atelem)
      return i;
  }
  return -1;
} /* setindex */


/*---------------------------------

  qh_setlarger(qh, oldsetp )
    returns a larger set that contains all elements of *oldsetp

  notes:
    if long memory,
      the new set is 2x larger
    if qhmem.LASTsize is between 1.5x and 2x
      the new set is qhmem.LASTsize
    otherwise use quick memory,
      the new set is 2x larger, rounded up to next qh_memsize
       
    if temp set, updates qh->qhmem.tempstack

  design:
    creates a new set
    copies the old set to the new set
    updates pointers in tempstack
    deletes the old set
*/
void qh_setlarger(qhT *qh, setT **oldsetp) {
  int setsize= 1, newsize;
  setT *newset, *set, **setp, *oldset;
  setelemT *sizep;
  setelemT *newp, *oldp;

  if (*oldsetp) {
    oldset= *oldsetp;
    SETreturnsize_(oldset, setsize);
    qh->qhmem.cntlarger++;
    qh->qhmem.totlarger += setsize+1;
    qh_setlarger_quick(qh, setsize, &newsize);
    newset= qh_setnew(qh, newsize);
    oldp= (setelemT *)SETaddr_(oldset, void);
    newp= (setelemT *)SETaddr_(newset, void);
    memcpy((char *)newp, (char *)oldp, (size_t)(setsize+1) * SETelemsize);
    sizep= SETsizeaddr_(newset);
    sizep->i= setsize+1;
    FOREACHset_((setT *)qh->qhmem.tempstack) {
      if (set == oldset)
        *(setp-1)= newset;
    }
    qh_setfree(qh, oldsetp);
  }else
    newset= qh_setnew(qh, 3);
  *oldsetp= newset;
} /* setlarger */


/*---------------------------------

  qh_setlarger_quick(qh, setsize, newsize )
    determine newsize for setsize
    returns True if newsize fits in quick memory

  design:
    if 2x fits into quick memory
      return True, 2x
    if x+4 does not fit into quick memory
      return False, 2x
    if x+x/3 fits into quick memory
      return True, the last quick set
    otherwise
      return False, 2x
*/
int qh_setlarger_quick(qhT *qh, int setsize, int *newsize) {
    int lastquickset;

    *newsize= 2 * setsize;
    lastquickset= (qh->qhmem.LASTsize - SETbasesize) / SETelemsize; /* matches size computation in qh_setnew */
    if (*newsize <= lastquickset)
      return 1;
    if (setsize + 4 > lastquickset)
      return 0;
    if (setsize + setsize/3 <= lastquickset) {
      *newsize= lastquickset;
      return 1;
    }
    return 0;
} /* setlarger_quick */

/*---------------------------------

  qh_setlast( set )
    return last element of set or NULL (use type conversion)

  notes:
    set may be NULL

  design:
    return last element
*/
void *qh_setlast(setT *set) {
  int size;

  if (set) {
    size= SETsizeaddr_(set)->i;
    if (!size)
      return SETelem_(set, set->maxsize - 1);
    else if (size > 1)
      return SETelem_(set, size - 2);
  }
  return NULL;
} /* setlast */


/*---------------------------------

  qh_setnew(qh, setsize )
    creates and allocates space for a set

  notes:
    setsize means the number of elements (!including the NULL terminator)
    use qh_settemp/qh_setfreetemp if set is temporary

  design:
    allocate memory for set
    roundup memory if small set
    initialize as empty set
*/
setT *qh_setnew(qhT *qh, int setsize) {
  setT *set;
  int sizereceived; /* used if !qh_NOmem */
  int size;
  void **freelistp; /* used if !qh_NOmem by qh_memalloc_() */

  if (!setsize)
    setsize++;
  size= SETbasesize + setsize * SETelemsize; /* setT includes NULL terminator, see qh.LASTquickset */
  if (size>0 && size <= qh->qhmem.LASTsize) {
    qh_memalloc_(qh, size, freelistp, set, setT);
#ifndef qh_NOmem
    sizereceived= qh->qhmem.sizetable[ qh->qhmem.indextable[size]];
    if (sizereceived > size)
      setsize += (sizereceived - size)/SETelemsize;
#endif
  }else
    set= (setT *)qh_memalloc(qh, size);
  set->maxsize= setsize;
  set->e[setsize].i= 1;
  set->e[0].p= NULL;
  return(set);
} /* setnew */


/*---------------------------------

  qh_setnew_delnthsorted(qh, set, size, nth, prepend )
    creates a sorted set not containing nth element
    if prepend, the first prepend elements are undefined

  notes:
    set must be defined
    checks nth
    see also: setdelnthsorted

  design:
    create new set
    setup pointers and allocate room for prepend'ed entries
    append head of old set to new set
    append tail of old set to new set
*/
setT *qh_setnew_delnthsorted(qhT *qh, setT *set, int size, int nth, int prepend) {
  setT *newset;
  void **oldp, **newp;
  int tailsize= size - nth -1, newsize;

  if (tailsize < 0) {
    qh_fprintf(qh, qh->qhmem.ferr, 6176, "qhull internal error (qh_setnew_delnthsorted): nth %d is out-of-bounds for set:\n", nth);
    qh_setprint(qh, qh->qhmem.ferr, "", set);
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  newsize= size-1 + prepend;
  newset= qh_setnew(qh, newsize);
  newset->e[newset->maxsize].i= newsize+1;  /* may be overwritten */
  oldp= SETaddr_(set, void);
  newp= SETaddr_(newset, void) + prepend;
  switch (nth) {
  case 0:
    break;
  case 1:
    *(newp++)= *oldp++;
    break;
  case 2:
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    break;
  case 3:
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    break;
  case 4:
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    break;
  default:
    memcpy((char *)newp, (char *)oldp, (size_t)nth * SETelemsize);
    newp += nth;
    oldp += nth;
    break;
  }
  oldp++;
  switch (tailsize) {
  case 0:
    break;
  case 1:
    *(newp++)= *oldp++;
    break;
  case 2:
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    break;
  case 3:
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    break;
  case 4:
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    *(newp++)= *oldp++;
    break;
  default:
    memcpy((char *)newp, (char *)oldp, (size_t)tailsize * SETelemsize);
    newp += tailsize;
  }
  *newp= NULL;
  return(newset);
} /* setnew_delnthsorted */


/*---------------------------------

  qh_setprint(qh, fp, string, set )
    print set elements to fp with identifying string

  notes:
    never errors
*/
void qh_setprint(qhT *qh, FILE *fp, const char* string, setT *set) {
  int size, k;

  if (!set)
    qh_fprintf(qh, fp, 9346, "%s set is null\n", string);
  else {
    SETreturnsize_(set, size);
    qh_fprintf(qh, fp, 9347, "%s set=%p maxsize=%d size=%d elems=",
             string, set, set->maxsize, size);
    if (size > set->maxsize)
      size= set->maxsize+1;
    for (k=0; k < size; k++)
      qh_fprintf(qh, fp, 9348, " %p", set->e[k].p);
    qh_fprintf(qh, fp, 9349, "\n");
  }
} /* setprint */

/*---------------------------------

  qh_setreplace(qh, set, oldelem, newelem )
    replaces oldelem in set with newelem

  notes:
    errors if oldelem not in the set
    newelem may be NULL, but it turns the set into an indexed set (no FOREACH)

  design:
    find oldelem
    replace with newelem
*/
void qh_setreplace(qhT *qh, setT *set, void *oldelem, void *newelem) {
  void **elemp;

  elemp= SETaddr_(set, void);
  while (*elemp != oldelem && *elemp)
    elemp++;
  if (*elemp)
    *elemp= newelem;
  else {
    qh_fprintf(qh, qh->qhmem.ferr, 6177, "qhull internal error (qh_setreplace): elem %p not found in set\n",
       oldelem);
    qh_setprint(qh, qh->qhmem.ferr, "", set);
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
} /* setreplace */


/*---------------------------------

  qh_setsize(qh, set )
    returns the size of a set

  notes:
    errors if set's maxsize is incorrect
    same as SETreturnsize_(set)
    same code for qh_setsize [qset_r.c] and QhullSetBase::count
    if first element is NULL, SETempty_() is True but qh_setsize may be greater than 0

  design:
    determine actual size of set from maxsize
*/
int qh_setsize(qhT *qh, setT *set) {
  int size;
  setelemT *sizep;

  if (!set)
    return(0);
  sizep= SETsizeaddr_(set);
  if ((size= sizep->i)) {
    size--;
    if (size > set->maxsize) {
      qh_fprintf(qh, qh->qhmem.ferr, 6178, "qhull internal error (qh_setsize): current set size %d is greater than maximum size %d\n",
               size, set->maxsize);
      qh_setprint(qh, qh->qhmem.ferr, "set: ", set);
      qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
    }
  }else
    size= set->maxsize;
  return size;
} /* setsize */

/*---------------------------------

  qh_settemp(qh, setsize )
    return a stacked, temporary set of up to setsize elements

  notes:
    use settempfree or settempfree_all to release from qh->qhmem.tempstack
    see also qh_setnew

  design:
    allocate set
    append to qh->qhmem.tempstack

*/
setT *qh_settemp(qhT *qh, int setsize) {
  setT *newset;

  newset= qh_setnew(qh, setsize);
  qh_setappend(qh, &qh->qhmem.tempstack, newset);
  if (qh->qhmem.IStracing >= 5)
    qh_fprintf(qh, qh->qhmem.ferr, 8123, "qh_settemp: temp set %p of %d elements, depth %d\n",
       newset, newset->maxsize, qh_setsize(qh, qh->qhmem.tempstack));
  return newset;
} /* settemp */

/*---------------------------------

  qh_settempfree(qh, set )
    free temporary set at top of qh->qhmem.tempstack

  notes:
    nop if set is NULL
    errors if set not from previous   qh_settemp

  to locate errors:
    use 'T2' to find source and then find mis-matching qh_settemp

  design:
    check top of qh->qhmem.tempstack
    free it
*/
void qh_settempfree(qhT *qh, setT **set) {
  setT *stackedset;

  if (!*set)
    return;
  stackedset= qh_settemppop(qh);
  if (stackedset != *set) {
    qh_settemppush(qh, stackedset);
    qh_fprintf(qh, qh->qhmem.ferr, 6179, "qhull internal error (qh_settempfree): set %p(size %d) was not last temporary allocated(depth %d, set %p, size %d)\n",
             *set, qh_setsize(qh, *set), qh_setsize(qh, qh->qhmem.tempstack)+1,
             stackedset, qh_setsize(qh, stackedset));
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  qh_setfree(qh, set);
} /* settempfree */

/*---------------------------------

  qh_settempfree_all(qh)
    free all temporary sets in qh->qhmem.tempstack

  design:
    for each set in tempstack
      free set
    free qh->qhmem.tempstack
*/
void qh_settempfree_all(qhT *qh) {
  setT *set, **setp;

  FOREACHset_(qh->qhmem.tempstack)
    qh_setfree(qh, &set);
  qh_setfree(qh, &qh->qhmem.tempstack);
} /* settempfree_all */

/*---------------------------------

  qh_settemppop(qh)
    pop and return temporary set from qh->qhmem.tempstack

  notes:
    the returned set is permanent

  design:
    pop and check top of qh->qhmem.tempstack
*/
setT *qh_settemppop(qhT *qh) {
  setT *stackedset;

  stackedset= (setT *)qh_setdellast(qh->qhmem.tempstack);
  if (!stackedset) {
    qh_fprintf(qh, qh->qhmem.ferr, 6180, "qhull internal error (qh_settemppop): pop from empty temporary stack\n");
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  if (qh->qhmem.IStracing >= 5)
    qh_fprintf(qh, qh->qhmem.ferr, 8124, "qh_settemppop: depth %d temp set %p of %d elements\n",
       qh_setsize(qh, qh->qhmem.tempstack)+1, stackedset, qh_setsize(qh, stackedset));
  return stackedset;
} /* settemppop */

/*---------------------------------

  qh_settemppush(qh, set )
    push temporary set unto qh->qhmem.tempstack (makes it temporary)

  notes:
    duplicates settemp() for tracing

  design:
    append set to tempstack
*/
void qh_settemppush(qhT *qh, setT *set) {
  if (!set) {
    qh_fprintf(qh, qh->qhmem.ferr, 6267, "qhull error (qh_settemppush): can not push a NULL temp\n");
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  qh_setappend(qh, &qh->qhmem.tempstack, set);
  if (qh->qhmem.IStracing >= 5)
    qh_fprintf(qh, qh->qhmem.ferr, 8125, "qh_settemppush: depth %d temp set %p of %d elements\n",
      qh_setsize(qh, qh->qhmem.tempstack), set, qh_setsize(qh, set));
} /* settemppush */


/*---------------------------------

  qh_settruncate(qh, set, size )
    truncate set to size elements

  notes:
    set must be defined

  see:
    SETtruncate_

  design:
    check size
    update actual size of set
*/
void qh_settruncate(qhT *qh, setT *set, int size) {

  if (size < 0 || size > set->maxsize) {
    qh_fprintf(qh, qh->qhmem.ferr, 6181, "qhull internal error (qh_settruncate): size %d out of bounds for set:\n", size);
    qh_setprint(qh, qh->qhmem.ferr, "", set);
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  set->e[set->maxsize].i= size+1;   /* maybe overwritten */
  set->e[size].p= NULL;
} /* settruncate */

/*---------------------------------

  qh_setunique(qh, set, elem )
    add elem to unsorted set unless it is already in set

  notes:
    returns 1 if it is appended

  design:
    if elem not in set
      append elem to set
*/
int qh_setunique(qhT *qh, setT **set, void *elem) {

  if (!qh_setin(*set, elem)) {
    qh_setappend(qh, set, elem);
    return 1;
  }
  return 0;
} /* setunique */

/*---------------------------------

  qh_setzero(qh, set, index, size )
    zero elements from index on
    set actual size of set to size

  notes:
    set must be defined
    the set becomes an indexed set (can not use FOREACH...)

  see also:
    qh_settruncate

  design:
    check index and size
    update actual size
    zero elements starting at e[index]
*/
void qh_setzero(qhT *qh, setT *set, int idx, int size) {
  int count;

  if (idx < 0 || idx >= size || size > set->maxsize) {
    qh_fprintf(qh, qh->qhmem.ferr, 6182, "qhull internal error (qh_setzero): index %d or size %d out of bounds for set:\n", idx, size);
    qh_setprint(qh, qh->qhmem.ferr, "", set);
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  set->e[set->maxsize].i=  size+1;  /* may be overwritten */
  count= size - idx + 1;   /* +1 for NULL terminator */
  memset((char *)SETelemaddr_(set, idx, void), 0, (size_t)count * SETelemsize);
} /* setzero */


geometry/src/QuadTree.h0000644000176200001440000000424014664422665014576 0ustar  liggesusers/*
  This program is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by the
  Free Software Foundation; either version 3 of the License, or (at your
  option) any later version.
  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  for more details.
  You should have received a copy of the GNU General Public License
  along with this program. If not, see  .
*/

// Originally written for package lidR by Jean-Romain Roussel
// Author: Jean-Romain Roussel
// 3 may 2017: copy from package lidR to package geometry by Jean-Romain Roussel to operate in fast tsearch funtion

#ifndef QT_H
#define QT_H

#include 

struct Point
{
  double x, y;
  int id;

  Point();
  Point(const double, const double);
  Point(const double, const double, const int);
};

struct BoundingBox
{
  Point center, half_res;

  BoundingBox();
  BoundingBox(const Point,const Point);
  bool contains(const Point&, const double);
  bool intersects(const BoundingBox&);
};

class QuadTree
{
public:
  ~QuadTree();
  static QuadTree* create(const std::vector&, const std::vector&, const double eps);
  bool insert(const Point&);
  void rect_lookup(const double, const double, const double, const double, std::vector&);
  void circle_lookup(const double, const double, const double, std::vector&);


private:
  int MAX_DEPTH;
  double EPSILON;
  int depth;
  BoundingBox boundary;
  std::vector points;
  QuadTree* NE;
  QuadTree* NW;
  QuadTree* SE;
  QuadTree* SW;

  QuadTree(const BoundingBox, const int, const double);

  void subdivide();
  void range_lookup(const BoundingBox, std::vector&, const int);
  void getPointsSquare(const BoundingBox, std::vector&, std::vector&);
  void getPointsCircle(const BoundingBox, std::vector&, std::vector&);
  bool in_circle(const Point&, const Point&, const double);
  bool in_rect(const BoundingBox&, const Point&);
};

#endif //QT_H
geometry/src/poly2_r.c0000644000176200001440000046520214664417655014461 0ustar  liggesusers/*
  ---------------------------------

   poly2_r.c
   implements polygons and simplicies

   see qh-poly_r.htm, poly_r.h and libqhull_r.h

   frequently used code is in poly_r.c

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/poly2_r.c#20 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#include "qhull_ra.h"

/*======== functions in alphabetical order ==========*/

/*---------------------------------

  qh_addfacetvertex(qh, facet, newvertex )
    add newvertex to facet.vertices if not already there
    vertices are inverse sorted by vertex->id

  returns:
    True if new vertex for facet

  notes:
    see qh_replacefacetvertex
*/
boolT qh_addfacetvertex(qhT *qh, facetT *facet, vertexT *newvertex) {
  vertexT *vertex;
  int vertex_i= 0, vertex_n;
  boolT isnew= True;

  FOREACHvertex_i_(qh, facet->vertices) {
    if (vertex->id < newvertex->id) {
      break;
    }else if (vertex->id == newvertex->id) {
      isnew= False;
      break;
    }
  }
  if (isnew)
    qh_setaddnth(qh, &facet->vertices, vertex_i, newvertex);
  return isnew;
} /* addfacetvertex */

/*---------------------------------

  qh_addhash( newelem, hashtable, hashsize, hash )
    add newelem to linear hash table at hash if not already there
*/
void qh_addhash(void *newelem, setT *hashtable, int hashsize, int hash) {
  int scan;
  void *elem;

  for (scan= (int)hash; (elem= SETelem_(hashtable, scan));
       scan= (++scan >= hashsize ? 0 : scan)) {
    if (elem == newelem)
      break;
  }
  /* loop terminates because qh_HASHfactor >= 1.1 by qh_initbuffers */
  if (!elem)
    SETelem_(hashtable, scan)= newelem;
} /* addhash */

/*---------------------------------

  qh_check_bestdist(qh)
    check that all points are within max_outside of the nearest facet
    if qh.ONLYgood,
      ignores !good facets

  see:
    qh_check_maxout(), qh_outerinner()

  notes:
    only called from qh_check_points()
      seldom used since qh.MERGING is almost always set
    if notverified>0 at end of routine
      some points were well inside the hull.  If the hull contains
      a lens-shaped component, these points were not verified.  Use
      options 'Qi Tv' to verify all points.  (Exhaustive check also verifies)

  design:
    determine facet for each point (if any)
    for each point
      start with the assigned facet or with the first facet
      find the best facet for the point and check all coplanar facets
      error if point is outside of facet
*/
void qh_check_bestdist(qhT *qh) {
  boolT waserror= False, unassigned;
  facetT *facet, *bestfacet, *errfacet1= NULL, *errfacet2= NULL;
  facetT *facetlist;
  realT dist, maxoutside, maxdist= -REALmax;
  pointT *point;
  int numpart= 0, facet_i, facet_n, notgood= 0, notverified= 0;
  setT *facets;

  trace1((qh, qh->ferr, 1020, "qh_check_bestdist: check points below nearest facet.  Facet_list f%d\n",
      qh->facet_list->id));
  maxoutside= qh_maxouter(qh);
  maxoutside += qh->DISTround;
  /* one more qh.DISTround for check computation */
  trace1((qh, qh->ferr, 1021, "qh_check_bestdist: check that all points are within %2.2g of best facet\n", maxoutside));
  facets= qh_pointfacet(qh /* qh.facet_list */);
  if (!qh_QUICKhelp && qh->PRINTprecision)
    qh_fprintf(qh, qh->ferr, 8091, "\n\
qhull output completed.  Verifying that %d points are\n\
below %2.2g of the nearest %sfacet.\n",
             qh_setsize(qh, facets), maxoutside, (qh->ONLYgood ?  "good " : ""));
  FOREACHfacet_i_(qh, facets) {  /* for each point with facet assignment */
    if (facet)
      unassigned= False;
    else {
      unassigned= True;
      facet= qh->facet_list;
    }
    point= qh_point(qh, facet_i);
    if (point == qh->GOODpointp)
      continue;
    qh_distplane(qh, point, facet, &dist);
    numpart++;
    bestfacet= qh_findbesthorizon(qh, !qh_IScheckmax, point, facet, qh_NOupper, &dist, &numpart);
    /* occurs after statistics reported */
    maximize_(maxdist, dist);
    if (dist > maxoutside) {
      if (qh->ONLYgood && !bestfacet->good
      && !((bestfacet= qh_findgooddist(qh, point, bestfacet, &dist, &facetlist))
      && dist > maxoutside))
        notgood++;
      else {
        waserror= True;
        qh_fprintf(qh, qh->ferr, 6109, "qhull precision error (qh_check_bestdist): point p%d is outside facet f%d, distance= %6.8g maxoutside= %6.8g\n",
                facet_i, bestfacet->id, dist, maxoutside);
        if (errfacet1 != bestfacet) {
          errfacet2= errfacet1;
          errfacet1= bestfacet;
        }
      }
    }else if (unassigned && dist < -qh->MAXcoplanar)
      notverified++;
  }
  qh_settempfree(qh, &facets);
  if (notverified && !qh->DELAUNAY && !qh_QUICKhelp && qh->PRINTprecision)
    qh_fprintf(qh, qh->ferr, 8092, "\n%d points were well inside the hull.  If the hull contains\n\
a lens-shaped component, these points were not verified.  Use\n\
options 'Qci Tv' to verify all points.\n", notverified);
  if (maxdist > qh->outside_err) {
    qh_fprintf(qh, qh->ferr, 6110, "qhull precision error (qh_check_bestdist): a coplanar point is %6.2g from convex hull.  The maximum value is qh.outside_err (%6.2g)\n",
              maxdist, qh->outside_err);
    qh_errexit2(qh, qh_ERRprec, errfacet1, errfacet2);
  }else if (waserror && qh->outside_err > REALmax/2)
    qh_errexit2(qh, qh_ERRprec, errfacet1, errfacet2);
  /* else if waserror, the error was logged to qh.ferr but does not effect the output */
  trace0((qh, qh->ferr, 20, "qh_check_bestdist: max distance outside %2.2g\n", maxdist));
} /* check_bestdist */

#ifndef qh_NOmerge
/*---------------------------------

  qh_check_maxout(qh)
    updates qh.max_outside by checking all points against bestfacet
    if qh.ONLYgood, ignores !good facets

  returns:
    updates facet->maxoutside via qh_findbesthorizon()
    sets qh.maxoutdone
    if printing qh.min_vertex (qh_outerinner),
      it is updated to the current vertices
    removes inside/coplanar points from coplanarset as needed

  notes:
    defines coplanar as qh.min_vertex instead of qh.MAXcoplanar
    may not need to check near-inside points because of qh.MAXcoplanar
      and qh.KEEPnearinside (before it was -qh.DISTround)

  see also:
    qh_check_bestdist()

  design:
    if qh.min_vertex is needed
      for all neighbors of all vertices
        test distance from vertex to neighbor
    determine facet for each point (if any)
    for each point with an assigned facet
      find the best facet for the point and check all coplanar facets
        (updates outer planes)
    remove near-inside points from coplanar sets
*/
void qh_check_maxout(qhT *qh) {
  facetT *facet, *bestfacet, *neighbor, **neighborp, *facetlist, *maxbestfacet= NULL, *minfacet, *maxfacet, *maxpointfacet;
  realT dist, maxoutside, mindist, nearest;
  realT maxoutside_base, minvertex_base;
  pointT *point, *maxpoint= NULL;
  int numpart= 0, facet_i, facet_n, notgood= 0;
  setT *facets, *vertices;
  vertexT *vertex, *minvertex;

  trace1((qh, qh->ferr, 1022, "qh_check_maxout: check and update qh.min_vertex %2.2g and qh.max_outside %2.2g\n", qh->min_vertex, qh->max_outside));
  minvertex_base= fmin_(qh->min_vertex, -(qh->ONEmerge+qh->DISTround));
  maxoutside= mindist= 0.0;
  minvertex= qh->vertex_list;
  maxfacet= minfacet= maxpointfacet= qh->facet_list;
  if (qh->VERTEXneighbors
  && (qh->PRINTsummary || qh->KEEPinside || qh->KEEPcoplanar
        || qh->TRACElevel || qh->PRINTstatistics || qh->VERIFYoutput || qh->CHECKfrequently
        || qh->PRINTout[0] == qh_PRINTsummary || qh->PRINTout[0] == qh_PRINTnone)) {
    trace1((qh, qh->ferr, 1023, "qh_check_maxout: determine actual minvertex\n"));
    vertices= qh_pointvertex(qh /* qh.facet_list */);
    FORALLvertices {
      FOREACHneighbor_(vertex) {
        zinc_(Zdistvertex);  /* distance also computed by main loop below */
        qh_distplane(qh, vertex->point, neighbor, &dist);
        if (dist < mindist) {
          if (qh->min_vertex/minvertex_base > qh_WIDEmaxoutside && (qh->PRINTprecision || !qh->ALLOWwide)) {
            nearest= qh_vertex_bestdist(qh, neighbor->vertices);
            /* should be caught in qh_mergefacet */
            qh_fprintf(qh, qh->ferr, 7083, "Qhull precision warning: in post-processing (qh_check_maxout) p%d(v%d) is %2.2g below f%d nearest vertices %2.2g\n",
              qh_pointid(qh, vertex->point), vertex->id, dist, neighbor->id, nearest);
          }
          mindist= dist;
          minvertex= vertex;
          minfacet= neighbor;
        }
#ifndef qh_NOtrace
        if (-dist > qh->TRACEdist || dist > qh->TRACEdist
        || neighbor == qh->tracefacet || vertex == qh->tracevertex) {
          nearest= qh_vertex_bestdist(qh, neighbor->vertices);
          qh_fprintf(qh, qh->ferr, 8093, "qh_check_maxout: p%d(v%d) is %.2g from f%d nearest vertices %2.2g\n",
                    qh_pointid(qh, vertex->point), vertex->id, dist, neighbor->id, nearest);
        }
#endif
      }
    }
    if (qh->MERGING) {
      wmin_(Wminvertex, qh->min_vertex);
    }
    qh->min_vertex= mindist;
    qh_settempfree(qh, &vertices);
  }
  trace1((qh, qh->ferr, 1055, "qh_check_maxout: determine actual maxoutside\n"));
  maxoutside_base= fmax_(qh->max_outside, qh->ONEmerge+qh->DISTround);
  /* maxoutside_base is same as qh.MAXoutside without qh.MINoutside (qh_detmaxoutside) */
  facets= qh_pointfacet(qh /* qh.facet_list */);
  FOREACHfacet_i_(qh, facets) {     /* for each point with facet assignment */
    if (facet) {
      point= qh_point(qh, facet_i);
      if (point == qh->GOODpointp)
        continue;
      zzinc_(Ztotcheck);
      qh_distplane(qh, point, facet, &dist);
      numpart++;
      bestfacet= qh_findbesthorizon(qh, qh_IScheckmax, point, facet, !qh_NOupper, &dist, &numpart);
      if (bestfacet && dist >= maxoutside) { 
        if (qh->ONLYgood && !bestfacet->good
        && !((bestfacet= qh_findgooddist(qh, point, bestfacet, &dist, &facetlist))
        && dist > maxoutside)) {       
          notgood++;
        }else if (dist/maxoutside_base > qh_WIDEmaxoutside && (qh->PRINTprecision || !qh->ALLOWwide)) {
          nearest= qh_vertex_bestdist(qh, bestfacet->vertices);
          if (nearest < fmax_(qh->ONEmerge, qh->max_outside) * qh_RATIOcoplanaroutside * 2) {
            qh_fprintf(qh, qh->ferr, 7087, "Qhull precision warning: in post-processing (qh_check_maxout) p%d for f%d is %2.2g above twisted facet f%d nearest vertices %2.2g\n",
              qh_pointid(qh, point), facet->id, dist, bestfacet->id, nearest);
          }else {
            qh_fprintf(qh, qh->ferr, 7088, "Qhull precision warning: in post-processing (qh_check_maxout) p%d for f%d is %2.2g above hidden facet f%d nearest vertices %2.2g\n",
              qh_pointid(qh, point), facet->id, dist, bestfacet->id, nearest);
          }
          maxbestfacet= bestfacet;
        }
        maxoutside= dist;
        maxfacet= bestfacet;
        maxpoint= point;
        maxpointfacet= facet;
      }
      if (dist > qh->TRACEdist || (bestfacet && bestfacet == qh->tracefacet))
        qh_fprintf(qh, qh->ferr, 8094, "qh_check_maxout: p%d is %.2g above f%d\n",
              qh_pointid(qh, point), dist, (bestfacet ? bestfacet->id : UINT_MAX));
    }
  }
  zzadd_(Zcheckpart, numpart);
  qh_settempfree(qh, &facets);
  wval_(Wmaxout)= maxoutside - qh->max_outside;
  wmax_(Wmaxoutside, qh->max_outside);
  if (!qh->APPROXhull && maxoutside > qh->DISTround) { /* initial value for f.maxoutside */
    FORALLfacets {
      if (maxoutside < facet->maxoutside) {
        if (!qh->KEEPcoplanar) {
          maxoutside= facet->maxoutside;
        }else if (maxoutside + qh->DISTround < facet->maxoutside) { /* maxoutside is computed distance, e.g., rbox 100 s D3 t1547136913 | qhull R1e-3 Tcv Qc */
          qh_fprintf(qh, qh->ferr, 7082, "Qhull precision warning (qh_check_maxout): f%d.maxoutside (%4.4g) is greater than computed qh.max_outside (%2.2g) + qh.DISTround (%2.2g).  It should be less than or equal\n",
            facet->id, facet->maxoutside, maxoutside, qh->DISTround); 
        }
      }
    }
  }
  qh->max_outside= maxoutside; 
  qh_nearcoplanar(qh /* qh.facet_list */);
  qh->maxoutdone= True;
  trace1((qh, qh->ferr, 1024, "qh_check_maxout:  p%d(v%d) is qh.min_vertex %2.2g below facet f%d.  Point p%d for f%d is qh.max_outside %2.2g above f%d.  %d points are outside of not-good facets\n", 
    qh_pointid(qh, minvertex->point), minvertex->id, qh->min_vertex, minfacet->id, qh_pointid(qh, maxpoint), maxpointfacet->id, qh->max_outside, maxfacet->id, notgood));
  if(!qh->ALLOWwide) {
    if (maxoutside/maxoutside_base > qh_WIDEmaxoutside) {
      qh_fprintf(qh, qh->ferr, 6297, "Qhull precision error (qh_check_maxout): large increase in qh.max_outside during post-processing dist %2.2g (%.1fx).  See warning QH0032/QH0033.  Allow with 'Q12' (allow-wide) and 'Pp'\n",
        maxoutside, maxoutside/maxoutside_base);
      qh_errexit(qh, qh_ERRwide, maxbestfacet, NULL);
    }else if (!qh->APPROXhull && maxoutside_base > (qh->ONEmerge * qh_WIDEmaxoutside2)) {
      if (maxoutside > (qh->ONEmerge * qh_WIDEmaxoutside2)) {  /* wide facets may have been deleted */
        qh_fprintf(qh, qh->ferr, 6298, "Qhull precision error (qh_check_maxout): a facet merge, vertex merge, vertex, or coplanar point produced a wide facet %2.2g (%.1fx). Trace with option 'TWn' to identify the merge.   Allow with 'Q12' (allow-wide)\n",
          maxoutside_base, maxoutside_base/(qh->ONEmerge + qh->DISTround));
        qh_errexit(qh, qh_ERRwide, maxbestfacet, NULL);
      }
    }else if (qh->min_vertex/minvertex_base > qh_WIDEmaxoutside) {
      qh_fprintf(qh, qh->ferr, 6354, "Qhull precision error (qh_check_maxout): large increase in qh.min_vertex during post-processing dist %2.2g (%.1fx).  See warning QH7083.  Allow with 'Q12' (allow-wide) and 'Pp'\n",
        qh->min_vertex, qh->min_vertex/minvertex_base);
      qh_errexit(qh, qh_ERRwide, minfacet, NULL);
    }else if (minvertex_base < -(qh->ONEmerge * qh_WIDEmaxoutside2)) {
      if (qh->min_vertex < -(qh->ONEmerge * qh_WIDEmaxoutside2)) {  /* wide facets may have been deleted */
        qh_fprintf(qh, qh->ferr, 6380, "Qhull precision error (qh_check_maxout): a facet or vertex merge produced a wide facet: v%d below f%d distance %2.2g (%.1fx). Trace with option 'TWn' to identify the merge.  Allow with 'Q12' (allow-wide)\n",
          minvertex->id, minfacet->id, mindist, -qh->min_vertex/(qh->ONEmerge + qh->DISTround));
        qh_errexit(qh, qh_ERRwide, minfacet, NULL);
      }
    }
  }
} /* check_maxout */
#else /* qh_NOmerge */
void qh_check_maxout(qhT *qh) {
  QHULL_UNUSED(qh)
}
#endif

/*---------------------------------

  qh_check_output(qh)
    performs the checks at the end of qhull algorithm
    Maybe called after Voronoi output.  If so, it recomputes centrums since they are Voronoi centers instead.
*/
void qh_check_output(qhT *qh) {
  int i;

  if (qh->STOPcone)
    return;
  if (qh->VERIFYoutput || qh->IStracing || qh->CHECKfrequently) {
    qh_checkpolygon(qh, qh->facet_list);
    qh_checkflipped_all(qh, qh->facet_list);
    qh_checkconvex(qh, qh->facet_list, qh_ALGORITHMfault);
  }else if (!qh->MERGING && qh_newstats(qh, qh->qhstat.precision, &i)) {
    qh_checkflipped_all(qh, qh->facet_list);
    qh_checkconvex(qh, qh->facet_list, qh_ALGORITHMfault);
  }
} /* check_output */



/*---------------------------------

  qh_check_point(qh, point, facet, maxoutside, maxdist, errfacet1, errfacet2, errcount )
    check that point is less than maxoutside from facet

  notes:
    only called from qh_checkpoints
    reports up to qh_MAXcheckpoint-1 errors per facet
*/
void qh_check_point(qhT *qh, pointT *point, facetT *facet, realT *maxoutside, realT *maxdist, facetT **errfacet1, facetT **errfacet2, int *errcount) {
  realT dist, nearest;

  /* occurs after statistics reported */
  qh_distplane(qh, point, facet, &dist);
  maximize_(*maxdist, dist);
  if (dist > *maxoutside) {
    (*errcount)++;
    if (*errfacet1 != facet) {
      *errfacet2= *errfacet1;
      *errfacet1= facet;
    }
    if (*errcount < qh_MAXcheckpoint) {
      nearest= qh_vertex_bestdist(qh, facet->vertices);
      qh_fprintf(qh, qh->ferr, 6111, "qhull precision error: point p%d is outside facet f%d, distance= %6.8g maxoutside= %6.8g nearest vertices %2.2g\n",
                qh_pointid(qh, point), facet->id, dist, *maxoutside, nearest);
    }
  }
} /* qh_check_point */


/*---------------------------------

  qh_check_points(qh)
    checks that all points are inside all facets

  notes:
    if many points and qh_check_maxout not called (i.e., !qh.MERGING),
       calls qh_findbesthorizon via qh_check_bestdist (seldom done).
    ignores flipped facets
    maxoutside includes 2 qh.DISTrounds
      one qh.DISTround for the computed distances in qh_check_points
    qh_printafacet and qh_printsummary needs only one qh.DISTround
    the computation for qh.VERIFYdirect does not account for qh.other_points

  design:
    if many points
      use qh_check_bestdist()
    else
      for all facets
        for all points
          check that point is inside facet
*/
void qh_check_points(qhT *qh) {
  facetT *facet, *errfacet1= NULL, *errfacet2= NULL;
  realT total, maxoutside, maxdist= -REALmax;
  pointT *point, **pointp, *pointtemp;
  int errcount;
  boolT testouter;

  maxoutside= qh_maxouter(qh);
  maxoutside += qh->DISTround;
  /* one more qh.DISTround for check computation */
  trace1((qh, qh->ferr, 1025, "qh_check_points: check all points below %2.2g of all facet planes\n",
          maxoutside));
  if (qh->num_good)   /* miss counts other_points and !good facets */
     total= (float)qh->num_good * (float)qh->num_points;
  else
     total= (float)qh->num_facets * (float)qh->num_points;
  if (total >= qh_VERIFYdirect && !qh->maxoutdone) {
    if (!qh_QUICKhelp && qh->SKIPcheckmax && qh->MERGING)
      qh_fprintf(qh, qh->ferr, 7075, "qhull input warning: merging without checking outer planes('Q5' or 'Po').  Verify may report that a point is outside of a facet.\n");
    qh_check_bestdist(qh);
  }else {
    if (qh_MAXoutside && qh->maxoutdone)
      testouter= True;
    else
      testouter= False;
    if (!qh_QUICKhelp) {
      if (qh->MERGEexact)
        qh_fprintf(qh, qh->ferr, 7076, "qhull input warning: exact merge ('Qx').  Verify may report that a point is outside of a facet.  See qh-optq.htm#Qx\n");
      else if (qh->SKIPcheckmax || qh->NOnearinside)
        qh_fprintf(qh, qh->ferr, 7077, "qhull input warning: no outer plane check ('Q5') or no processing of near-inside points ('Q8').  Verify may report that a point is outside of a facet.\n");
    }
    if (qh->PRINTprecision) {
      if (testouter)
        qh_fprintf(qh, qh->ferr, 8098, "\n\
Output completed.  Verifying that all points are below outer planes of\n\
all %sfacets.  Will make %2.0f distance computations.\n",
              (qh->ONLYgood ?  "good " : ""), total);
      else
        qh_fprintf(qh, qh->ferr, 8099, "\n\
Output completed.  Verifying that all points are below %2.2g of\n\
all %sfacets.  Will make %2.0f distance computations.\n",
              maxoutside, (qh->ONLYgood ?  "good " : ""), total);
    }
    FORALLfacets {
      if (!facet->good && qh->ONLYgood)
        continue;
      if (facet->flipped)
        continue;
      if (!facet->normal) {
        qh_fprintf(qh, qh->ferr, 7061, "qhull warning (qh_check_points): missing normal for facet f%d\n", facet->id);
        if (!errfacet1)
          errfacet1= facet;
        continue;
      }
      if (testouter) {
#if qh_MAXoutside
        maxoutside= facet->maxoutside + 2 * qh->DISTround;
        /* one DISTround to actual point and another to computed point */
#endif
      }
      errcount= 0;
      FORALLpoints {
        if (point != qh->GOODpointp)
          qh_check_point(qh, point, facet, &maxoutside, &maxdist, &errfacet1, &errfacet2, &errcount);
      }
      FOREACHpoint_(qh->other_points) {
        if (point != qh->GOODpointp)
          qh_check_point(qh, point, facet, &maxoutside, &maxdist, &errfacet1, &errfacet2, &errcount);
      }
      if (errcount >= qh_MAXcheckpoint) {
        qh_fprintf(qh, qh->ferr, 6422, "qhull precision error (qh_check_points): %d additional points outside facet f%d, maxdist= %6.8g\n",
             errcount-qh_MAXcheckpoint+1, facet->id, maxdist);
      }
    }
    if (maxdist > qh->outside_err) {
      qh_fprintf(qh, qh->ferr, 6112, "qhull precision error (qh_check_points): a coplanar point is %6.2g from convex hull.  The maximum value(qh.outside_err) is %6.2g\n",
                maxdist, qh->outside_err );
      qh_errexit2(qh, qh_ERRprec, errfacet1, errfacet2 );
    }else if (errfacet1 && qh->outside_err > REALmax/2)
        qh_errexit2(qh, qh_ERRprec, errfacet1, errfacet2 );
    /* else if errfacet1, the error was logged to qh.ferr but does not effect the output */
    trace0((qh, qh->ferr, 21, "qh_check_points: max distance outside %2.2g\n", maxdist));
  }
} /* check_points */


/*---------------------------------

  qh_checkconvex(qh, facetlist, fault )
    check that each ridge in facetlist is convex
    fault = qh_DATAfault if reporting errors from qh_initialhull with qh.ZEROcentrum
          = qh_ALGORITHMfault otherwise

  returns:
    counts Zconcaveridges and Zcoplanarridges
    errors if !qh.FORCEoutput ('Fo') and concaveridge or if merging a coplanar ridge
    overwrites Voronoi centers if set by qh_setvoronoi_all/qh_ASvoronoi

  notes:
    called by qh_initial_hull, qh_check_output, qh_all_merges ('Tc'), qh_build_withrestart ('QJ')
    does not test f.tricoplanar facets (qh_triangulate)
    must be no stronger than qh_test_appendmerge
    if not merging,
      tests vertices for neighboring simplicial facets < -qh.DISTround
    else if ZEROcentrum and simplicial facet,
      tests vertices for neighboring simplicial facets < 0.0
      tests centrums of neighboring nonsimplicial facets < 0.0
    else if ZEROcentrum 
      tests centrums of neighboring facets < 0.0
    else 
      tests centrums of neighboring facets < -qh.DISTround ('En' 'Rn')
    Does not test against -qh.centrum_radius since repeated computations may have different round-off errors (e.g., 'Rn')

  design:
    for all facets
      report flipped facets
      if ZEROcentrum and simplicial neighbors
        test vertices against neighbor
      else
        test centrum against neighbor
*/
void qh_checkconvex(qhT *qh, facetT *facetlist, int fault) {
  facetT *facet, *neighbor, **neighborp, *errfacet1=NULL, *errfacet2=NULL;
  vertexT *vertex;
  realT dist;
  pointT *centrum;
  boolT waserror= False, centrum_warning= False, tempcentrum= False, first_nonsimplicial= False, tested_simplicial, allsimplicial;
  int neighbor_i, neighbor_n;

  if (qh->ZEROcentrum) {
    trace1((qh, qh->ferr, 1064, "qh_checkconvex: check that facets are not-flipped and for qh.ZEROcentrum that simplicial vertices are below their neighbor (dist<0.0)\n"));
    first_nonsimplicial= True;
  }else if (!qh->MERGING) {
    trace1((qh, qh->ferr, 1026, "qh_checkconvex: check that facets are not-flipped and that simplicial vertices are convex by qh.DISTround ('En', 'Rn')\n"));
    first_nonsimplicial= True;
  }else
    trace1((qh, qh->ferr, 1062, "qh_checkconvex: check that facets are not-flipped and that their centrums are convex by qh.DISTround ('En', 'Rn') \n"));
  if (!qh->RERUN) {
    zzval_(Zconcaveridges)= 0;
    zzval_(Zcoplanarridges)= 0;
  }
  FORALLfacet_(facetlist) {
    if (facet->flipped) {
      qh_joggle_restart(qh, "flipped facet"); /* also tested by qh_checkflipped */
      qh_fprintf(qh, qh->ferr, 6113, "qhull precision error: f%d is flipped (interior point is outside)\n",
               facet->id);
      errfacet1= facet;
      waserror= True;
      continue;
    }
    if (facet->tricoplanar)
      continue;
    if (qh->MERGING && (!qh->ZEROcentrum || !facet->simplicial)) {
      allsimplicial= False;
      tested_simplicial= False;
    }else {
      allsimplicial= True;
      tested_simplicial= True;
      FOREACHneighbor_i_(qh, facet) {
        if (neighbor->tricoplanar)
          continue;
        if (!neighbor->simplicial) {
          allsimplicial= False;
          continue;
        }
        vertex= SETelemt_(facet->vertices, neighbor_i, vertexT);
        qh_distplane(qh, vertex->point, neighbor, &dist);
        if (dist >= -qh->DISTround) {
          if (fault == qh_DATAfault) {
            qh_joggle_restart(qh, "non-convex initial simplex");
            if (dist > qh->DISTround)
              qh_fprintf(qh, qh->ferr, 6114, "qhull precision error: initial simplex is not convex, since p%d(v%d) is %6.4g above opposite f%d\n", 
                  qh_pointid(qh, vertex->point), vertex->id, dist, neighbor->id);
            else
              qh_fprintf(qh, qh->ferr, 6379, "qhull precision error: initial simplex is not convex, since p%d(v%d) is within roundoff of opposite facet f%d (dist %6.4g)\n",
                  qh_pointid(qh, vertex->point), vertex->id, neighbor->id, dist);
            qh_errexit(qh, qh_ERRsingular, neighbor, NULL);
          }
          if (dist > qh->DISTround) {
            zzinc_(Zconcaveridges);
            qh_joggle_restart(qh, "concave ridge");
            qh_fprintf(qh, qh->ferr, 6115, "qhull precision error: f%d is concave to f%d, since p%d(v%d) is %6.4g above f%d\n",
              facet->id, neighbor->id, qh_pointid(qh, vertex->point), vertex->id, dist, neighbor->id);
            errfacet1= facet;
            errfacet2= neighbor;
            waserror= True;
          }else if (qh->ZEROcentrum) {
            if (dist > 0.0) {     /* qh_checkzero checked convex (dist < (- 2*qh->DISTround)), computation may differ e.g. 'Rn' */
              zzinc_(Zcoplanarridges);
              qh_joggle_restart(qh, "coplanar ridge");
              qh_fprintf(qh, qh->ferr, 6116, "qhull precision error: f%d is clearly not convex to f%d, since p%d(v%d) is %6.4g above or coplanar with f%d with qh.ZEROcentrum\n",
                facet->id, neighbor->id, qh_pointid(qh, vertex->point), vertex->id, dist, neighbor->id);
              errfacet1= facet;
              errfacet2= neighbor;
              waserror= True;
            }
          }else {
            zzinc_(Zcoplanarridges);
            qh_joggle_restart(qh, "coplanar ridge");
            trace0((qh, qh->ferr, 22, "qhull precision error: f%d is coplanar to f%d, since p%d(v%d) is within %6.4g of f%d, during p%d\n",
              facet->id, neighbor->id, qh_pointid(qh, vertex->point), vertex->id, dist, neighbor->id, qh->furthest_id));
          }
        }
      }
    }
    if (!allsimplicial) {
      if (first_nonsimplicial) {
        trace1((qh, qh->ferr, 1063, "qh_checkconvex: starting with f%d, also check that centrums of non-simplicial ridges are below their neighbors (dist<0.0)\n",
             facet->id));
        first_nonsimplicial= False;
      }
      if (qh->CENTERtype == qh_AScentrum) {
        if (!facet->center)
          facet->center= qh_getcentrum(qh, facet);
        centrum= facet->center;
      }else {
        if (!centrum_warning && !facet->simplicial) {  /* recomputed centrum correct for simplicial facets */
           centrum_warning= True;
           qh_fprintf(qh, qh->ferr, 7062, "qhull warning: recomputing centrums for convexity test.  This may lead to false, precision errors.\n");
        }
        centrum= qh_getcentrum(qh, facet);
        tempcentrum= True;
      }
      FOREACHneighbor_(facet) {
        if (neighbor->simplicial && tested_simplicial) /* tested above since f.simplicial */
          continue;
        if (neighbor->tricoplanar)
          continue;
        zzinc_(Zdistconvex);
        qh_distplane(qh, centrum, neighbor, &dist);
        if (dist > qh->DISTround) {
          zzinc_(Zconcaveridges);
          qh_joggle_restart(qh, "concave ridge");
          qh_fprintf(qh, qh->ferr, 6117, "qhull precision error: f%d is concave to f%d.  Centrum of f%d is %6.4g above f%d\n",
            facet->id, neighbor->id, facet->id, dist, neighbor->id);
          errfacet1= facet;
          errfacet2= neighbor;
          waserror= True;
        }else if (dist >= 0.0) {   /* if arithmetic always rounds the same,
                                     can test against centrum radius instead */
          zzinc_(Zcoplanarridges);
          qh_joggle_restart(qh, "coplanar ridge");
          qh_fprintf(qh, qh->ferr, 6118, "qhull precision error: f%d is coplanar or concave to f%d.  Centrum of f%d is %6.4g above f%d\n",
            facet->id, neighbor->id, facet->id, dist, neighbor->id);
          errfacet1= facet;
          errfacet2= neighbor;
          waserror= True;
        }
      }
      if (tempcentrum)
        qh_memfree(qh, centrum, qh->normal_size);
    }
  }
  if (waserror && !qh->FORCEoutput)
    qh_errexit2(qh, qh_ERRprec, errfacet1, errfacet2);
} /* checkconvex */


/*---------------------------------

  qh_checkfacet(qh, facet, newmerge, waserror )
    checks for consistency errors in facet
    newmerge set if from merge_r.c

  returns:
    sets waserror if any error occurs

  checks:
    vertex ids are inverse sorted
    unless newmerge, at least hull_dim neighbors and vertices (exactly if simplicial)
    if non-simplicial, at least as many ridges as neighbors
    neighbors are not duplicated
    ridges are not duplicated
    in 3-d, ridges=verticies
    (qh.hull_dim-1) ridge vertices
    neighbors are reciprocated
    ridge neighbors are facet neighbors and a ridge for every neighbor
    simplicial neighbors match facetintersect
    vertex intersection matches vertices of common ridges
    vertex neighbors and facet vertices agree
    all ridges have distinct vertex sets

  notes:
    called by qh_tracemerge and qh_checkpolygon
    uses neighbor->seen

  design:
    check sets
    check vertices
    check sizes of neighbors and vertices
    check for qh_MERGEridge and qh_DUPLICATEridge flags
    check neighbor set
    check ridge set
    check ridges, neighbors, and vertices
*/
void qh_checkfacet(qhT *qh, facetT *facet, boolT newmerge, boolT *waserrorp) {
  facetT *neighbor, **neighborp, *errother=NULL;
  ridgeT *ridge, **ridgep, *errridge= NULL, *ridge2;
  vertexT *vertex, **vertexp;
  unsigned int previousid= INT_MAX;
  int numneighbors, numvertices, numridges=0, numRvertices=0;
  boolT waserror= False;
  int skipA, skipB, ridge_i, ridge_n, i, last_v= qh->hull_dim-2;
  setT *intersection;

  trace4((qh, qh->ferr, 4088, "qh_checkfacet: check f%d newmerge? %d\n", facet->id, newmerge));
  if (facet->id >= qh->facet_id) {
    qh_fprintf(qh, qh->ferr, 6414, "qhull internal error (qh_checkfacet): unknown facet id f%d >= qh.facet_id (%d)\n", facet->id, qh->facet_id);
    waserror= True;
  }
  if (facet->visitid > qh->visit_id) {
    qh_fprintf(qh, qh->ferr, 6415, "qhull internal error (qh_checkfacet): expecting f%d.visitid <= qh.visit_id (%d).  Got visitid %d\n", facet->id, qh->visit_id, facet->visitid);
    waserror= True;
  }
  if (facet->visible && !qh->NEWtentative) {
    qh_fprintf(qh, qh->ferr, 6119, "qhull internal error (qh_checkfacet): facet f%d is on qh.visible_list\n",
      facet->id);
    qh_errexit(qh, qh_ERRqhull, facet, NULL);
  }
  if (facet->redundant && !facet->visible && qh_setsize(qh, qh->degen_mergeset)==0) {
    qh_fprintf(qh, qh->ferr, 6399, "qhull internal error (qh_checkfacet): redundant facet f%d not on qh.visible_list\n",
      facet->id);
    waserror= True;
  }
  if (facet->degenerate && !facet->visible && qh_setsize(qh, qh->degen_mergeset)==0) { 
    qh_fprintf(qh, qh->ferr, 6400, "qhull internal error (qh_checkfacet): degenerate facet f%d is not on qh.visible_list and qh.degen_mergeset is empty\n",
      facet->id);
    waserror= True;
  }
  if (!facet->normal) {
    qh_fprintf(qh, qh->ferr, 6120, "qhull internal error (qh_checkfacet): facet f%d does not have a normal\n",
      facet->id);
    waserror= True;
  }
  if (!facet->newfacet) {
    if (facet->dupridge) {
      qh_fprintf(qh, qh->ferr, 6349, "qhull internal error (qh_checkfacet): f%d is 'dupridge' but it is not a newfacet on qh.newfacet_list f%d\n",
        facet->id, getid_(qh->newfacet_list));
      waserror= True;
    }
    if (facet->newmerge) {
      qh_fprintf(qh, qh->ferr, 6383, "qhull internal error (qh_checkfacet): f%d is 'newmerge' but it is not a newfacet on qh.newfacet_list f%d.  Missing call to qh_reducevertices\n",  
        facet->id, getid_(qh->newfacet_list));
      waserror= True;
    }
  }
  qh_setcheck(qh, facet->vertices, "vertices for f", facet->id);
  qh_setcheck(qh, facet->ridges, "ridges for f", facet->id);
  qh_setcheck(qh, facet->outsideset, "outsideset for f", facet->id);
  qh_setcheck(qh, facet->coplanarset, "coplanarset for f", facet->id);
  qh_setcheck(qh, facet->neighbors, "neighbors for f", facet->id);
  FOREACHvertex_(facet->vertices) {
    if (vertex->deleted) {
      qh_fprintf(qh, qh->ferr, 6121, "qhull internal error (qh_checkfacet): deleted vertex v%d in f%d\n", vertex->id, facet->id);
      qh_errprint(qh, "ERRONEOUS", NULL, NULL, NULL, vertex);
      waserror= True;
    }
    if (vertex->id >= previousid) {
      qh_fprintf(qh, qh->ferr, 6122, "qhull internal error (qh_checkfacet): vertices of f%d are not in descending id order at v%d\n", facet->id, vertex->id);
      waserror= True;
      break;
    }
    previousid= vertex->id;
  }
  numneighbors= qh_setsize(qh, facet->neighbors);
  numvertices= qh_setsize(qh, facet->vertices);
  numridges= qh_setsize(qh, facet->ridges);
  if (facet->simplicial) {
    if (numvertices+numneighbors != 2*qh->hull_dim
    && !facet->degenerate && !facet->redundant) {
      qh_fprintf(qh, qh->ferr, 6123, "qhull internal error (qh_checkfacet): for simplicial facet f%d, #vertices %d + #neighbors %d != 2*qh->hull_dim\n",
                facet->id, numvertices, numneighbors);
      qh_setprint(qh, qh->ferr, "", facet->neighbors);
      waserror= True;
    }
  }else { /* non-simplicial */
    if (!newmerge
    &&(numvertices < qh->hull_dim || numneighbors < qh->hull_dim)
    && !facet->degenerate && !facet->redundant) {
      qh_fprintf(qh, qh->ferr, 6124, "qhull internal error (qh_checkfacet): for facet f%d, #vertices %d or #neighbors %d < qh->hull_dim\n",
         facet->id, numvertices, numneighbors);
       waserror= True;
    }
    /* in 3-d, can get a vertex twice in an edge list, e.g., RBOX 1000 s W1e-13 t995849315 D2 | QHULL d Tc Tv TP624 TW1e-13 T4 */
    if (numridges < numneighbors
    ||(qh->hull_dim == 3 && numvertices > numridges && !qh->NEWfacets)
    ||(qh->hull_dim == 2 && numridges + numvertices + numneighbors != 6)) {
      if (!facet->degenerate && !facet->redundant) {
        qh_fprintf(qh, qh->ferr, 6125, "qhull internal error (qh_checkfacet): for facet f%d, #ridges %d < #neighbors %d or(3-d) > #vertices %d or(2-d) not all 2\n",
            facet->id, numridges, numneighbors, numvertices);
        waserror= True;
      }
    }
  }
  FOREACHneighbor_(facet) {
    if (neighbor == qh_MERGEridge || neighbor == qh_DUPLICATEridge) {
      qh_fprintf(qh, qh->ferr, 6126, "qhull internal error (qh_checkfacet): facet f%d still has a MERGEridge or DUPLICATEridge neighbor\n", facet->id);
      qh_errexit(qh, qh_ERRqhull, facet, NULL);
    }
    if (neighbor->visible) {
      qh_fprintf(qh, qh->ferr, 6401, "qhull internal error (qh_checkfacet): facet f%d has deleted neighbor f%d (qh.visible_list)\n",
        facet->id, neighbor->id);
      errother= neighbor;
      waserror= True;
    }
    neighbor->seen= True;
  }
  FOREACHneighbor_(facet) {
    if (!qh_setin(neighbor->neighbors, facet)) {
      qh_fprintf(qh, qh->ferr, 6127, "qhull internal error (qh_checkfacet): facet f%d has neighbor f%d, but f%d does not have neighbor f%d\n",
              facet->id, neighbor->id, neighbor->id, facet->id);
      errother= neighbor;
      waserror= True;
    }
    if (!neighbor->seen) {
      qh_fprintf(qh, qh->ferr, 6128, "qhull internal error (qh_checkfacet): facet f%d has a duplicate neighbor f%d\n",
              facet->id, neighbor->id);
      errother= neighbor;
      waserror= True;
    }
    neighbor->seen= False;
  }
  FOREACHridge_(facet->ridges) {
    qh_setcheck(qh, ridge->vertices, "vertices for r", ridge->id);
    ridge->seen= False;
  }
  FOREACHridge_(facet->ridges) {
    if (ridge->seen) {
      qh_fprintf(qh, qh->ferr, 6129, "qhull internal error (qh_checkfacet): facet f%d has a duplicate ridge r%d\n",
              facet->id, ridge->id);
      errridge= ridge;
      waserror= True;
    }
    ridge->seen= True;
    numRvertices= qh_setsize(qh, ridge->vertices);
    if (numRvertices != qh->hull_dim - 1) {
      qh_fprintf(qh, qh->ferr, 6130, "qhull internal error (qh_checkfacet): ridge between f%d and f%d has %d vertices\n",
                ridge->top->id, ridge->bottom->id, numRvertices);
      errridge= ridge;
      waserror= True;
    }
    neighbor= otherfacet_(ridge, facet);
    neighbor->seen= True;
    if (!qh_setin(facet->neighbors, neighbor)) {
      qh_fprintf(qh, qh->ferr, 6131, "qhull internal error (qh_checkfacet): for facet f%d, neighbor f%d of ridge r%d not in facet\n",
           facet->id, neighbor->id, ridge->id);
      errridge= ridge;
      waserror= True;
    }
    if (!facet->newfacet && !neighbor->newfacet) {
      if ((!ridge->tested) | ridge->nonconvex | ridge->mergevertex) {
        qh_fprintf(qh, qh->ferr, 6384, "qhull internal error (qh_checkfacet): ridge r%d is nonconvex (%d), mergevertex (%d) or not tested (%d) for facet f%d, neighbor f%d\n",
          ridge->id, ridge->nonconvex, ridge->mergevertex, ridge->tested, facet->id, neighbor->id);
        errridge= ridge;
        waserror= True;
      }
    }
  }
  if (!facet->simplicial) {
    FOREACHneighbor_(facet) {
      if (!neighbor->seen) {
        qh_fprintf(qh, qh->ferr, 6132, "qhull internal error (qh_checkfacet): facet f%d does not have a ridge for neighbor f%d\n",
              facet->id, neighbor->id);
        errother= neighbor;
        waserror= True;
      }
      intersection= qh_vertexintersect_new(qh, facet->vertices, neighbor->vertices);
      qh_settemppush(qh, intersection);
      FOREACHvertex_(facet->vertices) {
        vertex->seen= False;
        vertex->seen2= False;
      }
      FOREACHvertex_(intersection)
        vertex->seen= True;
      FOREACHridge_(facet->ridges) {
        if (neighbor != otherfacet_(ridge, facet))
            continue;
        FOREACHvertex_(ridge->vertices) {
          if (!vertex->seen) {
            qh_fprintf(qh, qh->ferr, 6133, "qhull internal error (qh_checkfacet): vertex v%d in r%d not in f%d intersect f%d\n",
                  vertex->id, ridge->id, facet->id, neighbor->id);
            qh_errexit(qh, qh_ERRqhull, facet, ridge);
          }
          vertex->seen2= True;
        }
      }
      if (!newmerge) {
        FOREACHvertex_(intersection) {
          if (!vertex->seen2) {
            if (!qh->MERGING) {
              qh_fprintf(qh, qh->ferr, 6420, "qhull topology error (qh_checkfacet): vertex v%d in f%d intersect f%d but not in a ridge.  Last point was p%d\n",
                     vertex->id, facet->id, neighbor->id, qh->furthest_id);
              if (!qh->FORCEoutput) {
                qh_errprint(qh, "ERRONEOUS", facet, neighbor, NULL, vertex);
                qh_errexit(qh, qh_ERRtopology, NULL, NULL);
              }
            }else {
              trace4((qh, qh->ferr, 4025, "qh_checkfacet: vertex v%d in f%d intersect f%d but not in a ridge.  Repaired by qh_remove_extravertices in qh_reducevertices\n",
                vertex->id, facet->id, neighbor->id));
            }
          }
        }
      }
      qh_settempfree(qh, &intersection);
    }
  }else { /* simplicial */
    FOREACHneighbor_(facet) {
      if (neighbor->simplicial && !facet->degenerate && !neighbor->degenerate) {
        skipA= SETindex_(facet->neighbors, neighbor);
        skipB= qh_setindex(neighbor->neighbors, facet);
        if (skipA<0 || skipB<0 || !qh_setequal_skip(facet->vertices, skipA, neighbor->vertices, skipB)) {
          qh_fprintf(qh, qh->ferr, 6135, "qhull internal error (qh_checkfacet): facet f%d skip %d and neighbor f%d skip %d do not match \n",
                   facet->id, skipA, neighbor->id, skipB);
          errother= neighbor;
          waserror= True;
        }
      }
    }
  }
  if (!newmerge && qh->CHECKduplicates && qh->hull_dim < 5 && (qh->IStracing > 2 || qh->CHECKfrequently)) {
    FOREACHridge_i_(qh, facet->ridges) {           /* expensive, if was merge and qh_maybe_duplicateridges hasn't been called yet */
      if (!ridge->mergevertex) {
        for (i=ridge_i+1; i < ridge_n; i++) {
          ridge2= SETelemt_(facet->ridges, i, ridgeT);
          if (SETelem_(ridge->vertices, last_v) == SETelem_(ridge2->vertices, last_v)) { /* SETfirst is likely to be the same */
            if (SETfirst_(ridge->vertices) == SETfirst_(ridge2->vertices)) {
              if (qh_setequal(ridge->vertices, ridge2->vertices)) {
                qh_fprintf(qh, qh->ferr, 6294, "qhull internal error (qh_checkfacet): ridges r%d and r%d (f%d) have the same vertices\n", /* same as duplicate ridge */
                    ridge->id, ridge2->id, facet->id);
                errridge= ridge;
                waserror= True;
              }
            }
          }
        }
      }
    }
  }
  if (waserror) {
    qh_errprint(qh, "ERRONEOUS", facet, errother, errridge, NULL);
    *waserrorp= True;
  }
} /* checkfacet */

/*---------------------------------

  qh_checkflipped_all(qh, facetlist )
    checks orientation of facets in list against interior point

  notes:
    called by qh_checkoutput
*/
void qh_checkflipped_all(qhT *qh, facetT *facetlist) {
  facetT *facet;
  boolT waserror= False;
  realT dist;

  if (facetlist == qh->facet_list)
    zzval_(Zflippedfacets)= 0;
  FORALLfacet_(facetlist) {
    if (facet->normal && !qh_checkflipped(qh, facet, &dist, !qh_ALL)) {
      qh_fprintf(qh, qh->ferr, 6136, "qhull precision error: facet f%d is flipped, distance= %6.12g\n",
              facet->id, dist);
      if (!qh->FORCEoutput) {
        qh_errprint(qh, "ERRONEOUS", facet, NULL, NULL, NULL);
        waserror= True;
      }
    }
  }
  if (waserror) {
    qh_fprintf(qh, qh->ferr, 8101, "\n\
A flipped facet occurs when its distance to the interior point is\n\
greater than or equal to %2.2g, the maximum roundoff error.\n", -qh->DISTround);
    qh_errexit(qh, qh_ERRprec, NULL, NULL);
  }
} /* checkflipped_all */

/*---------------------------------

  qh_checklists(qh, facetlist )
    Check and repair facetlist and qh.vertex_list for infinite loops or overwritten facets
    Checks that qh.newvertex_list is on qh.vertex_list
    if facetlist is qh.facet_list
      Checks that qh.visible_list and qh.newfacet_list are on qh.facet_list
    Updates qh.facetvisit and qh.vertexvisit

  returns:
    True if no errors found
    If false, repairs erroneous lists to prevent infinite loops by FORALL macros

  notes:
    called by qh_buildtracing, qh_checkpolygon, qh_collectstatistics, qh_printfacetlist, qh_printsummary
    not called by qh_printlists

  design:
    if facetlist
      check qh.facet_tail
      for each facet
        check for infinite loop or overwritten facet
        check previous facet
      if facetlist is qh.facet_list
        check qh.next_facet, qh.visible_list and qh.newfacet_list
    if vertexlist
      check qh.vertex_tail
      for each vertex
        check for infinite loop or overwritten vertex
        check previous vertex
      check qh.newvertex_list
*/
boolT qh_checklists(qhT *qh, facetT *facetlist) {
  facetT *facet, *errorfacet= NULL, *errorfacet2= NULL, *previousfacet;
  vertexT *vertex, *vertexlist, *previousvertex, *errorvertex= NULL;
  boolT waserror= False, newseen= False, nextseen= False, newvertexseen= False, visibleseen= False;

  if (facetlist == qh->newfacet_list || facetlist == qh->visible_list) {
    vertexlist= qh->vertex_list;
    previousvertex= NULL;
    trace2((qh, qh->ferr, 2110, "qh_checklists: check qh.%s_list f%d and qh.vertex_list v%d\n", 
        (facetlist == qh->newfacet_list ? "newfacet" : "visible"), facetlist->id, getid_(vertexlist)));
  }else {
    vertexlist= qh->vertex_list;
    previousvertex= NULL;
    trace2((qh, qh->ferr, 2111, "qh_checklists: check %slist f%d and qh.vertex_list v%d\n", 
        (facetlist == qh->facet_list ? "qh.facet_" : "facet"), getid_(facetlist), getid_(vertexlist)));
  }
  if (facetlist) {
    if (qh->facet_tail == NULL || qh->facet_tail->id != 0 || qh->facet_tail->next != NULL) {
      qh_fprintf(qh, qh->ferr, 6397, "qhull internal error (qh_checklists): either qh.facet_tail f%d is NULL, or its id is not 0, or its next is not NULL\n", 
          getid_(qh->facet_tail));
      qh_errexit(qh, qh_ERRqhull, qh->facet_tail, NULL);
    }
    previousfacet= (facetlist == qh->facet_list ? NULL : facetlist->previous);
    qh->visit_id++;
    FORALLfacet_(facetlist) {
      if (facet->visitid >= qh->visit_id || facet->id >= qh->facet_id) {
        waserror= True;
        errorfacet= facet;
        errorfacet2= previousfacet;
        if (facet->visitid == qh->visit_id)
          qh_fprintf(qh, qh->ferr, 6039, "qhull internal error (qh_checklists): f%d already in facetlist causing an infinite loop ... f%d > f%d ... > f%d > f%d.  Truncate facetlist at f%d\n", 
            facet->id, facet->id, facet->next->id, getid_(previousfacet), facet->id, getid_(previousfacet));
        else
          qh_fprintf(qh, qh->ferr, 6350, "qhull internal error (qh_checklists): unknown or overwritten facet f%d, either id >= qh.facet_id (%d) or f.visitid %u > qh.visit_id %u.  Facetlist terminated at previous facet f%d\n", 
              facet->id, qh->facet_id, facet->visitid, qh->visit_id, getid_(previousfacet));
        if (previousfacet)
          previousfacet->next= qh->facet_tail;
        else
          facetlist= qh->facet_tail;
        break;
      }
      facet->visitid= qh->visit_id;
      if (facet->previous != previousfacet) {
        qh_fprintf(qh, qh->ferr, 6416, "qhull internal error (qh_checklists): expecting f%d.previous == f%d.  Got f%d\n",
          facet->id, getid_(previousfacet), getid_(facet->previous));
        waserror= True;
        errorfacet= facet;
        errorfacet2= facet->previous;
      }
      previousfacet= facet;
      if (facetlist == qh->facet_list) {
        if (facet == qh->visible_list) {
          if(newseen){
            qh_fprintf(qh, qh->ferr, 6285, "qhull internal error (qh_checklists): qh.visible_list f%d is after qh.newfacet_list f%d.  It should be at, before, or NULL\n",
              facet->id, getid_(qh->newfacet_list));
            waserror= True;
            errorfacet= facet;
            errorfacet2= qh->newfacet_list;
          }
          visibleseen= True;
        }
        if (facet == qh->newfacet_list)
          newseen= True;
        if (facet == qh->facet_next)
          nextseen= True;
      }
    }
    if (facetlist == qh->facet_list) {
      if (!nextseen && qh->facet_next && qh->facet_next->next) {
        qh_fprintf(qh, qh->ferr, 6369, "qhull internal error (qh_checklists): qh.facet_next f%d for qh_addpoint is not on qh.facet_list f%d\n", 
          qh->facet_next->id, facetlist->id);
        waserror= True;
        errorfacet= qh->facet_next;
        errorfacet2= facetlist;
      }
      if (!newseen && qh->newfacet_list && qh->newfacet_list->next) {
        qh_fprintf(qh, qh->ferr, 6286, "qhull internal error (qh_checklists): qh.newfacet_list f%d is not on qh.facet_list f%d\n", 
          qh->newfacet_list->id, facetlist->id);
        waserror= True;
        errorfacet= qh->newfacet_list;
        errorfacet2= facetlist;
      }
      if (!visibleseen && qh->visible_list && qh->visible_list->next) {
        qh_fprintf(qh, qh->ferr, 6138, "qhull internal error (qh_checklists): qh.visible_list f%d is not on qh.facet_list f%d\n", 
          qh->visible_list->id, facetlist->id);
        waserror= True;
        errorfacet= qh->visible_list;
        errorfacet2= facetlist;
      }
    }
  }
  if (vertexlist) {
    if (qh->vertex_tail == NULL || qh->vertex_tail->id != 0 || qh->vertex_tail->next != NULL) {
      qh_fprintf(qh, qh->ferr, 6366, "qhull internal error (qh_checklists): either qh.vertex_tail v%d is NULL, or its id is not 0, or its next is not NULL\n", 
           getid_(qh->vertex_tail));
      qh_errprint(qh, "ERRONEOUS", errorfacet, errorfacet2, NULL, qh->vertex_tail);
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }
    qh->vertex_visit++;
    FORALLvertex_(vertexlist) {
      if (vertex->visitid >= qh->vertex_visit || vertex->id >= qh->vertex_id) {
        waserror= True;
        errorvertex= vertex;
        if (vertex->visitid == qh->visit_id)
          qh_fprintf(qh, qh->ferr, 6367, "qhull internal error (qh_checklists): v%d already in vertexlist causing an infinite loop ... v%d > v%d ... > v%d > v%d.  Truncate vertexlist at v%d\n", 
            vertex->id, vertex->id, vertex->next->id, getid_(previousvertex), vertex->id, getid_(previousvertex));
        else
          qh_fprintf(qh, qh->ferr, 6368, "qhull internal error (qh_checklists): unknown or overwritten vertex v%d, either id >= qh.vertex_id (%d) or v.visitid %u > qh.visit_id %u.  vertexlist terminated at previous vertex v%d\n", 
            vertex->id, qh->vertex_id, vertex->visitid, qh->visit_id, getid_(previousvertex));
        if (previousvertex)
          previousvertex->next= qh->vertex_tail;
        else
          vertexlist= qh->vertex_tail;
        break;
      }
      vertex->visitid= qh->vertex_visit;
      if (vertex->previous != previousvertex) {
        qh_fprintf(qh, qh->ferr, 6427, "qhull internal error (qh_checklists): expecting v%d.previous == v%d.  Got v%d\n",
              vertex->id, previousvertex, getid_(vertex->previous));
        waserror= True;
        errorvertex= vertex;
      }
      previousvertex= vertex;
      if(vertex == qh->newvertex_list)
        newvertexseen= True;
    }
    if(!newvertexseen && qh->newvertex_list && qh->newvertex_list->next) {
      qh_fprintf(qh, qh->ferr, 6287, "qhull internal error (qh_checklists): new vertex list v%d is not on vertex list\n", qh->newvertex_list->id);
      waserror= True;
      errorvertex= qh->newvertex_list;
    }
  }
  if (waserror) {
    qh_errprint(qh, "ERRONEOUS", errorfacet, errorfacet2, NULL, errorvertex);
    return False;
  }
  return True;
} /* checklists */

/*---------------------------------

  qh_checkpolygon(qh, facetlist )
    checks the correctness of the structure

  notes:
    called by qh_addpoint, qh_all_vertexmerge, qh_check_output, qh_initialhull, qh_prepare_output, qh_triangulate
    call with qh.facet_list or qh.newfacet_list or another list
    checks num_facets and num_vertices if qh.facet_list

  design:
    check and repair lists for infinite loop
    for each facet
      check f.newfacet and f.visible
      check facet and outside set if qh.NEWtentative and not f.newfacet, or not f.visible
    initializes vertexlist for qh.facet_list or qh.newfacet_list
    for each vertex
      check vertex
      check v.newfacet
    for each facet
      count f.ridges
      check and count f.vertices
    if checking qh.facet_list
      check facet count
      if qh.VERTEXneighbors
        check and count v.neighbors for all vertices
        check v.neighbors count and report possible causes of mismatch
        check that facets are in their v.neighbors
      check vertex count
*/
void qh_checkpolygon(qhT *qh, facetT *facetlist) {
  facetT *facet, *neighbor, **neighborp;
  facetT *errorfacet= NULL, *errorfacet2= NULL;
  vertexT *vertex, **vertexp, *vertexlist;
  int numfacets= 0, numvertices= 0, numridges= 0;
  int totvneighbors= 0, totfacetvertices= 0;
  boolT waserror= False, newseen= False, newvertexseen= False, nextseen= False, visibleseen= False;
  boolT checkfacet;

  trace1((qh, qh->ferr, 1027, "qh_checkpolygon: check all facets from f%d, qh.NEWtentative? %d\n", facetlist->id, qh->NEWtentative));
  if (!qh_checklists(qh, facetlist)) {
    waserror= True;
    qh_fprintf(qh, qh->ferr, 6374, "qhull internal error: qh_checklists failed in qh_checkpolygon\n");
    if (qh->num_facets < 4000)
      qh_printlists(qh);
  }
  if (facetlist != qh->facet_list || qh->ONLYgood)
    nextseen= True; /* allow f.outsideset */
  FORALLfacet_(facetlist) {
    if (facet == qh->visible_list)
      visibleseen= True;
    if (facet == qh->newfacet_list)
      newseen= True;
    if (facet->newfacet && !newseen && !visibleseen) {
        qh_fprintf(qh, qh->ferr, 6289, "qhull internal error (qh_checkpolygon): f%d is 'newfacet' but it is not on qh.newfacet_list f%d or visible_list f%d\n",  facet->id, getid_(qh->newfacet_list), getid_(qh->visible_list));
        qh_errexit(qh, qh_ERRqhull, facet, NULL);
    }
    if (!facet->newfacet && newseen) {
        qh_fprintf(qh, qh->ferr, 6292, "qhull internal error (qh_checkpolygon): f%d is on qh.newfacet_list f%d but it is not 'newfacet'\n",  facet->id, getid_(qh->newfacet_list));
        qh_errexit(qh, qh_ERRqhull, facet, NULL);
    }
    if (facet->visible != (visibleseen & !newseen)) {
      if(facet->visible)
        qh_fprintf(qh, qh->ferr, 6290, "qhull internal error (qh_checkpolygon): f%d is 'visible' but it is not on qh.visible_list f%d\n", facet->id, getid_(qh->visible_list));
      else
        qh_fprintf(qh, qh->ferr, 6291, "qhull internal error (qh_checkpolygon): f%d is on qh.visible_list f%d but it is not 'visible'\n", facet->id, qh->newfacet_list->id);
      qh_errexit(qh, qh_ERRqhull, facet, NULL);
    }
    if (qh->NEWtentative) {
      checkfacet= !facet->newfacet;
    }else {
      checkfacet= !facet->visible;
    }
    if(checkfacet) {
      if (!nextseen) {
        if (facet == qh->facet_next)  /* previous facets do not have outsideset */
          nextseen= True;
        else if (qh_setsize(qh, facet->outsideset)) {
          if (!qh->NARROWhull
#if !qh_COMPUTEfurthest
          || facet->furthestdist >= qh->MINoutside
#endif
          ) {
            qh_fprintf(qh, qh->ferr, 6137, "qhull internal error (qh_checkpolygon): f%d has outside points before qh.facet_next f%d\n",
                     facet->id, getid_(qh->facet_next));
            qh_errexit2(qh, qh_ERRqhull, facet, qh->facet_next);
          }
        }
      }
      numfacets++;
      qh_checkfacet(qh, facet, False, &waserror);
    }else if (facet->visible && qh->NEWfacets) {
      if (!SETempty_(facet->neighbors) || !SETempty_(facet->ridges)) {
        qh_fprintf(qh, qh->ferr, 6376, "qhull internal error (qh_checkpolygon): expecting empty f.neighbors and f.ridges for visible facet f%d.  Got %d neighbors and %d ridges\n", 
          facet->id, qh_setsize(qh, facet->neighbors), qh_setsize(qh, facet->ridges));
        qh_errexit(qh, qh_ERRqhull, facet, NULL);
      }
    }
  }
  if (facetlist == qh->facet_list) {
    vertexlist= qh->vertex_list;
  }else if (facetlist == qh->newfacet_list) {
    vertexlist= qh->newvertex_list;
  }else {
    vertexlist= NULL;
  }
  FORALLvertex_(vertexlist) {
    qh_checkvertex(qh, vertex, !qh_ALL, &waserror);
    if(vertex == qh->newvertex_list)
      newvertexseen= True;
    vertex->seen= False;
    vertex->visitid= 0;
    if(vertex->newfacet && !newvertexseen && !vertex->deleted) {
      qh_fprintf(qh, qh->ferr, 6288, "qhull internal error (qh_checkpolygon): v%d is 'newfacet' but it is not on new vertex list v%d\n", vertex->id, getid_(qh->newvertex_list));
      qh_errexit(qh, qh_ERRqhull, qh->visible_list, NULL);
    }
  }
  FORALLfacet_(facetlist) {
    if (facet->visible)
      continue;
    if (facet->simplicial)
      numridges += qh->hull_dim;
    else
      numridges += qh_setsize(qh, facet->ridges);
    FOREACHvertex_(facet->vertices) {
      vertex->visitid++;
      if (!vertex->seen) {
        vertex->seen= True;
        numvertices++;
        if (qh_pointid(qh, vertex->point) == qh_IDunknown) {
          qh_fprintf(qh, qh->ferr, 6139, "qhull internal error (qh_checkpolygon): unknown point %p for vertex v%d first_point %p\n",
                   vertex->point, vertex->id, qh->first_point);
          waserror= True;
        }
      }
    }
  }
  qh->vertex_visit += (unsigned int)numfacets;
  if (facetlist == qh->facet_list) {
    if (numfacets != qh->num_facets - qh->num_visible) {
      qh_fprintf(qh, qh->ferr, 6140, "qhull internal error (qh_checkpolygon): actual number of facets is %d, cumulative facet count is %d - %d visible facets\n",
              numfacets, qh->num_facets, qh->num_visible);
      waserror= True;
    }
    qh->vertex_visit++;
    if (qh->VERTEXneighbors) {
      FORALLvertices {
        if (!vertex->neighbors) {
          qh_fprintf(qh, qh->ferr, 6407, "qhull internal error (qh_checkpolygon): missing vertex neighbors for v%d\n", vertex->id);
          waserror= True;
        }
        qh_setcheck(qh, vertex->neighbors, "neighbors for v", vertex->id);
        if (vertex->deleted)
          continue;
        totvneighbors += qh_setsize(qh, vertex->neighbors);
      }
      FORALLfacet_(facetlist) {
        if (!facet->visible)
          totfacetvertices += qh_setsize(qh, facet->vertices);
      }
      if (totvneighbors != totfacetvertices) {
        qh_fprintf(qh, qh->ferr, 6141, "qhull internal error (qh_checkpolygon): vertex neighbors inconsistent (tot_vneighbors %d != tot_facetvertices %d).  Maybe duplicate or missing vertex\n",
                totvneighbors, totfacetvertices);
        waserror= True;
        FORALLvertices {
          if (vertex->deleted)
            continue;
          qh->visit_id++;
          FOREACHneighbor_(vertex) {
            if (neighbor->visitid==qh->visit_id) {
              qh_fprintf(qh, qh->ferr, 6275, "qhull internal error (qh_checkpolygon): facet f%d occurs twice in neighbors of vertex v%d\n",
                  neighbor->id, vertex->id);
              errorfacet2= errorfacet;
              errorfacet= neighbor;
            }
            neighbor->visitid= qh->visit_id;
            if (!qh_setin(neighbor->vertices, vertex)) {
              qh_fprintf(qh, qh->ferr, 6276, "qhull internal error (qh_checkpolygon): facet f%d is a neighbor of vertex v%d but v%d is not a vertex of f%d\n",
                  neighbor->id, vertex->id, vertex->id, neighbor->id);
              errorfacet2= errorfacet;
              errorfacet= neighbor;
            }
          }
        }
        FORALLfacet_(facetlist){
          if (!facet->visible) {
            /* vertices are inverse sorted and are unlikely to be duplicated */
            FOREACHvertex_(facet->vertices){
              if (!qh_setin(vertex->neighbors, facet)) {
                qh_fprintf(qh, qh->ferr, 6277, "qhull internal error (qh_checkpolygon): v%d is a vertex of facet f%d but f%d is not a neighbor of v%d\n",
                  vertex->id, facet->id, facet->id, vertex->id);
                errorfacet2= errorfacet;
                errorfacet= facet;
              }
            }
          }
        }
      }
    }
    if (numvertices != qh->num_vertices - qh_setsize(qh, qh->del_vertices)) {
      qh_fprintf(qh, qh->ferr, 6142, "qhull internal error (qh_checkpolygon): actual number of vertices is %d, cumulative vertex count is %d\n",
              numvertices, qh->num_vertices - qh_setsize(qh, qh->del_vertices));
      waserror= True;
    }
    if (qh->hull_dim == 2 && numvertices != numfacets) {
      qh_fprintf(qh, qh->ferr, 6143, "qhull internal error (qh_checkpolygon): #vertices %d != #facets %d\n",
        numvertices, numfacets);
      waserror= True;
    }
    if (qh->hull_dim == 3 && numvertices + numfacets - numridges/2 != 2) {
      qh_fprintf(qh, qh->ferr, 7063, "qhull warning: #vertices %d + #facets %d - #edges %d != 2.  A vertex appears twice in a edge list.  May occur during merging.\n",
          numvertices, numfacets, numridges/2);
      /* occurs if lots of merging and a vertex ends up twice in an edge list.  e.g., RBOX 1000 s W1e-13 t995849315 D2 | QHULL d Tc Tv */
    }
  }
  if (waserror)
    qh_errexit2(qh, qh_ERRqhull, errorfacet, errorfacet2);
} /* checkpolygon */


/*---------------------------------

  qh_checkvertex(qh, vertex, allchecks, &waserror )
    check vertex for consistency
    if allchecks, checks vertex->neighbors

  returns:
    sets waserror if any error occurs

  notes:
    called by qh_tracemerge and qh_checkpolygon
    neighbors checked efficiently in qh_checkpolygon
*/
void qh_checkvertex(qhT *qh, vertexT *vertex, boolT allchecks, boolT *waserrorp) {
  boolT waserror= False;
  facetT *neighbor, **neighborp, *errfacet=NULL;

  if (qh_pointid(qh, vertex->point) == qh_IDunknown) {
    qh_fprintf(qh, qh->ferr, 6144, "qhull internal error (qh_checkvertex): unknown point id %p\n", vertex->point);
    waserror= True;
  }
  if (vertex->id >= qh->vertex_id) {
    qh_fprintf(qh, qh->ferr, 6145, "qhull internal error (qh_checkvertex): unknown vertex id v%d >= qh.vertex_id (%d)\n", vertex->id, qh->vertex_id);
    waserror= True;
  }
  if (vertex->visitid > qh->vertex_visit) {
    qh_fprintf(qh, qh->ferr, 6413, "qhull internal error (qh_checkvertex): expecting v%d.visitid <= qh.vertex_visit (%d).  Got visitid %d\n", vertex->id, qh->vertex_visit, vertex->visitid);
    waserror= True;
  }
  if (allchecks && !waserror && !vertex->deleted) {
    if (qh_setsize(qh, vertex->neighbors)) {
      FOREACHneighbor_(vertex) {
        if (!qh_setin(neighbor->vertices, vertex)) {
          qh_fprintf(qh, qh->ferr, 6146, "qhull internal error (qh_checkvertex): neighbor f%d does not contain v%d\n", neighbor->id, vertex->id);
          errfacet= neighbor;
          waserror= True;
        }
      }
    }
  }
  if (waserror) {
    qh_errprint(qh, "ERRONEOUS", NULL, NULL, NULL, vertex);
    if (errfacet)
      qh_errexit(qh, qh_ERRqhull, errfacet, NULL);
    *waserrorp= True;
  }
} /* checkvertex */

/*---------------------------------

  qh_clearcenters(qh, type )
    clear old data from facet->center

  notes:
    sets new centertype
    nop if CENTERtype is the same
*/
void qh_clearcenters(qhT *qh, qh_CENTER type) {
  facetT *facet;

  if (qh->CENTERtype != type) {
    FORALLfacets {
      if (facet->tricoplanar && !facet->keepcentrum)
          facet->center= NULL;  /* center is owned by the ->keepcentrum facet */
      else if (qh->CENTERtype == qh_ASvoronoi){
        if (facet->center) {
          qh_memfree(qh, facet->center, qh->center_size);
          facet->center= NULL;
        }
      }else /* qh.CENTERtype == qh_AScentrum */ {
        if (facet->center) {
          qh_memfree(qh, facet->center, qh->normal_size);
          facet->center= NULL;
        }
      }
    }
    qh->CENTERtype= type;
  }
  trace2((qh, qh->ferr, 2043, "qh_clearcenters: switched to center type %d\n", type));
} /* clearcenters */

/*---------------------------------

  qh_createsimplex(qh, vertices )
    creates a simplex from a set of vertices

  returns:
    initializes qh.facet_list to the simplex

  notes: 
    only called by qh_initialhull

  design:
    for each vertex
      create a new facet
    for each new facet
      create its neighbor set
*/
void qh_createsimplex(qhT *qh, setT *vertices /* qh.facet_list */) {
  facetT *facet= NULL, *newfacet;
  boolT toporient= True;
  int vertex_i, vertex_n, nth;
  setT *newfacets= qh_settemp(qh, qh->hull_dim+1);
  vertexT *vertex;

  FOREACHvertex_i_(qh, vertices) {
    newfacet= qh_newfacet(qh);
    newfacet->vertices= qh_setnew_delnthsorted(qh, vertices, vertex_n, vertex_i, 0);
    if (toporient)
      newfacet->toporient= True;
    qh_appendfacet(qh, newfacet);
    newfacet->newfacet= True;
    qh_appendvertex(qh, vertex);
    qh_setappend(qh, &newfacets, newfacet);
    toporient ^= True;
  }
  FORALLnew_facets {
    nth= 0;
    FORALLfacet_(qh->newfacet_list) {
      if (facet != newfacet)
        SETelem_(newfacet->neighbors, nth++)= facet;
    }
    qh_settruncate(qh, newfacet->neighbors, qh->hull_dim);
  }
  qh_settempfree(qh, &newfacets);
  trace1((qh, qh->ferr, 1028, "qh_createsimplex: created simplex\n"));
} /* createsimplex */

/*---------------------------------

  qh_delridge(qh, ridge )
    delete a ridge's vertices and frees its memory

  notes:
    assumes r.top->ridges and r.bottom->ridges have been updated
*/
void qh_delridge(qhT *qh, ridgeT *ridge) {

  if (ridge == qh->traceridge)
    qh->traceridge= NULL;
  qh_setfree(qh, &(ridge->vertices));
  qh_memfree(qh, ridge, (int)sizeof(ridgeT));
} /* delridge */

/*---------------------------------

  qh_delvertex(qh, vertex )
    deletes a vertex and frees its memory

  notes:
    assumes vertex->adjacencies have been updated if needed
    unlinks from vertex_list
*/
void qh_delvertex(qhT *qh, vertexT *vertex) {

  if (vertex->deleted && !vertex->partitioned && !qh->NOerrexit) {
    qh_fprintf(qh, qh->ferr, 6395, "qhull internal error (qh_delvertex): vertex v%d was deleted but it was not partitioned as a coplanar point\n",
      vertex->id);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  if (vertex == qh->tracevertex)
    qh->tracevertex= NULL;
  qh_removevertex(qh, vertex);
  qh_setfree(qh, &vertex->neighbors);
  qh_memfree(qh, vertex, (int)sizeof(vertexT));
} /* delvertex */


/*---------------------------------

  qh_facet3vertex(qh )
    return temporary set of 3-d vertices in qh_ORIENTclock order

  design:
    if simplicial facet
      build set from facet->vertices with facet->toporient
    else
      for each ridge in order
        build set from ridge's vertices
*/
setT *qh_facet3vertex(qhT *qh, facetT *facet) {
  ridgeT *ridge, *firstridge;
  vertexT *vertex;
  int cntvertices, cntprojected=0;
  setT *vertices;

  cntvertices= qh_setsize(qh, facet->vertices);
  vertices= qh_settemp(qh, cntvertices);
  if (facet->simplicial) {
    if (cntvertices != 3) {
      qh_fprintf(qh, qh->ferr, 6147, "qhull internal error (qh_facet3vertex): only %d vertices for simplicial facet f%d\n",
                  cntvertices, facet->id);
      qh_errexit(qh, qh_ERRqhull, facet, NULL);
    }
    qh_setappend(qh, &vertices, SETfirst_(facet->vertices));
    if (facet->toporient ^ qh_ORIENTclock)
      qh_setappend(qh, &vertices, SETsecond_(facet->vertices));
    else
      qh_setaddnth(qh, &vertices, 0, SETsecond_(facet->vertices));
    qh_setappend(qh, &vertices, SETelem_(facet->vertices, 2));
  }else {
    ridge= firstridge= SETfirstt_(facet->ridges, ridgeT);   /* no infinite */
    while ((ridge= qh_nextridge3d(ridge, facet, &vertex))) {
      qh_setappend(qh, &vertices, vertex);
      if (++cntprojected > cntvertices || ridge == firstridge)
        break;
    }
    if (!ridge || cntprojected != cntvertices) {
      qh_fprintf(qh, qh->ferr, 6148, "qhull internal error (qh_facet3vertex): ridges for facet %d don't match up.  got at least %d\n",
                  facet->id, cntprojected);
      qh_errexit(qh, qh_ERRqhull, facet, ridge);
    }
  }
  return vertices;
} /* facet3vertex */

/*---------------------------------

  qh_findbestfacet(qh, point, bestoutside, bestdist, isoutside )
    find facet that is furthest below a point

    for Delaunay triangulations,
      Use qh_setdelaunay() to lift point to paraboloid and scale by 'Qbb' if needed
      Do not use options 'Qbk', 'QBk', or 'QbB' since they scale the coordinates.

  returns:
    if bestoutside is set (e.g., qh_ALL)
      returns best facet that is not upperdelaunay
      if Delaunay and inside, point is outside circumsphere of bestfacet
    else
      returns first facet below point
      if point is inside, returns nearest, !upperdelaunay facet
    distance to facet
    isoutside set if outside of facet

  notes:
    Distance is measured by distance to the facet's hyperplane.  For
    Delaunay facets, this is not the same as the containing facet.  It may
    be an adjacent facet or a different tricoplanar facet.  See 
    locate a facet with qh_findbestfacet()

    For tricoplanar facets, this finds one of the tricoplanar facets closest
    to the point.  

    If inside, qh_findbestfacet performs an exhaustive search
       this may be too conservative.  Sometimes it is clearly required.

    qh_findbestfacet is not used by qhull.
    uses qh.visit_id and qh.coplanarset

  see:
    qh_findbest
*/
facetT *qh_findbestfacet(qhT *qh, pointT *point, boolT bestoutside,
           realT *bestdist, boolT *isoutside) {
  facetT *bestfacet= NULL;
  int numpart, totpart= 0;

  bestfacet= qh_findbest(qh, point, qh->facet_list,
                            bestoutside, !qh_ISnewfacets, bestoutside /* qh_NOupper */,
                            bestdist, isoutside, &totpart);
  if (*bestdist < -qh->DISTround) {
    bestfacet= qh_findfacet_all(qh, point, !qh_NOupper, bestdist, isoutside, &numpart);
    totpart += numpart;
    if ((isoutside && *isoutside && bestoutside)
    || (isoutside && !*isoutside && bestfacet->upperdelaunay)) {
      bestfacet= qh_findbest(qh, point, bestfacet,
                            bestoutside, False, bestoutside,
                            bestdist, isoutside, &totpart);
      totpart += numpart;
    }
  }
  trace3((qh, qh->ferr, 3014, "qh_findbestfacet: f%d dist %2.2g isoutside %d totpart %d\n",
          bestfacet->id, *bestdist, (isoutside ? *isoutside : UINT_MAX), totpart));
  return bestfacet;
} /* findbestfacet */

/*---------------------------------

  qh_findbestlower(qh, facet, point, bestdist, numpart )
    returns best non-upper, non-flipped neighbor of facet for point
    if needed, searches vertex neighbors

  returns:
    returns bestdist and updates numpart

  notes:
    called by qh_findbest() for points above an upperdelaunay facet
    if Delaunay and inside, point is outside of circumsphere of bestfacet

*/
facetT *qh_findbestlower(qhT *qh, facetT *upperfacet, pointT *point, realT *bestdistp, int *numpart) {
  facetT *neighbor, **neighborp, *bestfacet= NULL;
  realT bestdist= -REALmax/2 /* avoid underflow */;
  realT dist;
  vertexT *vertex;
  boolT isoutside= False;  /* not used */

  zinc_(Zbestlower);
  FOREACHneighbor_(upperfacet) {
    if (neighbor->upperdelaunay || neighbor->flipped)
      continue;
    (*numpart)++;
    qh_distplane(qh, point, neighbor, &dist);
    if (dist > bestdist) {
      bestfacet= neighbor;
      bestdist= dist;
    }
  }
  if (!bestfacet) {
    zinc_(Zbestlowerv);
    /* rarely called, numpart does not count nearvertex computations */
    vertex= qh_nearvertex(qh, upperfacet, point, &dist);
    qh_vertexneighbors(qh);
    FOREACHneighbor_(vertex) {
      if (neighbor->upperdelaunay || neighbor->flipped)
        continue;
      (*numpart)++;
      qh_distplane(qh, point, neighbor, &dist);
      if (dist > bestdist) {
        bestfacet= neighbor;
        bestdist= dist;
      }
    }
  }
  if (!bestfacet) {
    zinc_(Zbestlowerall);  /* invoked once per point in outsideset */
    zmax_(Zbestloweralln, qh->num_facets);
    /* [dec'15] Previously reported as QH6228 */
    trace3((qh, qh->ferr, 3025, "qh_findbestlower: all neighbors of facet %d are flipped or upper Delaunay.  Search all facets\n",
        upperfacet->id));
    /* rarely called */
    bestfacet= qh_findfacet_all(qh, point, qh_NOupper, &bestdist, &isoutside, numpart);
  }
  *bestdistp= bestdist;
  trace3((qh, qh->ferr, 3015, "qh_findbestlower: f%d dist %2.2g for f%d p%d\n",
          bestfacet->id, bestdist, upperfacet->id, qh_pointid(qh, point)));
  return bestfacet;
} /* findbestlower */

/*---------------------------------

  qh_findfacet_all(qh, point, noupper, bestdist, isoutside, numpart )
    exhaustive search for facet below a point
    ignore flipped and visible facets, f.normal==NULL, and if noupper, f.upperdelaunay facets

    for Delaunay triangulations,
      Use qh_setdelaunay() to lift point to paraboloid and scale by 'Qbb' if needed
      Do not use options 'Qbk', 'QBk', or 'QbB' since they scale the coordinates.

  returns:
    returns first facet below point
    if point is inside,
      returns nearest facet
    distance to facet
    isoutside if point is outside of the hull
    number of distance tests

  notes:
    called by qh_findbestlower if all neighbors are flipped or upper Delaunay (QH3025)
    primarily for library users (qh_findbestfacet), rarely used by Qhull
*/
facetT *qh_findfacet_all(qhT *qh, pointT *point, boolT noupper, realT *bestdist, boolT *isoutside,
                          int *numpart) {
  facetT *bestfacet= NULL, *facet;
  realT dist;
  int totpart= 0;

  *bestdist= -REALmax;
  *isoutside= False;
  FORALLfacets {
    if (facet->flipped || !facet->normal || facet->visible)
      continue;
    if (noupper && facet->upperdelaunay)
      continue;
    totpart++;
    qh_distplane(qh, point, facet, &dist);
    if (dist > *bestdist) {
      *bestdist= dist;
      bestfacet= facet;
      if (dist > qh->MINoutside) {
        *isoutside= True;
        break;
      }
    }
  }
  *numpart= totpart;
  trace3((qh, qh->ferr, 3016, "qh_findfacet_all: p%d, noupper? %d, f%d, dist %2.2g, isoutside %d, totpart %d\n",
      qh_pointid(qh, point), noupper, getid_(bestfacet), *bestdist, *isoutside, totpart));
  return bestfacet;
} /* findfacet_all */

/*---------------------------------

  qh_findgood(qh, facetlist, goodhorizon )
    identify good facets for qh.PRINTgood and qh_buildcone_onlygood
    goodhorizon is count of good, horizon facets from qh_find_horizon, otherwise 0 from qh_findgood_all
    if not qh.MERGING and qh.GOODvertex>0
      facet includes point as vertex
      if !match, returns goodhorizon
    if qh.GOODpoint
      facet is visible or coplanar (>0) or not visible (<0)
    if qh.GOODthreshold
      facet->normal matches threshold
    if !goodhorizon and !match,
      selects facet with closest angle to thresholds
      sets GOODclosest

  returns:
    number of new, good facets found
    determines facet->good
    may update qh.GOODclosest

  notes:
    called from qh_initbuild, qh_buildcone_onlygood, and qh_findgood_all
    qh_findgood_all (called from qh_prepare_output) further reduces the good region

  design:
    count good facets
    if not merging, clear good facets that fail qh.GOODvertex ('QVn', but not 'QV-n')
    clear good facets that fail qh.GOODpoint ('QGn' or 'QG-n')
    clear good facets that fail qh.GOODthreshold
    if !goodhorizon and !find f.good,
      sets GOODclosest to facet with closest angle to thresholds
*/
int qh_findgood(qhT *qh, facetT *facetlist, int goodhorizon) {
  facetT *facet, *bestfacet= NULL;
  realT angle, bestangle= REALmax, dist;
  int  numgood=0;

  FORALLfacet_(facetlist) {
    if (facet->good)
      numgood++;
  }
  if (qh->GOODvertex>0 && !qh->MERGING) {
    FORALLfacet_(facetlist) {
      if (facet->good && !qh_isvertex(qh->GOODvertexp, facet->vertices)) {
        facet->good= False;
        numgood--;
      }
    }
  }
  if (qh->GOODpoint && numgood) {
    FORALLfacet_(facetlist) {
      if (facet->good && facet->normal) {
        zinc_(Zdistgood);
        qh_distplane(qh, qh->GOODpointp, facet, &dist);
        if ((qh->GOODpoint > 0) ^ (dist > 0.0)) {
          facet->good= False;
          numgood--;
        }
      }
    }
  }
  if (qh->GOODthreshold && (numgood || goodhorizon || qh->GOODclosest)) {
    FORALLfacet_(facetlist) {
      if (facet->good && facet->normal) {
        if (!qh_inthresholds(qh, facet->normal, &angle)) {
          facet->good= False;
          numgood--;
          if (angle < bestangle) {
            bestangle= angle;
            bestfacet= facet;
          }
        }
      }
    }
    if (numgood == 0 && (goodhorizon == 0 || qh->GOODclosest)) {
      if (qh->GOODclosest) {
        if (qh->GOODclosest->visible)
          qh->GOODclosest= NULL;
        else {
          qh_inthresholds(qh, qh->GOODclosest->normal, &angle);
          if (angle < bestangle)
            bestfacet= qh->GOODclosest;
        }
      }
      if (bestfacet && bestfacet != qh->GOODclosest) {   /* numgood == 0 */
        if (qh->GOODclosest)
          qh->GOODclosest->good= False;
        qh->GOODclosest= bestfacet;
        bestfacet->good= True;
        numgood++;
        trace2((qh, qh->ferr, 2044, "qh_findgood: f%d is closest(%2.2g) to thresholds\n",
           bestfacet->id, bestangle));
        return numgood;
      }
    }else if (qh->GOODclosest) { /* numgood > 0 */
      qh->GOODclosest->good= False;
      qh->GOODclosest= NULL;
    }
  }
  zadd_(Zgoodfacet, numgood);
  trace2((qh, qh->ferr, 2045, "qh_findgood: found %d good facets with %d good horizon and qh.GOODclosest f%d\n",
               numgood, goodhorizon, getid_(qh->GOODclosest)));
  if (!numgood && qh->GOODvertex>0 && !qh->MERGING)
    return goodhorizon;
  return numgood;
} /* findgood */

/*---------------------------------

  qh_findgood_all(qh, facetlist )
    apply other constraints for good facets (used by qh.PRINTgood)
    if qh.GOODvertex
      facet includes (>0) or doesn't include (<0) point as vertex
      if last good facet and ONLYgood, prints warning and continues
    if qh.SPLITthresholds (e.g., qh.DELAUNAY)
      facet->normal matches threshold, or if none, the closest one
    calls qh_findgood
    nop if good not used

  returns:
    clears facet->good if not good
    sets qh.num_good

  notes:
    called by qh_prepare_output and qh_printneighborhood
    unless qh.ONLYgood, calls qh_findgood first

  design:
    uses qh_findgood to mark good facets
    clear f.good for failed qh.GOODvertex
    clear f.good for failed qh.SPLITthreholds
       if no more good facets, select best of qh.SPLITthresholds
*/
void qh_findgood_all(qhT *qh, facetT *facetlist) {
  facetT *facet, *bestfacet=NULL;
  realT angle, bestangle= REALmax;
  int  numgood=0, startgood;

  if (!qh->GOODvertex && !qh->GOODthreshold && !qh->GOODpoint
  && !qh->SPLITthresholds)
    return;
  if (!qh->ONLYgood)
    qh_findgood(qh, qh->facet_list, 0);
  FORALLfacet_(facetlist) {
    if (facet->good)
      numgood++;
  }
  if (qh->GOODvertex <0 || (qh->GOODvertex > 0 && qh->MERGING)) {
    FORALLfacet_(facetlist) {
      if (facet->good && ((qh->GOODvertex > 0) ^ !!qh_isvertex(qh->GOODvertexp, facet->vertices))) { /* convert to bool */
        if (!--numgood) {
          if (qh->ONLYgood) {
            qh_fprintf(qh, qh->ferr, 7064, "qhull warning: good vertex p%d does not match last good facet f%d.  Ignored.\n",
               qh_pointid(qh, qh->GOODvertexp), facet->id);
            return;
          }else if (qh->GOODvertex > 0)
            qh_fprintf(qh, qh->ferr, 7065, "qhull warning: point p%d is not a vertex('QV%d').\n",
                qh->GOODvertex-1, qh->GOODvertex-1);
          else
            qh_fprintf(qh, qh->ferr, 7066, "qhull warning: point p%d is a vertex for every facet('QV-%d').\n",
                -qh->GOODvertex - 1, -qh->GOODvertex - 1);
        }
        facet->good= False;
      }
    }
  }
  startgood= numgood;
  if (qh->SPLITthresholds) {
    FORALLfacet_(facetlist) {
      if (facet->good) {
        if (!qh_inthresholds(qh, facet->normal, &angle)) {
          facet->good= False;
          numgood--;
          if (angle < bestangle) {
            bestangle= angle;
            bestfacet= facet;
          }
        }
      }
    }
    if (!numgood && bestfacet) {
      bestfacet->good= True;
      numgood++;
      trace0((qh, qh->ferr, 23, "qh_findgood_all: f%d is closest(%2.2g) to split thresholds\n",
           bestfacet->id, bestangle));
      return;
    }
  }
  if (numgood == 1 && !qh->PRINTgood && qh->GOODclosest && qh->GOODclosest->good) {
    trace2((qh, qh->ferr, 2109, "qh_findgood_all: undo selection of qh.GOODclosest f%d since it would fail qh_inthresholds in qh_skipfacet\n",
      qh->GOODclosest->id));
    qh->GOODclosest->good= False;
    numgood= 0;
  }
  qh->num_good= numgood;
  trace0((qh, qh->ferr, 24, "qh_findgood_all: %d good facets remain out of %d facets\n",
        numgood, startgood));
} /* findgood_all */

/*---------------------------------

  qh_furthestnext()
    set qh.facet_next to facet with furthest of all furthest points
    searches all facets on qh.facet_list

  notes:
    this may help avoid precision problems
*/
void qh_furthestnext(qhT *qh /* qh.facet_list */) {
  facetT *facet, *bestfacet= NULL;
  realT dist, bestdist= -REALmax;

  FORALLfacets {
    if (facet->outsideset) {
#if qh_COMPUTEfurthest
      pointT *furthest;
      furthest= (pointT *)qh_setlast(facet->outsideset);
      zinc_(Zcomputefurthest);
      qh_distplane(qh, furthest, facet, &dist);
#else
      dist= facet->furthestdist;
#endif
      if (dist > bestdist) {
        bestfacet= facet;
        bestdist= dist;
      }
    }
  }
  if (bestfacet) {
    qh_removefacet(qh, bestfacet);
    qh_prependfacet(qh, bestfacet, &qh->facet_next);
    trace1((qh, qh->ferr, 1029, "qh_furthestnext: made f%d next facet(dist %.2g)\n",
            bestfacet->id, bestdist));
  }
} /* furthestnext */

/*---------------------------------

  qh_furthestout(qh, facet )
    make furthest outside point the last point of outsideset

  returns:
    updates facet->outsideset
    clears facet->notfurthest
    sets facet->furthestdist

  design:
    determine best point of outsideset
    make it the last point of outsideset
*/
void qh_furthestout(qhT *qh, facetT *facet) {
  pointT *point, **pointp, *bestpoint= NULL;
  realT dist, bestdist= -REALmax;

  FOREACHpoint_(facet->outsideset) {
    qh_distplane(qh, point, facet, &dist);
    zinc_(Zcomputefurthest);
    if (dist > bestdist) {
      bestpoint= point;
      bestdist= dist;
    }
  }
  if (bestpoint) {
    qh_setdel(facet->outsideset, point);
    qh_setappend(qh, &facet->outsideset, point);
#if !qh_COMPUTEfurthest
    facet->furthestdist= bestdist;
#endif
  }
  facet->notfurthest= False;
  trace3((qh, qh->ferr, 3017, "qh_furthestout: p%d is furthest outside point of f%d\n",
          qh_pointid(qh, point), facet->id));
} /* furthestout */


/*---------------------------------

  qh_infiniteloop(qh, facet )
    report infinite loop error due to facet
*/
void qh_infiniteloop(qhT *qh, facetT *facet) {

  qh_fprintf(qh, qh->ferr, 6149, "qhull internal error (qh_infiniteloop): potential infinite loop detected.  If visible, f.replace. If newfacet, f.samecycle\n");
  qh_errexit(qh, qh_ERRqhull, facet, NULL);
} /* qh_infiniteloop */

/*---------------------------------

  qh_initbuild()
    initialize hull and outside sets with point array
    qh.FIRSTpoint/qh.NUMpoints is point array
    if qh.GOODpoint
      adds qh.GOODpoint to initial hull

  returns:
    qh_facetlist with initial hull
    points partioned into outside sets, coplanar sets, or inside
    initializes qh.GOODpointp, qh.GOODvertexp,

  design:
    initialize global variables used during qh_buildhull
    determine precision constants and points with max/min coordinate values
      if qh.SCALElast, scale last coordinate(for 'd')
    initialize qh.newfacet_list, qh.facet_tail
    initialize qh.vertex_list, qh.newvertex_list, qh.vertex_tail
    determine initial vertices
    build initial simplex
    partition input points into facets of initial simplex
    set up lists
    if qh.ONLYgood
      check consistency
      add qh.GOODvertex if defined
*/
void qh_initbuild(qhT *qh) {
  setT *maxpoints, *vertices;
  facetT *facet;
  int i, numpart;
  realT dist;
  boolT isoutside;

  if (qh->PRINTstatistics) {
    qh_fprintf(qh, qh->ferr, 9350, "qhull %s Statistics: %s | %s\n",
      qh_version, qh->rbox_command, qh->qhull_command);
    fflush(NULL);
  }
  qh->furthest_id= qh_IDunknown;
  qh->lastreport= 0;
  qh->lastfacets= 0;
  qh->lastmerges= 0;
  qh->lastplanes= 0;
  qh->lastdist= 0;
  qh->facet_id= qh->vertex_id= qh->ridge_id= 0;
  qh->visit_id= qh->vertex_visit= 0;
  qh->maxoutdone= False;

  if (qh->GOODpoint > 0)
    qh->GOODpointp= qh_point(qh, qh->GOODpoint-1);
  else if (qh->GOODpoint < 0)
    qh->GOODpointp= qh_point(qh, -qh->GOODpoint-1);
  if (qh->GOODvertex > 0)
    qh->GOODvertexp= qh_point(qh, qh->GOODvertex-1);
  else if (qh->GOODvertex < 0)
    qh->GOODvertexp= qh_point(qh, -qh->GOODvertex-1);
  if ((qh->GOODpoint
       && (qh->GOODpointp < qh->first_point  /* also catches !GOODpointp */
           || qh->GOODpointp > qh_point(qh, qh->num_points-1)))
  || (qh->GOODvertex
       && (qh->GOODvertexp < qh->first_point  /* also catches !GOODvertexp */
           || qh->GOODvertexp > qh_point(qh, qh->num_points-1)))) {
    qh_fprintf(qh, qh->ferr, 6150, "qhull input error: either QGn or QVn point is > p%d\n",
             qh->num_points-1);
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  maxpoints= qh_maxmin(qh, qh->first_point, qh->num_points, qh->hull_dim);
  if (qh->SCALElast)
    qh_scalelast(qh, qh->first_point, qh->num_points, qh->hull_dim, qh->MINlastcoord, qh->MAXlastcoord, qh->MAXabs_coord);
  qh_detroundoff(qh);
  if (qh->DELAUNAY && qh->upper_threshold[qh->hull_dim-1] > REALmax/2
                  && qh->lower_threshold[qh->hull_dim-1] < -REALmax/2) {
    for (i=qh_PRINTEND; i--; ) {
      if (qh->PRINTout[i] == qh_PRINTgeom && qh->DROPdim < 0
          && !qh->GOODthreshold && !qh->SPLITthresholds)
        break;  /* in this case, don't set upper_threshold */
    }
    if (i < 0) {
      if (qh->UPPERdelaunay) { /* matches qh.upperdelaunay in qh_setfacetplane */
        qh->lower_threshold[qh->hull_dim-1]= qh->ANGLEround * qh_ZEROdelaunay;
        qh->GOODthreshold= True;
      }else {
        qh->upper_threshold[qh->hull_dim-1]= -qh->ANGLEround * qh_ZEROdelaunay;
        if (!qh->GOODthreshold)
          qh->SPLITthresholds= True; /* build upper-convex hull even if Qg */
          /* qh_initqhull_globals errors if Qg without Pdk/etc. */
      }
    }
  }
  trace4((qh, qh->ferr, 4091, "qh_initbuild: create sentinels for qh.facet_tail and qh.vertex_tail\n"));
  qh->facet_list= qh->newfacet_list= qh->facet_tail= qh_newfacet(qh);
  qh->num_facets= qh->num_vertices= qh->num_visible= 0;
  qh->vertex_list= qh->newvertex_list= qh->vertex_tail= qh_newvertex(qh, NULL);
  vertices= qh_initialvertices(qh, qh->hull_dim, maxpoints, qh->first_point, qh->num_points);
  qh_initialhull(qh, vertices);  /* initial qh->facet_list */
  qh_partitionall(qh, vertices, qh->first_point, qh->num_points);
  if (qh->PRINToptions1st || qh->TRACElevel || qh->IStracing) {
    if (qh->TRACElevel || qh->IStracing)
      qh_fprintf(qh, qh->ferr, 8103, "\nTrace level T%d, IStracing %d, point TP%d, merge TM%d, dist TW%2.2g, qh.tracefacet_id %d, traceridge_id %d, tracevertex_id %d, last qh.RERUN %d, %s | %s\n",
         qh->TRACElevel, qh->IStracing, qh->TRACEpoint, qh->TRACEmerge, qh->TRACEdist, qh->tracefacet_id, qh->traceridge_id, qh->tracevertex_id, qh->TRACElastrun, qh->rbox_command, qh->qhull_command);
    qh_fprintf(qh, qh->ferr, 8104, "Options selected for Qhull %s:\n%s\n", qh_version, qh->qhull_options);
  }
  qh_resetlists(qh, False, qh_RESETvisible /* qh.visible_list newvertex_list qh.newfacet_list */);
  qh->facet_next= qh->facet_list;
  qh_furthestnext(qh /* qh.facet_list */);
  if (qh->PREmerge) {
    qh->cos_max= qh->premerge_cos;
    qh->centrum_radius= qh->premerge_centrum; /* overwritten by qh_premerge */
  }
  if (qh->ONLYgood) {
    if (qh->GOODvertex > 0 && qh->MERGING) {
      qh_fprintf(qh, qh->ferr, 6151, "qhull input error: 'Qg QVn' (only good vertex) does not work with merging.\nUse 'QJ' to joggle the input or 'Q0' to turn off merging.\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    if (!(qh->GOODthreshold || qh->GOODpoint
         || (!qh->MERGEexact && !qh->PREmerge && qh->GOODvertexp))) {
      qh_fprintf(qh, qh->ferr, 6152, "qhull input error: 'Qg' (ONLYgood) needs a good threshold('Pd0D0'), a good point(QGn or QG-n), or a good vertex with 'QJ' or 'Q0' (QVn).\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    if (qh->GOODvertex > 0  && !qh->MERGING  /* matches qh_partitionall */
    && !qh_isvertex(qh->GOODvertexp, vertices)) {
      facet= qh_findbestnew(qh, qh->GOODvertexp, qh->facet_list,
                          &dist, !qh_ALL, &isoutside, &numpart);
      zadd_(Zdistgood, numpart);
      if (!isoutside) {
        qh_fprintf(qh, qh->ferr, 6153, "qhull input error: point for QV%d is inside initial simplex.  It can not be made a vertex.\n",
               qh_pointid(qh, qh->GOODvertexp));
        qh_errexit(qh, qh_ERRinput, NULL, NULL);
      }
      if (!qh_addpoint(qh, qh->GOODvertexp, facet, False)) {
        qh_settempfree(qh, &vertices);
        qh_settempfree(qh, &maxpoints);
        return;
      }
    }
    qh_findgood(qh, qh->facet_list, 0);
  }
  qh_settempfree(qh, &vertices);
  qh_settempfree(qh, &maxpoints);
  trace1((qh, qh->ferr, 1030, "qh_initbuild: initial hull created and points partitioned\n"));
} /* initbuild */

/*---------------------------------

  qh_initialhull(qh, vertices )
    constructs the initial hull as a DIM3 simplex of vertices

  notes:
    only called by qh_initbuild

  design:
    creates a simplex (initializes lists)
    determines orientation of simplex
    sets hyperplanes for facets
    doubles checks orientation (in case of axis-parallel facets with Gaussian elimination)
    checks for flipped facets and qh.NARROWhull
    checks the result
*/
void qh_initialhull(qhT *qh, setT *vertices) {
  facetT *facet, *firstfacet, *neighbor, **neighborp;
  realT angle, minangle= REALmax, dist;

  qh_createsimplex(qh, vertices /* qh.facet_list */);
  qh_resetlists(qh, False, qh_RESETvisible);
  qh->facet_next= qh->facet_list;      /* advance facet when processed */
  qh->interior_point= qh_getcenter(qh, vertices);
  if (qh->IStracing) {
    qh_fprintf(qh, qh->ferr, 8105, "qh_initialhull: ");
    qh_printpoint(qh, qh->ferr, "qh.interior_point", qh->interior_point);
  }
  firstfacet= qh->facet_list;
  qh_setfacetplane(qh, firstfacet);   /* qh_joggle_restart if flipped */
  if (firstfacet->flipped) {
    trace1((qh, qh->ferr, 1065, "qh_initialhull: ignore f%d flipped.  Test qh.interior_point (p-2) for clearly flipped\n", firstfacet->id));
    firstfacet->flipped= False;
  }
  zzinc_(Zdistcheck);
  qh_distplane(qh, qh->interior_point, firstfacet, &dist);
  if (dist > qh->DISTround) {  /* clearly flipped */
    trace1((qh, qh->ferr, 1060, "qh_initialhull: initial orientation incorrect, qh.interior_point is %2.2g from f%d.  Reversing orientation of all facets\n",
          dist, firstfacet->id));
    FORALLfacets
      facet->toporient ^= (unsigned char)True;
    qh_setfacetplane(qh, firstfacet);
  }
  FORALLfacets {
    if (facet != firstfacet)
      qh_setfacetplane(qh, facet);    /* qh_joggle_restart if flipped */
  }
  FORALLfacets {
    if (facet->flipped) {
      trace1((qh, qh->ferr, 1066, "qh_initialhull: ignore f%d flipped.  Test qh.interior_point (p-2) for clearly flipped\n", facet->id));
      facet->flipped= False;
    }
    zzinc_(Zdistcheck);
    qh_distplane(qh, qh->interior_point, facet, &dist);  /* duplicates qh_setfacetplane */
    if (dist > qh->DISTround) {  /* clearly flipped, due to axis-parallel facet or coplanar firstfacet */
      trace1((qh, qh->ferr, 1031, "qh_initialhull: initial orientation incorrect, qh.interior_point is %2.2g from f%d.  Either axis-parallel facet or coplanar firstfacet f%d.  Force outside orientation of all facets\n"));
      FORALLfacets { /* reuse facet, then 'break' */
        facet->flipped= False;
        facet->toporient ^= (unsigned char)True;
        qh_orientoutside(qh, facet);  /* force outside orientation for f.normal */
      }
      break;
    }
  }
  FORALLfacets {
    if (!qh_checkflipped(qh, facet, NULL, qh_ALL)) {
      if (qh->DELAUNAY && ! qh->ATinfinity) {
        qh_joggle_restart(qh, "initial Delaunay cocircular or cospherical");
        if (qh->UPPERdelaunay)
          qh_fprintf(qh, qh->ferr, 6240, "Qhull precision error: initial Delaunay input sites are cocircular or cospherical.  Option 'Qs' searches all points.  Use option 'QJ' to joggle the input, otherwise cannot compute the upper Delaunay triangulation or upper Voronoi diagram of cocircular/cospherical points.\n");
        else
          qh_fprintf(qh, qh->ferr, 6239, "Qhull precision error: initial Delaunay input sites are cocircular or cospherical.  Use option 'Qz' for the Delaunay triangulation or Voronoi diagram of cocircular/cospherical points; it adds a point \"at infinity\".  Alternatively use option 'QJ' to joggle the input.  Use option 'Qs' to search all points for the initial simplex.\n");
        qh_printvertexlist(qh, qh->ferr, "\ninput sites with last coordinate projected to a paraboloid\n", qh->facet_list, NULL, qh_ALL);
        qh_errexit(qh, qh_ERRinput, NULL, NULL);
      }else {
        qh_joggle_restart(qh, "initial simplex is flat");
        qh_fprintf(qh, qh->ferr, 6154, "Qhull precision error: Initial simplex is flat (facet %d is coplanar with the interior point)\n",
                   facet->id);
        qh_errexit(qh, qh_ERRsingular, NULL, NULL);  /* calls qh_printhelp_singular */
      }
    }
    FOREACHneighbor_(facet) {
      angle= qh_getangle(qh, facet->normal, neighbor->normal);
      minimize_( minangle, angle);
    }
  }
  if (minangle < qh_MAXnarrow && !qh->NOnarrow) {
    realT diff= 1.0 + minangle;

    qh->NARROWhull= True;
    qh_option(qh, "_narrow-hull", NULL, &diff);
    if (minangle < qh_WARNnarrow && !qh->RERUN && qh->PRINTprecision)
      qh_printhelp_narrowhull(qh, qh->ferr, minangle);
  }
  zzval_(Zprocessed)= qh->hull_dim+1;
  qh_checkpolygon(qh, qh->facet_list);
  qh_checkconvex(qh, qh->facet_list, qh_DATAfault);
  if (qh->IStracing >= 1) {
    qh_fprintf(qh, qh->ferr, 8105, "qh_initialhull: simplex constructed\n");
  }
} /* initialhull */

/*---------------------------------

  qh_initialvertices(qh, dim, maxpoints, points, numpoints )
    determines a non-singular set of initial vertices
    maxpoints may include duplicate points

  returns:
    temporary set of dim+1 vertices in descending order by vertex id
    if qh.RANDOMoutside && !qh.ALLpoints
      picks random points
    if dim >= qh_INITIALmax,
      uses min/max x and max points with non-zero determinants

  notes:
    unless qh.ALLpoints,
      uses maxpoints as long as determinate is non-zero
*/
setT *qh_initialvertices(qhT *qh, int dim, setT *maxpoints, pointT *points, int numpoints) {
  pointT *point, **pointp;
  setT *vertices, *simplex, *tested;
  realT randr;
  int idx, point_i, point_n, k;
  boolT nearzero= False;

  vertices= qh_settemp(qh, dim + 1);
  simplex= qh_settemp(qh, dim + 1);
  if (qh->ALLpoints)
    qh_maxsimplex(qh, dim, NULL, points, numpoints, &simplex);
  else if (qh->RANDOMoutside) {
    while (qh_setsize(qh, simplex) != dim+1) {
      randr= qh_RANDOMint;
      randr= randr/(qh_RANDOMmax+1);
      randr= floor(qh->num_points * randr);
      idx= (int)randr;
      while (qh_setin(simplex, qh_point(qh, idx))) {
        idx++; /* in case qh_RANDOMint always returns the same value */
        idx= idx < qh->num_points ? idx : 0;
      }
      qh_setappend(qh, &simplex, qh_point(qh, idx));
    }
  }else if (qh->hull_dim >= qh_INITIALmax) {
    tested= qh_settemp(qh, dim+1);
    qh_setappend(qh, &simplex, SETfirst_(maxpoints));   /* max and min X coord */
    qh_setappend(qh, &simplex, SETsecond_(maxpoints));
    qh_maxsimplex(qh, fmin_(qh_INITIALsearch, dim), maxpoints, points, numpoints, &simplex);
    k= qh_setsize(qh, simplex);
    FOREACHpoint_i_(qh, maxpoints) {
      if (k >= dim)  /* qh_maxsimplex for last point */
        break;
      if (point_i & 0x1) {     /* first try up to dim, max. coord. points */
        if (!qh_setin(simplex, point) && !qh_setin(tested, point)){
          qh_detsimplex(qh, point, simplex, k, &nearzero);
          if (nearzero)
            qh_setappend(qh, &tested, point);
          else {
            qh_setappend(qh, &simplex, point);
            k++;
          }
        }
      }
    }
    FOREACHpoint_i_(qh, maxpoints) {
      if (k >= dim)  /* qh_maxsimplex for last point */
        break;
      if ((point_i & 0x1) == 0) {  /* then test min. coord points */
        if (!qh_setin(simplex, point) && !qh_setin(tested, point)){
          qh_detsimplex(qh, point, simplex, k, &nearzero);
          if (nearzero)
            qh_setappend(qh, &tested, point);
          else {
            qh_setappend(qh, &simplex, point);
            k++;
          }
        }
      }
    }
    /* remove tested points from maxpoints */
    FOREACHpoint_i_(qh, maxpoints) {
      if (qh_setin(simplex, point) || qh_setin(tested, point))
        SETelem_(maxpoints, point_i)= NULL;
    }
    qh_setcompact(qh, maxpoints);
    idx= 0;
    while (k < dim && (point= qh_point(qh, idx++))) {
      if (!qh_setin(simplex, point) && !qh_setin(tested, point)){
        qh_detsimplex(qh, point, simplex, k, &nearzero);
        if (!nearzero){
          qh_setappend(qh, &simplex, point);
          k++;
        }
      }
    }
    qh_settempfree(qh, &tested);
    qh_maxsimplex(qh, dim, maxpoints, points, numpoints, &simplex);
  }else /* qh.hull_dim < qh_INITIALmax */
    qh_maxsimplex(qh, dim, maxpoints, points, numpoints, &simplex);
  FOREACHpoint_(simplex)
    qh_setaddnth(qh, &vertices, 0, qh_newvertex(qh, point)); /* descending order */
  qh_settempfree(qh, &simplex);
  return vertices;
} /* initialvertices */


/*---------------------------------

  qh_isvertex( point, vertices )
    returns vertex if point is in vertex set, else returns NULL

  notes:
    for qh.GOODvertex
*/
vertexT *qh_isvertex(pointT *point, setT *vertices) {
  vertexT *vertex, **vertexp;

  FOREACHvertex_(vertices) {
    if (vertex->point == point)
      return vertex;
  }
  return NULL;
} /* isvertex */

/*---------------------------------

  qh_makenewfacets(qh, point )
    make new facets from point and qh.visible_list

  returns:
    apex (point) of the new facets
    qh.newfacet_list= list of new facets with hyperplanes and ->newfacet
    qh.newvertex_list= list of vertices in new facets with ->newfacet set

    if (qh.NEWtentative)
      newfacets reference horizon facets, but not vice versa
      ridges reference non-simplicial horizon ridges, but not vice versa
      does not change existing facets
    else
      sets qh.NEWfacets
      new facets attached to horizon facets and ridges
      for visible facets,
        visible->r.replace is corresponding new facet

  see also:
    qh_makenewplanes() -- make hyperplanes for facets
    qh_attachnewfacets() -- attachnewfacets if not done here qh->NEWtentative
    qh_matchnewfacets() -- match up neighbors
    qh_update_vertexneighbors() -- update vertex neighbors and delvertices
    qh_deletevisible() -- delete visible facets
    qh_checkpolygon() --check the result
    qh_triangulate() -- triangulate a non-simplicial facet

  design:
    for each visible facet
      make new facets to its horizon facets
      update its f.replace
      clear its neighbor set
*/
vertexT *qh_makenewfacets(qhT *qh, pointT *point /* qh.visible_list */) {
  facetT *visible, *newfacet= NULL, *newfacet2= NULL, *neighbor, **neighborp;
  vertexT *apex;
  int numnew=0;

  if (qh->CHECKfrequently) {
    qh_checkdelridge(qh);
  }
  qh->newfacet_list= qh->facet_tail;
  qh->newvertex_list= qh->vertex_tail;
  apex= qh_newvertex(qh, point);
  qh_appendvertex(qh, apex);
  qh->visit_id++;
  FORALLvisible_facets {
    FOREACHneighbor_(visible)
      neighbor->seen= False;
    if (visible->ridges) {
      visible->visitid= qh->visit_id;
      newfacet2= qh_makenew_nonsimplicial(qh, visible, apex, &numnew);
    }
    if (visible->simplicial)
      newfacet= qh_makenew_simplicial(qh, visible, apex, &numnew);
    if (!qh->NEWtentative) {
      if (newfacet2)  /* newfacet is null if all ridges defined */
        newfacet= newfacet2;
      if (newfacet)
        visible->f.replace= newfacet;
      else
        zinc_(Zinsidevisible);
      if (visible->ridges)      /* ridges and neighbors are no longer valid for visible facet */
        SETfirst_(visible->ridges)= NULL;
      SETfirst_(visible->neighbors)= NULL;
    }
  }
  if (!qh->NEWtentative)
    qh->NEWfacets= True;
  trace1((qh, qh->ferr, 1032, "qh_makenewfacets: created %d new facets f%d..f%d from point p%d to horizon\n",
    numnew, qh->first_newfacet, qh->facet_id-1, qh_pointid(qh, point)));
  if (qh->IStracing >= 4)
    qh_printfacetlist(qh, qh->newfacet_list, NULL, qh_ALL);
  return apex;
} /* makenewfacets */

#ifndef qh_NOmerge
/*---------------------------------

  qh_matchdupridge(qh, atfacet, atskip, hashsize, hashcount )
    match duplicate ridges in qh.hash_table for atfacet@atskip
    duplicates marked with ->dupridge and qh_DUPLICATEridge

  returns:
    vertex-facet distance (>0.0) for qh_MERGEridge ridge
    updates hashcount
    set newfacet, facet, matchfacet's hyperplane (removes from mergecycle of coplanarhorizon facets)

  see also:
    qh_matchneighbor

  notes:
    only called by qh_matchnewfacets for qh_buildcone and qh_triangulate_facet
    assumes atfacet is simplicial
    assumes atfacet->neighbors @ atskip == qh_DUPLICATEridge
    usually keeps ridge with the widest merge
    both MRGdupridge and MRGflipped are required merges -- rbox 100 C1,2e-13 D4 t1 | qhull d Qbb
      can merge flipped f11842 skip 3 into f11862 skip 2 and vice versa (forced by goodmatch/goodmatch2)
         blocks -- cannot merge f11862 skip 2 and f11863 skip2 (the widest merge)
         must block -- can merge f11843 skip 3 into f11842 flipped skip 3, but not vice versa
      can merge f11843 skip 3 into f11863 skip 2, but not vice versa
    working/unused.h: [jan'19] Dropped qh_matchdupridge_coplanarhorizon, it was the same or slightly worse.  Complex addition, rarely occurs

  design:
    compute hash value for atfacet and atskip
    repeat twice -- once to make best matches, once to match the rest
      for each possible facet in qh.hash_table
        if it is a matching facet with the same orientation and pass 2
          make match
          unless tricoplanar, mark match for merging (qh_MERGEridge)
          [e.g., tricoplanar RBOX s 1000 t993602376 | QHULL C-1e-3 d Qbb FA Qt]
        if it is a matching facet with the same orientation and pass 1
          test if this is a better match
      if pass 1,
        make best match (it will not be merged)
        set newfacet, facet, matchfacet's hyperplane (removes from mergecycle of coplanarhorizon facets)

*/
coordT qh_matchdupridge(qhT *qh, facetT *atfacet, int atskip, int hashsize, int *hashcount) {
  boolT same, ismatch, isduplicate= False;
  int hash, scan;
  facetT *facet, *newfacet, *nextfacet;
  facetT *maxmatch= NULL, *maxmatch2= NULL, *goodmatch= NULL, *goodmatch2= NULL;
  int skip, newskip, nextskip= 0, makematch;
  int maxskip= 0, maxskip2= 0, goodskip= 0, goodskip2= 0;
  coordT maxdist= -REALmax, maxdist2= 0.0, dupdist, dupdist2, low, high, maxgood, gooddist= 0.0;

  maxgood= qh_WIDEdupridge * (qh->ONEmerge + qh->DISTround); 
  hash= qh_gethash(qh, hashsize, atfacet->vertices, qh->hull_dim, 1,
                     SETelem_(atfacet->vertices, atskip));
  trace2((qh, qh->ferr, 2046, "qh_matchdupridge: find dupridge matches for f%d skip %d hash %d hashcount %d\n",
          atfacet->id, atskip, hash, *hashcount));
  for (makematch=0; makematch < 2; makematch++) { /* makematch is false on the first pass and 1 on the second */
    qh->visit_id++;
    for (newfacet=atfacet, newskip=atskip; newfacet; newfacet= nextfacet, newskip= nextskip) {
      zinc_(Zhashlookup);
      nextfacet= NULL; /* exit when ismatch found */
      newfacet->visitid= qh->visit_id;
      for (scan=hash; (facet= SETelemt_(qh->hash_table, scan, facetT));
           scan= (++scan >= hashsize ? 0 : scan)) {
        if (!facet->dupridge || facet->visitid == qh->visit_id)
          continue;
        zinc_(Zhashtests);
        if (qh_matchvertices(qh, 1, newfacet->vertices, newskip, facet->vertices, &skip, &same)) {
          if (SETelem_(newfacet->vertices, newskip) == SETelem_(facet->vertices, skip)) {
            trace3((qh, qh->ferr, 3053, "qh_matchdupridge: duplicate ridge due to duplicate facets (f%d skip %d and f%d skip %d) previously reported as QH7084.  Maximize dupdist to force vertex merge\n",
              newfacet->id, newskip, facet->id, skip));
            isduplicate= True;
          }
          ismatch= (same == (boolT)(newfacet->toporient ^ facet->toporient));
          if (SETelemt_(facet->neighbors, skip, facetT) != qh_DUPLICATEridge) {
            if (!makematch) {  /* occurs if many merges, e.g., rbox 100 W0 C2,1e-13 D6 t1546872462 | qhull C0 Qt Tcv */
              qh_fprintf(qh, qh->ferr, 6155, "qhull topology error (qh_matchdupridge): missing qh_DUPLICATEridge at f%d skip %d for new f%d skip %d hash %d ismatch %d.  Set by qh_matchneighbor\n",
                facet->id, skip, newfacet->id, newskip, hash, ismatch);
              qh_errexit2(qh, qh_ERRtopology, facet, newfacet);
            }
          }else if (!ismatch) {
            nextfacet= facet;
            nextskip= skip;
          }else if (SETelemt_(newfacet->neighbors, newskip, facetT) == qh_DUPLICATEridge) {
            if (makematch) {
              if (newfacet->tricoplanar) {
                SETelem_(facet->neighbors, skip)= newfacet;
                SETelem_(newfacet->neighbors, newskip)= facet;
                *hashcount -= 2; /* removed two unmatched facets */
                trace2((qh, qh->ferr, 2075, "qh_matchdupridge: allow tricoplanar dupridge for new f%d skip %d and f%d skip %d\n",
                    newfacet->id, newskip, facet->id, skip)); 
              }else if (goodmatch && goodmatch2) {
                SETelem_(goodmatch2->neighbors, goodskip2)= qh_MERGEridge;  /* undo selection of goodmatch */
                SETelem_(facet->neighbors, skip)= newfacet;
                SETelem_(newfacet->neighbors, newskip)= facet;
                *hashcount -= 2; /* removed two unmatched facets */
                trace2((qh, qh->ferr, 2105, "qh_matchdupridge: make good forced merge of dupridge f%d skip %d into f%d skip %d, keep new f%d skip %d and f%d skip %d, dist %4.4g\n",
                  goodmatch->id, goodskip, goodmatch2->id, goodskip2, newfacet->id, newskip, facet->id, skip, gooddist)); 
                goodmatch2= NULL;
              }else {
                SETelem_(facet->neighbors, skip)= newfacet;
                SETelem_(newfacet->neighbors, newskip)= qh_MERGEridge;  /* resolved by qh_mark_dupridges */
                *hashcount -= 2; /* removed two unmatched facets */
                trace3((qh, qh->ferr, 3073, "qh_matchdupridge: make forced merge of dupridge for new f%d skip %d and f%d skip %d, maxdist %4.4g in qh_forcedmerges\n",
                  newfacet->id, newskip, facet->id, skip, maxdist2));
              }
            }else { /* !makematch */
              if (!facet->normal)
                qh_setfacetplane(qh, facet); /* qh_mergecycle will ignore 'mergehorizon' facets with normals, too many cases otherwise */
              if (!newfacet->normal) 
                qh_setfacetplane(qh, newfacet);
              dupdist= qh_getdistance(qh, facet, newfacet, &low, &high); /* ignore low/high */
              dupdist2= qh_getdistance(qh, newfacet, facet, &low, &high);
              if (isduplicate) {
                goodmatch= NULL;
                minimize_(dupdist, dupdist2);
                maxdist= dupdist;
                maxdist2= REALmax/2;
                maxmatch= facet;
                maxskip= skip;
                maxmatch2= newfacet;
                maxskip2= newskip;
                break; /* force maxmatch */
              }else if (facet->flipped && !newfacet->flipped && dupdist < maxgood) {
                if (!goodmatch || !goodmatch->flipped || dupdist < gooddist) {
                  goodmatch= facet; 
                  goodskip= skip;
                  goodmatch2= newfacet;
                  goodskip2= newskip;
                  gooddist= dupdist;
                  trace3((qh, qh->ferr, 3070, "qh_matchdupridge: try good dupridge flipped f%d skip %d into new f%d skip %d at dist %2.2g otherdist %2.2g\n",
                    goodmatch->id, goodskip, goodmatch2->id, goodskip2, gooddist, dupdist2));
                }
              }else if (newfacet->flipped && !facet->flipped && dupdist2 < maxgood) {
                if (!goodmatch || !goodmatch->flipped || dupdist2 < gooddist) {
                  goodmatch= newfacet;  
                  goodskip= newskip;
                  goodmatch2= facet;
                  goodskip2= skip;
                  gooddist= dupdist2;
                  trace3((qh, qh->ferr, 3071, "qh_matchdupridge: try good dupridge flipped new f%d skip %d into f%d skip %d at dist %2.2g otherdist %2.2g\n",
                    goodmatch->id, goodskip, goodmatch2->id, goodskip2, gooddist, dupdist));
                }
              }else if (dupdist < maxgood && (!newfacet->flipped || facet->flipped)) { /* disallow not-flipped->flipped */
                if (!goodmatch || (!goodmatch->flipped && dupdist < gooddist)) {
                  goodmatch= facet;
                  goodskip= skip;
                  goodmatch2= newfacet;
                  goodskip2= newskip;
                  gooddist= dupdist;
                  trace3((qh, qh->ferr, 3072, "qh_matchdupridge: try good dupridge f%d skip %d into new f%d skip %d at dist %2.2g otherdist %2.2g\n",
                    goodmatch->id, goodskip, goodmatch2->id, goodskip2, gooddist, dupdist2));
                }
              }else if (dupdist2 < maxgood && (!facet->flipped || newfacet->flipped)) { /* disallow not-flipped->flipped */
                if (!goodmatch || (!goodmatch->flipped && dupdist2 < gooddist)) {
                  goodmatch= newfacet;  
                  goodskip= newskip;
                  goodmatch2= facet;
                  goodskip2= skip;
                  gooddist= dupdist2;
                  trace3((qh, qh->ferr, 3018, "qh_matchdupridge: try good dupridge new f%d skip %d into f%d skip %d at dist %2.2g otherdist %2.2g\n",
                    goodmatch->id, goodskip, goodmatch2->id, goodskip2, gooddist, dupdist));
                }
              }else if (!goodmatch) { /* otherwise match the furthest apart facets */
                if (!newfacet->flipped || facet->flipped) {
                  minimize_(dupdist, dupdist2);
                }
                if (dupdist > maxdist) { /* could keep !flipped->flipped, but probably lost anyway */
                  maxdist2= maxdist;
                  maxdist= dupdist;
                  maxmatch= facet;
                  maxskip= skip;
                  maxmatch2= newfacet;
                  maxskip2= newskip;
                  trace3((qh, qh->ferr, 3055, "qh_matchdupridge: try furthest dupridge f%d skip %d new f%d skip %d at dist %2.2g\n",
                    maxmatch->id, maxskip, maxmatch2->id, maxskip2, maxdist));
                }else if (dupdist > maxdist2)
                  maxdist2= dupdist;
              }
            }
          }
        }
      } /* end of foreach entry in qh.hash_table starting at 'hash' */
      if (makematch && SETelemt_(newfacet->neighbors, newskip, facetT) == qh_DUPLICATEridge) {
        qh_fprintf(qh, qh->ferr, 6156, "qhull internal error (qh_matchdupridge): no MERGEridge match for dupridge new f%d skip %d at hash %d..%d\n",
                    newfacet->id, newskip, hash, scan);
        qh_errexit(qh, qh_ERRqhull, newfacet, NULL);
      }
    } /* end of foreach newfacet at 'hash' */
    if (!makematch) {
      if (!maxmatch && !goodmatch) {
        qh_fprintf(qh, qh->ferr, 6157, "qhull internal error (qh_matchdupridge): no maximum or good match for dupridge new f%d skip %d at hash %d..%d\n",
          atfacet->id, atskip, hash, scan);
        qh_errexit(qh, qh_ERRqhull, atfacet, NULL);
      }
      if (goodmatch) {
        SETelem_(goodmatch->neighbors, goodskip)= goodmatch2;
        SETelem_(goodmatch2->neighbors, goodskip2)= goodmatch;
        *hashcount -= 2; /* removed two unmatched facets */
        if (goodmatch->flipped) {
          if (!goodmatch2->flipped) {
            zzinc_(Zflipridge);
          }else {
            zzinc_(Zflipridge2);
            /* qh_joggle_restart called by qh_matchneighbor if qh_DUPLICATEridge */
          }
        }
        /* previously traced */
      }else {
        SETelem_(maxmatch->neighbors, maxskip)= maxmatch2; /* maxmatch!=NULL by QH6157 */
        SETelem_(maxmatch2->neighbors, maxskip2)= maxmatch;
        *hashcount -= 2; /* removed two unmatched facets */
        zzinc_(Zmultiridge);
        /* qh_joggle_restart called by qh_matchneighbor if qh_DUPLICATEridge */
        trace0((qh, qh->ferr, 25, "qh_matchdupridge: keep dupridge f%d skip %d and f%d skip %d, dist %4.4g\n",
          maxmatch2->id, maxskip2, maxmatch->id, maxskip, maxdist));
      }
    }
  }
  if (goodmatch)
    return gooddist;
  return maxdist2;
} /* matchdupridge */

#else /* qh_NOmerge */
coordT qh_matchdupridge(qhT *qh, facetT *atfacet, int atskip, int hashsize, int *hashcount) {
  QHULL_UNUSED(qh)
  QHULL_UNUSED(atfacet)
  QHULL_UNUSED(atskip)
  QHULL_UNUSED(hashsize)
  QHULL_UNUSED(hashcount)

  return 0.0;
}
#endif /* qh_NOmerge */

/*---------------------------------

  qh_nearcoplanar()
    for all facets, remove near-inside points from facet->coplanarset
    coplanar points defined by innerplane from qh_outerinner()

  returns:
    if qh->KEEPcoplanar && !qh->KEEPinside
      facet->coplanarset only contains coplanar points
    if qh.JOGGLEmax
      drops inner plane by another qh.JOGGLEmax diagonal since a
        vertex could shift out while a coplanar point shifts in

  notes:
    used for qh.PREmerge and qh.JOGGLEmax
    must agree with computation of qh.NEARcoplanar in qh_detroundoff

  design:
    if not keeping coplanar or inside points
      free all coplanar sets
    else if not keeping both coplanar and inside points
      remove !coplanar or !inside points from coplanar sets
*/
void qh_nearcoplanar(qhT *qh /* qh.facet_list */) {
  facetT *facet;
  pointT *point, **pointp;
  int numpart;
  realT dist, innerplane;

  if (!qh->KEEPcoplanar && !qh->KEEPinside) {
    FORALLfacets {
      if (facet->coplanarset)
        qh_setfree(qh, &facet->coplanarset);
    }
  }else if (!qh->KEEPcoplanar || !qh->KEEPinside) {
    qh_outerinner(qh, NULL, NULL, &innerplane);
    if (qh->JOGGLEmax < REALmax/2)
      innerplane -= qh->JOGGLEmax * sqrt((realT)qh->hull_dim);
    numpart= 0;
    FORALLfacets {
      if (facet->coplanarset) {
        FOREACHpoint_(facet->coplanarset) {
          numpart++;
          qh_distplane(qh, point, facet, &dist);
          if (dist < innerplane) {
            if (!qh->KEEPinside)
              SETref_(point)= NULL;
          }else if (!qh->KEEPcoplanar)
            SETref_(point)= NULL;
        }
        qh_setcompact(qh, facet->coplanarset);
      }
    }
    zzadd_(Zcheckpart, numpart);
  }
} /* nearcoplanar */

/*---------------------------------

  qh_nearvertex(qh, facet, point, bestdist )
    return nearest vertex in facet to point

  returns:
    vertex and its distance

  notes:
    if qh.DELAUNAY
      distance is measured in the input set
    searches neighboring tricoplanar facets (requires vertexneighbors)
      Slow implementation.  Recomputes vertex set for each point.
    The vertex set could be stored in the qh.keepcentrum facet.
*/
vertexT *qh_nearvertex(qhT *qh, facetT *facet, pointT *point, realT *bestdistp) {
  realT bestdist= REALmax, dist;
  vertexT *bestvertex= NULL, *vertex, **vertexp, *apex;
  coordT *center;
  facetT *neighbor, **neighborp;
  setT *vertices;
  int dim= qh->hull_dim;

  if (qh->DELAUNAY)
    dim--;
  if (facet->tricoplanar) {
    if (!qh->VERTEXneighbors || !facet->center) {
      qh_fprintf(qh, qh->ferr, 6158, "qhull internal error (qh_nearvertex): qh.VERTEXneighbors and facet->center required for tricoplanar facets\n");
      qh_errexit(qh, qh_ERRqhull, facet, NULL);
    }
    vertices= qh_settemp(qh, qh->TEMPsize);
    apex= SETfirstt_(facet->vertices, vertexT);
    center= facet->center;
    FOREACHneighbor_(apex) {
      if (neighbor->center == center) {
        FOREACHvertex_(neighbor->vertices)
          qh_setappend(qh, &vertices, vertex);
      }
    }
  }else
    vertices= facet->vertices;
  FOREACHvertex_(vertices) {
    dist= qh_pointdist(vertex->point, point, -dim);
    if (dist < bestdist) {
      bestdist= dist;
      bestvertex= vertex;
    }
  }
  if (facet->tricoplanar)
    qh_settempfree(qh, &vertices);
  *bestdistp= sqrt(bestdist);
  if (!bestvertex) {
      qh_fprintf(qh, qh->ferr, 6261, "qhull internal error (qh_nearvertex): did not find bestvertex for f%d p%d\n", facet->id, qh_pointid(qh, point));
      qh_errexit(qh, qh_ERRqhull, facet, NULL);
  }
  trace3((qh, qh->ferr, 3019, "qh_nearvertex: v%d dist %2.2g for f%d p%d\n",
        bestvertex->id, *bestdistp, facet->id, qh_pointid(qh, point))); /* bestvertex!=0 by QH2161 */
  return bestvertex;
} /* nearvertex */

/*---------------------------------

  qh_newhashtable(qh, newsize )
    returns size of qh.hash_table of at least newsize slots

  notes:
    assumes qh.hash_table is NULL
    qh_HASHfactor determines the number of extra slots
    size is not divisible by 2, 3, or 5
*/
int qh_newhashtable(qhT *qh, int newsize) {
  int size;

  size= ((newsize+1)*qh_HASHfactor) | 0x1;  /* odd number */
  while (True) {
    if (newsize<0 || size<0) {
        qh_fprintf(qh, qh->qhmem.ferr, 6236, "qhull error (qh_newhashtable): negative request (%d) or size (%d).  Did int overflow due to high-D?\n", newsize, size); /* WARN64 */
        qh_errexit(qh, qhmem_ERRmem, NULL, NULL);
    }
    if ((size%3) && (size%5))
      break;
    size += 2;
    /* loop terminates because there is an infinite number of primes */
  }
  qh->hash_table= qh_setnew(qh, size);
  qh_setzero(qh, qh->hash_table, 0, size);
  return size;
} /* newhashtable */

/*---------------------------------

  qh_newvertex(qh, point )
    returns a new vertex for point
*/
vertexT *qh_newvertex(qhT *qh, pointT *point) {
  vertexT *vertex;

  zinc_(Ztotvertices);
  vertex= (vertexT *)qh_memalloc(qh, (int)sizeof(vertexT));
  memset((char *) vertex, (size_t)0, sizeof(vertexT));
  if (qh->vertex_id == UINT_MAX) {
    qh_memfree(qh, vertex, (int)sizeof(vertexT));
    qh_fprintf(qh, qh->ferr, 6159, "qhull error: 2^32 or more vertices.  vertexT.id field overflows.  Vertices would not be sorted correctly.\n");
    qh_errexit(qh, qh_ERRother, NULL, NULL);
  }
  if (qh->vertex_id == qh->tracevertex_id)
    qh->tracevertex= vertex;
  vertex->id= qh->vertex_id++;
  vertex->point= point;
  trace4((qh, qh->ferr, 4060, "qh_newvertex: vertex p%d(v%d) created\n", qh_pointid(qh, vertex->point),
          vertex->id));
  return(vertex);
} /* newvertex */

/*---------------------------------

  qh_nextfacet2d( facet, &nextvertex )
    return next facet and vertex for a 2d facet in qh_ORIENTclock order
    returns NULL on error

  notes:
    in qh_ORIENTclock order (default counter-clockwise)
    nextvertex is in between the two facets
    does not use qhT or qh_errexit [QhullFacet.cpp]

  design:
    see io_r.c/qh_printextremes_2d
*/
facetT *qh_nextfacet2d(facetT *facet, vertexT **nextvertexp) {
  facetT *nextfacet;

  if (facet->toporient ^ qh_ORIENTclock) {
    *nextvertexp= SETfirstt_(facet->vertices, vertexT);
    nextfacet= SETfirstt_(facet->neighbors, facetT);
  }else {
    *nextvertexp= SETsecondt_(facet->vertices, vertexT);
    nextfacet= SETsecondt_(facet->neighbors, facetT);
  }
  return nextfacet;
} /* nextfacet2d */

/*---------------------------------

  qh_nextridge3d( atridge, facet, &vertex )
    return next ridge and vertex for a 3d facet
    returns NULL on error
    [for QhullFacet::nextRidge3d] Does not call qh_errexit nor access qhT.

  notes:
    in qh_ORIENTclock order
    this is a O(n^2) implementation to trace all ridges
    be sure to stop on any 2nd visit
    same as QhullRidge::nextRidge3d
    does not use qhT or qh_errexit [QhullFacet.cpp]

  design:
    for each ridge
      exit if it is the ridge after atridge
*/
ridgeT *qh_nextridge3d(ridgeT *atridge, facetT *facet, vertexT **vertexp) {
  vertexT *atvertex, *vertex, *othervertex;
  ridgeT *ridge, **ridgep;

  if ((atridge->top == facet) ^ qh_ORIENTclock)
    atvertex= SETsecondt_(atridge->vertices, vertexT);
  else
    atvertex= SETfirstt_(atridge->vertices, vertexT);
  FOREACHridge_(facet->ridges) {
    if (ridge == atridge)
      continue;
    if ((ridge->top == facet) ^ qh_ORIENTclock) {
      othervertex= SETsecondt_(ridge->vertices, vertexT);
      vertex= SETfirstt_(ridge->vertices, vertexT);
    }else {
      vertex= SETsecondt_(ridge->vertices, vertexT);
      othervertex= SETfirstt_(ridge->vertices, vertexT);
    }
    if (vertex == atvertex) {
      if (vertexp)
        *vertexp= othervertex;
      return ridge;
    }
  }
  return NULL;
} /* nextridge3d */

/*---------------------------------

  qh_opposite_vertex(qh, facetA, neighbor )
    return the opposite vertex in facetA to neighbor

*/
vertexT *qh_opposite_vertex(qhT *qh, facetT *facetA,  facetT *neighbor) {
    vertexT *opposite= NULL;
    facetT *facet;
    int facet_i, facet_n;

    if (facetA->simplicial) {
      FOREACHfacet_i_(qh, facetA->neighbors) {
        if (facet == neighbor) {
          opposite= SETelemt_(facetA->vertices, facet_i, vertexT);
          break;
        }
      }
    }
    if (!opposite) {
      qh_fprintf(qh, qh->ferr, 6396, "qhull internal error (qh_opposite_vertex): opposite vertex in facet f%d to neighbor f%d is not defined.  Either is facet is not simplicial or neighbor not found\n",
        facetA->id, neighbor->id);
      qh_errexit2(qh, qh_ERRqhull, facetA, neighbor);
    }
    return opposite;
} /* opposite_vertex */

/*---------------------------------

  qh_outcoplanar()
    move points from all facets' outsidesets to their coplanarsets

  notes:
    for post-processing under qh.NARROWhull

  design:
    for each facet
      for each outside point for facet
        partition point into coplanar set
*/
void qh_outcoplanar(qhT *qh /* facet_list */) {
  pointT *point, **pointp;
  facetT *facet;
  realT dist;

  trace1((qh, qh->ferr, 1033, "qh_outcoplanar: move outsideset to coplanarset for qh->NARROWhull\n"));
  FORALLfacets {
    FOREACHpoint_(facet->outsideset) {
      qh->num_outside--;
      if (qh->KEEPcoplanar || qh->KEEPnearinside) {
        qh_distplane(qh, point, facet, &dist);
        zinc_(Zpartition);
        qh_partitioncoplanar(qh, point, facet, &dist, qh->findbestnew);
      }
    }
    qh_setfree(qh, &facet->outsideset);
  }
} /* outcoplanar */

/*---------------------------------

  qh_point(qh, id )
    return point for a point id, or NULL if unknown

  alternative code:
    return((pointT *)((unsigned long)qh.first_point
           + (unsigned long)((id)*qh.normal_size)));
*/
pointT *qh_point(qhT *qh, int id) {

  if (id < 0)
    return NULL;
  if (id < qh->num_points)
    return qh->first_point + id * qh->hull_dim;
  id -= qh->num_points;
  if (id < qh_setsize(qh, qh->other_points))
    return SETelemt_(qh->other_points, id, pointT);
  return NULL;
} /* point */

/*---------------------------------

  qh_point_add(qh, set, point, elem )
    stores elem at set[point.id]

  returns:
    access function for qh_pointfacet and qh_pointvertex

  notes:
    checks point.id
*/
void qh_point_add(qhT *qh, setT *set, pointT *point, void *elem) {
  int id, size;

  SETreturnsize_(set, size);
  if ((id= qh_pointid(qh, point)) < 0)
    qh_fprintf(qh, qh->ferr, 7067, "qhull internal warning (point_add): unknown point %p id %d\n",
      point, id);
  else if (id >= size) {
    qh_fprintf(qh, qh->ferr, 6160, "qhull internal error (point_add): point p%d is out of bounds(%d)\n",
             id, size);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }else
    SETelem_(set, id)= elem;
} /* point_add */


/*---------------------------------

  qh_pointfacet()
    return temporary set of facet for each point
    the set is indexed by point id
    at most one facet per point, arbitrary selection

  notes:
    each point is assigned to at most one of vertices, coplanarset, or outsideset
    unassigned points are interior points or 
    vertices assigned to one of its facets
    coplanarset assigned to the facet
    outside set assigned to the facet
    NULL if no facet for point (inside)
      includes qh.GOODpointp

  access:
    FOREACHfacet_i_(qh, facets) { ... }
    SETelem_(facets, i)

  design:
    for each facet
      add each vertex
      add each coplanar point
      add each outside point
*/
setT *qh_pointfacet(qhT *qh /* qh.facet_list */) {
  int numpoints= qh->num_points + qh_setsize(qh, qh->other_points);
  setT *facets;
  facetT *facet;
  vertexT *vertex, **vertexp;
  pointT *point, **pointp;

  facets= qh_settemp(qh, numpoints);
  qh_setzero(qh, facets, 0, numpoints);
  qh->vertex_visit++;
  FORALLfacets {
    FOREACHvertex_(facet->vertices) {
      if (vertex->visitid != qh->vertex_visit) {
        vertex->visitid= qh->vertex_visit;
        qh_point_add(qh, facets, vertex->point, facet);
      }
    }
    FOREACHpoint_(facet->coplanarset)
      qh_point_add(qh, facets, point, facet);
    FOREACHpoint_(facet->outsideset)
      qh_point_add(qh, facets, point, facet);
  }
  return facets;
} /* pointfacet */

/*---------------------------------

  qh_pointvertex(qh )
    return temporary set of vertices indexed by point id
    entry is NULL if no vertex for a point
      this will include qh.GOODpointp

  access:
    FOREACHvertex_i_(qh, vertices) { ... }
    SETelem_(vertices, i)
*/
setT *qh_pointvertex(qhT *qh /* qh.facet_list */) {
  int numpoints= qh->num_points + qh_setsize(qh, qh->other_points);
  setT *vertices;
  vertexT *vertex;

  vertices= qh_settemp(qh, numpoints);
  qh_setzero(qh, vertices, 0, numpoints);
  FORALLvertices
    qh_point_add(qh, vertices, vertex->point, vertex);
  return vertices;
} /* pointvertex */


/*---------------------------------

  qh_prependfacet(qh, facet, facetlist )
    prepend facet to the start of a facetlist

  returns:
    increments qh.numfacets
    updates facetlist, qh.facet_list, facet_next

  notes:
    be careful of prepending since it can lose a pointer.
      e.g., can lose _next by deleting and then prepending before _next
*/
void qh_prependfacet(qhT *qh, facetT *facet, facetT **facetlist) {
  facetT *prevfacet, *list;

  trace4((qh, qh->ferr, 4061, "qh_prependfacet: prepend f%d before f%d\n",
          facet->id, getid_(*facetlist)));
  if (!*facetlist)
    (*facetlist)= qh->facet_tail;
  list= *facetlist;
  prevfacet= list->previous;
  facet->previous= prevfacet;
  if (prevfacet)
    prevfacet->next= facet;
  list->previous= facet;
  facet->next= *facetlist;
  if (qh->facet_list == list)  /* this may change *facetlist */
    qh->facet_list= facet;
  if (qh->facet_next == list)
    qh->facet_next= facet;
  *facetlist= facet;
  qh->num_facets++;
} /* prependfacet */


/*---------------------------------

  qh_printhashtable(qh, fp )
    print hash table to fp

  notes:
    not in I/O to avoid bringing io_r.c in

  design:
    for each hash entry
      if defined
        if unmatched or will merge (NULL, qh_MERGEridge, qh_DUPLICATEridge)
          print entry and neighbors
*/
void qh_printhashtable(qhT *qh, FILE *fp) {
  facetT *facet, *neighbor;
  int id, facet_i, facet_n, neighbor_i= 0, neighbor_n= 0;
  vertexT *vertex, **vertexp;

  FOREACHfacet_i_(qh, qh->hash_table) {
    if (facet) {
      FOREACHneighbor_i_(qh, facet) {
        if (!neighbor || neighbor == qh_MERGEridge || neighbor == qh_DUPLICATEridge)
          break;
      }
      if (neighbor_i == neighbor_n)
        continue;
      qh_fprintf(qh, fp, 9283, "hash %d f%d ", facet_i, facet->id);
      FOREACHvertex_(facet->vertices)
        qh_fprintf(qh, fp, 9284, "v%d ", vertex->id);
      qh_fprintf(qh, fp, 9285, "\n neighbors:");
      FOREACHneighbor_i_(qh, facet) {
        if (neighbor == qh_MERGEridge)
          id= -3;
        else if (neighbor == qh_DUPLICATEridge)
          id= -2;
        else
          id= getid_(neighbor);
        qh_fprintf(qh, fp, 9286, " %d", id);
      }
      qh_fprintf(qh, fp, 9287, "\n");
    }
  }
} /* printhashtable */

/*---------------------------------

  qh_printlists(qh)
    print out facet and vertex lists for debugging (without 'f/v' tags)

  notes:
    not in I/O to avoid bringing io_r.c in
*/
void qh_printlists(qhT *qh) {
  facetT *facet;
  vertexT *vertex;
  int count= 0;

  qh_fprintf(qh, qh->ferr, 3062, "qh_printlists: max_outside %2.2g all facets:", qh->max_outside);
  FORALLfacets{
    if (++count % 100 == 0)
      qh_fprintf(qh, qh->ferr, 8109, "\n     ");
    qh_fprintf(qh, qh->ferr, 8110, " %d", facet->id);
  }
    qh_fprintf(qh, qh->ferr, 8111, "\n  qh.visible_list f%d, newfacet_list f%d, facet_next f%d for qh_addpoint\n  qh.newvertex_list v%d all vertices:",
      getid_(qh->visible_list), getid_(qh->newfacet_list), getid_(qh->facet_next), getid_(qh->newvertex_list));
  count= 0;
  FORALLvertices{
    if (++count % 100 == 0)
      qh_fprintf(qh, qh->ferr, 8112, "\n     ");
    qh_fprintf(qh, qh->ferr, 8113, " %d", vertex->id);
  }
  qh_fprintf(qh, qh->ferr, 8114, "\n");
} /* printlists */

/*---------------------------------

  qh_replacefacetvertex(qh, facet, oldvertex, newvertex )
    replace oldvertex with newvertex in f.vertices
    vertices are inverse sorted by vertex->id

  returns:
    toporient is flipped if an odd parity, position change

  notes:
    for simplicial facets in qh_rename_adjacentvertex
    see qh_addfacetvertex
*/
void qh_replacefacetvertex(qhT *qh, facetT *facet, vertexT *oldvertex, vertexT *newvertex) {
  vertexT *vertex;
  facetT *neighbor;
  int vertex_i, vertex_n= 0;
  int old_i= -1, new_i= -1;

  trace3((qh, qh->ferr, 3038, "qh_replacefacetvertex: replace v%d with v%d in f%d\n", oldvertex->id, newvertex->id, facet->id));
  if (!facet->simplicial) {
    qh_fprintf(qh, qh->ferr, 6283, "qhull internal error (qh_replacefacetvertex): f%d is not simplicial\n", facet->id);
    qh_errexit(qh, qh_ERRqhull, facet, NULL);
  }
  FOREACHvertex_i_(qh, facet->vertices) {
    if (new_i == -1 && vertex->id < newvertex->id) {
      new_i= vertex_i;
    }else if (vertex->id == newvertex->id) {
      qh_fprintf(qh, qh->ferr, 6281, "qhull internal error (qh_replacefacetvertex): f%d already contains new v%d\n", facet->id, newvertex->id);
      qh_errexit(qh, qh_ERRqhull, facet, NULL);
    }
    if (vertex->id == oldvertex->id) {
      old_i= vertex_i;
    }
  }
  if (old_i == -1) {
    qh_fprintf(qh, qh->ferr, 6282, "qhull internal error (qh_replacefacetvertex): f%d does not contain old v%d\n", facet->id, oldvertex->id);
    qh_errexit(qh, qh_ERRqhull, facet, NULL);
  }
  if (new_i == -1) {
    new_i= vertex_n;
  }
  if (old_i < new_i)
    new_i--;
  if ((old_i & 0x1) != (new_i & 0x1))
    facet->toporient ^= 1;
  qh_setdelnthsorted(qh, facet->vertices, old_i);
  qh_setaddnth(qh, &facet->vertices, new_i, newvertex);
  neighbor= SETelemt_(facet->neighbors, old_i, facetT);
  qh_setdelnthsorted(qh, facet->neighbors, old_i);
  qh_setaddnth(qh, &facet->neighbors, new_i, neighbor);
} /* replacefacetvertex */

/*---------------------------------

  qh_resetlists(qh, stats, qh_RESETvisible )
    reset newvertex_list, newfacet_list, visible_list, NEWfacets, NEWtentative
    if stats,
      maintains statistics
    if resetVisible, 
      visible_list is restored to facet_list
      otherwise, f.visible/f.replace is retained

  returns:
    newvertex_list, newfacet_list, visible_list are NULL

  notes:
    To delete visible facets, call qh_deletevisible before qh_resetlists
*/
void qh_resetlists(qhT *qh, boolT stats, boolT resetVisible /* qh.newvertex_list newfacet_list visible_list */) {
  vertexT *vertex;
  facetT *newfacet, *visible;
  int totnew=0, totver=0;

  trace2((qh, qh->ferr, 2066, "qh_resetlists: reset newvertex_list v%d, newfacet_list f%d, visible_list f%d, facet_list f%d next f%d vertex_list v%d -- NEWfacets? %d, NEWtentative? %d, stats? %d\n",
    getid_(qh->newvertex_list), getid_(qh->newfacet_list), getid_(qh->visible_list), getid_(qh->facet_list), getid_(qh->facet_next), getid_(qh->vertex_list), qh->NEWfacets, qh->NEWtentative, stats));
  if (stats) {
    FORALLvertex_(qh->newvertex_list)
      totver++;
    FORALLnew_facets
      totnew++;
    zadd_(Zvisvertextot, totver);
    zmax_(Zvisvertexmax, totver);
    zadd_(Znewfacettot, totnew);
    zmax_(Znewfacetmax, totnew);
  }
  FORALLvertex_(qh->newvertex_list)
    vertex->newfacet= False;
  qh->newvertex_list= NULL;
  qh->first_newfacet= 0;
  FORALLnew_facets {
    newfacet->newfacet= False;
    newfacet->dupridge= False;
  }
  qh->newfacet_list= NULL;
  if (resetVisible) {
    FORALLvisible_facets {
      visible->f.replace= NULL;
      visible->visible= False;
    }
    qh->num_visible= 0;
  }
  qh->visible_list= NULL; 
  qh->NEWfacets= False;
  qh->NEWtentative= False;
} /* resetlists */

/*---------------------------------

  qh_setvoronoi_all(qh)
    compute Voronoi centers for all facets
    includes upperDelaunay facets if qh.UPPERdelaunay ('Qu')

  returns:
    facet->center is the Voronoi center

  notes:
    unused/untested code: please email bradb@shore.net if this works ok for you

  use:
    FORALLvertices {...} to locate the vertex for a point.
    FOREACHneighbor_(vertex) {...} to visit the Voronoi centers for a Voronoi cell.
*/
void qh_setvoronoi_all(qhT *qh) {
  facetT *facet;

  qh_clearcenters(qh, qh_ASvoronoi);
  qh_vertexneighbors(qh);

  FORALLfacets {
    if (!facet->normal || !facet->upperdelaunay || qh->UPPERdelaunay) {
      if (!facet->center)
        facet->center= qh_facetcenter(qh, facet->vertices);
    }
  }
} /* setvoronoi_all */

#ifndef qh_NOmerge
/*---------------------------------

  qh_triangulate()
    triangulate non-simplicial facets on qh.facet_list,
    if qh->VORONOI, sets Voronoi centers of non-simplicial facets
    nop if hasTriangulation

  returns:
    all facets simplicial
    each tricoplanar facet has ->f.triowner == owner of ->center,normal,etc.
    resets qh.newfacet_list and visible_list

  notes:
    called by qh_prepare_output and user_eg2_r.c
    call after qh_check_output since may switch to Voronoi centers, and qh_checkconvex skips f.tricoplanar facets
    Output may overwrite ->f.triowner with ->f.area
    while running, 'triangulated_facet_list' is a list of
       one non-simplicial facet followed by its 'f.tricoplanar' triangulated facets
    See qh_buildcone
*/
void qh_triangulate(qhT *qh /* qh.facet_list */) {
  facetT *facet, *nextfacet, *owner;
  facetT *neighbor, *visible= NULL, *facet1, *facet2, *triangulated_facet_list= NULL;
  facetT *orig_neighbor= NULL, *otherfacet;
  vertexT *triangulated_vertex_list= NULL;
  mergeT *merge;
  mergeType mergetype;
  int neighbor_i, neighbor_n;
  boolT onlygood= qh->ONLYgood;

  if (qh->hasTriangulation)
      return;
  trace1((qh, qh->ferr, 1034, "qh_triangulate: triangulate non-simplicial facets\n"));
  if (qh->hull_dim == 2)
    return;
  if (qh->VORONOI) {  /* otherwise lose Voronoi centers [could rebuild vertex set from tricoplanar] */
    qh_clearcenters(qh, qh_ASvoronoi);
    qh_vertexneighbors(qh);
  }
  qh->ONLYgood= False; /* for makenew_nonsimplicial */
  qh->visit_id++;
  qh_initmergesets(qh /* qh.facet_mergeset,degen_mergeset,vertex_mergeset */);
  qh->newvertex_list= qh->vertex_tail;
  for (facet=qh->facet_list; facet && facet->next; facet= nextfacet) { /* non-simplicial facets moved to end */
    nextfacet= facet->next;
    if (facet->visible || facet->simplicial)
      continue;
    /* triangulate all non-simplicial facets, otherwise merging does not work, e.g., RBOX c P-0.1 P+0.1 P+0.1 D3 | QHULL d Qt Tv */
    if (!triangulated_facet_list)
      triangulated_facet_list= facet;  /* will be first triangulated facet */
    qh_triangulate_facet(qh, facet, &triangulated_vertex_list); /* qh_resetlists ! */
  }
  /* qh_checkpolygon invalid due to f.visible without qh.visible_list */
  trace2((qh, qh->ferr, 2047, "qh_triangulate: delete null facets from facetlist f%d.  A null facet has the same first (apex) and second vertices\n", getid_(triangulated_facet_list)));
  for (facet=triangulated_facet_list; facet && facet->next; facet= nextfacet) {
    nextfacet= facet->next;
    if (facet->visible)
      continue;
    if (facet->ridges) {
      if (qh_setsize(qh, facet->ridges) > 0) {
        qh_fprintf(qh, qh->ferr, 6161, "qhull internal error (qh_triangulate): ridges still defined for f%d\n", facet->id);
        qh_errexit(qh, qh_ERRqhull, facet, NULL);
      }
      qh_setfree(qh, &facet->ridges);
    }
    if (SETfirst_(facet->vertices) == SETsecond_(facet->vertices)) {
      zinc_(Ztrinull);
      qh_triangulate_null(qh, facet); /* will delete facet */
    }
  }
  trace2((qh, qh->ferr, 2048, "qh_triangulate: delete %d or more mirrored facets.  Mirrored facets have the same vertices due to a null facet\n", qh_setsize(qh, qh->degen_mergeset)));
  qh->visible_list= qh->facet_tail;
  while ((merge= (mergeT *)qh_setdellast(qh->degen_mergeset))) {
    facet1= merge->facet1;
    facet2= merge->facet2;
    mergetype= merge->mergetype;
    qh_memfree(qh, merge, (int)sizeof(mergeT));
    if (mergetype == MRGmirror) {
      zinc_(Ztrimirror);
      qh_triangulate_mirror(qh, facet1, facet2);  /* will delete both facets */
    }
  }
  qh_freemergesets(qh);
  trace2((qh, qh->ferr, 2049, "qh_triangulate: update neighbor lists for vertices from v%d\n", getid_(triangulated_vertex_list)));
  qh->newvertex_list= triangulated_vertex_list;  /* all vertices of triangulated facets */
  qh->visible_list= NULL;
  qh_update_vertexneighbors(qh /* qh.newvertex_list, empty newfacet_list and visible_list */);
  qh_resetlists(qh, False, !qh_RESETvisible /* qh.newvertex_list, empty newfacet_list and visible_list */);

  trace2((qh, qh->ferr, 2050, "qh_triangulate: identify degenerate tricoplanar facets from f%d\n", getid_(triangulated_facet_list)));
  trace2((qh, qh->ferr, 2051, "qh_triangulate: and replace facet->f.triowner with tricoplanar facets that own center, normal, etc.\n"));
  FORALLfacet_(triangulated_facet_list) {
    if (facet->tricoplanar && !facet->visible) {
      FOREACHneighbor_i_(qh, facet) {
        if (neighbor_i == 0) {  /* first iteration */
          if (neighbor->tricoplanar)
            orig_neighbor= neighbor->f.triowner;
          else
            orig_neighbor= neighbor;
        }else {
          if (neighbor->tricoplanar)
            otherfacet= neighbor->f.triowner;
          else
            otherfacet= neighbor;
          if (orig_neighbor == otherfacet) {
            zinc_(Ztridegen);
            facet->degenerate= True;
            break;
          }
        }
      }
    }
  }
  if (qh->IStracing >= 4)
    qh_printlists(qh);
  trace2((qh, qh->ferr, 2052, "qh_triangulate: delete visible facets -- non-simplicial, null, and mirrored facets\n"));
  owner= NULL;
  visible= NULL;
  for (facet=triangulated_facet_list; facet && facet->next; facet= nextfacet) { 
    /* deleting facets, triangulated_facet_list is no longer valid */
    nextfacet= facet->next;
    if (facet->visible) {
      if (facet->tricoplanar) { /* a null or mirrored facet */
        qh_delfacet(qh, facet);
        qh->num_visible--;
      }else {  /* a non-simplicial facet followed by its tricoplanars */
        if (visible && !owner) {
          /*  RBOX 200 s D5 t1001471447 | QHULL Qt C-0.01 Qx Qc Tv Qt -- f4483 had 6 vertices/neighbors and 8 ridges */
          trace2((qh, qh->ferr, 2053, "qh_triangulate: delete f%d.  All tricoplanar facets degenerate for non-simplicial facet\n",
                       visible->id));
          qh_delfacet(qh, visible);
          qh->num_visible--;
        }
        visible= facet;
        owner= NULL;
      }
    }else if (facet->tricoplanar) {
      if (facet->f.triowner != visible || visible==NULL) {
        qh_fprintf(qh, qh->ferr, 6162, "qhull internal error (qh_triangulate): tricoplanar facet f%d not owned by its visible, non-simplicial facet f%d\n", facet->id, getid_(visible));
        qh_errexit2(qh, qh_ERRqhull, facet, visible);
      }
      if (owner)
        facet->f.triowner= owner;
      else if (!facet->degenerate) {
        owner= facet;
        nextfacet= visible->next; /* rescan tricoplanar facets with owner, visible!=0 by QH6162 */
        facet->keepcentrum= True;  /* one facet owns ->normal, etc. */
        facet->coplanarset= visible->coplanarset;
        facet->outsideset= visible->outsideset;
        visible->coplanarset= NULL;
        visible->outsideset= NULL;
        if (!qh->TRInormals) { /* center and normal copied to tricoplanar facets */
          visible->center= NULL;
          visible->normal= NULL;
        }
        qh_delfacet(qh, visible);
        qh->num_visible--;
      }
    }
    facet->degenerate= False; /* reset f.degenerate set by qh_triangulate*/
  }
  if (visible && !owner) {
    trace2((qh, qh->ferr, 2054, "qh_triangulate: all tricoplanar facets degenerate for last non-simplicial facet f%d\n",
                 visible->id));
    qh_delfacet(qh, visible);
    qh->num_visible--;
  }
  qh->ONLYgood= onlygood; /* restore value */
  if (qh->CHECKfrequently)
    qh_checkpolygon(qh, qh->facet_list);
  qh->hasTriangulation= True;
} /* triangulate */


/*---------------------------------

  qh_triangulate_facet(qh, facetA, &firstVertex )
    triangulate a non-simplicial facet
      if qh.CENTERtype=qh_ASvoronoi, sets its Voronoi center
  returns:
    qh.newfacet_list == simplicial facets
      facet->tricoplanar set and ->keepcentrum false
      facet->degenerate set if duplicated apex
      facet->f.trivisible set to facetA
      facet->center copied from facetA (created if qh_ASvoronoi)
        qh_eachvoronoi, qh_detvridge, qh_detvridge3 assume centers copied
      facet->normal,offset,maxoutside copied from facetA

  notes:
      only called by qh_triangulate
      qh_makenew_nonsimplicial uses neighbor->seen for the same
      if qh.TRInormals, newfacet->normal will need qh_free
        if qh.TRInormals and qh_AScentrum, newfacet->center will need qh_free
        keepcentrum is also set on Zwidefacet in qh_mergefacet
        freed by qh_clearcenters

  see also:
      qh_addpoint() -- add a point
      qh_makenewfacets() -- construct a cone of facets for a new vertex

  design:
      if qh_ASvoronoi,
         compute Voronoi center (facet->center)
      select first vertex (highest ID to preserve ID ordering of ->vertices)
      triangulate from vertex to ridges
      copy facet->center, normal, offset
      update vertex neighbors
*/
void qh_triangulate_facet(qhT *qh, facetT *facetA, vertexT **first_vertex) {
  facetT *newfacet;
  facetT *neighbor, **neighborp;
  vertexT *apex;
  int numnew=0;

  trace3((qh, qh->ferr, 3020, "qh_triangulate_facet: triangulate facet f%d\n", facetA->id));

  qh->first_newfacet= qh->facet_id;
  if (qh->IStracing >= 4)
    qh_printfacet(qh, qh->ferr, facetA);
  FOREACHneighbor_(facetA) {
    neighbor->seen= False;
    neighbor->coplanarhorizon= False;
  }
  if (qh->CENTERtype == qh_ASvoronoi && !facetA->center  /* matches upperdelaunay in qh_setfacetplane() */
  && fabs_(facetA->normal[qh->hull_dim -1]) >= qh->ANGLEround * qh_ZEROdelaunay) {
    facetA->center= qh_facetcenter(qh, facetA->vertices);
  }
  qh->visible_list= qh->newfacet_list= qh->facet_tail;
  facetA->visitid= qh->visit_id;
  apex= SETfirstt_(facetA->vertices, vertexT);
  qh_makenew_nonsimplicial(qh, facetA, apex, &numnew);
  qh_willdelete(qh, facetA, NULL);
  FORALLnew_facets {
    newfacet->tricoplanar= True;
    newfacet->f.trivisible= facetA;
    newfacet->degenerate= False;
    newfacet->upperdelaunay= facetA->upperdelaunay;
    newfacet->good= facetA->good;
    if (qh->TRInormals) { /* 'Q11' triangulate duplicates ->normal and ->center */
      newfacet->keepcentrum= True;
      if(facetA->normal){
        newfacet->normal= (double *)qh_memalloc(qh, qh->normal_size);
        memcpy((char *)newfacet->normal, facetA->normal, (size_t)qh->normal_size);
      }
      if (qh->CENTERtype == qh_AScentrum)
        newfacet->center= qh_getcentrum(qh, newfacet);
      else if (qh->CENTERtype == qh_ASvoronoi && facetA->center){
        newfacet->center= (double *)qh_memalloc(qh, qh->center_size);
        memcpy((char *)newfacet->center, facetA->center, (size_t)qh->center_size);
      }
    }else {
      newfacet->keepcentrum= False;
      /* one facet will have keepcentrum=True at end of qh_triangulate */
      newfacet->normal= facetA->normal;
      newfacet->center= facetA->center;
    }
    newfacet->offset= facetA->offset;
#if qh_MAXoutside
    newfacet->maxoutside= facetA->maxoutside;
#endif
  }
  qh_matchnewfacets(qh /* qh.newfacet_list */); /* ignore returned value, maxdupdist */ 
  zinc_(Ztricoplanar);
  zadd_(Ztricoplanartot, numnew);
  zmax_(Ztricoplanarmax, numnew);
  if (!(*first_vertex))
    (*first_vertex)= qh->newvertex_list;
  qh->newvertex_list= NULL;
  qh->visible_list= NULL;
  /* only update v.neighbors for qh.newfacet_list.  qh.visible_list and qh.newvertex_list are NULL */
  qh_update_vertexneighbors(qh /* qh.newfacet_list */);
  qh_resetlists(qh, False, !qh_RESETvisible /* qh.newfacet_list */);
} /* triangulate_facet */

/*---------------------------------

  qh_triangulate_link(qh, oldfacetA, facetA, oldfacetB, facetB)
    relink facetA to facetB via null oldfacetA or mirrored oldfacetA and oldfacetB
  returns:
    if neighbors are already linked, will merge as MRGmirror (qh.degen_mergeset, 4-d and up)
*/
void qh_triangulate_link(qhT *qh, facetT *oldfacetA, facetT *facetA, facetT *oldfacetB, facetT *facetB) {
  int errmirror= False;

  if (oldfacetA == oldfacetB) {
    trace3((qh, qh->ferr, 3052, "qh_triangulate_link: relink neighbors f%d and f%d of null facet f%d\n",
      facetA->id, facetB->id, oldfacetA->id));
  }else {
    trace3((qh, qh->ferr, 3021, "qh_triangulate_link: relink neighbors f%d and f%d of mirrored facets f%d and f%d\n",
      facetA->id, facetB->id, oldfacetA->id, oldfacetB->id));
  }
  if (qh_setin(facetA->neighbors, facetB)) {
    if (!qh_setin(facetB->neighbors, facetA))
      errmirror= True;
    else if (!facetA->redundant || !facetB->redundant || !qh_hasmerge(qh->degen_mergeset, MRGmirror, facetA, facetB))
      qh_appendmergeset(qh, facetA, facetB, MRGmirror, 0.0, 1.0);
  }else if (qh_setin(facetB->neighbors, facetA))
    errmirror= True;
  if (errmirror) {
    qh_fprintf(qh, qh->ferr, 6163, "qhull internal error (qh_triangulate_link): neighbors f%d and f%d do not match for null facet or mirrored facets f%d and f%d\n",
       facetA->id, facetB->id, oldfacetA->id, oldfacetB->id);
    qh_errexit2(qh, qh_ERRqhull, facetA, facetB);
  }
  qh_setreplace(qh, facetB->neighbors, oldfacetB, facetA);
  qh_setreplace(qh, facetA->neighbors, oldfacetA, facetB);
} /* triangulate_link */

/*---------------------------------

  qh_triangulate_mirror(qh, facetA, facetB)
    delete two mirrored facets identified by qh_triangulate_null() and itself
      a mirrored facet shares the same vertices of a logical ridge
  design:
    since a null facet duplicates the first two vertices, the opposing neighbors absorb the null facet
    if they are already neighbors, the opposing neighbors become MRGmirror facets
*/
void qh_triangulate_mirror(qhT *qh, facetT *facetA, facetT *facetB) {
  facetT *neighbor, *neighborB;
  int neighbor_i, neighbor_n;

  trace3((qh, qh->ferr, 3022, "qh_triangulate_mirror: delete mirrored facets f%d and f%d and link their neighbors\n",
         facetA->id, facetB->id));
  FOREACHneighbor_i_(qh, facetA) {
    neighborB= SETelemt_(facetB->neighbors, neighbor_i, facetT);
    if (neighbor == facetB && neighborB == facetA)
      continue; /* occurs twice */
    else if (neighbor->redundant && neighborB->redundant) { /* also mirrored facets (D5+) */
      if (qh_hasmerge(qh->degen_mergeset, MRGmirror, neighbor, neighborB))
        continue;
    }
    if (neighbor->visible && neighborB->visible) /* previously deleted as mirrored facets */
      continue;
    qh_triangulate_link(qh, facetA, neighbor, facetB, neighborB);
  }
  qh_willdelete(qh, facetA, NULL);
  qh_willdelete(qh, facetB, NULL);
} /* triangulate_mirror */

/*---------------------------------

  qh_triangulate_null(qh, facetA)
    remove null facetA from qh_triangulate_facet()
      a null facet has vertex #1 (apex) == vertex #2
  returns:
    adds facetA to ->visible for deletion after qh_update_vertexneighbors
    qh->degen_mergeset contains mirror facets (4-d and up only)
  design:
    since a null facet duplicates the first two vertices, the opposing neighbors absorb the null facet
    if they are already neighbors, the opposing neighbors will be merged (MRGmirror)
*/
void qh_triangulate_null(qhT *qh, facetT *facetA) {
  facetT *neighbor, *otherfacet;

  trace3((qh, qh->ferr, 3023, "qh_triangulate_null: delete null facet f%d\n", facetA->id));
  neighbor= SETfirstt_(facetA->neighbors, facetT);
  otherfacet= SETsecondt_(facetA->neighbors, facetT);
  qh_triangulate_link(qh, facetA, neighbor, facetA, otherfacet);
  qh_willdelete(qh, facetA, NULL);
} /* triangulate_null */

#else /* qh_NOmerge */
void qh_triangulate(qhT *qh) {
  QHULL_UNUSED(qh)
}
#endif /* qh_NOmerge */

/*---------------------------------

  qh_vertexintersect(qh, verticesA, verticesB )
    intersects two vertex sets (inverse id ordered)
    vertexsetA is a temporary set at the top of qh->qhmem.tempstack

  returns:
    replaces vertexsetA with the intersection

  notes:
    only called by qh_neighbor_intersections
    if !qh.QHULLfinished, non-simplicial facets may have f.vertices with extraneous vertices
      cleaned by qh_remove_extravertices in qh_reduce_vertices
    could optimize by overwriting vertexsetA
*/
void qh_vertexintersect(qhT *qh, setT **vertexsetA, setT *vertexsetB) {
  setT *intersection;

  intersection= qh_vertexintersect_new(qh, *vertexsetA, vertexsetB);
  qh_settempfree(qh, vertexsetA);
  *vertexsetA= intersection;
  qh_settemppush(qh, intersection);
} /* vertexintersect */

/*---------------------------------

  qh_vertexintersect_new(qh, verticesA, verticesB )
    intersects two vertex sets (inverse id ordered)

  returns:
    a new set

  notes:
    called by qh_checkfacet, qh_vertexintersect, qh_rename_sharedvertex, qh_findbest_pinchedvertex, qh_neighbor_intersections
    if !qh.QHULLfinished, non-simplicial facets may have f.vertices with extraneous vertices
       cleaned by qh_remove_extravertices in qh_reduce_vertices
*/
setT *qh_vertexintersect_new(qhT *qh, setT *vertexsetA, setT *vertexsetB) {
  setT *intersection= qh_setnew(qh, qh->hull_dim - 1);
  vertexT **vertexA= SETaddr_(vertexsetA, vertexT);
  vertexT **vertexB= SETaddr_(vertexsetB, vertexT);

  while (*vertexA && *vertexB) {
    if (*vertexA  == *vertexB) {
      qh_setappend(qh, &intersection, *vertexA);
      vertexA++; vertexB++;
    }else {
      if ((*vertexA)->id > (*vertexB)->id)
        vertexA++;
      else
        vertexB++;
    }
  }
  return intersection;
} /* vertexintersect_new */

/*---------------------------------

  qh_vertexneighbors(qh)
    for each vertex in qh.facet_list,
      determine its neighboring facets

  returns:
    sets qh.VERTEXneighbors
      nop if qh.VERTEXneighbors already set
      qh_addpoint() will maintain them

  notes:
    assumes all vertex->neighbors are NULL

  design:
    for each facet
      for each vertex
        append facet to vertex->neighbors
*/
void qh_vertexneighbors(qhT *qh /* qh.facet_list */) {
  facetT *facet;
  vertexT *vertex, **vertexp;

  if (qh->VERTEXneighbors)
    return;
  trace1((qh, qh->ferr, 1035, "qh_vertexneighbors: determining neighboring facets for each vertex\n"));
  qh->vertex_visit++;
  FORALLfacets {
    if (facet->visible)
      continue;
    FOREACHvertex_(facet->vertices) {
      if (vertex->visitid != qh->vertex_visit) {
        vertex->visitid= qh->vertex_visit;
        vertex->neighbors= qh_setnew(qh, qh->hull_dim);
      }
      qh_setappend(qh, &vertex->neighbors, facet);
    }
  }
  qh->VERTEXneighbors= True;
} /* vertexneighbors */

/*---------------------------------

  qh_vertexsubset( vertexsetA, vertexsetB )
    returns True if vertexsetA is a subset of vertexsetB
    assumes vertexsets are sorted

  note:
    empty set is a subset of any other set
*/
boolT qh_vertexsubset(setT *vertexsetA, setT *vertexsetB) {
  vertexT **vertexA= (vertexT **) SETaddr_(vertexsetA, vertexT);
  vertexT **vertexB= (vertexT **) SETaddr_(vertexsetB, vertexT);

  while (True) {
    if (!*vertexA)
      return True;
    if (!*vertexB)
      return False;
    if ((*vertexA)->id > (*vertexB)->id)
      return False;
    if (*vertexA  == *vertexB)
      vertexA++;
    vertexB++;
  }
  return False; /* avoid warnings */
} /* vertexsubset */
geometry/src/Rgeometry.c0000644000176200001440000000662314664417655015046 0ustar  liggesusers#include 
#include 
#include 
#include "qhull_ra.h"
#include               /* For unlink() */

void freeQhull(qhT *qh) {
  int curlong, totlong;
  qh_freeqhull(qh, !qh_ALL);                /* free long memory */
  qh_memfreeshort (qh, &curlong, &totlong);	/* free short memory and memory allocator */
  if (curlong || totlong) {
    Rf_warning("convhulln: did not free %d bytes of long memory (%d pieces)",
	    totlong, curlong);
  }
  qh_free(qh);
}

/* Finalizer which R will call when garbage collecting. This is
   registered at the end of convhulln() */
void qhullFinalizer(SEXP ptr)
{
  if(!R_ExternalPtrAddr(ptr)) return;
  qhT *qh;
  qh = R_ExternalPtrAddr(ptr);
  freeQhull(qh);
  R_ClearExternalPtr(ptr); /* not really needed */
}

boolT hasPrintOption(qhT *qh, qh_PRINT format) {
  for (int i=0; i < qh_PRINTEND; i++) {
    if (qh->PRINTout[i] == format) {
      return(True);
    }
  }
  return(False);
}

int qhullNewQhull(qhT *qh, const SEXP p, char* cmd, const SEXP options, const SEXP tmp_stdout, const SEXP tmp_stderr, unsigned int* pdim, unsigned int* pn, char errstr[ERRSTRSIZE]) {
  unsigned int dim, n;
  int exitcode = 1; 
  boolT ismalloc;
  char flags[250];             /* option flags for qhull, see qh_opt.htm */
  double *pt_array;
  int i, j;
  
  /* We cannot print directly to stdout in R, and the alternative of
     using R_Outputfile does not seem to work for all architectures.
     Setting outfile to NULL is not an option, as an open file handle
     is required for a call to freopen in the Qhull code when
     qh_new_qhull() is called. Therefore use the ersatz stdout,
     tmpstdout (see below). */
  /* qh_fprintf() in userprint.c has been redefined so that a NULL
     errfile results in printing via REprintf(). */
  FILE *tmpstdout = NULL;
  FILE *errfile = NULL;       

  if(!Rf_isString(options) || Rf_length(options) != 1){
    Rf_error("Second argument must be a single string.");
  }
  if(!Rf_isMatrix(p) || !Rf_isReal(p)){
    Rf_error("First argument should be a real matrix.");
  }

  /* Read options into command */
	i = LENGTH(STRING_ELT(options,0)); 
  if (i > 200) 
    Rf_error("Option string too long");
  snprintf(flags, 249, "%s %s", cmd, CHAR(STRING_ELT(options,0)));

  /* Check input matrix */
  dim = Rf_ncols(p);
  n   = Rf_nrows(p);
  if(dim <= 0 || n <= 0){
    Rf_error("Invalid input matrix.");
  }

  pt_array = (double *) R_alloc(n*dim, sizeof(double)); 
  for(i=0; i < n; i++)
    for(j=0; j < dim; j++)
      pt_array[dim*i+j] = REAL(p)[i+n*j]; /* could have been pt_array = REAL(p) if p had been transposed */

  ismalloc = False; /* True if qhull should free points in qh_freeqhull() or reallocation */

  /* Jiggery-pokery to create and destroy the ersatz stdout, and the
     call to qhull itself. */    
  const char *name, *errname;
  name = CHAR(STRING_ELT(tmp_stdout, 0));
  tmpstdout = fopen(name, "w");
  errname = CHAR(STRING_ELT(tmp_stderr, 0));
  errfile = fopen(errname, "w+");
  qh_zero(qh, errfile);
  exitcode = qh_new_qhull (qh, dim, n, pt_array, ismalloc, flags, tmpstdout, errfile);
  fclose(tmpstdout);
  unlink(name);
  rewind(errfile);
  char buf[200];
  errstr[0] = '\0';
  while(fgets(buf, sizeof(buf), errfile) != NULL &&
        (ERRSTRSIZE - strlen(errstr) - 1) > 0) {
    errstr = strncat(errstr, buf, ERRSTRSIZE - strlen(errstr) - 1);
  }
  
  fclose(errfile);
  unlink(errname);

  *pdim = dim;
  *pn = n;
  return(exitcode);
}
geometry/src/Makevars0000644000176200001440000000013014664417655014404 0ustar  liggesusersPKG_CFLAGS = -include Rgeometry.h
PKG_LDFLAGS = -fno-common
PKG_CPPFLAGS = -DR_NO_REMAP
geometry/src/Rinhulln.c0000644000176200001440000000441714664417655014663 0ustar  liggesusers/* Copyright (C) 2015, 2017, 2019 David Sterratt
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*/

#include "Rgeometry.h"
#include "qhull_ra.h"

/*  ch is the hull object produced by convhulln()
    p are the test points */
SEXP C_inhulln(const SEXP ch, const SEXP p)
{
  /* Get the qh object from the convhulln object */
  SEXP ptr, tag;
  qhT *qh;
  PROTECT(tag = Rf_allocVector(STRSXP, 1));
  SET_STRING_ELT(tag, 0, Rf_mkChar("convhulln"));
  PROTECT(ptr = Rf_getAttrib(ch, tag));
  if (ptr == R_NilValue) {
    Rf_error("Convex hull has no convhulln attribute");
  }
  qh = R_ExternalPtrAddr(ptr);
  UNPROTECT(2);
  
  /* Initialise return value */
  SEXP inside;
  inside = R_NilValue;

  /* Check input matrix */
  if(!Rf_isMatrix(p) || !Rf_isReal(p)){
    Rf_error("Second argument should be a real matrix.");
  }
  unsigned int dim, n;
  dim = Rf_ncols(p);
  n   = Rf_nrows(p);
  if(dim <= 0 || n <= 0){
    Rf_error("Invalid input matrix.");
  }
  if(dim != qh->hull_dim){
    Rf_error("Number of columns in test points p (%d) not equal to dimension of hull (%d).", dim, qh->hull_dim);
  }

  /* Run through the matrix using qh_findbestfacet to determine
     whether in hull or not */
  PROTECT(inside = Rf_allocVector(LGLSXP, n));
  double *point;
  point = (double *) R_alloc(dim, sizeof(double));
  boolT isoutside;
  realT bestdist;
  int i, j;
  for(i=0; i < n; i++) {
    for(j=0; j < dim; j++)
      point[j] = REAL(p)[i+n*j]; /* could have been pt_array = REAL(p) if p had been transposed */
    qh_findbestfacet(qh, point, !qh_ALL, &bestdist, &isoutside);
    LOGICAL(inside)[i] = !isoutside;
  }
  UNPROTECT(1);
  
  return inside;
}
geometry/src/io_r.c0000644000176200001440000042544214740034715014010 0ustar  liggesusers/*
  ---------------------------------

   io_r.c
   Input/Output routines of qhull application

   see qh-io_r.htm and io_r.h

   see user_r.c for qh_errprint and qh_printfacetlist

   unix_r.c calls qh_readpoints and qh_produce_output

   unix_r.c and user_r.c are the only callers of io_r.c functions
   This allows the user to avoid loading io_r.o from qhull.a

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/io_r.c#12 $$Change: 2965 $
   $DateTime: 2020/06/04 15:37:41 $$Author: bbarber $
*/

#include "qhull_ra.h"

/*========= -functions in alphabetical order after qh_produce_output(qh)  =====*/

/*---------------------------------

  qh_produce_output(qh )
  qh_produce_output2(qh )
    prints out the result of qhull in desired format
    qh_produce_output2 does not call qh_prepare_output
      qh_checkpolygon is valid for qh_prepare_output
    if qh.GETarea
      computes and prints area and volume
    qh.PRINTout[] is an array of output formats

  notes:
    prints output in qh.PRINTout order
*/
void qh_produce_output(qhT *qh) {
    int tempsize= qh_setsize(qh, qh->qhmem.tempstack);

    qh_prepare_output(qh);
    qh_produce_output2(qh);
    if (qh_setsize(qh, qh->qhmem.tempstack) != tempsize) {
        qh_fprintf(qh, qh->ferr, 6206, "qhull internal error (qh_produce_output): temporary sets not empty(%d)\n",
            qh_setsize(qh, qh->qhmem.tempstack));
        qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }
} /* produce_output */


void qh_produce_output2(qhT *qh) {
  int i, tempsize= qh_setsize(qh, qh->qhmem.tempstack), d_1;

  fflush(NULL);
  if (qh->PRINTsummary)
    qh_printsummary(qh, qh->ferr);
  else if (qh->PRINTout[0] == qh_PRINTnone)
    qh_printsummary(qh, qh->fout);
  for (i=0; i < qh_PRINTEND; i++)
    qh_printfacets(qh, qh->fout, qh->PRINTout[i], qh->facet_list, NULL, !qh_ALL);
  fflush(NULL);

  qh_allstatistics(qh);
  if (qh->PRINTprecision && !qh->MERGING && (qh->JOGGLEmax > REALmax/2 || qh->RERUN))
    qh_printstats(qh, qh->ferr, qh->qhstat.precision, NULL);
  if (qh->VERIFYoutput && (zzval_(Zridge) > 0 || zzval_(Zridgemid) > 0))
    qh_printstats(qh, qh->ferr, qh->qhstat.vridges, NULL);
  if (qh->PRINTstatistics) {
    qh_printstatistics(qh, qh->ferr, "");
    qh_memstatistics(qh, qh->ferr);
    d_1= SETbasesize + (qh->hull_dim - 1) * SETelemsize;
    qh_fprintf(qh, qh->ferr, 8040, "\
    size in bytes: merge %d ridge %d vertex %d facet %d\n\
         normal %d ridge vertices %d facet vertices or neighbors %d\n",
            (int)sizeof(mergeT), (int)sizeof(ridgeT),
            (int)sizeof(vertexT), (int)sizeof(facetT),
            qh->normal_size, d_1, d_1 + SETelemsize);
  }
  if (qh_setsize(qh, qh->qhmem.tempstack) != tempsize) {
    qh_fprintf(qh, qh->ferr, 6065, "qhull internal error (qh_produce_output2): temporary sets not empty(%d)\n",
             qh_setsize(qh, qh->qhmem.tempstack));
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
} /* produce_output2 */

/*---------------------------------

  qh_dfacet(qh, id )
    print facet by id, for debugging

*/
void qh_dfacet(qhT *qh, unsigned int id) {
  facetT *facet;

  FORALLfacets {
    if (facet->id == id) {
      qh_printfacet(qh, qh->fout, facet);
      break;
    }
  }
} /* dfacet */


/*---------------------------------

  qh_dvertex(qh, id )
    print vertex by id, for debugging
*/
void qh_dvertex(qhT *qh, unsigned int id) {
  vertexT *vertex;

  FORALLvertices {
    if (vertex->id == id) {
      qh_printvertex(qh, qh->fout, vertex);
      break;
    }
  }
} /* dvertex */


/*---------------------------------

  qh_compare_facetarea( p1, p2 )
    used by qsort() to order facets by area
*/
int qh_compare_facetarea(const void *p1, const void *p2) {
  const facetT *a= *((facetT *const*)p1), *b= *((facetT *const*)p2);

  if (!a->isarea)
    return -1;
  if (!b->isarea)
    return 1;
  if (a->f.area > b->f.area)
    return 1;
  else if (a->f.area == b->f.area)
    return 0;
  return -1;
} /* compare_facetarea */

/*---------------------------------

  qh_compare_facetvisit( p1, p2 )
    used by qsort() to order facets by visit id or id
*/
int qh_compare_facetvisit(const void *p1, const void *p2) {
  const facetT *a= *((facetT *const*)p1), *b= *((facetT *const*)p2);
  int i,j;

  if (!(i= (int)a->visitid))
    i= (int)(0 - a->id); /* sign distinguishes id from visitid */
  if (!(j= (int)b->visitid))
    j= (int)(0 - b->id);
  return(i - j);
} /* compare_facetvisit */

/*---------------------------------

  qh_compare_nummerge( p1, p2 )
    used by qsort() to order facets by number of merges

notes:
    called by qh_markkeep ('PMerge-keep')
*/
int qh_compare_nummerge(const void *p1, const void *p2) {
  const facetT *a= *((facetT *const*)p1), *b= *((facetT *const*)p2);

  return(a->nummerge - b->nummerge);
} /* compare_nummerge */

/*---------------------------------

  qh_copyfilename(qh, dest, size, source, length )
    copy filename identified by qh_skipfilename()

  notes:
    see qh_skipfilename() for syntax
*/
void qh_copyfilename(qhT *qh, char *filename, int size, const char* source, int length) {
  char c= *source;

  if (length > size + 1) {
      qh_fprintf(qh, qh->ferr, 6040, "qhull error: filename is more than %d characters, %s\n",  size-1, source);
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  strncpy(filename, source, (size_t)length);
  filename[length]= '\0';
  if (c == '\'' || c == '"') {
    char *s= filename + 1;
    char *t= filename;
    while (*s) {
      if (*s == c) {
          if (s[-1] == '\\')
              t[-1]= c;
      }else
          *t++= *s;
      s++;
    }
    *t= '\0';
  }
} /* copyfilename */

/*---------------------------------

  qh_countfacets(qh, facetlist, facets, printall,
          numfacets, numsimplicial, totneighbors, numridges, numcoplanar, numtricoplanars  )
    count good facets for printing and set visitid
    if allfacets, ignores qh_skipfacet()

  notes:
    qh_printsummary and qh_countfacets must match counts

  returns:
    numfacets, numsimplicial, total neighbors, numridges, coplanars
    each facet with ->visitid indicating 1-relative position
      ->visitid==0 indicates not good

  notes
    numfacets >= numsimplicial
    if qh.NEWfacets,
      does not count visible facets (matches qh_printafacet)

  design:
    for all facets on facetlist and in facets set
      unless facet is skipped or visible (i.e., will be deleted)
        mark facet->visitid
        update counts
*/
void qh_countfacets(qhT *qh, facetT *facetlist, setT *facets, boolT printall,
    int *numfacetsp, int *numsimplicialp, int *totneighborsp, int *numridgesp, int *numcoplanarsp, int *numtricoplanarsp) {
  facetT *facet, **facetp;
  int numfacets= 0, numsimplicial= 0, numridges= 0, totneighbors= 0, numcoplanars= 0, numtricoplanars= 0;

  FORALLfacet_(facetlist) {
    if ((facet->visible && qh->NEWfacets)
    || (!printall && qh_skipfacet(qh, facet)))
      facet->visitid= 0;
    else {
      facet->visitid= (unsigned int)(++numfacets);
      totneighbors += qh_setsize(qh, facet->neighbors);
      if (facet->simplicial) {
        numsimplicial++;
        if (facet->keepcentrum && facet->tricoplanar)
          numtricoplanars++;
      }else
        numridges += qh_setsize(qh, facet->ridges);
      if (facet->coplanarset)
        numcoplanars += qh_setsize(qh, facet->coplanarset);
    }
  }

  FOREACHfacet_(facets) {
    if ((facet->visible && qh->NEWfacets)
    || (!printall && qh_skipfacet(qh, facet)))
      facet->visitid= 0;
    else {
      facet->visitid= (unsigned int)(++numfacets);
      totneighbors += qh_setsize(qh, facet->neighbors);
      if (facet->simplicial){
        numsimplicial++;
        if (facet->keepcentrum && facet->tricoplanar)
          numtricoplanars++;
      }else
        numridges += qh_setsize(qh, facet->ridges);
      if (facet->coplanarset)
        numcoplanars += qh_setsize(qh, facet->coplanarset);
    }
  }
  qh->visit_id += (unsigned int)numfacets + 1;
  *numfacetsp= numfacets;
  *numsimplicialp= numsimplicial;
  *totneighborsp= totneighbors;
  *numridgesp= numridges;
  *numcoplanarsp= numcoplanars;
  *numtricoplanarsp= numtricoplanars;
} /* countfacets */

/*---------------------------------

  qh_detvnorm(qh, vertex, vertexA, centers, offset )
    compute separating plane of the Voronoi diagram for a pair of input sites
    centers= set of facets (i.e., Voronoi vertices)
      facet->visitid= 0 iff vertex-at-infinity (i.e., unbounded)

  assumes:
    qh_ASvoronoi and qh_vertexneighbors() already set

  returns:
    norm
      a pointer into qh.gm_matrix to qh.hull_dim-1 reals
      copy the data before reusing qh.gm_matrix
    offset
      if 'QVn'
        sign adjusted so that qh.GOODvertexp is inside
      else
        sign adjusted so that vertex is inside

    qh.gm_matrix= simplex of points from centers relative to first center

  notes:
    in io_r.c so that code for 'v Tv' can be removed by removing io_r.c
    returns pointer into qh.gm_matrix to avoid tracking of temporary memory

  design:
    determine midpoint of input sites
    build points as the set of Voronoi vertices
    select a simplex from points (if necessary)
      include midpoint if the Voronoi region is unbounded
    relocate the first vertex of the simplex to the origin
    compute the normalized hyperplane through the simplex
    orient the hyperplane toward 'QVn' or 'vertex'
    if 'Tv' or 'Ts'
      if bounded
        test that hyperplane is the perpendicular bisector of the input sites
      test that Voronoi vertices not in the simplex are still on the hyperplane
    free up temporary memory
*/
pointT *qh_detvnorm(qhT *qh, vertexT *vertex, vertexT *vertexA, setT *centers, realT *offsetp) {
  facetT *facet, **facetp;
  int  i, k, pointid, pointidA, point_i, point_n;
  setT *simplex= NULL;
  pointT *point, **pointp, *point0, *midpoint, *normal, *inpoint;
  coordT *coord, *gmcoord, *normalp;
  setT *points= qh_settemp(qh, qh->TEMPsize);
  boolT nearzero= False;
  boolT unbounded= False;
  int numcenters= 0;
  int dim= qh->hull_dim - 1;
  realT dist, offset, angle, zero= 0.0;

  midpoint= qh->gm_matrix + qh->hull_dim * qh->hull_dim;  /* last row */
  for (k=0; k < dim; k++)
    midpoint[k]= (vertex->point[k] + vertexA->point[k])/2;
  FOREACHfacet_(centers) {
    numcenters++;
    if (!facet->visitid)
      unbounded= True;
    else {
      if (!facet->center)
        facet->center= qh_facetcenter(qh, facet->vertices);
      qh_setappend(qh, &points, facet->center);
    }
  }
  if (numcenters > dim) {
    simplex= qh_settemp(qh, qh->TEMPsize);
    qh_setappend(qh, &simplex, vertex->point);
    if (unbounded)
      qh_setappend(qh, &simplex, midpoint);
    qh_maxsimplex(qh, dim, points, NULL, 0, &simplex);
    qh_setdelnth(qh, simplex, 0);
  }else if (numcenters == dim) {
    if (unbounded)
      qh_setappend(qh, &points, midpoint);
    simplex= points;
  }else {
    qh_fprintf(qh, qh->ferr, 6216, "qhull internal error (qh_detvnorm): too few points(%d) to compute separating plane\n", numcenters);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  i= 0;
  gmcoord= qh->gm_matrix;
  point0= SETfirstt_(simplex, pointT);
  FOREACHpoint_(simplex) {
    if (qh->IStracing >= 4)
      qh_printmatrix(qh, qh->ferr, "qh_detvnorm: Voronoi vertex or midpoint",
                              &point, 1, dim);
    if (point != point0) {
      qh->gm_row[i++]= gmcoord;
      coord= point0;
      for (k=dim; k--; )
        *(gmcoord++)= *point++ - *coord++;
    }
  }
  qh->gm_row[i]= gmcoord;  /* does not overlap midpoint, may be used later for qh_areasimplex */
  normal= gmcoord;
  qh_sethyperplane_gauss(qh, dim, qh->gm_row, point0, True,
                normal, &offset, &nearzero);
  /* nearzero is true for axis-parallel hyperplanes (e.g., a bounding box).  Should detect degenerate hyperplanes.  See 'Tv' check following */
  if (qh->GOODvertexp == vertexA->point)
    inpoint= vertexA->point;
  else
    inpoint= vertex->point;
  zinc_(Zdistio);
  dist= qh_distnorm(dim, inpoint, normal, &offset);
  if (dist > 0) {
    offset= -offset;
    normalp= normal;
    for (k=dim; k--; ) {
      *normalp= -(*normalp);
      normalp++;
    }
  }
  if (qh->VERIFYoutput || qh->PRINTstatistics) {
    pointid= qh_pointid(qh, vertex->point);
    pointidA= qh_pointid(qh, vertexA->point);
    if (!unbounded) {
      zinc_(Zdiststat);
      dist= qh_distnorm(dim, midpoint, normal, &offset);
      if (dist < 0)
        dist= -dist;
      zzinc_(Zridgemid);
      wwmax_(Wridgemidmax, dist);
      wwadd_(Wridgemid, dist);
      trace4((qh, qh->ferr, 4014, "qh_detvnorm: points %d %d midpoint dist %2.2g\n",
                 pointid, pointidA, dist));
      for (k=0; k < dim; k++)
        midpoint[k]= vertexA->point[k] - vertex->point[k];  /* overwrites midpoint! */
      qh_normalize(qh, midpoint, dim, False);
      angle= qh_distnorm(dim, midpoint, normal, &zero); /* qh_detangle uses dim+1 */
      if (angle < 0.0)
        angle= angle + 1.0;
      else
        angle= angle - 1.0;
      if (angle < 0.0)
        angle= -angle;
      trace4((qh, qh->ferr, 4015, "qh_detvnorm: points %d %d angle %2.2g nearzero %d\n",
                 pointid, pointidA, angle, nearzero));
      if (nearzero) {
        zzinc_(Zridge0);
        wwmax_(Wridge0max, angle);
        wwadd_(Wridge0, angle);
      }else {
        zzinc_(Zridgeok)
        wwmax_(Wridgeokmax, angle);
        wwadd_(Wridgeok, angle);
      }
    }
    if (simplex != points) {
      FOREACHpoint_i_(qh, points) {
        if (!qh_setin(simplex, point)) {
          facet= SETelemt_(centers, point_i, facetT);
          zinc_(Zdiststat);
          dist= qh_distnorm(dim, point, normal, &offset);
          if (dist < 0)
            dist= -dist;
          zzinc_(Zridge);
          wwmax_(Wridgemax, dist);
          wwadd_(Wridge, dist);
          trace4((qh, qh->ferr, 4016, "qh_detvnorm: points %d %d Voronoi vertex %d dist %2.2g\n",
                             pointid, pointidA, facet->visitid, dist));
        }
      }
    }
  }
  *offsetp= offset;
  if (simplex != points)
    qh_settempfree(qh, &simplex);
  qh_settempfree(qh, &points);
  return normal;
} /* detvnorm */

/*---------------------------------

  qh_detvridge(qh, vertexA )
    determine Voronoi ridge from 'seen' neighbors of vertexA
    include one vertex-at-infinite if an !neighbor->visitid

  returns:
    temporary set of centers (facets, i.e., Voronoi vertices)
    sorted by center id
*/
setT *qh_detvridge(qhT *qh, vertexT *vertex) {
  setT *centers= qh_settemp(qh, qh->TEMPsize);
  setT *tricenters= qh_settemp(qh, qh->TEMPsize);
  facetT *neighbor, **neighborp;
  boolT firstinf= True;

  FOREACHneighbor_(vertex) {
    if (neighbor->seen) {
      if (neighbor->visitid) {
        if (!neighbor->tricoplanar || qh_setunique(qh, &tricenters, neighbor->center))
          qh_setappend(qh, ¢ers, neighbor);
      }else if (firstinf) {
        firstinf= False;
        qh_setappend(qh, ¢ers, neighbor);
      }
    }
  }
  qsort(SETaddr_(centers, facetT), (size_t)qh_setsize(qh, centers),
             sizeof(facetT *), qh_compare_facetvisit);
  qh_settempfree(qh, &tricenters);
  return centers;
} /* detvridge */

/*---------------------------------

  qh_detvridge3(qh, atvertex, vertex )
    determine 3-d Voronoi ridge from 'seen' neighbors of atvertex and vertex
    include one vertex-at-infinite for !neighbor->visitid
    assumes all facet->seen2= True

  returns:
    temporary set of centers (facets, i.e., Voronoi vertices)
    listed in adjacency order (!oriented)
    all facet->seen2= True

  design:
    mark all neighbors of atvertex
    for each adjacent neighbor of both atvertex and vertex
      if neighbor selected
        add neighbor to set of Voronoi vertices
*/
setT *qh_detvridge3(qhT *qh, vertexT *atvertex, vertexT *vertex) {
  setT *centers= qh_settemp(qh, qh->TEMPsize);
  setT *tricenters= qh_settemp(qh, qh->TEMPsize);
  facetT *neighbor, **neighborp, *facet= NULL;
  boolT firstinf= True;

  FOREACHneighbor_(atvertex)
    neighbor->seen2= False;
  FOREACHneighbor_(vertex) {
    if (!neighbor->seen2) {
      facet= neighbor;
      break;
    }
  }
  while (facet) {
    facet->seen2= True;
    if (neighbor->seen) {
      if (facet->visitid) {
        if (!facet->tricoplanar || qh_setunique(qh, &tricenters, facet->center))
          qh_setappend(qh, ¢ers, facet);
      }else if (firstinf) {
        firstinf= False;
        qh_setappend(qh, ¢ers, facet);
      }
    }
    FOREACHneighbor_(facet) {
      if (!neighbor->seen2) {
        if (qh_setin(vertex->neighbors, neighbor))
          break;
        else
          neighbor->seen2= True;
      }
    }
    facet= neighbor;
  }
  if (qh->CHECKfrequently) {
    FOREACHneighbor_(vertex) {
      if (!neighbor->seen2) {
          qh_fprintf(qh, qh->ferr, 6217, "qhull internal error (qh_detvridge3): neighbors of vertex p%d are not connected at facet %d\n",
                 qh_pointid(qh, vertex->point), neighbor->id);
        qh_errexit(qh, qh_ERRqhull, neighbor, NULL);
      }
    }
  }
  FOREACHneighbor_(atvertex)
    neighbor->seen2= True;
  qh_settempfree(qh, &tricenters);
  return centers;
} /* detvridge3 */

/*---------------------------------

  qh_eachvoronoi(qh, fp, printvridge, vertex, visitall, innerouter, inorder )
    if visitall,
      visit all Voronoi ridges for vertex (i.e., an input site)
    else
      visit all unvisited Voronoi ridges for vertex
      all vertex->seen= False if unvisited
    assumes
      all facet->seen= False
      all facet->seen2= True (for qh_detvridge3)
      all facet->visitid == 0 if vertex_at_infinity
                         == index of Voronoi vertex
                         >= qh.num_facets if ignored
    innerouter:
      qh_RIDGEall--  both inner (bounded) and outer(unbounded) ridges
      qh_RIDGEinner- only inner
      qh_RIDGEouter- only outer

    if inorder
      orders vertices for 3-d Voronoi diagrams

  returns:
    number of visited ridges (does not include previously visited ridges)

    if printvridge,
      calls printvridge( fp, vertex, vertexA, centers)
        fp== any pointer (assumes FILE*)
             fp may be NULL for QhullQh::qh_fprintf which calls appendQhullMessage
        vertex,vertexA= pair of input sites that define a Voronoi ridge
        centers= set of facets (i.e., Voronoi vertices)
                 ->visitid == index or 0 if vertex_at_infinity
                 ordered for 3-d Voronoi diagram
  notes:
    uses qh.vertex_visit

  see:
    qh_eachvoronoi_all()

  design:
    mark selected neighbors of atvertex
    for each selected neighbor (either Voronoi vertex or vertex-at-infinity)
      for each unvisited vertex
        if atvertex and vertex share more than d-1 neighbors
          bump totalcount
          if printvridge defined
            build the set of shared neighbors (i.e., Voronoi vertices)
            call printvridge
*/
int qh_eachvoronoi(qhT *qh, FILE *fp, printvridgeT printvridge, vertexT *atvertex, boolT visitall, qh_RIDGE innerouter, boolT inorder) {
  boolT unbounded;
  int count;
  facetT *neighbor, **neighborp, *neighborA, **neighborAp;
  setT *centers;
  setT *tricenters= qh_settemp(qh, qh->TEMPsize);

  vertexT *vertex, **vertexp;
  boolT firstinf;
  unsigned int numfacets= (unsigned int)qh->num_facets;
  int totridges= 0;

  qh->vertex_visit++;
  atvertex->seen= True;
  if (visitall) {
    FORALLvertices
      vertex->seen= False;
  }
  FOREACHneighbor_(atvertex) {
    if (neighbor->visitid < numfacets)
      neighbor->seen= True;
  }
  FOREACHneighbor_(atvertex) {
    if (neighbor->seen) {
      FOREACHvertex_(neighbor->vertices) {
        if (vertex->visitid != qh->vertex_visit && !vertex->seen) {
          vertex->visitid= qh->vertex_visit;
          count= 0;
          firstinf= True;
          qh_settruncate(qh, tricenters, 0);
          FOREACHneighborA_(vertex) {
            if (neighborA->seen) {
              if (neighborA->visitid) {
                if (!neighborA->tricoplanar || qh_setunique(qh, &tricenters, neighborA->center))
                  count++;
              }else if (firstinf) {
                count++;
                firstinf= False;
              }
            }
          }
          if (count >= qh->hull_dim - 1) {  /* e.g., 3 for 3-d Voronoi */
            if (firstinf) {
              if (innerouter == qh_RIDGEouter)
                continue;
              unbounded= False;
            }else {
              if (innerouter == qh_RIDGEinner)
                continue;
              unbounded= True;
            }
            totridges++;
            trace4((qh, qh->ferr, 4017, "qh_eachvoronoi: Voronoi ridge of %d vertices between sites %d and %d\n",
                  count, qh_pointid(qh, atvertex->point), qh_pointid(qh, vertex->point)));
            if (printvridge) {
              if (inorder && qh->hull_dim == 3+1) /* 3-d Voronoi diagram */
                centers= qh_detvridge3(qh, atvertex, vertex);
              else
                centers= qh_detvridge(qh, vertex);
              (*printvridge)(qh, fp, atvertex, vertex, centers, unbounded);
              qh_settempfree(qh, ¢ers);
            }
          }
        }
      }
    }
  }
  FOREACHneighbor_(atvertex)
    neighbor->seen= False;
  qh_settempfree(qh, &tricenters);
  return totridges;
} /* eachvoronoi */


/*---------------------------------

  qh_eachvoronoi_all(qh, fp, printvridge, isUpper, innerouter, inorder )
    visit all Voronoi ridges

    innerouter:
      see qh_eachvoronoi()

    if inorder
      orders vertices for 3-d Voronoi diagrams

  returns
    total number of ridges

    if isUpper == facet->upperdelaunay  (i.e., a Vornoi vertex)
      facet->visitid= Voronoi vertex index(same as 'o' format)
    else
      facet->visitid= 0

    if printvridge,
      calls printvridge( fp, vertex, vertexA, centers)
      [see qh_eachvoronoi]

  notes:
    Not used for qhull.exe
    same effect as qh_printvdiagram but ridges not sorted by point id
*/
int qh_eachvoronoi_all(qhT *qh, FILE *fp, printvridgeT printvridge, boolT isUpper, qh_RIDGE innerouter, boolT inorder) {
  facetT *facet;
  vertexT *vertex;
  int numcenters= 1;  /* vertex 0 is vertex-at-infinity */
  int totridges= 0;

  qh_clearcenters(qh, qh_ASvoronoi);
  qh_vertexneighbors(qh);
  maximize_(qh->visit_id, (unsigned int)qh->num_facets);
  FORALLfacets {
    facet->visitid= 0;
    facet->seen= False;
    facet->seen2= True;
  }
  FORALLfacets {
    if (facet->upperdelaunay == isUpper)
      facet->visitid= (unsigned int)(numcenters++);
  }
  FORALLvertices
    vertex->seen= False;
  FORALLvertices {
    if (qh->GOODvertex > 0 && qh_pointid(qh, vertex->point)+1 != qh->GOODvertex)
      continue;
    totridges += qh_eachvoronoi(qh, fp, printvridge, vertex,
                   !qh_ALL, innerouter, inorder);
  }
  return totridges;
} /* eachvoronoi_all */

/*---------------------------------

  qh_facet2point(qh, facet, point0, point1, mindist )
    return two projected temporary vertices for a 2-d facet
    may be non-simplicial

  returns:
    point0 and point1 oriented and projected to the facet
    returns mindist (maximum distance below plane)
*/
void qh_facet2point(qhT *qh, facetT *facet, pointT **point0, pointT **point1, realT *mindist) {
  vertexT *vertex0, *vertex1;
  realT dist;

  if (facet->toporient ^ qh_ORIENTclock) {
    vertex0= SETfirstt_(facet->vertices, vertexT);
    vertex1= SETsecondt_(facet->vertices, vertexT);
  }else {
    vertex1= SETfirstt_(facet->vertices, vertexT);
    vertex0= SETsecondt_(facet->vertices, vertexT);
  }
  zadd_(Zdistio, 2);
  qh_distplane(qh, vertex0->point, facet, &dist);
  *mindist= dist;
  *point0= qh_projectpoint(qh, vertex0->point, facet, dist);
  qh_distplane(qh, vertex1->point, facet, &dist);
  minimize_(*mindist, dist);
  *point1= qh_projectpoint(qh, vertex1->point, facet, dist);
} /* facet2point */


/*---------------------------------

  qh_facetvertices(qh, facetlist, facets, allfacets )
    returns temporary set of vertices in a set and/or list of facets
    if allfacets, ignores qh_skipfacet()

  returns:
    vertices with qh.vertex_visit

  notes:
    optimized for allfacets of facet_list

  design:
    if allfacets of facet_list
      create vertex set from vertex_list
    else
      for each selected facet in facets or facetlist
        append unvisited vertices to vertex set
*/
setT *qh_facetvertices(qhT *qh, facetT *facetlist, setT *facets, boolT allfacets) {
  setT *vertices;
  facetT *facet, **facetp;
  vertexT *vertex, **vertexp;

  qh->vertex_visit++;
  if (facetlist == qh->facet_list && allfacets && !facets) {
    vertices= qh_settemp(qh, qh->num_vertices);
    FORALLvertices {
      vertex->visitid= qh->vertex_visit;
      qh_setappend(qh, &vertices, vertex);
    }
  }else {
    vertices= qh_settemp(qh, qh->TEMPsize);
    FORALLfacet_(facetlist) {
      if (!allfacets && qh_skipfacet(qh, facet))
        continue;
      FOREACHvertex_(facet->vertices) {
        if (vertex->visitid != qh->vertex_visit) {
          vertex->visitid= qh->vertex_visit;
          qh_setappend(qh, &vertices, vertex);
        }
      }
    }
  }
  FOREACHfacet_(facets) {
    if (!allfacets && qh_skipfacet(qh, facet))
      continue;
    FOREACHvertex_(facet->vertices) {
      if (vertex->visitid != qh->vertex_visit) {
        vertex->visitid= qh->vertex_visit;
        qh_setappend(qh, &vertices, vertex);
      }
    }
  }
  return vertices;
} /* facetvertices */

/*---------------------------------

  qh_geomplanes(qh, facet, outerplane, innerplane )
    return outer and inner planes for Geomview
    qh.PRINTradius is size of vertices and points (includes qh.JOGGLEmax)

  notes:
    assume precise calculations in io_r.c with roundoff covered by qh_GEOMepsilon
*/
void qh_geomplanes(qhT *qh, facetT *facet, realT *outerplane, realT *innerplane) {
  realT radius;

  if (qh->MERGING || qh->JOGGLEmax < REALmax/2) {
    qh_outerinner(qh, facet, outerplane, innerplane);
    radius= qh->PRINTradius;
    if (qh->JOGGLEmax < REALmax/2)
      radius -= qh->JOGGLEmax * sqrt((realT)qh->hull_dim);  /* already accounted for in qh_outerinner() */
    *outerplane += radius;
    *innerplane -= radius;
    if (qh->PRINTcoplanar || qh->PRINTspheres) {
      *outerplane += qh->MAXabs_coord * qh_GEOMepsilon;
      *innerplane -= qh->MAXabs_coord * qh_GEOMepsilon;
    }
  }else
    *innerplane= *outerplane= 0;
} /* geomplanes */


/*---------------------------------

  qh_markkeep(qh, facetlist )
    restrict good facets for qh.KEEParea, qh.KEEPmerge, and qh.KEEPminArea
    ignores visible facets (!part of convex hull)

  returns:
    may clear facet->good
    recomputes qh.num_good

  notes:
    only called by qh_prepare_output after qh_findgood_all
    does not throw errors except memory/corruption of qset_r.c

  design:
    get set of good facets
    if qh.KEEParea
      sort facets by area
      clear facet->good for all but n largest facets
    if qh.KEEPmerge
      sort facets by merge count
      clear facet->good for all but n most merged facets
    if qh.KEEPminarea
      clear facet->good if area too small
    update qh.num_good
*/
void qh_markkeep(qhT *qh, facetT *facetlist) {
  facetT *facet, **facetp;
  setT *facets= qh_settemp(qh, qh->num_facets);
  int size, count;

  trace2((qh, qh->ferr, 2006, "qh_markkeep: only keep %d largest and/or %d most merged facets and/or min area %.2g\n",
          qh->KEEParea, qh->KEEPmerge, qh->KEEPminArea));
  FORALLfacet_(facetlist) {
    if (!facet->visible && facet->good)
      qh_setappend(qh, &facets, facet);
  }
  size= qh_setsize(qh, facets);
  if (qh->KEEParea) {
    qsort(SETaddr_(facets, facetT), (size_t)size,
             sizeof(facetT *), qh_compare_facetarea);
    if ((count= size - qh->KEEParea) > 0) {
      FOREACHfacet_(facets) {
        facet->good= False;
        if (--count == 0)
          break;
      }
    }
  }
  if (qh->KEEPmerge) {
    qsort(SETaddr_(facets, facetT), (size_t)size,
             sizeof(facetT *), qh_compare_nummerge);
    if ((count= size - qh->KEEPmerge) > 0) {
      FOREACHfacet_(facets) {
        facet->good= False;
        if (--count == 0)
          break;
      }
    }
  }
  if (qh->KEEPminArea < REALmax/2) {
    FOREACHfacet_(facets) {
      if (!facet->isarea || facet->f.area < qh->KEEPminArea)
        facet->good= False;
    }
  }
  qh_settempfree(qh, &facets);
  count= 0;
  FORALLfacet_(facetlist) {
    if (facet->good)
      count++;
  }
  qh->num_good= count;
} /* markkeep */


/*---------------------------------

  qh_markvoronoi(qh, facetlist, facets, printall, isLower, numcenters )
    mark voronoi vertices for printing by site pairs

  returns:
    temporary set of vertices indexed by pointid
    isLower set if printing lower hull (i.e., at least one facet is lower hull)
    numcenters= total number of Voronoi vertices
    bumps qh.printoutnum for vertex-at-infinity
    clears all facet->seen and sets facet->seen2

    if selected
      facet->visitid= Voronoi vertex id
    else if upper hull (or 'Qu' and lower hull)
      facet->visitid= 0
    else
      facet->visitid >= qh->num_facets

  notes:
    ignores qh.ATinfinity, if defined
*/
setT *qh_markvoronoi(qhT *qh, facetT *facetlist, setT *facets, boolT printall, boolT *isLowerp, int *numcentersp) {
  int numcenters=0;
  facetT *facet, **facetp;
  setT *vertices;
  boolT isLower= False;

  qh->printoutnum++;
  qh_clearcenters(qh, qh_ASvoronoi);  /* in case, qh_printvdiagram2 called by user */
  qh_vertexneighbors(qh);
  vertices= qh_pointvertex(qh);
  if (qh->ATinfinity)
    SETelem_(vertices, qh->num_points-1)= NULL;
  qh->visit_id++;
  maximize_(qh->visit_id, (unsigned int)qh->num_facets);
  FORALLfacet_(facetlist) {
    if (printall || !qh_skipfacet(qh, facet)) {
      if (!facet->upperdelaunay) {
        isLower= True;
        break;
      }
    }
  }
  FOREACHfacet_(facets) {
    if (printall || !qh_skipfacet(qh, facet)) {
      if (!facet->upperdelaunay) {
        isLower= True;
        break;
      }
    }
  }
  FORALLfacets {
    if (facet->normal && (facet->upperdelaunay == isLower))
      facet->visitid= 0;  /* facetlist or facets may overwrite */
    else
      facet->visitid= qh->visit_id;
    facet->seen= False;
    facet->seen2= True;
  }
  numcenters++;  /* qh_INFINITE */
  FORALLfacet_(facetlist) {
    if (printall || !qh_skipfacet(qh, facet))
      facet->visitid= (unsigned int)(numcenters++);
  }
  FOREACHfacet_(facets) {
    if (printall || !qh_skipfacet(qh, facet))
      facet->visitid= (unsigned int)(numcenters++);
  }
  *isLowerp= isLower;
  *numcentersp= numcenters;
  trace2((qh, qh->ferr, 2007, "qh_markvoronoi: isLower %d numcenters %d\n", isLower, numcenters));
  return vertices;
} /* markvoronoi */

/*---------------------------------

  qh_order_vertexneighbors(qh, vertex )
    order facet neighbors of vertex by 2-d (orientation), 3-d (adjacency), or n-d (f.visitid,id)

  notes:
    error if qh_vertexneighbors not called beforehand
    only 2-d orients the neighbors
    for 4-d and higher
      set or clear f.visitid for qh_compare_facetvisit
      for example, use qh_markvoronoi (e.g., qh_printvornoi) or qh_countfacets (e.g., qh_printvneighbors)

  design (2-d):
    see qh_printextremes_2d
  design (3-d):
    initialize a new neighbor set with the first facet in vertex->neighbors
    while vertex->neighbors non-empty
      select next neighbor in the previous facet's neighbor set
    set vertex->neighbors to the new neighbor set
  design (n-d):
    qsort by f.visitid, or f.facetid (qh_compare_facetvisit)
    facet_id is negated (sorted before visit_id facets)
*/
void qh_order_vertexneighbors(qhT *qh, vertexT *vertex) {
  setT *newset;
  facetT *facet, *facetA, *facetB, *neighbor, **neighborp;
  vertexT *vertexA;
  int numneighbors;

  trace4((qh, qh->ferr, 4018, "qh_order_vertexneighbors: order facet neighbors of v%d by 2-d (orientation), 3-d (adjacency), or n-d (f.visitid,id)\n", vertex->id));
  if (!qh->VERTEXneighbors) {
    qh_fprintf(qh, qh->ferr, 6428, "qhull internal error (qh_order_vertexneighbors): call qh_vertexneighbors before calling qh_order_vertexneighbors\n");
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  if (qh->hull_dim == 2) {
    facetA= SETfirstt_(vertex->neighbors, facetT);
    if (facetA->toporient ^ qh_ORIENTclock)
      vertexA= SETfirstt_(facetA->vertices, vertexT);
    else
      vertexA= SETsecondt_(facetA->vertices, vertexT);
    if (vertexA!=vertex) {
      facetB= SETsecondt_(vertex->neighbors, facetT);
      SETfirst_(vertex->neighbors)= facetB;
      SETsecond_(vertex->neighbors)= facetA;
    }
  }else if (qh->hull_dim == 3) {
    newset= qh_settemp(qh, qh_setsize(qh, vertex->neighbors));
    facet= (facetT *)qh_setdellast(vertex->neighbors);
    qh_setappend(qh, &newset, facet);
    while (qh_setsize(qh, vertex->neighbors)) {
      FOREACHneighbor_(vertex) {
        if (qh_setin(facet->neighbors, neighbor)) {
          qh_setdel(vertex->neighbors, neighbor);
          qh_setappend(qh, &newset, neighbor);
          facet= neighbor;
          break;
        }
      }
      if (!neighbor) {
        qh_fprintf(qh, qh->ferr, 6066, "qhull internal error (qh_order_vertexneighbors): no neighbor of v%d for f%d\n",
          vertex->id, facet->id);
        qh_errexit(qh, qh_ERRqhull, facet, NULL);
      }
    }
    qh_setfree(qh, &vertex->neighbors);
    qh_settemppop(qh);
    vertex->neighbors= newset;
  }else { /* qh.hull_dim >= 4 */
    numneighbors= qh_setsize(qh, vertex->neighbors);
    qsort(SETaddr_(vertex->neighbors, facetT), (size_t)numneighbors,
        sizeof(facetT *), qh_compare_facetvisit);
  }
} /* order_vertexneighbors */

/*---------------------------------

  qh_prepare_output(qh )
    prepare for qh_produce_output2(qh) according to
      qh.KEEPminArea, KEEParea, KEEPmerge, GOODvertex, GOODthreshold, GOODpoint, ONLYgood, SPLITthresholds
    does not reset facet->good

  notes
    called by qh_produce_output, qh_new_qhull, Qhull.outputQhull
    except for PRINTstatistics, no-op if previously called with same options
*/
void qh_prepare_output(qhT *qh) {
  if (qh->VORONOI) {
    qh_clearcenters(qh, qh_ASvoronoi);  /* must be before qh_triangulate */
    qh_vertexneighbors(qh);
  }
  if (qh->TRIangulate && !qh->hasTriangulation) {
    qh_triangulate(qh);
    if (qh->VERIFYoutput && !qh->CHECKfrequently)
      qh_checkpolygon(qh, qh->facet_list);
  }
  qh_findgood_all(qh, qh->facet_list);
  if (qh->GETarea)
    qh_getarea(qh, qh->facet_list);
  if (qh->KEEParea || qh->KEEPmerge || qh->KEEPminArea < REALmax/2)
    qh_markkeep(qh, qh->facet_list);
  if (qh->PRINTstatistics)
    qh_collectstatistics(qh);
}

/*---------------------------------

  qh_printafacet(qh, fp, format, facet, printall )
    print facet to fp in given output format (see qh.PRINTout)

  returns:
    nop if !printall and qh_skipfacet()
    nop if visible facet and NEWfacets and format != PRINTfacets
    must match qh_countfacets

  notes
    preserves qh.visit_id
    facet->normal may be null if PREmerge/MERGEexact and STOPcone before merge

  see
    qh_printbegin() and qh_printend()

  design:
    test for printing facet
    call appropriate routine for format
    or output results directly
*/
void qh_printafacet(qhT *qh, FILE *fp, qh_PRINT format, facetT *facet, boolT printall) {
  realT color[4], offset, dist, outerplane, innerplane;
  boolT zerodiv;
  coordT *point, *normp, *coordp, **pointp, *feasiblep;
  int k;
  vertexT *vertex, **vertexp;
  facetT *neighbor, **neighborp;

  if (!printall && qh_skipfacet(qh, facet))
    return;
  if (facet->visible && qh->NEWfacets && format != qh_PRINTfacets)
    return;
  qh->printoutnum++;
  switch (format) {
  case qh_PRINTarea:
    if (facet->isarea) {
      qh_fprintf(qh, fp, 9009, qh_REAL_1, facet->f.area);
      qh_fprintf(qh, fp, 9010, "\n");
    }else
      qh_fprintf(qh, fp, 9011, "0\n");
    break;
  case qh_PRINTcoplanars:
    qh_fprintf(qh, fp, 9012, "%d", qh_setsize(qh, facet->coplanarset));
    FOREACHpoint_(facet->coplanarset)
      qh_fprintf(qh, fp, 9013, " %d", qh_pointid(qh, point));
    qh_fprintf(qh, fp, 9014, "\n");
    break;
  case qh_PRINTcentrums:
    qh_printcenter(qh, fp, format, NULL, facet);
    break;
  case qh_PRINTfacets:
    qh_printfacet(qh, fp, facet);
    break;
  case qh_PRINTfacets_xridge:
    qh_printfacetheader(qh, fp, facet);
    break;
  case qh_PRINTgeom:  /* either 2 , 3, or 4-d by qh_printbegin */
    if (!facet->normal)
      break;
    for (k=qh->hull_dim; k--; ) {
      color[k]= (facet->normal[k]+1.0)/2.0;
      maximize_(color[k], -1.0);
      minimize_(color[k], +1.0);
    }
    qh_projectdim3(qh, color, color);
    if (qh->PRINTdim != qh->hull_dim)
      qh_normalize2(qh, color, 3, True, NULL, NULL);
    if (qh->hull_dim <= 2)
      qh_printfacet2geom(qh, fp, facet, color);
    else if (qh->hull_dim == 3) {
      if (facet->simplicial)
        qh_printfacet3geom_simplicial(qh, fp, facet, color);
      else
        qh_printfacet3geom_nonsimplicial(qh, fp, facet, color);
    }else {
      if (facet->simplicial)
        qh_printfacet4geom_simplicial(qh, fp, facet, color);
      else
        qh_printfacet4geom_nonsimplicial(qh, fp, facet, color);
    }
    break;
  case qh_PRINTids:
    qh_fprintf(qh, fp, 9015, "%d\n", facet->id);
    break;
  case qh_PRINTincidences:
  case qh_PRINToff:
  case qh_PRINTtriangles:
    if (qh->hull_dim == 3 && format != qh_PRINTtriangles)
      qh_printfacet3vertex(qh, fp, facet, format);
    else if (facet->simplicial || qh->hull_dim == 2 || format == qh_PRINToff)
      qh_printfacetNvertex_simplicial(qh, fp, facet, format);
    else
      qh_printfacetNvertex_nonsimplicial(qh, fp, facet, qh->printoutvar++, format);
    break;
  case qh_PRINTinner:
    qh_outerinner(qh, facet, NULL, &innerplane);
    offset= facet->offset - innerplane;
    goto LABELprintnorm;
    break; /* prevent warning */
  case qh_PRINTmerges:
    qh_fprintf(qh, fp, 9016, "%d\n", facet->nummerge);
    break;
  case qh_PRINTnormals:
    offset= facet->offset;
    goto LABELprintnorm;
    break; /* prevent warning */
  case qh_PRINTouter:
    qh_outerinner(qh, facet, &outerplane, NULL);
    offset= facet->offset - outerplane;
  LABELprintnorm:
    if (!facet->normal) {
      qh_fprintf(qh, fp, 9017, "no normal for facet f%d\n", facet->id);
      break;
    }
    if (qh->CDDoutput) {
      qh_fprintf(qh, fp, 9018, qh_REAL_1, -offset);
      for (k=0; k < qh->hull_dim; k++)
        qh_fprintf(qh, fp, 9019, qh_REAL_1, -facet->normal[k]);
    }else {
      for (k=0; k < qh->hull_dim; k++)
        qh_fprintf(qh, fp, 9020, qh_REAL_1, facet->normal[k]);
      qh_fprintf(qh, fp, 9021, qh_REAL_1, offset);
    }
    qh_fprintf(qh, fp, 9022, "\n");
    break;
  case qh_PRINTmathematica:  /* either 2 or 3-d by qh_printbegin */
  case qh_PRINTmaple:
    if (qh->hull_dim == 2)
      qh_printfacet2math(qh, fp, facet, format, qh->printoutvar++);
    else
      qh_printfacet3math(qh, fp, facet, format, qh->printoutvar++);
    break;
  case qh_PRINTneighbors:
    qh_fprintf(qh, fp, 9023, "%d", qh_setsize(qh, facet->neighbors));
    FOREACHneighbor_(facet)
      qh_fprintf(qh, fp, 9024, " %d",
               neighbor->visitid ? neighbor->visitid - 1: 0 - neighbor->id);
    qh_fprintf(qh, fp, 9025, "\n");
    break;
  case qh_PRINTpointintersect:
    if (!qh->feasible_point) {
      qh_fprintf(qh, qh->ferr, 6067, "qhull input error (qh_printafacet): option 'Fp' needs qh->feasible_point\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    if (facet->offset > 0)
      goto LABELprintinfinite;
    point= coordp= (coordT *)qh_memalloc(qh, qh->normal_size);
    normp= facet->normal;
    feasiblep= qh->feasible_point;
    if (facet->offset < -qh->MINdenom) {
      for (k=qh->hull_dim; k--; )
        *(coordp++)= (*(normp++) / - facet->offset) + *(feasiblep++);
    }else {
      for (k=qh->hull_dim; k--; ) {
        *(coordp++)= qh_divzero(*(normp++), facet->offset, qh->MINdenom_1,
                                 &zerodiv) + *(feasiblep++);
        if (zerodiv) {
          qh_memfree(qh, point, qh->normal_size);
          goto LABELprintinfinite;
        }
      }
    }
    qh_printpoint(qh, fp, NULL, point);
    qh_memfree(qh, point, qh->normal_size);
    break;
  LABELprintinfinite:
    for (k=qh->hull_dim; k--; )
      qh_fprintf(qh, fp, 9026, qh_REAL_1, qh_INFINITE);
    qh_fprintf(qh, fp, 9027, "\n");
    break;
  case qh_PRINTpointnearest:
    FOREACHpoint_(facet->coplanarset) {
      int id, id2;
      vertex= qh_nearvertex(qh, facet, point, &dist);
      id= qh_pointid(qh, vertex->point);
      id2= qh_pointid(qh, point);
      qh_fprintf(qh, fp, 9028, "%d %d %d " qh_REAL_1 "\n", id, id2, facet->id, dist);
    }
    break;
  case qh_PRINTpoints:  /* VORONOI only by qh_printbegin */
    if (qh->CDDoutput)
      qh_fprintf(qh, fp, 9029, "1 ");
    qh_printcenter(qh, fp, format, NULL, facet);
    break;
  case qh_PRINTvertices:
    qh_fprintf(qh, fp, 9030, "%d", qh_setsize(qh, facet->vertices));
    FOREACHvertex_(facet->vertices)
      qh_fprintf(qh, fp, 9031, " %d", qh_pointid(qh, vertex->point));
    qh_fprintf(qh, fp, 9032, "\n");
    break;
  default:
    break;
  }
} /* printafacet */

/*---------------------------------

  qh_printbegin(qh )
    prints header for all output formats

  returns:
    checks for valid format

  notes:
    uses qh.visit_id for 3/4off
    changes qh.interior_point if printing centrums
    qh_countfacets clears facet->visitid for non-good facets

  see
    qh_printend() and qh_printafacet()

  design:
    count facets and related statistics
    print header for format
*/
void qh_printbegin(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall) {
  int numfacets, numsimplicial, numridges, totneighbors, numcoplanars, numtricoplanars;
  int i, num;
  facetT *facet, **facetp;
  vertexT *vertex, **vertexp;
  setT *vertices;
  pointT *point, **pointp, *pointtemp;

  qh->printoutnum= 0;
  qh_countfacets(qh, facetlist, facets, printall, &numfacets, &numsimplicial,
      &totneighbors, &numridges, &numcoplanars, &numtricoplanars);
  switch (format) {
  case qh_PRINTnone:
    break;
  case qh_PRINTarea:
    qh_fprintf(qh, fp, 9033, "%d\n", numfacets);
    break;
  case qh_PRINTcoplanars:
    qh_fprintf(qh, fp, 9034, "%d\n", numfacets);
    break;
  case qh_PRINTcentrums:
    if (qh->CENTERtype == qh_ASnone)
      qh_clearcenters(qh, qh_AScentrum);
    qh_fprintf(qh, fp, 9035, "%d\n%d\n", qh->hull_dim, numfacets);
    break;
  case qh_PRINTfacets:
  case qh_PRINTfacets_xridge:
    if (facetlist)
      qh_printvertexlist(qh, fp, "Vertices and facets:\n", facetlist, facets, printall);
    break;
  case qh_PRINTgeom:
    if (qh->hull_dim > 4)  /* qh_initqhull_globals also checks */
      goto LABELnoformat;
    if (qh->VORONOI && qh->hull_dim > 3)  /* PRINTdim == DROPdim == hull_dim-1 */
      goto LABELnoformat;
    if (qh->hull_dim == 2 && (qh->PRINTridges || qh->DOintersections))
      qh_fprintf(qh, qh->ferr, 7049, "qhull warning: output for ridges and intersections not implemented in 2-d\n");
    if (qh->hull_dim == 4 && (qh->PRINTinner || qh->PRINTouter ||
                             (qh->PRINTdim == 4 && qh->PRINTcentrums)))
      qh_fprintf(qh, qh->ferr, 7050, "qhull warning: output for outer/inner planes and centrums not implemented in 4-d\n");
    if (qh->PRINTdim == 4 && (qh->PRINTspheres))
      qh_fprintf(qh, qh->ferr, 7051, "qhull warning: output for vertices not implemented in 4-d\n");
    if (qh->PRINTdim == 4 && qh->DOintersections && qh->PRINTnoplanes)
      qh_fprintf(qh, qh->ferr, 7052, "qhull warning: 'Gnh' generates no output in 4-d\n");
    if (qh->PRINTdim == 2) {
      qh_fprintf(qh, fp, 9036, "{appearance {linewidth 3} LIST # %s | %s\n",
              qh->rbox_command, qh->qhull_command);
    }else if (qh->PRINTdim == 3) {
      qh_fprintf(qh, fp, 9037, "{appearance {+edge -evert linewidth 2} LIST # %s | %s\n",
              qh->rbox_command, qh->qhull_command);
    }else if (qh->PRINTdim == 4) {
      qh->visit_id++;
      num= 0;
      FORALLfacet_(facetlist)    /* get number of ridges to be printed */
        qh_printend4geom(qh, NULL, facet, &num, printall);
      FOREACHfacet_(facets)
        qh_printend4geom(qh, NULL, facet, &num, printall);
      qh->ridgeoutnum= num;
      qh->printoutvar= 0;  /* counts number of ridges in output */
      qh_fprintf(qh, fp, 9038, "LIST # %s | %s\n", qh->rbox_command, qh->qhull_command);
    }

    if (qh->PRINTdots) {
      qh->printoutnum++;
      num= qh->num_points + qh_setsize(qh, qh->other_points);
      if (qh->DELAUNAY && qh->ATinfinity)
        num--;
      if (qh->PRINTdim == 4)
        qh_fprintf(qh, fp, 9039, "4VECT %d %d 1\n", num, num);
      else
        qh_fprintf(qh, fp, 9040, "VECT %d %d 1\n", num, num);

      for (i=num; i--; ) {
        if (i % 20 == 0)
          qh_fprintf(qh, fp, 9041, "\n");
        qh_fprintf(qh, fp, 9042, "1 ");
      }
      qh_fprintf(qh, fp, 9043, "# 1 point per line\n1 ");
      for (i=num-1; i--; ) { /* num at least 3 for D2 */
        if (i % 20 == 0)
          qh_fprintf(qh, fp, 9044, "\n");
        qh_fprintf(qh, fp, 9045, "0 ");
      }
      qh_fprintf(qh, fp, 9046, "# 1 color for all\n");
      FORALLpoints {
        if (!qh->DELAUNAY || !qh->ATinfinity || qh_pointid(qh, point) != qh->num_points-1) {
          if (qh->PRINTdim == 4)
            qh_printpoint(qh, fp, NULL, point);
            else
              qh_printpoint3(qh, fp, point);
        }
      }
      FOREACHpoint_(qh->other_points) {
        if (qh->PRINTdim == 4)
          qh_printpoint(qh, fp, NULL, point);
        else
          qh_printpoint3(qh, fp, point);
      }
      qh_fprintf(qh, fp, 9047, "0 1 1 1  # color of points\n");
    }

    if (qh->PRINTdim == 4  && !qh->PRINTnoplanes)
      /* 4dview loads up multiple 4OFF objects slowly */
      qh_fprintf(qh, fp, 9048, "4OFF %d %d 1\n", 3*qh->ridgeoutnum, qh->ridgeoutnum);
    qh->PRINTcradius= 2 * qh->DISTround;  /* include test DISTround */
    if (qh->PREmerge) {
      maximize_(qh->PRINTcradius, qh->premerge_centrum + qh->DISTround);
    }else if (qh->POSTmerge)
      maximize_(qh->PRINTcradius, qh->postmerge_centrum + qh->DISTround);
    qh->PRINTradius= qh->PRINTcradius;
    if (qh->PRINTspheres + qh->PRINTcoplanar)
      maximize_(qh->PRINTradius, qh->MAXabs_coord * qh_MINradius);
    if (qh->premerge_cos < REALmax/2) {
      maximize_(qh->PRINTradius, (1- qh->premerge_cos) * qh->MAXabs_coord);
    }else if (!qh->PREmerge && qh->POSTmerge && qh->postmerge_cos < REALmax/2) {
      maximize_(qh->PRINTradius, (1- qh->postmerge_cos) * qh->MAXabs_coord);
    }
    maximize_(qh->PRINTradius, qh->MINvisible);
    if (qh->JOGGLEmax < REALmax/2)
      qh->PRINTradius += qh->JOGGLEmax * sqrt((realT)qh->hull_dim);
    if (qh->PRINTdim != 4 &&
        (qh->PRINTcoplanar || qh->PRINTspheres || qh->PRINTcentrums)) {
      vertices= qh_facetvertices(qh, facetlist, facets, printall);
      if (qh->PRINTspheres && qh->PRINTdim <= 3)
        qh_printspheres(qh, fp, vertices, qh->PRINTradius);
      if (qh->PRINTcoplanar || qh->PRINTcentrums) {
        qh->firstcentrum= True;
        if (qh->PRINTcoplanar&& !qh->PRINTspheres) {
          FOREACHvertex_(vertices)
            qh_printpointvect2(qh, fp, vertex->point, NULL, qh->interior_point, qh->PRINTradius);
        }
        FORALLfacet_(facetlist) {
          if (!printall && qh_skipfacet(qh, facet))
            continue;
          if (!facet->normal)
            continue;
          if (qh->PRINTcentrums && qh->PRINTdim <= 3)
            qh_printcentrum(qh, fp, facet, qh->PRINTcradius);
          if (!qh->PRINTcoplanar)
            continue;
          FOREACHpoint_(facet->coplanarset)
            qh_printpointvect2(qh, fp, point, facet->normal, NULL, qh->PRINTradius);
          FOREACHpoint_(facet->outsideset)
            qh_printpointvect2(qh, fp, point, facet->normal, NULL, qh->PRINTradius);
        }
        FOREACHfacet_(facets) {
          if (!printall && qh_skipfacet(qh, facet))
            continue;
          if (!facet->normal)
            continue;
          if (qh->PRINTcentrums && qh->PRINTdim <= 3)
            qh_printcentrum(qh, fp, facet, qh->PRINTcradius);
          if (!qh->PRINTcoplanar)
            continue;
          FOREACHpoint_(facet->coplanarset)
            qh_printpointvect2(qh, fp, point, facet->normal, NULL, qh->PRINTradius);
          FOREACHpoint_(facet->outsideset)
            qh_printpointvect2(qh, fp, point, facet->normal, NULL, qh->PRINTradius);
        }
      }
      qh_settempfree(qh, &vertices);
    }
    qh->visit_id++; /* for printing hyperplane intersections */
    break;
  case qh_PRINTids:
    qh_fprintf(qh, fp, 9049, "%d\n", numfacets);
    break;
  case qh_PRINTincidences:
    if (qh->VORONOI && qh->PRINTprecision)
      qh_fprintf(qh, qh->ferr, 7053, "qhull warning: input sites of Delaunay regions (option 'i').  Use option 'p' or 'o' for Voronoi centers.  Disable warning with option 'Pp'\n");
    qh->printoutvar= (int)qh->vertex_id;  /* centrum id for 4-d+, non-simplicial facets */
    if (qh->hull_dim <= 3)
      qh_fprintf(qh, fp, 9050, "%d\n", numfacets);
    else
      qh_fprintf(qh, fp, 9051, "%d\n", numsimplicial+numridges);
    break;
  case qh_PRINTinner:
  case qh_PRINTnormals:
  case qh_PRINTouter:
    if (qh->CDDoutput)
      qh_fprintf(qh, fp, 9052, "%s | %s\nbegin\n    %d %d real\n", qh->rbox_command,
            qh->qhull_command, numfacets, qh->hull_dim+1);
    else
      qh_fprintf(qh, fp, 9053, "%d\n%d\n", qh->hull_dim+1, numfacets);
    break;
  case qh_PRINTmathematica:
  case qh_PRINTmaple:
    if (qh->hull_dim > 3)  /* qh_initbuffers also checks */
      goto LABELnoformat;
    if (qh->VORONOI)
      qh_fprintf(qh, qh->ferr, 7054, "qhull warning: output is the Delaunay triangulation\n");
    if (format == qh_PRINTmaple) {
      if (qh->hull_dim == 2)
        qh_fprintf(qh, fp, 9054, "PLOT(CURVES(\n");
      else
        qh_fprintf(qh, fp, 9055, "PLOT3D(POLYGONS(\n");
    }else
      qh_fprintf(qh, fp, 9056, "{\n");
    qh->printoutvar= 0;   /* counts number of facets for notfirst */
    break;
  case qh_PRINTmerges:
    qh_fprintf(qh, fp, 9057, "%d\n", numfacets);
    break;
  case qh_PRINTpointintersect:
    qh_fprintf(qh, fp, 9058, "%d\n%d\n", qh->hull_dim, numfacets);
    break;
  case qh_PRINTneighbors:
    qh_fprintf(qh, fp, 9059, "%d\n", numfacets);
    break;
  case qh_PRINToff:
  case qh_PRINTtriangles:
    if (qh->VORONOI)
      goto LABELnoformat;
    num= qh->hull_dim;
    if (format == qh_PRINToff || qh->hull_dim == 2)
      qh_fprintf(qh, fp, 9060, "%d\n%d %d %d\n", num,
        qh->num_points+qh_setsize(qh, qh->other_points), numfacets, totneighbors/2);
    else { /* qh_PRINTtriangles */
      qh->printoutvar= qh->num_points+qh_setsize(qh, qh->other_points); /* first centrum */
      if (qh->DELAUNAY)
        num--;  /* drop last dimension */
      qh_fprintf(qh, fp, 9061, "%d\n%d %d %d\n", num, qh->printoutvar
        + numfacets - numsimplicial, numsimplicial + numridges, totneighbors/2);
    }
    FORALLpoints
      qh_printpointid(qh, qh->fout, NULL, num, point, qh_IDunknown);
    FOREACHpoint_(qh->other_points)
      qh_printpointid(qh, qh->fout, NULL, num, point, qh_IDunknown);
    if (format == qh_PRINTtriangles && qh->hull_dim > 2) {
      FORALLfacets {
        if (!facet->simplicial && facet->visitid)
          qh_printcenter(qh, qh->fout, format, NULL, facet);
      }
    }
    break;
  case qh_PRINTpointnearest:
    qh_fprintf(qh, fp, 9062, "%d\n", numcoplanars);
    break;
  case qh_PRINTpoints:
    if (!qh->VORONOI)
      goto LABELnoformat;
    if (qh->CDDoutput)
      qh_fprintf(qh, fp, 9063, "%s | %s\nbegin\n%d %d real\n", qh->rbox_command,
           qh->qhull_command, numfacets, qh->hull_dim);
    else
      qh_fprintf(qh, fp, 9064, "%d\n%d\n", qh->hull_dim-1, numfacets);
    break;
  case qh_PRINTvertices:
    qh_fprintf(qh, fp, 9065, "%d\n", numfacets);
    break;
  case qh_PRINTsummary:
  default:
  LABELnoformat:
    qh_fprintf(qh, qh->ferr, 6068, "qhull internal error (qh_printbegin): can not use this format for dimension %d\n",
         qh->hull_dim);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
} /* printbegin */

/*---------------------------------

  qh_printcenter(qh, fp, string, facet )
    print facet->center as centrum or Voronoi center
    string may be NULL.  Don't include '%' codes.
    nop if qh->CENTERtype neither CENTERvoronoi nor CENTERcentrum
    if upper envelope of Delaunay triangulation and point at-infinity
      prints qh_INFINITE instead;

  notes:
    defines facet->center if needed
    if format=PRINTgeom, adds a 0 if would otherwise be 2-d
    Same as QhullFacet::printCenter
*/
void qh_printcenter(qhT *qh, FILE *fp, qh_PRINT format, const char *string, facetT *facet) {
  int k, num;

  if (qh->CENTERtype != qh_ASvoronoi && qh->CENTERtype != qh_AScentrum)
    return;
  if (string)
    qh_fprintf(qh, fp, 9066, string);
  if (qh->CENTERtype == qh_ASvoronoi) {
    num= qh->hull_dim-1;
    if (!facet->normal || !facet->upperdelaunay || !qh->ATinfinity) {
      if (!facet->center)
        facet->center= qh_facetcenter(qh, facet->vertices);
      for (k=0; k < num; k++)
        qh_fprintf(qh, fp, 9067, qh_REAL_1, facet->center[k]);
    }else {
      for (k=0; k < num; k++)
        qh_fprintf(qh, fp, 9068, qh_REAL_1, qh_INFINITE);
    }
  }else /* qh.CENTERtype == qh_AScentrum */ {
    num= qh->hull_dim;
    if (format == qh_PRINTtriangles && qh->DELAUNAY)
      num--;
    if (!facet->center)
      facet->center= qh_getcentrum(qh, facet);
    for (k=0; k < num; k++)
      qh_fprintf(qh, fp, 9069, qh_REAL_1, facet->center[k]);
  }
  if (format == qh_PRINTgeom && num == 2)
    qh_fprintf(qh, fp, 9070, " 0\n");
  else
    qh_fprintf(qh, fp, 9071, "\n");
} /* printcenter */

/*---------------------------------

  qh_printcentrum(qh, fp, facet, radius )
    print centrum for a facet in OOGL format
    radius defines size of centrum
    2-d or 3-d only

  returns:
    defines facet->center if needed
*/
void qh_printcentrum(qhT *qh, FILE *fp, facetT *facet, realT radius) {
  pointT *centrum, *projpt;
  boolT tempcentrum= False;
  realT xaxis[4], yaxis[4], normal[4], dist;
  realT green[3]={0, 1, 0};
  vertexT *apex;
  int k;

  if (qh->CENTERtype == qh_AScentrum) {
    if (!facet->center)
      facet->center= qh_getcentrum(qh, facet);
    centrum= facet->center;
  }else {
    centrum= qh_getcentrum(qh, facet);
    tempcentrum= True;
  }
  qh_fprintf(qh, fp, 9072, "{appearance {-normal -edge normscale 0} ");
  if (qh->firstcentrum) {
    qh->firstcentrum= False;
    qh_fprintf(qh, fp, 9073, "{INST geom { define centrum CQUAD  # f%d\n\
-0.3 -0.3 0.0001     0 0 1 1\n\
 0.3 -0.3 0.0001     0 0 1 1\n\
 0.3  0.3 0.0001     0 0 1 1\n\
-0.3  0.3 0.0001     0 0 1 1 } transform { \n", facet->id);
  }else
    qh_fprintf(qh, fp, 9074, "{INST geom { : centrum } transform { # f%d\n", facet->id);
  apex= SETfirstt_(facet->vertices, vertexT);
  qh_distplane(qh, apex->point, facet, &dist);
  projpt= qh_projectpoint(qh, apex->point, facet, dist);
  for (k=qh->hull_dim; k--; ) {
    xaxis[k]= projpt[k] - centrum[k];
    normal[k]= facet->normal[k];
  }
  if (qh->hull_dim == 2) {
    xaxis[2]= 0;
    normal[2]= 0;
  }else if (qh->hull_dim == 4) {
    qh_projectdim3(qh, xaxis, xaxis);
    qh_projectdim3(qh, normal, normal);
    qh_normalize2(qh, normal, qh->PRINTdim, True, NULL, NULL);
  }
  qh_crossproduct(3, xaxis, normal, yaxis);
  qh_fprintf(qh, fp, 9075, "%8.4g %8.4g %8.4g 0\n", xaxis[0], xaxis[1], xaxis[2]);
  qh_fprintf(qh, fp, 9076, "%8.4g %8.4g %8.4g 0\n", yaxis[0], yaxis[1], yaxis[2]);
  qh_fprintf(qh, fp, 9077, "%8.4g %8.4g %8.4g 0\n", normal[0], normal[1], normal[2]);
  qh_printpoint3(qh, fp, centrum);
  qh_fprintf(qh, fp, 9078, "1 }}}\n");
  qh_memfree(qh, projpt, qh->normal_size);
  qh_printpointvect(qh, fp, centrum, facet->normal, NULL, radius, green);
  if (tempcentrum)
    qh_memfree(qh, centrum, qh->normal_size);
} /* printcentrum */

/*---------------------------------

  qh_printend(qh, fp, format )
    prints trailer for all output formats

  see:
    qh_printbegin() and qh_printafacet()

*/
void qh_printend(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall) {
  int num;
  facetT *facet, **facetp;

  if (!qh->printoutnum)
    qh_fprintf(qh, qh->ferr, 7055, "qhull warning: no facets printed\n");
  switch (format) {
  case qh_PRINTgeom:
    if (qh->hull_dim == 4 && qh->DROPdim < 0  && !qh->PRINTnoplanes) {
      qh->visit_id++;
      num= 0;
      FORALLfacet_(facetlist)
        qh_printend4geom(qh, fp, facet,&num, printall);
      FOREACHfacet_(facets)
        qh_printend4geom(qh, fp, facet, &num, printall);
      if (num != qh->ridgeoutnum || qh->printoutvar != qh->ridgeoutnum) {
        qh_fprintf(qh, qh->ferr, 6069, "qhull internal error (qh_printend): number of ridges %d != number printed %d and at end %d\n", qh->ridgeoutnum, qh->printoutvar, num);
        qh_errexit(qh, qh_ERRqhull, NULL, NULL);
      }
    }else
      qh_fprintf(qh, fp, 9079, "}\n");
    break;
  case qh_PRINTinner:
  case qh_PRINTnormals:
  case qh_PRINTouter:
    if (qh->CDDoutput)
      qh_fprintf(qh, fp, 9080, "end\n");
    break;
  case qh_PRINTmaple:
    qh_fprintf(qh, fp, 9081, "));\n");
    break;
  case qh_PRINTmathematica:
    qh_fprintf(qh, fp, 9082, "}\n");
    break;
  case qh_PRINTpoints:
    if (qh->CDDoutput)
      qh_fprintf(qh, fp, 9083, "end\n");
    break;
  default:
    break;
  }
} /* printend */

/*---------------------------------

  qh_printend4geom(qh, fp, facet, numridges, printall )
    helper function for qh_printbegin/printend

  returns:
    number of printed ridges

  notes:
    just counts printed ridges if fp=NULL
    uses facet->visitid
    must agree with qh_printfacet4geom...

  design:
    computes color for facet from its normal
    prints each ridge of facet
*/
void qh_printend4geom(qhT *qh, FILE *fp, facetT *facet, int *nump, boolT printall) {
  realT color[3];
  int i, num= *nump;
  facetT *neighbor, **neighborp;
  ridgeT *ridge, **ridgep;

  if (!printall && qh_skipfacet(qh, facet))
    return;
  if (qh->PRINTnoplanes || (facet->visible && qh->NEWfacets))
    return;
  if (!facet->normal)
    return;
  if (fp) {
    for (i=0; i < 3; i++) {
      color[i]= (facet->normal[i]+1.0)/2.0;
      maximize_(color[i], -1.0);
      minimize_(color[i], +1.0);
    }
  }
  facet->visitid= qh->visit_id;
  if (facet->simplicial) {
    FOREACHneighbor_(facet) {
      if (neighbor->visitid != qh->visit_id) {
        if (fp)
          qh_fprintf(qh, fp, 9084, "3 %d %d %d %8.4g %8.4g %8.4g 1 # f%d f%d\n",
                 3*num, 3*num+1, 3*num+2, color[0], color[1], color[2],
                 facet->id, neighbor->id);
        num++;
      }
    }
  }else {
    FOREACHridge_(facet->ridges) {
      neighbor= otherfacet_(ridge, facet);
      if (neighbor->visitid != qh->visit_id) {
        if (fp)
          qh_fprintf(qh, fp, 9085, "3 %d %d %d %8.4g %8.4g %8.4g 1 #r%d f%d f%d\n",
                 3*num, 3*num+1, 3*num+2, color[0], color[1], color[2],
                 ridge->id, facet->id, neighbor->id);
        num++;
      }
    }
  }
  *nump= num;
} /* printend4geom */

/*---------------------------------

  qh_printextremes(qh, fp, facetlist, facets, printall )
    print extreme points for convex hulls or halfspace intersections

  notes:
    #points, followed by ids, one per line

    sorted by id
    same order as qh_printpoints_out if no coplanar/interior points
*/
void qh_printextremes(qhT *qh, FILE *fp, facetT *facetlist, setT *facets, boolT printall) {
  setT *vertices, *points;
  pointT *point;
  vertexT *vertex, **vertexp;
  int id;
  int numpoints=0, point_i, point_n;
  int allpoints= qh->num_points + qh_setsize(qh, qh->other_points);

  points= qh_settemp(qh, allpoints);
  qh_setzero(qh, points, 0, allpoints);
  vertices= qh_facetvertices(qh, facetlist, facets, printall);
  FOREACHvertex_(vertices) {
    id= qh_pointid(qh, vertex->point);
    if (id >= 0) {
      SETelem_(points, id)= vertex->point;
      numpoints++;
    }
  }
  qh_settempfree(qh, &vertices);
  qh_fprintf(qh, fp, 9086, "%d\n", numpoints);
  FOREACHpoint_i_(qh, points) {
    if (point)
      qh_fprintf(qh, fp, 9087, "%d\n", point_i);
  }
  qh_settempfree(qh, &points);
} /* printextremes */

/*---------------------------------

  qh_printextremes_2d(qh, fp, facetlist, facets, printall )
    prints point ids for facets in qh_ORIENTclock order

  notes:
    #points, followed by ids, one per line
    if facetlist/facets are disjoint than the output includes skips
    errors if facets form a loop
    does not print coplanar points
*/
void qh_printextremes_2d(qhT *qh, FILE *fp, facetT *facetlist, setT *facets, boolT printall) {
  int numfacets, numridges, totneighbors, numcoplanars, numsimplicial, numtricoplanars;
  setT *vertices;
  facetT *facet, *startfacet, *nextfacet;
  vertexT *vertexA, *vertexB;

  qh_countfacets(qh, facetlist, facets, printall, &numfacets, &numsimplicial,
      &totneighbors, &numridges, &numcoplanars, &numtricoplanars); /* marks qh->visit_id */
  vertices= qh_facetvertices(qh, facetlist, facets, printall);
  qh_fprintf(qh, fp, 9088, "%d\n", qh_setsize(qh, vertices));
  qh_settempfree(qh, &vertices);
  if (!numfacets)
    return;
  facet= startfacet= facetlist ? facetlist : SETfirstt_(facets, facetT);
  qh->vertex_visit++;
  qh->visit_id++;
  do {
    if (facet->toporient ^ qh_ORIENTclock) {
      vertexA= SETfirstt_(facet->vertices, vertexT);
      vertexB= SETsecondt_(facet->vertices, vertexT);
      nextfacet= SETfirstt_(facet->neighbors, facetT);
    }else {
      vertexA= SETsecondt_(facet->vertices, vertexT);
      vertexB= SETfirstt_(facet->vertices, vertexT);
      nextfacet= SETsecondt_(facet->neighbors, facetT);
    }
    if (facet->visitid == qh->visit_id) {
      qh_fprintf(qh, qh->ferr, 6218, "qhull internal error (qh_printextremes_2d): loop in facet list.  facet %d nextfacet %d\n",
                 facet->id, nextfacet->id);
      qh_errexit2(qh, qh_ERRqhull, facet, nextfacet);
    }
    if (facet->visitid) {
      if (vertexA->visitid != qh->vertex_visit) {
        vertexA->visitid= qh->vertex_visit;
        qh_fprintf(qh, fp, 9089, "%d\n", qh_pointid(qh, vertexA->point));
      }
      if (vertexB->visitid != qh->vertex_visit) {
        vertexB->visitid= qh->vertex_visit;
        qh_fprintf(qh, fp, 9090, "%d\n", qh_pointid(qh, vertexB->point));
      }
    }
    facet->visitid= qh->visit_id;
    facet= nextfacet;
  }while (facet && facet != startfacet);
} /* printextremes_2d */

/*---------------------------------

  qh_printextremes_d(qh, fp, facetlist, facets, printall )
    print extreme points of input sites for Delaunay triangulations

  notes:
    #points, followed by ids, one per line

    unordered
*/
void qh_printextremes_d(qhT *qh, FILE *fp, facetT *facetlist, setT *facets, boolT printall) {
  setT *vertices;
  vertexT *vertex, **vertexp;
  boolT upperseen, lowerseen;
  facetT *neighbor, **neighborp;
  int numpoints=0;

  vertices= qh_facetvertices(qh, facetlist, facets, printall);
  qh_vertexneighbors(qh);
  FOREACHvertex_(vertices) {
    upperseen= lowerseen= False;
    FOREACHneighbor_(vertex) {
      if (neighbor->upperdelaunay)
        upperseen= True;
      else
        lowerseen= True;
    }
    if (upperseen && lowerseen) {
      vertex->seen= True;
      numpoints++;
    }else
      vertex->seen= False;
  }
  qh_fprintf(qh, fp, 9091, "%d\n", numpoints);
  FOREACHvertex_(vertices) {
    if (vertex->seen)
      qh_fprintf(qh, fp, 9092, "%d\n", qh_pointid(qh, vertex->point));
  }
  qh_settempfree(qh, &vertices);
} /* printextremes_d */

/*---------------------------------

  qh_printfacet(qh, fp, facet )
    prints all fields of a facet to fp

  notes:
    ridges printed in neighbor order
*/
void qh_printfacet(qhT *qh, FILE *fp, facetT *facet) {

  qh_printfacetheader(qh, fp, facet);
  if (facet->ridges)
    qh_printfacetridges(qh, fp, facet);
} /* printfacet */


/*---------------------------------

  qh_printfacet2geom(qh, fp, facet, color )
    print facet as part of a 2-d VECT for Geomview

    notes:
      assume precise calculations in io_r.c with roundoff covered by qh_GEOMepsilon
      mindist is calculated within io_r.c.  maxoutside is calculated elsewhere
      so a DISTround error may have occurred.
*/
void qh_printfacet2geom(qhT *qh, FILE *fp, facetT *facet, realT color[3]) {
  pointT *point0, *point1;
  realT mindist, innerplane, outerplane;
  int k;

  qh_facet2point(qh, facet, &point0, &point1, &mindist);
  qh_geomplanes(qh, facet, &outerplane, &innerplane);
  if (qh->PRINTouter || (!qh->PRINTnoplanes && !qh->PRINTinner))
    qh_printfacet2geom_points(qh, fp, point0, point1, facet, outerplane, color);
  if (qh->PRINTinner || (!qh->PRINTnoplanes && !qh->PRINTouter &&
                outerplane - innerplane > 2 * qh->MAXabs_coord * qh_GEOMepsilon)) {
    for (k=3; k--; )
      color[k]= 1.0 - color[k];
    qh_printfacet2geom_points(qh, fp, point0, point1, facet, innerplane, color);
  }
  qh_memfree(qh, point1, qh->normal_size);
  qh_memfree(qh, point0, qh->normal_size);
} /* printfacet2geom */

/*---------------------------------

  qh_printfacet2geom_points(qh, fp, point1, point2, facet, offset, color )
    prints a 2-d facet as a VECT with 2 points at some offset.
    The points are on the facet's plane.
*/
void qh_printfacet2geom_points(qhT *qh, FILE *fp, pointT *point1, pointT *point2,
                               facetT *facet, realT offset, realT color[3]) {
  pointT *p1= point1, *p2= point2;

  qh_fprintf(qh, fp, 9093, "VECT 1 2 1 2 1 # f%d\n", facet->id);
  if (offset != 0.0) {
    p1= qh_projectpoint(qh, p1, facet, -offset);
    p2= qh_projectpoint(qh, p2, facet, -offset);
  }
  qh_fprintf(qh, fp, 9094, "%8.4g %8.4g %8.4g\n%8.4g %8.4g %8.4g\n",
           p1[0], p1[1], 0.0, p2[0], p2[1], 0.0);
  if (offset != 0.0) {
    qh_memfree(qh, p1, qh->normal_size);
    qh_memfree(qh, p2, qh->normal_size);
  }
  qh_fprintf(qh, fp, 9095, "%8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]);
} /* printfacet2geom_points */


/*---------------------------------

  qh_printfacet2math(qh, fp, facet, format, notfirst )
    print 2-d Maple or Mathematica output for a facet
    may be non-simplicial

  notes:
    use %16.8f since Mathematica 2.2 does not handle exponential format
    see qh_printfacet3math
*/
void qh_printfacet2math(qhT *qh, FILE *fp, facetT *facet, qh_PRINT format, int notfirst) {
  pointT *point0, *point1;
  realT mindist;
  const char *pointfmt;

  qh_facet2point(qh, facet, &point0, &point1, &mindist);
  if (notfirst)
    qh_fprintf(qh, fp, 9096, ",");
  if (format == qh_PRINTmaple)
    pointfmt= "[[%16.8f, %16.8f], [%16.8f, %16.8f]]\n";
  else
    pointfmt= "Line[{{%16.8f, %16.8f}, {%16.8f, %16.8f}}]\n";
  qh_fprintf(qh, fp, 9097, pointfmt, point0[0], point0[1], point1[0], point1[1]);
  qh_memfree(qh, point1, qh->normal_size);
  qh_memfree(qh, point0, qh->normal_size);
} /* printfacet2math */


/*---------------------------------

  qh_printfacet3geom_nonsimplicial(qh, fp, facet, color )
    print Geomview OFF for a 3-d nonsimplicial facet.
    if DOintersections, prints ridges to unvisited neighbors(qh->visit_id)

  notes
    uses facet->visitid for intersections and ridges
*/
void qh_printfacet3geom_nonsimplicial(qhT *qh, FILE *fp, facetT *facet, realT color[3]) {
  ridgeT *ridge, **ridgep;
  setT *projectedpoints, *vertices;
  vertexT *vertex, **vertexp, *vertexA, *vertexB;
  pointT *projpt, *point, **pointp;
  facetT *neighbor;
  realT dist, outerplane, innerplane;
  int cntvertices, k;
  realT black[3]={0, 0, 0}, green[3]={0, 1, 0};

  qh_geomplanes(qh, facet, &outerplane, &innerplane);
  vertices= qh_facet3vertex(qh, facet); /* oriented */
  cntvertices= qh_setsize(qh, vertices);
  projectedpoints= qh_settemp(qh, cntvertices);
  FOREACHvertex_(vertices) {
    zinc_(Zdistio);
    qh_distplane(qh, vertex->point, facet, &dist);
    projpt= qh_projectpoint(qh, vertex->point, facet, dist);
    qh_setappend(qh, &projectedpoints, projpt);
  }
  if (qh->PRINTouter || (!qh->PRINTnoplanes && !qh->PRINTinner))
    qh_printfacet3geom_points(qh, fp, projectedpoints, facet, outerplane, color);
  if (qh->PRINTinner || (!qh->PRINTnoplanes && !qh->PRINTouter &&
                outerplane - innerplane > 2 * qh->MAXabs_coord * qh_GEOMepsilon)) {
    for (k=3; k--; )
      color[k]= 1.0 - color[k];
    qh_printfacet3geom_points(qh, fp, projectedpoints, facet, innerplane, color);
  }
  FOREACHpoint_(projectedpoints)
    qh_memfree(qh, point, qh->normal_size);
  qh_settempfree(qh, &projectedpoints);
  qh_settempfree(qh, &vertices);
  if ((qh->DOintersections || qh->PRINTridges)
  && (!facet->visible || !qh->NEWfacets)) {
    facet->visitid= qh->visit_id;
    FOREACHridge_(facet->ridges) {
      neighbor= otherfacet_(ridge, facet);
      if (neighbor->visitid != qh->visit_id) {
        if (qh->DOintersections)
          qh_printhyperplaneintersection(qh, fp, facet, neighbor, ridge->vertices, black);
        if (qh->PRINTridges) {
          vertexA= SETfirstt_(ridge->vertices, vertexT);
          vertexB= SETsecondt_(ridge->vertices, vertexT);
          qh_printline3geom(qh, fp, vertexA->point, vertexB->point, green);
        }
      }
    }
  }
} /* printfacet3geom_nonsimplicial */

/*---------------------------------

  qh_printfacet3geom_points(qh, fp, points, facet, offset )
    prints a 3-d facet as OFF Geomview object.
    offset is relative to the facet's hyperplane
    Facet is determined as a list of points
*/
void qh_printfacet3geom_points(qhT *qh, FILE *fp, setT *points, facetT *facet, realT offset, realT color[3]) {
  int k, n= qh_setsize(qh, points), i;
  pointT *point, **pointp;
  setT *printpoints;

  qh_fprintf(qh, fp, 9098, "{ OFF %d 1 1 # f%d\n", n, facet->id);
  if (offset != 0.0) {
    printpoints= qh_settemp(qh, n);
    FOREACHpoint_(points)
      qh_setappend(qh, &printpoints, qh_projectpoint(qh, point, facet, -offset));
  }else
    printpoints= points;
  FOREACHpoint_(printpoints) {
    for (k=0; k < qh->hull_dim; k++) {
      if (k == qh->DROPdim)
        qh_fprintf(qh, fp, 9099, "0 ");
      else
        qh_fprintf(qh, fp, 9100, "%8.4g ", point[k]);
    }
    if (printpoints != points)
      qh_memfree(qh, point, qh->normal_size);
    qh_fprintf(qh, fp, 9101, "\n");
  }
  if (printpoints != points)
    qh_settempfree(qh, &printpoints);
  qh_fprintf(qh, fp, 9102, "%d ", n);
  for (i=0; i < n; i++)
    qh_fprintf(qh, fp, 9103, "%d ", i);
  qh_fprintf(qh, fp, 9104, "%8.4g %8.4g %8.4g 1.0 }\n", color[0], color[1], color[2]);
} /* printfacet3geom_points */


/*---------------------------------

  qh_printfacet3geom_simplicial(qh )
    print Geomview OFF for a 3-d simplicial facet.

  notes:
    may flip color
    uses facet->visitid for intersections and ridges

    assume precise calculations in io_r.c with roundoff covered by qh_GEOMepsilon
    innerplane may be off by qh->DISTround.  Maxoutside is calculated elsewhere
    so a DISTround error may have occurred.
*/
void qh_printfacet3geom_simplicial(qhT *qh, FILE *fp, facetT *facet, realT color[3]) {
  setT *points, *vertices;
  vertexT *vertex, **vertexp, *vertexA, *vertexB;
  facetT *neighbor, **neighborp;
  realT outerplane, innerplane;
  realT black[3]={0, 0, 0}, green[3]={0, 1, 0};
  int k;

  qh_geomplanes(qh, facet, &outerplane, &innerplane);
  vertices= qh_facet3vertex(qh, facet);
  points= qh_settemp(qh, qh->TEMPsize);
  FOREACHvertex_(vertices)
    qh_setappend(qh, &points, vertex->point);
  if (qh->PRINTouter || (!qh->PRINTnoplanes && !qh->PRINTinner))
    qh_printfacet3geom_points(qh, fp, points, facet, outerplane, color);
  if (qh->PRINTinner || (!qh->PRINTnoplanes && !qh->PRINTouter &&
              outerplane - innerplane > 2 * qh->MAXabs_coord * qh_GEOMepsilon)) {
    for (k=3; k--; )
      color[k]= 1.0 - color[k];
    qh_printfacet3geom_points(qh, fp, points, facet, innerplane, color);
  }
  qh_settempfree(qh, &points);
  qh_settempfree(qh, &vertices);
  if ((qh->DOintersections || qh->PRINTridges)
  && (!facet->visible || !qh->NEWfacets)) {
    facet->visitid= qh->visit_id;
    FOREACHneighbor_(facet) {
      if (neighbor->visitid != qh->visit_id) {
        vertices= qh_setnew_delnthsorted(qh, facet->vertices, qh->hull_dim,
                          SETindex_(facet->neighbors, neighbor), 0);
        if (qh->DOintersections)
           qh_printhyperplaneintersection(qh, fp, facet, neighbor, vertices, black);
        if (qh->PRINTridges) {
          vertexA= SETfirstt_(vertices, vertexT);
          vertexB= SETsecondt_(vertices, vertexT);
          qh_printline3geom(qh, fp, vertexA->point, vertexB->point, green);
        }
        qh_setfree(qh, &vertices);
      }
    }
  }
} /* printfacet3geom_simplicial */

/*---------------------------------

  qh_printfacet3math(qh, fp, facet, notfirst )
    print 3-d Maple or Mathematica output for a facet

  notes:
    may be non-simplicial
    use %16.8f since Mathematica 2.2 does not handle exponential format
    see qh_printfacet2math
*/
void qh_printfacet3math(qhT *qh, FILE *fp, facetT *facet, qh_PRINT format, int notfirst) {
  vertexT *vertex, **vertexp;
  setT *points, *vertices;
  pointT *point, **pointp;
  boolT firstpoint= True;
  realT dist;
  const char *pointfmt, *endfmt;

  if (notfirst)
    qh_fprintf(qh, fp, 9105, ",\n");
  vertices= qh_facet3vertex(qh, facet);
  points= qh_settemp(qh, qh_setsize(qh, vertices));
  FOREACHvertex_(vertices) {
    zinc_(Zdistio);
    qh_distplane(qh, vertex->point, facet, &dist);
    point= qh_projectpoint(qh, vertex->point, facet, dist);
    qh_setappend(qh, &points, point);
  }
  if (format == qh_PRINTmaple) {
    qh_fprintf(qh, fp, 9106, "[");
    pointfmt= "[%16.8f, %16.8f, %16.8f]";
    endfmt= "]";
  }else {
    qh_fprintf(qh, fp, 9107, "Polygon[{");
    pointfmt= "{%16.8f, %16.8f, %16.8f}";
    endfmt= "}]";
  }
  FOREACHpoint_(points) {
    if (firstpoint)
      firstpoint= False;
    else
      qh_fprintf(qh, fp, 9108, ",\n");
    qh_fprintf(qh, fp, 9109, pointfmt, point[0], point[1], point[2]);
  }
  FOREACHpoint_(points)
    qh_memfree(qh, point, qh->normal_size);
  qh_settempfree(qh, &points);
  qh_settempfree(qh, &vertices);
  qh_fprintf(qh, fp, 9110, "%s", endfmt);
} /* printfacet3math */


/*---------------------------------

  qh_printfacet3vertex(qh, fp, facet, format )
    print vertices in a 3-d facet as point ids

  notes:
    prints number of vertices first if format == qh_PRINToff
    the facet may be non-simplicial
*/
void qh_printfacet3vertex(qhT *qh, FILE *fp, facetT *facet, qh_PRINT format) {
  vertexT *vertex, **vertexp;
  setT *vertices;

  vertices= qh_facet3vertex(qh, facet);
  if (format == qh_PRINToff)
    qh_fprintf(qh, fp, 9111, "%d ", qh_setsize(qh, vertices));
  FOREACHvertex_(vertices)
    qh_fprintf(qh, fp, 9112, "%d ", qh_pointid(qh, vertex->point));
  qh_fprintf(qh, fp, 9113, "\n");
  qh_settempfree(qh, &vertices);
} /* printfacet3vertex */


/*---------------------------------

  qh_printfacet4geom_nonsimplicial(qh )
    print Geomview 4OFF file for a 4d nonsimplicial facet
    prints all ridges to unvisited neighbors (qh.visit_id)
    if qh.DROPdim
      prints in OFF format

  notes:
    must agree with printend4geom()
*/
void qh_printfacet4geom_nonsimplicial(qhT *qh, FILE *fp, facetT *facet, realT color[3]) {
  facetT *neighbor;
  ridgeT *ridge, **ridgep;
  vertexT *vertex, **vertexp;
  pointT *point;
  int k;
  realT dist;

  facet->visitid= qh->visit_id;
  if (qh->PRINTnoplanes || (facet->visible && qh->NEWfacets))
    return;
  FOREACHridge_(facet->ridges) {
    neighbor= otherfacet_(ridge, facet);
    if (neighbor->visitid == qh->visit_id)
      continue;
    if (qh->PRINTtransparent && !neighbor->good)
      continue;
    if (qh->DOintersections)
      qh_printhyperplaneintersection(qh, fp, facet, neighbor, ridge->vertices, color);
    else {
      if (qh->DROPdim >= 0)
        qh_fprintf(qh, fp, 9114, "OFF 3 1 1 # f%d\n", facet->id);
      else {
        qh->printoutvar++;
        qh_fprintf(qh, fp, 9115, "# r%d between f%d f%d\n", ridge->id, facet->id, neighbor->id);
      }
      FOREACHvertex_(ridge->vertices) {
        zinc_(Zdistio);
        qh_distplane(qh, vertex->point,facet, &dist);
        point=qh_projectpoint(qh, vertex->point,facet, dist);
        for (k=0; k < qh->hull_dim; k++) {
          if (k != qh->DROPdim)
            qh_fprintf(qh, fp, 9116, "%8.4g ", point[k]);
        }
        qh_fprintf(qh, fp, 9117, "\n");
        qh_memfree(qh, point, qh->normal_size);
      }
      if (qh->DROPdim >= 0)
        qh_fprintf(qh, fp, 9118, "3 0 1 2 %8.4g %8.4g %8.4g\n", color[0], color[1], color[2]);
    }
  }
} /* printfacet4geom_nonsimplicial */


/*---------------------------------

  qh_printfacet4geom_simplicial(qh, fp, facet, color )
    print Geomview 4OFF file for a 4d simplicial facet
    prints triangles for unvisited neighbors (qh.visit_id)

  notes:
    must agree with printend4geom()
*/
void qh_printfacet4geom_simplicial(qhT *qh, FILE *fp, facetT *facet, realT color[3]) {
  setT *vertices;
  facetT *neighbor, **neighborp;
  vertexT *vertex, **vertexp;
  int k;

  facet->visitid= qh->visit_id;
  if (qh->PRINTnoplanes || (facet->visible && qh->NEWfacets))
    return;
  FOREACHneighbor_(facet) {
    if (neighbor->visitid == qh->visit_id)
      continue;
    if (qh->PRINTtransparent && !neighbor->good)
      continue;
    vertices= qh_setnew_delnthsorted(qh, facet->vertices, qh->hull_dim,
                          SETindex_(facet->neighbors, neighbor), 0);
    if (qh->DOintersections)
      qh_printhyperplaneintersection(qh, fp, facet, neighbor, vertices, color);
    else {
      if (qh->DROPdim >= 0)
        qh_fprintf(qh, fp, 9119, "OFF 3 1 1 # ridge between f%d f%d\n",
                facet->id, neighbor->id);
      else {
        qh->printoutvar++;
        qh_fprintf(qh, fp, 9120, "# ridge between f%d f%d\n", facet->id, neighbor->id);
      }
      FOREACHvertex_(vertices) {
        for (k=0; k < qh->hull_dim; k++) {
          if (k != qh->DROPdim)
            qh_fprintf(qh, fp, 9121, "%8.4g ", vertex->point[k]);
        }
        qh_fprintf(qh, fp, 9122, "\n");
      }
      if (qh->DROPdim >= 0)
        qh_fprintf(qh, fp, 9123, "3 0 1 2 %8.4g %8.4g %8.4g\n", color[0], color[1], color[2]);
    }
    qh_setfree(qh, &vertices);
  }
} /* printfacet4geom_simplicial */


/*---------------------------------

  qh_printfacetNvertex_nonsimplicial(qh, fp, facet, id, format )
    print vertices for an N-d non-simplicial facet
    triangulates each ridge to the id
*/
void qh_printfacetNvertex_nonsimplicial(qhT *qh, FILE *fp, facetT *facet, int id, qh_PRINT format) {
  vertexT *vertex, **vertexp;
  ridgeT *ridge, **ridgep;

  if (facet->visible && qh->NEWfacets)
    return;
  FOREACHridge_(facet->ridges) {
    if (format == qh_PRINTtriangles)
      qh_fprintf(qh, fp, 9124, "%d ", qh->hull_dim);
    qh_fprintf(qh, fp, 9125, "%d ", id);
    if ((ridge->top == facet) ^ qh_ORIENTclock) {
      FOREACHvertex_(ridge->vertices)
        qh_fprintf(qh, fp, 9126, "%d ", qh_pointid(qh, vertex->point));
    }else {
      FOREACHvertexreverse12_(ridge->vertices)
        qh_fprintf(qh, fp, 9127, "%d ", qh_pointid(qh, vertex->point));
    }
    qh_fprintf(qh, fp, 9128, "\n");
  }
} /* printfacetNvertex_nonsimplicial */


/*---------------------------------

  qh_printfacetNvertex_simplicial(qh, fp, facet, format )
    print vertices for an N-d simplicial facet
    prints vertices for non-simplicial facets
      2-d facets (orientation preserved by qh_mergefacet2d)
      PRINToff ('o') for 4-d and higher
*/
void qh_printfacetNvertex_simplicial(qhT *qh, FILE *fp, facetT *facet, qh_PRINT format) {
  vertexT *vertex, **vertexp;

  if (format == qh_PRINToff || format == qh_PRINTtriangles)
    qh_fprintf(qh, fp, 9129, "%d ", qh_setsize(qh, facet->vertices));
  if ((facet->toporient ^ qh_ORIENTclock)
  || (qh->hull_dim > 2 && !facet->simplicial)) {
    FOREACHvertex_(facet->vertices)
      qh_fprintf(qh, fp, 9130, "%d ", qh_pointid(qh, vertex->point));
  }else {
    FOREACHvertexreverse12_(facet->vertices)
      qh_fprintf(qh, fp, 9131, "%d ", qh_pointid(qh, vertex->point));
  }
  qh_fprintf(qh, fp, 9132, "\n");
} /* printfacetNvertex_simplicial */


/*---------------------------------

  qh_printfacetheader(qh, fp, facet )
    prints header fields of a facet to fp

  notes:
    for 'f' output and debugging
    Same as QhullFacet::printHeader()
*/
void qh_printfacetheader(qhT *qh, FILE *fp, facetT *facet) {
  pointT *point, **pointp, *furthest;
  facetT *neighbor, **neighborp;
  realT dist;

  if (facet == qh_MERGEridge) {
    qh_fprintf(qh, fp, 9133, " MERGEridge\n");
    return;
  }else if (facet == qh_DUPLICATEridge) {
    qh_fprintf(qh, fp, 9134, " DUPLICATEridge\n");
    return;
  }else if (!facet) {
    qh_fprintf(qh, fp, 9135, " NULLfacet\n");
    return;
  }
  qh->old_randomdist= qh->RANDOMdist;
  qh->RANDOMdist= False;
  qh_fprintf(qh, fp, 9136, "- f%d\n", facet->id);
  qh_fprintf(qh, fp, 9137, "    - flags:");
  if (facet->toporient)
    qh_fprintf(qh, fp, 9138, " top");
  else
    qh_fprintf(qh, fp, 9139, " bottom");
  if (facet->simplicial)
    qh_fprintf(qh, fp, 9140, " simplicial");
  if (facet->tricoplanar)
    qh_fprintf(qh, fp, 9141, " tricoplanar");
  if (facet->upperdelaunay)
    qh_fprintf(qh, fp, 9142, " upperDelaunay");
  if (facet->visible)
    qh_fprintf(qh, fp, 9143, " visible");
  if (facet->newfacet)
    qh_fprintf(qh, fp, 9144, " newfacet");
  if (facet->tested)
    qh_fprintf(qh, fp, 9145, " tested");
  if (!facet->good)
    qh_fprintf(qh, fp, 9146, " notG");
  if (facet->seen && qh->IStracing)
    qh_fprintf(qh, fp, 9147, " seen");
  if (facet->seen2 && qh->IStracing)
    qh_fprintf(qh, fp, 9418, " seen2");
  if (facet->isarea)
    qh_fprintf(qh, fp, 9419, " isarea");
  if (facet->coplanarhorizon)
    qh_fprintf(qh, fp, 9148, " coplanarhorizon");
  if (facet->mergehorizon)
    qh_fprintf(qh, fp, 9149, " mergehorizon");
  if (facet->cycledone)
    qh_fprintf(qh, fp, 9420, " cycledone");
  if (facet->keepcentrum)
    qh_fprintf(qh, fp, 9150, " keepcentrum");
  if (facet->dupridge)
    qh_fprintf(qh, fp, 9151, " dupridge");
  if (facet->mergeridge && !facet->mergeridge2)
    qh_fprintf(qh, fp, 9152, " mergeridge1");
  if (facet->mergeridge2)
    qh_fprintf(qh, fp, 9153, " mergeridge2");
  if (facet->newmerge)
    qh_fprintf(qh, fp, 9154, " newmerge");
  if (facet->flipped)
    qh_fprintf(qh, fp, 9155, " flipped");
  if (facet->notfurthest)
    qh_fprintf(qh, fp, 9156, " notfurthest");
  if (facet->degenerate)
    qh_fprintf(qh, fp, 9157, " degenerate");
  if (facet->redundant)
    qh_fprintf(qh, fp, 9158, " redundant");
  qh_fprintf(qh, fp, 9159, "\n");
  if (facet->isarea)
    qh_fprintf(qh, fp, 9160, "    - area: %2.2g\n", facet->f.area);
  else if (qh->NEWfacets && facet->visible && facet->f.replace)
    qh_fprintf(qh, fp, 9161, "    - replacement: f%d\n", facet->f.replace->id);
  else if (facet->newfacet) {
    if (facet->f.samecycle && facet->f.samecycle != facet)
      qh_fprintf(qh, fp, 9162, "    - shares same visible/horizon as f%d\n", facet->f.samecycle->id);
  }else if (facet->tricoplanar /* !isarea */) {
    if (facet->f.triowner)
      qh_fprintf(qh, fp, 9163, "    - owner of normal & centrum is facet f%d\n", facet->f.triowner->id);
  }else if (facet->f.newcycle)
    qh_fprintf(qh, fp, 9164, "    - was horizon to f%d\n", facet->f.newcycle->id);
  if (facet->nummerge == qh_MAXnummerge)
    qh_fprintf(qh, fp, 9427, "    - merges: %dmax\n", qh_MAXnummerge);
  else if (facet->nummerge)
    qh_fprintf(qh, fp, 9165, "    - merges: %d\n", facet->nummerge);
  qh_printpointid(qh, fp, "    - normal: ", qh->hull_dim, facet->normal, qh_IDunknown);
  qh_fprintf(qh, fp, 9166, "    - offset: %10.7g\n", facet->offset);
  if (qh->CENTERtype == qh_ASvoronoi || facet->center)
    qh_printcenter(qh, fp, qh_PRINTfacets, "    - center: ", facet);
#if qh_MAXoutside
  if (facet->maxoutside > qh->DISTround) /* initial value */
    qh_fprintf(qh, fp, 9167, "    - maxoutside: %10.7g\n", facet->maxoutside);
#endif
  if (!SETempty_(facet->outsideset)) {
    furthest= (pointT *)qh_setlast(facet->outsideset);
    if (qh_setsize(qh, facet->outsideset) < 6) {
      qh_fprintf(qh, fp, 9168, "    - outside set(furthest p%d):\n", qh_pointid(qh, furthest));
      FOREACHpoint_(facet->outsideset)
        qh_printpoint(qh, fp, "     ", point);
    }else if (qh_setsize(qh, facet->outsideset) < 21) {
      qh_printpoints(qh, fp, "    - outside set:", facet->outsideset);
    }else {
      qh_fprintf(qh, fp, 9169, "    - outside set:  %d points.", qh_setsize(qh, facet->outsideset));
      qh_printpoint(qh, fp, "  Furthest", furthest);
    }
#if !qh_COMPUTEfurthest
    qh_fprintf(qh, fp, 9170, "    - furthest distance= %2.2g\n", facet->furthestdist);
#endif
  }
  if (!SETempty_(facet->coplanarset)) {
    furthest= (pointT *)qh_setlast(facet->coplanarset);
    if (qh_setsize(qh, facet->coplanarset) < 6) {
      qh_fprintf(qh, fp, 9171, "    - coplanar set(furthest p%d):\n", qh_pointid(qh, furthest));
      FOREACHpoint_(facet->coplanarset)
        qh_printpoint(qh, fp, "     ", point);
    }else if (qh_setsize(qh, facet->coplanarset) < 21) {
      qh_printpoints(qh, fp, "    - coplanar set:", facet->coplanarset);
    }else {
      qh_fprintf(qh, fp, 9172, "    - coplanar set:  %d points.", qh_setsize(qh, facet->coplanarset));
      qh_printpoint(qh, fp, "  Furthest", furthest);
    }
    zinc_(Zdistio);
    qh_distplane(qh, furthest, facet, &dist);
    qh_fprintf(qh, fp, 9173, "      furthest distance= %2.2g\n", dist);
  }
  qh_printvertices(qh, fp, "    - vertices:", facet->vertices);
  qh_fprintf(qh, fp, 9174, "    - neighboring facets:");
  FOREACHneighbor_(facet) {
    if (neighbor == qh_MERGEridge)
      qh_fprintf(qh, fp, 9175, " MERGEridge");
    else if (neighbor == qh_DUPLICATEridge)
      qh_fprintf(qh, fp, 9176, " DUPLICATEridge");
    else
      qh_fprintf(qh, fp, 9177, " f%d", neighbor->id);
  }
  qh_fprintf(qh, fp, 9178, "\n");
  qh->RANDOMdist= qh->old_randomdist;
} /* printfacetheader */


/*---------------------------------

  qh_printfacetridges(qh, fp, facet )
    prints ridges of a facet to fp

  notes:
    ridges printed in neighbor order
    assumes the ridges exist
    for 'f' output
    same as QhullFacet::printRidges
*/
void qh_printfacetridges(qhT *qh, FILE *fp, facetT *facet) {
  facetT *neighbor, **neighborp;
  ridgeT *ridge, **ridgep;
  int numridges= 0;
  int n;

  if (facet->visible && qh->NEWfacets) {
    qh_fprintf(qh, fp, 9179, "    - ridges (tentative ids):");
    FOREACHridge_(facet->ridges)
      qh_fprintf(qh, fp, 9180, " r%d", ridge->id);
    qh_fprintf(qh, fp, 9181, "\n");
  }else {
    qh_fprintf(qh, fp, 9182, "    - ridges:\n");
    FOREACHridge_(facet->ridges)
      ridge->seen= False;
    if (qh->hull_dim == 3) {
      ridge= SETfirstt_(facet->ridges, ridgeT);
      while (ridge && !ridge->seen) {
        ridge->seen= True;
        qh_printridge(qh, fp, ridge);
        numridges++;
        ridge= qh_nextridge3d(ridge, facet, NULL);
        }
    }else {
      FOREACHneighbor_(facet) {
        FOREACHridge_(facet->ridges) {
          if (otherfacet_(ridge, facet) == neighbor && !ridge->seen) {
            ridge->seen= True;
            qh_printridge(qh, fp, ridge);
            numridges++;
          }
        }
      }
    }
    n= qh_setsize(qh, facet->ridges);
    if (n == 1 && facet->newfacet && qh->NEWtentative) {
      qh_fprintf(qh, fp, 9411, "     - horizon ridge to visible facet\n");
    }
    if (numridges != n) {
      qh_fprintf(qh, fp, 9183, "     - all ridges:");
      FOREACHridge_(facet->ridges)
        qh_fprintf(qh, fp, 9184, " r%d", ridge->id);
      qh_fprintf(qh, fp, 9185, "\n");
    }
    /* non-3d ridges w/o non-simplicial neighbors */
    FOREACHridge_(facet->ridges) {
      if (!ridge->seen)
        qh_printridge(qh, fp, ridge);
    }
  }
} /* printfacetridges */

/*---------------------------------

  qh_printfacets(qh, fp, format, facetlist, facets, printall )
    prints facetlist and/or facet set in output format

  notes:
    also used for specialized formats ('FO' and summary)
    turns off 'Rn' option since want actual numbers
*/
void qh_printfacets(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall) {
  int numfacets, numsimplicial, numridges, totneighbors, numcoplanars, numtricoplanars;
  facetT *facet, **facetp;
  setT *vertices;
  coordT *center;
  realT outerplane, innerplane;

  qh->old_randomdist= qh->RANDOMdist;
  qh->RANDOMdist= False;
  if (qh->CDDoutput && (format == qh_PRINTcentrums || format == qh_PRINTpointintersect || format == qh_PRINToff))
    qh_fprintf(qh, qh->ferr, 7056, "qhull warning: CDD format is not available for centrums, halfspace\nintersections, and OFF file format.\n");
  if (format == qh_PRINTnone)
    ; /* print nothing */
  else if (format == qh_PRINTaverage) {
    vertices= qh_facetvertices(qh, facetlist, facets, printall);
    center= qh_getcenter(qh, vertices);
    qh_fprintf(qh, fp, 9186, "%d 1\n", qh->hull_dim);
    qh_printpointid(qh, fp, NULL, qh->hull_dim, center, qh_IDunknown);
    qh_memfree(qh, center, qh->normal_size);
    qh_settempfree(qh, &vertices);
  }else if (format == qh_PRINTextremes) {
    if (qh->DELAUNAY)
      qh_printextremes_d(qh, fp, facetlist, facets, printall);
    else if (qh->hull_dim == 2)
      qh_printextremes_2d(qh, fp, facetlist, facets, printall);
    else
      qh_printextremes(qh, fp, facetlist, facets, printall);
  }else if (format == qh_PRINToptions)
    qh_fprintf(qh, fp, 9187, "Options selected for Qhull %s:\n%s\n", qh_version, qh->qhull_options);
  else if (format == qh_PRINTpoints && !qh->VORONOI)
    qh_printpoints_out(qh, fp, facetlist, facets, printall);
  else if (format == qh_PRINTqhull)
    qh_fprintf(qh, fp, 9188, "%s | %s\n", qh->rbox_command, qh->qhull_command);
  else if (format == qh_PRINTsize) {
    qh_fprintf(qh, fp, 9189, "0\n2 ");
    qh_fprintf(qh, fp, 9190, qh_REAL_1, qh->totarea);
    qh_fprintf(qh, fp, 9191, qh_REAL_1, qh->totvol);
    qh_fprintf(qh, fp, 9192, "\n");
  }else if (format == qh_PRINTsummary) {
    qh_countfacets(qh, facetlist, facets, printall, &numfacets, &numsimplicial,
      &totneighbors, &numridges, &numcoplanars, &numtricoplanars);
    vertices= qh_facetvertices(qh, facetlist, facets, printall);
    qh_fprintf(qh, fp, 9193, "10 %d %d %d %d %d %d %d %d %d %d\n2 ", qh->hull_dim,
                qh->num_points + qh_setsize(qh, qh->other_points),
                qh->num_vertices, qh->num_facets - qh->num_visible,
                qh_setsize(qh, vertices), numfacets, numcoplanars,
                numfacets - numsimplicial, zzval_(Zdelvertextot),
                numtricoplanars);
    qh_settempfree(qh, &vertices);
    qh_outerinner(qh, NULL, &outerplane, &innerplane);
    qh_fprintf(qh, fp, 9194, qh_REAL_2n, outerplane, innerplane);
  }else if (format == qh_PRINTvneighbors)
    qh_printvneighbors(qh, fp, facetlist, facets, printall);
  else if (qh->VORONOI && format == qh_PRINToff)
    qh_printvoronoi(qh, fp, format, facetlist, facets, printall);
  else if (qh->VORONOI && format == qh_PRINTgeom) {
    qh_printbegin(qh, fp, format, facetlist, facets, printall);
    qh_printvoronoi(qh, fp, format, facetlist, facets, printall);
    qh_printend(qh, fp, format, facetlist, facets, printall);
  }else if (qh->VORONOI
  && (format == qh_PRINTvertices || format == qh_PRINTinner || format == qh_PRINTouter))
    qh_printvdiagram(qh, fp, format, facetlist, facets, printall);
  else {
    qh_printbegin(qh, fp, format, facetlist, facets, printall);
    FORALLfacet_(facetlist)
      qh_printafacet(qh, fp, format, facet, printall);
    FOREACHfacet_(facets)
      qh_printafacet(qh, fp, format, facet, printall);
    qh_printend(qh, fp, format, facetlist, facets, printall);
  }
  qh->RANDOMdist= qh->old_randomdist;
} /* printfacets */


/*---------------------------------

  qh_printhyperplaneintersection(qh, fp, facet1, facet2, vertices, color )
    print Geomview OFF or 4OFF for the intersection of two hyperplanes in 3-d or 4-d
*/
void qh_printhyperplaneintersection(qhT *qh, FILE *fp, facetT *facet1, facetT *facet2,
                   setT *vertices, realT color[3]) {
  realT costheta, denominator, dist1, dist2, s, t, mindenom, p[4];
  vertexT *vertex, **vertexp;
  int i, k;
  boolT nearzero1, nearzero2;

  costheta= qh_getangle(qh, facet1->normal, facet2->normal);
  denominator= 1 - costheta * costheta;
  i= qh_setsize(qh, vertices);
  if (qh->hull_dim == 3)
    qh_fprintf(qh, fp, 9195, "VECT 1 %d 1 %d 1 ", i, i);
  else if (qh->hull_dim == 4 && qh->DROPdim >= 0)
    qh_fprintf(qh, fp, 9196, "OFF 3 1 1 ");
  else
    qh->printoutvar++;
  qh_fprintf(qh, fp, 9197, "# intersect f%d f%d\n", facet1->id, facet2->id);
  mindenom= 1 / (10.0 * qh->MAXabs_coord);
  FOREACHvertex_(vertices) {
    zadd_(Zdistio, 2);
    qh_distplane(qh, vertex->point, facet1, &dist1);
    qh_distplane(qh, vertex->point, facet2, &dist2);
    s= qh_divzero(-dist1 + costheta * dist2, denominator,mindenom,&nearzero1);
    t= qh_divzero(-dist2 + costheta * dist1, denominator,mindenom,&nearzero2);
    if (nearzero1 || nearzero2)
      s= t= 0.0;
    for (k=qh->hull_dim; k--; )
      p[k]= vertex->point[k] + facet1->normal[k] * s + facet2->normal[k] * t;
    if (qh->PRINTdim <= 3) {
      qh_projectdim3(qh, p, p);
      qh_fprintf(qh, fp, 9198, "%8.4g %8.4g %8.4g # ", p[0], p[1], p[2]);
    }else
      qh_fprintf(qh, fp, 9199, "%8.4g %8.4g %8.4g %8.4g # ", p[0], p[1], p[2], p[3]);
    if (nearzero1+nearzero2)
      qh_fprintf(qh, fp, 9200, "p%d(coplanar facets)\n", qh_pointid(qh, vertex->point));
    else
      qh_fprintf(qh, fp, 9201, "projected p%d\n", qh_pointid(qh, vertex->point));
  }
  if (qh->hull_dim == 3)
    qh_fprintf(qh, fp, 9202, "%8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]);
  else if (qh->hull_dim == 4 && qh->DROPdim >= 0)
    qh_fprintf(qh, fp, 9203, "3 0 1 2 %8.4g %8.4g %8.4g 1.0\n", color[0], color[1], color[2]);
} /* printhyperplaneintersection */

/*---------------------------------

  qh_printline3geom(qh, fp, pointA, pointB, color )
    prints a line as a VECT
    prints 0's for qh.DROPdim

  notes:
    if pointA == pointB,
      it's a 1 point VECT
*/
void qh_printline3geom(qhT *qh, FILE *fp, pointT *pointA, pointT *pointB, realT color[3]) {
  int k;
  realT pA[4], pB[4];

  qh_projectdim3(qh, pointA, pA);
  qh_projectdim3(qh, pointB, pB);
  if ((fabs(pA[0] - pB[0]) > 1e-3) ||
      (fabs(pA[1] - pB[1]) > 1e-3) ||
      (fabs(pA[2] - pB[2]) > 1e-3)) {
    qh_fprintf(qh, fp, 9204, "VECT 1 2 1 2 1\n");
    for (k=0; k < 3; k++)
       qh_fprintf(qh, fp, 9205, "%8.4g ", pB[k]);
    qh_fprintf(qh, fp, 9206, " # p%d\n", qh_pointid(qh, pointB));
  }else
    qh_fprintf(qh, fp, 9207, "VECT 1 1 1 1 1\n");
  for (k=0; k < 3; k++)
    qh_fprintf(qh, fp, 9208, "%8.4g ", pA[k]);
  qh_fprintf(qh, fp, 9209, " # p%d\n", qh_pointid(qh, pointA));
  qh_fprintf(qh, fp, 9210, "%8.4g %8.4g %8.4g 1\n", color[0], color[1], color[2]);
}

/*---------------------------------

  qh_printneighborhood(qh, fp, format, facetA, facetB, printall )
    print neighborhood of one or two facets

  notes:
    calls qh_findgood_all()
    bumps qh.visit_id
*/
void qh_printneighborhood(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetA, facetT *facetB, boolT printall) {
  facetT *neighbor, **neighborp, *facet;
  setT *facets;

  if (format == qh_PRINTnone)
    return;
  qh_findgood_all(qh, qh->facet_list);
  if (facetA == facetB)
    facetB= NULL;
  facets= qh_settemp(qh, 2*(qh_setsize(qh, facetA->neighbors)+1));
  qh->visit_id++;
  for (facet=facetA; facet; facet= ((facet == facetA) ? facetB : NULL)) {
    if (facet->visitid != qh->visit_id) {
      facet->visitid= qh->visit_id;
      qh_setappend(qh, &facets, facet);
    }
    FOREACHneighbor_(facet) {
      if (neighbor->visitid == qh->visit_id)
        continue;
      neighbor->visitid= qh->visit_id;
      if (printall || !qh_skipfacet(qh, neighbor))
        qh_setappend(qh, &facets, neighbor);
    }
  }
  qh_printfacets(qh, fp, format, NULL, facets, printall);
  qh_settempfree(qh, &facets);
} /* printneighborhood */

/*---------------------------------

  qh_printpoint(qh, fp, string, point )
  qh_printpointid(qh, fp, string, dim, point, id )
    prints the coordinates of a point

  returns:
    if string is defined
      prints 'string p%d'.  Skips p%d if id=qh_IDunknown(-1) or qh_IDnone(-3)

  notes:
    nop if point is NULL
    Same as QhullPoint's printPoint
*/
void qh_printpoint(qhT *qh, FILE *fp, const char *string, pointT *point) {
  int id= qh_pointid(qh, point);

  qh_printpointid(qh, fp, string, qh->hull_dim, point, id);
} /* printpoint */

void qh_printpointid(qhT *qh, FILE *fp, const char *string, int dim, pointT *point, int id) {
  int k;
  realT r; /*bug fix*/

  if (!point)
    return;
  if (string) {
    qh_fprintf(qh, fp, 9211, "%s", string);
    if (id != qh_IDunknown && id != qh_IDnone)
      qh_fprintf(qh, fp, 9212, " p%d: ", id);
  }
  for (k=dim; k--; ) {
    r= *point++;
    if (string)
      qh_fprintf(qh, fp, 9213, " %8.4g", r);
    else
      qh_fprintf(qh, fp, 9214, qh_REAL_1, r);
  }
  qh_fprintf(qh, fp, 9215, "\n");
} /* printpointid */

/*---------------------------------

  qh_printpoint3(qh, fp, point )
    prints 2-d, 3-d, or 4-d point as Geomview 3-d coordinates
*/
void qh_printpoint3(qhT *qh, FILE *fp, pointT *point) {
  int k;
  realT p[4];

  qh_projectdim3(qh, point, p);
  for (k=0; k < 3; k++)
    qh_fprintf(qh, fp, 9216, "%8.4g ", p[k]);
  qh_fprintf(qh, fp, 9217, " # p%d\n", qh_pointid(qh, point));
} /* printpoint3 */

/*----------------------------------------
-printpoints- print pointids for a set of points starting at index
   see geom_r.c
*/

/*---------------------------------

  qh_printpoints_out(qh, fp, facetlist, facets, printall )
    prints vertices, coplanar/inside points, for facets by their point coordinates
    allows qh.CDDoutput

  notes:
    same format as qhull input
    if no coplanar/interior points,
      same order as qh_printextremes
*/
void qh_printpoints_out(qhT *qh, FILE *fp, facetT *facetlist, setT *facets, boolT printall) {
  int allpoints= qh->num_points + qh_setsize(qh, qh->other_points);
  int numpoints=0, point_i, point_n;
  setT *vertices, *points;
  facetT *facet, **facetp;
  pointT *point, **pointp;
  vertexT *vertex, **vertexp;
  int id;

  points= qh_settemp(qh, allpoints);
  qh_setzero(qh, points, 0, allpoints);
  vertices= qh_facetvertices(qh, facetlist, facets, printall);
  FOREACHvertex_(vertices) {
    id= qh_pointid(qh, vertex->point);
    if (id >= 0)
      SETelem_(points, id)= vertex->point;
  }
  if (qh->KEEPinside || qh->KEEPcoplanar || qh->KEEPnearinside) {
    FORALLfacet_(facetlist) {
      if (!printall && qh_skipfacet(qh, facet))
        continue;
      FOREACHpoint_(facet->coplanarset) {
        id= qh_pointid(qh, point);
        if (id >= 0)
          SETelem_(points, id)= point;
      }
    }
    FOREACHfacet_(facets) {
      if (!printall && qh_skipfacet(qh, facet))
        continue;
      FOREACHpoint_(facet->coplanarset) {
        id= qh_pointid(qh, point);
        if (id >= 0)
          SETelem_(points, id)= point;
      }
    }
  }
  qh_settempfree(qh, &vertices);
  FOREACHpoint_i_(qh, points) {
    if (point)
      numpoints++;
  }
  if (qh->CDDoutput)
    qh_fprintf(qh, fp, 9218, "%s | %s\nbegin\n%d %d real\n", qh->rbox_command,
             qh->qhull_command, numpoints, qh->hull_dim + 1);
  else
    qh_fprintf(qh, fp, 9219, "%d\n%d\n", qh->hull_dim, numpoints);
  FOREACHpoint_i_(qh, points) {
    if (point) {
      if (qh->CDDoutput)
        qh_fprintf(qh, fp, 9220, "1 ");
      qh_printpoint(qh, fp, NULL, point);
    }
  }
  if (qh->CDDoutput)
    qh_fprintf(qh, fp, 9221, "end\n");
  qh_settempfree(qh, &points);
} /* printpoints_out */


/*---------------------------------

  qh_printpointvect(qh, fp, point, normal, center, radius, color )
    prints a 2-d, 3-d, or 4-d point as 3-d VECT's relative to normal or to center point
*/
void qh_printpointvect(qhT *qh, FILE *fp, pointT *point, coordT *normal, pointT *center, realT radius, realT color[3]) {
  realT diff[4], pointA[4];
  int k;

  for (k=qh->hull_dim; k--; ) {
    if (center)
      diff[k]= point[k]-center[k];
    else if (normal)
      diff[k]= normal[k];
    else
      diff[k]= 0;
  }
  if (center)
    qh_normalize2(qh, diff, qh->hull_dim, True, NULL, NULL);
  for (k=qh->hull_dim; k--; )
    pointA[k]= point[k]+diff[k] * radius;
  qh_printline3geom(qh, fp, point, pointA, color);
} /* printpointvect */

/*---------------------------------

  qh_printpointvect2(qh, fp, point, normal, center, radius )
    prints a 2-d, 3-d, or 4-d point as 2 3-d VECT's for an imprecise point
*/
void qh_printpointvect2(qhT *qh, FILE *fp, pointT *point, coordT *normal, pointT *center, realT radius) {
  realT red[3]={1, 0, 0}, yellow[3]={1, 1, 0};

  qh_printpointvect(qh, fp, point, normal, center, radius, red);
  qh_printpointvect(qh, fp, point, normal, center, -radius, yellow);
} /* printpointvect2 */

/*---------------------------------

  qh_printridge(qh, fp, ridge )
    prints the information in a ridge

  notes:
    for qh_printfacetridges()
    same as operator<< [QhullRidge.cpp]
*/
void qh_printridge(qhT *qh, FILE *fp, ridgeT *ridge) {

  qh_fprintf(qh, fp, 9222, "     - r%d", ridge->id);
  if (ridge->tested)
    qh_fprintf(qh, fp, 9223, " tested");
  if (ridge->nonconvex)
    qh_fprintf(qh, fp, 9224, " nonconvex");
  if (ridge->mergevertex)
    qh_fprintf(qh, fp, 9421, " mergevertex");
  if (ridge->mergevertex2)
    qh_fprintf(qh, fp, 9422, " mergevertex2");
  if (ridge->simplicialtop)
    qh_fprintf(qh, fp, 9425, " simplicialtop");
  if (ridge->simplicialbot)
    qh_fprintf(qh, fp, 9423, " simplicialbot");
  qh_fprintf(qh, fp, 9225, "\n");
  qh_printvertices(qh, fp, "           vertices:", ridge->vertices);
  if (ridge->top && ridge->bottom)
    qh_fprintf(qh, fp, 9226, "           between f%d and f%d\n",
            ridge->top->id, ridge->bottom->id);
} /* printridge */

/*---------------------------------

  qh_printspheres(qh, fp, vertices, radius )
    prints 3-d vertices as OFF spheres

  notes:
    inflated octahedron from Stuart Levy earth/mksphere2
*/
void qh_printspheres(qhT *qh, FILE *fp, setT *vertices, realT radius) {
  vertexT *vertex, **vertexp;

  qh->printoutnum++;
  qh_fprintf(qh, fp, 9227, "{appearance {-edge -normal normscale 0} {\n\
INST geom {define vsphere OFF\n\
18 32 48\n\
\n\
0 0 1\n\
1 0 0\n\
0 1 0\n\
-1 0 0\n\
0 -1 0\n\
0 0 -1\n\
0.707107 0 0.707107\n\
0 -0.707107 0.707107\n\
0.707107 -0.707107 0\n\
-0.707107 0 0.707107\n\
-0.707107 -0.707107 0\n\
0 0.707107 0.707107\n\
-0.707107 0.707107 0\n\
0.707107 0.707107 0\n\
0.707107 0 -0.707107\n\
0 0.707107 -0.707107\n\
-0.707107 0 -0.707107\n\
0 -0.707107 -0.707107\n\
\n\
3 0 6 11\n\
3 0 7 6 \n\
3 0 9 7 \n\
3 0 11 9\n\
3 1 6 8 \n\
3 1 8 14\n\
3 1 13 6\n\
3 1 14 13\n\
3 2 11 13\n\
3 2 12 11\n\
3 2 13 15\n\
3 2 15 12\n\
3 3 9 12\n\
3 3 10 9\n\
3 3 12 16\n\
3 3 16 10\n\
3 4 7 10\n\
3 4 8 7\n\
3 4 10 17\n\
3 4 17 8\n\
3 5 14 17\n\
3 5 15 14\n\
3 5 16 15\n\
3 5 17 16\n\
3 6 13 11\n\
3 7 8 6\n\
3 9 10 7\n\
3 11 12 9\n\
3 14 8 17\n\
3 15 13 14\n\
3 16 12 15\n\
3 17 10 16\n} transforms { TLIST\n");
  FOREACHvertex_(vertices) {
    qh_fprintf(qh, fp, 9228, "%8.4g 0 0 0 # v%d\n 0 %8.4g 0 0\n0 0 %8.4g 0\n",
      radius, vertex->id, radius, radius);
    qh_printpoint3(qh, fp, vertex->point);
    qh_fprintf(qh, fp, 9229, "1\n");
  }
  qh_fprintf(qh, fp, 9230, "}}}\n");
} /* printspheres */


/*----------------------------------------------
-printsummary-
                see libqhull_r.c
*/

/*---------------------------------

  qh_printvdiagram(qh, fp, format, facetlist, facets, printall )
    print voronoi diagram
      # of pairs of input sites
      #indices site1 site2 vertex1 ...

    sites indexed by input point id
      point 0 is the first input point
    vertices indexed by 'o' and 'p' order
      vertex 0 is the 'vertex-at-infinity'
      vertex 1 is the first Voronoi vertex

  see:
    qh_printvoronoi()
    qh_eachvoronoi_all()

  notes:
    if all facets are upperdelaunay,
      prints upper hull (furthest-site Voronoi diagram)
*/
void qh_printvdiagram(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall) {
  setT *vertices;
  int totcount, numcenters;
  boolT isLower;
  qh_RIDGE innerouter= qh_RIDGEall;
  printvridgeT printvridge= NULL;

  if (format == qh_PRINTvertices) {
    innerouter= qh_RIDGEall;
    printvridge= qh_printvridge;
  }else if (format == qh_PRINTinner) {
    innerouter= qh_RIDGEinner;
    printvridge= qh_printvnorm;
  }else if (format == qh_PRINTouter) {
    innerouter= qh_RIDGEouter;
    printvridge= qh_printvnorm;
  }else {
    qh_fprintf(qh, qh->ferr, 6219, "qhull internal error (qh_printvdiagram): unknown print format %d.\n", format);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  vertices= qh_markvoronoi(qh, facetlist, facets, printall, &isLower, &numcenters);
  totcount= qh_printvdiagram2(qh, NULL, NULL, vertices, innerouter, False);
  qh_fprintf(qh, fp, 9231, "%d\n", totcount);
  totcount= qh_printvdiagram2(qh, fp, printvridge, vertices, innerouter, True /* inorder*/);
  qh_settempfree(qh, &vertices);
#if 0  /* for testing qh_eachvoronoi_all */
  qh_fprintf(qh, fp, 9232, "\n");
  totcount= qh_eachvoronoi_all(qh, fp, printvridge, qh->UPPERdelaunay, innerouter, True /* inorder*/);
  qh_fprintf(qh, fp, 9233, "%d\n", totcount);
#endif
} /* printvdiagram */

/*---------------------------------

  qh_printvdiagram2(qh, fp, printvridge, vertices, innerouter, inorder )
    visit all pairs of input sites (vertices) for selected Voronoi vertices
    vertices may include NULLs

  innerouter:
    qh_RIDGEall   print inner ridges(bounded) and outer ridges(unbounded)
    qh_RIDGEinner print only inner ridges
    qh_RIDGEouter print only outer ridges

  inorder:
    print 3-d Voronoi vertices in order

  assumes:
    qh_markvoronoi marked facet->visitid for Voronoi vertices
    all facet->seen= False
    all facet->seen2= True

  returns:
    total number of Voronoi ridges
    if printvridge,
      calls printvridge( fp, vertex, vertexA, centers) for each ridge
      [see qh_eachvoronoi()]

  see:
    qh_eachvoronoi_all()
*/
int qh_printvdiagram2(qhT *qh, FILE *fp, printvridgeT printvridge, setT *vertices, qh_RIDGE innerouter, boolT inorder) {
  int totcount= 0;
  int vertex_i, vertex_n;
  vertexT *vertex;

  FORALLvertices
    vertex->seen= False;
  FOREACHvertex_i_(qh, vertices) {
    if (vertex) {
      if (qh->GOODvertex > 0 && qh_pointid(qh, vertex->point)+1 != qh->GOODvertex)
        continue;
      totcount += qh_eachvoronoi(qh, fp, printvridge, vertex, !qh_ALL, innerouter, inorder);
    }
  }
  return totcount;
} /* printvdiagram2 */

/*---------------------------------

  qh_printvertex(qh, fp, vertex )
    prints the information in a vertex
    Duplicated as operator<< [QhullVertex.cpp]
*/
void qh_printvertex(qhT *qh, FILE *fp, vertexT *vertex) {
  pointT *point;
  int k, count= 0;
  facetT *neighbor, **neighborp;
  realT r; /*bug fix*/

  if (!vertex) {
    qh_fprintf(qh, fp, 9234, "  NULLvertex\n");
    return;
  }
  qh_fprintf(qh, fp, 9235, "- p%d(v%d):", qh_pointid(qh, vertex->point), vertex->id);
  point= vertex->point;
  if (point) {
    for (k=qh->hull_dim; k--; ) {
      r= *point++;
      qh_fprintf(qh, fp, 9236, " %5.2g", r);
    }
  }
  if (vertex->deleted)
    qh_fprintf(qh, fp, 9237, " deleted");
  if (vertex->delridge)
    qh_fprintf(qh, fp, 9238, " delridge");
  if (vertex->newfacet)
    qh_fprintf(qh, fp, 9415, " newfacet");
  if (vertex->seen && qh->IStracing)
    qh_fprintf(qh, fp, 9416, " seen");
  if (vertex->seen2 && qh->IStracing)
    qh_fprintf(qh, fp, 9417, " seen2");
  qh_fprintf(qh, fp, 9239, "\n");
  if (vertex->neighbors) {
    qh_fprintf(qh, fp, 9240, "  neighbors:");
    FOREACHneighbor_(vertex) {
      if (++count % 100 == 0)
        qh_fprintf(qh, fp, 9241, "\n     ");
      qh_fprintf(qh, fp, 9242, " f%d", neighbor->id);
    }
    qh_fprintf(qh, fp, 9243, "\n");
  }
} /* printvertex */


/*---------------------------------

  qh_printvertexlist(qh, fp, string, facetlist, facets, printall )
    prints vertices used by a facetlist or facet set
    tests qh_skipfacet() if !printall
*/
void qh_printvertexlist(qhT *qh, FILE *fp, const char* string, facetT *facetlist,
                         setT *facets, boolT printall) {
  vertexT *vertex, **vertexp;
  setT *vertices;

  vertices= qh_facetvertices(qh, facetlist, facets, printall);
  qh_fprintf(qh, fp, 9244, "%s", string);
  FOREACHvertex_(vertices)
    qh_printvertex(qh, fp, vertex);
  qh_settempfree(qh, &vertices);
} /* printvertexlist */


/*---------------------------------

  qh_printvertices(qh, fp, string, vertices )
    prints vertices in a set
    duplicated as printVertexSet [QhullVertex.cpp]
*/
void qh_printvertices(qhT *qh, FILE *fp, const char* string, setT *vertices) {
  vertexT *vertex, **vertexp;

  qh_fprintf(qh, fp, 9245, "%s", string);
  FOREACHvertex_(vertices)
    qh_fprintf(qh, fp, 9246, " p%d(v%d)", qh_pointid(qh, vertex->point), vertex->id);
  qh_fprintf(qh, fp, 9247, "\n");
} /* printvertices */

/*---------------------------------

  qh_printvneighbors(qh, fp, facetlist, facets, printall )
    print vertex neighbors of vertices in facetlist and facets ('FN')

  notes:
    qh_countfacets clears facet->visitid for non-printed facets

  design:
    collect facet count and related statistics
    if necessary, build neighbor sets for each vertex
    collect vertices in facetlist and facets
    build a point array for point->vertex and point->coplanar facet
    for each point
      list vertex neighbors or coplanar facet
*/
void qh_printvneighbors(qhT *qh, FILE *fp, facetT* facetlist, setT *facets, boolT printall) {
  int numfacets, numsimplicial, numridges, totneighbors, numneighbors, numcoplanars, numtricoplanars;
  setT *vertices, *vertex_points, *coplanar_points;
  int numpoints= qh->num_points + qh_setsize(qh, qh->other_points);
  vertexT *vertex, **vertexp;
  int vertex_i, vertex_n;
  facetT *facet, **facetp, *neighbor, **neighborp;
  pointT *point, **pointp;

  qh_countfacets(qh, facetlist, facets, printall, &numfacets, &numsimplicial,
      &totneighbors, &numridges, &numcoplanars, &numtricoplanars);  /* sets facet->visitid */
  qh_fprintf(qh, fp, 9248, "%d\n", numpoints);
  qh_vertexneighbors(qh);
  vertices= qh_facetvertices(qh, facetlist, facets, printall);
  vertex_points= qh_settemp(qh, numpoints);
  coplanar_points= qh_settemp(qh, numpoints);
  qh_setzero(qh, vertex_points, 0, numpoints);
  qh_setzero(qh, coplanar_points, 0, numpoints);
  FOREACHvertex_(vertices)
    qh_point_add(qh, vertex_points, vertex->point, vertex);
  FORALLfacet_(facetlist) {
    FOREACHpoint_(facet->coplanarset)
      qh_point_add(qh, coplanar_points, point, facet);
  }
  FOREACHfacet_(facets) {
    FOREACHpoint_(facet->coplanarset)
      qh_point_add(qh, coplanar_points, point, facet);
  }
  FOREACHvertex_i_(qh, vertex_points) {
    if (vertex) {
      numneighbors= qh_setsize(qh, vertex->neighbors);
      qh_fprintf(qh, fp, 9249, "%d", numneighbors);
      qh_order_vertexneighbors(qh, vertex);
      FOREACHneighbor_(vertex)
        qh_fprintf(qh, fp, 9250, " %d",
                 neighbor->visitid ? neighbor->visitid - 1 : 0 - neighbor->id);
      qh_fprintf(qh, fp, 9251, "\n");
    }else if ((facet= SETelemt_(coplanar_points, vertex_i, facetT)))
      qh_fprintf(qh, fp, 9252, "1 %d\n",
                  facet->visitid ? facet->visitid - 1 : 0 - facet->id);
    else
      qh_fprintf(qh, fp, 9253, "0\n");
  }
  qh_settempfree(qh, &coplanar_points);
  qh_settempfree(qh, &vertex_points);
  qh_settempfree(qh, &vertices);
} /* printvneighbors */

/*---------------------------------

  qh_printvoronoi(qh, fp, format, facetlist, facets, printall )
    print voronoi diagram in 'o' or 'G' format
    for 'o' format
      prints voronoi centers for each facet and for infinity
      for each vertex, lists ids of printed facets or infinity
      assumes facetlist and facets are disjoint
    for 'G' format
      prints an OFF object
      adds a 0 coordinate to center
      prints infinity but does not list in vertices

  see:
    qh_printvdiagram()

  notes:
    if 'o',
      prints a line for each point except "at-infinity"
    if all facets are upperdelaunay,
      reverses lower and upper hull
*/
void qh_printvoronoi(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall) {
  int k, numcenters, numvertices= 0, numneighbors, numinf, vid=1, vertex_i, vertex_n;
  facetT *facet, **facetp, *neighbor, **neighborp;
  setT *vertices;
  vertexT *vertex;
  boolT isLower;
  unsigned int numfacets= (unsigned int)qh->num_facets;

  vertices= qh_markvoronoi(qh, facetlist, facets, printall, &isLower, &numcenters);
  FOREACHvertex_i_(qh, vertices) {
    if (vertex) {
      numvertices++;
      numneighbors= numinf= 0;
      FOREACHneighbor_(vertex) {
        if (neighbor->visitid == 0)
          numinf= 1;
        else if (neighbor->visitid < numfacets)
          numneighbors++;
      }
      if (numinf && !numneighbors) {
        SETelem_(vertices, vertex_i)= NULL;
        numvertices--;
      }
    }
  }
  if (format == qh_PRINTgeom)
    qh_fprintf(qh, fp, 9254, "{appearance {+edge -face} OFF %d %d 1 # Voronoi centers and cells\n",
                numcenters, numvertices);
  else
    qh_fprintf(qh, fp, 9255, "%d\n%d %d 1\n", qh->hull_dim-1, numcenters, qh_setsize(qh, vertices));
  if (format == qh_PRINTgeom) {
    for (k=qh->hull_dim-1; k--; )
      qh_fprintf(qh, fp, 9256, qh_REAL_1, 0.0);
    qh_fprintf(qh, fp, 9257, " 0 # infinity not used\n");
  }else {
    for (k=qh->hull_dim-1; k--; )
      qh_fprintf(qh, fp, 9258, qh_REAL_1, qh_INFINITE);
    qh_fprintf(qh, fp, 9259, "\n");
  }
  FORALLfacet_(facetlist) {
    if (facet->visitid && facet->visitid < numfacets) {
      if (format == qh_PRINTgeom)
        qh_fprintf(qh, fp, 9260, "# %d f%d\n", vid++, facet->id);
      qh_printcenter(qh, fp, format, NULL, facet);
    }
  }
  FOREACHfacet_(facets) {
    if (facet->visitid && facet->visitid < numfacets) {
      if (format == qh_PRINTgeom)
        qh_fprintf(qh, fp, 9261, "# %d f%d\n", vid++, facet->id);
      qh_printcenter(qh, fp, format, NULL, facet);
    }
  }
  FOREACHvertex_i_(qh, vertices) {
    numneighbors= 0;
    numinf=0;
    if (vertex) {
      qh_order_vertexneighbors(qh, vertex);
      FOREACHneighbor_(vertex) {
        if (neighbor->visitid == 0)
          numinf= 1;
        else if (neighbor->visitid < numfacets)
          numneighbors++;
      }
    }
    if (format == qh_PRINTgeom) {
      if (vertex) {
        qh_fprintf(qh, fp, 9262, "%d", numneighbors);
        FOREACHneighbor_(vertex) {
          if (neighbor->visitid && neighbor->visitid < numfacets)
            qh_fprintf(qh, fp, 9263, " %d", neighbor->visitid);
        }
        qh_fprintf(qh, fp, 9264, " # p%d(v%d)\n", vertex_i, vertex->id);
      }else
        qh_fprintf(qh, fp, 9265, " # p%d is coplanar or isolated\n", vertex_i);
    }else {
      if (numinf)
        numneighbors++;
      qh_fprintf(qh, fp, 9266, "%d", numneighbors);
      if (vertex) {
        FOREACHneighbor_(vertex) {
          if (neighbor->visitid == 0) {
            if (numinf) {
              numinf= 0;
              qh_fprintf(qh, fp, 9267, " %d", neighbor->visitid);
            }
          }else if (neighbor->visitid < numfacets)
            qh_fprintf(qh, fp, 9268, " %d", neighbor->visitid);
        }
      }
      qh_fprintf(qh, fp, 9269, "\n");
    }
  }
  if (format == qh_PRINTgeom)
    qh_fprintf(qh, fp, 9270, "}\n");
  qh_settempfree(qh, &vertices);
} /* printvoronoi */

/*---------------------------------

  qh_printvnorm(qh, fp, vertex, vertexA, centers, unbounded )
    print one separating plane of the Voronoi diagram for a pair of input sites
    unbounded==True if centers includes vertex-at-infinity

  assumes:
    qh_ASvoronoi and qh_vertexneighbors() already set

  note:
    parameter unbounded is UNUSED by this callback

  see:
    qh_printvdiagram()
    qh_eachvoronoi()
*/
void qh_printvnorm(qhT *qh, FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded) {
  pointT *normal;
  realT offset;
  int k;
  QHULL_UNUSED(unbounded);

  normal= qh_detvnorm(qh, vertex, vertexA, centers, &offset);
  qh_fprintf(qh, fp, 9271, "%d %d %d ",
      2+qh->hull_dim, qh_pointid(qh, vertex->point), qh_pointid(qh, vertexA->point));
  for (k=0; k< qh->hull_dim-1; k++)
    qh_fprintf(qh, fp, 9272, qh_REAL_1, normal[k]);
  qh_fprintf(qh, fp, 9273, qh_REAL_1, offset);
  qh_fprintf(qh, fp, 9274, "\n");
} /* printvnorm */

/*---------------------------------

  qh_printvridge(qh, fp, vertex, vertexA, centers, unbounded )
    print one ridge of the Voronoi diagram for a pair of input sites
    unbounded==True if centers includes vertex-at-infinity

  see:
    qh_printvdiagram()

  notes:
    the user may use a different function
    parameter unbounded is UNUSED
*/
void qh_printvridge(qhT *qh, FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded) {
  facetT *facet, **facetp;
  QHULL_UNUSED(unbounded);

  qh_fprintf(qh, fp, 9275, "%d %d %d", qh_setsize(qh, centers)+2,
       qh_pointid(qh, vertex->point), qh_pointid(qh, vertexA->point));
  FOREACHfacet_(centers)
    qh_fprintf(qh, fp, 9276, " %d", facet->visitid);
  qh_fprintf(qh, fp, 9277, "\n");
} /* printvridge */

/*---------------------------------

  qh_projectdim3(qh, source, destination )
    project 2-d 3-d or 4-d point to a 3-d point
    uses qh.DROPdim and qh.hull_dim
    source and destination may be the same

  notes:
    allocate 4 elements to destination just in case
*/
void qh_projectdim3(qhT *qh, pointT *source, pointT *destination) {
  int i,k;

  for (k=0, i=0; k < qh->hull_dim; k++) {
    if (qh->hull_dim == 4) {
      if (k != qh->DROPdim)
        destination[i++]= source[k];
    }else if (k == qh->DROPdim)
      destination[i++]= 0;
    else
      destination[i++]= source[k];
  }
  while (i < 3)
    destination[i++]= 0.0;
} /* projectdim3 */

/*---------------------------------

  qh_readfeasible(qh, dim, curline )
    read feasible point from current line and qh.fin

  returns:
    number of lines read from qh.fin
    sets qh.feasible_point with malloc'd coordinates

  notes:
    checks for qh.HALFspace
    assumes dim > 1

  see:
    qh_setfeasible
*/
int qh_readfeasible(qhT *qh, int dim, const char *curline) {
  boolT isfirst= True;
  int linecount= 0, tokcount= 0;
  const char *s;
  char *t, firstline[qh_MAXfirst+1];
  coordT *coords, value;

  if (!qh->HALFspace) {
    qh_fprintf(qh, qh->ferr, 6070, "qhull input error: feasible point(dim 1 coords) is only valid for halfspace intersection\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  if (qh->feasible_string)
    qh_fprintf(qh, qh->ferr, 7057, "qhull input warning: feasible point(dim 1 coords) overrides 'Hn,n,n' feasible point for halfspace intersection\n");
  if (!(qh->feasible_point= (coordT *)qh_malloc((size_t)dim * sizeof(coordT)))) {
    qh_fprintf(qh, qh->ferr, 6071, "qhull error: insufficient memory for feasible point\n");
    qh_errexit(qh, qh_ERRmem, NULL, NULL);
  }
  coords= qh->feasible_point;
  while ((s= (isfirst ?  curline : fgets(firstline, qh_MAXfirst, qh->fin)))) {
    if (isfirst)
      isfirst= False;
    else
      linecount++;
    while (*s) {
      while (isspace(*s))
        s++;
      value= qh_strtod(s, &t);
      if (s == t)
        break;
      s= t;
      *(coords++)= value;
      if (++tokcount == dim) {
        while (isspace(*s))
          s++;
        qh_strtod(s, &t);
        if (s != t) {
          qh_fprintf(qh, qh->ferr, 6072, "qhull input error: coordinates for feasible point do not finish out the line: %s\n",
               s);
          qh_errexit(qh, qh_ERRinput, NULL, NULL);
        }
        return linecount;
      }
    }
  }
  qh_fprintf(qh, qh->ferr, 6073, "qhull input error: only %d coordinates.  Could not read %d-d feasible point.\n",
           tokcount, dim);
  qh_errexit(qh, qh_ERRinput, NULL, NULL);
  return 0;
} /* readfeasible */

/*---------------------------------

  qh_readpoints(qh, numpoints, dimension, ismalloc )
    read points from qh.fin into qh.first_point, qh.num_points
    qh.fin is lines of coordinates, one per vertex, first line number of points
    if 'rbox D4',
      gives message
    if qh.ATinfinity,
      adds point-at-infinity for Delaunay triangulations

  returns:
    number of points, array of point coordinates, dimension, ismalloc True
    if qh.DELAUNAY & !qh.PROJECTinput, projects points to paraboloid
        and clears qh.PROJECTdelaunay
    if qh.HALFspace, reads optional feasible point, reads halfspaces,
        converts to dual.

  for feasible point in "cdd format" in 3-d:
    3 1
    coordinates
    comments
    begin
    n 4 real/integer
    ...
    end

  notes:
    dimension will change in qh_initqhull_globals if qh.PROJECTinput
    uses malloc() since qh_mem not initialized
    QH11012 FIX: qh_readpoints needs rewriting, too long
*/
coordT *qh_readpoints(qhT *qh, int *numpoints, int *dimension, boolT *ismalloc) {
  coordT *points, *coords, *infinity= NULL;
  realT paraboloid, maxboloid= -REALmax, value;
  realT *coordp= NULL, *offsetp= NULL, *normalp= NULL;
  char *s= 0, *t, firstline[qh_MAXfirst+1];
  int diminput=0, numinput=0, dimfeasible= 0, newnum, k, tempi;
  int firsttext=0, firstshort=0, firstlong=0, firstpoint=0;
  int tokcount= 0, linecount=0, maxcount, coordcount=0;
  boolT islong, isfirst= True, wasbegin= False;
  boolT isdelaunay= qh->DELAUNAY && !qh->PROJECTinput;

  if (qh->CDDinput) {
    while ((s= fgets(firstline, qh_MAXfirst, qh->fin))) {
      linecount++;
      if (qh->HALFspace && linecount == 1 && isdigit(*s)) {
        dimfeasible= qh_strtol(s, &s);
        while (isspace(*s))
          s++;
        if (qh_strtol(s, &s) == 1)
          linecount += qh_readfeasible(qh, dimfeasible, s);
        else
          dimfeasible= 0;
      }else if (!memcmp(firstline, "begin", (size_t)5) || !memcmp(firstline, "BEGIN", (size_t)5))
        break;
      else if (!*qh->rbox_command)
        strncat(qh->rbox_command, s, sizeof(qh->rbox_command)-1);
    }
    if (!s) {
      qh_fprintf(qh, qh->ferr, 6074, "qhull input error: missing \"begin\" for cdd-formated input\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
  }
  while (!numinput && (s= fgets(firstline, qh_MAXfirst, qh->fin))) {
    linecount++;
    if (!memcmp(s, "begin", (size_t)5) || !memcmp(s, "BEGIN", (size_t)5))
      wasbegin= True;
    while (*s) {
      while (isspace(*s))
        s++;
      if (!*s)
        break;
      if (!isdigit(*s)) {
        if (!*qh->rbox_command) {
          strncat(qh->rbox_command, s, sizeof(qh->rbox_command)-1);
          firsttext= linecount;
        }
        break;
      }
      if (!diminput)
        diminput= qh_strtol(s, &s);
      else {
        numinput= qh_strtol(s, &s);
        if (numinput == 1 && diminput >= 2 && qh->HALFspace && !qh->CDDinput) {
          linecount += qh_readfeasible(qh, diminput, s); /* checks if ok */
          dimfeasible= diminput;
          diminput= numinput= 0;
        }else
          break;
      }
    }
  }
  if (!s) {
    qh_fprintf(qh, qh->ferr, 6075, "qhull input error: short input file.  Did not find dimension and number of points\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  if (diminput > numinput) {
    tempi= diminput;    /* exchange dim and n, e.g., for cdd input format */
    diminput= numinput;
    numinput= tempi;
  }
  if (diminput < 2) {
    qh_fprintf(qh, qh->ferr, 6220, "qhull input error: dimension %d (first or smaller number) should be at least 2\n",
            diminput);
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  if (numinput < 1 || numinput > qh_POINTSmax) {
    qh_fprintf(qh, qh->ferr, 6411, "qhull input error: expecting between 1 and %d points.  Got %d %d-d points\n",
      qh_POINTSmax, numinput, diminput);
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
    /* same error message in qh_initqhull_globals */
  }

  if (isdelaunay && qh->HALFspace) {
    qh_fprintf(qh, qh->ferr, 6037, "qhull option error (qh_readpoints): can not use Delaunay('d') or Voronoi('v') with halfspace intersection('H')\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
    /* otherwise corrupted memory allocations, same error message as in qh_initqhull_globals */
  }else if (isdelaunay) {
    qh->PROJECTdelaunay= False;
    if (qh->CDDinput)
      *dimension= diminput;
    else
      *dimension= diminput+1;
    *numpoints= numinput;
    if (qh->ATinfinity)
      (*numpoints)++;
  }else if (qh->HALFspace) {
    *dimension= diminput - 1;
    *numpoints= numinput;
    if (diminput < 3) {
      qh_fprintf(qh, qh->ferr, 6221, "qhull input error: dimension %d (first number, includes offset) should be at least 3 for halfspaces\n",
            diminput);
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    if (dimfeasible) {
      if (dimfeasible != *dimension) {
        qh_fprintf(qh, qh->ferr, 6222, "qhull input error: dimension %d of feasible point is not one less than dimension %d for halfspaces\n",
          dimfeasible, diminput);
        qh_errexit(qh, qh_ERRinput, NULL, NULL);
      }
    }else
      qh_setfeasible(qh, *dimension);
  }else {
    if (qh->CDDinput)
      *dimension= diminput-1;
    else
      *dimension= diminput;
    *numpoints= numinput;
  }
  qh->normal_size= *dimension * (int)sizeof(coordT); /* for tracing with qh_printpoint */
  if (qh->HALFspace) {
    qh->half_space= coordp= (coordT *)qh_malloc((size_t)qh->normal_size + sizeof(coordT));
    if (qh->CDDinput) {
      offsetp= qh->half_space;
      normalp= offsetp + 1;
    }else {
      normalp= qh->half_space;
      offsetp= normalp + *dimension;
    }
  }
  qh->maxline= diminput * (qh_REALdigits + 5);
  maximize_(qh->maxline, 500);
  qh->line= (char *)qh_malloc((size_t)(qh->maxline+1) * sizeof(char));
  *ismalloc= True;  /* use malloc since memory not setup */
  coords= points= qh->temp_malloc=  /* numinput and diminput >=2 by QH6220 */
        (coordT *)qh_malloc((size_t)((*numpoints)*(*dimension))*sizeof(coordT));
  if (!coords || !qh->line || (qh->HALFspace && !qh->half_space)) {
    qh_fprintf(qh, qh->ferr, 6076, "qhull error: insufficient memory to read %d points\n",
            numinput);
    qh_errexit(qh, qh_ERRmem, NULL, NULL);
  }
  if (isdelaunay && qh->ATinfinity) {
    infinity= points + numinput * (*dimension);
    for (k= (*dimension) - 1; k--; )
      infinity[k]= 0.0;
  }
  maxcount= numinput * diminput;
  paraboloid= 0.0;
  while ((s= (isfirst ?  s : fgets(qh->line, qh->maxline, qh->fin)))) {
    if (!isfirst) {
      linecount++;
      if (*s == 'e' || *s == 'E') {
        if (!memcmp(s, "end", (size_t)3) || !memcmp(s, "END", (size_t)3)) {
          if (qh->CDDinput )
            break;
          else if (wasbegin)
            qh_fprintf(qh, qh->ferr, 7058, "qhull input warning: the input appears to be in cdd format.  If so, use 'Fd'\n");
        }
      }
    }
    islong= False;
    while (*s) {
      while (isspace(*s))
        s++;
      value= qh_strtod(s, &t);
      if (s == t) {
        if (!*qh->rbox_command)
         strncat(qh->rbox_command, s, sizeof(qh->rbox_command)-1);
        if (*s && !firsttext)
          firsttext= linecount;
        if (!islong && !firstshort && coordcount)
          firstshort= linecount;
        break;
      }
      if (!firstpoint)
        firstpoint= linecount;
      s= t;
      if (++tokcount > maxcount)
        continue;
      if (qh->HALFspace) {
        if (qh->CDDinput)
          *(coordp++)= -value; /* both coefficients and offset */
        else
          *(coordp++)= value;
      }else {
        *(coords++)= value;
        if (qh->CDDinput && !coordcount) {
          if (value != 1.0) {
            qh_fprintf(qh, qh->ferr, 6077, "qhull input error: for cdd format, point at line %d does not start with '1'\n",
                   linecount);
            qh_errexit(qh, qh_ERRinput, NULL, NULL);
          }
          coords--;
        }else if (isdelaunay) {
          paraboloid += value * value;
          if (qh->ATinfinity) {
            if (qh->CDDinput)
              infinity[coordcount-1] += value;
            else
              infinity[coordcount] += value;
          }
        }
      }
      if (++coordcount == diminput) {
        coordcount= 0;
        if (isdelaunay) {
          *(coords++)= paraboloid;
          maximize_(maxboloid, paraboloid);
          paraboloid= 0.0;
        }else if (qh->HALFspace) {
          if (!qh_sethalfspace(qh, *dimension, coords, &coords, normalp, offsetp, qh->feasible_point)) {
            qh_fprintf(qh, qh->ferr, 8048, "The halfspace was on line %d\n", linecount);
            if (wasbegin)
              qh_fprintf(qh, qh->ferr, 8049, "The input appears to be in cdd format.  If so, you should use option 'Fd'\n");
            qh_errexit(qh, qh_ERRinput, NULL, NULL);
          }
          coordp= qh->half_space;
        }
        while (isspace(*s))
          s++;
        if (*s) {
          islong= True;
          if (!firstlong)
            firstlong= linecount;
        }
      }
    }
    if (!islong && !firstshort && coordcount)
      firstshort= linecount;
    if (!isfirst && s - qh->line >= qh->maxline) {
      qh_fprintf(qh, qh->ferr, 6078, "qhull input error: line %d contained more than %d characters\n",
              linecount, (int) (s - qh->line));   /* WARN64 */
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    isfirst= False;
  }
  if (qh->rbox_command[0])
    qh->rbox_command[strlen(qh->rbox_command)-1]= '\0'; /* remove \n, previous qh_errexit's display command as two lines */
  if (tokcount != maxcount) {
    newnum= fmin_(numinput, tokcount/diminput);
    if (qh->ALLOWshort)
      qh_fprintf(qh, qh->ferr, 7073, "qhull warning: instead of %d points in %d-d, input contains %d points and %d extra coordinates.\n",
          numinput, diminput, tokcount/diminput, tokcount % diminput);
    else
      qh_fprintf(qh, qh->ferr, 6410, "qhull error: instead of %d points in %d-d, input contains %d points and %d extra coordinates.\n",
          numinput, diminput, tokcount/diminput, tokcount % diminput);
    if (firsttext)
      qh_fprintf(qh, qh->ferr, 8051, "    Line %d is the first comment.\n", firsttext);
    qh_fprintf(qh, qh->ferr, 8033,   "    Line %d is the first point.\n", firstpoint);
    if (firstshort)
      qh_fprintf(qh, qh->ferr, 8052, "    Line %d is the first short line.\n", firstshort);
    if (firstlong)
      qh_fprintf(qh, qh->ferr, 8053, "    Line %d is the first long line.\n", firstlong);
    if (qh->ALLOWshort)
      qh_fprintf(qh, qh->ferr, 8054, "    Continuing with %d points.\n", newnum);
    else {
      qh_fprintf(qh, qh->ferr, 8077, "    Override with option 'Qa' (allow-short)\n");
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    numinput= newnum;
    if (isdelaunay && qh->ATinfinity) {
      for (k= tokcount % diminput; k--; )
        infinity[k] -= *(--coords);
      *numpoints= newnum+1;
    }else {
      coords -= tokcount % diminput;
      *numpoints= newnum;
    }
  }
  if (isdelaunay && qh->ATinfinity) {
    for (k= (*dimension) - 1; k--; )
      infinity[k] /= numinput;
    if (coords == infinity)
      coords += (*dimension) -1;
    else {
      for (k=0; k < (*dimension) - 1; k++)
        *(coords++)= infinity[k];
    }
    *(coords++)= maxboloid * 1.1;
  }
  if (!strcmp(qh->rbox_command, "./rbox D4"))
    qh_fprintf(qh, qh->ferr, 8055, "\n\
This is the qhull test case.  If any errors or core dumps occur,\n\
recompile qhull with 'make new'.  If errors still occur, there is\n\
an incompatibility.  You should try a different compiler.  You can also\n\
change the choices in user_r.h.  If you discover the source of the problem,\n\
please send mail to qhull_bug@qhull.org.\n\
\n\
Type 'qhull' for a short list of options.\n");
  qh_free(qh->line);
  qh->line= NULL;
  if (qh->half_space) {
    qh_free(qh->half_space);
    qh->half_space= NULL;
  }
  qh->temp_malloc= NULL;
  trace1((qh, qh->ferr, 1008,"qh_readpoints: read in %d %d-dimensional points\n",
          numinput, diminput));
  return(points);
} /* readpoints */


/*---------------------------------

  qh_setfeasible(qh, dim )
    set qh.feasible_point from qh.feasible_string in "n,n,n" or "n n n" format

  notes:
    "n,n,n" already checked by qh_initflags()
    see qh_readfeasible()
    called only once from qh_new_qhull, otherwise leaks memory
*/
void qh_setfeasible(qhT *qh, int dim) {
  int tokcount= 0;
  char *s;
  coordT *coords, value;

  if (!(s= qh->feasible_string)) {
    qh_fprintf(qh, qh->ferr, 6223, "qhull input error: halfspace intersection needs a feasible point.  Either prepend the input with 1 point or use 'Hn,n,n'.  See manual.\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  if (!(qh->feasible_point= (pointT *)qh_malloc((size_t)dim * sizeof(coordT)))) {
    qh_fprintf(qh, qh->ferr, 6079, "qhull error: insufficient memory for 'Hn,n,n'\n");
    qh_errexit(qh, qh_ERRmem, NULL, NULL);
  }
  coords= qh->feasible_point;
  while (*s) {
    value= qh_strtod(s, &s);
    if (++tokcount > dim) {
      qh_fprintf(qh, qh->ferr, 7059, "qhull input warning: more coordinates for 'H%s' than dimension %d\n",
          qh->feasible_string, dim);
      break;
    }
    *(coords++)= value;
    if (*s)
      s++;
  }
  while (++tokcount <= dim)
    *(coords++)= 0.0;
} /* setfeasible */

/*---------------------------------

  qh_skipfacet(qh, facet )
    returns 'True' if this facet is not to be printed

  notes:
    based on the user provided slice thresholds and 'good' specifications
*/
boolT qh_skipfacet(qhT *qh, facetT *facet) {
  facetT *neighbor, **neighborp;

  if (qh->PRINTneighbors) {
    if (facet->good)
      return !qh->PRINTgood;
    FOREACHneighbor_(facet) {
      if (neighbor->good)
        return False;
    }
    return True;
  }else if (qh->PRINTgood)
    return !facet->good;
  else if (!facet->normal)
    return True;
  return(!qh_inthresholds(qh, facet->normal, NULL));
} /* skipfacet */

/*---------------------------------

  qh_skipfilename(qh, string )
    returns pointer to character after filename

  notes:
    skips leading spaces
    ends with spacing or eol
    if starts with ' or " ends with the same, skipping \' or \"
    For qhull, qh_argv_to_command() only uses double quotes
*/
char *qh_skipfilename(qhT *qh, char *filename) {
  char *s= filename;  /* non-const due to return */
  char c;

  while (*s && isspace(*s))
    s++;
  c= *s++;
  if (c == '\0') {
    qh_fprintf(qh, qh->ferr, 6204, "qhull input error: filename expected, none found.\n");
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  if (c == '\'' || c == '"') {
    while (*s !=c || s[-1] == '\\') {
      if (!*s) {
        qh_fprintf(qh, qh->ferr, 6203, "qhull input error: missing quote after filename -- %s\n", filename);
        qh_errexit(qh, qh_ERRinput, NULL, NULL);
      }
      s++;
    }
    s++;
  }
  else while (*s && !isspace(*s))
      s++;
  return s;
} /* skipfilename */

geometry/src/Rtsearch.cpp0000644000176200001440000001130214664422665015167 0ustar  liggesusers/*
  This program is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by the
  Free Software Foundation; either version 3 of the License, or (at your
  option) any later version.
  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  for more details.
  You should have received a copy of the GNU General Public License
  along with this program. If not, see  .
*/

// Originally written for package lidR by Jean-Romain Roussel
// Author: Jean-Romain Roussel
//  3  may 2017: copy from package lidR to package geometry by Jean-Romain Roussel to replace former code of tsearch
//  4  may 2017: Add barycentric coordinates support to reproduce original tsearch function
// 23 sept 2017: fix bug of computeur precision by Jean-Romain Roussel


// [[Rcpp::depends(RcppProgress)]]
#include 
#include 
#include "QuadTree.h"

using namespace Rcpp;

static inline double max (double a, double b, double c)
{
  if (a < b)
    return (b < c ? c : b);
  else
    return (a < c ? c : a);
}

static inline double min (double a, double b, double c)
{
  if (a > b)
    return (b > c ? c : b);
  else
    return (a > c ? c : a);
}

bool PointInTriangle(Point p0, Point p1, Point p2, Point p, Point* bary, double eps)
{
  double det = ((p1.y - p2.y)*(p0.x - p2.x) + (p2.x - p1.x)*(p0.y - p2.y));
  double a = ((p1.y - p2.y)*(p.x - p2.x) + (p2.x - p1.x)*(p.y - p2.y)) / det;
  double b = ((p2.y - p0.y)*(p.x - p2.x) + (p0.x - p2.x)*(p.y - p2.y)) / det;
  double c = 1 - a - b;

  bary->x = c;
  bary->y = b;

  return -eps <= a && a <= 1+eps && -eps <= b && b <= 1+eps && -eps <= c && c <= 1+eps;
}

//' @importFrom Rcpp sourceCpp
// [[Rcpp::export]]
SEXP C_tsearch(NumericVector x,  NumericVector y, IntegerMatrix elem, NumericVector xi, NumericVector yi, bool bary = false, double eps = 1.0e-12)
{
  std::vector xx = as< std::vector >(xi);
  std::vector yy = as< std::vector >(yi);

  // Compute the minimum of each vector
  double xoffset = *std::min_element(xx.begin(), xx.end());
  double yoffset = *std::min_element(yy.begin(), yy.end());

  // Subtract the minimum from all elements in the vector
  std::transform(xx.begin(), xx.end(), xx.begin(), [xoffset](double& elem) { return elem - xoffset; });
  std::transform(yy.begin(), yy.end(), yy.begin(), [yoffset](double& elem) { return elem - yoffset; });

  QuadTree *tree = QuadTree::create(xx, yy, eps);

  if (tree == nullptr)
    Rcpp::stop("Failed to insert point into QuadTree.\nPlease post input to tsearch  (or tsearchn at\nhttps://github.com/davidcsterratt/geometry/issues\nor email the maintainer.");

  int nelem = elem.nrow();
  int np = xi.size();

  // set false -> true if you want to display a progressbar
  Progress p(nelem, false);

  IntegerVector indexes(np);
  std::fill(indexes.begin(), indexes.end(), NA_INTEGER);

  NumericMatrix barycentric;

  if(bary)
  {
    barycentric = NumericMatrix(np, 3);
    std::fill(barycentric.begin(), barycentric.end(), NA_REAL);
  }

  // Loop over each triangle
  for (int k = 0; k < nelem; k++)
  {
    if (Progress::check_abort() )
    {
      delete tree;
      return indexes;
    }
    else
      p.update(k);

    // Retrieve triangle A B C coordinates

    int iA = elem(k, 0) - 1;
    int iB = elem(k, 1) - 1;
    int iC = elem(k, 2) - 1;

    Point A(x(iA)-xoffset, y(iA)-yoffset);
    Point B(x(iB)-xoffset, y(iB)-yoffset);
    Point C(x(iC)-xoffset, y(iC)-yoffset);

    // Boundingbox of A B C

    double rminx = min(A.x, B.x, C.x);
    double rmaxx = max(A.x, B.x, C.x);
    double rminy = min(A.y, B.y, C.y);
    double rmaxy = max(A.y, B.y, C.y);

    double xcenter =     (rminx + rmaxx)/2;
    double ycenter =     (rminy + rmaxy)/2;
    double half_width =  (rmaxx - rminx)/2;
    double half_height = (rmaxy - rminy)/2;

    // QuadTree search of points in enclosing boundingbox

    std::vector points;
    tree->rect_lookup(xcenter, ycenter, half_width + eps, half_height + eps, points);

    // Compute if the points are in A B C

    for (unsigned int i = 0 ; i < points.size() ; i++)
    {
      Point pbary;

      if (PointInTriangle(A, B, C, *points[i], &pbary, eps))
      {
        int id = points[i]->id;
        indexes(id) = k + 1;

        if(bary)
        {
          barycentric(id, 0) = 1 - pbary.x - pbary.y;
          barycentric(id, 1) = pbary.y;
          barycentric(id, 2) = pbary.x;
        }
      }
    }
  }

  delete tree;

  if (bary)
  {
   return (List::create(indexes, barycentric));
  }
  else
    return (indexes);
}
geometry/src/user_r.c0000644000176200001440000005714314664417655014373 0ustar  liggesusers/*
  ---------------------------------

   user_r.c
   user redefinable functions

   see user2_r.c for qh_fprintf, qh_malloc, qh_free

   see README.txt  see COPYING.txt for copyright information.

   see libqhull_r.h for data structures, macros, and user-callable functions.

   see user_eg_r.c, user_eg2_r.c, and unix_r.c for examples.

   see user_r.h for user-definable constants

      use qh_NOmem in mem_r.h to turn off memory management
      use qh_NOmerge in user_r.h to turn off facet merging
      set qh_KEEPstatistics in user_r.h to 0 to turn off statistics

   This is unsupported software.  You're welcome to make changes,
   but you're on your own if something goes wrong.  Use 'Tc' to
   check frequently.  Usually qhull will report an error if
   a data structure becomes inconsistent.  If so, it also reports
   the last point added to the hull, e.g., 102.  You can then trace
   the execution of qhull with "T4P102".

   Please report any errors that you fix to qhull@qhull.org

   Qhull-template is a template for calling qhull from within your application

   if you recompile and load this module, then user.o will not be loaded
   from qhull.a

   you can add additional quick allocation sizes in qh_user_memsizes

   if the other functions here are redefined to not use qh_print...,
   then io.o will not be loaded from qhull.a.  See user_eg_r.c for an
   example.  We recommend keeping io.o for the extra debugging
   information it supplies.
*/

#include "qhull_ra.h"

#include 

/*---------------------------------

  Qhull-template
    Template for calling qhull from inside your program

  returns:
    exit code(see qh_ERR... in libqhull_r.h)
    all memory freed

  notes:
    This can be called any number of times.
*/
#if 0
{
  int dim;                  /* dimension of points */
  int numpoints;            /* number of points */
  coordT *points;           /* array of coordinates for each point */
  boolT ismalloc;           /* True if qhull should free points in qh_freeqhull() or reallocation */
  char flags[]= "qhull Tv"; /* option flags for qhull, see html/qh-quick.htm */
  FILE *outfile= stdout;    /* output from qh_produce_output
                               use NULL to skip qh_produce_output */
  FILE *errfile= stderr;    /* error messages from qhull code */
  int exitcode;             /* 0 if no error from qhull */
  facetT *facet;            /* set by FORALLfacets */
  int curlong, totlong;     /* memory remaining after qh_memfreeshort */

  qhT qh_qh;                /* Qhull's data structure.  First argument of most calls */
  qhT *qh= &qh_qh;          /* Alternatively -- qhT *qh= (qhT *)malloc(sizeof(qhT)) */

  QHULL_LIB_CHECK /* Check for compatible library */

  qh_zero(qh, errfile);

  /* initialize dim, numpoints, points[], ismalloc here */
  exitcode= qh_new_qhull(qh, dim, numpoints, points, ismalloc,
                      flags, outfile, errfile);
  if (!exitcode) {                  /* if no error */
    /* 'qh->facet_list' contains the convex hull */
    FORALLfacets {
       /* ... your code ... */
    }
  }
  qh_freeqhull(qh, !qh_ALL);
  qh_memfreeshort(qh, &curlong, &totlong);
  if (curlong || totlong)
    qh_fprintf(qh, errfile, 7079, "qhull internal warning (main): did not free %d bytes of long memory(%d pieces)\n", totlong, curlong);
}
#endif

/*---------------------------------

  qh_new_qhull(qh, dim, numpoints, points, ismalloc, qhull_cmd, outfile, errfile )
    Run qhull
    Before first call, either call qh_zero(qh, errfile), or set qh to all zero.

  returns:
    results in qh
    exitcode (0 if no errors).

  notes:
    do not modify points until finished with results.
      The qhull data structure contains pointers into the points array.
    do not call qhull functions before qh_new_qhull().
      The qhull data structure is not initialized until qh_new_qhull().
    do not call qh_init_A (global_r.c)

    Default errfile is stderr, outfile may be null
    qhull_cmd must start with "qhull "
    projects points to a new point array for Delaunay triangulations ('d' and 'v')
    transforms points into a new point array for halfspace intersection ('H')

  see:
    Qhull-template at the beginning of this file.
    An example of using qh_new_qhull is user_eg_r.c
*/
int qh_new_qhull(qhT *qh, int dim, int numpoints, coordT *points, boolT ismalloc,
                char *qhull_cmd, FILE *outfile, FILE *errfile) {
  /* gcc may issue a "might be clobbered" warning for dim, points, and ismalloc [-Wclobbered].
     These parameters are not referenced after a longjmp() and hence not clobbered.
     See http://stackoverflow.com/questions/7721854/what-sense-do-these-clobbered-variable-warnings-make */
  int exitcode, hulldim;
  boolT new_ismalloc;
  coordT *new_points;

  if(!errfile){
    errfile= stderr;
  }
  if (!qh->qhmem.ferr) {
    qh_meminit(qh, errfile);
  } else {
    qh_memcheck(qh);
  }
  if (strncmp(qhull_cmd, "qhull ", (size_t)6) && strcmp(qhull_cmd, "qhull") != 0) {
    qh_fprintf(qh, errfile, 6186, "qhull error (qh_new_qhull): start qhull_cmd argument with \"qhull \" or set to \"qhull\"\n");
    return qh_ERRinput;
  }
  qh_initqhull_start(qh, NULL, outfile, errfile);
  if(numpoints==0 && points==NULL){
      trace1((qh, qh->ferr, 1047, "qh_new_qhull: initialize Qhull\n"));
      return 0;
  }
  trace1((qh, qh->ferr, 1044, "qh_new_qhull: build new Qhull for %d %d-d points with %s\n", numpoints, dim, qhull_cmd));
  exitcode= setjmp(qh->errexit);
  if (!exitcode) {
    qh->NOerrexit= False;
    qh_initflags(qh, qhull_cmd);
    if (qh->DELAUNAY)
      qh->PROJECTdelaunay= True;
    if (qh->HALFspace) {
      /* points is an array of halfspaces,
         the last coordinate of each halfspace is its offset */
      hulldim= dim-1;
      qh_setfeasible(qh, hulldim);
      new_points= qh_sethalfspace_all(qh, dim, numpoints, points, qh->feasible_point);
      new_ismalloc= True;
      if (ismalloc)
        qh_free(points);
    }else {
      hulldim= dim;
      new_points= points;
      new_ismalloc= ismalloc;
    }
    qh_init_B(qh, new_points, numpoints, hulldim, new_ismalloc);
    qh_qhull(qh);
    qh_check_output(qh);
    if (outfile) {
      qh_produce_output(qh);
    }else {
      qh_prepare_output(qh);
    }
    if (qh->VERIFYoutput && !qh->FORCEoutput && !qh->STOPadd && !qh->STOPcone && !qh->STOPpoint)
      qh_check_points(qh);
  }
  qh->NOerrexit= True;
  return exitcode;
} /* new_qhull */

/*---------------------------------

  qh_errexit(qh, exitcode, facet, ridge )
    report and exit from an error
    report facet and ridge if non-NULL
    reports useful information such as last point processed
    set qh.FORCEoutput to print neighborhood of facet

  see:
    qh_errexit2() in libqhull_r.c for printing 2 facets

  design:
    check for error within error processing
    compute qh.hulltime
    print facet and ridge (if any)
    report commandString, options, qh.furthest_id
    print summary and statistics (including precision statistics)
    if qh_ERRsingular
      print help text for singular data set
    exit program via long jump (if defined) or exit()
*/
void qh_errexit(qhT *qh, int exitcode, facetT *facet, ridgeT *ridge) {

  qh->tracefacet= NULL;  /* avoid infinite recursion through qh_fprintf */
  qh->traceridge= NULL;
  qh->tracevertex= NULL;
  if (qh->ERREXITcalled) {
    qh_fprintf(qh, qh->ferr, 8126, "\nqhull error while handling previous error in qh_errexit.  Exit program\n");
    qh_exit(qh_ERRother);
  }
  qh->ERREXITcalled= True;
  if (!qh->QHULLfinished)
    qh->hulltime= qh_CPUclock - qh->hulltime;
  qh_errprint(qh, "ERRONEOUS", facet, NULL, ridge, NULL);
  qh_option(qh, "_maxoutside", NULL, &qh->MAXoutside);
  qh_fprintf(qh, qh->ferr, 8127, "\nWhile executing: %s | %s\n", qh->rbox_command, qh->qhull_command);
  qh_fprintf(qh, qh->ferr, 8128, "Options selected for Qhull %s:\n%s\n", qh_version, qh->qhull_options);
  if (qh->furthest_id >= 0) {
    qh_fprintf(qh, qh->ferr, 8129, "Last point added to hull was p%d.", qh->furthest_id);
    if (zzval_(Ztotmerge))
      qh_fprintf(qh, qh->ferr, 8130, "  Last merge was #%d.", zzval_(Ztotmerge));
    if (qh->QHULLfinished)
      qh_fprintf(qh, qh->ferr, 8131, "\nQhull has finished constructing the hull.");
    else if (qh->POSTmerging)
      qh_fprintf(qh, qh->ferr, 8132, "\nQhull has started post-merging.");
    qh_fprintf(qh, qh->ferr, 8133, "\n");
  }
  if (qh->FORCEoutput && (qh->QHULLfinished || (!facet && !ridge)))
    qh_produce_output(qh);
  else if (exitcode != qh_ERRinput) {
    if (exitcode != qh_ERRsingular && zzval_(Zsetplane) > qh->hull_dim+1) {
      qh_fprintf(qh, qh->ferr, 8134, "\nAt error exit:\n");
      qh_printsummary(qh, qh->ferr);
      if (qh->PRINTstatistics) {
        qh_collectstatistics(qh);
        qh_allstatistics(qh);
        qh_printstatistics(qh, qh->ferr, "at error exit");
        qh_memstatistics(qh, qh->ferr);
      }
    }
    if (qh->PRINTprecision)
      qh_printstats(qh, qh->ferr, qh->qhstat.precision, NULL);
  }
  if (!exitcode)
    exitcode= qh_ERRother;
  else if (exitcode == qh_ERRprec && !qh->PREmerge)
    qh_printhelp_degenerate(qh, qh->ferr);
  else if (exitcode == qh_ERRqhull)
    qh_printhelp_internal(qh, qh->ferr);
  else if (exitcode == qh_ERRsingular)
    qh_printhelp_singular(qh, qh->ferr);
  else if (exitcode == qh_ERRdebug)
    qh_fprintf(qh, qh->ferr, 8016, "qhull exit due to qh_ERRdebug\n");
  else if (exitcode == qh_ERRtopology || exitcode == qh_ERRwide || exitcode == qh_ERRprec) {
    if (qh->NOpremerge && !qh->MERGING)
      qh_printhelp_degenerate(qh, qh->ferr);
    else if (exitcode == qh_ERRtopology)
      qh_printhelp_topology(qh, qh->ferr);
    else if (exitcode == qh_ERRwide)
      qh_printhelp_wide(qh, qh->ferr);
  }else if (exitcode > 255) {
    qh_fprintf(qh, qh->ferr, 6426, "qhull internal error (qh_errexit): exit code %d is greater than 255.  Invalid argument for exit().  Replaced with 255\n", exitcode);
    exitcode= 255;
  }
  if (qh->NOerrexit) {
    qh_fprintf(qh, qh->ferr, 6187, "qhull internal error (qh_errexit): either error while reporting error QH%d, or qh.NOerrexit not cleared after setjmp(). Exit program with error status %d\n",
         qh->last_errcode, exitcode);
    qh_exit(exitcode);
  }
  qh->ERREXITcalled= False;
  qh->NOerrexit= True;
  qh->ALLOWrestart= False;  /* longjmp will undo qh_build_withrestart */
  longjmp(qh->errexit, exitcode);
} /* errexit */

/*---------------------------------

  qh_errprint(qh, fp, string, atfacet, otherfacet, atridge, atvertex )
    prints out the information of facets and ridges to fp
    also prints neighbors and geomview output

  notes:
    except for string, any parameter may be NULL
*/
void qh_errprint(qhT *qh, const char *string, facetT *atfacet, facetT *otherfacet, ridgeT *atridge, vertexT *atvertex) {
  int i;

  if (atvertex) {
    qh_fprintf(qh, qh->ferr, 8138, "%s VERTEX:\n", string);
    qh_printvertex(qh, qh->ferr, atvertex);
  }
  if (atridge) {
    qh_fprintf(qh, qh->ferr, 8137, "%s RIDGE:\n", string);
    qh_printridge(qh, qh->ferr, atridge);
    if (!atfacet)
      atfacet= atridge->top;
    if (!otherfacet)
      otherfacet= otherfacet_(atridge, atfacet);
    if (atridge->top && atridge->top != atfacet && atridge->top != otherfacet)
      qh_printfacet(qh, qh->ferr, atridge->top);
    if (atridge->bottom && atridge->bottom != atfacet && atridge->bottom != otherfacet)
      qh_printfacet(qh, qh->ferr, atridge->bottom);
  }
  if (atfacet) {
    qh_fprintf(qh, qh->ferr, 8135, "%s FACET:\n", string);
    qh_printfacet(qh, qh->ferr, atfacet);
  }
  if (otherfacet) {
    qh_fprintf(qh, qh->ferr, 8136, "%s OTHER FACET:\n", string);
    qh_printfacet(qh, qh->ferr, otherfacet);
  }
  if (qh->fout && qh->FORCEoutput && atfacet && !qh->QHULLfinished && !qh->IStracing) {
    qh_fprintf(qh, qh->ferr, 8139, "ERRONEOUS and NEIGHBORING FACETS to output\n");
    for (i=0; i < qh_PRINTEND; i++)  /* use fout for geomview output */
      qh_printneighborhood(qh, qh->fout, qh->PRINTout[i], atfacet, otherfacet,
                            !qh_ALL);
  }
} /* errprint */


/*---------------------------------

  qh_printfacetlist(qh, fp, facetlist, facets, printall )
    print all fields for a facet list and/or set of facets to fp
    if !printall,
      only prints good facets

  notes:
    also prints all vertices
*/
void qh_printfacetlist(qhT *qh, facetT *facetlist, setT *facets, boolT printall) {
  facetT *facet, **facetp;

  if (facetlist)
    qh_checklists(qh, facetlist);
  qh_fprintf(qh, qh->ferr, 9424, "printfacetlist: vertices\n");
  qh_printbegin(qh, qh->ferr, qh_PRINTfacets, facetlist, facets, printall);
  if (facetlist) {
    qh_fprintf(qh, qh->ferr, 9413, "printfacetlist: facetlist\n");
    FORALLfacet_(facetlist)
      qh_printafacet(qh, qh->ferr, qh_PRINTfacets, facet, printall);
  }
  if (facets) {
    qh_fprintf(qh, qh->ferr, 9414, "printfacetlist: %d facets\n", qh_setsize(qh, facets));
    FOREACHfacet_(facets)
      qh_printafacet(qh, qh->ferr, qh_PRINTfacets, facet, printall);
  }
  qh_fprintf(qh, qh->ferr, 9412, "printfacetlist: end\n");
  qh_printend(qh, qh->ferr, qh_PRINTfacets, facetlist, facets, printall);
} /* printfacetlist */


/*---------------------------------

  qh_printhelp_degenerate(qh, fp )
    prints descriptive message for precision error with qh_ERRprec

  notes:
    no message if qh_QUICKhelp
*/
void qh_printhelp_degenerate(qhT *qh, FILE *fp) {

  if (qh->MERGEexact || qh->PREmerge || qh->JOGGLEmax < REALmax/2)
    qh_fprintf(qh, fp, 9368, "\n\
A Qhull error has occurred.  Qhull should have corrected the above\n\
precision error.  Please send the input and all of the output to\n\
qhull_bug@qhull.org\n");
  else if (!qh_QUICKhelp) {
    qh_fprintf(qh, fp, 9369, "\n\
Precision problems were detected during construction of the convex hull.\n\
This occurs because convex hull algorithms assume that calculations are\n\
exact, but floating-point arithmetic has roundoff errors.\n\
\n\
To correct for precision problems, do not use 'Q0'.  By default, Qhull\n\
selects 'C-0' or 'Qx' and merges non-convex facets.  With option 'QJ',\n\
Qhull joggles the input to prevent precision problems.  See \"Imprecision\n\
in Qhull\" (qh-impre.htm).\n\
\n\
If you use 'Q0', the output may include\n\
coplanar ridges, concave ridges, and flipped facets.  In 4-d and higher,\n\
Qhull may produce a ridge with four neighbors or two facets with the same \n\
vertices.  Qhull reports these events when they occur.  It stops when a\n\
concave ridge, flipped facet, or duplicate facet occurs.\n");
#if REALfloat
    qh_fprintf(qh, fp, 9370, "\
\n\
Qhull is currently using single precision arithmetic.  The following\n\
will probably remove the precision problems:\n\
  - recompile qhull for realT precision(#define REALfloat 0 in user_r.h).\n");
#endif
    if (qh->DELAUNAY && !qh->SCALElast && qh->MAXabs_coord > 1e4)
      qh_fprintf(qh, fp, 9371, "\
\n\
When computing the Delaunay triangulation of coordinates > 1.0,\n\
  - use 'Qbb' to scale the last coordinate to [0,m] (max previous coordinate)\n");
    if (qh->DELAUNAY && !qh->ATinfinity)
      qh_fprintf(qh, fp, 9372, "\
When computing the Delaunay triangulation:\n\
  - use 'Qz' to add a point at-infinity.  This reduces precision problems.\n");

    qh_fprintf(qh, fp, 9373, "\
\n\
If you need triangular output:\n\
  - use option 'Qt' to triangulate the output\n\
  - use option 'QJ' to joggle the input points and remove precision errors\n\
  - use option 'Ft'.  It triangulates non-simplicial facets with added points.\n\
\n\
If you must use 'Q0',\n\
try one or more of the following options.  They can not guarantee an output.\n\
  - use 'QbB' to scale the input to a cube.\n\
  - use 'Po' to produce output and prevent partitioning for flipped facets\n\
  - use 'V0' to set min. distance to visible facet as 0 instead of roundoff\n\
  - use 'En' to specify a maximum roundoff error less than %2.2g.\n\
  - options 'Qf', 'Qbb', and 'QR0' may also help\n",
               qh->DISTround);
    qh_fprintf(qh, fp, 9374, "\
\n\
To guarantee simplicial output:\n\
  - use option 'Qt' to triangulate the output\n\
  - use option 'QJ' to joggle the input points and remove precision errors\n\
  - use option 'Ft' to triangulate the output by adding points\n\
  - use exact arithmetic (see \"Imprecision in Qhull\", qh-impre.htm)\n\
");
  }
} /* printhelp_degenerate */

/*---------------------------------

  qh_printhelp_internal(qh, fp )
    prints descriptive message for qhull internal error with qh_ERRqhull

  notes:
    no message if qh_QUICKhelp
*/
void qh_printhelp_internal(qhT *qh, FILE *fp) {

  if (!qh_QUICKhelp) {
    qh_fprintf(qh, fp, 9426, "\n\
A Qhull internal error has occurred.  Please send the input and output to\n\
qhull_bug@qhull.org. If you can duplicate the error with logging ('T4z'), please\n\
include the log file.\n");
  }
} /* printhelp_internal */

/*---------------------------------

  qh_printhelp_narrowhull(qh, minangle )
    Warn about a narrow hull

  notes:
    Alternatively, reduce qh_WARNnarrow in user_r.h

*/
void qh_printhelp_narrowhull(qhT *qh, FILE *fp, realT minangle) {

    qh_fprintf(qh, fp, 7089, "qhull precision warning: The initial hull is narrow.  Is the input lower\n\
dimensional (e.g., a square in 3-d instead of a cube)?  Cosine of the minimum\n\
angle is %.16f.  If so, Qhull may produce a wide facet.\n\
Options 'Qs' (search all points), 'Qbb' (scale last coordinate), or\n\
'QbB' (scale to unit box) may remove this warning.\n\
See 'Limitations' in qh-impre.htm.  Use 'Pp' to skip this warning.\n",
          -minangle);   /* convert from angle between normals to angle between facets */
} /* printhelp_narrowhull */

/*---------------------------------

  qh_printhelp_singular(qh, fp )
    prints descriptive message for singular input
*/
void qh_printhelp_singular(qhT *qh, FILE *fp) {
  facetT *facet;
  vertexT *vertex, **vertexp;
  realT min, max, *coord, dist;
  int i,k;

  qh_fprintf(qh, fp, 9376, "\n\
The input to qhull appears to be less than %d dimensional, or a\n\
computation has overflowed.\n\n\
Qhull could not construct a clearly convex simplex from points:\n",
           qh->hull_dim);
  qh_printvertexlist(qh, fp, "", qh->facet_list, NULL, qh_ALL);
  if (!qh_QUICKhelp)
    qh_fprintf(qh, fp, 9377, "\n\
The center point is coplanar with a facet, or a vertex is coplanar\n\
with a neighboring facet.  The maximum round off error for\n\
computing distances is %2.2g.  The center point, facets and distances\n\
to the center point are as follows:\n\n", qh->DISTround);
  qh_printpointid(qh, fp, "center point", qh->hull_dim, qh->interior_point, qh_IDunknown);
  qh_fprintf(qh, fp, 9378, "\n");
  FORALLfacets {
    qh_fprintf(qh, fp, 9379, "facet");
    FOREACHvertex_(facet->vertices)
      qh_fprintf(qh, fp, 9380, " p%d", qh_pointid(qh, vertex->point));
    zinc_(Zdistio);
    qh_distplane(qh, qh->interior_point, facet, &dist);
    qh_fprintf(qh, fp, 9381, " distance= %4.2g\n", dist);
  }
  if (!qh_QUICKhelp) {
    if (qh->HALFspace)
      qh_fprintf(qh, fp, 9382, "\n\
These points are the dual of the given halfspaces.  They indicate that\n\
the intersection is degenerate.\n");
    qh_fprintf(qh, fp, 9383,"\n\
These points either have a maximum or minimum x-coordinate, or\n\
they maximize the determinant for k coordinates.  Trial points\n\
are first selected from points that maximize a coordinate.\n");
    if (qh->hull_dim >= qh_INITIALmax)
      qh_fprintf(qh, fp, 9384, "\n\
Because of the high dimension, the min x-coordinate and max-coordinate\n\
points are used if the determinant is non-zero.  Option 'Qs' will\n\
do a better, though much slower, job.  Instead of 'Qs', you can change\n\
the points by randomly rotating the input with 'QR0'.\n");
  }
  qh_fprintf(qh, fp, 9385, "\nThe min and max coordinates for each dimension are:\n");
  for (k=0; k < qh->hull_dim; k++) {
    min= REALmax;
    max= -REALmin;
    for (i=qh->num_points, coord= qh->first_point+k; i--; coord += qh->hull_dim) {
      maximize_(max, *coord);
      minimize_(min, *coord);
    }
    qh_fprintf(qh, fp, 9386, "  %d:  %8.4g  %8.4g  difference= %4.4g\n", k, min, max, max-min);
  }
  if (!qh_QUICKhelp) {
    qh_fprintf(qh, fp, 9387, "\n\
If the input should be full dimensional, you have several options that\n\
may determine an initial simplex:\n\
  - use 'QJ'  to joggle the input and make it full dimensional\n\
  - use 'QbB' to scale the points to the unit cube\n\
  - use 'QR0' to randomly rotate the input for different maximum points\n\
  - use 'Qs'  to search all points for the initial simplex\n\
  - use 'En'  to specify a maximum roundoff error less than %2.2g.\n\
  - trace execution with 'T3' to see the determinant for each point.\n",
                     qh->DISTround);
#if REALfloat
    qh_fprintf(qh, fp, 9388, "\
  - recompile qhull for realT precision(#define REALfloat 0 in libqhull_r.h).\n");
#endif
    qh_fprintf(qh, fp, 9389, "\n\
If the input is lower dimensional:\n\
  - use 'QJ' to joggle the input and make it full dimensional\n\
  - use 'Qbk:0Bk:0' to delete coordinate k from the input.  You should\n\
    pick the coordinate with the least range.  The hull will have the\n\
    correct topology.\n\
  - determine the flat containing the points, rotate the points\n\
    into a coordinate plane, and delete the other coordinates.\n\
  - add one or more points to make the input full dimensional.\n\
");
  }
} /* printhelp_singular */

/*---------------------------------

  qh_printhelp_topology(qh, fp )
    prints descriptive message for qhull topology error with qh_ERRtopology

  notes:
    no message if qh_QUICKhelp
*/
void qh_printhelp_topology(qhT *qh, FILE *fp) {

  if (!qh_QUICKhelp) {
    qh_fprintf(qh, fp, 9427, "\n\
A Qhull topology error has occurred.  Qhull did not recover from facet merges and vertex merges.\n\
This usually occurs when the input is nearly degenerate and substantial merging has occurred.\n\
See http://www.qhull.org/html/qh-impre.htm#limit\n");
  }
} /* printhelp_topology */

/*---------------------------------

  qh_printhelp_wide(qh, fp )
    prints descriptive message for qhull wide facet with qh_ERRwide

  notes:
    no message if qh_QUICKhelp
*/
void qh_printhelp_wide(qhT *qh, FILE *fp) {

  if (!qh_QUICKhelp) {
    qh_fprintf(qh, fp, 9428, "\n\
A wide merge error has occurred.  Qhull has produced a wide facet due to facet merges and vertex merges.\n\
This usually occurs when the input is nearly degenerate and substantial merging has occurred.\n\
See http://www.qhull.org/html/qh-impre.htm#limit\n");
  }
} /* printhelp_wide */

/*---------------------------------

  qh_user_memsizes(qh)
    allocate up to 10 additional, quick allocation sizes

  notes:
    increase maximum number of allocations in qh_initqhull_mem()
*/
void qh_user_memsizes(qhT *qh) {

  QHULL_UNUSED(qh)
  /* qh_memsize(qh, size); */
} /* user_memsizes */


geometry/src/poly_r.h0000644000176200001440000003003314664417655014372 0ustar  liggesusers/*
  ---------------------------------

   poly_r.h
   header file for poly_r.c and poly2_r.c

   see qh-poly_r.htm, libqhull_r.h and poly_r.c

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/poly_r.h#5 $$Change: 2963 $
   $DateTime: 2020/06/03 19:31:01 $$Author: bbarber $
*/

#ifndef qhDEFpoly
#define qhDEFpoly 1

#include "libqhull_r.h"

/*===============   constants ========================== */

/*----------------------------------

  qh_ALGORITHMfault
    use as argument to checkconvex() to report errors during buildhull
*/
#define qh_ALGORITHMfault 0

/*----------------------------------

  qh_DATAfault
    use as argument to checkconvex() to report errors during initialhull
*/
#define qh_DATAfault 1

/*----------------------------------

  qh_DUPLICATEridge
    special value for facet->neighbor to indicate a duplicate ridge

  notes:
    set by qh_matchneighbor for qh_matchdupridge
*/
#define qh_DUPLICATEridge (facetT *)1L

/*----------------------------------

  qh_MERGEridge       flag in facet
    special value for facet->neighbor to indicate a duplicate ridge that needs merging

  notes:
    set by qh_matchnewfacets..qh_matchdupridge from qh_DUPLICATEridge
    used by qh_mark_dupridges to set facet->mergeridge, facet->mergeridge2 from facet->dupridge
*/
#define qh_MERGEridge (facetT *)2L


/*============ -structures- ====================*/

/*=========== -macros- =========================*/

/*----------------------------------

  FORALLfacet_( facetlist ) { ... }
    assign 'facet' to each facet in facetlist

  notes:
    uses 'facetT *facet;'
    assumes last facet is a sentinel

  see:
    FORALLfacets
*/
#define FORALLfacet_( facetlist ) if (facetlist) for ( facet=(facetlist); facet && facet->next; facet= facet->next )

/*----------------------------------

  FORALLnew_facets { ... }
    assign 'newfacet' to each facet in qh.newfacet_list

  notes:
    uses 'facetT *newfacet;'
    at exit, newfacet==NULL
*/
#define FORALLnew_facets for ( newfacet=qh->newfacet_list; newfacet && newfacet->next; newfacet=newfacet->next )

/*----------------------------------

  FORALLvertex_( vertexlist ) { ... }
    assign 'vertex' to each vertex in vertexlist

  notes:
    uses 'vertexT *vertex;'
    at exit, vertex==NULL
*/
#define FORALLvertex_( vertexlist ) for (vertex=( vertexlist );vertex && vertex->next;vertex= vertex->next )

/*----------------------------------

  FORALLvisible_facets { ... }
    assign 'visible' to each visible facet in qh.visible_list

  notes:
    uses 'vacetT *visible;'
    at exit, visible==NULL
*/
#define FORALLvisible_facets for (visible=qh->visible_list; visible && visible->visible; visible= visible->next)

/*----------------------------------

  FORALLsame_( newfacet ) { ... }
    assign 'same' to each facet in newfacet->f.samecycle

  notes:
    uses 'facetT *same;'
    stops when it returns to newfacet
*/
#define FORALLsame_(newfacet) for (same= newfacet->f.samecycle; same != newfacet; same= same->f.samecycle)

/*----------------------------------

  FORALLsame_cycle_( newfacet ) { ... }
    assign 'same' to each facet in newfacet->f.samecycle

  notes:
    uses 'facetT *same;'
    at exit, same == NULL
*/
#define FORALLsame_cycle_(newfacet) \
     for (same= newfacet->f.samecycle; \
         same; same= (same == newfacet ?  NULL : same->f.samecycle))

/*----------------------------------

  FOREACHneighborA_( facet ) { ... }
    assign 'neighborA' to each neighbor in facet->neighbors

  FOREACHneighborA_( vertex ) { ... }
    assign 'neighborA' to each neighbor in vertex->neighbors

  declare:
    facetT *neighborA, **neighborAp;

  see:
    FOREACHsetelement_
*/
#define FOREACHneighborA_(facet)  FOREACHsetelement_(facetT, facet->neighbors, neighborA)

/*----------------------------------

  FOREACHvisible_( facets ) { ... }
    assign 'visible' to each facet in facets

  notes:
    uses 'facetT *facet, *facetp;'
    see FOREACHsetelement_
*/
#define FOREACHvisible_(facets) FOREACHsetelement_(facetT, facets, visible)

/*----------------------------------

  FOREACHnewfacet_( facets ) { ... }
    assign 'newfacet' to each facet in facets

  notes:
    uses 'facetT *newfacet, *newfacetp;'
    see FOREACHsetelement_
*/
#define FOREACHnewfacet_(facets) FOREACHsetelement_(facetT, facets, newfacet)

/*----------------------------------

  FOREACHvertexA_( vertices ) { ... }
    assign 'vertexA' to each vertex in vertices

  notes:
    uses 'vertexT *vertexA, *vertexAp;'
    see FOREACHsetelement_
*/
#define FOREACHvertexA_(vertices) FOREACHsetelement_(vertexT, vertices, vertexA)

/*----------------------------------

  FOREACHvertexreverse12_( vertices ) { ... }
    assign 'vertex' to each vertex in vertices
    reverse order of first two vertices

  notes:
    uses 'vertexT *vertex, *vertexp;'
    see FOREACHsetelement_
*/
#define FOREACHvertexreverse12_(vertices) FOREACHsetelementreverse12_(vertexT, vertices, vertex)


/*=============== prototypes poly_r.c in alphabetical order ================*/

#ifdef __cplusplus
extern "C" {
#endif

void    qh_appendfacet(qhT *qh, facetT *facet);
void    qh_appendvertex(qhT *qh, vertexT *vertex);
void    qh_attachnewfacets(qhT *qh /* qh.visible_list, qh.newfacet_list */);
boolT   qh_checkflipped(qhT *qh, facetT *facet, realT *dist, boolT allerror);
void    qh_delfacet(qhT *qh, facetT *facet);
void    qh_deletevisible(qhT *qh /* qh.visible_list, qh.horizon_list */);
setT   *qh_facetintersect(qhT *qh, facetT *facetA, facetT *facetB, int *skipAp,int *skipBp, int extra);
int     qh_gethash(qhT *qh, int hashsize, setT *set, int size, int firstindex, void *skipelem);
facetT *qh_getreplacement(qhT *qh, facetT *visible);
facetT *qh_makenewfacet(qhT *qh, setT *vertices, boolT toporient, facetT *facet);
void    qh_makenewplanes(qhT *qh /* qh.newfacet_list */);
facetT *qh_makenew_nonsimplicial(qhT *qh, facetT *visible, vertexT *apex, int *numnew);
facetT *qh_makenew_simplicial(qhT *qh, facetT *visible, vertexT *apex, int *numnew);
void    qh_matchneighbor(qhT *qh, facetT *newfacet, int newskip, int hashsize,
                          int *hashcount);
coordT  qh_matchnewfacets(qhT *qh);
boolT   qh_matchvertices(qhT *qh, int firstindex, setT *verticesA, int skipA,
                          setT *verticesB, int *skipB, boolT *same);
facetT *qh_newfacet(qhT *qh);
ridgeT *qh_newridge(qhT *qh);
int     qh_pointid(qhT *qh, pointT *point);
void    qh_removefacet(qhT *qh, facetT *facet);
void    qh_removevertex(qhT *qh, vertexT *vertex);
void    qh_update_vertexneighbors(qhT *qh);
void    qh_update_vertexneighbors_cone(qhT *qh);


/*========== -prototypes poly2_r.c in alphabetical order ===========*/

boolT   qh_addfacetvertex(qhT *qh, facetT *facet, vertexT *newvertex);
void    qh_addhash(void *newelem, setT *hashtable, int hashsize, int hash);
void    qh_check_bestdist(qhT *qh);
void    qh_check_maxout(qhT *qh);
void    qh_check_output(qhT *qh);
void    qh_check_point(qhT *qh, pointT *point, facetT *facet, realT *maxoutside, realT *maxdist, facetT **errfacet1, facetT **errfacet2, int *errcount);
void    qh_check_points(qhT *qh);
void    qh_checkconvex(qhT *qh, facetT *facetlist, int fault);
void    qh_checkfacet(qhT *qh, facetT *facet, boolT newmerge, boolT *waserrorp);
void    qh_checkflipped_all(qhT *qh, facetT *facetlist);
boolT   qh_checklists(qhT *qh, facetT *facetlist);
void    qh_checkpolygon(qhT *qh, facetT *facetlist);
void    qh_checkvertex(qhT *qh, vertexT *vertex, boolT allchecks, boolT *waserrorp);
void    qh_clearcenters(qhT *qh, qh_CENTER type);
void    qh_createsimplex(qhT *qh, setT *vertices);
void    qh_delridge(qhT *qh, ridgeT *ridge);
void    qh_delvertex(qhT *qh, vertexT *vertex);
setT   *qh_facet3vertex(qhT *qh, facetT *facet);
facetT *qh_findbestfacet(qhT *qh, pointT *point, boolT bestoutside,
           realT *bestdist, boolT *isoutside);
facetT *qh_findbestlower(qhT *qh, facetT *upperfacet, pointT *point, realT *bestdistp, int *numpart);
facetT *qh_findfacet_all(qhT *qh, pointT *point, boolT noupper, realT *bestdist, boolT *isoutside,
                          int *numpart);
int     qh_findgood(qhT *qh, facetT *facetlist, int goodhorizon);
void    qh_findgood_all(qhT *qh, facetT *facetlist);
void    qh_furthestnext(qhT *qh /* qh.facet_list */);
void    qh_furthestout(qhT *qh, facetT *facet);
void    qh_infiniteloop(qhT *qh, facetT *facet);
void    qh_initbuild(qhT *qh);
void    qh_initialhull(qhT *qh, setT *vertices);
setT   *qh_initialvertices(qhT *qh, int dim, setT *maxpoints, pointT *points, int numpoints);
vertexT *qh_isvertex(pointT *point, setT *vertices);
vertexT *qh_makenewfacets(qhT *qh, pointT *point /* qh.horizon_list, visible_list */);
coordT  qh_matchdupridge(qhT *qh, facetT *atfacet, int atskip, int hashsize, int *hashcount);
void    qh_nearcoplanar(qhT *qh /* qh.facet_list */);
vertexT *qh_nearvertex(qhT *qh, facetT *facet, pointT *point, realT *bestdistp);
int     qh_newhashtable(qhT *qh, int newsize);
vertexT *qh_newvertex(qhT *qh, pointT *point);
facetT *qh_nextfacet2d(facetT *facet, vertexT **nextvertexp);
ridgeT *qh_nextridge3d(ridgeT *atridge, facetT *facet, vertexT **vertexp);
vertexT *qh_opposite_vertex(qhT *qh, facetT *facetA,  facetT *neighbor);
void    qh_outcoplanar(qhT *qh /* qh.facet_list */);
pointT *qh_point(qhT *qh, int id);
void    qh_point_add(qhT *qh, setT *set, pointT *point, void *elem);
setT   *qh_pointfacet(qhT *qh /* qh.facet_list */);
setT   *qh_pointvertex(qhT *qh /* qh.facet_list */);
void    qh_prependfacet(qhT *qh, facetT *facet, facetT **facetlist);
void    qh_printhashtable(qhT *qh, FILE *fp);
void    qh_printlists(qhT *qh);
void    qh_replacefacetvertex(qhT *qh, facetT *facet, vertexT *oldvertex, vertexT *newvertex);
void    qh_resetlists(qhT *qh, boolT stats, boolT resetVisible /* qh.newvertex_list qh.newfacet_list qh.visible_list */);
void    qh_setvoronoi_all(qhT *qh);
void    qh_triangulate(qhT *qh /* qh.facet_list */);
void    qh_triangulate_facet(qhT *qh, facetT *facetA, vertexT **first_vertex);
void    qh_triangulate_link(qhT *qh, facetT *oldfacetA, facetT *facetA, facetT *oldfacetB, facetT *facetB);
void    qh_triangulate_mirror(qhT *qh, facetT *facetA, facetT *facetB);
void    qh_triangulate_null(qhT *qh, facetT *facetA);
void    qh_vertexintersect(qhT *qh, setT **vertexsetA,setT *vertexsetB);
setT   *qh_vertexintersect_new(qhT *qh, setT *vertexsetA,setT *vertexsetB);
void    qh_vertexneighbors(qhT *qh /* qh.facet_list */);
boolT   qh_vertexsubset(setT *vertexsetA, setT *vertexsetB);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* qhDEFpoly */
geometry/src/usermem_r.c0000644000176200001440000000604414664417655015064 0ustar  liggesusers/*
  ---------------------------------

   usermem_r.c
   user redefinable functions -- qh_exit, qh_free, and qh_malloc

   See README.txt.

   If you redefine one of these functions you must redefine all of them.
   If you recompile and load this file, then usermem.o will not be loaded
   from qhull.a or qhull.lib

   See libqhull_r.h for data structures, macros, and user-callable functions.
   See user_r.c for qhull-related, redefinable functions
   see user_r.h for user-definable constants
   See userprintf_r.c for qh_fprintf and userprintf_rbox_r.c for qh_fprintf_rbox

   Please report any errors that you fix to qhull@qhull.org
*/

#include "libqhull_r.h"

#include 
#include 

/*---------------------------------

  qh_exit( exitcode )
    exit program
    the exitcode must be 255 or less.  Zero indicates success.
    Note: Exit status ('$?') in bash reports 256 as 0

  notes:
    qh_exit() is called when qh_errexit() and longjmp() are not available.

    This is the only use of exit() in Qhull
    To replace qh_exit with 'throw', see libqhullcpp/usermem_r-cpp.cpp
*/
void qh_exit(int exitcode) {
    /* CHANGE TO SOURCE: The commented line below is the original. It
     needs to be replaced to fix warnings about exit being called. --
     David Sterratt 3/4/12. */
    /* exit(exitcode); */
    Rf_error("Qhull exit, code %i", exitcode);
} /* exit */

/*---------------------------------

  qh_fprintf_stderr( msgcode, format, list of args )
    fprintf to stderr with msgcode (non-zero)

  notes:
    qh_fprintf_stderr() is called when qh.ferr is not defined, usually due to an initialization error
    if msgcode is a MSG_ERROR (6000), caller should set qh.last_errcode (like qh_fprintf) or variable 'last_errcode'
    
    It is typically followed by qh_errexit().

    Redefine this function to avoid using stderr

    Use qh_fprintf [userprintf_r.c] for normal printing
*/
void qh_fprintf_stderr(int msgcode, const char *fmt, ... ) {
    va_list args;

    va_start(args, fmt);
    if(msgcode)
      /* CHANGE TO SOURCE */
      /* fprintf(stderr, "QH%.4d ", msgcode); */
      REprintf("QH%.4d", msgcode);
    /* CHANGE TO SOURCE */
    /* vfprintf(stderr, fmt, args); */
    REvprintf(fmt, args);
    va_end(args);
} /* fprintf_stderr */

/*---------------------------------

  qh_free(qh, mem )
    free memory

  notes:
    same as free()
    No calls to qh_errexit() 
*/
void qh_free(void *mem) {
    free(mem);
} /* free */

/*---------------------------------

    qh_malloc( mem )
      allocate memory

    notes:
      same as malloc()
*/
void *qh_malloc(size_t size) {
    return malloc(size);
} /* malloc */


geometry/src/rboxlib_r.c0000644000176200001440000006304114664417655015050 0ustar  liggesusers/*
  ---------------------------------

   rboxlib_r.c
     Generate input points

   notes:
     For documentation, see prompt[] of rbox_r.c
     50 points generated for 'rbox D4'

   WARNING:
     incorrect range if qh_RANDOMmax is defined wrong (user_r.h)
*/

#include "libqhull_r.h"  /* First for user_r.h */
#include "random_r.h"

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#ifdef _MSC_VER  /* Microsoft Visual C++ */
#pragma warning( disable : 4706)  /* assignment within conditional expression. */
#pragma warning( disable : 4996)  /* this function (strncat,sprintf,strcpy) or variable may be unsafe. */
#endif

#define MAXdim 200
#define PI 3.1415926535897932384

/* ------------------------------ prototypes ----------------*/
int qh_roundi(qhT *qh, double a);
void qh_out1(qhT *qh, double a);
void qh_out2n(qhT *qh, double a, double b);
void qh_out3n(qhT *qh, double a, double b, double c);
void qh_outcoord(qhT *qh, int iscdd, double *coord, int dim);
void qh_outcoincident(qhT *qh, int coincidentpoints, double radius, int iscdd, double *coord, int dim);
void qh_rboxpoints2(qhT *qh, char* rbox_command, double **simplex);

void    qh_fprintf_rbox(qhT *qh, FILE *fp, int msgcode, const char *fmt, ... );
void    qh_free(void *mem);
void   *qh_malloc(size_t size);
int     qh_rand(qhT *qh);
void    qh_srand(qhT *qh, int seed);

/*---------------------------------

  qh_rboxpoints(qh, rbox_command )
    Generate points to qh.fout according to rbox options
    Report errors on qh.ferr

  returns:
    0 (qh_ERRnone) on success
    1 (qh_ERRinput) on input error
    4 (qh_ERRmem) on memory error
    5 (qh_ERRqhull) on internal error

  notes:
    To avoid using stdio, redefine qh_malloc, qh_free, and qh_fprintf_rbox (user_r.c)
    Split out qh_rboxpoints2() to avoid -Wclobbered

  design:
    Straight line code (consider defining a struct and functions):

    Parse arguments into variables
    Determine the number of points
    Generate the points
*/
int qh_rboxpoints(qhT *qh, char* rbox_command) {
  int exitcode;
  double *simplex;

  simplex= NULL;
  exitcode= setjmp(qh->rbox_errexit);
  if (exitcode) {
    /* same code for error exit and normal return.  qh.NOerrexit is set */
    if (simplex)
      qh_free(simplex);
    return exitcode;
  }
  qh_rboxpoints2(qh, rbox_command, &simplex);
  /* same code for error exit and normal return */
  if (simplex)
    qh_free(simplex);
  return qh_ERRnone;
} /* rboxpoints */

void qh_rboxpoints2(qhT *qh, char* rbox_command, double **simplex) {
  int i,j,k;
  int gendim;
  int coincidentcount=0, coincidenttotal=0, coincidentpoints=0;
  int cubesize, diamondsize, seed=0, count, apex;
  int dim=3, numpoints=0, totpoints, addpoints=0;
  int issphere=0, isaxis=0,  iscdd=0, islens=0, isregular=0, iswidth=0, addcube=0;
  int isgap=0, isspiral=0, NOcommand=0, adddiamond=0;
  int israndom=0, istime=0;
  int isbox=0, issimplex=0, issimplex2=0, ismesh=0;
  double width=0.0, gap=0.0, radius=0.0, coincidentradius=0.0;
  double coord[MAXdim], offset, meshm=3.0, meshn=4.0, meshr=5.0;
  double *coordp, *simplexp;
  int nthroot, mult[MAXdim];
  double norm, factor, randr, rangap, tempr, lensangle=0, lensbase=1;
  double anglediff, angle, x, y, cube=0.0, diamond=0.0;
  double box= qh_DEFAULTbox; /* scale all numbers before output */
  double randmax= qh_RANDOMmax;
  char command[250], seedbuf[50];
  char *s=command, *t, *first_point=NULL;
  time_t timedata;

  *command= '\0';
  strncat(command, rbox_command, sizeof(command)-sizeof(seedbuf)-strlen(command)-1);

  while (*s && !isspace(*s))  /* skip program name */
    s++;
  while (*s) {
    while (*s && isspace(*s))
      s++;
    if (*s == '-')
      s++;
    if (!*s)
      break;
    if (isdigit(*s)) {
      numpoints= qh_strtol(s, &s);
      continue;
    }
    /* ============= read flags =============== */
    switch (*s++) {
    case 'c':
      addcube= 1;
      t= s;
      while (isspace(*t))
        t++;
      if (*t == 'G')
        cube= qh_strtod(++t, &s);
      break;
    case 'd':
      adddiamond= 1;
      t= s;
      while (isspace(*t))
        t++;
      if (*t == 'G')
        diamond= qh_strtod(++t, &s);
      break;
    case 'h':
      iscdd= 1;
      break;
    case 'l':
      isspiral= 1;
      break;
    case 'n':
      NOcommand= 1;
      break;
    case 'r':
      isregular= 1;
      break;
    case 's':
      issphere= 1;
      break;
    case 't':
      istime= 1;
      if (isdigit(*s)) {
        seed= qh_strtol(s, &s);
        israndom= 0;
      }else
        israndom= 1;
      break;
    case 'x':
      issimplex= 1;
      break;
    case 'y':
      issimplex2= 1;
      break;
    case 'z':
      qh->rbox_isinteger= 1;
      break;
    case 'B':
      box= qh_strtod(s, &s);
      isbox= 1;
      break;
    case 'C':
      if (*s)
        coincidentpoints=  qh_strtol(s, &s);
      if (*s == ',') {
        ++s;
        coincidentradius=  qh_strtod(s, &s);
      }
      if (*s == ',') {
        ++s;
        coincidenttotal=  qh_strtol(s, &s);
      }
      if (*s && !isspace(*s)) {
        qh_fprintf_rbox(qh, qh->ferr, 7080, "rbox error: arguments for 'Cn,r,m' are not 'int', 'float', and 'int'.  Remaining string is '%s'\n", s);
        qh_errexit_rbox(qh, qh_ERRinput);
      }
      if (coincidentpoints==0){
        qh_fprintf_rbox(qh, qh->ferr, 6268, "rbox error: missing arguments for 'Cn,r,m' where n is the number of coincident points, r is the radius (default 0.0), and m is the number of points\n");
        qh_errexit_rbox(qh, qh_ERRinput);
      }
      if (coincidentpoints<0 || coincidenttotal<0 || coincidentradius<0.0){
        qh_fprintf_rbox(qh, qh->ferr, 6269, "rbox error: negative arguments for 'Cn,m,r' where n (%d) is the number of coincident points, m (%d) is the number of points, and r (%.2g) is the radius (default 0.0)\n", coincidentpoints, coincidenttotal, coincidentradius);
        qh_errexit_rbox(qh, qh_ERRinput);
      }
      break;
    case 'D':
      dim= qh_strtol(s, &s);
      if (dim < 1
      || dim > MAXdim) {
        qh_fprintf_rbox(qh, qh->ferr, 6189, "rbox error: dimension, D%d, out of bounds (>=%d or <=0)\n", dim, MAXdim);
        qh_errexit_rbox(qh, qh_ERRinput);
      }
      break;
    case 'G':
      if (isdigit(*s))
        gap= qh_strtod(s, &s);
      else
        gap= 0.5;
      isgap= 1;
      break;
    case 'L':
      if (isdigit(*s))
        radius= qh_strtod(s, &s);
      else
        radius= 10;
      islens= 1;
      break;
    case 'M':
      ismesh= 1;
      if (*s)
        meshn= qh_strtod(s, &s);
      if (*s == ',') {
        ++s;
        meshm= qh_strtod(s, &s);
      }else
        meshm= 0.0;
      if (*s == ',') {
        ++s;
        meshr= qh_strtod(s, &s);
      }else
        meshr= sqrt(meshn*meshn + meshm*meshm);
      if (*s && !isspace(*s)) {
        qh_fprintf_rbox(qh, qh->ferr, 7069, "rbox warning: assuming 'M3,4,5' since mesh args are not integers or reals\n");
        meshn= 3.0, meshm=4.0, meshr=5.0;
      }
      break;
    case 'O':
      qh->rbox_out_offset= qh_strtod(s, &s);
      break;
    case 'P':
      if (!first_point)
        first_point= s - 1;
      addpoints++;
      while (*s && !isspace(*s))   /* read points later */
        s++;
      break;
    case 'W':
      width= qh_strtod(s, &s);
      iswidth= 1;
      break;
    case 'Z':
      if (isdigit(*s))
        radius= qh_strtod(s, &s);
      else
        radius= 1.0;
      isaxis= 1;
      break;
    default:
      qh_fprintf_rbox(qh, qh->ferr, 6352, "rbox error: unknown flag at '%s'.\nExecute 'rbox' without arguments for documentation.\n", s - 1);
      qh_errexit_rbox(qh, qh_ERRinput);
    }
    if (*s && !isspace(*s)) {
      qh_fprintf_rbox(qh, qh->ferr, 6353, "rbox error: missing space between flags at %s.\n", s);
      qh_errexit_rbox(qh, qh_ERRinput);
    }
  }

  /* ============= defaults, constants, and sizes =============== */
  if (qh->rbox_isinteger && !isbox)
    box= qh_DEFAULTzbox;
  if (addcube) {
    tempr= floor(ldexp(1.0,dim)+0.5);
    cubesize= (int)tempr;
    if (cube == 0.0)
      cube= box;
  }else
    cubesize= 0;
  if (adddiamond) {
    diamondsize= 2*dim;
    if (diamond == 0.0)
      diamond= box;
  }else
    diamondsize= 0;
  if (islens) {
    if (isaxis) {
        qh_fprintf_rbox(qh, qh->ferr, 6190, "rbox error: can not combine 'Ln' with 'Zn'\n");
        qh_errexit_rbox(qh, qh_ERRinput);
    }
    if (radius <= 1.0) {
        qh_fprintf_rbox(qh, qh->ferr, 6191, "rbox error: lens radius %.2g should be greater than 1.0\n",
               radius);
        qh_errexit_rbox(qh, qh_ERRinput);
    }
    lensangle= asin(1.0/radius);
    lensbase= radius * cos(lensangle);
  }

  if (!numpoints) {
    if (issimplex2)
        ; /* ok */
    else if (isregular + issimplex + islens + issphere + isaxis + isspiral + iswidth + ismesh) {
        qh_fprintf_rbox(qh, qh->ferr, 6192, "rbox error: missing count\n");
        qh_errexit_rbox(qh, qh_ERRinput);
    }else if (adddiamond + addcube + addpoints)
        ; /* ok */
    else {
        numpoints= 50;  /* ./rbox D4 is the test case */
        issphere= 1;
    }
  }
  if ((issimplex + islens + isspiral + ismesh > 1)
  || (issimplex + issphere + isspiral + ismesh > 1)) {
    qh_fprintf_rbox(qh, qh->ferr, 6193, "rbox error: can only specify one of 'l', 's', 'x', 'Ln', or 'Mn,m,r' ('Ln s' is ok).\n");
    qh_errexit_rbox(qh, qh_ERRinput);
  }
  if (coincidentpoints>0 && (numpoints == 0 || coincidenttotal > numpoints)) {
    qh_fprintf_rbox(qh, qh->ferr, 6270, "rbox error: 'Cn,r,m' requested n coincident points for each of m points.  Either there is no points or m (%d) is greater than the number of points (%d).\n", coincidenttotal, numpoints);
    qh_errexit_rbox(qh, qh_ERRinput);
  }
  if (coincidentpoints > 0 && isregular) {
    qh_fprintf_rbox(qh, qh->ferr, 6423, "rbox error: 'Cn,r,m' is not implemented for regular points ('r')\n");
    qh_errexit_rbox(qh, qh_ERRinput);
  }

  if (coincidenttotal == 0)
    coincidenttotal= numpoints;

  /* ============= print header with total points =============== */
  if (issimplex || ismesh)
    totpoints= numpoints;
  else if (issimplex2)
    totpoints= numpoints+dim+1;
  else if (isregular) {
    totpoints= numpoints;
    if (dim == 2) {
        if (islens)
          totpoints += numpoints - 2;
    }else if (dim == 3) {
        if (islens)
          totpoints += 2 * numpoints;
      else if (isgap)
        totpoints += 1 + numpoints;
      else
        totpoints += 2;
    }
  }else
    totpoints= numpoints + isaxis;
  totpoints += cubesize + diamondsize + addpoints;
  totpoints += coincidentpoints*coincidenttotal;

  /* ============= seed randoms =============== */
  if (istime == 0) {
    for (s=command; *s; s++) {
      if (issimplex2 && *s == 'y') /* make 'y' same seed as 'x' */
        i= 'x';
      else
        i= *s;
      seed= 11*seed + i;
    }
  }else if (israndom) {
    seed= (int)time(&timedata);
    snprintf(seedbuf, 22, " t%d", seed);  /* appends an extra t, not worth removing */
    strncat(command, seedbuf, sizeof(command) - strlen(command) - 1);
    t= strstr(command, " t ");
    if (t)
      strcpy(t+1, t+3); /* remove " t " */
  } /* else, seed explicitly set to n */
  qh_RANDOMseed_(qh, seed);

  /* ============= print header =============== */

  if (iscdd)
      qh_fprintf_rbox(qh, qh->fout, 9391, "%s\nbegin\n        %d %d %s\n",
      NOcommand ? "" : command,
      totpoints, dim+1,
      qh->rbox_isinteger ? "integer" : "real");
  else if (NOcommand)
      qh_fprintf_rbox(qh, qh->fout, 9392, "%d\n%d\n", dim, totpoints);
  else
      /* qh_fprintf_rbox special cases 9393 to append 'command' to the RboxPoints.comment() */
      qh_fprintf_rbox(qh, qh->fout, 9393, "%d %s\n%d\n", dim, command, totpoints);

  /* ============= explicit points =============== */
  if ((s= first_point)) {
    while (s && *s) { /* 'P' */
      count= 0;
      if (iscdd)
        qh_out1(qh, 1.0);
      while (*++s) {
        qh_out1(qh, qh_strtod(s, &s));
        count++;
        if (isspace(*s) || !*s)
          break;
        if (*s != ',') {
          qh_fprintf_rbox(qh, qh->ferr, 6194, "rbox error: missing comma after coordinate in %s\n\n", s);
          qh_errexit_rbox(qh, qh_ERRinput);
        }
      }
      if (count < dim) {
        for (k=dim-count; k--; )
          qh_out1(qh, 0.0);
      }else if (count > dim) {
        qh_fprintf_rbox(qh, qh->ferr, 6195, "rbox error: %d coordinates instead of %d coordinates in %s\n\n",
                  count, dim, s);
        qh_errexit_rbox(qh, qh_ERRinput);
      }
      qh_fprintf_rbox(qh, qh->fout, 9394, "\n");
      while ((s= strchr(s, 'P'))) {
        if (isspace(s[-1]))
          break;
      }
    }
  }

  /* ============= simplex distribution =============== */
  if (issimplex+issimplex2) {
    if (!(*simplex= (double *)qh_malloc( (size_t)(dim * (dim+1)) * sizeof(double)))) {
      qh_fprintf_rbox(qh, qh->ferr, 6196, "rbox error: insufficient memory for simplex\n");
      qh_errexit_rbox(qh, qh_ERRmem); /* qh_ERRmem */
    }
    simplexp= *simplex;
    if (isregular) {
      for (i=0; ifout, 9395, "\n");
      }
    }
    for (j=0; jferr, 6197, "rbox error: regular points can be used only in 2-d and 3-d\n\n");
      qh_errexit_rbox(qh, qh_ERRinput);
    }
    if (!isaxis || radius == 0.0) {
      isaxis= 1;
      radius= 1.0;
    }
    if (dim == 3) {
      if (iscdd)
        qh_out1(qh, 1.0);
      qh_out3n(qh, 0.0, 0.0, -box);
      if (!isgap) {
        if (iscdd)
          qh_out1(qh, 1.0);
        qh_out3n(qh, 0.0, 0.0, box);
      }
    }
    angle= 0.0;
    anglediff= 2.0 * PI/numpoints;
    for (i=0; i < numpoints; i++) {
      angle += anglediff;
      x= radius * cos(angle);
      y= radius * sin(angle);
      if (dim == 2) {
        if (iscdd)
          qh_out1(qh, 1.0);
        qh_out2n(qh, x*box, y*box);
      }else {
        norm= sqrt(1.0 + x*x + y*y);
        if (iscdd)
          qh_out1(qh, 1.0);
        qh_out3n(qh, box*x/norm, box*y/norm, box/norm);
        if (isgap) {
          x *= 1-gap;
          y *= 1-gap;
          norm= sqrt(1.0 + x*x + y*y);
          if (iscdd)
            qh_out1(qh, 1.0);
          qh_out3n(qh, box*x/norm, box*y/norm, box/norm);
        }
      }
    }
  }
  /* ============= regular points for 'r Ln D2' =============== */
  else if (isregular && islens && dim == 2) {
    double cos_0;

    angle= lensangle;
    anglediff= 2 * lensangle/(numpoints - 1);
    cos_0= cos(lensangle);
    for (i=0; i < numpoints; i++, angle -= anglediff) {
      x= radius * sin(angle);
      y= radius * (cos(angle) - cos_0);
      if (iscdd)
        qh_out1(qh, 1.0);
      qh_out2n(qh, x*box, y*box);
      if (i != 0 && i != numpoints - 1) {
        if (iscdd)
          qh_out1(qh, 1.0);
        qh_out2n(qh, x*box, -y*box);
      }
    }
  }
  /* ============= regular points for 'r Ln D3' =============== */
  else if (isregular && islens && dim != 2) {
    if (dim != 3) {
      qh_fprintf_rbox(qh, qh->ferr, 6198, "rbox error: regular points can be used only in 2-d and 3-d\n\n");
      qh_errexit_rbox(qh, qh_ERRinput);
    }
    angle= 0.0;
    anglediff= 2* PI/numpoints;
    if (!isgap) {
      isgap= 1;
      gap= 0.5;
    }
    offset= sqrt(radius * radius - (1-gap)*(1-gap)) - lensbase;
    for (i=0; i < numpoints; i++, angle += anglediff) {
      x= cos(angle);
      y= sin(angle);
      if (iscdd)
        qh_out1(qh, 1.0);
      qh_out3n(qh, box*x, box*y, 0.0);
      x *= 1-gap;
      y *= 1-gap;
      if (iscdd)
        qh_out1(qh, 1.0);
      qh_out3n(qh, box*x, box*y, box * offset);
      if (iscdd)
        qh_out1(qh, 1.0);
      qh_out3n(qh, box*x, box*y, -box * offset);
    }
  }
  /* ============= apex of 'Zn' distribution + gendim =============== */
  else {
    if (isaxis) {
      gendim= dim-1;
      if (iscdd)
        qh_out1(qh, 1.0);
      for (j=0; j < gendim; j++)
        qh_out1(qh, 0.0);
      qh_out1(qh, -box);
      qh_fprintf_rbox(qh, qh->fout, 9398, "\n");
    }else if (islens)
      gendim= dim-1;
    else
      gendim= dim;
    /* ============= generate random point in unit cube =============== */
    for (i=0; i < numpoints; i++) {
      norm= 0.0;
      for (j=0; j < gendim; j++) {
        randr= qh_RANDOMint;
        coord[j]= 2.0 * randr/randmax - 1.0;
        norm += coord[j] * coord[j];
      }
      norm= sqrt(norm);
      /* ============= dim-1 point of 'Zn' distribution ========== */
      if (isaxis) {
        if (!isgap) {
          isgap= 1;
          gap= 1.0;
        }
        randr= qh_RANDOMint;
        rangap= 1.0 - gap * randr/randmax;
        factor= radius * rangap / norm;
        for (j=0; jferr, 6199, "rbox error: spiral distribution is available only in 3d\n\n");
          qh_errexit_rbox(qh, qh_ERRinput);
        }
        coord[0]= cos(2*PI*i/(numpoints - 1));
        coord[1]= sin(2*PI*i/(numpoints - 1));
        coord[2]= 2.0*(double)i/(double)(numpoints - 1) - 1.0;
      /* ============= point of 's' distribution =============== */
      }else if (issphere) {
        factor= 1.0/norm;
        if (iswidth) {
          randr= qh_RANDOMint;
          factor *= 1.0 - width * randr/randmax;
        }
        for (j=0; j randmax/2)
          coord[dim-1]= -coord[dim-1];
      /* ============= project 'Wn' point toward boundary =============== */
      }else if (iswidth && !issphere) {
        j= qh_RANDOMint % gendim;
        if (coord[j] < 0)
          coord[j]= -1.0 - coord[j] * width;
        else
          coord[j]= 1.0 - coord[j] * width;
      }
      /* ============= scale point to box =============== */
      for (k=0; k=0; k--) {
        if (j & ( 1 << k))
          qh_out1(qh, cube);
        else
          qh_out1(qh, -cube);
      }
      qh_fprintf_rbox(qh, qh->fout, 9400, "\n");
    }
  }

  /* ============= write diamond vertices =============== */
  if (adddiamond) {
    for (j=0; j=0; k--) {
        if (j/2 != k)
          qh_out1(qh, 0.0);
        else if (j & 0x1)
          qh_out1(qh, diamond);
        else
          qh_out1(qh, -diamond);
      }
      qh_fprintf_rbox(qh, qh->fout, 9401, "\n");
    }
  }

  if (iscdd)
    qh_fprintf_rbox(qh, qh->fout, 9402, "end\nhull\n");
} /* rboxpoints2 */

/*------------------------------------------------
outxxx - output functions for qh_rboxpoints
*/
int qh_roundi(qhT *qh, double a) {
  if (a < 0.0) {
    if (a - 0.5 < INT_MIN) {
      qh_fprintf_rbox(qh, qh->ferr, 6200, "rbox input error: negative coordinate %2.2g is too large.  Reduce 'Bn'\n", a);
      qh_errexit_rbox(qh, qh_ERRinput);
    }
    return (int)(a - 0.5);
  }else {
    if (a + 0.5 > INT_MAX) {
      qh_fprintf_rbox(qh, qh->ferr, 6201, "rbox input error: coordinate %2.2g is too large.  Reduce 'Bn'\n", a);
      qh_errexit_rbox(qh, qh_ERRinput);
    }
    return (int)(a + 0.5);
  }
} /* qh_roundi */

void qh_out1(qhT *qh, double a) {

  if (qh->rbox_isinteger)
    qh_fprintf_rbox(qh, qh->fout, 9403, "%d ", qh_roundi(qh, a+qh->rbox_out_offset));
  else
    qh_fprintf_rbox(qh, qh->fout, 9404, qh_REAL_1, a+qh->rbox_out_offset);
} /* qh_out1 */

void qh_out2n(qhT *qh, double a, double b) {

  if (qh->rbox_isinteger)
    qh_fprintf_rbox(qh, qh->fout, 9405, "%d %d\n", qh_roundi(qh, a+qh->rbox_out_offset), qh_roundi(qh, b+qh->rbox_out_offset));
  else
    qh_fprintf_rbox(qh, qh->fout, 9406, qh_REAL_2n, a+qh->rbox_out_offset, b+qh->rbox_out_offset);
} /* qh_out2n */

void qh_out3n(qhT *qh, double a, double b, double c) {

  if (qh->rbox_isinteger)
    qh_fprintf_rbox(qh, qh->fout, 9407, "%d %d %d\n", qh_roundi(qh, a+qh->rbox_out_offset), qh_roundi(qh, b+qh->rbox_out_offset), qh_roundi(qh, c+qh->rbox_out_offset));
  else
    qh_fprintf_rbox(qh, qh->fout, 9408, qh_REAL_3n, a+qh->rbox_out_offset, b+qh->rbox_out_offset, c+qh->rbox_out_offset);
} /* qh_out3n */

void qh_outcoord(qhT *qh, int iscdd, double *coord, int dim) {
    double *p= coord;
    int k;

    if (iscdd)
      qh_out1(qh, 1.0);
    for (k=0; k < dim; k++)
      qh_out1(qh, *(p++));
    qh_fprintf_rbox(qh, qh->fout, 9396, "\n");
} /* qh_outcoord */

void qh_outcoincident(qhT *qh, int coincidentpoints, double radius, int iscdd, double *coord, int dim) {
  double *p;
  double randr, delta;
  int i,k;
  double randmax= qh_RANDOMmax;

  for (i=0; ifout, 9410, "\n");
  }
} /* qh_outcoincident */

/*------------------------------------------------
   Only called from qh_rboxpoints2 or qh_fprintf_rbox
   qh_fprintf_rbox is only called from qh_rboxpoints2
   The largest exitcode is '255' for compatibility with exit()
*/
void qh_errexit_rbox(qhT *qh, int exitcode)
{
    longjmp(qh->rbox_errexit, exitcode);
} /* qh_errexit_rbox */

geometry/src/poly_r.c0000644000176200001440000015042214664417655014372 0ustar  liggesusers/*
  ---------------------------------

   poly_r.c
   implements polygons and simplices

   see qh-poly_r.htm, poly_r.h and libqhull_r.h

   infrequent code is in poly2_r.c
   (all but top 50 and their callers 12/3/95)

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/poly_r.c#8 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#include "qhull_ra.h"

/*======== functions in alphabetical order ==========*/

/*---------------------------------

  qh_appendfacet(qh, facet )
    appends facet to end of qh.facet_list,

  returns:
    updates qh.newfacet_list, facet_next, facet_list
    increments qh.numfacets

  notes:
    assumes qh.facet_list/facet_tail is defined (createsimplex)

  see:
    qh_removefacet()

*/
void qh_appendfacet(qhT *qh, facetT *facet) {
  facetT *tail= qh->facet_tail;

  if (tail == qh->newfacet_list) {
    qh->newfacet_list= facet;
    if (tail == qh->visible_list) /* visible_list is at or before newfacet_list */
      qh->visible_list= facet;
  }
  if (tail == qh->facet_next)
    qh->facet_next= facet;
  facet->previous= tail->previous;
  facet->next= tail;
  if (tail->previous)
    tail->previous->next= facet;
  else
    qh->facet_list= facet;
  tail->previous= facet;
  qh->num_facets++;
  trace4((qh, qh->ferr, 4044, "qh_appendfacet: append f%d to facet_list\n", facet->id));
} /* appendfacet */


/*---------------------------------

  qh_appendvertex(qh, vertex )
    appends vertex to end of qh.vertex_list,

  returns:
    sets vertex->newfacet
    updates qh.vertex_list, newvertex_list
    increments qh.num_vertices

  notes:
    assumes qh.vertex_list/vertex_tail is defined (createsimplex)

*/
void qh_appendvertex(qhT *qh, vertexT *vertex) {
  vertexT *tail= qh->vertex_tail;

  if (tail == qh->newvertex_list)
    qh->newvertex_list= vertex;
  vertex->newfacet= True;
  vertex->previous= tail->previous;
  vertex->next= tail;
  if (tail->previous)
    tail->previous->next= vertex;
  else
    qh->vertex_list= vertex;
  tail->previous= vertex;
  qh->num_vertices++;
  trace4((qh, qh->ferr, 4045, "qh_appendvertex: append v%d to qh.newvertex_list and set v.newfacet\n", vertex->id));
} /* appendvertex */


/*---------------------------------

  qh_attachnewfacets(qh)
    attach horizon facets to new facets in qh.newfacet_list
    newfacets have neighbor and ridge links to horizon but not vice versa

  returns:
    clears qh.NEWtentative
    set qh.NEWfacets
    horizon facets linked to new facets
      ridges changed from visible facets to new facets
      simplicial ridges deleted
    qh.visible_list, no ridges valid
    facet->f.replace is a newfacet (if any)

  notes:
    used for qh.NEWtentative, otherwise see qh_makenew_nonsimplicial and qh_makenew_simplicial
    qh_delridge_merge not needed (as tested by qh_checkdelridge)

  design:
    delete interior ridges and neighbor sets by
      for each visible, non-simplicial facet
        for each ridge
          if last visit or if neighbor is simplicial
            if horizon neighbor
              delete ridge for horizon's ridge set
            delete ridge
        erase neighbor set
    attach horizon facets and new facets by
      for all new facets
        if corresponding horizon facet is simplicial
          locate corresponding visible facet {may be more than one}
          link visible facet to new facet
          replace visible facet with new facet in horizon
        else it is non-simplicial
          for all visible neighbors of the horizon facet
            link visible neighbor to new facet
            delete visible neighbor from horizon facet
          append new facet to horizon's neighbors
          the first ridge of the new facet is the horizon ridge
          link the new facet into the horizon ridge
*/
void qh_attachnewfacets(qhT *qh /* qh.visible_list, qh.newfacet_list */) {
  facetT *newfacet= NULL, *neighbor, **neighborp, *horizon, *visible;
  ridgeT *ridge, **ridgep;

  trace3((qh, qh->ferr, 3012, "qh_attachnewfacets: delete interior ridges\n"));
  if (qh->CHECKfrequently) {
    qh_checkdelridge(qh);
  }
  qh->visit_id++;
  FORALLvisible_facets {
    visible->visitid= qh->visit_id;
    if (visible->ridges) {
      FOREACHridge_(visible->ridges) {
        neighbor= otherfacet_(ridge, visible);
        if (neighbor->visitid == qh->visit_id
            || (!neighbor->visible && neighbor->simplicial)) {
          if (!neighbor->visible)  /* delete ridge for simplicial horizon */
            qh_setdel(neighbor->ridges, ridge);
          qh_delridge(qh, ridge); /* delete on second visit */
        }
      }
    }
  }
  trace1((qh, qh->ferr, 1017, "qh_attachnewfacets: attach horizon facets to new facets\n"));
  FORALLnew_facets {
    horizon= SETfirstt_(newfacet->neighbors, facetT);
    if (horizon->simplicial) {
      visible= NULL;
      FOREACHneighbor_(horizon) {   /* may have more than one horizon ridge */
        if (neighbor->visible) {
          if (visible) {
            if (qh_setequal_skip(newfacet->vertices, 0, horizon->vertices,
                                  SETindex_(horizon->neighbors, neighbor))) {
              visible= neighbor;
              break;
            }
          }else
            visible= neighbor;
        }
      }
      if (visible) {
        visible->f.replace= newfacet;
        qh_setreplace(qh, horizon->neighbors, visible, newfacet);
      }else {
        qh_fprintf(qh, qh->ferr, 6102, "qhull internal error (qh_attachnewfacets): could not find visible facet for horizon f%d of newfacet f%d\n",
                 horizon->id, newfacet->id);
        qh_errexit2(qh, qh_ERRqhull, horizon, newfacet);
      }
    }else { /* non-simplicial, with a ridge for newfacet */
      FOREACHneighbor_(horizon) {    /* may hold for many new facets */
        if (neighbor->visible) {
          neighbor->f.replace= newfacet;
          qh_setdelnth(qh, horizon->neighbors, SETindex_(horizon->neighbors, neighbor));
          neighborp--; /* repeat */
        }
      }
      qh_setappend(qh, &horizon->neighbors, newfacet);
      ridge= SETfirstt_(newfacet->ridges, ridgeT);
      if (ridge->top == horizon) {
        ridge->bottom= newfacet;
        ridge->simplicialbot= True;
      }else {
        ridge->top= newfacet;
        ridge->simplicialtop= True;
      }
    }
  } /* newfacets */
  trace4((qh, qh->ferr, 4094, "qh_attachnewfacets: clear f.ridges and f.neighbors for visible facets, may become invalid before qh_deletevisible\n"));
  FORALLvisible_facets {
    if (visible->ridges)
      SETfirst_(visible->ridges)= NULL; 
    SETfirst_(visible->neighbors)= NULL;
  }
  qh->NEWtentative= False;
  qh->NEWfacets= True;
  if (qh->PRINTstatistics) {
    FORALLvisible_facets {
      if (!visible->f.replace)
        zinc_(Zinsidevisible);
    }
  }
} /* attachnewfacets */

/*---------------------------------

  qh_checkflipped(qh, facet, dist, allerror )
    checks facet orientation to interior point

    if allerror set,
      tests against -qh.DISTround
    else
      tests against 0.0 since tested against -qh.DISTround before

  returns:
    False if it flipped orientation (sets facet->flipped)
    distance if non-NULL

  notes:
    called by qh_setfacetplane, qh_initialhull, and qh_checkflipped_all
*/
boolT qh_checkflipped(qhT *qh, facetT *facet, realT *distp, boolT allerror) {
  realT dist;

  if (facet->flipped && !distp)
    return False;
  zzinc_(Zdistcheck);
  qh_distplane(qh, qh->interior_point, facet, &dist);
  if (distp)
    *distp= dist;
  if ((allerror && dist >= -qh->DISTround) || (!allerror && dist > 0.0)) {
    facet->flipped= True;
    trace0((qh, qh->ferr, 19, "qh_checkflipped: facet f%d flipped, allerror? %d, distance= %6.12g during p%d\n",
              facet->id, allerror, dist, qh->furthest_id));
    if (qh->num_facets > qh->hull_dim+1) { /* qh_initialhull reverses orientation if !qh_checkflipped */
      zzinc_(Zflippedfacets);
      qh_joggle_restart(qh, "flipped facet");
    }
    return False;
  }
  return True;
} /* checkflipped */

/*---------------------------------

  qh_delfacet(qh, facet )
    removes facet from facet_list and frees up its memory

  notes:
    assumes vertices and ridges already freed or referenced elsewhere
*/
void qh_delfacet(qhT *qh, facetT *facet) {
  void **freelistp; /* used if !qh_NOmem by qh_memfree_() */

  trace3((qh, qh->ferr, 3057, "qh_delfacet: delete f%d\n", facet->id));
  if (qh->CHECKfrequently || qh->VERIFYoutput) { 
    if (!qh->NOerrexit) {
      qh_checkdelfacet(qh, facet, qh->facet_mergeset);
      qh_checkdelfacet(qh, facet, qh->degen_mergeset);
      qh_checkdelfacet(qh, facet, qh->vertex_mergeset);
    }
  }
  if (facet == qh->tracefacet)
    qh->tracefacet= NULL;
  if (facet == qh->GOODclosest)
    qh->GOODclosest= NULL;
  qh_removefacet(qh, facet);
  if (!facet->tricoplanar || facet->keepcentrum) {
    qh_memfree_(qh, facet->normal, qh->normal_size, freelistp);
    if (qh->CENTERtype == qh_ASvoronoi) {   /* braces for macro calls */
      qh_memfree_(qh, facet->center, qh->center_size, freelistp);
    }else /* AScentrum */ {
      qh_memfree_(qh, facet->center, qh->normal_size, freelistp);
    }
  }
  qh_setfree(qh, &(facet->neighbors));
  if (facet->ridges)
    qh_setfree(qh, &(facet->ridges));
  qh_setfree(qh, &(facet->vertices));
  if (facet->outsideset)
    qh_setfree(qh, &(facet->outsideset));
  if (facet->coplanarset)
    qh_setfree(qh, &(facet->coplanarset));
  qh_memfree_(qh, facet, (int)sizeof(facetT), freelistp);
} /* delfacet */


/*---------------------------------

  qh_deletevisible()
    delete visible facets and vertices

  returns:
    deletes each facet and removes from facetlist
    deletes vertices on qh.del_vertices and ridges in qh.del_ridges
    at exit, qh.visible_list empty (== qh.newfacet_list)

  notes:
    called by qh_all_vertexmerges, qh_addpoint, and qh_qhull
    ridges already deleted or moved elsewhere
    deleted vertices on qh.del_vertices
    horizon facets do not reference facets on qh.visible_list
    new facets in qh.newfacet_list
    uses   qh.visit_id;
*/
void qh_deletevisible(qhT *qh /* qh.visible_list */) {
  facetT *visible, *nextfacet;
  vertexT *vertex, **vertexp;
  int numvisible= 0, numdel= qh_setsize(qh, qh->del_vertices);

  trace1((qh, qh->ferr, 1018, "qh_deletevisible: delete %d visible facets and %d vertices\n",
         qh->num_visible, numdel));
  for (visible=qh->visible_list; visible && visible->visible;
                visible= nextfacet) { /* deleting current */
    nextfacet= visible->next;
    numvisible++;
    qh_delfacet(qh, visible);  /* f.ridges deleted or moved elsewhere, deleted f.vertices on qh.del_vertices */
  }
  if (numvisible != qh->num_visible) {
    qh_fprintf(qh, qh->ferr, 6103, "qhull internal error (qh_deletevisible): qh->num_visible %d is not number of visible facets %d\n",
             qh->num_visible, numvisible);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  qh->num_visible= 0;
  zadd_(Zvisfacettot, numvisible);
  zmax_(Zvisfacetmax, numvisible);
  zzadd_(Zdelvertextot, numdel);
  zmax_(Zdelvertexmax, numdel);
  FOREACHvertex_(qh->del_vertices)
    qh_delvertex(qh, vertex);
  qh_settruncate(qh, qh->del_vertices, 0);
} /* deletevisible */

/*---------------------------------

  qh_facetintersect(qh, facetA, facetB, skipa, skipB, prepend )
    return vertices for intersection of two simplicial facets
    may include 1 prepended entry (if more, need to settemppush)

  returns:
    returns set of qh.hull_dim-1 + prepend vertices
    returns skipped index for each test and checks for exactly one

  notes:
    does not need settemp since set in quick memory

  see also:
    qh_vertexintersect and qh_vertexintersect_new
    use qh_setnew_delnthsorted to get nth ridge (no skip information)

  design:
    locate skipped vertex by scanning facet A's neighbors
    locate skipped vertex by scanning facet B's neighbors
    intersect the vertex sets
*/
setT *qh_facetintersect(qhT *qh, facetT *facetA, facetT *facetB,
                         int *skipA,int *skipB, int prepend) {
  setT *intersect;
  int dim= qh->hull_dim, i, j;
  facetT **neighborsA, **neighborsB;

  neighborsA= SETaddr_(facetA->neighbors, facetT);
  neighborsB= SETaddr_(facetB->neighbors, facetT);
  i= j= 0;
  if (facetB == *neighborsA++)
    *skipA= 0;
  else if (facetB == *neighborsA++)
    *skipA= 1;
  else if (facetB == *neighborsA++)
    *skipA= 2;
  else {
    for (i=3; i < dim; i++) {
      if (facetB == *neighborsA++) {
        *skipA= i;
        break;
      }
    }
  }
  if (facetA == *neighborsB++)
    *skipB= 0;
  else if (facetA == *neighborsB++)
    *skipB= 1;
  else if (facetA == *neighborsB++)
    *skipB= 2;
  else {
    for (j=3; j < dim; j++) {
      if (facetA == *neighborsB++) {
        *skipB= j;
        break;
      }
    }
  }
  if (i >= dim || j >= dim) {
    qh_fprintf(qh, qh->ferr, 6104, "qhull internal error (qh_facetintersect): f%d or f%d not in other's neighbors\n",
            facetA->id, facetB->id);
    qh_errexit2(qh, qh_ERRqhull, facetA, facetB);
  }
  intersect= qh_setnew_delnthsorted(qh, facetA->vertices, qh->hull_dim, *skipA, prepend);
  trace4((qh, qh->ferr, 4047, "qh_facetintersect: f%d skip %d matches f%d skip %d\n",
          facetA->id, *skipA, facetB->id, *skipB));
  return(intersect);
} /* facetintersect */

/*---------------------------------

  qh_gethash(qh, hashsize, set, size, firstindex, skipelem )
    return hashvalue for a set with firstindex and skipelem

  notes:
    returned hash is in [0,hashsize)
    assumes at least firstindex+1 elements
    assumes skipelem is NULL, in set, or part of hash

    hashes memory addresses which may change over different runs of the same data
    using sum for hash does badly in high d
*/
int qh_gethash(qhT *qh, int hashsize, setT *set, int size, int firstindex, void *skipelem) {
  void **elemp= SETelemaddr_(set, firstindex, void);
  ptr_intT hash= 0, elem;
  unsigned int uresult;
  int i;
#ifdef _MSC_VER                   /* Microsoft Visual C++ -- warn about 64-bit issues */
#pragma warning( push)            /* WARN64 -- ptr_intT holds a 64-bit pointer */
#pragma warning( disable : 4311)  /* 'type cast': pointer truncation from 'void*' to 'ptr_intT' */
#endif

  switch (size-firstindex) {
  case 1:
    hash= (ptr_intT)(*elemp) - (ptr_intT) skipelem;
    break;
  case 2:
    hash= (ptr_intT)(*elemp) + (ptr_intT)elemp[1] - (ptr_intT) skipelem;
    break;
  case 3:
    hash= (ptr_intT)(*elemp) + (ptr_intT)elemp[1] + (ptr_intT)elemp[2]
      - (ptr_intT) skipelem;
    break;
  case 4:
    hash= (ptr_intT)(*elemp) + (ptr_intT)elemp[1] + (ptr_intT)elemp[2]
      + (ptr_intT)elemp[3] - (ptr_intT) skipelem;
    break;
  case 5:
    hash= (ptr_intT)(*elemp) + (ptr_intT)elemp[1] + (ptr_intT)elemp[2]
      + (ptr_intT)elemp[3] + (ptr_intT)elemp[4] - (ptr_intT) skipelem;
    break;
  case 6:
    hash= (ptr_intT)(*elemp) + (ptr_intT)elemp[1] + (ptr_intT)elemp[2]
      + (ptr_intT)elemp[3] + (ptr_intT)elemp[4]+ (ptr_intT)elemp[5]
      - (ptr_intT) skipelem;
    break;
  default:
    hash= 0;
    i= 3;
    do {     /* this is about 10% in 10-d */
      if ((elem= (ptr_intT)*elemp++) != (ptr_intT)skipelem) {
        hash ^= (elem << i) + (elem >> (32-i));
        i += 3;
        if (i >= 32)
          i -= 32;
      }
    }while (*elemp);
    break;
  }
  if (hashsize<0) {
    qh_fprintf(qh, qh->ferr, 6202, "qhull internal error: negative hashsize %d passed to qh_gethash [poly_r.c]\n", hashsize);
    qh_errexit2(qh, qh_ERRqhull, NULL, NULL);
  }
  uresult= (unsigned int)hash;
  uresult %= (unsigned int)hashsize;
  /* result= 0; for debugging */
  return (int)uresult;
#ifdef _MSC_VER
#pragma warning( pop)
#endif
} /* gethash */

/*---------------------------------

  qh_getreplacement(qh, visible )
    get replacement for visible facet

  returns:
    valid facet from visible.replace (may be chained)
*/
facetT *qh_getreplacement(qhT *qh, facetT *visible) {
  unsigned int count= 0;

  facetT *result= visible;
  while (result && result->visible) {
    result= result->f.replace;
    if (count++ > qh->facet_id)
      qh_infiniteloop(qh, visible);
  }
  return result;
}

/*---------------------------------

  qh_makenewfacet(qh, vertices, toporient, horizon )
    creates a toporient? facet from vertices

  returns:
    returns newfacet
      adds newfacet to qh.facet_list
      newfacet->vertices= vertices
      if horizon
        newfacet->neighbor= horizon, but not vice versa
    newvertex_list updated with vertices
*/
facetT *qh_makenewfacet(qhT *qh, setT *vertices, boolT toporient, facetT *horizon) {
  facetT *newfacet;
  vertexT *vertex, **vertexp;

  FOREACHvertex_(vertices) {
    if (!vertex->newfacet) {
      qh_removevertex(qh, vertex);
      qh_appendvertex(qh, vertex);
    }
  }
  newfacet= qh_newfacet(qh);
  newfacet->vertices= vertices;
  if (toporient)
    newfacet->toporient= True;
  if (horizon)
    qh_setappend(qh, &(newfacet->neighbors), horizon);
  qh_appendfacet(qh, newfacet);
  return(newfacet);
} /* makenewfacet */


/*---------------------------------

  qh_makenewplanes()
    make new hyperplanes for facets on qh.newfacet_list

  returns:
    all facets have hyperplanes or are marked for   merging
    doesn't create hyperplane if horizon is coplanar (will merge)
    updates qh.min_vertex if qh.JOGGLEmax

  notes:
    facet->f.samecycle is defined for facet->mergehorizon facets
*/
void qh_makenewplanes(qhT *qh /* qh.newfacet_list */) {
  facetT *newfacet;

  trace4((qh, qh->ferr, 4074, "qh_makenewplanes: make new hyperplanes for facets on qh.newfacet_list f%d\n",
    qh->newfacet_list->id));
  FORALLnew_facets {
    if (!newfacet->mergehorizon)
      qh_setfacetplane(qh, newfacet); /* updates Wnewvertexmax */
  }
  if (qh->JOGGLEmax < REALmax/2)
    minimize_(qh->min_vertex, -wwval_(Wnewvertexmax));
} /* makenewplanes */

#ifndef qh_NOmerge
/*---------------------------------

  qh_makenew_nonsimplicial(qh, visible, apex, numnew )
    make new facets for ridges of a visible facet

  returns:
    first newfacet, bumps numnew as needed
    attaches new facets if !qh->NEWtentative
    marks ridge neighbors for simplicial visible
    if (qh.NEWtentative)
      ridges on newfacet, horizon, and visible
    else
      ridge and neighbors between newfacet and horizon
      visible facet's ridges are deleted
      visible facet's f.neighbors is empty

  notes:
    called by qh_makenewfacets and qh_triangulatefacet
    qh.visit_id if visible has already been processed
    sets neighbor->seen for building f.samecycle
      assumes all 'seen' flags initially false
    qh_delridge_merge not needed (as tested by qh_checkdelridge in qh_makenewfacets)

  design:
    for each ridge of visible facet
      get neighbor of visible facet
      if neighbor was already processed
        delete the ridge (will delete all visible facets later)
      if neighbor is a horizon facet
        create a new facet
        if neighbor coplanar
          adds newfacet to f.samecycle for later merging
        else
          updates neighbor's neighbor set
          (checks for non-simplicial facet with multiple ridges to visible facet)
        updates neighbor's ridge set
        (checks for simplicial neighbor to non-simplicial visible facet)
        (deletes ridge if neighbor is simplicial)

*/
facetT *qh_makenew_nonsimplicial(qhT *qh, facetT *visible, vertexT *apex, int *numnew) {
  void **freelistp; /* used if !qh_NOmem by qh_memfree_() */
  ridgeT *ridge, **ridgep;
  facetT *neighbor, *newfacet= NULL, *samecycle;
  setT *vertices;
  boolT toporient;
  unsigned int ridgeid;

  FOREACHridge_(visible->ridges) {
    ridgeid= ridge->id;
    neighbor= otherfacet_(ridge, visible);
    if (neighbor->visible) {
      if (!qh->NEWtentative) {
        if (neighbor->visitid == qh->visit_id) {
          if (qh->traceridge == ridge)
            qh->traceridge= NULL;
          qh_setfree(qh, &(ridge->vertices));  /* delete on 2nd visit */
          qh_memfree_(qh, ridge, (int)sizeof(ridgeT), freelistp);
        }
      }
    }else {  /* neighbor is an horizon facet */
      toporient= (ridge->top == visible);
      vertices= qh_setnew(qh, qh->hull_dim); /* makes sure this is quick */
      qh_setappend(qh, &vertices, apex);
      qh_setappend_set(qh, &vertices, ridge->vertices);
      newfacet= qh_makenewfacet(qh, vertices, toporient, neighbor);
      (*numnew)++;
      if (neighbor->coplanarhorizon) {
        newfacet->mergehorizon= True;
        if (!neighbor->seen) {
          newfacet->f.samecycle= newfacet;
          neighbor->f.newcycle= newfacet;
        }else {
          samecycle= neighbor->f.newcycle;
          newfacet->f.samecycle= samecycle->f.samecycle;
          samecycle->f.samecycle= newfacet;
        }
      }
      if (qh->NEWtentative) {
        if (!neighbor->simplicial)
          qh_setappend(qh, &(newfacet->ridges), ridge);
      }else {  /* qh_attachnewfacets */
        if (neighbor->seen) {
          if (neighbor->simplicial) {
            qh_fprintf(qh, qh->ferr, 6105, "qhull internal error (qh_makenew_nonsimplicial): simplicial f%d sharing two ridges with f%d\n",
                   neighbor->id, visible->id);
            qh_errexit2(qh, qh_ERRqhull, neighbor, visible);
          }
          qh_setappend(qh, &(neighbor->neighbors), newfacet);
        }else
          qh_setreplace(qh, neighbor->neighbors, visible, newfacet);
        if (neighbor->simplicial) {
          qh_setdel(neighbor->ridges, ridge);
          qh_delridge(qh, ridge);
        }else {
          qh_setappend(qh, &(newfacet->ridges), ridge);
          if (toporient) {
            ridge->top= newfacet;
            ridge->simplicialtop= True;
          }else {
            ridge->bottom= newfacet;
            ridge->simplicialbot= True;
          }
        }
      }
      trace4((qh, qh->ferr, 4048, "qh_makenew_nonsimplicial: created facet f%d from v%d and r%d of horizon f%d\n",
          newfacet->id, apex->id, ridgeid, neighbor->id));
    }
    neighbor->seen= True;
  } /* for each ridge */
  return newfacet;
} /* makenew_nonsimplicial */

#else /* qh_NOmerge */
facetT *qh_makenew_nonsimplicial(qhT *qh, facetT *visible, vertexT *apex, int *numnew) {
  QHULL_UNUSED(qh)
  QHULL_UNUSED(visible)
  QHULL_UNUSED(apex)
  QHULL_UNUSED(numnew)

  return NULL;
}
#endif /* qh_NOmerge */

/*---------------------------------

  qh_makenew_simplicial(qh, visible, apex, numnew )
    make new facets for simplicial visible facet and apex

  returns:
    attaches new facets if !qh.NEWtentative
      neighbors between newfacet and horizon

  notes:
    nop if neighbor->seen or neighbor->visible(see qh_makenew_nonsimplicial)

  design:
    locate neighboring horizon facet for visible facet
    determine vertices and orientation
    create new facet
    if coplanar,
      add new facet to f.samecycle
    update horizon facet's neighbor list
*/
facetT *qh_makenew_simplicial(qhT *qh, facetT *visible, vertexT *apex, int *numnew) {
  facetT *neighbor, **neighborp, *newfacet= NULL;
  setT *vertices;
  boolT flip, toporient;
  int horizonskip= 0, visibleskip= 0;

  FOREACHneighbor_(visible) {
    if (!neighbor->seen && !neighbor->visible) {
      vertices= qh_facetintersect(qh, neighbor,visible, &horizonskip, &visibleskip, 1);
      SETfirst_(vertices)= apex;
      flip= ((horizonskip & 0x1) ^ (visibleskip & 0x1));
      if (neighbor->toporient)
        toporient= horizonskip & 0x1;
      else
        toporient= (horizonskip & 0x1) ^ 0x1;
      newfacet= qh_makenewfacet(qh, vertices, toporient, neighbor);
      (*numnew)++;
      if (neighbor->coplanarhorizon && (qh->PREmerge || qh->MERGEexact)) {
#ifndef qh_NOmerge
        newfacet->f.samecycle= newfacet;
        newfacet->mergehorizon= True;
#endif
      }
      if (!qh->NEWtentative)
        SETelem_(neighbor->neighbors, horizonskip)= newfacet;
      trace4((qh, qh->ferr, 4049, "qh_makenew_simplicial: create facet f%d top %d from v%d and horizon f%d skip %d top %d and visible f%d skip %d, flip? %d\n",
            newfacet->id, toporient, apex->id, neighbor->id, horizonskip,
              neighbor->toporient, visible->id, visibleskip, flip));
    }
  }
  return newfacet;
} /* makenew_simplicial */

/*---------------------------------

  qh_matchneighbor(qh, newfacet, newskip, hashsize, hashcount )
    either match subridge of newfacet with neighbor or add to hash_table

  returns:
    matched ridges of newfacet, except for duplicate ridges
    duplicate ridges marked by qh_DUPLICATEridge for qh_matchdupridge

  notes:
    called by qh_matchnewfacets
    assumes newfacet is simplicial
    ridge is newfacet->vertices w/o newskip vertex
    do not allocate memory (need to free hash_table cleanly)
    uses linear hash chains
    see qh_matchdupridge (poly2_r.c)

  design:
    for each possible matching facet in qh.hash_table
      if vertices match
        set ismatch, if facets have opposite orientation
        if ismatch and matching facet doesn't have a match
          match the facets by updating their neighbor sets
        else
          note: dupridge detected when a match 'f&d skip %d' has already been seen 
                need to mark all of the dupridges for qh_matchdupridge
          indicate a duplicate ridge by qh_DUPLICATEridge and f.dupridge
          add facet to hashtable
          unless the other facet was already a duplicate ridge
            mark both facets with a duplicate ridge
            add other facet (if defined) to hash table

  state at "indicate a duplicate ridge":
    newfacet@newskip= the argument
    facet= the hashed facet@skip that has the same vertices as newfacet@newskip
    same= true if matched vertices have the same orientation
    matchfacet= neighbor at facet@skip
    matchfacet=qh_DUPLICATEridge, matchfacet was previously detected as a dupridge of facet@skip
    ismatch if 'vertex orientation (same) matches facet/newfacet orientation (toporient)
    unknown facet will match later

  details at "indicate a duplicate ridge":
    if !ismatch and matchfacet,
      dupridge is between hashed facet@skip/matchfacet@matchskip and arg newfacet@newskip/unknown 
      set newfacet@newskip, facet@skip, and matchfacet@matchskip to qh_DUPLICATEridge
      add newfacet and matchfacet to hash_table
      if ismatch and matchfacet, 
        same as !ismatch and matchfacet -- it matches facet instead of matchfacet
      if !ismatch and !matchfacet
        dupridge between hashed facet@skip/unknown and arg newfacet@newskip/unknown 
        set newfacet@newskip and facet@skip to qh_DUPLICATEridge
        add newfacet to hash_table
      if ismatch and matchfacet==qh_DUPLICATEridge
        dupridge with already duplicated hashed facet@skip and arg newfacet@newskip/unknown
        set newfacet@newskip to qh_DUPLICATEridge
        add newfacet to hash_table
        facet's hyperplane already set
*/
void qh_matchneighbor(qhT *qh, facetT *newfacet, int newskip, int hashsize, int *hashcount) {
  boolT newfound= False;   /* True, if new facet is already in hash chain */
  boolT same, ismatch;
  int hash, scan;
  facetT *facet, *matchfacet;
  int skip, matchskip;

  hash= qh_gethash(qh, hashsize, newfacet->vertices, qh->hull_dim, 1,
                     SETelem_(newfacet->vertices, newskip));
  trace4((qh, qh->ferr, 4050, "qh_matchneighbor: newfacet f%d skip %d hash %d hashcount %d\n",
          newfacet->id, newskip, hash, *hashcount));
  zinc_(Zhashlookup);
  for (scan=hash; (facet= SETelemt_(qh->hash_table, scan, facetT));
       scan= (++scan >= hashsize ? 0 : scan)) {
    if (facet == newfacet) {
      newfound= True;
      continue;
    }
    zinc_(Zhashtests);
    if (qh_matchvertices(qh, 1, newfacet->vertices, newskip, facet->vertices, &skip, &same)) {
      if (SETelem_(newfacet->vertices, newskip) == SETelem_(facet->vertices, skip)) {
        qh_joggle_restart(qh, "two new facets with the same vertices");
        /* duplicated for multiple skips, not easily avoided */
        qh_fprintf(qh, qh->ferr, 7084, "qhull topology warning (qh_matchneighbor): will merge vertices to undo new facets -- f%d and f%d have the same vertices (skip %d, skip %d) and same horizon ridges to f%d and f%d\n",
          facet->id, newfacet->id, skip, newskip, SETfirstt_(facet->neighbors, facetT)->id, SETfirstt_(newfacet->neighbors, facetT)->id);
        /* will rename a vertex (QH3053).  The fault was duplicate ridges (same vertices) in different facets due to a previous rename.  Expensive to detect beforehand */
      }
      ismatch= (same == (boolT)((newfacet->toporient ^ facet->toporient)));
      matchfacet= SETelemt_(facet->neighbors, skip, facetT);
      if (ismatch && !matchfacet) {
        SETelem_(facet->neighbors, skip)= newfacet;
        SETelem_(newfacet->neighbors, newskip)= facet;
        (*hashcount)--;
        trace4((qh, qh->ferr, 4051, "qh_matchneighbor: f%d skip %d matched with new f%d skip %d\n",
           facet->id, skip, newfacet->id, newskip));
        return;
      }
      if (!qh->PREmerge && !qh->MERGEexact) {
        qh_joggle_restart(qh, "a ridge with more than two neighbors");
        qh_fprintf(qh, qh->ferr, 6107, "qhull topology error: facets f%d, f%d and f%d meet at a ridge with more than 2 neighbors.  Can not continue due to no qh.PREmerge and no 'Qx' (MERGEexact)\n",
                 facet->id, newfacet->id, getid_(matchfacet));
        qh_errexit2(qh, qh_ERRtopology, facet, newfacet);
      }
      SETelem_(newfacet->neighbors, newskip)= qh_DUPLICATEridge;
      newfacet->dupridge= True;
      qh_addhash(newfacet, qh->hash_table, hashsize, hash);
      (*hashcount)++;
      if (matchfacet != qh_DUPLICATEridge) {
        SETelem_(facet->neighbors, skip)= qh_DUPLICATEridge;
        facet->dupridge= True;
        if (matchfacet) {
          matchskip= qh_setindex(matchfacet->neighbors, facet);
          if (matchskip<0) {
              qh_fprintf(qh, qh->ferr, 6260, "qhull topology error (qh_matchneighbor): matchfacet f%d is in f%d neighbors but not vice versa.  Can not continue.\n",
                  matchfacet->id, facet->id);
              qh_errexit2(qh, qh_ERRtopology, matchfacet, facet);
          }
          SETelem_(matchfacet->neighbors, matchskip)= qh_DUPLICATEridge; /* matchskip>=0 by QH6260 */
          matchfacet->dupridge= True;
          qh_addhash(matchfacet, qh->hash_table, hashsize, hash);
          *hashcount += 2;
        }
      }
      trace4((qh, qh->ferr, 4052, "qh_matchneighbor: new f%d skip %d duplicates ridge for f%d skip %d matching f%d ismatch %d at hash %d\n",
           newfacet->id, newskip, facet->id, skip,
           (matchfacet == qh_DUPLICATEridge ? -2 : getid_(matchfacet)),
           ismatch, hash));
      return; /* end of duplicate ridge */
    }
  }
  if (!newfound)
    SETelem_(qh->hash_table, scan)= newfacet;  /* same as qh_addhash */
  (*hashcount)++;
  trace4((qh, qh->ferr, 4053, "qh_matchneighbor: no match for f%d skip %d at hash %d\n",
           newfacet->id, newskip, hash));
} /* matchneighbor */


/*---------------------------------

  qh_matchnewfacets(qh )
    match new facets in qh.newfacet_list to their newfacet neighbors
    all facets are simplicial

  returns:
    if dupridges and merging 
      returns maxdupdist (>=0.0) from vertex to opposite facet
      sets facet->dupridge
      missing neighbor links identify dupridges to be merged (qh_DUPLICATEridge)
    else  
      qh.newfacet_list with full neighbor sets
        vertices for the nth neighbor match all but the nth vertex
    if not merging and qh.FORCEoutput
      for facets with normals (i.e., with dupridges)
      sets facet->flippped for flipped normals, also prevents point partitioning

  notes:
    called by qh_buildcone* and qh_triangulate_facet
    neighbor[0] of new facets is the horizon facet
    if NEWtentative, new facets not attached to the horizon
    assumes qh.hash_table is NULL
    vertex->neighbors has not been updated yet
    do not allocate memory after qh.hash_table (need to free it cleanly)
    
  design:
    truncate neighbor sets to horizon facet for all new facets
    initialize a hash table
    for all new facets
      match facet with neighbors
    if unmatched facets (due to duplicate ridges)
      for each new facet with a duplicate ridge
        try to match facets with the same coplanar horizon
    if not all matched
      for each new facet with a duplicate ridge
        match it with a coplanar facet, or identify a pinched vertex
    if not merging and qh.FORCEoutput
      check for flipped facets
*/
coordT qh_matchnewfacets(qhT *qh /* qh.newfacet_list */) {
  int numnew=0, hashcount=0, newskip;
  facetT *newfacet, *neighbor;
  coordT maxdupdist= 0.0, maxdist2;
  int dim= qh->hull_dim, hashsize, neighbor_i, neighbor_n;
  setT *neighbors;
#ifndef qh_NOtrace
  int facet_i, facet_n, numunused= 0;
  facetT *facet;
#endif

  trace1((qh, qh->ferr, 1019, "qh_matchnewfacets: match neighbors for new facets.\n"));
  FORALLnew_facets {
    numnew++;
    {  /* inline qh_setzero(qh, newfacet->neighbors, 1, qh->hull_dim); */
      neighbors= newfacet->neighbors;
      neighbors->e[neighbors->maxsize].i= dim+1; /*may be overwritten*/
      memset((char *)SETelemaddr_(neighbors, 1, void), 0, (size_t)(dim * SETelemsize));
    }
  }

  qh_newhashtable(qh, numnew*(qh->hull_dim-1)); /* twice what is normally needed,
                                     but every ridge could be DUPLICATEridge */
  hashsize= qh_setsize(qh, qh->hash_table);
  FORALLnew_facets {
    if (!newfacet->simplicial) {
      qh_fprintf(qh, qh->ferr, 6377, "qhull internal error (qh_matchnewfacets): expecting simplicial facets on qh.newfacet_list f%d for qh_matchneighbors, qh_matchneighbor, and qh_matchdupridge.  Got non-simplicial f%d\n",
        qh->newfacet_list->id, newfacet->id);
      qh_errexit2(qh, qh_ERRqhull, newfacet, qh->newfacet_list);
    }
    for (newskip=1; newskiphull_dim; newskip++) /* furthest/horizon already matched */
      /* hashsize>0 because hull_dim>1 and numnew>0 */
      qh_matchneighbor(qh, newfacet, newskip, hashsize, &hashcount);
#if 0   /* use the following to trap hashcount errors */
    {
      int count= 0, k;
      facetT *facet, *neighbor;

      count= 0;
      FORALLfacet_(qh->newfacet_list) {  /* newfacet already in use */
        for (k=1; k < qh->hull_dim; k++) {
          neighbor= SETelemt_(facet->neighbors, k, facetT);
          if (!neighbor || neighbor == qh_DUPLICATEridge)
            count++;
        }
        if (facet == newfacet)
          break;
      }
      if (count != hashcount) {
        qh_fprintf(qh, qh->ferr, 6266, "qhull error (qh_matchnewfacets): after adding facet %d, hashcount %d != count %d\n",
                 newfacet->id, hashcount, count);
        qh_errexit(qh, qh_ERRdebug, newfacet, NULL);
      }
    }
#endif  /* end of trap code */
  } /* end FORALLnew_facets */
  if (hashcount) { /* all neighbors matched, except for qh_DUPLICATEridge neighbors */
    qh_joggle_restart(qh, "ridge with multiple neighbors");
    if (hashcount) {
      FORALLnew_facets {
        if (newfacet->dupridge) {
          FOREACHneighbor_i_(qh, newfacet) {
            if (neighbor == qh_DUPLICATEridge) {
              maxdist2= qh_matchdupridge(qh, newfacet, neighbor_i, hashsize, &hashcount);
              maximize_(maxdupdist, maxdist2);
            }
          }
        }
      }
    }
  }
  if (hashcount) {
    qh_fprintf(qh, qh->ferr, 6108, "qhull internal error (qh_matchnewfacets): %d neighbors did not match up\n",
        hashcount);
    qh_printhashtable(qh, qh->ferr);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
#ifndef qh_NOtrace
  if (qh->IStracing >= 3) {
    FOREACHfacet_i_(qh, qh->hash_table) {
      if (!facet)
        numunused++;
    }
    qh_fprintf(qh, qh->ferr, 3063, "qh_matchnewfacets: maxdupdist %2.2g, new facets %d, unused hash entries %d, hashsize %d\n",
             maxdupdist, numnew, numunused, qh_setsize(qh, qh->hash_table));
  }
#endif /* !qh_NOtrace */
  qh_setfree(qh, &qh->hash_table);
  if (qh->PREmerge || qh->MERGEexact) {
    if (qh->IStracing >= 4)
      qh_printfacetlist(qh, qh->newfacet_list, NULL, qh_ALL);
  }
  return maxdupdist;
} /* matchnewfacets */


/*---------------------------------

  qh_matchvertices(qh, firstindex, verticesA, skipA, verticesB, skipB, same )
    tests whether vertices match with a single skip
    starts match at firstindex since all new facets have a common vertex

  returns:
    true if matched vertices
    skip index for skipB
    sets same iff vertices have the same orientation

  notes:
    called by qh_matchneighbor and qh_matchdupridge
    assumes skipA is in A and both sets are the same size

  design:
    set up pointers
    scan both sets checking for a match
    test orientation
*/
boolT qh_matchvertices(qhT *qh, int firstindex, setT *verticesA, int skipA,
       setT *verticesB, int *skipB, boolT *same) {
  vertexT **elemAp, **elemBp, **skipBp=NULL, **skipAp;

  elemAp= SETelemaddr_(verticesA, firstindex, vertexT);
  elemBp= SETelemaddr_(verticesB, firstindex, vertexT);
  skipAp= SETelemaddr_(verticesA, skipA, vertexT);
  do if (elemAp != skipAp) {
    while (*elemAp != *elemBp++) {
      if (skipBp)
        return False;
      skipBp= elemBp;  /* one extra like FOREACH */
    }
  }while (*(++elemAp));
  if (!skipBp)
    skipBp= ++elemBp;
  *skipB= SETindex_(verticesB, skipB); /* i.e., skipBp - verticesB
                                       verticesA and verticesB are the same size, otherwise trace4 may segfault */
  *same= !((skipA & 0x1) ^ (*skipB & 0x1)); /* result is 0 or 1 */
  trace4((qh, qh->ferr, 4054, "qh_matchvertices: matched by skip %d(v%d) and skip %d(v%d) same? %d\n",
          skipA, (*skipAp)->id, *skipB, (*(skipBp-1))->id, *same));
  return(True);
} /* matchvertices */

/*---------------------------------

  qh_newfacet(qh)
    return a new facet

  returns:
    all fields initialized or cleared   (NULL)
    preallocates neighbors set
*/
facetT *qh_newfacet(qhT *qh) {
  facetT *facet;
  void **freelistp; /* used if !qh_NOmem by qh_memalloc_() */

  qh_memalloc_(qh, (int)sizeof(facetT), freelistp, facet, facetT);
  memset((char *)facet, (size_t)0, sizeof(facetT));
  if (qh->facet_id == qh->tracefacet_id)
    qh->tracefacet= facet;
  facet->id= qh->facet_id++;
  facet->neighbors= qh_setnew(qh, qh->hull_dim);
#if !qh_COMPUTEfurthest
  facet->furthestdist= 0.0;
#endif
#if qh_MAXoutside
  if (qh->FORCEoutput && qh->APPROXhull)
    facet->maxoutside= qh->MINoutside;
  else
    facet->maxoutside= qh->DISTround; /* same value as test for QH7082 */
#endif
  facet->simplicial= True;
  facet->good= True;
  facet->newfacet= True;
  trace4((qh, qh->ferr, 4055, "qh_newfacet: created facet f%d\n", facet->id));
  return(facet);
} /* newfacet */


/*---------------------------------

  qh_newridge()
    return a new ridge
  notes:
    caller sets qh.traceridge
*/
ridgeT *qh_newridge(qhT *qh) {
  ridgeT *ridge;
  void **freelistp;   /* used if !qh_NOmem by qh_memalloc_() */

  qh_memalloc_(qh, (int)sizeof(ridgeT), freelistp, ridge, ridgeT);
  memset((char *)ridge, (size_t)0, sizeof(ridgeT));
  zinc_(Ztotridges);
  if (qh->ridge_id == UINT_MAX) {
    qh_fprintf(qh, qh->ferr, 7074, "qhull warning: more than 2^32 ridges.  Qhull results are OK.  Since the ridge ID wraps around to 0, two ridges may have the same identifier.\n");
  }
  ridge->id= qh->ridge_id++;
  trace4((qh, qh->ferr, 4056, "qh_newridge: created ridge r%d\n", ridge->id));
  return(ridge);
} /* newridge */


/*---------------------------------

  qh_pointid(qh, point )
    return id for a point,
    returns qh_IDnone(-3) if null, qh_IDinterior(-2) if interior, or qh_IDunknown(-1) if not known

  alternative code if point is in qh.first_point...
    unsigned long id;
    id= ((unsigned long)point - (unsigned long)qh.first_point)/qh.normal_size;

  notes:
    Valid points are non-negative
    WARN64 -- id truncated to 32-bits, at most 2G points
    NOerrors returned (QhullPoint::id)
    if point not in point array
      the code does a comparison of unrelated pointers.
*/
int qh_pointid(qhT *qh, pointT *point) {
  ptr_intT offset, id;

  if (!point || !qh)
    return qh_IDnone;
  else if (point == qh->interior_point)
    return qh_IDinterior;
  else if (point >= qh->first_point
  && point < qh->first_point + qh->num_points * qh->hull_dim) {
    offset= (ptr_intT)(point - qh->first_point);
    id= offset / qh->hull_dim;
  }else if ((id= qh_setindex(qh->other_points, point)) != -1)
    id += qh->num_points;
  else
    return qh_IDunknown;
  return (int)id;
} /* pointid */

/*---------------------------------

  qh_removefacet(qh, facet )
    unlinks facet from qh.facet_list,

  returns:
    updates qh.facet_list .newfacet_list .facet_next visible_list
    decrements qh.num_facets

  see:
    qh_appendfacet
*/
void qh_removefacet(qhT *qh, facetT *facet) {
  facetT *next= facet->next, *previous= facet->previous; /* next is always defined */

  if (facet == qh->newfacet_list)
    qh->newfacet_list= next;
  if (facet == qh->facet_next)
    qh->facet_next= next;
  if (facet == qh->visible_list)
    qh->visible_list= next;
  if (previous) {
    previous->next= next;
    next->previous= previous;
  }else {  /* 1st facet in qh->facet_list */
    qh->facet_list= next;
    qh->facet_list->previous= NULL;
  }
  qh->num_facets--;
  trace4((qh, qh->ferr, 4057, "qh_removefacet: removed f%d from facet_list, newfacet_list, and visible_list\n", facet->id));
} /* removefacet */


/*---------------------------------

  qh_removevertex(qh, vertex )
    unlinks vertex from qh.vertex_list,

  returns:
    updates qh.vertex_list .newvertex_list
    decrements qh.num_vertices
*/
void qh_removevertex(qhT *qh, vertexT *vertex) {
  vertexT *next= vertex->next, *previous= vertex->previous; /* next is always defined */

  trace4((qh, qh->ferr, 4058, "qh_removevertex: remove v%d from qh.vertex_list\n", vertex->id));
  if (vertex == qh->newvertex_list)
    qh->newvertex_list= next;
  if (previous) {
    previous->next= next;
    next->previous= previous;
  }else {  /* 1st vertex in qh->vertex_list */
    qh->vertex_list= next;
    qh->vertex_list->previous= NULL;
  }
  qh->num_vertices--;
} /* removevertex */


/*---------------------------------

  qh_update_vertexneighbors(qh )
    update vertex neighbors and delete interior vertices

  returns:
    if qh.VERTEXneighbors, 
      if qh.newvertex_list,
         removes visible neighbors from vertex neighbors
      if qh.newfacet_list
         adds new facets to vertex neighbors
      if qh.visible_list
         interior vertices added to qh.del_vertices for later partitioning as coplanar points
    if not qh.VERTEXneighbors (not merging)
      interior vertices of visible facets added to qh.del_vertices for later partitioning as coplanar points
  
  notes
    [jan'19] split off qh_update_vertexneighbors_cone.  Optimize the remaining cases in a future release
    called by qh_triangulate_facet after triangulating a non-simplicial facet, followed by reset_lists
    called by qh_triangulate after triangulating null and mirror facets
    called by qh_all_vertexmerges after calling qh_merge_pinchedvertices

  design:
    if qh.VERTEXneighbors
      for each vertex on newvertex_list (i.e., new vertices and vertices of new facets)
        delete visible facets from vertex neighbors
      for each new facet on newfacet_list
        for each vertex of facet
          append facet to vertex neighbors
      for each visible facet on qh.visible_list
        for each vertex of facet
          if the vertex is not on a new facet and not itself deleted
            if the vertex has a not-visible neighbor (due to merging)
               remove the visible facet from the vertex's neighbors
            otherwise
               add the vertex to qh.del_vertices for later deletion

    if not qh.VERTEXneighbors (not merging)
      for each vertex of a visible facet
        if the vertex is not on a new facet and not itself deleted
           add the vertex to qh.del_vertices for later deletion
*/
void qh_update_vertexneighbors(qhT *qh /* qh.newvertex_list, newfacet_list, visible_list */) {
  facetT *newfacet= NULL, *neighbor, **neighborp, *visible;
  vertexT *vertex, **vertexp;
  int neighborcount= 0;

  if (qh->VERTEXneighbors) {
    trace3((qh, qh->ferr, 3013, "qh_update_vertexneighbors: update v.neighbors for qh.newvertex_list (v%d) and qh.newfacet_list (f%d)\n",
         getid_(qh->newvertex_list), getid_(qh->newfacet_list)));
    FORALLvertex_(qh->newvertex_list) {
      neighborcount= 0;
      FOREACHneighbor_(vertex) {
        if (neighbor->visible) {
          neighborcount++;
          SETref_(neighbor)= NULL;
        }
      }
      if (neighborcount) {
        trace4((qh, qh->ferr, 4046, "qh_update_vertexneighbors: delete %d of %d vertex neighbors for v%d.  Removes to-be-deleted, visible facets\n",
          neighborcount, qh_setsize(qh, vertex->neighbors), vertex->id));
        qh_setcompact(qh, vertex->neighbors);
      }
    }
    FORALLnew_facets {
      if (qh->first_newfacet && newfacet->id >= qh->first_newfacet) {
        FOREACHvertex_(newfacet->vertices)
          qh_setappend(qh, &vertex->neighbors, newfacet);
      }else {  /* called after qh_merge_pinchedvertices.  In 7-D, many more neighbors than new facets.  qh_setin is expensive */
        FOREACHvertex_(newfacet->vertices)
          qh_setunique(qh, &vertex->neighbors, newfacet); 
      }
    }
    trace3((qh, qh->ferr, 3058, "qh_update_vertexneighbors: delete interior vertices for qh.visible_list (f%d)\n",
        getid_(qh->visible_list)));
    FORALLvisible_facets {
      FOREACHvertex_(visible->vertices) {
        if (!vertex->newfacet && !vertex->deleted) {
          FOREACHneighbor_(vertex) { /* this can happen under merging */
            if (!neighbor->visible)
              break;
          }
          if (neighbor)
            qh_setdel(vertex->neighbors, visible);
          else {
            vertex->deleted= True;
            qh_setappend(qh, &qh->del_vertices, vertex);
            trace2((qh, qh->ferr, 2041, "qh_update_vertexneighbors: delete interior vertex p%d(v%d) of visible f%d\n",
                  qh_pointid(qh, vertex->point), vertex->id, visible->id));
          }
        }
      }
    }
  }else {  /* !VERTEXneighbors */
    trace3((qh, qh->ferr, 3058, "qh_update_vertexneighbors: delete old vertices for qh.visible_list (f%d)\n",
      getid_(qh->visible_list)));
    FORALLvisible_facets {
      FOREACHvertex_(visible->vertices) {
        if (!vertex->newfacet && !vertex->deleted) {
          vertex->deleted= True;
          qh_setappend(qh, &qh->del_vertices, vertex);
          trace2((qh, qh->ferr, 2042, "qh_update_vertexneighbors: will delete interior vertex p%d(v%d) of visible f%d\n",
                  qh_pointid(qh, vertex->point), vertex->id, visible->id));
        }
      }
    }
  }
} /* update_vertexneighbors */

/*---------------------------------

  qh_update_vertexneighbors_cone(qh )
    update vertex neighbors for a cone of new facets and delete interior vertices

  returns:
    if qh.VERTEXneighbors, 
      if qh.newvertex_list,
         removes visible neighbors from vertex neighbors
      if qh.newfacet_list
         adds new facets to vertex neighbors
      if qh.visible_list
         interior vertices added to qh.del_vertices for later partitioning as coplanar points
    if not qh.VERTEXneighbors (not merging)
      interior vertices of visible facets added to qh.del_vertices for later partitioning as coplanar points
  
  notes
    called by qh_addpoint after create cone and before premerge

  design:
    if qh.VERTEXneighbors
      for each vertex on newvertex_list (i.e., new vertices and vertices of new facets)
        delete visible facets from vertex neighbors
      for each new facet on newfacet_list
        for each vertex of facet
          append facet to vertex neighbors
      for each visible facet on qh.visible_list
        for each vertex of facet
          if the vertex is not on a new facet and not itself deleted
            if the vertex has a not-visible neighbor (due to merging)
               remove the visible facet from the vertex's neighbors
            otherwise
               add the vertex to qh.del_vertices for later deletion

    if not qh.VERTEXneighbors (not merging)
      for each vertex of a visible facet
        if the vertex is not on a new facet and not itself deleted
           add the vertex to qh.del_vertices for later deletion

*/
void qh_update_vertexneighbors_cone(qhT *qh /* qh.newvertex_list, newfacet_list, visible_list */) {
  facetT *newfacet= NULL, *neighbor, **neighborp, *visible;
  vertexT *vertex, **vertexp;
  int delcount= 0;

  if (qh->VERTEXneighbors) {
    trace3((qh, qh->ferr, 3059, "qh_update_vertexneighbors_cone: update v.neighbors for qh.newvertex_list (v%d) and qh.newfacet_list (f%d)\n",
         getid_(qh->newvertex_list), getid_(qh->newfacet_list)));
    FORALLvertex_(qh->newvertex_list) {
      delcount= 0;
      FOREACHneighbor_(vertex) {
        if (neighbor->visible) { /* alternative design is a loop over visible facets, but needs qh_setdel() */
          delcount++;
          qh_setdelnth(qh, vertex->neighbors, SETindex_(vertex->neighbors, neighbor));
          neighborp--; /* repeat */
        }
      }
      if (delcount) {
        trace4((qh, qh->ferr, 4021, "qh_update_vertexneighbors_cone: deleted %d visible vertexneighbors of v%d\n",
          delcount, vertex->id));
      }
    }
    FORALLnew_facets {
      FOREACHvertex_(newfacet->vertices)
        qh_setappend(qh, &vertex->neighbors, newfacet);
    }
    trace3((qh, qh->ferr, 3065, "qh_update_vertexneighbors_cone: delete interior vertices, if any, for qh.visible_list (f%d)\n",
        getid_(qh->visible_list)));
    FORALLvisible_facets {
      FOREACHvertex_(visible->vertices) {
        if (!vertex->newfacet && !vertex->deleted) {
          FOREACHneighbor_(vertex) { /* this can happen under merging, qh_checkfacet QH4025 */
            if (!neighbor->visible)
              break;
          }
          if (neighbor)
            qh_setdel(vertex->neighbors, visible);
          else {
            vertex->deleted= True;
            qh_setappend(qh, &qh->del_vertices, vertex);
            trace2((qh, qh->ferr, 2102, "qh_update_vertexneighbors_cone: will delete interior vertex p%d(v%d) of visible f%d\n",
              qh_pointid(qh, vertex->point), vertex->id, visible->id));
          }
        }
      }
    }
  }else {  /* !VERTEXneighbors */
    trace3((qh, qh->ferr, 3066, "qh_update_vertexneighbors_cone: delete interior vertices for qh.visible_list (f%d)\n",
      getid_(qh->visible_list)));
    FORALLvisible_facets {
      FOREACHvertex_(visible->vertices) {
        if (!vertex->newfacet && !vertex->deleted) {
          vertex->deleted= True;
          qh_setappend(qh, &qh->del_vertices, vertex);
          trace2((qh, qh->ferr, 2059, "qh_update_vertexneighbors_cone: will delete interior vertex p%d(v%d) of visible f%d\n",
                  qh_pointid(qh, vertex->point), vertex->id, visible->id));
        }
      }
    }
  }
} /* update_vertexneighbors_cone */

geometry/src/mem_r.c0000644000176200001440000005225614664417655014173 0ustar  liggesusers/*
  ---------------------------------

  mem_r.c
    memory management routines for qhull

  See libqhull/mem.c for a standalone program.

  To initialize memory:

    qh_meminit(qh, stderr);
    qh_meminitbuffers(qh, qh->IStracing, qh_MEMalign, 7, qh_MEMbufsize,qh_MEMinitbuf);
    qh_memsize(qh, (int)sizeof(facetT));
    qh_memsize(qh, (int)sizeof(facetT));
    ...
    qh_memsetup(qh);

  To free up all memory buffers:
    qh_memfreeshort(qh, &curlong, &totlong);

  if qh_NOmem,
    malloc/free is used instead of mem_r.c

  notes:
    uses Quickfit algorithm (freelists for commonly allocated sizes)
    assumes small sizes for freelists (it discards the tail of memory buffers)

  see:
    qh-mem_r.htm and mem_r.h
    global_r.c (qh_initbuffers) for an example of using mem_r.c

  Copyright (c) 1993-2020 The Geometry Center.
  $Id: //main/2019/qhull/src/libqhull_r/mem_r.c#7 $$Change: 2953 $
  $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#include "libqhull_r.h"  /* includes user_r.h and mem_r.h */

#include 
#include 
#include 

#ifndef qh_NOmem

/*============= internal functions ==============*/

static int qh_intcompare(const void *i, const void *j);

/*========== functions in alphabetical order ======== */

/*---------------------------------

  qh_intcompare( i, j )
    used by qsort and bsearch to compare two integers
*/
static int qh_intcompare(const void *i, const void *j) {
  return(*((const int *)i) - *((const int *)j));
} /* intcompare */


/*----------------------------------

  qh_memalloc(qh, insize )
    returns object of insize bytes
    qhmem is the global memory structure

  returns:
    pointer to allocated memory
    errors if insufficient memory

  notes:
    use explicit type conversion to avoid type warnings on some compilers
    actual object may be larger than insize
    use qh_memalloc_() for inline code for quick allocations
    logs allocations if 'T5'
    caller is responsible for freeing the memory.
    short memory is freed on shutdown by qh_memfreeshort unless qh_NOmem

  design:
    if size < qh->qhmem.LASTsize
      if qh->qhmem.freelists[size] non-empty
        return first object on freelist
      else
        round up request to size of qh->qhmem.freelists[size]
        allocate new allocation buffer if necessary
        allocate object from allocation buffer
    else
      allocate object with qh_malloc() in user_r.c
*/
void *qh_memalloc(qhT *qh, int insize) {
  void **freelistp, *newbuffer;
  int idx, size, n;
  int outsize, bufsize;
  void *object;

  if (insize<0) {
      qh_fprintf(qh, qh->qhmem.ferr, 6235, "qhull error (qh_memalloc): negative request size (%d).  Did int overflow due to high-D?\n", insize); /* WARN64 */
      qh_errexit(qh, qhmem_ERRmem, NULL, NULL);
  }
  if (insize>=0 && insize <= qh->qhmem.LASTsize) {
    idx= qh->qhmem.indextable[insize];
    outsize= qh->qhmem.sizetable[idx];
    qh->qhmem.totshort += outsize;
    freelistp= qh->qhmem.freelists+idx;
    if ((object= *freelistp)) {
      qh->qhmem.cntquick++;
      qh->qhmem.totfree -= outsize;
      *freelistp= *((void **)*freelistp);  /* replace freelist with next object */
#ifdef qh_TRACEshort
      n= qh->qhmem.cntshort+qh->qhmem.cntquick+qh->qhmem.freeshort;
      if (qh->qhmem.IStracing >= 5)
          qh_fprintf(qh, qh->qhmem.ferr, 8141, "qh_mem %p n %8d alloc quick: %d bytes (tot %d cnt %d)\n", object, n, outsize, qh->qhmem.totshort, qh->qhmem.cntshort+qh->qhmem.cntquick-qh->qhmem.freeshort);
#endif
      return(object);
    }else {
      qh->qhmem.cntshort++;
      if (outsize > qh->qhmem.freesize) {
        qh->qhmem.totdropped += qh->qhmem.freesize;
        if (!qh->qhmem.curbuffer)
          bufsize= qh->qhmem.BUFinit;
        else
          bufsize= qh->qhmem.BUFsize;
        if (!(newbuffer= qh_malloc((size_t)bufsize))) {
          qh_fprintf(qh, qh->qhmem.ferr, 6080, "qhull error (qh_memalloc): insufficient memory to allocate short memory buffer (%d bytes)\n", bufsize);
          qh_errexit(qh, qhmem_ERRmem, NULL, NULL);
        }
        *((void **)newbuffer)= qh->qhmem.curbuffer;  /* prepend newbuffer to curbuffer
                                                    list.  newbuffer!=0 by QH6080 */
        qh->qhmem.curbuffer= newbuffer;
        size= ((int)sizeof(void **) + qh->qhmem.ALIGNmask) & ~qh->qhmem.ALIGNmask;
        qh->qhmem.freemem= (void *)((char *)newbuffer+size);
        qh->qhmem.freesize= bufsize - size;
        qh->qhmem.totbuffer += bufsize - size; /* easier to check */
        /* Periodically test totbuffer.  It matches at beginning and exit of every call */
        n= qh->qhmem.totshort + qh->qhmem.totfree + qh->qhmem.totdropped + qh->qhmem.freesize - outsize;
        if (qh->qhmem.totbuffer != n) {
            qh_fprintf(qh, qh->qhmem.ferr, 6212, "qhull internal error (qh_memalloc): short totbuffer %d != totshort+totfree... %d\n", qh->qhmem.totbuffer, n);
            qh_errexit(qh, qhmem_ERRmem, NULL, NULL);
        }
      }
      object= qh->qhmem.freemem;
      qh->qhmem.freemem= (void *)((char *)qh->qhmem.freemem + outsize);
      qh->qhmem.freesize -= outsize;
      qh->qhmem.totunused += outsize - insize;
#ifdef qh_TRACEshort
      n= qh->qhmem.cntshort+qh->qhmem.cntquick+qh->qhmem.freeshort;
      if (qh->qhmem.IStracing >= 5)
          qh_fprintf(qh, qh->qhmem.ferr, 8140, "qh_mem %p n %8d alloc short: %d bytes (tot %d cnt %d)\n", object, n, outsize, qh->qhmem.totshort, qh->qhmem.cntshort+qh->qhmem.cntquick-qh->qhmem.freeshort);
#endif
      return object;
    }
  }else {                     /* long allocation */
    if (!qh->qhmem.indextable) {
      qh_fprintf(qh, qh->qhmem.ferr, 6081, "qhull internal error (qh_memalloc): qhmem has not been initialized.\n");
      qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
    }
    outsize= insize;
    qh->qhmem.cntlong++;
    qh->qhmem.totlong += outsize;
    if (qh->qhmem.maxlong < qh->qhmem.totlong)
      qh->qhmem.maxlong= qh->qhmem.totlong;
    if (!(object= qh_malloc((size_t)outsize))) {
      qh_fprintf(qh, qh->qhmem.ferr, 6082, "qhull error (qh_memalloc): insufficient memory to allocate %d bytes\n", outsize);
      qh_errexit(qh, qhmem_ERRmem, NULL, NULL);
    }
    if (qh->qhmem.IStracing >= 5)
      qh_fprintf(qh, qh->qhmem.ferr, 8057, "qh_mem %p n %8d alloc long: %d bytes (tot %d cnt %d)\n", object, qh->qhmem.cntlong+qh->qhmem.freelong, outsize, qh->qhmem.totlong, qh->qhmem.cntlong-qh->qhmem.freelong);
  }
  return(object);
} /* memalloc */


/*----------------------------------

  qh_memcheck(qh)
*/
void qh_memcheck(qhT *qh) {
  int i, count, totfree= 0;
  void *object;

  if (!qh) {
    qh_fprintf_stderr(6243, "qhull internal error (qh_memcheck): qh is 0.  It does not point to a qhT\n");
    qh_exit(qhmem_ERRqhull);  /* can not use qh_errexit() */
  }
  if (qh->qhmem.ferr == 0 || qh->qhmem.IStracing < 0 || qh->qhmem.IStracing > 10 || (((qh->qhmem.ALIGNmask+1) & qh->qhmem.ALIGNmask) != 0)) {
    qh_fprintf_stderr(6244, "qhull internal error (qh_memcheck): either qh->qhmem is overwritten or qh->qhmem is not initialized.  Call qh_meminit or qh_new_qhull before calling qh_mem routines.  ferr 0x%x, IsTracing %d, ALIGNmask 0x%x\n", 
          qh->qhmem.ferr, qh->qhmem.IStracing, qh->qhmem.ALIGNmask);
    qh_exit(qhmem_ERRqhull);  /* can not use qh_errexit() */
  }
  if (qh->qhmem.IStracing != 0)
    qh_fprintf(qh, qh->qhmem.ferr, 8143, "qh_memcheck: check size of freelists on qh->qhmem\nqh_memcheck: A segmentation fault indicates an overwrite of qh->qhmem\n");
  for (i=0; i < qh->qhmem.TABLEsize; i++) {
    count=0;
    for (object= qh->qhmem.freelists[i]; object; object= *((void **)object))
      count++;
    totfree += qh->qhmem.sizetable[i] * count;
  }
  if (totfree != qh->qhmem.totfree) {
    qh_fprintf(qh, qh->qhmem.ferr, 6211, "qhull internal error (qh_memcheck): totfree %d not equal to freelist total %d\n", qh->qhmem.totfree, totfree);
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  if (qh->qhmem.IStracing != 0)
    qh_fprintf(qh, qh->qhmem.ferr, 8144, "qh_memcheck: total size of freelists totfree is the same as qh->qhmem.totfree\n", totfree);
} /* memcheck */

/*----------------------------------

  qh_memfree(qh, object, insize )
    free up an object of size bytes
    size is insize from qh_memalloc

  notes:
    object may be NULL
    type checking warns if using (void **)object
    use qh_memfree_() for quick free's of small objects

  design:
    if size <= qh->qhmem.LASTsize
      append object to corresponding freelist
    else
      call qh_free(object)
*/
void qh_memfree(qhT *qh, void *object, int insize) {
  void **freelistp;
  int idx, outsize;

  if (!object)
    return;
  if (insize <= qh->qhmem.LASTsize) {
    qh->qhmem.freeshort++;
    idx= qh->qhmem.indextable[insize];
    outsize= qh->qhmem.sizetable[idx];
    qh->qhmem.totfree += outsize;
    qh->qhmem.totshort -= outsize;
    freelistp= qh->qhmem.freelists + idx;
    *((void **)object)= *freelistp;
    *freelistp= object;
#ifdef qh_TRACEshort
    idx= qh->qhmem.cntshort+qh->qhmem.cntquick+qh->qhmem.freeshort;
    if (qh->qhmem.IStracing >= 5)
        qh_fprintf(qh, qh->qhmem.ferr, 8142, "qh_mem %p n %8d free short: %d bytes (tot %d cnt %d)\n", object, idx, outsize, qh->qhmem.totshort, qh->qhmem.cntshort+qh->qhmem.cntquick-qh->qhmem.freeshort);
#endif
  }else {
    qh->qhmem.freelong++;
    qh->qhmem.totlong -= insize;
    if (qh->qhmem.IStracing >= 5)
      qh_fprintf(qh, qh->qhmem.ferr, 8058, "qh_mem %p n %8d free long: %d bytes (tot %d cnt %d)\n", object, qh->qhmem.cntlong+qh->qhmem.freelong, insize, qh->qhmem.totlong, qh->qhmem.cntlong-qh->qhmem.freelong);
    qh_free(object);
  }
} /* memfree */


/*---------------------------------

  qh_memfreeshort(qh, curlong, totlong )
    frees up all short and qhmem memory allocations

  returns:
    number and size of current long allocations

  notes:
    if qh_NOmem (qh_malloc() for all allocations),
       short objects (e.g., facetT) are not recovered.
       use qh_freeqhull(qh, qh_ALL) instead.

  see:
    qh_freeqhull(qh, allMem)
    qh_memtotal(qh, curlong, totlong, curshort, totshort, maxlong, totbuffer);
*/
void qh_memfreeshort(qhT *qh, int *curlong, int *totlong) {
  void *buffer, *nextbuffer;
  FILE *ferr;

  *curlong= qh->qhmem.cntlong - qh->qhmem.freelong;
  *totlong= qh->qhmem.totlong;
  for (buffer=qh->qhmem.curbuffer; buffer; buffer= nextbuffer) {
    nextbuffer= *((void **) buffer);
    qh_free(buffer);
  }
  qh->qhmem.curbuffer= NULL;
  if (qh->qhmem.LASTsize) {
    qh_free(qh->qhmem.indextable);
    qh_free(qh->qhmem.freelists);
    qh_free(qh->qhmem.sizetable);
  }
  ferr= qh->qhmem.ferr;
  memset((char *)&qh->qhmem, 0, sizeof(qh->qhmem));  /* every field is 0, FALSE, NULL */
  qh->qhmem.ferr= ferr;
} /* memfreeshort */


/*----------------------------------

  qh_meminit(qh, ferr )
    initialize qhmem and test sizeof(void *)
    Does not throw errors.  qh_exit on failure
*/
void qh_meminit(qhT *qh, FILE *ferr) {

  memset((char *)&qh->qhmem, 0, sizeof(qh->qhmem));  /* every field is 0, FALSE, NULL */
  if (ferr)
    qh->qhmem.ferr= ferr;
  else
    qh->qhmem.ferr= stderr;
  if (sizeof(void *) < sizeof(int)) {
    qh_fprintf(qh, qh->qhmem.ferr, 6083, "qhull internal error (qh_meminit): sizeof(void *) %d < sizeof(int) %d.  qset_r.c will not work\n", (int)sizeof(void*), (int)sizeof(int));
    qh_exit(qhmem_ERRqhull);  /* can not use qh_errexit() */
  }
  if (sizeof(void *) > sizeof(ptr_intT)) {
    qh_fprintf(qh, qh->qhmem.ferr, 6084, "qhull internal error (qh_meminit): sizeof(void *) %d > sizeof(ptr_intT) %d. Change ptr_intT in mem_r.h to 'long long'\n", (int)sizeof(void*), (int)sizeof(ptr_intT));
    qh_exit(qhmem_ERRqhull);  /* can not use qh_errexit() */
  }
  qh_memcheck(qh);
} /* meminit */

/*---------------------------------

  qh_meminitbuffers(qh, tracelevel, alignment, numsizes, bufsize, bufinit )
    initialize qhmem
    if tracelevel >= 5, trace memory allocations
    alignment= desired address alignment for memory allocations
    numsizes= number of freelists
    bufsize=  size of additional memory buffers for short allocations
    bufinit=  size of initial memory buffer for short allocations
*/
void qh_meminitbuffers(qhT *qh, int tracelevel, int alignment, int numsizes, int bufsize, int bufinit) {

  qh->qhmem.IStracing= tracelevel;
  qh->qhmem.NUMsizes= numsizes;
  qh->qhmem.BUFsize= bufsize;
  qh->qhmem.BUFinit= bufinit;
  qh->qhmem.ALIGNmask= alignment-1;
  if (qh->qhmem.ALIGNmask & ~qh->qhmem.ALIGNmask) {
    qh_fprintf(qh, qh->qhmem.ferr, 6085, "qhull internal error (qh_meminit): memory alignment %d is not a power of 2\n", alignment);
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  qh->qhmem.sizetable= (int *) calloc((size_t)numsizes, sizeof(int));
  qh->qhmem.freelists= (void **) calloc((size_t)numsizes, sizeof(void *));
  if (!qh->qhmem.sizetable || !qh->qhmem.freelists) {
    qh_fprintf(qh, qh->qhmem.ferr, 6086, "qhull error (qh_meminit): insufficient memory\n");
    qh_errexit(qh, qhmem_ERRmem, NULL, NULL);
  }
  if (qh->qhmem.IStracing >= 1)
    qh_fprintf(qh, qh->qhmem.ferr, 8059, "qh_meminitbuffers: memory initialized with alignment %d\n", alignment);
} /* meminitbuffers */

/*---------------------------------

  qh_memsetup(qh)
    set up memory after running memsize()
*/
void qh_memsetup(qhT *qh) {
  int k,i;

  qsort(qh->qhmem.sizetable, (size_t)qh->qhmem.TABLEsize, sizeof(int), qh_intcompare);
  qh->qhmem.LASTsize= qh->qhmem.sizetable[qh->qhmem.TABLEsize-1];
  if (qh->qhmem.LASTsize >= qh->qhmem.BUFsize || qh->qhmem.LASTsize >= qh->qhmem.BUFinit) {
    qh_fprintf(qh, qh->qhmem.ferr, 6087, "qhull error (qh_memsetup): largest mem size %d is >= buffer size %d or initial buffer size %d\n",
            qh->qhmem.LASTsize, qh->qhmem.BUFsize, qh->qhmem.BUFinit);
    qh_errexit(qh, qhmem_ERRmem, NULL, NULL);
  }
  if (!(qh->qhmem.indextable= (int *)qh_malloc((size_t)(qh->qhmem.LASTsize+1) * sizeof(int)))) {
    qh_fprintf(qh, qh->qhmem.ferr, 6088, "qhull error (qh_memsetup): insufficient memory\n");
    qh_errexit(qh, qhmem_ERRmem, NULL, NULL);
  }
  for (k=qh->qhmem.LASTsize+1; k--; )
    qh->qhmem.indextable[k]= k;
  i= 0;
  for (k=0; k <= qh->qhmem.LASTsize; k++) {
    if (qh->qhmem.indextable[k] <= qh->qhmem.sizetable[i])
      qh->qhmem.indextable[k]= i;
    else
      qh->qhmem.indextable[k]= ++i;
  }
} /* memsetup */

/*---------------------------------

  qh_memsize(qh, size )
    define a free list for this size
*/
void qh_memsize(qhT *qh, int size) {
  int k;

  if (qh->qhmem.LASTsize) {
    qh_fprintf(qh, qh->qhmem.ferr, 6089, "qhull internal error (qh_memsize): qh_memsize called after qh_memsetup\n");
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
  size= (size + qh->qhmem.ALIGNmask) & ~qh->qhmem.ALIGNmask;
  if (qh->qhmem.IStracing >= 3)
    qh_fprintf(qh, qh->qhmem.ferr, 3078, "qh_memsize: quick memory of %d bytes\n", size);
  for (k=qh->qhmem.TABLEsize; k--; ) {
    if (qh->qhmem.sizetable[k] == size)
      return;
  }
  if (qh->qhmem.TABLEsize < qh->qhmem.NUMsizes)
    qh->qhmem.sizetable[qh->qhmem.TABLEsize++]= size;
  else
    qh_fprintf(qh, qh->qhmem.ferr, 7060, "qhull warning (qh_memsize): free list table has room for only %d sizes\n", qh->qhmem.NUMsizes);
} /* memsize */


/*---------------------------------

  qh_memstatistics(qh, fp )
    print out memory statistics

    Verifies that qh->qhmem.totfree == sum of freelists
*/
void qh_memstatistics(qhT *qh, FILE *fp) {
  int i;
  int count;
  void *object;

  qh_memcheck(qh);
  qh_fprintf(qh, fp, 9278, "\nmemory statistics:\n\
%7d quick allocations\n\
%7d short allocations\n\
%7d long allocations\n\
%7d short frees\n\
%7d long frees\n\
%7d bytes of short memory in use\n\
%7d bytes of short memory in freelists\n\
%7d bytes of dropped short memory\n\
%7d bytes of unused short memory (estimated)\n\
%7d bytes of long memory allocated (max, except for input)\n\
%7d bytes of long memory in use (in %d pieces)\n\
%7d bytes of short memory buffers (minus links)\n\
%7d bytes per short memory buffer (initially %d bytes)\n",
           qh->qhmem.cntquick, qh->qhmem.cntshort, qh->qhmem.cntlong,
           qh->qhmem.freeshort, qh->qhmem.freelong,
           qh->qhmem.totshort, qh->qhmem.totfree,
           qh->qhmem.totdropped + qh->qhmem.freesize, qh->qhmem.totunused,
           qh->qhmem.maxlong, qh->qhmem.totlong, qh->qhmem.cntlong - qh->qhmem.freelong,
           qh->qhmem.totbuffer, qh->qhmem.BUFsize, qh->qhmem.BUFinit);
  if (qh->qhmem.cntlarger) {
    qh_fprintf(qh, fp, 9279, "%7d calls to qh_setlarger\n%7.2g     average copy size\n",
           qh->qhmem.cntlarger, ((double)qh->qhmem.totlarger)/(double)qh->qhmem.cntlarger);
    qh_fprintf(qh, fp, 9280, "  freelists(bytes->count):");
  }
  for (i=0; i < qh->qhmem.TABLEsize; i++) {
    count=0;
    for (object= qh->qhmem.freelists[i]; object; object= *((void **)object))
      count++;
    qh_fprintf(qh, fp, 9281, " %d->%d", qh->qhmem.sizetable[i], count);
  }
  qh_fprintf(qh, fp, 9282, "\n\n");
} /* memstatistics */


/*---------------------------------

  qh_NOmem
    turn off quick-fit memory allocation

  notes:
    uses qh_malloc() and qh_free() instead
*/
#else /* qh_NOmem */

void *qh_memalloc(qhT *qh, int insize) {
  void *object;

  if (!(object= qh_malloc((size_t)insize))) {
    qh_fprintf(qh, qh->qhmem.ferr, 6090, "qhull error (qh_memalloc): insufficient memory\n");
    qh_errexit(qh, qhmem_ERRmem, NULL, NULL);
  }
  qh->qhmem.cntlong++;
  qh->qhmem.totlong += insize;
  if (qh->qhmem.maxlong < qh->qhmem.totlong)
      qh->qhmem.maxlong= qh->qhmem.totlong;
  if (qh->qhmem.IStracing >= 5)
    qh_fprintf(qh, qh->qhmem.ferr, 8060, "qh_mem %p n %8d alloc long: %d bytes (tot %d cnt %d)\n", object, qh->qhmem.cntlong+qh->qhmem.freelong, insize, qh->qhmem.totlong, qh->qhmem.cntlong-qh->qhmem.freelong);
  return object;
}

void qh_memcheck(qhT *qh) {
}

void qh_memfree(qhT *qh, void *object, int insize) {

  if (!object)
    return;
  qh_free(object);
  qh->qhmem.freelong++;
  qh->qhmem.totlong -= insize;
  if (qh->qhmem.IStracing >= 5)
    qh_fprintf(qh, qh->qhmem.ferr, 8061, "qh_mem %p n %8d free long: %d bytes (tot %d cnt %d)\n", object, qh->qhmem.cntlong+qh->qhmem.freelong, insize, qh->qhmem.totlong, qh->qhmem.cntlong-qh->qhmem.freelong);
}

void qh_memfreeshort(qhT *qh, int *curlong, int *totlong) {
  *totlong= qh->qhmem.totlong;
  *curlong= qh->qhmem.cntlong - qh->qhmem.freelong;
  memset((char *)&qh->qhmem, 0, sizeof(qh->qhmem));  /* every field is 0, FALSE, NULL */
}

void qh_meminit(qhT *qh, FILE *ferr) {

  memset((char *)&qh->qhmem, 0, sizeof(qh->qhmem));  /* every field is 0, FALSE, NULL */
  if (ferr)
      qh->qhmem.ferr= ferr;
  else
      qh->qhmem.ferr= stderr;
  if (sizeof(void *) < sizeof(int)) {
    qh_fprintf(qh, qh->qhmem.ferr, 6091, "qhull internal error (qh_meminit): sizeof(void *) %d < sizeof(int) %d.  qset_r.c will not work\n", (int)sizeof(void*), (int)sizeof(int));
    qh_errexit(qh, qhmem_ERRqhull, NULL, NULL);
  }
}

void qh_meminitbuffers(qhT *qh, int tracelevel, int alignment, int numsizes, int bufsize, int bufinit) {

  qh->qhmem.IStracing= tracelevel;
}

void qh_memsetup(qhT *qh) {
}

void qh_memsize(qhT *qh, int size) {
}

void qh_memstatistics(qhT *qh, FILE *fp) {

  qh_fprintf(qh, fp, 9409, "\nmemory statistics:\n\
%7d long allocations\n\
%7d long frees\n\
%7d bytes of long memory allocated (max, except for input)\n\
%7d bytes of long memory in use (in %d pieces)\n",
           qh->qhmem.cntlong,
           qh->qhmem.freelong,
           qh->qhmem.maxlong, qh->qhmem.totlong, qh->qhmem.cntlong - qh->qhmem.freelong);
}

#endif /* qh_NOmem */

/*---------------------------------

  qh_memtotal(qh, totlong, curlong, totshort, curshort, maxlong, totbuffer )
    Return the total, allocated long and short memory

  returns:
    Returns the total current bytes of long and short allocations
    Returns the current count of long and short allocations
    Returns the maximum long memory and total short buffer (minus one link per buffer)
    Does not error (for deprecated UsingLibQhull.cpp in libqhullpcpp)
*/
void qh_memtotal(qhT *qh, int *totlong, int *curlong, int *totshort, int *curshort, int *maxlong, int *totbuffer) {
    *totlong= qh->qhmem.totlong;
    *curlong= qh->qhmem.cntlong - qh->qhmem.freelong;
    *totshort= qh->qhmem.totshort;
    *curshort= qh->qhmem.cntshort + qh->qhmem.cntquick - qh->qhmem.freeshort;
    *maxlong= qh->qhmem.maxlong;
    *totbuffer= qh->qhmem.totbuffer;
} /* memtotlong */

geometry/src/Rtsearch_orig.c0000644000176200001440000001321514664417655015657 0ustar  liggesusers/*

  Copyright (C) 2002-2011, 2017 Andreas Stahel
  Copyright (C) 2011-2017 David Sterratt

  This program is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published by the
  Free Software Foundation; either version 3 of the License, or (at your
  option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  for more details.

  You should have received a copy of the GNU General Public License
  along with this program. If not, see
  .

*/

/* Originally written for Octave */
/* Author: Andreas Stahel  */
/* 19 August 2011: Ported to R by David Sterratt  */

#include 
#include 
#include 
#include 
#include "Rgeometry.h"
#include "qhull_ra.h"

static inline double max (double a, double b, double c)
{
  if (a < b)
    return (b < c ? c : b);
  else
    return (a < c ? c : a);
}

static inline double min (double a, double b, double c)
{
  if (a > b)
    return (b > c ? c : b);
  else
    return (a > c ? c : a);
}


#define REF(x,k,i) x[ielem[k + i*nelem] - 1]

/* for large data set the algorithm is very slow one should presort
 (how?) either the elements of the points of evaluation to cut down
 the time needed to decide which triangle contains the given point

 e.g., build up a neighbouring triangle structure and use a simplex-like
 method to traverse it
*/

SEXP C_tsearch_orig(SEXP x,  SEXP y, SEXP elem,
                    SEXP xi, SEXP yi,
                    SEXP bary) {
  int ibary = 0;
  if (Rf_isLogical(bary))
    if (*LOGICAL(bary) == TRUE)
      ibary = 1;

  /* printf("Here 1\n"); */
  double *rx = REAL(x);
  double *ry = REAL(y);
  int nelem = Rf_nrows(elem);
  int *ielem = INTEGER(elem);
  double *rxi = REAL(xi);
  double *ryi = REAL(yi);
  int np = LENGTH(xi);
  /* printf("%i points\n", np); */
  SEXP minx, maxx, miny, maxy;
  PROTECT(minx = Rf_allocVector(REALSXP, nelem));
  PROTECT(maxx = Rf_allocVector(REALSXP, nelem));
  PROTECT(miny = Rf_allocVector(REALSXP, nelem));
  PROTECT(maxy = Rf_allocVector(REALSXP, nelem));
  double *rminx = REAL(minx);
  double *rmaxx = REAL(maxx);
  double *rminy = REAL(miny);
  double *rmaxy = REAL(maxy);

  /* Find bounding boxes of each triangle */
  for (int k = 0; k < nelem; k++) {
    /* printf("X[T[%i, 1]] = %f; T[%i, 1] = %i\n", k+1, REF(rx, k, 0), k+1, ielem[k + 0*nelem]); */
    rminx[k] = min(REF(rx, k, 0), REF(rx, k, 1), REF(rx, k, 2)) - DBL_EPSILON;
    rmaxx[k] = max(REF(rx, k, 0), REF(rx, k, 1), REF(rx, k, 2)) + DBL_EPSILON;
    rminy[k] = min(REF(ry, k, 0), REF(ry, k, 1), REF(ry, k, 2)) - DBL_EPSILON;
    rmaxy[k] = max(REF(ry, k, 0), REF(ry, k, 1), REF(ry, k, 2)) + DBL_EPSILON;
    /* printf("%f %f %f %f\n", rminx[k], rmaxx[k], rminy[k], rmaxy[k]); */
  }

  /* Make space for output */
  SEXP values;
  PROTECT(values = Rf_allocVector(INTSXP, np));
  int *ivalues = INTEGER(values);
  SEXP p = NULL;
  double *rp = NULL;
  if (ibary) {
    PROTECT(p = Rf_allocMatrix(REALSXP, np, 3));
    rp = REAL(p);
    for (int k = 0; k < 3*np; k++)
      rp[k] = NA_REAL;
  }

  double x0 = 0.0, y0 = 0.0;
  double a11 = 0.0, a12 = 0.0, a21 = 0.0, a22 = 0.0, det = 0.0;

  double xt, yt;
  double dx1, dx2, c1, c2;
  int k = nelem; // k is a counter of elements
  for (int kp = 0; kp < np; kp++) {
    xt = rxi[kp];
    yt = ryi[kp];

    /* check if last triangle contains the next point */
    if (k < nelem) {
      dx1 = xt - x0;
      dx2 = yt - y0;
      c1 = ( a22 * dx1 - a21 * dx2) / det;
      c2 = (-a12 * dx1 + a11 * dx2) / det;
      if ((c1 >= -DBL_EPSILON) && (c2 >= -DBL_EPSILON) && ((c1 + c2) <= (1 + DBL_EPSILON))) {
        ivalues[kp] = k+1;
        if (ibary) {
          rp[kp] = 1 - c1 - c2;
          rp[kp+np] = c1;
          rp[kp+2*np] = c2;
        }
        continue;
      }
    }

    // it doesn't, so go through all elements
    for (k = 0; k < nelem; k++) {
      /* OCTAVE_QUIT; */
      if (xt >= rminx[k] && xt <= rmaxx[k] && yt >= rminy[k] && yt <= rmaxy[k]) {
        /* printf("Point %i (%1.3f, %1.3f) could be in triangle %i (%1.3f, %1.3f) (%1.3f, %1.3f)\n",  */
        /*        kp+1, xt, yt, k+1, rminx[k], rminy[k], rmaxx[k], rmaxy[k]); */
        // element inside the minimum rectangle: examine it closely
        x0  = REF(rx, k, 0);
        y0  = REF(ry, k, 0);
        /* printf("Triangle %i: x0=%f, y0=%f\n", k+1, x0, y0); */
        a11 = REF(rx, k, 1) - x0;
        a12 = REF(ry, k, 1) - y0;
        a21 = REF(rx, k, 2) - x0;
        a22 = REF(ry, k, 2) - y0;
        det = a11 * a22 - a21 * a12;

        // solve the system
        dx1 = xt - x0;
        dx2 = yt - y0;
        c1 = ( a22 * dx1 - a21 * dx2) / det;
        c2 = (-a12 * dx1 + a11 * dx2) / det;
        if ((c1 >= -DBL_EPSILON) && (c2 >= -DBL_EPSILON) && ((c1 + c2) <= (1 + DBL_EPSILON))) {
          /* printf("Setting point %i's triangle to %i\n", kp+1, k+1);  */
          ivalues[kp] = k+1;
          if (ibary) {
            rp[kp] = 1 - c1 - c2;
            rp[kp+np] = c1;
            rp[kp+2*np] = c2;
          }
          break;
        }
      } //endif # examine this element closely
    } //endfor # each element
    /* printf("%i\n", kp); */
    if (k == nelem) {
      ivalues[kp] = NA_INTEGER;
    }
  } //endfor # kp

  SEXP ans;
  if (ibary) {
    PROTECT(ans = Rf_allocVector(VECSXP, 2));
    SET_VECTOR_ELT(ans, 0, values);
    SET_VECTOR_ELT(ans, 1, p);
    UNPROTECT(7);
    return(ans);
  } else {
    UNPROTECT(5);
    return(values);
  }
}
geometry/src/geometry_init.c0000644000176200001440000000230014662323271015717 0ustar  liggesusers#include 
#include 
#include  // for NULL
#include 

/* FIXME: 
   Check these declarations against the C/Fortran source code.
*/

/* .Call calls */
extern SEXP _geometry_C_tsearch(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP C_convhulln(SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP C_delaunayn(SEXP, SEXP, SEXP, SEXP);
extern SEXP C_halfspacen(SEXP, SEXP, SEXP, SEXP);
extern SEXP C_inhulln(SEXP, SEXP);
extern SEXP C_tsearch_orig(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP);
extern SEXP C_tsearchn(SEXP, SEXP);

static const R_CallMethodDef CallEntries[] = {
    {"_geometry_C_tsearch", (DL_FUNC) &_geometry_C_tsearch, 7},
    {"C_convhulln",         (DL_FUNC) &C_convhulln,         5},
    {"C_delaunayn",         (DL_FUNC) &C_delaunayn,         4},
    {"C_halfspacen",        (DL_FUNC) &C_halfspacen,        4},
    {"C_inhulln",           (DL_FUNC) &C_inhulln,           2},
    {"C_tsearch_orig",      (DL_FUNC) &C_tsearch_orig,      6},
    {"C_tsearchn",          (DL_FUNC) &C_tsearchn,          2},
    {NULL, NULL, 0}
};

void R_init_geometry(DllInfo *dll)
{
    R_registerRoutines(dll, NULL, CallEntries, NULL, NULL);
    R_useDynamicSymbols(dll, FALSE);
}
geometry/src/geom2_r.c0000644000176200001440000022645114664417655014426 0ustar  liggesusers/*
  ---------------------------------


   geom2_r.c
   infrequently used geometric routines of qhull

   see qh-geom_r.htm and geom_r.h

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/geom2_r.c#17 $$Change: 3037 $
   $DateTime: 2020/09/03 17:28:32 $$Author: bbarber $

   frequently used code goes into geom_r.c
*/

#include "qhull_ra.h"

/*================== functions in alphabetic order ============*/

/*---------------------------------

  qh_copypoints(qh, points, numpoints, dimension )
    return qh_malloc'd copy of points

  notes:
    qh_free the returned points to avoid a memory leak
*/
coordT *qh_copypoints(qhT *qh, coordT *points, int numpoints, int dimension)
{
  int size;
  coordT *newpoints;

  size= numpoints * dimension * (int)sizeof(coordT);
  if (!(newpoints= (coordT *)qh_malloc((size_t)size))) {
    qh_fprintf(qh, qh->ferr, 6004, "qhull error: insufficient memory to copy %d points\n",
        numpoints);
    qh_errexit(qh, qh_ERRmem, NULL, NULL);
  }
  memcpy((char *)newpoints, (char *)points, (size_t)size); /* newpoints!=0 by QH6004 */
  return newpoints;
} /* copypoints */

/*---------------------------------

  qh_crossproduct( dim, vecA, vecB, vecC )
    crossproduct of 2 dim vectors
    C= A x B

  notes:
    from Glasner, Graphics Gems I, p. 639
    only defined for dim==3
*/
void qh_crossproduct(int dim, realT vecA[3], realT vecB[3], realT vecC[3]){

  if (dim == 3) {
    vecC[0]=   det2_(vecA[1], vecA[2],
                     vecB[1], vecB[2]);
    vecC[1]= - det2_(vecA[0], vecA[2],
                     vecB[0], vecB[2]);
    vecC[2]=   det2_(vecA[0], vecA[1],
                     vecB[0], vecB[1]);
  }
} /* vcross */

/*---------------------------------

  qh_determinant(qh, rows, dim, nearzero )
    compute signed determinant of a square matrix
    uses qh.NEARzero to test for degenerate matrices

  returns:
    determinant
    overwrites rows and the matrix
    if dim == 2 or 3
      nearzero iff determinant < qh->NEARzero[dim-1]
      (!quite correct, not critical)
    if dim >= 4
      nearzero iff diagonal[k] < qh->NEARzero[k]
*/
realT qh_determinant(qhT *qh, realT **rows, int dim, boolT *nearzero) {
  realT det=0;
  int i;
  boolT sign= False;

  *nearzero= False;
  if (dim < 2) {
    qh_fprintf(qh, qh->ferr, 6005, "qhull internal error (qh_determinate): only implemented for dimension >= 2\n");
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }else if (dim == 2) {
    det= det2_(rows[0][0], rows[0][1],
                 rows[1][0], rows[1][1]);
    if (fabs_(det) < 10*qh->NEARzero[1])  /* QH11031 FIX: not really correct, what should this be? */
      *nearzero= True;
  }else if (dim == 3) {
    det= det3_(rows[0][0], rows[0][1], rows[0][2],
                 rows[1][0], rows[1][1], rows[1][2],
                 rows[2][0], rows[2][1], rows[2][2]);
    if (fabs_(det) < 10*qh->NEARzero[2])  /* QH11031 FIX: what should this be?  det 5.5e-12 was flat for qh_maxsimplex of qdelaunay 0,0 27,27 -36,36 -9,63 */
      *nearzero= True;
  }else {
    qh_gausselim(qh, rows, dim, dim, &sign, nearzero);  /* if nearzero, diagonal still ok */
    det= 1.0;
    for (i=dim; i--; )
      det *= (rows[i])[i];
    if (sign)
      det= -det;
  }
  return det;
} /* determinant */

/*---------------------------------

  qh_detjoggle(qh, points, numpoints, dimension )
    determine default max joggle for point array
      as qh_distround * qh_JOGGLEdefault

  returns:
    initial value for JOGGLEmax from points and REALepsilon

  notes:
    computes DISTround since qh_maxmin not called yet
    if qh->SCALElast, last dimension will be scaled later to MAXwidth

    loop duplicated from qh_maxmin
*/
realT qh_detjoggle(qhT *qh, pointT *points, int numpoints, int dimension) {
  realT abscoord, distround, joggle, maxcoord, mincoord;
  pointT *point, *pointtemp;
  realT maxabs= -REALmax;
  realT sumabs= 0;
  realT maxwidth= 0;
  int k;

  if (qh->SETroundoff)
    distround= qh->DISTround; /* 'En' */
  else{
    for (k=0; k < dimension; k++) {
      if (qh->SCALElast && k == dimension-1)
        abscoord= maxwidth;
      else if (qh->DELAUNAY && k == dimension-1) /* will qh_setdelaunay() */
        abscoord= 2 * maxabs * maxabs;  /* may be low by qh->hull_dim/2 */
      else {
        maxcoord= -REALmax;
        mincoord= REALmax;
        FORALLpoint_(qh, points, numpoints) {
          maximize_(maxcoord, point[k]);
          minimize_(mincoord, point[k]);
        }
        maximize_(maxwidth, maxcoord-mincoord);
        abscoord= fmax_(maxcoord, -mincoord);
      }
      sumabs += abscoord;
      maximize_(maxabs, abscoord);
    } /* for k */
    distround= qh_distround(qh, qh->hull_dim, maxabs, sumabs);
  }
  joggle= distround * qh_JOGGLEdefault;
  maximize_(joggle, REALepsilon * qh_JOGGLEdefault);
  trace2((qh, qh->ferr, 2001, "qh_detjoggle: joggle=%2.2g maxwidth=%2.2g\n", joggle, maxwidth));
  return joggle;
} /* detjoggle */

/*---------------------------------

  qh_detmaxoutside(qh);
    determine qh.MAXoutside target for qh_RATIO... tests of distance
    updates option '_max-outside'

  notes:
    called from qh_addpoint and qh_detroundoff
    accounts for qh.ONEmerge, qh.DISTround, qh.MINoutside ('Wn'), qh.max_outside
    see qh_maxout for qh.max_outside with qh.DISTround
*/

void qh_detmaxoutside(qhT *qh) {
  realT maxoutside;

  maxoutside= fmax_(qh->max_outside, qh->ONEmerge + qh->DISTround);
  maximize_(maxoutside, qh->MINoutside);
  qh->MAXoutside= maxoutside;
  trace3((qh, qh->ferr, 3056, "qh_detmaxoutside: MAXoutside %2.2g from qh.max_outside %2.2g, ONEmerge %2.2g, MINoutside %2.2g, DISTround %2.2g\n",
      qh->MAXoutside, qh->max_outside, qh->ONEmerge, qh->MINoutside, qh->DISTround));
} /* detmaxoutside */

/*---------------------------------

  qh_detroundoff(qh)
    determine maximum roundoff errors from
      REALepsilon, REALmax, REALmin, qh.hull_dim, qh.MAXabs_coord,
      qh.MAXsumcoord, qh.MAXwidth, qh.MINdenom_1

    accounts for qh.SETroundoff, qh.RANDOMdist, qh->MERGEexact
      qh.premerge_cos, qh.postmerge_cos, qh.premerge_centrum,
      qh.postmerge_centrum, qh.MINoutside,
      qh_RATIOnearinside, qh_COPLANARratio, qh_WIDEcoplanar

  returns:
    sets qh.DISTround, etc. (see below)
    appends precision constants to qh.qhull_options

  see:
    qh_maxmin() for qh.NEARzero

  design:
    determine qh.DISTround for distance computations
    determine minimum denominators for qh_divzero
    determine qh.ANGLEround for angle computations
    adjust qh.premerge_cos,... for roundoff error
    determine qh.ONEmerge for maximum error due to a single merge
    determine qh.NEARinside, qh.MAXcoplanar, qh.MINvisible,
      qh.MINoutside, qh.WIDEfacet
    initialize qh.max_vertex and qh.minvertex
*/
void qh_detroundoff(qhT *qh) {

  qh_option(qh, "_max-width", NULL, &qh->MAXwidth);
  if (!qh->SETroundoff) {
    qh->DISTround= qh_distround(qh, qh->hull_dim, qh->MAXabs_coord, qh->MAXsumcoord);
    qh_option(qh, "Error-roundoff", NULL, &qh->DISTround);
  }
  qh->MINdenom= qh->MINdenom_1 * qh->MAXabs_coord;
  qh->MINdenom_1_2= sqrt(qh->MINdenom_1 * qh->hull_dim) ;  /* if will be normalized */
  qh->MINdenom_2= qh->MINdenom_1_2 * qh->MAXabs_coord;
                                              /* for inner product */
  qh->ANGLEround= 1.01 * qh->hull_dim * REALepsilon;
  if (qh->RANDOMdist) {
    qh->ANGLEround += qh->RANDOMfactor;
    trace4((qh, qh->ferr, 4096, "qh_detroundoff: increase qh.ANGLEround by option 'R%2.2g'\n", qh->RANDOMfactor));
  }
  if (qh->premerge_cos < REALmax/2) {
    qh->premerge_cos -= qh->ANGLEround;
    if (qh->RANDOMdist)
      qh_option(qh, "Angle-premerge-with-random", NULL, &qh->premerge_cos);
  }
  if (qh->postmerge_cos < REALmax/2) {
    qh->postmerge_cos -= qh->ANGLEround;
    if (qh->RANDOMdist)
      qh_option(qh, "Angle-postmerge-with-random", NULL, &qh->postmerge_cos);
  }
  qh->premerge_centrum += 2 * qh->DISTround;    /*2 for centrum and distplane()*/
  qh->postmerge_centrum += 2 * qh->DISTround;
  if (qh->RANDOMdist && (qh->MERGEexact || qh->PREmerge))
    qh_option(qh, "Centrum-premerge-with-random", NULL, &qh->premerge_centrum);
  if (qh->RANDOMdist && qh->POSTmerge)
    qh_option(qh, "Centrum-postmerge-with-random", NULL, &qh->postmerge_centrum);
  { /* compute ONEmerge, max vertex offset for merging simplicial facets */
    realT maxangle= 1.0, maxrho;

    minimize_(maxangle, qh->premerge_cos);
    minimize_(maxangle, qh->postmerge_cos);
    /* max diameter * sin theta + DISTround for vertex to its hyperplane */
    qh->ONEmerge= sqrt((realT)qh->hull_dim) * qh->MAXwidth *
      sqrt(1.0 - maxangle * maxangle) + qh->DISTround;
    maxrho= qh->hull_dim * qh->premerge_centrum + qh->DISTround;
    maximize_(qh->ONEmerge, maxrho);
    maxrho= qh->hull_dim * qh->postmerge_centrum + qh->DISTround;
    maximize_(qh->ONEmerge, maxrho);
    if (qh->MERGING)
      qh_option(qh, "_one-merge", NULL, &qh->ONEmerge);
  }
  qh->NEARinside= qh->ONEmerge * qh_RATIOnearinside; /* only used if qh->KEEPnearinside */
  if (qh->JOGGLEmax < REALmax/2 && (qh->KEEPcoplanar || qh->KEEPinside)) {
    realT maxdist;             /* adjust qh.NEARinside for joggle */
    qh->KEEPnearinside= True;
    maxdist= sqrt((realT)qh->hull_dim) * qh->JOGGLEmax + qh->DISTround;
    maxdist= 2*maxdist;        /* vertex and coplanar point can joggle in opposite directions */
    maximize_(qh->NEARinside, maxdist);  /* must agree with qh_nearcoplanar() */
  }
  if (qh->KEEPnearinside)
    qh_option(qh, "_near-inside", NULL, &qh->NEARinside);
  if (qh->JOGGLEmax < qh->DISTround) {
    qh_fprintf(qh, qh->ferr, 6006, "qhull option error: the joggle for 'QJn', %.2g, is below roundoff for distance computations, %.2g\n",
         qh->JOGGLEmax, qh->DISTround);
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  if (qh->MINvisible > REALmax/2) {
    if (!qh->MERGING)
      qh->MINvisible= qh->DISTround;
    else if (qh->hull_dim <= 3)
      qh->MINvisible= qh->premerge_centrum;
    else
      qh->MINvisible= qh_COPLANARratio * qh->premerge_centrum;
    if (qh->APPROXhull && qh->MINvisible > qh->MINoutside)
      qh->MINvisible= qh->MINoutside;
    qh_option(qh, "Visible-distance", NULL, &qh->MINvisible);
  }
  if (qh->MAXcoplanar > REALmax/2) {
    qh->MAXcoplanar= qh->MINvisible;
    qh_option(qh, "U-max-coplanar", NULL, &qh->MAXcoplanar);
  }
  if (!qh->APPROXhull) {             /* user may specify qh->MINoutside */
    qh->MINoutside= 2 * qh->MINvisible;
    if (qh->premerge_cos < REALmax/2)
      maximize_(qh->MINoutside, (1- qh->premerge_cos) * qh->MAXabs_coord);
    qh_option(qh, "Width-outside", NULL, &qh->MINoutside);
  }
  qh->WIDEfacet= qh->MINoutside;
  maximize_(qh->WIDEfacet, qh_WIDEcoplanar * qh->MAXcoplanar);
  maximize_(qh->WIDEfacet, qh_WIDEcoplanar * qh->MINvisible);
  qh_option(qh, "_wide-facet", NULL, &qh->WIDEfacet);
  if (qh->MINvisible > qh->MINoutside + 3 * REALepsilon
  && !qh->BESToutside && !qh->FORCEoutput)
    qh_fprintf(qh, qh->ferr, 7001, "qhull input warning: minimum visibility V%.2g is greater than \nminimum outside W%.2g.  Flipped facets are likely.\n",
             qh->MINvisible, qh->MINoutside);
  qh->max_vertex= qh->DISTround;
  qh->min_vertex= -qh->DISTround;
  /* numeric constants reported in printsummary */
  qh_detmaxoutside(qh);
} /* detroundoff */

/*---------------------------------

  qh_detsimplex(qh, apex, points, dim, nearzero )
    compute determinant of a simplex with point apex and base points

  returns:
     signed determinant and nearzero from qh_determinant

  notes:
     called by qh_maxsimplex and qh_initialvertices
     uses qh.gm_matrix/qh.gm_row (assumes they're big enough)

  design:
    construct qm_matrix by subtracting apex from points
    compute determinate
*/
realT qh_detsimplex(qhT *qh, pointT *apex, setT *points, int dim, boolT *nearzero) {
  pointT *coorda, *coordp, *gmcoord, *point, **pointp;
  coordT **rows;
  int k,  i=0;
  realT det;

  zinc_(Zdetsimplex);
  gmcoord= qh->gm_matrix;
  rows= qh->gm_row;
  FOREACHpoint_(points) {
    if (i == dim)
      break;
    rows[i++]= gmcoord;
    coordp= point;
    coorda= apex;
    for (k=dim; k--; )
      *(gmcoord++)= *coordp++ - *coorda++;
  }
  if (i < dim) {
    qh_fprintf(qh, qh->ferr, 6007, "qhull internal error (qh_detsimplex): #points %d < dimension %d\n",
               i, dim);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  det= qh_determinant(qh, rows, dim, nearzero);
  trace2((qh, qh->ferr, 2002, "qh_detsimplex: det=%2.2g for point p%d, dim %d, nearzero? %d\n",
          det, qh_pointid(qh, apex), dim, *nearzero));
  return det;
} /* detsimplex */

/*---------------------------------

  qh_distnorm( dim, point, normal, offset )
    return distance from point to hyperplane at normal/offset

  returns:
    dist

  notes:
    dist > 0 if point is outside of hyperplane

  see:
    qh_distplane in geom_r.c
*/
realT qh_distnorm(int dim, pointT *point, pointT *normal, realT *offsetp) {
  coordT *normalp= normal, *coordp= point;
  realT dist;
  int k;

  dist= *offsetp;
  for (k=dim; k--; )
    dist += *(coordp++) * *(normalp++);
  return dist;
} /* distnorm */

/*---------------------------------

  qh_distround(qh, dimension, maxabs, maxsumabs )
    compute maximum round-off error for a distance computation
      to a normalized hyperplane
    maxabs is the maximum absolute value of a coordinate
    maxsumabs is the maximum possible sum of absolute coordinate values
    if qh.RANDOMdist ('Qr'), adjusts qh_distround

  returns:
    max dist round for qh.REALepsilon and qh.RANDOMdist

  notes:
    calculate roundoff error according to Golub & van Loan, 1983, Lemma 3.2-1, "Rounding Errors"
    use sqrt(dim) since one vector is normalized
      or use maxsumabs since one vector is < 1
*/
realT qh_distround(qhT *qh, int dimension, realT maxabs, realT maxsumabs) {
  realT maxdistsum, maxround, delta;

  maxdistsum= sqrt((realT)dimension) * maxabs;
  minimize_( maxdistsum, maxsumabs);
  maxround= REALepsilon * (dimension * maxdistsum * 1.01 + maxabs);
              /* adds maxabs for offset */
  if (qh->RANDOMdist) {
    delta= qh->RANDOMfactor * maxabs;
    maxround += delta;
    trace4((qh, qh->ferr, 4092, "qh_distround: increase roundoff by random delta %2.2g for option 'R%2.2g'\n", delta, qh->RANDOMfactor));
  }
  trace4((qh, qh->ferr, 4008, "qh_distround: %2.2g, maxabs %2.2g, maxsumabs %2.2g, maxdistsum %2.2g\n",
            maxround, maxabs, maxsumabs, maxdistsum));
  return maxround;
} /* distround */

/*---------------------------------

  qh_divzero( numer, denom, mindenom1, zerodiv )
    divide by a number that's nearly zero
    mindenom1= minimum denominator for dividing into 1.0

  returns:
    quotient
    sets zerodiv and returns 0.0 if it would overflow

  design:
    if numer is nearly zero and abs(numer) < abs(denom)
      return numer/denom
    else if numer is nearly zero
      return 0 and zerodiv
    else if denom/numer non-zero
      return numer/denom
    else
      return 0 and zerodiv
*/
realT qh_divzero(realT numer, realT denom, realT mindenom1, boolT *zerodiv) {
  realT temp, numerx, denomx;


  if (numer < mindenom1 && numer > -mindenom1) {
    numerx= fabs_(numer);
    denomx= fabs_(denom);
    if (numerx < denomx) {
      *zerodiv= False;
      return numer/denom;
    }else {
      *zerodiv= True;
      return 0.0;
    }
  }
  temp= denom/numer;
  if (temp > mindenom1 || temp < -mindenom1) {
    *zerodiv= False;
    return numer/denom;
  }else {
    *zerodiv= True;
    return 0.0;
  }
} /* divzero */


/*---------------------------------

  qh_facetarea(qh, facet )
    return area for a facet

  notes:
    if non-simplicial,
      uses centrum to triangulate facet and sums the projected areas.
    if (qh->DELAUNAY),
      computes projected area instead for last coordinate
    assumes facet->normal exists
    projecting tricoplanar facets to the hyperplane does not appear to make a difference

  design:
    if simplicial
      compute area
    else
      for each ridge
        compute area from centrum to ridge
    negate area if upper Delaunay facet
*/
realT qh_facetarea(qhT *qh, facetT *facet) {
  vertexT *apex;
  pointT *centrum;
  realT area= 0.0;
  ridgeT *ridge, **ridgep;

  if (facet->simplicial) {
    apex= SETfirstt_(facet->vertices, vertexT);
    area= qh_facetarea_simplex(qh, qh->hull_dim, apex->point, facet->vertices,
                    apex, facet->toporient, facet->normal, &facet->offset);
  }else {
    if (qh->CENTERtype == qh_AScentrum)
      centrum= facet->center;
    else
      centrum= qh_getcentrum(qh, facet);
    FOREACHridge_(facet->ridges)
      area += qh_facetarea_simplex(qh, qh->hull_dim, centrum, ridge->vertices,
                 NULL, (boolT)(ridge->top == facet),  facet->normal, &facet->offset);
    if (qh->CENTERtype != qh_AScentrum)
      qh_memfree(qh, centrum, qh->normal_size);
  }
  if (facet->upperdelaunay && qh->DELAUNAY)
    area= -area;  /* the normal should be [0,...,1] */
  trace4((qh, qh->ferr, 4009, "qh_facetarea: f%d area %2.2g\n", facet->id, area));
  return area;
} /* facetarea */

/*---------------------------------

  qh_facetarea_simplex(qh, dim, apex, vertices, notvertex, toporient, normal, offset )
    return area for a simplex defined by
      an apex, a base of vertices, an orientation, and a unit normal
    if simplicial or tricoplanar facet,
      notvertex is defined and it is skipped in vertices

  returns:
    computes area of simplex projected to plane [normal,offset]
    returns 0 if vertex too far below plane (qh->WIDEfacet)
      vertex can't be apex of tricoplanar facet

  notes:
    if (qh->DELAUNAY),
      computes projected area instead for last coordinate
    uses qh->gm_matrix/gm_row and qh->hull_dim
    helper function for qh_facetarea

  design:
    if Notvertex
      translate simplex to apex
    else
      project simplex to normal/offset
      translate simplex to apex
    if Delaunay
      set last row/column to 0 with -1 on diagonal
    else
      set last row to Normal
    compute determinate
    scale and flip sign for area
*/
realT qh_facetarea_simplex(qhT *qh, int dim, coordT *apex, setT *vertices,
        vertexT *notvertex,  boolT toporient, coordT *normal, realT *offset) {
  pointT *coorda, *coordp, *gmcoord;
  coordT **rows, *normalp;
  int k,  i=0;
  realT area, dist;
  vertexT *vertex, **vertexp;
  boolT nearzero;

  gmcoord= qh->gm_matrix;
  rows= qh->gm_row;
  FOREACHvertex_(vertices) {
    if (vertex == notvertex)
      continue;
    rows[i++]= gmcoord;
    coorda= apex;
    coordp= vertex->point;
    normalp= normal;
    if (notvertex) {
      for (k=dim; k--; )
        *(gmcoord++)= *coordp++ - *coorda++;
    }else {
      dist= *offset;
      for (k=dim; k--; )
        dist += *coordp++ * *normalp++;
      if (dist < -qh->WIDEfacet) {
        zinc_(Znoarea);
        return 0.0;
      }
      coordp= vertex->point;
      normalp= normal;
      for (k=dim; k--; )
        *(gmcoord++)= (*coordp++ - dist * *normalp++) - *coorda++;
    }
  }
  if (i != dim-1) {
    qh_fprintf(qh, qh->ferr, 6008, "qhull internal error (qh_facetarea_simplex): #points %d != dim %d -1\n",
               i, dim);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  rows[i]= gmcoord;
  if (qh->DELAUNAY) {
    for (i=0; i < dim-1; i++)
      rows[i][dim-1]= 0.0;
    for (k=dim; k--; )
      *(gmcoord++)= 0.0;
    rows[dim-1][dim-1]= -1.0;
  }else {
    normalp= normal;
    for (k=dim; k--; )
      *(gmcoord++)= *normalp++;
  }
  zinc_(Zdetfacetarea);
  area= qh_determinant(qh, rows, dim, &nearzero);
  if (toporient)
    area= -area;
  area *= qh->AREAfactor;
  trace4((qh, qh->ferr, 4010, "qh_facetarea_simplex: area=%2.2g for point p%d, toporient %d, nearzero? %d\n",
          area, qh_pointid(qh, apex), toporient, nearzero));
  return area;
} /* facetarea_simplex */

/*---------------------------------

  qh_facetcenter(qh, vertices )
    return Voronoi center (Voronoi vertex) for a facet's vertices

  returns:
    return temporary point equal to the center

  see:
    qh_voronoi_center()
*/
pointT *qh_facetcenter(qhT *qh, setT *vertices) {
  setT *points= qh_settemp(qh, qh_setsize(qh, vertices));
  vertexT *vertex, **vertexp;
  pointT *center;

  FOREACHvertex_(vertices)
    qh_setappend(qh, &points, vertex->point);
  center= qh_voronoi_center(qh, qh->hull_dim-1, points);
  qh_settempfree(qh, &points);
  return center;
} /* facetcenter */

/*---------------------------------

  qh_findgooddist(qh, point, facetA, dist, facetlist )
    find best good facet visible for point from facetA
    assumes facetA is visible from point

  returns:
    best facet, i.e., good facet that is furthest from point
      distance to best facet
      NULL if none

    moves good, visible facets (and some other visible facets)
      to end of qh->facet_list

  notes:
    uses qh->visit_id

  design:
    initialize bestfacet if facetA is good
    move facetA to end of facetlist
    for each facet on facetlist
      for each unvisited neighbor of facet
        move visible neighbors to end of facetlist
        update best good neighbor
        if no good neighbors, update best facet
*/
facetT *qh_findgooddist(qhT *qh, pointT *point, facetT *facetA, realT *distp,
               facetT **facetlist) {
  realT bestdist= -REALmax, dist;
  facetT *neighbor, **neighborp, *bestfacet=NULL, *facet;
  boolT goodseen= False;

  if (facetA->good) {
    zzinc_(Zcheckpart);  /* calls from check_bestdist occur after print stats */
    qh_distplane(qh, point, facetA, &bestdist);
    bestfacet= facetA;
    goodseen= True;
  }
  qh_removefacet(qh, facetA);
  qh_appendfacet(qh, facetA);
  *facetlist= facetA;
  facetA->visitid= ++qh->visit_id;
  FORALLfacet_(*facetlist) {
    FOREACHneighbor_(facet) {
      if (neighbor->visitid == qh->visit_id)
        continue;
      neighbor->visitid= qh->visit_id;
      if (goodseen && !neighbor->good)
        continue;
      zzinc_(Zcheckpart);
      qh_distplane(qh, point, neighbor, &dist);
      if (dist > 0) {
        qh_removefacet(qh, neighbor);
        qh_appendfacet(qh, neighbor);
        if (neighbor->good) {
          goodseen= True;
          if (dist > bestdist) {
            bestdist= dist;
            bestfacet= neighbor;
          }
        }
      }
    }
  }
  if (bestfacet) {
    *distp= bestdist;
    trace2((qh, qh->ferr, 2003, "qh_findgooddist: p%d is %2.2g above good facet f%d\n",
      qh_pointid(qh, point), bestdist, bestfacet->id));
    return bestfacet;
  }
  trace4((qh, qh->ferr, 4011, "qh_findgooddist: no good facet for p%d above f%d\n",
      qh_pointid(qh, point), facetA->id));
  return NULL;
}  /* findgooddist */

/*---------------------------------

  qh_furthestnewvertex(qh, unvisited, facet, &maxdist )
    return furthest unvisited, new vertex to a facet

  return:
    NULL if no vertex is above facet
    maxdist to facet
    updates v.visitid

  notes:
    Ignores vertices in facetB
    Does not change qh.vertex_visit.  Use in conjunction with qh_furthestvertex
*/
vertexT *qh_furthestnewvertex(qhT *qh, unsigned int unvisited, facetT *facet, realT *maxdistp /* qh.newvertex_list */) {
  vertexT *maxvertex= NULL, *vertex;
  coordT dist, maxdist= 0.0;

  FORALLvertex_(qh->newvertex_list) {
    if (vertex->newfacet && vertex->visitid <= unvisited) {
      vertex->visitid= qh->vertex_visit;
      qh_distplane(qh, vertex->point, facet, &dist);
      if (dist > maxdist) {
        maxdist= dist;
        maxvertex= vertex;
      }
    }
  }
  trace4((qh, qh->ferr, 4085, "qh_furthestnewvertex: v%d dist %2.2g is furthest new vertex for f%d\n",
    getid_(maxvertex), maxdist, facet->id));
  *maxdistp= maxdist;
  return maxvertex;
} /* furthestnewvertex */

/*---------------------------------

  qh_furthestvertex(qh, facetA, facetB, &maxdist, &mindist )
    return furthest vertex in facetA from facetB, or NULL if none

  return:
    maxdist and mindist to facetB or 0.0 if none
    updates qh.vertex_visit

  notes:
    Ignores vertices in facetB
*/
vertexT *qh_furthestvertex(qhT *qh, facetT *facetA, facetT *facetB, realT *maxdistp, realT *mindistp) {
  vertexT *maxvertex= NULL, *vertex, **vertexp;
  coordT dist, maxdist= -REALmax, mindist= REALmax;

  qh->vertex_visit++;
  FOREACHvertex_(facetB->vertices)
    vertex->visitid= qh->vertex_visit;
  FOREACHvertex_(facetA->vertices) {
    if (vertex->visitid != qh->vertex_visit) {
      vertex->visitid= qh->vertex_visit;
      zzinc_(Zvertextests);
      qh_distplane(qh, vertex->point, facetB, &dist);
      if (!maxvertex) {
        maxdist= dist;
        mindist= dist;
        maxvertex= vertex;
      }else if (dist > maxdist) {
        maxdist= dist;
        maxvertex= vertex;
      }else if (dist < mindist)
        mindist= dist;
    }
  }
  if (!maxvertex) {
    trace3((qh, qh->ferr, 3067, "qh_furthestvertex: all vertices of f%d are in f%d.  Returning 0.0 for max and mindist\n",
      facetA->id, facetB->id));
    maxdist= mindist= 0.0;
  }else {
    trace4((qh, qh->ferr, 4084, "qh_furthestvertex: v%d dist %2.2g is furthest (mindist %2.2g) of f%d above f%d\n",
      maxvertex->id, maxdist, mindist, facetA->id, facetB->id));
  }
  *maxdistp= maxdist;
  *mindistp= mindist;
  return maxvertex;
} /* furthestvertex */

/*---------------------------------

  qh_getarea(qh, facetlist )
    set area of all facets in facetlist
    collect statistics
    nop if hasAreaVolume

  returns:
    sets qh->totarea/totvol to total area and volume of convex hull
    for Delaunay triangulation, computes projected area of the lower or upper hull
      ignores upper hull if qh->ATinfinity

  notes:
    could compute outer volume by expanding facet area by rays from interior
    the following attempt at perpendicular projection underestimated badly:
      qh.totoutvol += (-dist + facet->maxoutside + qh->DISTround)
                            * area/ qh->hull_dim;
  design:
    for each facet on facetlist
      compute facet->area
      update qh.totarea and qh.totvol
*/
void qh_getarea(qhT *qh, facetT *facetlist) {
  realT area;
  realT dist;
  facetT *facet;

  if (qh->hasAreaVolume)
    return;
  if (qh->REPORTfreq)
    qh_fprintf(qh, qh->ferr, 8020, "computing area of each facet and volume of the convex hull\n");
  else
    trace1((qh, qh->ferr, 1001, "qh_getarea: computing area for each facet and its volume to qh.interior_point (dist*area/dim)\n"));
  qh->totarea= qh->totvol= 0.0;
  FORALLfacet_(facetlist) {
    if (!facet->normal)
      continue;
    if (facet->upperdelaunay && qh->ATinfinity)
      continue;
    if (!facet->isarea) {
      facet->f.area= qh_facetarea(qh, facet);
      facet->isarea= True;
    }
    area= facet->f.area;
    if (qh->DELAUNAY) {
      if (facet->upperdelaunay == qh->UPPERdelaunay)
        qh->totarea += area;
    }else {
      qh->totarea += area;
      qh_distplane(qh, qh->interior_point, facet, &dist);
      qh->totvol += -dist * area/ qh->hull_dim;
    }
    if (qh->PRINTstatistics) {
      wadd_(Wareatot, area);
      wmax_(Wareamax, area);
      wmin_(Wareamin, area);
    }
  }
  qh->hasAreaVolume= True;
} /* getarea */

/*---------------------------------

  qh_gram_schmidt(qh, dim, row )
    implements Gram-Schmidt orthogonalization by rows

  returns:
    false if zero norm
    overwrites rows[dim][dim]

  notes:
    see Golub & van Loan, 1983, Algorithm 6.2-2, "Modified Gram-Schmidt"
    overflow due to small divisors not handled

  design:
    for each row
      compute norm for row
      if non-zero, normalize row
      for each remaining rowA
        compute inner product of row and rowA
        reduce rowA by row * inner product
*/
boolT qh_gram_schmidt(qhT *qh, int dim, realT **row) {
  realT *rowi, *rowj, norm;
  int i, j, k;

  for (i=0; i < dim; i++) {
    rowi= row[i];
    for (norm=0.0, k=dim; k--; rowi++)
      norm += *rowi * *rowi;
    norm= sqrt(norm);
    wmin_(Wmindenom, norm);
    if (norm == 0.0)  /* either 0 or overflow due to sqrt */
      return False;
    for (k=dim; k--; )
      *(--rowi) /= norm;
    for (j=i+1; j < dim; j++) {
      rowj= row[j];
      for (norm=0.0, k=dim; k--; )
        norm += *rowi++ * *rowj++;
      for (k=dim; k--; )
        *(--rowj) -= *(--rowi) * norm;
    }
  }
  return True;
} /* gram_schmidt */


/*---------------------------------

  qh_inthresholds(qh, normal, angle )
    return True if normal within qh.lower_/upper_threshold

  returns:
    estimate of angle by summing of threshold diffs
      angle may be NULL
      smaller "angle" is better

  notes:
    invalid if qh.SPLITthresholds

  see:
    qh.lower_threshold in qh_initbuild()
    qh_initthresholds()

  design:
    for each dimension
      test threshold
*/
boolT qh_inthresholds(qhT *qh, coordT *normal, realT *angle) {
  boolT within= True;
  int k;
  realT threshold;

  if (angle)
    *angle= 0.0;
  for (k=0; k < qh->hull_dim; k++) {
    threshold= qh->lower_threshold[k];
    if (threshold > -REALmax/2) {
      if (normal[k] < threshold)
        within= False;
      if (angle) {
        threshold -= normal[k];
        *angle += fabs_(threshold);
      }
    }
    if (qh->upper_threshold[k] < REALmax/2) {
      threshold= qh->upper_threshold[k];
      if (normal[k] > threshold)
        within= False;
      if (angle) {
        threshold -= normal[k];
        *angle += fabs_(threshold);
      }
    }
  }
  return within;
} /* inthresholds */


/*---------------------------------

  qh_joggleinput(qh)
    randomly joggle input to Qhull by qh.JOGGLEmax
    initial input is qh.first_point/qh.num_points of qh.hull_dim
      repeated calls use qh.input_points/qh.num_points

  returns:
    joggles points at qh.first_point/qh.num_points
    copies data to qh.input_points/qh.input_malloc if first time
    determines qh.JOGGLEmax if it was zero
    if qh.DELAUNAY
      computes the Delaunay projection of the joggled points

  notes:
    if qh.DELAUNAY, unnecessarily joggles the last coordinate
    the initial 'QJn' may be set larger than qh_JOGGLEmaxincrease

  design:
    if qh.DELAUNAY
      set qh.SCALElast for reduced precision errors
    if first call
      initialize qh.input_points to the original input points
      if qh.JOGGLEmax == 0
        determine default qh.JOGGLEmax
    else
      increase qh.JOGGLEmax according to qh.build_cnt
    joggle the input by adding a random number in [-qh.JOGGLEmax,qh.JOGGLEmax]
    if qh.DELAUNAY
      sets the Delaunay projection
*/
void qh_joggleinput(qhT *qh) {
  int i, seed, size;
  coordT *coordp, *inputp;
  realT randr, randa, randb;

  if (!qh->input_points) { /* first call */
    qh->input_points= qh->first_point;
    qh->input_malloc= qh->POINTSmalloc;
    size= qh->num_points * qh->hull_dim * (int)sizeof(coordT);
    if (!(qh->first_point= (coordT *)qh_malloc((size_t)size))) {
      qh_fprintf(qh, qh->ferr, 6009, "qhull error: insufficient memory to joggle %d points\n",
          qh->num_points);
      qh_errexit(qh, qh_ERRmem, NULL, NULL);
    }
    qh->POINTSmalloc= True;
    if (qh->JOGGLEmax == 0.0) {
      qh->JOGGLEmax= qh_detjoggle(qh, qh->input_points, qh->num_points, qh->hull_dim);
      qh_option(qh, "QJoggle", NULL, &qh->JOGGLEmax);
    }
  }else {                 /* repeated call */
    if (!qh->RERUN && qh->build_cnt > qh_JOGGLEretry) {
      if (((qh->build_cnt-qh_JOGGLEretry-1) % qh_JOGGLEagain) == 0) {
        realT maxjoggle= qh->MAXwidth * qh_JOGGLEmaxincrease;
        if (qh->JOGGLEmax < maxjoggle) {
          qh->JOGGLEmax *= qh_JOGGLEincrease;
          minimize_(qh->JOGGLEmax, maxjoggle);
        }
      }
    }
    qh_option(qh, "QJoggle", NULL, &qh->JOGGLEmax);
  }
  if (qh->build_cnt > 1 && qh->JOGGLEmax > fmax_(qh->MAXwidth/4, 0.1)) {
      qh_fprintf(qh, qh->ferr, 6010, "qhull input error (qh_joggleinput): the current joggle for 'QJn', %.2g, is too large for the width\nof the input.  If possible, recompile Qhull with higher-precision reals.\n",
                qh->JOGGLEmax);
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  /* for some reason, using qh->ROTATErandom and qh_RANDOMseed does not repeat the run. Use 'TRn' instead */
  seed= qh_RANDOMint;
  qh_option(qh, "_joggle-seed", &seed, NULL);
  trace0((qh, qh->ferr, 6, "qh_joggleinput: joggle input by %4.4g with seed %d\n",
    qh->JOGGLEmax, seed));
  inputp= qh->input_points;
  coordp= qh->first_point;
  randa= 2.0 * qh->JOGGLEmax/qh_RANDOMmax;
  randb= -qh->JOGGLEmax;
  size= qh->num_points * qh->hull_dim;
  for (i=size; i--; ) {
    randr= qh_RANDOMint;
    *(coordp++)= *(inputp++) + (randr * randa + randb);
  }
  if (qh->DELAUNAY) {
    qh->last_low= qh->last_high= qh->last_newhigh= REALmax;
    qh_setdelaunay(qh, qh->hull_dim, qh->num_points, qh->first_point);
  }
} /* joggleinput */

/*---------------------------------

  qh_maxabsval( normal, dim )
    return pointer to maximum absolute value of a dim vector
    returns NULL if dim=0
*/
realT *qh_maxabsval(realT *normal, int dim) {
  realT maxval= -REALmax;
  realT *maxp= NULL, *colp, absval;
  int k;

  for (k=dim, colp= normal; k--; colp++) {
    absval= fabs_(*colp);
    if (absval > maxval) {
      maxval= absval;
      maxp= colp;
    }
  }
  return maxp;
} /* maxabsval */


/*---------------------------------

  qh_maxmin(qh, points, numpoints, dimension )
    return max/min points for each dimension
    determine max and min coordinates

  returns:
    returns a temporary set of max and min points
      may include duplicate points. Does not include qh.GOODpoint
    sets qh.NEARzero, qh.MAXabs_coord, qh.MAXsumcoord, qh.MAXwidth
         qh.MAXlastcoord, qh.MINlastcoord
    initializes qh.max_outside, qh.min_vertex, qh.WAScoplanar, qh.ZEROall_ok

  notes:
    loop duplicated in qh_detjoggle()

  design:
    initialize global precision variables
    checks definition of REAL...
    for each dimension
      for each point
        collect maximum and minimum point
      collect maximum of maximums and minimum of minimums
      determine qh.NEARzero for Gaussian Elimination
*/
setT *qh_maxmin(qhT *qh, pointT *points, int numpoints, int dimension) {
  int k;
  realT maxcoord, temp;
  pointT *minimum, *maximum, *point, *pointtemp;
  setT *set;

  qh->max_outside= 0.0;
  qh->MAXabs_coord= 0.0;
  qh->MAXwidth= -REALmax;
  qh->MAXsumcoord= 0.0;
  qh->min_vertex= 0.0;
  qh->WAScoplanar= False;
  if (qh->ZEROcentrum)
    qh->ZEROall_ok= True;
  if (REALmin < REALepsilon && REALmin < REALmax && REALmin > -REALmax
  && REALmax > 0.0 && -REALmax < 0.0)
    ; /* all ok */
  else {
    qh_fprintf(qh, qh->ferr, 6011, "qhull error: one or more floating point constants in user_r.h are inconsistent. REALmin %g, -REALmax %g, 0.0, REALepsilon %g, REALmax %g\n",
          REALmin, -REALmax, REALepsilon, REALmax);
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  set= qh_settemp(qh, 2*dimension);
  trace1((qh, qh->ferr, 8082, "qh_maxmin: dim             min             max           width    nearzero  min-point  max-point\n"));
  for (k=0; k < dimension; k++) {
    if (points == qh->GOODpointp)
      minimum= maximum= points + dimension;
    else
      minimum= maximum= points;
    FORALLpoint_(qh, points, numpoints) {
      if (point == qh->GOODpointp)
        continue;
      if (maximum[k] < point[k])
        maximum= point;
      else if (minimum[k] > point[k])
        minimum= point;
    }
    if (k == dimension-1) {
      qh->MINlastcoord= minimum[k];
      qh->MAXlastcoord= maximum[k];
    }
    if (qh->SCALElast && k == dimension-1)
      maxcoord= qh->MAXabs_coord;
    else {
      maxcoord= fmax_(maximum[k], -minimum[k]);
      if (qh->GOODpointp) {
        temp= fmax_(qh->GOODpointp[k], -qh->GOODpointp[k]);
        maximize_(maxcoord, temp);
      }
      temp= maximum[k] - minimum[k];
      maximize_(qh->MAXwidth, temp);
    }
    maximize_(qh->MAXabs_coord, maxcoord);
    qh->MAXsumcoord += maxcoord;
    qh_setappend(qh, &set, minimum);
    qh_setappend(qh, &set, maximum);
    /* calculation of qh NEARzero is based on Golub & van Loan, 1983,
       Eq. 4.4-13 for "Gaussian elimination with complete pivoting".
       Golub & van Loan say that n^3 can be ignored and 10 be used in
       place of rho */
    qh->NEARzero[k]= 80 * qh->MAXsumcoord * REALepsilon;
    trace1((qh, qh->ferr, 8106, "           %3d % 14.8e % 14.8e % 14.8e  %4.4e  p%-9d p%-d\n",
            k, minimum[k], maximum[k], maximum[k]-minimum[k], qh->NEARzero[k], qh_pointid(qh, minimum), qh_pointid(qh, maximum)));
    if (qh->SCALElast && k == dimension-1)
      trace1((qh, qh->ferr, 8107, "           last coordinate scaled to (%4.4g, %4.4g), width %4.4e for option 'Qbb'\n",
            qh->MAXabs_coord - qh->MAXwidth, qh->MAXabs_coord, qh->MAXwidth));
  }
  if (qh->IStracing >= 1)
    qh_printpoints(qh, qh->ferr, "qh_maxmin: found the max and min points (by dim):", set);
  return(set);
} /* maxmin */

/*---------------------------------

  qh_maxouter(qh)
    return maximum distance from facet to outer plane
    normally this is qh.max_outside+qh.DISTround
    does not include qh.JOGGLEmax

  see:
    qh_outerinner()

  notes:
    need to add another qh.DISTround if testing actual point with computation
    see qh_detmaxoutside for a qh_RATIO... target

  for joggle:
    qh_setfacetplane() updated qh.max_outer for Wnewvertexmax (max distance to vertex)
    need to use Wnewvertexmax since could have a coplanar point for a high
      facet that is replaced by a low facet
    need to add qh.JOGGLEmax if testing input points
*/
realT qh_maxouter(qhT *qh) {
  realT dist;

  dist= fmax_(qh->max_outside, qh->DISTround);
  dist += qh->DISTround;
  trace4((qh, qh->ferr, 4012, "qh_maxouter: max distance from facet to outer plane is %4.4g, qh.max_outside is %4.4g\n", dist, qh->max_outside));
  return dist;
} /* maxouter */

/*---------------------------------

  qh_maxsimplex(qh, dim, maxpoints, points, numpoints, simplex )
    determines maximum simplex for a set of points
    maxpoints is the subset of points with a min or max coordinate
    may start with points already in simplex
    skips qh.GOODpointp (assumes that it isn't in maxpoints)

  returns:
    simplex with dim+1 points

  notes:
    called by qh_initialvertices, qh_detvnorm, and qh_voronoi_center
    requires qh.MAXwidth to estimate determinate for each vertex
    assumes at least needed points in points
    maximizes determinate for x,y,z,w, etc.
    uses maxpoints as long as determinate is clearly non-zero

  design:
    initialize simplex with at least two points
      (find points with max or min x coordinate)
    create a simplex of dim+1 vertices as follows
      add point from maxpoints that maximizes the determinate of the point and the simplex vertices  
      if last point and maxdet/prevdet < qh_RATIOmaxsimplex (3.0e-2)
        flag maybe_falsenarrow
      if no maxpoint or maxnearzero or maybe_falsenarrow
        search all points for maximum determinate
        early exit if maybe_falsenarrow and !maxnearzero and maxdet > prevdet
*/
void qh_maxsimplex(qhT *qh, int dim, setT *maxpoints, pointT *points, int numpoints, setT **simplex) {
  pointT *point, **pointp, *pointtemp, *maxpoint, *minx=NULL, *maxx=NULL;
  boolT nearzero, maxnearzero= False, maybe_falsenarrow;
  int i, sizinit;
  realT maxdet= -1.0, prevdet= -1.0, det, mincoord= REALmax, maxcoord= -REALmax, mindet, ratio, targetdet;

  if (qh->MAXwidth <= 0.0) {
    qh_fprintf(qh, qh->ferr, 6421, "qhull internal error (qh_maxsimplex): qh.MAXwidth required for qh_maxsimplex.  Used to estimate determinate\n");
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  sizinit= qh_setsize(qh, *simplex);
  if (sizinit >= 2) {
    maxdet= pow(qh->MAXwidth, sizinit - 1);
  }else {
    if (qh_setsize(qh, maxpoints) >= 2) {
      FOREACHpoint_(maxpoints) {
        if (maxcoord < point[0]) {
          maxcoord= point[0];
          maxx= point;
        }
        if (mincoord > point[0]) {
          mincoord= point[0];
          minx= point;
        }
      }
    }else {
      FORALLpoint_(qh, points, numpoints) {
        if (point == qh->GOODpointp)
          continue;
        if (maxcoord < point[0]) {
          maxcoord= point[0];
          maxx= point;
        }
        if (mincoord > point[0]) {
          mincoord= point[0];
          minx= point;
        }
      }
    }
    maxdet= maxcoord - mincoord;
    qh_setunique(qh, simplex, minx);
    if (qh_setsize(qh, *simplex) < 2)
      qh_setunique(qh, simplex, maxx);
    sizinit= qh_setsize(qh, *simplex);
    if (sizinit < 2) {
      qh_joggle_restart(qh, "input has same x coordinate");
      if (zzval_(Zsetplane) > qh->hull_dim+1) {
        qh_fprintf(qh, qh->ferr, 6012, "qhull precision error (qh_maxsimplex for voronoi_center): %d points with the same x coordinate %4.4g\n",
                 qh_setsize(qh, maxpoints)+numpoints, mincoord);
        qh_errexit(qh, qh_ERRprec, NULL, NULL);
      }else {
        qh_fprintf(qh, qh->ferr, 6013, "qhull input error: input is less than %d-dimensional since all points have the same x coordinate %4.4g\n",
                 qh->hull_dim, mincoord);
        qh_errexit(qh, qh_ERRinput, NULL, NULL);
      }
    }
  }
  for (i=sizinit; i < dim+1; i++) {
    prevdet= maxdet;
    maxpoint= NULL;
    maxdet= -1.0;
    FOREACHpoint_(maxpoints) {
      if (!qh_setin(*simplex, point) && point != maxpoint) {
        det= qh_detsimplex(qh, point, *simplex, i, &nearzero); /* retests maxpoints if duplicate or multiple iterations */
        if ((det= fabs_(det)) > maxdet) {
          maxdet= det;
          maxpoint= point;
          maxnearzero= nearzero;
        }
      }
    }
    maybe_falsenarrow= False;
    ratio= 1.0;
    targetdet= prevdet * qh->MAXwidth;
    mindet= 10 * qh_RATIOmaxsimplex * targetdet;
    if (maxdet > 0.0) {
      ratio= maxdet / targetdet;
      if (ratio < qh_RATIOmaxsimplex)
        maybe_falsenarrow= True;
    }
    if (!maxpoint || maxnearzero || maybe_falsenarrow) {
      zinc_(Zsearchpoints);
      if (!maxpoint) {
        trace0((qh, qh->ferr, 7, "qh_maxsimplex: searching all points for %d-th initial vertex, better than mindet %4.4g, targetdet %4.4g\n",
                i+1, mindet, targetdet));
      }else if (qh->ALLpoints) {
        trace0((qh, qh->ferr, 30, "qh_maxsimplex: searching all points ('Qs') for %d-th initial vertex, better than p%d det %4.4g, targetdet %4.4g, ratio %4.4g\n",
                i+1, qh_pointid(qh, maxpoint), maxdet, targetdet, ratio));
      }else if (maybe_falsenarrow) {
        trace0((qh, qh->ferr, 17, "qh_maxsimplex: searching all points for %d-th initial vertex, better than p%d det %4.4g and mindet %4.4g, ratio %4.4g\n",
                i+1, qh_pointid(qh, maxpoint), maxdet, mindet, ratio));
      }else {
        trace0((qh, qh->ferr, 8, "qh_maxsimplex: searching all points for %d-th initial vertex, better than p%d det %2.2g and mindet %4.4g, targetdet %4.4g\n",
                i+1, qh_pointid(qh, maxpoint), maxdet, mindet, targetdet));
      }
      FORALLpoint_(qh, points, numpoints) {
        if (point == qh->GOODpointp)
          continue;
        if (!qh_setin(maxpoints, point) && !qh_setin(*simplex, point)) {
          det= qh_detsimplex(qh, point, *simplex, i, &nearzero);
          if ((det= fabs_(det)) > maxdet) {
            maxdet= det;
            maxpoint= point;
            maxnearzero= nearzero;
            if (!maxnearzero && !qh->ALLpoints && maxdet > mindet)
              break;
          }
        }
      }
    } /* !maxpoint */
    if (!maxpoint) {
      qh_fprintf(qh, qh->ferr, 6014, "qhull internal error (qh_maxsimplex): not enough points available\n");
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }
    qh_setappend(qh, simplex, maxpoint);
    trace1((qh, qh->ferr, 1002, "qh_maxsimplex: selected point p%d for %d`th initial vertex, det=%4.4g, targetdet=%4.4g, mindet=%4.4g\n",
            qh_pointid(qh, maxpoint), i+1, maxdet, prevdet * qh->MAXwidth, mindet));
  } /* i */
} /* maxsimplex */

/*---------------------------------

  qh_minabsval( normal, dim )
    return minimum absolute value of a dim vector
*/
realT qh_minabsval(realT *normal, int dim) {
  realT minval= 0;
  realT maxval= 0;
  realT *colp;
  int k;

  for (k=dim, colp=normal; k--; colp++) {
    maximize_(maxval, *colp);
    minimize_(minval, *colp);
  }
  return fmax_(maxval, -minval);
} /* minabsval */


/*---------------------------------

  qh_mindif(qh, vecA, vecB, dim )
    return index of min abs. difference of two vectors
*/
int qh_mindiff(realT *vecA, realT *vecB, int dim) {
  realT mindiff= REALmax, diff;
  realT *vecAp= vecA, *vecBp= vecB;
  int k, mink= 0;

  for (k=0; k < dim; k++) {
    diff= *vecAp++ - *vecBp++;
    diff= fabs_(diff);
    if (diff < mindiff) {
      mindiff= diff;
      mink= k;
    }
  }
  return mink;
} /* mindiff */



/*---------------------------------

  qh_orientoutside(qh, facet  )
    make facet outside oriented via qh.interior_point

  returns:
    True if facet reversed orientation.
*/
boolT qh_orientoutside(qhT *qh, facetT *facet) {
  int k;
  realT dist;

  qh_distplane(qh, qh->interior_point, facet, &dist);
  if (dist > 0) {
    for (k=qh->hull_dim; k--; )
      facet->normal[k]= -facet->normal[k];
    facet->offset= -facet->offset;
    return True;
  }
  return False;
} /* orientoutside */

/*---------------------------------

  qh_outerinner(qh, facet, outerplane, innerplane  )
    if facet and qh.maxoutdone (i.e., qh_check_maxout)
      returns outer and inner plane for facet
    else
      returns maximum outer and inner plane
    accounts for qh.JOGGLEmax

  see:
    qh_maxouter(qh), qh_check_bestdist(), qh_check_points()

  notes:
    outerplaner or innerplane may be NULL
    facet is const
    Does not error (QhullFacet)

    includes qh.DISTround for actual points
    adds another qh.DISTround if testing with floating point arithmetic
*/
void qh_outerinner(qhT *qh, facetT *facet, realT *outerplane, realT *innerplane) {
  realT dist, mindist;
  vertexT *vertex, **vertexp;

  if (outerplane) {
    if (!qh_MAXoutside || !facet || !qh->maxoutdone) {
      *outerplane= qh_maxouter(qh);       /* includes qh.DISTround */
    }else { /* qh_MAXoutside ... */
#if qh_MAXoutside
      *outerplane= facet->maxoutside + qh->DISTround;
#endif

    }
    if (qh->JOGGLEmax < REALmax/2)
      *outerplane += qh->JOGGLEmax * sqrt((realT)qh->hull_dim);
  }
  if (innerplane) {
    if (facet) {
      mindist= REALmax;
      FOREACHvertex_(facet->vertices) {
        zinc_(Zdistio);
        qh_distplane(qh, vertex->point, facet, &dist);
        minimize_(mindist, dist);
      }
      *innerplane= mindist - qh->DISTround;
    }else
      *innerplane= qh->min_vertex - qh->DISTround;
    if (qh->JOGGLEmax < REALmax/2)
      *innerplane -= qh->JOGGLEmax * sqrt((realT)qh->hull_dim);
  }
} /* outerinner */

/*---------------------------------

  qh_pointdist( point1, point2, dim )
    return distance between two points

  notes:
    returns distance squared if 'dim' is negative
*/
coordT qh_pointdist(pointT *point1, pointT *point2, int dim) {
  coordT dist, diff;
  int k;

  dist= 0.0;
  for (k= (dim > 0 ? dim : -dim); k--; ) {
    diff= *point1++ - *point2++;
    dist += diff * diff;
  }
  if (dim > 0)
    return(sqrt(dist));
  return dist;
} /* pointdist */


/*---------------------------------

  qh_printmatrix(qh, fp, string, rows, numrow, numcol )
    print matrix to fp given by row vectors
    print string as header
    qh may be NULL if fp is defined

  notes:
    print a vector by qh_printmatrix(qh, fp, "", &vect, 1, len)
*/
void qh_printmatrix(qhT *qh, FILE *fp, const char *string, realT **rows, int numrow, int numcol) {
  realT *rowp;
  realT r; /*bug fix*/
  int i,k;

  qh_fprintf(qh, fp, 9001, "%s\n", string);
  for (i=0; i < numrow; i++) {
    rowp= rows[i];
    for (k=0; k < numcol; k++) {
      r= *rowp++;
      qh_fprintf(qh, fp, 9002, "%6.3g ", r);
    }
    qh_fprintf(qh, fp, 9003, "\n");
  }
} /* printmatrix */


/*---------------------------------

  qh_printpoints(qh, fp, string, points )
    print pointids to fp for a set of points
    if string, prints string and 'p' point ids
*/
void qh_printpoints(qhT *qh, FILE *fp, const char *string, setT *points) {
  pointT *point, **pointp;

  if (string) {
    qh_fprintf(qh, fp, 9004, "%s", string);
    FOREACHpoint_(points)
      qh_fprintf(qh, fp, 9005, " p%d", qh_pointid(qh, point));
    qh_fprintf(qh, fp, 9006, "\n");
  }else {
    FOREACHpoint_(points)
      qh_fprintf(qh, fp, 9007, " %d", qh_pointid(qh, point));
    qh_fprintf(qh, fp, 9008, "\n");
  }
} /* printpoints */


/*---------------------------------

  qh_projectinput(qh)
    project input points using qh.lower_bound/upper_bound and qh->DELAUNAY
    if qh.lower_bound[k]=qh.upper_bound[k]= 0,
      removes dimension k
    if halfspace intersection
      removes dimension k from qh.feasible_point
    input points in qh->first_point, num_points, input_dim

  returns:
    new point array in qh->first_point of qh->hull_dim coordinates
    sets qh->POINTSmalloc
    if qh->DELAUNAY
      projects points to paraboloid
      lowbound/highbound is also projected
    if qh->ATinfinity
      adds point "at-infinity"
    if qh->POINTSmalloc
      frees old point array

  notes:
    checks that qh.hull_dim agrees with qh.input_dim, PROJECTinput, and DELAUNAY


  design:
    sets project[k] to -1 (delete), 0 (keep), 1 (add for Delaunay)
    determines newdim and newnum for qh->hull_dim and qh->num_points
    projects points to newpoints
    projects qh.lower_bound to itself
    projects qh.upper_bound to itself
    if qh->DELAUNAY
      if qh->ATINFINITY
        projects points to paraboloid
        computes "infinity" point as vertex average and 10% above all points
      else
        uses qh_setdelaunay to project points to paraboloid
*/
void qh_projectinput(qhT *qh) {
  int k,i;
  int newdim= qh->input_dim, newnum= qh->num_points;
  signed char *project;
  int projectsize= (qh->input_dim + 1) * (int)sizeof(*project);
  pointT *newpoints, *coord, *infinity;
  realT paraboloid, maxboloid= 0;

  project= (signed char *)qh_memalloc(qh, projectsize);
  memset((char *)project, 0, (size_t)projectsize);
  for (k=0; k < qh->input_dim; k++) {   /* skip Delaunay bound */
    if (qh->lower_bound[k] == 0.0 && qh->upper_bound[k] == 0.0) {
      project[k]= -1;
      newdim--;
    }
  }
  if (qh->DELAUNAY) {
    project[k]= 1;
    newdim++;
    if (qh->ATinfinity)
      newnum++;
  }
  if (newdim != qh->hull_dim) {
    qh_memfree(qh, project, projectsize);
    qh_fprintf(qh, qh->ferr, 6015, "qhull internal error (qh_projectinput): dimension after projection %d != hull_dim %d\n", newdim, qh->hull_dim);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  if (!(newpoints= qh->temp_malloc= (coordT *)qh_malloc((size_t)(newnum * newdim) * sizeof(coordT)))) {
    qh_memfree(qh, project, projectsize);
    qh_fprintf(qh, qh->ferr, 6016, "qhull error: insufficient memory to project %d points\n",
           qh->num_points);
    qh_errexit(qh, qh_ERRmem, NULL, NULL);
  }
  /* qh_projectpoints throws error if mismatched dimensions */
  qh_projectpoints(qh, project, qh->input_dim+1, qh->first_point,
                    qh->num_points, qh->input_dim, newpoints, newdim);
  trace1((qh, qh->ferr, 1003, "qh_projectinput: updating lower and upper_bound\n"));
  qh_projectpoints(qh, project, qh->input_dim+1, qh->lower_bound,
                    1, qh->input_dim+1, qh->lower_bound, newdim+1);
  qh_projectpoints(qh, project, qh->input_dim+1, qh->upper_bound,
                    1, qh->input_dim+1, qh->upper_bound, newdim+1);
  if (qh->HALFspace) {
    if (!qh->feasible_point) {
      qh_memfree(qh, project, projectsize);
      qh_fprintf(qh, qh->ferr, 6017, "qhull internal error (qh_projectinput): HALFspace defined without qh.feasible_point\n");
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }
    qh_projectpoints(qh, project, qh->input_dim, qh->feasible_point,
                      1, qh->input_dim, qh->feasible_point, newdim);
  }
  qh_memfree(qh, project, projectsize);
  if (qh->POINTSmalloc)
    qh_free(qh->first_point);
  qh->first_point= newpoints;
  qh->POINTSmalloc= True;
  qh->temp_malloc= NULL;
  if (qh->DELAUNAY && qh->ATinfinity) {
    coord= qh->first_point;
    infinity= qh->first_point + qh->hull_dim * qh->num_points;
    for (k=qh->hull_dim-1; k--; )
      infinity[k]= 0.0;
    for (i=qh->num_points; i--; ) {
      paraboloid= 0.0;
      for (k=0; k < qh->hull_dim-1; k++) {
        paraboloid += *coord * *coord;
        infinity[k] += *coord;
        coord++;
      }
      *(coord++)= paraboloid;
      maximize_(maxboloid, paraboloid);
    }
    /* coord == infinity */
    for (k=qh->hull_dim-1; k--; )
      *(coord++) /= qh->num_points;
    *(coord++)= maxboloid * 1.1;
    qh->num_points++;
    trace0((qh, qh->ferr, 9, "qh_projectinput: projected points to paraboloid for Delaunay\n"));
  }else if (qh->DELAUNAY)  /* !qh->ATinfinity */
    qh_setdelaunay(qh, qh->hull_dim, qh->num_points, qh->first_point);
} /* projectinput */


/*---------------------------------

  qh_projectpoints(qh, project, n, points, numpoints, dim, newpoints, newdim )
    project points/numpoints/dim to newpoints/newdim
    if project[k] == -1
      delete dimension k
    if project[k] == 1
      add dimension k by duplicating previous column
    n is size of project

  notes:
    newpoints may be points if only adding dimension at end

  design:
    check that 'project' and 'newdim' agree
    for each dimension
      if project == -1
        skip dimension
      else
        determine start of column in newpoints
        determine start of column in points
          if project == +1, duplicate previous column
        copy dimension (column) from points to newpoints
*/
void qh_projectpoints(qhT *qh, signed char *project, int n, realT *points,
        int numpoints, int dim, realT *newpoints, int newdim) {
  int testdim= dim, oldk=0, newk=0, i,j=0,k;
  realT *newp, *oldp;

  for (k=0; k < n; k++)
    testdim += project[k];
  if (testdim != newdim) {
    qh_fprintf(qh, qh->ferr, 6018, "qhull internal error (qh_projectpoints): newdim %d should be %d after projection\n",
      newdim, testdim);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  for (j=0; j= dim)
          continue;
        oldp= points+oldk;
      }else
        oldp= points+oldk++;
      for (i=numpoints; i--; ) {
        *newp= *oldp;
        newp += newdim;
        oldp += dim;
      }
    }
    if (oldk >= dim)
      break;
  }
  trace1((qh, qh->ferr, 1004, "qh_projectpoints: projected %d points from dim %d to dim %d\n",
    numpoints, dim, newdim));
} /* projectpoints */


/*---------------------------------

  qh_rotateinput(qh, rows )
    rotate input using row matrix
    input points given by qh->first_point, num_points, hull_dim
    assumes rows[dim] is a scratch buffer
    if qh->POINTSmalloc, overwrites input points, else mallocs a new array

  returns:
    rotated input
    sets qh->POINTSmalloc

  design:
    see qh_rotatepoints
*/
void qh_rotateinput(qhT *qh, realT **rows) {

  if (!qh->POINTSmalloc) {
    qh->first_point= qh_copypoints(qh, qh->first_point, qh->num_points, qh->hull_dim);
    qh->POINTSmalloc= True;
  }
  qh_rotatepoints(qh, qh->first_point, qh->num_points, qh->hull_dim, rows);
}  /* rotateinput */

/*---------------------------------

  qh_rotatepoints(qh, points, numpoints, dim, row )
    rotate numpoints points by a d-dim row matrix
    assumes rows[dim] is a scratch buffer

  returns:
    rotated points in place

  design:
    for each point
      for each coordinate
        use row[dim] to compute partial inner product
      for each coordinate
        rotate by partial inner product
*/
void qh_rotatepoints(qhT *qh, realT *points, int numpoints, int dim, realT **row) {
  realT *point, *rowi, *coord= NULL, sum, *newval;
  int i,j,k;

  if (qh->IStracing >= 1)
    qh_printmatrix(qh, qh->ferr, "qh_rotatepoints: rotate points by", row, dim, dim);
  for (point=points, j=numpoints; j--; point += dim) {
    newval= row[dim];
    for (i=0; i < dim; i++) {
      rowi= row[i];
      coord= point;
      for (sum=0.0, k=dim; k--; )
        sum += *rowi++ * *coord++;
      *(newval++)= sum;
    }
    for (k=dim; k--; )
      *(--coord)= *(--newval);
  }
} /* rotatepoints */


/*---------------------------------

  qh_scaleinput(qh)
    scale input points using qh->low_bound/high_bound
    input points given by qh->first_point, num_points, hull_dim
    if qh->POINTSmalloc, overwrites input points, else mallocs a new array

  returns:
    scales coordinates of points to low_bound[k], high_bound[k]
    sets qh->POINTSmalloc

  design:
    see qh_scalepoints
*/
void qh_scaleinput(qhT *qh) {

  if (!qh->POINTSmalloc) {
    qh->first_point= qh_copypoints(qh, qh->first_point, qh->num_points, qh->hull_dim);
    qh->POINTSmalloc= True;
  }
  qh_scalepoints(qh, qh->first_point, qh->num_points, qh->hull_dim,
       qh->lower_bound, qh->upper_bound);
}  /* scaleinput */

/*---------------------------------

  qh_scalelast(qh, points, numpoints, dim, low, high, newhigh )
    scale last coordinate to [0.0, newhigh], for Delaunay triangulation
    input points given by points, numpoints, dim

  returns:
    changes scale of last coordinate from [low, high] to [0.0, newhigh]
    overwrites last coordinate of each point
    saves low/high/newhigh in qh.last_low, etc. for qh_setdelaunay()

  notes:
    to reduce precision issues, qh_scalelast makes the last coordinate similar to other coordinates
      the last coordinate for Delaunay triangulation is the sum of squares of input coordinates
      note that the range [0.0, newwidth] is wrong for narrow distributions with large positive coordinates (e.g., [995933.64, 995963.48])

    when called by qh_setdelaunay, low/high may not match the data passed to qh_setdelaunay

  design:
    compute scale and shift factors
    apply to last coordinate of each point
*/
void qh_scalelast(qhT *qh, coordT *points, int numpoints, int dim, coordT low,
                   coordT high, coordT newhigh) {
  realT scale, shift;
  coordT *coord, newlow;
  int i;
  boolT nearzero= False;

  newlow= 0.0;
  trace4((qh, qh->ferr, 4013, "qh_scalelast: scale last coordinate from [%2.2g, %2.2g] to [%2.2g, %2.2g]\n",
    low, high, newlow, newhigh));
  qh->last_low= low;
  qh->last_high= high;
  qh->last_newhigh= newhigh;
  scale= qh_divzero(newhigh - newlow, high - low,
                  qh->MINdenom_1, &nearzero);
  if (nearzero) {
    if (qh->DELAUNAY)
      qh_fprintf(qh, qh->ferr, 6019, "qhull input error (qh_scalelast): can not scale last coordinate to [%4.4g, %4.4g].  Input is cocircular or cospherical.   Use option 'Qz' to add a point at infinity.\n",
             newlow, newhigh);
    else
      qh_fprintf(qh, qh->ferr, 6020, "qhull input error (qh_scalelast): can not scale last coordinate to [%4.4g, %4.4g].  New bounds are too wide for compared to existing bounds [%4.4g, %4.4g] (width %4.4g)\n",
             newlow, newhigh, low, high, high-low);
    qh_errexit(qh, qh_ERRinput, NULL, NULL);
  }
  shift= newlow - low * scale;
  coord= points + dim - 1;
  for (i=numpoints; i--; coord += dim)
    *coord= *coord * scale + shift;
} /* scalelast */

/*---------------------------------

  qh_scalepoints(qh, points, numpoints, dim, newlows, newhighs )
    scale points to new lowbound and highbound
    retains old bound when newlow= -REALmax or newhigh= +REALmax

  returns:
    scaled points
    overwrites old points

  design:
    for each coordinate
      compute current low and high bound
      compute scale and shift factors
      scale all points
      enforce new low and high bound for all points
*/
void qh_scalepoints(qhT *qh, pointT *points, int numpoints, int dim,
        realT *newlows, realT *newhighs) {
  int i,k;
  realT shift, scale, *coord, low, high, newlow, newhigh, mincoord, maxcoord;
  boolT nearzero= False;

  for (k=0; k < dim; k++) {
    newhigh= newhighs[k];
    newlow= newlows[k];
    if (newhigh > REALmax/2 && newlow < -REALmax/2)
      continue;
    low= REALmax;
    high= -REALmax;
    for (i=numpoints, coord=points+k; i--; coord += dim) {
      minimize_(low, *coord);
      maximize_(high, *coord);
    }
    if (newhigh > REALmax/2)
      newhigh= high;
    if (newlow < -REALmax/2)
      newlow= low;
    if (qh->DELAUNAY && k == dim-1 && newhigh < newlow) {
      qh_fprintf(qh, qh->ferr, 6021, "qhull input error: 'Qb%d' or 'QB%d' inverts paraboloid since high bound %.2g < low bound %.2g\n",
               k, k, newhigh, newlow);
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    scale= qh_divzero(newhigh - newlow, high - low,
                  qh->MINdenom_1, &nearzero);
    if (nearzero) {
      qh_fprintf(qh, qh->ferr, 6022, "qhull input error: %d'th dimension's new bounds [%2.2g, %2.2g] too wide for\nexisting bounds [%2.2g, %2.2g]\n",
              k, newlow, newhigh, low, high);
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    shift= (newlow * high - low * newhigh)/(high-low);
    coord= points+k;
    for (i=numpoints; i--; coord += dim)
      *coord= *coord * scale + shift;
    coord= points+k;
    if (newlow < newhigh) {
      mincoord= newlow;
      maxcoord= newhigh;
    }else {
      mincoord= newhigh;
      maxcoord= newlow;
    }
    for (i=numpoints; i--; coord += dim) {
      minimize_(*coord, maxcoord);  /* because of roundoff error */
      maximize_(*coord, mincoord);
    }
    trace0((qh, qh->ferr, 10, "qh_scalepoints: scaled %d'th coordinate [%2.2g, %2.2g] to [%.2g, %.2g] for %d points by %2.2g and shifted %2.2g\n",
      k, low, high, newlow, newhigh, numpoints, scale, shift));
  }
} /* scalepoints */


/*---------------------------------

  qh_setdelaunay(qh, dim, count, points )
    project count points to dim-d paraboloid for Delaunay triangulation

    dim is one more than the dimension of the input set
    assumes dim is at least 3 (i.e., at least a 2-d Delaunay triangulation)

    points is a dim*count realT array.  The first dim-1 coordinates
    are the coordinates of the first input point.  array[dim] is
    the first coordinate of the second input point.  array[2*dim] is
    the first coordinate of the third input point.

    if qh.last_low defined (i.e., 'Qbb' called qh_scalelast)
      calls qh_scalelast to scale the last coordinate the same as the other points

  returns:
    for each point
      sets point[dim-1] to sum of squares of coordinates
    scale points to 'Qbb' if needed

  notes:
    to project one point, use
      qh_setdelaunay(qh, qh->hull_dim, 1, point)

    Do not use options 'Qbk', 'QBk', or 'QbB' since they scale
    the coordinates after the original projection.

*/
void qh_setdelaunay(qhT *qh, int dim, int count, pointT *points) {
  int i, k;
  coordT *coordp, coord;
  realT paraboloid;

  trace0((qh, qh->ferr, 11, "qh_setdelaunay: project %d points to paraboloid for Delaunay triangulation\n", count));
  coordp= points;
  for (i=0; i < count; i++) {
    coord= *coordp++;
    paraboloid= coord*coord;
    for (k=dim-2; k--; ) {
      coord= *coordp++;
      paraboloid += coord*coord;
    }
    *coordp++= paraboloid;
  }
  if (qh->last_low < REALmax/2)
    qh_scalelast(qh, points, count, dim, qh->last_low, qh->last_high, qh->last_newhigh);
} /* setdelaunay */


/*---------------------------------

  qh_sethalfspace(qh, dim, coords, nextp, normal, offset, feasible )
    set point to dual of halfspace relative to feasible point
    halfspace is normal coefficients and offset.

  returns:
    false and prints error if feasible point is outside of hull
    overwrites coordinates for point at dim coords
    nextp= next point (coords)
    does not call qh_errexit

  design:
    compute distance from feasible point to halfspace
    divide each normal coefficient by -dist
*/
boolT qh_sethalfspace(qhT *qh, int dim, coordT *coords, coordT **nextp,
         coordT *normal, coordT *offset, coordT *feasible) {
  coordT *normp= normal, *feasiblep= feasible, *coordp= coords;
  realT dist;
  realT r; /*bug fix*/
  int k;
  boolT zerodiv;

  dist= *offset;
  for (k=dim; k--; )
    dist += *(normp++) * *(feasiblep++);
  if (dist > 0)
    goto LABELerroroutside;
  normp= normal;
  if (dist < -qh->MINdenom) {
    for (k=dim; k--; )
      *(coordp++)= *(normp++) / -dist;
  }else {
    for (k=dim; k--; ) {
      *(coordp++)= qh_divzero(*(normp++), -dist, qh->MINdenom_1, &zerodiv);
      if (zerodiv)
        goto LABELerroroutside;
    }
  }
  *nextp= coordp;
#ifndef qh_NOtrace
  if (qh->IStracing >= 4) {
    qh_fprintf(qh, qh->ferr, 8021, "qh_sethalfspace: halfspace at offset %6.2g to point: ", *offset);
    for (k=dim, coordp=coords; k--; ) {
      r= *coordp++;
      qh_fprintf(qh, qh->ferr, 8022, " %6.2g", r);
    }
    qh_fprintf(qh, qh->ferr, 8023, "\n");
  }
#endif
  return True;
LABELerroroutside:
  feasiblep= feasible;
  normp= normal;
  qh_fprintf(qh, qh->ferr, 6023, "qhull input error: feasible point is not clearly inside halfspace\nfeasible point: ");
  for (k=dim; k--; )
    qh_fprintf(qh, qh->ferr, 8024, qh_REAL_1, r=*(feasiblep++));
  qh_fprintf(qh, qh->ferr, 8025, "\n     halfspace: ");
  for (k=dim; k--; )
    qh_fprintf(qh, qh->ferr, 8026, qh_REAL_1, r=*(normp++));
  qh_fprintf(qh, qh->ferr, 8027, "\n     at offset: ");
  qh_fprintf(qh, qh->ferr, 8028, qh_REAL_1, *offset);
  qh_fprintf(qh, qh->ferr, 8029, " and distance: ");
  qh_fprintf(qh, qh->ferr, 8030, qh_REAL_1, dist);
  qh_fprintf(qh, qh->ferr, 8031, "\n");
  return False;
} /* sethalfspace */

/*---------------------------------

  qh_sethalfspace_all(qh, dim, count, halfspaces, feasible )
    generate dual for halfspace intersection with feasible point
    array of count halfspaces
      each halfspace is normal coefficients followed by offset
      the origin is inside the halfspace if the offset is negative
    feasible is a point inside all halfspaces (http://www.qhull.org/html/qhalf.htm#notes)

  returns:
    malloc'd array of count X dim-1 points

  notes:
    call before qh_init_B or qh_initqhull_globals
    free memory when done
    unused/untested code: please email bradb@shore.net if this works ok for you
    if using option 'Fp', qh.feasible_point must be set (e.g., to 'feasible')
    qh->feasible_point is a malloc'd array that is freed by qh_freebuffers.

  design:
    see qh_sethalfspace
*/
coordT *qh_sethalfspace_all(qhT *qh, int dim, int count, coordT *halfspaces, pointT *feasible) {
  int i, newdim;
  pointT *newpoints;
  coordT *coordp, *normalp, *offsetp;

  trace0((qh, qh->ferr, 12, "qh_sethalfspace_all: compute dual for halfspace intersection\n"));
  newdim= dim - 1;
  if (!(newpoints= (coordT *)qh_malloc((size_t)(count * newdim) * sizeof(coordT)))){
    qh_fprintf(qh, qh->ferr, 6024, "qhull error: insufficient memory to compute dual of %d halfspaces\n",
          count);
    qh_errexit(qh, qh_ERRmem, NULL, NULL);
  }
  coordp= newpoints;
  normalp= halfspaces;
  for (i=0; i < count; i++) {
    offsetp= normalp + newdim;
    if (!qh_sethalfspace(qh, newdim, coordp, &coordp, normalp, offsetp, feasible)) {
      qh_free(newpoints);  /* feasible is not inside halfspace as reported by qh_sethalfspace */
      qh_fprintf(qh, qh->ferr, 8032, "The halfspace was at index %d\n", i);
      qh_errexit(qh, qh_ERRinput, NULL, NULL);
    }
    normalp= offsetp + 1;
  }
  return newpoints;
} /* sethalfspace_all */


/*---------------------------------

  qh_sharpnewfacets(qh)

  returns:
    true if could be an acute angle (facets in different quadrants)

  notes:
    for qh_findbest

  design:
    for all facets on qh.newfacet_list
      if two facets are in different quadrants
        set issharp
*/
boolT qh_sharpnewfacets(qhT *qh) {
  facetT *facet;
  boolT issharp= False;
  int *quadrant, k;

  quadrant= (int *)qh_memalloc(qh, qh->hull_dim * (int)sizeof(int));
  FORALLfacet_(qh->newfacet_list) {
    if (facet == qh->newfacet_list) {
      for (k=qh->hull_dim; k--; )
        quadrant[ k]= (facet->normal[ k] > 0);
    }else {
      for (k=qh->hull_dim; k--; ) {
        if (quadrant[ k] != (facet->normal[ k] > 0)) {
          issharp= True;
          break;
        }
      }
    }
    if (issharp)
      break;
  }
  qh_memfree(qh, quadrant, qh->hull_dim * (int)sizeof(int));
  trace3((qh, qh->ferr, 3001, "qh_sharpnewfacets: %d\n", issharp));
  return issharp;
} /* sharpnewfacets */

/*---------------------------------

  qh_vertex_bestdist(qh, vertices )
  qh_vertex_bestdist2(qh, vertices, vertexp, vertexp2 )
    return nearest distance between vertices
    optionally returns vertex and vertex2

  notes:
    called by qh_partitioncoplanar, qh_mergefacet, qh_check_maxout, qh_checkpoint
*/
coordT qh_vertex_bestdist(qhT *qh, setT *vertices) {
  vertexT *vertex, *vertex2;

  return qh_vertex_bestdist2(qh, vertices, &vertex, &vertex2);
} /* vertex_bestdist */

coordT qh_vertex_bestdist2(qhT *qh, setT *vertices, vertexT **vertexp/*= NULL*/, vertexT **vertexp2/*= NULL*/) {
  vertexT *vertex, *vertexA, *bestvertex= NULL, *bestvertex2= NULL;
  coordT dist, bestdist= REALmax;
  int k, vertex_i, vertex_n;

  FOREACHvertex_i_(qh, vertices) {
    for (k= vertex_i+1; k < vertex_n; k++) {
      vertexA= SETelemt_(vertices, k, vertexT);
      dist= qh_pointdist(vertex->point, vertexA->point, -qh->hull_dim);
      if (dist < bestdist) {
        bestdist= dist;
        bestvertex= vertex;
        bestvertex2= vertexA;
      }
    }
  }
  *vertexp= bestvertex;
  *vertexp2= bestvertex2;
  return sqrt(bestdist);
} /* vertex_bestdist */

/*---------------------------------

  qh_voronoi_center(qh, dim, points )
    return Voronoi center for a set of points
    dim is the orginal dimension of the points
    gh.gm_matrix/qh.gm_row are scratch buffers

  returns:
    center as a temporary point (qh_memalloc)
    if non-simplicial,
      returns center for max simplex of points

  notes:
    only called by qh_facetcenter
    from Bowyer & Woodwark, A Programmer's Geometry, 1983, p. 65

  design:
    if non-simplicial
      determine max simplex for points
    translate point0 of simplex to origin
    compute sum of squares of diagonal
    compute determinate
    compute Voronoi center (see Bowyer & Woodwark)
*/
pointT *qh_voronoi_center(qhT *qh, int dim, setT *points) {
  pointT *point, **pointp, *point0;
  pointT *center= (pointT *)qh_memalloc(qh, qh->center_size);
  setT *simplex;
  int i, j, k, size= qh_setsize(qh, points);
  coordT *gmcoord;
  realT *diffp, sum2, *sum2row, *sum2p, det, factor;
  boolT nearzero, infinite;

  if (size == dim+1)
    simplex= points;
  else if (size < dim+1) {
    qh_memfree(qh, center, qh->center_size);
    qh_fprintf(qh, qh->ferr, 6025, "qhull internal error (qh_voronoi_center):  need at least %d points to construct a Voronoi center\n",
             dim+1);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    simplex= points;  /* never executed -- avoids warning */
  }else {
    simplex= qh_settemp(qh, dim+1);
    qh_maxsimplex(qh, dim, points, NULL, 0, &simplex);
  }
  point0= SETfirstt_(simplex, pointT);
  gmcoord= qh->gm_matrix;
  for (k=0; k < dim; k++) {
    qh->gm_row[k]= gmcoord;
    FOREACHpoint_(simplex) {
      if (point != point0)
        *(gmcoord++)= point[k] - point0[k];
    }
  }
  sum2row= gmcoord;
  for (i=0; i < dim; i++) {
    sum2= 0.0;
    for (k=0; k < dim; k++) {
      diffp= qh->gm_row[k] + i;
      sum2 += *diffp * *diffp;
    }
    *(gmcoord++)= sum2;
  }
  det= qh_determinant(qh, qh->gm_row, dim, &nearzero);
  factor= qh_divzero(0.5, det, qh->MINdenom, &infinite);
  if (infinite) {
    for (k=dim; k--; )
      center[k]= qh_INFINITE;
    if (qh->IStracing)
      qh_printpoints(qh, qh->ferr, "qh_voronoi_center: at infinity for ", simplex);
  }else {
    for (i=0; i < dim; i++) {
      gmcoord= qh->gm_matrix;
      sum2p= sum2row;
      for (k=0; k < dim; k++) {
        qh->gm_row[k]= gmcoord;
        if (k == i) {
          for (j=dim; j--; )
            *(gmcoord++)= *sum2p++;
        }else {
          FOREACHpoint_(simplex) {
            if (point != point0)
              *(gmcoord++)= point[k] - point0[k];
          }
        }
      }
      center[i]= qh_determinant(qh, qh->gm_row, dim, &nearzero)*factor + point0[i];
    }
#ifndef qh_NOtrace
    if (qh->IStracing >= 3) {
      qh_fprintf(qh, qh->ferr, 3061, "qh_voronoi_center: det %2.2g factor %2.2g ", det, factor);
      qh_printmatrix(qh, qh->ferr, "center:", ¢er, 1, dim);
      if (qh->IStracing >= 5) {
        qh_printpoints(qh, qh->ferr, "points", simplex);
        FOREACHpoint_(simplex)
          qh_fprintf(qh, qh->ferr, 8034, "p%d dist %.2g, ", qh_pointid(qh, point),
                   qh_pointdist(point, center, dim));
        qh_fprintf(qh, qh->ferr, 8035, "\n");
      }
    }
#endif
  }
  if (simplex != points)
    qh_settempfree(qh, &simplex);
  return center;
} /* voronoi_center */

geometry/src/stat_r.c0000644000176200001440000010030614740034715014341 0ustar  liggesusers/*
  ---------------------------------

   stat_r.c
   contains all statistics that are collected for qhull

   see qh-stat_r.htm and stat_r.h

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/stat_r.c#9 $$Change: 3037 $
   $DateTime: 2020/09/03 17:28:32 $$Author: bbarber $
*/

#include "qhull_ra.h"

/*========== functions in alphabetic order ================*/

/*---------------------------------

  qh_allstatA()
    define statistics in groups of 20

  notes:
    (otherwise, 'gcc -O2' uses too much memory)
    uses qhstat.next
*/
void qh_allstatA(qhT *qh) {

   /* zdef_(type,name,doc,average) */
  zzdef_(zdoc, Zdoc2, "precision statistics", -1);
  zdef_(zinc, Znewvertex, NULL, -1);
  zdef_(wadd, Wnewvertex, "ave. distance of a new vertex to a facet", Znewvertex);
  zzdef_(wmax, Wnewvertexmax, "max. distance of a new vertex to a facet", -1);
  zdef_(wmax, Wvertexmax, "max. distance of an output vertex to a facet", -1);
  zdef_(wmin, Wvertexmin, "min. distance of an output vertex to a facet", -1);
  zdef_(wmin, Wmindenom, "min. denominator in hyperplane computation", -1);

  qh->qhstat.precision= qh->qhstat.next;  /* usually call qh_joggle_restart, printed if Q0 or QJn */
  zzdef_(zdoc, Zdoc3, "precision problems (corrected unless 'Q0' or an error)", -1);
  zzdef_(zinc, Zcoplanarridges, "coplanar half ridges in output", -1);
  zzdef_(zinc, Zconcaveridges, "concave half ridges in output", -1);
  zzdef_(zinc, Zflippedfacets, "flipped facets", -1);
  zzdef_(zinc, Zcoplanarhorizon, "coplanar horizon facets for new vertices", -1);
  zzdef_(zinc, Zcoplanarpart, "coplanar points during partitioning", -1);
  zzdef_(zinc, Zminnorm, "degenerate hyperplanes recomputed with gaussian elimination", -1);
  zzdef_(zinc, Znearlysingular, "nearly singular or axis-parallel hyperplanes", -1);
  zzdef_(zinc, Zback0, "zero divisors during back substitute", -1);
  zzdef_(zinc, Zgauss0, "zero divisors during gaussian elimination", -1);
  zzdef_(zinc, Zmultiridge, "dupridges with multiple neighbors", -1);
  zzdef_(zinc, Zflipridge, "dupridges with flip facet into good neighbor", -1);
  zzdef_(zinc, Zflipridge2, "dupridges with flip facet into good flip neighbor", -1);
}
void qh_allstatB(qhT *qh) {
  zzdef_(zdoc, Zdoc1, "summary information", -1);
  zdef_(zinc, Zvertices, "number of vertices in output", -1);
  zdef_(zinc, Znumfacets, "number of facets in output", -1);
  zdef_(zinc, Znonsimplicial, "number of non-simplicial facets in output", -1);
  zdef_(zinc, Znowsimplicial, "simplicial facets that were non-simplicial", -1);
  zdef_(zinc, Znumridges, "number of ridges in output", -1);
  zdef_(zadd, Znumridges, "average number of ridges per facet", Znumfacets);
  zdef_(zmax, Zmaxridges, "maximum number of ridges", -1);
  zdef_(zadd, Znumneighbors, "average number of neighbors per facet", Znumfacets);
  zdef_(zmax, Zmaxneighbors, "maximum number of neighbors", -1);
  zdef_(zadd, Znumvertices, "average number of vertices per facet", Znumfacets);
  zdef_(zmax, Zmaxvertices, "maximum number of vertices", -1);
  zdef_(zadd, Znumvneighbors, "average number of neighbors per vertex", Zvertices);
  zdef_(zmax, Zmaxvneighbors, "maximum number of neighbors", -1);
  zdef_(wadd, Wcpu, "cpu seconds for qhull after input", -1);
  zdef_(zinc, Ztotvertices, "vertices created altogether", -1);
  zzdef_(zinc, Zsetplane, "facets created altogether", -1);
  zdef_(zinc, Ztotridges, "ridges created altogether", -1);
  zdef_(zinc, Zpostfacets, "facets before post merge", -1);
  zdef_(zadd, Znummergetot, "average merges per facet (at most 511)", Znumfacets);
  zdef_(zmax, Znummergemax, "  maximum merges for a facet (at most 511)", -1);
  zdef_(zinc, Zangle, NULL, -1);
  zdef_(wadd, Wangle, "average cosine (angle) of facet normals for all ridges", Zangle);
  zdef_(wmax, Wanglemax, "  maximum cosine of facet normals (flatest) across a ridge", -1);
  zdef_(wmin, Wanglemin, "  minimum cosine of facet normals (sharpest) across a ridge", -1);
  zdef_(wadd, Wareatot, "total area of facets", -1);
  zdef_(wmax, Wareamax, "  maximum facet area", -1);
  zdef_(wmin, Wareamin, "  minimum facet area", -1);
}
void qh_allstatC(qhT *qh) {
  zdef_(zdoc, Zdoc9, "build hull statistics", -1);
  zzdef_(zinc, Zprocessed, "points processed", -1);
  zzdef_(zinc, Zretry, "retries due to precision problems", -1);
  zdef_(wmax, Wretrymax, "  max. random joggle", -1);
  zdef_(zmax, Zmaxvertex, "max. vertices at any one time", -1);
  zdef_(zinc, Ztotvisible, "ave. visible facets per iteration", Zprocessed);
  zdef_(zinc, Zinsidevisible, "  ave. visible facets without an horizon neighbor", Zprocessed);
  zdef_(zadd, Zvisfacettot,  "  ave. facets deleted per iteration", Zprocessed);
  zdef_(zmax, Zvisfacetmax,  "    maximum", -1);
  zdef_(zadd, Zvisvertextot, "ave. visible vertices per iteration", Zprocessed);
  zdef_(zmax, Zvisvertexmax, "    maximum", -1);
  zdef_(zinc, Ztothorizon, "ave. horizon facets per iteration", Zprocessed);
  zdef_(zadd, Znewfacettot,  "ave. new or merged facets per iteration", Zprocessed);
  zdef_(zmax, Znewfacetmax,  "    maximum (includes initial simplex)", -1);
  zdef_(wadd, Wnewbalance, "average new facet balance", Zprocessed);
  zdef_(wadd, Wnewbalance2, "  standard deviation", -1);
  zdef_(wadd, Wpbalance, "average partition balance", Zpbalance);
  zdef_(wadd, Wpbalance2, "  standard deviation", -1);
  zdef_(zinc, Zpbalance,  "  count", -1);
  zdef_(zinc, Zsearchpoints, "searches of all points for initial simplex", -1);
  zdef_(zinc, Zdetfacetarea, "determinants for facet area", -1);
  zdef_(zinc, Znoarea, "  determinants not computed because vertex too low", -1);
  zdef_(zinc, Zdetsimplex, "determinants for initial hull or voronoi vertices", -1);
  zdef_(zinc, Znotmax, "points ignored (!above max_outside)", -1);
  zdef_(zinc, Zpinchedapex, "points ignored (pinched apex)", -1);
  zdef_(zinc, Znotgood, "points ignored (!above a good facet)", -1);
  zdef_(zinc, Znotgoodnew, "points ignored (didn't create a good new facet)", -1);
  zdef_(zinc, Zgoodfacet, "good facets found", -1);
  zzdef_(zinc, Znumvisibility, "distance tests for facet visibility", -1);
  zdef_(zinc, Zdistvertex, "distance tests to report minimum vertex", -1);
  zzdef_(zinc, Ztotcheck, "points checked for facets' outer planes", -1);
  zzdef_(zinc, Zcheckpart, "  ave. distance tests per check", Ztotcheck);
}
void qh_allstatD(qhT *qh) {
  zdef_(zinc, Zvisit, "resets of visit_id", -1);
  zdef_(zinc, Zvvisit, "  resets of vertex_visit", -1);
  zdef_(zmax, Zvisit2max, "  max visit_id/2", -1);
  zdef_(zmax, Zvvisit2max, "  max vertex_visit/2", -1);

  zdef_(zdoc, Zdoc4, "partitioning statistics (see previous for outer planes)", -1);
  zzdef_(zadd, Zdelvertextot, "total vertices deleted", -1);
  zdef_(zmax, Zdelvertexmax, "    maximum vertices deleted per iteration", -1);
  zdef_(zinc, Zfindbest, "calls to findbest", -1);
  zdef_(zadd, Zfindbesttot, " ave. facets tested", Zfindbest);
  zdef_(zmax, Zfindbestmax, " max. facets tested", -1);
  zdef_(zadd, Zfindcoplanar, " ave. coplanar search", Zfindbest);
  zdef_(zinc, Zfindnew, "calls to findbestnew", -1);
  zdef_(zadd, Zfindnewtot, " ave. facets tested", Zfindnew);
  zdef_(zmax, Zfindnewmax, " max. facets tested", -1);
  zdef_(zinc, Zfindnewjump, " ave. clearly better", Zfindnew);
  zdef_(zinc, Zfindnewsharp, " calls due to qh_sharpnewfacets", -1);
  zdef_(zinc, Zfindhorizon, "calls to findhorizon", -1);
  zdef_(zadd, Zfindhorizontot, " ave. facets tested", Zfindhorizon);
  zdef_(zmax, Zfindhorizonmax, " max. facets tested", -1);
  zdef_(zinc, Zfindjump,       " ave. clearly better", Zfindhorizon);
  zdef_(zinc, Znewbesthorizon, " new bestfacets during qh_findbesthorizon", -1);
  zdef_(zinc, Zpartangle, "angle tests for repartitioned coplanar points", -1);
  zdef_(zinc, Zpartcorner, "  repartitioned coplanar points above a corner facet", -1);
  zdef_(zinc, Zparthidden, "  repartitioned coplanar points above a hidden facet", -1);
  zdef_(zinc, Zparttwisted, "  repartitioned coplanar points above a twisted facet", -1);
}
void qh_allstatE(qhT *qh) {
  zdef_(zinc, Zpartinside, "inside points", -1);
  zdef_(zinc, Zpartnear, "  near inside points kept with a facet", -1);
  zdef_(zinc, Zcoplanarinside, "  inside points that were coplanar with a facet", -1);
  zdef_(zinc, Zbestlower, "calls to findbestlower", -1);
  zdef_(zinc, Zbestlowerv, "  with search of vertex neighbors", -1);
  zdef_(zinc, Zbestlowerall, "  with rare search of all facets", -1);
  zdef_(zmax, Zbestloweralln, "  facets per search of all facets", -1);
  zdef_(wadd, Wmaxout, "difference in max_outside at final check", -1);
  zzdef_(zinc, Zpartitionall, "distance tests for initial partition", -1);
  zdef_(zinc, Ztotpartition, "partitions of a point", -1);
  zzdef_(zinc, Zpartition, "distance tests for partitioning", -1);
  zzdef_(zinc, Zdistcheck, "distance tests for checking flipped facets", -1);
  zzdef_(zinc, Zdistconvex, "distance tests for checking convexity", -1);
  zdef_(zinc, Zdistgood, "distance tests for checking good point", -1);
  zdef_(zinc, Zdistio, "distance tests for output", -1);
  zdef_(zinc, Zdiststat, "distance tests for statistics", -1);
  zzdef_(zinc, Zdistplane, "total number of distance tests", -1);
  zdef_(zinc, Ztotpartcoplanar, "partitions of coplanar points or deleted vertices", -1);
  zzdef_(zinc, Zpartcoplanar, "   distance tests for these partitions", -1);
  zdef_(zinc, Zcomputefurthest, "distance tests for computing furthest", -1);
}
void qh_allstatE2(qhT *qh) {
  zdef_(zdoc, Zdoc5, "statistics for matching ridges", -1);
  zdef_(zinc, Zhashlookup, "total lookups for matching ridges of new facets", -1);
  zdef_(zinc, Zhashtests, "average number of tests to match a ridge", Zhashlookup);
  zdef_(zinc, Zhashridge, "total lookups of subridges (duplicates and boundary)", -1);
  zdef_(zinc, Zhashridgetest, "average number of tests per subridge", Zhashridge);
  zdef_(zinc, Zdupsame, "duplicated ridges in same merge cycle", -1);
  zdef_(zinc, Zdupflip, "duplicated ridges with flipped facets", -1);

  zdef_(zdoc, Zdoc6, "statistics for determining merges", -1);
  zdef_(zinc, Zangletests, "angles computed for ridge convexity", -1);
  zdef_(zinc, Zbestcentrum, "best merges used centrum instead of vertices",-1);
  zzdef_(zinc, Zbestdist, "distance tests for best merge", -1);
  zzdef_(zinc, Zcentrumtests, "distance tests for centrum convexity", -1);
  zzdef_(zinc, Zvertextests, "distance tests for vertex convexity", -1);
  zzdef_(zinc, Zdistzero, "distance tests for checking simplicial convexity", -1);
  zdef_(zinc, Zcoplanarangle, "coplanar angles in getmergeset", -1);
  zdef_(zinc, Zcoplanarcentrum, "coplanar centrums or vertices in getmergeset", -1);
  zdef_(zinc, Zconcaveridge, "concave ridges in getmergeset", -1);
  zdef_(zinc, Zconcavecoplanarridge, "concave-coplanar ridges in getmergeset", -1);
  zdef_(zinc, Ztwistedridge, "twisted ridges in getmergeset", -1);
}
void qh_allstatF(qhT *qh) {
  zdef_(zdoc, Zdoc7, "statistics for merging", -1);
  zdef_(zinc, Zpremergetot, "merge iterations", -1);
  zdef_(zadd, Zmergeinittot, "ave. initial non-convex ridges per iteration", Zpremergetot);
  zdef_(zadd, Zmergeinitmax, "  maximum", -1);
  zdef_(zadd, Zmergesettot, "  ave. additional non-convex ridges per iteration", Zpremergetot);
  zdef_(zadd, Zmergesetmax, "  maximum additional in one pass", -1);
  zdef_(zadd, Zmergeinittot2, "initial non-convex ridges for post merging", -1);
  zdef_(zadd, Zmergesettot2, "  additional non-convex ridges", -1);
  zdef_(wmax, Wmaxoutside, "max distance of vertex or coplanar point above facet (w/roundoff)", -1);
  zdef_(wmin, Wminvertex, "max distance of vertex below facet (or roundoff)", -1);
  zdef_(zinc, Zwidefacet, "centrums frozen due to a wide merge", -1);
  zdef_(zinc, Zwidevertices, "centrums frozen due to extra vertices", -1);
  zzdef_(zinc, Ztotmerge, "total number of facets or cycles of facets merged", -1);
  zdef_(zinc, Zmergesimplex, "merged a simplex", -1);
  zdef_(zinc, Zonehorizon, "simplices merged into coplanar horizon", -1);
  zzdef_(zinc, Zcyclehorizon, "cycles of facets merged into coplanar horizon", -1);
  zzdef_(zadd, Zcyclefacettot, "  ave. facets per cycle", Zcyclehorizon);
  zdef_(zmax, Zcyclefacetmax, "  max. facets", -1);
  zdef_(zinc, Zmergeintocoplanar, "new facets merged into coplanar horizon", -1);
  zdef_(zinc, Zmergeintohorizon, "new facets merged into horizon", -1);
  zdef_(zinc, Zmergenew, "new facets merged", -1);
  zdef_(zinc, Zmergehorizon, "horizon facets merged into new facets", -1);
  zdef_(zinc, Zmergevertex, "vertices deleted by merging", -1);
  zdef_(zinc, Zcyclevertex, "vertices deleted by merging into coplanar horizon", -1);
  zdef_(zinc, Zdegenvertex, "vertices deleted by degenerate facet", -1);
  zdef_(zinc, Zmergeflipdup, "merges due to flipped facets in duplicated ridge", -1);
  zdef_(zinc, Zredundant, "merges due to redundant neighbors", -1);
  zdef_(zinc, Zredundantmerge, "  detected by qh_test_nonsimplicial_merge instead of qh_test_redundant_neighbors", -1);
  zdef_(zadd, Ztestvneighbor, "non-convex vertex neighbors", -1);
}
void qh_allstatG(qhT *qh) {
  zdef_(zinc, Zacoplanar, "merges due to angle coplanar facets", -1);
  zdef_(wadd, Wacoplanartot, "  average merge distance", Zacoplanar);
  zdef_(wmax, Wacoplanarmax, "  maximum merge distance", -1);
  zdef_(zinc, Zcoplanar, "merges due to coplanar facets", -1);
  zdef_(wadd, Wcoplanartot, "  average merge distance", Zcoplanar);
  zdef_(wmax, Wcoplanarmax, "  maximum merge distance", -1);
  zdef_(zinc, Zconcave, "merges due to concave facets", -1);
  zdef_(wadd, Wconcavetot, "  average merge distance", Zconcave);
  zdef_(wmax, Wconcavemax, "  maximum merge distance", -1);
  zdef_(zinc, Zconcavecoplanar, "merges due to concave-coplanar facets", -1);
  zdef_(wadd, Wconcavecoplanartot, "  average merge distance", Zconcavecoplanar);
  zdef_(wmax, Wconcavecoplanarmax, "  maximum merge distance", -1);
  zdef_(zinc, Zavoidold, "coplanar/concave merges due to avoiding old merge", -1);
  zdef_(wadd, Wavoidoldtot, "  average merge distance", Zavoidold);
  zdef_(wmax, Wavoidoldmax, "  maximum merge distance", -1);
  zdef_(zinc, Zdegen, "merges due to degenerate facets", -1);
  zdef_(wadd, Wdegentot, "  average merge distance", Zdegen);
  zdef_(wmax, Wdegenmax, "  maximum merge distance", -1);
  zdef_(zinc, Zflipped, "merges due to removing flipped facets", -1);
  zdef_(wadd, Wflippedtot, "  average merge distance", Zflipped);
  zdef_(wmax, Wflippedmax, "  maximum merge distance", -1);
  zdef_(zinc, Zduplicate, "merges due to dupridges", -1);
  zdef_(wadd, Wduplicatetot, "  average merge distance", Zduplicate);
  zdef_(wmax, Wduplicatemax, "  maximum merge distance", -1);
  zdef_(zinc, Ztwisted, "merges due to twisted facets", -1);
  zdef_(wadd, Wtwistedtot, "  average merge distance", Ztwisted);
  zdef_(wmax, Wtwistedmax, "  maximum merge distance", -1);
}
void qh_allstatH(qhT *qh) {
  zdef_(zdoc, Zdoc8, "statistics for vertex merges", -1);
  zzdef_(zinc, Zpinchduplicate, "merge pinched vertices for a duplicate ridge", -1);
  zzdef_(zinc, Zpinchedvertex, "merge pinched vertices for a dupridge", -1);
  zdef_(zinc, Zrenameshare, "renamed vertices shared by two facets", -1);
  zdef_(zinc, Zrenamepinch, "renamed vertices in a pinched facet", -1);
  zdef_(zinc, Zrenameall, "renamed vertices shared by multiple facets", -1);
  zdef_(zinc, Zfindfail, "rename failures due to duplicated ridges", -1);
  zdef_(zinc, Znewvertexridge, "  found new vertex in ridge", -1);
  zdef_(zinc, Zdelridge, "deleted ridges due to renamed vertices", -1);
  zdef_(zinc, Zdropneighbor, "dropped neighbors due to renamed vertices", -1);
  zdef_(zinc, Zdropdegen, "merge degenerate facets due to dropped neighbors", -1);
  zdef_(zinc, Zdelfacetdup, "  facets deleted because of no neighbors", -1);
  zdef_(zinc, Zremvertex, "vertices removed from facets due to no ridges", -1);
  zdef_(zinc, Zremvertexdel, "  deleted", -1);
  zdef_(zinc, Zretryadd, "retry qh_addpoint after merge pinched vertex", -1);
  zdef_(zadd, Zretryaddtot, "  tot. merge pinched vertex due to dupridge", -1);
  zdef_(zmax, Zretryaddmax, "  max. merge pinched vertex for a qh_addpoint", -1);
  zdef_(zinc, Zintersectnum, "vertex intersections for locating redundant vertices", -1);
  zdef_(zinc, Zintersectfail, "intersections failed to find a redundant vertex", -1);
  zdef_(zinc, Zintersect, "intersections found redundant vertices", -1);
  zdef_(zadd, Zintersecttot, "   ave. number found per vertex", Zintersect);
  zdef_(zmax, Zintersectmax, "   max. found for a vertex", -1);
  zdef_(zinc, Zvertexridge, NULL, -1);
  zdef_(zadd, Zvertexridgetot, "  ave. number of ridges per tested vertex", Zvertexridge);
  zdef_(zmax, Zvertexridgemax, "  max. number of ridges per tested vertex", -1);

  zdef_(zdoc, Zdoc10, "memory usage statistics (in bytes)", -1);
  zdef_(zadd, Zmemfacets, "for facets and their normals, neighbor and vertex sets", -1);
  zdef_(zadd, Zmemvertices, "for vertices and their neighbor sets", -1);
  zdef_(zadd, Zmempoints, "for input points, outside and coplanar sets, and qhT",-1);
  zdef_(zadd, Zmemridges, "for ridges and their vertex sets", -1);
} /* allstat */

void qh_allstatI(qhT *qh) {
  qh->qhstat.vridges= qh->qhstat.next; /* printed in qh_produce_output2 if non-zero Zridge or Zridgemid */
  zzdef_(zdoc, Zdoc11, "Voronoi ridge statistics", -1);
  zzdef_(zinc, Zridge, "non-simplicial Voronoi vertices for all ridges", -1);
  zzdef_(wadd, Wridge, "  ave. distance to ridge", Zridge);
  zzdef_(wmax, Wridgemax, "  max. distance to ridge", -1);
  zzdef_(zinc, Zridgemid, "bounded ridges", -1);
  zzdef_(wadd, Wridgemid, "  ave. distance of midpoint to ridge", Zridgemid);
  zzdef_(wmax, Wridgemidmax, "  max. distance of midpoint to ridge", -1);
  zzdef_(zinc, Zridgeok, "bounded ridges with ok normal", -1);
  zzdef_(wadd, Wridgeok, "  ave. angle to ridge", Zridgeok);
  zzdef_(wmax, Wridgeokmax, "  max. angle to ridge", -1);
  zzdef_(zinc, Zridge0, "bounded ridges with near-zero normal", -1);
  zzdef_(wadd, Wridge0, "  ave. angle to ridge", Zridge0);
  zzdef_(wmax, Wridge0max, "  max. angle to ridge", -1);

  zdef_(zdoc, Zdoc12, "Triangulation statistics ('Qt')", -1);
  zdef_(zinc, Ztricoplanar, "non-simplicial facets triangulated", -1);
  zdef_(zadd, Ztricoplanartot, "  ave. new facets created (may be deleted)", Ztricoplanar);
  zdef_(zmax, Ztricoplanarmax, "  max. new facets created", -1);
  zdef_(zinc, Ztrinull, "null new facets deleted (duplicated vertex)", -1);
  zdef_(zinc, Ztrimirror, "mirrored pairs of new facets deleted (same vertices)", -1);
  zdef_(zinc, Ztridegen, "degenerate new facets in output (same ridge)", -1);
} /* allstat */

/*---------------------------------

  qh_allstatistics()
    reset printed flag for all statistics
*/
void qh_allstatistics(qhT *qh) {
  int i;

  for(i=ZEND; i--; )
    qh->qhstat.printed[i]= False;
} /* allstatistics */

#if qh_KEEPstatistics
/*---------------------------------

  qh_collectstatistics()
    collect statistics for qh.facet_list

*/
void qh_collectstatistics(qhT *qh) {
  facetT *facet, *neighbor, **neighborp;
  vertexT *vertex, **vertexp;
  realT dotproduct, dist;
  int sizneighbors, sizridges, sizvertices, i;

  qh->old_randomdist= qh->RANDOMdist;
  qh->RANDOMdist= False;
  zval_(Zmempoints)= qh->num_points * qh->normal_size + (int)sizeof(qhT);
  zval_(Zmemfacets)= 0;
  zval_(Zmemridges)= 0;
  zval_(Zmemvertices)= 0;
  zval_(Zangle)= 0;
  wval_(Wangle)= 0.0;
  zval_(Znumridges)= 0;
  zval_(Znumfacets)= 0;
  zval_(Znumneighbors)= 0;
  zval_(Znumvertices)= 0;
  zval_(Znumvneighbors)= 0;
  zval_(Znummergetot)= 0;
  zval_(Znummergemax)= 0;
  zval_(Zvertices)= qh->num_vertices - qh_setsize(qh, qh->del_vertices);
  if (qh->MERGING || qh->APPROXhull || qh->JOGGLEmax < REALmax/2)
    wmax_(Wmaxoutside, qh->max_outside);
  if (qh->MERGING)
    wmin_(Wminvertex, qh->min_vertex);
  if (!qh_checklists(qh, qh->facet_list)) {
    qh_fprintf(qh, qh->ferr, 6373, "qhull internal error: qh_checklists failed on qh_collectstatistics\n");
    if (!qh->ERREXITcalled)
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  FORALLfacets
    facet->seen= False;
  if (qh->DELAUNAY) {
    FORALLfacets {
      if (facet->upperdelaunay != qh->UPPERdelaunay)
        facet->seen= True; /* remove from angle statistics */
    }
  }
  FORALLfacets {
    if (facet->visible && qh->NEWfacets)
      continue;
    sizvertices= qh_setsize(qh, facet->vertices);
    sizneighbors= qh_setsize(qh, facet->neighbors);
    sizridges= qh_setsize(qh, facet->ridges);
    zinc_(Znumfacets);
    zadd_(Znumvertices, sizvertices);
    zmax_(Zmaxvertices, sizvertices);
    zadd_(Znumneighbors, sizneighbors);
    zmax_(Zmaxneighbors, sizneighbors);
    zadd_(Znummergetot, facet->nummerge);
    i= facet->nummerge; /* avoid warnings */
    zmax_(Znummergemax, i);
    if (!facet->simplicial) {
      if (sizvertices == qh->hull_dim) {
        zinc_(Znowsimplicial);
      }else {
        zinc_(Znonsimplicial);
      }
    }
    if (sizridges) {
      zadd_(Znumridges, sizridges);
      zmax_(Zmaxridges, sizridges);
    }
    zadd_(Zmemfacets, (int)sizeof(facetT) + qh->normal_size + 2*SETbasesize
       + SETelemsize * (sizneighbors + sizvertices));
    if (facet->ridges) {
      zadd_(Zmemridges,
        SETbasesize + SETelemsize * sizridges + sizridges *
         ((int)sizeof(ridgeT) + SETbasesize + SETelemsize * (qh->hull_dim-1))/2);
    }
    if (facet->outsideset)
      zadd_(Zmempoints, SETbasesize + SETelemsize * qh_setsize(qh, facet->outsideset));
    if (facet->coplanarset)
      zadd_(Zmempoints, SETbasesize + SETelemsize * qh_setsize(qh, facet->coplanarset));
    if (facet->seen) /* Delaunay upper envelope */
      continue;
    facet->seen= True;
    FOREACHneighbor_(facet) {
      if (neighbor == qh_DUPLICATEridge || neighbor == qh_MERGEridge
          || neighbor->seen || !facet->normal || !neighbor->normal)
        continue;
      dotproduct= qh_getangle(qh, facet->normal, neighbor->normal);
      zinc_(Zangle);
      wadd_(Wangle, dotproduct);
      wmax_(Wanglemax, dotproduct)
      wmin_(Wanglemin, dotproduct)
    }
    if (facet->normal) {
      FOREACHvertex_(facet->vertices) {
        zinc_(Zdiststat);
        qh_distplane(qh, vertex->point, facet, &dist);
        wmax_(Wvertexmax, dist);
        wmin_(Wvertexmin, dist);
      }
    }
  }
  FORALLvertices {
    if (vertex->deleted)
      continue;
    zadd_(Zmemvertices, (int)sizeof(vertexT));
    if (vertex->neighbors) {
      sizneighbors= qh_setsize(qh, vertex->neighbors);
      zadd_(Znumvneighbors, sizneighbors);
      zmax_(Zmaxvneighbors, sizneighbors);
      zadd_(Zmemvertices, (int)sizeof(vertexT) + SETelemsize * sizneighbors);
    }
  }
  qh->RANDOMdist= qh->old_randomdist;
} /* collectstatistics */
#endif /* qh_KEEPstatistics */

/*---------------------------------

  qh_initstatistics(qh)
    initialize statistics

  notes:
    NOerrors -- qh_initstatistics can not use qh_errexit(), qh_fprintf, or qh.ferr
    On first call, only qhmem.ferr is defined.  qh_memalloc is not setup.
    Also invoked by QhullQh().
*/
void qh_initstatistics(qhT *qh) {
  int i;
  realT realx;
  int intx;

  qh_allstatistics(qh);
  qh->qhstat.next= 0;
  qh_allstatA(qh);
  qh_allstatB(qh);
  qh_allstatC(qh);
  qh_allstatD(qh);
  qh_allstatE(qh);
  qh_allstatE2(qh);
  qh_allstatF(qh);
  qh_allstatG(qh);
  qh_allstatH(qh);
  qh_allstatI(qh);
  if (qh->qhstat.next > (int)sizeof(qh->qhstat.id)) {
    qh_fprintf_stderr(6184, "qhull internal error (qh_initstatistics): increase size of qhstat.id[].  qhstat.next %d should be <= sizeof(qh->qhstat.id) %d\n", 
          qh->qhstat.next, (int)sizeof(qh->qhstat.id));
#if 0 /* for locating error, Znumridges should be duplicated */
    for(i=0; i < ZEND; i++) {
      int j;
      for(j=i+1; j < ZEND; j++) {
        if (qh->qhstat.id[i] == qh->qhstat.id[j]) {
          qh_fprintf_stderr(6185, "qhull error (qh_initstatistics): duplicated statistic %d at indices %d and %d\n",
              qh->qhstat.id[i], i, j);
        }
      }
    }
#endif
    qh_exit(qh_ERRqhull);  /* can not use qh_errexit() */
  }
  qh->qhstat.init[zinc].i= 0;
  qh->qhstat.init[zadd].i= 0;
  qh->qhstat.init[zmin].i= INT_MAX;
  qh->qhstat.init[zmax].i= INT_MIN;
  qh->qhstat.init[wadd].r= 0;
  qh->qhstat.init[wmin].r= REALmax;
  qh->qhstat.init[wmax].r= -REALmax;
  for(i=0; i < ZEND; i++) {
    if (qh->qhstat.type[i] > ZTYPEreal) {
      realx= qh->qhstat.init[(unsigned char)(qh->qhstat.type[i])].r;
      qh->qhstat.stats[i].r= realx;
    }else if (qh->qhstat.type[i] != zdoc) {
      intx= qh->qhstat.init[(unsigned char)(qh->qhstat.type[i])].i;
      qh->qhstat.stats[i].i= intx;
    }
  }
} /* initstatistics */

/*---------------------------------

  qh_newstats(qh )
    returns True if statistics for zdoc

  returns:
    next zdoc
*/
boolT qh_newstats(qhT *qh, int idx, int *nextindex) {
  boolT isnew= False;
  int start, i;

  if (qh->qhstat.type[qh->qhstat.id[idx]] == zdoc)
    start= idx+1;
  else
    start= idx;
  for(i= start; i < qh->qhstat.next && qh->qhstat.type[qh->qhstat.id[i]] != zdoc; i++) {
    if (!qh_nostatistic(qh, qh->qhstat.id[i]) && !qh->qhstat.printed[qh->qhstat.id[i]])
        isnew= True;
  }
  *nextindex= i;
  return isnew;
} /* newstats */

/*---------------------------------

  qh_nostatistic(qh, index )
    true if no statistic to print
*/
boolT qh_nostatistic(qhT *qh, int i) {

  if ((qh->qhstat.type[i] > ZTYPEreal
       &&qh->qhstat.stats[i].r == qh->qhstat.init[(unsigned char)(qh->qhstat.type[i])].r)
      || (qh->qhstat.type[i] < ZTYPEreal
          &&qh->qhstat.stats[i].i == qh->qhstat.init[(unsigned char)(qh->qhstat.type[i])].i))
    return True;
  return False;
} /* nostatistic */

#if qh_KEEPstatistics
/*---------------------------------

  qh_printallstatistics(qh, fp, string )
    print all statistics with header 'string'
*/
void qh_printallstatistics(qhT *qh, FILE *fp, const char *string) {

  qh_allstatistics(qh);
  qh_collectstatistics(qh);
  qh_printstatistics(qh, fp, string);
  qh_memstatistics(qh, fp);
}


/*---------------------------------

  qh_printstatistics(qh, fp, string )
    print statistics to a file with header 'string'
    skips statistics with qhstat.printed[] (reset with qh_allstatistics)

  see:
    qh_printallstatistics()
*/
void qh_printstatistics(qhT *qh, FILE *fp, const char *string) {
  int i, k;
  realT ave; /* ignored */

  if (qh->num_points != qh->num_vertices || zval_(Zpbalance) == 0) {
    wval_(Wpbalance)= 0.0;
    wval_(Wpbalance2)= 0.0;
  }else
    wval_(Wpbalance2)= qh_stddev(qh, zval_(Zpbalance), wval_(Wpbalance),
                                 wval_(Wpbalance2), &ave);
  if (zval_(Zprocessed) == 0)
    wval_(Wnewbalance2)= 0.0;
  else
    wval_(Wnewbalance2)= qh_stddev(qh, zval_(Zprocessed), wval_(Wnewbalance),
                                 wval_(Wnewbalance2), &ave);
  qh_fprintf(qh, fp, 9350, "\n\
%s\n\
qhull invoked by: %s | %s\n  %s with options:\n%s\n", 
    string, qh->rbox_command, qh->qhull_command, qh_version, qh->qhull_options);

  qh_fprintf(qh, fp, 9351, "\nprecision constants:\n\
 %6.2g max. abs. coordinate in the (transformed) input ('Qbd:n')\n\
 %6.2g max. roundoff error for distance computation ('En')\n\
 %6.2g max. roundoff error for angle computations\n\
 %6.2g min. distance for outside points ('Wn')\n\
 %6.2g min. distance for visible facets ('Vn')\n\
 %6.2g max. distance for coplanar facets ('Un')\n\
 %6.2g max. facet width for recomputing centrum and area\n\
",
  qh->MAXabs_coord, qh->DISTround, qh->ANGLEround, qh->MINoutside,
        qh->MINvisible, qh->MAXcoplanar, qh->WIDEfacet);
  if (qh->KEEPnearinside)
    qh_fprintf(qh, fp, 9352, "\
 %6.2g max. distance for near-inside points\n", qh->NEARinside);
  if (qh->premerge_cos < REALmax/2) qh_fprintf(qh, fp, 9353, "\
 %6.2g max. cosine for pre-merge angle\n", qh->premerge_cos);
  if (qh->PREmerge) qh_fprintf(qh, fp, 9354, "\
 %6.2g radius of pre-merge centrum\n", qh->premerge_centrum);
  if (qh->postmerge_cos < REALmax/2) qh_fprintf(qh, fp, 9355, "\
 %6.2g max. cosine for post-merge angle\n", qh->postmerge_cos);
  if (qh->POSTmerge) qh_fprintf(qh, fp, 9356, "\
 %6.2g radius of post-merge centrum\n", qh->postmerge_centrum);
  qh_fprintf(qh, fp, 9357, "\
 %6.2g max. distance for merging two simplicial facets\n\
 %6.2g max. roundoff error for arithmetic operations\n\
 %6.2g min. denominator for division\n\
  zero diagonal for Gauss: ", qh->ONEmerge, REALepsilon, qh->MINdenom);
  for(k=0; k < qh->hull_dim; k++)
    qh_fprintf(qh, fp, 9358, "%6.2e ", qh->NEARzero[k]);
  qh_fprintf(qh, fp, 9359, "\n\n");
  for(i=0 ; i < qh->qhstat.next; )
    qh_printstats(qh, fp, i, &i);
} /* printstatistics */
#endif /* qh_KEEPstatistics */

/*---------------------------------

  qh_printstatlevel(qh, fp, id )
    print level information for a statistic

  notes:
    nop if id >= ZEND, printed, or same as initial value
*/
void qh_printstatlevel(qhT *qh, FILE *fp, int id) {

  if (id >= ZEND || qh->qhstat.printed[id])
    return;
  if (qh->qhstat.type[id] == zdoc) {
    qh_fprintf(qh, fp, 9360, "%s\n", qh->qhstat.doc[id]);
    return;
  }
  if (qh_nostatistic(qh, id) || !qh->qhstat.doc[id])
    return;
  qh->qhstat.printed[id]= True;
  if (qh->qhstat.count[id] != -1
      && qh->qhstat.stats[(unsigned char)(qh->qhstat.count[id])].i == 0)
    qh_fprintf(qh, fp, 9361, " *0 cnt*");
  else if (qh->qhstat.type[id] >= ZTYPEreal && qh->qhstat.count[id] == -1)
    qh_fprintf(qh, fp, 9362, "%7.2g", qh->qhstat.stats[id].r);
  else if (qh->qhstat.type[id] >= ZTYPEreal && qh->qhstat.count[id] != -1)
    qh_fprintf(qh, fp, 9363, "%7.2g", qh->qhstat.stats[id].r/ qh->qhstat.stats[(unsigned char)(qh->qhstat.count[id])].i);
  else if (qh->qhstat.type[id] < ZTYPEreal && qh->qhstat.count[id] == -1)
    qh_fprintf(qh, fp, 9364, "%7d", qh->qhstat.stats[id].i);
  else if (qh->qhstat.type[id] < ZTYPEreal && qh->qhstat.count[id] != -1)
    qh_fprintf(qh, fp, 9365, "%7.3g", (realT) qh->qhstat.stats[id].i / qh->qhstat.stats[(unsigned char)(qh->qhstat.count[id])].i);
  qh_fprintf(qh, fp, 9366, " %s\n", qh->qhstat.doc[id]);
} /* printstatlevel */


/*---------------------------------

  qh_printstats(qh, fp, index, nextindex )
    print statistics for a zdoc group

  returns:
    next zdoc if non-null
*/
void qh_printstats(qhT *qh, FILE *fp, int idx, int *nextindex) {
  int j, nexti;

  if (qh_newstats(qh, idx, &nexti)) {
    qh_fprintf(qh, fp, 9367, "\n");
    for (j=idx; jqhstat.id[j]);
  }
  if (nextindex)
    *nextindex= nexti;
} /* printstats */

#if qh_KEEPstatistics

/*---------------------------------

  qh_stddev(qh, num, tot, tot2, ave )
    compute the standard deviation and average from statistics

    tot2 is the sum of the squares
  notes:
    computes r.m.s.:
      (x-ave)^2
      == x^2 - 2x tot/num +   (tot/num)^2
      == tot2 - 2 tot tot/num + tot tot/num
      == tot2 - tot ave
*/
realT qh_stddev(qhT *qh, int num, realT tot, realT tot2, realT *ave) {
  realT stddev;

  if (num <= 0) {
    qh_fprintf(qh, qh->ferr, 7101, "qhull warning (qh_stddev): expecting num > 0.  Got num %d, tot %4.4g, tot2 %4.4g.  Returning 0.0\n",
      num, tot, tot2);
    return 0.0;
  }
  *ave= tot/num;
  stddev= sqrt(fabs(tot2/num - *ave * *ave));
  return stddev;
} /* stddev */
#else
realT qh_stddev(qhT *qh, int num, realT tot, realT tot2, realT *ave) { /* for qhull_r-exports.def */
  QHULL_UNUSED(qh)
  QHULL_UNUSED(num)
  QHULL_UNUSED(tot)
  QHULL_UNUSED(tot2)
  QHULL_UNUSED(ave)

  return 0.0;
}
#endif /* qh_KEEPstatistics */

#if !qh_KEEPstatistics
void    qh_collectstatistics(qhT *qh) {}
void    qh_printallstatistics(qhT *qh, FILE *fp, const char *string) {}
void    qh_printstatistics(qhT *qh, FILE *fp, const char *string) {}
#endif

geometry/src/stat_r.h0000644000176200001440000003166514664417655014376 0ustar  liggesusers/*
  ---------------------------------

   stat_r.h
     contains all statistics that are collected for qhull

   see qh-stat_r.htm and stat_r.c

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/stat_r.h#4 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $

   recompile qhull if you change this file

   Integer statistics are Z* while real statistics are W*.

   define MAYdebugx to call a routine at every statistic event

*/

#ifndef qhDEFstat
#define qhDEFstat 1

/* Depends on realT.  Do not include "libqhull_r" to avoid circular dependency */

#ifndef DEFqhT
#define DEFqhT 1
typedef struct qhT qhT;         /* Defined by libqhull_r.h */
#endif

#ifndef DEFqhstatT
#define DEFqhstatT 1
typedef struct qhstatT qhstatT; /* Defined here */
#endif

/*---------------------------------

  qh_KEEPstatistics
    0 turns off statistic reporting and gathering (except zzdef/zzinc/zzadd/zzval/wwval)

  set qh_KEEPstatistics in user_r.h to 0 to turn off statistics
*/
#ifndef qh_KEEPstatistics
#define qh_KEEPstatistics 1
#endif

/*---------------------------------

  Zxxx for integers, Wxxx for reals

  notes:
    be sure that all statistics are defined in stat_r.c
      otherwise initialization may core dump
    can pick up all statistics by:
      grep '[zw].*_[(][ZW]' *.c >z.x
    remove trailers with query">-
    remove leaders with  query-replace-regexp [ ^I]+  (
*/
#if qh_KEEPstatistics
enum qh_statistics {     /* alphabetical after Z/W */
    Zacoplanar,
    Wacoplanarmax,
    Wacoplanartot,
    Zangle,
    Wangle,
    Wanglemax,
    Wanglemin,
    Zangletests,
    Wareatot,
    Wareamax,
    Wareamin,
    Zavoidold,
    Wavoidoldmax,
    Wavoidoldtot,
    Zback0,
    Zbestcentrum,
    Zbestdist,
    Zbestlower,
    Zbestlowerall,
    Zbestloweralln,
    Zbestlowerv,
    Zcentrumtests,
    Zcheckpart,
    Zcomputefurthest,
    Zconcave,
    Wconcavemax,
    Wconcavetot,
    Zconcavecoplanar,
    Wconcavecoplanarmax,
    Wconcavecoplanartot,
    Zconcavecoplanarridge,
    Zconcaveridge,
    Zconcaveridges,
    Zcoplanar,
    Wcoplanarmax,
    Wcoplanartot,
    Zcoplanarangle,
    Zcoplanarcentrum,
    Zcoplanarhorizon,
    Zcoplanarinside,
    Zcoplanarpart,
    Zcoplanarridges,
    Wcpu,
    Zcyclefacetmax,
    Zcyclefacettot,
    Zcyclehorizon,
    Zcyclevertex,
    Zdegen,
    Wdegenmax,
    Wdegentot,
    Zdegenvertex,
    Zdelfacetdup,
    Zdelridge,
    Zdelvertextot,
    Zdelvertexmax,
    Zdetfacetarea,
    Zdetsimplex,
    Zdistcheck,
    Zdistconvex,
    Zdistgood,
    Zdistio,
    Zdistplane,
    Zdiststat,
    Zdistvertex,
    Zdistzero,
    Zdoc1,
    Zdoc2,
    Zdoc3,
    Zdoc4,
    Zdoc5,
    Zdoc6,
    Zdoc7,
    Zdoc8,
    Zdoc9,
    Zdoc10,
    Zdoc11,
    Zdoc12,
    Zdropdegen,
    Zdropneighbor,
    Zdupflip,
    Zduplicate,
    Wduplicatemax,
    Wduplicatetot,
    Zdupsame,
    Zflipped,
    Wflippedmax,
    Wflippedtot,
    Zflippedfacets,
    Zflipridge,
    Zflipridge2,
    Zfindbest,
    Zfindbestmax,
    Zfindbesttot,
    Zfindcoplanar,
    Zfindfail,
    Zfindhorizon,
    Zfindhorizonmax,
    Zfindhorizontot,
    Zfindjump,
    Zfindnew,
    Zfindnewmax,
    Zfindnewtot,
    Zfindnewjump,
    Zfindnewsharp,
    Zgauss0,
    Zgoodfacet,
    Zhashlookup,
    Zhashridge,
    Zhashridgetest,
    Zhashtests,
    Zinsidevisible,
    Zintersect,
    Zintersectfail,
    Zintersectmax,
    Zintersectnum,
    Zintersecttot,
    Zmaxneighbors,
    Wmaxout,
    Wmaxoutside,
    Zmaxridges,
    Zmaxvertex,
    Zmaxvertices,
    Zmaxvneighbors,
    Zmemfacets,
    Zmempoints,
    Zmemridges,
    Zmemvertices,
    Zmergeflipdup,
    Zmergehorizon,
    Zmergeinittot,
    Zmergeinitmax,
    Zmergeinittot2,
    Zmergeintocoplanar,
    Zmergeintohorizon,
    Zmergenew,
    Zmergesettot,
    Zmergesetmax,
    Zmergesettot2,
    Zmergesimplex,
    Zmergevertex,
    Wmindenom,
    Wminvertex,
    Zminnorm,
    Zmultiridge,
    Znearlysingular,
    Zredundant,
    Wnewbalance,
    Wnewbalance2,
    Znewbesthorizon,
    Znewfacettot,
    Znewfacetmax,
    Znewvertex,
    Wnewvertex,
    Wnewvertexmax,
    Znewvertexridge,
    Znoarea,
    Znonsimplicial,
    Znowsimplicial,
    Znotgood,
    Znotgoodnew,
    Znotmax,
    Znumfacets,
    Znummergemax,
    Znummergetot,
    Znumneighbors,
    Znumridges,
    Znumvertices,
    Znumvisibility,
    Znumvneighbors,
    Zonehorizon,
    Zpartangle,
    Zpartcoplanar,
    Zpartcorner,
    Zparthidden,
    Zpartinside,
    Zpartition,
    Zpartitionall,
    Zpartnear,
    Zparttwisted,
    Zpbalance,
    Wpbalance,
    Wpbalance2,
    Zpinchduplicate,
    Zpinchedapex,
    Zpinchedvertex,
    Zpostfacets,
    Zpremergetot,
    Zprocessed,
    Zremvertex,
    Zremvertexdel,
    Zredundantmerge,
    Zrenameall,
    Zrenamepinch,
    Zrenameshare,
    Zretry,
    Wretrymax,
    Zretryadd,
    Zretryaddmax,
    Zretryaddtot,
    Zridge,
    Wridge,
    Wridgemax,
    Zridge0,
    Wridge0,
    Wridge0max,
    Zridgemid,
    Wridgemid,
    Wridgemidmax,
    Zridgeok,
    Wridgeok,
    Wridgeokmax,
    Zsearchpoints,
    Zsetplane,
    Ztestvneighbor,
    Ztotcheck,
    Ztothorizon,
    Ztotmerge,
    Ztotpartcoplanar,
    Ztotpartition,
    Ztotridges,
    Ztotvertices,
    Ztotvisible,
    Ztricoplanar,
    Ztricoplanarmax,
    Ztricoplanartot,
    Ztridegen,
    Ztrimirror,
    Ztrinull,
    Ztwisted,
    Wtwistedtot,
    Wtwistedmax,
    Ztwistedridge,
    Zvertextests,
    Wvertexmax,
    Wvertexmin,
    Zvertexridge,
    Zvertexridgetot,
    Zvertexridgemax,
    Zvertices,
    Zvisfacettot,
    Zvisfacetmax,
    Zvisit,
    Zvisit2max,
    Zvisvertextot,
    Zvisvertexmax,
    Zvvisit,
    Zvvisit2max,
    Zwidefacet,
    Zwidevertices,
    ZEND};

/*---------------------------------

  Zxxx/Wxxx statistics that remain defined if qh_KEEPstatistics=0

  notes:
    be sure to use zzdef, zzinc, etc. with these statistics (no double checking!)
*/
#else
enum qh_statistics {     /* for zzdef etc. macros */
  Zback0,
  Zbestdist,
  Zcentrumtests,
  Zcheckpart,
  Zconcaveridges,
  Zcoplanarhorizon,
  Zcoplanarpart,
  Zcoplanarridges,
  Zcyclefacettot,
  Zcyclehorizon,
  Zdelvertextot,
  Zdistcheck,
  Zdistconvex,
  Zdistplane,
  Zdistzero,
  Zdoc1,
  Zdoc2,
  Zdoc3,
  Zdoc11,
  Zflippedfacets,
  Zflipridge,
  Zflipridge2,
  Zgauss0,
  Zminnorm,
  Zmultiridge,
  Znearlysingular,
  Wnewvertexmax,
  Znumvisibility,
  Zpartcoplanar,
  Zpartition,
  Zpartitionall,
  Zpinchduplicate,
  Zpinchedvertex,
  Zprocessed,
  Zretry,
  Zridge,
  Wridge,
  Wridgemax,
  Zridge0,
  Wridge0,
  Wridge0max,
  Zridgemid,
  Wridgemid,
  Wridgemidmax,
  Zridgeok,
  Wridgeok,
  Wridgeokmax,
  Zsetplane,
  Ztotcheck,
  Ztotmerge,
  Zvertextests,
  ZEND};
#endif

/*---------------------------------

  ztype
    the type of a statistic sets its initial value.

  notes:
    The type should be the same as the macro for collecting the statistic
*/
enum ztypes {zdoc,zinc,zadd,zmax,zmin,ZTYPEreal,wadd,wmax,wmin,ZTYPEend};

/*========== macros and constants =============*/

/*----------------------------------

  MAYdebugx
    define as maydebug() to be called frequently for error trapping
*/
#define MAYdebugx

/*----------------------------------

  zzdef_, zdef_( type, name, doc, -1)
    define a statistic (assumes 'qhstat.next= 0;')

  zdef_( type, name, doc, count)
    define an averaged statistic
    printed as name/count
*/
#define zzdef_(stype,name,string,cnt) qh->qhstat.id[qh->qhstat.next++]=name; \
   qh->qhstat.doc[name]= string; qh->qhstat.count[name]= cnt; qh->qhstat.type[name]= stype
#if qh_KEEPstatistics
#define zdef_(stype,name,string,cnt) qh->qhstat.id[qh->qhstat.next++]=name; \
   qh->qhstat.doc[name]= string; qh->qhstat.count[name]= cnt; qh->qhstat.type[name]= stype
#else
#define zdef_(type,name,doc,count)
#endif

/*----------------------------------

  zzinc_( name ), zinc_( name)
    increment an integer statistic
*/
#define zzinc_(id) {MAYdebugx; qh->qhstat.stats[id].i++;}
#if qh_KEEPstatistics
#define zinc_(id) {MAYdebugx; qh->qhstat.stats[id].i++;}
#else
#define zinc_(id) {}
#endif

/*----------------------------------

  zzadd_( name, value ), zadd_( name, value ), wadd_( name, value )
    add value to an integer or real statistic
*/
#define zzadd_(id, val) {MAYdebugx; qh->qhstat.stats[id].i += (val);}
#define wwadd_(id, val) {MAYdebugx; qh->qhstat.stats[id].r += (val);}
#if qh_KEEPstatistics
#define zadd_(id, val) {MAYdebugx; qh->qhstat.stats[id].i += (val);}
#define wadd_(id, val) {MAYdebugx; qh->qhstat.stats[id].r += (val);}
#else
#define zadd_(id, val) {}
#define wadd_(id, val) {}
#endif

/*----------------------------------

  zzval_( name ), zval_( name ), wwval_( name )
    set or return value of a statistic
*/
#define zzval_(id) ((qh->qhstat.stats[id]).i)
#define wwval_(id) ((qh->qhstat.stats[id]).r)
#if qh_KEEPstatistics
#define zval_(id) ((qh->qhstat.stats[id]).i)
#define wval_(id) ((qh->qhstat.stats[id]).r)
#else
#define zval_(id) qh->qhstat.tempi
#define wval_(id) qh->qhstat.tempr
#endif

/*----------------------------------

  zmax_( id, val ), wmax_( id, value )
    maximize id with val
*/
#define wwmax_(id, val) {MAYdebugx; maximize_(qh->qhstat.stats[id].r,(val));}
#if qh_KEEPstatistics
#define zmax_(id, val) {MAYdebugx; maximize_(qh->qhstat.stats[id].i,(val));}
#define wmax_(id, val) {MAYdebugx; maximize_(qh->qhstat.stats[id].r,(val));}
#else
#define zmax_(id, val) {}
#define wmax_(id, val) {}
#endif

/*----------------------------------

  zmin_( id, val ), wmin_( id, value )
    minimize id with val
*/
#if qh_KEEPstatistics
#define zmin_(id, val) {MAYdebugx; minimize_(qh->qhstat.stats[id].i,(val));}
#define wmin_(id, val) {MAYdebugx; minimize_(qh->qhstat.stats[id].r,(val));}
#else
#define zmin_(id, val) {}
#define wmin_(id, val) {}
#endif

/*================== stat_r.h types ==============*/


/*----------------------------------

  intrealT
    union of integer and real, used for statistics
*/
typedef union intrealT intrealT;    /* union of int and realT */
union intrealT {
    int i;
    realT r;
};

/*----------------------------------

  qhstat
    Data structure for statistics, similar to qh and qhrbox

    Allocated as part of qhT (libqhull_r.h)
*/

struct qhstatT {
  intrealT   stats[ZEND];     /* integer and real statistics */
  unsigned char id[ZEND+10];  /* id's in print order */
  const char *doc[ZEND];      /* array of documentation strings */
  short int  count[ZEND];     /* -1 if none, else index of count to use */
  char       type[ZEND];      /* type, see ztypes above */
  char       printed[ZEND];   /* true, if statistic has been printed */
  intrealT   init[ZTYPEend];  /* initial values by types, set initstatistics */

  int        next;            /* next index for zdef_ */
  int        precision;       /* index for precision problems, printed on qh_errexit and qh_produce_output2/Q0/QJn */
  int        vridges;         /* index for Voronoi ridges, printed on qh_produce_output2 */
  int        tempi;
  realT      tempr;
};

/*========== function prototypes ===========*/

#ifdef __cplusplus
extern "C" {
#endif

void    qh_allstatA(qhT *qh);
void    qh_allstatB(qhT *qh);
void    qh_allstatC(qhT *qh);
void    qh_allstatD(qhT *qh);
void    qh_allstatE(qhT *qh);
void    qh_allstatE2(qhT *qh);
void    qh_allstatF(qhT *qh);
void    qh_allstatG(qhT *qh);
void    qh_allstatH(qhT *qh);
void    qh_allstatI(qhT *qh);
void    qh_allstatistics(qhT *qh);
void    qh_collectstatistics(qhT *qh);
void    qh_initstatistics(qhT *qh);
boolT   qh_newstats(qhT *qh, int idx, int *nextindex);
boolT   qh_nostatistic(qhT *qh, int i);
void    qh_printallstatistics(qhT *qh, FILE *fp, const char *string);
void    qh_printstatistics(qhT *qh, FILE *fp, const char *string);
void    qh_printstatlevel(qhT *qh, FILE *fp, int id);
void    qh_printstats(qhT *qh, FILE *fp, int idx, int *nextindex);
realT   qh_stddev(qhT *qh, int num, realT tot, realT tot2, realT *ave);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif   /* qhDEFstat */
geometry/src/qhull_ra.h0000644000176200001440000001253714664417655014706 0ustar  liggesusers/*
  ---------------------------------

   qhull_ra.h
   all header files for compiling qhull with reentrant code
   included before C++ headers for user_r.h:QHULL_CRTDBG

   see qh-qhull.htm

   see libqhull_r.h for user-level definitions

   see user_r.h for user-definable constants

   defines internal functions for libqhull_r.c global_r.c

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/qhull_ra.h#2 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $

   Notes:  grep for ((" and (" to catch fprintf("lkasdjf");
           full parens around (x?y:z)
           use '#include "libqhull_r/qhull_ra.h"' to avoid name clashes
*/

#ifndef qhDEFqhulla
#define qhDEFqhulla 1

#include "libqhull_r.h"  /* Includes user_r.h and data types */

#include "stat_r.h"
#include "random_r.h"
#include "mem_r.h"
#include "qset_r.h"
#include "geom_r.h"
#include "merge_r.h"
#include "poly_r.h"
#include "io_r.h"

#include 
#include 
#include 
#include     /* some compilers will not need float.h */
#include 
#include 
#include 
#include 
#include 
/*** uncomment here and qset_r.c
     if string.h does not define memcpy()
#include 
*/

#if qh_CLOCKtype == 2  /* defined in user_r.h from libqhull_r.h */
#include 
#include 
#include 
#endif

#ifdef _MSC_VER  /* Microsoft Visual C++ -- warning level 4 */
#pragma warning( disable : 4100)  /* unreferenced formal parameter */
#pragma warning( disable : 4127)  /* conditional expression is constant */
#pragma warning( disable : 4706)  /* assignment within conditional function */
#pragma warning( disable : 4996)  /* function was declared deprecated(strcpy, localtime, etc.) */
#endif

/* ======= -macros- =========== */

/*----------------------------------

  traceN((qh, qh->ferr, 0Nnnn, "format\n", vars));
    calls qh_fprintf if qh.IStracing >= N

    Add debugging traps to the end of qh_fprintf

  notes:
    removing tracing reduces code size but doesn't change execution speed
*/
#ifndef qh_NOtrace
#define trace0(args) {if (qh->IStracing) qh_fprintf args;}
#define trace1(args) {if (qh->IStracing >= 1) qh_fprintf args;}
#define trace2(args) {if (qh->IStracing >= 2) qh_fprintf args;}
#define trace3(args) {if (qh->IStracing >= 3) qh_fprintf args;}
#define trace4(args) {if (qh->IStracing >= 4) qh_fprintf args;}
#define trace5(args) {if (qh->IStracing >= 5) qh_fprintf args;}
#else /* qh_NOtrace */
#define trace0(args) {}
#define trace1(args) {}
#define trace2(args) {}
#define trace3(args) {}
#define trace4(args) {}
#define trace5(args) {}
#endif /* qh_NOtrace */

/*----------------------------------

  Define an unused variable to avoid compiler warnings

  Derived from Qt's corelib/global/qglobal.h

*/

#if defined(__cplusplus) && defined(__INTEL_COMPILER) && !defined(QHULL_OS_WIN)
template 
inline void qhullUnused(T &x) { (void)x; }
#  define QHULL_UNUSED(x) qhullUnused(x);
#else
#  define QHULL_UNUSED(x) (void)x;
#endif

#ifdef __cplusplus
extern "C" {
#endif

/***** -libqhull_r.c prototypes (alphabetical after qhull) ********************/

void    qh_qhull(qhT *qh);
boolT   qh_addpoint(qhT *qh, pointT *furthest, facetT *facet, boolT checkdist);
void    qh_build_withrestart(qhT *qh);
vertexT *qh_buildcone(qhT *qh, pointT *furthest, facetT *facet, int goodhorizon, facetT **retryfacet);
boolT   qh_buildcone_mergepinched(qhT *qh, vertexT *apex, facetT *facet, facetT **retryfacet);
boolT   qh_buildcone_onlygood(qhT *qh, vertexT *apex, int goodhorizon);
void    qh_buildhull(qhT *qh);
void    qh_buildtracing(qhT *qh, pointT *furthest, facetT *facet);
void    qh_errexit2(qhT *qh, int exitcode, facetT *facet, facetT *otherfacet);
void    qh_findhorizon(qhT *qh, pointT *point, facetT *facet, int *goodvisible,int *goodhorizon);
pointT *qh_nextfurthest(qhT *qh, facetT **visible);
void    qh_partitionall(qhT *qh, setT *vertices, pointT *points,int npoints);
void    qh_partitioncoplanar(qhT *qh, pointT *point, facetT *facet, realT *dist, boolT allnew);
void    qh_partitionpoint(qhT *qh, pointT *point, facetT *facet);
void    qh_partitionvisible(qhT *qh, boolT allpoints, int *numpoints);
void    qh_joggle_restart(qhT *qh, const char *reason);
void    qh_printsummary(qhT *qh, FILE *fp);

/***** -global_r.c internal prototypes (alphabetical) ***********************/

void    qh_appendprint(qhT *qh, qh_PRINT format);
void    qh_freebuild(qhT *qh, boolT allmem);
void    qh_freebuffers(qhT *qh);
void    qh_initbuffers(qhT *qh, coordT *points, int numpoints, int dim, boolT ismalloc);

/***** -stat_r.c internal prototypes (alphabetical) ***********************/

void    qh_allstatA(qhT *qh);
void    qh_allstatB(qhT *qh);
void    qh_allstatC(qhT *qh);
void    qh_allstatD(qhT *qh);
void    qh_allstatE(qhT *qh);
void    qh_allstatE2(qhT *qh);
void    qh_allstatF(qhT *qh);
void    qh_allstatG(qhT *qh);
void    qh_allstatH(qhT *qh);
void    qh_freebuffers(qhT *qh);
void    qh_initbuffers(qhT *qh, coordT *points, int numpoints, int dim, boolT ismalloc);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* qhDEFqhulla */
geometry/src/io_r.h0000644000176200001440000002060314664417655014020 0ustar  liggesusers/*
  ---------------------------------

   io_r.h
   declarations of Input/Output functions

   see README, libqhull_r.h and io_r.c

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/io_r.h#3 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#ifndef qhDEFio
#define qhDEFio 1

#include "libqhull_r.h"

/*============ constants and flags ==================*/

/*----------------------------------

  qh_MAXfirst
    maximum length of first two lines of stdin
*/
#define qh_MAXfirst  200

/*----------------------------------

  qh_MINradius
    min radius for Gp and Gv, fraction of maxcoord
*/
#define qh_MINradius 0.02

/*----------------------------------

  qh_GEOMepsilon
    adjust outer planes for 'lines closer' and geomview roundoff.
    This prevents bleed through.
*/
#define qh_GEOMepsilon 2e-3

/*----------------------------------

  qh_WHITESPACE
    possible values of white space
*/
#define qh_WHITESPACE " \n\t\v\r\f"


/*----------------------------------

  qh_RIDGE
    to select which ridges to print in qh_eachvoronoi
*/
typedef enum
{
    qh_RIDGEall= 0, qh_RIDGEinner, qh_RIDGEouter
}
qh_RIDGE;

/*----------------------------------

  printvridgeT
    prints results of qh_printvdiagram

  see:
    qh_printvridge for an example
*/
typedef void (*printvridgeT)(qhT *qh, FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded);

/*============== -prototypes in alphabetical order =========*/

#ifdef __cplusplus
extern "C" {
#endif

void    qh_dfacet(qhT *qh, unsigned int id);
void    qh_dvertex(qhT *qh, unsigned int id);
int     qh_compare_facetarea(const void *p1, const void *p2);
int     qh_compare_facetvisit(const void *p1, const void *p2);
int     qh_compare_nummerge(const void *p1, const void *p2);
void    qh_copyfilename(qhT *qh, char *filename, int size, const char* source, int length);
void    qh_countfacets(qhT *qh, facetT *facetlist, setT *facets, boolT printall,
              int *numfacetsp, int *numsimplicialp, int *totneighborsp,
              int *numridgesp, int *numcoplanarsp, int *numnumtricoplanarsp);
pointT *qh_detvnorm(qhT *qh, vertexT *vertex, vertexT *vertexA, setT *centers, realT *offsetp);
setT   *qh_detvridge(qhT *qh, vertexT *vertex);
setT   *qh_detvridge3(qhT *qh, vertexT *atvertex, vertexT *vertex);
int     qh_eachvoronoi(qhT *qh, FILE *fp, printvridgeT printvridge, vertexT *atvertex, boolT visitall, qh_RIDGE innerouter, boolT inorder);
int     qh_eachvoronoi_all(qhT *qh, FILE *fp, printvridgeT printvridge, boolT isUpper, qh_RIDGE innerouter, boolT inorder);
void    qh_facet2point(qhT *qh, facetT *facet, pointT **point0, pointT **point1, realT *mindist);
setT   *qh_facetvertices(qhT *qh, facetT *facetlist, setT *facets, boolT allfacets);
void    qh_geomplanes(qhT *qh, facetT *facet, realT *outerplane, realT *innerplane);
void    qh_markkeep(qhT *qh, facetT *facetlist);
setT   *qh_markvoronoi(qhT *qh, facetT *facetlist, setT *facets, boolT printall, boolT *isLowerp, int *numcentersp);
void    qh_order_vertexneighbors(qhT *qh, vertexT *vertex);
void    qh_prepare_output(qhT *qh);
void    qh_printafacet(qhT *qh, FILE *fp, qh_PRINT format, facetT *facet, boolT printall);
void    qh_printbegin(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall);
void    qh_printcenter(qhT *qh, FILE *fp, qh_PRINT format, const char *string, facetT *facet);
void    qh_printcentrum(qhT *qh, FILE *fp, facetT *facet, realT radius);
void    qh_printend(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall);
void    qh_printend4geom(qhT *qh, FILE *fp, facetT *facet, int *num, boolT printall);
void    qh_printextremes(qhT *qh, FILE *fp, facetT *facetlist, setT *facets, boolT printall);
void    qh_printextremes_2d(qhT *qh, FILE *fp, facetT *facetlist, setT *facets, boolT printall);
void    qh_printextremes_d(qhT *qh, FILE *fp, facetT *facetlist, setT *facets, boolT printall);
void    qh_printfacet(qhT *qh, FILE *fp, facetT *facet);
void    qh_printfacet2math(qhT *qh, FILE *fp, facetT *facet, qh_PRINT format, int notfirst);
void    qh_printfacet2geom(qhT *qh, FILE *fp, facetT *facet, realT color[3]);
void    qh_printfacet2geom_points(qhT *qh, FILE *fp, pointT *point1, pointT *point2,
                               facetT *facet, realT offset, realT color[3]);
void    qh_printfacet3math(qhT *qh, FILE *fp, facetT *facet, qh_PRINT format, int notfirst);
void    qh_printfacet3geom_nonsimplicial(qhT *qh, FILE *fp, facetT *facet, realT color[3]);
void    qh_printfacet3geom_points(qhT *qh, FILE *fp, setT *points, facetT *facet, realT offset, realT color[3]);
void    qh_printfacet3geom_simplicial(qhT *qh, FILE *fp, facetT *facet, realT color[3]);
void    qh_printfacet3vertex(qhT *qh, FILE *fp, facetT *facet, qh_PRINT format);
void    qh_printfacet4geom_nonsimplicial(qhT *qh, FILE *fp, facetT *facet, realT color[3]);
void    qh_printfacet4geom_simplicial(qhT *qh, FILE *fp, facetT *facet, realT color[3]);
void    qh_printfacetNvertex_nonsimplicial(qhT *qh, FILE *fp, facetT *facet, int id, qh_PRINT format);
void    qh_printfacetNvertex_simplicial(qhT *qh, FILE *fp, facetT *facet, qh_PRINT format);
void    qh_printfacetheader(qhT *qh, FILE *fp, facetT *facet);
void    qh_printfacetridges(qhT *qh, FILE *fp, facetT *facet);
void    qh_printfacets(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall);
void    qh_printhyperplaneintersection(qhT *qh, FILE *fp, facetT *facet1, facetT *facet2,
                   setT *vertices, realT color[3]);
void    qh_printline3geom(qhT *qh, FILE *fp, pointT *pointA, pointT *pointB, realT color[3]);
void    qh_printneighborhood(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetA, facetT *facetB, boolT printall);
void    qh_printpoint(qhT *qh, FILE *fp, const char *string, pointT *point);
void    qh_printpointid(qhT *qh, FILE *fp, const char *string, int dim, pointT *point, int id);
void    qh_printpoint3(qhT *qh, FILE *fp, pointT *point);
void    qh_printpoints_out(qhT *qh, FILE *fp, facetT *facetlist, setT *facets, boolT printall);
void    qh_printpointvect(qhT *qh, FILE *fp, pointT *point, coordT *normal, pointT *center, realT radius, realT color[3]);
void    qh_printpointvect2(qhT *qh, FILE *fp, pointT *point, coordT *normal, pointT *center, realT radius);
void    qh_printridge(qhT *qh, FILE *fp, ridgeT *ridge);
void    qh_printspheres(qhT *qh, FILE *fp, setT *vertices, realT radius);
void    qh_printvdiagram(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall);
int     qh_printvdiagram2(qhT *qh, FILE *fp, printvridgeT printvridge, setT *vertices, qh_RIDGE innerouter, boolT inorder);
void    qh_printvertex(qhT *qh, FILE *fp, vertexT *vertex);
void    qh_printvertexlist(qhT *qh, FILE *fp, const char* string, facetT *facetlist,
                         setT *facets, boolT printall);
void    qh_printvertices(qhT *qh, FILE *fp, const char* string, setT *vertices);
void    qh_printvneighbors(qhT *qh, FILE *fp, facetT* facetlist, setT *facets, boolT printall);
void    qh_printvoronoi(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetlist, setT *facets, boolT printall);
void    qh_printvnorm(qhT *qh, FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded);
void    qh_printvridge(qhT *qh, FILE *fp, vertexT *vertex, vertexT *vertexA, setT *centers, boolT unbounded);
void    qh_produce_output(qhT *qh);
void    qh_produce_output2(qhT *qh);
void    qh_projectdim3(qhT *qh, pointT *source, pointT *destination);
int     qh_readfeasible(qhT *qh, int dim, const char *curline);
coordT *qh_readpoints(qhT *qh, int *numpoints, int *dimension, boolT *ismalloc);
void    qh_setfeasible(qhT *qh, int dim);
boolT   qh_skipfacet(qhT *qh, facetT *facet);
char   *qh_skipfilename(qhT *qh, char *filename);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* qhDEFio */
geometry/src/Rdelaunayn.c0000644000176200001440000001621414664417655015170 0ustar  liggesusers/* Copyright (C) 2000 Kai Habel
** Copyright R-version (C) 2005 Raoul Grasman
** Copyright           (C) 2013-2024 David Sterratt
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*/

/*
16. July 2000 - Kai Habel: first release

25. September 2002 - Changes by Rafael Laboissiere 

 * Added Qbb option to normalize the input and avoid crashes in Octave.
 * delaunayn accepts now a second (optional) argument that must be a string
   containing extra options to the qhull command.
 * Fixed doc string.  The dimension of the result matrix is [m, dim+1], and
   not [n, dim-1].

20. May 2005 - Raoul Grasman: ported to R
 * Changed the interface for R
*/

#include "Rgeometry.h"
#include               /* For unlink() */

SEXP C_delaunayn(const SEXP p, const SEXP options, SEXP tmp_stdout, SEXP tmp_stderr)
{
  /* Initialise return values */ 

  SEXP retlist, retnames;       /* Return list and names */
	SEXP tri;                     /* The triangulation */
  SEXP neighbour, neighbours;   /* List of neighbours */
  SEXP areas;                   /* Facet areas */
	tri = neighbours = retlist = areas = R_NilValue;

  /* Run Qhull */
  
  qhT *qh= (qhT*)malloc(sizeof(qhT));
  char errstr[ERRSTRSIZE];
  unsigned int dim, n;
  char cmd[50] = "qhull d Qbb T0";
  /* Qz forces triangulation when the number of points is equal to the
     number of dimensions + 1 ; This mirrors the behaviour of octave
     and matlab */
  if (Rf_nrows(p) == Rf_ncols(p) + 1) {
    strncat(cmd, " Qz", 4);
  }
  int exitcode = qhullNewQhull(qh, p, cmd,  options, tmp_stdout, tmp_stderr, &dim, &n, errstr);

  /* Extract information from output */
  
  if (!exitcode) {                    /* 0 if no error from qhull */
    /* Triangulate non-simplicial facets - this commented out code
       does not appear to be needed, but retaining in case useful --
       David Sterratt, 2013-04-17 */
    /* qh_triangulate (); */

    facetT *facet;                  /* set by FORALLfacets */
    vertexT *vertex, **vertexp;
    facetT *neighbor, **neighborp;

    /* Count the number of facets so we know how much space to
       allocate in R */
    int nf=0;                 /* Number of facets */
    FORALLfacets {
      if (!facet->upperdelaunay) {
        /* Remove degenerate simplicies */
        if (!facet->isarea) {
          facet->f.area= qh_facetarea(qh, facet);
          facet->isarea= True;
        }
        if (facet->f.area)
          nf++;
      }
      /* Double check. Non-simplicial facets will cause segfault
         below */
      if (! facet->simplicial) {
        Rprintf("Qhull returned non-simplicial facets -- try delaunayn with different options");
        exitcode = 1;
        break;
      }
    }
      
    /* Alocate the space in R */
    PROTECT(tri = Rf_allocMatrix(INTSXP, nf, dim+1));
    if (hasPrintOption(qh, qh_PRINTneighbors)) {
      PROTECT(neighbours = Rf_allocVector(VECSXP, nf));
    } else {
      PROTECT(neighbours = R_NilValue);
    }
    if (hasPrintOption(qh, qh_PRINTarea)) {
      PROTECT(areas = Rf_allocVector(REALSXP, nf));
    } else {
      PROTECT(areas = R_NilValue);
    }
    
    /* Iterate through facets to extract information */
    int i=0;
    FORALLfacets {
      if (!facet->upperdelaunay && facet->f.area) {
        if (i >= nf) {
          Rf_error("Trying to access non-existent facet %i", i);
        }

        /* Triangulation */
        int j=0;
        FOREACHvertex_ (facet->vertices) {
          if ((i + nf*j) >= nf*(dim+1))
            Rf_error("Trying to write to non-existent area of memory i=%i, j=%i, nf=%i, dim=%i", i, j, nf, dim);
          INTEGER(tri)[i + nf*j] = 1 + qh_pointid(qh, vertex->point);
          j++;
        }

        /* Neighbours - option Fn */
        if (hasPrintOption(qh, qh_PRINTneighbors)) {
          PROTECT(neighbour = Rf_allocVector(INTSXP, qh_setsize(qh, facet->neighbors)));
          j=0;
          FOREACHneighbor_(facet) {
            INTEGER(neighbour)[j] = neighbor->visitid ? neighbor->visitid: 0 - neighbor->id;
            j++;
          }
          SET_VECTOR_ELT(neighbours, i, neighbour);
          UNPROTECT(1);
        }

        /* Areas - option Fa */
        if (hasPrintOption(qh, qh_PRINTarea)) {
          /* Area. Code modified from qh_getarea() in libquhull/geom2.c */
          if ((facet->normal) && !(facet->upperdelaunay && qh->ATinfinity)) {
            if (!facet->isarea) {
              facet->f.area= qh_facetarea(qh, facet);
              facet->isarea= True;
            }
            REAL(areas)[i] = facet->f.area;
          }
        }

        i++;
      }
    }
  } else { /* exitcode != 1 */
    /* There has been an error; Qhull will print the error
       message */
    PROTECT(tri = Rf_allocMatrix(INTSXP, 0, dim+1));
    if (hasPrintOption(qh, qh_PRINTneighbors)) {
      PROTECT(neighbours = Rf_allocVector(VECSXP, 0));
    } else {
      PROTECT(neighbours = R_NilValue);
    }
    if (hasPrintOption(qh, qh_PRINTarea)) {
      PROTECT(areas = Rf_allocVector(REALSXP, 0));
    } else {
      PROTECT(areas = R_NilValue);
    }

    /* If the error been because the points are colinear, coplanar
       &c., then avoid mentioning an error by setting exitcode=2 .

       This is the same behaviour as octave:
    >> delaunayn([0 0; 1 1; 2 2], "")
       ans = [](0x3)

       But Matlab has different behaviour:
       delaunayn([0 0; 1 1; 2 2])
       ans =     1     2     3
    */

    if ((dim + 1) == n) {
      exitcode = 2;
    }
  }

  /* Set up output structure */
  retlist =  PROTECT(Rf_allocVector(VECSXP, 3));
  retnames = PROTECT(Rf_allocVector(VECSXP, 3));
  SET_VECTOR_ELT(retlist,  0, tri);
  SET_VECTOR_ELT(retnames, 0, Rf_mkChar("tri"));
  SET_VECTOR_ELT(retlist,  1, neighbours);
  SET_VECTOR_ELT(retnames, 1, Rf_mkChar("neighbours"));
  SET_VECTOR_ELT(retlist,  2, areas);
  SET_VECTOR_ELT(retnames, 2, Rf_mkChar("areas"));
  Rf_setAttrib(retlist, R_NamesSymbol, retnames);
  
  /* Register qhullFinalizer() for garbage collection and attach a
     pointer to the hull as an attribute for future use. */
  SEXP ptr, tag;
  PROTECT(tag = Rf_allocVector(STRSXP, 1));
  SET_STRING_ELT(tag, 0, Rf_mkChar("delaunayn"));
  PROTECT(ptr = R_MakeExternalPtr(qh, tag, R_NilValue));
  if (exitcode) {
    qhullFinalizer(ptr);
  } else {
    R_RegisterCFinalizerEx(ptr, qhullFinalizer, TRUE);
    Rf_setAttrib(retlist, tag, ptr);
  }

  UNPROTECT(7); /* ptr, tag, retnames, retlist, areas, neigbours, tri */
  
  if (exitcode & (exitcode != 2)) {
    Rf_error("Received error code %d from qhull. Qhull error:\n%s", exitcode, errstr);
  } 
  
	return retlist;
}


geometry/src/qset_r.h0000644000176200001440000003740714740036162014360 0ustar  liggesusers/*
  ---------------------------------

   qset_r.h
     header file for qset_r.c that implements set

   see qh-set_r.htm and qset_r.c

   only uses mem_r.c, malloc/free

   for error handling, writes message and calls
      qh_errexit(qhT *qh, qhmem_ERRqhull, NULL, NULL);

   set operations satisfy the following properties:
    - sets have a max size, the actual size (if different) is stored at the end
    - every set is NULL terminated
    - sets may be sorted or unsorted, the caller must distinguish this

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/qset_r.h#4 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#ifndef qhDEFset
#define qhDEFset 1

#include 

/*================= -structures- ===============*/

#ifndef DEFsetT
#define DEFsetT 1
typedef struct setT setT;   /* a set is a sorted or unsorted array of pointers */
#endif

#ifndef DEFqhT
#define DEFqhT 1
typedef struct qhT qhT;          /* defined in libqhull_r.h */
#endif

/* [jan'15] Decided not to use countT.  Most sets are small.  The code uses signed tests */

/*------------------------------------------

setT
  a set or list of pointers with maximum size and actual size.

variations:
  unsorted, unique   -- a list of unique pointers with NULL terminator
                           user guarantees uniqueness
  sorted             -- a sorted list of unique pointers with NULL terminator
                           qset_r.c guarantees uniqueness
  unsorted           -- a list of pointers terminated with NULL
  indexed            -- an array of pointers with NULL elements

structure for set of n elements:

        --------------
        |  maxsize
        --------------
        |  e[0] - a pointer, may be NULL for indexed sets
        --------------
        |  e[1]

        --------------
        |  ...
        --------------
        |  e[n-1]
        --------------
        |  e[n] = NULL
        --------------
        |  ...
        --------------
        |  e[maxsize] - n+1 or NULL (determines actual size of set)
        --------------

*/

/*-- setelemT -- internal type to allow both pointers and indices
*/
typedef union setelemT setelemT;
union setelemT {
  void    *p;
  int   i;         /* integer used for e[maxSize] */
};

struct setT {
  int maxsize;          /* maximum number of elements (except NULL) */
  setelemT e[];        /* array of pointers, tail is NULL */ /* CHANGE TO SOURCE , Tomas Kalibera 2025-01-09 */
                        /* last slot (unless NULL) is actual size+1
                           e[maxsize]==NULL or e[e[maxsize]-1]==NULL */
                        /* this may generate a warning since e[] contains
                           maxsize elements */
};

/*=========== -constants- =========================*/

/*-------------------------------------

  SETelemsize
    size of a set element in bytes
*/
#define SETelemsize ((int)sizeof(setelemT))

/*
   CHANGE TO SOURCE: SETbasesize - size of setT with a single element
   in e[]. Before C99, setT has been declared with e[1], so
   sizeof(setT) included already space for one element, but with e[]
   (C99), it does not. All instances of (int)sizeof(setT) have been
   replaced with SETbasesize throughout the code -- Tomas Kalibera,
   2025-01-09 */
#define SETbasesize ((int)sizeof(setT) + SETelemsize)


/*=========== -macros- =========================*/

/*-------------------------------------

   FOREACHsetelement_(type, set, variable)
     define FOREACH iterator

   declare:
     assumes *variable and **variablep are declared
     no space in "variable)" [DEC Alpha cc compiler]

   each iteration:
     variable is set element
     variablep is one beyond variable.

   to repeat an element:
     variablep--; / *repeat* /

   at exit:
     variable is NULL at end of loop

   example:
     #define FOREACHfacet_(facets) FOREACHsetelement_(facetT, facets, facet)

   notes:
     use FOREACHsetelement_i_() if need index or include NULLs
     assumes set is not modified

   WARNING:
     nested loops can't use the same variable (define another FOREACH)

     needs braces if nested inside another FOREACH
     this includes intervening blocks, e.g. FOREACH...{ if () FOREACH...} )
*/
#define FOREACHsetelement_(type, set, variable) \
        if (((variable= NULL), set)) for (\
          variable##p= (type **)&((set)->e[0].p); \
          (variable= *variable##p++);)

/*------------------------------------------

   FOREACHsetelement_i_(qh, type, set, variable)
     define indexed FOREACH iterator

   declare:
     type *variable, variable_n, variable_i;

   each iteration:
     variable is set element, may be NULL
     variable_i is index, variable_n is qh_setsize()

   to repeat an element:
     variable_i--; variable_n-- repeats for deleted element

   at exit:
     variable==NULL and variable_i==variable_n

   example:
     #define FOREACHfacet_i_(qh, facets) FOREACHsetelement_i_(qh, facetT, facets, facet)

   WARNING:
     nested loops can't use the same variable (define another FOREACH)

     needs braces if nested inside another FOREACH
     this includes intervening blocks, e.g. FOREACH...{ if () FOREACH...} )
*/
#define FOREACHsetelement_i_(qh, type, set, variable) \
        if (((variable= NULL), set)) for (\
          variable##_i= 0, variable= (type *)((set)->e[0].p), \
                   variable##_n= qh_setsize(qh, set);\
          variable##_i < variable##_n;\
          variable= (type *)((set)->e[++variable##_i].p) )

/*----------------------------------------

   FOREACHsetelementreverse_(qh, type, set, variable)-
     define FOREACH iterator in reverse order

   declare:
     assumes *variable and **variablep are declared
     also declare 'int variabletemp'

   each iteration:
     variable is set element

   to repeat an element:
     variabletemp++; / *repeat* /

   at exit:
     variable is NULL

   example:
     #define FOREACHvertexreverse_(vertices) FOREACHsetelementreverse_(vertexT, vertices, vertex)

   notes:
     use FOREACHsetelementreverse12_() to reverse first two elements
     WARNING: needs braces if nested inside another FOREACH
*/
#define FOREACHsetelementreverse_(qh, type, set, variable) \
        if (((variable= NULL), set)) for (\
           variable##temp= qh_setsize(qh, set)-1, variable= qh_setlast(qh, set);\
           variable; variable= \
           ((--variable##temp >= 0) ? SETelemt_(set, variable##temp, type) : NULL))

/*-------------------------------------

   FOREACHsetelementreverse12_(type, set, variable)-
     define FOREACH iterator with e[1] and e[0] reversed

   declare:
     assumes *variable and **variablep are declared

   each iteration:
     variable is set element
     variablep is one after variable.

   to repeat an element:
     variablep--; / *repeat* /

   at exit:
     variable is NULL at end of loop

   example
     #define FOREACHvertexreverse12_(vertices) FOREACHsetelementreverse12_(vertexT, vertices, vertex)

   notes:
     WARNING: needs braces if nested inside another FOREACH
*/
#define FOREACHsetelementreverse12_(type, set, variable) \
        if (((variable= NULL), set)) for (\
          variable##p= (type **)&((set)->e[1].p); \
          (variable= *variable##p); \
          variable##p == ((type **)&((set)->e[0].p))?variable##p += 2: \
              (variable##p == ((type **)&((set)->e[1].p))?variable##p--:variable##p++))

/*-------------------------------------

   FOREACHelem_( set )-
     iterate elements in a set

   declare:
     void *elem, *elemp;

   each iteration:
     elem is set element
     elemp is one beyond

   to repeat an element:
     elemp--; / *repeat* /

   at exit:
     elem == NULL at end of loop

   example:
     FOREACHelem_(set) {

   notes:
     assumes set is not modified
     WARNING: needs braces if nested inside another FOREACH
*/
#define FOREACHelem_(set) FOREACHsetelement_(void, set, elem)

/*-------------------------------------

   FOREACHset_( set )-
     iterate a set of sets

   declare:
     setT *set, **setp;

   each iteration:
     set is set element
     setp is one beyond

   to repeat an element:
     setp--; / *repeat* /

   at exit:
     set == NULL at end of loop

   example
     FOREACHset_(sets) {

   notes:
     WARNING: needs braces if nested inside another FOREACH
*/
#define FOREACHset_(sets) FOREACHsetelement_(setT, sets, set)

/*-------------------------------------------

   SETindex_( set, elem )
     return index of elem in set

   notes:
     for use with FOREACH iteration
     WARN64 -- Maximum set size is 2G

   example:
     i= SETindex_(ridges, ridge)
*/
#define SETindex_(set, elem) ((int)((void **)elem##p - (void **)&(set)->e[1].p))

/*-----------------------------------------

   SETref_( elem )
     l.h.s. for modifying the current element in a FOREACH iteration

   example:
     SETref_(ridge)= anotherridge;
*/
#define SETref_(elem) (elem##p[-1])

/*-----------------------------------------

   SETelem_(set, n)
     return the n'th element of set

   notes:
      assumes that n is valid [0..size] and that set is defined
      use SETelemt_() for type cast
*/
#define SETelem_(set, n)           ((set)->e[n].p)

/*-----------------------------------------

   SETelemt_(set, n, type)
     return the n'th element of set as a type

   notes:
      assumes that n is valid [0..size] and that set is defined
*/
#define SETelemt_(set, n, type)    ((type *)((set)->e[n].p))

/*-----------------------------------------

   SETelemaddr_(set, n, type)
     return address of the n'th element of a set

   notes:
      assumes that n is valid [0..size] and set is defined
*/
#define SETelemaddr_(set, n, type) ((type **)(&((set)->e[n].p)))

/*-----------------------------------------

   SETfirst_(set)
     return first element of set

*/
#define SETfirst_(set)             ((set)->e[0].p)

/*-----------------------------------------

   SETfirstt_(set, type)
     return first element of set as a type

*/
#define SETfirstt_(set, type)      ((type *)((set)->e[0].p))

/*-----------------------------------------

   SETsecond_(set)
     return second element of set

*/
#define SETsecond_(set)            ((set)->e[1].p)

/*-----------------------------------------

   SETsecondt_(set, type)
     return second element of set as a type
*/
#define SETsecondt_(set, type)     ((type *)((set)->e[1].p))

/*-----------------------------------------

   SETaddr_(set, type)
       return address of set's elements
*/
#define SETaddr_(set,type)         ((type **)(&((set)->e[0].p)))

/*-----------------------------------------

   SETreturnsize_(set, size)
     return size of a set

   notes:
      set must be defined
      use qh_setsize(qhT *qh, set) unless speed is critical
*/
#define SETreturnsize_(set, size) (((size)= ((set)->e[(set)->maxsize].i))?(--(size)):((size)= (set)->maxsize))

/*-----------------------------------------

   SETempty_(set)
     return true(1) if set is empty (i.e., FOREACHsetelement_ is empty)

   notes:
      set may be NULL
      qh_setsize may be non-zero if first element is NULL
*/
#define SETempty_(set)            (!set || (SETfirst_(set) ? 0 : 1))

/*---------------------------------

  SETsizeaddr_(set)
    return pointer to 'actual size+1' of set (set CANNOT be NULL!!)
    Its type is setelemT* for strict aliasing
    All SETelemaddr_ must be cast to setelemT


  notes:
    *SETsizeaddr==NULL or e[*SETsizeaddr-1].p==NULL
*/
#define SETsizeaddr_(set) (&((set)->e[(set)->maxsize]))

/*-----------------------------------------

   SETtruncate_(set, size)
     truncate set to size

   see:
     qh_settruncate()

*/
#define SETtruncate_(set, size) {set->e[set->maxsize].i= size+1; /* maybe overwritten */ \
      set->e[size].p= NULL;}

/*======= prototypes in alphabetical order ============*/

#ifdef __cplusplus
extern "C" {
#endif

void  qh_setaddsorted(qhT *qh, setT **setp, void *elem);
void  qh_setaddnth(qhT *qh, setT **setp, int nth, void *newelem);
void  qh_setappend(qhT *qh, setT **setp, void *elem);
void  qh_setappend_set(qhT *qh, setT **setp, setT *setA);
void  qh_setappend2ndlast(qhT *qh, setT **setp, void *elem);
void  qh_setcheck(qhT *qh, setT *set, const char *tname, unsigned int id);
void  qh_setcompact(qhT *qh, setT *set);
setT *qh_setcopy(qhT *qh, setT *set, int extra);
void *qh_setdel(setT *set, void *elem);
void *qh_setdellast(setT *set);
void *qh_setdelnth(qhT *qh, setT *set, int nth);
void *qh_setdelnthsorted(qhT *qh, setT *set, int nth);
void *qh_setdelsorted(setT *set, void *newelem);
setT *qh_setduplicate(qhT *qh, setT *set, int elemsize);
void **qh_setendpointer(setT *set);
int   qh_setequal(setT *setA, setT *setB);
int   qh_setequal_except(setT *setA, void *skipelemA, setT *setB, void *skipelemB);
int   qh_setequal_skip(setT *setA, int skipA, setT *setB, int skipB);
void  qh_setfree(qhT *qh, setT **set);
void  qh_setfree2(qhT *qh, setT **setp, int elemsize);
void  qh_setfreelong(qhT *qh, setT **set);
int   qh_setin(setT *set, void *setelem);
int   qh_setindex(setT *set, void *setelem);
void  qh_setlarger(qhT *qh, setT **setp);
int   qh_setlarger_quick(qhT *qh, int setsize, int *newsize);
void *qh_setlast(setT *set);
setT *qh_setnew(qhT *qh, int size);
setT *qh_setnew_delnthsorted(qhT *qh, setT *set, int size, int nth, int prepend);
void  qh_setprint(qhT *qh, FILE *fp, const char* string, setT *set);
void  qh_setreplace(qhT *qh, setT *set, void *oldelem, void *newelem);
int   qh_setsize(qhT *qh, setT *set);
setT *qh_settemp(qhT *qh, int setsize);
void  qh_settempfree(qhT *qh, setT **set);
void  qh_settempfree_all(qhT *qh);
setT *qh_settemppop(qhT *qh);
void  qh_settemppush(qhT *qh, setT *set);
void  qh_settruncate(qhT *qh, setT *set, int size);
int   qh_setunique(qhT *qh, setT **set, void *elem);
void  qh_setzero(qhT *qh, setT *set, int idx, int size);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* qhDEFset */
geometry/src/userprintf_rbox_r.c0000644000176200001440000000323714664417655016643 0ustar  liggesusers/*
  ---------------------------------

   userprintf_rbox_r.c
   user redefinable function -- qh_fprintf_rbox

   see README.txt  see COPYING.txt for copyright information.

   If you recompile and load this file, then userprintf_rbox_r.o will not be loaded
   from qhull.a or qhull.lib

   See libqhull_r.h for data structures, macros, and user-callable functions.
   See user_r.c for qhull-related, redefinable functions
   see user_r.h for user-definable constants
   See usermem_r.c for qh_exit(), qh_free(), and qh_malloc()
   see Qhull.cpp and RboxPoints.cpp for examples.

   Please report any errors that you fix to qhull@qhull.org
*/

#include "libqhull_r.h"

#include 
#include 
#include 

/*---------------------------------

   qh_fprintf_rbox(qh, fp, msgcode, format, list of args )
     print arguments to *fp according to format
     Use qh_fprintf_rbox() for rboxlib_r.c

   notes:
     same as fprintf()
     fgets() is not trapped like fprintf()
     exit qh_fprintf_rbox via qh_errexit_rbox()
*/

void qh_fprintf_rbox(qhT *qh, FILE *fp, int msgcode, const char *fmt, ... ) {
    va_list args;

    if (!fp) {
      qh_fprintf_stderr(6231, "qhull internal error (userprintf_rbox_r.c): fp is 0.  Wrong qh_fprintf_rbox called.\n");
      qh_errexit_rbox(qh, qh_ERRqhull);
    }
    if (msgcode >= MSG_ERROR && msgcode < MSG_STDERR)
      fprintf(fp, "QH%.4d ", msgcode);
    va_start(args, fmt);
    vfprintf(fp, fmt, args);
    va_end(args);
} /* qh_fprintf_rbox */

geometry/src/mem_r.h0000644000176200001440000002171714744661713014171 0ustar  liggesusers/*
  ---------------------------------

   mem_r.h
     prototypes for memory management functions

   see qh-mem_r.htm, mem_r.c and qset_r.h

   for error handling, writes message and calls
     qh_errexit(qhT *qh, qhmem_ERRmem, NULL, NULL) if insufficient memory
       and
     qh_errexit(qhT *qh, qhmem_ERRqhull, NULL, NULL) otherwise

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/mem_r.h#6 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#ifndef qhDEFmem
#define qhDEFmem 1

#include 
#include 

#ifndef DEFsetT
#define DEFsetT 1
typedef struct setT setT;          /* defined in qset_r.h */
#endif

#ifndef DEFqhT
#define DEFqhT 1
typedef struct qhT qhT;          /* defined in libqhull_r.h */
#endif

/*---------------------------------

  qh_NOmem
    turn off quick-fit memory allocation

  notes:
    mem_r.c implements Quickfit memory allocation for about 20% time
    savings.  If it fails on your machine, try to locate the
    problem, and send the answer to qhull@qhull.org.  If this can
    not be done, define qh_NOmem to use malloc/free instead.

    #define qh_NOmem
*/

/*---------------------------------

qh_TRACEshort
Trace short and quick memory allocations at T5

*/
#define qh_TRACEshort

/*-------------------------------------------
    to avoid bus errors, memory allocation must consider alignment requirements.
    malloc() automatically takes care of alignment.   Since mem_r.c manages
    its own memory, we need to explicitly specify alignment in
    qh_meminitbuffers().

    A safe choice is sizeof(double).  sizeof(float) may be used if doubles
    do not occur in data structures and pointers are the same size.  Be careful
    of machines (e.g., DEC Alpha) with large pointers.  If gcc is available,
    use __alignof__(double) or fmax_(__alignof__(float), __alignof__(void *)).

   see qh_MEMalign in user_r.h for qhull's alignment
*/

#define qhmem_ERRmem 4    /* matches qh_ERRmem in libqhull_r.h */
#define qhmem_ERRqhull 5  /* matches qh_ERRqhull in libqhull_r.h */

/*----------------------------------

  ptr_intT
    for casting a void * to an integer-type that holds a pointer
    Used for integer expressions (e.g., computing qh_gethash() in poly_r.c)

  notes:
    WARN64 -- these notes indicate 64-bit issues
    On 64-bit machines, a pointer may be larger than an 'int'.
    qh_meminit()/mem_r.c checks that 'ptr_intT' holds a 'void*'
    ptr_intT is typically a signed value, but not necessarily so
    size_t is typically unsigned, but should match the parameter type
    Qhull uses int instead of size_t except for system calls such as malloc, qsort, qh_malloc, etc.
    This matches Qt convention and is easier to work with.
*/
#if (defined(__MINGW64__)) && defined(_WIN64)
typedef uintptr_t ptr_intT;
#elif defined(_MSC_VER) && defined(_WIN64)
typedef uintptr_t ptr_intT;
#else
typedef uintptr_t ptr_intT;
#endif

/*----------------------------------

  qhmemT
    global memory structure for mem_r.c

 notes:
   users should ignore qhmem except for writing extensions
   qhmem is allocated in mem_r.c

   qhmem could be swapable like qh and qhstat, but then
   multiple qh's and qhmem's would need to keep in synch.
   A swapable qhmem would also waste memory buffers.  As long
   as memory operations are atomic, there is no problem with
   multiple qh structures being active at the same time.
   If you need separate address spaces, you can swap the
   contents of qh->qhmem.
*/
typedef struct qhmemT qhmemT;

struct qhmemT {               /* global memory management variables */
  int      BUFsize;           /* size of memory allocation buffer */
  int      BUFinit;           /* initial size of memory allocation buffer */
  int      TABLEsize;         /* actual number of sizes in free list table */
  int      NUMsizes;          /* maximum number of sizes in free list table */
  int      LASTsize;          /* last size in free list table */
  int      ALIGNmask;         /* worst-case alignment, must be 2^n-1 */
  void   **freelists;          /* free list table, linked by offset 0 */
  int     *sizetable;         /* size of each freelist */
  int     *indextable;        /* size->index table */
  void    *curbuffer;         /* current buffer, linked by offset 0 */
  void    *freemem;           /*   free memory in curbuffer */
  int      freesize;          /*   size of freemem in bytes */
  setT    *tempstack;         /* stack of temporary memory, managed by users */
  FILE    *ferr;              /* file for reporting errors when 'qh' may be undefined */
  int      IStracing;         /* =5 if tracing memory allocations */
  int      cntquick;          /* count of quick allocations */
                              /* Note: removing statistics doesn't effect speed */
  int      cntshort;          /* count of short allocations */
  int      cntlong;           /* count of long allocations */
  int      freeshort;         /* count of short memfrees */
  int      freelong;          /* count of long memfrees */
  int      totbuffer;         /* total short memory buffers minus buffer links */
  int      totdropped;        /* total dropped memory at end of short memory buffers (e.g., freesize) */
  int      totfree;           /* total size of free, short memory on freelists */
  int      totlong;           /* total size of long memory in use */
  int      maxlong;           /*   maximum totlong */
  int      totshort;          /* total size of short memory in use */
  int      totunused;         /* total unused short memory (estimated, short size - request size of first allocations) */
  int      cntlarger;         /* count of setlarger's */
  int      totlarger;         /* total copied by setlarger */
};


/*==================== -macros ====================*/

/*----------------------------------

  qh_memalloc_(qh, insize, freelistp, object, type)
    returns object of size bytes
        assumes size<=qh->qhmem.LASTsize and void **freelistp is a temp
*/

#if defined qh_NOmem
#define qh_memalloc_(qh, insize, freelistp, object, type) {\
  (void)freelistp; /* Avoid warnings */ \
  object= (type *)qh_memalloc(qh, insize); }
#elif defined qh_TRACEshort
#define qh_memalloc_(qh, insize, freelistp, object, type) {\
  (void)freelistp; /* Avoid warnings */ \
  object= (type *)qh_memalloc(qh, insize); }
#else /* !qh_NOmem */

#define qh_memalloc_(qh, insize, freelistp, object, type) {\
  freelistp= qh->qhmem.freelists + qh->qhmem.indextable[insize];\
  if ((object= (type *)*freelistp)) {\
    qh->qhmem.totshort += qh->qhmem.sizetable[qh->qhmem.indextable[insize]]; \
    qh->qhmem.totfree -= qh->qhmem.sizetable[qh->qhmem.indextable[insize]]; \
    qh->qhmem.cntquick++;  \
    *freelistp= *((void **)*freelistp);\
  }else object= (type *)qh_memalloc(qh, insize);}
#endif

/*----------------------------------

  qh_memfree_(qh, object, insize, freelistp)
    free up an object

  notes:
    object may be NULL
    assumes size<=qh->qhmem.LASTsize and void **freelistp is a temp
*/
#if defined qh_NOmem
#define qh_memfree_(qh, object, insize, freelistp) {\
  (void)freelistp; /* Avoid warnings */ \
  qh_memfree(qh, object, insize); }
#elif defined qh_TRACEshort
#define qh_memfree_(qh, object, insize, freelistp) {\
  (void)freelistp; /* Avoid warnings */ \
  qh_memfree(qh, object, insize); }
#else /* !qh_NOmem */

#define qh_memfree_(qh, object, insize, freelistp) {\
  if (object) { \
    qh->qhmem.freeshort++;\
    freelistp= qh->qhmem.freelists + qh->qhmem.indextable[insize];\
    qh->qhmem.totshort -= qh->qhmem.sizetable[qh->qhmem.indextable[insize]]; \
    qh->qhmem.totfree += qh->qhmem.sizetable[qh->qhmem.indextable[insize]]; \
    *((void **)object)= *freelistp;\
    *freelistp= object;}}
#endif

/*=============== prototypes in alphabetical order ============*/

#ifdef __cplusplus
extern "C" {
#endif

void *qh_memalloc(qhT *qh, int insize);
void qh_memcheck(qhT *qh);
void qh_memfree(qhT *qh, void *object, int insize);
void qh_memfreeshort(qhT *qh, int *curlong, int *totlong);
void qh_meminit(qhT *qh, FILE *ferr);
void qh_meminitbuffers(qhT *qh, int tracelevel, int alignment, int numsizes,
                        int bufsize, int bufinit);
void qh_memsetup(qhT *qh);
void qh_memsize(qhT *qh, int size);
void qh_memstatistics(qhT *qh, FILE *fp);
void qh_memtotal(qhT *qh, int *totlong, int *curlong, int *totshort, int *curshort, int *maxlong, int *totbuffer);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* qhDEFmem */
geometry/src/merge_r.c0000644000176200001440000065545614664417655014527 0ustar  liggesusers/*
  ---------------------------------

   merge_r.c
   merges non-convex facets

   see qh-merge_r.htm and merge_r.h

   other modules call qh_premerge() and qh_postmerge()

   the user may call qh_postmerge() to perform additional merges.

   To remove deleted facets and vertices (qhull() in libqhull_r.c):
     qh_partitionvisible(qh, !qh_ALL, &numoutside);  // visible_list, newfacet_list
     qh_deletevisible();         // qh.visible_list
     qh_resetlists(qh, False, qh_RESETvisible);       // qh.visible_list newvertex_list newfacet_list

   assumes qh.CENTERtype= centrum

   merges occur in qh_mergefacet and in qh_mergecycle
   vertex->neighbors not set until the first merge occurs

   Copyright (c) 1993-2020 C.B. Barber.
   $Id: //main/2019/qhull/src/libqhull_r/merge_r.c#14 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#include "qhull_ra.h"

#ifndef qh_NOmerge

/* MRGnone, etc. */
const char *mergetypes[]= {
  "none",
  "coplanar",
  "anglecoplanar",
  "concave",
  "concavecoplanar",
  "twisted",
  "flip",
  "dupridge",
  "subridge",
  "vertices",
  "degen",
  "redundant",
  "mirror",
  "coplanarhorizon",
};

/*===== functions(alphabetical after premerge and postmerge) ======*/

/*---------------------------------

  qh_premerge(qh, apexpointid, maxcentrum )
    pre-merge nonconvex facets in qh.newfacet_list for apexpointid
    maxcentrum defines coplanar and concave (qh_test_appendmerge)

  returns:
    deleted facets added to qh.visible_list with facet->visible set

  notes:
    only called by qh_addpoint
    uses globals, qh.MERGEexact, qh.PREmerge

  design:
    mark dupridges in qh.newfacet_list
    merge facet cycles in qh.newfacet_list
    merge dupridges and concave facets in qh.newfacet_list
    check merged facet cycles for degenerate and redundant facets
    merge degenerate and redundant facets
    collect coplanar and concave facets
    merge concave, coplanar, degenerate, and redundant facets
*/
void qh_premerge(qhT *qh, int apexpointid, realT maxcentrum, realT maxangle /* qh.newfacet_list */) {
  boolT othermerge= False;

  if (qh->ZEROcentrum && qh_checkzero(qh, !qh_ALL))
    return;
  trace2((qh, qh->ferr, 2008, "qh_premerge: premerge centrum %2.2g angle %4.4g for apex p%d newfacet_list f%d\n",
            maxcentrum, maxangle, apexpointid, getid_(qh->newfacet_list)));
  if (qh->IStracing >= 4 && qh->num_facets < 100)
    qh_printlists(qh);
  qh->centrum_radius= maxcentrum;
  qh->cos_max= maxangle;
  if (qh->hull_dim >=3) {
    qh_mark_dupridges(qh, qh->newfacet_list, qh_ALL); /* facet_mergeset */
    qh_mergecycle_all(qh, qh->newfacet_list, &othermerge);
    qh_forcedmerges(qh, &othermerge /* qh.facet_mergeset */);
  }else /* qh.hull_dim == 2 */
    qh_mergecycle_all(qh, qh->newfacet_list, &othermerge);
  qh_flippedmerges(qh, qh->newfacet_list, &othermerge);
  if (!qh->MERGEexact || zzval_(Ztotmerge)) {
    zinc_(Zpremergetot);
    qh->POSTmerging= False;
    qh_getmergeset_initial(qh, qh->newfacet_list);
    qh_all_merges(qh, othermerge, False);
  }
} /* premerge */

/*---------------------------------

  qh_postmerge(qh, reason, maxcentrum, maxangle, vneighbors )
    post-merge nonconvex facets as defined by maxcentrum and maxangle
    'reason' is for reporting progress
    if vneighbors ('Qv'),
      calls qh_test_vneighbors at end of qh_all_merge from qh_postmerge

  returns:
    if first call (qh.visible_list != qh.facet_list),
      builds qh.facet_newlist, qh.newvertex_list
    deleted facets added to qh.visible_list with facet->visible
    qh.visible_list == qh.facet_list

  notes:
    called by qh_qhull after qh_buildhull
    called if a merge may be needed due to
      qh.MERGEexact ('Qx'), qh_DIMreduceBuild, POSTmerge (e.g., 'Cn'), or TESTvneighbors ('Qv')
    if firstmerge,
      calls qh_reducevertices before qh_getmergeset

  design:
    if first call
      set qh.visible_list and qh.newfacet_list to qh.facet_list
      add all facets to qh.newfacet_list
      mark non-simplicial facets, facet->newmerge
      set qh.newvertext_list to qh.vertex_list
      add all vertices to qh.newvertex_list
      if a pre-merge occurred
        set vertex->delridge {will retest the ridge}
        if qh.MERGEexact
          call qh_reducevertices()
      if no pre-merging
        merge flipped facets
    determine non-convex facets
    merge all non-convex facets
*/
void qh_postmerge(qhT *qh, const char *reason, realT maxcentrum, realT maxangle,
                      boolT vneighbors) {
  facetT *newfacet;
  boolT othermerges= False;
  vertexT *vertex;

  if (qh->REPORTfreq || qh->IStracing) {
    qh_buildtracing(qh, NULL, NULL);
    qh_printsummary(qh, qh->ferr);
    if (qh->PRINTstatistics)
      qh_printallstatistics(qh, qh->ferr, "reason");
    qh_fprintf(qh, qh->ferr, 8062, "\n%s with 'C%.2g' and 'A%.2g'\n",
        reason, maxcentrum, maxangle);
  }
  trace2((qh, qh->ferr, 2009, "qh_postmerge: postmerge.  test vneighbors? %d\n",
            vneighbors));
  qh->centrum_radius= maxcentrum;
  qh->cos_max= maxangle;
  qh->POSTmerging= True;
  if (qh->visible_list != qh->facet_list) {  /* first call due to qh_buildhull, multiple calls if qh.POSTmerge */
    qh->NEWfacets= True;
    qh->visible_list= qh->newfacet_list= qh->facet_list;
    FORALLnew_facets {              /* all facets are new facets for qh_postmerge */
      newfacet->newfacet= True;
       if (!newfacet->simplicial)
        newfacet->newmerge= True;   /* test f.vertices for 'delridge'.  'newmerge' was cleared at end of qh_all_merges */
     zinc_(Zpostfacets);
    }
    qh->newvertex_list= qh->vertex_list;
    FORALLvertices
      vertex->newfacet= True;
    if (qh->VERTEXneighbors) {  /* a merge has occurred */
      if (qh->MERGEexact && qh->hull_dim <= qh_DIMreduceBuild)
        qh_reducevertices(qh);  /* qh_all_merges did not call qh_reducevertices for v.delridge */
    }
    if (!qh->PREmerge && !qh->MERGEexact)
      qh_flippedmerges(qh, qh->newfacet_list, &othermerges);
  }
  qh_getmergeset_initial(qh, qh->newfacet_list);
  qh_all_merges(qh, False, vneighbors); /* calls qh_reducevertices before exiting */
  FORALLnew_facets
    newfacet->newmerge= False;   /* Was True if no vertex in f.vertices was 'delridge' */
} /* post_merge */

/*---------------------------------

  qh_all_merges(qh, othermerge, vneighbors )
    merge all non-convex facets

    set othermerge if already merged facets (calls qh_reducevertices)
    if vneighbors ('Qv' at qh.POSTmerge)
      tests vertex neighbors for convexity at end (qh_test_vneighbors)
    qh.facet_mergeset lists the non-convex ridges in qh_newfacet_list
    qh.degen_mergeset is defined
    if qh.MERGEexact && !qh.POSTmerging,
      does not merge coplanar facets

  returns:
    deleted facets added to qh.visible_list with facet->visible
    deleted vertices added qh.delvertex_list with vertex->delvertex

  notes:
    unless !qh.MERGEindependent,
      merges facets in independent sets
    uses qh.newfacet_list as implicit argument since merges call qh_removefacet()
    [apr'19] restored qh_setdellast in place of qh_next_facetmerge.  Much faster for post-merge

  design:
    while merges occur
      for each merge in qh.facet_mergeset
        unless one of the facets was already merged in this pass
          merge the facets
        test merged facets for additional merges
        add merges to qh.facet_mergeset
        if qh.POSTmerging
          periodically call qh_reducevertices to reduce extra vertices and redundant vertices
      after each pass, if qh.VERTEXneighbors
        if qh.POSTmerging or was a merge with qh.hull_dim<=5
          call qh_reducevertices
          update qh.facet_mergeset if degenredundant merges
      if 'Qv' and qh.POSTmerging
        test vertex neighbors for convexity
*/
void qh_all_merges(qhT *qh, boolT othermerge, boolT vneighbors) {
  facetT *facet1, *facet2, *newfacet;
  mergeT *merge;
  boolT wasmerge= False, isreduce;
  void **freelistp;  /* used if !qh_NOmem by qh_memfree_() */
  vertexT *vertex;
  realT angle, distance;
  mergeType mergetype;
  int numcoplanar=0, numconcave=0, numconcavecoplanar= 0, numdegenredun= 0, numnewmerges= 0, numtwisted= 0;

  trace2((qh, qh->ferr, 2010, "qh_all_merges: starting to merge %d facet and %d degenerate merges for new facets f%d, othermerge? %d\n",
            qh_setsize(qh, qh->facet_mergeset), qh_setsize(qh, qh->degen_mergeset), getid_(qh->newfacet_list), othermerge));

  while (True) {
    wasmerge= False;
    while (qh_setsize(qh, qh->facet_mergeset) > 0 || qh_setsize(qh, qh->degen_mergeset) > 0) {
      if (qh_setsize(qh, qh->degen_mergeset) > 0) {
        numdegenredun += qh_merge_degenredundant(qh);
        wasmerge= True;
      }
      while ((merge= (mergeT *)qh_setdellast(qh->facet_mergeset))) {
        facet1= merge->facet1;
        facet2= merge->facet2;
        vertex= merge->vertex1;  /* not used for qh.facet_mergeset*/
        mergetype= merge->mergetype;
        angle= merge->angle;
        distance= merge->distance;
        qh_memfree_(qh, merge, (int)sizeof(mergeT), freelistp);   /* 'merge' is invalid */
        if (facet1->visible || facet2->visible) {
          trace3((qh, qh->ferr, 3045, "qh_all_merges: drop merge of f%d (del? %d) into f%d (del? %d) mergetype %d, dist %4.4g, angle %4.4g.  One or both facets is deleted\n",
            facet1->id, facet1->visible, facet2->id, facet2->visible, mergetype, distance, angle));
          continue;
        }else if (mergetype == MRGcoplanar || mergetype == MRGanglecoplanar) {
          if (qh->MERGEindependent) {
            if ((!facet1->tested && facet1->newfacet)
            || (!facet2->tested && facet2->newfacet)) {
              trace3((qh, qh->ferr, 3064, "qh_all_merges: drop merge of f%d (tested? %d) into f%d (tested? %d) mergetype %d, dist %2.2g, angle %4.4g.  Merge independent sets of coplanar merges\n",
                facet1->id, facet1->visible, facet2->id, facet2->visible, mergetype, distance, angle));
              continue;
            }
          }
        }
        trace3((qh, qh->ferr, 3047, "qh_all_merges: merge f%d and f%d type %d dist %2.2g angle %4.4g\n",
          facet1->id, facet2->id, mergetype, distance, angle));
        if (mergetype == MRGtwisted)
          qh_merge_twisted(qh, facet1, facet2);
        else
          qh_merge_nonconvex(qh, facet1, facet2, mergetype);
        numnewmerges++;
        numdegenredun += qh_merge_degenredundant(qh);
        wasmerge= True;
        if (mergetype == MRGconcave)
          numconcave++;
        else if (mergetype == MRGconcavecoplanar)
          numconcavecoplanar++;
        else if (mergetype == MRGtwisted)
          numtwisted++;
        else if (mergetype == MRGcoplanar || mergetype == MRGanglecoplanar)
          numcoplanar++;
        else {
          qh_fprintf(qh, qh->ferr, 6394, "qhull internal error (qh_all_merges): expecting concave, coplanar, or twisted merge.  Got merge f%d f%d v%d mergetype %d\n",
            getid_(facet1), getid_(facet2), getid_(vertex), mergetype);
          qh_errexit2(qh, qh_ERRqhull, facet1, facet2);
        }
      } /* while qh_setdellast */
      if (qh->POSTmerging && qh->hull_dim <= qh_DIMreduceBuild
      && numnewmerges > qh_MAXnewmerges) {
        numnewmerges= 0;
        wasmerge= othermerge= False;
        qh_reducevertices(qh);  /* otherwise large post merges too slow */
      }
      qh_getmergeset(qh, qh->newfacet_list); /* qh.facet_mergeset */
    } /* while facet_mergeset or degen_mergeset */
    if (qh->VERTEXneighbors) {  /* at least one merge */
      isreduce= False;
      if (qh->POSTmerging && qh->hull_dim >= 4) {
        isreduce= True;
      }else if (qh->POSTmerging || !qh->MERGEexact) {
        if ((wasmerge || othermerge) && qh->hull_dim > 2 && qh->hull_dim <= qh_DIMreduceBuild)
          isreduce= True;
      }
      if (isreduce) {
        wasmerge= othermerge= False;
        if (qh_reducevertices(qh)) {
          qh_getmergeset(qh, qh->newfacet_list); /* facet_mergeset */
          continue;
        }
      }
    }
    if (vneighbors && qh_test_vneighbors(qh /* qh.newfacet_list */))
      continue;
    break;
  } /* while (True) */
  if (wasmerge || othermerge) {
    trace3((qh, qh->ferr, 3033, "qh_all_merges: skip qh_reducevertices due to post-merging, no qh.VERTEXneighbors (%d), or hull_dim %d ==2 or >%d\n", qh->VERTEXneighbors, qh->hull_dim, qh_DIMreduceBuild))
    FORALLnew_facets {
      newfacet->newmerge= False;
    }
  }
  if (qh->CHECKfrequently && !qh->MERGEexact) {
    qh->old_randomdist= qh->RANDOMdist;
    qh->RANDOMdist= False;
    qh_checkconvex(qh, qh->newfacet_list, qh_ALGORITHMfault);
    /* qh_checkconnect(qh); [this is slow and it changes the facet order] */
    qh->RANDOMdist= qh->old_randomdist;
  }
  trace1((qh, qh->ferr, 1009, "qh_all_merges: merged %d coplanar %d concave %d concavecoplanar %d twisted facets and %d degen or redundant facets.\n",
    numcoplanar, numconcave, numconcavecoplanar, numtwisted, numdegenredun));
  if (qh->IStracing >= 4 && qh->num_facets < 500)
    qh_printlists(qh);
} /* all_merges */

/*---------------------------------

  qh_all_vertexmerges(qh, apexpointid, facet, &retryfacet )
    merge vertices in qh.vertex_mergeset and subsequent merges

  returns:
    returns retryfacet for facet (if defined)
    updates qh.facet_list, qh.num_facets, qh.vertex_list, qh.num_vertices
    mergesets are empty
    if merges, resets facet lists

  notes:
    called from qh_qhull, qh_addpoint, and qh_buildcone_mergepinched
    vertex merges occur after facet merges and qh_resetlists

  design:
    while merges in vertex_mergeset (MRGvertices)
      merge a pair of pinched vertices
      update vertex neighbors
      merge non-convex and degenerate facets and check for ridges with duplicate vertices
      partition outside points of deleted, "visible" facets
*/
void qh_all_vertexmerges(qhT *qh, int apexpointid, facetT *facet, facetT **retryfacet) {
  int numpoints; /* ignore count of partitioned points.  Used by qh_addpoint for Zpbalance */

  if (retryfacet)
    *retryfacet= facet;
  while (qh_setsize(qh, qh->vertex_mergeset) > 0) {
    trace1((qh, qh->ferr, 1057, "qh_all_vertexmerges: starting to merge %d vertex merges for apex p%d facet f%d\n",
            qh_setsize(qh, qh->vertex_mergeset), apexpointid, getid_(facet)));
    if (qh->IStracing >= 4  && qh->num_facets < 1000)
      qh_printlists(qh);
    qh_merge_pinchedvertices(qh, apexpointid /* qh.vertex_mergeset, visible_list, newvertex_list, newfacet_list */);
    qh_update_vertexneighbors(qh); /* update neighbors of qh.newvertex_list from qh_newvertices for deleted facets on qh.visible_list */
                           /* test ridges and merge non-convex facets */
    qh_getmergeset(qh, qh->newfacet_list);
    qh_all_merges(qh, True, False); /* calls qh_reducevertices */
    if (qh->CHECKfrequently)
      qh_checkpolygon(qh, qh->facet_list);
    qh_partitionvisible(qh, !qh_ALL, &numpoints /* qh.visible_list qh.del_vertices*/);
    if (retryfacet)
      *retryfacet= qh_getreplacement(qh, *retryfacet);
    qh_deletevisible(qh /* qh.visible_list  qh.del_vertices*/);
    qh_resetlists(qh, False, qh_RESETvisible /* qh.visible_list newvertex_list qh.newfacet_list */);
    if (qh->IStracing >= 4  && qh->num_facets < 1000) {
      qh_printlists(qh);
      qh_checkpolygon(qh, qh->facet_list);
    }
  }
} /* all_vertexmerges */

/*---------------------------------

  qh_appendmergeset(qh, facet, vertex, neighbor, mergetype, dist, angle )
    appends an entry to qh.facet_mergeset or qh.degen_mergeset
    if 'dist' is unknown, set it to 0.0
        if 'angle' is unknown, set it to 1.0 (coplanar)

  returns:
    merge appended to facet_mergeset or degen_mergeset
      sets ->degenerate or ->redundant if degen_mergeset

  notes:
    caller collects statistics and/or caller of qh_mergefacet
    see: qh_test_appendmerge()

  design:
    allocate merge entry
    if regular merge
      append to qh.facet_mergeset
    else if degenerate merge and qh.facet_mergeset is all degenerate
      append to qh.degen_mergeset
    else if degenerate merge
      prepend to qh.degen_mergeset (merged last)
    else if redundant merge
      append to qh.degen_mergeset
*/
void qh_appendmergeset(qhT *qh, facetT *facet, facetT *neighbor, mergeType mergetype, coordT dist, realT angle) {
  mergeT *merge, *lastmerge;
  void **freelistp; /* used if !qh_NOmem by qh_memalloc_() */
  const char *mergename;

  if ((facet->redundant && mergetype != MRGmirror) || neighbor->redundant) {
    trace3((qh, qh->ferr, 3051, "qh_appendmergeset: f%d is already redundant (%d) or f%d is already redundant (%d).  Ignore merge f%d and f%d type %d\n",
      facet->id, facet->redundant, neighbor->id, neighbor->redundant, facet->id, neighbor->id, mergetype));
    return;
  }
  if (facet->degenerate && mergetype == MRGdegen) {
    trace3((qh, qh->ferr, 3077, "qh_appendmergeset: f%d is already degenerate.  Ignore merge f%d type %d (MRGdegen)\n",
      facet->id, facet->id, mergetype));
    return;
  }
  if (!qh->facet_mergeset || !qh->degen_mergeset) {
    qh_fprintf(qh, qh->ferr, 6403, "qhull internal error (qh_appendmergeset): expecting temp set defined for qh.facet_mergeset (0x%x) and qh.degen_mergeset (0x%x).  Got NULL\n",
      qh->facet_mergeset, qh->degen_mergeset);
    /* otherwise qh_setappend creates a new set that is not freed by qh_freebuild() */
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  if (neighbor->flipped && !facet->flipped) {
    if (mergetype != MRGdupridge) {
      qh_fprintf(qh, qh->ferr, 6355, "qhull internal error (qh_appendmergeset): except for MRGdupridge, cannot merge a non-flipped facet f%d into flipped f%d, mergetype %d, dist %4.4g\n",
        facet->id, neighbor->id, mergetype, dist);
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }else {
      trace2((qh, qh->ferr, 2106, "qh_appendmergeset: dupridge will merge a non-flipped facet f%d into flipped f%d, dist %4.4g\n",
        facet->id, neighbor->id, dist));
    }
  }
  qh_memalloc_(qh, (int)sizeof(mergeT), freelistp, merge, mergeT);
  merge->angle= angle;
  merge->distance= dist;
  merge->facet1= facet;
  merge->facet2= neighbor;
  merge->vertex1= NULL;
  merge->vertex2= NULL;
  merge->ridge1= NULL;
  merge->ridge2= NULL;
  merge->mergetype= mergetype;
  if(mergetype > 0 && mergetype < sizeof(mergetypes)/sizeof(char *))
    mergename= mergetypes[mergetype];
  else
    mergename= mergetypes[MRGnone];
  if (mergetype < MRGdegen)
    qh_setappend(qh, &(qh->facet_mergeset), merge);
  else if (mergetype == MRGdegen) {
    facet->degenerate= True;
    if (!(lastmerge= (mergeT *)qh_setlast(qh->degen_mergeset))
    || lastmerge->mergetype == MRGdegen)
      qh_setappend(qh, &(qh->degen_mergeset), merge);
    else
      qh_setaddnth(qh, &(qh->degen_mergeset), 0, merge);    /* merged last */
  }else if (mergetype == MRGredundant) {
    facet->redundant= True;
    qh_setappend(qh, &(qh->degen_mergeset), merge);
  }else /* mergetype == MRGmirror */ {
    if (facet->redundant || neighbor->redundant) {
      qh_fprintf(qh, qh->ferr, 6092, "qhull internal error (qh_appendmergeset): facet f%d or f%d is already a mirrored facet (i.e., 'redundant')\n",
           facet->id, neighbor->id);
      qh_errexit2(qh, qh_ERRqhull, facet, neighbor);
    }
    if (!qh_setequal(facet->vertices, neighbor->vertices)) {
      qh_fprintf(qh, qh->ferr, 6093, "qhull internal error (qh_appendmergeset): mirrored facets f%d and f%d do not have the same vertices\n",
           facet->id, neighbor->id);
      qh_errexit2(qh, qh_ERRqhull, facet, neighbor);
    }
    facet->redundant= True;
    neighbor->redundant= True;
    qh_setappend(qh, &(qh->degen_mergeset), merge);
  }
  if (merge->mergetype >= MRGdegen) {
    trace3((qh, qh->ferr, 3044, "qh_appendmergeset: append merge f%d and f%d type %d (%s) to qh.degen_mergeset (size %d)\n",
      merge->facet1->id, merge->facet2->id, merge->mergetype, mergename, qh_setsize(qh, qh->degen_mergeset)));
  }else {
    trace3((qh, qh->ferr, 3027, "qh_appendmergeset: append merge f%d and f%d type %d (%s) dist %2.2g angle %4.4g to qh.facet_mergeset (size %d)\n",
      merge->facet1->id, merge->facet2->id, merge->mergetype, mergename, merge->distance, merge->angle, qh_setsize(qh, qh->facet_mergeset)));
  }
} /* appendmergeset */


/*---------------------------------

  qh_appendvertexmerge(qh, vertex, vertex2, mergetype, distance, ridge1, ridge2 )
    appends a vertex merge to qh.vertex_mergeset
    MRGsubridge includes two ridges (from MRGdupridge)
    MRGvertices includes two ridges

  notes:
    called by qh_getpinchedmerges for MRGsubridge
    called by qh_maybe_duplicateridge and qh_maybe_duplicateridges for MRGvertices
    only way to add a vertex merge to qh.vertex_mergeset
    checked by qh_next_vertexmerge
*/
void qh_appendvertexmerge(qhT *qh, vertexT *vertex, vertexT *destination, mergeType mergetype, realT distance, ridgeT *ridge1, ridgeT *ridge2) {
  mergeT *merge;
  void **freelistp; /* used if !qh_NOmem by qh_memalloc_() */
  const char *mergename;

  if (!qh->vertex_mergeset) {
    qh_fprintf(qh, qh->ferr, 6387, "qhull internal error (qh_appendvertexmerge): expecting temp set defined for qh.vertex_mergeset (0x%x).  Got NULL\n",
      qh->vertex_mergeset);
    /* otherwise qh_setappend creates a new set that is not freed by qh_freebuild() */
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  qh_memalloc_(qh, (int)sizeof(mergeT), freelistp, merge, mergeT);
  merge->angle= qh_ANGLEnone;
  merge->distance= distance;
  merge->facet1= NULL;
  merge->facet2= NULL;
  merge->vertex1= vertex;
  merge->vertex2= destination;
  merge->ridge1= ridge1;
  merge->ridge2= ridge2;
  merge->mergetype= mergetype;
  if(mergetype > 0 && mergetype < sizeof(mergetypes)/sizeof(char *))
    mergename= mergetypes[mergetype];
  else
    mergename= mergetypes[MRGnone];
  if (mergetype == MRGvertices) {
    if (!ridge1 || !ridge2 || ridge1 == ridge2) {
      qh_fprintf(qh, qh->ferr, 6106, "qhull internal error (qh_appendvertexmerge): expecting two distinct ridges for MRGvertices.  Got r%d r%d\n",
        getid_(ridge1), getid_(ridge2));
      qh_errexit(qh, qh_ERRqhull, NULL, ridge1);
    }
  }
  qh_setappend(qh, &(qh->vertex_mergeset), merge);
  trace3((qh, qh->ferr, 3034, "qh_appendvertexmerge: append merge v%d into v%d r%d r%d dist %2.2g type %d (%s)\n",
    vertex->id, destination->id, getid_(ridge1), getid_(ridge2), distance, merge->mergetype, mergename));
} /* appendvertexmerge */


/*---------------------------------

  qh_basevertices(qh, samecycle )
    return temporary set of base vertices for samecycle
    samecycle is first facet in the cycle
    assumes apex is SETfirst_( samecycle->vertices )

  returns:
    vertices(settemp)
    all ->seen are cleared

  notes:
    uses qh_vertex_visit;

  design:
    for each facet in samecycle
      for each unseen vertex in facet->vertices
        append to result
*/
setT *qh_basevertices(qhT *qh, facetT *samecycle) {
  facetT *same;
  vertexT *apex, *vertex, **vertexp;
  setT *vertices= qh_settemp(qh, qh->TEMPsize);

  apex= SETfirstt_(samecycle->vertices, vertexT);
  apex->visitid= ++qh->vertex_visit;
  FORALLsame_cycle_(samecycle) {
    if (same->mergeridge)
      continue;
    FOREACHvertex_(same->vertices) {
      if (vertex->visitid != qh->vertex_visit) {
        qh_setappend(qh, &vertices, vertex);
        vertex->visitid= qh->vertex_visit;
        vertex->seen= False;
      }
    }
  }
  trace4((qh, qh->ferr, 4019, "qh_basevertices: found %d vertices\n",
         qh_setsize(qh, vertices)));
  return vertices;
} /* basevertices */

/*---------------------------------

  qh_check_dupridge(qh, facet1, dist1, facet2, dist2 )
    Check dupridge between facet1 and facet2 for wide merge
    dist1 is the maximum distance of facet1's vertices to facet2
    dist2 is the maximum distance of facet2's vertices to facet1

  returns
    Level 1 log of the dupridge with the minimum distance between vertices
    Throws error if the merge will increase the maximum facet width by qh_WIDEduplicate (100x)

  notes:
    only called from qh_forcedmerges
*/
void qh_check_dupridge(qhT *qh, facetT *facet1, realT dist1, facetT *facet2, realT dist2) {
  vertexT *vertex, **vertexp, *vertexA, **vertexAp;
  realT dist, innerplane, mergedist, outerplane, prevdist, ratio, vertexratio;
  realT minvertex= REALmax;

  mergedist= fmin_(dist1, dist2);
  qh_outerinner(qh, NULL, &outerplane, &innerplane);  /* ratio from qh_printsummary */
  FOREACHvertex_(facet1->vertices) {     /* The dupridge is between facet1 and facet2, so either facet can be tested */
    FOREACHvertexA_(facet1->vertices) {
      if (vertex > vertexA){   /* Test each pair once */
        dist= qh_pointdist(vertex->point, vertexA->point, qh->hull_dim);
        minimize_(minvertex, dist);
        /* Not quite correct.  A facet may have a dupridge and another pair of nearly adjacent vertices. */
      }
    }
  }
  prevdist= fmax_(outerplane, innerplane);
  maximize_(prevdist, qh->ONEmerge + qh->DISTround);
  maximize_(prevdist, qh->MINoutside + qh->DISTround);
  ratio= mergedist/prevdist;
  vertexratio= minvertex/prevdist;
  trace0((qh, qh->ferr, 16, "qh_check_dupridge: dupridge between f%d and f%d (vertex dist %2.2g), dist %2.2g, reverse dist %2.2g, ratio %2.2g while processing p%d\n",
        facet1->id, facet2->id, minvertex, dist1, dist2, ratio, qh->furthest_id));
  if (ratio > qh_WIDEduplicate) {
    qh_fprintf(qh, qh->ferr, 6271, "qhull topology error (qh_check_dupridge): wide merge (%.1fx wider) due to dupridge between f%d and f%d (vertex dist %2.2g), merge dist %2.2g, while processing p%d\n- Allow error with option 'Q12'\n",
      ratio, facet1->id, facet2->id, minvertex, mergedist, qh->furthest_id);
    if (vertexratio < qh_WIDEpinched)
      qh_fprintf(qh, qh->ferr, 8145, "- Experimental option merge-pinched-vertices ('Q14') may avoid this error.  It merges nearly adjacent vertices.\n");
    if (qh->DELAUNAY)
      qh_fprintf(qh, qh->ferr, 8145, "- A bounding box for the input sites may alleviate this error.\n");
    if (!qh->ALLOWwide)
      qh_errexit2(qh, qh_ERRwide, facet1, facet2);
  }
} /* check_dupridge */

/*---------------------------------

  qh_checkconnect(qh)
    check that new facets are connected
    new facets are on qh.newfacet_list

  notes:
    this is slow and it changes the order of the facets
    uses qh.visit_id

  design:
    move first new facet to end of qh.facet_list
    for all newly appended facets
      append unvisited neighbors to end of qh.facet_list
    for all new facets
      report error if unvisited
*/
void qh_checkconnect(qhT *qh /* qh.newfacet_list */) {
  facetT *facet, *newfacet, *errfacet= NULL, *neighbor, **neighborp;

  facet= qh->newfacet_list;
  qh_removefacet(qh, facet);
  qh_appendfacet(qh, facet);
  facet->visitid= ++qh->visit_id;
  FORALLfacet_(facet) {
    FOREACHneighbor_(facet) {
      if (neighbor->visitid != qh->visit_id) {
        qh_removefacet(qh, neighbor);
        qh_appendfacet(qh, neighbor);
        neighbor->visitid= qh->visit_id;
      }
    }
  }
  FORALLnew_facets {
    if (newfacet->visitid == qh->visit_id)
      break;
    qh_fprintf(qh, qh->ferr, 6094, "qhull internal error (qh_checkconnect): f%d is not attached to the new facets\n",
         newfacet->id);
    errfacet= newfacet;
  }
  if (errfacet)
    qh_errexit(qh, qh_ERRqhull, errfacet, NULL);
} /* checkconnect */

/*---------------------------------

  qh_checkdelfacet(qh, facet, mergeset )
    check that mergeset does not reference facet

*/
void qh_checkdelfacet(qhT *qh, facetT *facet, setT *mergeset) {
  mergeT *merge, **mergep;

  FOREACHmerge_(mergeset) {
    if (merge->facet1 == facet || merge->facet2 == facet) {
      qh_fprintf(qh, qh->ferr, 6390, "qhull internal error (qh_checkdelfacet): cannot delete f%d.  It is referenced by merge f%d f%d mergetype %d\n",
        facet->id, merge->facet1->id, getid_(merge->facet2), merge->mergetype);
      qh_errexit2(qh, qh_ERRqhull, merge->facet1, merge->facet2);
    }
  }
} /* checkdelfacet */

/*---------------------------------

  qh_checkdelridge(qh)
    check that qh_delridge_merge is not needed for deleted ridges

    notes:
      called from qh_mergecycle, qh_makenewfacets, qh_attachnewfacets
      errors if qh.vertex_mergeset is non-empty
      errors if any visible or new facet has a ridge with r.nonconvex set
      assumes that vertex.delfacet is not needed
*/
void qh_checkdelridge(qhT *qh /* qh.visible_facets, vertex_mergeset */) {
  facetT *newfacet, *visible;
  ridgeT *ridge, **ridgep;

  if (!SETempty_(qh->vertex_mergeset)) {
    qh_fprintf(qh, qh->ferr, 6382, "qhull internal error (qh_checkdelridge): expecting empty qh.vertex_mergeset in order to avoid calling qh_delridge_merge.  Got %d merges\n", qh_setsize(qh, qh->vertex_mergeset));
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }

  FORALLnew_facets {
    FOREACHridge_(newfacet->ridges) {
      if (ridge->nonconvex) {
        qh_fprintf(qh, qh->ferr, 6313, "qhull internal error (qh_checkdelridge): unexpected 'nonconvex' flag for ridge r%d in newfacet f%d.  Otherwise need to call qh_delridge_merge\n",
           ridge->id, newfacet->id);
        qh_errexit(qh, qh_ERRqhull, newfacet, ridge);
      }
    }
  }

  FORALLvisible_facets {
    FOREACHridge_(visible->ridges) {
      if (ridge->nonconvex) {
        qh_fprintf(qh, qh->ferr, 6385, "qhull internal error (qh_checkdelridge): unexpected 'nonconvex' flag for ridge r%d in visible facet f%d.  Otherwise need to call qh_delridge_merge\n",
          ridge->id, visible->id);
        qh_errexit(qh, qh_ERRqhull, visible, ridge);
      }
    }
  }
} /* checkdelridge */


/*---------------------------------

  qh_checkzero(qh, testall )
    check that facets are clearly convex for qh.DISTround with qh.MERGEexact

    if testall,
      test all facets for qh.MERGEexact post-merging
    else
      test qh.newfacet_list

    if qh.MERGEexact,
      allows coplanar ridges
      skips convexity test while qh.ZEROall_ok

  returns:
    True if all facets !flipped, !dupridge, normal
         if all horizon facets are simplicial
         if all vertices are clearly below neighbor
         if all opposite vertices of horizon are below
    clears qh.ZEROall_ok if any problems or coplanar facets

  notes:
    called by qh_premerge (qh.CHECKzero, 'C-0') and qh_qhull ('Qx')
    uses qh.vertex_visit
    horizon facets may define multiple new facets

  design:
    for all facets in qh.newfacet_list or qh.facet_list
      check for flagged faults (flipped, etc.)
    for all facets in qh.newfacet_list or qh.facet_list
      for each neighbor of facet
        skip horizon facets for qh.newfacet_list
        test the opposite vertex
      if qh.newfacet_list
        test the other vertices in the facet's horizon facet
*/
boolT qh_checkzero(qhT *qh, boolT testall) {
  facetT *facet, *neighbor;
  facetT *horizon, *facetlist;
  int neighbor_i, neighbor_n;
  vertexT *vertex, **vertexp;
  realT dist;

  if (testall)
    facetlist= qh->facet_list;
  else {
    facetlist= qh->newfacet_list;
    FORALLfacet_(facetlist) {
      horizon= SETfirstt_(facet->neighbors, facetT);
      if (!horizon->simplicial)
        goto LABELproblem;
      if (facet->flipped || facet->dupridge || !facet->normal)
        goto LABELproblem;
    }
    if (qh->MERGEexact && qh->ZEROall_ok) {
      trace2((qh, qh->ferr, 2011, "qh_checkzero: skip convexity check until first pre-merge\n"));
      return True;
    }
  }
  FORALLfacet_(facetlist) {
    qh->vertex_visit++;
    horizon= NULL;
    FOREACHneighbor_i_(qh, facet) {
      if (!neighbor_i && !testall) {
        horizon= neighbor;
        continue; /* horizon facet tested in qh_findhorizon */
      }
      vertex= SETelemt_(facet->vertices, neighbor_i, vertexT);
      vertex->visitid= qh->vertex_visit;
      zzinc_(Zdistzero);
      qh_distplane(qh, vertex->point, neighbor, &dist);
      if (dist >= -2 * qh->DISTround) {  /* need 2x for qh_distround and 'Rn' for qh_checkconvex, same as qh.premerge_centrum */
        qh->ZEROall_ok= False;
        if (!qh->MERGEexact || testall || dist > qh->DISTround)
          goto LABELnonconvex;
      }
    }
    if (!testall && horizon) {
      FOREACHvertex_(horizon->vertices) {
        if (vertex->visitid != qh->vertex_visit) {
          zzinc_(Zdistzero);
          qh_distplane(qh, vertex->point, facet, &dist);
          if (dist >= -2 * qh->DISTround) {
            qh->ZEROall_ok= False;
            if (!qh->MERGEexact || dist > qh->DISTround)
              goto LABELnonconvexhorizon;
          }
          break;
        }
      }
    }
  }
  trace2((qh, qh->ferr, 2012, "qh_checkzero: testall %d, facets are %s\n", testall,
        (qh->MERGEexact && !testall) ?
           "not concave, flipped, or dupridge" : "clearly convex"));
  return True;

 LABELproblem:
  qh->ZEROall_ok= False;
  trace2((qh, qh->ferr, 2013, "qh_checkzero: qh_premerge is needed.  New facet f%d or its horizon f%d is non-simplicial, flipped, dupridge, or mergehorizon\n",
       facet->id, horizon->id));
  return False;

 LABELnonconvex:
  trace2((qh, qh->ferr, 2014, "qh_checkzero: facet f%d and f%d are not clearly convex.  v%d dist %.2g\n",
         facet->id, neighbor->id, vertex->id, dist));
  return False;

 LABELnonconvexhorizon:
  trace2((qh, qh->ferr, 2060, "qh_checkzero: facet f%d and horizon f%d are not clearly convex.  v%d dist %.2g\n",
      facet->id, horizon->id, vertex->id, dist));
  return False;
} /* checkzero */

/*---------------------------------

  qh_compare_anglemerge( mergeA, mergeB )
    used by qsort() to order qh.facet_mergeset by mergetype and angle (qh.ANGLEmerge, 'Q1')
    lower numbered mergetypes done first (MRGcoplanar before MRGconcave)

  notes:
    qh_all_merges processes qh.facet_mergeset by qh_setdellast
    [mar'19] evaluated various options with eg/q_benchmark and merging of pinched vertices (Q14)
*/
int qh_compare_anglemerge(const void *p1, const void *p2) {
  const mergeT *a= *((mergeT *const*)p1), *b= *((mergeT *const*)p2);

  if (a->mergetype != b->mergetype)
    return (a->mergetype < b->mergetype ? 1 : -1); /* select MRGcoplanar (1) before MRGconcave (3) */
  else
    return (a->angle > b->angle ? 1 : -1);         /* select coplanar merge (1.0) before sharp merge (-0.5) */
} /* compare_anglemerge */

/*---------------------------------

  qh_compare_facetmerge( mergeA, mergeB )
    used by qsort() to order merges by mergetype, first merge, first
    lower numbered mergetypes done first (MRGcoplanar before MRGconcave)
    if same merge type, flat merges are first

  notes:
    qh_all_merges processes qh.facet_mergeset by qh_setdellast
    [mar'19] evaluated various options with eg/q_benchmark and merging of pinched vertices (Q14)
*/
int qh_compare_facetmerge(const void *p1, const void *p2) {
  const mergeT *a= *((mergeT *const*)p1), *b= *((mergeT *const*)p2);

  if (a->mergetype != b->mergetype)
    return (a->mergetype < b->mergetype ? 1 : -1); /* select MRGcoplanar (1) before MRGconcave (3) */
  else if (a->mergetype == MRGanglecoplanar)
    return (a->angle > b->angle ? 1 : -1);         /* if MRGanglecoplanar, select coplanar merge (1.0) before sharp merge (-0.5) */
  else
    return (a->distance < b->distance ? 1 : -1);   /* select flat (0.0) merge before wide (1e-10) merge */
} /* compare_facetmerge */

/*---------------------------------

  qh_comparevisit( vertexA, vertexB )
    used by qsort() to order vertices by their visitid

  notes:
    only called by qh_find_newvertex
*/
int qh_comparevisit(const void *p1, const void *p2) {
  const vertexT *a= *((vertexT *const*)p1), *b= *((vertexT *const*)p2);

  if (a->visitid > b->visitid)
    return 1;
  return -1;
} /* comparevisit */

/*---------------------------------

  qh_copynonconvex(qh, atridge )
    set non-convex flag on other ridges (if any) between same neighbors

  notes:
    may be faster if use smaller ridge set

  design:
    for each ridge of atridge's top facet
      if ridge shares the same neighbor
        set nonconvex flag
*/
void qh_copynonconvex(qhT *qh, ridgeT *atridge) {
  facetT *facet, *otherfacet;
  ridgeT *ridge, **ridgep;

  facet= atridge->top;
  otherfacet= atridge->bottom;
  atridge->nonconvex= False;
  FOREACHridge_(facet->ridges) {
    if (otherfacet == ridge->top || otherfacet == ridge->bottom) {
      if (ridge != atridge) {
        ridge->nonconvex= True;
        trace4((qh, qh->ferr, 4020, "qh_copynonconvex: moved nonconvex flag from r%d to r%d between f%d and f%d\n",
                atridge->id, ridge->id, facet->id, otherfacet->id));
        break;
      }
    }
  }
} /* copynonconvex */

/*---------------------------------

  qh_degen_redundant_facet(qh, facet )
    check for a degenerate (too few neighbors) or redundant (subset of vertices) facet

  notes:
    called at end of qh_mergefacet, qh_renamevertex, and qh_reducevertices
    bumps vertex_visit
    called if a facet was redundant but no longer is (qh_merge_degenredundant)
    qh_appendmergeset() only appends first reference to facet (i.e., redundant)
    see: qh_test_redundant_neighbors, qh_maydropneighbor

  design:
    test for redundant neighbor
    test for degenerate facet
*/
void qh_degen_redundant_facet(qhT *qh, facetT *facet) {
  vertexT *vertex, **vertexp;
  facetT *neighbor, **neighborp;

  trace3((qh, qh->ferr, 3028, "qh_degen_redundant_facet: test facet f%d for degen/redundant\n",
          facet->id));
  if (facet->flipped) {
    trace2((qh, qh->ferr, 3074, "qh_degen_redundant_facet: f%d is flipped, will merge later\n", facet->id));
    return;
  }
  FOREACHneighbor_(facet) {
    if (neighbor->flipped) /* disallow merge of non-flipped into flipped, neighbor will be merged later */
      continue;
    if (neighbor->visible) {
      qh_fprintf(qh, qh->ferr, 6357, "qhull internal error (qh_degen_redundant_facet): facet f%d has deleted neighbor f%d (qh.visible_list)\n",
        facet->id, neighbor->id);
      qh_errexit2(qh, qh_ERRqhull, facet, neighbor);
    }
    qh->vertex_visit++;
    FOREACHvertex_(neighbor->vertices)
      vertex->visitid= qh->vertex_visit;
    FOREACHvertex_(facet->vertices) {
      if (vertex->visitid != qh->vertex_visit)
        break;
    }
    if (!vertex) {
      trace2((qh, qh->ferr, 2015, "qh_degen_redundant_facet: f%d is contained in f%d.  merge\n", facet->id, neighbor->id));
      qh_appendmergeset(qh, facet, neighbor, MRGredundant, 0.0, 1.0);
      return;
    }
  }
  if (qh_setsize(qh, facet->neighbors) < qh->hull_dim) {
    qh_appendmergeset(qh, facet, facet, MRGdegen, 0.0, 1.0);
    trace2((qh, qh->ferr, 2016, "qh_degen_redundant_facet: f%d is degenerate.\n", facet->id));
  }
} /* degen_redundant_facet */


/*---------------------------------

  qh_delridge_merge(qh, ridge )
    delete ridge due to a merge

  notes:
    only called by merge_r.c (qh_mergeridges, qh_renameridgevertex)
    ridges also freed in qh_freeqhull and qh_mergecycle_ridges

  design:
    if needed, moves ridge.nonconvex to another ridge
    sets vertex.delridge for qh_reducevertices
    deletes ridge from qh.vertex_mergeset
    deletes ridge from its neighboring facets
    frees up its memory
*/
void qh_delridge_merge(qhT *qh, ridgeT *ridge) {
  vertexT *vertex, **vertexp;
  mergeT *merge;
  int merge_i, merge_n;

  trace3((qh, qh->ferr, 3036, "qh_delridge_merge: delete ridge r%d between f%d and f%d\n",
    ridge->id, ridge->top->id, ridge->bottom->id));
  if (ridge->nonconvex)
    qh_copynonconvex(qh, ridge);
  FOREACHvertex_(ridge->vertices)
    vertex->delridge= True;
  FOREACHmerge_i_(qh, qh->vertex_mergeset) {
    if (merge->ridge1 == ridge || merge->ridge2 == ridge) {
      trace3((qh, qh->ferr, 3029, "qh_delridge_merge: drop merge of v%d into v%d (dist %2.2g r%d r%d) due to deleted, duplicated ridge r%d\n",
        merge->vertex1->id, merge->vertex2->id, merge->distance, merge->ridge1->id, merge->ridge2->id, ridge->id));
      if (merge->ridge1 == ridge)
        merge->ridge2->mergevertex= False;
      else
        merge->ridge1->mergevertex= False;
      qh_setdelnth(qh, qh->vertex_mergeset, merge_i);
      merge_i--; merge_n--; /* next merge after deleted */
    }
  }
  qh_setdel(ridge->top->ridges, ridge);
  qh_setdel(ridge->bottom->ridges, ridge);
  qh_delridge(qh, ridge);
} /* delridge_merge */


/*---------------------------------

  qh_drop_mergevertex(qh, merge )

  clear mergevertex flags for ridges of a vertex merge
*/
void qh_drop_mergevertex(qhT *qh, mergeT *merge)
{
  if (merge->mergetype == MRGvertices) {
    merge->ridge1->mergevertex= False;
    merge->ridge1->mergevertex2= True;
    merge->ridge2->mergevertex= False;
    merge->ridge2->mergevertex2= True;
    trace3((qh, qh->ferr, 3032, "qh_drop_mergevertex: unset mergevertex for r%d and r%d due to dropped vertex merge v%d to v%d.  Sets mergevertex2\n",
      merge->ridge1->id, merge->ridge2->id, merge->vertex1->id, merge->vertex2->id));
  }
} /* drop_mergevertex */

/*---------------------------------

  qh_find_newvertex(qh, oldvertex, vertices, ridges )
    locate new vertex for renaming old vertex
    vertices is a set of possible new vertices
      vertices sorted by number of deleted ridges

  returns:
    newvertex or NULL
      each ridge includes both newvertex and oldvertex
    vertices without oldvertex sorted by number of deleted ridges
    qh.vertex_visit updated
    sets v.seen

  notes:
    called by qh_redundant_vertex due to vertex->delridge and qh_rename_sharedvertex
    sets vertex->visitid to 0..setsize() for vertices
    new vertex is in one of the ridges
    renaming will not cause a duplicate ridge
    renaming will minimize the number of deleted ridges
    newvertex may not be adjacent in the dual (though unlikely)

  design:
    for each vertex in vertices
      set vertex->visitid to number of ridges
    remove unvisited vertices
    set qh.vertex_visit above all possible values
    sort vertices by number of ridges (minimize ridges that need renaming
    add each ridge to qh.hash_table
    for each vertex in vertices
      find the first vertex that would not cause a duplicate ridge after a rename
*/
vertexT *qh_find_newvertex(qhT *qh, vertexT *oldvertex, setT *vertices, setT *ridges) {
  vertexT *vertex, **vertexp;
  setT *newridges;
  ridgeT *ridge, **ridgep;
  int size, hashsize;
  int hash;
  unsigned int maxvisit;

#ifndef qh_NOtrace
  if (qh->IStracing >= 4) {
    qh_fprintf(qh, qh->ferr, 8063, "qh_find_newvertex: find new vertex for v%d from ",
             oldvertex->id);
    FOREACHvertex_(vertices)
      qh_fprintf(qh, qh->ferr, 8064, "v%d ", vertex->id);
    FOREACHridge_(ridges)
      qh_fprintf(qh, qh->ferr, 8065, "r%d ", ridge->id);
    qh_fprintf(qh, qh->ferr, 8066, "\n");
  }
#endif
  FOREACHridge_(ridges) {
    FOREACHvertex_(ridge->vertices)
      vertex->seen= False;
  }
  FOREACHvertex_(vertices) {
    vertex->visitid= 0;  /* v.visitid will be number of ridges */
    vertex->seen= True;
  }
  FOREACHridge_(ridges) {
    FOREACHvertex_(ridge->vertices) {
      if (vertex->seen)
        vertex->visitid++;
    }
  }
  FOREACHvertex_(vertices) {
    if (!vertex->visitid) {
      qh_setdelnth(qh, vertices, SETindex_(vertices,vertex));
      vertexp--; /* repeat since deleted this vertex */
    }
  }
  maxvisit= (unsigned int)qh_setsize(qh, ridges);
  maximize_(qh->vertex_visit, maxvisit);
  if (!qh_setsize(qh, vertices)) {
    trace4((qh, qh->ferr, 4023, "qh_find_newvertex: vertices not in ridges for v%d\n",
            oldvertex->id));
    return NULL;
  }
  qsort(SETaddr_(vertices, vertexT), (size_t)qh_setsize(qh, vertices),
                sizeof(vertexT *), qh_comparevisit);
  /* can now use qh->vertex_visit */
  if (qh->PRINTstatistics) {
    size= qh_setsize(qh, vertices);
    zinc_(Zintersect);
    zadd_(Zintersecttot, size);
    zmax_(Zintersectmax, size);
  }
  hashsize= qh_newhashtable(qh, qh_setsize(qh, ridges));
  FOREACHridge_(ridges)
    qh_hashridge(qh, qh->hash_table, hashsize, ridge, oldvertex);
  FOREACHvertex_(vertices) {
    newridges= qh_vertexridges(qh, vertex, !qh_ALL);
    FOREACHridge_(newridges) {
      if (qh_hashridge_find(qh, qh->hash_table, hashsize, ridge, vertex, oldvertex, &hash)) {
        zinc_(Zvertexridge);
        break;
      }
    }
    qh_settempfree(qh, &newridges);
    if (!ridge)
      break;  /* found a rename */
  }
  if (vertex) {
    /* counted in qh_renamevertex */
    trace2((qh, qh->ferr, 2020, "qh_find_newvertex: found v%d for old v%d from %d vertices and %d ridges.\n",
      vertex->id, oldvertex->id, qh_setsize(qh, vertices), qh_setsize(qh, ridges)));
  }else {
    zinc_(Zfindfail);
    trace0((qh, qh->ferr, 14, "qh_find_newvertex: no vertex for renaming v%d (all duplicated ridges) during p%d\n",
      oldvertex->id, qh->furthest_id));
  }
  qh_setfree(qh, &qh->hash_table);
  return vertex;
} /* find_newvertex */

/*---------------------------------

  qh_findbest_pinchedvertex(qh, merge, apex, nearestp, distp )
    Determine the best pinched vertex to rename as its nearest neighboring vertex
    Renaming will remove a duplicate MRGdupridge in newfacet_list

  returns:
    pinched vertex (either apex or subridge), nearest vertex (subridge or neighbor vertex), and the distance between them

  notes:
    only called by qh_getpinchedmerges
    assumes qh.VERTEXneighbors
    see qh_findbest_ridgevertex

  design:
    if the facets have the same vertices
      return the nearest vertex pair
    else
      the subridge is the intersection of the two new facets minus the apex
      the subridge consists of qh.hull_dim-2 horizon vertices
      the subridge is also a matched ridge for the new facets (its duplicate)
      determine the nearest vertex to the apex
      determine the nearest pair of subridge vertices
      for each vertex in the subridge
        determine the nearest neighbor vertex (not in the subridge)
*/
vertexT *qh_findbest_pinchedvertex(qhT *qh, mergeT *merge, vertexT *apex, vertexT **nearestp, coordT *distp /* qh.newfacet_list */) {
  vertexT *vertex, **vertexp, *vertexA, **vertexAp;
  vertexT *bestvertex= NULL, *bestpinched= NULL;
  setT *subridge, *maybepinched;
  coordT dist, bestdist= REALmax;
  coordT pincheddist= (qh->ONEmerge+qh->DISTround)*qh_RATIOpinchedsubridge;

  if (!merge->facet1->simplicial || !merge->facet2->simplicial) {
    qh_fprintf(qh, qh->ferr, 6351, "qhull internal error (qh_findbest_pinchedvertex): expecting merge of adjacent, simplicial new facets.  f%d or f%d is not simplicial\n",
      merge->facet1->id, merge->facet2->id);
    qh_errexit2(qh, qh_ERRqhull, merge->facet1, merge->facet2);
  }
  subridge= qh_vertexintersect_new(qh, merge->facet1->vertices, merge->facet2->vertices); /* new setT.  No error_exit() */
  if (qh_setsize(qh, subridge) == qh->hull_dim) { /* duplicate vertices */
    bestdist= qh_vertex_bestdist2(qh, subridge, &bestvertex, &bestpinched);
    if(bestvertex == apex) {
      bestvertex= bestpinched;
      bestpinched= apex;
    }
  }else {
    qh_setdel(subridge, apex);
    if (qh_setsize(qh, subridge) != qh->hull_dim - 2) {
      qh_fprintf(qh, qh->ferr, 6409, "qhull internal error (qh_findbest_pinchedvertex): expecting subridge of qh.hull_dim-2 vertices for the intersection of new facets f%d and f%d minus their apex.  Got %d vertices\n",
          merge->facet1->id, merge->facet2->id, qh_setsize(qh, subridge));
      qh_errexit2(qh, qh_ERRqhull, merge->facet1, merge->facet2);
    }
    FOREACHvertex_(subridge) {
      dist= qh_pointdist(vertex->point, apex->point, qh->hull_dim);
      if (dist < bestdist) {
        bestpinched= apex;
        bestvertex= vertex;
        bestdist= dist;
      }
    }
    if (bestdist > pincheddist) {
      FOREACHvertex_(subridge) {
        FOREACHvertexA_(subridge) {
          if (vertexA->id > vertex->id) { /* once per vertex pair, do not compare addresses */
            dist= qh_pointdist(vertexA->point, vertex->point, qh->hull_dim);
            if (dist < bestdist) {
              bestpinched= vertexA;
              bestvertex= vertex;
              bestdist= dist;
            }
          }
        }
      }
    }
    if (bestdist > pincheddist) {
      FOREACHvertexA_(subridge) {
        maybepinched= qh_neighbor_vertices(qh, vertexA, subridge); /* subridge and apex tested above */
        FOREACHvertex_(maybepinched) {
          dist= qh_pointdist(vertex->point, vertexA->point, qh->hull_dim);
          if (dist < bestdist) {
            bestvertex= vertex;
            bestpinched= vertexA;
            bestdist= dist;
          }
        }
        qh_settempfree(qh, &maybepinched);
      }
    }
  }
  *distp= bestdist;
  qh_setfree(qh, &subridge); /* qh_err_exit not called since allocated */
  if (!bestvertex) {  /* should never happen if qh.hull_dim > 2 */
    qh_fprintf(qh, qh->ferr, 6274, "qhull internal error (qh_findbest_pinchedvertex): did not find best vertex for subridge of dupridge between f%d and f%d, while processing p%d\n", merge->facet1->id, merge->facet2->id, qh->furthest_id);
    qh_errexit2(qh, qh_ERRqhull, merge->facet1, merge->facet2);
  }
  *nearestp= bestvertex;
  trace2((qh, qh->ferr, 2061, "qh_findbest_pinchedvertex: best pinched p%d(v%d) and vertex p%d(v%d) are closest (%2.2g) for duplicate subridge between f%d and f%d\n",
      qh_pointid(qh, bestpinched->point), bestpinched->id, qh_pointid(qh, bestvertex->point), bestvertex->id, bestdist, merge->facet1->id, merge->facet2->id));
  return bestpinched;
} /* findbest_pinchedvertex */

/*---------------------------------

  qh_findbest_ridgevertex(qh, ridge, pinchedp, distp )
    Determine the best vertex/pinched-vertex to merge for ridges with the same vertices

  returns:
    vertex, pinched vertex, and the distance between them

  notes:
    assumes qh.hull_dim>=3
    see qh_findbest_pinchedvertex

*/
vertexT *qh_findbest_ridgevertex(qhT *qh, ridgeT *ridge, vertexT **pinchedp, coordT *distp) {
  vertexT *bestvertex;

  *distp= qh_vertex_bestdist2(qh, ridge->vertices, &bestvertex, pinchedp);
  trace4((qh, qh->ferr, 4069, "qh_findbest_ridgevertex: best pinched p%d(v%d) and vertex p%d(v%d) are closest (%2.2g) for duplicated ridge r%d (same vertices) between f%d and f%d\n",
      qh_pointid(qh, (*pinchedp)->point), (*pinchedp)->id, qh_pointid(qh, bestvertex->point), bestvertex->id, *distp, ridge->id, ridge->top->id, ridge->bottom->id));
  return bestvertex;
} /* findbest_ridgevertex */

/*---------------------------------

  qh_findbest_test(qh, testcentrum, facet, neighbor, &bestfacet, &dist, &mindist, &maxdist )
    test neighbor of facet for qh_findbestneighbor()
    if testcentrum,
      tests centrum (assumes it is defined)
    else
      tests vertices
    initially *bestfacet==NULL and *dist==REALmax

  returns:
    if a better facet (i.e., vertices/centrum of facet closer to neighbor)
      updates bestfacet, dist, mindist, and maxdist

  notes:
    called by qh_findbestneighbor
    ignores pairs of flipped facets, unless that's all there is
*/
void qh_findbest_test(qhT *qh, boolT testcentrum, facetT *facet, facetT *neighbor,
      facetT **bestfacet, realT *distp, realT *mindistp, realT *maxdistp) {
  realT dist, mindist, maxdist;

  if (facet->flipped && neighbor->flipped && *bestfacet && !(*bestfacet)->flipped)
    return; /* do not merge flipped into flipped facets */
  if (testcentrum) {
    zzinc_(Zbestdist);
    qh_distplane(qh, facet->center, neighbor, &dist);
    dist *= qh->hull_dim; /* estimate furthest vertex */
    if (dist < 0) {
      maxdist= 0;
      mindist= dist;
      dist= -dist;
    }else {
      mindist= 0;
      maxdist= dist;
    }
  }else
    dist= qh_getdistance(qh, facet, neighbor, &mindist, &maxdist);
  if (dist < *distp) {
    *bestfacet= neighbor;
    *mindistp= mindist;
    *maxdistp= maxdist;
    *distp= dist;
  }
} /* findbest_test */

/*---------------------------------

  qh_findbestneighbor(qh, facet, dist, mindist, maxdist )
    finds best neighbor (least dist) of a facet for merging

  returns:
    returns min and max distances and their max absolute value

  notes:
    error if qh_ASvoronoi
    avoids merging old into new
    assumes ridge->nonconvex only set on one ridge between a pair of facets
    could use an early out predicate but not worth it

  design:
    if a large facet
      will test centrum
    else
      will test vertices
    if a large facet
      test nonconvex neighbors for best merge
    else
      test all neighbors for the best merge
    if testing centrum
      get distance information
*/
facetT *qh_findbestneighbor(qhT *qh, facetT *facet, realT *distp, realT *mindistp, realT *maxdistp) {
  facetT *neighbor, **neighborp, *bestfacet= NULL;
  ridgeT *ridge, **ridgep;
  boolT nonconvex= True, testcentrum= False;
  int size= qh_setsize(qh, facet->vertices);

  if(qh->CENTERtype==qh_ASvoronoi){
    qh_fprintf(qh, qh->ferr, 6272, "qhull internal error: cannot call qh_findbestneighor for f%d while qh.CENTERtype is qh_ASvoronoi\n", facet->id);
    qh_errexit(qh, qh_ERRqhull, facet, NULL);
  }
  *distp= REALmax;
  if (size > qh_BESTcentrum2 * qh->hull_dim + qh_BESTcentrum) {
    testcentrum= True;
    zinc_(Zbestcentrum);
    if (!facet->center)
       facet->center= qh_getcentrum(qh, facet);
  }
  if (size > qh->hull_dim + qh_BESTnonconvex) {
    FOREACHridge_(facet->ridges) {
      if (ridge->nonconvex) {
        neighbor= otherfacet_(ridge, facet);
        qh_findbest_test(qh, testcentrum, facet, neighbor,
                          &bestfacet, distp, mindistp, maxdistp);
      }
    }
  }
  if (!bestfacet) {
    nonconvex= False;
    FOREACHneighbor_(facet)
      qh_findbest_test(qh, testcentrum, facet, neighbor,
                        &bestfacet, distp, mindistp, maxdistp);
  }
  if (!bestfacet) {
    qh_fprintf(qh, qh->ferr, 6095, "qhull internal error (qh_findbestneighbor): no neighbors for f%d\n", facet->id);
    qh_errexit(qh, qh_ERRqhull, facet, NULL);
  }
  if (testcentrum)
    qh_getdistance(qh, facet, bestfacet, mindistp, maxdistp);
  trace3((qh, qh->ferr, 3002, "qh_findbestneighbor: f%d is best neighbor for f%d testcentrum? %d nonconvex? %d dist %2.2g min %2.2g max %2.2g\n",
     bestfacet->id, facet->id, testcentrum, nonconvex, *distp, *mindistp, *maxdistp));
  return(bestfacet);
} /* findbestneighbor */


/*---------------------------------

  qh_flippedmerges(qh, facetlist, wasmerge )
    merge flipped facets into best neighbor
    assumes qh.facet_mergeset at top of temporary stack

  returns:
    no flipped facets on facetlist
    sets wasmerge if merge occurred
    degen/redundant merges passed through

  notes:
    othermerges not needed since qh.facet_mergeset is empty before & after
      keep it in case of change

  design:
    append flipped facets to qh.facetmergeset
    for each flipped merge
      find best neighbor
      merge facet into neighbor
      merge degenerate and redundant facets
    remove flipped merges from qh.facet_mergeset
*/
void qh_flippedmerges(qhT *qh, facetT *facetlist, boolT *wasmerge) {
  facetT *facet, *neighbor, *facet1;
  realT dist, mindist, maxdist;
  mergeT *merge, **mergep;
  setT *othermerges;
  int nummerge= 0, numdegen= 0;

  trace4((qh, qh->ferr, 4024, "qh_flippedmerges: begin\n"));
  FORALLfacet_(facetlist) {
    if (facet->flipped && !facet->visible)
      qh_appendmergeset(qh, facet, facet, MRGflip, 0.0, 1.0);
  }
  othermerges= qh_settemppop(qh);
  if(othermerges != qh->facet_mergeset) {
    qh_fprintf(qh, qh->ferr, 6392, "qhull internal error (qh_flippedmerges): facet_mergeset (%d merges) not at top of tempstack (%d merges)\n",
        qh_setsize(qh, qh->facet_mergeset), qh_setsize(qh, othermerges));
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  qh->facet_mergeset= qh_settemp(qh, qh->TEMPsize);
  qh_settemppush(qh, othermerges);
  FOREACHmerge_(othermerges) {
    facet1= merge->facet1;
    if (merge->mergetype != MRGflip || facet1->visible)
      continue;
    if (qh->TRACEmerge-1 == zzval_(Ztotmerge))
      qh->qhmem.IStracing= qh->IStracing= qh->TRACElevel;
    neighbor= qh_findbestneighbor(qh, facet1, &dist, &mindist, &maxdist);
    trace0((qh, qh->ferr, 15, "qh_flippedmerges: merge flipped f%d into f%d dist %2.2g during p%d\n",
      facet1->id, neighbor->id, dist, qh->furthest_id));
    qh_mergefacet(qh, facet1, neighbor, merge->mergetype, &mindist, &maxdist, !qh_MERGEapex);
    nummerge++;
    if (qh->PRINTstatistics) {
      zinc_(Zflipped);
      wadd_(Wflippedtot, dist);
      wmax_(Wflippedmax, dist);
    }
  }
  FOREACHmerge_(othermerges) {
    if (merge->facet1->visible || merge->facet2->visible)
      qh_memfree(qh, merge, (int)sizeof(mergeT)); /* invalidates merge and othermerges */
    else
      qh_setappend(qh, &qh->facet_mergeset, merge);
  }
  qh_settempfree(qh, &othermerges);
  numdegen += qh_merge_degenredundant(qh); /* somewhat better here than after each flipped merge -- qtest.sh 10 '500 C1,2e-13 D4' 'd Qbb' */
  if (nummerge)
    *wasmerge= True;
  trace1((qh, qh->ferr, 1010, "qh_flippedmerges: merged %d flipped and %d degenredundant facets into a good neighbor\n",
    nummerge, numdegen));
} /* flippedmerges */


/*---------------------------------

  qh_forcedmerges(qh, wasmerge )
    merge dupridges
    calls qh_check_dupridge to report an error on wide merges
    assumes qh_settemppop is qh.facet_mergeset

  returns:
    removes all dupridges on facet_mergeset
    wasmerge set if merge
    qh.facet_mergeset may include non-forced merges(none for now)
    qh.degen_mergeset includes degen/redun merges

  notes:
    called by qh_premerge
    dupridges occur when the horizon is pinched,
        i.e. a subridge occurs in more than two horizon ridges.
     could rename vertices that pinch the horizon
    assumes qh_merge_degenredundant() has not be called
    othermerges isn't needed since facet_mergeset is empty afterwards
      keep it in case of change

  design:
    for each dupridge
      find current facets by chasing f.replace links
      check for wide merge due to dupridge
      determine best direction for facet
      merge one facet into the other
      remove dupridges from qh.facet_mergeset
*/
void qh_forcedmerges(qhT *qh, boolT *wasmerge) {
  facetT *facet1, *facet2, *merging, *merged, *newfacet;
  mergeT *merge, **mergep;
  realT dist, mindist, maxdist, dist2, mindist2, maxdist2;
  setT *othermerges;
  int nummerge=0, numflip=0, numdegen= 0;
  boolT wasdupridge= False;

  if (qh->TRACEmerge-1 == zzval_(Ztotmerge))
    qh->qhmem.IStracing= qh->IStracing= qh->TRACElevel;
  trace3((qh, qh->ferr, 3054, "qh_forcedmerges: merge dupridges\n"));
  othermerges= qh_settemppop(qh); /* was facet_mergeset */
  if (qh->facet_mergeset != othermerges ) {
      qh_fprintf(qh, qh->ferr, 6279, "qhull internal error (qh_forcedmerges): qh_settemppop (size %d) is not qh->facet_mergeset (size %d)\n",
          qh_setsize(qh, othermerges), qh_setsize(qh, qh->facet_mergeset));
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  qh->facet_mergeset= qh_settemp(qh, qh->TEMPsize);
  qh_settemppush(qh, othermerges);
  FOREACHmerge_(othermerges) {
    if (merge->mergetype != MRGdupridge)
        continue;
    wasdupridge= True;
    if (qh->TRACEmerge-1 == zzval_(Ztotmerge))
        qh->qhmem.IStracing= qh->IStracing= qh->TRACElevel;
    facet1= qh_getreplacement(qh, merge->facet1);  /* must exist, no qh_merge_degenredunant */
    facet2= qh_getreplacement(qh, merge->facet2);  /* previously merged facet, if any */
    if (facet1 == facet2)
      continue;
    if (!qh_setin(facet2->neighbors, facet1)) {
      qh_fprintf(qh, qh->ferr, 6096, "qhull internal error (qh_forcedmerges): f%d and f%d had a dupridge but as f%d and f%d they are no longer neighbors\n",
               merge->facet1->id, merge->facet2->id, facet1->id, facet2->id);
      qh_errexit2(qh, qh_ERRqhull, facet1, facet2);
    }
    dist= qh_getdistance(qh, facet1, facet2, &mindist, &maxdist);
    dist2= qh_getdistance(qh, facet2, facet1, &mindist2, &maxdist2);
    qh_check_dupridge(qh, facet1, dist, facet2, dist2);
    if (dist < dist2) {
      if (facet2->flipped && !facet1->flipped && dist2 < qh_WIDEdupridge*(qh->ONEmerge+qh->DISTround)) { /* prefer merge of flipped facet */
        merging= facet2;
        merged= facet1;
        dist= dist2;
        mindist= mindist2;
        maxdist= maxdist2;
      }else {
        merging= facet1;
        merged= facet2;
      }
    }else {
      if (facet1->flipped && !facet2->flipped && dist < qh_WIDEdupridge*(qh->ONEmerge+qh->DISTround)) { /* prefer merge of flipped facet */
        merging= facet1;
        merged= facet2;
      }else {
        merging= facet2;
        merged= facet1;
        dist= dist2;
        mindist= mindist2;
        maxdist= maxdist2;
      }
    }
    qh_mergefacet(qh, merging, merged, merge->mergetype, &mindist, &maxdist, !qh_MERGEapex);
    numdegen += qh_merge_degenredundant(qh); /* better here than at end -- qtest.sh 10 '500 C1,2e-13 D4' 'd Qbb' */
    if (facet1->flipped) {
      zinc_(Zmergeflipdup);
      numflip++;
    }else
      nummerge++;
    if (qh->PRINTstatistics) {
      zinc_(Zduplicate);
      wadd_(Wduplicatetot, dist);
      wmax_(Wduplicatemax, dist);
    }
  }
  FOREACHmerge_(othermerges) {
    if (merge->mergetype == MRGdupridge)
      qh_memfree(qh, merge, (int)sizeof(mergeT)); /* invalidates merge and othermerges */
    else
      qh_setappend(qh, &qh->facet_mergeset, merge);
  }
  qh_settempfree(qh, &othermerges);
  if (wasdupridge) {
    FORALLnew_facets {
      if (newfacet->dupridge) {
        newfacet->dupridge= False;
        newfacet->mergeridge= False;
        newfacet->mergeridge2= False;
        if (qh_setsize(qh, newfacet->neighbors) < qh->hull_dim) { /* not tested for MRGdupridge */
          qh_appendmergeset(qh, newfacet, newfacet, MRGdegen, 0.0, 1.0);
          trace2((qh, qh->ferr, 2107, "qh_forcedmerges: dupridge f%d is degenerate with fewer than %d neighbors\n",
                      newfacet->id, qh->hull_dim));
        }
      }
    }
    numdegen += qh_merge_degenredundant(qh);
  }
  if (nummerge || numflip) {
    *wasmerge= True;
    trace1((qh, qh->ferr, 1011, "qh_forcedmerges: merged %d facets, %d flipped facets, and %d degenredundant facets across dupridges\n",
                  nummerge, numflip, numdegen));
  }
} /* forcedmerges */


/*---------------------------------

  qh_freemergesets(qh )
    free the merge sets

  notes:
    matches qh_initmergesets
*/
void qh_freemergesets(qhT *qh) {

  if (!qh->facet_mergeset || !qh->degen_mergeset || !qh->vertex_mergeset) {
    qh_fprintf(qh, qh->ferr, 6388, "qhull internal error (qh_freemergesets): expecting mergesets.  Got a NULL mergeset, qh.facet_mergeset (0x%x), qh.degen_mergeset (0x%x), qh.vertex_mergeset (0x%x)\n",
      qh->facet_mergeset, qh->degen_mergeset, qh->vertex_mergeset);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  if (!SETempty_(qh->facet_mergeset) || !SETempty_(qh->degen_mergeset) || !SETempty_(qh->vertex_mergeset)) {
    qh_fprintf(qh, qh->ferr, 6389, "qhull internal error (qh_freemergesets): expecting empty mergesets.  Got qh.facet_mergeset (%d merges), qh.degen_mergeset (%d merges), qh.vertex_mergeset (%d merges)\n",
      qh_setsize(qh, qh->facet_mergeset), qh_setsize(qh, qh->degen_mergeset), qh_setsize(qh, qh->vertex_mergeset));
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  qh_settempfree(qh, &qh->facet_mergeset);
  qh_settempfree(qh, &qh->vertex_mergeset);
  qh_settempfree(qh, &qh->degen_mergeset);
} /* freemergesets */

/*---------------------------------

  qh_getmergeset(qh, facetlist )
    determines nonconvex facets on facetlist
    tests !tested ridges and nonconvex ridges of !tested facets

  returns:
    returns sorted qh.facet_mergeset of facet-neighbor pairs to be merged
    all ridges tested

  notes:
    facetlist is qh.facet_newlist, use qh_getmergeset_initial for all facets
    assumes no nonconvex ridges with both facets tested
    uses facet->tested/ridge->tested to prevent duplicate tests
    can not limit tests to modified ridges since the centrum changed
    uses qh.visit_id

  design:
    for each facet on facetlist
      for each ridge of facet
        if untested ridge
          test ridge for convexity
          if non-convex
            append ridge to qh.facet_mergeset
    sort qh.facet_mergeset by mergetype and angle or distance
*/
void qh_getmergeset(qhT *qh, facetT *facetlist) {
  facetT *facet, *neighbor, **neighborp;
  ridgeT *ridge, **ridgep;
  int nummerges;
  boolT simplicial;

  nummerges= qh_setsize(qh, qh->facet_mergeset);
  trace4((qh, qh->ferr, 4026, "qh_getmergeset: started.\n"));
  qh->visit_id++;
  FORALLfacet_(facetlist) {
    if (facet->tested)
      continue;
    facet->visitid= qh->visit_id;
    FOREACHneighbor_(facet)
      neighbor->seen= False;
    /* facet must be non-simplicial due to merge to qh.facet_newlist */
    FOREACHridge_(facet->ridges) {
      if (ridge->tested && !ridge->nonconvex)
        continue;
      /* if r.tested & r.nonconvex, need to retest and append merge */
      neighbor= otherfacet_(ridge, facet);
      if (neighbor->seen) { /* another ridge for this facet-neighbor pair was already tested in this loop */
        ridge->tested= True;
        ridge->nonconvex= False;   /* only one ridge is marked nonconvex per facet-neighbor pair */
      }else if (neighbor->visitid != qh->visit_id) {
        neighbor->seen= True;
        ridge->nonconvex= False;
        simplicial= False;
        if (ridge->simplicialbot && ridge->simplicialtop)
          simplicial= True;
        if (qh_test_appendmerge(qh, facet, neighbor, simplicial))
          ridge->nonconvex= True;
        ridge->tested= True;
      }
    }
    facet->tested= True;
  }
  nummerges= qh_setsize(qh, qh->facet_mergeset);
  if (qh->ANGLEmerge)
    qsort(SETaddr_(qh->facet_mergeset, mergeT), (size_t)nummerges, sizeof(mergeT *), qh_compare_anglemerge);
  else
    qsort(SETaddr_(qh->facet_mergeset, mergeT), (size_t)nummerges, sizeof(mergeT *), qh_compare_facetmerge);
  nummerges += qh_setsize(qh, qh->degen_mergeset);
  if (qh->POSTmerging) {
    zadd_(Zmergesettot2, nummerges);
  }else {
    zadd_(Zmergesettot, nummerges);
    zmax_(Zmergesetmax, nummerges);
  }
  trace2((qh, qh->ferr, 2021, "qh_getmergeset: %d merges found\n", nummerges));
} /* getmergeset */


/*---------------------------------

  qh_getmergeset_initial(qh, facetlist )
    determine initial qh.facet_mergeset for facets
    tests all facet/neighbor pairs on facetlist

  returns:
    sorted qh.facet_mergeset with nonconvex ridges
    sets facet->tested, ridge->tested, and ridge->nonconvex

  notes:
    uses visit_id, assumes ridge->nonconvex is False
    see qh_getmergeset

  design:
    for each facet on facetlist
      for each untested neighbor of facet
        test facet and neighbor for convexity
        if non-convex
          append merge to qh.facet_mergeset
          mark one of the ridges as nonconvex
    sort qh.facet_mergeset by mergetype and angle or distance
*/
void qh_getmergeset_initial(qhT *qh, facetT *facetlist) {
  facetT *facet, *neighbor, **neighborp;
  ridgeT *ridge, **ridgep;
  int nummerges;
  boolT simplicial;

  qh->visit_id++;
  FORALLfacet_(facetlist) {
    facet->visitid= qh->visit_id;
    FOREACHneighbor_(facet) {
      if (neighbor->visitid != qh->visit_id) {
        simplicial= False; /* ignores r.simplicialtop/simplicialbot.  Need to test horizon facets */
        if (facet->simplicial && neighbor->simplicial)
          simplicial= True;
        if (qh_test_appendmerge(qh, facet, neighbor, simplicial)) {
          FOREACHridge_(neighbor->ridges) {
            if (facet == otherfacet_(ridge, neighbor)) {
              ridge->nonconvex= True;
              break;    /* only one ridge is marked nonconvex */
            }
          }
        }
      }
    }
    facet->tested= True;
    FOREACHridge_(facet->ridges)
      ridge->tested= True;
  }
  nummerges= qh_setsize(qh, qh->facet_mergeset);
  if (qh->ANGLEmerge)
    qsort(SETaddr_(qh->facet_mergeset, mergeT), (size_t)nummerges, sizeof(mergeT *), qh_compare_anglemerge);
  else
    qsort(SETaddr_(qh->facet_mergeset, mergeT), (size_t)nummerges, sizeof(mergeT *), qh_compare_facetmerge);
  nummerges += qh_setsize(qh, qh->degen_mergeset);
  if (qh->POSTmerging) {
    zadd_(Zmergeinittot2, nummerges);
  }else {
    zadd_(Zmergeinittot, nummerges);
    zmax_(Zmergeinitmax, nummerges);
  }
  trace2((qh, qh->ferr, 2022, "qh_getmergeset_initial: %d merges found\n", nummerges));
} /* getmergeset_initial */

/*---------------------------------

  qh_getpinchedmerges(qh, apex, maxdist, iscoplanar )
    get pinched merges for dupridges in qh.facet_mergeset
    qh.NEWtentative==True
      qh.newfacet_list with apex
      qh.horizon_list is attached to qh.visible_list instead of qh.newfacet_list
      maxdist for vertex-facet of a dupridge
    qh.facet_mergeset is empty
    qh.vertex_mergeset is a temporary set

  returns:
    False if nearest vertex would increase facet width by more than maxdist or qh_WIDEpinched
    True and iscoplanar, if the pinched vertex is the apex (i.e., make the apex a coplanar point)
    True and !iscoplanar, if should merge a pinched vertex of a dupridge
      qh.vertex_mergeset contains one or more MRGsubridge with a pinched vertex and a nearby, neighboring vertex
    qh.facet_mergeset is empty

  notes:
    called by qh_buildcone_mergepinched
    hull_dim >= 3
    a pinched vertex is in a dupridge and the horizon
    selects the pinched vertex that is closest to its neighbor

  design:
    for each dupridge
        determine the best pinched vertex to be merged into a neighboring vertex
        if merging the pinched vertex would produce a wide merge (qh_WIDEpinched)
           ignore pinched vertex with a warning, and use qh_merge_degenredundant instead
        else
           append the pinched vertex to vertex_mergeset for merging
*/
boolT qh_getpinchedmerges(qhT *qh, vertexT *apex, coordT maxdupdist, boolT *iscoplanar /* qh.newfacet_list, qh.vertex_mergeset */) {
  mergeT *merge, **mergep, *bestmerge= NULL;
  vertexT *nearest, *pinched, *bestvertex= NULL, *bestpinched= NULL;
  boolT result;
  coordT dist, prevdist, bestdist= REALmax/(qh_RATIOcoplanarapex+1.0); /* allow *3.0 */
  realT ratio;

  trace2((qh, qh->ferr, 2062, "qh_getpinchedmerges: try to merge pinched vertices for dupridges in new facets with apex p%d(v%d) max dupdist %2.2g\n",
      qh_pointid(qh, apex->point), apex->id, maxdupdist));
  *iscoplanar= False;
  prevdist= fmax_(qh->ONEmerge + qh->DISTround, qh->MINoutside + qh->DISTround);
  maximize_(prevdist, qh->max_outside);
  maximize_(prevdist, -qh->min_vertex);
  qh_mark_dupridges(qh, qh->newfacet_list, !qh_ALL); /* qh.facet_mergeset, creates ridges */
  /* qh_mark_dupridges is called a second time in qh_premerge */
  FOREACHmerge_(qh->facet_mergeset) {  /* read-only */
    if (merge->mergetype != MRGdupridge) {
      qh_fprintf(qh, qh->ferr, 6393, "qhull internal error (qh_getpinchedmerges): expecting MRGdupridge from qh_mark_dupridges.  Got merge f%d f%d type %d\n",
        getid_(merge->facet1), getid_(merge->facet2), merge->mergetype);
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
    }
    /* dist is distance between vertices */
    pinched= qh_findbest_pinchedvertex(qh, merge, apex, &nearest, &dist /* qh.newfacet_list */);
    if (pinched == apex && dist < qh_RATIOcoplanarapex*bestdist) { /* prefer coplanar apex since it always works */
      bestdist= dist/qh_RATIOcoplanarapex;
      bestmerge= merge;
      bestpinched= pinched;
      bestvertex= nearest;
    }else if (dist < bestdist) {
      bestdist= dist;
      bestmerge= merge;
      bestpinched= pinched;
      bestvertex= nearest;
    }
  }
  result= False;
  if (bestmerge && bestdist < maxdupdist) {
    ratio= bestdist / prevdist;
    if (ratio > qh_WIDEpinched) {
      if (bestmerge->facet1->mergehorizon || bestmerge->facet2->mergehorizon) { /* e.g., rbox 175 C3,2e-13 t1539182828 | qhull d */
        trace1((qh, qh->ferr, 1051, "qh_getpinchedmerges: dupridge (MRGdupridge) of coplanar horizon would produce a wide merge (%.0fx) due to pinched vertices v%d and v%d (dist %2.2g) for f%d and f%d.  qh_mergecycle_all will merge one or both facets\n",
          ratio, bestpinched->id, bestvertex->id, bestdist, bestmerge->facet1->id, bestmerge->facet2->id));
      }else {
        qh_fprintf(qh, qh->ferr, 7081, "qhull precision warning (qh_getpinchedmerges): pinched vertices v%d and v%d (dist %2.2g, %.0fx) would produce a wide merge for f%d and f%d.  Will merge dupridge instead\n",
          bestpinched->id, bestvertex->id, bestdist, ratio, bestmerge->facet1->id, bestmerge->facet2->id);
      }
    }else {
      if (bestpinched == apex) {
        trace2((qh, qh->ferr, 2063, "qh_getpinchedmerges: will make the apex a coplanar point.  apex p%d(v%d) is the nearest vertex to v%d on dupridge.  Dist %2.2g\n",
          qh_pointid(qh, apex->point), apex->id, bestvertex->id, bestdist*qh_RATIOcoplanarapex));
        qh->coplanar_apex= apex->point;
        *iscoplanar= True;
        result= True;
      }else if (qh_setin(bestmerge->facet1->vertices, bestpinched) != qh_setin(bestmerge->facet2->vertices, bestpinched)) { /* pinched in one facet but not the other facet */
        trace2((qh, qh->ferr, 2064, "qh_getpinchedmerges: will merge new facets to resolve dupridge between f%d and f%d with pinched v%d and v%d\n",
          bestmerge->facet1->id, bestmerge->facet2->id, bestpinched->id, bestvertex->id));
        qh_appendvertexmerge(qh, bestpinched, bestvertex, MRGsubridge, bestdist, NULL, NULL);
        result= True;
      }else {
        trace2((qh, qh->ferr, 2065, "qh_getpinchedmerges: will merge pinched v%d into v%d to resolve dupridge between f%d and f%d\n",
          bestpinched->id, bestvertex->id, bestmerge->facet1->id, bestmerge->facet2->id));
        qh_appendvertexmerge(qh, bestpinched, bestvertex, MRGsubridge, bestdist, NULL, NULL);
        result= True;
      }
    }
  }
  /* delete MRGdupridge, qh_mark_dupridges is called a second time in qh_premerge */
  while ((merge= (mergeT *)qh_setdellast(qh->facet_mergeset)))
    qh_memfree(qh, merge, (int)sizeof(mergeT));
  return result;
}/* getpinchedmerges */

/*---------------------------------

  qh_hasmerge( mergeset, mergetype, facetA, facetB )
    True if mergeset has mergetype for facetA and facetB
*/
boolT   qh_hasmerge(setT *mergeset, mergeType type, facetT *facetA, facetT *facetB) {
  mergeT *merge, **mergep;

  FOREACHmerge_(mergeset) {
    if (merge->mergetype == type) {
      if (merge->facet1 == facetA && merge->facet2 == facetB)
        return True;
      if (merge->facet1 == facetB && merge->facet2 == facetA)
        return True;
    }
  }
  return False;
}/* hasmerge */

/*---------------------------------

  qh_hashridge(qh, hashtable, hashsize, ridge, oldvertex )
    add ridge to hashtable without oldvertex

  notes:
    assumes hashtable is large enough

  design:
    determine hash value for ridge without oldvertex
    find next empty slot for ridge
*/
void qh_hashridge(qhT *qh, setT *hashtable, int hashsize, ridgeT *ridge, vertexT *oldvertex) {
  int hash;
  ridgeT *ridgeA;

  hash= qh_gethash(qh, hashsize, ridge->vertices, qh->hull_dim-1, 0, oldvertex);
  while (True) {
    if (!(ridgeA= SETelemt_(hashtable, hash, ridgeT))) {
      SETelem_(hashtable, hash)= ridge;
      break;
    }else if (ridgeA == ridge)
      break;
    if (++hash == hashsize)
      hash= 0;
  }
} /* hashridge */


/*---------------------------------

  qh_hashridge_find(qh, hashtable, hashsize, ridge, vertex, oldvertex, hashslot )
    returns matching ridge without oldvertex in hashtable
      for ridge without vertex
    if oldvertex is NULL
      matches with any one skip

  returns:
    matching ridge or NULL
    if no match,
      if ridge already in   table
        hashslot= -1
      else
        hashslot= next NULL index

  notes:
    assumes hashtable is large enough
    can't match ridge to itself

  design:
    get hash value for ridge without vertex
    for each hashslot
      return match if ridge matches ridgeA without oldvertex
*/
ridgeT *qh_hashridge_find(qhT *qh, setT *hashtable, int hashsize, ridgeT *ridge,
              vertexT *vertex, vertexT *oldvertex, int *hashslot) {
  int hash;
  ridgeT *ridgeA;

  *hashslot= 0;
  zinc_(Zhashridge);
  hash= qh_gethash(qh, hashsize, ridge->vertices, qh->hull_dim-1, 0, vertex);
  while ((ridgeA= SETelemt_(hashtable, hash, ridgeT))) {
    if (ridgeA == ridge)
      *hashslot= -1;
    else {
      zinc_(Zhashridgetest);
      if (qh_setequal_except(ridge->vertices, vertex, ridgeA->vertices, oldvertex))
        return ridgeA;
    }
    if (++hash == hashsize)
      hash= 0;
  }
  if (!*hashslot)
    *hashslot= hash;
  return NULL;
} /* hashridge_find */


/*---------------------------------

  qh_initmergesets(qh )
    initialize the merge sets
    if 'all', include qh.degen_mergeset

  notes:
    matches qh_freemergesets
*/
void qh_initmergesets(qhT *qh /* qh.facet_mergeset,degen_mergeset,vertex_mergeset */) {

  if (qh->facet_mergeset || qh->degen_mergeset || qh->vertex_mergeset) {
    qh_fprintf(qh, qh->ferr, 6386, "qhull internal error (qh_initmergesets): expecting NULL mergesets.  Got qh.facet_mergeset (0x%x), qh.degen_mergeset (0x%x), qh.vertex_mergeset (0x%x)\n",
      qh->facet_mergeset, qh->degen_mergeset, qh->vertex_mergeset);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  qh->degen_mergeset= qh_settemp(qh, qh->TEMPsize);
  qh->vertex_mergeset= qh_settemp(qh, qh->TEMPsize);
  qh->facet_mergeset= qh_settemp(qh, qh->TEMPsize); /* last temporary set for qh_forcedmerges */
} /* initmergesets */

/*---------------------------------

  qh_makeridges(qh, facet )
    creates explicit ridges between simplicial facets

  returns:
    facet with ridges and without qh_MERGEridge
    ->simplicial is False
    if facet was tested, new ridges are tested

  notes:
    allows qh_MERGEridge flag
    uses existing ridges
    duplicate neighbors ok if ridges already exist (qh_mergecycle_ridges)

  see:
    qh_mergecycle_ridges()
    qh_rename_adjacentvertex for qh_merge_pinchedvertices

  design:
    look for qh_MERGEridge neighbors
    mark neighbors that already have ridges
    for each unprocessed neighbor of facet
      create a ridge for neighbor and facet
    if any qh_MERGEridge neighbors
      delete qh_MERGEridge flags (previously processed by qh_mark_dupridges)
*/
void qh_makeridges(qhT *qh, facetT *facet) {
  facetT *neighbor, **neighborp;
  ridgeT *ridge, **ridgep;
  int neighbor_i, neighbor_n;
  boolT toporient, mergeridge= False;

  if (!facet->simplicial)
    return;
  trace4((qh, qh->ferr, 4027, "qh_makeridges: make ridges for f%d\n", facet->id));
  facet->simplicial= False;
  FOREACHneighbor_(facet) {
    if (neighbor == qh_MERGEridge)
      mergeridge= True;
    else
      neighbor->seen= False;
  }
  FOREACHridge_(facet->ridges)
    otherfacet_(ridge, facet)->seen= True;
  FOREACHneighbor_i_(qh, facet) {
    if (neighbor == qh_MERGEridge)
      continue;  /* fixed by qh_mark_dupridges */
    else if (!neighbor->seen) {  /* no current ridges */
      ridge= qh_newridge(qh);
      ridge->vertices= qh_setnew_delnthsorted(qh, facet->vertices, qh->hull_dim,
                                                          neighbor_i, 0);
      toporient= (boolT)(facet->toporient ^ (neighbor_i & 0x1));
      if (toporient) {
        ridge->top= facet;
        ridge->bottom= neighbor;
        ridge->simplicialtop= True;
        ridge->simplicialbot= neighbor->simplicial;
      }else {
        ridge->top= neighbor;
        ridge->bottom= facet;
        ridge->simplicialtop= neighbor->simplicial;
        ridge->simplicialbot= True;
      }
      if (facet->tested && !mergeridge)
        ridge->tested= True;
#if 0 /* this also works */
      flip= (facet->toporient ^ neighbor->toporient)^(skip1 & 0x1) ^ (skip2 & 0x1);
      if (facet->toporient ^ (skip1 & 0x1) ^ flip) {
        ridge->top= neighbor;
        ridge->bottom= facet;
        ridge->simplicialtop= True;
        ridge->simplicialbot= neighbor->simplicial;
      }else {
        ridge->top= facet;
        ridge->bottom= neighbor;
        ridge->simplicialtop= neighbor->simplicial;
        ridge->simplicialbot= True;
      }
#endif
      qh_setappend(qh, &(facet->ridges), ridge);
      trace5((qh, qh->ferr, 5005, "makeridges: appended r%d to ridges for f%d.  Next is ridges for neighbor f%d\n",
            ridge->id, facet->id, neighbor->id));
      qh_setappend(qh, &(neighbor->ridges), ridge);
      if (qh->ridge_id == qh->traceridge_id)
        qh->traceridge= ridge;
    }
  }
  if (mergeridge) {
    while (qh_setdel(facet->neighbors, qh_MERGEridge))
      ; /* delete each one */
  }
} /* makeridges */


/*---------------------------------

  qh_mark_dupridges(qh, facetlist, allmerges )
    add duplicated ridges to qh.facet_mergeset
    facet-dupridge is true if it contains a subridge shared by more than one new facet
    for each such facet, one has a neighbor marked qh_MERGEridge
    allmerges is true if merging dupridges
    allmerges is false if merging pinched vertices followed by retry addpoint
      qh_mark_dupridges will be called again if pinched vertices not found

  returns:
    dupridges on qh.facet_mergeset (MRGdupridge)
    f.mergeridge and f.mergeridge2 set for facet
    f.mergeridge set for neighbor
    if allmerges is true
      make ridges for facets with dupridges as marked by qh_MERGEridge and both sides facet->dupridge
      removes qh_MERGEridge from neighbor sets

  notes:
    called by qh_premerge and qh_getpinchedmerges
    dupridges are due to duplicate subridges
        i.e. a subridge occurs in more than two horizon ridges.
        i.e., a ridge has more than two neighboring facets
    dupridges occur in at least two cases
    1) a pinched horizon with nearly adjacent vertices -> merge the vertices (qh_getpinchedmerges)
    2) more than one newfacet for a horizon face -> merge coplanar facets (qh_premerge)
    qh_matchdupridge previously identified the furthest apart pair of facets to retain
       they must have a matching subridge and the same orientation
    only way to set facet->mergeridge and mergeridge2
    uses qh.visit_id

  design:
    for all facets on facetlist
      if facet contains a dupridge
        for each neighbor of facet
          if neighbor marked qh_MERGEridge (one side of the merge)
            set facet->mergeridge
          else
            if neighbor contains a dupridge
            and the back link is qh_MERGEridge
              append dupridge to qh.facet_mergeset
   exit if !allmerges for repeating qh_mark_dupridges later
   for each dupridge
     make ridge sets in preparation for merging
     remove qh_MERGEridge from neighbor set
   for each dupridge
     restore the missing neighbor from the neighbor set that was qh_MERGEridge
     add the missing ridge for this neighbor
*/
void qh_mark_dupridges(qhT *qh, facetT *facetlist, boolT allmerges) {
  facetT *facet, *neighbor, **neighborp;
  int nummerge=0;
  mergeT *merge, **mergep;

  trace4((qh, qh->ferr, 4028, "qh_mark_dupridges: identify dupridges in facetlist f%d, allmerges? %d\n",
    facetlist->id, allmerges));
  FORALLfacet_(facetlist) {  /* not necessary for first call */
    facet->mergeridge2= False;
    facet->mergeridge= False;
  }
  FORALLfacet_(facetlist) {
    if (facet->dupridge) {
      FOREACHneighbor_(facet) {
        if (neighbor == qh_MERGEridge) {
          facet->mergeridge= True;
          continue;
        }
        if (neighbor->dupridge) {
          if (!qh_setin(neighbor->neighbors, facet)) { /* i.e., it is qh_MERGEridge, neighbors are distinct */
            qh_appendmergeset(qh, facet, neighbor, MRGdupridge, 0.0, 1.0);
            facet->mergeridge2= True;
            facet->mergeridge= True;
            nummerge++;
          }else if (qh_setequal(facet->vertices, neighbor->vertices)) { /* neighbors are the same except for horizon and qh_MERGEridge, see QH7085 */
            trace3((qh, qh->ferr, 3043, "qh_mark_dupridges): dupridge due to duplicate vertices for subridges f%d and f%d\n",
                 facet->id, neighbor->id));
            qh_appendmergeset(qh, facet, neighbor, MRGdupridge, 0.0, 1.0);
            facet->mergeridge2= True;
            facet->mergeridge= True;
            nummerge++;
            break; /* same for all neighbors */
          }
        }
      }
    }
  }
  if (!nummerge)
    return;
  if (!allmerges) {
    trace1((qh, qh->ferr, 1012, "qh_mark_dupridges: found %d duplicated ridges (MRGdupridge) for qh_getpinchedmerges\n", nummerge));
    return;
  }
  trace1((qh, qh->ferr, 1048, "qh_mark_dupridges: found %d duplicated ridges (MRGdupridge) for qh_premerge.  Prepare facets for merging\n", nummerge));
  /* make ridges in preparation for merging */
  FORALLfacet_(facetlist) {
    if (facet->mergeridge && !facet->mergeridge2)
      qh_makeridges(qh, facet);
  }
  trace3((qh, qh->ferr, 3075, "qh_mark_dupridges: restore missing neighbors and ridges due to qh_MERGEridge\n"));
  FOREACHmerge_(qh->facet_mergeset) {   /* restore the missing neighbors */
    if (merge->mergetype == MRGdupridge) { /* only between simplicial facets */
      if (merge->facet2->mergeridge2 && qh_setin(merge->facet2->neighbors, merge->facet1)) {
        /* Due to duplicate or multiple subridges, e.g., ../eg/qtest.sh t712682 '200 s W1e-13  C1,1e-13 D5' 'd'
            merge->facet1:    - neighboring facets: f27779 f59186 f59186 f59186 MERGEridge f59186
            merge->facet2:    - neighboring facets: f27779 f59100 f59100 f59100 f59100 f59100
           or, ../eg/qtest.sh 100 '500 s W1e-13 C1,1e-13 D4' 'd'
           both facets will be degenerate after merge, consider for special case handling
        */
        qh_fprintf(qh, qh->ferr, 6361, "qhull topological error (qh_mark_dupridges): multiple dupridges for f%d and f%d, including reverse\n",
          merge->facet1->id, merge->facet2->id);
        qh_errexit2(qh, qh_ERRtopology, merge->facet1, merge->facet2);
      }else
        qh_setappend(qh, &merge->facet2->neighbors, merge->facet1);
      qh_makeridges(qh, merge->facet1);   /* and the missing ridges */
    }
  }
} /* mark_dupridges */

/*---------------------------------

  qh_maybe_duplicateridge(qh, ridge )
    add MRGvertices if neighboring facet has another ridge with the same vertices

  returns:
    adds rename requests to qh.vertex_mergeset

  notes:
    called by qh_renamevertex
    nop if 2-D
    expensive test
    Duplicate ridges may lead to new facets with same vertex set (QH7084), will try merging vertices
    same as qh_maybe_duplicateridges

  design:
    for the two neighbors
      if non-simplicial
        for each ridge with the same first and last vertices (max id and min id)
          if the remaining vertices are the same
            get the closest pair of vertices
            add to vertex_mergeset for merging
*/
void qh_maybe_duplicateridge(qhT *qh, ridgeT *ridgeA) {
  ridgeT *ridge, **ridgep;
  vertexT *vertex, *pinched;
  facetT *neighbor;
  coordT dist;
  int i, k, last= qh->hull_dim-2;

  if (qh->hull_dim < 3 )
    return;

  for (neighbor= ridgeA->top, i=0; i<2; neighbor= ridgeA->bottom, i++) {
    if (!neighbor->simplicial && neighbor->nummerge > 0) { /* skip degenerate neighbors with both new and old vertices that will be merged */
      FOREACHridge_(neighbor->ridges) {
        if (ridge != ridgeA && SETfirst_(ridge->vertices) == SETfirst_(ridgeA->vertices)) {
          if (SETelem_(ridge->vertices, last) == SETelem_(ridgeA->vertices, last)) {
            for (k=1; kvertices, k) != SETelem_(ridgeA->vertices, k))
                break;
            }
            if (k == last) {
              vertex= qh_findbest_ridgevertex(qh, ridge, &pinched, &dist);
              trace2((qh, qh->ferr, 2069, "qh_maybe_duplicateridge: will merge v%d into v%d (dist %2.2g) due to duplicate ridges r%d/r%d with the same vertices.  mergevertex set\n",
                pinched->id, vertex->id, dist, ridgeA->id, ridge->id, ridgeA->top->id, ridgeA->bottom->id, ridge->top->id, ridge->bottom->id));
              qh_appendvertexmerge(qh, pinched, vertex, MRGvertices, dist, ridgeA, ridge);
              ridge->mergevertex= True; /* disables check for duplicate vertices in qh_checkfacet */
              ridgeA->mergevertex= True;
            }
          }
        }
      }
    }
  }
} /* maybe_duplicateridge */

/*---------------------------------

  qh_maybe_duplicateridges(qh, facet )
    if Q15, add MRGvertices if facet has ridges with the same vertices

  returns:
    adds rename requests to qh.vertex_mergeset

  notes:
    called at end of qh_mergefacet and qh_mergecycle_all
    only enabled if qh.CHECKduplicates ('Q15') and 3-D or more
    expensive test, not worth it
    same as qh_maybe_duplicateridge

  design:
    for all ridge pairs in facet
        if the same first and last vertices (max id and min id)
          if the remaining vertices are the same
            get the closest pair of vertices
            add to vertex_mergeset for merging
*/
void qh_maybe_duplicateridges(qhT *qh, facetT *facet) {
  facetT *otherfacet;
  ridgeT *ridge, *ridge2;
  vertexT *vertex, *pinched;
  coordT dist;
  int ridge_i, ridge_n, i, k, last_v= qh->hull_dim-2;

  if (qh->hull_dim < 3 || !qh->CHECKduplicates)
    return;

  FOREACHridge_i_(qh, facet->ridges) {
    otherfacet= otherfacet_(ridge, facet);
    if (otherfacet->degenerate || otherfacet->redundant || otherfacet->dupridge || otherfacet->flipped) /* will merge */
      continue;
    for (i=ridge_i+1; i < ridge_n; i++) {
      ridge2= SETelemt_(facet->ridges, i, ridgeT);
      otherfacet= otherfacet_(ridge2, facet);
      if (otherfacet->degenerate || otherfacet->redundant || otherfacet->dupridge || otherfacet->flipped) /* will merge */
        continue;
      /* optimize qh_setequal(ridge->vertices, ridge2->vertices) */
      if (SETelem_(ridge->vertices, last_v) == SETelem_(ridge2->vertices, last_v)) { /* SETfirst is likely to be the same */
        if (SETfirst_(ridge->vertices) == SETfirst_(ridge2->vertices)) {
          for (k=1; kvertices, k) != SETelem_(ridge2->vertices, k))
              break;
          }
          if (k == last_v) {
            vertex= qh_findbest_ridgevertex(qh, ridge, &pinched, &dist);
            if (ridge->top == ridge2->bottom && ridge->bottom == ridge2->top) {
              /* proof that ridges may have opposite orientation */
              trace2((qh, qh->ferr, 2088, "qh_maybe_duplicateridges: will merge v%d into v%d (dist %2.2g) due to opposite oriented ridges r%d/r%d for f%d and f%d\n",
                pinched->id, vertex->id, dist, ridge->id, ridge2->id, ridge->top->id, ridge->bottom->id));
            }else {
              trace2((qh, qh->ferr, 2083, "qh_maybe_duplicateridges: will merge v%d into v%d (dist %2.2g) due to duplicate ridges with the same vertices r%d/r%d in merged facet f%d\n",
                pinched->id, vertex->id, dist, ridge->id, ridge2->id, facet->id));
            }
            qh_appendvertexmerge(qh, pinched, vertex, MRGvertices, dist, ridge, ridge2);
            ridge->mergevertex= True; /* disables check for duplicate vertices in qh_checkfacet */
            ridge2->mergevertex= True;
          }
        }
      }
    }
  }
} /* maybe_duplicateridges */

/*---------------------------------

  qh_maydropneighbor(qh, facet )
    drop neighbor relationship if ridge was deleted between a non-simplicial facet and its neighbors

  returns:
    for deleted ridges
      ridges made for simplicial neighbors
      neighbor sets updated
      appends degenerate facets to qh.facet_mergeset

  notes:
    called by qh_renamevertex
    assumes neighbors do not include qh_MERGEridge (qh_makeridges)
    won't cause redundant facets since vertex inclusion is the same
    may drop vertex and neighbor if no ridge
    uses qh.visit_id

  design:
    visit all neighbors with ridges
    for each unvisited neighbor of facet
      delete neighbor and facet from the non-simplicial neighbor sets
      if neighbor becomes degenerate
        append neighbor to qh.degen_mergeset
    if facet is degenerate
      append facet to qh.degen_mergeset
*/
void qh_maydropneighbor(qhT *qh, facetT *facet) {
  ridgeT *ridge, **ridgep;
  facetT *neighbor, **neighborp;

  qh->visit_id++;
  trace4((qh, qh->ferr, 4029, "qh_maydropneighbor: test f%d for no ridges to a neighbor\n",
          facet->id));
  if (facet->simplicial) {
    qh_fprintf(qh, qh->ferr, 6278, "qhull internal error (qh_maydropneighbor): not valid for simplicial f%d while adding furthest p%d\n",
      facet->id, qh->furthest_id);
    qh_errexit(qh, qh_ERRqhull, facet, NULL);
  }
  FOREACHridge_(facet->ridges) {
    ridge->top->visitid= qh->visit_id;
    ridge->bottom->visitid= qh->visit_id;
  }
  FOREACHneighbor_(facet) {
    if (neighbor->visible) {
      qh_fprintf(qh, qh->ferr, 6358, "qhull internal error (qh_maydropneighbor): facet f%d has deleted neighbor f%d (qh.visible_list)\n",
            facet->id, neighbor->id);
      qh_errexit2(qh, qh_ERRqhull, facet, neighbor);
    }
    if (neighbor->visitid != qh->visit_id) {
      trace2((qh, qh->ferr, 2104, "qh_maydropneighbor: facets f%d and f%d are no longer neighbors while adding furthest p%d\n",
            facet->id, neighbor->id, qh->furthest_id));
      if (neighbor->simplicial) {
        qh_fprintf(qh, qh->ferr, 6280, "qhull internal error (qh_maydropneighbor): not valid for simplicial neighbor f%d of f%d while adding furthest p%d\n",
            neighbor->id, facet->id, qh->furthest_id);
        qh_errexit2(qh, qh_ERRqhull, neighbor, facet);
      }
      zinc_(Zdropneighbor);
      qh_setdel(neighbor->neighbors, facet);
      if (qh_setsize(qh, neighbor->neighbors) < qh->hull_dim) {
        zinc_(Zdropdegen);
        qh_appendmergeset(qh, neighbor, neighbor, MRGdegen, 0.0, qh_ANGLEnone);
        trace2((qh, qh->ferr, 2023, "qh_maydropneighbors: f%d is degenerate.\n", neighbor->id));
      }
      qh_setdel(facet->neighbors, neighbor);
      neighborp--;  /* repeat, deleted a neighbor */
    }
  }
  if (qh_setsize(qh, facet->neighbors) < qh->hull_dim) {
    zinc_(Zdropdegen);
    qh_appendmergeset(qh, facet, facet, MRGdegen, 0.0, qh_ANGLEnone);
    trace2((qh, qh->ferr, 2024, "qh_maydropneighbors: f%d is degenerate.\n", facet->id));
  }
} /* maydropneighbor */


/*---------------------------------

  qh_merge_degenredundant(qh)
    merge all degenerate and redundant facets
    qh.degen_mergeset contains merges from  qh_test_degen_neighbors, qh_test_redundant_neighbors, and qh_degen_redundant_facet

  returns:
    number of merges performed
    resets facet->degenerate/redundant
    if deleted (visible) facet has no neighbors
      sets ->f.replace to NULL

  notes:
    redundant merges happen before degenerate ones
    merging and renaming vertices can result in degen/redundant facets
    check for coplanar and convex neighbors afterwards

  design:
    for each merge on qh.degen_mergeset
      if redundant merge
        if non-redundant facet merged into redundant facet
          recheck facet for redundancy
        else
          merge redundant facet into other facet
*/
int qh_merge_degenredundant(qhT *qh) {
  int size;
  mergeT *merge;
  facetT *bestneighbor, *facet1, *facet2, *facet3;
  realT dist, mindist, maxdist;
  vertexT *vertex, **vertexp;
  int nummerges= 0;
  mergeType mergetype;
  setT *mergedfacets;

  trace2((qh, qh->ferr, 2095, "qh_merge_degenredundant: merge %d degenerate, redundant, and mirror facets\n",
    qh_setsize(qh, qh->degen_mergeset)));
  mergedfacets= qh_settemp(qh, qh->TEMPsize);
  while ((merge= (mergeT *)qh_setdellast(qh->degen_mergeset))) {
    facet1= merge->facet1;
    facet2= merge->facet2;
    mergetype= merge->mergetype;
    qh_memfree(qh, merge, (int)sizeof(mergeT)); /* 'merge' is invalidated */
    if (facet1->visible)
      continue;
    facet1->degenerate= False;
    facet1->redundant= False;
    if (qh->TRACEmerge-1 == zzval_(Ztotmerge))
      qh->qhmem.IStracing= qh->IStracing= qh->TRACElevel;
    if (mergetype == MRGredundant) {
      zinc_(Zredundant);
      facet3= qh_getreplacement(qh, facet2); /* the same facet if !facet2.visible */
      if (!facet3) {
          qh_fprintf(qh, qh->ferr, 6097, "qhull internal error (qh_merge_degenredunant): f%d is redundant but visible f%d has no replacement\n",
               facet1->id, getid_(facet2));
          qh_errexit2(qh, qh_ERRqhull, facet1, facet2);
      }
      qh_setunique(qh, &mergedfacets, facet3);
      if (facet1 == facet3) {
        continue;
      }
      trace2((qh, qh->ferr, 2025, "qh_merge_degenredundant: merge redundant f%d into f%d (arg f%d)\n",
            facet1->id, facet3->id, facet2->id));
      qh_mergefacet(qh, facet1, facet3, mergetype, NULL, NULL, !qh_MERGEapex);
      /* merge distance is already accounted for */
      nummerges++;
    }else {  /* mergetype == MRGdegen or MRGmirror, other merges may have fixed */
      if (!(size= qh_setsize(qh, facet1->neighbors))) {
        zinc_(Zdelfacetdup);
        trace2((qh, qh->ferr, 2026, "qh_merge_degenredundant: facet f%d has no neighbors.  Deleted\n", facet1->id));
        qh_willdelete(qh, facet1, NULL);
        FOREACHvertex_(facet1->vertices) {
          qh_setdel(vertex->neighbors, facet1);
          if (!SETfirst_(vertex->neighbors)) {
            zinc_(Zdegenvertex);
            trace2((qh, qh->ferr, 2027, "qh_merge_degenredundant: deleted v%d because f%d has no neighbors\n",
                 vertex->id, facet1->id));
            vertex->deleted= True;
            qh_setappend(qh, &qh->del_vertices, vertex);
          }
        }
        nummerges++;
      }else if (size < qh->hull_dim) {
        bestneighbor= qh_findbestneighbor(qh, facet1, &dist, &mindist, &maxdist);
        trace2((qh, qh->ferr, 2028, "qh_merge_degenredundant: facet f%d has %d neighbors, merge into f%d dist %2.2g\n",
              facet1->id, size, bestneighbor->id, dist));
        qh_mergefacet(qh, facet1, bestneighbor, mergetype, &mindist, &maxdist, !qh_MERGEapex);
        nummerges++;
        if (qh->PRINTstatistics) {
          zinc_(Zdegen);
          wadd_(Wdegentot, dist);
          wmax_(Wdegenmax, dist);
        }
      } /* else, another merge fixed the degeneracy and redundancy tested */
    }
  }
  qh_settempfree(qh, &mergedfacets);
  return nummerges;
} /* merge_degenredundant */

/*---------------------------------

  qh_merge_nonconvex(qh, facet1, facet2, mergetype )
    remove non-convex ridge between facet1 into facet2
    mergetype gives why the facet's are non-convex

  returns:
    merges one of the facets into the best neighbor

  notes:
    mergetype is MRGcoplanar..MRGconvex

  design:
    if one of the facets is a new facet
      prefer merging new facet into old facet
    find best neighbors for both facets
    merge the nearest facet into its best neighbor
    update the statistics
*/
void qh_merge_nonconvex(qhT *qh, facetT *facet1, facetT *facet2, mergeType mergetype) {
  facetT *bestfacet, *bestneighbor, *neighbor, *merging, *merged;
  realT dist, dist2, mindist, mindist2, maxdist, maxdist2;

  if (mergetype < MRGcoplanar || mergetype > MRGconcavecoplanar) {
    qh_fprintf(qh, qh->ferr, 6398, "qhull internal error (qh_merge_nonconvex): expecting mergetype MRGcoplanar..MRGconcavecoplanar.  Got merge f%d and f%d type %d\n",
      facet1->id, facet2->id, mergetype);
    qh_errexit2(qh, qh_ERRqhull, facet1, facet2);
  }
  if (qh->TRACEmerge-1 == zzval_(Ztotmerge))
    qh->qhmem.IStracing= qh->IStracing= qh->TRACElevel;
  trace3((qh, qh->ferr, 3003, "qh_merge_nonconvex: merge #%d for f%d and f%d type %d\n",
      zzval_(Ztotmerge) + 1, facet1->id, facet2->id, mergetype));
  /* concave or coplanar */
  if (!facet1->newfacet) {
    bestfacet= facet2;   /* avoid merging old facet if new is ok */
    facet2= facet1;
    facet1= bestfacet;
  }else
    bestfacet= facet1;
  bestneighbor= qh_findbestneighbor(qh, bestfacet, &dist, &mindist, &maxdist);
  neighbor= qh_findbestneighbor(qh, facet2, &dist2, &mindist2, &maxdist2);
  if (dist < dist2) {
    merging= bestfacet;
    merged= bestneighbor;
  }else if (qh->AVOIDold && !facet2->newfacet
  && ((mindist >= -qh->MAXcoplanar && maxdist <= qh->max_outside)
       || dist * 1.5 < dist2)) {
    zinc_(Zavoidold);
    wadd_(Wavoidoldtot, dist);
    wmax_(Wavoidoldmax, dist);
    trace2((qh, qh->ferr, 2029, "qh_merge_nonconvex: avoid merging old facet f%d dist %2.2g.  Use f%d dist %2.2g instead\n",
           facet2->id, dist2, facet1->id, dist2));
    merging= bestfacet;
    merged= bestneighbor;
  }else {
    merging= facet2;
    merged= neighbor;
    dist= dist2;
    mindist= mindist2;
    maxdist= maxdist2;
  }
  qh_mergefacet(qh, merging, merged, mergetype, &mindist, &maxdist, !qh_MERGEapex);
  /* caller merges qh_degenredundant */
  if (qh->PRINTstatistics) {
    if (mergetype == MRGanglecoplanar) {
      zinc_(Zacoplanar);
      wadd_(Wacoplanartot, dist);
      wmax_(Wacoplanarmax, dist);
    }else if (mergetype == MRGconcave) {
      zinc_(Zconcave);
      wadd_(Wconcavetot, dist);
      wmax_(Wconcavemax, dist);
    }else if (mergetype == MRGconcavecoplanar) {
      zinc_(Zconcavecoplanar);
      wadd_(Wconcavecoplanartot, dist);
      wmax_(Wconcavecoplanarmax, dist);
    }else { /* MRGcoplanar */
      zinc_(Zcoplanar);
      wadd_(Wcoplanartot, dist);
      wmax_(Wcoplanarmax, dist);
    }
  }
} /* merge_nonconvex */

/*---------------------------------

  qh_merge_pinchedvertices(qh, apex )
    merge pinched vertices in qh.vertex_mergeset to avoid qh_forcedmerges of dupridges

  notes:
    only called by qh_all_vertexmerges
    hull_dim >= 3

  design:
    make vertex neighbors if necessary
    for each pinched vertex
      determine the ridges for the pinched vertex (make ridges as needed)
      merge the pinched vertex into the horizon vertex
      merge the degenerate and redundant facets that result
    check and resolve new dupridges
*/
void qh_merge_pinchedvertices(qhT *qh, int apexpointid /* qh.newfacet_list */) {
  mergeT *merge, *mergeA, **mergeAp;
  vertexT *vertex, *vertex2;
  realT dist;
  boolT firstmerge= True;

  qh_vertexneighbors(qh);
  if (qh->visible_list || qh->newfacet_list || qh->newvertex_list) {
    qh_fprintf(qh, qh->ferr, 6402, "qhull internal error (qh_merge_pinchedvertices): qh.visible_list (f%d), newfacet_list (f%d), or newvertex_list (v%d) not empty\n",
      getid_(qh->visible_list), getid_(qh->newfacet_list), getid_(qh->newvertex_list));
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  qh->visible_list= qh->newfacet_list= qh->facet_tail;
  qh->newvertex_list= qh->vertex_tail;
  qh->isRenameVertex= True; /* disable duplicate ridge vertices check in qh_checkfacet */
  while ((merge= qh_next_vertexmerge(qh /* qh.vertex_mergeset */))) { /* only one at a time from qh_getpinchedmerges */
    if (qh->TRACEmerge-1 == zzval_(Ztotmerge))
      qh->qhmem.IStracing= qh->IStracing= qh->TRACElevel;
    if (merge->mergetype == MRGsubridge) {
      zzinc_(Zpinchedvertex);
      trace1((qh, qh->ferr, 1050, "qh_merge_pinchedvertices: merge one of %d pinched vertices before adding apex p%d.  Try to resolve duplicate ridges in newfacets\n",
        qh_setsize(qh, qh->vertex_mergeset)+1, apexpointid));
      qh_remove_mergetype(qh, qh->vertex_mergeset, MRGsubridge);
    }else {
      zzinc_(Zpinchduplicate);
      if (firstmerge)
        trace1((qh, qh->ferr, 1056, "qh_merge_pinchedvertices: merge %d pinched vertices from dupridges in merged facets, apex p%d\n",
           qh_setsize(qh, qh->vertex_mergeset)+1, apexpointid));
      firstmerge= False;
    }
    vertex= merge->vertex1;
    vertex2= merge->vertex2;
    dist= merge->distance;
    qh_memfree(qh, merge, (int)sizeof(mergeT)); /* merge is invalidated */
    qh_rename_adjacentvertex(qh, vertex, vertex2, dist);
#ifndef qh_NOtrace
    if (qh->IStracing >= 2) {
      FOREACHmergeA_(qh->degen_mergeset) {
        if (mergeA->mergetype== MRGdegen) {
          qh_fprintf(qh, qh->ferr, 2072, "qh_merge_pinchedvertices: merge degenerate f%d into an adjacent facet\n", mergeA->facet1->id);
        }else {
          qh_fprintf(qh, qh->ferr, 2084, "qh_merge_pinchedvertices: merge f%d into f%d mergeType %d\n", mergeA->facet1->id, mergeA->facet2->id, mergeA->mergetype);
        }
      }
    }
#endif
    qh_merge_degenredundant(qh); /* simplicial facets with both old and new vertices */
  }
  qh->isRenameVertex= False;
}/* merge_pinchedvertices */

/*---------------------------------

  qh_merge_twisted(qh, facet1, facet2 )
    remove twisted ridge between facet1 into facet2 or report error

  returns:
    merges one of the facets into the best neighbor

  notes:
    a twisted ridge has opposite vertices that are convex and concave

  design:
    find best neighbors for both facets
    error if wide merge
    merge the nearest facet into its best neighbor
    update statistics
*/
void qh_merge_twisted(qhT *qh, facetT *facet1, facetT *facet2) {
  facetT *neighbor2, *neighbor, *merging, *merged;
  vertexT *bestvertex, *bestpinched;
  realT dist, dist2, mindist, mindist2, maxdist, maxdist2, mintwisted, bestdist;

  if (qh->TRACEmerge-1 == zzval_(Ztotmerge))
    qh->qhmem.IStracing= qh->IStracing= qh->TRACElevel;
  trace3((qh, qh->ferr, 3050, "qh_merge_twisted: merge #%d for twisted f%d and f%d\n",
      zzval_(Ztotmerge) + 1, facet1->id, facet2->id));
  /* twisted */
  neighbor= qh_findbestneighbor(qh, facet1, &dist, &mindist, &maxdist);
  neighbor2= qh_findbestneighbor(qh, facet2, &dist2, &mindist2, &maxdist2);
  mintwisted= qh_RATIOtwisted * qh->ONEmerge;
  maximize_(mintwisted, facet1->maxoutside);
  maximize_(mintwisted, facet2->maxoutside);
  if (dist > mintwisted && dist2 > mintwisted) {
    bestdist= qh_vertex_bestdist2(qh, facet1->vertices, &bestvertex, &bestpinched);
    if (bestdist > mintwisted) {
      qh_fprintf(qh, qh->ferr, 6417, "qhull precision error (qh_merge_twisted): twisted facet f%d does not contain pinched vertices.  Too wide to merge into neighbor.  mindist %2.2g maxdist %2.2g vertexdist %2.2g maxpinched %2.2g neighbor f%d mindist %2.2g maxdist %2.2g\n",
        facet1->id, mindist, maxdist, bestdist, mintwisted, facet2->id, mindist2, maxdist2);
    }else {
      qh_fprintf(qh, qh->ferr, 6418, "qhull precision error (qh_merge_twisted): twisted facet f%d with pinched vertices.  Could merge vertices, but too wide to merge into neighbor.   mindist %2.2g maxdist %2.2g vertexdist %2.2g neighbor f%d mindist %2.2g maxdist %2.2g\n",
        facet1->id, mindist, maxdist, bestdist, facet2->id, mindist2, maxdist2);
    }
    qh_errexit2(qh, qh_ERRwide, facet1, facet2);
  }
  if (dist < dist2) {
    merging= facet1;
    merged= neighbor;
  }else {
    /* ignores qh.AVOIDold ('Q4') */
    merging= facet2;
    merged= neighbor2;
    dist= dist2;
    mindist= mindist2;
    maxdist= maxdist2;
  }
  qh_mergefacet(qh, merging, merged, MRGtwisted, &mindist, &maxdist, !qh_MERGEapex);
  /* caller merges qh_degenredundant */
  zinc_(Ztwisted);
  wadd_(Wtwistedtot, dist);
  wmax_(Wtwistedmax, dist);
} /* merge_twisted */

/*---------------------------------

  qh_mergecycle(qh, samecycle, newfacet )
    merge a cycle of facets starting at samecycle into a newfacet
    newfacet is a horizon facet with ->normal
    samecycle facets are simplicial from an apex

  returns:
    initializes vertex neighbors on first merge
    samecycle deleted (placed on qh.visible_list)
    newfacet at end of qh.facet_list
    deleted vertices on qh.del_vertices

  notes:
    only called by qh_mergecycle_all for multiple, same cycle facets
    see qh_mergefacet

  design:
    make vertex neighbors if necessary
    make ridges for newfacet
    merge neighbor sets of samecycle into newfacet
    merge ridges of samecycle into newfacet
    merge vertex neighbors of samecycle into newfacet
    make apex of samecycle the apex of newfacet
    if newfacet wasn't a new facet
      add its vertices to qh.newvertex_list
    delete samecycle facets a make newfacet a newfacet
*/
void qh_mergecycle(qhT *qh, facetT *samecycle, facetT *newfacet) {
  int traceonce= False, tracerestore= 0;
  vertexT *apex;
#ifndef qh_NOtrace
  facetT *same;
#endif

  zzinc_(Ztotmerge);
  if (qh->REPORTfreq2 && qh->POSTmerging) {
    if (zzval_(Ztotmerge) > qh->mergereport + qh->REPORTfreq2)
      qh_tracemerging(qh);
  }
#ifndef qh_NOtrace
  if (qh->TRACEmerge == zzval_(Ztotmerge))
    qh->qhmem.IStracing= qh->IStracing= qh->TRACElevel;
  trace2((qh, qh->ferr, 2030, "qh_mergecycle: merge #%d for facets from cycle f%d into coplanar horizon f%d\n",
        zzval_(Ztotmerge), samecycle->id, newfacet->id));
  if (newfacet == qh->tracefacet) {
    tracerestore= qh->IStracing;
    qh->IStracing= 4;
    qh_fprintf(qh, qh->ferr, 8068, "qh_mergecycle: ========= trace merge %d of samecycle %d into trace f%d, furthest is p%d\n",
               zzval_(Ztotmerge), samecycle->id, newfacet->id,  qh->furthest_id);
    traceonce= True;
  }
  if (qh->IStracing >=4) {
    qh_fprintf(qh, qh->ferr, 8069, "  same cycle:");
    FORALLsame_cycle_(samecycle)
      qh_fprintf(qh, qh->ferr, 8070, " f%d", same->id);
    qh_fprintf(qh, qh->ferr, 8071, "\n");
  }
  if (qh->IStracing >=4)
    qh_errprint(qh, "MERGING CYCLE", samecycle, newfacet, NULL, NULL);
#endif /* !qh_NOtrace */
  if (newfacet->tricoplanar) {
    if (!qh->TRInormals) {
      qh_fprintf(qh, qh->ferr, 6224, "qhull internal error (qh_mergecycle): does not work for tricoplanar facets.  Use option 'Q11'\n");
      qh_errexit(qh, qh_ERRqhull, newfacet, NULL);
    }
    newfacet->tricoplanar= False;
    newfacet->keepcentrum= False;
  }
  if (qh->CHECKfrequently)
    qh_checkdelridge(qh);
  if (!qh->VERTEXneighbors)
    qh_vertexneighbors(qh);
  apex= SETfirstt_(samecycle->vertices, vertexT);
  qh_makeridges(qh, newfacet);
  qh_mergecycle_neighbors(qh, samecycle, newfacet);
  qh_mergecycle_ridges(qh, samecycle, newfacet);
  qh_mergecycle_vneighbors(qh, samecycle, newfacet);
  if (SETfirstt_(newfacet->vertices, vertexT) != apex)
    qh_setaddnth(qh, &newfacet->vertices, 0, apex);  /* apex has last id */
  if (!newfacet->newfacet)
    qh_newvertices(qh, newfacet->vertices);
  qh_mergecycle_facets(qh, samecycle, newfacet);
  qh_tracemerge(qh, samecycle, newfacet, MRGcoplanarhorizon);
  /* check for degen_redundant_neighbors after qh_forcedmerges() */
  if (traceonce) {
    qh_fprintf(qh, qh->ferr, 8072, "qh_mergecycle: end of trace facet\n");
    qh->IStracing= tracerestore;
  }
} /* mergecycle */

/*---------------------------------

  qh_mergecycle_all(qh, facetlist, wasmerge )
    merge all samecycles of coplanar facets into horizon
    don't merge facets with ->mergeridge (these already have ->normal)
    all facets are simplicial from apex
    all facet->cycledone == False

  returns:
    all newfacets merged into coplanar horizon facets
    deleted vertices on  qh.del_vertices
    sets wasmerge if any merge

  notes:
    called by qh_premerge
    calls qh_mergecycle for multiple, same cycle facets

  design:
    for each facet on facetlist
      skip facets with dupridges and normals
      check that facet is in a samecycle (->mergehorizon)
      if facet only member of samecycle
        sets vertex->delridge for all vertices except apex
        merge facet into horizon
      else
        mark all facets in samecycle
        remove facets with dupridges from samecycle
        merge samecycle into horizon (deletes facets from facetlist)
*/
void qh_mergecycle_all(qhT *qh, facetT *facetlist, boolT *wasmerge) {
  facetT *facet, *same, *prev, *horizon, *newfacet;
  facetT *samecycle= NULL, *nextfacet, *nextsame;
  vertexT *apex, *vertex, **vertexp;
  int cycles=0, total=0, facets, nummerge, numdegen= 0;

  trace2((qh, qh->ferr, 2031, "qh_mergecycle_all: merge new facets into coplanar horizon facets.  Bulk merge a cycle of facets with the same horizon facet\n"));
  for (facet=facetlist; facet && (nextfacet= facet->next); facet= nextfacet) {
    if (facet->normal)
      continue;
    if (!facet->mergehorizon) {
      qh_fprintf(qh, qh->ferr, 6225, "qhull internal error (qh_mergecycle_all): f%d without normal\n", facet->id);
      qh_errexit(qh, qh_ERRqhull, facet, NULL);
    }
    horizon= SETfirstt_(facet->neighbors, facetT);
    if (facet->f.samecycle == facet) {
      if (qh->TRACEmerge-1 == zzval_(Ztotmerge))
        qh->qhmem.IStracing= qh->IStracing= qh->TRACElevel;
      zinc_(Zonehorizon);
      /* merge distance done in qh_findhorizon */
      apex= SETfirstt_(facet->vertices, vertexT);
      FOREACHvertex_(facet->vertices) {
        if (vertex != apex)
          vertex->delridge= True;
      }
      horizon->f.newcycle= NULL;
      qh_mergefacet(qh, facet, horizon, MRGcoplanarhorizon, NULL, NULL, qh_MERGEapex);
    }else {
      samecycle= facet;
      facets= 0;
      prev= facet;
      for (same= facet->f.samecycle; same;  /* FORALLsame_cycle_(facet) */
           same= (same == facet ? NULL :nextsame)) { /* ends at facet */
        nextsame= same->f.samecycle;
        if (same->cycledone || same->visible)
          qh_infiniteloop(qh, same);
        same->cycledone= True;
        if (same->normal) {
          prev->f.samecycle= same->f.samecycle; /* unlink ->mergeridge */
          same->f.samecycle= NULL;
        }else {
          prev= same;
          facets++;
        }
      }
      while (nextfacet && nextfacet->cycledone)  /* will delete samecycle */
        nextfacet= nextfacet->next;
      horizon->f.newcycle= NULL;
      qh_mergecycle(qh, samecycle, horizon);
      nummerge= horizon->nummerge + facets;
      if (nummerge > qh_MAXnummerge)
        horizon->nummerge= qh_MAXnummerge;
      else
        horizon->nummerge= (short unsigned int)nummerge; /* limited to 9 bits by qh_MAXnummerge, -Wconversion */
      zzinc_(Zcyclehorizon);
      total += facets;
      zzadd_(Zcyclefacettot, facets);
      zmax_(Zcyclefacetmax, facets);
    }
    cycles++;
  }
  if (cycles) {
    FORALLnew_facets {
      /* qh_maybe_duplicateridges postponed since qh_mergecycle_ridges deletes ridges without calling qh_delridge_merge */
      if (newfacet->coplanarhorizon) {
        qh_test_redundant_neighbors(qh, newfacet);
        qh_maybe_duplicateridges(qh, newfacet);
        newfacet->coplanarhorizon= False;
      }
    }
    numdegen += qh_merge_degenredundant(qh);
    *wasmerge= True;
    trace1((qh, qh->ferr, 1013, "qh_mergecycle_all: merged %d same cycles or facets into coplanar horizons and %d degenredundant facets\n",
      cycles, numdegen));
  }
} /* mergecycle_all */

/*---------------------------------

  qh_mergecycle_facets(qh, samecycle, newfacet )
    finish merge of samecycle into newfacet

  returns:
    samecycle prepended to visible_list for later deletion and partitioning
      each facet->f.replace == newfacet

    newfacet moved to end of qh.facet_list
      makes newfacet a newfacet (get's facet1->id if it was old)
      sets newfacet->newmerge
      clears newfacet->center (unless merging into a large facet)
      clears newfacet->tested and ridge->tested for facet1

    adds neighboring facets to facet_mergeset if redundant or degenerate

  design:
    make newfacet a new facet and set its flags
    move samecycle facets to qh.visible_list for later deletion
    unless newfacet is large
      remove its centrum
*/
void qh_mergecycle_facets(qhT *qh, facetT *samecycle, facetT *newfacet) {
  facetT *same, *next;

  trace4((qh, qh->ferr, 4030, "qh_mergecycle_facets: make newfacet new and samecycle deleted\n"));
  qh_removefacet(qh, newfacet);  /* append as a newfacet to end of qh->facet_list */
  qh_appendfacet(qh, newfacet);
  newfacet->newfacet= True;
  newfacet->simplicial= False;
  newfacet->newmerge= True;

  for (same= samecycle->f.samecycle; same; same= (same == samecycle ?  NULL : next)) {
    next= same->f.samecycle;  /* reused by willdelete */
    qh_willdelete(qh, same, newfacet);
  }
  if (newfacet->center
      && qh_setsize(qh, newfacet->vertices) <= qh->hull_dim + qh_MAXnewcentrum) {
    qh_memfree(qh, newfacet->center, qh->normal_size);
    newfacet->center= NULL;
  }
  trace3((qh, qh->ferr, 3004, "qh_mergecycle_facets: merged facets from cycle f%d into f%d\n",
             samecycle->id, newfacet->id));
} /* mergecycle_facets */

/*---------------------------------

  qh_mergecycle_neighbors(qh, samecycle, newfacet )
    add neighbors for samecycle facets to newfacet

  returns:
    newfacet with updated neighbors and vice-versa
    newfacet has ridges
    all neighbors of newfacet marked with qh.visit_id
    samecycle facets marked with qh.visit_id-1
    ridges updated for simplicial neighbors of samecycle with a ridge

  notes:
    assumes newfacet not in samecycle
    usually, samecycle facets are new, simplicial facets without internal ridges
      not so if horizon facet is coplanar to two different samecycles

  see:
    qh_mergeneighbors()

  design:
    check samecycle
    delete neighbors from newfacet that are also in samecycle
    for each neighbor of a facet in samecycle
      if neighbor is simplicial
        if first visit
          move the neighbor relation to newfacet
          update facet links for its ridges
        else
          make ridges for neighbor
          remove samecycle reference
      else
        update neighbor sets
*/
void qh_mergecycle_neighbors(qhT *qh, facetT *samecycle, facetT *newfacet) {
  facetT *same, *neighbor, **neighborp;
  int delneighbors= 0, newneighbors= 0;
  unsigned int samevisitid;
  ridgeT *ridge, **ridgep;

  samevisitid= ++qh->visit_id;
  FORALLsame_cycle_(samecycle) {
    if (same->visitid == samevisitid || same->visible)
      qh_infiniteloop(qh, samecycle);
    same->visitid= samevisitid;
  }
  newfacet->visitid= ++qh->visit_id;
  trace4((qh, qh->ferr, 4031, "qh_mergecycle_neighbors: delete shared neighbors from newfacet\n"));
  FOREACHneighbor_(newfacet) {
    if (neighbor->visitid == samevisitid) {
      SETref_(neighbor)= NULL;  /* samecycle neighbors deleted */
      delneighbors++;
    }else
      neighbor->visitid= qh->visit_id;
  }
  qh_setcompact(qh, newfacet->neighbors);

  trace4((qh, qh->ferr, 4032, "qh_mergecycle_neighbors: update neighbors\n"));
  FORALLsame_cycle_(samecycle) {
    FOREACHneighbor_(same) {
      if (neighbor->visitid == samevisitid)
        continue;
      if (neighbor->simplicial) {
        if (neighbor->visitid != qh->visit_id) {
          qh_setappend(qh, &newfacet->neighbors, neighbor);
          qh_setreplace(qh, neighbor->neighbors, same, newfacet);
          newneighbors++;
          neighbor->visitid= qh->visit_id;
          FOREACHridge_(neighbor->ridges) { /* update ridge in case of qh_makeridges */
            if (ridge->top == same) {
              ridge->top= newfacet;
              break;
            }else if (ridge->bottom == same) {
              ridge->bottom= newfacet;
              break;
            }
          }
        }else {
          qh_makeridges(qh, neighbor);
          qh_setdel(neighbor->neighbors, same);
          /* same can't be horizon facet for neighbor */
        }
      }else { /* non-simplicial neighbor */
        qh_setdel(neighbor->neighbors, same);
        if (neighbor->visitid != qh->visit_id) {
          qh_setappend(qh, &neighbor->neighbors, newfacet);
          qh_setappend(qh, &newfacet->neighbors, neighbor);
          neighbor->visitid= qh->visit_id;
          newneighbors++;
        }
      }
    }
  }
  trace2((qh, qh->ferr, 2032, "qh_mergecycle_neighbors: deleted %d neighbors and added %d\n",
             delneighbors, newneighbors));
} /* mergecycle_neighbors */

/*---------------------------------

  qh_mergecycle_ridges(qh, samecycle, newfacet )
    add ridges/neighbors for facets in samecycle to newfacet
    all new/old neighbors of newfacet marked with qh.visit_id
    facets in samecycle marked with qh.visit_id-1
    newfacet marked with qh.visit_id

  returns:
    newfacet has merged ridges

  notes:
    ridge already updated for simplicial neighbors of samecycle with a ridge
    qh_checkdelridge called by qh_mergecycle

  see:
    qh_mergeridges()
    qh_makeridges()

  design:
    remove ridges between newfacet and samecycle
    for each facet in samecycle
      for each ridge in facet
        update facet pointers in ridge
        skip ridges processed in qh_mergecycle_neighors
        free ridges between newfacet and samecycle
        free ridges between facets of samecycle (on 2nd visit)
        append remaining ridges to newfacet
      if simplicial facet
        for each neighbor of facet
          if simplicial facet
          and not samecycle facet or newfacet
            make ridge between neighbor and newfacet
*/
void qh_mergecycle_ridges(qhT *qh, facetT *samecycle, facetT *newfacet) {
  facetT *same, *neighbor= NULL;
  int numold=0, numnew=0;
  int neighbor_i, neighbor_n;
  unsigned int samevisitid;
  ridgeT *ridge, **ridgep;
  boolT toporient;
  void **freelistp; /* used if !qh_NOmem by qh_memfree_() */

  trace4((qh, qh->ferr, 4033, "qh_mergecycle_ridges: delete shared ridges from newfacet\n"));
  samevisitid= qh->visit_id -1;
  FOREACHridge_(newfacet->ridges) {
    neighbor= otherfacet_(ridge, newfacet);
    if (neighbor->visitid == samevisitid)
      SETref_(ridge)= NULL; /* ridge free'd below */
  }
  qh_setcompact(qh, newfacet->ridges);

  trace4((qh, qh->ferr, 4034, "qh_mergecycle_ridges: add ridges to newfacet\n"));
  FORALLsame_cycle_(samecycle) {
    FOREACHridge_(same->ridges) {
      if (ridge->top == same) {
        ridge->top= newfacet;
        neighbor= ridge->bottom;
      }else if (ridge->bottom == same) {
        ridge->bottom= newfacet;
        neighbor= ridge->top;
      }else if (ridge->top == newfacet || ridge->bottom == newfacet) {
        qh_setappend(qh, &newfacet->ridges, ridge);
        numold++;  /* already set by qh_mergecycle_neighbors */
        continue;
      }else {
        qh_fprintf(qh, qh->ferr, 6098, "qhull internal error (qh_mergecycle_ridges): bad ridge r%d\n", ridge->id);
        qh_errexit(qh, qh_ERRqhull, NULL, ridge);
      }
      if (neighbor == newfacet) {
        if (qh->traceridge == ridge)
          qh->traceridge= NULL;
        qh_setfree(qh, &(ridge->vertices));
        qh_memfree_(qh, ridge, (int)sizeof(ridgeT), freelistp);
        numold++;
      }else if (neighbor->visitid == samevisitid) {
        qh_setdel(neighbor->ridges, ridge);
        if (qh->traceridge == ridge)
          qh->traceridge= NULL;
        qh_setfree(qh, &(ridge->vertices));
        qh_memfree_(qh, ridge, (int)sizeof(ridgeT), freelistp);
        numold++;
      }else {
        qh_setappend(qh, &newfacet->ridges, ridge);
        numold++;
      }
    }
    if (same->ridges)
      qh_settruncate(qh, same->ridges, 0);
    if (!same->simplicial)
      continue;
    FOREACHneighbor_i_(qh, same) {       /* note: !newfact->simplicial */
      if (neighbor->visitid != samevisitid && neighbor->simplicial) {
        ridge= qh_newridge(qh);
        ridge->vertices= qh_setnew_delnthsorted(qh, same->vertices, qh->hull_dim,
                                                          neighbor_i, 0);
        toporient= (boolT)(same->toporient ^ (neighbor_i & 0x1));
        if (toporient) {
          ridge->top= newfacet;
          ridge->bottom= neighbor;
          ridge->simplicialbot= True;
        }else {
          ridge->top= neighbor;
          ridge->bottom= newfacet;
          ridge->simplicialtop= True;
        }
        qh_setappend(qh, &(newfacet->ridges), ridge);
        qh_setappend(qh, &(neighbor->ridges), ridge);
        if (qh->ridge_id == qh->traceridge_id)
          qh->traceridge= ridge;
        numnew++;
      }
    }
  }

  trace2((qh, qh->ferr, 2033, "qh_mergecycle_ridges: found %d old ridges and %d new ones\n",
             numold, numnew));
} /* mergecycle_ridges */

/*---------------------------------

  qh_mergecycle_vneighbors(qh, samecycle, newfacet )
    create vertex neighbors for newfacet from vertices of facets in samecycle
    samecycle marked with visitid == qh.visit_id - 1

  returns:
    newfacet vertices with updated neighbors
    marks newfacet with qh.visit_id-1
    deletes vertices that are merged away
    sets delridge on all vertices (faster here than in mergecycle_ridges)

  see:
    qh_mergevertex_neighbors()

  design:
    for each vertex of samecycle facet
      set vertex->delridge
      delete samecycle facets from vertex neighbors
      append newfacet to vertex neighbors
      if vertex only in newfacet
        delete it from newfacet
        add it to qh.del_vertices for later deletion
*/
void qh_mergecycle_vneighbors(qhT *qh, facetT *samecycle, facetT *newfacet) {
  facetT *neighbor, **neighborp;
  unsigned int mergeid;
  vertexT *vertex, **vertexp, *apex;
  setT *vertices;

  trace4((qh, qh->ferr, 4035, "qh_mergecycle_vneighbors: update vertex neighbors for newfacet\n"));
  mergeid= qh->visit_id - 1;
  newfacet->visitid= mergeid;
  vertices= qh_basevertices(qh, samecycle); /* temp */
  apex= SETfirstt_(samecycle->vertices, vertexT);
  qh_setappend(qh, &vertices, apex);
  FOREACHvertex_(vertices) {
    vertex->delridge= True;
    FOREACHneighbor_(vertex) {
      if (neighbor->visitid == mergeid)
        SETref_(neighbor)= NULL;
    }
    qh_setcompact(qh, vertex->neighbors);
    qh_setappend(qh, &vertex->neighbors, newfacet);
    if (!SETsecond_(vertex->neighbors)) {
      zinc_(Zcyclevertex);
      trace2((qh, qh->ferr, 2034, "qh_mergecycle_vneighbors: deleted v%d when merging cycle f%d into f%d\n",
        vertex->id, samecycle->id, newfacet->id));
      qh_setdelsorted(newfacet->vertices, vertex);
      vertex->deleted= True;
      qh_setappend(qh, &qh->del_vertices, vertex);
    }
  }
  qh_settempfree(qh, &vertices);
  trace3((qh, qh->ferr, 3005, "qh_mergecycle_vneighbors: merged vertices from cycle f%d into f%d\n",
             samecycle->id, newfacet->id));
} /* mergecycle_vneighbors */

/*---------------------------------

  qh_mergefacet(qh, facet1, facet2, mergetype, mindist, maxdist, mergeapex )
    merges facet1 into facet2
    mergeapex==qh_MERGEapex if merging new facet into coplanar horizon (optimizes qh_mergesimplex)

  returns:
    qh.max_outside and qh.min_vertex updated
    initializes vertex neighbors on first merge

  note:
    mergetype only used for logging and error reporting

  returns:
    facet2 contains facet1's vertices, neighbors, and ridges
      facet2 moved to end of qh.facet_list
      makes facet2 a newfacet
      sets facet2->newmerge set
      clears facet2->center (unless merging into a large facet)
      clears facet2->tested and ridge->tested for facet1

    facet1 prepended to visible_list for later deletion and partitioning
      facet1->f.replace == facet2

    adds neighboring facets to facet_mergeset if redundant or degenerate

  notes:
    when done, tests facet1 and facet2 for degenerate or redundant neighbors and dupridges
    mindist/maxdist may be NULL (only if both NULL)
    traces merge if fmax_(maxdist,-mindist) > TRACEdist

  see:
    qh_mergecycle()

  design:
    trace merge and check for degenerate simplex
    make ridges for both facets
    update qh.max_outside, qh.max_vertex, qh.min_vertex
    update facet2->maxoutside and keepcentrum
    update facet2->nummerge
    update tested flags for facet2
    if facet1 is simplicial
      merge facet1 into facet2
    else
      merge facet1's neighbors into facet2
      merge facet1's ridges into facet2
      merge facet1's vertices into facet2
      merge facet1's vertex neighbors into facet2
      add facet2's vertices to qh.new_vertexlist
    move facet2 to end of qh.newfacet_list
    unless MRGcoplanarhorizon
      test facet2 for redundant neighbors
      test facet1 for degenerate neighbors
      test for redundant facet2
      maybe test for duplicate ridges ('Q15')
    move facet1 to qh.visible_list for later deletion
*/
void qh_mergefacet(qhT *qh, facetT *facet1, facetT *facet2, mergeType mergetype, realT *mindist, realT *maxdist, boolT mergeapex) {
  boolT traceonce= False;
  vertexT *vertex, **vertexp;
  realT mintwisted, vertexdist;
  realT onemerge;
  int tracerestore=0, nummerge;
  const char *mergename;

  if(mergetype > 0 && mergetype < sizeof(mergetypes)/sizeof(char *))
    mergename= mergetypes[mergetype];
  else
    mergename= mergetypes[MRGnone];
  if (facet1->tricoplanar || facet2->tricoplanar) {
    if (!qh->TRInormals) {
      qh_fprintf(qh, qh->ferr, 6226, "qhull internal error (qh_mergefacet): merge f%d into f%d for mergetype %d (%s) does not work for tricoplanar facets.  Use option 'Q11'\n",
        facet1->id, facet2->id, mergetype, mergename);
      qh_errexit2(qh, qh_ERRqhull, facet1, facet2);
    }
    if (facet2->tricoplanar) {
      facet2->tricoplanar= False;
      facet2->keepcentrum= False;
    }
  }
  zzinc_(Ztotmerge);
  if (qh->REPORTfreq2 && qh->POSTmerging) {
    if (zzval_(Ztotmerge) > qh->mergereport + qh->REPORTfreq2)
      qh_tracemerging(qh);
  }
#ifndef qh_NOtrace
  if (qh->build_cnt >= qh->RERUN) {
    if (mindist && (-*mindist > qh->TRACEdist || *maxdist > qh->TRACEdist)) {
      tracerestore= 0;
      qh->IStracing= qh->TRACElevel;
      traceonce= True;
      qh_fprintf(qh, qh->ferr, 8075, "qh_mergefacet: ========= trace wide merge #%d(%2.2g) for f%d into f%d for mergetype %d (%s), last point was p%d\n",
          zzval_(Ztotmerge), fmax_(-*mindist, *maxdist), facet1->id, facet2->id, mergetype, mergename, qh->furthest_id);
    }else if (facet1 == qh->tracefacet || facet2 == qh->tracefacet) {
      tracerestore= qh->IStracing;
      qh->IStracing= 4;
      traceonce= True;
      qh_fprintf(qh, qh->ferr, 8076, "qh_mergefacet: ========= trace merge #%d for f%d into f%d for mergetype %d (%s), furthest is p%d\n",
                 zzval_(Ztotmerge), facet1->id, facet2->id, mergetype, mergename, qh->furthest_id);
    }
  }
  if (qh->IStracing >= 2) {
    realT mergemin= -2;
    realT mergemax= -2;

    if (mindist) {
      mergemin= *mindist;
      mergemax= *maxdist;
    }
    qh_fprintf(qh, qh->ferr, 2081, "qh_mergefacet: #%d merge f%d into f%d for merge for mergetype %d (%s), mindist= %2.2g, maxdist= %2.2g, max_outside %2.2g\n",
    zzval_(Ztotmerge), facet1->id, facet2->id, mergetype, mergename, mergemin, mergemax, qh->max_outside);
  }
#endif /* !qh_NOtrace */
  if(!qh->ALLOWwide && mindist) {
    mintwisted= qh_WIDEmaxoutside * qh->ONEmerge;  /* same as qh_merge_twisted and qh_check_maxout (poly2) */
    maximize_(mintwisted, facet1->maxoutside);
    maximize_(mintwisted, facet2->maxoutside);
    if (*maxdist > mintwisted || -*mindist > mintwisted) {
      vertexdist= qh_vertex_bestdist(qh, facet1->vertices);
      onemerge= qh->ONEmerge + qh->DISTround;
      if (vertexdist > mintwisted) {
        qh_fprintf(qh, qh->ferr, 6347, "qhull precision error (qh_mergefacet): wide merge for facet f%d into f%d for mergetype %d (%s).  maxdist %2.2g (%.1fx) mindist %2.2g (%.1fx) vertexdist %2.2g  Allow with 'Q12' (allow-wide)\n",
          facet1->id, facet2->id, mergetype, mergename, *maxdist, *maxdist/onemerge, *mindist, -*mindist/onemerge, vertexdist);
      }else {
        qh_fprintf(qh, qh->ferr, 6348, "qhull precision error (qh_mergefacet): wide merge for pinched facet f%d into f%d for mergetype %d (%s).  maxdist %2.2g (%.fx) mindist %2.2g (%.1fx) vertexdist %2.2g  Allow with 'Q12' (allow-wide)\n",
          facet1->id, facet2->id, mergetype, mergename, *maxdist, *maxdist/onemerge, *mindist, -*mindist/onemerge, vertexdist);
      }
      qh_errexit2(qh, qh_ERRwide, facet1, facet2);
    }
  }
  if (facet1 == facet2 || facet1->visible || facet2->visible) {
    qh_fprintf(qh, qh->ferr, 6099, "qhull internal error (qh_mergefacet): either f%d and f%d are the same or one is a visible facet, mergetype %d (%s)\n",
             facet1->id, facet2->id, mergetype, mergename);
    qh_errexit2(qh, qh_ERRqhull, facet1, facet2);
  }
  if (qh->num_facets - qh->num_visible <= qh->hull_dim + 1) {
    qh_fprintf(qh, qh->ferr, 6227, "qhull topology error: Only %d facets remain.  The input is too degenerate or the convexity constraints are too strong.\n", 
          qh->hull_dim+1);
    if (qh->hull_dim >= 5 && !qh->MERGEexact)
      qh_fprintf(qh, qh->ferr, 8079, "    Option 'Qx' may avoid this problem.\n");
    qh_errexit(qh, qh_ERRtopology, NULL, NULL);
  }
  if (!qh->VERTEXneighbors)
    qh_vertexneighbors(qh);
  qh_makeridges(qh, facet1);
  qh_makeridges(qh, facet2);
  if (qh->IStracing >=4)
    qh_errprint(qh, "MERGING", facet1, facet2, NULL, NULL);
  if (mindist) {
    maximize_(qh->max_outside, *maxdist);
    maximize_(qh->max_vertex, *maxdist);
#if qh_MAXoutside
    maximize_(facet2->maxoutside, *maxdist);
#endif
    minimize_(qh->min_vertex, *mindist);
    if (!facet2->keepcentrum
    && (*maxdist > qh->WIDEfacet || *mindist < -qh->WIDEfacet)) {
      facet2->keepcentrum= True;
      zinc_(Zwidefacet);
    }
  }
  nummerge= facet1->nummerge + facet2->nummerge + 1;
  if (nummerge >= qh_MAXnummerge)
    facet2->nummerge= qh_MAXnummerge;
  else
    facet2->nummerge= (short unsigned int)nummerge; /* limited to 9 bits by qh_MAXnummerge, -Wconversion */
  facet2->newmerge= True;
  facet2->dupridge= False;
  qh_updatetested(qh, facet1, facet2);
  if (qh->hull_dim > 2 && qh_setsize(qh, facet1->vertices) == qh->hull_dim)
    qh_mergesimplex(qh, facet1, facet2, mergeapex);
  else {
    qh->vertex_visit++;
    FOREACHvertex_(facet2->vertices)
      vertex->visitid= qh->vertex_visit;
    if (qh->hull_dim == 2)
      qh_mergefacet2d(qh, facet1, facet2);
    else {
      qh_mergeneighbors(qh, facet1, facet2);
      qh_mergevertices(qh, facet1->vertices, &facet2->vertices);
    }
    qh_mergeridges(qh, facet1, facet2);
    qh_mergevertex_neighbors(qh, facet1, facet2);
    if (!facet2->newfacet)
      qh_newvertices(qh, facet2->vertices);
  }
  if (facet2->coplanarhorizon) {
    zinc_(Zmergeintocoplanar);
  }else if (!facet2->newfacet) {
    zinc_(Zmergeintohorizon);
  }else if (!facet1->newfacet && facet2->newfacet) {
    zinc_(Zmergehorizon);
  }else {
    zinc_(Zmergenew);
  }
  qh_removefacet(qh, facet2);  /* append as a newfacet to end of qh->facet_list */
  qh_appendfacet(qh, facet2);
  facet2->newfacet= True;
  facet2->tested= False;
  qh_tracemerge(qh, facet1, facet2, mergetype);
  if (traceonce) {
    qh_fprintf(qh, qh->ferr, 8080, "qh_mergefacet: end of wide tracing\n");
    qh->IStracing= tracerestore;
  }
  if (mergetype != MRGcoplanarhorizon) {
    trace3((qh, qh->ferr, 3076, "qh_mergefacet: check f%d and f%d for redundant and degenerate neighbors\n",
        facet1->id, facet2->id));
    qh_test_redundant_neighbors(qh, facet2);
    qh_test_degen_neighbors(qh, facet1);  /* after qh_test_redundant_neighbors since MRGdegen more difficult than MRGredundant
                                             and before qh_willdelete which clears facet1.neighbors */
    qh_degen_redundant_facet(qh, facet2); /* may occur in qh_merge_pinchedvertices, e.g., rbox 175 C3,2e-13 D4 t1545228104 | qhull d */
    qh_maybe_duplicateridges(qh, facet2);
  }
  qh_willdelete(qh, facet1, facet2);
} /* mergefacet */


/*---------------------------------

  qh_mergefacet2d(qh, facet1, facet2 )
    in 2d, merges neighbors and vertices of facet1 into facet2

  returns:
    build ridges for neighbors if necessary
    facet2 looks like a simplicial facet except for centrum, ridges
      neighbors are opposite the corresponding vertex
      maintains orientation of facet2

  notes:
    qh_mergefacet() retains non-simplicial structures
      they are not needed in 2d, but later routines may use them
    preserves qh.vertex_visit for qh_mergevertex_neighbors()

  design:
    get vertices and neighbors
    determine new vertices and neighbors
    set new vertices and neighbors and adjust orientation
    make ridges for new neighbor if needed
*/
void qh_mergefacet2d(qhT *qh, facetT *facet1, facetT *facet2) {
  vertexT *vertex1A, *vertex1B, *vertex2A, *vertex2B, *vertexA, *vertexB;
  facetT *neighbor1A, *neighbor1B, *neighbor2A, *neighbor2B, *neighborA, *neighborB;

  vertex1A= SETfirstt_(facet1->vertices, vertexT);
  vertex1B= SETsecondt_(facet1->vertices, vertexT);
  vertex2A= SETfirstt_(facet2->vertices, vertexT);
  vertex2B= SETsecondt_(facet2->vertices, vertexT);
  neighbor1A= SETfirstt_(facet1->neighbors, facetT);
  neighbor1B= SETsecondt_(facet1->neighbors, facetT);
  neighbor2A= SETfirstt_(facet2->neighbors, facetT);
  neighbor2B= SETsecondt_(facet2->neighbors, facetT);
  if (vertex1A == vertex2A) {
    vertexA= vertex1B;
    vertexB= vertex2B;
    neighborA= neighbor2A;
    neighborB= neighbor1A;
  }else if (vertex1A == vertex2B) {
    vertexA= vertex1B;
    vertexB= vertex2A;
    neighborA= neighbor2B;
    neighborB= neighbor1A;
  }else if (vertex1B == vertex2A) {
    vertexA= vertex1A;
    vertexB= vertex2B;
    neighborA= neighbor2A;
    neighborB= neighbor1B;
  }else { /* 1B == 2B */
    vertexA= vertex1A;
    vertexB= vertex2A;
    neighborA= neighbor2B;
    neighborB= neighbor1B;
  }
  /* vertexB always from facet2, neighborB always from facet1 */
  if (vertexA->id > vertexB->id) {
    SETfirst_(facet2->vertices)= vertexA;
    SETsecond_(facet2->vertices)= vertexB;
    if (vertexB == vertex2A)
      facet2->toporient= !facet2->toporient;
    SETfirst_(facet2->neighbors)= neighborA;
    SETsecond_(facet2->neighbors)= neighborB;
  }else {
    SETfirst_(facet2->vertices)= vertexB;
    SETsecond_(facet2->vertices)= vertexA;
    if (vertexB == vertex2B)
      facet2->toporient= !facet2->toporient;
    SETfirst_(facet2->neighbors)= neighborB;
    SETsecond_(facet2->neighbors)= neighborA;
  }
  /* qh_makeridges not needed since neighborB is not degenerate */
  qh_setreplace(qh, neighborB->neighbors, facet1, facet2);
  trace4((qh, qh->ferr, 4036, "qh_mergefacet2d: merged v%d and neighbor f%d of f%d into f%d\n",
       vertexA->id, neighborB->id, facet1->id, facet2->id));
} /* mergefacet2d */


/*---------------------------------

  qh_mergeneighbors(qh, facet1, facet2 )
    merges the neighbors of facet1 into facet2

  notes:
    only called by qh_mergefacet
    qh.hull_dim >= 3
    see qh_mergecycle_neighbors

  design:
    for each neighbor of facet1
      if neighbor is also a neighbor of facet2
        if neighbor is simplicial
          make ridges for later deletion as a degenerate facet
        update its neighbor set
      else
        move the neighbor relation to facet2
    remove the neighbor relation for facet1 and facet2
*/
void qh_mergeneighbors(qhT *qh, facetT *facet1, facetT *facet2) {
  facetT *neighbor, **neighborp;

  trace4((qh, qh->ferr, 4037, "qh_mergeneighbors: merge neighbors of f%d and f%d\n",
          facet1->id, facet2->id));
  qh->visit_id++;
  FOREACHneighbor_(facet2) {
    neighbor->visitid= qh->visit_id;
  }
  FOREACHneighbor_(facet1) {
    if (neighbor->visitid == qh->visit_id) {
      if (neighbor->simplicial)    /* is degen, needs ridges */
        qh_makeridges(qh, neighbor);
      if (SETfirstt_(neighbor->neighbors, facetT) != facet1) /*keep newfacet->horizon*/
        qh_setdel(neighbor->neighbors, facet1);
      else {
        qh_setdel(neighbor->neighbors, facet2);
        qh_setreplace(qh, neighbor->neighbors, facet1, facet2);
      }
    }else if (neighbor != facet2) {
      qh_setappend(qh, &(facet2->neighbors), neighbor);
      qh_setreplace(qh, neighbor->neighbors, facet1, facet2);
    }
  }
  qh_setdel(facet1->neighbors, facet2);  /* here for makeridges */
  qh_setdel(facet2->neighbors, facet1);
} /* mergeneighbors */


/*---------------------------------

  qh_mergeridges(qh, facet1, facet2 )
    merges the ridge set of facet1 into facet2

  returns:
    may delete all ridges for a vertex
    sets vertex->delridge on deleted ridges

  see:
    qh_mergecycle_ridges()

  design:
    delete ridges between facet1 and facet2
      mark (delridge) vertices on these ridges for later testing
    for each remaining ridge
      rename facet1 to facet2
*/
void qh_mergeridges(qhT *qh, facetT *facet1, facetT *facet2) {
  ridgeT *ridge, **ridgep;

  trace4((qh, qh->ferr, 4038, "qh_mergeridges: merge ridges of f%d into f%d\n",
          facet1->id, facet2->id));
  FOREACHridge_(facet2->ridges) {
    if ((ridge->top == facet1) || (ridge->bottom == facet1)) {
      /* ridge.nonconvex is irrelevant due to merge */
      qh_delridge_merge(qh, ridge);  /* expensive in high-d, could rebuild */
      ridgep--; /* deleted this ridge, repeat with next ridge*/
    }
  }
  FOREACHridge_(facet1->ridges) {
    if (ridge->top == facet1) {
      ridge->top= facet2;
      ridge->simplicialtop= False;
    }else { /* ridge.bottom is facet1 */
      ridge->bottom= facet2;
      ridge->simplicialbot= False;
    }
    qh_setappend(qh, &(facet2->ridges), ridge);
  }
} /* mergeridges */


/*---------------------------------

  qh_mergesimplex(qh, facet1, facet2, mergeapex )
    merge simplicial facet1 into facet2
    mergeapex==qh_MERGEapex if merging samecycle into horizon facet
      vertex id is latest (most recently created)
    facet1 may be contained in facet2
    ridges exist for both facets

  returns:
    facet2 with updated vertices, ridges, neighbors
    updated neighbors for facet1's vertices
    facet1 not deleted
    sets vertex->delridge on deleted ridges

  notes:
    special case code since this is the most common merge
    called from qh_mergefacet()

  design:
    if qh_MERGEapex
      add vertices of facet2 to qh.new_vertexlist if necessary
      add apex to facet2
    else
      for each ridge between facet1 and facet2
        set vertex->delridge
      determine the apex for facet1 (i.e., vertex to be merged)
      unless apex already in facet2
        insert apex into vertices for facet2
      add vertices of facet2 to qh.new_vertexlist if necessary
      add apex to qh.new_vertexlist if necessary
      for each vertex of facet1
        if apex
          rename facet1 to facet2 in its vertex neighbors
        else
          delete facet1 from vertex neighbors
          if only in facet2
            add vertex to qh.del_vertices for later deletion
      for each ridge of facet1
        delete ridges between facet1 and facet2
        append other ridges to facet2 after renaming facet to facet2
*/
void qh_mergesimplex(qhT *qh, facetT *facet1, facetT *facet2, boolT mergeapex) {
  vertexT *vertex, **vertexp, *opposite;
  ridgeT *ridge, **ridgep;
  boolT isnew= False;
  facetT *neighbor, **neighborp, *otherfacet;

  if (mergeapex) {
    opposite= SETfirstt_(facet1->vertices, vertexT); /* apex is opposite facet2.  It has the last vertex id */
    trace4((qh, qh->ferr, 4086, "qh_mergesimplex: merge apex v%d of f%d into facet f%d\n",
      opposite->id, facet1->id, facet2->id));
    if (!facet2->newfacet)
      qh_newvertices(qh, facet2->vertices);  /* apex, the first vertex, is already new */
    if (SETfirstt_(facet2->vertices, vertexT) != opposite) {
      qh_setaddnth(qh, &facet2->vertices, 0, opposite);
      isnew= True;
    }
  }else {
    zinc_(Zmergesimplex);
    FOREACHvertex_(facet1->vertices)
      vertex->seen= False;
    FOREACHridge_(facet1->ridges) {
      if (otherfacet_(ridge, facet1) == facet2) {
        FOREACHvertex_(ridge->vertices) {
          vertex->seen= True;
          vertex->delridge= True;
        }
        break;
      }
    }
    FOREACHvertex_(facet1->vertices) {
      if (!vertex->seen)
        break;  /* must occur */
    }
    opposite= vertex;
    trace4((qh, qh->ferr, 4039, "qh_mergesimplex: merge opposite v%d of f%d into facet f%d\n",
          opposite->id, facet1->id, facet2->id));
    isnew= qh_addfacetvertex(qh, facet2, opposite);
    if (!facet2->newfacet)
      qh_newvertices(qh, facet2->vertices);
    else if (!opposite->newfacet) {
      qh_removevertex(qh, opposite);
      qh_appendvertex(qh, opposite);
    }
  }
  trace4((qh, qh->ferr, 4040, "qh_mergesimplex: update vertex neighbors of f%d\n",
          facet1->id));
  FOREACHvertex_(facet1->vertices) {
    if (vertex == opposite && isnew)
      qh_setreplace(qh, vertex->neighbors, facet1, facet2);
    else {
      qh_setdel(vertex->neighbors, facet1);
      if (!SETsecond_(vertex->neighbors))
        qh_mergevertex_del(qh, vertex, facet1, facet2);
    }
  }
  trace4((qh, qh->ferr, 4041, "qh_mergesimplex: merge ridges and neighbors of f%d into f%d\n",
          facet1->id, facet2->id));
  qh->visit_id++;
  FOREACHneighbor_(facet2)
    neighbor->visitid= qh->visit_id;
  FOREACHridge_(facet1->ridges) {
    otherfacet= otherfacet_(ridge, facet1);
    if (otherfacet == facet2) {
      /* ridge.nonconvex is irrelevant due to merge */
      qh_delridge_merge(qh, ridge);  /* expensive in high-d, could rebuild */
      ridgep--; /* deleted this ridge, repeat with next ridge*/
      qh_setdel(facet2->neighbors, facet1); /* a simplicial facet may have duplicate neighbors, need to delete each one */
    }else if (otherfacet->dupridge && !qh_setin(otherfacet->neighbors, facet1)) {
      qh_fprintf(qh, qh->ferr, 6356, "qhull topology error (qh_mergesimplex): f%d is a dupridge of f%d, cannot merge f%d into f%d\n",
        facet1->id, otherfacet->id, facet1->id, facet2->id);
      qh_errexit2(qh, qh_ERRqhull, facet1, otherfacet);
    }else {
      trace4((qh, qh->ferr, 4059, "qh_mergesimplex: move r%d with f%d to f%d, new neighbor? %d, maybe horizon? %d\n",
        ridge->id, otherfacet->id, facet2->id, (otherfacet->visitid != qh->visit_id), (SETfirstt_(otherfacet->neighbors, facetT) == facet1)));
      qh_setappend(qh, &facet2->ridges, ridge);
      if (otherfacet->visitid != qh->visit_id) {
        qh_setappend(qh, &facet2->neighbors, otherfacet);
        qh_setreplace(qh, otherfacet->neighbors, facet1, facet2);
        otherfacet->visitid= qh->visit_id;
      }else {
        if (otherfacet->simplicial)    /* is degen, needs ridges */
          qh_makeridges(qh, otherfacet);
        if (SETfirstt_(otherfacet->neighbors, facetT) == facet1) {
          /* keep new, otherfacet->neighbors->horizon */
          qh_setdel(otherfacet->neighbors, facet2);
          qh_setreplace(qh, otherfacet->neighbors, facet1, facet2);
        }else {
          /* facet2 is already a neighbor of otherfacet, by f.visitid */
          qh_setdel(otherfacet->neighbors, facet1);
        }
      }
      if (ridge->top == facet1) { /* wait until after qh_makeridges */
        ridge->top= facet2;
        ridge->simplicialtop= False;
      }else {
        ridge->bottom= facet2;
        ridge->simplicialbot= False;
      }
    }
  }
  trace3((qh, qh->ferr, 3006, "qh_mergesimplex: merged simplex f%d v%d into facet f%d\n",
          facet1->id, opposite->id, facet2->id));
} /* mergesimplex */

/*---------------------------------

  qh_mergevertex_del(qh, vertex, facet1, facet2 )
    delete a vertex because of merging facet1 into facet2

  returns:
    deletes vertex from facet2
    adds vertex to qh.del_vertices for later deletion
*/
void qh_mergevertex_del(qhT *qh, vertexT *vertex, facetT *facet1, facetT *facet2) {

  zinc_(Zmergevertex);
  trace2((qh, qh->ferr, 2035, "qh_mergevertex_del: deleted v%d when merging f%d into f%d\n",
          vertex->id, facet1->id, facet2->id));
  qh_setdelsorted(facet2->vertices, vertex);
  vertex->deleted= True;
  qh_setappend(qh, &qh->del_vertices, vertex);
} /* mergevertex_del */

/*---------------------------------

  qh_mergevertex_neighbors(qh, facet1, facet2 )
    merge the vertex neighbors of facet1 to facet2

  returns:
    if vertex is current qh.vertex_visit
      deletes facet1 from vertex->neighbors
    else
      renames facet1 to facet2 in vertex->neighbors
    deletes vertices if only one neighbor

  notes:
    assumes vertex neighbor sets are good
*/
void qh_mergevertex_neighbors(qhT *qh, facetT *facet1, facetT *facet2) {
  vertexT *vertex, **vertexp;

  trace4((qh, qh->ferr, 4042, "qh_mergevertex_neighbors: merge vertex neighborset for f%d into f%d\n",
          facet1->id, facet2->id));
  if (qh->tracevertex) {
    qh_fprintf(qh, qh->ferr, 8081, "qh_mergevertex_neighbors: of f%d into f%d at furthest p%d f0= %p\n",
             facet1->id, facet2->id, qh->furthest_id, qh->tracevertex->neighbors->e[0].p);
    qh_errprint(qh, "TRACE", NULL, NULL, NULL, qh->tracevertex);
  }
  FOREACHvertex_(facet1->vertices) {
    if (vertex->visitid != qh->vertex_visit)
      qh_setreplace(qh, vertex->neighbors, facet1, facet2);
    else {
      qh_setdel(vertex->neighbors, facet1);
      if (!SETsecond_(vertex->neighbors))
        qh_mergevertex_del(qh, vertex, facet1, facet2);
    }
  }
  if (qh->tracevertex)
    qh_errprint(qh, "TRACE", NULL, NULL, NULL, qh->tracevertex);
} /* mergevertex_neighbors */


/*---------------------------------

  qh_mergevertices(qh, vertices1, vertices2 )
    merges the vertex set of facet1 into facet2

  returns:
    replaces vertices2 with merged set
    preserves vertex_visit for qh_mergevertex_neighbors
    updates qh.newvertex_list

  design:
    create a merged set of both vertices (in inverse id order)
*/
void qh_mergevertices(qhT *qh, setT *vertices1, setT **vertices2) {
  int newsize= qh_setsize(qh, vertices1)+qh_setsize(qh, *vertices2) - qh->hull_dim + 1;
  setT *mergedvertices;
  vertexT *vertex, **vertexp, **vertex2= SETaddr_(*vertices2, vertexT);

  mergedvertices= qh_settemp(qh, newsize);
  FOREACHvertex_(vertices1) {
    if (!*vertex2 || vertex->id > (*vertex2)->id)
      qh_setappend(qh, &mergedvertices, vertex);
    else {
      while (*vertex2 && (*vertex2)->id > vertex->id)
        qh_setappend(qh, &mergedvertices, *vertex2++);
      if (!*vertex2 || (*vertex2)->id < vertex->id)
        qh_setappend(qh, &mergedvertices, vertex);
      else
        qh_setappend(qh, &mergedvertices, *vertex2++);
    }
  }
  while (*vertex2)
    qh_setappend(qh, &mergedvertices, *vertex2++);
  if (newsize < qh_setsize(qh, mergedvertices)) {
    qh_fprintf(qh, qh->ferr, 6100, "qhull internal error (qh_mergevertices): facets did not share a ridge\n");
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  qh_setfree(qh, vertices2);
  *vertices2= mergedvertices;
  qh_settemppop(qh);
} /* mergevertices */


/*---------------------------------

  qh_neighbor_intersections(qh, vertex )
    return intersection of all vertices in vertex->neighbors except for vertex

  returns:
    returns temporary set of vertices
    does not include vertex
    NULL if a neighbor is simplicial
    NULL if empty set

  notes:
    only called by qh_redundant_vertex for qh_reducevertices
      so f.vertices does not contain extraneous vertices that are not in f.ridges
    used for renaming vertices

  design:
    initialize the intersection set with vertices of the first two neighbors
    delete vertex from the intersection
    for each remaining neighbor
      intersect its vertex set with the intersection set
      return NULL if empty
    return the intersection set
*/
setT *qh_neighbor_intersections(qhT *qh, vertexT *vertex) {
  facetT *neighbor, **neighborp, *neighborA, *neighborB;
  setT *intersect;
  int neighbor_i, neighbor_n;

  FOREACHneighbor_(vertex) {
    if (neighbor->simplicial)
      return NULL;
  }
  neighborA= SETfirstt_(vertex->neighbors, facetT);
  neighborB= SETsecondt_(vertex->neighbors, facetT);
  zinc_(Zintersectnum);
  if (!neighborA)
    return NULL;
  if (!neighborB)
    intersect= qh_setcopy(qh, neighborA->vertices, 0);
  else
    intersect= qh_vertexintersect_new(qh, neighborA->vertices, neighborB->vertices);
  qh_settemppush(qh, intersect);
  qh_setdelsorted(intersect, vertex);
  FOREACHneighbor_i_(qh, vertex) {
    if (neighbor_i >= 2) {
      zinc_(Zintersectnum);
      qh_vertexintersect(qh, &intersect, neighbor->vertices);
      if (!SETfirst_(intersect)) {
        zinc_(Zintersectfail);
        qh_settempfree(qh, &intersect);
        return NULL;
      }
    }
  }
  trace3((qh, qh->ferr, 3007, "qh_neighbor_intersections: %d vertices in neighbor intersection of v%d\n",
          qh_setsize(qh, intersect), vertex->id));
  return intersect;
} /* neighbor_intersections */

/*---------------------------------

  qh_neighbor_vertices(qh, vertex )
    return neighboring vertices for a vertex (not in subridge)
    assumes vertices have full vertex->neighbors

  returns:
    temporary set of vertices

  notes:
    updates qh.visit_id and qh.vertex_visit
    similar to qh_vertexridges

*/
setT *qh_neighbor_vertices(qhT *qh, vertexT *vertexA, setT *subridge) {
  facetT *neighbor, **neighborp;
  vertexT *vertex, **vertexp;
  setT *vertices= qh_settemp(qh, qh->TEMPsize);

  qh->visit_id++;
  FOREACHneighbor_(vertexA)
    neighbor->visitid= qh->visit_id;
  qh->vertex_visit++;
  vertexA->visitid= qh->vertex_visit;
  FOREACHvertex_(subridge) {
    vertex->visitid= qh->vertex_visit;
  }
  FOREACHneighbor_(vertexA) {
    if (*neighborp)   /* no new ridges in last neighbor */
      qh_neighbor_vertices_facet(qh, vertexA, neighbor, &vertices);
  }
  trace3((qh, qh->ferr, 3035, "qh_neighbor_vertices: %d non-subridge, vertex neighbors for v%d\n",
    qh_setsize(qh, vertices), vertexA->id));
  return vertices;
} /* neighbor_vertices */

/*---------------------------------

  qh_neighbor_vertices_facet(qh, vertex, facet, vertices )
    add neighboring vertices on ridges for vertex in facet
    neighbor->visitid==qh.visit_id if it hasn't been visited
    v.visitid==qh.vertex_visit if it is already in vertices

  returns:
    vertices updated
    sets facet->visitid to qh.visit_id-1

  notes:
    only called by qh_neighbor_vertices
    similar to qh_vertexridges_facet

  design:
    for each ridge of facet
      if ridge of visited neighbor (i.e., unprocessed)
        if vertex in ridge
          append unprocessed vertices of ridge
    mark facet processed
*/
void qh_neighbor_vertices_facet(qhT *qh, vertexT *vertexA, facetT *facet, setT **vertices) {
  ridgeT *ridge, **ridgep;
  facetT *neighbor;
  vertexT *second, *last, *vertex, **vertexp;
  int last_i= qh->hull_dim-2, count= 0;
  boolT isridge;

  if (facet->simplicial) {
    FOREACHvertex_(facet->vertices) {
      if (vertex->visitid != qh->vertex_visit) {
        vertex->visitid= qh->vertex_visit;
        qh_setappend(qh, vertices, vertex);
        count++;
      }
    }
  }else {
    FOREACHridge_(facet->ridges) {
      neighbor= otherfacet_(ridge, facet);
      if (neighbor->visitid == qh->visit_id) {
        isridge= False;
        if (SETfirst_(ridge->vertices) == vertexA) {
          isridge= True;
        }else if (last_i > 2) {
          second= SETsecondt_(ridge->vertices, vertexT);
          last= SETelemt_(ridge->vertices, last_i, vertexT);
          if (second->id >= vertexA->id && last->id <= vertexA->id) { /* vertices inverse sorted by id */
            if (second == vertexA || last == vertexA)
              isridge= True;
            else if (qh_setin(ridge->vertices, vertexA))
              isridge= True;
          }
        }else if (SETelem_(ridge->vertices, last_i) == vertexA) {
          isridge= True;
        }else if (last_i > 1 && SETsecond_(ridge->vertices) == vertexA) {
          isridge= True;
        }
        if (isridge) {
          FOREACHvertex_(ridge->vertices) {
            if (vertex->visitid != qh->vertex_visit) {
              vertex->visitid= qh->vertex_visit;
              qh_setappend(qh, vertices, vertex);
              count++;
            }
          }
        }
      }
    }
  }
  facet->visitid= qh->visit_id-1;
  if (count) {
    trace4((qh, qh->ferr, 4079, "qh_neighbor_vertices_facet: found %d vertex neighbors for v%d in f%d (simplicial? %d)\n",
      count, vertexA->id, facet->id, facet->simplicial));
  }
} /* neighbor_vertices_facet */


/*---------------------------------

  qh_newvertices(qh, vertices )
    add vertices to end of qh.vertex_list (marks as new vertices)

  returns:
    vertices on qh.newvertex_list
    vertex->newfacet set
*/
void qh_newvertices(qhT *qh, setT *vertices) {
  vertexT *vertex, **vertexp;

  FOREACHvertex_(vertices) {
    if (!vertex->newfacet) {
      qh_removevertex(qh, vertex);
      qh_appendvertex(qh, vertex);
    }
  }
} /* newvertices */

/*---------------------------------

  qh_next_vertexmerge(qh )
    return next vertex merge from qh.vertex_mergeset

  returns:
    vertex merge either MRGvertices or MRGsubridge
    drops merges of deleted vertices

  notes:
    called from qh_merge_pinchedvertices
*/
mergeT *qh_next_vertexmerge(qhT *qh /* qh.vertex_mergeset */) {
  mergeT *merge;
  int merge_i, merge_n, best_i= -1;
  realT bestdist= REALmax;

  FOREACHmerge_i_(qh, qh->vertex_mergeset) {
    if (!merge->vertex1 || !merge->vertex2) {
      qh_fprintf(qh, qh->ferr, 6299, "qhull internal error (qh_next_vertexmerge): expecting two vertices for vertex merge.  Got v%d v%d and optional f%d\n",
        getid_(merge->vertex1), getid_(merge->vertex2), getid_(merge->facet1));
      qh_errexit(qh, qh_ERRqhull, merge->facet1, NULL);
    }
    if (merge->vertex1->deleted || merge->vertex2->deleted) {
      trace3((qh, qh->ferr, 3030, "qh_next_vertexmerge: drop merge of v%d (del? %d) into v%d (del? %d) due to deleted vertex of r%d and r%d\n",
        merge->vertex1->id, merge->vertex1->deleted, merge->vertex2->id, merge->vertex2->deleted, getid_(merge->ridge1), getid_(merge->ridge2)));
      qh_drop_mergevertex(qh, merge);
      qh_setdelnth(qh, qh->vertex_mergeset, merge_i);
      merge_i--; merge_n--;
      qh_memfree(qh, merge, (int)sizeof(mergeT));
    }else if (merge->distance < bestdist) {
      bestdist= merge->distance;
      best_i= merge_i;
    }
  }
  merge= NULL;
  if (best_i >= 0) {
    merge= SETelemt_(qh->vertex_mergeset, best_i, mergeT);
    if (bestdist/qh->ONEmerge > qh_WIDEpinched) {
      if (merge->mergetype==MRGvertices) {
        if (merge->ridge1->top == merge->ridge2->bottom && merge->ridge1->bottom == merge->ridge2->top)
          qh_fprintf(qh, qh->ferr, 6391, "qhull topology error (qh_next_vertexmerge): no nearly adjacent vertices to resolve opposite oriented ridges r%d and r%d in f%d and f%d.  Nearest v%d and v%d dist %2.2g (%.1fx)\n",
            merge->ridge1->id, merge->ridge2->id, merge->ridge1->top->id, merge->ridge1->bottom->id, merge->vertex1->id, merge->vertex2->id, bestdist, bestdist/qh->ONEmerge);
        else
          qh_fprintf(qh, qh->ferr, 6381, "qhull topology error (qh_next_vertexmerge): no nearly adjacent vertices to resolve duplicate ridges r%d and r%d.  Nearest v%d and v%d dist %2.2g (%.1fx)\n",
            merge->ridge1->id, merge->ridge2->id, merge->vertex1->id, merge->vertex2->id, bestdist, bestdist/qh->ONEmerge);
      }else {
        qh_fprintf(qh, qh->ferr, 6208, "qhull topology error (qh_next_vertexmerge): no nearly adjacent vertices to resolve dupridge.  Nearest v%d and v%d dist %2.2g (%.1fx)\n",
          merge->vertex1->id, merge->vertex2->id, bestdist, bestdist/qh->ONEmerge);
      }
      /* it may be possible to find a different vertex, after other vertex merges have occurred */
      qh_errexit(qh, qh_ERRtopology, NULL, merge->ridge1);
    }
    qh_setdelnth(qh, qh->vertex_mergeset, best_i);
  }
  return merge;
} /* next_vertexmerge */

/*---------------------------------

  qh_opposite_horizonfacet(qh, merge, opposite )
    return horizon facet for one of the merge facets, and its opposite vertex across the ridge
    assumes either facet1 or facet2 of merge is 'mergehorizon'
    assumes both facets are simplicial facets on qh.new_facetlist

  returns:
    horizon facet and opposite vertex

  notes:
    called by qh_getpinchedmerges
*/
facetT *qh_opposite_horizonfacet(qhT *qh, mergeT *merge, vertexT **opposite) {
  facetT *facet, *horizon, *otherfacet;
  int neighbor_i;

  if (!merge->facet1->simplicial || !merge->facet2->simplicial || (!merge->facet1->mergehorizon && !merge->facet2->mergehorizon)) {
    qh_fprintf(qh, qh->ferr, 6273, "qhull internal error (qh_opposite_horizonfacet): expecting merge of simplicial facets, at least one of which is mergehorizon.  Either simplicial or mergehorizon is wrong\n");
    qh_errexit2(qh, qh_ERRqhull, merge->facet1, merge->facet2);
  }
  if (merge->facet1->mergehorizon) {
    facet= merge->facet1;
    otherfacet= merge->facet2;
  }else {
    facet= merge->facet2;
    otherfacet= merge->facet1;
  }
  horizon= SETfirstt_(facet->neighbors, facetT);
  neighbor_i= qh_setindex(otherfacet->neighbors, facet);
  if (neighbor_i==-1)
    neighbor_i= qh_setindex(otherfacet->neighbors, qh_MERGEridge);
  if (neighbor_i==-1) {
    qh_fprintf(qh, qh->ferr, 6238, "qhull internal error (qh_opposite_horizonfacet): merge facet f%d not connected to mergehorizon f%d\n",
      otherfacet->id, facet->id);
    qh_errexit2(qh, qh_ERRqhull, otherfacet, facet);
  }
  *opposite= SETelemt_(otherfacet->vertices, neighbor_i, vertexT);
  return horizon;
} /* opposite_horizonfacet */


/*---------------------------------

  qh_reducevertices(qh)
    reduce extra vertices, shared vertices, and redundant vertices
    facet->newmerge is set if merged since last call
    vertex->delridge is set if vertex was on a deleted ridge
    if !qh.MERGEvertices, only removes extra vertices

  returns:
    True if also merged degen_redundant facets
    vertices are renamed if possible
    clears facet->newmerge and vertex->delridge

  notes:
    called by qh_all_merges and qh_postmerge
    ignored if 2-d

  design:
    merge any degenerate or redundant facets
    repeat until no more degenerate or redundant facets
      for each newly merged facet
        remove extra vertices
      if qh.MERGEvertices
        for each newly merged facet
          for each vertex
            if vertex was on a deleted ridge
              rename vertex if it is shared
        for each new, undeleted vertex
          remove delridge flag
          if vertex is redundant
            merge degenerate or redundant facets
*/
boolT qh_reducevertices(qhT *qh) {
  int numshare=0, numrename= 0;
  boolT degenredun= False;
  facetT *newfacet;
  vertexT *vertex, **vertexp;

  if (qh->hull_dim == 2)
    return False;
  trace2((qh, qh->ferr, 2101, "qh_reducevertices: reduce extra vertices, shared vertices, and redundant vertices\n"));
  if (qh_merge_degenredundant(qh))
    degenredun= True;
LABELrestart:
  FORALLnew_facets {
    if (newfacet->newmerge) {
      if (!qh->MERGEvertices)
        newfacet->newmerge= False;
      if (qh_remove_extravertices(qh, newfacet)) {
        qh_degen_redundant_facet(qh, newfacet);
        if (qh_merge_degenredundant(qh)) {
          degenredun= True;
          goto LABELrestart;
        }
      }
    }
  }
  if (!qh->MERGEvertices)
    return False;
  FORALLnew_facets {
    if (newfacet->newmerge) {
      newfacet->newmerge= False;
      FOREACHvertex_(newfacet->vertices) {
        if (vertex->delridge) {
          if (qh_rename_sharedvertex(qh, vertex, newfacet)) {
            numshare++;
            if (qh_merge_degenredundant(qh)) {
              degenredun= True;
              goto LABELrestart;
            }
            vertexp--; /* repeat since deleted vertex */
          }
        }
      }
    }
  }
  FORALLvertex_(qh->newvertex_list) {
    if (vertex->delridge && !vertex->deleted) {
      vertex->delridge= False;
      if (qh->hull_dim >= 4 && qh_redundant_vertex(qh, vertex)) {
        numrename++;
        if (qh_merge_degenredundant(qh)) {
          degenredun= True;
          goto LABELrestart;
        }
      }
    }
  }
  trace1((qh, qh->ferr, 1014, "qh_reducevertices: renamed %d shared vertices and %d redundant vertices. Degen? %d\n",
          numshare, numrename, degenredun));
  return degenredun;
} /* reducevertices */

/*---------------------------------

  qh_redundant_vertex(qh, vertex )
    rename a redundant vertex if qh_find_newvertex succeeds
    assumes vertices have full vertex->neighbors

  returns:
    if find a replacement vertex
      returns new vertex
      qh_renamevertex sets vertex->deleted for redundant vertex

  notes:
    only called by qh_reducevertices for vertex->delridge and hull_dim >= 4
    may add degenerate facets to qh.facet_mergeset
    doesn't change vertex->neighbors or create redundant facets

  design:
    intersect vertices of all facet neighbors of vertex
    determine ridges for these vertices
    if find a new vertex for vertex among these ridges and vertices
      rename vertex to the new vertex
*/
vertexT *qh_redundant_vertex(qhT *qh, vertexT *vertex) {
  vertexT *newvertex= NULL;
  setT *vertices, *ridges;

  trace3((qh, qh->ferr, 3008, "qh_redundant_vertex: check if v%d from a deleted ridge can be renamed\n", vertex->id));
  if ((vertices= qh_neighbor_intersections(qh, vertex))) {
    ridges= qh_vertexridges(qh, vertex, !qh_ALL);
    if ((newvertex= qh_find_newvertex(qh, vertex, vertices, ridges))) {
      zinc_(Zrenameall);
      qh_renamevertex(qh, vertex, newvertex, ridges, NULL, NULL); /* ridges invalidated */
    }
    qh_settempfree(qh, &ridges);
    qh_settempfree(qh, &vertices);
  }
  return newvertex;
} /* redundant_vertex */

/*---------------------------------

  qh_remove_extravertices(qh, facet )
    remove extra vertices from non-simplicial facets

  returns:
    returns True if it finds them
      deletes facet from vertex neighbors
      facet may be redundant (test with qh_degen_redundant)

  notes:
    called by qh_renamevertex and qh_reducevertices
    a merge (qh_reducevertices) or qh_renamevertex may drop all ridges for a vertex in a facet

  design:
    for each vertex in facet
      if vertex not in a ridge (i.e., no longer used)
        delete vertex from facet
        delete facet from vertex's neighbors
        unless vertex in another facet
          add vertex to qh.del_vertices for later deletion
*/
boolT qh_remove_extravertices(qhT *qh, facetT *facet) {
  ridgeT *ridge, **ridgep;
  vertexT *vertex, **vertexp;
  boolT foundrem= False;

  if (facet->simplicial) {
    return False;
  }
  trace4((qh, qh->ferr, 4043, "qh_remove_extravertices: test non-simplicial f%d for extra vertices\n",
          facet->id));
  FOREACHvertex_(facet->vertices)
    vertex->seen= False;
  FOREACHridge_(facet->ridges) {
    FOREACHvertex_(ridge->vertices)
      vertex->seen= True;
  }
  FOREACHvertex_(facet->vertices) {
    if (!vertex->seen) {
      foundrem= True;
      zinc_(Zremvertex);
      qh_setdelsorted(facet->vertices, vertex);
      qh_setdel(vertex->neighbors, facet);
      if (!qh_setsize(qh, vertex->neighbors)) {
        vertex->deleted= True;
        qh_setappend(qh, &qh->del_vertices, vertex);
        zinc_(Zremvertexdel);
        trace2((qh, qh->ferr, 2036, "qh_remove_extravertices: v%d deleted because it's lost all ridges\n", vertex->id));
      }else
        trace3((qh, qh->ferr, 3009, "qh_remove_extravertices: v%d removed from f%d because it's lost all ridges\n", vertex->id, facet->id));
      vertexp--; /*repeat*/
    }
  }
  return foundrem;
} /* remove_extravertices */

/*---------------------------------

  qh_remove_mergetype(qh, mergeset, mergetype )
    Remove mergetype merges from mergeset

  notes:
    Does not preserve order
*/
void qh_remove_mergetype(qhT *qh, setT *mergeset, mergeType type) {
  mergeT *merge;
  int merge_i, merge_n;

  FOREACHmerge_i_(qh, mergeset) {
    if (merge->mergetype == type) {
        trace3((qh, qh->ferr, 3037, "qh_remove_mergetype: remove merge f%d f%d v%d v%d r%d r%d dist %2.2g type %d",
            getid_(merge->facet1), getid_(merge->facet2), getid_(merge->vertex1), getid_(merge->vertex2), getid_(merge->ridge1), getid_(merge->ridge2), merge->distance, type));
        qh_setdelnth(qh, mergeset, merge_i);
        merge_i--; merge_n--;  /* repeat with next merge */
    }
  }
} /* remove_mergetype */

/*---------------------------------

  qh_rename_adjacentvertex(qh, oldvertex, newvertex )
    renames oldvertex as newvertex.  Must be adjacent (i.e., in the same subridge)
    no-op if either vertex is deleted

  notes:
    called from qh_merge_pinchedvertices

  design:
    for all neighbors of oldvertex
      if simplicial, rename oldvertex to newvertex and drop if degenerate
      if needed, add oldvertex neighbor to newvertex
    determine ridges for oldvertex
    rename oldvertex as newvertex in ridges (qh_renamevertex)
*/
void qh_rename_adjacentvertex(qhT *qh, vertexT *oldvertex, vertexT *newvertex, realT dist) {
  setT *ridges;
  facetT *neighbor, **neighborp, *maxfacet= NULL;
  ridgeT *ridge, **ridgep;
  boolT istrace= False;
  int oldsize= qh_setsize(qh, oldvertex->neighbors);
  int newsize= qh_setsize(qh, newvertex->neighbors);
  coordT maxdist2= -REALmax, dist2;

  if (qh->IStracing >= 4 || oldvertex->id == qh->tracevertex_id || newvertex->id == qh->tracevertex_id) {
    istrace= True;
  }
  zzinc_(Ztotmerge);
  if (istrace) {
    qh_fprintf(qh, qh->ferr, 2071, "qh_rename_adjacentvertex: merge #%d rename v%d (%d neighbors) to v%d (%d neighbors) dist %2.2g\n",
      zzval_(Ztotmerge), oldvertex->id, oldsize, newvertex->id, newsize, dist);
  }
  if (oldvertex->deleted || newvertex->deleted) {
    if (istrace || qh->IStracing >= 2) {
      qh_fprintf(qh, qh->ferr, 2072, "qh_rename_adjacentvertex: ignore rename.  Either v%d (%d) or v%d (%d) is deleted\n",
        oldvertex->id, oldvertex->deleted, newvertex->id, newvertex->deleted);
    }
    return;
  }
  if (oldsize == 0 || newsize == 0) {
    qh_fprintf(qh, qh->ferr, 2072, "qhull internal error (qh_rename_adjacentvertex): expecting neighbor facets for v%d and v%d.  Got %d and %d neighbors resp.\n",
      oldvertex->id, newvertex->id, oldsize, newsize);
      qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  FOREACHneighbor_(oldvertex) {
    if (neighbor->simplicial) {
      if (qh_setin(neighbor->vertices, newvertex)) {
        if (istrace || qh->IStracing >= 2) {
          qh_fprintf(qh, qh->ferr, 2070, "qh_rename_adjacentvertex: simplicial f%d contains old v%d and new v%d.  Will be marked degenerate by qh_renamevertex\n",
            neighbor->id, oldvertex->id, newvertex->id);
        }
        qh_makeridges(qh, neighbor); /* no longer simplicial, nummerge==0, skipped by qh_maybe_duplicateridge */
      }else {
        qh_replacefacetvertex(qh, neighbor, oldvertex, newvertex);
        qh_setunique(qh, &newvertex->neighbors, neighbor);
        qh_newvertices(qh, neighbor->vertices);  /* for qh_update_vertexneighbors of vertex neighbors */
      }
    }
  }
  ridges= qh_vertexridges(qh, oldvertex, qh_ALL);
  if (istrace) {
    FOREACHridge_(ridges) {
      qh_printridge(qh, qh->ferr, ridge);
    }
  }
  FOREACHneighbor_(oldvertex) {
    if (!neighbor->simplicial){
      qh_addfacetvertex(qh, neighbor, newvertex);
      qh_setunique(qh, &newvertex->neighbors, neighbor);
      qh_newvertices(qh, neighbor->vertices);  /* for qh_update_vertexneighbors of vertex neighbors */
      if (qh->newfacet_list == qh->facet_tail) {
        qh_removefacet(qh, neighbor);  /* add a neighbor to newfacet_list so that qh_partitionvisible has a newfacet */
        qh_appendfacet(qh, neighbor);
        neighbor->newfacet= True;
      }
    }
  }
  qh_renamevertex(qh, oldvertex, newvertex, ridges, NULL, NULL);  /* ridges invalidated */
  if (oldvertex->deleted && !oldvertex->partitioned) {
    FOREACHneighbor_(newvertex) {
      if (!neighbor->visible) {
        qh_distplane(qh, oldvertex->point, neighbor, &dist2);
        if (dist2>maxdist2) {
          maxdist2= dist2;
          maxfacet= neighbor;
        }
      }
    }
    trace2((qh, qh->ferr, 2096, "qh_rename_adjacentvertex: partition old p%d(v%d) as a coplanar point for furthest f%d dist %2.2g.  Maybe repartition later (QH0031)\n",
      qh_pointid(qh, oldvertex->point), oldvertex->id, maxfacet->id, maxdist2))
    qh_partitioncoplanar(qh, oldvertex->point, maxfacet, NULL, !qh_ALL);  /* faster with maxdist2, otherwise duplicates distance tests from maxdist2/dist2 */
    oldvertex->partitioned= True;
  }
  qh_settempfree(qh, &ridges);
} /* rename_adjacentvertex */

/*---------------------------------

  qh_rename_sharedvertex(qh, vertex, facet )
    detect and rename if shared vertex in facet
    vertices have full ->neighbors

  returns:
    newvertex or NULL
    the vertex may still exist in other facets (i.e., a neighbor was pinched)
    does not change facet->neighbors
    updates vertex->neighbors

  notes:
    only called by qh_reducevertices after qh_remove_extravertices
       so f.vertices does not contain extraneous vertices
    a shared vertex for a facet is only in ridges to one neighbor
    this may undo a pinched facet

    it does not catch pinches involving multiple facets.  These appear
      to be difficult to detect, since an exhaustive search is too expensive.

  design:
    if vertex only has two neighbors
      determine the ridges that contain the vertex
      determine the vertices shared by both neighbors
      if can find a new vertex in this set
        rename the vertex to the new vertex
*/
vertexT *qh_rename_sharedvertex(qhT *qh, vertexT *vertex, facetT *facet) {
  facetT *neighbor, **neighborp, *neighborA= NULL;
  setT *vertices, *ridges;
  vertexT *newvertex= NULL;

  if (qh_setsize(qh, vertex->neighbors) == 2) {
    neighborA= SETfirstt_(vertex->neighbors, facetT);
    if (neighborA == facet)
      neighborA= SETsecondt_(vertex->neighbors, facetT);
  }else if (qh->hull_dim == 3)
    return NULL;
  else {
    qh->visit_id++;
    FOREACHneighbor_(facet)
      neighbor->visitid= qh->visit_id;
    FOREACHneighbor_(vertex) {
      if (neighbor->visitid == qh->visit_id) {
        if (neighborA)
          return NULL;
        neighborA= neighbor;
      }
    }
  }
  if (!neighborA) {
    qh_fprintf(qh, qh->ferr, 6101, "qhull internal error (qh_rename_sharedvertex): v%d's neighbors not in f%d\n",
        vertex->id, facet->id);
    qh_errprint(qh, "ERRONEOUS", facet, NULL, NULL, vertex);
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  if (neighborA) { /* avoid warning */
    /* the vertex is shared by facet and neighborA */
    ridges= qh_settemp(qh, qh->TEMPsize);
    neighborA->visitid= ++qh->visit_id;
    qh_vertexridges_facet(qh, vertex, facet, &ridges);
    trace2((qh, qh->ferr, 2037, "qh_rename_sharedvertex: p%d(v%d) is shared by f%d(%d ridges) and f%d\n",
      qh_pointid(qh, vertex->point), vertex->id, facet->id, qh_setsize(qh, ridges), neighborA->id));
    zinc_(Zintersectnum);
    vertices= qh_vertexintersect_new(qh, facet->vertices, neighborA->vertices);
    qh_setdel(vertices, vertex);
    qh_settemppush(qh, vertices);
    if ((newvertex= qh_find_newvertex(qh, vertex, vertices, ridges)))
      qh_renamevertex(qh, vertex, newvertex, ridges, facet, neighborA);  /* ridges invalidated */
    qh_settempfree(qh, &vertices);
    qh_settempfree(qh, &ridges);
  }
  return newvertex;
} /* rename_sharedvertex */

/*---------------------------------

  qh_renameridgevertex(qh, ridge, oldvertex, newvertex )
    renames oldvertex as newvertex in ridge

  returns:
    True if renames oldvertex
    False if deleted the ridge

  notes:
    called by qh_renamevertex
    caller sets newvertex->delridge for deleted ridges (qh_reducevertices)

  design:
    delete oldvertex from ridge
    if newvertex already in ridge
      copy ridge->noconvex to another ridge if possible
      delete the ridge
    else
      insert newvertex into the ridge
      adjust the ridge's orientation
*/
boolT qh_renameridgevertex(qhT *qh, ridgeT *ridge, vertexT *oldvertex, vertexT *newvertex) {
  int nth= 0, oldnth;
  facetT *temp;
  vertexT *vertex, **vertexp;

  oldnth= qh_setindex(ridge->vertices, oldvertex);
  if (oldnth < 0) {
    qh_fprintf(qh, qh->ferr, 6424, "qhull internal error (qh_renameridgevertex): oldvertex v%d not found in r%d.  Cannot rename to v%d\n",
        oldvertex->id, ridge->id, newvertex->id);
    qh_errexit(qh, qh_ERRqhull, NULL, ridge);
  }
  qh_setdelnthsorted(qh, ridge->vertices, oldnth);
  FOREACHvertex_(ridge->vertices) {
    if (vertex == newvertex) {
      zinc_(Zdelridge);
      if (ridge->nonconvex) /* only one ridge has nonconvex set */
        qh_copynonconvex(qh, ridge);
      trace2((qh, qh->ferr, 2038, "qh_renameridgevertex: ridge r%d deleted.  It contained both v%d and v%d\n",
        ridge->id, oldvertex->id, newvertex->id));
      qh_delridge_merge(qh, ridge); /* ridge.vertices deleted */
      return False;
    }
    if (vertex->id < newvertex->id)
      break;
    nth++;
  }
  qh_setaddnth(qh, &ridge->vertices, nth, newvertex);
  ridge->simplicialtop= False;
  ridge->simplicialbot= False;
  if (abs(oldnth - nth)%2) {
    trace3((qh, qh->ferr, 3010, "qh_renameridgevertex: swapped the top and bottom of ridge r%d\n",
            ridge->id));
    temp= ridge->top;
    ridge->top= ridge->bottom;
    ridge->bottom= temp;
  }
  return True;
} /* renameridgevertex */


/*---------------------------------

  qh_renamevertex(qh, oldvertex, newvertex, ridges, oldfacet, neighborA )
    renames oldvertex as newvertex in ridges of non-simplicial neighbors
    set oldfacet/neighborA if oldvertex is shared between two facets (qh_rename_sharedvertex)
    otherwise qh_redundant_vertex or qh_rename_adjacentvertex

  returns:
    if oldfacet and multiple neighbors, oldvertex may still exist afterwards
    otherwise sets oldvertex->deleted for later deletion
    one or more ridges maybe deleted
    ridges is invalidated
    merges may be added to degen_mergeset via qh_maydropneighbor or qh_degen_redundant_facet

  notes:
    qh_rename_sharedvertex can not change neighbors of newvertex (since it's a subset)
    qh_redundant_vertex due to vertex->delridge for qh_reducevertices
    qh_rename_adjacentvertex for complete renames

  design:
    for each ridge in ridges
      rename oldvertex to newvertex and delete degenerate ridges
    if oldfacet not defined
      for each non-simplicial neighbor of oldvertex
        delete oldvertex from neighbor's vertices
        remove extra vertices from neighbor
      add oldvertex to qh.del_vertices
    else if oldvertex only between oldfacet and neighborA
      delete oldvertex from oldfacet and neighborA
      add oldvertex to qh.del_vertices
    else oldvertex is in oldfacet and neighborA and other facets (i.e., pinched)
      delete oldvertex from oldfacet
      delete oldfacet from old vertex's neighbors
      remove extra vertices (e.g., oldvertex) from neighborA
*/
void qh_renamevertex(qhT *qh, vertexT *oldvertex, vertexT *newvertex, setT *ridges, facetT *oldfacet, facetT *neighborA) {
  facetT *neighbor, **neighborp;
  ridgeT *ridge, **ridgep;
  int topsize, bottomsize;
  boolT istrace= False;

#ifndef qh_NOtrace
  if (qh->IStracing >= 2 || oldvertex->id == qh->tracevertex_id ||
        newvertex->id == qh->tracevertex_id) {
    istrace= True;
    qh_fprintf(qh, qh->ferr, 2086, "qh_renamevertex: rename v%d to v%d in %d ridges with old f%d and neighbor f%d\n",
      oldvertex->id, newvertex->id, qh_setsize(qh, ridges), getid_(oldfacet), getid_(neighborA));
  }
#endif
  FOREACHridge_(ridges) {
    if (qh_renameridgevertex(qh, ridge, oldvertex, newvertex)) { /* ridge is deleted if False, invalidating ridges */
      topsize= qh_setsize(qh, ridge->top->vertices);
      bottomsize= qh_setsize(qh, ridge->bottom->vertices);
      if (topsize < qh->hull_dim || (topsize == qh->hull_dim && !ridge->top->simplicial && qh_setin(ridge->top->vertices, newvertex))) {
        trace4((qh, qh->ferr, 4070, "qh_renamevertex: ignore duplicate check for r%d.  top f%d (size %d) will be degenerate after rename v%d to v%d\n",
          ridge->id, ridge->top->id, topsize, oldvertex->id, newvertex->id));
      }else if (bottomsize < qh->hull_dim || (bottomsize == qh->hull_dim && !ridge->bottom->simplicial && qh_setin(ridge->bottom->vertices, newvertex))) {
        trace4((qh, qh->ferr, 4071, "qh_renamevertex: ignore duplicate check for r%d.  bottom f%d (size %d) will be degenerate after rename v%d to v%d\n",
          ridge->id, ridge->bottom->id, bottomsize, oldvertex->id, newvertex->id));
      }else
        qh_maybe_duplicateridge(qh, ridge);
    }
  }
  if (!oldfacet) {
    /* stat Zrenameall or Zpinchduplicate */
    if (istrace)
      qh_fprintf(qh, qh->ferr, 2087, "qh_renamevertex: renaming v%d to v%d in several facets for qh_redundant_vertex or MRGsubridge\n",
               oldvertex->id, newvertex->id);
    FOREACHneighbor_(oldvertex) {
      if (neighbor->simplicial) {
        qh_degen_redundant_facet(qh, neighbor); /* e.g., rbox 175 C3,2e-13 D4 t1545235541 | qhull d */
      }else {
        if (istrace)
          qh_fprintf(qh, qh->ferr, 4080, "qh_renamevertex: rename vertices in non-simplicial neighbor f%d of v%d\n", neighbor->id, oldvertex->id);
        qh_maydropneighbor(qh, neighbor);
        qh_setdelsorted(neighbor->vertices, oldvertex); /* if degenerate, qh_degen_redundant_facet will add to mergeset */
        if (qh_remove_extravertices(qh, neighbor))
          neighborp--; /* neighbor deleted from oldvertex neighborset */
        qh_degen_redundant_facet(qh, neighbor); /* either direction may be redundant, faster if combine? */
        qh_test_redundant_neighbors(qh, neighbor);
        qh_test_degen_neighbors(qh, neighbor);
      }
    }
    if (!oldvertex->deleted) {
      oldvertex->deleted= True;
      qh_setappend(qh, &qh->del_vertices, oldvertex);
    }
  }else if (qh_setsize(qh, oldvertex->neighbors) == 2) {
    zinc_(Zrenameshare);
    if (istrace)
      qh_fprintf(qh, qh->ferr, 3039, "qh_renamevertex: renaming v%d to v%d in oldfacet f%d for qh_rename_sharedvertex\n",
               oldvertex->id, newvertex->id, oldfacet->id);
    FOREACHneighbor_(oldvertex) {
      qh_setdelsorted(neighbor->vertices, oldvertex);
      qh_degen_redundant_facet(qh, neighbor);
    }
    oldvertex->deleted= True;
    qh_setappend(qh, &qh->del_vertices, oldvertex);
  }else {
    zinc_(Zrenamepinch);
    if (istrace || qh->IStracing >= 1)
      qh_fprintf(qh, qh->ferr, 3040, "qh_renamevertex: renaming pinched v%d to v%d between f%d and f%d\n",
               oldvertex->id, newvertex->id, oldfacet->id, neighborA->id);
    qh_setdelsorted(oldfacet->vertices, oldvertex);
    qh_setdel(oldvertex->neighbors, oldfacet);
    if (qh_remove_extravertices(qh, neighborA))
      qh_degen_redundant_facet(qh, neighborA);
  }
  if (oldfacet)
    qh_degen_redundant_facet(qh, oldfacet);
} /* renamevertex */

/*---------------------------------

  qh_test_appendmerge(qh, facet, neighbor, simplicial )
    test convexity and append to qh.facet_mergeset if non-convex
    if pre-merging,
      no-op if qh.SKIPconvex, or qh.MERGEexact and coplanar
    if simplicial, assumes centrum test is valid (e.g., adjacent, simplicial new facets)

  returns:
    true if appends facet/neighbor to qh.facet_mergeset
    sets facet->center as needed
    does not change facet->seen

  notes:
    called from qh_getmergeset_initial, qh_getmergeset, and qh_test_vneighbors
    must be at least as strong as qh_checkconvex (poly2_r.c)
    assumes !f.flipped

  design:
    exit if qh.SKIPconvex ('Q0') and !qh.POSTmerging
    if qh.cos_max ('An') is defined and merging coplanars
      if the angle between facet normals is too shallow
        append an angle-coplanar merge to qh.mergeset
        return True
    test convexity of facet and neighbor
*/
boolT qh_test_appendmerge(qhT *qh, facetT *facet, facetT *neighbor, boolT simplicial) {
  realT angle= -REALmax;
  boolT okangle= False;

  if (qh->SKIPconvex && !qh->POSTmerging)
    return False;
  if (qh->cos_max < REALmax/2 && (!qh->MERGEexact || qh->POSTmerging)) {
    angle= qh_getangle(qh, facet->normal, neighbor->normal);
    okangle= True;
    zinc_(Zangletests);
    if (angle > qh->cos_max) {
      zinc_(Zcoplanarangle);
      qh_appendmergeset(qh, facet, neighbor, MRGanglecoplanar, 0.0, angle);
      trace2((qh, qh->ferr, 2039, "qh_test_appendmerge: coplanar angle %4.4g between f%d and f%d\n",
         angle, facet->id, neighbor->id));
      return True;
    }
  }
  if (simplicial || qh->hull_dim <= 3)
    return qh_test_centrum_merge(qh, facet, neighbor, angle, okangle);
  else
    return qh_test_nonsimplicial_merge(qh, facet, neighbor, angle, okangle);
} /* test_appendmerge */

/*---------------------------------

  qh_test_centrum_merge(qh, facet, neighbor, angle, okangle )
    test centrum convexity and append non-convex facets to qh.facet_mergeset
    'angle' is angle between facets if okangle is true, otherwise use 0.0

  returns:
    true if append facet/neighbor to qh.facet_mergeset
    sets facet->center as needed
    does not change facet->seen

  notes:
    called from test_appendmerge if adjacent simplicial facets or 2-d/3-d
    at least as strict as qh_checkconvex, including qh.DISTround ('En' and 'Rn')

  design:
    make facet's centrum if needed
    if facet's centrum is above the neighbor (qh.centrum_radius)
      set isconcave

    if facet's centrum is not below the neighbor (-qh.centrum_radius)
      set iscoplanar
    make neighbor's centrum if needed
    if neighbor's centrum is above the facet
      set isconcave
    else if neighbor's centrum is not below the facet
      set iscoplanar
    if isconcave or iscoplanar and merging coplanars
      get angle if needed (qh.ANGLEmerge 'An')
      append concave-coplanar, concave ,or coplanar merge to qh.mergeset
*/
boolT qh_test_centrum_merge(qhT *qh, facetT *facet, facetT *neighbor, realT angle, boolT okangle) {
  coordT dist, dist2, mergedist;
  boolT isconcave= False, iscoplanar= False;

  if (!facet->center)
    facet->center= qh_getcentrum(qh, facet);
  zzinc_(Zcentrumtests);
  qh_distplane(qh, facet->center, neighbor, &dist);
  if (dist > qh->centrum_radius)
    isconcave= True;
  else if (dist >= -qh->centrum_radius)
    iscoplanar= True;
  if (!neighbor->center)
    neighbor->center= qh_getcentrum(qh, neighbor);
  zzinc_(Zcentrumtests);
  qh_distplane(qh, neighbor->center, facet, &dist2);
  if (dist2 > qh->centrum_radius)
    isconcave= True;
  else if (!iscoplanar && dist2 >= -qh->centrum_radius)
    iscoplanar= True;
  if (!isconcave && (!iscoplanar || (qh->MERGEexact && !qh->POSTmerging)))
    return False;
  if (!okangle && qh->ANGLEmerge) {
    angle= qh_getangle(qh, facet->normal, neighbor->normal);
    zinc_(Zangletests);
  }
  if (isconcave && iscoplanar) {
    zinc_(Zconcavecoplanarridge);
    if (dist > dist2)
      qh_appendmergeset(qh, facet, neighbor, MRGconcavecoplanar, dist, angle);
    else
      qh_appendmergeset(qh, neighbor, facet, MRGconcavecoplanar, dist2, angle);
    trace0((qh, qh->ferr, 36, "qh_test_centrum_merge: concave f%d to coplanar f%d, dist %4.4g and reverse dist %4.4g, angle %4.4g during p%d\n",
           facet->id, neighbor->id, dist, dist2, angle, qh->furthest_id));
  }else if (isconcave) {
    mergedist= fmax_(dist, dist2);
    zinc_(Zconcaveridge);
    qh_appendmergeset(qh, facet, neighbor, MRGconcave, mergedist, angle);
    trace0((qh, qh->ferr, 37, "qh_test_centrum_merge: concave f%d to f%d, dist %4.4g and reverse dist %4.4g, angle %4.4g during p%d\n",
      facet->id, neighbor->id, dist, dist2, angle, qh->furthest_id));
  }else /* iscoplanar */ {
    mergedist= fmin_(fabs_(dist), fabs_(dist2));
    zinc_(Zcoplanarcentrum);
    qh_appendmergeset(qh, facet, neighbor, MRGcoplanar, mergedist, angle);
    trace2((qh, qh->ferr, 2097, "qh_test_centrum_merge: coplanar f%d to f%d dist %4.4g, reverse dist %4.4g angle %4.4g\n",
              facet->id, neighbor->id, dist, dist2, angle));
  }
  return True;
} /* test_centrum_merge */

/*---------------------------------

  qh_test_degen_neighbors(qh, facet )
    append degenerate neighbors to qh.degen_mergeset

  notes:
  called at end of qh_mergefacet() and qh_renamevertex()
  call after test_redundant_facet() since MRGredundant is less expensive then MRGdegen
    a degenerate facet has fewer than hull_dim neighbors
    see: qh_merge_degenredundant()

*/
void qh_test_degen_neighbors(qhT *qh, facetT *facet) {
  facetT *neighbor, **neighborp;
  int size;

  trace4((qh, qh->ferr, 4073, "qh_test_degen_neighbors: test for degenerate neighbors of f%d\n", facet->id));
  FOREACHneighbor_(facet) {
    if (neighbor->visible) {
      qh_fprintf(qh, qh->ferr, 6359, "qhull internal error (qh_test_degen_neighbors): facet f%d has deleted neighbor f%d (qh.visible_list)\n",
        facet->id, neighbor->id);
      qh_errexit2(qh, qh_ERRqhull, facet, neighbor);
    }
    if (neighbor->degenerate || neighbor->redundant || neighbor->dupridge) /* will merge or delete */
      continue;
    /* merge flipped-degenerate facet before flipped facets */
    if ((size= qh_setsize(qh, neighbor->neighbors)) < qh->hull_dim) {
      qh_appendmergeset(qh, neighbor, neighbor, MRGdegen, 0.0, 1.0);
      trace2((qh, qh->ferr, 2019, "qh_test_degen_neighbors: f%d is degenerate with %d neighbors.  Neighbor of f%d.\n", neighbor->id, size, facet->id));
    }
  }
} /* test_degen_neighbors */


/*---------------------------------

  qh_test_nonsimplicial_merge(qh, facet, neighbor, angle, okangle )
    test centrum and vertex convexity and append non-convex or redundant facets to qh.facet_mergeset
    'angle' is angle between facets if okangle is true, otherwise use 0.0
    skips coplanar merges if pre-merging with qh.MERGEexact ('Qx')

  returns:
    true if appends facet/neighbor to qh.facet_mergeset
    sets facet->center as needed
    does not change facet->seen

  notes:
    only called from test_appendmerge if a non-simplicial facet and at least 4-d
    at least as strict as qh_checkconvex, including qh.DISTround ('En' and 'Rn')
      centrums must be < -qh.centrum_radius
    tests vertices as well as centrums since a facet may be twisted relative to its neighbor

  design:
    set precision constants for maxoutside, clearlyconcave, minvertex, and coplanarcentrum
      use maxoutside for coplanarcentrum if premerging with 'Qx' and qh_MAXcoplanarcentrum merges
      otherwise use qh.centrum_radious for coplanarcentrum
    make facet and neighbor centrums if needed
    isconcave if a centrum is above neighbor (coplanarcentrum)
    iscoplanar if a centrum is not below neighbor (-qh.centrum_radius)
    maybeconvex if a centrum is clearly below neighbor (-clearyconvex)
    return False if both centrums clearly below neighbor (-clearyconvex)
    return MRGconcave if isconcave

    facets are neither clearly convex nor clearly concave
    test vertices as well as centrums
    if maybeconvex
      determine mindist and maxdist for vertices of the other facet
      maybe MRGredundant
    otherwise
      determine mindist and maxdist for vertices of either facet
      maybe MRGredundant
      maybeconvex if a vertex is clearly below neighbor (-clearconvex)

    vertices are concave if dist > clearlyconcave
    vertices are twisted if dist > maxoutside (isconcave and maybeconvex)
    return False if not concave and pre-merge of 'Qx' (qh.MERGEexact)
    vertices are coplanar if dist in -minvertex..maxoutside
    if !isconcave, vertices are coplanar if dist >= -qh.MAXcoplanar (n*qh.premerge_centrum)

    return False if neither concave nor coplanar
    return MRGtwisted if isconcave and maybeconvex
    return MRGconcavecoplanar if isconcave and isconvex
    return MRGconcave if isconcave
    return MRGcoplanar if iscoplanar
*/
boolT qh_test_nonsimplicial_merge(qhT *qh, facetT *facet, facetT *neighbor, realT angle, boolT okangle) {
  coordT dist, mindist, maxdist, mindist2, maxdist2, dist2, maxoutside, clearlyconcave, minvertex, clearlyconvex, mergedist, coplanarcentrum;
  boolT isconcave= False, iscoplanar= False, maybeconvex= False, isredundant= False;
  vertexT *maxvertex= NULL, *maxvertex2= NULL;

  maxoutside= fmax_(neighbor->maxoutside, qh->ONEmerge + qh->DISTround);
  maxoutside= fmax_(maxoutside, facet->maxoutside);
  clearlyconcave= qh_RATIOconcavehorizon * maxoutside;
  minvertex= fmax_(-qh->min_vertex, qh->MAXcoplanar); /* non-negative, not available per facet, not used for iscoplanar */
  clearlyconvex= qh_RATIOconvexmerge * minvertex; /* must be convex for MRGtwisted */
  if (qh->MERGEexact && !qh->POSTmerging && (facet->nummerge > qh_MAXcoplanarcentrum || neighbor->nummerge > qh_MAXcoplanarcentrum))
    coplanarcentrum= maxoutside;
  else
    coplanarcentrum= qh->centrum_radius;

  if (!facet->center)
    facet->center= qh_getcentrum(qh, facet);
  zzinc_(Zcentrumtests);
  qh_distplane(qh, facet->center, neighbor, &dist);
  if (dist > coplanarcentrum)
    isconcave= True;
  else if (dist >= -qh->centrum_radius)
    iscoplanar= True;
  else if (dist < -clearlyconvex)
    maybeconvex= True;
  if (!neighbor->center)
    neighbor->center= qh_getcentrum(qh, neighbor);
  zzinc_(Zcentrumtests);
  qh_distplane(qh, neighbor->center, facet, &dist2);
  if (dist2 > coplanarcentrum)
    isconcave= True;
  else if (dist2 >= -qh->centrum_radius)
    iscoplanar= True;
  else if (dist2 < -clearlyconvex) {
    if (maybeconvex)
      return False; /* both centrums clearly convex */
    maybeconvex= True;
  }
  if (isconcave) {
    if (!okangle && qh->ANGLEmerge) {
      angle= qh_getangle(qh, facet->normal, neighbor->normal);
      zinc_(Zangletests);
    }
    mergedist= fmax_(dist, dist2);
    zinc_(Zconcaveridge);
    qh_appendmergeset(qh, facet, neighbor, MRGconcave, mergedist, angle);
    trace0((qh, qh->ferr, 18, "qh_test_nonsimplicial_merge: concave centrum for f%d or f%d, dist %4.4g and reverse dist %4.4g, angle %4.4g during p%d\n",
      facet->id, neighbor->id, dist, dist2, angle, qh->furthest_id));
    return True;
  }
  /* neither clearly convex nor clearly concave, test vertices as well as centrums */
  if (maybeconvex) {
    if (dist < -clearlyconvex) {
      maxdist= dist;  /* facet centrum clearly convex, no need to test its vertex distance */
      mindist= dist;
      maxvertex2= qh_furthestvertex(qh, neighbor, facet, &maxdist2, &mindist2);
      if (!maxvertex2) {
        qh_appendmergeset(qh, neighbor, facet, MRGredundant, maxdist2, qh_ANGLEnone);
        isredundant= True;
      }
    }else { /* dist2 < -clearlyconvex */
      maxdist2= dist2;   /* neighbor centrum clearly convex, no need to test its vertex distance */
      mindist2= dist2;
      maxvertex= qh_furthestvertex(qh, facet, neighbor, &maxdist, &mindist);
      if (!maxvertex) {
        qh_appendmergeset(qh, facet, neighbor, MRGredundant, maxdist, qh_ANGLEnone);
        isredundant= True;
      }
    }
  }else {
    maxvertex= qh_furthestvertex(qh, facet, neighbor, &maxdist, &mindist);
    if (maxvertex) {
      maxvertex2= qh_furthestvertex(qh, neighbor, facet, &maxdist2, &mindist2);
      if (!maxvertex2) {
        qh_appendmergeset(qh, neighbor, facet, MRGredundant, maxdist2, qh_ANGLEnone);
        isredundant= True;
      }else if (mindist < -clearlyconvex || mindist2 < -clearlyconvex)
        maybeconvex= True;
    }else { /* !maxvertex */
      qh_appendmergeset(qh, facet, neighbor, MRGredundant, maxdist, qh_ANGLEnone);
      isredundant= True;
    }
  }
  if (isredundant) {
    zinc_(Zredundantmerge);
    return True;
  }

  if (maxdist > clearlyconcave || maxdist2 > clearlyconcave)
    isconcave= True;
  else if (maybeconvex) {
    if (maxdist > maxoutside || maxdist2 > maxoutside)
      isconcave= True;  /* MRGtwisted */
  }
  if (!isconcave && qh->MERGEexact && !qh->POSTmerging)
    return False;
  if (isconcave && !iscoplanar) {
    if (maxdist < maxoutside && (-qh->MAXcoplanar || (maxdist2 < maxoutside && mindist2 >= -qh->MAXcoplanar)))
      iscoplanar= True; /* MRGconcavecoplanar */
  }else if (!iscoplanar) {
    if (mindist >= -qh->MAXcoplanar || mindist2 >= -qh->MAXcoplanar)
      iscoplanar= True;  /* MRGcoplanar */
  }
  if (!isconcave && !iscoplanar)
    return False;
  if (!okangle && qh->ANGLEmerge) {
    angle= qh_getangle(qh, facet->normal, neighbor->normal);
    zinc_(Zangletests);
  }
  if (isconcave && maybeconvex) {
    zinc_(Ztwistedridge);
    if (maxdist > maxdist2)
      qh_appendmergeset(qh, facet, neighbor, MRGtwisted, maxdist, angle);
    else
      qh_appendmergeset(qh, neighbor, facet, MRGtwisted, maxdist2, angle);
    trace0((qh, qh->ferr, 27, "qh_test_nonsimplicial_merge: twisted concave f%d v%d to f%d v%d, dist %4.4g and reverse dist %4.4g, angle %4.4g during p%d\n",
           facet->id, getid_(maxvertex), neighbor->id, getid_(maxvertex2), maxdist, maxdist2, angle, qh->furthest_id));
  }else if (isconcave && iscoplanar) {
    zinc_(Zconcavecoplanarridge);
    if (maxdist > maxdist2)
      qh_appendmergeset(qh, facet, neighbor, MRGconcavecoplanar, maxdist, angle);
    else
      qh_appendmergeset(qh, neighbor, facet, MRGconcavecoplanar, maxdist2, angle);
    trace0((qh, qh->ferr, 28, "qh_test_nonsimplicial_merge: concave coplanar f%d v%d to f%d v%d, dist %4.4g and reverse dist %4.4g, angle %4.4g during p%d\n",
      facet->id, getid_(maxvertex), neighbor->id, getid_(maxvertex2), maxdist, maxdist2, angle, qh->furthest_id));
  }else if (isconcave) {
    mergedist= fmax_(maxdist, maxdist2);
    zinc_(Zconcaveridge);
    qh_appendmergeset(qh, facet, neighbor, MRGconcave, mergedist, angle);
    trace0((qh, qh->ferr, 29, "qh_test_nonsimplicial_merge: concave f%d v%d to f%d v%d, dist %4.4g and reverse dist %4.4g, angle %4.4g during p%d\n",
      facet->id, getid_(maxvertex), neighbor->id, getid_(maxvertex2), maxdist, maxdist2, angle, qh->furthest_id));
  }else /* iscoplanar */ {
    mergedist= fmax_(fmax_(maxdist, maxdist2), fmax_(-mindist, -mindist2));
    zinc_(Zcoplanarcentrum);
    qh_appendmergeset(qh, facet, neighbor, MRGcoplanar, mergedist, angle);
    trace2((qh, qh->ferr, 2099, "qh_test_nonsimplicial_merge: coplanar f%d v%d to f%d v%d, dist %4.4g and reverse dist %4.4g, angle %4.4g during p%d\n",
      facet->id, getid_(maxvertex), neighbor->id, getid_(maxvertex2), maxdist, maxdist2, angle, qh->furthest_id));
  }
  return True;
} /* test_nonsimplicial_merge */

/*---------------------------------

  qh_test_redundant_neighbors(qh, facet )
    append degenerate facet or its redundant neighbors to qh.degen_mergeset

  returns:
    bumps vertex_visit

  notes:
    called at end of qh_mergefacet(), qh_mergecycle_all(), and qh_renamevertex
    call before qh_test_degen_neighbors (MRGdegen are more likely to cause problems)
    a redundant neighbor's vertices is a subset of the facet's vertices
    with pinched and flipped facets, a redundant neighbor may have a wildly different normal

    see qh_merge_degenredundant() and qh_-_facet()

  design:
    if facet is degenerate
       appends facet to degen_mergeset
    else
       appends redundant neighbors of facet to degen_mergeset
*/
void qh_test_redundant_neighbors(qhT *qh, facetT *facet) {
  vertexT *vertex, **vertexp;
  facetT *neighbor, **neighborp;
  int size;

  trace4((qh, qh->ferr, 4022, "qh_test_redundant_neighbors: test neighbors of f%d vertex_visit %d\n",
          facet->id, qh->vertex_visit+1));
  if ((size= qh_setsize(qh, facet->neighbors)) < qh->hull_dim) {
    qh_appendmergeset(qh, facet, facet, MRGdegen, 0.0, 1.0);
    trace2((qh, qh->ferr, 2017, "qh_test_redundant_neighbors: f%d is degenerate with %d neighbors.\n", facet->id, size));
  }else {
    qh->vertex_visit++;
    FOREACHvertex_(facet->vertices)
      vertex->visitid= qh->vertex_visit;
    FOREACHneighbor_(facet) {
      if (neighbor->visible) {
        qh_fprintf(qh, qh->ferr, 6360, "qhull internal error (qh_test_redundant_neighbors): facet f%d has deleted neighbor f%d (qh.visible_list)\n",
          facet->id, neighbor->id);
        qh_errexit2(qh, qh_ERRqhull, facet, neighbor);
      }
      if (neighbor->degenerate || neighbor->redundant || neighbor->dupridge) /* will merge or delete */
        continue;
      if (facet->flipped && !neighbor->flipped) /* do not merge non-flipped into flipped */
        continue;
      /* merge redundant-flipped facet first */
      /* uses early out instead of checking vertex count */
      FOREACHvertex_(neighbor->vertices) {
        if (vertex->visitid != qh->vertex_visit)
          break;
      }
      if (!vertex) {
        qh_appendmergeset(qh, neighbor, facet, MRGredundant, 0.0, 1.0);
        trace2((qh, qh->ferr, 2018, "qh_test_redundant_neighbors: f%d is contained in f%d.  merge\n", neighbor->id, facet->id));
      }
    }
  }
} /* test_redundant_neighbors */

/*---------------------------------

  qh_test_vneighbors(qh)
    test vertex neighbors for convexity
    tests all facets on qh.newfacet_list

  returns:
    true if non-convex vneighbors appended to qh.facet_mergeset
    initializes vertex neighbors if needed

  notes:
    called by qh_all_merges from qh_postmerge if qh.TESTvneighbors ('Qv')
    assumes all facet neighbors have been tested
    this can be expensive
    this does not guarantee that a centrum is below all facets
      but it is unlikely
    uses qh.visit_id

  design:
    build vertex neighbors if necessary
    for all new facets
      for all vertices
        for each unvisited facet neighbor of the vertex
          test new facet and neighbor for convexity
*/
boolT qh_test_vneighbors(qhT *qh /* qh.newfacet_list */) {
  facetT *newfacet, *neighbor, **neighborp;
  vertexT *vertex, **vertexp;
  int nummerges= 0;

  trace1((qh, qh->ferr, 1015, "qh_test_vneighbors: testing vertex neighbors for convexity\n"));
  if (!qh->VERTEXneighbors)
    qh_vertexneighbors(qh);
  FORALLnew_facets
    newfacet->seen= False;
  FORALLnew_facets {
    newfacet->seen= True;
    newfacet->visitid= qh->visit_id++;
    FOREACHneighbor_(newfacet)
      newfacet->visitid= qh->visit_id;
    FOREACHvertex_(newfacet->vertices) {
      FOREACHneighbor_(vertex) {
        if (neighbor->seen || neighbor->visitid == qh->visit_id)
          continue;
        if (qh_test_appendmerge(qh, newfacet, neighbor, False)) /* ignores optimization for simplicial ridges */
          nummerges++;
      }
    }
  }
  zadd_(Ztestvneighbor, nummerges);
  trace1((qh, qh->ferr, 1016, "qh_test_vneighbors: found %d non-convex, vertex neighbors\n",
           nummerges));
  return (nummerges > 0);
} /* test_vneighbors */

/*---------------------------------

  qh_tracemerge(qh, facet1, facet2 )
    print trace message after merge
*/
void qh_tracemerge(qhT *qh, facetT *facet1, facetT *facet2, mergeType mergetype) {
  boolT waserror= False;
  const char *mergename;

#ifndef qh_NOtrace
  if(mergetype > 0 && mergetype < sizeof(mergetypes)/sizeof(char *))
    mergename= mergetypes[mergetype];
  else
    mergename= mergetypes[MRGnone];
  if (qh->IStracing >= 4)
    qh_errprint(qh, "MERGED", facet2, NULL, NULL, NULL);
  if (facet2 == qh->tracefacet || (qh->tracevertex && qh->tracevertex->newfacet)) {
    qh_fprintf(qh, qh->ferr, 8085, "qh_tracemerge: trace facet and vertex after merge of f%d into f%d type %d (%s), furthest p%d\n",
      facet1->id, facet2->id, mergetype, mergename, qh->furthest_id);
    if (facet2 != qh->tracefacet)
      qh_errprint(qh, "TRACE", qh->tracefacet,
        (qh->tracevertex && qh->tracevertex->neighbors) ?
           SETfirstt_(qh->tracevertex->neighbors, facetT) : NULL,
        NULL, qh->tracevertex);
  }
  if (qh->tracevertex) {
    if (qh->tracevertex->deleted)
      qh_fprintf(qh, qh->ferr, 8086, "qh_tracemerge: trace vertex deleted at furthest p%d\n",
            qh->furthest_id);
    else
      qh_checkvertex(qh, qh->tracevertex, qh_ALL, &waserror);
  }
  if (qh->tracefacet && qh->tracefacet->normal && !qh->tracefacet->visible)
    qh_checkfacet(qh, qh->tracefacet, True /* newmerge */, &waserror);
#endif /* !qh_NOtrace */
  if (qh->CHECKfrequently || qh->IStracing >= 4) { /* can't check polygon here */
    if (qh->IStracing >= 4 && qh->num_facets < 500) {
      qh_printlists(qh);
    }
    qh_checkfacet(qh, facet2, True /* newmerge */, &waserror);
  }
  if (waserror)
    qh_errexit(qh, qh_ERRqhull, NULL, NULL); /* erroneous facet logged by qh_checkfacet */
} /* tracemerge */

/*---------------------------------

  qh_tracemerging(qh)
    print trace message during POSTmerging

  returns:
    updates qh.mergereport

  notes:
    called from qh_mergecycle() and qh_mergefacet()

  see:
    qh_buildtracing()
*/
void qh_tracemerging(qhT *qh) {
  realT cpu;
  int total;
  time_t timedata;
  struct tm *tp;

  qh->mergereport= zzval_(Ztotmerge);
  time(&timedata);
  tp= localtime(&timedata);
  cpu= qh_CPUclock;
  cpu /= qh_SECticks;
  total= zzval_(Ztotmerge) - zzval_(Zcyclehorizon) + zzval_(Zcyclefacettot);
  qh_fprintf(qh, qh->ferr, 8087, "\n\
At %d:%d:%d & %2.5g CPU secs, qhull has merged %d facets with max_outside %2.2g, min_vertex %2.2g.\n\
  The hull contains %d facets and %d vertices.\n",
      tp->tm_hour, tp->tm_min, tp->tm_sec, cpu, total, qh->max_outside, qh->min_vertex,
      qh->num_facets - qh->num_visible,
      qh->num_vertices-qh_setsize(qh, qh->del_vertices));
} /* tracemerging */

/*---------------------------------

  qh_updatetested(qh, facet1, facet2 )
    clear facet2->tested and facet1->ridge->tested for merge

  returns:
    deletes facet2->center unless it's already large
      if so, clears facet2->ridge->tested

  notes:
    only called by qh_mergefacet

  design:
    clear facet2->tested
    clear ridge->tested for facet1's ridges
    if facet2 has a centrum
      if facet2 is large
        set facet2->keepcentrum
      else if facet2 has 3 vertices due to many merges, or not large and post merging
        clear facet2->keepcentrum
      unless facet2->keepcentrum
        clear facet2->center to recompute centrum later
        clear ridge->tested for facet2's ridges
*/
void qh_updatetested(qhT *qh, facetT *facet1, facetT *facet2) {
  ridgeT *ridge, **ridgep;
  int size;

  facet2->tested= False;
  FOREACHridge_(facet1->ridges)
    ridge->tested= False;
  if (!facet2->center)
    return;
  size= qh_setsize(qh, facet2->vertices);
  if (!facet2->keepcentrum) {
    if (size > qh->hull_dim + qh_MAXnewcentrum) {
      facet2->keepcentrum= True;
      zinc_(Zwidevertices);
    }
  }else if (size <= qh->hull_dim + qh_MAXnewcentrum) {
    /* center and keepcentrum was set */
    if (size == qh->hull_dim || qh->POSTmerging)
      facet2->keepcentrum= False; /* if many merges need to recompute centrum */
  }
  if (!facet2->keepcentrum) {
    qh_memfree(qh, facet2->center, qh->normal_size);
    facet2->center= NULL;
    FOREACHridge_(facet2->ridges)
      ridge->tested= False;
  }
} /* updatetested */

/*---------------------------------

  qh_vertexridges(qh, vertex, allneighbors )
    return temporary set of ridges adjacent to a vertex
    vertex->neighbors defined (qh_vertexneighbors)

  notes:
    uses qh.visit_id
    does not include implicit ridges for simplicial facets
    skips last neighbor, unless allneighbors.  For new facets, the last neighbor shares ridges with adjacent neighbors
    if the last neighbor is not simplicial, it will have ridges for its simplicial neighbors
    Use allneighbors when a new cone is attached to an existing convex hull
    similar to qh_neighbor_vertices

  design:
    for each neighbor of vertex
      add ridges that include the vertex to ridges
*/
setT *qh_vertexridges(qhT *qh, vertexT *vertex, boolT allneighbors) {
  facetT *neighbor, **neighborp;
  setT *ridges= qh_settemp(qh, qh->TEMPsize);
  int size;

  qh->visit_id += 2;  /* visit_id for vertex neighbors, visit_id-1 for facets of visited ridges */
  FOREACHneighbor_(vertex)
    neighbor->visitid= qh->visit_id;
  FOREACHneighbor_(vertex) {
    if (*neighborp || allneighbors)   /* no new ridges in last neighbor */
      qh_vertexridges_facet(qh, vertex, neighbor, &ridges);
  }
  if (qh->PRINTstatistics || qh->IStracing) {
    size= qh_setsize(qh, ridges);
    zinc_(Zvertexridge);
    zadd_(Zvertexridgetot, size);
    zmax_(Zvertexridgemax, size);
    trace3((qh, qh->ferr, 3011, "qh_vertexridges: found %d ridges for v%d\n",
             size, vertex->id));
  }
  return ridges;
} /* vertexridges */

/*---------------------------------

  qh_vertexridges_facet(qh, vertex, facet, ridges )
    add adjacent ridges for vertex in facet
    neighbor->visitid==qh.visit_id if it hasn't been visited

  returns:
    ridges updated
    sets facet->visitid to qh.visit_id-1

  design:
    for each ridge of facet
      if ridge of visited neighbor (i.e., unprocessed)
        if vertex in ridge
          append ridge
    mark facet processed
*/
void qh_vertexridges_facet(qhT *qh, vertexT *vertex, facetT *facet, setT **ridges) {
  ridgeT *ridge, **ridgep;
  facetT *neighbor;
  int last_i= qh->hull_dim-2;
  vertexT *second, *last;

  FOREACHridge_(facet->ridges) {
    neighbor= otherfacet_(ridge, facet);
    if (neighbor->visitid == qh->visit_id) {
      if (SETfirst_(ridge->vertices) == vertex) {
        qh_setappend(qh, ridges, ridge);
      }else if (last_i > 2) {
        second= SETsecondt_(ridge->vertices, vertexT);
        last= SETelemt_(ridge->vertices, last_i, vertexT);
        if (second->id >= vertex->id && last->id <= vertex->id) { /* vertices inverse sorted by id */
          if (second == vertex || last == vertex)
            qh_setappend(qh, ridges, ridge);
          else if (qh_setin(ridge->vertices, vertex))
            qh_setappend(qh, ridges, ridge);
        }
      }else if (SETelem_(ridge->vertices, last_i) == vertex
          || (last_i > 1 && SETsecond_(ridge->vertices) == vertex)) {
        qh_setappend(qh, ridges, ridge);
      }
    }
  }
  facet->visitid= qh->visit_id-1;
} /* vertexridges_facet */

/*---------------------------------

  qh_willdelete(qh, facet, replace )
    moves facet to visible list for qh_deletevisible
    sets facet->f.replace to replace (may be NULL)
    clears f.ridges and f.neighbors -- no longer valid

  returns:
    bumps qh.num_visible
*/
void qh_willdelete(qhT *qh, facetT *facet, facetT *replace) {

  trace4((qh, qh->ferr, 4081, "qh_willdelete: move f%d to visible list, set its replacement as f%d, and clear f.neighbors and f.ridges\n", facet->id, getid_(replace)));
  if (!qh->visible_list && qh->newfacet_list) {
    qh_fprintf(qh, qh->ferr, 6378, "qhull internal error (qh_willdelete): expecting qh.visible_list at before qh.newfacet_list f%d.   Got NULL\n",
        qh->newfacet_list->id);
    qh_errexit2(qh, qh_ERRqhull, NULL, NULL);
  }
  qh_removefacet(qh, facet);
  qh_prependfacet(qh, facet, &qh->visible_list);
  qh->num_visible++;
  facet->visible= True;
  facet->f.replace= replace;
  if (facet->ridges)
    SETfirst_(facet->ridges)= NULL;
  if (facet->neighbors)
    SETfirst_(facet->neighbors)= NULL;
} /* willdelete */

#else /* qh_NOmerge */

void qh_all_vertexmerges(qhT *qh, int apexpointid, facetT *facet, facetT **retryfacet) {
  QHULL_UNUSED(qh)
  QHULL_UNUSED(apexpointid)
  QHULL_UNUSED(facet)
  QHULL_UNUSED(retryfacet)
}
void qh_premerge(qhT *qh, int apexpointid, realT maxcentrum, realT maxangle) {
  QHULL_UNUSED(qh)
  QHULL_UNUSED(apexpointid)
  QHULL_UNUSED(maxcentrum)
  QHULL_UNUSED(maxangle)
}
void qh_postmerge(qhT *qh, const char *reason, realT maxcentrum, realT maxangle,
                      boolT vneighbors) {
  QHULL_UNUSED(qh)
  QHULL_UNUSED(reason)
  QHULL_UNUSED(maxcentrum)
  QHULL_UNUSED(maxangle)
  QHULL_UNUSED(vneighbors)
}
void qh_checkdelfacet(qhT *qh, facetT *facet, setT *mergeset) {
  QHULL_UNUSED(qh)
  QHULL_UNUSED(facet)
  QHULL_UNUSED(mergeset)
}
void qh_checkdelridge(qhT *qh /* qh.visible_facets, vertex_mergeset */) {
  QHULL_UNUSED(qh)
}
boolT qh_checkzero(qhT *qh, boolT testall) {
  QHULL_UNUSED(qh)
  QHULL_UNUSED(testall)
    
  return True;
}
void qh_freemergesets(qhT *qh) {
  QHULL_UNUSED(qh)
}
void qh_initmergesets(qhT *qh) {
  QHULL_UNUSED(qh)
}
void qh_merge_pinchedvertices(qhT *qh, int apexpointid /* qh.newfacet_list */) {
  QHULL_UNUSED(qh)
  QHULL_UNUSED(apexpointid)
}
#endif /* qh_NOmerge */

geometry/src/Rconvhulln.c0000644000176200001440000001311214664417655015212 0ustar  liggesusers/* Copyright (C) 2000 Kai Habel
** Copyright R-version (C) 2005 Raoul Grasman 
**                     (C) 2013-2015, 2017-2019 David Sterratt
**                     (C) 2018 Pavlo Mozharovskyi
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*/

/*
29. July 2000 - Kai Habel: first release
2002-04-22 Paul Kienzle
* Use Rf_warning(...) function rather than writing to cerr

23. May 2005 - Raoul Grasman: ported to R
* Changed the interface for R

02. February 2018 - Pavlo Mozharovskyi: added non-triangulated output
*/

#include "Rgeometry.h"

SEXP C_convhulln(const SEXP p, const SEXP options, const SEXP returnNonTriangulatedFacets, const SEXP tmp_stdout, const SEXP tmp_stderr)
{
  /* Initialise return values */
  SEXP retval, area, vol, normals, retlist, retnames;
  retval = area = vol = normals = retlist = R_NilValue;

  /* Run Qhull */
  qhT *qh= (qhT*)malloc(sizeof(qhT));
  char errstr[ERRSTRSIZE];
  unsigned int dim, n;
  char cmd[50] = "qhull";
  int exitcode = qhullNewQhull(qh, p, cmd,  options, tmp_stdout, tmp_stderr, &dim, &n, errstr);

  /* Error handling */
  if (exitcode) {
    freeQhull(qh);
    Rf_error("Received error code %d from qhull. Qhull error:\n%s", exitcode, errstr);
  }
  
  /* Extract information from output */
  int i, j, *idx;
  facetT *facet;              /* set by FORALLfacets */
  vertexT *vertex, **vertexp; /* set by FORALLfacets */
  unsigned int nf = qh->num_facets;
  unsigned int nVertexMax = 0;

  /* If parameter (flag) returnNonTriangulatedFacets is set, count the
     number of columns in the output matrix of vertices as the maximal
     number of vertices in a facet, then allocate the matrix. */
  if (INTEGER(returnNonTriangulatedFacets)[0] > 0){
    i = 0;
    FORALLfacets {
      j = 0;
      FOREACHvertex_ (facet->vertices) {
        j++;
      }
      if (j > nVertexMax){
        nVertexMax = j;
      }
    }
  } else {
    /* If parameter (flag) returnNonTriangulatedFacets is not set, the
       number of columns equals dimension. */
    nVertexMax = dim;
  }
  retval = PROTECT(Rf_allocMatrix(INTSXP, nf, nVertexMax));
  idx = (int *) R_alloc(nf*nVertexMax,sizeof(int));

  if (hasPrintOption(qh, qh_PRINTnormals)) {
    normals = PROTECT(Rf_allocMatrix(REALSXP, nf, dim+1));
  } else {
    normals = PROTECT(R_NilValue);
  }

  qh_vertexneighbors(qh);

  i = 0; /* Facet counter */
  FORALLfacets {
    j = 0;
    /* qh_printfacet(stdout,facet); */
    FOREACHvertex_ (facet->vertices) {
      /* qh_printvertex(stdout,vertex); */
      if (INTEGER(returnNonTriangulatedFacets)[0] == 0 && j >= dim)
        Rf_warning("extra vertex %d of facet %d = %d",
                j++, i, 1+qh_pointid(qh, vertex->point));
      else
        idx[i + nf*j++] = 1 + qh_pointid(qh, vertex->point);
    }
    if (j < dim) Rf_warning("facet %d only has %d vertices",i,j);
    while (j < nVertexMax){
      idx[i + nf*j++] = 0; /* Fill with zeros for the moment */
    }

    /* Output normals */
    if (hasPrintOption(qh, qh_PRINTnormals)) {
      if (facet->normal) {
        for (j=0; jnormal[j];
        }
        REAL(normals)[i + Rf_nrows(normals)*dim] = facet->offset;
      } else {
        for (j=0; j<=dim; j++) {
          REAL(normals)[i + Rf_nrows(normals)*j] = 0;
        }
      }
    }
    i++; /* Increment facet counter */
  }
  j = 0;
  for(i = 0; i 0){
        INTEGER(retval)[i + Rf_nrows(retval)*j] = idx[i + nf*j];
      } else {
        INTEGER(retval)[i + Rf_nrows(retval)*j] = NA_INTEGER;
      }

  /* Return area and volume - will be there when option "FA" is provided */
  if (qh->totarea != 0.0) {
    area = PROTECT(Rf_allocVector(REALSXP, 1));
    REAL(area)[0] = qh->totarea;
  } else {
    area = PROTECT(R_NilValue);
  }
  if (qh->totvol != 0.0) {
    vol = PROTECT(Rf_allocVector(REALSXP, 1));
    REAL(vol)[0] = qh->totvol;
  } else {
    vol = PROTECT(R_NilValue);
  }

  /* Set up output structure */
  retlist =  PROTECT(Rf_allocVector(VECSXP, 4));
  retnames = PROTECT(Rf_allocVector(VECSXP, 4));
  SET_VECTOR_ELT(retlist,  0, retval);
  SET_VECTOR_ELT(retnames, 0, Rf_mkChar("hull"));
  SET_VECTOR_ELT(retlist,  1, area);
  SET_VECTOR_ELT(retnames, 1, Rf_mkChar("area"));
  SET_VECTOR_ELT(retlist,  2, vol);
  SET_VECTOR_ELT(retnames, 2, Rf_mkChar("vol"));
  SET_VECTOR_ELT(retlist,  3, normals);
  SET_VECTOR_ELT(retnames, 3, Rf_mkChar("normals"));
  Rf_setAttrib(retlist, R_NamesSymbol, retnames);

  /* Register qhullFinalizer() for garbage collection and attach a
     pointer to the hull as an attribute for future use. */
  SEXP ptr, tag;
  tag = PROTECT(Rf_allocVector(STRSXP, 1));
  SET_STRING_ELT(tag, 0, Rf_mkChar("convhulln"));
  ptr = PROTECT(R_MakeExternalPtr(qh, tag, R_NilValue));
  R_RegisterCFinalizerEx(ptr, qhullFinalizer, TRUE);
  Rf_setAttrib(retlist, tag, ptr);

  UNPROTECT(8); /* ptr, tag, retnames, retlist, normals, vol, area, retval */

  return retlist;
}
geometry/src/userprintf_r.c0000644000176200001440000000655614664417655015620 0ustar  liggesusers/*
  ---------------------------------

  userprintf_r.c
  user redefinable function -- qh_fprintf

  see README.txt  see COPYING.txt for copyright information.

  If you recompile and load this file, then userprintf_r.o will not be loaded
  from qhull_r.a or qhull_r.lib

  See libqhull_r.h for data structures, macros, and user-callable functions.
  See user_r.c for qhull-related, redefinable functions
  see user_r.h for user-definable constants
  See usermem_r.c for qh_exit(), qh_free(), and qh_malloc()
  see Qhull.cpp and RboxPoints.cpp for examples.

  qh_printf is a good location for debugging traps, checked on each log line

  Please report any errors that you fix to qhull@qhull.org
*/

#include "libqhull_r.h"
#include "poly_r.h" /* for qh.tracefacet */

#include 
#include 
#include 

/*---------------------------------

  qh_fprintf(qh, fp, msgcode, format, list of args )
    print arguments to *fp according to format
    Use qh_fprintf_rbox() for rboxlib_r.c

  notes:
    sets qh.last_errcode if msgcode is error 6000..6999
    same as fprintf()
    fgets() is not trapped like fprintf()
    exit qh_fprintf via qh_errexit()
    may be called for errors in qh_initstatistics and qh_meminit
*/

void qh_fprintf(qhT *qh, FILE *fp, int msgcode, const char *fmt, ... ) {
  va_list args;
  facetT *neighbor, **neighborp;

  if (!fp) {
    if(!qh){
      qh_fprintf_stderr(6241, "qhull internal error (userprintf_r.c): fp and qh not defined for qh_fprintf '%s'\n", fmt);
      qh->last_errcode= 6241;
      qh_exit(qh_ERRqhull);  /* can not use qh_errexit() */
    }
    /* could use qh->qhmem.ferr, but probably better to be cautious */
    qh_fprintf_stderr(6028, "qhull internal error (userprintf_r.c): fp is 0.  Wrong qh_fprintf was called.\n");
    qh->last_errcode= 6028;
    qh_errexit(qh, qh_ERRqhull, NULL, NULL);
  }
  if ((qh && qh->ANNOTATEoutput) || msgcode < MSG_TRACE4) {
    fprintf(fp, "[QH%.4d]", msgcode);
  }else if (msgcode >= MSG_ERROR && msgcode < MSG_STDERR ) {
    fprintf(fp, "QH%.4d ", msgcode);
  }
  va_start(args, fmt);
  vfprintf(fp, fmt, args);
  va_end(args);
    
  if (qh) {
    if (msgcode >= MSG_ERROR && msgcode < MSG_WARNING)
      qh->last_errcode= msgcode;
    /* Place debugging traps here. Use with trace option 'Tn' 
       Set qh.tracefacet_id, qh.traceridge_id, and/or qh.tracevertex_id in global_r.c
    */
    if (False) { /* in production skip test for debugging traps */
      if (qh->tracefacet && qh->tracefacet->tested) {
        if (qh_setsize(qh, qh->tracefacet->neighbors) < qh->hull_dim)
          qh_errexit(qh, qh_ERRdebug, qh->tracefacet, qh->traceridge);
        FOREACHneighbor_(qh->tracefacet) {
          if (neighbor != qh_DUPLICATEridge && neighbor != qh_MERGEridge && neighbor->visible)
            qh_errexit2(qh, qh_ERRdebug, qh->tracefacet, neighbor);
        }
      } 
      if (qh->traceridge && qh->traceridge->top->id == 234342223) {
        qh_errexit(qh, qh_ERRdebug, qh->tracefacet, qh->traceridge);
      }
      if (qh->tracevertex && qh_setsize(qh, qh->tracevertex->neighbors)>3434334) {
        qh_errexit(qh, qh_ERRdebug, qh->tracefacet, qh->traceridge);
      }
    }
    if (qh->FLUSHprint)
      fflush(fp);
  }
} /* qh_fprintf */

geometry/src/merge_r.h0000644000176200001440000002757314664417655014525 0ustar  liggesusers/*
  ---------------------------------

   merge_r.h
   header file for merge_r.c

   see qh-merge_r.htm and merge_r.c

   Copyright (c) 1993-2020 C.B. Barber.
   $Id: //main/2019/qhull/src/libqhull_r/merge_r.h#2 $$Change: 2953 $
   $DateTime: 2020/05/21 22:05:32 $$Author: bbarber $
*/

#ifndef qhDEFmerge
#define qhDEFmerge 1

#include "libqhull_r.h"


/*============ -constants- ==============*/

/*----------------------------------

  qh_ANGLEnone
    indicates missing angle for mergeT->angle
*/
#define qh_ANGLEnone 2.0

/*----------------------------------

  MRG... (mergeType)
    indicates the type of a merge (mergeT->type)
    MRGcoplanar...MRGtwisted set by qh_test_centrum_merge, qh_test_nonsimplicial_merge
*/
typedef enum {  /* must match mergetypes[] */
  MRGnone= 0,
                  /* MRGcoplanar..MRGtwisted go into qh.facet_mergeset for qh_all_merges 
                     qh_compare_facetmerge selects lower mergetypes for merging first */
  MRGcoplanar,          /* (1) centrum coplanar if centrum ('Cn') or vertex not clearly above or below neighbor */
  MRGanglecoplanar,     /* (2) angle coplanar if angle ('An') is coplanar */
  MRGconcave,           /* (3) concave ridge */
  MRGconcavecoplanar,   /* (4) concave and coplanar ridge, one side concave, other side coplanar */
  MRGtwisted,           /* (5) twisted ridge, both concave and convex, facet1 is wider */
                  /* MRGflip go into qh.facet_mergeset for qh_flipped_merges */
  MRGflip,              /* (6) flipped facet if qh.interior_point is above facet, w/ facet1 == facet2 */
                  /* MRGdupridge go into qh.facet_mergeset for qh_forcedmerges */
  MRGdupridge,          /* (7) dupridge if more than two neighbors.  Set by qh_mark_dupridges for qh_MERGEridge */
                  /* MRGsubridge and MRGvertices go into vertex_mergeset */
  MRGsubridge,          /* (8) merge pinched vertex to remove the subridge of a MRGdupridge */
  MRGvertices,          /* (9) merge pinched vertex to remove a facet's ridges with the same vertices */
                  /* MRGdegen, MRGredundant, and MRGmirror go into qh.degen_mergeset */
  MRGdegen,             /* (10) degenerate facet (!enough neighbors) facet1 == facet2 */
  MRGredundant,         /* (11) redundant facet (vertex subset) */
                        /* merge_degenredundant assumes degen < redundant */
  MRGmirror,            /* (12) mirror facets: same vertices due to null facets in qh_triangulate 
                           f.redundant for both facets*/
                  /* MRGcoplanarhorizon for qh_mergecycle_all only */
  MRGcoplanarhorizon,   /* (13) new facet coplanar with the horizon (qh_mergecycle_all) */
  ENDmrg
} mergeType;

/*----------------------------------

  qh_MERGEapex
    flag for qh_mergefacet() to indicate an apex merge
*/
#define qh_MERGEapex     True

/*============ -structures- ====================*/

/*----------------------------------

  mergeT
    structure used to merge facets
*/

typedef struct mergeT mergeT;
struct mergeT {         /* initialize in qh_appendmergeset */
  realT   angle;        /* cosine of angle between normals of facet1 and facet2, 
                           null value and right angle is 0.0, coplanar is 1.0, narrow is -1.0 */
  realT   distance;     /* absolute value of distance between vertices, centrum and facet, or vertex and facet */
  facetT *facet1;       /* will merge facet1 into facet2 */
  facetT *facet2;
  vertexT *vertex1;     /* will merge vertext1 into vertex2 for MRGsubridge or MRGvertices */
  vertexT *vertex2;
  ridgeT  *ridge1;      /* the duplicate ridges resolved by MRGvertices */
  ridgeT  *ridge2;      /* merge is deleted if either ridge is deleted (qh_delridge) */
  mergeType mergetype;
};


/*=========== -macros- =========================*/

/*----------------------------------

  FOREACHmerge_( merges ) {...}
    assign 'merge' to each merge in merges

  notes:
    uses 'mergeT *merge, **mergep;'
    if qh_mergefacet(),
      restart or use qh_setdellast() since qh.facet_mergeset may change
    see FOREACHsetelement_
*/
#define FOREACHmerge_(merges) FOREACHsetelement_(mergeT, merges, merge)

/*----------------------------------

  FOREACHmergeA_( vertices ) { ... }
    assign 'mergeA' to each merge in merges

  notes:
    uses 'mergeT *mergeA, *mergeAp;'
    see FOREACHsetelement_
*/
#define FOREACHmergeA_(merges) FOREACHsetelement_(mergeT, merges, mergeA)

/*----------------------------------

  FOREACHmerge_i_(qh, vertices ) { ... }
    assign 'merge' and 'merge_i' for each merge in mergeset

  declare:
    mergeT *merge;
    int     merge_n, merge_i;

  see:
    FOREACHsetelement_i_
*/
#define FOREACHmerge_i_(qh, mergeset) FOREACHsetelement_i_(qh, mergeT, mergeset, merge)

/*============ prototypes in alphabetical order after pre/postmerge =======*/

#ifdef __cplusplus
extern "C" {
#endif

void    qh_premerge(qhT *qh, int apexpointid, realT maxcentrum, realT maxangle);
void    qh_postmerge(qhT *qh, const char *reason, realT maxcentrum, realT maxangle,
             boolT vneighbors);
void    qh_all_merges(qhT *qh, boolT othermerge, boolT vneighbors);
void    qh_all_vertexmerges(qhT *qh, int apexpointid, facetT *facet, facetT **retryfacet);
void    qh_appendmergeset(qhT *qh, facetT *facet, facetT *neighbor, mergeType mergetype, coordT dist, realT angle);
void    qh_appendvertexmerge(qhT *qh, vertexT *vertex, vertexT *destination, mergeType mergetype, realT distance, ridgeT *ridge1, ridgeT *ridge2);
setT   *qh_basevertices(qhT *qh, facetT *samecycle);
void    qh_check_dupridge(qhT *qh, facetT *facet1, realT dist1, facetT *facet2, realT dist2);
void    qh_checkconnect(qhT *qh /* qh.new_facets */);
void    qh_checkdelfacet(qhT *qh, facetT *facet, setT *mergeset);
void    qh_checkdelridge(qhT *qh /* qh.visible_facets, vertex_mergeset */);
boolT   qh_checkzero(qhT *qh, boolT testall);
int     qh_compare_anglemerge(const void *p1, const void *p2);
int     qh_compare_facetmerge(const void *p1, const void *p2);
int     qh_comparevisit(const void *p1, const void *p2);
void    qh_copynonconvex(qhT *qh, ridgeT *atridge);
void    qh_degen_redundant_facet(qhT *qh, facetT *facet);
void    qh_drop_mergevertex(qhT *qh, mergeT *merge);
void    qh_delridge_merge(qhT *qh, ridgeT *ridge);
vertexT *qh_find_newvertex(qhT *qh, vertexT *oldvertex, setT *vertices, setT *ridges);
vertexT *qh_findbest_pinchedvertex(qhT *qh, mergeT *merge, vertexT *apex, vertexT **pinchedp, realT *distp /* qh.newfacet_list */);
vertexT *qh_findbest_ridgevertex(qhT *qh, ridgeT *ridge, vertexT **pinchedp, coordT *distp);
void    qh_findbest_test(qhT *qh, boolT testcentrum, facetT *facet, facetT *neighbor,
           facetT **bestfacet, realT *distp, realT *mindistp, realT *maxdistp);
facetT *qh_findbestneighbor(qhT *qh, facetT *facet, realT *distp, realT *mindistp, realT *maxdistp);
void    qh_flippedmerges(qhT *qh, facetT *facetlist, boolT *wasmerge);
void    qh_forcedmerges(qhT *qh, boolT *wasmerge);
void    qh_freemergesets(qhT *qh);
void    qh_getmergeset(qhT *qh, facetT *facetlist);
void    qh_getmergeset_initial(qhT *qh, facetT *facetlist);
boolT   qh_getpinchedmerges(qhT *qh, vertexT *apex, coordT maxdupdist, boolT *iscoplanar /* qh.newfacet_list, vertex_mergeset */);
boolT   qh_hasmerge(setT *mergeset, mergeType type, facetT *facetA, facetT *facetB);
void    qh_hashridge(qhT *qh, setT *hashtable, int hashsize, ridgeT *ridge, vertexT *oldvertex);
ridgeT *qh_hashridge_find(qhT *qh, setT *hashtable, int hashsize, ridgeT *ridge,
              vertexT *vertex, vertexT *oldvertex, int *hashslot);
void    qh_initmergesets(qhT *qh);
void    qh_makeridges(qhT *qh, facetT *facet);
void    qh_mark_dupridges(qhT *qh, facetT *facetlist, boolT allmerges);
void    qh_maybe_duplicateridge(qhT *qh, ridgeT *ridge);
void    qh_maybe_duplicateridges(qhT *qh, facetT *facet);
void    qh_maydropneighbor(qhT *qh, facetT *facet);
int     qh_merge_degenredundant(qhT *qh);
void    qh_merge_nonconvex(qhT *qh, facetT *facet1, facetT *facet2, mergeType mergetype);
void    qh_merge_pinchedvertices(qhT *qh, int apexpointid /* qh.newfacet_list */);
void    qh_merge_twisted(qhT *qh, facetT *facet1, facetT *facet2);
void    qh_mergecycle(qhT *qh, facetT *samecycle, facetT *newfacet);
void    qh_mergecycle_all(qhT *qh, facetT *facetlist, boolT *wasmerge);
void    qh_mergecycle_facets(qhT *qh, facetT *samecycle, facetT *newfacet);
void    qh_mergecycle_neighbors(qhT *qh, facetT *samecycle, facetT *newfacet);
void    qh_mergecycle_ridges(qhT *qh, facetT *samecycle, facetT *newfacet);
void    qh_mergecycle_vneighbors(qhT *qh, facetT *samecycle, facetT *newfacet);
void    qh_mergefacet(qhT *qh, facetT *facet1, facetT *facet2, mergeType mergetype, realT *mindist, realT *maxdist, boolT mergeapex);
void    qh_mergefacet2d(qhT *qh, facetT *facet1, facetT *facet2);
void    qh_mergeneighbors(qhT *qh, facetT *facet1, facetT *facet2);
void    qh_mergeridges(qhT *qh, facetT *facet1, facetT *facet2);
void    qh_mergesimplex(qhT *qh, facetT *facet1, facetT *facet2, boolT mergeapex);
void    qh_mergevertex_del(qhT *qh, vertexT *vertex, facetT *facet1, facetT *facet2);
void    qh_mergevertex_neighbors(qhT *qh, facetT *facet1, facetT *facet2);
void    qh_mergevertices(qhT *qh, setT *vertices1, setT **vertices);
setT   *qh_neighbor_intersections(qhT *qh, vertexT *vertex);
setT   *qh_neighbor_vertices(qhT *qh, vertexT *vertex, setT *subridge);
void    qh_neighbor_vertices_facet(qhT *qh, vertexT *vertexA, facetT *facet, setT **vertices);
void    qh_newvertices(qhT *qh, setT *vertices);
mergeT *qh_next_vertexmerge(qhT *qh);
facetT *qh_opposite_horizonfacet(qhT *qh, mergeT *merge, vertexT **vertex);
boolT   qh_reducevertices(qhT *qh);
vertexT *qh_redundant_vertex(qhT *qh, vertexT *vertex);
boolT   qh_remove_extravertices(qhT *qh, facetT *facet);
void    qh_remove_mergetype(qhT *qh, setT *mergeset, mergeType type);
void    qh_rename_adjacentvertex(qhT *qh, vertexT *oldvertex, vertexT *newvertex, realT dist);
vertexT *qh_rename_sharedvertex(qhT *qh, vertexT *vertex, facetT *facet);
boolT   qh_renameridgevertex(qhT *qh, ridgeT *ridge, vertexT *oldvertex, vertexT *newvertex);
void    qh_renamevertex(qhT *qh, vertexT *oldvertex, vertexT *newvertex, setT *ridges,
                        facetT *oldfacet, facetT *neighborA);
boolT   qh_test_appendmerge(qhT *qh, facetT *facet, facetT *neighbor, boolT simplicial);
void    qh_test_degen_neighbors(qhT *qh, facetT *facet);
boolT   qh_test_centrum_merge(qhT *qh, facetT *facet, facetT *neighbor, realT angle, boolT okangle);
boolT   qh_test_nonsimplicial_merge(qhT *qh, facetT *facet, facetT *neighbor, realT angle, boolT okangle);
void    qh_test_redundant_neighbors(qhT *qh, facetT *facet);
boolT   qh_test_vneighbors(qhT *qh /* qh.newfacet_list */);
void    qh_tracemerge(qhT *qh, facetT *facet1, facetT *facet2, mergeType mergetype);
void    qh_tracemerging(qhT *qh);
void    qh_undo_newfacets(qhT *qh);
void    qh_updatetested(qhT *qh, facetT *facet1, facetT *facet2);
setT   *qh_vertexridges(qhT *qh, vertexT *vertex, boolT allneighbors);
void    qh_vertexridges_facet(qhT *qh, vertexT *vertex, facetT *facet, setT **ridges);
void    qh_willdelete(qhT *qh, facetT *facet, facetT *replace);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* qhDEFmerge */
geometry/src/Rhalfspacen.c0000644000176200001440000000633514664417655015317 0ustar  liggesusers/* Copyright (C) 2018, 2019 David Sterratt
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
*/

#include "Rgeometry.h"
#include "qhull_ra.h"
#include               /* For unlink() */

SEXP C_halfspacen(const SEXP p, const SEXP options, const SEXP tmp_stdout, const SEXP tmp_stderr)
{
  /* Return value*/
  SEXP retval;

  /* Run Qhull */
  qhT *qh= (qhT*)malloc(sizeof(qhT));
  char errstr[ERRSTRSIZE];
  unsigned int dim, n;
  char cmd[50] = "qhull H";
  int exitcode = qhullNewQhull(qh, p, cmd,  options, tmp_stdout, tmp_stdout, &dim, &n, errstr);

  /* If error */
  if (exitcode) {
    freeQhull(qh);
    Rf_error("Received error code %d from qhull. Qhull error:\n%s", exitcode, errstr);
  }

  if (!qh->feasible_point) {
    freeQhull(qh);
    Rf_error("qhull input error (qh_printafacet): option 'Fp' needs qh->feasible_point");
  }
  
  /* Extract information from output */
  int i;
  facetT *facet;
  boolT zerodiv;
  coordT *point, *normp, *coordp, *feasiblep;
    
  /* Count facets. Perhaps a better way of doing this is: 
     int numfacets, numsimplicial, numridges, totneighbors, numcoplanars, numtricoplanars;
     int num;
     qh_countfacets(qh, NULL, facets, printall, &numfacets, &numsimplicial,
     &totneighbors, &numridges, &numcoplanars, &numtricoplanars); */
  int nf = 0;
  FORALLfacets {
    nf++;
  }

  /* Output of intersections based on case qh_PRINTpointintersect:
     qh_printafacet() in io_r.c . This corresponds to the "Fp"
     option to the qhull program */
  retval = PROTECT(Rf_allocMatrix(REALSXP, nf, dim-1));
  int k;
  i=0; /* Facet counter */
  FORALLfacets {
    point = coordp = (coordT*)qh_memalloc(qh, qh->normal_size);
    if (facet->offset > 0) {
      for (k=qh->hull_dim; k--; ) {
        point[k] = R_PosInf;
      }
    } else {
      normp = facet->normal;
      feasiblep = qh->feasible_point;
      if (facet->offset < -qh->MINdenom) {
        for (k=qh->hull_dim; k--; )
          *(coordp++) = (*(normp++) / - facet->offset) + *(feasiblep++);
      } else {
        for (k=qh->hull_dim; k--; ) {
          *(coordp++) = qh_divzero(*(normp++), facet->offset, qh->MINdenom_1,
                                   &zerodiv) + *(feasiblep++);
          if (zerodiv) {
            for (k=qh->hull_dim; k--; ) {
              point[k] = R_PosInf;
            }
          }
        }
      }
    }
    /* qh_printpoint(qh, fp, NULL, point); */
    for (k=0; khull_dim; k++) {
      REAL(retval)[i + k*nf] = point[k];
    }
    qh_memfree(qh, point, qh->normal_size);
    i++; /* Increment facet counter */
  }

  freeQhull(qh);
  UNPROTECT(1);

  return retval;
}
geometry/src/libqhull_r.h0000644000176200001440000016647714740034715015234 0ustar  liggesusers/*
  ---------------------------------

   libqhull_r.h
   user-level header file for using qhull.a library

   see qh-qhull_r.htm, qhull_ra.h

   Copyright (c) 1993-2020 The Geometry Center.
   $Id: //main/2019/qhull/src/libqhull_r/libqhull_r.h#16 $$Change: 3037 $
   $DateTime: 2020/09/03 17:28:32 $$Author: bbarber $

   includes function prototypes for libqhull_r.c, geom_r.c, global_r.c, io_r.c, user_r.c

   use mem_r.h for mem_r.c
   use qset_r.h for qset_r.c

   see unix_r.c for an example of using libqhull_r.h

   recompile qhull if you change this file
*/

#ifndef qhDEFlibqhull
#define qhDEFlibqhull 1

/*=========================== -included files ==============*/

/* user_r.h first for QHULL_CRTDBG */
#include "user_r.h"      /* user definable constants (e.g., realT). */

#include "mem_r.h"   /* Needed for qhT in libqhull_r.h */
#include "qset_r.h"   /* Needed for QHULL_LIB_CHECK */
/* include stat_r.h after defining boolT.  Needed for qhT in libqhull_r.h */

#include 
#include 
#include 
#include 
#include 

#ifndef __STDC__
#ifndef __cplusplus
#if     !defined(_MSC_VER)
#error  Neither __STDC__ nor __cplusplus is defined.  Please use strict ANSI C or C++ to compile
#error  Qhull.  You may need to turn off compiler extensions in your project configuration.  If
#error  your compiler is a standard C compiler, you can delete this warning from libqhull_r.h
#endif
#endif
#endif

/*============ constants and basic types ====================*/

extern const char qh_version[]; /* defined in global_r.c */
extern const char qh_version2[]; /* defined in global_r.c */

/*----------------------------------

  coordT
    coordinates and coefficients are stored as realT (i.e., double)

  notes:
    Qhull works well if realT is 'float'.  If so joggle (QJ) is not effective.

    Could use 'float' for data and 'double' for calculations (realT vs. coordT)
      This requires many type casts, and adjusted error bounds.
      Also C compilers may do expressions in double anyway.
*/
#define coordT realT

/*----------------------------------

  pointT
    a point is an array of coordinates, usually qh.hull_dim
    qh_pointid returns
      qh_IDnone if point==0 or qh is undefined
      qh_IDinterior for qh.interior_point
      qh_IDunknown if point is neither in qh.first_point... nor qh.other_points

  notes:
    qh.STOPcone and qh.STOPpoint assume that qh_IDunknown==-1 (other negative numbers indicate points)
    qh_IDunknown is also returned by getid_() for unknown facet, ridge, or vertex
*/
#define pointT coordT
typedef enum
{
    qh_IDnone= -3, qh_IDinterior= -2, qh_IDunknown= -1
}
qh_pointT;

/*----------------------------------

  flagT
    Boolean flag as a bit
*/
#define flagT unsigned int

/*----------------------------------

  boolT
    boolean value, either True or False

  notes:
    needed for portability
    Use qh_False/qh_True as synonyms
*/
#define boolT unsigned int
#ifdef False
#undef False
#endif
#ifdef True
#undef True
#endif
#define False 0
#define True 1
#define qh_False 0
#define qh_True 1

#include "stat_r.h"  /* needs boolT */

/*----------------------------------

  qh_CENTER
    to distinguish facet->center
*/
typedef enum
{
    qh_ASnone= 0,    /* If not MERGING and not VORONOI */
    qh_ASvoronoi,    /* Set by qh_clearcenters on qh_prepare_output, or if not MERGING and VORONOI */
    qh_AScentrum     /* If MERGING (assumed during merging) */
}
qh_CENTER;

/*----------------------------------

  qh_PRINT
    output formats for printing (qh.PRINTout).
    'Fa' 'FV' 'Fc' 'FC'


   notes:
   some of these names are similar to qhT names.  The similar names are only
   used in switch statements in qh_printbegin() etc.
*/
typedef enum {qh_PRINTnone= 0,
  qh_PRINTarea, qh_PRINTaverage,           /* 'Fa' 'FV' 'Fc' 'FC' */
  qh_PRINTcoplanars, qh_PRINTcentrums,
  qh_PRINTfacets, qh_PRINTfacets_xridge,   /* 'f' 'FF' 'G' 'FI' 'Fi' 'Fn' */
  qh_PRINTgeom, qh_PRINTids, qh_PRINTinner, qh_PRINTneighbors,
  qh_PRINTnormals, qh_PRINTouter, qh_PRINTmaple, /* 'n' 'Fo' 'i' 'm' 'Fm' 'FM', 'o' */
  qh_PRINTincidences, qh_PRINTmathematica, qh_PRINTmerges, qh_PRINToff,
  qh_PRINToptions, qh_PRINTpointintersect, /* 'FO' 'Fp' 'FP' 'p' 'FQ' 'FS' */
  qh_PRINTpointnearest, qh_PRINTpoints, qh_PRINTqhull, qh_PRINTsize,
  qh_PRINTsummary, qh_PRINTtriangles,      /* 'Fs' 'Ft' 'Fv' 'FN' 'Fx' */
  qh_PRINTvertices, qh_PRINTvneighbors, qh_PRINTextremes,
  qh_PRINTEND} qh_PRINT;

/*----------------------------------

  qh_ALL
    argument flag for selecting everything
*/
#define qh_ALL      True
#define qh_NOupper  True      /* argument for qh_findbest */
#define qh_IScheckmax  True   /* argument for qh_findbesthorizon */
#define qh_ISnewfacets  True  /* argument for qh_findbest */
#define qh_RESETvisible  True /* argument for qh_resetlists */

/*----------------------------------

  qh_ERR...
    Qhull exit status codes, for indicating errors
    See: MSG_ERROR (6000) and MSG_WARNING (7000) [user_r.h]
*/
#define qh_ERRnone  0    /* no error occurred during qhull */
#define qh_ERRinput 1    /* input inconsistency */
#define qh_ERRsingular 2 /* singular input data, calls qh_printhelp_singular */
#define qh_ERRprec  3    /* precision error, calls qh_printhelp_degenerate */
#define qh_ERRmem   4    /* insufficient memory, matches mem_r.h */
#define qh_ERRqhull 5    /* internal error detected, matches mem_r.h, calls qh_printhelp_internal */
#define qh_ERRother 6    /* other error detected */
#define qh_ERRtopology 7 /* topology error, maybe due to nearly adjacent vertices, calls qh_printhelp_topology */
#define qh_ERRwide 8     /* wide facet error, maybe due to nearly adjacent vertices, calls qh_printhelp_wide */
#define qh_ERRdebug 9    /* qh_errexit from debugging code */

/*----------------------------------

qh_FILEstderr
Fake stderr to distinguish error output from normal output
For C++ interface.  Must redefine qh_fprintf_qhull
*/
#define qh_FILEstderr ((FILE *)1)

/* ============ -structures- ====================
   each of the following structures is defined by a typedef
   all realT and coordT fields occur at the beginning of a structure
        (otherwise space may be wasted due to alignment)
   define all flags together and pack into 32-bit number

   DEFqhT and DEFsetT are likewise defined in mem_r.h, qset_r.h, and stat_r.h
*/

typedef struct vertexT vertexT;
typedef struct ridgeT ridgeT;
typedef struct facetT facetT;

#ifndef DEFqhT
#define DEFqhT 1
typedef struct qhT qhT;          /* defined below */
#endif

#ifndef DEFsetT
#define DEFsetT 1
typedef struct setT setT;        /* defined in qset_r.h */
#endif

/*----------------------------------

  facetT
    defines a facet

  notes:
   qhull() generates the hull as a list of facets.

  topological information:
    f.previous,next     doubly-linked list of facets, next is always defined
    f.vertices          set of vertices
    f.ridges            set of ridges
    f.neighbors         set of neighbors
    f.toporient         True if facet has top-orientation (else bottom)

  geometric information:
    f.offset,normal     hyperplane equation
    f.maxoutside        offset to outer plane -- all points inside
    f.center            centrum for testing convexity or Voronoi center for output
    f.simplicial        True if facet is simplicial
    f.flipped           True if facet does not include qh.interior_point

  for constructing hull:
    f.visible           True if facet on list of visible facets (will be deleted)
    f.newfacet          True if facet on list of newly created facets
    f.coplanarset       set of points coplanar with this facet
                        (includes near-inside points for later testing)
    f.outsideset        set of points outside of this facet
    f.furthestdist      distance to furthest point of outside set
    f.visitid           marks visited facets during a loop
    f.replace           replacement facet for to-be-deleted, visible facets
    f.samecycle,newcycle cycle of facets for merging into horizon facet

  see below for other flags and fields
*/
/* QhullFacet.cpp -- Update static initializer list for s_empty_facet if add or remove fields */
struct facetT {
#if !qh_COMPUTEfurthest
  coordT   furthestdist;/* distance to furthest point of outsideset */
#endif
#if qh_MAXoutside
  coordT   maxoutside;  /* max computed distance of point to facet
                        Before QHULLfinished this is an approximation
                        since maxdist not always set for qh_mergefacet
                        Actual outer plane is +DISTround and
                        computed outer plane is +2*DISTround.
                        Initial maxoutside is qh.DISTround, otherwise distance tests need to account for DISTround */
#endif
  coordT   offset;      /* exact offset of hyperplane from origin */
  coordT  *normal;      /* normal of hyperplane, hull_dim coefficients */
                        /*   if f.tricoplanar, shared with a neighbor */
  union {               /* in order of testing */
   realT   area;        /* area of facet, only in io_r.c if  f.isarea */
   facetT *replace;     /* replacement facet for qh.NEWfacets with f.visible
                             NULL if qh_mergedegen_redundant, interior, or !NEWfacets */
   facetT *samecycle;   /* cycle of facets from the same visible/horizon intersection,
                             if ->newfacet */
   facetT *newcycle;    /*  in horizon facet, current samecycle of new facets */
   facetT *trivisible;  /* visible facet for ->tricoplanar facets during qh_triangulate() */
   facetT *triowner;    /* owner facet for ->tricoplanar, !isarea facets w/ ->keepcentrum */
  }f;
  coordT  *center;      /* set according to qh.CENTERtype */
                        /*   qh_ASnone:    no center (not MERGING) */
                        /*   qh_AScentrum: centrum for testing convexity (qh_getcentrum) */
                        /*                 assumed qh_AScentrum while merging */
                        /*   qh_ASvoronoi: Voronoi center (qh_facetcenter) */
                        /* after constructing the hull, it may be changed (qh_clearcenter) */
                        /* if tricoplanar and !keepcentrum, shared with a neighbor */
  facetT  *previous;    /* previous facet in the facet_list or NULL, for C++ interface */
  facetT  *next;        /* next facet in the facet_list or facet_tail */
  setT    *vertices;    /* vertices for this facet, inverse sorted by ID
                           if simplicial, 1st vertex was apex/furthest
                           qh_reduce_vertices removes extraneous vertices via qh_remove_extravertices
                           if f.visible, vertices may be on qh.del_vertices */
  setT    *ridges;      /* explicit ridges for nonsimplicial facets or nonsimplicial neighbors.
                           For simplicial facets, neighbors define the ridges
                           qh_makeridges() converts simplicial facets by creating ridges prior to merging
                           If qh.NEWtentative, new facets have horizon ridge, but not vice versa
                           if f.visible && qh.NEWfacets, ridges is empty */
  setT    *neighbors;   /* neighbors of the facet.  Neighbors may be f.visible
                           If simplicial, the kth neighbor is opposite the kth vertex and the
                           first neighbor is the horizon facet for the first vertex.
                           dupridges marked by qh_DUPLICATEridge (0x01) and qh_MERGEridge (0x02)
                           if f.visible && qh.NEWfacets, neighbors is empty */
  setT    *outsideset;  /* set of points outside this facet
                           if non-empty, last point is furthest
                           if NARROWhull, includes coplanars (less than qh.MINoutside) for partitioning*/
  setT    *coplanarset; /* set of points coplanar with this facet
                           >= qh.min_vertex and <= facet->max_outside
                           a point is assigned to the furthest facet
                           if non-empty, last point is furthest away */
  unsigned int visitid; /* visit_id, for visiting all neighbors,
                           all uses are independent */
  unsigned int id;      /* unique identifier from qh.facet_id, 1..qh.facet_id, 0 is sentinel, printed as 'f%d' */
  unsigned int nummerge:9; /* number of merges */
#define qh_MAXnummerge 511 /* 2^9-1 */
                        /* 23 flags (at most 23 due to nummerge), printed by "flags:" in io_r.c */
  flagT    tricoplanar:1; /* True if TRIangulate and simplicial and coplanar with a neighbor */
                          /*   all tricoplanars share the same apex */
                          /*   all tricoplanars share the same ->center, ->normal, ->offset, ->maxoutside */
                          /*     ->keepcentrum is true for the owner.  It has the ->coplanareset */
                          /*   if ->degenerate, does not span facet (one logical ridge) */
                          /*   during qh_triangulate, f.trivisible points to original facet */
  flagT    newfacet:1;  /* True if facet on qh.newfacet_list (new/qh.first_newfacet or merged) */
  flagT    visible:1;   /* True if visible facet (will be deleted) */
  flagT    toporient:1; /* True if created with top orientation
                           after merging, use ridge orientation */
  flagT    simplicial:1;/* True if simplicial facet, ->ridges may be implicit */
  flagT    seen:1;      /* used to perform operations only once, like visitid */
  flagT    seen2:1;     /* used to perform operations only once, like visitid */
  flagT    flipped:1;   /* True if facet is flipped */
  flagT    upperdelaunay:1; /* True if facet is upper envelope of Delaunay triangulation */
  flagT    notfurthest:1; /* True if last point of outsideset is not furthest */

/*-------- flags primarily for output ---------*/
  flagT    good:1;      /* True if a facet marked good for output */
  flagT    isarea:1;    /* True if facet->f.area is defined */

/*-------- flags for merging ------------------*/
  flagT    dupridge:1;  /* True if facet has one or more dupridge in a new facet (qh_matchneighbor),
                             a dupridge has a subridge shared by more than one new facet */
  flagT    mergeridge:1; /* True if facet or neighbor has a qh_MERGEridge (qh_mark_dupridges)
                            ->normal defined for mergeridge and mergeridge2 */
  flagT    mergeridge2:1; /* True if neighbor has a qh_MERGEridge (qh_mark_dupridges) */
  flagT    coplanarhorizon:1;  /* True if horizon facet is coplanar at last use */
  flagT     mergehorizon:1; /* True if will merge into horizon (its first neighbor w/ f.coplanarhorizon). */
  flagT     cycledone:1;/* True if mergecycle_all already done */
  flagT    tested:1;    /* True if facet convexity has been tested (false after merge */
  flagT    keepcentrum:1; /* True if keep old centrum after a merge, or marks owner for ->tricoplanar
                             Set by qh_updatetested if more than qh_MAXnewcentrum extra vertices
                             Set by qh_mergefacet if |maxdist| > qh.WIDEfacet */
  flagT    newmerge:1;  /* True if facet is newly merged for reducevertices */
  flagT    degenerate:1; /* True if facet is degenerate (degen_mergeset or ->tricoplanar) */
  flagT    redundant:1;  /* True if facet is redundant (degen_mergeset)
                         Maybe merge degenerate and redundant to gain another flag */
};


/*----------------------------------

  ridgeT
    defines a ridge

  notes:
  a ridge is hull_dim-1 simplex between two neighboring facets.  If the
  facets are non-simplicial, there may be more than one ridge between
  two facets.  E.G. a 4-d hypercube has two triangles between each pair
  of neighboring facets.

  topological information:
    vertices            a set of vertices
    top,bottom          neighboring facets with orientation

  geometric information:
    tested              True if ridge is clearly convex
    nonconvex           True if ridge is non-convex
*/
/* QhullRidge.cpp -- Update static initializer list for s_empty_ridge if add or remove fields */
struct ridgeT {
  setT    *vertices;    /* vertices belonging to this ridge, inverse sorted by ID
                           NULL if a degen ridge (matchsame) */
  facetT  *top;         /* top facet for this ridge */
  facetT  *bottom;      /* bottom facet for this ridge
                        ridge oriented by odd/even vertex order and top/bottom */
  unsigned int id;      /* unique identifier.  Same size as vertex_id, printed as 'r%d' */
  flagT    seen:1;      /* used to perform operations only once */
  flagT    tested:1;    /* True when ridge is tested for convexity by centrum or opposite vertices */
  flagT    nonconvex:1; /* True if getmergeset detected a non-convex neighbor
                           only one ridge between neighbors may have nonconvex */
  flagT    mergevertex:1; /* True if pending qh_appendvertexmerge due to
                             qh_maybe_duplicateridge or qh_maybe_duplicateridges
                             disables check for duplicate vertices in qh_checkfacet */
  flagT    mergevertex2:1; /* True if qh_drop_mergevertex of MRGvertices, printed but not used */
  flagT    simplicialtop:1; /* True if top was simplicial (original vertices) */
  flagT    simplicialbot:1; /* True if bottom was simplicial (original vertices)
                             use qh_test_centrum_merge if top and bot, need to retest since centrum may change */
};

/*----------------------------------

  vertexT
     defines a vertex

  topological information:
    next,previous       doubly-linked list of all vertices
    neighbors           set of adjacent facets (only if qh.VERTEXneighbors)

  geometric information:
    point               array of DIM3 coordinates
*/
/* QhullVertex.cpp -- Update static initializer list for s_empty_vertex if add or remove fields */
struct vertexT {
  vertexT *next;        /* next vertex in vertex_list or vertex_tail */
  vertexT *previous;    /* previous vertex in vertex_list or NULL, for C++ interface */
  pointT  *point;       /* hull_dim coordinates (coordT) */
  setT    *neighbors;   /* neighboring facets of vertex, qh_vertexneighbors()
                           initialized in io_r.c or after first merge
                           qh_update_vertices for qh_addpoint or qh_triangulate
                           updated by merges
                           qh_order_vertexneighbors by 2-d (orientation) 3-d (adjacency), n-d (f.visitid,id) */
  unsigned int id;      /* unique identifier, 1..qh.vertex_id,  0 for sentinel, printed as 'r%d' */
  unsigned int visitid; /* for use with qh.vertex_visit, size must match */
  flagT    seen:1;      /* used to perform operations only once */
  flagT    seen2:1;     /* another seen flag */
  flagT    deleted:1;   /* vertex will be deleted via qh.del_vertices */
  flagT    delridge:1;  /* vertex belonged to a deleted ridge, cleared by qh_reducevertices */
  flagT    newfacet:1;  /* true if vertex is in a new facet
                           vertex is on qh.newvertex_list and it has a facet on qh.newfacet_list
                           or vertex is on qh.newvertex_list due to qh_newvertices while merging
                           cleared by qh_resetlists */
  flagT    partitioned:1; /* true if deleted vertex has been partitioned */
};

/*======= -global variables -qh ============================*/

/*----------------------------------

  qhT
   All global variables for qhull are in qhT.  It includes qhmemT, qhstatT, and rbox globals

   This version of Qhull is reentrant, but it is not thread-safe.

   Do not run separate threads on the same instance of qhT.

   QHULL_LIB_CHECK checks that a program and the corresponding
   qhull library were built with the same type of header files.

   QHULL_LIB_TYPE is QHULL_NON_REENTRANT, QHULL_QH_POINTER, or QHULL_REENTRANT
*/

#define QHULL_NON_REENTRANT 0
#define QHULL_QH_POINTER 1
#define QHULL_REENTRANT 2

#define QHULL_LIB_TYPE QHULL_REENTRANT

#define QHULL_LIB_CHECK qh_lib_check(QHULL_LIB_TYPE, sizeof(qhT), sizeof(vertexT), sizeof(ridgeT), sizeof(facetT), SETbasesize, sizeof(qhmemT));
#define QHULL_LIB_CHECK_RBOX qh_lib_check(QHULL_LIB_TYPE, sizeof(qhT), sizeof(vertexT), sizeof(ridgeT), sizeof(facetT), 0, 0);

struct qhT {

/*----------------------------------

  qh constants
    configuration flags and constants for Qhull

  notes:
    The user configures Qhull by defining flags.  They are
    copied into qh by qh_setflags().  qh-quick_r.htm#options defines the flags.
*/
  boolT ALLpoints;        /* true 'Qs' if search all points for initial simplex */
  boolT ALLOWshort;       /* true 'Qa' allow input with fewer or more points than coordinates */
  boolT ALLOWwarning;     /* true 'Qw' if allow option warnings */
  boolT ALLOWwide;        /* true 'Q12' if allow wide facets and wide dupridges, c.f. qh_WIDEmaxoutside */
  boolT ANGLEmerge;       /* true 'Q1' if sort potential merges by type/angle instead of type/distance  */
  boolT APPROXhull;       /* true 'Wn' if MINoutside set */
  realT MINoutside;       /*   Minimum distance for an outside point ('Wn' or 2*qh.MINvisible) */
  boolT ANNOTATEoutput;   /* true 'Ta' if annotate output with message codes */
  boolT ATinfinity;       /* true 'Qz' if point num_points-1 is "at-infinity"
                             for improving precision in Delaunay triangulations */
  boolT AVOIDold;         /* true 'Q4' if avoid old->new merges */
  boolT BESToutside;      /* true 'Qf' if partition points into best outsideset */
  boolT CDDinput;         /* true 'Pc' if input uses CDD format (1.0/offset first) */
  boolT CDDoutput;        /* true 'PC' if print normals in CDD format (offset first) */
  boolT CHECKduplicates;  /* true 'Q15' if qh_maybe_duplicateridges after each qh_mergefacet */
  boolT CHECKfrequently;  /* true 'Tc' if checking frequently */
  realT premerge_cos;     /*   'A-n'   cos_max when pre merging */
  realT postmerge_cos;    /*   'An'    cos_max when post merging */
  boolT DELAUNAY;         /* true 'd' or 'v' if computing DELAUNAY triangulation */
  boolT DOintersections;  /* true 'Gh' if print hyperplane intersections */
  int   DROPdim;          /* drops dim 'GDn' for 4-d -> 3-d output */
  boolT FLUSHprint;       /* true 'Tf' if flush after qh_fprintf for segfaults */
  boolT FORCEoutput;      /* true 'Po' if forcing output despite degeneracies */
  int   GOODpoint;        /* 'QGn' or 'QG-n' (n+1, n-1), good facet if visible from point n (or not) */
  pointT *GOODpointp;     /*   the actual point */
  boolT GOODthreshold;    /* true 'Pd/PD' if qh.lower_threshold/upper_threshold defined
                             set if qh.UPPERdelaunay (qh_initbuild)
                             false if qh.SPLITthreshold */
  int   GOODvertex;       /* 'QVn' or 'QV-n' (n+1, n-1), good facet if vertex for point n (or not) */
  pointT *GOODvertexp;     /*   the actual point */
  boolT HALFspace;        /* true 'Hn,n,n' if halfspace intersection */
  boolT ISqhullQh;        /* Set by Qhull.cpp on initialization */
  int   IStracing;        /* 'Tn' trace execution, 0=none, 1=least, 4=most, -1=events */
  int   KEEParea;         /* 'PAn' number of largest facets to keep */
  boolT KEEPcoplanar;     /* true 'Qc' if keeping nearest facet for coplanar points */
  boolT KEEPinside;       /* true 'Qi' if keeping nearest facet for inside points
                              set automatically if 'd Qc' */
  int   KEEPmerge;        /* 'PMn' number of facets to keep with most merges */
  realT KEEPminArea;      /* 'PFn' minimum facet area to keep */
  realT MAXcoplanar;      /* 'Un' max distance below a facet to be coplanar*/
  int   MAXwide;          /* 'QWn' max ratio for wide facet, otherwise error unless Q12-allow-wide */
  boolT MERGEexact;       /* true 'Qx' if exact merges (concave, degen, dupridge, flipped)
                             tested by qh_checkzero and qh_test_*_merge */
  boolT MERGEindependent; /* true if merging independent sets of coplanar facets. 'Q2' disables */
  boolT MERGING;          /* true if exact-, pre- or post-merging, with angle and centrum tests */
  realT   premerge_centrum;  /*   'C-n' centrum_radius when pre merging.  Default is round-off */
  realT   postmerge_centrum; /*   'Cn' centrum_radius when post merging.  Default is round-off */
  boolT MERGEpinched;     /* true 'Q14' if merging pinched vertices due to dupridge */
  boolT MERGEvertices;    /* true if merging redundant vertices, 'Q3' disables or qh.hull_dim > qh_DIMmergeVertex */
  realT MINvisible;       /* 'Vn' min. distance for a facet to be visible */
  boolT NOnarrow;         /* true 'Q10' if no special processing for narrow distributions */
  boolT NOnearinside;     /* true 'Q8' if ignore near-inside points when partitioning, qh_check_points may fail */
  boolT NOpremerge;       /* true 'Q0' if no defaults for C-0 or Qx */
  boolT ONLYgood;         /* true 'Qg' if process points with good visible or horizon facets */
  boolT ONLYmax;          /* true 'Qm' if only process points that increase max_outside */
  boolT PICKfurthest;     /* true 'Q9' if process furthest of furthest points*/
  boolT POSTmerge;        /* true if merging after buildhull ('Cn' or 'An') */
  boolT PREmerge;         /* true if merging during buildhull ('C-n' or 'A-n') */
                        /* NOTE: some of these names are similar to qh_PRINT names */
  boolT PRINTcentrums;    /* true 'Gc' if printing centrums */
  boolT PRINTcoplanar;    /* true 'Gp' if printing coplanar points */
  int   PRINTdim;         /* print dimension for Geomview output */
  boolT PRINTdots;        /* true 'Ga' if printing all points as dots */
  boolT PRINTgood;        /* true 'Pg' if printing good facets
                             PGood set if 'd', 'PAn', 'PFn', 'PMn', 'QGn', 'QG-n', 'QVn', or 'QV-n' */
  boolT PRINTinner;       /* true 'Gi' if printing inner planes */
  boolT PRINTneighbors;   /* true 'PG' if printing neighbors of good facets */
  boolT PRINTnoplanes;    /* true 'Gn' if printing no planes */
  boolT PRINToptions1st;  /* true 'FO' if printing options to stderr */
  boolT PRINTouter;       /* true 'Go' if printing outer planes */
  boolT PRINTprecision;   /* false 'Pp' if not reporting precision problems */
  qh_PRINT PRINTout[qh_PRINTEND]; /* list of output formats to print */
  boolT PRINTridges;      /* true 'Gr' if print ridges */
  boolT PRINTspheres;     /* true 'Gv' if print vertices as spheres */
  boolT PRINTstatistics;  /* true 'Ts' if printing statistics to stderr */
  boolT PRINTsummary;     /* true 's' if printing summary to stderr */
  boolT PRINTtransparent; /* true 'Gt' if print transparent outer ridges */
  boolT PROJECTdelaunay;  /* true if DELAUNAY, no readpoints() and
                             need projectinput() for Delaunay in qh_init_B */
  int   PROJECTinput;     /* number of projected dimensions 'bn:0Bn:0' */
  boolT RANDOMdist;       /* true 'Rn' if randomly change distplane and setfacetplane */
  realT RANDOMfactor;     /*    maximum random perturbation */
  realT RANDOMa;          /*    qh_randomfactor is randr * RANDOMa + RANDOMb */
  realT RANDOMb;
  boolT RANDOMoutside;    /* true 'Qr' if select a random outside point */
  int   REPORTfreq;       /* 'TFn' buildtracing reports every n facets */
  int   REPORTfreq2;      /* tracemerging reports every REPORTfreq/2 facets */
  int   RERUN;            /* 'TRn' rerun qhull n times (qh.build_cnt) */
  int   ROTATErandom;     /* 'QRn' n<-1 random seed, n==-1 time is seed, n==0 random rotation by time, n>0 rotate input */
  boolT SCALEinput;       /* true 'Qbk' if scaling input */
  boolT SCALElast;        /* true 'Qbb' if scale last coord to max prev coord */
  boolT SETroundoff;      /* true 'En' if qh.DISTround is predefined */
  boolT SKIPcheckmax;     /* true 'Q5' if skip qh_check_maxout, qh_check_points may fail */
  boolT SKIPconvex;       /* true 'Q6' if skip convexity testing during pre-merge */
  boolT SPLITthresholds;  /* true 'Pd/PD' if upper_/lower_threshold defines a region
                               else qh.GOODthresholds
                               set if qh.DELAUNAY (qh_initbuild)
                               used only for printing (!for qh.ONLYgood) */
  int   STOPadd;          /* 'TAn' 1+n for stop after adding n vertices */
  int   STOPcone;         /* 'TCn' 1+n for stopping after cone for point n */
                          /*       also used by qh_build_withresart for err exit*/
  int   STOPpoint;        /* 'TVn' 'TV-n' 1+n for stopping after/before(-)
                                        adding point n */
  int   TESTpoints;       /* 'QTn' num of test points after qh.num_points.  Test points always coplanar. */
  boolT TESTvneighbors;   /*  true 'Qv' if test vertex neighbors at end */
  int   TRACElevel;       /* 'Tn' conditional IStracing level */
  int   TRACElastrun;     /*  qh.TRACElevel applies to last qh.RERUN */
  int   TRACEpoint;       /* 'TPn' start tracing when point n is a vertex, use qh_IDunknown (-1) after qh_buildhull and qh_postmerge */
  realT TRACEdist;        /* 'TWn' start tracing when merge distance too big */
  int   TRACEmerge;       /* 'TMn' start tracing before this merge */
  boolT TRIangulate;      /* true 'Qt' if triangulate non-simplicial facets */
  boolT TRInormals;       /* true 'Q11' if triangulate duplicates ->normal and ->center (sets Qt) */
  boolT UPPERdelaunay;    /* true 'Qu' if computing furthest-site Delaunay */
  boolT USEstdout;        /* true 'Tz' if using stdout instead of stderr */
  boolT VERIFYoutput;     /* true 'Tv' if verify output at end of qhull */
  boolT VIRTUALmemory;    /* true 'Q7' if depth-first processing in buildhull */
  boolT VORONOI;          /* true 'v' if computing Voronoi diagram, also sets qh.DELAUNAY */

  /*--------input constants ---------*/
  realT AREAfactor;       /* 1/(hull_dim-1)! for converting det's to area */
  boolT DOcheckmax;       /* true if calling qh_check_maxout (!qh.SKIPcheckmax && qh.MERGING) */
  char  *feasible_string;  /* feasible point 'Hn,n,n' for halfspace intersection */
  coordT *feasible_point;  /*    as coordinates, both malloc'd */
  boolT GETarea;          /* true 'Fa', 'FA', 'FS', 'PAn', 'PFn' if compute facet area/Voronoi volume in io_r.c */
  boolT KEEPnearinside;   /* true if near-inside points in coplanarset */
  int   hull_dim;         /* dimension of hull, set by initbuffers */
  int   input_dim;        /* dimension of input, set by initbuffers */
  int   num_points;       /* number of input points */
  pointT *first_point;    /* array of input points, see POINTSmalloc */
  boolT POINTSmalloc;     /*   true if qh.first_point/num_points allocated */
  pointT *input_points;   /* copy of original qh.first_point for input points for qh_joggleinput */
  boolT input_malloc;     /* true if qh.input_points malloc'd */
  char  qhull_command[256];/* command line that invoked this program */
  int   qhull_commandsiz2; /*    size of qhull_command at qh_clear_outputflags */
  char  rbox_command[256]; /* command line that produced the input points */
  char  qhull_options[512];/* descriptive list of options */
  int   qhull_optionlen;  /*    length of last line */
  int   qhull_optionsiz;  /*    size of qhull_options at qh_build_withrestart */
  int   qhull_optionsiz2; /*    size of qhull_options at qh_clear_outputflags */
  int   run_id;           /* non-zero, random identifier for this instance of qhull */
  boolT VERTEXneighbors;  /* true if maintaining vertex neighbors */
  boolT ZEROcentrum;      /* true if 'C-0' or 'C-0 Qx' and not post-merging or 'A-n'.  Sets ZEROall_ok */
  realT *upper_threshold; /* don't print if facet->normal[k]>=upper_threshold[k]
                             must set either GOODthreshold or SPLITthreshold
                             if qh.DELAUNAY, default is 0.0 for upper envelope (qh_initbuild) */
  realT *lower_threshold; /* don't print if facet->normal[k] <=lower_threshold[k] */
  realT *upper_bound;     /* scale point[k] to new upper bound */
  realT *lower_bound;     /* scale point[k] to new lower bound
                             project if both upper_ and lower_bound == 0 */

/*----------------------------------

  qh precision constants
    precision constants for Qhull

  notes:
    qh_detroundoff [geom2_r.c] computes the maximum roundoff error for distance
    and other computations.  It also sets default values for the
    qh constants above.
*/
  realT ANGLEround;       /* max round off error for angles */
  realT centrum_radius;   /* max centrum radius for convexity ('Cn' + 2*qh.DISTround) */
  realT cos_max;          /* max cosine for convexity (roundoff added) */
  realT DISTround;        /* max round off error for distances, qh.SETroundoff ('En') overrides qh_distround */
  realT MAXabs_coord;     /* max absolute coordinate */
  realT MAXlastcoord;     /* max last coordinate for qh_scalelast */
  realT MAXoutside;       /* max target for qh.max_outside/f.maxoutside, base for qh_RATIO...
                             recomputed at qh_addpoint, unrelated to qh_MAXoutside */
  realT MAXsumcoord;      /* max sum of coordinates */
  realT MAXwidth;         /* max rectilinear width of point coordinates */
  realT MINdenom_1;       /* min. abs. value for 1/x */
  realT MINdenom;         /*    use divzero if denominator < MINdenom */
  realT MINdenom_1_2;     /* min. abs. val for 1/x that allows normalization */
  realT MINdenom_2;       /*    use divzero if denominator < MINdenom_2 */
  realT MINlastcoord;     /* min. last coordinate for qh_scalelast */
  realT *NEARzero;        /* hull_dim array for near zero in gausselim */
  realT NEARinside;       /* keep points for qh_check_maxout if close to facet */
  realT ONEmerge;         /* max distance for merging simplicial facets */
  realT outside_err;      /* application's epsilon for coplanar points
                             qh_check_bestdist() qh_check_points() reports error if point outside */
  realT WIDEfacet;        /* size of wide facet for skipping ridge in
                             area computation and locking centrum */
  boolT NARROWhull;       /* set in qh_initialhull if angle < qh_MAXnarrow */

/*----------------------------------

  qh internal constants
    internal constants for Qhull
*/
  char qhull[sizeof("qhull")]; /* "qhull" for checking ownership while debugging */
  jmp_buf errexit;        /* exit label for qh_errexit, defined by setjmp() and NOerrexit */
  char    jmpXtra[40];    /* extra bytes in case jmp_buf is defined wrong by compiler */
  jmp_buf restartexit;    /* restart label for qh_errexit, defined by setjmp() and ALLOWrestart */
  char    jmpXtra2[40];   /* extra bytes in case jmp_buf is defined wrong by compiler*/
  FILE *  fin;            /* pointer to input file, init by qh_initqhull_start2 */
  FILE *  fout;           /* pointer to output file */
  FILE *  ferr;           /* pointer to error file */
  pointT *interior_point; /* center point of the initial simplex*/
  int     normal_size;    /* size in bytes for facet normals and point coords */
  int     center_size;    /* size in bytes for Voronoi centers */
  int     TEMPsize;       /* size for small, temporary sets (in quick mem) */

/*----------------------------------

  qh facet and vertex lists
    defines lists of facets, new facets, visible facets, vertices, and
    new vertices.  Includes counts, next ids, and trace ids.
  see:
    qh_resetlists()
*/
  facetT *facet_list;     /* first facet */
  facetT *facet_tail;     /* end of facet_list (dummy facet with id 0 and next==NULL) */
  facetT *facet_next;     /* next facet for buildhull()
                             previous facets do not have outside sets
                             NARROWhull: previous facets may have coplanar outside sets for qh_outcoplanar */
  facetT *newfacet_list;  /* list of new facets to end of facet_list
                             qh_postmerge sets newfacet_list to facet_list */
  facetT *visible_list;   /* list of visible facets preceding newfacet_list,
                             end of visible list if !facet->visible, same as newfacet_list
                             qh_findhorizon sets visible_list at end of facet_list
                             qh_willdelete prepends to visible_list
                             qh_triangulate appends mirror facets to visible_list at end of facet_list
                             qh_postmerge sets visible_list to facet_list
                             qh_deletevisible deletes the visible facets */
  int       num_visible;  /* current number of visible facets */
  unsigned int tracefacet_id; /* set at init, then can print whenever */
  facetT  *tracefacet;    /*   set in newfacet/mergefacet, undone in delfacet and qh_errexit */
  unsigned int traceridge_id; /* set at init, then can print whenever */
  ridgeT  *traceridge;    /*   set in newridge, undone in delridge, errexit, errexit2, makenew_nonsimplicial, mergecycle_ridges */
  unsigned int tracevertex_id; /* set at buildtracing, can print whenever */
  vertexT *tracevertex;   /*   set in newvertex, undone in delvertex and qh_errexit */
  vertexT *vertex_list;   /* list of all vertices, to vertex_tail */
  vertexT *vertex_tail;   /*      end of vertex_list (dummy vertex with ID 0, next NULL) */
  vertexT *newvertex_list; /* list of vertices in newfacet_list, to vertex_tail
                             all vertices have 'newfacet' set */
  int   num_facets;       /* number of facets in facet_list
                             includes visible faces (num_visible) */
  int   num_vertices;     /* number of vertices in facet_list */
  int   num_outside;      /* number of points in outsidesets (for tracing and RANDOMoutside)
                               includes coplanar outsideset points for NARROWhull/qh_outcoplanar() */
  int   num_good;         /* number of good facets (after qh_findgood_all or qh_markkeep) */
  unsigned int facet_id;  /* ID of next, new facet from newfacet() */
  unsigned int ridge_id;  /* ID of next, new ridge from newridge() */
  unsigned int vertex_id; /* ID of next, new vertex from newvertex() */
  unsigned int first_newfacet; /* ID of first_newfacet for qh_buildcone, or 0 if none */

/*----------------------------------

  qh global variables
    defines minimum and maximum distances, next visit ids, several flags,
    and other global variables.
    initialize in qh_initbuild or qh_maxmin if used in qh_buildhull
*/
  unsigned long hulltime; /* ignore time to set up input and randomize */
                          /*   use 'unsigned long' to avoid wrap-around errors */
  boolT ALLOWrestart;     /* true if qh_joggle_restart can use qh.restartexit */
  int   build_cnt;        /* number of calls to qh_initbuild */
  qh_CENTER CENTERtype;   /* current type of facet->center, qh_CENTER */
  int   furthest_id;      /* pointid of furthest point, for tracing */
  int   last_errcode;     /* last errcode from qh_fprintf, reset in qh_build_withrestart */
  facetT *GOODclosest;    /* closest facet to GOODthreshold in qh_findgood */
  pointT *coplanar_apex;  /* last apex declared a coplanar point by qh_getpinchedmerges, prevents infinite loop */
  boolT hasAreaVolume;    /* true if totarea, totvol was defined by qh_getarea */
  boolT hasTriangulation; /* true if triangulation created by qh_triangulate */
  boolT isRenameVertex;   /* true during qh_merge_pinchedvertices, disables duplicate ridge vertices in qh_checkfacet */
  realT JOGGLEmax;        /* set 'QJn' if randomly joggle input. 'QJ'/'QJ0.0' sets default (qh_detjoggle) */
  boolT maxoutdone;       /* set qh_check_maxout(), cleared by qh_addpoint() */
  realT max_outside;      /* maximum distance from a point to a facet,
                               before roundoff, not simplicial vertices
                               actual outer plane is +DISTround and
                               computed outer plane is +2*DISTround */
  realT max_vertex;       /* maximum distance (>0) from vertex to a facet,
                               before roundoff, due to a merge */
  realT min_vertex;       /* minimum distance (<0) from vertex to a facet,
                               before roundoff, due to a merge
                               if qh.JOGGLEmax, qh_makenewplanes sets it
                               recomputed if qh.DOcheckmax, default -qh.DISTround */
  boolT NEWfacets;        /* true while visible facets invalid due to new or merge
                              from qh_makecone/qh_attachnewfacets to qh_resetlists */
  boolT NEWtentative;     /* true while new facets are tentative due to !qh.IGNOREpinched or qh.ONLYgood
                              from qh_makecone to qh_attachnewfacets */
  boolT findbestnew;      /* true if partitioning calls qh_findbestnew */
  boolT findbest_notsharp; /* true if new facets are at least 90 degrees */
  boolT NOerrexit;        /* true if qh.errexit is not available, cleared after setjmp.  See qh.ERREXITcalled */
  realT PRINTcradius;     /* radius for printing centrums */
  realT PRINTradius;      /* radius for printing vertex spheres and points */
  boolT POSTmerging;      /* true when post merging */
  int   printoutvar;      /* temporary variable for qh_printbegin, etc. */
  int   printoutnum;      /* number of facets printed */
  unsigned int repart_facetid; /* previous facetid to prevent recursive qh_partitioncoplanar+qh_partitionpoint */
  int   retry_addpoint;   /* number of retries of qh_addpoint due to merging pinched vertices */
  boolT QHULLfinished;    /* True after qhull() is finished */
  realT totarea;          /* 'FA': total facet area computed by qh_getarea, hasAreaVolume */
  realT totvol;           /* 'FA': total volume computed by qh_getarea, hasAreaVolume */
  unsigned int visit_id;  /* unique ID for searching neighborhoods, */
  unsigned int vertex_visit; /* unique ID for searching vertices, reset with qh_buildtracing */
  boolT WAScoplanar;      /* True if qh_partitioncoplanar (qh_check_maxout) */
  boolT ZEROall_ok;       /* True if qh_checkzero always succeeds */

/*----------------------------------

  qh global sets
    defines sets for merging, initial simplex, hashing, extra input points,
    and deleted vertices
*/
  setT *facet_mergeset;   /* temporary set of merges to be done */
  setT *degen_mergeset;   /* temporary set of degenerate and redundant merges */
  setT *vertex_mergeset;  /* temporary set of vertex merges */
  setT *hash_table;       /* hash table for matching ridges in qh_matchfacets
                             size is setsize() */
  setT *other_points;     /* additional points */
  setT *del_vertices;     /* vertices to partition and delete with visible
                             facets.  v.deleted is set for checkfacet */

/*----------------------------------

  qh global buffers
    defines buffers for maxtrix operations, input, and error messages
*/
  coordT *gm_matrix;      /* (dim+1)Xdim matrix for geom_r.c */
  coordT **gm_row;        /* array of gm_matrix rows */
  char* line;             /* malloc'd input line of maxline+1 chars */
  int maxline;
  coordT *half_space;     /* malloc'd input array for halfspace (qh.normal_size+coordT) */
  coordT *temp_malloc;    /* malloc'd input array for points */

/*----------------------------------

  qh static variables
    defines static variables for individual functions

  notes:
    do not use 'static' within a function.  Multiple instances of qhull
    may exist.

    do not assume zero initialization, 'QPn' may cause a restart
*/
  boolT ERREXITcalled;    /* true during qh_errexit (prevents duplicate calls).  see qh.NOerrexit */
  boolT firstcentrum;     /* for qh_printcentrum */
  boolT old_randomdist;   /* save RANDOMdist flag during io, tracing, or statistics */
  setT *coplanarfacetset; /* set of coplanar facets for searching qh_findbesthorizon() */
  realT last_low;         /* qh_scalelast parameters for qh_setdelaunay */
  realT last_high;
  realT last_newhigh;
  realT lastcpu;          /* for qh_buildtracing */
  int   lastfacets;       /*   last qh.num_facets */
  int   lastmerges;       /*   last zzval_(Ztotmerge) */ 
  int   lastplanes;       /*   last zzval_(Zsetplane) */ 
  int   lastdist;         /*   last zzval_(Zdistplane) */ 
  unsigned int lastreport; /*  last qh.facet_id */
  int mergereport;        /* for qh_tracemerging */
  setT *old_tempstack;    /* for saving qh->qhmem.tempstack in save_qhull */
  int   ridgeoutnum;      /* number of ridges for 4OFF output (qh_printbegin,etc) */

/*----------------------------------

  qh memory management, rbox globals, and statistics

  Replaces global data structures defined for libqhull
*/
  int     last_random;    /* Last random number from qh_rand (random_r.c) */
  jmp_buf rbox_errexit;   /* errexit from rboxlib_r.c, defined by qh_rboxpoints() only */
  char    jmpXtra3[40];   /* extra bytes in case jmp_buf is defined wrong by compiler */
  int     rbox_isinteger;
  double  rbox_out_offset;
  void *  cpp_object;     /* C++ pointer.  Currently used by RboxPoints.qh_fprintf_rbox */
  void *  cpp_other;      /* C++ pointer.  Reserved for other users */
  void *  cpp_user;       /* C++ pointer.  Currently used by QhullUser.qh_fprintf */

  /* Last, otherwise zero'd by qh_initqhull_start2 (global_r.c */
  qhmemT  qhmem;          /* Qhull managed memory (mem_r.h) */
  /* After qhmem because its size depends on the number of statistics */
  qhstatT qhstat;         /* Qhull statistics (stat_r.h) */
};

/*=========== -macros- =========================*/

/*----------------------------------

  otherfacet_(ridge, facet)
    return neighboring facet for a ridge in facet
*/
#define otherfacet_(ridge, facet) \
                        (((ridge)->top == (facet)) ? (ridge)->bottom : (ridge)->top)

/*----------------------------------

  getid_(p)
    return int ID for facet, ridge, or vertex
    return qh_IDunknown(-1) if NULL
    return 0 if facet_tail or vertex_tail
*/
#define getid_(p)       ((p) ? (int)((p)->id) : qh_IDunknown)

/*============== FORALL macros ===================*/

/*----------------------------------

  FORALLfacets { ... }
    assign 'facet' to each facet in qh.facet_list

  notes:
    uses 'facetT *facet;'
    assumes last facet is a sentinel
    assumes qh defined

  see:
    FORALLfacet_( facetlist )
*/
#define FORALLfacets for (facet=qh->facet_list;facet && facet->next;facet=facet->next)

/*----------------------------------

  FORALLpoints { ... }
    assign 'point' to each point in qh.first_point, qh.num_points

  notes:
    assumes qh defined

  declare:
    coordT *point, *pointtemp;
*/
#define FORALLpoints FORALLpoint_(qh, qh->first_point, qh->num_points)

/*----------------------------------

  FORALLpoint_(qh, points, num) { ... }
    assign 'point' to each point in points array of num points

  declare:
    coordT *point, *pointtemp;
*/
#define FORALLpoint_(qh, points, num) for (point=(points), \
      pointtemp= (points)+qh->hull_dim*(num); point < pointtemp; point += qh->hull_dim)

/*----------------------------------

  FORALLvertices { ... }
    assign 'vertex' to each vertex in qh.vertex_list

  declare:
    vertexT *vertex;

  notes:
    assumes qh.vertex_list terminated by NULL or a sentinel (v.next==NULL)
    assumes qh defined
*/
#define FORALLvertices for (vertex=qh->vertex_list;vertex && vertex->next;vertex= vertex->next)

/*----------------------------------

  FOREACHfacet_( facets ) { ... }
    assign 'facet' to each facet in facets

  declare:
    facetT *facet, **facetp;

  notes:
    assumes set is not modified

  see:
    FOREACHsetelement_
*/
#define FOREACHfacet_(facets)    FOREACHsetelement_(facetT, facets, facet)

/*----------------------------------

  FOREACHneighbor_( facet ) { ... }
    assign 'neighbor' to each neighbor in facet->neighbors

  FOREACHneighbor_( vertex ) { ... }
    assign 'neighbor' to each neighbor in vertex->neighbors

  declare:
    facetT *neighbor, **neighborp;

  notes:
    assumes set is not modified

  see:
    FOREACHsetelement_
*/
#define FOREACHneighbor_(facet)  FOREACHsetelement_(facetT, facet->neighbors, neighbor)

/*----------------------------------

  FOREACHpoint_( points ) { ... }
    assign 'point' to each point in points set

  declare:
    pointT *point, **pointp;

  notes:
    assumes set is not modified

  see:
    FOREACHsetelement_
*/
#define FOREACHpoint_(points)    FOREACHsetelement_(pointT, points, point)

/*----------------------------------

  FOREACHridge_( ridges ) { ... }
    assign 'ridge' to each ridge in ridges set

  declare:
    ridgeT *ridge, **ridgep;

  notes:
    assumes set is not modified

  see:
    FOREACHsetelement_
*/
#define FOREACHridge_(ridges)    FOREACHsetelement_(ridgeT, ridges, ridge)

/*----------------------------------

  FOREACHvertex_( vertices ) { ... }
    assign 'vertex' to each vertex in vertices set

  declare:
    vertexT *vertex, **vertexp;

  notes:
    assumes set is not modified

  see:
    FOREACHsetelement_
*/
#define FOREACHvertex_(vertices) FOREACHsetelement_(vertexT, vertices,vertex)

/*----------------------------------

  FOREACHfacet_i_(qh, facets ) { ... }
    assign 'facet' and 'facet_i' for each facet in facets set

  declare:
    facetT *facet;
    int     facet_n, facet_i;

  see:
    FOREACHsetelement_i_
*/
#define FOREACHfacet_i_(qh, facets)    FOREACHsetelement_i_(qh, facetT, facets, facet)

/*----------------------------------

  FOREACHneighbor_i_(qh, facet ) { ... }
    assign 'neighbor' and 'neighbor_i' for each neighbor in facet->neighbors

  declare:
    facetT *neighbor;
    int     neighbor_n, neighbor_i;

  notes:
    see FOREACHsetelement_i_
    for facet neighbors of vertex, need to define a new macro
*/
#define FOREACHneighbor_i_(qh, facet)  FOREACHsetelement_i_(qh, facetT, facet->neighbors, neighbor)

/*----------------------------------

  FOREACHpoint_i_(qh, points ) { ... }
    assign 'point' and 'point_i' for each point in points set

  declare:
    pointT *point;
    int     point_n, point_i;

  see:
    FOREACHsetelement_i_
*/
#define FOREACHpoint_i_(qh, points)    FOREACHsetelement_i_(qh, pointT, points, point)

/*----------------------------------

  FOREACHridge_i_(qh, ridges ) { ... }
    assign 'ridge' and 'ridge_i' for each ridge in ridges set

  declare:
    ridgeT *ridge;
    int     ridge_n, ridge_i;

  see:
    FOREACHsetelement_i_
*/
#define FOREACHridge_i_(qh, ridges)    FOREACHsetelement_i_(qh, ridgeT, ridges, ridge)

/*----------------------------------

  FOREACHvertex_i_(qh, vertices ) { ... }
    assign 'vertex' and 'vertex_i' for each vertex in vertices set

  declare:
    vertexT *vertex;
    int     vertex_n, vertex_i;

  see:
    FOREACHsetelement_i_
*/
#define FOREACHvertex_i_(qh, vertices) FOREACHsetelement_i_(qh, vertexT, vertices, vertex)

#ifdef __cplusplus
extern "C" {
#endif

/********* -libqhull_r.c prototypes (duplicated from qhull_ra.h) **********************/

void    qh_qhull(qhT *qh);
boolT   qh_addpoint(qhT *qh, pointT *furthest, facetT *facet, boolT checkdist);
void    qh_errexit2(qhT *qh, int exitcode, facetT *facet, facetT *otherfacet);
void    qh_printsummary(qhT *qh, FILE *fp);

/********* -user_r.c prototypes (alphabetical) **********************/

void    qh_errexit(qhT *qh, int exitcode, facetT *facet, ridgeT *ridge);
void    qh_errprint(qhT *qh, const char* string, facetT *atfacet, facetT *otherfacet, ridgeT *atridge, vertexT *atvertex);
int     qh_new_qhull(qhT *qh, int dim, int numpoints, coordT *points, boolT ismalloc,
                char *qhull_cmd, FILE *outfile, FILE *errfile);
void    qh_printfacetlist(qhT *qh, facetT *facetlist, setT *facets, boolT printall);
void    qh_printhelp_degenerate(qhT *qh, FILE *fp);
void    qh_printhelp_internal(qhT *qh, FILE *fp);
void    qh_printhelp_narrowhull(qhT *qh, FILE *fp, realT minangle);
void    qh_printhelp_singular(qhT *qh, FILE *fp);
void    qh_printhelp_topology(qhT *qh, FILE *fp);
void    qh_printhelp_wide(qhT *qh, FILE *fp);
void    qh_user_memsizes(qhT *qh);

/********* -usermem_r.c prototypes (alphabetical) **********************/
void    qh_exit(int exitcode);
void    qh_fprintf_stderr(int msgcode, const char *fmt, ... );
void    qh_free(void *mem);
void   *qh_malloc(size_t size);

/********* -userprintf_r.c and userprintf_rbox_r.c prototypes **********************/
void    qh_fprintf(qhT *qh, FILE *fp, int msgcode, const char *fmt, ... );
void    qh_fprintf_rbox(qhT *qh, FILE *fp, int msgcode, const char *fmt, ... );

/***** -geom_r.c/geom2_r.c/random_r.c prototypes (duplicated from geom_r.h, random_r.h) ****************/

facetT *qh_findbest(qhT *qh, pointT *point, facetT *startfacet,
                     boolT bestoutside, boolT newfacets, boolT noupper,
                     realT *dist, boolT *isoutside, int *numpart);
facetT *qh_findbestnew(qhT *qh, pointT *point, facetT *startfacet,
                     realT *dist, boolT bestoutside, boolT *isoutside, int *numpart);
boolT   qh_gram_schmidt(qhT *qh, int dim, realT **rows);
void    qh_outerinner(qhT *qh, facetT *facet, realT *outerplane, realT *innerplane);
void    qh_printsummary(qhT *qh, FILE *fp);
void    qh_projectinput(qhT *qh);
void    qh_randommatrix(qhT *qh, realT *buffer, int dim, realT **row);
void    qh_rotateinput(qhT *qh, realT **rows);
void    qh_scaleinput(qhT *qh);
void    qh_setdelaunay(qhT *qh, int dim, int count, pointT *points);
coordT  *qh_sethalfspace_all(qhT *qh, int dim, int count, coordT *halfspaces, pointT *feasible);

/***** -global_r.c prototypes (alphabetical) ***********************/

unsigned long qh_clock(qhT *qh);
void    qh_checkflags(qhT *qh, char *command, char *hiddenflags);
void    qh_clear_outputflags(qhT *qh);
void    qh_freebuffers(qhT *qh);
void    qh_freeqhull(qhT *qh, boolT allmem);
void    qh_init_A(qhT *qh, FILE *infile, FILE *outfile, FILE *errfile, int argc, char *argv[]);
void    qh_init_B(qhT *qh, coordT *points, int numpoints, int dim, boolT ismalloc);
void    qh_init_qhull_command(qhT *qh, int argc, char *argv[]);
void    qh_initbuffers(qhT *qh, coordT *points, int numpoints, int dim, boolT ismalloc);
void    qh_initflags(qhT *qh, char *command);
void    qh_initqhull_buffers(qhT *qh);
void    qh_initqhull_globals(qhT *qh, coordT *points, int numpoints, int dim, boolT ismalloc);
void    qh_initqhull_mem(qhT *qh);
void    qh_initqhull_outputflags(qhT *qh);
void    qh_initqhull_start(qhT *qh, FILE *infile, FILE *outfile, FILE *errfile);
void    qh_initqhull_start2(qhT *qh, FILE *infile, FILE *outfile, FILE *errfile);
void    qh_initthresholds(qhT *qh, char *command);
void    qh_lib_check(int qhullLibraryType, int qhTsize, int vertexTsize, int ridgeTsize, int facetTsize, int setTsize, int qhmemTsize);
void    qh_option(qhT *qh, const char *option, int *i, realT *r);
void    qh_zero(qhT *qh, FILE *errfile);

/***** -io_r.c prototypes (duplicated from io_r.h) ***********************/

void    qh_dfacet(qhT *qh, unsigned int id);
void    qh_dvertex(qhT *qh, unsigned int id);
void    qh_printneighborhood(qhT *qh, FILE *fp, qh_PRINT format, facetT *facetA, facetT *facetB, boolT printall);
void    qh_produce_output(qhT *qh);
coordT *qh_readpoints(qhT *qh, int *numpoints, int *dimension, boolT *ismalloc);


/********* -mem_r.c prototypes (duplicated from mem_r.h) **********************/

void qh_meminit(qhT *qh, FILE *ferr);
void qh_memfreeshort(qhT *qh, int *curlong, int *totlong);

/********* -poly_r.c/poly2_r.c prototypes (duplicated from poly_r.h) **********************/

void    qh_check_output(qhT *qh);
void    qh_check_points(qhT *qh);
setT   *qh_facetvertices(qhT *qh, facetT *facetlist, setT *facets, boolT allfacets);
facetT *qh_findbestfacet(qhT *qh, pointT *point, boolT bestoutside,
           realT *bestdist, boolT *isoutside);
vertexT *qh_nearvertex(qhT *qh, facetT *facet, pointT *point, realT *bestdistp);
pointT *qh_point(qhT *qh, int id);
setT   *qh_pointfacet(qhT *qh /* qh.facet_list */);
int     qh_pointid(qhT *qh, pointT *point);
setT   *qh_pointvertex(qhT *qh /* qh.facet_list */);
void    qh_setvoronoi_all(qhT *qh);
void    qh_triangulate(qhT *qh /* qh.facet_list */);

/********* -rboxlib_r.c prototypes **********************/
int     qh_rboxpoints(qhT *qh, char* rbox_command);
void    qh_errexit_rbox(qhT *qh, int exitcode);

/********* -stat_r.c prototypes (duplicated from stat_r.h) **********************/

void    qh_collectstatistics(qhT *qh);
void    qh_printallstatistics(qhT *qh, FILE *fp, const char *string);

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /* qhDEFlibqhull */
geometry/NAMESPACE0000644000176200001440000000213114662314120013320 0ustar  liggesusers# Generated by roxygen2: do not edit by hand

S3method(plot,convhulln)
S3method(plot,delaunayn)
S3method(plot,intersectn)
S3method(to.mesh3d,convhulln)
export("entry.value<-")
export(Unique)
export(bary2cart)
export(cart2bary)
export(cart2pol)
export(cart2sph)
export(convhulln)
export(delaunayn)
export(distmesh2d)
export(distmeshnd)
export(dot)
export(entry.value)
export(extprod3d)
export(feasible.point)
export(halfspacen)
export(inhulln)
export(intersectn)
export(matmax)
export(matmin)
export(matorder)
export(matsort)
export(mesh.dcircle)
export(mesh.diff)
export(mesh.drectangle)
export(mesh.dsphere)
export(mesh.hunif)
export(mesh.intersect)
export(mesh.union)
export(pol2cart)
export(polyarea)
export(rbox)
export(sph2cart)
export(surf.tri)
export(tetramesh)
export(to.mesh3d)
export(trimesh)
export(tsearch)
export(tsearchn)
importFrom(Rcpp,sourceCpp)
importFrom(graphics,box)
importFrom(graphics,plot)
importFrom(graphics,plot.new)
importFrom(graphics,plot.window)
importFrom(graphics,segments)
importFrom(magic,ashift)
importFrom(magic,shift)
importFrom(utils,packageDescription)
useDynLib(geometry)
geometry/inst/0000755000176200001440000000000014751720222013064 5ustar  liggesusersgeometry/inst/doc/0000755000176200001440000000000014751720222013631 5ustar  liggesusersgeometry/inst/doc/qhull-eg.Rnw0000644000176200001440000000603313431000557016035 0ustar  liggesusers%\VignetteIndexEntry{Qhull examples}
\documentclass{article}
\usepackage{Sweave}
\SweaveOpts{echo=TRUE}
\usepackage{hyperref}
\usepackage[british]{babel}

\title{Qhull examples}
\author{David C. Sterratt}

\begin{document}

\maketitle

This document presents examples of the \texttt{geometry} package
functions which implement functions using the
\href{http://www.qhull.org}{Qhull library}.

\section{Convex hulls in 2D}
\label{qhull-eg:sec:convex-hull-2d}

\subsection{Calling \texttt{convhulln} with one argument}
\label{qhull-eg:sec:call-convh-with}

With one argument, convhulln returns the indices of the points of the
convex hull.
<<>>=
library(geometry)
ps <-matrix(rnorm(30), , 2)
ch <- convhulln(ps)
head(ch)
@ 

\subsection{Calling \texttt{convhulln} with \texttt{options}}
\label{qhull-eg:sec:call-convh-with}

We can supply Qhull options to \texttt{convhulln}; in this case it
returns an object of class \texttt{convhulln} which is also a list.
For example \texttt{FA} returns the generalised \texttt{area} and

\texttt{vol}ume. Confusingly in 2D the generalised area is the length
of the perimeter, and the generalised volume is the area.
<<>>=
ps <-matrix(rnorm(30), , 2)
ch <- convhulln(ps, options="FA")
print(ch$area)
print(ch$vol)
@ 

A \texttt{convhulln} object can also be plotted. 
<>=
plot(ch)
@ 

We can also find the normals to the ``facets'' of the convex hull:
<<>>=
ch <- convhulln(ps, options="n")
head(ch$normals)
@ 
Here the first two columns and the $x$ and $y$ direction of the normal,
and the third column defines the position at which the face intersects
that normal.

\subsection{Testing if points are inside a convex hull with \texttt{inhulln}}
\label{qhull-eg:sec:testing-if-points}

The function \texttt{inhulln} can be used to test if points are inside
a convex hull. Here the function \texttt{rbox} is a handy way to
create points at random locations.
<>=
tp <- rbox(n=200, D=2, B=4)
in_ch <- inhulln(ch, tp)
plot(tp[!in_ch,], col="gray")
points(tp[in_ch,], col="red")
plot(ch, add=TRUE)
@ 

\section{Delaunay triangulation in 2D}
\label{qhull-eg:sec:dela-triang-2d}

\subsection{Calling \texttt{delaunayn} with one argument}
\label{qhull-eg:sec:call-delaunayn-with}

With one argument, a set of points, \texttt{delaunayn} returns the
indices of the points at each vertex of each triangle in the triangulation.
<>=
ps <- rbox(n=10, D=2)
dt <- delaunayn(ps)
head(dt)
trimesh(dt, ps)
points(ps)
@ 

\subsection{Calling \texttt{delaunayn} with \texttt{options}}
\label{qhull-eg:sec:call-dela-with}

We can supply Qhull options to \texttt{delaunayn}; in this case it
returns an object of class \texttt{delaunayn} which is also a list.
For example \texttt{Fa} returns the generalised \texttt{area} of each
triangle. In 2D the generalised area is the actual area; in 3D it
would be the volume.
<<>>=
dt2 <- delaunayn(ps, options="Fa")
print(dt2$areas)
dt2 <- delaunayn(ps, options="Fn")
print(dt2$neighbours)
@

\end{document}


%  LocalWords:  Qhull convhulln ps rnorm ume inhulln rbox tp gray dt
%  LocalWords:  delaunayn trimesh Fn
geometry/inst/doc/qhull/0000755000176200001440000000000014751753072014767 5ustar  liggesusersgeometry/inst/doc/qhull/REGISTER.txt0000644000176200001440000000167613431000556016750 0ustar  liggesusersDear Qhull User

We would like to find out how you are using our software.  Think of
Qhull as a new kind of shareware: you share your science and successes 
with us, and we share our software and support with you. 

If you use Qhull, please send us a note telling
us what you are doing with it.

We need to know:

  (1) What you are working on - an abstract of your work would be
      fine.

  (2) How Qhull has helped you, for example, by increasing your 
      productivity or allowing you to do things you could not do
      before.  If Qhull had a direct bearing on your work, please 
      tell us about this.

We encourage you to cite Qhull in your publications.  

To cite Qhull, please use

        Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., "The Quickhull 
        algorithm for convex hulls," ACM Trans. on Mathematical Software,
        22(4):469-483, Dec 1996, http://www.qhull.org.

Please send e-mail to

    bradb@shore.net

Thank you!
geometry/inst/doc/qhull/File_id.diz0000644000176200001440000000063113431000556017014 0ustar  liggesusersQhull 2015.2 - Qhull computes convex hulls,
Delaunay triangulations, halfspace inter-
sections about a point, Voronoi diagrams, 
furthest-site Delaunay triangulations, and 
furthest-site Voronoi diagrams.  Qhull 
works with 2-d, 3-d, 4-d, 5-d, and higher 
dimensions.  It computes volumes, surface 
areas, and approximations.  It runs in a 
command window under Windows 95/NT/XP/7.
www.qhull.org, freeware.


geometry/inst/doc/qhull/README.txt0000644000176200001440000005253113431000556016455 0ustar  liggesusersName

      qhull, rbox         2015.2       2016/01/18
  
Convex hull, Delaunay triangulation, Voronoi diagrams, Halfspace intersection
 
      Documentation:
        html/index.htm
        

      Available from:
        
        
         (git@github.com:qhull/qhull.git)
 
      News and a paper:
        
        

     Version 1 (simplicial only):
        
       
Purpose

  Qhull is a general dimension convex hull program that reads a set 
  of points from stdin, and outputs the smallest convex set that contains 
  the points to stdout.  It also generates Delaunay triangulations, Voronoi 
  diagrams, furthest-site Voronoi diagrams, and halfspace intersections
  about a point.

  Rbox is a useful tool in generating input for Qhull; it generates 
  hypercubes, diamonds, cones, circles, simplices, spirals, 
  lattices, and random points.
  
  Qhull produces graphical output for Geomview.  This helps with
  understanding the output. 

Environment requirements

  Qhull and rbox should run on all 32-bit and 64-bit computers.  Use
  an ANSI C or C++ compiler to compile the program.  The software is 
  self-contained.  It comes with examples and test scripts.
  
  Qhull's C++ interface uses the STL.  The C++ test program uses QTestLib 
  from the Qt Framework.  Qhull's C++ interface may change without 
  notice.  Eventually, it will move into the qhull shared library.
  
  Qhull is copyrighted software.  Please read COPYING.txt and REGISTER.txt
  before using or distributing Qhull.

To cite Qhull, please use

  Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., "The Quickhull 
  algorithm for convex hulls," ACM Trans. on Mathematical Software,
  22(4):469-483, Dec 1996, http://www.qhull.org.

To modify Qhull, particularly the C++ interface

  Qhull is on GitHub 
     (http://github.com/qhull/qhull, git@github.com:qhull/qhull.git)
  
  For internal documentation, see html/qh-code.htm

To install Qhull

  Qhull is precompiled for Windows 32-bit, otherwise it needs compilation.
  
  Qhull includes Makefiles for gcc and other targets, CMakeLists.txt for CMake,
  .sln/.vcproj/.vcxproj files for Microsoft Visual Studio, and .pro files 
  for Qt Creator.  It compiles under Windows with mingw.
  
  Install and build instructions follow.  
  
  See the end of this document for a list of distributed files.

-----------------
Installing Qhull on Windows 10, 8, 7 (32- or 64-bit), Windows XP, and Windows NT

  The zip file contains rbox.exe, qhull.exe, qconvex.exe, qdelaunay.exe, 
  qhalf.exe, qvoronoi.exe, testqset.exe, user_eg*.exe, documentation files, 
  and source files.  Qhull.exe and user-eg3.exe are compiled with the reentrant 
  library while the other executables use the non-reentrant library.
  
  To install Qhull:
  - Unzip the files into a directory (e.g., named 'qhull')
  - Click on QHULL-GO or open a command window into Qhull's bin directory.
  - Test with 'rbox D4 | qhull'
    
  To uninstall Qhull
  - Delete the qhull directory
  
  To learn about Qhull:
  - Execute 'qconvex' for a synopsis and examples.
  - Execute 'rbox 10 | qconvex' to compute the convex hull of 10 random points.
  - Execute 'rbox 10 | qconvex i TO file' to write results to 'file'.
  - Browse the documentation: qhull\html\index.htm
  - If an error occurs, Windows sends the error to stdout instead of stderr.
    Use 'TO xxx' to send normal output to xxx

  To improve the command window
  - Double-click the window bar to increase the size of the window
  - Right-click the window bar
  - Select Properties
  - Check QuickEdit Mode
    Select text with right-click or Enter
    Paste text with right-click
  - Change Font to Lucinda Console
  - Change Layout to Screen Buffer Height 999, Window Size Height 55
  - Change Colors to Screen Background White, Screen Text Black
  - Click OK
  - Select 'Modify shortcut that started this window', then OK

  If you use qhull a lot, install a bash shell such as
    MSYS (www.mingw.org/wiki/msys), Road Bash (www.qhull.org/bash), 
    or Cygwin (www.cygwin.com).

-----------------
Installing Qhull on Unix with gcc

  To build Qhull, static libraries, shared library, and C++ interface
  - Download and extract Qhull (either GitHub, .tgz file, or .zip file)
  - make
  - export LD_LIBRARY_PATH=$PWD/lib:$LD_LIBRARY_PATH

  The Makefiles may be edited for other compilers.
  If 'testqset' exits with an error, qhull is broken
  
  A simple Makefile for Qhull is in src/libqhull and src/libqhull_r.
  To build the Qhull executables and libqhullstatic
  - Extract Qhull from qhull...tgz or qhull...zip
  - cd src/libqhull_r  # cd src/libqhull 
  - make

  
-----------------
Installing Qhull with CMake 2.6 or later

  See CMakeLists.txt for examples and further build instructions
  
  To build Qhull, static libraries, shared library, and C++ interface
  - Download and extract Qhull (either GitHub, .tgz file, or .zip file)
  - cd build
  - cmake --help  # List build generators
  - make -G "" .. && cmake ..  
  - cmake ..
  - make
  - make install

  The ".." is important.  It refers to the parent directory (i.e., qhull/)

  On Windows, CMake installs to C:/Program Files/qhull.  64-bit generators
  have a "Win64" tag.
  
  If creating a qhull package, please include a pkg-config file based on build/qhull*.pc.in

  If cmake fails with "No CMAKE_C_COMPILER could be found"
  - cmake was not able to find the build environment specified by -G "..."
  
-----------------
Installing Qhull with Qt

  To build Qhull, including its C++ test (qhulltest)
  - Download and extract Qhull (either GitHub, .tgz file, or .zip file)
  - Load src/qhull-all.pro into QtCreator
  - Build

-------------------
Working with Qhull's C++ interface

  See html/qh-code.htm#cpp for calling Qhull from C++ programs
  
  See html/qh-code.htm#reentrant for converting from Qhull-2012

  Examples of using the C++ interface
    user_eg3_r.cpp
    qhulltest/*_test.cpp

  Qhull's C++ interface is likely to change.  Stay current with GitHub.

  To clone Qhull's next branch from http://github.com/qhull/qhull
    git init
    git clone git@github.com:qhull/qhull.git
    cd qhull
    git checkout next
    ...
    git pull origin next
    
  Compile qhullcpp and libqhullstatic_r with the same compiler.  Both libraries
  use the C routines setjmp() and longjmp() for error handling.  They must 
  be compiled with the same compiler.
  
-------------------
Calling Qhull from C programs

  See html/qh-code.htm#library for calling Qhull from C programs

  See html/qh-code.htm#reentrant for converting from Qhull-2012

  Warning: You will need to understand Qhull's data structures and read the 
  code.  Most users will find it easier to call Qhull as an external command.

  The new, reentrant 'C' code (src/libqhull_r), passes a pointer to qhT 
  to most Qhull routines.  This allows multiple instances of Qhull to run 
  at the same time.  It simplifies the C++ interface.

  The non-reentrant 'C' code (src/libqhull) looks unusual.  It refers to 
  Qhull's global data structure, qhT, through a 'qh' macro (e.g., 'qh ferr'). 
  This allows the same code to use static memory or heap memory. 
  If qh_QHpointer is defined, qh_qh is a pointer to an allocated qhT; 
  otherwise qh_qh is a global static data structure of type qhT.

------------------
Compiling Qhull with Microsoft Visual C++

  To compile 32-bit Qhull with Microsoft Visual C++ 2010 and later
  - Download and extract Qhull (either GitHub, .tgz file, or .zip file)
  - Load solution build/qhull-32.sln 
  - Build target 'Win32'
  - Project qhulltest requires Qt for DevStudio (http://www.qt.io)
    Set the QTDIR environment variable to your Qt directory (e.g., c:/qt/5.2.0/5.2.0/msvc2012)
    If QTDIR is incorrect, precompile will fail with 'Can not locate the file specified'

  To compile 64-bit Qhull with Microsoft Visual C++ 2010 and later
  - 64-bit Qhull has larger data structures due to 64-bit pointers
  - Download and extract Qhull (either GitHub, .tgz file, or .zip file)
  - Load solution build/qhull-64.sln 
  - Build target 'Win32'
  - Project qhulltest requires Qt for DevStudio (http://www.qt.io)
    Set the QTDIR environment variable to your Qt directory (e.g., c:/qt/5.2.0/5.2.0/msvc2012_64)
    If QTDIR is incorrect, precompile will fail with 'Can not locate the file specified'
  
  To compile Qhull with Microsoft Visual C++ 2005 (vcproj files)
  - Download and extract Qhull (either GitHub, .tgz file, or .zip file)
  - Load solution build/qhull.sln 
  - Build target 'win32' (not 'x64')
  - Project qhulltest requires Qt for DevStudio (http://www.qt.io)
    Set the QTDIR environment variable to your Qt directory (e.g., c:/qt/4.7.4)
    If QTDIR is incorrect, precompile will fail with 'Can not locate the file specified'
  
-----------------
Compiling Qhull with Qt Creator

  Qt (http://www.qt.io) is a C++ framework for Windows, Linux, and Macintosh

  Qhull uses QTestLib to test qhull's C++ interface (see src/qhulltest/)
  
  To compile Qhull with Qt Creator
  - Download and extract Qhull (either GitHub, .tgz file, or .zip file)
  - Download the Qt SDK
  - Start Qt Creator
  - Load src/qhull-all.pro
  - Build

-----------------
Compiling Qhull with mingw on Windows

  To compile Qhull with MINGW
  - Download and extract Qhull (either GitHub, .tgz file, or .zip file)
  - Install Road Bash (http://www.qhull.org/bash)
    or install MSYS (http://www.mingw.org/wiki/msys)
  - Install MINGW-w64 (http://sourceforge.net/projects/mingw-w64).  
    Mingw is included with Qt SDK.  
  - make
  
-----------------
Compiling Qhull with cygwin on Windows

  To compile Qhull with cygwin
  - Download and extract Qhull (either GitHub, .tgz file, or .zip file)
  - Install cygwin (http://www.cygwin.com)
  - Include packages for gcc, make, ar, and ln
  - make

-----------------
Compiling from Makfile without gcc

  The file, qhull-src.tgz, contains documentation and source files for
  qhull and rbox.  
  
  To unpack the tgz file
  - tar zxf qhull-src.tgz
  - cd qhull
  - Use qhull/Makefile
   Simpler Makefiles are qhull/src/libqhull/Makefile and qhull/src/libqhull_r/Makefile
  
  Compiling qhull and rbox with Makefile
  - in Makefile, check the CC, CCOPTS1, PRINTMAN, and PRINTC defines
      - the defaults are gcc and enscript
      - CCOPTS1 should include the ANSI flag.  It defines __STDC__
  - in user.h, check the definitions of qh_SECticks and qh_CPUclock.
      - use '#define qh_CLOCKtype 2' for timing runs longer than 1 hour
  - type: make 
      - this builds: qhull qconvex qdelaunay qhalf qvoronoi rbox libqhull.a libqhull_r.a
  - type: make doc
      - this prints the man page
      - See also qhull/html/index.htm
  - if your compiler reports many errors, it is probably not a ANSI C compiler
      - you will need to set the -ansi switch or find another compiler
  - if your compiler warns about missing prototypes for fprintf() etc.
      - this is ok, your compiler should have these in stdio.h
  - if your compiler warns about missing prototypes for memset() etc.
      - include memory.h in qhull_a.h
  - if your compiler reports "global.c: storage size of 'qh_qh' isn't known"
      - delete the initializer "={0}" in global.c, stat.c and mem.c
  - if your compiler warns about "stat.c: improper initializer"
      - this is ok, the initializer is not used
  - if you have trouble building libqhull.a with 'ar'
      - try 'make -f Makefile.txt qhullx' 
  - if the code compiles, the qhull test case will automatically execute
  - if an error occurs, there's an incompatibility between machines
      - If you can, try a different compiler 
      - You can turn off the Qhull memory manager with qh_NOmem in mem.h
      - You can turn off compiler optimization (-O2 in Makefile)
      - If you find the source of the problem, please let us know
  - to install the programs and their man pages:
      - define MANDIR and BINDIR
      - type 'make install'

  - if you have Geomview (www.geomview.org)
       - try  'rbox 100 | qconvex G >a' and load 'a' into Geomview
       - run 'q_eg' for Geomview examples of Qhull output (see qh-eg.htm)

------------------
Compiling on other machines and compilers

  Qhull may compile with Borland C++ 5.0 bcc32.  A Makefile is included.
  Execute 'cd src/libqhull; make -f Mborland'.  If you use the Borland IDE, set
  the ANSI option in Options:Project:Compiler:Source:Language-compliance.
  
  Qhull may compile with Borland C++ 4.02 for Win32 and DOS Power Pack.  
  Use 'cd src/libqhull; make -f Mborland -D_DPMI'.  Qhull 1.0 compiles with 
  Borland C++ 4.02.  For rbox 1.0, use "bcc32 -WX -w- -O2-e -erbox -lc rbox.c".  
  Use the same options for Qhull 1.0. [D. Zwick]
  
  If you have troubles with the memory manager, you can turn it off by
  defining qh_NOmem in mem.h.

-----------------
Distributed files

  README.txt           // Instructions for installing Qhull 
  REGISTER.txt         // Qhull registration 
  COPYING.txt          // Copyright notice 
  QHULL-GO.lnk         // Windows icon for eg/qhull-go.bat
  Announce.txt         // Announcement 
  CMakeLists.txt       // CMake build file (2.6 or later)
  CMakeModules/CheckLFS.cmake // enables Large File Support in cmake
  File_id.diz          // Package descriptor
  index.htm            // Home page 
  Makefile             // Makefile for gcc and other compilers
  qhull*.md5sum        // md5sum for all files

  bin/*                // Qhull executables and dll (.zip only)
  build/qhull*.pc.in   // pkg-config templates for qhull_r, qhull, and qhull_p
  build/qhull-32.sln   // 32-bit DevStudio solution and project files (2010 and later)
  build/*-32.vcxproj
  build/qhull-64.sln   // 64-bit DevStudio solution and project files (2010 and later)
  build/*-64.vcxproj
  build/qhull.sln      // DevStudio solution and project files (2005 and 2009)
  build/*.vcproj
  eg/*                 // Test scripts and geomview files from q_eg
  html/index.htm       // Manual
  html/qh-faq.htm      // Frequently asked questions
  html/qh-get.htm      // Download page
  html/qhull-cpp.xml   // C++ style notes as a Road FAQ (www.qhull.org/road)
  src/Changes.txt      // Change history for Qhull and rbox 
  src/qhull-all.pro    // Qt project

eg/ 
  q_eg                 // shell script for Geomview examples (eg.01.cube)
  q_egtest             // shell script for Geomview test examples
  q_test               // shell script to test qhull
  q_test-ok.txt        // output from q_test
  qhulltest-ok.txt     // output from qhulltest (Qt only)
  make-vcproj.sh       // bash shell script to create vcproj and vcxprog files
  qhull-zip.sh	       // bash shell script for distribution files

rbox consists of (bin, html):
  rbox.exe             // Win32 executable (.zip only) 
  rbox.htm             // html manual 
  rbox.man             // Unix man page 
  rbox.txt

qhull consists of (bin, html):
  qconvex.exe          // Win32 executables and dlls (.zip download only) 
  qhull.exe            // Built with the reentrant library (about 2% slower)
  qdelaunay.exe
  qhalf.exe
  qvoronoi.exe
  qhull_r.dll
  qhull-go.bat         // command window
  qconvex.htm          // html manual
  qdelaun.htm
  qdelau_f.htm        
  qhalf.htm
  qvoronoi.htm
  qvoron_f.htm
  qh-eg.htm
  qh-code.htm
  qh-impre.htm
  index.htm
  qh-opt*.htm
  qh-quick.htm
  qh--*.gif            // images for manual
  normal_voronoi_knauss_oesterle.jpg
  qhull.man            // Unix man page 
  qhull.txt

bin/
  msvcr80.dll          // Visual C++ redistributable file (.zip download only)

src/
  qhull/unix.c         // Qhull and rbox applications using non-reentrant libqhullstatic.a
  rbox/rbox.c
  qconvex/qconvex.c    
  qhalf/qhalf.c
  qdelaunay/qdelaunay.c
  qvoronoi/qvoronoi.c

  qhull/unix_r.c        // Qhull and rbox applications using reentrant libqhullstatic_r.a
  rbox/rbox_r.c
  qconvex/qconvex_r.c   // Qhull applications built with reentrant libqhull_r/Makefile  
  qhalf/qhalf_r.c
  qdelaunay/qdelaun_r.c
  qvoronoi/qvoronoi_r.c

  user_eg/user_eg_r.c     // example of using qhull_r.dll from a user program
  user_eg2/user_eg2_r.c   // example of using libqhullstatic_r.a from a user program
  user_eg3/user_eg3_r.cpp // example of Qhull's C++ interface libqhullcpp with libqhullstatic_r.a
  qhulltest/qhulltest.cpp // Test of Qhull's C++ interface using Qt's QTestLib
  qhull-*.pri             // Include files for Qt projects
  testqset_r/testqset_r.c  // Test of reentrant qset_r.c and mem_r.c
  testqset/testqset.c     // Test of non-rentrant qset.c and mem.c


src/libqhull
  libqhull.pro         // Qt project for non-rentrant, shared library (qhull.dll)
  index.htm            // design documentation for libqhull
  qh-*.htm
  qhull-exports.def    // Export Definition file for Visual C++
  Makefile             // Simple gcc Makefile for qhull and libqhullstatic.a
  Mborland             // Makefile for Borland C++ 5.0

  libqhull.h           // header file for qhull
  user.h               // header file of user definable constants 
  libqhull.c           // Quickhull algorithm with partitioning
  user.c               // user re-definable functions 
  usermem.c
  userprintf.c
  userprintf_rbox.c

  qhull_a.h            // include files for libqhull/*.c 
  geom.c               // geometric routines 
  geom2.c
  geom.h     
  global.c             // global variables 
  io.c                 // input-output routines 
  io.h   
  mem.c                // memory routines, this is stand-alone code 
  mem.h
  merge.c              // merging of non-convex facets 
  merge.h
  poly.c               // polyhedron routines 
  poly2.c
  poly.h 
  qset.c               // set routines, this only depends on mem.c 
  qset.h
  random.c             // utilities w/ Park & Miller's random number generator
  random.h
  rboxlib.c            // point set generator for rbox
  stat.c               // statistics 
  stat.h

src/libqhull_r
  libqhull_r.pro       // Qt project for rentrant, shared library (qhull_r.dll)
  index.htm            // design documentation for libqhull_r
  qh-*_r.htm
  qhull-exports_r.def  // Export Definition file for Visual C++
  Makefile             // Simple gcc Makefile for qhull and libqhullstatic.a

  libqhull_r.h          // header file for qhull
  user_r.h              // header file of user definable constants 
  libqhull_r.c          // Quickhull algorithm wi_r.hpartitioning
  user_r.c              // user re-definable functions 
  usermem.c
  userprintf.c
  userprintf_rbox.c
  qhull_ra.h            // include files for libqhull/*_r.c
  geom_r.c              // geometric routines 
  geom2.c
  geom_r.h    
  global_r.c            // global variables 
  io_r.c                // input-output routines 
  io_r.h  
  mem_r.c               // memory routines, this is stand-alone code 
  mem.h
  merge_r.c             // merging of non-convex facets 
  merge.h
  poly_r.c              // polyhedron routines 
  poly2.c
  poly_r.h
  qset_r.c              // set routines, this only depends on mem_r.c
  qset.h
  random_r.c            // utilities w/ Park & Miller's random number generator
  random.h
  rboxlib_r.c           // point set generator for rbox
  stat_r.c              // statistics 
  stat.h

src/libqhullcpp/
  libqhullcpp.pro      // Qt project for renentrant, static C++ library     
  Qhull.cpp            // Calls libqhull_r.c from C++
  Qhull.h
  qt-qhull.cpp         // Supporting methods for Qt
    
  Coordinates.cpp      // input classes
  Coordinates.h

  PointCoordinates.cpp
  PointCoordinates.h
  RboxPoints.cpp       // call rboxlib.c from C++
  RboxPoints.h

  QhullFacet.cpp       // data structure classes
  QhullFacet.h
  QhullHyperplane.cpp
  QhullHyperplane.h
  QhullPoint.cpp
  QhullPoint.h
  QhullQh.cpp
  QhullRidge.cpp
  QhullRidge.h
  QhullVertex.cpp
  QhullVertex.h
  
  QhullFacetList.cpp   // collection classes
  QhullFacetList.h
  QhullFacetSet.cpp
  QhullFacetSet.h
  QhullIterator.h
  QhullLinkedList.h
  QhullPoints.cpp
  QhullPoints.h
  QhullPointSet.cpp
  QhullPointSet.h
  QhullSet.cpp
  QhullSet.h
  QhullSets.h
  QhullVertexSet.cpp
  QhullVertexSet.h

  functionObjects.h    // supporting classes
  QhullError.cpp
  QhullError.h
  QhullQh.cpp
  QhullQh.h
  QhullStat.cpp
  QhullStat.h
  RoadError.cpp        // Supporting base classes
  RoadError.h
  RoadLogEvent.cpp
  RoadLogEvent.h
  usermem_r-cpp.cpp    // Optional override for qh_exit() to throw an error

src/libqhullstatic/
  libqhullstatic.pro   // Qt project for non-reentrant, static library     
     
src/libqhullstatic_r/
  libqhullstatic_r.pro // Qt project for reentrant, static library     
     
src/qhulltest/
  qhulltest.pro        // Qt project for test of C++ interface     
  Coordinates_test.cpp // Test of each class
  PointCoordinates_test.cpp
  Qhull_test.cpp
  QhullFacet_test.cpp
  QhullFacetList_test.cpp
  QhullFacetSet_test.cpp
  QhullHyperplane_test.cpp
  QhullLinkedList_test.cpp
  QhullPoint_test.cpp
  QhullPoints_test.cpp
  QhullPointSet_test.cpp
  QhullRidge_test.cpp
  QhullSet_test.cpp
  QhullVertex_test.cpp
  QhullVertexSet_test.cpp
  RboxPoints_test.cpp
  RoadTest.cpp         // Run multiple test files with QTestLib
  RoadTest.h

-----------------
Authors:

  C. Bradford Barber                  Hannu Huhdanpaa (Version 1.0)
  bradb@shore.net                     hannu@qhull.org
  
  Qhull 1.0 and 2.0 were developed under NSF grants NSF/DMS-8920161 
  and NSF-CCR-91-15793 750-7504 at the Geometry Center and Harvard 
  University.  If you find Qhull useful, please let us know.
geometry/inst/doc/qhull/html/0000755000176200001440000000000014664417655015742 5ustar  liggesusersgeometry/inst/doc/qhull/html/qconvex.html0000644000176200001440000006620114664417655020320 0ustar  liggesusers



qconvex -- convex hull




Up:
Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options

[cone]qconvex -- convex hull

The convex hull of a set of points is the smallest convex set containing the points. See the detailed introduction by O'Rourke ['94]. See Description of Qhull and How Qhull adds a point.

Example: rbox 10 D3 | qconvex s o TO result
Compute the 3-d convex hull of 10 random points. Write a summary to the console and the points and facets to 'result'.
 
Example: rbox c | qconvex n
Print the normals for each facet of a cube.
 
Example: rbox c | qconvex i Qt
Print the triangulated facets of a cube.
 
Example: rbox y 500 W0 | qconvex
Compute the convex hull of a simplex with 500 points on its surface.
 
Example: rbox x W1e-12 1000 | qconvex QR0
Compute the convex hull of 1000 points near the surface of a randomly rotated simplex. Report the maximum thickness of a facet.
 
Example: rbox 1000 s | qconvex s FA
Compute the convex hull of 1000 cospherical points. Verify the results and print a summary with the total area and volume.
 
Example: rbox d D12 | qconvex QR0 FA
Compute the convex hull of a 12-d diamond. Randomly rotate the input. Note the large number of facets and the small volume.
 
Example: rbox c D7 | qconvex FA TF1000
Compute the convex hull of the 7-d hypercube. Report on progress every 1000 facets. Computing the convex hull of the 9-d hypercube takes too much time and space.
 
Example: rbox c d D2 | qconvex Qc s f Fx | more
Dump all fields of all facets for a square and a diamond. Also print a summary and a list of vertices. Note the coplanar points.
 

Except for rbox, all of the qhull programs compute a convex hull.

By default, Qhull merges coplanar facets. For example, the convex hull of a cube's vertices has six facets.

If you use 'Qt' (triangulated output), all facets will be simplicial (e.g., triangles in 2-d). For the cube example, it will have 12 facets. Some facets may be degenerate and have zero area.

If you use 'QJ' (joggled input), all facets will be simplicial. The corresponding vertices will be slightly perturbed and identical points will be joggled apart. Joggled input is less accurate that triangulated output.See Merged facets or joggled input.

The output for 4-d convex hulls may be confusing if the convex hull contains non-simplicial facets (e.g., a hypercube). See Why are there extra points in a 4-d or higher convex hull?

The 'qconvex' program is equivalent to 'qhull'. It disables the following Qhull options: d v H Qbb Qf Qg Qm Qr Qu Qv Qx Qz TR E V Fp Gt Q0,etc.

Copyright © 1995-2020 C.B. Barber


»qconvex synopsis

qconvex -- compute the convex hull.
    input (stdin): dimension, number of points, point coordinates
    comments start with a non-numeric character

options:
    Qt   - triangulated output
    QJ   - joggled input instead of merged facets
    Tv   - verify result: structure, convexity, and point inclusion
    .    - concise list of all options
    -    - one-line description of each option
    -?   - this message
    -V   - version

output options (subset):
    s    - summary of results (default)
    i    - vertices incident to each facet
    n    - normals with offsets
    p    - vertex coordinates (if 'Qc', includes coplanar points)
    FA   - report total area and volume
    FS   - total area and volume
    Fx   - extreme points (convex hull vertices)
    G    - Geomview output (2-d, 3-d, and 4-d)
    m    - Mathematica output (2-d and 3-d)
    o    - OFF format (dim, n, points, facets)
    QVn  - print facets that include point n, -n if not
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes

examples:
    rbox c D2 | qconvex s n                    rbox c D2 | qconvex i
    rbox c D2 | qconvex o                      rbox 1000 s | qconvex s Tv FA
    rbox c d D2 | qconvex s Qc Fx              rbox y 1000 W0 | qconvex Qc s n
    rbox y 1000 W0 | qconvex s QJ              rbox d G1 D12 | qconvex QR0 FA Pp
    rbox c D7 | qconvex FA TF1000

»qconvex input

The input data on stdin consists of:

  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qconvex < data.txt), a pipe (e.g., rbox 10 | qconvex), or the 'TI' option (e.g., qconvex TI data.txt).

Comments start with a non-numeric character. Error reporting is simpler if there is one point per line. Dimension and number of points may be reversed.

Here is the input for computing the convex hull of the unit cube. The output is the normals, one per facet.

rbox c > data

3 RBOX c
8
  -0.5   -0.5   -0.5
  -0.5   -0.5    0.5
  -0.5    0.5   -0.5
  -0.5    0.5    0.5
   0.5   -0.5   -0.5
   0.5   -0.5    0.5
   0.5    0.5   -0.5
   0.5    0.5    0.5

qconvex s n < data


Convex hull of 8 points in 3-d:

  Number of vertices: 8
  Number of facets: 6
  Number of non-simplicial facets: 6

Statistics for: RBOX c | QCONVEX s n

  Number of points processed: 8
  Number of hyperplanes created: 11
  Number of distance tests for qhull: 35
  Number of merged facets: 6
  Number of distance tests for merging: 84
  CPU seconds to compute hull (after input): 0.081

4
6
     0      0     -1   -0.5
     0     -1      0   -0.5
     1      0      0   -0.5
    -1      0      0   -0.5
     0      1      0   -0.5
     0      0      1   -0.5

»qconvex outputs

These options control the output of qconvex. They may be used individually or together.

 
Vertices
Fx
list extreme points (i.e., vertices). The first line is the number of extreme points. Each point is listed, one per line. The cube example has eight vertices. In 2-d, extreme points are in counter-clockwise order.
Fv
list vertices for each facet. The first line is the number of facets. Each remaining line starts with the number of vertices. For the cube example, each facet has four vertices.
i
list vertices for each facet. The first line is the number of facets. The remaining lines list the vertices for each facet. The facets are oriented. In 4-d and higher, triangulate non-simplicial facets by adding an extra point.
 
 
Coordinates
o
print vertices and facets of the convex hull in OFF format. The first line is the dimension. The second line is the number of vertices, facets, and ridges. The vertex coordinates are next, followed by the facets. Each facet starts with the number of vertices. Simplicial and 3-d facets are oriented. The cube example has four vertices per facet.
Ft
print a triangulation of the convex hull in OFF format. The first line is the dimension. The second line is the number of vertices and added points, followed by the number of facets and the number of ridges. The vertex coordinates are next, followed by the centrum coordinates. There is one centrum for each non-simplicial facet. The cube example has six centrums, one per square. Each facet starts with the number of vertices or centrums. In the cube example, each facet uses two vertices and one centrum.
p
print vertex coordinates. The first line is the dimension and the second line is the number of vertices. The following lines are the coordinates of each vertex. The cube example has eight vertices.
Qc p
print coordinates of vertices and coplanar points. The first line is the dimension. The second line is the number of vertices and coplanar points. The coordinates are next, one line per point. Use 'Qc Qi p' to print the coordinates of all points.
 
 
Facets
Fn
list neighboring facets for each facet. The first line is the number of facets. Each remaining line starts with the number of neighboring facets. The cube example has four neighbors per facet.
FN
list neighboring facets for each point. The first line is the total number of points. Each remaining line starts with the number of neighboring facets. Each vertex of the cube example has three neighboring facets. Use 'Qc Qi FN' to include coplanar and interior points.
Fa
print area for each facet. The first line is the number of facets. Facet area follows, one line per facet. For the cube example, each facet has area one.
FI
list facet IDs. The first line is the number of facets. The IDs follow, one per line.
 
 
Coplanar and interior points
Fc
list coplanar points for each facet. The first line is the number of facets. The remaining lines start with the number of coplanar points. A coplanar point is assigned to one facet.
Qi Fc
list interior points for each facet. The first line is the number of facets. The remaining lines start with the number of interior points. A coplanar point is assigned to one facet.
FP
print distance to nearest vertex for coplanar points. The first line is the number of coplanar points. Each remaining line starts with the point ID of a vertex, followed by the point ID of a coplanar point, its facet, and distance. Use 'Qc Qi FP' for coplanar and interior points.
 
 
Hyperplanes
n
print hyperplane for each facet. The first line is the dimension. The second line is the number of facets. Each remaining line is the hyperplane's coefficients followed by its offset.
Fo
print outer plane for each facet. The output plane is above all points. The first line is the dimension. The second line is the number of facets. Each remaining line is the outer plane's coefficients followed by its offset.
Fi
print inner plane for each facet. The inner plane of a facet is below its vertices. The first line is the dimension. The second line is the number of facets. Each remaining line is the inner plane's coefficients followed by its offset.
 
 
General
s
print summary for the convex hull. Use 'Fs' and 'FS' if you need numeric data.
FA
compute total area and volume for 's' and 'FS'
m
Mathematica output for the convex hull in 2-d or 3-d.
FM
Maple output for the convex hull in 2-d or 3-d.
G
Geomview output for the convex hull in 2-d, 3-d, or 4-d.
 
 
Scaling and rotation
Qbk:n
scale k'th coordinate to lower bound.
QBk:n
scale k'th coordinate to upper bound.
QbB
scale input to unit cube centered at the origin.
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
Qbk:0Bk:0
remove k'th coordinate from input. This computes the convex hull in one lower dimension.

»qconvex controls

These options provide additional control:

Qt
triangulated output. Qhull triangulates non-simplicial facets. It may produce degenerate facets of zero area.
QJ
joggle the input instead of merging facets. This guarantees simplicial facets (e.g., triangles in 3-d). It is less accurate than triangulated output ('Qt').
Qc
keep coplanar points
Qi
keep interior points
f
facet dump. Print the data structure for each facet.
QVn
select facets containing point n as a vertex,
QGn
select facets that are visible from point n (marked 'good'). Use -n for the remainder.
PDk:0
select facets with a negative coordinate for dimension k
TFn
report progress after constructing n facets
Tv
verify result
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
Qs
search all points for the initial simplex. If Qhull can not construct an initial simplex, it reports a descriptive message. Usually, the point set is degenerate and one or more dimensions should be removed ('Qbk:0Bk:0'). If not, use option 'Qs'. It performs an exhaustive search for the best initial simplex. This is expensive is high dimensions.

»qconvex graphics

Display 2-d, 3-d, and 4-d convex hulls with Geomview ('G').

Display 2-d and 3-d convex hulls with Mathematica ('m').

To view 4-d convex hulls in 3-d, use 'Pd0d1d2d3' to select the positive octant and 'GrD2' to drop dimension 2.

»qconvex notes

Qhull always computes a convex hull. The convex hull may be used for other geometric structures. The general technique is to transform the structure into an equivalent convex hull problem. For example, the Delaunay triangulation is equivalent to the convex hull of the input sites after lifting the points to a paraboloid.

»qconvex conventions

The following terminology is used for convex hulls in Qhull. See Qhull's data structures.

  • point - d coordinates
  • vertex - extreme point of the input set
  • ridge - d-1 vertices between two neighboring facets
  • hyperplane - halfspace defined by a unit normal and offset
  • coplanar point - a nearly incident point to a hyperplane
  • centrum - a point on the hyperplane for testing convexity
  • facet - a facet with vertices, ridges, coplanar points, neighboring facets, and hyperplane
  • simplicial facet - a facet with d vertices, d ridges, and d neighbors
  • non-simplicial facet - a facet with more than d vertices
  • good facet - a facet selected by 'QVn', etc.

»qconvex options

qconvex -- compute the convex hull
    http://www.qhull.org

input (stdin):
    first lines: dimension and number of points (or vice-versa).
    other lines: point coordinates, best if one point per line
    comments:    start with a non-numeric character

options:
    Qc   - keep coplanar points with nearest facet
    Qi   - keep interior points with nearest facet
    QJ   - joggled input instead of merged facets
    Qt   - triangulated output

Qhull control options:
    Qa   - allow input with fewer or more points than coordinates
    Qbk:n   - scale coord k so that low bound is n
      QBk:n - scale coord k so that upper bound is n (QBk is 0.5)
    QbB  - scale input to unit cube centered at the origin
    Qbk:0Bk:0 - remove k-th coordinate from input
    QJn  - randomly joggle input in range [-n,n]
    QRn  - random rotation (n=seed, n=0 time, n=-1 time/no rotate)
    Qs   - search all points for the initial simplex

Qhull extra options:
    QGn  - good facet if visible from point n, -n for not visible
    QVn  - good facet if it includes point n, -n if not
    Qw   - allow option warnings
    Q12  - allow wide facets and wide dupridge
    Q14  - merge pinched vertices that create a dupridge

T options:
    TFn  - report summary when n or more facets created
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes
    Ts   - statistics
    Tv   - verify result: structure, convexity, and in-circle test
    Tz   - send all output to stdout

Trace options:
    T4   - trace at level n, 4=all, 5=mem/gauss, -1= events
    Ta   - annotate output with message codes
    TAn  - stop qhull after adding n vertices
     TCn - stop qhull after building cone for point n
     TVn - stop qhull after adding point n, -n for before
    Tc   - check frequently during execution
    Tf   - flush each qh_fprintf for debugging segfaults
    TPn  - turn on tracing when point n added to hull
     TMn - turn on tracing at merge n
     TWn - trace merge facets when width > n

Precision options:
    Cn   - radius of centrum (roundoff added).  Merge facets if non-convex
     An  - cosine of maximum angle.  Merge facets if cosine > n or non-convex
           C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge
    Rn   - randomly perturb computations by a factor of [1-n,1+n]
    Un   - max distance below plane for a new, coplanar point
    Wn   - min facet width for outside point (before roundoff)

Output formats (may be combined; if none, produces a summary to stdout):
    f    - facet dump
    G    - Geomview output (see below)
    i    - vertices incident to each facet
    m    - Mathematica output (2-d and 3-d)
    n    - normals with offsets
    o    - OFF file format (dim, points and facets)
    p    - point coordinates
    s    - summary (stderr)

More formats:
    Fa   - area for each facet
    FA   - compute total area and volume for option 's'
    Fc   - count plus coplanar points for each facet
           use 'Qc' (default) for coplanar and 'Qi' for interior
    FC   - centrum for each facet
    Fd   - use cdd format for input (homogeneous with offset first)
    FD   - use cdd format for numeric output (offset first)
    FF   - facet dump without ridges
    Fi   - inner plane for each facet
    FI   - ID for each facet
    Fm   - merge count for each facet (511 max)
    FM   - Maple output (2-d and 3-d)
    Fn   - count plus neighboring facets for each facet
    FN   - count plus neighboring facets for each point
    Fo   - outer plane (or max_outside) for each facet
    FO   - options and precision constants
    FP   - nearest vertex for each coplanar point
    FQ   - command used for qconvex
    Fs   - summary: #int (8), dimension, #points, tot vertices, tot facets,
                      output: #vertices, #facets, #coplanars, #nonsimplicial
                    #real (2), max outer plane, min vertex
    FS   - sizes:   #int (0)
                    #real (2) tot area, tot volume
    Ft   - triangulation with centrums for non-simplicial facets (OFF format)
    Fv   - count plus vertices for each facet
    FV   - average of vertices (a feasible point for 'H')
    Fx   - extreme points (in order for 2-d)

Geomview output (2-d, 3-d, and 4-d)
    Ga   - all points as dots
     Gp  -  coplanar points and vertices as radii
     Gv  -  vertices as spheres
    Gc   - centrums
    GDn  - drop dimension n in 3-d and 4-d output
    Gh   - hyperplane intersections
    Gi   - inner planes only
     Gn  -  no planes
     Go  -  outer planes only
    Gr   - ridges

Print options:
    PAn  - keep n largest facets by area
    Pdk:n - drop facet if normal[k] <= n (default 0.0)
    PDk:n - drop facet if normal[k] >= n
    PFn  - keep facets whose area is at least n
    Pg   - print good facets (needs 'QGn' or 'QVn')
    PG   - print neighbors of good facets
    PMn  - keep n facets with most merges
    Po   - force output.  If error, output neighborhood of facet
    Pp   - do not report precision problems

    .    - list of all options
    -    - one line descriptions of all options
    -?   - help with examples
    -V   - version

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qh-get.html0000644000176200001440000001352714664417655020025 0ustar liggesusers Qhull Downloads

Up: Qhull Home Page (www.qhull.org)


[CONE] Qhull Downloads

  • Qhull Home Page

    Qhull computes the convex hull, Delaunay triangulation, Voronoi diagram, halfspace intersection about a point, furthest-site Delaunay triangulation, and furthest-site Voronoi diagram. It runs in 2-d, 3-d, 4-d, and higher dimensions. It implements the Quickhull algorithm for computing the convex hull. Qhull handles roundoff errors from floating point arithmetic. It can approximate a convex hull.

    Visit Qhull News for news, bug reports, change history, and users. If you use Qhull 2003.1 or 2009.1, please upgrade or apply poly.c-qh_gethash.patch.

  • Download: Qhull 2020.2 for Windows 10, 8, 7, XP, and NT (3.3 MB, readme, md5sum, contents)

    Type: console programs for Windows (32- or 64-bit)

    Includes 32-bit executables, documentation, and sources files. It runs in a command window. Qhull may be compiled for 64-bits.

  • GitHub Qhull (git@github.com:qhull/qhull.git)

    Type: git repository for Qhull. See current Changes.txt

    Includes documentation, source files, C++ interface, and test programs. It builds with gcc, mingw, CMake, DevStudio, and Qt Creator.

  • Download: Qhull 2020.2 for Unix (1.3 MB, readme, md5sum, contents)

    Type: C/C++ source code for 32-bit and 64-bit architectures.

    Includes documentation, source files, Makefiles, CMakeLists.txt, DevStudio projects, and Qt projects. Includes C++ support.

    Download and search sites for pre-built packages include

  • The Quickhull algorithm for convex hulls (PDF, 307K)

    Type: PDF on ACM Digital Library (from this page only)

    Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., "The Quickhull algorithm for convex hulls," ACM Transactions on Mathematical Software, 22(4):469-483, Dec 1996 [abstract].

  • Download: Qhull version 1.0 (92K)

    Type: C source code for 32-bit architectures

    Version 1.0 is a fifth the size of version 2.4. It computes convex hulls and Delaunay triangulations. If a precision error occurs, it stops with an error message. It reports an initialization error for inputs made with 0/1 coordinates.

    Version 1.0 compiles on a PC with Borland C++ 4.02 for Win32 and DOS Power Pack. The options for rbox are "bcc32 -WX -w- -O2-e -erbox -lc rbox.c". The options for qhull are the same. [D. Zwick]

  • Sept. 3, 2020 22:14 EDT md5sum for Qhull 2020.2 downloads
    4f68ebb4700849a548b332de500d42e9 *qhull-2020.2/qhull-2020.2-zip.md5sum
    ed767244864488d5e9a22dfa788663a9 *qhull-2020.2/qhull-2020-src-8.0.2-tgz.md5sum
    7ed0bcce474bf12f6fbb5b4093760f3d *qhull-2020.2.zip
    295f7332269a38279478f555cc185296 *qhull-2020-src-8.0.2.tgz
    

Up: Qhull Home Page (www.qhull.org)


[HOME] The Geometry Center Home Page

Comments to: qhull@qhull.org
geometry/inst/doc/qhull/html/qh--cone.gif0000644000176200001440000000560213431000556020016 0ustar liggesusersGIF87addç[~.TopPZ OXa>Uj3.OšP*$?C1Lk5k4'#?9$k)KTRn(7+-aV_"/*&%Z—@‹®˜K\!£µ©JZ W‘=:5€¨ÅÊÇQƒ7]/F@(Y()]/D_¤½­)$&Kb>2;<}M7%,'X{-NY zvsUu*$j(f2?…S=Q"9-\N…:?€I^œCÕ×Ö]œB\šAOz1L[!<6^caþþþqpmüüü¶µ´_‚0úúúT^"öööS\!ôôôñòñ86Oq*1.$ìììPBCK$4''´Á¸T¤VÛÜÛF†EO†:PœR’‘W.OšQ(%M–Oª¯®k5?9LX >9&!608&U3+j>=}IU_"L`#E-“Ÿ—$!ðïïT‹;QBG˜cZ{-2i*b>P‡:3-2-O™P6%ikj3Q($q ‚MY $j)put(D\01#:{O]œC%.;B/)*"+{~{M5R\!QZ %FK33<520[éêê@G3PD{7àâá%k)LSS€Š†Mq,-a.6/21.]›B$#Xz[<=>9$g+<7Ls.ÿÿÿHPýýý_ƒ0Z*F?÷÷÷DŒ^I.óóóQt,#TQM4=ííí;$$G˜dQBA‚GCH;{K3=)&Q*&8[1/GŽP*H˜˜–T£VS£Ub0:)QŸSN™PEd#ÒÓÒ'34Uw,>8¢¦¦Ne%\ZT'&U^"¿¿¿ ::9s;!d*ÇÏÊE•a=~L0+)*Ô,ddþe H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—‰„Ú“%-s_ù Æ&˜ 5Mâ"#[ uÄ-[º4S’ "ÍE’¤NUª«rá"Ш—P:zõª:u„¶v¶#ˆ©gËV=‹Im 6RÚf$Bª„Õ¿€ÿfÕÚÕ™Þ‹I^ü·DšSø:\1‰ ƘWýÙìçO/`”%î…9sç?§‘ ب¹VçÂ6«ÓæÛ\аvØéõlÙr©Ö¾½ÙMZ».!·*íàgë·àfÍµä ‰îœ{lᄈþ'[Cá v„¤J«—ô ¤dÓP 0ù|AnëÕOúÅÿ—¦‹P°ö N~êAÒ©L3ßjö€ ‚™±°à)B2ŸnöÙlÍ}âU“hâ¨8°I€Qa"ÞèU% bâ8 ƒÖGFs þ&œ\«hrã/§À¢£†k˜—\(Æ(¤Œy"*Úè¸âõ±fiböÍ) þ²‰h éà€»}fiœb!§hƒ&šRðUh漉Y ‰|’È)d¢’æ¡ÇáaKLåçb“ òÉ ƒ4sЇ¢‰†ƒ-Rææ£}ÓŒ¤”~¢@˜‘ªäy^þPN$tsUñÉ­·*Bd™¥‰6yØv²>×Ýb(€k®qÄÑŠ¯¬îÈ¥^ UìŒÀá°¬©4;‹’¿jÓÀâ8Ö—C¢ŒÂ%»­Í6;ŽŽÑ»gPø’NjêqTÐ,‡º‹Â$Å„úþ…€¿þ& °Àq€ó„¦h6@APQÒpcÚö;ˆLÜlŸ‚¢k¬ÑCMÀ0ü1$Œzë TT`rÀLx°²¦\”Wӧئk4Uä`JšjI¼PÇ*½âÒ. ½îl% cŠ)˜ÒŒTD µPh¹/q£îµF«ƒCØ`ƒÝŒfCªþ¯Úp±Æ½+‘ÉÛ´+I#u×rä/¯|›°JG|, $L ùæÖÔÀ:|²è­Üi†ktʘúª£Âæ›s‚D-µÌP²è¢ ümšhúýòJ=øÕðܰOC6´ÓÞ 8¸ï<ïhÈç¤JŸê›tñ9tž|-HÑ<V¯ôZá„ÏU‚ `‡6'Û'C Ž+ñ„6¾2"M)uBVú"‚M×HÐ>°qñK^˜à¸bàOGòœIÜ7c­4@†æ–…n¯qy³„|õ‡5È@%C`— «Ri`PåÈœ)´çAÚ™à ŽKßÁ1”ìB_þÒx€(D!ÄÌÉ®†Û³ÝΆ¶C¥Áe(¨¤q!‘ˆÈ@··¼ïU ‡J s’Êù©4¸âiŠRl1~Þ£ØÄx…&m0¢K%¡Ãi D+>€>øA,LðFÚÍOŽ«@éV–†ý$=ajD9†HIQ°ñàÁ#€ƒBÖ"OË]¾Å*1JP$ŠYáUZh‹¦ƒ P…| KU„@‹oaÔæ¥#FœÐ$C8w¾10 •–´$9h9ËZªâ¼(ä ÍF_¥á.*I0Uù0”e@&÷PËfÒR–(Åì¶h;³=AG©XCLkѪÑþ(Ã7ËIÒ€œåd¦*j)HBn±JˆZ1Р X0‚Œ$ €Ä4‡2,@Ÿ]€-@NðÀ)H?RN¾1޳šÒà zªá€Q‡¤1‡ŒbÔ¢¶ØÃF*R‘z´§<¸åi² )âXBI †J¨Á «€.@€6ÔÀ¢7eÀnÑž†”¤$åG¡¹EPšì>³ã)?ÂT<àa• ê ¨ª¬Z4äxÆ3ªÁÕ°úÔ¯$Mçå°30š¡¿ÉÔ0…)À•| @d½ N¼‚ЀÆ34Ë×>ÈR ufAkhC@m#´À1J Æ:¶•þ,([ƒ7Pc³šÍ-4: ZföV&õà è¯gÁ óŒhcÙȶŸÄØ,n¥›ÙÍòv ¾u&3…êA„>®Wu€¨H¸±\Ø6·ªåƒ^uKÝÜêµ³¡=§oÉêA@mÚ°@KI‚ :¼5®TmÃqtà XxÌ`ë5Á€è«X½*V ¸1zÀ¡îº ¥–$ d…€ma£Äy(01Âàà+øÁ ÆÂ¸úW r 4k³ž€†:„#%¡¸ÂNpŽŸÅ6@‡'Âã¿ØÅXúU‘÷ƒ[¨(a“  ¹ÈŠMœ‡${¢Nn°þ“¥ÜÀö”»É3Aí‹Õ¾$ æØ˜Ålä2·Àêe¯f¥+å.|6´ôM^;¥¦^$f È@NpäÛàÏc¨î u[hš3ëT^B/ñ ˆ*Aþ@ÎQbKczÓÓ…F§MËÑÒ hV„°_ÊÐÂË{>r.Z°ÌÆZ¯îí•3Ô¦ÃûÁ³žÃ|âaÆ/.4XA g³¶Â?.Ð."=éj›0NpF *û Ñ„…€[ tBÈ«ÎÃ Îæuë §¦ì;ŽHÔû DÈ—üïháÉ^`·XGk»YX OH®¡ç4üá Ž¸o0¹ÉN"ô §ÎøAš@î\8Âášù@…ªbôZå ‘¾s‘¿›N.p™|ÙpЂ¿ÓV„›è¡Ç @OÜB±à—¡^\à„ÊPF&¸ž)¡ !»Ú×Îö¶»ýíp—E@;geometry/inst/doc/qhull/html/qh-opto.html0000644000176200001440000003705514664417655020231 0ustar liggesusers Qhull output options

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull output options

This section lists the output options for Qhull. These options are indicated by lower case characters. See Formats, Print, and Geomview for other output options.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Output options

Qhull prints its output to standard out. All output is printed text. The default output is a summary (option 's'). Other outputs may be specified as follows.

f
print all fields of all facets
i
print vertices incident to each facet
m
print Mathematica output (2-d and 3-d)
n
print hyperplane normals with offsets
o
print OFF file format (dim, points and facets)
p
print vertex and point coordinates
s
print summary to stderr
 
 
Related options
F
additional input/output formats
Ft
print triangulation with added points
G
Geomview output
P
Print options
 

»f - print all fields of all facets

Print all fields of facetT for all facets. The facet is the primary data structure for Qhull.

Option 'f' is for debugging. Most of the fields are available via the 'F' options. If you need specialized information from Qhull, you can use the Qhull library or C++ interface.

Use the 'FF' option to print the facets but not the ridges.

»i - print vertices incident to each facet

The first line is the number of facets. The remaining lines list the vertices for each facet, one facet per line. The indices are 0-relative indices of the corresponding input points. The facets are oriented. Option 'Fv' displays an unoriented list of vertices with a vertex count per line. Options 'o' and 'Ft' displays coordinates for each vertex prior to the vertices for each facet.

Simplicial facets (e.g., triangles in 3-d) consist of d vertices. Non-simplicial facets in 3-d consist of 4 or more vertices. For example, a facet of a cube consists of 4 vertices. Use option 'Qt' to triangulate non-simplicial facets.

For 4-d and higher convex hulls and 3-d and higher Delaunay triangulations, d vertices are listed for all facets. A non-simplicial facet is triangulated with its centrum and each ridge. The index of the centrum is higher than any input point. Use option 'Fv' to list the vertices of non-simplicial facets as is. Use option 'Ft' to print the coordinates of the centrums as well as those of the input points. The centrum indices for option 'i' are one more than the centrum indices for option 'Ft'.

For halfspace intersection (qhalf), a "facet" is an intersection point and a "point" is a halfspace. Option 'i' lists the non-redundant halfspaces incident to each intersection point. The first line is the number of non-redundant halfspaces. Each remaining line lists the incident, non-redundant halfspaces for that intersection point.

»m - print Mathematica output

Qhull writes a Mathematica file for 2-d and 3-d convex hulls, 2-d and 3-d halfspace intersections, and 2-d Delaunay triangulations. Qhull produces a list of objects that you can assign to a variable in Mathematica, for example: "list= << <outputfilename> ". If the object is 2-d, it can be visualized by "Show[Graphics[list]] ". For 3-d objects the command is "Show[Graphics3D[list]] ". Now the object can be manipulated by commands of the form "Show[%, <parametername> -> <newvalue>]".

For Delaunay triangulation orthogonal projection is better. This can be specified, for example, by "BoxRatios: Show[%, BoxRatios -> {1, 1, 1e-8}]". To see the meaningful side of the 3-d object used to visualize 2-d Delaunay, you need to change the viewpoint: "Show[%, ViewPoint -> {0, 0, -1}]". By specifying different viewpoints you can slowly rotate objects.

For halfspace intersections, Qhull produces the dual convex hull.

See Is Qhull available for Mathematica? for URLs.

»n - print hyperplane normals with offsets

The first line is the dimension plus one. The second line is the number of facets. The remaining lines are the normals for each facet, one normal per line. The facet's offset follows its normal coefficients.

The normals point outward, i.e., the convex hull satisfies Ax <= -b where A is the matrix of coefficients and b is the vector of offsets.

A point is inside or below a hyperplane if its distance to the hyperplane is negative. A point is outside or above a hyperplane if its distance to the hyperplane is positive. Otherwise a point is on or coplanar to the hyperplane.

If cdd output is specified ('FD'), Qhull prints the command line, the keyword "begin", the number of facets, the dimension (plus one), the keyword "real", and the normals for each facet. The facet's negative offset precedes its normal coefficients (i.e., if the origin is an interior point, the offset is positive). Qhull ends the output with the keyword "end".

»o - print OFF file format

The output is:

  • The first line is the dimension
  • The second line is the number of points, the number of facets, and the number of ridges.
  • All of the input points follow, one per line.
  • Then Qhull prints the vertices for each facet. Each facet is on a separate line. The first number is the number of vertices. The remainder is the indices of the corresponding points. The vertices are oriented in 2-d, 3-d, and in simplicial facets.

Option 'Ft' prints the same information with added points for non-simplicial facets.

Option 'i' displays vertices without the point coordinates. Option 'p' displays the point coordinates without vertex and facet information.

In 3-d, Geomview can load the file directly if you delete the first line (e.g., by piping through 'tail +2').

For Voronoi diagrams (qvoronoi), option 'o' prints Voronoi vertices and Voronoi regions instead of input points and facets. The first vertex is the infinity vertex [-10.101, -10.101, ...]. Then, option 'o' lists the vertices in the Voronoi region for each input site. The regions appear in site ID order. In 2-d, the vertices of a Voronoi region are sorted by adjacency (non-oriented). In 3-d and higher, the Voronoi vertices are sorted by index. See the 'FN' option for listing Voronoi regions without listing Voronoi vertices.

If you are using the Qhull library, options 'v o' have the side effect of reordering the neighbors for a vertex.

»p - print vertex and point coordinates

The first line is the dimension. The second line is the number of vertices. The remaining lines are the vertices, one vertex per line. A vertex consists of its point coordinates

With the 'Gc' and 'Gi' options, option 'p' also prints coplanar and interior points respectively.

For qvoronoi, it prints the coordinates of each Voronoi vertex.

For qdelaunay, it prints the input sites as lifted to a paraboloid. For qhalf it prints the dual points. For both, option 'p' is the same as the first section of option 'o'.

Use 'Fx' to list the point ids of the extreme points (i.e., vertices).

If a subset of the facets is selected ('Pdk', 'PDk', 'Pg' options), option 'p' only prints vertices and points associated with those facets.

If cdd-output format is selected ('FD'), the first line is "begin". The second line is the number of vertices, the dimension plus one, and "real". The vertices follow with a leading "1". Output ends with "end".

»s - print summary to stderr

The default output of Qhull is a summary to stderr. Options 'FS' and 'Fs' produce the same information for programs. Note: Windows 95 and 98 treats stderr the same as stdout. Use option 'TO file' to separate stderr and stdout.

The summary lists the number of input points, the dimension, the number of vertices in the convex hull, and the number of facets in the convex hull. It lists the number of selected ("good") facets for options 'Pg', 'Pdk', qdelaunay, or qvoronoi (Delaunay triangulations only use the lower half of a convex hull). It lists the number of coplanar points. For Delaunay triangulations without 'Qc', it lists the total number of coplanar points. It lists the number of simplicial facets in the output.

The terminology depends on the output structure.

The summary lists these statistics:

  • number of points processed by Qhull
  • number of hyperplanes created
  • number of distance tests (not counting statistics, summary, and checking)
  • number of merged facets (if any)
  • number of distance tests for merging (if any)
  • CPU seconds to compute the hull
  • the maximum joggle for 'QJ'
    or, the probability of precision errors for 'QJ TRn'
  • total area and volume (if computed, see 'FS' 'FA' 'Fa' 'PAn')
  • max. distance of a point above a facet (if non-zero)
  • max. distance of a vertex below a facet (if non-zero)

The statistics include intermediate hulls. For example 'rbox d D4 | qhull' reports merged facets even though the final hull is simplicial.

Qhull starts counting CPU seconds after it has read and projected the input points. It stops counting before producing output. In the code, CPU seconds measures the execution time of function qhull() in libqhull.c. If the number of CPU seconds is clearly wrong, check qh_SECticks in user.h.

The last two figures measure the maximum distance from a point or vertex to a facet. They are not printed if less than roundoff or if not merging. They account for roundoff error in computing the distance (c.f., option 'Rn'). Use 'Fs' to report the maximum outer and inner plane.

A number may appear in parentheses after the maximum distance (e.g., 2.1x). It is the ratio between the maximum distance and the worst-case distance due to merging two simplicial facets. It should be small for 2-d, 3-d, and 4-d, and for higher dimensions with 'Qx'. It is not printed if less than 0.05.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qh--rand.gif0000644000176200001440000000744313431000556020023 0ustar liggesusersGIF87addç=*2-E>,^0GI*c‹cNk_(*&Ø×Ö^?DN2A…>L0Be(E@Io¥Jn¥I6-LFƒ‡uBm+‘Ž:DU2 )VT!‹~_ Iƒ!F>99=;`G #(5"nW]„hl¦§¡AN aˆ]üüüøøø/D"E4fŽesjaEPF[I*1'RVv *fFŽBƒFIML4L*:#_@DK2-fmoM+²±³U9+$DN=}uuUL&??=%)F$B‚U<;?|[ÌÊÉ5?4>-E;K8‚7'F …‘ƒ4j{ov=eF5z4tzet+UGTF8l7:TMX}<ëëç9[BO:#'*UlC63(ng*7f".b-d”-2hA3„GŽ„F`XeHETH:^N+Sie?`:3ZK2M[]L…©¬©ÞÝÝ4\";'†Mk_hI;VK<:iG[.“‡†[vR<4-BFtydV>J1#'6@9E :&jc,C89T'yeUe•-t@CcV2ht:-;?¼²±3RRRsBGJ>E-GT*zqEfŽfr…)>L!RfO>yE|wJZ|ZL(Z)04@*+…†‹7..Q2FIMT`)3 8‚87€7b‘3%:ÿÿÿ(/W,M3ilDg^xc`õõõž˜™V;8@B@`JOïïï2A=ˆ›tjZˆAu‰*…G·¹·`Ye5(N‘+\hÔ,ddþ‰ H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(Sª\ɲ¥Ë—0c†|&3¥²Êéª2ˆÁ­*ÒjÎÄ©³W<}œ(Æ)C†jW„^”6&ß•+ŒÊ•»’o£mkÊu†J&§NOU¡)U¢²mÊ^»¢‹¡5>è§Z´œäkK‘ÈãÌ Â†A6FæôøKù”.•-Óeޱ>}ccbnËŒ[~)ÿŤ+.f…W¶„ý9ôhl·äŒP²D5e9[®½FxmÜšÚ´iƒ+R$ ¤ÐåxñýWŽ.wà 1'ã(íÆ Áþõ&ºùHPG›J£ìË9[¦OÐgûöÁqà Ä€ÿù7·dЍ`*Œ,ãÚk $ÁˆõݧO凙2>(ÐAcöÖÌ9ò „,Ú,‘‡~(Ï)%Žh¢SLô’„U’„ ºà§<$Èc ²x`¥"È¢Å$„ÑáäqÊ‚AˆIYˆ3˜P¨$‘ÄØä'ÏÖ¸‘@¯\©'–Z’@£çœ5$™râB½ )Ó5 $±Æ8ŽÉ3L8ëd↵쩩•7jq5çpË-§T3¨S.ì’AÁ4Äþn^4›ÀÁŽndb›öje-ÌSƧÔü’Ç9Kœ‚I5˜¤š… ÛÀ´Œ›‰lŽ TšÉ:ë€p„ß~ î¸ãŠ{DºÌR@l“G±¹œƒ…7l’ê)î4âR„š|óF>Ùn›É¶ádZ®•á"LîÃÌ¢ÎçHaÇ9.¤º‹*®ôŒ3̘@Ê$°S©¶ (aîÂ,›ÛÇŒEô…Æ.TÓjJŒcÂþ OÀÚÂqÄÊH+lîaÄìôºu་+%óóP°‰3Öœœ‰%–´¬ôØÔÒ O;͆Ô.`‡’4!Oa7ä!J×Ë’ðþÁ|ïmI7¤sԻ쒪 r¤ÔÀóW;œÁpTi‚½2›0ؾÛå" ,I’‘½¡Œ@N!nJþݨ ­‡€Æpå É3¼€:RL‚¢¸….´¾‰-œóÜÃfñ îp_ÜÅü@Ò/Œãoóœq yèBÃ\nPO‹ìêbq6‚’¸Ã ðxÃ'˜·Š[ƒ·(F6G±%âx„¼:œ%‘$W‚&ÞQ€à´À>ÂÑ2TIŽdKØË"Y€:€j_#H–A g¼ÁK(Ã. Ê'  —°\æäx¦±’¿ÈE÷q‹@Ã$•ð‚(0_¼Äæ1šÀ( ÒŠGÂÙXY†df7 <òqƒ%˜äÒüÄ1°IOzö¢ :þÈT#W&(¼ ¬”G2sñ‹_PãÆH+LâŒvø ¢Œ¨DiQŒl„a‚µhÆ%¶ xô£ õh.â±…\Ѐ$Ø+NÀÒ,´$ßhG2\QÖ´¦ø¨))M =K„A] ÀЌ¢õ¨E,ð‡K¤ ¥P}éHˆà…vlá 8½©MñáK`öPSG€J2ÀA/@ÖÊÖ¶²—ð ÚR©ŠdUBN·šÕœn³›{Ð….è€ ðÐ ¸ÑP¸õ±NhÆø)Е¥v ɼ ½öõ³ø¸g>9¥„Kö°f°ÇbÛXȶU ŠPþ0Úp \\–%A…¶°½î´´h‚E3jZÃ’!sà VËXÀµkeƒ"šq`œ¡²·-I9¨0Sßjõ·¢$%€jܨB¹Êe®s¡; E$"À°.mm UÜ’¤æàÁ¼Ë_œ>¡MÀF"ÈÐ<´€¹ËEo"âàÚYØâm¨®uQÐÕ¾#YÃìPO^fÓâäå6!£„pƒ-@ñ‰Sœâv0ø±(H„",Ž3œ¡ÆéhÃVÚR ‹d S(E‡‡üa®£ P±ŠS¼dn,²2ŽÃmŒã3Tªu( #BÑÛ"{9Ä£lÂ#’Ëd¯Xʼn¨Ãþcá¡TyÊ5ŽÃŽ[š†’ü€® 2˜?ü3 “hA™•lfM¨¹­p˜n:ÞüæÖ¤ÄoXÓ ÆÇ¦[ñŽIxú¼Mnr8´°VØBq06£W>dÁc8 *x _Ðþ(Æ;îa ^ÁÌ]·c îêJØßñ80Ò± ]°Å$>B)Ü}Ómjáǵ¼Zæ†CN0C›'üï s<àh`¶IþÁîP‚÷·37Ä!NˆGßè=‚%`KÝÛ\àéðAºSR @ôä5uE¾ò{¼£ÓªUî`{Ìan0‡{á{s œÐR ¨ŠP~·¦+h¼‹~_<„ð„Ú;í醈pÀ­Nw £¡,¹B(˜t¡ €ì+‡Â#`3ÀØp „/rƒD˜¡ sï¸äŒì\ë\gÆ~³zϱþèÂ…èG/zmðà «°…ª>y>¡-¡u(¨gl÷¨@î!®{ÝB £èƒè…ßah£ü(%lQr;ߨhp‡¬Y² ®‡Ây¾€5>þ0ïÞó~÷¾@„üàûâ ÈG¾láæb»?U´K€ $ƒ ´¨ ¾¯ûÝ÷Þs@~Äç…~üpz…aãVc|pò×Çp X@ Ÿð ˆÀcç}þq½ €Ágz˜|… ¶nÏ ¸ÐÂîpèÀÎð Ù0ý§xtè 1|<ȃ…¶ Î׸ãb€Hp®»·¹Gx0|£  Vàƒh€_`J TfnÃ{1Ñ „Jœà Rhƒá€Ãצ§…th–Pm ް Ž BP6PHP‚X+ þ°xE (zs°ƒ‰’x€Va@|èjà@Pc€ ƒ(ˆõ€ € ž§ˆƒ¢Y8‰‘ø”Ð ¶@$0 š¨j@R±¡8ˆJ¸ “À†ŠXvâ7s(‰•š` ð@ ÑÀ‹¸¨‹Rñ‰„è‹„È|‘ˆŠhªðˆ¯H ƒ` f䀋à {€Ò¨0€€ ¢Ø‹è@3pŠ+Ø@ _p@̨Ñà ÞŽ‹@ì(0}m v€Ó põpvÂXtïÀ 0ƒ  ä°IéHÑ(G@<„! •€.) ’ þJ( vÜx°à   8P$铉Òè– ’¯Á’.‘0‰.ˆ\ ïˆð1à“éh•)”›Ø ðŽð1×/‰È“’p°“@!)’nù–Y[ ” r_)Û –X“È€ è€b Ž p —Ñ€~à n@w‰yù’}‰ z` ýÐ’{ „é–‡©˜AÐ vù˜Ñ6 ™ÈÀ—¹š˜Ù hЇÃÐ A ì K¤y% /I ¬y™™²¡·ù¹i@° ô0›‹)œÎ `›Å¹%{ Ø™0 20šÓùàžâ9žäYžß;geometry/inst/doc/qhull/html/qh--4d.gif0000644000176200001440000001042413431000556017377 0ustar liggesusersGIF87addç>JJIQbKƒSNJILX\ZZZXXXVVSRQEF,GGHHMHKKJIQ]\NfOOdP[¨bV„ZPW[VVWZ¦aX¤_Y¢`W¢^QRRW˜^Y.Z.+J^_J†Q\]:<HHUVDFSdZOP:G?nZKLJKIJGH)KKMQJJJQE65GFIMHZf\©bTUTSSSTQTUMUW¡]XŸ^Y›_LKV\V›\RIRW=WV•\W5W;OO#5HS3SW+WZ%Z6IJHI4K‰QK‡QUq[;=N!NK,AMMOOJMx!7IBA+LL89EF*J\qK(D67?POLLHFE[ZZDD4ONM8ITTSW SSRRF1LRRQQPPONNSDRMLL5)OLJKJLIKJJLHK-IJN,MIRKJMGF!\K4JJT€\DE<"LL8:78DE(DwVNP\[ZNP\YZEDMOKMCCWUUO%JMKKLKJIL|JIHINHGF\©c[©bZ§a0LLNaOQ…U<>ZXRSSW¡^V¡]VGWKJW^FES9T@E[!\K7LP+Q\]!KJ9;NONoUSTNOOPDDNODIHKLJUe57FE,1DYZY[¤aY¤_TTTT|WOVO$JIOPOGTJJJILLLSjVJJJKHKLDL; LS`VK@K0ONJˆPN€TRxX;<:<BC$EDLOpAEA@QQM68DC)GF\[[IEEXWWCDI>@UUTPOOOONJdjNMMMMLMKLV“[AQIHLKKIL}JIILCK:MMK‰P\[KxZ;=KJWG$PDPPHHTgY 7GÔ,ddþ9r$ ÁFǘۖäܹ†I BtØðáÉ-F¼˜±b’b™BŠ —’'Mš<™²åÊ—.Kœy0Â’(ãÒQä¸ÑãΞ;5JìH1×H‘»X¢\ÊE©J•Ma.•9f#²HDI$@(Ï C}zÚ‘ÏÑ᜺Œ“¥Û§)aÐ4x• Ž ã®ô ö+ѽDž8› êÔ·maª-)·ªãº5´Z£O²—ùv¤s6éb¨Ÿ†1°´éÓêtȺµë×°c³¦³kW&Û™Òryµ›÷+ßMyïî=¼¸ïã¯N+7}3JWÙУÃPû6ÉàÄÇ®]¸÷ì¿—þ‹·e›ôóÒ=ܶm[WÓáÝoïŽ>rñâe9ȉ¾?l£ÕÙ¶ÀwñmgŸÇõöÊ\Aæ˜#:´…1~eXe™uÔRÁÕáZˆMÕ˜At5ø`#@0£f?YÖb…q6Òî|ÈThŠyH‰ šÈ£#”ÇâX}&–Œ"‰ é(šŽ#Zåã\7¥ã"‘iV’!µÓ“!zÈÖh ô#]hÕ•XZ¾8ä#í@ -î°u˜9ÆD~|:"‹ Wø×_.ìÙFÌœTp—àw2ºhx}ò©3« ]/íšI;s¶£hvõ-*xÉEʧ&ÌPh)lÆC‹þ…Ê9'-s4*·~ú[©¦âgÇJ¬êZ)4ÌI {™|1+-‰>Š ¨óÝ×+ŸK˜'ì9­.‹²œÎꩳŽB‹«‚3 Tn‰göhfÛXéf‘»,-;ˆ´7óÎá$žcByî¹ê– Yƒ²\ñ\›B àê¼eè"$â”±, ûÚ)f˜qýk®#3”+pÀ2„åeòÎZƒâ¬2’⤱¬ãدžsÌq¹?²#šè„p@°l g´a4"áqˆ8‡˜1k%µÞi1ˆLî9m¤v¨*[:ÅÎY7m4`tuX÷"â rH ³²Þ³ôE«àÕ½.,ll3þ3´˜qHb‹6 Ö±6ÚÙ̪ÅÛáÆ=î®t›*K¥­¥ƒS„vàc‹ri‡.Û´T"MwSÀ«­¼FÎçZŸãÁ6‰0³ÎØs¶;!ÕÈáâˆsFÛÝy1Eã«?êŽë¦êàCé0€con½àäˆäË3ÆœÄç òªs¡€´ÔŒ3ÎÛÜñÍ6Ç_®I¹Ñøç¯Hgú!K[Ó¸ARôaO Dêd¢haVêƒ_ßGÁöá,ûË þŽs0-€Á[ZJP‚!ÀÅS»ÑKnÑ-ZP‚/¤ ûä! ÚÐhoÈÄxñA¦…PþÀèC ‚. 0f0 Z¸¬ ÎPc2¤¡ÍŽqC.¡Å‡Ð%©«˜4¨€‹y51†OÜXÕTQƒõ:B·(@@¡„kq†“æ‰ ˜q^Ì‹”&§¹BæîzFs‡.Vq8à‰Ÿ@E0@5/pÇ_¨Äg…"4!}‚!GÊëqλAùÈà!b \FÜP¸›óiò>àDNŠ^‚?:Ç(«§¹QriG÷ÐÖÊH!n„ „ÿxN€ ½Ì¦/¹œZ Ò¦Ô\tÁe:’™ÌlB0â& ÌËÖĦ6ç‰ 'Jq}0þ´YlñF ¾Ôð!éøÃC ã,Q"§ºq ¤ a/K0QTH”„%°§FÓ¨ qô3ƒ·8B9ç(À’~ÐRc;xá†OÀá ½hE-jј’P£hÌg¹zñÑ Š¢œÕ¢Iè ¬bph‚U‘›Òô©NÅ(Ni¸Fså@=ÕŸ/ZP¡vUŸà%E-šUDu¦Q½iN7*?;x4«ø[T‚Öu„PUÁEcŠÖšÖ´Ü4M„QLݕҘa@èÊJtº2mhãå5Ã}ÍoGæi­vÂÊ]<«*XaxŸ÷9àèEýÂTO:3>#L`B2”!^ /âï†4Ä¡þ­û@xÞ^ðÂ-H‘]t>Á²Áí8*È­|3vã-Ø4\A=¨ca EìaýþGÒÝ÷}Þç}ß÷O°Ì$}€~ê—MíU Ë7/cà4sRÝp“à РLÀÈø7'àlý·}ñæ¶@o~´¦ŸÀLå°Zé×qøGÝÀ 8(Hp êÀ=ø@¸Ëâdm±–‚¸‚ßçsÀžÇoýÖ€7'â  °ƒÑ—…Z¸… ˜´0]p{oÇf°{z7d}¨£à Ü„ߨ>¨Œ´pä°˜p‚Ï(€K¸„*ªPYLÕ€½D Wx ÞhŽäØêà £ðƒåøÉ 0+&7 A0‚°¦‚ñ˜„ðȪPÚTVøˆ H0 ÿx©zÝø‘@‹sò D€ úg€pI€IþoÁP)z‰ 9Ž9éy ÿh#©zXD@ Ëb>° 1É‚ðHoÒˆ 5© 3Øq;é‘åH’X•A‰Ýà ž`Fs°”ò¸”ô•”e‘ꇌj}Ð0 k}ÑÐ0/˜Ð и{pQ<—ˆ§8vo©–yЊoé?°,A &p—™— àS{iŠ…÷c©–£à“k‰7°,€˜Š™yO¹cÀÈW}ùW“©–Èà É –b0/FÀ™©wðð É‹>6vZù“:¹•¬è9 F0/”ðR –1©„H‘gÙK4I“ÊÙœôt›Ð¹•L`ŒV}/G ÂþIœMiœ, É •PÉœâ)ž5™MÐÙ@É›ê©Yù“O ’³‚ Ú9Üù’Lù}幜ýÙœQY‘éI’ÕiY0ýˆ è`ËòõyŸÜ¹„e  äi‘þY‘ª0 W©“íiŽÙ/ð•†ù MÉ”ø‘ßG‘úŸæ¹œªPš0:–9 N0—ËR¡ 𚃘 ÁÀ—‘é—1Zš’˜ z@ …¹,ž£;Ê£f(y5¤1ê U À€ƒZ ¦` MꤻgBd¡YT£/Ð¡ `:ˆyI¦}v¦0j¿¹,ô™£nú¦fø£¤×g J þѧ ØÙ  nZ¢cɨ0Ùû•Îy¡Ú¡š›¸ÉžL   Ÿ³‰ú‹ ~Jª ‘𠺢¨ëy©šêÀ 7ª£ê'zª1©¢ʪ•J¨*ƒ*"ª¤¡ ê¨&Zœ?Ú«-:ž/J§o9 ž`£ËB lЬ|ú‰PZ›¤)­k—I:+6À¦¡ ­Û:ˆ&ðÞ:¥àª–`Й‰§æ銋Ю$ô®jè`Fʦöz¯Ÿè§Rº¯üZ‰Êà w:¢K°ŸØ 1¤媘 HЇZ«¡j¯Êš«Ëú±& ¾­ {‡åЩf´¤ ±Ÿ˜¯e;geometry/inst/doc/qhull/html/qh--geom.gif0000644000176200001440000000047613431000556020025 0ustar liggesusersGIF87a((òóóóLLL¿¿¿æææ,((þºÜþ0ÊIÙ¸8ëÍûŠ'Ž\Bª®lë²§‰’4‡_ ì@}Ÿ9@,òD¿gWl:{dPpZŸ¶N°©^^ãFÊÍ„Ÿ¼aŠ!›¿a5¶­–gpœ˜'°n}~Ciƒlƒ|Ui~WˆuJŠOŽ_~‰–•LVq˜‘Aš„Lrœ—€ e¢¥…œPn“kŽqŒŒŸ2¡¢‹g†;·[h›„k¿v‚k½hµÆ¨¸e^¤Òj¦§™£¦|tн®¥ÞÇJxpÝFÉÌÊåæSïzÔÍ|î–âÒc©–ô+•œ@]¾ ë  ’€#ÄÑØWÃÄŠ¥TØø Æ(^ˆI2E;geometry/inst/doc/qhull/html/qh-faq.html0000644000176200001440000015664714664417655020030 0ustar liggesusers Qhull FAQ

Up: Home page for Qhull (local)
Up: Qhull Wiki and FAQ (local)
Up: Qhull manual: contents
To: Imprecision in Qhull
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: FAQ: contents


[4-d cube] Frequently Asked Questions about Qhull

If your question does not appear here, see:

Qhull is a general dimension code for computing convex hulls, Delaunay triangulations, halfspace intersections about a point, Voronoi diagrams, furthest-site Delaunay triangulations, and furthest-site Voronoi diagrams. These structures have applications in science, engineering, statistics, and mathematics. For a detailed introduction, see O'Rourke ['94], Computational Geometry in C.

There are separate programs for each application of Qhull. These programs disable experimental and inappropriate options. If you prefer, you may use Qhull directly. All programs run the same code.

Version 2019.1 adds an experimental option for vertex merging of nearly adjacent vertices ('Q14'). It may resolve topological issues such as "dupridges" with more than two facet neighbors.

Version 2015.1 introduced the reentrant library. It should be used for all code that calls Qhull. The 'qhull' program is built with the reentrant library.

Version 3.1 added triangulated output ('Qt'). It may be used for Delaunay triangulations instead of using joggled input ('QJ').

Brad Barber, Arlington MA, 2019/02/11

Copyright © 1998-2020 C.B. Barber


»FAQ: contents

Within each category, the most recently asked questions are first.

  • Startup questions
    • How do I run Qhull from Windows?
    • How do I enter points for Qhull?
    • How do I learn to use Qhull?
  • Convex hull questions
    • How do I report just the area and volume of a convex hull?
    • Why are there extra points in a 4-d or higher convex hull?
    • How do I report duplicate vertices?
  • Delaunay triangulation questions
    • How do I get rid of nearly flat Delaunay triangles?
    • How do I find the Delaunay triangle or Voronoi region that is closest to a point?
    • How do I compute the Delaunay triangulation of a non-convex object?
    • How do I mesh a volume from a set of triangulated surface points?
    • Can Qhull produce a triangular mesh for an object?
    • For 3-d Delaunay triangulations, how do I report the triangles of each tetrahedron?
    • How do I construct a 3-d Delaunay triangulation?
    • How do I get the triangles for a 2-d Delaunay triangulation and the vertices of its Voronoi diagram?
    • Can Qhull triangulate a hundred 16-d points?
  • Voronoi diagram questions
    • See also "Delaunay diagram questions". Qhull computes the Voronoi diagram from the Delaunay triagulation.
    • How do I compute the volume of a Voronoi region?
    • How do I get the radii of the empty spheres for each Voronoi vertex?
    • What is the Voronoi diagram of a square?
    • How do I construct the Voronoi diagram of cospherical points?
    • Can Qhull compute the unbounded rays of the Voronoi diagram?
  • Approximation questions
    • How do I approximate data with a simplex?
  • Halfspace questions
    • How do I compute the intersection of halfspaces with Qhull?
  • Qhull library questions
    • Is Qhull available for Mathematica, Matlab, or Maple?
    • Why are there too few ridges?
    • Can Qhull use coordinates without placing them in a data file?
    • How large are Qhull's data structures?
    • Can Qhull construct convex hulls and Delaunay triangulations one point at a time?
    • How do I visit the ridges of a Delaunay triangulation?
    • How do I visit the Delaunay facets?
    • When is a point outside or inside a facet?
    • How do I find the facet that is closest to a point?
    • How do I find the Delaunay triangle or Voronoi region that is closest to a point?
    • How do I list the vertices?
    • How do I test code that uses the Qhull library?
    • When I compute a plane equation from a facet, I sometimes get an outward-pointing normal and sometimes an inward-pointing normal

»Startup questions

»How do I run Qhull from Windows?

Qhull is a console program. You will first need a command window (i.e., a "command prompt"). You can double click on 'eg\Qhull-go.bat'.

  • Type 'qconvex', 'qdelaunay', 'qhalf', 'qvoronoi, 'qhull', and 'rbox' for a synopsis of each program.
  • Type 'rbox c D2 | qconvex s i' to compute the convex hull of a square.
  • Type 'rbox c D2 | qconvex s i TO results.txt' to write the results to the file 'results.txt'. A summary is still printed on the the console.
  • Type 'rbox c D2' to see the input format for qconvex.
  • Type 'qconvex < data.txt s i TO results.txt' to read input data from 'data.txt'.
  • If you want to enter data by hand, type 'qconvex s i TO results.txt' to read input data from the console. Type in the numbers and end with a ctrl-D.

If you regularly use Qhull on a Windows host, install a bash shell such as

  • Git for Windows (wiki, based on MSYS2) -- Git for Windows v2.21 requires arguments for 'qhull', otherwise it waits for stdin. Use 'qhull --help' for a usage note instead of 'qhull'.
  • MSYS2 (wiki)
  • Cygwin

If you use Windows XP or Windows 8, you may use

»How do I enter points for Qhull?

Qhull takes its data from standard input (stdin). For example, create a file named 'data.txt' with the following contents:

2  #sample 2-d input
5  #number of points
1 2  #coordinates of points
-1.1 3
3 2.2
4 5
-10 -10

Then call qconvex with 'qconvex < data.txt'. It will print a summary of the convex hull. Use 'qconvex < data.txt o' to print the vertices and edges. See also input format.

You can generate sample data with rbox. For example, 'rbox 10' generates 10 random points in 3-d. Use a pipe ('|') to run rbox and qhull together, e.g.,

rbox c | qconvex o

computes the convex hull of a cube.

»How do I learn to use Qhull?

First read:

Look at Qhull's on-line documentation:

  • 'rbox' lists all of the options for generating point sets
  • 'qconvex --help' gives a synopsis of qconvex and its options
  • 'qconvex -' lists all of the options for qconvex
  • 'qconvex .' gives a concise list of options
  • 'qdelaunay', 'qhalf', 'qvoronoi', and 'qhull' also have a synopsis and options

Then try out the Qhull programs on small examples.

  • 'rbox c' -- lists the vertices of a cube
  • 'rbox c D2 | qconvex' -- is the convex hull of a square
  • 'rbox c D2 | qconvex o' -- lists the vertices and facets of a square
  • 'rbox c | qconvex' -- is the convex hull of a cube
  • 'rbox c | qconvex o' -- lists the vertices and facets of a cube
  • 'rbox c | qconvex Qt o' -- triangulates the cube
  • 'rbox c | qconvex QJ o' -- joggles the input and triangulates the cube
  • 'rbox c D4 | qconvex' -- is the convex hull of a hypercube

  • 'rbox 6 s D2 t | qconvex p Fx' -- is the convex hull of 6 random, cocircular points. Option 'p' lists the points while option 'Fx' lists the vertices in order.

  • 'rbox d D2 c G2 | qdelaunay' -- is the Delaunay triangulation of a diamond and a square. The diamond's vertices are cocircular.
  • 'rbox d D2 c G2 | qdelaunay o' -- lists the input sites projected to a paraboloid and the Delaunay regions. The region with 4 vertices is the diamond.
  • 'rbox d D2 c G2 | qdelaunay o Qt' -- the cocircular diamond is triangulated as two Delaunay regions.
  • 'rbox d D2 c G2 | qdelaunay o QJ' -- the input is joggled and the diamond is triangulated.

  • 'rbox d D2 c G2 | qvoronoi o' -- is the Voronoi regions for a diamond and a square. The Voronoi vertex for the diamond is the origin (0,0). Unbounded regions are represented by the first vertex (-10.101 -10.101)
  • 'rbox d D2 c G2 | qvoronoi Fv' -- shows the Voronoi diagram for the previous example. Each line is one edge of the diagram. The first number is 4, the next two numbers list a pair of input sites, and the last two numbers list the corresponding pair of Voronoi vertices.
  • 'rbox d D2 c G2 | qvoronoi o Qt' -- the cocircular Delaunay region is triangulated. Instead of one Voronoi vertex for the diamond, there are two Voronoi vertices (0,0) and (0,0).

Install Geomview if you are running SGI Irix, Solaris, SunOS, Linux, HP, IBM RS/6000, DEC Alpha, or Next. You can then visualize the output of Qhull. Qhull comes with Geomview examples.

Then try Qhull with a small example of your application. Work out the results by hand. Then experiment with Qhull's options to find the ones that you need.

You will need to decide how Qhull should handle precision problems. It can triangulate the output ('Qt'), joggle the input ('QJ'), or merge facets (the default).

  • With triangulated output, Qhull merges facets and triangulates the result.
  • With joggle, Qhull produces simplicial (i.e., triangular) output by joggling the input. After joggle, no points are cocircular or cospherical.
  • With facet merging, Qhull produces a better approximation than joggle, nor does it modify the input.
  • See Merged facets or joggled input.

»Convex hull questions

»How do I report just the area and volume of a convex hull?

Use option 'FS' or 'FA'. The area is the area of the surface of the convex hull, while the volume is the total volume of the convex hull.

For example,

rbox 10 | qconvex FS
0
2 2.192915621644613 0.2027867899638665

rbox 10 | qconvex FA

Convex hull of 10 points in 3-d:

  Number of vertices: 10
  Number of facets: 16

Statistics for: RBOX 10 | QCONVEX FA

  Number of points processed: 10
  Number of hyperplanes created: 28
  Number of distance tests for qhull: 44
  CPU seconds to compute hull (after input):  0
  Total facet area:   2.1929156
  Total volume:       0.20278679

In 2-d, the convex hull is a polygon. Its surface is the edges of a polygon. So in 2-d, the 'area' is the length of the polygon's edges, while the 'volume' is the area of the polygon.

For example the convex hull of a square,

rbox c D2 | qconvex FS
0
2      4      1

rbox c D2 | qconvex FA

Convex hull of 4 points in 2-d:

  Number of vertices: 4
  Number of facets: 4

Statistics for: rbox c D2 | qconvex FA

  Number of points processed: 4
  Number of hyperplanes created: 6
  Number of distance tests for qhull: 5
  CPU seconds to compute hull (after input):  0
  Total facet area:    4
  Total volume:        1

»Why are there extra points in a 4-d or higher convex hull?

Options 'i' (in 4-D and higher) and 'Ft' (in 3-D and higher) use "extra" points for non-simplicial facets (e.g., a face of a cube or hypercube). These points are not part of the convex hull. Options 'i' and 'Ft' triangulate non-simplicial facets using the facet's centrum.

For example, Qhull reports the following for one facet of the convex hull of a hypercube. The facets of a 4-D hypercube are 3-d cubes. Option 'Pd0:0.5' returns the facet along the positive-x axis. Point 17 represents the centrum of this facet. The facet's vertices are eight points: point 8 to point 15

rbox c D4 | qconvex i Pd0:0.5
12
17 13 14 15
17 13 12 14
17 11 13 15
17 14 11 15
17 10 11 14
17 14 12 8
17 12 13 8
17 10 14 8
17 11 10 8
17 13 9 8
17 9 11 8
17 11 9 13

rbox c D4 | qconvex Fx Pd0:0.5
8
8
9
10
11
12
13
14
15

The 4-d hypercube has 16 vertices; so point "17" was added by qconvex. Qhull adds the point in order to report a simplicial decomposition of the facet. The point corresponds to the "centrum" which Qhull computes to test for convexity.

Triangulate the output ('Qt') to avoid the extra points. Since the hypercube is 4-d, each simplicial facet is a tetrahedron.

C:\qhull3.1>rbox c D4 | qconvex i Pd0:0.5 Qt
9
9 13 14 15
12 9 13 14
9 11 13 15
11 9 14 15
9 10 11 14
12 9 14 8
9 12 13 8
9 10 14 8
10 9 11 8

Use the 'Fv' option to print the vertices of simplicial and non-simplicial facets. For example, here is the same hypercube facet with option 'Fv' instead of 'i':

C:\qhull>rbox c D4 | qconvex Pd0:0.5 Fv
1
8 9 10 12 11 13 14 15 8

The coordinates of the extra point are printed with the 'Ft' option. For centrums, option 'Ft' uses indices one less than option 'i'. In this case, point 16 represents the centrum of the facet.

rbox c D4 | qconvex Pd0:0.5 Ft
4
17 12 3
  -0.5   -0.5   -0.5   -0.5
  -0.5   -0.5   -0.5    0.5
  -0.5   -0.5    0.5   -0.5
  -0.5   -0.5    0.5    0.5
  -0.5    0.5   -0.5   -0.5
  -0.5    0.5   -0.5    0.5
  -0.5    0.5    0.5   -0.5
  -0.5    0.5    0.5    0.5
   0.5   -0.5   -0.5   -0.5
   0.5   -0.5   -0.5    0.5
   0.5   -0.5    0.5   -0.5
   0.5   -0.5    0.5    0.5
   0.5    0.5   -0.5   -0.5
   0.5    0.5   -0.5    0.5
   0.5    0.5    0.5   -0.5
   0.5    0.5    0.5    0.5
   0.5      0      0      0
4 16 13 14 15
4 16 13 12 14
4 16 11 13 15
4 16 14 11 15
4 16 10 11 14
4 16 14 12 8
4 16 12 13 8
4 16 10 14 8
4 16 11 10 8
4 16 13 9 8
4 16 9 11 8
4 16 11 9 13

»How do I report duplicate vertices?

There's no direct way. You can use option 'FP' to report the distance to the nearest vertex for coplanar input points. Select the minimum distance for a duplicated vertex, and locate all input sites less than this distance.

For Delaunay triangulations, all coplanar points are nearly incident to a vertex. If you want a report of coincident input sites, do not use option 'QJ'. By adding a small random quantity to each input coordinate, it prevents coincident input sites.

»Delaunay triangulation questions

»How do I get rid of nearly flat Delaunay triangles?

Nearly flat triangles occur when boundary points are nearly collinear or coplanar. They also occur for nearly coincident points. Both events can easily occur when using joggle. For example (rbox 10 W0 D2 | qdelaunay QJ Fa) lists the areas of the Delaunay triangles of 10 points on the boundary of a square. Some of these triangles are nearly flat. This occurs when one point is joggled inside of two other points. In this case, nearly flat triangles do not occur with triangulated output (rbox 10 W0 D2 | qdelaunay Qt Fa).

Another example, (rbox c P0 P0 D2 | qdelaunay QJ Fa), computes the areas of the Delaunay triangles for the unit square and two instances of the origin. Four of the triangles have an area of 0.25 while two have an area of 2.0e-11. The later are due to the duplicated origin. With triangulated output (rbox c P0 P0 D2 | qdelaunay Qt Fa) there are four triangles of equal area.

Nearly flat triangles also occur without using joggle. For example, (rbox c P0 P0,0.4999999999 | qdelaunay Fa), computes the areas of the Delaunay triangles for the unit square, a nearly collinear point, and the origin. One triangle has an area of 3.3e-11.

Unfortunately, none of Qhull's merging options remove nearly flat Delaunay triangles due to nearly collinear or coplanar boundary points. The merging options concern the empty circumsphere property of Delaunay triangles. This is independent of the area of the Delaunay triangles. Qhull does handle nearly coincident points.

If you are calling Qhull from a program, you can merge slivers into an adjacent facet. In d dimensions with simplicial facets (e.g., from 'Qt'), each facet has d+1 neighbors. Each neighbor shares d vertices of the facet's d+1 vertices. Let the other vertex be the opposite vertex. For each neighboring facet, if its circumsphere includes the opposite.vertex, the two facets can be merged. [M. Treacy]

You can handle collinear or coplanar boundary points by enclosing the points in a box. For example, (rbox c P0 P0,0.4999999999 c G1 | qdelaunay Fa), surrounds the previous points with [(1,1), (1,-1), (-1,-1), (-1, 1)]. Its Delaunay triangulation does not include a nearly flat triangle. The box also simplifies the graphical output from Qhull.

Without joggle, Qhull lists coincident points as "coplanar" points. For example, (rbox c P0 P0 D2 | qdelaunay Fa), ignores the duplicated origin and lists four triangles of size 0.25. Use 'Fc' to list the coincident points (e.g., rbox c P0 P0 D2 | qdelaunay Fc).

There is no easy way to determine coincident points with joggle. Joggle removes all coincident, cocircular, and cospherical points before running Qhull. Instead use facet merging (the default) or triangulated output ('Qt').

»How do I compute the Delaunay triangulation of a non-convex object?

A similar question is "How do I mesh a volume from a set of triangulated surface points?"

This is an instance of the constrained Delaunay Triangulation problem. Qhull does not handle constraints. The boundary of the Delaunay triangulation is always convex. But if the input set contains enough points, the triangulation will include the boundary. The number of points needed depends on the input.

Shewchuk has developed a theory of constrained Delaunay triangulations. See his paper at the 1998 Computational Geometry Conference. Using these ideas, constraints could be added to Qhull. They would have many applications.

There is a large literature on mesh generation and many commercial offerings. For pointers see Owen's International Meshing Roundtable and Schneiders' Finite Element Mesh Generation page.

»Can Qhull produce a triangular mesh for an object?

Yes for convex objects, no for non-convex objects. For non-convex objects, it triangulates the concavities. Unless the object has many points on its surface, triangles may cross the surface.

»For 3-d Delaunay triangulations, how do I report the triangles of each tetrahedron?

For points in general position, a 3-d Delaunay triangulation generates tetrahedron. Each face of a tetrahedron is a triangle. For example, the 3-d Delaunay triangulation of random points on the surface of a cube, is a cellular structure of tetrahedron.

Use triangulated output ('qdelaunay Qt i') or joggled input ('qdelaunay QJ i') to generate the Delaunay triangulation. Option 'i' reports each tetrahedron. The triangles are every combination of 3 vertices. Each triangle is a "ridge" of the Delaunay triangulation.

For example,

        rbox 10 | qdelaunay Qt i
        14
        9 5 8 7
        0 9 8 7
        5 3 8 7
        3 0 8 7
        5 4 8 1
        4 6 8 1
        2 9 5 8
        4 2 5 8
        4 2 9 5
        6 2 4 8
        9 2 0 8
        2 6 0 8
        2 4 9 1
        2 6 4 1

is the Delaunay triangulation of 10 random points. Ridge 9-5-8 occurs twice. Once for tetrahedron 9 5 8 7 and the other for tetrahedron 2 9 5 8.

You can also use the Qhull library to generate the triangles. See 'How do I visit the ridges of a Delaunay triangulation?'

»How do I construct a 3-d Delaunay triangulation?

For 3-d Delaunay triangulations with cospherical input sites, use triangulated output ('Qt') or joggled input ('QJ'). Otherwise option 'i' will triangulate non-simplicial facets with the facet's centrum.

If you want non-simplicial output for cospherical sites, use option 'Fv' or 'o'. For option 'o', ignore the last coordinate. It is the lifted coordinate for the corresponding convex hull in 4-d.

The following example is a cube inside a tetrahedron. The 8-vertex facet is the cube. Ignore the last coordinates.

C:\qhull>rbox r y c G0.1 | qdelaunay Fv
4
12 20 44
   0.5      0      0 0.3055555555555555
   0    0.5      0 0.3055555555555555
   0      0    0.5 0.3055555555555555
  -0.5   -0.5   -0.5 0.9999999999999999
  -0.1   -0.1   -0.1 -6.938893903907228e-018
  -0.1   -0.1    0.1 -6.938893903907228e-018
  -0.1    0.1   -0.1 -6.938893903907228e-018
  -0.1    0.1    0.1 -6.938893903907228e-018
   0.1   -0.1   -0.1 -6.938893903907228e-018
   0.1   -0.1    0.1 -6.938893903907228e-018
   0.1    0.1   -0.1 -6.938893903907228e-018
   0.1    0.1    0.1 -6.938893903907228e-018
4 2 11 1 0
4 10 1 0 3
4 11 10 1 0
4 2 9 0 3
4 9 11 2 0
4 7 2 1 3
4 11 7 2 1
4 8 10 0 3
4 9 8 0 3
5 8 9 10 11 0
4 10 6 1 3
4 6 7 1 3
5 6 8 10 4 3
5 6 7 10 11 1
4 5 9 2 3
4 7 5 2 3
5 5 8 9 4 3
5 5 6 7 4 3
8 5 6 8 7 9 10 11 4
5 5 7 9 11 2

If you want simplicial output use options 'Qt i' or 'QJ i', e.g.,

rbox r y c G0.1 | qdelaunay Qt i
31
2 11 1 0
11 10 1 0
9 11 2 0
11 7 2 1
8 10 0 3
9 8 0 3
10 6 1 3
6 7 1 3
5 9 2 3
7 5 2 3
9 8 10 11
8 10 11 0
9 8 11 0
6 8 10 4
8 6 10 3
6 8 4 3
6 7 10 11
10 6 11 1
6 7 11 1
8 5 4 3
5 8 9 3
5 6 4 3
6 5 7 3
5 9 10 11
8 5 9 10
7 5 10 11
5 6 7 10
8 5 10 4
5 6 10 4
5 9 11 2
7 5 11 2

»How do I get the triangles for a 2-d Delaunay triangulation and the vertices of its Voronoi diagram?

To compute the Delaunay triangles indexed by the indices of the input sites, use

rbox 10 D2 | qdelaunay Qt i

To compute the Voronoi vertices and the Voronoi region for each input site, use

rbox 10 D2 | qvoronoi o

To compute each edge ("ridge") of the Voronoi diagram for each pair of adjacent input sites, use

rbox 10 D2 | qvoronoi Fv

To compute the area and volume of the Voronoi region for input site 5 (site 0 is the first one), use

rbox 10 D2 | qvoronoi QV5 p | qconvex s FS

To compute the lines ("hyperplanes") that define the Voronoi region for input site 5, use

rbox 10 D2 | qvoronoi QV5 p | qconvex n

or

rbox 10 D2 | qvoronoi QV5 Fi Fo

To list the extreme points of the input sites use

rbox 10 D2 | qdelaunay Fx

You will get the same point ids with

rbox 10 D2 | qconvex Fx

»Can Qhull triangulate a hundred 16-d points?

No. This is an immense structure. A triangulation of 19, 16-d points has 43 simplices. If you add one point at a time, the triangulation increased as follows: 43, 189, 523, 1289, 2830, 6071, 11410, 20487. The last triangulation for 26 points used 13 megabytes of memory. When Qhull uses virtual memory, it becomes too slow to use.

»Voronoi diagram questions

»How do I compute the volume of a Voronoi region?

For each Voronoi region, compute the convex hull of the region's Voronoi vertices. The volume of each convex hull is the volume of the corresponding Vornoi region.

For example, to compute the volume of the bounded Voronoi region about [0,0,0]: output the origin's Voronoi vertices and compute the volume of their convex hull. The last number from option 'FS' is the volume.

rbox P0 10 | qvoronoi QV0 p | qhull FS
0
2 1.448134756744281 0.1067973560800857

For another example, see How do I get the triangles for a 2-d Delaunay triangulation and the vertices of its Voronoi diagram?

This approach is slow if you are using the command line. A faster approcach is to call Qhull from a program. The fastest method is Clarkson's hull program. It computes the volume for all Voronoi regions.

An unbounded Voronoi region does not have a volume.

»How do I get the radii of the empty spheres for each Voronoi vertex?

Use option 'Fi' to list each bisector (i.e. Delaunay ridge). Then compute the minimum distance for each Voronoi vertex.

There's other ways to get the same information. Let me know if you find a better method.

»What is the Voronoi diagram of a square?

Consider a square,

C:\qhull>rbox c D2
2 RBOX c D2
4
  -0.5   -0.5
  -0.5    0.5
   0.5   -0.5
   0.5    0.5

There's two ways to compute the Voronoi diagram: with facet merging or with joggle. With facet merging, the result is:

C:\qhull>rbox c D2 | qvoronoi Qz

Voronoi diagram by the convex hull of 5 points in 3-d:

  Number of Voronoi regions and at-infinity: 5
  Number of Voronoi vertices: 1
  Number of facets in hull: 5

Statistics for: RBOX c D2 | QVORONOI Qz

  Number of points processed: 5
  Number of hyperplanes created: 7
  Number of distance tests for qhull: 8
  Number of merged facets: 1
  Number of distance tests for merging: 29
  CPU seconds to compute hull (after input):  0

C:\qhull>rbox c D2 | qvoronoi Qz o
2
2 5 1
-10.101 -10.101
     0      0
2 0 1
2 0 1
2 0 1
2 0 1
0

C:\qhull>rbox c D2 | qvoronoi Qz Fv
4
4 0 1 0 1
4 0 2 0 1
4 1 3 0 1
4 2 3 0 1

There is one Voronoi vertex at the origin and rays from the origin along each of the coordinate axes. The last line '4 2 3 0 1' means that there is a ray that bisects input points #2 and #3 from infinity (vertex 0) to the origin (vertex 1). Option 'Qz' adds an artificial point since the input is cocircular. Coordinates -10.101 indicate the vertex at infinity.

With triangulated output, the Voronoi vertex is duplicated:

C:\qhull3.1>rbox c D2 | qvoronoi Qt Qz

Voronoi diagram by the convex hull of 5 points in 3-d:

  Number of Voronoi regions and at-infinity: 5
  Number of Voronoi vertices: 2
  Number of triangulated facets: 1

Statistics for: RBOX c D2 | QVORONOI Qt Qz

  Number of points processed: 5
  Number of hyperplanes created: 7
  Number of facets in hull: 6
  Number of distance tests for qhull: 8
  Number of distance tests for merging: 33
  Number of distance tests for checking: 30
  Number of merged facets: 1
  CPU seconds to compute hull (after input): 0.05

C:\qhull3.1>rbox c D2 | qvoronoi Qt Qz o
2
3 5 1
-10.101 -10.101
     0      0
     0      0
3 2 0 1
2 1 0
2 2 0
3 2 0 1
0

C:\qhull3.1>rbox c D2 | qvoronoi Qt Qz Fv
4
4 0 2 0 2
4 0 1 0 1
4 1 3 0 1
4 2 3 0 2

With joggle, the input is no longer cocircular and the Voronoi vertex is split into two:

C:\qhull>rbox c D2 | qvoronoi Qt Qz

C:\qhull>rbox c D2 | qvoronoi QJ o
2
3 4 1
-10.101 -10.101
-4.71511718558304e-012 -1.775812830118184e-011
9.020340030474472e-012 -4.02267108512433e-012
2 0 1
3 2 1 0
3 2 0 1
2 2 0

C:\qhull>rbox c D2 | qvoronoi QJ Fv
5
4 0 2 0 1
4 0 1 0 1
4 1 2 1 2
4 1 3 0 2
4 2 3 0 2

Note that the Voronoi diagram includes the same rays as before plus a short edge between the two vertices.

»How do I construct the Voronoi diagram of cospherical points?

Three-dimensional terrain data can be approximated with cospherical points. The Delaunay triangulation of cospherical points is the same as their convex hull. If the points lie on the unit sphere, the facet normals are the Voronoi vertices [via S. Fortune].

For example, consider the points {[1,0,0], [-1,0,0], [0,1,0], ...}. Their convex hull is:

rbox d G1 | qconvex o
3
6 8 12
     0      0     -1
     0      0      1
     0     -1      0
     0      1      0
    -1      0      0
     1      0      0
3 3 1 4
3 1 3 5
3 0 3 4
3 3 0 5
3 2 1 5
3 1 2 4
3 2 0 4
3 0 2 5

The facet normals are:

rbox d G1 | qconvex n
4
8
-0.5773502691896258  0.5773502691896258  0.5773502691896258 -0.5773502691896258
 0.5773502691896258  0.5773502691896258  0.5773502691896258 -0.5773502691896258
-0.5773502691896258  0.5773502691896258 -0.5773502691896258 -0.5773502691896258
 0.5773502691896258  0.5773502691896258 -0.5773502691896258 -0.5773502691896258
 0.5773502691896258 -0.5773502691896258  0.5773502691896258 -0.5773502691896258
-0.5773502691896258 -0.5773502691896258  0.5773502691896258 -0.5773502691896258
-0.5773502691896258 -0.5773502691896258 -0.5773502691896258 -0.5773502691896258
 0.5773502691896258 -0.5773502691896258 -0.5773502691896258 -0.5773502691896258

If you drop the offset from each line (the last number), each line is the Voronoi vertex for the corresponding facet. The neighboring facets for each point define the Voronoi region for each point. For example:

rbox d G1 | qconvex FN
6
4 7 3 2 6
4 5 0 1 4
4 7 4 5 6
4 3 1 0 2
4 6 2 0 5
4 7 3 1 4

The Voronoi vertices {7, 3, 2, 6} define the Voronoi region for point 0. Point 0 is [0,0,-1]. Its Voronoi vertices are

-0.5773502691896258  0.5773502691896258 -0.5773502691896258
 0.5773502691896258  0.5773502691896258 -0.5773502691896258
-0.5773502691896258 -0.5773502691896258 -0.5773502691896258
 0.5773502691896258 -0.5773502691896258 -0.5773502691896258

In this case, the Voronoi vertices are oriented, but in general they are unordered.

By taking the dual of the Delaunay triangulation, you can construct the Voronoi diagram. For cospherical points, the convex hull vertices for each facet, define the input sites for each Voronoi vertex. In 3-d, the input sites are oriented. For example:

rbox d G1 | qconvex i
8
3 1 4
1 3 5
0 3 4
3 0 5
2 1 5
1 2 4
2 0 4
0 2 5

The convex hull vertices for facet 0 are {3, 1, 4}. So Voronoi vertex 0 (i.e., [-0.577, 0.577, 0.577]) is the Voronoi vertex for input sites {3, 1, 4} (i.e., {[0,1,0], [0,0,1], [-1,0,0]}).

»Can Qhull compute the unbounded rays of the Voronoi diagram?

Use 'Fo' to compute the separating hyperplanes for unbounded Voronoi regions. The corresponding ray goes to infinity from the Voronoi vertices. The midpoint between input sites replaces the Voronoi vertex at infinity. Alternatively, if you enclose the input sites in a large enough box, the outermost bounded regions will represent the unbounded regions of the original points.

If you do not box the input sites, you can identify the unbounded regions. They list '0' as a vertex. Vertex 0 represents "infinity". Each unbounded ray includes vertex 0 in option 'Fv. See Voronoi graphics and Voronoi notes.

»Approximation questions

»How do I approximate data with a simplex

Qhull may be used to help select a simplex that approximates a data set. It will take experimentation. Geomview will help to visualize the results. This task may be difficult to do in 5-d and higher. Use rbox options 'x' and 'y' to produce random distributions within a simplex. Your methods work if you can recover the simplex.

Use Qhull's precision options to get a first approximation to the hull, say with 10 to 50 facets. For example, try 'C0.05' to remove small facets after constructing the hull. Use 'W0.05' to ignore points within 0.05 of a facet. Use 'PA5' to print the five largest facets by area.

Then use other methods to fit a simplex to this data. Remove outlying vertices with few nearby points. Look for large facets in different quadrants. You can use option 'Pd0d1d2' to print all the facets in a quadrant.

In 4-d and higher, use the outer planes (option 'Fo' or 'facet->maxoutside') since the hyperplane of an approximate facet may be below many of the input points.

For example, consider fitting a cube to 1000 uniformly random points in the unit cube. In this case, the first try was good:

rbox 1000 | qconvex W0.05 C0.05 PA6 Fo
4
6
0.35715408374381 0.08706467018177928 -0.9299788727015564 -0.5985514741284483
0.995841591359023 -0.02512604712761577 0.08756829720435189 -0.5258834069202866
0.02448099521570909 -0.02685210459017302 0.9993396046151313 -0.5158104982631999
-0.9990223929415094 -0.01261133513150079 0.04236994958247349 -0.509218270408407
-0.0128069014364698 -0.9998380680115362 0.01264203427283151 -0.5002512653670584
0.01120895057872914 0.01803671994177704 -0.9997744926535512 -0.5056824072956361

»Halfspace questions

»How do I compute the intersection of halfspaces with Qhull?

Qhull computes the halfspace intersection about a point. The point must be inside all of the halfspaces. Given a point, a duality turns a halfspace intersection problem into a convex hull problem.

Use linear programming if you do not know a point in the interior of the halfspaces. See the notes for qhalf. You will need a linear programming code. This may require a fair amount of work to implement.

»Qhull library questions

»Is Qhull available for Mathematica, Matlab, or Maple?

MATLAB

Z. You of MathWorks added qhull to MATLAB 6. See functions convhulln, delaunayn, griddatan, tsearchn, and voronoin. V. Brumberg update MATLAB R14 for Qhull 2003.1 and triangulated output.

Engwirda wrote mesh2d for unstructured mesh generation in MATLAB. It is based on the iterative method of Persson and generally results in better quality meshes than delaunay refinement.

Mathematica and Maple

See qh-math for a Delaunay interface to Mathematica. It includes projects for CodeWarrior on the Macintosh and Visual C++ on Win32 PCs.

See Mathematica ('m') and Maple ('FM') output options.

»Why are there too few ridges?

The following sample code may produce fewer ridges than expected:
  facetT *facetp;
  ridgeT *ridge, **ridgep;

  FORALLfacets {
    printf("facet f%d\n", facet->id);
    FOREACHridge_(facet->ridges) {
      printf("   ridge r%d between f%d and f%d\n", ridge->id, ridge->top->id, ridge->bottom->id);
    }
  }

Qhull does not create ridges for simplicial facets. Instead it computes ridges from facet->neighbors. To make ridges for a simplicial facet, use qh_makeridges() in merge.c. Use facet->visit_id to visit each ridge once (instead of twice). For example,

  facetT *facet, *neighbor;
  ridgeT *ridge, **ridgep;

  qh visit_id++;
  FORALLfacets {
    printf("facet f%d\n", facet->id);
    qh_makeridges(facet);
    facet->visitId= qh visit_id;
    FOREACHridge_(facet->ridges) {
        neighbor= otherfacet_(ridge, visible);
        if (neighbor->visitid != qh visit_id)
            printf("   ridge r%d between f%d and f%d\n", ridge->id, ridge->top->id, ridge->bottom->id);
    }
  }

»Can Qhull use coordinates without placing them in a data file?

You may call Qhull from a program. Please use the reentrant Qhull library (libqhullstatic_r.a, libqhull_r.so, or qhull_r.dll). See user_eg.c and "Qhull-template" in user_r.c for examples.. See Qhull code for an introduction to Qhull's reentrant library and its C++ interface.

Hint: Start with a small example for which you know the answer.

»How large are Qhull's data structures?

Qhull uses a general-dimension data structure. The size depends on the dimension. Use option 'Ts' to print out the memory statistics [e.g., 'rbox D2 10 | qconvex Ts'].

Qhull's data structures use many pointers. For 64-bit code, pointers are twice the size of integers. For 64-bit code, Qhull uses 50% more memory. It there is not enough memory in the computer's level 1 and level 2 caches, Qhull will run slower as it retrieves data from main memory. A future version of Qhull will include memory and performance improvements for 64-bit code.

»Can Qhull construct convex hulls and Delaunay triangulations one point at a time?

The Qhull library may be used to construct convex hulls and Delaunay triangulations one point at a time. It may not be used for deleting points or moving points.

Qhull is designed for batch processing. Neither Clarkson's randomized incremental algorithm nor Qhull are designed for on-line operation. For many applications, it is better to reconstruct the convex hull or Delaunay triangulation from scratch for each new point.

With random point sets and on-line processing, Clarkson's algorithm should run faster than Qhull. Clarkson uses the intermediate facets to reject new, interior points, while Qhull, when used on-line, visits every facet to reject such points. If used on-line for n points, Clarkson may take O(n) times as much memory as the average off-line case, while Qhull's space requirement does not change.

If you triangulate the output before adding all the points (option 'Qt' and procedure qh_triangulate), you must set option 'Q11'. It duplicates the normals of triangulated facets and recomputes the centrums. This should be avoided for regular use since triangulated facets are not clearly convex with their neighbors. It appears to work most of the time, but fails for cases that Qhull normally handles well [see the test call to qh_triangulate in qh_addpoint].

»How do I visit the ridges of a Delaunay triangulation?

To visit the ridges of a Delaunay triangulation, visit each facet. Each ridge will appear twice since it belongs to two facets. In pseudo-code:

    for each facet of the triangulation
        if the facet is Delaunay (i.e., part of the lower convex hull)
            for each ridge of the facet
                if the ridge's neighboring facet has not been visited
                    ... process a ridge of the Delaunay triangulation ...

In undebugged, C code:

    qh visit_id++;
    FORALLfacets_(facetlist)
        if (!facet->upperdelaunay) {
            facet->visitid= qh visit_id;
            qh_makeridges(facet);
            FOREACHridge_(facet->ridges) {
                neighbor= otherfacet_(ridge, facet);
                if (neighbor->visitid != qh visit_id) {
                    /* Print ridge here with facet-id and neighbor-id */
                    /*fprintf(fp, "f%d\tf%d\t",facet->id,neighbor->ID);*/
                    FOREACHvertex_(ridge->vertices)
                        fprintf(fp,"%d ",qh_pointid (vertex->point) );
                    qh_printfacetNvertex_simplicial (fp, facet, format);
                    fprintf(fp," ");
                    if(neighbor->upperdelaunay)
                        fprintf(fp," -1 -1 -1 -1 ");
                    else
                        qh_printfacetNvertex_simplicial (fp, neighbor, format);
                    fprintf(fp,"\n");
                }
            }
        }
    }

»How do I visit the Delaunay regions?

Qhull constructs a Delaunay triangulation by lifting the input sites to a paraboloid. The Delaunay triangulation corresponds to the lower convex hull of the lifted points. To visit each facet of the lower convex hull, use:

    facetT *facet;

    ...
    FORALLfacets {
        if (!facet->upperdelaunay) {
            ... only facets for Delaunay regions ...
        }
    }

»When is a point outside or inside a facet?

A point is outside of a facet if it is clearly outside the facet's outer plane. The outer plane is defined by an offset (facet->maxoutside) from the facet's hyperplane.

    facetT *facet;
    pointT *point;
    realT dist;

    ...
    qh_distplane(point, facet, &dist);
    if (dist > facet->maxoutside + 2 * qh DISTround) {
        /* point is clearly outside of facet */
    }

A point is inside of a facet if it is clearly inside the facet's inner plane. The inner plane is computed as the maximum distance of a vertex to the facet. It may be computed for an individual facet, or you may use the maximum over all facets. For example:

    facetT *facet;
    pointT *point;
    realT dist;

    ...
    qh_distplane(point, facet, &dist);
    if (dist < qh min_vertex - 2 * qh DISTround) {
        /* point is clearly inside of facet */
    }

Both tests include two qh.DISTrounds because the computation of the furthest point from a facet may be off by qh.DISTround and the computation of the current distance to the facet may be off by qh.DISTround.

»How do I find the facet that is closest to a point?

See Locate facet with qh_findbestfacet. For Delaunay triangulations, qh_findbestfacet returns the Delaunay triangle or adjacent triangle that contains the point.

Use qh_findbestfacet(). For example,

    coordT point[ DIM ];
    boolT isoutside;
    realT bestdist;
    facetT *facet;

    ... set coordinates for point ...

    facet= qh_findbestfacet (point, qh_ALL, &bestdist, &isoutside);

    /* 'facet' or an adjacent facet is the closest facet to 'point' */

qh_findbestfacet() performs a directed search for the facet furthest below the point. If the point lies inside this facet, qh_findbestfacet() performs an exhaustive search of all facets. An exhaustive search may be needed because a facet on the far side of a lens-shaped distribution may be closer to a point than all of the facet's neighbors. The exhaustive search may be skipped for spherical distributions.

Also see, 'How do I find the Delaunay triangle that is closest to a point?'

»How do I find the Delaunay triangle or Voronoi region that is closest to a point?

A Delaunay triangulation subdivides the plane, or in general dimension, subdivides space. Given a point, how do you determine the subdivision containing the point? Or, given a set of points, how do you determine the subdivision containing each point of the set? Efficiency is important -- an exhaustive search of the subdivision is too slow.

First compute the Delaunay triangle with qh_new_qhull() in user_r.c or Qhull::runQhull(). Lift the point to the paraboloid by summing the squares of the coordinates. Use qh_findbestfacet [poly2_r.c] to find the closest Delaunay facet or adjacent facet. Determine the closest vertex to find the corresponding Voronoi region. Do not use options 'Qbb', 'QbB', 'Qbk:n', or 'QBk:n' since these scale the last coordinate. Optimizations of qh_findbestfacet() should be possible for Delaunay triangulations.

You first need to lift the point to the paraboloid (i.e., the last coordinate is the sum of the squares of the point's coordinates). The routine, qh_setdelaunay() [geom2.c], lifts an array of points to the paraboloid. The following excerpt is from findclosest() in user_eg.c.

    coordT point[ DIM + 1];  /* one extra coordinate for lifting the point */
    boolT isoutside;
    realT bestdist;
    facetT *facet;

    ... set coordinates for point[] ...

    qh_setdelaunay (DIM+1, 1, point);
    facet= qh_findbestfacet (point, qh_ALL, &bestdist, &isoutside);
    /* 'facet' or an adjacent facet is the closest Delaunay triangle to 'point' */

The returned facet either contains the point, or an adjacent facet contains the point, or it is the closest Delaunay triangle along the convex hull of the input set.

Point location is an active research area in Computational Geometry. For a practical approach, see Mucke, et al, "Fast randomized point location without preprocessing in two- and three-dimensional Delaunay triangulations," Computational Geometry '96, p. 274-283, May 1996. For an introduction to planar point location see [O'Rourke '93]. Also see, 'How do I find the facet that is closest to a point?'

To locate the closest Voronoi region, determine the closest vertex of the closest Delaunay triangle.

    realT dist, bestdist= REALmax;
        vertexT *bestvertex= NULL, *vertex, **vertexp;

    /* 'facet' is the closest Delaunay triangle to 'point' */

    FOREACHvertex_( facet->vertices ) {
        dist= qh_pointdist( point, vertex->point, DIM );
        if (dist < bestdist) {
            bestdist= dist;
            bestvertex= vertex;
        }
    }
    /* 'bestvertex' represents the Voronoi region closest to 'point'.  The corresponding
       input site is 'bestvertex->point' */

»How do I list the vertices?

To list the vertices (i.e., extreme points) of the convex hull use

    vertexT *vertex;

    FORALLvertices {
      ...
      // vertex->point is the coordinates of the vertex
      // qh_pointid(vertex->point) is the point ID of the vertex
      ...
    }
    

»How do I test code that uses the Qhull library?

Compare the output from your program with the output from the Qhull program. Use option 'T1' or 'T4' to trace what Qhull is doing. Prepare a small example for which you know the output. Run the example through the Qhull program and your code. Compare the trace outputs. If you do everything right, the two trace outputs should be almost the same. The trace output will also guide you to the functions that you need to review.

»When I compute a plane equation from a facet, I sometimes get an outward-pointing normal and sometimes an inward-pointing normal

Qhull orients simplicial facets, and prints oriented output for 'i', 'Ft', and other options. The orientation depends on both the vertex order and the flag facet->toporient.

Qhull does not orient non-simplicial facets. Instead it orients the facet's ridges. These are printed with the 'Qt' and 'Ft' option. The facet's hyperplane is oriented.


Up:Home page for Qhull (local)
Up: Qhull Wiki and FAQ (local)
Up: Qhull manual: contents
To: Imprecision in Qhull
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: FAQ: contents


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/rbox.txt0000644000176200001440000001214213431000556017430 0ustar liggesusers rbox(1) rbox(1) NAME rbox - generate point distributions for qhull SYNOPSIS Command "rbox" (w/o arguments) lists the options. DESCRIPTION rbox generates random or regular points according to the options given, and outputs the points to stdout. The points are generated in a cube, unless 's' or given. The format of the output is the following: first line contains the dimension and a comment, second line contains the num- ber of points, and the following lines contain the points, one point per line. Points are represented by their coor- dinate values. EXAMPLES rbox 10 10 random points in the unit cube centered at the origin. rbox 10 s D2 10 random points on a 2-d circle. rbox 100 W0 100 random points on the surface of a cube. rbox 1000 s D4 1000 random points on a 4-d sphere. rbox c D5 O0.5 a 5-d hypercube with one corner at the origin. rbox d D10 a 10-d diamond. rbox x 1000 r W0 100 random points on the surface of a fixed simplex rbox y D12 a 12-d simplex. rbox l 10 10 random points along a spiral rbox l 10 r 10 regular points along a spiral plus two end points rbox 1000 L10000 D4 s 1000 random points on the surface of a narrow lens. rbox c G2 d G3 a cube with coordinates +2/-2 and a diamond with Geometry Center August 10, 1998 1 rbox(1) rbox(1) coordinates +3/-3. rbox 64 M3,4 z a rotated, {0,1,2,3} x {0,1,2,3} x {0,1,2,3} lat- tice (Mesh) of integer points. rbox P0 P0 P0 P0 P0 5 copies of the origin in 3-d. Try 'rbox P0 P0 P0 P0 P0 | qhull QJ'. r 100 s Z1 G0.1 two cospherical 100-gons plus another cospherical point. 100 s Z1 a cone of points. 100 s Z1e-7 a narrow cone of points with many precision errors. OPTIONS n number of points Dn dimension n-d (default 3-d) Bn bounding box coordinates (default 0.5) l spiral distribution, available only in 3-d Ln lens distribution of radius n. May be used with 's', 'r', 'G', and 'W'. Mn,m,r lattice (Mesh) rotated by {[n,-m,0], [m,n,0], [0,0,r], ...}. Use 'Mm,n' for a rigid rotation with r = sqrt(n^2+m^2). 'M1,0' is an orthogonal lattice. For example, '27 M1,0' is {0,1,2} x {0,1,2} x {0,1,2}. s cospherical points randomly generated in a cube and projected to the unit sphere x simplicial distribution. It is fixed for option 'r'. May be used with 'W'. y simplicial distribution plus a simplex. Both 'x' and 'y' generate the same points. Wn restrict points to distance n of the surface of a sphere or a cube c add a unit cube to the output c Gm add a cube with all combinations of +m and -m to the output Geometry Center August 10, 1998 2 rbox(1) rbox(1) d add a unit diamond to the output. d Gm add a diamond made of 0, +m and -m to the output Cn,r,m add n nearly coincident points within radius r of m points Pn,m,r add point [n,m,r] to the output first. Pad coordi- nates with 0.0. n Remove the command line from the first line of out- put. On offset the data by adding n to each coordinate. t use time in seconds as the random number seed (default is command line). tn set the random number seed to n. z generate integer coordinates. Use 'Bn' to change the range. The default is 'B1e6' for six-digit coordinates. In R^4, seven-digit coordinates will overflow hyperplane normalization. Zn s restrict points to a disk about the z+ axis and the sphere (default Z1.0). Includes the opposite pole. 'Z1e-6' generates degenerate points under single precision. Zn Gm s same as Zn with an empty center (default G0.5). r s D2 generate a regular polygon r s Z1 G0.1 generate a regular cone BUGS Some combinations of arguments generate odd results. Report bugs to qhull_bug@qhull.org, other correspon- dence to qhull@qhull.org SEE ALSO qhull(1) AUTHOR C. Bradford Barber bradb@shore.net Geometry Center August 10, 1998 3 geometry/inst/doc/qhull/html/qhull-cpp.xml0000644000176200001440000002726213431000557020356 0ustar liggesusers

Qhull C++ -- C++ interface to Qhull

Copyright (c) 2009-2018, C.B. Barber

This draft document records some of the design decisions for Qhull C++. Convert it to HTML by road-faq.xsl from road-faq. Please send comments and suggestions to bradb@shore.net

Help
.
Qhull's collection APIs are modeled on Qt's collection API (QList, QVector, QHash) w/o QT_STRICT_ITERATORS. They support STL and Qt programming.

Some of Qhull's collection classes derive from STL classes. If so, please avoid additional STL functions and operators added by inheritance. These collection classes may be rewritten to derive from Qt classes instead. See Road's .

Qhull's collection API (where applicable). For documentation, see Qt's QList, QMap, QListIterator, QMapIterator, QMutableListIterator, and QMutableMapIterator
  • STL types [list, qlinkedlist, qlist, qvector, vector] -- const_iterator, iterator
  • STL types describing iterators [list, qlinkedlist, qlist, qvector, vector] -- const_pointer, const_reference, difference_type, pointer, reference, size_type, value_type. Pointer and reference types not defined if unavailable (not needed for <algorithm>)
  • const_iterator, iterator types -- difference_type, iterator_category, pointer, reference, value_type
  • Qt types [qlinkedlist, qlist, qvector] -- ConstIterator, Iterator, QhullclassIterator, MutableQhullclassIterator. Qt's foreach requires const_iterator.
  • Types for sets/maps [hash_map, QHash] -- key_compare, key_type, mapped_type
  • Constructor -- default constructor, copy constructor, assignment operator, destructor
  • Conversion -- to/from/as corresponding C, STL, and Qt constructs. Include toQList and toStdVector (may be filtered, e.g., QhullFacetSet). Do not define fromStdList and fromQList if container is not reference counted (i.e., acts like a value)
  • Get/set -- configuration options for class
  • STL-style iterator - begin, constBegin, constEnd, end, key, value, =, *, [], ->, ++, --, +, -, ==, !=, <, <=, >, >=, const_iterator(iterator), iterator COMPARE const_iterator. An iterator is an abstraction of a pointer. It is not aware of its container.
  • Java-style iterator [qiterator.h] - countRemaining, findNext, findPrevious, hasNext, hasPrevious, next, peekNext, peekPrevious, previous, toBack, toFront, = Coordinates
  • Mutable Java-style iterator adds - insert, remove, setValue, value
  • Element access -- back, first, front, last
  • Element access w/ index -- [], at (const& only), constData, data, mid, value
  • Read-only - (int)count, empty, isEmpty, (size_t)size. Count() and size() may be filtered. If so, they may be zero when !empty().
  • Read-only for sets/maps - capacity, key, keys, reserve, resize, values
  • Operator - ==, !=, +, +=, <<
  • Read-write -- append, clear, erase, insert, move, prepend, pop_back, pop_front, push_back, push_front, removeAll, removeAt, removeFirst, removeLast, replace, swap, takeAt, takeFirst, takeLast
  • Read-write for sets/maps -- insertMulti, squeeze, take, unite
  • Search -- contains(const T &), count(const T &), indexOf, lastIndexOf
  • Search for sets/maps -- constFind, lowerBound, upperBound
  • Stream I/O -- stream <<
STL list and vector -- For unfiltered access to each element.
  • Apache: Creating your own containers -- requirements for STL containers. Iterators should define the types from 'iterator_traits'.
  • STL types -- allocator_type, const_iterator, const_pointer, const_reference, const_reverse_iterator, difference_type, iterator, iterator_category, pointer, reference, reverse_iterator, size_type, value_type
  • STL constructors -- MyType(), MyType(count), MyType(count, value), MyType(first, last), MyType(MyType&),
  • STL getter/setters -- at (random_access only), back, begin, capacity, end, front, rbegin, rend, size, max_size
  • STL predicates -- empty
  • STL iterator types -- const_pointer, const_reference, difference_type, iterator_category, pointer, reference, value_type
  • STL iterator operators -- *, -<, ++, --, +=, -=, +, -, [], ==, !=, <, >, >=, <=
  • STL operators -- =, [] (random_access only), ==, !=, <, >, <=, >=
  • STL modifiers -- assign, clear, erase, insert, pop_back, push_back, reserve, resize, swap
Qt Qlist -- For unfiltered access to each element
  • Additional Qt types -- ConstIterator, Iterator, QListIterator, QMutableListIterator
  • Additional Qt get/set -- constBegin, constEnd, count, first, last, value (random_access only)
  • Additional Qt predicates -- isEmpty
  • Additional Qt -- mid (random_access only)
  • Additional Qt search -- contains, count(T&), indexOf (random_access only), lastIndeOf (random_access only)
  • Additional Qt modifiers -- append, insert(index,value) (random_access only), move (random_access only), pop_front, prepend, push_front, removeAll, removeAt (random_access only), removeFirst, removeLast, replace, swap by index, takeAt, takeFirst, takeLast
  • Additional Qt operators -- +, <<, +=, stream << and >>
  • Unsupported types by Qt -- allocator_type, const_reverse_iterator, reverse_iterator
  • Unsupported accessors by Qt -- max_size, rbegin, rend
  • Unsupported constructors by Qt -- multi-value constructors
  • unsupported modifiers by Qt -- assign, muli-value inserts, STL's swaps
STL map and Qt QMap. These use nearly the same API as list and vector classes. They add the following.
  • STL types -- key_compare, key_type, mapped_type
  • STL search -- equal_range, find, lower_bound, upper_bound
  • Qt removes -- equal_range, key_compare
  • Qt renames -- lowerBound, upperBound
  • Qt adds -- constFind, insertMulti, key, keys, take, uniqueKeys, unite, values
  • Not applicable to map and QMap -- at, back, pop_back, pop_front, push_back, push_front, swap
  • Not applicable to QMap -- append, first, last, lastIndexOf, mid, move, prepend, removeAll, removeAt, removeFirst, removeLast, replace, squeeze, takeAt, takeFirst, takeLast
  • Not applicable to map -- assign
Qt QHash. STL extensions provide similar classes, e.g., Microsoft's stdext::hash_set. THey are nearly the same as QMap
  • Not applicable to Qhash -- lowerBound, unite, upperBound,
  • Qt adds -- squeeze
  • check... -- Throw error on failure
  • try... -- Return false on failure. Do not throw errors.
  • ...Temporarily -- lifetime depends on source. e.g., toByteArrayTemporarily
  • ...p -- indicates pointer-to.
  • end... -- points to one beyond the last available
  • private functions -- No syntactic indication. They may become public later on.
  • Error messages -- Preceed error messages with the name of the class throwing the error (e.g. "ClassName: ..."). If this is an internal error, use "ClassName inconsistent: ..."
  • parameter order -- qhRunId, dimension, coordinates, count.
  • toClass -- Convert into a Class object (makes a deep copy)
  • qRunId -- Requires Qh installed. Some routines allow 0 for limited info (e.g., operator<<)
  • Disable methods in derived classes -- If the default constructor, copy constructor, or copy assignment is disabled, it should be also disabled in derived classes (better error messages).
  • Constructor order -- default constructor, other constructors, copy constructor, copy assignment, destructor
geometry/inst/doc/qhull/html/qh-code.html0000644000176200001440000023100414664417655020150 0ustar liggesusers Qhull code

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Imprecision in Qhull
To: Qhull code: contents


[4-d cube] Qhull code

This section discusses the code for Qhull.

Copyright © 1995-2020 C.B. Barber


»Qhull code: contents


»Reentrant Qhull

Qhull-2015 introduces reentrant Qhull (libqhull_r). Reentrant Qhull uses a qhT* argument instead of global data structures. The qhT* pointer is the first argument to most Qhull routines. It allows multiple instances of Qhull to run at the same time. It simplifies the C++ interface to Qhull.

New code should be written with libqhull_r. Existing users of libqhull should consider converting to libqhull_r. Although libqhull will be supported indefinitely, improvements may not be implemented. Reentrant qhull is 1-2% slower than non-reentrant qhull.

Note: Reentrant Qhull is not thread safe. Do not invoke Qhull routines with the same qhT* pointer from multiple threads.

»How to convert code to reentrant Qhull

C++ users need to convert to libqhull_r. The new C++ interface does a better, but not perfect, job of hiding Qhull's C data structures. The previous C++ interface was unusual due to Qhull's global data structures.

All other users should consider converting to libqhull_r. The conversion is straight forward. Most of the changes may be made with global search and replace. The resulting files may be checked via eg/make-qhull_qh.sh. It performs the inverse mapping for comparison with non-reentrant code.

For example, even though the original conversion of libqhull to libqhull_r required thousands of changes, the first run of reentrant Qhull (unix_r.c) produced the same output, and nearly the same log files, as the original, non-reentrant Qhull (unix.c). The original conversion was made without the help of eg/make-qhull_qh.sh. Conversion errors almost always produce compiler errors.

Suggestions to help with conversion.

  • Qhull 2019.1 introduced eg/make-qhull_qh.sh. It simplifies the task of checking the consistency of reentrant and non-reentrant C code for Qhull.
  • Compare qconvex_r.c with qconvex.c. Define a qhT object and a pointer it. The qhT* pointer is the first argument to most Qhull functions. Clear qh_qh-<NOerrext before calling qh_initflags(). Invoke QHULL_LIB_CHECK to check for a compatible Qhull library.
  • Compare user_eg2_r.c with user_eg2.c
  • Compare user_eg_r.c with user_eg.c. If you use qhT before invoking qh_init_A, call qh_zero() to clear the qhT object. user_eg_r.c includes multiple Qhull runs.
  • Review user_eg3_r.cpp. As with the other programs, invoke QHULL_LIB_CHECK. Simple C++ programs should compile as is.
  • Compare QhullFacet.cpp with the same file in Qhull-2012.1. UsingLibQhull was replaced with the macro QH_TRY_() and 'qh_qh-<NOerrext= true'.
  • For detailed notes on libqhull_r, see "libqhull_r (reentrant Qhull)" and "Source code changes for libqhull_r" in Changes.txt.
  • For detailed notes on libqhullcpp, see "C++ interface" and following sections in Changes.txt.
  • For regexps and conversion notes, see README_r.txt (unedited).

Suggestions for updating src/libqhull/* from src/libqhull_r/*:

  • Make edits to libqhull_r/* instead of libqhull/*. The reverse update is more difficult, as desribed above.
  • Use 'eg/make-qhull_qh.sh libqhull_r' to automatically convert libqhull_r/* to qhull_qh/*
  • Compare src/qhull_qh/ to src/libqhull/ using Beyond Compare (www.scootersoftware.com) or another directory comparison utility.
  • Configure Beyond Compare for expected differences:
    • Rules > Importance > Unimportant text
      '$Id: ', '$DateTime: ', 'char qh_version'
    • When updating 'Unimportant text', select 'Use for all files in parent session' and, optionally, 'Updated session defaults'
    • Select 'Minor' to ignore unimportant text
    • Review Rules > Importance > Mark grammar elements. Be sure to include 'Comment'
  • Almost all unmodified lines should be identical.
  • Use 'Diffs' view to review diffs, and 'All' view to copy diffs. Otherwise wrong lines may be changed
  • Copy modified lines as needed.
  • Be careful of removing true differences, such as those involiving
    • DEFqhT
    • oldqhA, oldqhB
    • qh_QHpointer
    • qh_last_random
    • qh_rand_r
    • qhmem
    • qhstat, qhstatT
    • rbox_inuse
    • rboxT
    • "renentrant" vs. "non-reentrant"

»Qhull on 64-bit computers

Qhull compiles for 64-bit hosts. Since the size of a pointer on a 64-bit host is double the size on a 32-bit host, memory consumption increases about 50% for simplicial facets and up-to 100% for non-simplicial facets. If the convex hull does not fit in the computer's level 1 and level 2 cache memory, Qhull will run slower as it retrieves data from main memory.

If your data fits in 32-bits, run Qhull as 32-bit code. It will use less memory and run faster.

You can check memory consumption with option Ts. It includes the size of each data structure:

  • 32-bit -- merge 24 ridge 20 vertex 28 facet 88 normal 24 ridge vertices 16 facet vertices or neighbors 20
  • 64-bit -- merge 32 ridge 32 vertex 48 facet 120 normal 32 ridge vertices 40 facet vertices or neighbors 48

For Qhull 2015, the maximum identifier for ridges, vertices, and facets was increased from 24-bits to 32-bits. This allows for larger convex hulls, but may increase the size of the corresponding data structures. The sizes for Qhull 2012.1 were

  • 32-bit -- merge 24 ridge 16 vertex 24 facet 88
  • 64-bit -- merge 32 ridge 32 vertex 40 facet 120

»Calling Qhull from C++ programs

Qhull 2015 uses reentrant Qhull for its C++ interface. If you used the C++ interface from qhull 2012.1, you may need to adjust how you initialize and use the Qhull classes. See How to convert code to reentrant Qhull.

Qhull's C++ interface allows you to explore the results of running Qhull. It provides access to Qhull's data structures. Most of the classes derive from the corresponding qhull data structure. For example, QhullFacet is an instance of Qhull's facetT.

You can retain most of the data in Qhull and use the C++ interface to explore its results. Each object contains a reference to Qhull's data structure (via QhullQh), making the C++ representation less memory efficient.

Besides using the C++ interface, you can also use libqhull_r directly. For example, the FOREACHfacet_(...) macro will visit each facet in turn.

The C++ interface to Qhull is incomplete. You may need to extend the interface. If so, you will need to understand Qhull's data structures and read the code.

The C++ interface is not documented. You will need to read the code and review user_eg3 and Qhull's test program qhulltest. Please consider documenting the C++ interface with Doxygen or another javadoc-style processor.

user_eg3 demonstrates the C++ interface. For example, user_eg3 eg-100 prints the facets generated by Qhull.

    RboxPoints rbox;
    rbox.appendPoints("100");
    Qhull qhull;
    qhull.runQhull(rbox, "");
    cout << qhull.facetList();

The C++ iterface for RboxPoints redefines the fprintf() calls in rboxlib.c. Instead of writing its output to stdout, RboxPoints appends the output to a std::vector.

  • Run Qhull with option 'Ta' to annotate the output with qh_fprintf() identifiers.
  • Redefine qh_fprintf() for these identifiers.
  • See RboxPoints.cpp for an example.

The same technique may be used for calling Qhull from C++. The class QhullUser provides a starting point. See user_eg3 eg-fifo for a demonstration of Voronoi diagrams.

Since the C++ interface uses reentrant Qhull, multiple threads may run Qhull at the same time. Each thread is one run of Qhull.

Do not have two threads accessing the same Qhull instance. Qhull is not thread-safe.

»CoordinateIterator

A CoordinateIterator or ConstCoordinateIterator [RboxPoints.cpp] is a std::vector<realT>::iterator for Rbox and Qhull coordinates. It is the result type of RboxPoints.coordinates().

Qhull does not use CoordinateIterator for its data structures. A point in Qhull is an array of reals instead of a std::vector. See QhullPoint.

»Qhull

Qhull is the top-level class for running Qhull. It initializes Qhull, runs the computation, and records errors. It provides access to the global data structure QhullQh, Qhull's facets, and vertices.

»QhullError

QhullError is derived from std::exception. It reports errors from Qhull and captures the output to stderr.

If error handling is not set up, Qhull exits with a code from 1 to 5. The codes are defined by qh_ERR* in libqhull_r.h. The exit is via qh_exit() in usermem_r.c. The C++ interface does not report the captured output in QhullError. Call Qhull::setErrorStream to send output to cerr instead.

»QhullFacet

A QhullFacet is a facet of the convex hull, a region of the Delaunay triangulation, a vertex of a Voronoi diagram, or an intersection of the halfspace intersection about a point. A QhullFacet has a set of QhullVertex, a set of QhullRidge, and a set of neighboring QhullFacets.

»QhullFacetList

A QhullFacetList is a linked list of QhullFacet. The result of Qhull.runQhull is a QhullFacetList stored in QhullQh.

»QhullFacetSet

A QhullFacetSet is a QhullSet of QhullFacet. QhullFacetSet may be ordered or unordered. The neighboring facets of a QhullFacet is a QhullFacetSet. The neighbors of a QhullFacet is a QhullFacetSet. The neighbors are ordered for simplicial facets, matching the opposite vertex of the facet.

»QhullIterator

QhullIterator contains macros for defining Java-style iterator templates from a STL-style iterator template.

»QhullLinkedList

A QhullLinkedLIst is a template for linked lists with next and previous pointers. QhullFacetList and QhullVertexList are QhullLinkedLists.

»QhullPoint

A QhullPoint is an array of point coordinates, typically doubles. The length of the array is QhullQh.hull_dim. The identifier of a QhullPoint is its 0-based index from QhullQh.first_point followed by QhullQh.other_points.

»QhullPointSet

A QhullPointSet is a QhullSet of QhullPoint. The QhullPointSet of a QhullFacet is its coplanar points.

»QhullQh

QhullQh is the root of Qhull's data structure. It contains initialized constants, sets, buffers, and variables. It contains an array and a set of QhullPoint, a list of QhullFacet, and a list of QhullVertex. The points are the input to Qhull. The facets and vertices are the result of running Qhull.

Qhull's functions access QhullQh through the global variable, qh_qh. The global data structures, qh_stat and qh_mem, record statistics and manage memory respectively.

»QhullRidge

A QhullRidge represents the edge between two QhullFacet's. It is always simplicial with qh.hull_dim-1 QhullVertex)'s.

»QhullRidgeSet

A QhullRidgeSet is a QhullSet of QhullRidge. Each QhullFacet contains a QhullRidgeSet.

»QhullSet

A QhullSet is a set of pointers to objects. QhullSets may be ordered or unordered. They are the core data structure for Qhull.

»QhullVertex

A QhullVertex is a vertex of the convex hull. A simplicial QhullFacet has qh.hull_dim-1 vertices. A QhullVertex contains a QhullPoint. It may list its neighboring QhullFacet's.

»QhullVertexList

A QhullVertexList is a QhullLinkedList of QhullVertex. The global data structure, QhullQh contains a QhullVertexList of all the vertices.

»QhullVertexSet

A QhullVertexSet is a QhullSet of QhullVertex. The QhullVertexSet of a QhullFacet is the vertices of the facet. It is ordered for simplicial facets and unordered for non-simplicial facets.

»RboxPoints

RboxPoints is a std::vector of point coordinates (QhullPoint). Its iterator is CoordinateIterator.

RboxPoints.appendPoints() appends points from a variety of distributions such as uniformly distributed within a cube and random points on a sphere. It can also append a cube's vertices or specific points.

»Cpp questions for Qhull

Developing C++ code requires many conventions, idioms, and technical details. The following questions have either mystified the author or do not have a clear answer. See also C++ and Perl Guidelines and 'QH110nn FIX' notes in the code. Please add notes to Qhull Wiki.
  • QH11028 FIX: Should return reference, but get reference to temporary
    iterator Coordinates::operator++() { return iterator(++i); }
  • size() as size_t, size_type, or int
  • Should all containers have a reserve()?
  • Qhull.feasiblePoint interface
  • How to avoid copy constructor while logging, maybeThrowQhullMessage()
  • How to configure Qhull output. Trace and results should go to stdout/stderr
  • Qhull and RboxPoints messaging. e.g., ~Qhull, hasQhullMessage(). Rename them as QhullErrorMessage?
  • How to add additional output to an error message, e.g., qh_setprint
  • Is idx the best name for an index? It's rather cryptic, but BSD strings.h defines index().
  • Qhull::feasiblePoint Qhull::useOutputStream as field or getter?
  • Define virtual functions for user customization of Qhull (e.g., qh_fprintf, qh_memfree,etc.)
  • Figure out RoadError::global_log. clearQhullMessage currently clearGlobalLog
  • Should the false QhullFacet be NULL or empty? e.g., QhullFacet::tricoplanarOwner() and QhullFacetSet::end()
  • Should output format for floats be predefined (qh_REAL_1, 2.2g, 10.7g) or as currently set for stream
  • Should cout << !point.defined() be blank or 'undefined'
  • Infinite point as !defined()
  • qlist and qlinkedlist define pointer, reference, size_type, difference_type, const_pointer, const_reference for the class but not for iterator and const_iterator vector.h --
    reference operator[](difference_type _Off) const
  • When forwarding an implementation is base() an approriate name (e.g., Coordinates::iterator::base() as std::vector::iterator).
  • When forwarding an implementation, does not work "returning address of temporary"
  • Also --, +=, and -=
    iterator       &operator++() { return iterator(i++); }
  • if vector inheritance is bad, is QhullVertexSet OK?
  • Should QhullPointSet define pointer and reference data types?

»Calling Qhull from C programs

Warning: Qhull was not designed for calling from C programs. You may find the C++ interface easier to use. You will need to understand the data structures and read the code. Most users will find it easier to call Qhull as an external command.

For examples of calling Qhull, see GNU Octave's computational geometry code, and Qhull's user_eg_r.c, user_eg2_r.c, and user_r.c. To see how Qhull calls its library, read unix_r.c, qconvex.c, qdelaun.c, qhalf.c, and qvoronoi.c. The '*_r.c' files are reentrant, otherwise they are non-reentrant. Either version may be used. New code should use reentrant Qhull.

See Functions (local) for internal documentation of Qhull. The documentation provides an overview and index. To use the library you will need to read and understand the code. For most users, it is better to write data to a file, call the qhull program, and read the results from the output file.

If you use non-reentrant Qhull, be aware of the macros "qh" and "qhstat", e.g., "qh hull_dim". They are defined in libqhull.h. They allow the global data structures to be pre-allocated (faster access) or dynamically allocated (allows multiple copies).

Qhull's Makefile produces a library, libqhull_r.a, for inclusion in your programs. First review libqhull_r.h. This defines the data structures used by Qhull and provides prototypes for the top-level functions. Most users will only need libqhull_r.h in their programs. For example, the Qhull program is defined with libqhull_r.h and unix_r.c. To access all functions, use qhull_ra.h. Include the file with "#include <libqhull_r/qhull_ra.h>". This avoids potential name conflicts.

Qhull provides build/qhull.pc.in for pkg-config support and CMakeLists.txt for CMake. Using back-ticks, you can compile your C program with Qhull. For example:

  	gcc `pkg-config --cflags --libs qhull_r` -o my_app my_app.c

If you use the Qhull library, you are on your own as far as bugs go. Start with small examples for which you know the output. If you get a bug, try to duplicate it with the Qhull program. The 'Tc' option will catch many problems as they occur. When an error occurs, use 'T4 TPn' to trace from the last point added to the hull. Compare your trace with the trace output from the Qhull program.

Errors in the Qhull library are more likely than errors in the Qhull program. These are usually due to feature interactions that do not occur in the Qhull program. Please report all errors that you find in the Qhull library. Please include suggestions for improvement.

»How to avoid exit(), fprintf(), stderr, and stdout

Qhull sends output to qh.fout and errors, log messages, and summaries to qh.ferr. qh.fout is normally stdout and qh.ferr is stderr. qh.fout may be redefined by option 'TO' or the caller. qh.ferr may be redirected to qh.fout by option 'Tz'.

Qhull does not use stderr, stdout, fprintf(), or exit() directly.

Qhull reports errors via qh_errexit() by writting a message to qh.ferr and invoking longjmp(). This returns the caller to the corresponding setjmp() (c.f., QH_TRY_ in QhullQh.h). If qh_errexit() is not available, Qhull functions call qh_exit(). qh_exit() normally calls exit(), but may be redefined by the user. An example is libqhullcpp/usermem_r-cpp.cpp. It redefines qh_exit() as a 'throw'.

If qh_meminit() or qh_new_qhull() is called with ferr==NULL, then they set ferr to stderr. Otherwise the Qhull libraries use qh->ferr and qh->qhmem.ferr for error output.

If an error occurs before qh->ferr is initialized, Qhull invokes qh_fprintf_stderr(). The user may redefine this function along with qh_exit(), qh_malloc(), and qh_free().

The Qhull libraries write output via qh_fprintf() [userprintf_r.c]. Otherwise, the Qhull libraries do not use stdout, fprintf(), or printf(). Like qh_exit(), the user may redefine qh_fprintf().

»sets and quick memory allocation

You can use mem_r.c and qset_r.c individually. Mem_r.c implements quick-fit memory allocation. It is faster than malloc/free in applications that allocate and deallocate lots of memory.

qset_r.c implements sets and related collections. It's the inner loop of Qhull, so speed is more important than abstraction. Set iteration is particularly fast. qset_r.c just includes the functions needed for Qhull.

»Delaunay triangulations and point indices

Here some unchecked code to print the point indices of each Delaunay triangle. Use option 'QJ' if you want to avoid non-simplicial facets. Note that upper Delaunay regions are skipped. These facets correspond to the furthest-site Delaunay triangulation.

  facetT *facet;
  vertexT *vertex, **vertexp;

  FORALLfacets {
    if (!facet->upperdelaunay) {
      printf ("%d", qh_setsize (facet->vertices);
      FOREACHvertex_(facet->vertices)
        printf (" %d", qh_pointid (vertex->point));
      printf ("\n");
    }
  }

»locate a facet with qh_findbestfacet()

The routine qh_findbestfacet in poly2_r.c is particularly useful. It uses a directed search to locate the facet that is furthest below a point.

For Delaunay triangulations, this facet is either the Delaunay triangle or a neighbor of the Delaunay triangle that contains the lifted point. Qhull determines the Delaunay triangulation by projecting the input sites to a paraboloid. The convex hull matches the Delaunay triangulation at the input sites, but does not match along the edges. See this image by F. Drielsma. A point is green or yellow depending upon the facet returned by qh_findbestfacet. For points near an edge, the circumcircles overlap and the adjacent facet may be returned.

For convex hulls, the distance of a point to the convex hull is either the distance to this facet or the distance to a subface of the facet.

Warning: If triangulated output ('Qt') and the best facet was triangulated, qh_findbestfacet() returns one of the corresponding 'tricoplanar' facets. The actual best facet may be a different tricoplanar facet from the same set of facets.

See qh_nearvertex() in poly2.c for sample code to visit each tricoplanar facet. To identify the correct tricoplanar facet, see Devillers, et. al., ['01] and Mucke, et al ['96]. If you implement this test in general dimension, please notify qhull@qhull.org.

qh_findbestfacet performs an exhaustive search if its directed search returns a facet that is above the point. This occurs when the point is inside the hull or if the curvature of the convex hull is less than the curvature of a sphere centered at the point (e.g., a point near a lens-shaped convex hull). When the later occurs, the distance function is bimodal and a directed search may return a facet on the far side of the convex hull.

Algorithms that retain the previously constructed hulls usually avoid an exhaustive search for the best facet. You may use a hierarchical decomposition of the convex hull [Dobkin and Kirkpatrick '90].

To use qh_findbestfacet with Delaunay triangulations, lift the point to a paraboloid by summing the squares of its coordinates (see qh_setdelaunay in geom2_r.c). Do not scale the input with options 'Qbk', 'QBk', 'QbB' or 'Qbb'. See Mucke, et al ['96] for a good point location algorithm.

The intersection of a ray with the convex hull may be found by locating the facet closest to a distant point on the ray. Intersecting the ray with the facet's hyperplane gives a new point to test.

»on-line construction with qh_addpoint()

The Qhull library may be used for the on-line construction of convex hulls, Delaunay triangulations, and halfspace intersections about a point. It may be slower than implementations that retain intermediate convex hulls (e.g., Clarkson's hull program). These implementations always use a directed search. For the on-line construction of convex hulls and halfspace intersections, Qhull may use an exhaustive search (qh_findbestfacet).

You may use qh_findbestfacet and qh_addpoint (libqhull.c) to add a point to a convex hull. Do not modify the point's coordinates since qh_addpoint does not make a copy of the coordinates. For Delaunay triangulations, you need to lift the point to a paraboloid by summing the squares of the coordinates (see qh_setdelaunay in geom2.c). Do not scale the input with options 'Qbk', 'QBk', 'QbB' or 'Qbb'. Do not deallocate the point's coordinates. You need to provide a facet that is below the point (qh_findbestfacet).

You can not delete points. Another limitation is that Qhull uses the initial set of points to determine the maximum roundoff error (via the upper and lower bounds for each coordinate).

For many applications, it is better to rebuild the hull from scratch for each new point. This is especially true if the point set is small or if many points are added at a time.

Calling qh_addpoint from your program may be slower than recomputing the convex hull with qh_qhull. This is especially true if the added points are not appended to the qh first_point array. In this case, Qhull must search a set to determine a point's ID. [R. Weber]

See user_eg.c for examples of the on-line construction of convex hulls, Delaunay triangulations, and halfspace intersections. The outline is:

initialize qhull with an initial set of points
qh_qhull();

for each additional point p
   append p to the end of the point array or allocate p separately
   lift p to the paraboloid by calling qh_setdelaunay
   facet= qh_findbestfacet (p, !qh_ALL, &bestdist, &isoutside);
   if (isoutside)
      if (!qh_addpoint (point, facet, False))
         break;  /* user requested an early exit with 'TVn' or 'TCn' */

call qh_check_maxout() to compute outer planes
terminate qhull

»Constrained Delaunay triangulation

With a fair amount of work, Qhull is suitable for constrained Delaunay triangulation. See Shewchuk, ACM Symposium on Computational Geometry, Minneapolis 1998.

Here's a quick way to add a constraint to a Delaunay triangulation: subdivide the constraint into pieces shorter than the minimum feature separation. You will need an independent check of the constraint in the output since the minimum feature separation may be incorrect. [H. Geron]

»Tricoplanar facets and option 'Qt'

Option 'Qt' triangulates non-simplicial facets (e.g., a square facet in 3-d or a cubical facet in 4-d). All facets share the same apex (i.e., the first vertex in facet->vertices). For each triangulated facet, Qhull sets facet->tricoplanar true and copies facet->center, facet->normal, facet->offset, and facet->maxoutside. One of the facets owns facet->normal; its facet->keepcentrum is true. If facet->isarea is false, facet->triowner points to the owning facet.

Qhull sets facet->degenerate if the facet's vertices belong to the same ridge of the non-simplicial facet.

To visit each tricoplanar facet of a non-simplicial facet, either visit all neighbors of the apex or recursively visit all neighbors of a tricoplanar facet. The tricoplanar facets will have the same facet->center.

See qh_detvridge for an example of ignoring tricoplanar facets.

»Voronoi vertices of a region

The following code iterates over all Voronoi vertices for each Voronoi region. Qhull computes Voronoi vertices from the convex hull that corresponds to a Delaunay triangulation. An input site corresponds to a vertex of the convex hull and a Voronoi vertex corresponds to an adjacent facet. A facet is "upperdelaunay" if it corresponds to a Voronoi vertex "at-infinity". Qhull uses qh_printvoronoi in io.c for 'qvoronoi o'

/* please review this code for correctness */
qh_setvoronoi_all();
FORALLvertices {
   site_id = qh_pointid (vertex->point);
   if (qh hull_dim == 3)
      qh_order_vertexneighbors(vertex);
   infinity_seen = 0;
   FOREACHneighbor_(vertex) {
      if (neighbor->upperdelaunay) {
        if (!infinity_seen) {
          infinity_seen = 1;
          ... process a Voronoi vertex "at infinity" ...
        }
      }else {
        voronoi_vertex = neighbor->center;
        ... your code goes here ...
      }
   }
}

»Voronoi vertices of a ridge

Qhull uses qh_printvdiagram() in io.c to print the ridges of a Voronoi diagram for option 'Fv'. The helper function qh_eachvoronoi() does the real work. It calls the callback 'printvridge' for each ridge of the Voronoi diagram.

You may call qh_printvdiagram2(), qh_eachvoronoi(), or qh_eachvoronoi_all() with your own function. If you do not need the total number of ridges, you can skip the first call to qh_printvdiagram2(). See qh_printvridge() and qh_printvnorm() in io.c for examples.

»vertex neighbors of a vertex

To visit all of the vertices that share an edge with a vertex:

  • Generate neighbors for each vertex with qh_vertexneighbors in poly2.c.
  • For simplicial facets, visit the vertices of each neighbor
  • For non-simplicial facets,
    • Generate ridges for neighbors with qh_makeridges in merge.c.
    • Generate ridges for a vertex with qh_vertexridges in merge.c.
    • Visit the vertices of these ridges.

For non-simplicial facets, the ridges form a simplicial decomposition of the (d-2)-faces between each pair of facets -- if you need 1-faces, you probably need to generate the full face graph of the convex hull.

»How to debug Qhull

Qhull continually checks its execution, so most errors will stop Qhull with an error message. Additional checking occurs for verified output ('Tv'), check frequently ('Tc'), check for duplicate ridges ('Q15'), and tracing at level 4 ('T4').

If Qhull detects an error, it writes a descriptive error message to stderr, and exits with an exit status code (see following). The C++ interface captures the message in Qhull::qhullMessage. If Qhull::setErrorStream was called, it writes the error message to Qhull::errorStream.

If a Qhull segfault occurs, turn on tracing with option 'T4' and flush output (qh_fprintf) with option 'Tf'. See core dumps and segfaults.

If Qhull never finishes, is Qhull running slow or was there an infinite loop?

  • If you are running Qhull under Git for Windows or MSYS2, 'qhull' waits for stdin instead of displaying a help message. Use 'qhull --help' instead.
  • Turn on monitoring with option 'TFn'. Qhull normally takes approximately the same amount of time per point. If the output is too large, it will slow down due to main memory or virtual memory.
  • If there are large, non-simplicial facets, see "quadradic running time" in Limitations of merged facets.
  • See Performance and infinite loops for further suggestions.

If a Qhull error occurs, try to simplify the problem.

  • If new to Qhull, start with short examples that you can work out by hand. Your problem may be due to misunderstanding Qhull's output, or an incompatibility between your program and the Qhull libraries.
  • Can you produce the input that triggers the problem? The input to Qhull includes the dimension, number of points, point coordinates, and Qhull options. Qhull is usually deterministic for a particular build.
  • Can you duplicate the problem using one of the Qhull programs (e.g., 'qhull' or 'qconvex')?
  • Does a shorter output trigger the problem?
  • Can you turn on tracing with option 'T4'? If too much output occurs, use the trace options to reduce the trace output.
  • The test program, 'eg/qtest.sh', repeats a qhull run for intermittent errors. It can log a qhull run to 'qhull.log' and a reduced log, 'qhull-step.log'.

If the segfault, infinite loop, or internal error was due to Qhull, please report the error to 'bradb@shore.net. Please include the input data (i.e., point coordinates) that triggered the error.

»Qhull errors

Qhull errors start with 'QH6...' and Qhull warnings start with 'QH7...'. The error message and error code are arguments to a qh_fprintf call. After printing the error message, Qhull exits with an exit status code. The exit status code indicates the type of error:

  • qh_ERRinput (1) -- badly formed options or input. Badly formed options are reported as Qhull warnings. Unless option 'Qw' is specified, Qhull reports error QH6035 or QH6037 and exits with qh_ERRinput. Inconsistent options typically report an error.
    The input to Qhull specifies the dimension and number of points. If the input contains fewer or more points than coordinates, Qhull reports error QH6410 and exits with qh_ERRinput. If option 'Qa' is specified, it reports warning QH7073 and continues execution.
  • qh_ERRsingular (2) -- singular input data. If the input data is singular or flat (e.g., a line segment in 2-d), Qhull reports error QH6114, QH6379, or QH6154. Qhull calls qh_printhelp_singular to print an explanation of the error. It exits qhull with qh_ERRsingular.
  • qh_ERRprec (3) -- precision error. By default, Qhull handles precision errors by merging. If merging is not possible, or if a precision error is identified after Qhull finishes, Qhull reports an error and calls qh_printhelp_degenerate. It exits qhull with qh_ERRprec.
  • qh_ERRmem (4) -- memory error. If Qhull runs out of memory, it reports an error and exits qhull with qh_ERRmem.
  • qh_ERRQhull (5) -- internal error. If Qhull detects an internal error, it reports the error and calls qh_printhelp_internal. It exits qhull with qh_ERRQhull.
  • qh_ERRother (6) -- other errors. If Qhull identifies an error while reporting another error, it prints "qhull error while handling previous error" and exits Qhull with qh_ERRother. The same exit code is used for vertex id overflow and missing exitcode for qh_errexit.
  • qh_ERRtopology (7) -- topology error. If Qhull cannot recover from a topology error, it reports the error and calls qh_printhelp_topology. It exits qhull with qh_ERRtopology.
  • qh_ERRwide (8) -- wide facet error. If Qhull produces an extra-wide facet, it reports the error and calls qh_printhelp_wide. It exits qhull with qh_ERRwide.
  • qh_ERRdebug (9) -- debug. Use qh_ERRdebug for exits from debugging code.

»Qhull infinite loops

Except for list traversals, most loops in Qhull are limited by a count or the size of set. Linked lists of facets and vertices terminate with a sentinel whose next element is NULL. If a programming error inserts a link to a previous facet or vertex, an infinite loop occurs on the next traversal. Qhull periodically checks and corrects its linked lists for infinite loops (qh_checklists).

»Qhull trace options

Qhull's trace options are the key to debugging Qhull. They describe an execution of Qhull at various levels of detail, with various options to control what is traced.

  • Level 0 ('T-1') -- Key events are prefixed with '[QH00nn]'
  • Level 1 ('T1') -- Main steps in the program are prefixed with '[QH1nnn]'.
    [QH1049]qh_addpoint -- When Qhull adds a point, it logs information about the point, the convex hull so far, and changes since the previous qh_addpoint.
  • Level 2 ('T2') -- Minor steps in the program are prefixed with '[QH2nnn]'.
  • Level 3 ('T3') -- Merge and other events are prefixed with '[QH3nnn]'.
  • Level 4 ('T4') -- Detailed trace of Qhull execution.
  • Level 5 ('T5') -- Memory allocations and Guassian elimination. Memory allocations are prefixed with "qh_mem " followed by address, sequence number, alloc/free, short/long, etc. If you sort by address and sequence number, each allocate should be paired with its free.

These options select when tracing starts or stops. It limits the amount of tracing, especially in high dimensions.

  • 'TAn' -- stop Qhull after adding n vertices
  • 'TCn' -- stop Qhull after building cone for point n
  • 'TMn' -- turn on tracing at merge n. When Qhull reports an error, it reports "Last merge was #nnn".
  • 'TPn' -- turn on tracing when point n is added to hull or point n is referenced. When Qhull reports an error, it reports "Last point added to hull was pnnn".
  • 'TVn' -- stop Qhull after adding point n, -n for before
  • 'TWn' -- trace merge facets when width > n

Additional logging by facet id (fnnn), ridge id (rnnn) or vertex id (vnnn), may be enabled by setting qh.tracefacet_id, qh.traceridge_id, or qh.tracevertex_id in global_r.c/qh_initqhull_start2.

»Qhull core dumps and segfaults

If a segfault occurs, use option 'Tf' to flush output after every qh_fprintf. Logging will be significantly slower than normal.

The following debugging plan usually identifies the error

  1. Trace execution at level 1 with flush after each qh_fprintf and output to stdout ('T1 Tf Tz').
  2. Repeat at level 4 after the last qh_addpoint (QH1049, 'TPn'). Add line numbers to the log by piping the output through 'grep -n .'.
    • If there is too much level 4 output, repeat at level 2 to find the last qh_mergefacet (QH2081) and then trace at level 4 from the last merge ('TMn').
    • If there is still too much level 4 output, identify one of the last level 3 events and add debugging to the corresponding trace3 call. Be sure to mark the code for removal. For example
        if (facetA->id==4675)
          qh->IStracing= 4; /* DEBUG */
        trace3((qh, qh->ferr, 3020, "qh_triangulate_facet: triangulate facet f%d\n", facetA->id));
      
  3. Identify the location of the failure using a build of Qhull with debug symbols.
  4. Use the debugger to find relevant facet ids, ridge ids, and vertex ids. These identifiers will appear in the level 4 log.

»eg/qtest.sh for intermittent errors and logging

For intermittent errors, use 'rbox' to generate random test cases, and eg/qtest.sh to invoke multiple runs of qhull. When a failing case is found, rerun eg/qtest.sh with the test case identifier. It produces qhull.log and the corresponding reduced log, qhull-step.log. These logs include line numbers generated by 'grep -n .'

qtest.sh provides the following options

  • N qhull runs (qtest.sh -N 'rbox c | qhull')
    execute the qhull command N times with rotated input 'QR1', 'QR2', ...
  • N random qhull runs (qtest.sh N 'rbox c | qhull')
    execute the qhull command N times with random rotations 'QRn', ...

  • N 'rbox|qhull' runs (qtest.sh -N 'rbox-opts' 'qhull-opts')
    execute rbox and qhull N times with random inputs 't1', 't2', ...
  • N random 'rbox|qhull' runs (qtest.sh N 'rbox-opts' 'qhull-opts')
    execute rbox and qhull N times with random inputs 'tnnn', ...

  • Run qhull command (qtest.sh run 'rbox c | qhull')
    execute a qhull command line
  • Run qhull QRnnn (qtest.sh run QRnnn 'rbox | qhull')
    execute a qhull command line with QRnnn rotated input
  • Run rbox tnnn | qhull (qtest.sh run t... 'rbox-opts' 'qhull-opts')
    execute rbox and qhull commands with tnnn random input

  • Log qhull command (qtest.sh log 'rbox c | qhull')
    trace (T4) a qhull command line to qhull.log and qhull-step.log
  • Log qhull QRnnn (qtest.sh QRnnn 'rbox | qhull')
    trace (T4) a qhull command line with QRnnn rotated input to qhull.log and qhull-step.log
  • Log rbox tnnn | qhull (qtest.sh tnnn 'rbox-opts' 'qhull-opts')
    trace (T4) rbox and qhull commands with tnnn random input to qhull.log and qhull-step.log

  • Grep qhull.log for events (qtest.sh grep)
    grep qhull.log for $QH_GREP excluding $QH_GREPX to stdout
  • Grep qhull.log for regexp (qtest.sh grep 'include-regexp')
    grep qhull.log for regexp|$QH_GREP excluding $QH_GREPX to stdout
  • Grep qhull.log for include and exclude regexps (qtest.sh grep 'include-regexp' 'exclude-regexp')
    grep qhull.log for include|$QH_GREP excluding exclude|$QH_GREPX to stdout

  • Grep logfile for merge events (qtest.sh grep-merge logfile)
    grep logfile for merge events to stdout, see #grep-merge in qtest.sh

  • Grep logfile for step events (qtest.sh grep-merge logfile)
    grep logfile for step events to stdout, same as qhull-step.log

  • Verbose logging (qtest.sh -v ...)
    prepend log with command and environment variables

»Memory errors

Qhull checks memory usage before exiting. To locate memory that is not freed ("QH7079 qhull internal warning (main): did not free ..."):
  1. Run qhull with memory tracing 'T5'.
    See 'Level 5' in Qhull trace options (above)
  2. Sort lines that start with 'qh_mem'. It matches qh_memalloc with the corresponding qh_memfree.
  3. For long allocations, sort lines that contain -- qh_mem.*long:
  4. Replace -- qh_mem.*alloc.*\nqh_mem.*free.* -- with 'Match' (Textpad supports internal newlines in match expressions).
  5. Sort by column 25 (n...). It shows unallocated actions. Long allocations are in execution order. Short and quick allocations are in execution order.
  6. For example: qh_mem 0000000000537440 n 10053 alloc long: 128 bytes (tot 484800 cnt 1209)
  7. To check quick vs. long allocations -- grep "qh_mem .*alloc " qhull.log | sed -e 's/^.*long/long/' -e 's/^.*short/short/' -e 's/^.*quick/quick/' -e 's/bytes.*/bytes/' | sort | uniq -c >x.1

Option 'Ts' reports numerous memory statistics.

»Qhull debugging tips

  • qh_printlists in poly2_r.c -- called during qh_addpoint. Easily inserted into existing code and a good location for debugging code.
  • qh_fprintf in user_r.c -- called for all Qhull output, including trace logs. A good location for reasonably efficient debugging code. The debugging code may refer to a facet, ridge, or vertex by setting qh.tracefacet_id, qh.traceridge_id, or qh.tracevertex_id in global_r.c/qh_initqhull_start2.
  • qh_tracemerge in merge_r.c -- called after each merge. It is a good location for debugging code.

»Performance of Qhull

Empirically, Qhull's performance is balanced in the sense that the average case happens on average. This may always be true if the precision of the input is limited to at most O(log n) bits. Empirically, the maximum number of vertices occurs at the end of constructing the hull.

Let n be the number of input points, v be the number of output vertices, and f_v be the maximum number of facets for a convex hull of v vertices. If both conditions hold, Qhull runs in O(n log v) in 2-d and 3-d and O(n f_v/v) otherwise. The function f_v increases rapidly with dimension. It is O(v^floor(d/2) / floor(d/2)!).

The time complexity for merging is unknown. The default options 'C-0' (2-d, 3-d, 4-d) and 'Qx' (5-d and higher) handle precision problems due to floating-point arithmetic. They are optimized for simplicial outputs.

When running large data sets, you should monitor Qhull's performance with the 'TFn' option. The time per facet is approximately constant. In high-d with many merged facets, the size of the ridge sets grows rapidly. For example the product of 8-d simplices contains 18 facets and 500,000 ridges. This will increase the time needed per facet.

Additional detail is provided by QH1049 in the level-1 trace ('T1'). For each qh_addpoint, it provides vertex id, facet count, outside point count, CPU time for the previous point, deltas for facets/hyperplanes/distplanes, and the number of retries due to merged pinched vertices. For example:

[QH1049]qh_addpoint: add p260(v176) to hull of 286 facets (1.4e-12 above f830) and 2 outside at 1.192 CPU secs. Previous p710(v175) delta 0.007 CPU, 2 facets, 3 hyperplanes, 443 distplanes, 0 retries

As dimension increases, the number of facets and ridges in a convex hull grows rapidly for the same number of vertices. For example, the convex hull of 300 cospherical points in 6-d has 30,000 facets.

If Qhull appears to stop processing facets, check the memory usage of Qhull. If more than 5-10% of Qhull is in virtual memory, its performance will degrade rapidly.

When building hulls in 20-d and higher, you can follow the progress of Qhull with option 'T1'. It reports each major event in processing a point.

To reduce memory requirements, recompile Qhull for single-precision reals (REALfloat in user.h). Single-precision does not work with joggle ('QJ'). Check qh_MEMalign in user.h and the match between free list sizes and data structure sizes (see the end of the statistics report from 'Ts'). If free list sizes do not match, you may be able to use a smaller qh_MEMalign. Setting qh_COMPUTEfurthest saves a small amount of memory, as does clearing qh_MAXoutside (both in user.h).

Shewchuk is working on a 3-d version of his triangle program. It is optimized for 3-d simplicial Delaunay triangulation and uses less memory than Qhull.

To reduce the size of the Qhull executable, consider qh_NOtrace and qh_KEEPstatistics 0 in user.h. By changing user.c you can also remove the input/output code in io.c. If you don't need facet merging, then version 1.01 of Qhull is much smaller. It contains some bugs that prevent Qhull from initializing in simple test cases. It is slower in high dimensions.

The precision options, 'Vn', 'Wn', 'Un'. 'A-n', 'C-n', 'An', 'Cn', and 'Qx', may have large effects on Qhull performance. You will need to experiment to find the best combination for your application.

The verify option ('Tv') checks every point after the hull is complete. If facet merging is used, it checks that every point is inside every facet. This can take a very long time if there are many points and many facets. You can interrupt the verify without losing your output. If facet merging is not used and there are many points and facets, Qhull uses a directed search instead of an exhaustive search. This should be fast enough for most point sets. Directed search is not used for facet merging because directed search was already used for updating the facets' outer planes.

The check-frequently option ('Tc') becomes expensive as the dimension increases. The verify option ('Tv') performs many of the same checks before outputting the results.

Options 'Q0' (no pre-merging), 'Q3' (no checks for redundant vertices), 'Q5' (no updates for outer planes), and 'Q8' (no near-interior points) increase Qhull's speed. The corresponding operations may not be needed in your application.

In 2-d and 3-d, a partial hull may be faster to produce. Option 'QgGn' only builds facets visible to point n. Option 'QgVn' only builds facets that contain point n. In higher-dimensions, this does not reduce the number of facets.

User.h includes a number of performance-related constants. Changes may improve Qhull performance on your data sets. To understand their effect on performance, you will need to read the corresponding code.

GNU gprof reports that the dominate cost for 3-d convex hull of cosperical points is qh_distplane(), mainly called from qh_findbestnew(). The dominate cost for 3-d Delaunay triangulation is creating new facets in qh_addpoint(), while qh_distplane() remains the most expensive function.

»eg/q_benchmark for optimizing Qhull

eg/q_benchmark and eg/qtest.sh make multiple runs of Qhull for testing, benchmarking, and debugging. They help test and analyze intermittent errors, performance issues, and precision issues. Each release updates eg/q_benchmark-ok.txt.

Qhull 2019.1 is 15% larger than Qhull 2015.2 due to enhanced error reporting, tracing, and facet merging. The increased code size may increase startup times.

Qhull is single threaded. Gcc's gprof works well for profiling Qhull performance.

  • Recompile Qhull with '-pg' added to CC_OPTS1 in qhull's Makefile. Check for optimization ('-O3').
  • Execute a performance test of Qhull
    • See "=== Timing test cases ===" in 'eg/q_benchmark'.
  • Check for gmon.out from gcc's '-pg' option -- ls -l gmon.out
  • Run gprof -- gprof qhull >gprof.txt # gprof qhull.exe >gprof.txt
  • Review gprof.txt
    • The first section gives results by function, the second section, results by caller
  • Sample runs
    rbox 500000 s >r.x; time qhull TI r.x
    
    AIR2-/local/qhull/bin> time qhull TI r.x
    
    Convex hull of 500000 points in 3-d:
    
      Number of vertices: 500000
      Number of facets: 999996
    
    Statistics for: rbox 500000 s | qhull TI r.x
    
      Number of points processed: 500000
      Number of hyperplanes created: 2827999
      Number of distance tests for qhull: 24786928
      CPU seconds to compute hull (after input): 4.852
    
    
    [4]     62.8    0.02    2.11  499996         qh_addpoint [4]
                    0.01    0.83  499996/499996      qh_buildcone [5]
                    0.04    0.56  499996/499996      qh_partitionvisible [7]
                    0.01    0.28  499996/499996      qh_premerge [13]
                    0.04    0.13  499996/499996      qh_findhorizon [19]
    
    # 2015.2
    Statistics for: rbox 500000 s | qhull TI c:/bash/local/qhull/bin/r.x
      Number of vertices: 500000
      Number of facets: 999996
      Number of points processed: 500000
      Number of hyperplanes created: 2827999
      Number of distance tests for qhull: 24786929
      CPU seconds to compute hull (after input): 4.477
    real    0m6.334s
    user    0m0.016s
    sys     0m0.015s
    

»Enhancements to Qhull

There are many ways in which Qhull can be improved.

Top Suggestions
 - Document the C++ interface using Doxygen
 - Construct the full Voronoi Diagram using the C++ interface.  See "To do" in Changes.txt
 - Optimize for 64-bit code
   Custom facetT for simplicial facets
   32-bit indices for facets and vertices
 - Bulk qh_addpoint with a custom point partition
 - Full-dimensional flats
   Add points at right angles like 'Qz'
   Ignore added facets in output (cf. f.upperDelaunay and f.good)
 - Per-vertex joggle
   Joggle by random flip of low-order and adjustable-order bits in mantissa
   Allows consistent triangulations across distributed partitions
   Detect integer input data and automatically translate to the origin
 - Develop a theory for merging Qhull's non-simplicial facets
   A merge creates constraints on subsequent merges, what are these constraints?
   Identify topological errors in qh_findbest_test (merge_r.c)f
   Prevent duplicate ridges (Q15-check-duplicates) or facets with the same vertices
   Preserve facet-ridge orientation for nonsimplicial facets (ridge top/bot)
   Produce conformant triangulations for nonsimplicial facets (option 'Qt', QH2088)
   Should vertex merge account for facet orientation?
   Rationalize the merge options qh_RATIOtwisted, qh_WIDEdupridge, etc.
   Should wide merges be proportional to qh.ONEmerge or f.maxoutside?
   Can dupridges be avoided with geometric and topological constraints?
   Review coplanar tests across sharp ridges (coplanar horizon, qh_test_appendmerge, qh_check_maxout)
 - Improve Qhull's computations, particularly qh_setfacetplane for hyperplanes
   Toronto, N., McCarthy, J., "Practically accurate floating-point math,", Computing in
   Science & Engineering, IEEE, July/August 2014, p. 80-95.
 - Octave creates endpoints for unbounded ridges, for drawing Delaunay/Voronoi diagrams [M. Voss]
 - Option to select bounded Voronoi regions [A. Uzunovic]
 - Review Qhull performance.  qh_next_vertexmerge and qh_check_maxout are slower than expected
   Compare to Peterka et al and Li and Snoeyink, particularly 64-bit vs. 32-bit
 - Use Gaussian distribution for random cospherical points in rbox
 - Implement dimension reduction via Johnson-Lindenstrauss flattening
 - Implement bulk qh_addpoint via a subset of the facets, perhaps a box about qh.interior_point
   Allow qh_triangulate to run after each increment [coldfix, scipy #4974]
 - Write incremental addPoint with bucketed inputs and facet search (CGAL)
 - Compute hyperplanes in parallel (cf. qh_setfactplane)
 - Create Voronoi volumes and topology in parallel
 - Implement Delaunay to Voronoi tesselation [Peterka et al, 2014, www.mcs.anl.gov/papers/P5154-0614.pdf]
 - Integrate 4dview with Geomview 1.9.5
 - Use coverage testing to expand Qhull's test programs
 - Add RPM and Debian builds to Qhull (CMake's CPackRMP and CPackDeb).
 - Create a mirror/archive web site for old and new Qhull builds
 - Constrain delaunay triangulations via Shewchuk's algorithm (ACM Symp. Comp. Geo., 1998)

-----------
To do for a furture version of the C++ interface
 - Document C++ using Doxygen conventions (//! and //!<)
 - Add defineAs() to each object
 - Add Qtest::toString() functions for QhullPoint and others.  QByteArray and qstrdup()
 - Add toQVector() for Qt container support.  QVector is preferred over QList
 - Add mutable Java-style iterators for containers.  Limited due to memory-allocation issues.
 - Should Qhull manage the output formats for doubles?  QH11010 FIX: user_r.h defines qh_REAL_1 as %6.8g
 - Allocate memory for QhullSet using Qhull.qhmem.  Create default constructors for QhullVertexSet etc.  Also mid() etc.
 - Add interior point for automatic translation?
 - Write a program with concurrent Qhull
 - Write QhullStat and QhullStat_test
 - Add QList and vector instance of facetT*, etc.
 - Generalize QhullPointSetIterator
 - qh-code.html: Document changes to C++ interface.
      Organize C++ documentation into collection classes, etc.
 - Review all C++ classes and C++ tests
 - QhullVertexSet uses QhullSetBase::referenceSetT() to free its memory.   Probably needed elsewhere
 - The Boost Graph Library provides C++ classes for graph data structures. It may help
   enhance Qhull's C++ interface [Dr. Dobb's 9/00 p. 29-38; OOPSLA 99 p. 399-414].

[May 2020] Suggestions
- Check that the midpoint for Voronoi option 'Fo' is not a Voronoi vertex (rbox c D2 P0 | qvoronoi Fo)
- How to detect degenerate hyperplanes for Voronoi option 'Fo' and 'Fi'?
  qh_sethyperplane_gauss reports nearzero for axis parallel hyperplanes.
- Add a 'Tv' test for Voronoi option 'Fo' that does not use midpoints

[May 2019] Suggestions
------------
Precision issues
- Improve handling of data with positive, integer coordinates, particularly for Delaunay triangulation
  eg Sterratt's github issue #25
  Add a warning that available precision is reduced
  Add an option to automatically translate the data to the origin
- Review qh.MAXcoplanar ('Un'), it varies by dimension compared to qh.ONEmerge

Topology issues
- Need theory for facet merging, vertex merging, and topological errors
- Does qh_triangulate produce a consistent orientation if qh_renamevertex is not called?

Facet and vertex merging
- Reduce the overhead of qh.NEWtentative ('Q14') and improve the speed of facet and vertex merging
- Review MRGconcavecoplanar and early out for isconcave in qh_test_nonsimplicial_merge
- Review user_r.h ratios and precision constants for merging
  Pre-compute derived precision values (e.g., qh_detmaxoutside)
- Use a fixed target instead of a relative wide-max ratio.
  Why should qh.MAXoutside increase when qh.max_outside increases dramatically
  Why should a slow but steady increase in qh.max_outside be OK?
  Define an option to specify wide-max ratio -- 100x is borderline, bad cases can produce 400x,
- Add statistics for dupridge matching in qh_matchneighbor and qh_matchdupridge.  Report as a "precision problem"
- Collect statistics for MRGdegen and MRGredundant
- In qh_all_merges, why is isreduce set when qh.POSTmerging && qh.hull_dim >= 4?
- In qh_forcedmerges and qh_initmergesets, remove assumption that qh.facet_mergeset is the last temporary set
- Review comparisons for qh_compare_anglemerge and qh_compare_facetmerge (after developing a theory)

Other
- Add a version flag to 'rbox' (cf. global_r.c/qh_version).  Currently, the release date is part of its help prompt.
- Review effect of qh.GOODclosest on qh_buildcone_onlygood ('Qg', QH11030 FIX).  qh_findgood preserves old value if didn't find a good facet.  See qh_findgood_all for disabling
- Review the rules for -REALmax -- they look inconsistent.
  Why REALmax/2 and -REALmax/2?  The comments say 'avoid underflow'.  When was it introduced?
- Review comment in qh_matchnewfacets -- "do not allocate memory after qh.hash_table (need to free it cleanly)"
- Chase circular dependencies when compiling qhulltest with Microsoft Devstudio
  Warning MSB8017 A circular dependency has been detected while executing custom build commands for item "moc\Coordinates_test.moc". This may cause incremental build to work incorrectly.        qhulltest-64    C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets   209
- Add 'design:' documentation for poly2_r.c/qh_triangulate
  Consider splitting up
- Geomview for 4-d merge is difficult to understand.  Not able to see the convexity of the edges
- Review memory sizes (mem_r.c/qh_memsize) and quick allocations for 64-bit code
- Review Qhull's collection API conventions, http://www.qhull.org/road/road-faq/xml/qhull-cpp.xml
  See http://gnuwin32.sourceforge.net/packages.html and https://google-styleguide.googlecode.com/svn/trunk/cppguide.html

[Jan 2019] Suggestions
- Optimize poly_r.c/qh_update_vertexneighbors for qh_triangulate. qh_setunique and qh_setcompact are slow
- The size of maxpoints in qh_initialvertices/qh_maxsimplex should be d+3 unique points to help avoid QH6154
- Review coordT vs. realT.  Should parameters and variables be coordT when they are distances or coordinates?
  'coordT' is defined as 'realT'
  Having computations as 'double' with coordinates stored as 'float' requires many type conversions
  Expressions are often computed as 'double' anyway
  Source code sometimes uses 'coordT' and sometimes 'realT'
- Need a separate, hash check for duplicate ridge vertices in a facet list -- faster than current qh_checkfacet
- Add joggle for 'almost incident' vertices (order of 100), may clean up Qt as well, projected to hyperplane
- Consider using r.mergevertex2 to optimize qh_postmerge
- Report two facets with same ridge vertices, opposite orientation (topology error)
  add warning (see QH7084) for duplicate ridge with opposite orientation (only two facets in the list)
- Check 'qh_NOmerge' compiler option

[Jan 2016] Suggestions
------------
 - Add a post-merge pass for Delaunay slivers.  Merge into a neighbor with a circumsphere that includes the opposite point. [M. Treacy]
 - Option to add a bounding box for Delaunay triangulations, e,g., nearly coincident points
 - Rescale output to match 'QbB' on input [J. Metz, 1/30/2014 12:21p]
 - Run through valgrind
 - Notes to compgeom on conformant triangulation and Voronoi volume
 - Implement weighted Delaunay triangulation and weighted Voronoi diagram [A. Liebscher]
   e.g., Sugihara, "Three-dimensional convex hull as a fruitful source of diagrams," Theoretical Computer Science, 2000, 235:325-337
 - testqset: test qh_setdelnth and move-to-front
 - Makefile: Re-review gcc/g++ warnings.  OK in 2011.
 - Break up -Wextra into its components or figure out how to override -Wunused-but-set-variable
   unused-but-set-variable is reporting incorrectly.  All instances are annotated.

 - Can countT be defined as 'int', 'unsigned int', or 64-bit int?
   countT is currently defined as 'int' in qset_r.h
   Vertex ID and ridge ID perhaps should be countT, They are currently 'unsigned'
   Check use of 'int' vs. countT in all cpp code
   Check use of 'int' vs. countT in all c code
   qset_r.h defines countT -- duplicates code in user_r.h -- need to add to qset.h/user.h
   countT -1 used as a flag in Coordinates.mid(), QhullFacet->id()
   Also QhullPoints indexOf and lastIndexOf
   Also QhullPointSet indexOf and lastIndexOf
   Coordinates.indexOf assumes countT is signed (from end)
   Coordinates.lastIndexOf assumes countT is signed (from end)
   All error messages with countT are wrong, convert to int?
   RboxPoints.qh_fprintf_rbox, etc. message 9393 assumes countT but may be int, va_arg(args, countT);  Need to split

[Jan 2010] Suggestions
 - Generate vcproj from qtpro files
   cd qtpro && qmake -spec win32-msvc2005 -tp vc -recursive
   sed -i 's/C\:\/bash\/local\/qhull\/qtpro\///' qhull-all.sln
   Change qhullcpp to libqhull.dll
   Allow both builds on same host (keep /tmp separate)
 - C++ class for access to statistics, accumulate vs. add
 - Add dialog box to RoadError-- a virtual function?
 - Option 'Gt' does not make visible all facets of the mesh example, rbox 32 M1,0,1 | qhull d Gt
 - Merge small volume boundary cells into unbounded regions [Dominik Szczerba]
 - Postmerge with merge options
 - Add modify operators and MutablePointCoordinateIterator to PointCoordinates
 - Fix option Qt for conformant triangulations of merged facets
 - Investigate flipped facet -- rbox 100 s D3 t1263080158 | qhull R1e-3 Tcv Qc
 - Add doc comments to c++ code
 - Measure performance of Qhull, seconds per point by dimension
 - Report potential wraparound of 64-bit ints -- e.g., a large set or points

Documentation
- Qhull::addPoint().  Problems with qh_findbestfacet and otherpoints see
   qh-code.html#inc on-line construction with qh_addpoint()
- How to handle 64-bit possible loss of data.  WARN64, ptr_intT, size_t/int
- Show custom of qh_fprintf
- cat x.x | grep 'qh_mem ' | sort | awk '{ print $2; }' | uniq -c | grep -vE ' (2|4|6|8|10|12|14|16|20|64|162)[^0-9]'
- qtpro/qhulltest contains .pro and Makefile.  Remove Makefiles by setting shadow directory to ../../tmp/projectname
- Rules for use of qh_qh and multi processes
    UsingQhull
    errorIfAnotherUser
    ~QhullPoints() needs ownership of qh_qh
    Does !qh_pointer work?
    When is qh_qh required?  Minimize the time.
   qhmem, qhstat.ferr
   qhull_inuse==1 when qhull globals active [not useful?]
   rbox_inuse==1 when rbox globals active
   - Multithreaded -- call largest dimension for infinityPoint() and origin()
 - Better documentation for qhmem totshort, freesize, etc.
 - how to change .h, .c, and .cpp to text/html.  OK in Opera
 - QhullVertex.dimension() is not quite correct, epensive
 - Check globalAngleEpsilon
 - Deprecate save_qhull()

[Dec 2003] Here is a partial list:
 - fix finddelaunay() in user_eg.c for tricoplanar facets
 - write a BGL, C++ interface to Qhull
     http://www.boost.org/libs/graph/doc/table_of_contents.html
 - change qh_save_qhull to swap the qhT structure instead of using pointers
 - change error handling and tracing to be independent of 'qh ferr'
 - determine the maximum width for a given set of parameters
 - prove that directed search locates all coplanar facets
 - in high-d merging, can a loop of facets become disconnected?
 - find a way to improve inner hulls in 5-d and higher
 - determine the best policy for facet visibility ('Vn')
 - determine the limitations of 'Qg'

Precision improvements:
 - For 'Qt', resolve cross-linked, butterfly ridges.
     May allow retriangulation in qh_addpoint().
 - for Delaunay triangulations ('d' or 'v') under joggled input ('QJ'),
     remove vertical facets whose lowest vertex may be coplanar with convex hull
 - review use of 'Qbb' with 'd QJ'.  Is MAXabs_coord better than MAXwidth?
 - check Sugihara and Iri's better in-sphere test [Canadian
     Conf. on Comp. Geo., 1989; Univ. of Tokyo RMI 89-05]
 - replace centrum with center of mass and facet area
 - handle numeric overflow in qh_normalize and elsewhere
 - merge flipped facets into non-flipped neighbors.
     currently they merge into best neighbor (appears ok)
 - determine min norm for Cramer's rule (qh_sethyperplane_det).  It looks high.
 - improve facet width for very narrow distributions

New features:
 - implement Matlab's tsearch() using Qhull
 - compute volume of Voronoi regions.  You need to determine the dual face
   graph in all dimensions [see Clarkson's hull program]
 - compute alpha shapes [see Clarkson's hull program]
 - implement deletion of Delaunay vertices
      see Devillers, ACM Symposium on Computational Geometry, Minneapolis 1999.
 - compute largest empty circle [see O'Rourke, chapter 5.5.3] [Hase]
 - list redundant (i.e., coincident) vertices [Spitz]
 - implement Mucke, et al, ['96] for point location in Delaunay triangulations
 - implement convex hull of moving points
 - implement constrained Delaunay diagrams
      see Shewchuk, ACM Symposium on Computational Geometry, Minneapolis 1998.
 - estimate outer volume of hull
 - automatically determine lower dimensional hulls
 - allow "color" data for input points
      need to insert a coordinate for Delaunay triangulations

Input/output improvements:
 - Support the VTK Visualization Toolkit, http://www.kitware.com/vtk.html
 - generate output data array for Qhull library [Gautier]
 - need improved DOS window with screen fonts, scrollbar, cut/paste
 - generate Geomview output for Voronoi ridges and unbounded rays
 - generate Geomview output for halfspace intersection
 - generate Geomview display of furthest-site Voronoi diagram
 - use 'GDn' to view 5-d facets in 4-d
 - convert Geomview output for other 3-d viewers
 - add interactive output option to avoid recomputing a hull
 - orient vertex neighbors for 'Fv' in 3-d and 2-d
 - track total number of ridges for summary and logging

Performance improvements:
 - GPU hardware acceleration, particularly for qh_setplane [D. Reese]
 - optimize Qhull for 2-d Delaunay triangulations
 -   use O'Rourke's '94 vertex->duplicate_edge
 -   add bucketing
 -   better to specialize all of the code (ca. 2-3x faster w/o meSrging)
 - use updated LU decomposition to speed up hyperplane construction
 -        [Gill et al. 1974, Math. Comp. 28:505-35]
 - construct hyperplanes from the corresponding horizon/visible facets
 - for merging in high d, do not use vertex->neighbors

Please let us know about your applications and improvements.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Imprecision in Qhull
To: Qhull code: contents


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see Changes.txt

geometry/inst/doc/qhull/html/qh-optp.html0000644000176200001440000002377114664417655020232 0ustar liggesusers Qhull print options (P)

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull print options (P)

This section lists the print options for Qhull. These options are indicated by 'P' followed by a letter. See Output, Geomview, and Format for other output options.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Print options

Po
force output despite precision problems
Po
if error, output neighborhood of facet
Pp
do not report precision problems
 
 
Selection options
PAn
print n largest facets by area
Pdk:n
print facets with normal[k] >= n (default 0.0)
PDk:n
print facets with normal[k] <= n
PFn
print facets whose area is at least n
Pg
print good facets only (needs 'QGn' or 'QVn')
PG
print neighbors of good facets
PMn
print n facets with most merges

»PAn - keep n largest facets by area

The n largest facets are marked good for printing. This may be useful for approximating a hull. Unless 'PG' is set, 'Pg' is automatically set.

»Pdk:n - print facet if normal[k] >= n

For a given output, print only those facets with normal[k] >= n and drop the others. For example, 'Pd0:0.5' prints facets with normal[0] >= 0.5 . The default value of n is zero. For example in 3-d, 'Pd0d1d2' prints facets in the positive octant.

If no facets match, use option 'Pg' to print the closest facet.

On Windows 95, do not combine multiple options. A 'd' is considered part of a number. For example, use 'Pd0:0.5 Pd1:0.5' instead of 'Pd0:0.5d1:0.5'.

»PDk:n - print facet if normal[k] <= n

For a given output, print only those facets with normal[k] <= n and drop the others. For example, 'PD0:0.5' prints facets with normal[0] <= 0.5 . The default value of n is zero. For example in 3-d, 'PD0D1D2' displays facets in the negative octant.

If no facets match, use option 'Pg' to print the closest facet.

In 2-d, 'd G PD2' displays the Delaunay triangulation instead of the corresponding paraboloid.

Be careful of placing 'Dk' or 'dk' immediately after a real number. Some compilers treat the 'D' as a double precision exponent.

»PFn - keep facets whose area is at least n

The facets with area at least n are marked good for printing. This may be useful for approximating a hull. Unless 'PG' is set, 'Pg' is automatically set.

»Pg - print good facets

Qhull can mark facets as "good". This is used to

  • mark the lower convex hull for Delaunay triangulations and Voronoi diagrams
  • mark the facets that are visible from a point (option 'QGn')
  • mark the facets that contain a point (option 'QVn').
  • indicate facets with a large enough area (options 'PAn' and 'PFn')
  • indicate facets with many merges (option 'PMn')

Option 'Pg' only prints good facets that also meet 'Pdk' and 'PDk' options. It is automatically set for options 'd', 'PAn', 'PFn', 'PMn', 'QGn', and 'QVn'.

»PG - print neighbors of good facets

Option 'PG' can be used with or without option 'Pg' to print the neighbors of good facets. For example, options 'QGn' and 'QVn' print the horizon facets for point n.

»PMn - keep n facets with most merges

The n facets with the most merges are marked good for printing. This may be useful for approximating a hull. Unless 'PG' is set, 'Pg' is automatically set.

Use option 'Fm' to print merges per facet.

»Po - force output despite precision problems

Use options 'Po' and 'Q0' if you can not merge facets, triangulate the output ('Qt'), or joggle the input (QJ).

Option 'Po' can not force output when duplicate ridges or duplicate facets occur. It may produce erroneous results. For these reasons, merged facets, joggled input, or exact arithmetic are better.

If you need a simplicial Delaunay triangulation, use joggled input 'QJ' or triangulated output 'Ft'.

Option 'Po' may be used without 'Q0' to remove some steps from Qhull or to output the neighborhood of an error.

Option 'Po' may be used with option 'Q5') to skip qh_check_maxout (i.e., do not determine the maximum outside distance). This can save a significant amount of time.

If option 'Po' is used,

  • most precision errors allow Qhull to continue.
  • verify ('Tv') does not check coplanar points.
  • points are not partitioned into flipped facets and a flipped facet is always visible to a point. This may delete flipped facets from the output.

»Po - if error, output neighborhood of facet

If an error occurs before the completion of Qhull and tracing is not active, 'Po' outputs a neighborhood of the erroneous facets (if any). It uses the current output options.

See 'Po' - force output despite precision problems.

»Pp - do not report precision problems

With option 'Pp', Qhull does not print statistics about precision problems, and it removes some of the warnings. It removes the narrow hull warning.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qvoronoi.html0000644000176200001440000007022114664417655020506 0ustar liggesusers qvoronoi -- Voronoi diagram Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options

[voronoi]qvoronoi -- Voronoi diagram

The Voronoi diagram is the nearest-neighbor map for a set of points. Each region contains those points that are nearer one input site than any other input site. It has many useful properties and applications. See the survey article by Aurenhammer ['91] and the detailed introduction by O'Rourke ['94]. The Voronoi diagram is the dual of the Delaunay triangulation.

Example: rbox 10 D3 | qvoronoi s o TO result
Compute the 3-d Voronoi diagram of 10 random points. Write a summary to the console and the Voronoi vertices and regions to 'result'. The first vertex of the result indicates unbounded regions.
 
Example: rbox r y c G0.1 D2 | qvoronoi s o TO result
Compute the 2-d Voronoi diagram of a triangle and a small square. Write a summary to the console and Voronoi vertices and regions to 'result'. Report a single Voronoi vertex for cocircular input sites. The first vertex of the result indicates unbounded regions. The origin is the Voronoi vertex for the square.
 
Example: rbox r y c G0.1 D2 | qvoronoi Fv TO result
Compute the 2-d Voronoi diagram of a triangle and a small square. Write a summary to the console and the Voronoi ridges to 'result'. Each ridge is the perpendicular bisector of a pair of input sites. Vertex "0" indicates unbounded ridges. Vertex "8" is the Voronoi vertex for the square.
 
Example: rbox r y c G0.1 D2 | qvoronoi Fi
Print the bounded, separating hyperplanes for the 2-d Voronoi diagram of a triangle and a small square. Note the four hyperplanes (i.e., lines) for Voronoi vertex "8". It is at the origin.

Qhull computes the Voronoi diagram via the Delaunay triangulation. Each Voronoi vertex is the circumcenter of a facet of the Delaunay triangulation. Each Voronoi region corresponds to a vertex (i.e., input site) of the Delaunay triangulation.

Qhull outputs the Voronoi vertices for each Voronoi region. With option 'Fv', it lists all ridges of the Voronoi diagram with the corresponding pairs of input sites. With options 'Fi' and 'Fo', it lists the bounded and unbounded separating hyperplanes. You can also output a single Voronoi region for further processing [see graphics].

Use option 'Qz' if the input is circular, cospherical, or nearly so. It improves precision by adding a point "at infinity," above the corresponding paraboloid.

See Qhull FAQ (local) - Delaunay and Voronoi diagram questions.

The 'qvonoroi' program is equivalent to 'qhull v Qbb'. It disables the following Qhull options: d n v Qbb QbB Qf Qg Qm Qr Qv Qx Qz TR E V Fa FA FC FD FS Ft FV Gt Q0,etc.

Copyright © 1995-2020 C.B. Barber

Voronoi image by KOOK Architecture, Silvan Oesterle and Michael Knauss.


»qvoronoi synopsis

qvoronoi -- compute the Voronoi diagram.
    input (stdin): dimension, number of points, point coordinates
    comments start with a non-numeric character

options (qvoronoi.html):
    Qu   - compute furthest-site Voronoi diagram
    Tv   - verify result: structure, convexity, and in-circle test
    .    - concise list of all options
    -    - one-line description of all options
    -?   - this message
    -V   - version

output options (subset):
    Fi   - separating hyperplanes for bounded regions, 'Fo' for unbounded
    FN   - count and Voronoi vertices for each Voronoi region
    Fv   - Voronoi diagram as Voronoi vertices between adjacent input sites
    G    - Geomview output (2-d only)
    o    - OFF file format (dim, Voronoi vertices, and Voronoi regions)
    p    - Voronoi vertices
    QVn  - Voronoi vertices for input point n, -n if not
    s    - summary of results (default)
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes

examples:
rbox c P0 D2 | qvoronoi s o         rbox c P0 D2 | qvoronoi Fi
rbox c P0 D2 | qvoronoi Fo          rbox c P0 D2 | qvoronoi Fv
rbox c P0 D2 | qvoronoi s Qu Fv     rbox c P0 D2 | qvoronoi Qu Fo
rbox c G1 d D2 | qvoronoi s p       rbox c P0 D2 | qvoronoi s Fv QV0

»qvoronoi input

The input data on stdin consists of:
  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qvoronoi < data.txt), a pipe (e.g., rbox 10 | qvoronoi), or the 'TI' option (e.g., qvoronoi TI data.txt).

For example, this is four cocircular points inside a square. Their Voronoi diagram has nine vertices and eight regions. Notice the Voronoi vertex at the origin, and the Voronoi vertices (on each axis) for the four sides of the square.

rbox s 4 W0 c G1 D2 > data
2 RBOX s 4 W0 c D2
8
-0.4941988586954018 -0.07594397977563715
-0.06448037284989526 0.4958248496365813
0.4911154367094632 0.09383830681375946
-0.348353580869097 -0.3586778257652367
    -1     -1
    -1      1
     1     -1
     1      1

qvoronoi s p < data


Voronoi diagram by the convex hull of 8 points in 3-d:

  Number of Voronoi regions: 8
  Number of Voronoi vertices: 9
  Number of non-simplicial Voronoi vertices: 1

Statistics for: RBOX s 4 W0 c D2 | QVORONOI s p

  Number of points processed: 8
  Number of hyperplanes created: 18
  Number of facets in hull: 10
  Number of distance tests for qhull: 33
  Number of merged facets: 2
  Number of distance tests for merging: 102
  CPU seconds to compute hull (after input): 0.094

2
9
4.217546450968612e-17 1.735507986399734
-8.402566836762659e-17 -1.364368854147395
0.3447488772716865 -0.6395484723719818
1.719446929853986 2.136555906154247e-17
0.4967882915039657 0.68662371396699
-1.729928876283549 1.343733067524222e-17
-0.8906163241424728 -0.4594150543829102
-0.6656840313875723 0.5003013793414868
-7.318364664277155e-19 -1.188217818408333e-16

» qvoronoi outputs

These options control the output of Voronoi diagrams.

 
Voronoi vertices
p
print the coordinates of the Voronoi vertices. The first line is the dimension. The second line is the number of vertices. Each remaining line is a Voronoi vertex.
Fn
list the neighboring Voronoi vertices for each Voronoi vertex. The first line is the number of Voronoi vertices. Each remaining line starts with the number of neighboring vertices. Negative vertices (e.g., -1) indicate vertices outside of the Voronoi diagram. In the circle-in-box example, the Voronoi vertex at the origin has four neighbors.
FN
list the Voronoi vertices for each Voronoi region. The first line is the number of Voronoi regions. Each remaining line starts with the number of Voronoi vertices. Negative indices (e.g., -1) indicate vertices outside of the Voronoi diagram. In the circle-in-box example, the four bounded regions are defined by four Voronoi vertices.
 
 
Voronoi regions
o
print the Voronoi regions in OFF format. The first line is the dimension. The second line is the number of vertices, the number of input sites, and "1". The third line represents the vertex-at-infinity. Its coordinates are "-10.101". The next lines are the coordinates of the Voronoi vertices. Each remaining line starts with the number of Voronoi vertices in a Voronoi region. In 2-d, the vertices are listed in adjacency order (unoriented). In 3-d and higher, the vertices are listed in numeric order. In the circle-in-square example, each bounded region includes the Voronoi vertex at the origin. Lines consisting of 0 indicate coplanar input sites or 'Qz'.
Fi
print separating hyperplanes for inner, bounded Voronoi regions. The first number is the number of separating hyperplanes. Each remaining line starts with 3+dim. The next two numbers are adjacent input sites. The next dim numbers are the coefficients of the separating hyperplane. The last number is its offset. Use 'Tv' to verify that the hyperplanes are perpendicular bisectors. It will list relevant statistics to stderr.
Fo
print separating hyperplanes for outer, unbounded Voronoi regions. The first number is the number of separating hyperplanes. Each remaining line starts with 3+dim. The next two numbers are adjacent input sites on the convex hull. The next dim numbers are the coefficients of the separating hyperplane. The last number is its offset.
 
 
Input sites
Fv
list ridges of Voronoi vertices for pairs of input sites. The first line is the number of ridges. Each remaining line starts with two plus the number of Voronoi vertices in the ridge. The next two numbers are two adjacent input sites. The remaining numbers list the Voronoi vertices. As with option 'o', a 0 indicates the vertex-at-infinity and an unbounded, separating hyperplane. The perpendicular bisector (separating hyperplane) of the input sites is a flat through these vertices. In the circle-in-square example, the ridge for each edge of the square is unbounded.
Fc
list coincident input sites for each Voronoi vertex. The first line is the number of vertices. The remaining lines start with the number of coincident sites and deleted vertices. Deleted vertices indicate highly degenerate input (see'Fs'). A coincident site is assigned to one Voronoi vertex. Do not use 'QJ' with 'Fc'; the joggle will separate coincident sites.
FP
print coincident input sites with distance to nearest site (i.e., vertex). The first line is the number of coincident sites. Each remaining line starts with the point ID of an input site, followed by the point ID of a coincident point, its vertex, and distance. Includes deleted vertices which indicate highly degenerate input (see'Fs'). Do not use 'QJ' with 'FP'; the joggle will separate coincident sites.
 
 
General
s
print summary of the Voronoi diagram. Use 'Fs' for numeric data.
i
list input sites for each Delaunay region. Use option 'Pp' to avoid the warning. The first line is the number of regions. The remaining lines list the input sites for each region. The regions are oriented. In the circle-in-square example, the cocircular region has four edges. In 3-d and higher, report cospherical sites by adding extra points.
G
Geomview output for 2-d Voronoi diagrams.

» qvoronoi controls

These options provide additional control:

Qu
compute the furthest-site Voronoi diagram.
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
QVn
select Voronoi vertices for input site n
Qz
add a point above the paraboloid to reduce precision errors. Use it for nearly cocircular/cospherical input (e.g., 'rbox c | qvoronoi Qz').
Tv
verify result
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
TFn
report progress after constructing n facets
PDk:1
include upper and lower facets in the output. Set k to the last dimension (e.g., 'PD2:1' for 2-d inputs).
f
facet dump. Print the data structure for each facet (i.e., Voronoi vertex).

» qvoronoi graphics

In 2-d, Geomview output ('G') displays a Voronoi diagram with extra edges to close the unbounded Voronoi regions. To view the unbounded rays, enclose the input points in a square.

You can also view individual Voronoi regions in 3-d. To view the Voronoi region for site 3 in Geomview, execute

qvoronoi <data QV3 p | qconvex s G >output

The qvoronoi command returns the Voronoi vertices for input site 3. The qconvex command computes their convex hull. This is the Voronoi region for input site 3. Its hyperplane normals (qconvex 'n') are the same as the separating hyperplanes from options 'Fi' and 'Fo' (up to roundoff error).

See the Delaunay and Voronoi examples for 2-d and 3-d examples. Turn off normalization (on Geomview's 'obscure' menu) when comparing the Voronoi diagram with the corresponding Delaunay triangulation.

»qvoronoi notes

You can simplify the Voronoi diagram by enclosing the input sites in a large square or cube. This is particularly recommended for cocircular or cospherical input data.

See Voronoi graphics for computing the convex hull of a Voronoi region.

Voronoi diagrams do not include facets that are coplanar with the convex hull of the input sites. A facet is coplanar if the last coefficient of its normal is nearly zero (see qh_ZEROdelaunay).

Unbounded regions can be confusing. For example, 'rbox c | qvoronoi Qz o' produces the Voronoi regions for the vertices of a cube centered at the origin. All regions are unbounded. The output is

3
2 9 1
-10.101 -10.101 -10.101
     0      0      0
2 0 1
2 0 1
2 0 1
2 0 1
2 0 1
2 0 1
2 0 1
2 0 1
0

The first line is the dimension. The second line is the number of vertices and the number of regions. There is one region per input point plus a region for the point-at-infinity added by option 'Qz'. The next two lines lists the Voronoi vertices. The first vertex is the infinity vertex. It is indicate by the coordinates -10.101. The second vertex is the origin. The next nine lines list the regions. Each region lists two vertices -- the infinity vertex and the origin. The last line is "0" because no region is associated with the point-at-infinity. A "0" would also be listed for nearly incident input sites.

To use option 'Fv', add an interior point. For example,

rbox c P0 | qvoronoi Fv
20
5 0 7 1 3 5
5 0 3 1 4 5
5 0 5 1 2 3
5 0 1 1 2 4
5 0 6 2 3 6
5 0 2 2 4 6
5 0 4 4 5 6
5 0 8 5 3 6
5 1 2 0 2 4
5 1 3 0 1 4
5 1 5 0 1 2
5 2 4 0 4 6
5 2 6 0 2 6
5 3 4 0 4 5
5 3 7 0 1 5
5 4 8 0 6 5
5 5 6 0 2 3
5 5 7 0 1 3
5 6 8 0 6 3
5 7 8 0 3 5

The output consists of 20 ridges and each ridge lists a pair of input sites and a triplet of Voronoi vertices. The first eight ridges connect the origin ('P0'). The remainder list the edges of the cube. Each edge generates an unbounded ray through the midpoint. The corresponding separating planes ('Fo') follow each pair of coordinate axes.

Options 'Qt' (triangulated output) and 'QJ' (joggled input) are deprecated. They may produce unexpected results. If you use these options, cocircular and cospherical input sites will produce duplicate or nearly duplicate Voronoi vertices. See also Merged facets or joggled input.

»qvoronoi conventions

The following terminology is used for Voronoi diagrams in Qhull. The underlying structure is a Delaunay triangulation from a convex hull in one higher dimension. Facets of the Delaunay triangulation correspond to vertices of the Voronoi diagram. Vertices of the Delaunay triangulation correspond to input sites. They also correspond to regions of the Voronoi diagram. See convex hull conventions, Delaunay conventions, and Qhull's data structures.

  • input site - a point in the input (one dimension lower than a point on the convex hull)
  • point - a point has d+1 coordinates. The last coordinate is the sum of the squares of the input site's coordinates
  • coplanar point - a nearly incident input site
  • vertex - a point on the paraboloid. It corresponds to a unique input site.
  • point-at-infinity - a point added above the paraboloid by option 'Qz'
  • Delaunay facet - a lower facet of the paraboloid. The last coefficient of its normal is clearly negative.
  • Voronoi vertex - the circumcenter of a Delaunay facet
  • Voronoi region - the Voronoi vertices for an input site. The region of Euclidean space nearest to an input site.
  • Voronoi diagram - the graph of the Voronoi regions. It includes the ridges (i.e., edges) between the regions.
  • vertex-at-infinity - the Voronoi vertex that indicates unbounded Voronoi regions in 'o' output format. Its coordinates are -10.101.
  • good facet - a Voronoi vertex with optional restrictions by 'QVn', etc.

»qvoronoi options

qvoronoi -- compute the Voronoi diagram
    http://www.qhull.org

input (stdin):
    first lines: dimension and number of points (or vice-versa).
    other lines: point coordinates, best if one point per line
    comments:    start with a non-numeric character

options:
    Qu   - compute furthest-site Voronoi diagram

Qhull control options:
    Qa   - allow input with fewer or more points than coordinates
    QRn  - random rotation (n=seed, n=0 time, n=-1 time/no rotate)
    Qs   - search all points for the initial simplex
    Qz   - add point-at-infinity to Voronoi diagram

Qhull extra options:
    QGn  - Voronoi vertices if visible from point n, -n if not
    QVn  - Voronoi vertices for input point n, -n if not
    Qw   - allow option warnings
    Q12  - allow wide facets and wide dupridge
    Q14  - merge pinched vertices that create a dupridge

T options:
    TFn  - report summary when n or more facets created
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes
    Ts   - statistics
    Tv   - verify result: structure, convexity, and in-circle test
    Tz   - send all output to stdout

Trace options:
    T4   - trace at level n, 4=all, 5=mem/gauss, -1= events
    Ta   - annotate output with message codes
    TAn  - stop qhull after adding n vertices
     TCn - stop qhull after building cone for point n
     TVn - stop qhull after adding point n, -n for before
    Tc   - check frequently during execution
    Tf   - flush each qh_fprintf for debugging segfaults
    TPn  - turn on tracing when point n added to hull
     TMn - turn on tracing at merge n
     TWn - trace merge facets when width > n

Precision options:
    Cn   - radius of centrum (roundoff added).  Merge facets if non-convex
     An  - cosine of maximum angle.  Merge facets if cosine > n or non-convex
           C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge
    Rn   - randomly perturb computations by a factor of [1-n,1+n]
    Wn   - min facet width for non-coincident point (before roundoff)

Output formats (may be combined; if none, summary to stdout):
    p    - Voronoi vertices
    s    - summary to stderr
    f    - facet dump
    i    - Delaunay regions (use 'Pp' to avoid warning)
    o    - OFF format (dim, Voronoi vertices, and Voronoi regions)

More formats:
    Fc   - count plus coincident points (by Voronoi vertex)
    Fd   - use cdd format for input (homogeneous with offset first)
    FD   - use cdd format for output (offset first)
    FF   - facet dump without ridges
    Fi   - separating hyperplanes for bounded Voronoi regions
    FI   - ID for each Voronoi vertex
    Fm   - merge count for each Voronoi vertex (511 max)
    Fn   - count plus neighboring Voronoi vertices for each Voronoi vertex
    FN   - count and Voronoi vertices for each Voronoi region
    Fo   - separating hyperplanes for unbounded Voronoi regions
    FO   - options and precision constants
    FP   - nearest point and distance for each coincident point
    FQ   - command used for qvoronoi
    Fs   - summary: #int (8), dimension, #points, tot vertices, tot facets,
                    for output: #Voronoi regions, #Voronoi vertices,
                                #coincident points, #non-simplicial regions
                    #real (2), max outer plane and min vertex
    Fv   - Voronoi diagram as Voronoi vertices between adjacent input sites
    Fx   - extreme points of Delaunay triangulation (on convex hull)

Geomview output (2-d only)
    Ga   - all points as dots
     Gp  -  coplanar points and vertices as radii
     Gv  -  vertices as spheres
    Gc   - centrums
    GDn  - drop dimension n in 3-d and 4-d output
    Gh   - hyperplane intersections
    Gi   - inner planes only
     Gn  -  no planes
     Go  -  outer planes only
    Gr   - ridges

Print options:
    PAn  - keep n largest Voronoi vertices by 'area'
    Pdk:n - drop facet if normal[k] <= n (default 0.0)
    PDk:n - drop facet if normal[k] >= n
    PFn  - keep Voronoi vertices whose 'area' is at least n
    Pg   - print good Voronoi vertices (needs 'QGn' or 'QVn')
    PG   - print neighbors of good Voronoi vertices
    PMn  - keep n Voronoi vertices with most merges
    Po   - force output.  If error, output neighborhood of facet
    Pp   - do not report precision problems

    .    - list of all options
    -    - one line descriptions of all options
    -?   - help with examples
    -V   - version

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/rbox.html0000644000176200001440000002302514664417655017604 0ustar liggesusers rbox -- generate point distributions

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • outputs • examples • notes • options


[CONE]rbox -- generate point distributions

rbox generates random or regular points according to the options given, and outputs the points to stdout. The points are generated in a cube, unless 's', 'x', or 'y' are given.

»rbox synopsis

rbox- generate various point distributions.  Default is random in cube.

args (any order, space separated):
  3000    number of random points in cube, lens, spiral, sphere or grid
  D3      dimension 3-d
  c       add a unit cube to the output ('c G2.0' sets size)
  d       add a unit diamond to the output ('d G2.0' sets size)
  l       generate a regular 3-d spiral
  r       generate a regular polygon, ('r s Z1 G0.1' makes a cone)
  s       generate cospherical points
  x       generate random points in simplex, may use 'r' or 'Wn'
  y       same as 'x', plus simplex
  Cn,r,m  add n nearly coincident points within radius r of m points
  Pn,m,r  add point [n,m,r] first, pads with 0

  Ln      lens distribution of radius n.  Also 's', 'r', 'G', 'W'.
  Mn,m,r  lattice (Mesh) rotated by [n,-m,0], [m,n,0], [0,0,r], ...
          '27 M1,0,1' is {0,1,2} x {0,1,2} x {0,1,2}.  Try 'M3,4 z'.
  W0.1    random distribution within 0.1 of the cube's or sphere's surface
  Z0.5 s  random points in a 0.5 disk projected to a sphere
  Z0.5 s G0.6 same as Z0.5 within a 0.6 gap

  Bn      bounding box coordinates, default 0.5
  h       output as homogeneous coordinates for cdd
  n       remove command line from the first line of output
  On      offset coordinates by n
  t       use time as the random number seed (default is command line)
  tn      use n as the random number seed
  z       print integer coordinates, default 'Bn' is 1e+06

»rbox outputs

The format of the output is the following: first line contains the dimension and a comment, second line contains the number of points, and the following lines contain the points, one point per line. Points are represented by their coordinate values.

For example, rbox c 10 D2 generates

2 RBOX c 10 D2
14
-0.4999921736307369 -0.3684622117955817
0.2556053225468894 -0.0413498678629751
0.0327672376602583 -0.2810408135699488
-0.452955383763607 0.17886471718444
0.1792964061529342 0.4346928963760779
-0.1164979223315585 0.01941637230982666
0.3309653464993139 -0.4654278894564396
-0.4465383649305798 0.02970019358182344
0.1711493843897706 -0.4923018137852678
-0.1165843490665633 -0.433157762450313
  -0.5   -0.5
  -0.5    0.5
   0.5   -0.5
   0.5    0.5

»rbox examples

       rbox 10
              10 random points in the unit cube centered  at  the
              origin.

       rbox 10 s D2
              10 random points on a 2-d circle.

       rbox 100 W0
              100 random points on the surface of a cube.

       rbox 1000 s D4
              1000 random points on a 4-d sphere.

       rbox c D5 O0.5
              a 5-d hypercube with one corner at the origin.

       rbox d D10
              a 10-d diamond.

       rbox x 1000 r W0
              100 random points on the surface of a fixed simplex

       rbox y D12
              a 12-d simplex.

       rbox l 10
              10 random points along a spiral

       rbox l 10 r
              10 regular points  along  a  spiral  plus  two  end
              points

       rbox 1000 L10000 D4 s
              1000 random points on the surface of a narrow lens.

           rbox 1000 L100000 s G1e-6
                  1000 random points near the edge of a narrow lens

       rbox c G2 d G3
              a cube with coordinates +2/-2 and  a  diamond  with
              coordinates +3/-3.

       rbox 64 M3,4 z
              a  rotated,  {0,1,2,3} x {0,1,2,3} x {0,1,2,3} lat-
              tice (Mesh) of integer points.

       rbox P0 P0 P0 P0 P0
              5 copies of the origin in 3-d.  Try 'rbox P0 P0  P0
              P0 P0 | qhull QJ'.

       r 100 s Z1 G0.1
              two  cospherical  100-gons plus another cospherical
              point.

       100 s Z1
              a cone of points.

       100 s Z1e-7
              a narrow cone of points with many precision errors.

»rbox notes

Some combinations of arguments generate odd results.

»rbox options

       n      number of points

       Dn     dimension n-d (default 3-d)

       Bn     bounding box coordinates (default 0.5)

       l      spiral distribution, available only in 3-d

       Ln     lens  distribution  of  radius n.  May be used with
              's', 'r', 'G', and 'W'.

       Mn,m,r lattice  (Mesh)  rotated  by  {[n,-m,0],   [m,n,0],
              [0,0,r],  ...}.   Use  'Mm,n'  for a rigid rotation
              with r = sqrt(n^2+m^2).  'M1,0'  is  an  orthogonal
              lattice.   For  example,  '27  M1,0'  is  {0,1,2} x
              {0,1,2} x {0,1,2}.

       s      cospherical points randomly generated in a cube and
              projected to the unit sphere

       x      simplicial  distribution.   It  is fixed for option
              'r'.  May be used with 'W'.

       y      simplicial distribution plus a simplex.   Both  'x'
              and 'y' generate the same points.

       Wn     restrict  points  to distance n of the surface of a
              sphere or a cube

       c      add a unit cube to the output

       c Gm   add a cube with all combinations of +m  and  -m  to
              the output

       d      add a unit diamond to the output.

       d Gm   add a diamond made of 0, +m and -m to the output

       Cn,r,m add n nearly coincident points within radius r of m points

       Pn,m,r add point [n,m,r] to the output first.  Pad coordi-
              nates with 0.0.

       n      Remove the command line from the first line of out-
              put.

       On     offset the data by adding n to each coordinate.

       t      use  time  in  seconds  as  the  random number seed
              (default is command line).

       tn     set the random number seed to n.

       z      generate integer coordinates.  Use 'Bn'  to  change
              the  range.   The  default  is 'B1e6' for six-digit
              coordinates.  In R^4, seven-digit coordinates  will
              overflow hyperplane normalization.

       Zn s   restrict points to a disk about the z+ axis and the
              sphere (default Z1.0).  Includes the opposite pole.
              'Z1e-6'  generates  degenerate  points under single
              precision.

       Zn Gm s
              same as Zn with an empty center (default G0.5).

       r s D2 generate a regular polygon

       r s Z1 G0.1
              generate a regular cone

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • outputs • examples • notes • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: August 12, 1998

geometry/inst/doc/qhull/html/qh--half.gif0000644000176200001440000000475113431000556020010 0ustar liggesusersGIF87addç.=-/HO%#-ZdbQ?qR0^S;D6gE2hTN;BGG•PZLL‰9 \%+'/<>lN..hPHyJJH‰FNOJ91BWƒ.\pX`NNOIGUM8N™o44II‚&B;¡X[@@XC2[:8']eqH8L‹PY\;.X_l)TKK‡eo|$.%HJO}84‰@CSSSQQQ¡YkMMM‹k”jRcmO1WgLKLSHI‰i’dEMOg'h7/BBfpR0>>7JJ…7:0IBd48‘RW43#¢Zk$5'-19D`'=AgK46OS*-u&LHHGF?Og;4€bˆ9UYWKzvZ~EEQ™TeFG}FHH362-<,–SXBBo.3#rS1‰HUXO?=JVžVYA,Z*6,`@)MMŠ`T@EBaAOS<=7-0[[\Ž-g+.{JJ€7YRSSG#Y:VY‡=8NOOfK?KMLn9rWN:i-FF|yNK/=-OV] (¢!‹¦Ie^¨:tœQJ\ (òéQ†ˆ-P/\ DuÕeÊHbÊ1É“<`Æâ%kV/k¸bŒFØ·`·Ê:דZ‹ðö4€ WMÙ2sˤ½+ÑÇ&¾ˆ·Ð 'a‡¶DHAŒØ/àË 7Lò†²gÅs òbK³Bxn=S~æ%ôÜ­¦~UýÙu/bDC[µeÑ€aë¨ÁQoÕ"øð¡CÇ‹' ÃÎ>N¹‹k×®gëÝÇ ê”Gþ¥¸žýZ îºm OYˆ6ò×#©¾‡=åMå˻ФÛ;X)íˆb_XøÁwM1pÄfËaaÙ‘K;ÆÙÇD~שbMlõ‰%…:K< Ïì5Cá5p|ƒf.\׃̡Ɍrœxfƒ 8K=f _VRÄ'Y@0mî‘r )F¦ˆah6Ý[#ÌrB ‘šjø‰ä5‘øáG1!!\ÊqÂ$´,Ó[–Gé‚—Q<æƒg#¨F%'¢–Fã%zwíHÙ†ƒà`†žG¶y*^òGØ“|9²ÈÇ5B¢[ÂÑ(a4<3`{Ú`JŠ^^xלŸ"f:%𩤗þÎ&hªomPN dx£ ’‘€ãe ¥©Õ­b­p†.5Ô Ë)₯~€W4 A¬Xf(›,²? Ó´à€ÉoׂµÚj«K9ç€[Z³; :ÛÖ«Kx,mœ\‘Sn ›.²gÜ`‰—ÑNÁU ”»A:GüÃ.XrŽ—àÀAS980dª Ðñ¶=P1¾‚“ žB“±HkÀ'{F&[Å’à`’E È0ÌкL:É&ì‰XGN_¬ÅmÜ‘ˆÈ”D,þ¦J¯ÒIg`òÓÄq 8Z€s$d‘EŽ09Ðð§ìv²ìDGþÙ{ÇÁZhAÛ´QЏ/ÙЧö}ÀÎÝÊ&R6ß“_8„³ÝB“/³}jLy 6ŒMùÞÇh昳E&»sà!1ë  v:7˜NöÞ¢Š&™ÐÆÝR±xÜ›œ(Ñ0(qw({Oþ»ÉWXŒ*m@BøÑÜq"K ƒò Ã5 '¸C=õF<6Ù÷Ý·Éç(N/æšh°Á%Š{G<^‘½…‹˜ßü:P=‘¡ “ÓÞþ €ÿõ"s æx òk%žS`<ÞÁ@k傯ßô&8½3$+¦Ó`ã ‡ÿýoþS@ JXÀ̬f*T!§ Îpz†Êq (äPF8|Ø‹~¢DŒF&¾±æ%1+l„ôœ(CêAñ»ÈŸïö7„rñƒ½XÂXB^ %1(ÄW\@±4D4<à<àsä[ìˆG<ÎÁ$âU24’†dãüŒ s┇H#ñ ·Ó¹bJ[¬äÿAŒO€X‰,LÀŒO*ð‡” )M‰Êbž²ÄYÙ°€…3Ý1Á81†A" à|*±… ^Æ_³¤ô€1ÇYÌ4Ò Ì¬E%&!Ë9 cšÄ¸B&9ÇŒ ¿þŒáôILrú ÀA-Ò‰…JãdÄ;ß9k”ð]/I3%ƒŸþÌ( 0p‚ 5h'q€…ƒzàE6 “ 0c¥ Qhull control options (Q)

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull control options (Q)

This section lists the control options for Qhull. These options are indicated by 'Q' followed by a letter.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Qhull control options

Qa
allow input with fewer or more points than coordinates
Qc
keep coplanar points with nearest facet
Qi
keep interior points with nearest facet
QJ
joggled input to avoid precision problems
Qt
triangulated output
Qu
compute upper hull for furthest-site Delaunay triangulation
Qw
allow warnings about Qhull options
 
 
Precision handling
Qbb
scale last coordinate to [0,m] for Delaunay
Qs
search all points for the initial simplex
Qv
test vertex neighbors for convexity
Qx
exact pre-merges (allows coplanar facets)
Qz
add a point-at-infinity for Delaunay triangulations
 
 
Transform input
Qbk:n
scale coord[k] to low bound of n (default -0.5)
Qbk:0Bk:0
drop dimension k from input
QbB
scale input to fit the unit cube
QBk:n
scale coord[k] to upper bound of n (default 0.5)
QRn
random rotation (n=seed, n=0 time, n=-1 time/no rotate)
 
 
Select facets
Qg
only build good facets (needs 'QGn', 'QVn', or 'Pdk')
QGn
good facet if visible from point n, -n for not visible
QVn
good facet if it includes point n, -n if not
 
 
Experimental
Qf
partition point to furthest outside facet
Qm
process points only if they would increase the max. outer plane
Qr
process random outside points instead of furthest one
Q0
do not pre-merge facets with 'C-0' or 'Qx'
Q1
merge by mergetype/angle instead of mergetype/distance
Q2
merge all non-convex at once instead of independent sets
Q3
do not merge redundant vertices
Q4
avoid merging old facets into new facets
Q5
do not correct outer planes at end of qhull
Q6
do not pre-merge concave or coplanar facets
Q7
process facets depth-first instead of breadth-first
Q8
ignore near-interior points
Q9
process furthest of furthest points
Q10
no special processing for narrow distributions
Q11
copy normals and recompute centrums for tricoplanar facets
Q12
allow wide facets and wide dupridge
Q14
merge pinched vertices that create a dupridge
Q15
check for duplicate ridges with the same vertices

»Qa - allow input with fewer or more points than coordinates

Option 'Qa' (qh.ALLOWshort) allows input with fewer or more points than coordinates. Qhull's input starts with the number of points and the dimension, d. The coordinates follow, d coordinates per point.

With option 'Qa', there may be fewer or more points than coordinates. This simplifies exploring an input point set by adjusting the number of points.

»Qbb - scale the last coordinate to [0,m] for Delaunay

After scaling with option 'Qbb', the lower bound of the last coordinate will be 0 and the upper bound will be the maximum width of the other coordinates. Scaling happens after projecting the points to a paraboloid and scaling other coordinates.

Option 'Qbb' is automatically set for qdelaunay and qvoronoi. Option 'Qbb' is automatically set for joggled input 'QJ'.

Option 'Qbb' should be used for Delaunay triangulations with integer coordinates. Since the last coordinate is the sum of squares, it may be much larger than the other coordinates. For example, rbox 10000 D2 B1e8 | qhull d has precision problems while rbox 10000 D2 B1e8 | qhull d Qbb is OK.

»QbB - scale the input to fit the unit cube

After scaling with option 'QbB', the lower bound will be -0.5 and the upper bound +0.5 in all dimensions. For different bounds change qh_DEFAULTbox in user.h (0.5 is best for Geomview).

For Delaunay and Voronoi diagrams, scaling happens after projection to the paraboloid. Under precise arithmetic, scaling does not change the topology of the convex hull. Scaling may reduce precision errors if coordinate values vary widely.

»Qbk:n - scale coord[k] to low bound

After scaling, the lower bound for dimension k of the input points will be n. 'Qbk' scales coord[k] to -0.5.

»QBk:n - scale coord[k] to upper bound

After scaling, the upper bound for dimension k of the input points will be n. 'QBk' scales coord[k] to 0.5.

»Qbk:0Bk:0 - drop dimension k from the input points

Drop dimension k from the input points. For example, 'Qb1:0B1:0' deletes the y-coordinate from all input points. This allows the user to take convex hulls of sub-dimensional objects. It happens before the Delaunay and Voronoi transformation. It happens after the halfspace transformation for both the data and the feasible point.

»Qc - keep coplanar points with nearest facet

During construction of the hull, a point is coplanar if it is between 'Wn' above and 'Un' below a facet's hyperplane. A different definition is used for output from Qhull.

For output, a coplanar point is above the minimum vertex (i.e., above the inner plane). With joggle ('QJ'), a coplanar point includes points within one joggle of the inner plane.

With option 'Qc', output formats 'p', 'f', 'Gp', 'Fc', 'FN', and 'FP' will print the coplanar points. With options 'Qc Qi' these outputs include the interior points.

For Delaunay triangulations (qdelaunay or qvoronoi), a coplanar point is a point that is nearly incident to a vertex. All input points are either vertices of the triangulation or coplanar.

Qhull stores coplanar points with a facet. While constructing the hull, it retains all points within qh_RATIOnearInside (user.h) of a facet. In qh_check_maxout(), it uses these points to determine the outer plane for each facet. With option 'Qc', qh_check_maxout() retains points above the minimum vertex for the hull. Other points are removed. If qh_RATIOnearInside is wrong or if options 'Q5 Q8' are set, a coplanar point may be missed in the output (see Qhull limitations).

»Qf - partition point to furthest outside facet

After adding a new point to the convex hull, Qhull partitions the outside points and coplanar points of the old, visible facets. Without the 'f' option and merging, it assigns a point to the first facet that it is outside ('Wn'). When merging, it assigns a point to the first facet that is more than several times outside (see qh_DISToutside in user.h).

If option 'Qf' is selected, Qhull performs a directed search (no merging) or an exhaustive search (merging) of new facets. Option 'Qf' may reduce precision errors if pre-merging does not occur.

Option 'Q9' processes the furthest of all furthest points.

»Qg - only build good facets (needs 'QGn' 'QVn' or 'Pdk')

Qhull has several options for defining and printing good facets. With the 'Qg' option, Qhull will only build those facets that it needs to determine the good facets in the output. Outside points that are not above good facets are ignored. This may speed up Qhull in 2-d and 3-d. It is useful for furthest-site Delaunay triangulations (qdelaunay Qu, invoke with 'qhull d Qbb Qu Qg'). It is not effective in higher dimensions because many facets see a given point and contain a given vertex. It may not work for all combinations of options.

See 'QGn', 'QVn', and 'Pdk' for defining good facets, and 'Pg' and 'PG' for printing good facets and their neighbors. If pre-merging ('C-n') is not used and there are coplanar facets, then 'Qg Pg' may produce a different result than 'Pg'.

Option Qg disables renaming vertices due to duplicate ridges. See ('Q14' merge-pinched-vertices).

»QGn - good facet if visible from point n, -n for not visible

With option 'QGn', a facet is good (see 'Qg' and 'Pg') if it is visible from point n. If n < 0, a facet is good if it is not visible from point n. Point n is not added to the hull (unless 'TCn' or 'TPn').

With rbox, use the 'Pn,m,r' option to define your point; it will be point 0 ('QG0').

»Qi - keep interior points with nearest facet

Normally Qhull ignores points that are clearly interior to the convex hull. With option 'Qi', Qhull treats interior points the same as coplanar points. Option 'Qi' does not retain coplanar points. You will probably want 'Qc' as well.

Option 'Qi' is automatically set for 'qdelaunay Qc' and 'qvoronoi Qc'. If you use 'qdelaunay Qi' or 'qvoronoi Qi', option 's' reports all nearly incident points while option 'Fs' reports the number of interior points (should always be zero).

With option 'Qi', output formats 'p', 'f','Gp', 'Fc', 'FN', and 'FP' include interior points.

»QJ or QJn - joggled input to avoid precision errors

Option 'QJ' or 'QJn' joggles each input coordinate by adding a random number in the range [-n,n]. If a precision error occurs, It tries again. If precision errors still occur, Qhull increases n ten-fold and tries again. The maximum value for increasing n is 0.01 times the maximum width of the input. Option 'QJ' selects a default value for n. The header file user_r.h defines these parameters and a maximum number of retries. See Merged facets or joggled input.

On repeated joggles, Qhull errors (QH6010) if the joggle is greater than 0.1 or one quarter of the maximum coordinate width.

Users of joggled input should consider converting to triangulated output ('Qt'). Triangulated output is approximately 1000 times more accurate than joggled input.

Option 'QJ' also sets 'Qbb' for Delaunay triangulations and Voronoi diagrams. It does not set 'Qbb' if 'Qbk:n' or 'QBk:n' are set.

If 'QJn' is set, Qhull does not merge facets unless requested to. All facets are simplicial (triangular in 2-d). This may be important for your application. You may also use triangulated output ('Qt') or Option 'Ft'.

Qhull adjusts the outer and inner planes for 'QJn' ('Fs'). They are increased by sqrt(d)*n to account for the maximum distance between a joggled point and the corresponding input point.

Coplanar points ('Qc', option '_near-inside') require an additional sqrt(d)*n since vertices and coplanar points may be joggled in opposite directions.

For Delaunay triangulations (qdelaunay), joggle happens before lifting the input sites to a paraboloid. Instead of 'QJ', you may use triangulated output ('Qt')

This option is deprecated for Voronoi diagrams (qvoronoi). It triangulates cospherical points, leading to duplicated Voronoi vertices.

By default, 'QJn' uses a fixed random number seed. To use time as the random number seed, select 'QR-1'. The summary ('s') will show the selected seed as 'QR-n'.

With 'QJn', Qhull does not error on degenerate hyperplane computations. Except for Delaunay and Voronoi computations, Qhull does not error on coplanar points.

Use option 'FO' to display the selected options. Option 'FO' displays the joggle and the joggle seed. If Qhull restarts, it will redisplay the options.

Use option 'TRn' to estimate the probability that Qhull will fail for a given 'QJn'.

If your application incrementally adds points with qh_addpoint, facet merging for precision problems is disabled by default. You can reduce the probability of failure by joggling the point's coordinates before calling qh_addpoint. See qh_joggleinput for sample code.

»Qm - only process points that increase the maximum outer plane

Qhull reports the maximum outer plane in its summary ('s'). With option 'Qm', Qhull does not process points that are below the current, maximum outer plane. This is equivalent to always adjusting 'Wn ' to the maximum distance of a coplanar point to a facet. It is ignored for points above the upper convex hull of a Delaunay triangulation. Option 'Qm' is no longer important for merging.

»Qr - process random outside points instead of furthest ones

Normally, Qhull processes the furthest point of a facet's outside points. Option 'Qr' instead selects a random outside point for processing. This makes Qhull equivalent to the randomized incremental algorithms.

The original randomization algorithm by Clarkson and Shor ['89] used a conflict list which is equivalent to Qhull's outside set. Later randomized algorithms retained the previously constructed facets.

To compare Qhull to the randomized algorithms with option 'Qr', compare "hyperplanes constructed" and "distance tests". Qhull does not report CPU time because the randomization is inefficient.

»QRn - random rotation

Option 'QRn' randomly rotates the input. For Delaunay triangulations (qdelaunay or qvoronoi), it rotates the lifted points about the last axis.

If n=0, use time as the random number seed. If n>0, use n as the random number seed. If n=-1, don't rotate but use time as the random number seed. If n<-1, don't rotate but use n as the random number seed.

If set, the summary option ('s') displays the corresponding 'QRn' option after "Statistics for: ..."

»Qs - search all points for the initial simplex

Qhull constructs an initial simplex from d+1 points. It selects points with the maximum and minimum coordinates and non-zero determinants. If this fails, it searches all other points. In 8-d and higher, Qhull selects points with the minimum x or maximum coordinate (see qh_initialvertices in poly2.c ). It rejects points with nearly zero determinants. This should work for almost all input sets.

If Qhull can not construct an initial simplex, it reports a descriptive message. Usually, the point set is degenerate and one or more dimensions should be removed ('Qbk:0Bk:0'). If not, use option 'Qs'. It performs an exhaustive search for the best initial simplex. This is expensive is high dimensions.

»Qt - triangulated output

By default, qhull merges facets to handle precision errors. This produces non-simplicial facets (e.g., the convex hull of a cube has 6 square facets). Each facet is non-simplicial because it has four vertices.

Use option 'Qt' to triangulate all non-simplicial facets before generating results. Alternatively, use joggled input ('QJ') to prevent non-simplical facets. Unless 'Pp' is set, qhull produces a warning if 'QJ' and 'Qt' are used together.

For Delaunay triangulations (qdelaunay), triangulation occurs after lifting the input sites to a paraboloid and computing the convex hull.

Option 'Qt' is deprecated for Voronoi diagrams (qvoronoi). It triangulates cospherical points, leading to duplicated Voronoi vertices.

Option 'Qt' may produce degenerate facets with zero area.

Facet area and hull volumes may differ with and without 'Qt'. The triangulations are different and different triangles may be ignored due to precision errors.

With sufficient merging, the ridges of a non-simplicial facet may share more than two neighboring facets. If so, their triangulation ('Qt') will fail since two facets have the same vertex set.

»Qu - compute upper hull for furthest-site Delaunay triangulation

When computing a Delaunay triangulation (qdelaunay or qvoronoi), Qhull computes both the the convex hull of points on a paraboloid. It normally prints facets of the lower hull. These correspond to the Delaunay triangulation. With option 'Qu', Qhull prints facets of the upper hull. These correspond to the furthest-site Delaunay triangulation and the furthest-site Voronoi diagram.

Option 'qhull d Qbb Qu Qg' may improve the speed of option 'Qu'. If you use the Qhull library, a faster method is 1) use Qhull to compute the convex hull of the input sites; 2) take the extreme points (vertices) of the convex hull; 3) add one interior point (e.g., 'FV', the average of d extreme points); 4) run 'qhull d Qbb Qu' or 'qhull v Qbb Qu' on these points.

»Qv - test vertex neighbors for convexity

Normally, Qhull tests all facet neighbors for convexity. Non-neighboring facets which share a vertex may not satisfy the convexity constraint. This occurs when a facet undercuts the centrum of another facet. They should still be convex. Option 'Qv' extends Qhull's convexity testing to all neighboring facets of each vertex. The extra testing occurs after the hull is constructed..

»QVn - good facet if it includes point n, -n if not

With option 'QVn', a facet is good ('Qg', 'Pg') if one of its vertices is point n. If n<0, a good facet does not include point n.

If options 'PG' and 'Qg' are not set, option 'Pg' (print only good) is automatically set.

Option 'QVn' behaves oddly with options 'Fx' and 'qvoronoi Fv'.

If used with option 'Qg' (only process good facets), point n is either in the initial simplex or it is the first point added to the hull. Options 'QVn Qg' require either 'QJ' or 'Q0' (no merging).

»Qw - allow warnings about Qhull options

Option 'Qw' allows warning about unknown, malformed, or incompatible Qhull options. If 'Qw' is not specified, option warnings produce a 'Qhull option error' and return exit status qh_ERRinput (1).

»Qx - exact pre-merges (allows coplanar facets)

Option 'Qx' performs exact merges while building the hull. Options 'Qx' and 'C-0' are set by default in 5-d and higher. To disable this default, set option 'C-0' or another pre-merge option. Use option 'Q0' to disable all merging, including 'Qx' and 'C-0'.

The "exact" pre-merges are merging a point into a coplanar horizon facet (defined by 'Vn', 'Un', and 'C-n'), merging concave facets, merging duplicate ridges, and merging flipped facets. Coplanar merges and angle coplanar merges ('A-n') are not performed. Superfluous vertices are allowed. Concavity testing is delayed until a merge occurs.

After the hull is built, all coplanar merges are performed (defined by 'C-n' and 'A-n'), then post-merges are performed (defined by 'Cn' and 'An'). Superfluous vertices are removed.

If facet progress is logged ('TFn'), Qhull reports each phase and prints intermediate summaries and statistics ('Ts').

Without 'Qx' in 5-d and higher, options 'C-n' and 'A-n' may merge too many facets. Facets become increasingly wide.

Option 'Qx' may report a wide facet. With 'Qx', coplanar facets are not merged. This can produce a "dent" in an intermediate hull. If a point is partitioned into a dent and it is below the surrounding facets but above other facets, one or more wide facets will occur. In practice, this is unlikely. To observe this effect, run Qhull with option 'Q6' which doesn't pre-merge concave facets. A concave facet makes a large dent in the intermediate hull.

Option 'Qx' may set an outer plane below one of the input points. A coplanar point may be assigned to the wrong facet because of a "dent" in an intermediate hull. After constructing the hull, Qhull double checks all outer planes with qh_check_maxout in poly2.c . If a coplanar point is assigned to the wrong facet, qh_check_maxout may reach a local maximum instead of locating all coplanar facets. This appears to be unlikely.

»Qz - add a point-at-infinity for Delaunay triangulations

Option 'Qz' adds a point above the paraboloid of lifted sites for a Delaunay triangulation. It allows the Delaunay triangulation of cospherical sites. It reduces precision errors for nearly cospherical sites.

»Q0 - no merging with C-0 and Qx

Turn off default merge options 'C-0' and 'Qx'.

With 'Q0' and without other pre-merge options, Qhull ignores precision issues while constructing the convex hull. This may lead to precision errors. If so, a descriptive warning is generated. See Precision issues.

»Q1 - merge by mergetype/angle instead of mergetype/distance

Qhull merges coplanar facets first, then concave and flipped facets. Within a merge-type, it merges coplanar facets by distance first.

With option 'Q1', Qhull merges coplanar facets by angle instead of by distance.

»Q2 - merge all non-convex at once instead of independent sets

With 'Q2', Qhull merges all facets at once instead of performing merges in independent sets. This may make the facets wider.

»Q3 - do not merge redundant vertices

With 'Q3', Qhull does not remove redundant vertices. In 6-d and higher, Qhull never removes redundant vertices (since vertices are highly interconnected). Option 'Q3' may be faster, but it may result in wider facets. Its effect is easiest to see in 3-d and 4-d.

»Q4 - avoid merging old facets into new facets

With 'Q4', Qhull avoids merges of an old facet into a new facet. This sometimes improves facet width and sometimes makes it worse. See qh_merge_nonconvex. It is not supported for qh_merge_twisted.

»Q5 - do not correct outer planes at end of qhull

When merging facets or approximating a hull, Qhull tests coplanar points and outer planes after constructing the hull. It does this by performing a directed search (qh_findbest in geom.c). It includes points that are just inside the hull.

With options 'Q5' or 'Po', Qhull does not test outer planes. The maximum outer plane is used instead. Coplanar points ('Qc') are defined by 'Un'. An input point may be outside of the maximum outer plane (this appears to be unlikely). An interior point may be above 'Un' from a hyperplane.

Option 'Q5' may be used if outer planes are not needed. Outer planes are needed for options 's', 'G', 'Go', 'Fs', 'Fo', 'FF', and 'f'.

»Q6 - do not pre-merge concave or coplanar facets

With 'Q6', Qhull does not pre-merge concave or coplanar facets. This demonstrates the effect of "dents" when using 'Qx'.

»Q7 - depth-first processing instead of breadth-first

With 'Q7', Qhull processes facets in depth-first order instead of breadth-first order. This may increase the locality of reference in low dimensions. If so, Qhull may be able to use virtual memory effectively.

In 5-d and higher, many facets are visible from each unprocessed point. So each iteration may access a large proportion of allocated memory. This makes virtual memory ineffectual. Once real memory is used up, Qhull will spend most of its time waiting for I/O.

Under 'Q7', Qhull runs slower and the facets may be wider.

»Q8 - ignore near-interior points

With 'Q8' and merging, Qhull does not process interior points that are near to a facet (as defined by qh_RATIOnearInside in user.h). This avoids partitioning steps. It may miss a coplanar point when adjusting outer hulls in qh_check_maxout(). The best value for qh_RATIOnearInside is not known. Options 'Q8 Qc' may be sufficient.

»Q9 - process furthest of furthest points

With 'Q9', Qhull processes the furthest point of all outside sets. This may reduce precision problems. The furthest point of all outside sets is not necessarily the furthest point from the convex hull.

»Q10 - no special processing for narrow distributions

With 'Q10', Qhull does not special-case narrow distributions. See Limitations of merged facets for more information.

»Q11 - copy normals and recompute centrums for tricoplanar facets

Option 'Qt' triangulates non-simplicial facets into "tricoplanar" facets. Normally tricoplanar facets share the same normal, centrum, and Voronoi vertex. They can not be merged or replaced. With option 'Q11', Qhull duplicates the normal and Voronoi vertex. It recomputes the centrum.

Use 'Q11' if you use the Qhull library to add points incrementally and call qh_triangulate() after each point. Otherwise, Qhull will report an error when it tries to merge and replace a tricoplanar facet.

With sufficient merging and new points, option 'Q11' may lead to precision problems such as duplicate ridges and concave facets. For example, if qh_triangulate() is added to qh_addpoint(), RBOX 1000 s W1e-12 t1001813667 P0 | QHULL d Q11 Tv, reports an error due to a duplicate ridge.

»Q12 - allow wide facets and wide dupridge

Option 'Q12' (qh.ALLOWwide) disables error exits due to wide facets and wide dupridge. With 'Q12', Qhull may produce arbitrarily wide facets. A facet is 'wide' if there is a wide gap between its outer plane (f.maxoutside above all points) and its inner plane (below its vertices). A wide facet is typically due to multiple topological and geometric problems that Qhull cannot resolve. As Qhull merges facets, they become increasingly wide, making further problems more likely.

A 'dupridge' is a ridge with more than two neighboring facets. A dupridge is a loop in the facet topology. A convex hull should never have dupridges, but with imprecise arithmetic, they may occur. Dupridges may occur in 3-D and higher. They are more likely for nearly adjacent points in 4-D and higher.

Qhull handles dupridges by merging all but one pair of facets (qh_matchdupridge in poly2_r.c) or by dropping one of its vertices as a coplanar point (qh_getpinchedmerges in merge_r.c). If vertices are too far apart and a merge would produce an wide facet, qh_check_dupridge reports an error. The corresponding error exit is disabled by 'Q12'.

To demonstrate the problem, use rbox option 'Cn,r,m' to generate nearly adjacent points. For Delaunay triangulations, a bounding box may alleviate this error (e.g., rbox 500 C1,1E-13 c G1 | qhull d). This avoids the ill-defined edge between upper and lower convex hulls. For more information, see "Nearly adjacent vertices within 1e-13" in Limitations of merged facets.

Errors disabled by 'Q12' return an error status of qh_ERRwide (8). Wide facets are defined by constants in user_r.h (qh_WIDE... and qh_RATIO...).

»Q14 - merge pinched vertices due to a dupridge

A ridge in Qhull is the d-1 simplex between two neighboring facets. For example in 3-d, a ridge is the edge shared by two neighboring polygons. With non-simplicial facets, Qhull may create a "dupridge", a ridge with four or more neighboring facets. In effect, the surface of the convex hull forms a loop that crosses itself at the dupridge. Qhull resolves a dupridge by merging a pair of facets. With experimental option, 'Q14' it may resolve a dupridge by merging a pair of vertices.

In 3-d and higher, nearly adjacent vertices may lead to dupridges (see "Nearly adjacent vertices within 1e-13" in Imprecision in Qhull). With option 'Q14', Qhull merges nearly adjacent vertices when they create a dupridge.

»Q15 - check for duplicate ridges with the same vertices

Option 'Q15' (qh.CHECKduplicates) checks for duplicate ridges after each merge (qh_maybe_duplicateridges, qh_checkfacet). Duplicate ridges have the same vertices. It is a topological error for convex hulls. Qhull resolves a duplicate ridge by merging vertices and partitioning the deleted vertex as a coplanar point (qh_renamevertex).

Option 'Q15' does not prevent duplicate ridges for non-neighboring facets, nor does it prevent other topological errors such as inconsistent facet orientation. Resolving a duplicate ridge may itself lead to topological errors and wide facets.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qhalf.html0000644000176200001440000007167614664417655017744 0ustar liggesusers qhalf -- halfspace intersection about a point

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


[halfspace]qhalf -- halfspace intersection about a point

The intersection of a set of halfspaces is a polytope. The polytope may be unbounded. See Preparata & Shamos ['85] for a discussion. In low dimensions, halfspace intersection may be used for linear programming.

Example: rbox c | qconvex FV n | qhalf Fp

Print the intersection of the facets of a cube. rbox c generates the vertices of a cube. qconvex FV returns a feasible point for halfspace intersection. This feasible or interior point, qconvex FV, is the average of the cube's vertices (i.e., the origin). qconvex n returns the halfspaces that define the cube. qhalf Fp computes the intersection of the halfspaces about the feasible point. The intersection is the vertices of the original cube.

Example: rbox c | qconvex FQ n | qhalf H0.1,0.1,0.1

Compute the intersection of the facets of a cube and print a summary ('s'). Option 'FQ' prints the qconvex command as an input comment for the summary. 'qhalf Hn,n,n' specifies the feasible point as [0.1, 0.1, 0.1]. 'qhalf H0' would specify the feasible point as the origin.

Example: rbox c d G0.55 | qconvex FQ FV n | qhalf Fp

Print the intersection of the facets of a cube and a diamond. There are 24 facets and 14 intersection points. Four facets define each diamond vertex. Six facets define each cube vertex.

Example: rbox c d G0.55 | qconvex FQ FV n | qhalf Fp Qt

Same as above except triangulate before computing the intersection points. Three facets define each intersection point. There are two duplicates of the diamond and four duplicates of the cube.

Example: rbox 10 s t10 | qconvex FQ FV n | qhalf Fp Fn

Print the intersection of the facets of the convex hull of 10 cospherical points. Include the intersection points and the neighboring intersections. As in the previous examples, the intersection points are nearly the same as the original input points.

In Qhull, a halfspace is defined by the points on or below a hyperplane. The distance of each point to the hyperplane is less than or equal to zero.

Qhull computes a halfspace intersection by the geometric duality between points and halfspaces. See halfspace examples, qhalf notes, and option 'p' of qhalf outputs.

Qhalf's outputs are the intersection points (Fp) and the neighboring intersection points (Fn). For random inputs, halfspace intersections are usually defined by more than d halfspaces. See the sphere example.

The identity pipeline for Qhull starts with points, produces the halfspaces for their convex hull, and intersects these halfspaces, returning the original points. For example, 'rbox c' is the unit cube.

	rbox c | qconvex FV n | qhalf Fp
	3
	8
	  -0.5    0.5    0.5
	   0.5    0.5    0.5
	  -0.5    0.5   -0.5
	   0.5    0.5   -0.5
	   0.5   -0.5    0.5
	  -0.5   -0.5    0.5
	   0.5   -0.5   -0.5
	  -0.5   -0.5   -0.5

You can try triangulated output ('Qt') and joggled input ('QJ'). It demonstrates that triangulated output is more accurate than joggled input.

If you use 'Qt' (triangulated output), all halfspace intersections are simplicial (e.g., three halfspaces per intersection in 3-d). In 3-d, if more than three halfspaces intersect at the same point, triangulated output will produce duplicate intersections, one for each additional halfspace. See the third example, or add 'Qt' to the sphere example.

If you use 'QJ' (joggled input), all halfspace intersections are simplicial. This may lead to nearly identical intersections. For example, either replace 'Qt' with 'QJ' above, or add 'QJ' to the sphere example. See Merged facets or joggled input.

The 'qhalf' program is equivalent to 'qhull H'. It disables the following Qhull options: d n v Qbb QbB Qf Qg Qm Qr Qv Qx Qz TR E V Fa FA FC FD FS Ft FV Gt Q0,etc.

Copyright © 1995-2020 C.B. Barber


»qhalf synopsis

qhalf -- halfspace intersection about a point.
    input (stdin): [dimension, 1, interior point]
                       dimension+1, number of halfspaces, coefficients+offset
    comments start with a non-numeric character

options:
    Hn,n - specify coordinates of interior point
    Qt   - triangulated output
    QJ   - joggled input instead of merged facets
    Tv   - verify result: structure, convexity, and redundancy
    .    - concise list of all options
    -    - one-line description of each option
    -?   - this message
    -V   - version

output options (subset):
    s    - summary of results (default)
    Fp   - intersection coordinates
    Fv   - non-redundant halfspaces incident to each intersection
    Fx   - non-redundant halfspaces
    G    - Geomview output (dual convex hull)
    m    - Mathematica output (dual convex hull)
    o    - OFF file format (dual convex hull)
    QVn  - print intersections for halfspace n, -n if not
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes

examples:
    rbox d | qconvex FQ n | qhalf s H0,0,0 Fp
    rbox c | qconvex FQ FV n | qhalf s i
    rbox c | qconvex FQ FV n | qhalf s o

»qhalf input

The input data on stdin consists of:

  • [optional] feasible point
    • dimension
    • 1
    • coordinates of feasible point
  • dimension + 1
  • number of halfspaces
  • halfspace coefficients followed by offset

Use I/O redirection (e.g., qhalf < data.txt), a pipe (e.g., rbox c | qconvex FV n | qhalf), or the 'TI' option (e.g., qhalf TI data.txt).

Qhull needs a feasible point to compute the halfspace intersection. A feasible point is clearly inside all of the halfspaces. A point is inside a halfspace if its distance to the corresponding hyperplane is negative.

The feasible point may be listed at the beginning of the input (as shown above). If not, option 'Hn,n' defines the feasible point as [n,n,0,...] where 0 is the default coordinate (e.g., 'H0' is the origin). Use linear programming if you do not know the feasible point (see halfspace notes),

The input to qhalf is a set of halfspaces that are defined by their hyperplanes. Each halfspace is defined by d coefficients followed by a signed offset. This defines a linear inequality. The coefficients define a vector that is normal to the halfspace. The vector may have any length. If it has length one, the offset is the distance from the origin to the halfspace's boundary. Points in the halfspace have a negative distance to the hyperplane. The distance from the feasible point to each halfspace is likewise negative.

The halfspace format is the same as Qhull's output options 'n', 'Fo', and 'Fi'. Use option 'Fd' to use cdd format for the halfspaces.

For example, here is the input for computing the intersection of halfplanes that form a cube.

rbox c | qconvex FQ FV n TO data

RBOX c | QCONVEX FQ FV n
3 1
     0      0      0
4
6
     0      0     -1   -0.5
     0     -1      0   -0.5
     1      0      0   -0.5
    -1      0      0   -0.5
     0      1      0   -0.5
     0      0      1   -0.5

qhalf s Fp < data


Halfspace intersection by the convex hull of 6 points in 3-d:

  Number of halfspaces: 6
  Number of non-redundant halfspaces: 6
  Number of intersection points: 8

Statistics for: RBOX c | QCONVEX FQ FV n | QHALF s Fp

  Number of points processed: 6
  Number of hyperplanes created: 11
  Number of distance tests for qhull: 11
  Number of merged facets: 1
  Number of distance tests for merging: 45
  CPU seconds to compute hull (after input):  0

3
3
8
  -0.5    0.5    0.5
   0.5    0.5    0.5
  -0.5    0.5   -0.5
   0.5    0.5   -0.5
   0.5   -0.5    0.5
  -0.5   -0.5    0.5
  -0.5   -0.5   -0.5
   0.5   -0.5   -0.5

»qhalf outputs

The following options control the output for halfspace intersection.

 
Intersections
FN
list intersection points for each halfspace. The first line is the number of halfspaces. Each remaining line starts with the number of intersection points. Redundant halfspaces have 0 intersection points. For the cube example, each halfspace has four intersection points.
Fn
list neighboring intersections for each intersection point. The first line is the number of intersection points. Each following line starts with the number of neighboring intersections. For the cube example, each intersection point has three neighboring intersections.

In 3-d, a non-simplicial intersection has more than three neighboring intersections. For random data (e.g., the sphere example), non-simplicial intersections are the norm. Option 'Qt' produces three neighboring intersections per intersection by duplicating the intersection points. Option QJ' produces three neighboring intersections per intersection by joggling the hyperplanes and hence their intersections.

Fp
print intersection coordinates. The first line is the dimension and the second line is the number of intersection points. The following lines are the coordinates of each intersection point. The "infinity" point, [-10.101,-10.101,...] (qh_INFINITE), indicates an unbounded intersection.
FI
list intersection IDs. The first line is the number of intersections. The IDs follow, one per line.
 
 
Halfspaces
Fx
list non-redundant halfspaces. The first line is the number of non-redundant halfspaces. The other lines list one halfspace per line. A halfspace is non-redundant if it defines a facet of the intersection. Redundant halfspaces are ignored. For the cube example, none of the halfspaces are redundant.
Fv
list non-redundant halfspaces incident to each intersection point. The first line is the number of non-redundant halfspaces. Each remaining line starts with the number of non-redundant halfspaces incident to that point. For the cube example, each intersection point is incident to three halfspaces.
i
list non-redundant halfspaces incident to each intersection point. The first line is the number of intersection points. Each remaining line lists the incident, non-redundant halfspaces for that intersection point. For the cube example, each intersection point is incident to three halfspaces.
Fc
list coplanar halfspaces for each intersection point. The first line is the number of intersection points. Each remaining line starts with the number of coplanar halfspaces. A coplanar halfspace is listed for one intersection point even though it is coplanar to multiple intersection points.
Qi Fc
list redundant halfspaces for each intersection point. The first line is the number of intersection points. Each remaining line starts with the number of redundant halfspaces. Use options 'Qc Qi Fc' to list coplanar and redundant halfspaces.
 
 
General
s
print summary for the halfspace intersection. Use 'Fs' if you need numeric data.
o
print vertices and facets of the dual convex hull. The first line is the dimension. The second line is the number of vertices, facets, and ridges. The vertex coordinates are next, followed by the facets, one per line.
p
print vertex coordinates of the dual convex hull. Each vertex corresponds to a non-redundant halfspace. Its coordinates are the negative of the hyperplane's coefficients divided by the offset plus the inner product of the coefficients and the feasible point (-c/(b+a.p). Options 'p Qc' includes coplanar halfspaces. Options 'p Qi' includes redundant halfspaces.
m
Mathematica output for the dual convex hull in 2-d or 3-d.
FM
Maple output for the dual convex hull in 2-d or 3-d.
G
Geomview output for the dual convex hull in 2-d, 3-d, or 4-d.

»qhalf controls

These options provide additional control:

Qt
triangulated output. If a 3-d intersection is defined by more than three hyperplanes, Qhull produces duplicate intersections -- one for each extra hyperplane.
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
QJ
joggle the input instead of merging facets. In 3-d, this guarantees that each intersection is defined by three hyperplanes.
f
facet dump. Print the data structure for each intersection (i.e., facet)
TFn
report summary after constructing n intersections
QVn
select intersection points for halfspace n (marked 'good')
QGn
select intersection points that are visible to halfspace n (marked 'good'). Use -n for the remainder.
Qbk:0Bk:0
remove the k-th coordinate from the input. This computes the halfspace intersection in one lower dimension.
Tv
verify result
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
Qs
search all points for the initial simplex. If Qhull can not construct an initial simplex, it reports a descriptive message. Usually, the point set is degenerate and one or more dimensions should be removed ('Qbk:0Bk:0'). If not, use option 'Qs'. It performs an exhaustive search for the best initial simplex. This is expensive is high dimensions.

»qhalf graphics

To view the results with Geomview, compute the convex hull of the intersection points ('qhull FQ H0 Fp | qhull G'). See Halfspace examples.

»qhalf notes

See halfspace intersection for precision issues related to qhalf.

If you do not know a feasible point for the halfspaces, use linear programming to find one. Assume, n halfspaces defined by: aj*x1+bj*x2+cj*x3+dj<=0, j=1..n. Perform the following linear program:

max(x5) aj*x1+bj*x2+cj*x3+dj*x4+x5<=0, j=1..n

Then, if [x1,x2,x3,x4,x5] is an optimal solution with x4>0 and x5>0 we get:

aj*(x1/x4)+bj*(x2/x4)+cj*(x3/x4)+dj<=(-x5/x4) j=1..n and (-x5/x4)<0,

and conclude that the point [x1/x4,x2/x4,x3/x4] is inside all the halfspaces. Since x5 is optimal, this feasible point is "clearly inside" the halfspaces (good for precision errors).

After finding a feasible point, the rest of the intersection algorithm is from Preparata & Shamos ['85, p. 316, "A simple case ..."]. Translate the halfspaces so that the feasible point is the origin. Calculate the dual polytope. The dual polytope is the convex hull of the vertices dual to the original faces in regard to the unit sphere (i.e., halfspaces at distance d from the origin are dual to vertices at distance 1/d). Then calculate the resulting polytope, which is the dual of the dual polytope, and translate the origin back to the feasible point [S. Spitz, S. Teller, D. Strawn].

»qhalf conventions

The following terminology is used for halfspace intersection in Qhull. This is the hardest structure to understand. The underlying structure is a convex hull with one vertex per non-redundant halfspace. See convex hull conventions and Qhull's data structures.

  • feasible or interior point - a point in the intersection of the halfspaces. Qhull needs a feasible point to compute the intersection. See halfspace input.
  • halfspace - d coordinates for the normal and a signed offset. The distance to the feasible point is negative.
  • non-redundant halfspace - a halfspace that defines an output facet
  • vertex - a dual vertex in the convex hull corresponding to a non-redundant halfspace
  • coplanar point - the dual point corresponding to a similar halfspace
  • interior point - the dual point corresponding to a redundant halfspace
  • intersection point- the intersection of d or more non-redundant halfspaces
  • facet - a dual facet in the convex hull corresponding to an intersection point
  • non-simplicial facet - more than d halfspaces intersect at a point
  • good facet - an intersection point that satisfies restriction 'QVn', etc.

»qhalf options

qhalf -- compute the intersection of halfspaces about a point
    http://www.qhull.org

input (stdin):
    optional interior point: dimension, 1, coordinates
    first lines: dimension+1 and number of halfspaces
    other lines: halfspace coefficients followed by offset
    comments:    start with a non-numeric character

options:
    Hn,n - specify coordinates of interior point
    Qc   - keep coplanar halfspaces
    Qi   - keep other redundant halfspaces
    QJ   - joggled input instead of merged facets
    Qt   - triangulated output

Qhull control options:
    Qa   - allow input with fewer or more points than coordinates
    Qbk:0Bk:0 - remove k-th coordinate from input
    QJn  - randomly joggle input in range [-n,n]
    QRn  - random rotation (n=seed, n=0 time, n=-1 time/no rotate)
    Qs   - search all halfspaces for the initial simplex

Qhull extra options:
    QGn  - print intersection if visible to halfspace n, -n for not
    QVn  - print intersections for halfspace n, -n if not
    Qw   - allow option warnings
    Q12  - allow wide facets and wide dupridge
    Q14  - merge pinched vertices that create a dupridge

T options:
    TFn  - report summary when n or more facets created
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes
    Ts   - statistics
    Tv   - verify result: structure, convexity, and in-circle test
    Tz   - send all output to stdout

Trace options:
    T4   - trace at level n, 4=all, 5=mem/gauss, -1= events
    Ta   - annotate output with message codes
    TAn  - stop qhull after adding n vertices
     TCn - stop qhull after building cone for point n
     TVn - stop qhull after adding point n, -n for before
    Tc   - check frequently during execution
    Tf   - flush each qh_fprintf for debugging segfaults
    TPn - turn on tracing when point n added to hull
     TMn  - turn on tracing at merge n
     TWn - trace merge facets when width > n

Precision options:
    Cn   - radius of centrum (roundoff added).  Merge facets if non-convex
     An  - cosine of maximum angle.  Merge facets if cosine > n or non-convex
           C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge
    Rn   - randomly perturb computations by a factor of [1-n,1+n]
    Un   - max distance below plane for a new, coplanar halfspace
    Wn   - min facet width for outside halfspace (before roundoff)

Output formats (may be combined; if none, produces a summary to stdout):
    f    - facet dump
    G    - Geomview output (dual convex hull)
    i    - non-redundant halfspaces incident to each intersection
    m    - Mathematica output (dual convex hull)
    o    - OFF format (dual convex hull: dimension, points, and facets)
    p    - vertex coordinates of dual convex hull (coplanars if 'Qc' or 'Qi')
    s    - summary (stderr)

More formats:
    Fc   - count plus redundant halfspaces for each intersection
         -   Qc (default) for coplanar and Qi for other redundant
    Fd   - use cdd format for input (homogeneous with offset first)
    FF   - facet dump without ridges
    FI   - ID of each intersection
    Fm   - merge count for each intersection (511 max)
    FM   - Maple output (dual 2-d or 3-d convex hull)
    Fn   - count plus neighboring intersections for each intersection
    FN   - count plus intersections for each halfspace
    FO   - options and precision constants
    Fp   - dim, count, and intersection coordinates
    FP   - nearest halfspace and distance for each redundant halfspace
    FQ   - command used for qhalf
    Fs   - summary: #int (8), dim, #halfspaces, #non-redundant, #intersections
                      output: #non-redundant, #intersections, #coplanar
                                  halfspaces, #non-simplicial intersections
                    #real (2), max outer plane, min vertex
    Fv   - count plus non-redundant halfspaces for each intersection
    Fx   - non-redundant halfspaces

Geomview output (2-d, 3-d and 4-d; dual convex hull)
    Ga   - all points (i.e., transformed halfspaces) as dots
     Gp  -  coplanar points and vertices as radii
     Gv  -  vertices (i.e., non-redundant halfspaces) as spheres
    Gc   - centrums
    GDn  - drop dimension n in 3-d and 4-d output
    Gh   - hyperplane intersections
    Gi   - inner planes (i.e., halfspace intersections) only
     Gn  -  no planes
     Go  -  outer planes only
    Gr   - ridges

Print options:
    PAn  - keep n largest facets (i.e., intersections) by area
    Pdk:n- drop facet if normal[k] <= n (default 0.0)
    PDk:n- drop facet if normal[k] >= n
    PFn  - keep facets whose area is at least n
    Pg   - print good facets (needs 'QGn' or 'QVn')
    PG   - print neighbors of good facets
    PMn  - keep n facets with most merges
    Po   - force output.  If error, output neighborhood of facet
    Pp   - do not report precision problems

    .    - list of all options
    -    - one line descriptions of all options
    -?   - help with examples
    -V   - version

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qh-optc.html0000644000176200001440000002771414664417655020216 0ustar liggesusers Qhull precision options

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull precision options

This section lists the precision options for Qhull. These options are indicated by an upper-case letter followed by a number.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Precision options

Most users will not need to set these options. They are best used for approximating a convex hull. They may also be used for testing Qhull's handling of precision errors.

Qhull uses the default option 'C-0' for 2-d, 3-d and 4-d, and 'Qx' for 5-d and higher. These options use facet merging to handle precision errors. You may also use joggled input 'QJ' to avoid precision problems. For more information see Imprecision in Qhull.

 
General
Cn
centrum radius for post-merging
C-n
centrum radius for pre-merging
An
cosine of maximum angle for post-merging
A-n
cosine of maximum angle for pre-merging
Qx
exact pre-merges (allows coplanar facets)
C-0
handle all precision errors
Wn
min distance above plane for outside points
 
Experimental
Un
max distance below plane for a new, coplanar point
En
max roundoff error for distance computation
Vn
min distance above plane for a visible facet
Rn
randomly perturb computations by a factor of [1-n,1+n]

»A-n - cosine of maximum angle for pre-merging.

Pre-merging occurs while Qhull constructs the hull. It is indicated by 'C-n', 'A-n', or 'Qx'.

If the angle between a pair of facet normals is greater than n, Qhull merges one of the facets into a neighbor. It selects the facet that is closest to a neighboring facet.

For example, option 'A-0.99' merges facets during the construction of the hull. If the cosine of the angle between facets is greater than 0.99, one or the other facet is merged. Qhull accounts for the maximum roundoff error.

If 'A-n' is set without 'C-n', then 'C-0' is automatically set.

In 5-d and higher, you should set 'Qx' along with 'A-n'. It skips merges of coplanar facets until after the hull is constructed and before 'An' and 'Cn' are checked.

»An - cosine of maximum angle for post-merging.

Post merging occurs after the hull is constructed. For example, option 'A0.99' merges a facet if the cosine of the angle between facets is greater than 0.99. Qhull accounts for the maximum roundoff error.

If 'An' is set without 'Cn', then 'C0' is automatically set.

»C-0 - handle all precision errors

Qhull handles precision errors by merging facets. The default option 'C-0' handles all precision errors in 2-d, 3-d, and 4-d. It may be used in higher dimensions, but sometimes the facet width grows rapidly. In 5-d and higher, the default option is 'Qx'. Use 'QJ' to joggle the input instead of merging facets. Use 'Q0' to turn both options off.

Qhull optimizes 'C-0' ("_zero-centrum") by testing vertices instead of centrums for adjacent simplices. This may be slower in higher dimensions if merges decrease the number of processed points. The optimization may be turned off by setting a small value such as 'C-1e-30'. See How Qhull handles imprecision.

»C-n - centrum radius for pre-merging

Pre-merging occurs while Qhull constructs the hull. It is indicated by 'C-n', 'A-n', or 'Qx'.

The centrum of a facet is a point on the facet for testing facet convexity. It is the average of the vertices projected to the facet's hyperplane. Two adjacent facets are convex if each centrum is clearly below the other facet.

If adjacent facets are non-convex, one of the facets is merged into a neighboring facet. Qhull merges the facet that is closest to a neighboring facet.

For option 'C-n', n is the centrum radius. For example, 'C-0.001' merges facets whenever the centrum is less than 0.001 from a neighboring hyperplane. Qhull accounts for roundoff error when testing the centrum.

In 5-d and higher, you should set 'Qx' along with 'C-n'. It skips merges of coplanar facets until after the hull is constructed and before 'An' and 'Cn' are checked.

»Cn - centrum radius for post-merging

Post-merging occurs after Qhull constructs the hull. It is indicated by 'Cn' or 'An'.

For option 'Cn', n is the centrum radius. For example, 'C0.001' merges facets when the centrum is less than 0.001 from a neighboring hyperplane. Qhull accounts for roundoff error when testing the centrum.

Both pre-merging and post-merging may be defined. If only post-merging is used ('Q0' with 'Cn'), Qhull may fail to produce a hull due to precision errors during the hull's construction.

»En - max roundoff error for distance computations

This allows the user to change the maximum roundoff error computed by Qhull. The value computed by Qhull may be overly pessimistic. If 'En' is set too small, then the output may not be convex. The statistic "max. distance of a new vertex to a facet" (from option 'Ts') is a reasonable upper bound for the actual roundoff error.

»Rn - randomly perturb computations

This option perturbs every distance, hyperplane, and angle computation by up to (+/- n * max_coord). It simulates the effect of roundoff errors. Unless 'En' is explicitly set, it is adjusted for 'Rn'. The command 'qhull Rn' will generate a convex hull despite the perturbations. See the Examples section for an example.

Options 'Rn C-n' have the effect of 'W2n' and 'C-2n'. To use time as the random number seed, use option 'QR-1'.

»Un - max distance for a new, coplanar point

This allows the user to set coplanarity. When pre-merging ('C-n', 'A-n' or 'Qx'), Qhull merges a new point into any coplanar facets. The default value for 'Un' is 'Vn'.

»Vn - min distance for a visible facet

This allows the user to set facet visibility. When adding a point to the convex hull, Qhull determines all facets that are visible from the point. A facet is visible if the distance from the point to the facet is greater than 'Vn'.

Without merging, the default value for 'Vn' is the roundoff error ('En'). With merging, the default value is the pre-merge centrum ('C-n') in 2-d or 3-d, or three times that in other dimensions. If the outside width is specified with option 'Wn', the maximum, default value for 'Vn' is 'Wn'.

Qhull warns if 'Vn' is greater than 'Wn' and furthest outside ('Qf') is not selected; this combination usually results in flipped facets (i.e., reversed normals).

»Wn - min distance above plane for outside points

Points are added to the convex hull only if they are clearly outside of a facet. A point is outside of a facet if its distance to the facet is greater than 'Wn'. Without pre-merging, the default value for 'Wn' is 'En'. If the user specifies pre-merging and does not set 'Wn', than 'Wn' is set to the maximum of 'C-n' and maxcoord*(1 - A-n).

This option is good for approximating a convex hull.

Options 'Qc' and 'Qi' use the minimum vertex to distinguish coplanar points from interior points.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qh-optf.html0000644000176200001440000010131314664417655020205 0ustar liggesusers Qhull format options (F)

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull format options (F)

This section lists the format options for Qhull. These options are indicated by 'F' followed by a letter. See Output, Print, and Geomview for other output options.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Additional input & output formats

These options allow for automatic processing of Qhull output. Options 'i', 'o', 'n', and 'p' may also be used.

FA
compute total area and volume for option 's'
Fd
use cdd format for input (offset first)
FD
use cdd format for normals (offset first)
FM
print Maple output (2-d and 3-d)
FO
print options to stderr or stdout
FQ
print command for qhull and input
Fs
print summary -- dim, #points, total vertices and facets, #vertices, #facets, max outer and inner plane
FS
print sizes -- total area and volume
FV
print average vertex (interior point for 'qhalf')
 
 
Facets, points, and vertices
Fa
print area for each facet
Fc
print coplanar points for each facet
FC
print centrum for each facet
FF
print facets w/o ridges
Fi
print inner planes for each facet
FI
print ID for each facet
Fm
print merge count for each facet (511 max)
Fn
print neighboring facets for each facet
FN
print neighboring facets for each point
Fo
print outer planes for each facet
FP
print nearest vertex for coplanar points
Ft
print triangulation with added points
Fv
print vertices for each facet
Fx
print extreme points (i.e., vertices) of convex hull
 
 
Delaunay, Voronoi, and halfspace
FC
print Voronoi vertex ("center") for each facet
Fi
print separating hyperplanes for inner, bounded Voronoi regions
Fo
print separating hyperplanes for outer, unbounded Voronoi regions
Fp
print points at halfspace intersections
Fv
print Voronoi diagram as ridges for each input pair
Fx
print extreme input sites of Delaunay triangulation or Voronoi diagram

»Fa - print area for each facet

The first line is the number of facets. The remaining lines are the area for each facet, one facet per line. See 'FA' and 'FS' for computing the total area and volume.

Use 'PAn' for printing the n largest facets. Use option 'PFn' for printing facets larger than n.

For Delaunay triangulations, the area is the area of each Delaunay triangle. For Voronoi vertices, the area is the area of the dual facet to each vertex.

Qhull uses the centrum and ridges to triangulate non-simplicial facets. The area for non-simplicial facets is the sum of the areas for each triangle. It is an approximation of the actual area. The ridge's vertices are projected to the facet's hyperplane. If a vertex is far below a facet (qh_WIDEcoplanar in user.h), the corresponding triangles are ignored.

For non-simplicial facets, vertices are often below the facet's hyperplane. If so, the approximation is less than the actual value and it may be significantly less or 0.0.

»FA - compute total area and volume for option 's'

With option 'FA', Qhull includes the total area and volume in the summary ('s'). Option 'FS' also includes the total area and volume. If facets are merged, the area and volume are approximations. Option 'FA' is automatically set for options 'Fa', 'PAn', and 'PFn'.

With 'qdelaunay s FA', Qhull computes the total area of the Delaunay triangulation. This equals the volume of the convex hull of the data points. With options 'qdelaunay Qu s FA', Qhull computes the total area of the furthest-site Delaunay triangulation. This equals of the total area of the Delaunay triangulation.

See 'Fa' for further details. Option 'FS' also computes the total area and volume.

»Fc - print coplanar points for each facet

The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of coplanar points followed by the point ids.

By default, option 'Fc' reports coplanar points ('Qc'). You may also use option 'Qi'. Options 'Qi Fc' prints interior points while 'Qci Fc' prints both coplanar and interior points.

Each coplanar point or interior point is assigned to the facet it is furthest above (resp., least below).

For halfspace intersection (qhalf), a "facet" is an intersection point and a "point" is a halfspace. Option 'Fc' lists the coplanar halfspaces for each intersection point. The first line is the number of intersection points. Each remaining line starts with the number of coplanar halfspaces. A coplanar halfspace is listed for one intersection point even though it is coplanar to multiple intersection points. Options "Fc Qi" list the redundant halfspaces for each intersection point.

Use 'Qc p' to print vertex and coplanar point coordinates. Use 'Fv' to print vertices.

»FC - print centrum or Voronoi vertex for each facet

The output starts with the dimension followed by the number of facets. Then each facet centrum is printed, one per line. For qvoronoi, Voronoi vertices are printed instead.

»Fd - use cdd format for input

The input starts with comments. The first comment is reported in the summary. Data starts after a "begin" line. The next line is the number of points followed by the dimension plus one and "real" or "integer". Then the points are listed with a leading "1" or "1.0". The data ends with an "end" line.

For halfspaces ('qhalf Fd'), the input format is the same. Each halfspace starts with its offset. The signs of the offset and coefficients are the opposite of Qhull's convention. The first two lines of the input may be an interior point in 'FV' format.

»FD - use cdd format for normals

Option 'FD' prints normals ('n', 'Fo', 'Fi') or points ('p') in cdd format. The first line is the command line that invoked Qhull. Data starts with a "begin" line. The next line is the number of normals or points followed by the dimension plus one and "real". Then the normals or points are listed with the offset before the coefficients. The offset for points is 1.0. For normals, the offset and coefficients use the opposite sign from Qhull. The data ends with an "end" line.

»FF - print facets w/o ridges

Option 'FF' prints all fields of all facets (as in 'f') without printing the ridges. This is useful in higher dimensions where a facet may have many ridges. For simplicial facets, options 'FF' and 'f ' are equivalent.

»Fi - print inner planes for each facet

The first line is the dimension plus one. The second line is the number of facets. The remainder is one inner plane per line. The format is the same as option 'n'.

The inner plane is a plane that is below the facet's vertices. It is an offset from the facet's hyperplane. It includes a roundoff error for computing the vertex distance.

Note that the inner planes for Geomview output ('Gi') include an additional offset for vertex visualization and roundoff error.

»Fi - print separating hyperplanes for inner, bounded Voronoi regions

With qvoronoi, 'Fi' prints the separating hyperplanes for inner, bounded regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the number of indices and floats. The first pair of indices indicates an adjacent pair of input sites. The next d floats are the normalized coefficients for the hyperplane, and the last float is the offset. The hyperplane is oriented toward 'QVn' (if defined), or the first input site of the pair (the point is below the hyperplane).

Use 'Fo' for unbounded regions, and 'Fv' for the corresponding Voronoi vertices.

Use 'Tv' to verify that the hyperplanes are perpendicular bisectors. It will list relevant statistics to stderr. The hyperplane is a perpendicular bisector if the midpoint of the input sites lies on the plane, all Voronoi vertices in the ridge lie on the plane, and the angle between the input sites and the plane is ninety degrees. This is true if all statistics are zero. Roundoff and computation errors make these non-zero. The deviations appear to be largest when the corresponding Delaunay triangles are large and thin; for example, the Voronoi diagram of nearly cospherical points.

»FI - print ID for each facet

Print facet identifiers. These are used internally and listed with options 'f' and 'FF'. Options 'Fn' and 'FN' use facet identifiers for negative indices.

»Fm - print merge count for each facet

The first line is the number of facets. The remainder is the number of merges for each facet, one per line. At most 511 merges are reported for a facet. See 'PMn' for printing the facets with the most merges.

»FM - print Maple output

Qhull writes a Maple file for 2-d and 3-d convex hulls, 2-d and 3-d halfspace intersections, and 2-d Delaunay triangulations. Qhull produces a 2-d or 3-d plot.

Warning: This option has not been tested in Maple.

[From T. K. Abraham with help from M. R. Feinberg and N. Platinova.] The following steps apply while working within the Maple worksheet environment :

  1. Generate the data and store it as an array . For example, in 3-d, data generated in Maple is of the form : x[i],y[i],z[i]

  2. Create a single variable and assign the entire array of data points to this variable. Use the "seq" command within square brackets as shown in the following example. (The square brackets are essential for the rest of the steps to work.)

    >data:=[seq([x[i],y[i],z[i]],i=1..n)]:# here n is the number of data points

  3. Next we need to write the data to a file to be read by qhull. Before writing the data to a file, make sure that the qhull executable files and the data file lie in the same subdirectory. If the executable files are stored in the "C:\qhull3.1\" subdirectory, then save the file in the same subdirectory, say "C:\qhull3.1\datafile.txt". For the sake of integrity of the data file , it is best to first ensure that the data file does not exist before writing into the data file. This can be done by running a delete command first . To write the data to the file, use the "writedata" and the "writedata[APPEND]" commands as illustrated in the following example :

    >system("del c:\\qhull3.1\\datafile.txt");#To erase any previous versions of the file
    >writedata("c:\\qhull3.1\\datafile.txt ",[3, nops(data)]);#writing in qhull format
    >writedata[APPEND]("c:\\ qhull3.1\\datafile.txt ", data);#writing the data points

  4. Use the 'FM' option to produce Maple output. Store the output as a ".mpl" file. For example, using the file we created above, we type the following (in DOS environment)

    qconvex s FM <datafile.txt >dataplot.mpl

  5. To read 3-d output in Maple, we use the 'read' command followed by a 'display3d' command. For example (in Maple environment):

    >with (plots):
    >read `c:\\qhull3.1\\dataplot.mpl`:#IMPORTANT - Note that the punctuation mark used is ' and NOT '. The correct punctuation mark is the one next to the key for "1" (not the punctuation mark near the enter key)
    > qhullplot:=%:
    > display3d(qhullplot);

For Delaunay triangulation orthogonal projection is better.

For halfspace intersections, Qhull produces the dual convex hull.

See Is Qhull available for Maple? for other URLs.

»Fn - print neighboring facets for each facet

The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of neighbors followed by an index for each neighbor. The indices match the other facet output formats.

For simplicial facets, each neighbor is opposite the corresponding vertex (option 'Fv'). Do not compare to option 'i'. Option 'i' orients facets by reversing the order of two vertices. For non-simplicial facets, the neighbors are unordered.

A negative index indicates an unprinted facet due to printing only good facets ('Pg', qdelaunay, qvoronoi). It is the negation of the facet's ID (option 'FI'). For example, negative indices are used for facets "at infinity" in the Delaunay triangulation.

For halfspace intersection (qhalf), a "facet" is an intersection point. Option 'Fn' lists the neighboring intersection points for each intersection point.

»FN - print neighboring facets for each point

The first line is the number of points. Then each point is printed, one per line. For unassigned points (either interior or coplanar), the line is "0". For assigned coplanar points ('Qc'), the line is "1" followed by the index of the facet that is furthest below the point. For assigned interior points ('Qi'), the line is "1" followed by the index of the facet that is least above the point. For vertices that do not belong to good facet, the line is "0"

For vertices of good facets, the line is the number of neighboring facets followed by the facet indices. The indices correspond to the other 'F' formats. In 4-d and higher, the facets are sorted by index. In 3-d, the facets are in adjacency order (not oriented).

A negative index indicates an unprinted facet due to printing only good facets (qdelaunay, qvoronoi, 'Pdk', 'Pg'). It is the negation of the facet's ID (' FI'). For example, negative indices are used for facets "at infinity" in the Delaunay triangulation.

For Voronoi vertices, option 'FN' lists the vertices of the Voronoi region for each input site. Option 'FN' lists the regions in site ID order. Option 'FN' corresponds to the second half of option 'o'. To convert from 'FN' to 'o', replace negative indices with zero and increment non-negative indices by one.

For halfspace intersection (qhalf), a "facet" is an intersection point and a "point" is a halfspace. Option 'FN' lists the intersection points for each halfspace. The first line is the number of halfspaces. Each remaining line starts with the number of intersection points for this halfspace. Redundant halfspaces have 0 intersection points.

If you are using the Qhull library or C++ interface, option 'FN' has the side effect of reordering the neighbors for a vertex

»Fo - print outer planes for each facet

The first line is the dimension plus one. The second line is the number of facets. The remainder is one outer plane per line. The format is the same as option 'n'.

The outer plane is a plane that is above all points. It is an offset from the facet's hyperplane. It includes a roundoff error for computing the point distance. When testing the outer plane (e.g., 'Tv'), another roundoff error should be added for the tested point.

If outer planes are not checked ('Q5') or not computed (!qh_MAXoutside), the maximum, computed outside distance is used instead. This can be much larger than the actual outer planes.

Note that the outer planes for Geomview output ('G') include an additional offset for vertex/point visualization, 'lines closer,' and roundoff error.

»Fo - print separating hyperplanes for outer, unbounded Voronoi regions

With qvoronoi, 'Fo' prints the separating hyperplanes for outer, unbounded regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the number of indices and floats. The first pair of indices indicates an adjacent pair of input sites. The next d floats are the normalized coefficients for the hyperplane, and the last float is the offset. The hyperplane is oriented toward 'QVn' (if defined), or the first input site of the pair (the point is below the hyperplane).

Option 'Fo' gives the separating hyperplanes for the unbounded regions of the Voronoi diagram. The midpoint between each pair of input sites is used in place of the vertex at infinity.

If the midpoint happens to be a Voronoi vertex, the hyperplane is degenerate (e.g., 'rbox c P0 D2 | qvoronoi p Fo').

Use 'Fi' for bounded regions, and 'Fv' for the corresponding Voronoi vertices.

»FO - print list of selected options

Lists selected options and default values to stderr. Additional 'FO's are printed to stdout.

»Fp - print points at halfspace intersections

The first line is the number of intersection points. The remainder is one intersection point per line. A intersection point is the intersection of d or more halfspaces from 'qhalf'. It corresponds to a facet of the dual polytope. The "infinity" point, [-10.101,-10.101,...] (qh_INFINITE), indicates an unbounded intersection.

If [x,y,z] are the dual facet's normal coefficients and b<0 is its offset, the halfspace intersection occurs at [x/-b,y/-b,z/-b] plus the interior point. If b>=0, the halfspace intersection is unbounded.

»FP - print nearest vertex for coplanar points

The output starts with the number of coplanar points. Then each coplanar point is printed one per line. Each line is the point ID of the closest vertex, the point ID of the coplanar point, the corresponding facet ID, and the distance. Sort the lines to list the coplanar points nearest to each vertex.

Use options 'Qc' and/or 'Qi' with 'FP'. Options 'Qc FP' prints coplanar points while 'Qci FP' prints coplanar and interior points. Option 'Qc' is automatically selected if 'Qi' is not selected.

For Delaunay triangulations (qdelaunay or qvoronoi), a coplanar point is nearly incident to a vertex. The distance is the distance in the original point set.

If imprecision problems are severe, Qhull will delete input sites when constructing the Delaunay triangulation. Option 'FP' will list these points along with coincident points.

If there are many coplanar or coincident points and non-simplicial facets are triangulated ('Qt'), option 'FP' may be inefficient. It redetermines the original vertex set for each coplanar point.

»FQ - print command for qhull and input

Prints qhull and input command, e.g., 'rbox 10 s | qhull FQ'. Option 'FQ' may be repeated multiple times.

»Fs - print summary

The first line consists of number of integers ("10") followed by the:

  • dimension
  • number of points
  • number of vertices
  • number of facets
  • number of vertices selected for output
  • number of facets selected for output
  • number of coplanar points for selected facets
  • number of nonsimplicial or merged facets selected for output
  • number of deleted vertices
  • number of triangulated facets ('Qt')

The second line consists of the number of reals ("2") followed by the:

  • maximum offset to an outer plane
  • minimum offset to an inner plane.
Roundoff and joggle are included.

For Delaunay triangulations and Voronoi diagrams, the number of deleted vertices should be zero. If greater than zero, then the input is highly degenerate and coplanar points are not necessarily coincident points. For example, 'RBOX 1000 s W1e-13 t995138628 | QHULL d Qbb' reports deleted vertices; the input is nearly cospherical.

Later versions of Qhull may produce additional integers or reals.

»FS - print sizes

The first line consists of the number of integers ("0"). The second line consists of the number of reals ("2"), followed by the total facet area, and the total volume. Later versions of Qhull may produce additional integers or reals.

The total volume measures the volume of the intersection of the halfspaces defined by each facet. It is computed from the facet area. Both area and volume are approximations for non-simplicial facets. See option 'Fa' for further notes. Option 'FA' also computes the total area and volume.

»Ft - print triangulation

Prints a triangulation with added points for non-simplicial facets. The output is

  • The first line is the dimension
  • The second line is the number of points, the number of facets, and the number of ridges.
  • All of the input points follow, one per line.
  • The centrums follow, one per non-simplicial facet
  • Then the facets follow as a list of point indices preceded by the number of points. The simplices are oriented.

For convex hulls with simplicial facets, the output is the same as option 'o'.

The added points are the centrums of the non-simplicial facets. Except for large facets, the centrum is the average vertex coordinate projected to the facet's hyperplane. Large facets may use an old centrum to avoid recomputing the centrum after each merge. In either case, the centrum is clearly below neighboring facets. See Precision issues.

The new simplices will not be clearly convex with their neighbors and they will not satisfy the Delaunay property. They may even have a flipped orientation. Use triangulated input ('Qt') for Delaunay triangulations.

For Delaunay triangulations with simplicial facets, the output is the same as option 'o' without the lifted coordinate. Since 'Ft' is invalid for merged Delaunay facets, option 'Ft' is not available for qdelaunay or qvoronoi. It may be used with joggled input ('QJ') or triangulated output ('Qt'), for example, rbox 10 c G 0.01 | qhull d QJ Ft

If you add a point-at-infinity with 'Qz', it is printed after the input sites and before any centrums. It will not be used in a Delaunay facet.

»Fv - print vertices for each facet

The first line is the number of facets. Then each facet is printed, one per line. Each line is the number of vertices followed by the corresponding point ids. Vertices are listed in the order they were added to the hull (the last one added is the first listed).

Option 'i' also lists the vertices, but it orients facets by reversing the order of two vertices. Option 'i' triangulates non-simplicial, 4-d and higher facets by adding vertices for the centrums.

For halfspace intersection (qhalf), a "facet" is an intersection point and a "point" is a halfspace. Option 'Fv' lists the non-redundant halfspaces incident to each intersection point. The first line is the number of non-redundant halfspaces. Each remaining line starts with the number of non-redundant halfspaces incident to that point.

»Fv - print Voronoi diagram

With qvoronoi, 'Fv' prints the Voronoi diagram or furthest-site Voronoi diagram. The first line is the number of ridges. Then each ridge is printed, one per line. The first number is the count of indices. The second pair of indices indicates a pair of input sites. The remaining indices list the corresponding ridge of Voronoi vertices. Vertex 0 is the vertex-at-infinity. It indicates an unbounded ray.

All vertices of a ridge are coplanar. If the ridge is unbounded, add the midpoint of the pair of input sites. The unbounded ray is directed from the Voronoi vertices to infinity.

Use 'Fo' for separating hyperplanes of outer, unbounded regions. Use 'Fi' for separating hyperplanes of inner, bounded regions.

Option 'Fv' does not list ridges that require more than one midpoint. For example, the Voronoi diagram of cospherical points lists zero ridges (e.g., 'rbox 10 s | qvoronoi Fv Qz'). Other examples are the Voronoi diagrams of a rectangular mesh (e.g., 'rbox 27 M1,0 | qvoronoi Fv') or a point set with a rectangular corner (e.g., 'rbox P4,4,4 P4,2,4 P2,4,4 P4,4,2 10 | qvoronoi Fv'). Both cases miss unbounded rays at the corners. To determine these ridges, surround the points with a large cube (e.g., 'rbox 10 s c G2.0 | qvoronoi Fv Qz'). The cube needs to be large enough to bound all Voronoi regions of the original point set. Please report any other cases that are missed. If you can formally describe these cases or write code to handle them, please send email to qhull@qhull.org.

»FV - print average vertex

The average vertex is the average of all vertex coordinates. It is an interior point for halfspace intersection. The first line is the dimension and "1"; the second line is the coordinates. For example,

qconvex FV n | qhalf Fp

prints the extreme points of the original point set (roundoff included).

»Fx - print extreme points (vertices) of convex hulls and Delaunay triangulations

The first line is the number of points. The following lines give the index of the corresponding points. The first point is '0'.

In 2-d, the extreme points (vertices) are listed in counter-clockwise order (by qh_ORIENTclock in user.h).

In 3-d and higher convex hulls, the extreme points (vertices) are sorted by index. This is the same order as option 'p' when it doesn't include coplanar or interior points.

For Delaunay triangulations, 'Fx' lists the extreme points of the input sites (i.e., the vertices of their convex hull). The points are unordered.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qh-quick.html0000644000176200001440000004536014664417655020362 0ustar liggesusers Qhull quick reference

Up: Home page for Qhull (local)
Up: Qhull manual
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull code
To: Qhull files (local)
To: GeomGlobalIoMemMergePolyQhullSetStatUser


[cone] Qhull quick reference

This section lists all programs and options in Qhull.

Copyright © 1995-2020 C.B. Barber

 


Qhull programs

» ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

qconvex -- convex hull
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
qdelaunay -- Delaunay triangulation
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
qdelaunay Qu -- furthest-site Delaunay triangulation
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
qhalf -- halfspace intersection about a point
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
qvoronoi -- Voronoi diagram
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
qvoronoi Qu -- furthest-site Voronoi diagram
synopsis • input • outputs • controls • graphics • notes • conventions • options
 
rbox -- generate point distributions for qhull
synopsis • outputs • examples • notes • options
 
qhull -- convex hull and related structures
synopsis • input • outputs • controls • options
 
Qhull options

» ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

'd' delaunay 'f' facet-dump 'G' Geomview 'H' Halfspace
'i' incidences 'm' mathematica 'n' normals 'o' OFF-format
'p' points 's' summary 'v' voronoi
 
'Fa' Farea 'FA' FArea-total 'Fc' Fcoplanars 'FC' FCentrums
'Fd' Fd-cdd-in 'FD' FD-cdd-out 'FF' FFacets-xridge 'Fi' Finner
'Fi' Finner-bounded 'FI' FIDs 'Fm' Fmerges 'FM' FMaple
'Fn' Fneighbors 'FN' FNeigh-vertex 'Fo' Fouter 'Fo' Fouter-unbounded
'FO' FOptions 'Fp' Fpoint-intersect 'FP' FPoint-near 'FQ' FQhull
'Fs' Fsummary 'FS' FSize 'Ft' Ftriangles 'Fv' Fvertices
'Fv' Fvoronoi 'FV' FVertex-ave 'Fx' Fxtremes
 
'Ga' Gall-points 'Gc' Gcentrums 'GDn' GDrop-dim 'Gh' Ghyperplanes
'Gi' Ginner 'Gn' Gno-planes 'Go' Gouter 'Gp' Gpoints
'Gr' Gridges 'Gt' Gtransparent 'Gv' Gvertices
 
'PAn' PArea-keep 'Pdk:n' Pdrop-low 'PDk:n' Pdrop-high 'PFn' PFacet-area-keep
'Pg' Pgood 'PG' PGood-neighbors 'PMn' PMerge-keep 'Po' Poutput-forced
'Po' Poutput-error 'Pp' Pprecision-not
 
'Qa' Qallow-short 'Qbk:n' Qbound-low 'QBk:n' QBound-high 'QbB' QbB-scale-box
'Qbb' Qbb-scale-last 'Qbk:0Bk:0' Qbound-drop 'Qc' Qcoplanar 'Qi' Qinterior
'QJn' QJoggle 'QRn' QRotate 'Qs' Qsearch-all 'Qt' Qtriangulate
'Qu' QupperDelaunay 'Qw' Qwarn-allow 'Qx' Qxact-merge 'Qz' Qzinfinite
 
'Qf' Qfurthest 'Qg' Qgood-only 'QGn' QGood-point 'Qm' Qmax-outside
'Qr' Qrandom 'Qv' Qvertex-neighbors 'QVn' QVertex-good
'Q0' Q0-no-premerge 'Q1' Q1-angle-merge 'Q2' Q2-no-independent 'Q3' Q3-no-redundant
'Q4' Q4-no-old 'Q5' Q5-no-check-out 'Q6' Q6-no-concave 'Q7' Q7-depth-first
'Q8' Q8-no-near-interior 'Q9' Q9-pick-furthest 'Q10' Q10-no-narrow 'Q11' Q11-trinormals
'Q12' Q12-allow-wide 'Q14' Q14-merge-pinched 'Q15' Q15-duplicate-ridges
 
'TFn' TFacet-log 'TI file' TInput-file 'TO file' TOutput-file 'Ts' Tstatistics
'Tv' Tverify 'Tz' Tz-stdout
 
'T4' T4-trace 'Ta' Tannotate 'TAn' TAdd-stop 'Tc' Tcheck-often
'TCn' TCone-stop 'Tf' Tflush 'TMn' TMerge-trace 'TPn' TPoint-trace
'TRn' TRerun 'TV-n' TVertex-stop-before 'TVn' TVertex-stop-after 'TWn' TWide-trace
 
'A-n' Angle-max-pre 'An' Angle-max-post 'C-0' Centrum-roundoff 'C-n' Centrum-size-pre
'Cn' Centrum-size-post 'En' Error-round 'Rn' Random-dist 'Un' Ucoplanar-max
'Vn' Visible-min 'Wn' Wide-outside


Up: Home page for Qhull (local)
Up: Qhull manual
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull code
To: Qhull files (local)
To: GeomGlobalIoMemMergePolyQhullSetStatUser


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qh-optg.html0000644000176200001440000002607714664417655020223 0ustar liggesusers Qhull Geomview options (G)

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull Geomview options (G)

This section lists the Geomview options for Qhull. These options are indicated by 'G' followed by a letter. See Output, Print, and Format for other output options.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Geomview output options

Geomview is the graphical viewer for visualizing Qhull output in 2-d, 3-d and 4-d.

Geomview displays each facet of the convex hull. The color of a facet is determined by the coefficients of the facet's normal equation. For imprecise hulls, Geomview displays the inner and outer hull. Geomview can also display points, ridges, vertices, coplanar points, and facet intersections.

For 2-d Delaunay triangulations, Geomview displays the corresponding paraboloid. Geomview displays the 2-d Voronoi diagram. For halfspace intersections, it displays the dual convex hull.

G
display Geomview output
GDn
drop dimension n in 3-d and 4-d output
Gt
display transparent 3-d Delaunay triangulation
 
 
Specific
Ga
display all points as dots
Gc
display centrums (2-d, 3-d)
Gh
display hyperplane intersections
Gi
display inner planes only (2-d, 3-d)
Gn
do not display planes
Go
display outer planes only (2-d, 3-d)
Gp
display coplanar points and vertices as radii
Gr
display ridges (3-d)
Gv
display vertices as spheres

»G - produce output for viewing with Geomview

By default, option 'G' displays edges in 2-d, outer planes in 3-d, and ridges in 4-d.

A ridge can be explicit or implicit. An explicit ridge is a (d-1)-dimensional simplex between two facets. In 4-d, the explicit ridges are triangles. An implicit ridge is the topological intersection of two neighboring facets. It is the union of explicit ridges.

For non-simplicial 4-d facets, the explicit ridges can be quite complex. When displaying a ridge in 4-d, Qhull projects the ridge's vertices to one of its facets' hyperplanes. Use 'Gh' to project ridges to the intersection of both hyperplanes. This usually results in a cleaner display.

For 2-d Delaunay triangulations, Geomview displays the corresponding paraboloid. Geomview displays the 2-d Voronoi diagram. For halfspace intersections, it displays the dual convex hull.

»Ga - display all points as dots

Each input point is displayed as a green dot.

»Gc - display centrums (3-d)

The centrum is defined by a green radius sitting on a blue plane. The plane corresponds to the facet's hyperplane. If you sight along a facet's hyperplane, you will see that all neighboring centrums are below the facet. The radius is defined by 'C-n' or 'Cn'.

»GDn - drop dimension n in 3-d and 4-d output

The result is a 2-d or 3-d object. In 4-d, this corresponds to viewing the 4-d object from the nth axis without perspective. It's best to view 4-d objects in pieces. Use the 'Pdk' 'Pg' 'PG' 'QGn' and 'QVn' options to select a few facets. If one of the facets is perpendicular to an axis, then projecting along that axis will show the facet exactly as it is in 4-d. If you generate many facets, use Geomview's ginsu module to view the interior

To view multiple 4-d dimensions at once, output the object without 'GDn' and read it with Geomview's ndview. As you rotate the object in one set of dimensions, you can see how it changes in other sets of dimensions.

For additional control over 4-d objects, output the object without 'GDn' and read it with Geomview's 4dview. You can slice the object along any 4-d plane. You can also flip the halfspace that's deleted when slicing. By combining these features, you can get some interesting cross sections.

»Gh - display hyperplane intersections (3-d, 4-d)

In 3-d, the intersection is a black line. It lies on two neighboring hyperplanes, c.f., the blue squares associated with centrums ('Gc'). In 4-d, the ridges are projected to the intersection of both hyperplanes. If you turn on edges (Geomview's 'appearances' menu), each triangle corresponds to one ridge. The ridges may overlap each other.

»Gi - display inner planes only (2-d, 3-d)

The inner plane of a facet is below all of its vertices. It is parallel to the facet's hyperplane. The inner plane's color is the opposite of the outer plane's color, i.e., [1-r,1-g,1-b] . Its edges are determined by the vertices.

»Gn - do not display planes

By default, Geomview displays the precise plane (no merging) or both inner and output planes (if merging). If merging, Geomview does not display the inner plane if the the difference between inner and outer is too small.

»Go - display outer planes only (2-d, 3-d)

The outer plane of a facet is above all input points. It is parallel to the facet's hyperplane. Its color is determined by the facet's normal, and its edges are determined by the vertices.

»Gp - display coplanar points and vertices as radii

Coplanar points ('Qc'), interior points ('Qi'), outside points ('TCn' or 'TVn'), and vertices are displayed as red and yellow radii. The radii are perpendicular to the corresponding facet. Vertices are aligned with an interior point. The radii define a ball which corresponds to the imprecision of the point. The imprecision is the maximum of the roundoff error, the centrum radius, and maxcoord * (1 - A-n). It is at least 1/20'th of the maximum coordinate, and ignores post merging if pre-merging is done.

If 'Gv' (print vertices as spheres) is also selected, option 'Gp' displays coplanar points as radii. Select options Qc' and/or 'Qi'. Options 'Qc Gpv' displays coplanar points while 'Qci Gpv' displays coplanar and interior points. Option 'Qc' is automatically selected if 'Qi' is not selected with options 'Gpv'.

»Gr - display ridges (3-d)

A ridge connects the two vertices that are shared by neighboring facets. It is displayed in green. A ridge is the topological edge between two facets while the hyperplane intersection is the geometric edge between two facets. Ridges are always displayed in 4-d.

»Gt - transparent 3-d Delaunay

A 3-d Delaunay triangulation looks like a convex hull with interior facets. Option 'Gt' removes the outside ridges to reveal the outermost facets. It automatically sets options 'Gr' and 'GDn'. See example eg.17f.delaunay.3.

»Gv - display vertices as spheres (2-d, 3-d)

The radius of the sphere corresponds to the imprecision of the data. See 'Gp' for determining the radius.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qh-eg.html0000644000176200001440000007472714664417655017652 0ustar liggesusers Examples of Qhull

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull examples: contents


[halfspace] Examples of Qhull

This section of the Qhull manual will introduce you to Qhull and its options. Each example is a file for viewing with Geomview. You will need to use a Unix computer with a copy of Geomview.

If you are not running Unix, you can view pictures for some of the examples. To understand Qhull without Geomview, try the examples in Programs and Programs/input. You can also try small examples that you compute by hand. Use rbox to generate examples.

To generate the Geomview examples, execute the shell script eg/q_eg. It uses rbox. The shell script eg/q_egtest generates test examples, and eg/q_test exercises the code. Test and log Qhull with eg/qtest.sh. eg/q_benchmark is a benchmark of Qhull precision and performance. If you find yourself viewing the inside of a 3-d example, use Geomview's normalization option on the 'obscure' menu.

Copyright © 1995-2020 C.B. Barber


»Qhull examples: contents



»2-d and 3-d examples

»rbox c D3 | qconvex G >eg.01.cube

The first example is a cube in 3-d. The color of each facet indicates its normal. For example, normal [0,0,1] along the Z axis is (r=0.5, g=0.5, b=1.0). With the 'Dn' option in rbox, you can generate hypercubes in any dimension. Above 7-d the number of intermediate facets grows rapidly. Use 'TFn' to track qconvex's progress. Note that each facet is a square that qconvex merged from coplanar triangles.

»rbox c d G3.0 | qconvex G >eg.02.diamond.cube

The second example is a cube plus a diamond ('d') scaled by rbox's 'G' option. In higher dimensions, diamonds are much simpler than hypercubes.

»rbox s 100 D3 | qconvex G >eg.03.sphere

The rbox s option generates random points and projects them to the d-sphere. All points should be on the convex hull. Notice that random points look more clustered than you might expect. You can get a smoother distribution by merging facets and printing the vertices, e.g., rbox 1000 s | qconvex A-0.95 p | qconvex G >eg.99.

»rbox s 100 D2 | qconvex G >eg.04.circle

In 2-d, there are many ways to generate a convex hull. One of the earliest algorithms, and one of the fastest, is the 2-d Quickhull algorithm [c.f., Preparata & Shamos '85]. It was the model for Qhull.

»rbox 10 l | qconvex G >eg.05.spiral

One rotation of a spiral.

»rbox 1000 D2 | qconvex C-0.03 Qc Gapcv >eg.06.merge.square

This demonstrates how Qhull handles precision errors. Option 'C-0.03' requires a clearly convex angle between adjacent facets. Otherwise, Qhull merges the facets.

This is the convex hull of random points in a square. The facets have thickness because they must be outside all points and must include their vertices. The colored lines represent the original points and the spheres represent the vertices. Floating in the middle of each facet is the centrum. Each centrum is at least 0.03 below the planes of its neighbors. This guarantees that the facets are convex.

»rbox 1000 D3 | qconvex G >eg.07.box

Here's the same distribution but in 3-d with Qhull handling machine roundoff errors. Note the large number of facets.

»rbox c G0.4 s 500 | qconvex G >eg.08a.cube.sphere

The sphere is just barely poking out of the cube. Try the same distribution with randomization turned on ('Qr'). This turns Qhull into a randomized incremental algorithm. To compare Qhull and randomization, look at the number of hyperplanes created and the number of points partitioned. Don't compare CPU times since Qhull's implementation of randomization is inefficient. The number of hyperplanes and partitionings indicate the dominant costs for Qhull. With randomization, you'll notice that the number of facets created is larger than before. This is especially true as you increase the number of points. It is because the randomized algorithm builds most of the sphere before it adds the cube's vertices.

»rbox d G0.6 s 500 | qconvex G >eg.08b.diamond.sphere

This is a combination of the diamond distribution and the sphere.

»rbox 100 L3 G0.5 s | qconvex G >eg.09.lens

Each half of the lens distribution lies on a sphere of radius three. A directed search for the furthest facet below a point (e.g., qh_findbest in geom.c) may fail if started from an arbitrary facet. For example, if the first facet is on the opposite side of the lens, a directed search will report that the point is inside the convex hull even though it is outside. This problem occurs whenever the curvature of the convex hull is less than a sphere centered at the test point.

To prevent this problem, Qhull does not use directed search all the time. When Qhull processes a point on the edge of the lens, it partitions the remaining points with an exhaustive search instead of a directed search (see qh_findbestnew in geom2.c).

»How Qhull adds a point

»rbox 100 s P0.5,0.5,0.5 | qconvex Ga QG0 >eg.10a.sphere.visible

The next 4 examples show how Qhull adds a point. The point [0.5,0.5,0.5] is at one corner of the bounding box. Qhull adds a point using the beneath-beyond algorithm. First Qhull finds all of the facets that are visible from the point. Qhull will replace these facets with new facets.

»rbox 100 s P0.5,0.5,0.5|qconvex Ga QG-0 >eg.10b.sphere.beyond

These are the facets that are not visible from the point. Qhull will keep these facets.

»rbox 100 s P0.5,0.5,0.5 | qconvex PG Ga QG0 >eg.10c.sphere.horizon

These facets are the horizon facets; they border the visible facets. The inside edges are the horizon ridges. Each horizon ridge will form the base for a new facet.

»rbox 100 s P0.5,0.5,0.5 | qconvex Ga QV0 PgG >eg.10d.sphere.cone

This is the cone of points from the new point to the horizon facets. Try combining this image with eg.10c.sphere.horizon and eg.10a.sphere.visible.

»rbox 100 s P0.5,0.5,0.5 | qconvex Ga >eg.10e.sphere.new

This is the convex hull after [0.5,0.5,0.5] has been added. Note that in actual practice, the above sequence would never happen. Unlike the randomized algorithms, Qhull always processes a point that is furthest in an outside set. A point like [0.5,0.5,0.5] would be one of the first points processed.

»rbox 100 s P0.5,0.5,0.5 | qhull Ga QV0g Q0 >eg.14.sphere.corner

The 'QVn', 'QGn' and 'Pdk' options define good facets for Qhull. In this case 'QV0' defines the 0'th point [0.5,0.5,0.5] as the good vertex, and 'Qg' tells Qhull to only build facets that might be part of a good facet. This technique reduces output size in low dimensions. It does not work with facet merging (turned off with 'Q0')

»Triangulated output or joggled input

»rbox 500 W0 | qconvex QR0 Qc Gvp >eg.15a.surface

This is the convex hull of 500 points on the surface of a cube. Note the large, non-simplicial facet for each face. Qhull merges non-convex facets.

If the facets were not merged, Qhull would report precision problems. For example, turn off facet merging with option 'Q0'. Qhull may report concave facets, flipped facets, or other precision errors:

rbox 500 W0 | qhull QR0 Q0

»rbox 500 W0 | qconvex QR0 Qt Qc Gvp >eg.15b.triangle

Like the previous examples, this is the convex hull of 500 points on the surface of a cube. Option 'Qt' triangulates the non-simplicial facets. Triangulated output is particularly helpful for Delaunay triangulations.

»rbox 500 W0 | qconvex QR0 QJ5e-2 Qc Gvp >eg.15c.joggle

This is the convex hull of 500 joggled points on the surface of a cube. The option 'QJ5e-2' sets a very large joggle to make the effect visible. Notice that all of the facets are triangles. If you rotate the cube, you'll see red-yellow lines for coplanar points.

With option 'QJ', Qhull joggles the input to avoid precision problems. It adds a small random number to each input coordinate. If a precision error occurs, it increases the joggle and tries again. It repeats this process until no precision problems occur.

Joggled input is a simple solution to precision problems in computational geometry. Qhull can also merge facets to handle precision problems. See Merged facets or joggled input.

»Delaunay and Voronoi diagrams

»qdelaunay Qt <eg.data.17 GnraD2 >eg.17a.delaunay.2

The input file, eg.data.17, consists of a square, 15 random points within the outside half of the square, and 6 co-circular points centered on the square.

The Delaunay triangulation is the triangulation with empty circumcircles. The input for this example is unusual because it includes six co-circular points. Every triangular subset of these points has the same circumcircle. Option 'Qt' triangulates the co-circular facet.

»qdelaunay <eg.data.17 GnraD2 >eg.17b.delaunay.2i

This is the same example without triangulated output ('Qt'). qdelaunay merges the non-unique Delaunay triangles into a hexagon.

»qdelaunay <eg.data.17 Ga >eg.17c.delaunay.2-3

This is how Qhull generated both diagrams. Use Geomview's 'obscure' menu to turn off normalization, and Geomview's 'cameras' menu to turn off perspective. Then load this object with one of the previous diagrams.

The points are lifted to a paraboloid by summing the squares of each coordinate. These are the light blue points. Then the convex hull is taken. That's what you see here. If you look up the Z-axis, you'll see that points and edges coincide.

»qvoronoi QJ <eg.data.17 Gna >eg.17d.voronoi.2

The Voronoi diagram is the dual of the Delaunay triangulation. Here you see the original sites and the Voronoi vertices. Notice the each vertex is equidistant from three sites. The edges indicate the Voronoi region for a site. Qhull does not draw the unbounded edges. Instead, it draws extra edges to close the unbounded Voronoi regions. You may find it helpful to enclose the input points in a square. You can compute the unbounded rays from option 'Fo'.

Instead of triangulated output ('Qt'), this example uses joggled input ('QJ'). Normally, you should use neither 'QJ' nor 'Qt' for Voronoi diagrams.

»qvoronoi <eg.data.17 Gna >eg.17e.voronoi.2i

This looks the same as the previous diagrams, but take a look at the data. Run 'qvoronoi p <eg/eg.data.17'. This prints the Voronoi vertices.

With 'QJ', there are four nearly identical Voronoi vertices within 10^-11 of the origin. Option 'QJ' joggled the input. After the joggle, the cocircular input sites are no longer cocircular. The corresponding Voronoi vertices are similar but not identical.

This example does not use options 'Qt' or 'QJ'. The cocircular input sites define one Voronoi vertex near the origin.

Option 'Qt' would triangulate the corresponding Delaunay region into four triangles. Each triangle is assigned the same Voronoi vertex.

» rbox c G0.1 d | qdelaunay Gt Qz <eg.17f.delaunay.3

This is the 3-d Delaunay triangulation of a small cube inside a prism. Since the outside ridges are transparent, it shows the interior of the outermost facets. If you slice open the triangulation with Geomview's ginsu, you will see that the innermost facet is a cube. Note the use of 'Qz' to add a point "at infinity". This avoids a degenerate input due to cospherical points.

»rbox 10 D2 d | qdelaunay Qu G >eg.18a.furthest.2-3

The furthest-site Voronoi diagram contains Voronoi regions for points that are furthest from an input site. It is the dual of the furthest-site Delaunay triangulation. You can determine the furthest-site Delaunay triangulation from the convex hull of the lifted points (eg.17c.delaunay.2-3). The upper convex hull (blue) generates the furthest-site Delaunay triangulation.

»rbox 10 D2 d | qdelaunay Qu Pd2 G >eg.18b.furthest-up.2-3

This is the upper convex hull of the preceding example. The furthest-site Delaunay triangulation is the projection of the upper convex hull back to the input points. The furthest-site Voronoi vertices are the circumcenters of the furthest-site Delaunay triangles.

»rbox 10 D2 d | qvoronoi Qu Gv >eg.18c.furthest.2

This shows an incomplete furthest-site Voronoi diagram. It only shows regions with more than two vertices. The regions are artificially truncated. The actual regions are unbounded. You can print the regions' vertices with 'qvoronoi Qu o'.

Use Geomview's 'obscure' menu to turn off normalization, and Geomview's 'cameras' menu to turn off perspective. Then load this with the upper convex hull.

»rbox 10 D3 | qvoronoi QV5 p | qconvex G >eg.19.voronoi.region.3

This shows the Voronoi region for input site 5 of a 3-d Voronoi diagram.

»Facet merging for imprecision

»rbox r s 20 Z1 G0.2 | qconvex G >eg.20.cone

There are two things unusual about this cone. One is the large flat disk at one end and the other is the rectangles about the middle. That's how the points were generated, and if those points were exact, this is the correct hull. But rbox used floating point arithmetic to generate the data. So the precise convex hull should have been triangles instead of rectangles. By requiring convexity, Qhull has recovered the original design.

»rbox 200 s | qhull Q0 R0.01 Gav Po >eg.21a.roundoff.errors

This is the convex hull of 200 cospherical points with precision errors ignored ('Q0'). To demonstrate the effect of roundoff error, we've added a random perturbation ('R0.01') to every distance and hyperplane calculation. Qhull, like all other convex hull algorithms with floating point arithmetic, makes inconsistent decisions and generates wildly wrong results. In this case, one or more facets are flipped over. These facets have the wrong color. You can also turn on 'normals' in Geomview's appearances menu and turn off 'facing normals'. There should be some white lines pointing in the wrong direction. These correspond to flipped facets.

Different machines may not produce this picture. If your machine generated a long error message, decrease the number of points or the random perturbation ('R0.01'). If it did not report flipped facets, increase the number of points or perturbation.

»rbox 200 s | qconvex Qc R0.01 Gpav >eg.21b.roundoff.fixed

Qhull handles the random perturbations and returns an imprecise sphere. In this case, the output is a weak approximation to the points. This is because a random perturbation of 'R0.01' is equivalent to losing all but 1.8 digits of precision. The outer planes float above the points because Qhull needs to allow for the maximum roundoff error.

If you start with a smaller random perturbation, you can use joggle ('QJn') to avoid precision problems. You need to set n significantly larger than the random perturbation. For example, try 'rbox 200 s | qconvex Qc R1e-4 QJ1e-1'.

»rbox 1000 s| qconvex C0.01 Qc Gcrp >eg.22a.merge.sphere.01

»rbox 1000 s| qconvex C-0.01 Qc Gcrp >eg.22b.merge.sphere.-01

»rbox 1000 s| qconvex C0.05 Qc Gcrpv >eg.22c.merge.sphere.05

»rbox 1000 s| qconvex C-0.05 Qc Gcrpv >eg.22d.merge.sphere.-05

The next four examples compare post-merging and pre-merging ('Cn' vs. 'C-n'). Qhull uses '-' as a flag to indicate pre-merging.

Post-merging happens after the convex hull is built. During post-merging, Qhull repeatedly merges an independent set of non-convex facets. For a given set of parameters, the result is about as good as one can hope for.

Pre-merging does the same thing as post-merging, except that it happens after adding each point to the convex hull. With pre-merging, Qhull guarantees a convex hull, but the facets are wider than those from post-merging. If a pre-merge option is not specified, Qhull handles machine round-off errors.

You may see coplanar points appearing slightly outside the facets of the last example. This is becomes Geomview moves line segments forward toward the viewer. You can avoid the effect by setting 'lines closer' to '0' in Geomview's camera menu.

»rbox 1000 | qconvex s Gcprvah C0.1 Qc >eg.23.merge.cube

Here's the 3-d imprecise cube with all of the Geomview options. There's spheres for the vertices, radii for the coplanar points, dots for the interior points, hyperplane intersections, centrums, and inner and outer planes. The radii are shorter than the spheres because this uses post-merging ('C0.1') instead of pre-merging.

»4-d objects

With Qhull and Geomview you can develop an intuitive sense of 4-d surfaces. When you get into trouble, think of viewing the surface of a 3-d sphere in a 2-d plane.

»rbox 5000 D4 | qconvex s GD0v Pd0:0.5 C-0.02 C0.1 >eg.24.merge.cube.4d-in-3d

Here's one facet of the imprecise cube in 4-d. It is projected into 3-d (the 'GDn' option drops dimension n). Each ridge consists of two triangles between this facet and the neighboring facet. In this case, Geomview displays the topological ridges, i.e., as triangles between three vertices. That is why the cube looks lopsided.

»rbox 5000 D4 | qconvex s C-0.02 C0.1 Gh >eg.30.4d.merge.cube

Here is the equivalent in 4-d of the imprecise square and imprecise cube. It's the imprecise convex hull of 5000 random points in a hypercube. It's a full 4-d object so Geomview's ginsu does not work. If you view it in Geomview, you'll be inside the hypercube. To view 4-d objects directly, either load the 4dview module or the ndview module. For 4dview, you must have started Geomview in the same directory as the object. For ndview, initialize a set of windows with the prefab menu, and load the object through Geomview. The 4dview module includes an option for slicing along any hyperplane. If you do this in the x, y, or z plane, you'll see the inside of a hypercube.

The 'Gh' option prints the geometric intersections between adjacent facets. Note the strong convexity constraint for post-merging ('C0.1'). It deletes the small facets.

»rbox 20 D3 | qdelaunay G >eg.31.4d.delaunay

The Delaunay triangulation of 3-d sites corresponds to a 4-d convex hull. You can't see 4-d directly but each facet is a 3-d object that you can project to 3-d. This is exactly the same as projecting a 2-d facet of a soccer ball onto a plane.

Here we see all of the facets together. You can use Geomview's ndview to look at the object from several directions. Try turning on edges in the appearance menu. You'll notice that some edges seem to disappear. That's because the object is actually two sets of overlapping facets.

You can slice the object apart using Geomview's 4dview. With 4dview, try slicing along the w axis to get a single set of facets and then slice along the x axis to look inside. Another interesting picture is to slice away the equator in the w dimension.

»rbox 30 s D4 | qconvex s G Pd0d1d2D3

This is the positive octant of the convex hull of 30 4-d points. When looking at 4-d, it's easier to look at just a few facets at once. If you picked a facet that was directly above you, then that facet looks exactly the same in 3-d as it looks in 4-d. If you pick several facets, then you need to imagine that the space of a facet is rotated relative to its neighbors. Try Geomview's ndview on this example.

»Halfspace intersections

»rbox 10 r s Z1 G0.3 | qconvex G >eg.33a.cone

»rbox 10 r s Z1 G0.3 | qconvex FV n | qhalf G >eg.33b.cone.dual

»rbox 10 r s Z1 G0.3 | qconvex FV n | qhalf Fp | qconvex G >eg.33c.cone.halfspace

These examples illustrate halfspace intersection. The first picture is the convex hull of two 20-gons plus an apex. The second picture is the dual of the first. Try loading both at once. Each vertex of the second picture corresponds to a facet or halfspace of the first. The vertices with four edges correspond to a facet with four neighbors. Similarly the facets correspond to vertices. A facet's normal coefficients divided by its negative offset is the vertice's coordinates. The coordinates are the intersection of the original halfspaces.

The third picture shows how Qhull can go back and forth between equivalent representations. It starts with a cone, generates the halfspaces that define each facet of the cone, and then intersects these halfspaces. Except for roundoff error, the third picture is a duplicate of the first.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull examples: contents


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qdelaun.html0000644000176200001440000006747314664417655020302 0ustar liggesusers qdelaunay -- Delaunay triangulation Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options

[delaunay]qdelaunay -- Delaunay triangulation

The Delaunay triangulation is the triangulation with empty circumspheres. It has many useful properties and applications. See the survey article by Aurenhammer ['91] and the detailed introduction by O'Rourke ['94].

Example: rbox r y c G0.1 D2 | qdelaunay s Fv TO result
Compute the 2-d Delaunay triangulation of a triangle and a small square. Write a summary to the console and unoriented regions to 'result'. Merge regions for cocircular input sites (i.e., the square).
 
Example: rbox r y c G0.1 D2 | qdelaunay s Fv Qt
Compute the 2-d Delaunay triangulation of a triangle and a small square. Write a summary and unoriented regions to the console. Produce triangulated output.
 
Example: rbox 10 D2 | qdelaunay QJ s i TO result
Compute the 2-d Delaunay triangulation of 10 random points. Joggle the input to guarantee triangular output. Write a summary to the console and the regions to 'result'.

Qhull computes the Delaunay triangulation by computing a convex hull. It lifts the input sites to a paraboloid by adding the sum of the squares of the coordinates. It scales the height of the paraboloid to improve numeric precision ('Qbb'). It computes the convex hull of the lifted sites, and projects the lower convex hull to the input.

Each region of the Delaunay triangulation corresponds to a facet of the lower half of the convex hull. Facets of the upper half of the convex hull correspond to the furthest-site Delaunay triangulation. See the examples, Delaunay and Voronoi diagrams.

See Qhull FAQ (local) - Delaunay and Voronoi diagram questions.

By default, qdelaunay merges cocircular and cospherical regions. For example, the Delaunay triangulation of a square inside a diamond ('rbox D2 c d G4 | qdelaunay') contains one region for the square.

Use option 'Qz' if the input is circular, cospherical, or nearly so. It improves precision by adding a point "at infinity," above the corresponding paraboloid.

If you use 'Qt' (triangulated output), all Delaunay regions will be simplicial (e.g., triangles in 2-d). Some regions may be degenerate and have zero area. Triangulated output identifies coincident points.

If you use 'QJ' (joggled input), all Delaunay regions will be simplicial (e.g., triangles in 2-d). Coincident points will create small regions since the points are joggled apart. Joggled input is less accurate than triangulated output ('Qt'). See Merged facets or joggled input.

The output for 3-d Delaunay triangulations may be confusing if the input contains cospherical data. See the FAQ item Why are there extra points in a 4-d or higher convex hull? Avoid these problems with triangulated output ('Qt') or joggled input ('QJ').

The 'qdelaunay' program is equivalent to 'qhull d Qbb'. It disables the following Qhull options: d n v H U Qb QB Qc Qf Qg Qi Qm Qr Qv Qx TR E V FC Fi Fo Fp Ft FV Q0,etc.

Copyright © 1995-2020 C.B. Barber


»qdelaunay synopsis

qdelaunay -- compute the Delaunay triangulation.
    input (stdin): dimension, number of points, point coordinates
    comments start with a non-numeric character

options:
    Qu   - furthest-site Delaunay triangulation
    Qt   - triangulated output
    QJ   - joggled input instead of merged facets
    Tv   - verify result: structure, convexity, and in-circle test
    .    - concise list of all options
    -    - one-line description of each option
    -?   - this message
    -V   - version

output options (subset):
    s    - summary of results (default)
    i    - vertices incident to each Delaunay region
    Fx   - extreme points (vertices of the convex hull)
    G    - Geomview output (2-d and 3-d points lifted to a paraboloid)
    m    - Mathematica output (2-d inputs lifted to a paraboloid)
    o    - OFF format (shows the points lifted to a paraboloid)
    QVn  - print Delaunay regions that include point n, -n if not
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes

examples:
    rbox c P0 D2 | qdelaunay s o          rbox c P0 D2 | qdelaunay i
    rbox c P0 D2 | qdelaunay Fv           rbox c P0 D2 | qdelaunay s Qu Fv
    rbox c G1 d D2 | qdelaunay s i        rbox c G1 d D2 | qdelaunay Qt
    rbox M3,4 z 100 D2 | qdelaunay s      rbox M3,4 z 100 D2 | qdelaunay s Qt

»qdelaunay input

The input data on stdin consists of:

  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qdelaunay < data.txt), a pipe (e.g., rbox 10 | qdelaunay), or the 'TI' option (e.g., qdelaunay TI data.txt).

For example, this is four cocircular points inside a square. Its Delaunay triangulation contains 8 triangles and one four-sided figure.

rbox s 4 W0 c G1 D2 > data
2 RBOX s 4 W0 c D2
8
-0.4941988586954018 -0.07594397977563715
-0.06448037284989526 0.4958248496365813
0.4911154367094632 0.09383830681375946
-0.348353580869097 -0.3586778257652367
    -1     -1
    -1      1
     1     -1
     1      1

qdelaunay s i < data


Delaunay triangulation by the convex hull of 8 points in 3-d

  Number of input sites: 8
  Number of Delaunay regions: 9
  Number of non-simplicial Delaunay regions: 1

Statistics for: RBOX s 4 W0 c D2 | QDELAUNAY s i

  Number of points processed: 8
  Number of hyperplanes created: 18
  Number of facets in hull: 10
  Number of distance tests for qhull: 33
  Number of merged facets: 2
  Number of distance tests for merging: 102
  CPU seconds to compute hull (after input): 0.028

9
1 7 5
6 3 4
2 3 6
7 2 6
2 7 1
0 5 4
3 0 4
0 1 5
1 0 3 2

»qdelaunay outputs

These options control the output of Delaunay triangulations:

Delaunay regions
i
list input sites for each Delaunay region. The first line is the number of regions. The remaining lines list the input sites for each region. The regions are oriented. In 3-d and higher, report cospherical sites by adding extra points. Use triangulated output ('Qt') to avoid non-simpicial regions. For the circle-in-square example, eight Delaunay regions are triangular and the ninth has four input sites.
Fv
list input sites for each Delaunay region. The first line is the number of regions. Each remaining line starts with the number of input sites. The regions are unoriented. For the circle-in-square example, eight Delaunay regions are triangular and the ninth has four input sites.
Fn
list neighboring regions for each Delaunay region. The first line is the number of regions. Each remaining line starts with the number of neighboring regions. Negative indices (e.g., -1) indicate regions outside of the Delaunay triangulation. For the circle-in-square example, the four regions on the square are neighbors to the region-at-infinity.
FN
list the Delaunay regions for each input site. The first line is the total number of input sites. Each remaining line starts with the number of Delaunay regions. Negative indices (e.g., -1) indicate regions outside of the Delaunay triangulation. For the circle-in-square example, each point on the circle belongs to four Delaunay regions. Use 'Qc FN' to include coincident input sites and deleted vertices.
Fa
print area for each Delaunay region. The first line is the number of regions. The areas follow, one line per region. For the circle-in-square example, the cocircular region has area 0.4.
 
 
Input sites
Fc
list coincident input sites for each Delaunay region. The first line is the number of regions. The remaining lines start with the number of coincident sites and deleted vertices. Deleted vertices indicate highly degenerate input (see'Fs'). A coincident site is assigned to one Delaunay region. Do not use 'QJ' with 'Fc'; the joggle will separate coincident sites.
FP
print coincident input sites with distance to nearest site (i.e., vertex). The first line is the number of coincident sites. Each remaining line starts with the point ID of an input site, followed by the point ID of a coincident point, its region, and distance. Includes deleted vertices which indicate highly degenerate input (see'Fs'). Do not use 'QJ' with 'FP'; the joggle will separate coincident sites.
Fx
list extreme points of the input sites. These points are on the boundary of the convex hull. The first line is the number of extreme points. Each point is listed, one per line. The circle-in-square example has four extreme points.
 
 
General
FA
compute total area for 's' and 'FS'
o
print lower facets of the corresponding convex hull (a paraboloid)
m
Mathematica output for the lower facets of the paraboloid (2-d triangulations).
FM
Maple output for the lower facets of the paraboloid (2-d triangulations).
G
Geomview output for the paraboloid (2-d or 3-d triangulations).
s
print summary for the Delaunay triangulation. Use 'Fs' and 'FS' for numeric data.

»qdelaunay controls

These options provide additional control:

Qt
triangulated output. Qhull triangulates non-simplicial facets. It may produce degenerate facets of zero area.
QJ
joggle the input to avoid cospherical and coincident sites. It is less accurate than triangulated output ('Qt').
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
Qu
compute the furthest-site Delaunay triangulation.
Qz
add a point above the paraboloid to reduce precision errors. Use it for nearly cocircular/cospherical input (e.g., 'rbox c | qdelaunay Qz'). The point is printed for options 'Ft' and 'o'.
QVn
select facets adjacent to input site n (marked 'good').
Tv
verify result.
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
TFn
report progress after constructing n facets
PDk:1
include upper and lower facets in the output. Set k to the last dimension (e.g., 'PD2:1' for 2-d inputs).
f
facet dump. Print the data structure for each facet (i.e., Delaunay region).

»qdelaunay graphics

For 2-d and 3-d Delaunay triangulations, Geomview ('qdelaunay G') displays the corresponding convex hull (a paraboloid).

To view a 2-d Delaunay triangulation, use 'qdelaunay GrD2' to drop the last dimension and view ridges. This is the same as viewing the hull without perspective (see Geomview's 'cameras' menu).

To view a 3-d Delaunay triangulation, use 'qdelaunay GrD3' to drop the last dimension and view ridges. You may see extra edges. These are interior edges that Geomview moves towards the viewer (see 'lines closer' in Geomview's camera options). Use option 'Gt' to make the outer ridges transparent in 3-d. See Delaunay and Voronoi examples.

For 2-d Delaunay triangulations, Mathematica ('m') and Maple ('FM') output displays the lower facets of the corresponding convex hull (a paraboloid).

For 2-d, furthest-site Delaunay triangulations, Maple and Mathematica output ('Qu m') displays the upper facets of the corresponding convex hull (a paraboloid).

»qdelaunay notes

You can simplify the Delaunay triangulation by enclosing the input sites in a large square or cube. This is particularly recommended for cocircular or cospherical input data.

A non-simplicial Delaunay region indicates nearly cocircular or cospherical input sites. To avoid non-simplicial regions either triangulate the output ('Qt') or joggle the input ('QJ'). Triangulated output is more accurate than joggled input. Alternatively, use an exact arithmetic code.

Delaunay triangulations do not include facets that are coplanar with the convex hull of the input sites. A facet is coplanar if the last coefficient of its normal is nearly zero (see qh_ZEROdelaunay).

See Imprecision issues :: Delaunay triangulations for a discussion of precision issues. Deleted vertices indicate highly degenerate input. They are listed in the summary output and option 'Fs'.

To compute the Delaunay triangulation of points on a sphere, compute their convex hull. If the sphere is the unit sphere at the origin, the facet normals are the Voronoi vertices of the input. The points may be restricted to a hemisphere. [S. Fortune]

The 3-d Delaunay triangulation of regular points on a half spiral (e.g., 'rbox 100 l | qdelaunay') has quadratic size, while the Delaunay triangulation of random 3-d points is approximately linear for reasonably sized point sets.

With the Qhull library, you can use qh_findbestfacet in poly2.c to locate the facet or adjacent facet that contains a point. First lift the point to the paraboloid (i.e., the last coordinate is the sum of the squares of the point's coordinates -- qh_setdelaunay). Do not use options 'Qbb', 'QbB', 'Qbk:n', or 'QBk:n' since these scale the last coordinate. See locate a facet with qh_findbestfacet()

If a point is interior to the convex hull of the input set, it is interior to the adjacent vertices of the Delaunay triangulation. This is demonstrated by the following pipe for point 0:

    qdelaunay <data s FQ QV0 p | qconvex s Qb3:0B3:0 p

The first call to qdelaunay returns the neighboring points of point 0 in the Delaunay triangulation. The second call to qconvex returns the vertices of the convex hull of these points (after dropping the lifted coordinate). If point 0 is interior to the original point set, it is interior to the reduced point set.

»qdelaunay conventions

The following terminology is used for Delaunay triangulations in Qhull for dimension d. The underlying structure is the lower facets of a convex hull in dimension d+1. For further information, see data structures and convex hull conventions.

  • input site - a point in the input (one dimension lower than a point on the convex hull)
  • point - a point has d+1 coordinates. The last coordinate is the sum of the squares of the input site's coordinates
  • coplanar point - a coincident input site or a deleted vertex. Deleted vertices indicate highly degenerate input.
  • vertex - a point on the paraboloid. It corresponds to a unique input site.
  • point-at-infinity - a point added above the paraboloid by option 'Qz'
  • lower facet - a facet corresponding to a Delaunay region. The last coefficient of its normal is clearly negative.
  • upper facet - a facet corresponding to a furthest-site Delaunay region. The last coefficient of its normal is clearly positive.
  • Delaunay region - a lower facet projected to the input sites
  • upper Delaunay region - an upper facet projected to the input sites
  • non-simplicial facet - more than d input sites are cocircular or cospherical
  • good facet - a Delaunay region with optional restrictions by 'QVn', etc.

»qdelaunay options

qdelaunay -- compute the Delaunay triangulation
    http://www.qhull.org

input (stdin):
    first lines: dimension and number of points (or vice-versa).
    other lines: point coordinates, best if one point per line
    comments:    start with a non-numeric character

options:
    QJ   - joggled input instead of merged facets
    Qt   - triangulated output
    Qu   - compute furthest-site Delaunay triangulation

Qhull control options:
    Qa   - allow input with fewer or more points than coordinates
    QJn  - randomly joggle input in range [-n,n]
    QRn  - random rotation (n=seed, n=0 time, n=-1 time/no rotate)
    Qs   - search all points for the initial simplex
    Qz   - add point-at-infinity to Delaunay triangulation

Qhull extra options:
    QGn  - print Delaunay region if visible from point n, -n if not
    QVn  - print Delaunay regions that include point n, -n if not
    Qw   - allow option warnings
    Q12  - allow wide facets and wide dupridge
    Q14  - merge pinched vertices that create a dupridge

T options:
    TFn  - report summary when n or more facets created
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes
    Ts   - statistics
    Tv   - verify result: structure, convexity, and in-circle test
    Tz   - send all output to stdout

Trace options:
    T4   - trace at level n, 4=all, 5=mem/gauss, -1= events
    Ta   - annotate output with message codes
    TAn  - stop qhull after adding n vertices
     TCn - stop qhull after building cone for point n
     TVn - stop qhull after adding point n, -n for before
    Tc   - check frequently during execution
    Tf   - flush each qh_fprintf for debugging segfaults
    TPn  - turn on tracing when point n added to hull
     TMn - turn on tracing at merge n
     TWn - trace merge facets when width > n

Precision options:
    Cn   - radius of centrum (roundoff added).  Merge facets if non-convex
     An  - cosine of maximum angle.  Merge facets if cosine > n or non-convex
           C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge
    Rn   - randomly perturb computations by a factor of [1-n,1+n]
    Wn   - min facet width for outside point (before roundoff)

Output formats (may be combined; if none, produces a summary to stdout):
    f    - facet dump
    G    - Geomview output (see below)
    i    - vertices incident to each Delaunay region
    m    - Mathematica output (2-d only, lifted to a paraboloid)
    o    - OFF format (dim, points, and facets as a paraboloid)
    p    - point coordinates (lifted to a paraboloid)
    s    - summary (stderr)

More formats:
    Fa   - area for each Delaunay region
    FA   - compute total area for option 's'
    Fc   - count plus coincident points for each Delaunay region
    Fd   - use cdd format for input (homogeneous with offset first)
    FD   - use cdd format for numeric output (offset first)
    FF   - facet dump without ridges
    FI   - ID of each Delaunay region
    Fm   - merge count for each Delaunay region (511 max)
    FM   - Maple output (2-d only, lifted to a paraboloid)
    Fn   - count plus neighboring region for each Delaunay region
    FN   - count plus neighboring region for each point
    FO   - options and precision constants
    FP   - nearest point and distance for each coincident point
    FQ   - command used for qdelaunay
    Fs   - summary: #int (8), dimension, #points, tot vertices, tot facets,
                    output: #vertices, #Delaunay regions,
                                #coincident points, #non-simplicial regions
                    #real (2), max outer plane, min vertex
    FS   - sizes:   #int (0)
                    #real (2), tot area, 0
    Fv   - count plus vertices for each Delaunay region
    Fx   - extreme points of Delaunay triangulation (on convex hull)

Geomview output (2-d and 3-d points lifted to a paraboloid)
    Ga   - all points as dots
     Gp  -  coplanar points and vertices as radii
     Gv  -  vertices as spheres
    Gc   - centrums
    GDn  - drop dimension n in 3-d and 4-d output
    Gh   - hyperplane intersections
    Gi   - inner planes only
     Gn  -  no planes
     Go  -  outer planes only
    Gr   - ridges
    Gt   - transparent outer ridges to view 3-d Delaunay

Print options:
    PAn  - keep n largest Delaunay regions by area
    Pdk:n - drop facet if normal[k] <= n (default 0.0)
    PDk:n - drop facet if normal[k] >= n
    PFn  - keep Delaunay regions whose area is at least n
    Pg   - print good Delaunay regions (needs 'QGn' or 'QVn')
    PG   - print neighbors of good regions (needs 'QGn' or 'QVn')
    PMn  - keep n Delaunay regions with most merges
    Po   - force output.  If error, output neighborhood of facet
    Pp   - do not report precision problems

    .    - list of all options
    -    - one line descriptions of all options
    -?   - help with examples
    -V   - version

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/normal_voronoi_knauss_oesterle.jpg0000644000176200001440000005656413431000556024770 0ustar liggesusersÿØÿàJFIFÿþ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 80 ÿÛC   %# , #&')*)-0-(0%()(ÿÛC   (((((((((((((((((((((((((((((((((((((((((((((((((((ÿÀ8 "ÿÄ ÿĵ}!1AQa"q2‘¡#B±ÁRÑð$3br‚ %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ ÿĵw!1AQaq"2B‘¡±Á #3RðbrÑ $4á%ñ&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖרÙÚâãäåæçèéêòóôõö÷øùúÿÚ ?Í9ÉäÒdúšyšLVä Éõ4dúšv(Å7'ÔÑÏ©§b´ÜŸSFO©§b´Þ}MúšvÚ1@ Éõ4dúšvÚ1@ çÔÒóêiqFÚnO©£'ÔӶѶ€sêhçÔÓ±FÚo>¦Ž}M;mh¼úš2}M;m óêhçÔÕí2ÀßNêÒÇ1FÒË4Ÿv4QÉ? ú‘U¦…¡•ã|nSƒŠ@E“êhçÔӶѶ˜ çÔÒóêiqFÚnO©£ŸSNÛ@Þ}M9êiÛhÅ7ŸSFO©§bŒPr}MúšvÚ1@ Éõ4¼úš\QŠN}M&O©§m£m'>¦“ŸSNÅ äúš2}M;mh¹>¦Ž}M;b€Î:š^}M.(Å7ŸSG>¦Š1@ Éõ4£9š]´ r(Ärh©äÒb ŧâ—ÈèÅIŠ1@\ŽŒSð=(Å3SñF(˜£üQŠe§âŒPE?b€EIIŠe§â—€¹(ÅIéFqúÜìƒkÑã÷ÚtKô$9>ê*ž•qöëŽnlþSêÑgÿÀOBµ©bŸlYtgé©Å,q{N^/Ì‚¿ð:ã,o$Óõ$ºŒÚ~d=Hù”ýA"£©GIEXž8ÁW‹Á*‰"cÝO¯¸äpj,U’2Š““ÆQOÅ.GŠ1OÅ QŠ~)p=(:)ø¥Àô ñE?b€Š*LJ0(Ð^Åm¾Ê)e‘‚7•€Xªàœ³÷…s>#Õ®Á†;Ÿ³BÜ­”B¤{íä©4Ô®:†Ó.rÊ"ŽURÞKÈ¢B$ü™Ï@O#µSÅexNém5ppLB šFÀ?»K{’´QLi,n²C ÊH½¨íM;‰¢,QŠ“bªÂ"Å©qF(°bŒT¸£X±F*]´b‹(ÅKŠ6Ñ`"Å.*LQŠ,X£&)qE€‹ r*M´äQ`%#šMµ1^M&Ú‹mj]´m ¶Ñ¶¥ÛFÚ‹m©vѶ€"ÛFÚ—mh-´m©vѶ€"Åj]´m ¶ÑŠ—mh-´m©HÅ:+­-ôk{·–hüÛ‰`ó±º0T)œÇ‘ž)7a؃m«R[²F²‚²@ÿrXÎäo¡ýºÔ[i(ÛRí£m#´u'sü7ÿ’Òדhí·Vµ÷Ìãú×­…ÀÔŸûšeÑÿÈ.?­xõ³yw–ïýÙýk)nËEÒ;WMáËØ¯mN¨¸TcºÞSÏ”ÿáØOp+Ÿ6Ï*ú1­0¬9v§¸Ž«L[½+Z*ð’cÊ\! )ŒõËtÆ0AéÐÖ½ÅóË3áÛÉ|Ñ7–Jþðþ§­eøõu³Ó’Wûe­œ-q㇑—yõ€LwË륎b&”[­ºÈbÞvnb[8éœÍ$ßAØÝ½X#•¦Öux<îé}¢Cì6ü£èXVtºöŸoņœ×ÿ=od8úˆÓüY…sx£ìö¿ª^Äa’飶=`€£?U\õ5»á:6©ø¾[‚­c`{ùŒ¿¼qþê}Z¹k+I¯o µ¶C$óȱƣø˜œùšêÔžLW’¯ýô¨¥2V[hIqó£úKáÖQá;ÒçÈß'¶QÇô¬›©Œò–è¿Â=?úôy¹¢CÕï¤ÿY;Gf‡Øí Eð*é¼'<);sºö$LöÂ9l~kù À¼ìºgÑž6½“ýéËÿŽ"ƺý D^¶ø¥»yÏÓþ€i¡2¶Ú6Ô»hÛZE¶µ:ÆÎÁUK1èɦ\4V¤‹©á‡U‘ÀoûçïÀP2=´mª“kZtyØó\Þ\{Tþ-‚?ï“Tfñ-¬¡ŒzÊÆF–ÑùƒJàm* ($žÂ–tÃý*H­ûâgOÐOá\¬ú¾£8!ï%U=V,D§êÔ:v›q¨LÉk;Fé$cµPy˜ð+…ކm[N‹…š[†ì!ˆãól~€ÔÏx– &ÔàŽÏ~fBÇ€ƒê ö¬¯¶Zhãn•‹›ßâ½uùPÿÓ5?úçÐ £§ØÝë:¤vðî–âfË;œã¹f>€rM&ØÎÊvK‹K È¢H–æ å;Uƒ23þ®ÜG¼6ö6d½µª”Wn®Äå›Û' íUöÕ-„E¶µ.Ú6ÓÚP¼Š“m(^EJW“I¶¦+Í&ÚE¶µ.Ú6Ð[hÛRí£mE¶µ.Ú6Ð[hÛRí£mE¶µ.Ú6Ð[hÛRí£mE¶µ.ÚÀ&€9Ÿßþ…`°Ì¬;O©þ_….œ>ÑàÍZß½¬ðÝ(ôtmÿ¡%gk,­ßª(P²‘íÇô­_$Ô`7ÝXÏHÃ;äUóªγ½ÕË·C+OÔ.ô»‰ÈóbûÃèÊx5ÑØë–¸[¥Ÿâh[ù•ýGÒ¼¨K ›ÎWa6woÏ9­ËØî”,€E7B?…¾ž”\L’ÚHöWûޤ2·ÐŽ E}«7ö|ï¢AgæØ;%È’+²îÀ”nÈÆx#që\ׇµK6þóZ4«çBÜ« óÁèqߨ¢áçð÷‰n~ÎÁžÞgŒ‡.H*ø# ÓnàEwâíd“¸·1ÊŒ³…USòœ È>•ËC¢ß07I¥ÜÿÏH3,ê„î_¨'ØWAâË(mÞÇSÓÃ2âQ´“ ½{ŽÞ£ŸZóûˆ¼›™£?ÀÅ#RÆŽÏRÒnOwm²îбs5¹Þï«ÿ›ám9uOiÖrq ³/š}#¹üƆê{ibžÒiaY^6*ÃåäWSá]íz“ÛÞÃiíÜÚÃ~Ëdy¨, sœŒóœÐ„sÚÞ±.£â[ýT5Äï(_öIà~X¦êíöÜ^)ÜB¬r/÷p0º~?QTn`’Úy`9£bŽÕHàƒO·­î$`7!fVCцOl;•è«76áZZ Qò>ã§ÿ®³#’æîá`³„™¶ŒòsÓð§p:¿ H4‹[ÍzFÖËäÚ“Þwÿ?•aY±™œáÎõ8=Û'¶hø®H¬Åž9H•Û4í˶;ã…ç¦ eØÃ<‘Í,l|Ç“ŒôÉÉéSæö*Ë¢kÇ÷#x\3.ñêfŸ§Ï¨L#·BFF÷è¨=Xô­ø Õ&}ZÖ6‚æG·ƒÉå ȧæ‘ÐdŸaÖº½^×BŽ4µx5;ö_”ù[líóÞ8ßoöŸò9¦€ÑÔtí:K¹5-JðÁ¥q¹ A–4TFÌçtÚ««§Ï¥­m…ž¢\Fòe䙓 FzäœÔž½k˵ Û­Féîoç’âwêòŸ§°ö®ÇQSeáM>3Ãß$oÿlÑr?6‘¿ïšb%›^±ˆ–{†ÿeB)üO#þùªøŠàñoo#±lÈÃóÂÿ㵊1T"ÅÎ¥}r¥g»™õEmˆà+úU5P£ ¤Å c1F*Õ•œ÷³ˆmbi$<àv¤öõ¦$²Ñ¿ÔywÚˆÿ–¤fû#øÏ¹ãëHm´¤‚»Ö$k{vŽ%½›ýÑØ´ Ô:Ž©%Ô"ÚÖÖÅNVÞ3Æ}Xõf÷?¥U¹š[©Þk‰Y\åÎI¨ñ@ DiQ³1ÀP2I¯BÓìW@°{U ê3ö§À:ˆöïïôªÓÆ—o£:í ×6‘‘þ©:ˆõ쿟aZ~§ÜЕÄô"ÛFÚ—mjÉ"ÛFÚ—mh-´¡y&ÚP¼Ð¤rhÅHW“FÚ`GŠLT»hÛ@bŒT»hÛ@â“.Ú6Ðx£&Ú6ÐX¥ÅI¶´(ÅI¶´)Q7º¯÷ˆ?m6Fò£y?çš—ü†¥'°Ñç—‘JÚ˜~ÐÇ0''æuæµ4Ɇ‘®øz{ø^%[£‡*AÆW#ÝHb?­rºœ2\kæÞ/#ùqªŽçbŠˆ[\iÀ}¦2m& ù‘ˑѕ‡â+/"ȵëÒõ»û5´ï>ÌER^‚A?Ï·ù÷®Óâ˯4’2ÿ¦A Ô2öËÆ í»w=«Ž’6™u8 õ˜H±Üe— =Çùô®·Äî'ÔÖàr.­¡ºVõÜ€?þ>ó®ŒóŒfºMJ诇ü3¨‘ žÂ^…X8Ïá)ü© ¹i©[Ù–²Õ¤ÒowpïFGÝ•ÚSùŒŽõÊøÃK—I×î ‘–Dp²Ç2}ÙQ†C¯±«º´‚X”m*ÈØaÔ}A­M<Ãâ-*Û@»eKÕRÚmÃ3'01þëqFúÐõ–Sû¸sòÇÒ”­•Î:ƒNòd„g£š&hÝ`«9zÓed‰q3ªÐ£êJéÃó«v^MíÍÌ2Ü ‹x yVÒÜV ɈëÁ=æ±în%òZY¤w–OÝ©c’ðüM?²µ¾¿i2¨eFùÁèPýìûmÍ;é<%ªÏ}yu CZrÚLÒ1¶=ÁwsÝËÉ$š«3´·œåŽXš·¡X½¯¿³mãvHÄÑ(9VFè ÔW6——.—pK€¶T*#õ¦€‰T³PK€zë¬Ç’iy:™f’K‹¦ q)Üä è vp;.Ú6Õ¥bH±F*]´m¦",Râ¤ÛFÚ‹ r*M´äP¸äÒb¤#“F(˜£üQŠf(Å?¸ ñF*LRb€ŠLT˜£)qRb“ÌRb¤Å b©êí³M¹oúfÃóZÓh¼»V¹¸xííW¬Ó8DÙ5‰q¨iÚÌ7:v—sö›¹"&"¸UvR`ÉÎNÒ ãÖ¦MlR]O<»²>·©ttÿE€ÿÓGùr>ŠþUÏ隥ޚX[Éû¦ûñ8Üõ§â{¡=”p+L³M)8ÿZ[OÑv×½sõš(ô}v[moÂ>¼>M´¡e³ N(û¶†Ðq‘Ž1ÍVñ/Št}<› €uSnÅWMµCi§ÂÃûË÷ä ÷5Ëj~/Ö5› ,îdK LþîÖÑDQ•î Ž[×'=é]Œô $Aá›Vö?ì»ÍFÒ1‹M)Vfµ9‘ÝÉbW€HÉqç×ú¥—%Ž;¹EŽ«òàžrs.IÛ!P¶I;€ÁÏ#«V©>…ªÃs§Ê`¸‰¹c’Hî×Òºm{I´ñ•γᘖ+Ô]÷–*0L±ê{áç·C¨Ʀ³ÛêRÙÞC$2Áò*È0Jއñ랇5ÒøoCžå…¼(|ù†d$ãbŽpIèRON;ñT¼?zë1xžÕ¦±‡Ù]ÁÄsÑ?¼ƒ©SÁí‚s]—Š’çKÝ£éÐÌÖò"I-Ú®Màa¹H#8ž~<Ó GWÓí¡¹ÓmyVeT¹Ô"`¯&Ñ€ªÿVdÇ&³¬.µ»xvhÚ«jÙ$ZH7¡…ò ÿwwÖ³^ÆíQ›ì³à ÿ«?áU£P†sµTr}ý½;ô/Þ®­m{g}§ÛÚMy°ù¶¨ÑÈ|µóHÚNÐ2ª0¬¨àT…dŠEš )"ô#úQIà}NâOø~+‹‰¤ŽG2Èåð® 㟭ex2äÛjöÖ·5²’äE¤ð*Ö©¢X'¼7³ùed7ÆCòþY¤äÒlv(ÅA§kQk?iYGh-™…rìÊÀòÄõ9Sеk'pjÃ1@Š~(šb$ÛÉ£ò94˜§`¶´üQŠn(Å;b€Š1NÅ b—ìQŠfÚ\S±F(° ÛXþ.ñ ørÂ×ìÐÄ÷·EÊ4©¸F«´dÇRzƒÒ·íÐ5ÄJà °?ZòŸˆ· úý­«±&ÚÍgûïûÆý_…DßB¢aêšö«qçêWs\Ê:;G öV’Úxç¶s±0taÙÈ?>^gÛÏrz=IíI-Ì00ŠÜ,ÎNF_p£úÔ Øñ1„Mk¬D i:Ê—žß§÷Ob Ü;a±Ó5ÌÞÚµ´ƒÑ?1J>ìƒÔéÔè´TŽí¯¼>v‹}UEÅn‘Ü®v¯¶ïš3õS\$k&ŸzÏ,Äa†L2tÈÇ+íêH΋À¿é6þ#ÓO?jÓ$u¯Ñ r¾[œIlÇón^ÕÕ|=K›OÛÉunEµ³rëþ­a,OM¥K~1\þ½¢ëÚoï§·Ÿì ߺ¹·­Øg‚2¿®h2i3{ ›,G·?á]„z£i_t9‹Ž8ìMÆîwn†3!?]Í\Þ™¦_kWŠº-œ—3?úÛd^ûc°ïý3C×ü-¡ÙkWz¿‰u5žàCio&Ĩ4IÀû¨ ÷¤3–Ðô¿øLµmÊÚID?iµF¿*à0RÌxÉ5v}#Ã^ÍñÇö¥ú ý‚ÊCå÷äêà8úÓ|SñPÔµâ‹Ë·Ò®&én¾_š ä¶9,}IÍpŽè59#–1»+g¿8ÿêï~#ë -œúqŽÂÆÎdxlí”$càצ9©|V‘é¾$¶ñ‹òi÷¶kŽˆÿÄŸð=;+Š `ŽEBJ’¥O¨9ÅwzM®xSðñ‡7ðFnì\ä#ý¥\€:(·Ä¿. NÎ5ºÄ)¨DGQ¼ÃþûßXšl1¸¸Ôn“u½ºí@ßòÒSÐ~Oÿ^·Îë_øg¥…þÛ¤^=›n £z1ÿd2°ükYž4Km.ÍÙ­†òßßcüGë×ñö¡¼“Å^;ùRê–q™ôægÎŒs-¾G9ºêEqþóBñóéÓ<3ÁpÛ û5vúu•®¼ZðõÌ:F­fÂæâÜ+ìG™b¬vœd®8ÆztäžêÐL‹,L¹êñ¶T{`Œ¯4;]O¨E摱ÈR‹÷W<äàŠê|u¡Ùß„ñFŸyfšuÃùW‹b ºÆ\"ÖûÃ8î;W?奼 ¤rº©É–P2Fy ×ý){×gþ 2â&ÂEw…‡÷C ʯxºØÙø«VHÁ¹W¸joèr\CáŠ=?O߸\ÊLyoECþÛOåW|uö{¿\_ÚÎ+ÿô˜Ô®Ö!ºõ#œ†ã­bí%¿†ð°û6£]î» 9úo ‘øýbd*pýu¥Â?… I-<ÉlîL#Í Yåq¹_ŸzϽ×ÞXl¢·Q7ñ"1o,ÿtNO¯P?:jVÐ-sTð¥‰GRx«I{ ÿ«Ì§ýžŸ™þ™¬K½YnïcŠÞÝYƒgi”Ô/ÓÔ`WSáMûZñäŸréÖß<î ô@}N?“ÚšacOÃ0OIªMM+’¶6Ì2ÇY\Ÿùfž¸ª„ý?k´±™/í žÕd)0%U—æàF> ×ž¿ØìÉóŸÎ˜uŽ GûÎx_Ö»(u+ÀÖÓGåÁ¨“öUBsobK†ë–'¯ñNö®o\ÚÇa™«ÝA`˜Î%9dÖï‹ì-òš5ƒ]Éÿ?g>ˆ:þf¸É¥Éq#M!9%Îyÿ?:^ãØ·ªêšŽ®âevó éùc_¢Ž?:¥Šu%m€Ùð{ìÕn"í-¹?аþŒÕÖí®#ÃòyZýƒvghü JÔŠî±U1¸£Šv)@欑ØäÑŠSE£Q@(ÅPŠ1EbŒQE¨o."²µ{‹†"1ÂÕÛû£üñRM,VÐ<÷,RêGV=”{šò-Å:Ž¥¨4ʱ%ºü±CõkéžçÔÔÊVÐiä'™îáH4ôË:¨-pN2qÓer"·ŠòO‡Q±¾Ñ] ˆŒ|Ç 9t dU/ j×3ø†Â9—jùÏË‘…ù#éYx–ëÃñÛA%¼7Ú]Ÿ7¶’$Þźö8# ØÖMÜ´ˆ¦•u,¾š kÍŨ9`?¿Ÿâ_åúÖ\kŒHÄ$`ä³tÿëÖ®½cŽ–zÿ†$žãJ¸lG3cu»÷ŠAëúëWCMVÆ-fîQ¤Ù¸>jH…³ŽI…G,¾Ý­+Etë¹­ŒVÀËs‰íÌ —Ï~ð'‚8íZ.Ò´t½ms\óšñáY¯4›B2³žÆB+`1rÄqTäñ/Ù#>·’Ö#ÃO!ßq/¯=EüI¬;è/–F¸ÓY‰F 6H¨Ç*Frnr Œè£ñ>‘â½SÃò$…m$·fkvîU9=þõcÙ[êÞÕdWÖNœPÿËÏúáרãi£ðªvÚl:¤–“ìKv‰·M|ÄÜò>éã¡ãž1Òµ<}g=ö‘áK¬ÅçMg$MûÅå–y8¿ («Öü`4mEXš(†¬¯s;E_-´3Œð;ƒë^u¯Ü&£©\\]ÝO³ÝÌ Š€ò°9Ú3Ç+oâ^—7Ø|2Û¡#LŽåÞ ™ãŽà‘‘\Ιi-ÿ•a$ðvÄá‰ù{©ã§_åR¸4纷qçÆÖ¨ªætlˆñœpy§_\éòÝMr’Z‘Ëq+äŸ`þu'ˆ¡:=¥¶™bë4F¯&xòO1©ÁÁÚc\×94bM’ò‘À¦ã^ÆÖαêRFTgýØ&ýô ]ÑîÓJû>½k%ÕÍÅ”«´³l*X}æëzu®VcY ÿ±£O7oÉÂåàýÌàgê§i RÒܯˆ¯ì´•K}+ÄyŸNû:„Û0ùÂ;‰®=z×›I Züs]éÈ"ÔW-sh¼ 1Õãþ«Û·:O \Ý%…Î’A:¾‡?ö€[ahdz(Ü=H…ã‹5Ò|w{-‹4Vr2êÏÇÉ  mÛ HlÂ+娈 $÷¿_Ê›ç3#>3" çÔdWDÃ-Áx¬õ—ͺÜŽUàÎg‘ßË›X~Õ!ë®AXÿà1õoÇj¡ Ö-¥¸×.ž@ûdŸ¼ öúÖ׆…Þ™ks$ý–ôO ˆC€êŠsc9ÀÊþuPj?ÚQ%µÜÞMÎ?s&v«û2Žzç.#ºÓï \#Ãv‡ tÛô=èÙ4}KD»³Z[+W/eu` %d•Heš,}Ö ÀàŒrFpxæäÔ4yðé–ÿÚÚ”’æõ1L>Xÿ‹p[¿j¹e`uI<dZ8V8_R¸]¤*)bìÿ÷Ìcq\óxºÏN¸¹“ÃP†Y&-%åéó¦~I;Wî§>€Ÿz@h;[ÖdmSÄwdµ`O|Ûqu#žŠ1W!Ô¼(ðå߮©{o1KÈÕ¶2%{à°æ¹{¯í »ƒ}ªßHc— ‹d”ÿ³‚x>üS¡º@’ D ß-¹ˆúöü)ˆõ/èKia©CáMjÛP¸º˜ ¼‹k %Z2 Éò=ÅrºÎ‚‰·ûBÙ´;’ÛD¬kG#²¿,¿†ÿ¸gý¡_Í}ãä$õíÏzí´_k¶j`º–;ô ƒow–vQÛpù€Çðç·JCDð–£>¡Q@‚ÝÙw‡‡ÉdIî+±Ô/ †Ê=EÞ,!Îç?zwîíõÇO@j¯»coá}GRÓôÕÓšgŽÖî%=K‚Ãp£…<©Írz¥ÍÔltdWPê¤R¤du?‰ªB5亵€îfaÕ# õsÀü3YwÚÔ’£E#Ö8²ªÞ?y¿ ÈyLolã ì>‚™T#¡ðv‘'‰Ó\uÆ¿¨ßjBþöîYnÁâF==€è°â½wGÐõ4Ï?”÷~²ÑÒO5'F‘ŒX@©ÊÅy˜Òíî.#|ÚãqRHÏ9#¡ú€~´ ­«Ý2\Ë ¤ ǘ#ÉÀÈúgúØMÊ£Ö0ÜÀ~}i43Íô{tÓ¨IzÖño³’5/:Xãh'ŒŠÉòð <öæN€4 îk­>0¿³GIt ÛÊ_ÊÊÒ Æc¹IàsÐõ¬ù>"ëÈÇÊ:dôK¶R?ñÊwb9ój6îÍÉc(ËóÚµìm§Ô,…ï—3ģɑ,pGÈxä}zzÔÖ¿]¹žþh­ vùŽ2=‡Sø çu/jI!†ÖÓû7ý§\ËŽçs?+Î5­dêWF¦i÷X±g•½O|z —1¤vÞ#ñ¾’êi¶“_*sºà˜âfþöÁó7°$}+Ô5Í[Z_&YØ[E¼ G÷Fâjœv±Çþ½Ô¿üóVÿ þj8dœ¬h¡?,pŒŒþMADöЩ;™$uRÇs@ÏSŒþŸejW™”–k“‘WåAôÿëb» + O7Ä7±iq8â"7ÎãÚ1ÈúœVøŠ )|Ÿi+“À¼D·ÝF6§à?!__5¢Ýk×0hšcr¿hYÇû™¹üéö:½•ƒ±ð†æMÞÕõ,~ïÝSrk õnšç^º—SÔ[“¶ûoÏä*+Æ»».™- _õpãb¨öAÏãŠm®¤Ú†®.×T¼¸ÔbùÌžc@Æè‡PSƒžàVá¿Ñõ©Ù|K<:f¶É„Õbä7΀mÏûkõ"¸|˜&O(&È Íò`çŒc-×é]v—cuâ o¡ºO+I€í7òü‚ßcÿÏð*[ŸªølézÊYO¢ÜÍs; <Ãʸøâòó¼¸ Þµï5{_ÆÐÇoa?‰söxÁŽÇÛyÉi? µeâx<'ac£Y½ö¡£\³nÔÞ\2–RÀ9òÈÏ òyÍpZþ„ú=âŸ4]Ú\6ÞíyY÷ö>£±£¨Vz¹Ô­$‡Q•çbLŽÎ²EÉ;Àa󯪞GQß•’iÌ¿j´·x&¢¸´”¨z€r? §1H²BÛNC/ÕŠñ^ÙÕ YíØï¹³Çüµ‹ÐúéÑì‰ÉÕt„6W“Åyb˜bù_2ÙÚNvúñÁ¬½*ÿWÑõK}NÇ\[°uhpÙö;}}êÆÉô˘55ÖêÍ›á8Üv8íßµ[ºðäÑÜýº vkGÄG'É´žÍœp¾ø¥`:ŸˆVú÷…ô_ÃÖR gVŽke_ø÷}ÌþXö&F+ì=«Í~ÇsËwg-»™~y¯Xðs‰ä“E¼·šúÒ}>YeB Ç$ˆ ŠwAÜ0Ç‘Šu,ôi*31ódÿÇÙ¿•qM½ÄðßÇ2O T@Š¥›;Áè9þël<#â´Ás—:]Ü)Ey±À %ÈOaõ«?ð–ëL«sâY@s¼Go•=Ð>¸®wYŠýµ äòI†W[µÞTô 9ΠŠ7„¼#¦ª×z”–·V‰æÅ¦Û\¤¯#‚1¸FÕûÄIÆ1Ö¹Ý [ÄW^"Õ®§K[Y~Ósr§_?,h¼HÀô=ª„—–7°\ƒsmå¸`Í!Î{0ãõ®¿â#Ý2XÛHÈÍjª÷«vcV.ØêOLÿ³@_ˆwW—kºe“$³7dŽf NNàÃæúõ©uIu‰îtÚÌ–’ :?1GQº?½œwåSœ?ïç#¾jü×—z»Íe¹¤E¨_]8‰.¡ýÔëþÓ0à€2NAÀ*î§¥|?Ðõ{.G×5k«yŒ$ÛÈ‘Äì:ã4=½¡x°]_½íõœ wdŸe†8ÔÆ²ÂÊG”9ÇÝ'‚?•Ë?E™¯VÃR’Í|¶·Ô®ÆÈ y€`ò=tRø›Ã6Ò=½„¬Ì6˜&{«™&±ºx'ŒUh~)_Ítñ¥¦¥«qö¶ˆY1жAÏ”®{ü=ñ ÓRæÞÅ.lÔdÍÄn¹'Óv}J¡‰¨é.Ók6—VýOŸ_0Ëž§>+^ëǾ'¶¾µmjåo¬Ëƒæ ˜æNãnvž;Wõ=sÖú¤É©èkm"«­Î Û"žC˜Xl'§ÝÙÏ­ Äÿñ0‹uÑ0[’»# ¸ è28÷Ï5 Æ—)·y­Hºˆq¾r½ŽåûÊ©÷®œxfêëO{Ï ê6ú¤lÞd®O‘,iÑw#ãß;I&‘¥ÞGË}=ì¶ì®mô茿09!äáPvêx¦#S^T‹âmâ}Ø4}#É Œí)gý «ŠÓ㜠KKn FľcÏGHù¾¼t®âæ ‹ÍWXÔõ‹­?N¸¹È•`?j†pv•_” 3Ï5ƒu¬hð¶ú†®Ãîý®_*ô?Æ‹\ ivZ¾¿lšØ–Qn‚K‰¾ÞˆÔå·)Rí÷‡ZÕÖ¼N5OßC«#ÙFdòàÜò00Œ¼ |ó\Γã uE²¾²²·Ñ®¢x&†ÚŒ…l îêHÏ|ÕÍkL–åf°„º®h¥òûiŒ«ö”~™W%m‡¹³©46ž|±ûÙOáÐ~"€9ÅŽ$ú éü1¥_ÚÜÉwqnÐÛI @d!I;”Œ)ç±üë{Oµ´Óú'Ìÿžóïø þ¥wi´ŒYRNM5Åq´wQÜU’;¹¤¥=M%QPÞÇ,°à—ÊfàÉ·qQÜ‘“øŠœñ>®]šÂÍñÚi·û#Þ¹øÿtŒìÛЃŒ~5¼Þº‰·ZÞZÜŽNÉ3©b?CUN‰ª‹„‰´§2?ÝÛàý$cô¬®]‚ßÄ:­º…Kë‰ §zÿãÙýIkwm{!‚}Êw”óöHÚþøÀ?•Y—LÓ´¨Ëk³°¸-,ä?ј«ùÖ6£â÷ío¥4:E¹á–Øy“8ÿjN¿–*t·«h°Š7Ô/.´Û‡#ý Ê’ÉÀ|¿R~µ¨Mu£Â!¤ÃÝóg9ã™*™ô®®m·òd’Br^v-“ë…¦Iw#Œ,Áû¨¥òµ+½2`ï>±xa ÿ3ï4‡õñ¨ÛS´ˆ[1FNÖ ì-þóqíÀ¦¬ÒÙÌî<Ÿ™O*ÿˆïïÔT­’O½°ËªÞ'ñ(ô?Ð÷ fv§yqk!H¡X[ø„ciüúŸÎ«ÙÛÝêWQ[XÃ-ÅÄØÛJK1#ÐWY¢xN]OMMG_¸HÑ”(Šú㆔q«ûÞý¥ÖaHê³Ñ\ñ «ÆØ1AÏ7¶Tã±5Bï ØMšf«j— Û–K™|”×dy=»µcëÝÞ£ª]ÞÈê²ÜÊÒ¨3–9ëŒÓmæ˜@ÒÞÊò 8E$‚ÇÓé@Gü%Ñ‹§Ãc£ù±[À±“Ï1ù¿3ô£Yšñ|%m<÷³5Ìú„¤LÒ|ácsã-úW/eln¥’öîLZ¡ùŸ¡f싞ÿÈ~·ñXÆ“á˜cv1½¬—XïûÉþH(³øA!Ô®ÞäšÝe$´›Ë#Âêsô;kÎ- ·iʓΕT²£.#ùœsÿUt¿nžˆöpἫ¸ä…³ë´‘ü«„’êx&Êùi"·PeH=© “,“4ŒKlùØÿŸZÑI£ñ›$s ŽúÄcwÅœ²àžÝ@ôÎ* íÚ|×1©Á‘Dq×ÐŒ‘ô#µgéwZj qlÛ)üÑø Ío¼Sa³h‡ím8SÇ?÷Î*+-ZãZÕuùå¯ Ü äaƒ#¦G_JÞÛèÞ×u»<,W°¥•ª±™2¯àãØŠâ¼?pmešá91ª¸÷ïÝ” …Þ?é¢,Ãÿ<2\É,öPžKoBèO¹ÎW¿¥.·Ú]Ì#æ6;¢÷Vä~•á—†¤ñ_‹ ÓŒ’Ggƒ=Üáöù0¯,Ùý>¦€=Â_gð_€î|PåáÕõ…{=,2«´QÿÃdvük€µˆÚÅ%ïŸÒ0ÄLi8f9ñýkSâˆÆ~/TÒäŠ-&ÍE­”œnß窔³ZÁ=´s@â+öd`AÆN2}Û9ü¨"ÞúDcxäÇ" ïÏ ý)fþ̸ÚdG²“ (<Èò}¾ðüÍ\mY“Mšò¤©ŽD ŽÞ[aà÷¬+ó傲+ᔌõÀض‹P³ŠD‰aÔ¬2ÅÞ>¥~òŸ|W[ek¥ÛøvÇSñÜÚjƒö%2ዃ’ £c§ë^o1X–u ²«`ölàô¯AñV áðÍÌ+w˜ZI<Æ;³œ‚=ròzÒ-Kâ>]l¬4{k[HÿÕ™G˜Š{ƒ øã5‰®ëšÞ© e¯§¯É$ ÛR3êãiê+2òÆÊâØµ¼ÒÃ"Dr®ì@À0* w¨ÚX&d2Ÿ-™¸;çéÔzS`;v6ZýÄXY.o!ùˆÎvÆÌWZ†ìÚ:G9¶"9X_[¸ ‚?,VÎ6‡w§­…ÉírÈ^O çr¯†^B®UÀéà š[ˆRH,ïbs8Ìv׸¶œýäbLoÿrO¥rwQCæÄöò»H"DÚGÄŽÕÝhW3ëš I ø‡C}«óMå“ÜŽ }GñW.›=¹oí "µUb0Næ$ÀUí#TmòÝ.)MÄldo¼ß€àøšÚ¿Ó Ô#‹Z³0ZXJGÚBÛKÝ@î­É\vÈíš»c­Cw*Ú[HnLkÿ‡g…8ê@îqVïbŠ-Gûn’ëAÖÔ,öasä¸ûÊ= Ÿ™OáØ×y¥ø[HÓb‰ØµèuFÙR2©¦®&rz~›{¨ËåÚ$Ó7,mêGOÄ×O§øBÖÛçÔçûÃm×ñjßk†ò„Q†Ò8†Õý**ÕG¹%㳈ŧÁª Aó«u5$’Iɤ¢©$„£Q@¨¢—¸ õ4”Òy4f€E3p¤ßï@oŠÞÒêîáKÃor™Æö諞Ù&¸í[Äú¥ú4Jºu‘9òm ÿyÏ'ô®®íôë­$Ú_ÜÜ[fmì#>`˜ü£’zÖ Ä¾ÓÆF©Ýz5ÔÂ5?M™²m7fZZ©†ÙâÜÛ¤ë×,Ì~ ×5~‚ù±`/QÏEòüåü×~Fºcâ¸àãNÑ4›FxŒ®?¥Wºñ–¹:í:Œ±'÷a0?ï)X vøqâ\+Ed¯ ËFqPûHü¨<c_ÑlxÎÏ<Êÿ÷ÊëMº½¸ºm×3Ë3zÈåëM[é’1™º!ÿ,äÓþù9¥a ¿`ðm€c6»©_“Ë% Œ7ýü<Ó-bab¶öXŒäzzV,ú½b†K(Ze6ëf)ú…Î?V|­z>Ô¯k¨E†e …—Øç£tèi ì[Á—í£´Ë­3Sw”ÈEµê €0>ö\×?á_Y‚nt{È#þòB\ßC#õªíذ{;5€)ŠÝN$°fùˆãóU­üS«Úö+Û‹`?ç“lÿëÓ%´’K¨ uu9fbËʨêHú]®›(°ø}­jò'•& ÃK¶û¨Né8ôÙøQµñ·‰†›n&¼Ó]8Ž(®bIrù‰Ü9É ~¶Ï‹´[ø‡õ°ºrA!hïì`Ve`y†L¼>aH9µ´Ú…äB±–`3¸z\ÒÁk&§pòH|›ÎÀ«^Ê=IôúŸZë|Oá RÈYÊZØé »×Q´mÖ¥z–±ÿdóÐW#«ê‹pÚ×rÙC÷œ³žîÞçôéLjË/îÔyv±ü°Ä‡;}ÉîOs]ÄHÔýŽÍF%Ó4ûP}v´j[òf™®.Ƶêð'ßžeŒc¹'ÖºÏÝ™þ)ê±¢4½ËY”A’È>N?,þŸî_¼< Ž ôÊ‘úæ«xçKKjPD…Z˜˜Û‚ᣞiCÃàÍÍi8—[ÿŸ„?êûûÞ¦ºÛÿЏÑt;ÍJÛKÖ`ž7G]NÕe"Tl8ÃŒ‚½é\,p Ó¸ìÍ,àž cŸÄv÷Å>7´@D Î%f¾€~µÚÿmx T´S¬xQÐf»LºUЕ<$œ$v=ª¼>ðÖ¡yš?Œìå€8imoà{iÂg¼cŽ˜<ÐÏý’ DðÜŠ±OuoöÜ“ÂÍ'Üç¦Õñ¯?Óâž8ïc–'ˆù{TFNáßó®›âMä’x†úúâØÅ0”ÇjŽ ðùι I&3Í+eÏ [;}ÿ::ÑÏ¥]jÚ„‘yJÐ3@Í,ª€Á\yêJôWѯ<ðÉ´ÛU„xÄ8{ÂfDh-Ý@IçwSõö48în¬%Ög)£h£PÔ½$‘þe>ø^=¯9ñ׊um{Ä—š½ü’Åö§&$VÊ*TŽ:PètÖдɮo"Ì’‚0¤0*?„‘ÉëŽÂ°c¼–æÞñ„‡ÏÝç§#¨ü¿•\ðö¡ý¡é•Ágmö“¹æ ñ“ýÖè ÏØloÊ\EäMo!IâdzcÓ¯Nž”X™%ºYd…9ÑfR¿+ ŽyyÏPjeÕä™;·KØW/PŒÉ´z,«‡_ÀS&‘¨ÝiPEkm$ïnïC;&r¬£©yÕ™#4r´6¢ Èß‘ãô¤2ák •+§Cqà`‘„ˆÞêÜýöéa’Æ5|)2î_¸À[¡³§èð[ ó¿'rüÀTz ­†Ÿ9,,äÞàq Ÿ,€zã†úÖ¼êa™ãlnF ‘ÐÓHMšzÌQ<–7D-Þˆêßø\}?—Ðøfib{ ÷‹‹mÏoÎr½Yî?ˆ{Šâ d`ò tÏ5ö›õ³‘«iEX·wˆ}Ö÷ÇCì}VÌ[vh¦Gsõ¤ö£l7%?盼Ÿý£ukrÑL”u-74f€@ëMÍ(<Š®[“I¿š›šij.…©¥ª"ôÆz˜¿­@ÑÆ3°'©C·?__ÆšÒTM%&¯¸Ê·Zm¼¤–Ž6> l?˜ãô¬›­FL2:{8Ü?1þ¶ÏïQ<žõ« îrsÙ]D yeÐuhÎáúU—ÙJÊNHù‡~ãñªW)ÙóQ$ÿ|dþ}ZVhg(Òš¦=ÍlÜé–ÏŸ-žÿ}¯ô?βn´Ë•$ÂRqÿLÏ?‘æ•ÂÅYd³²r’/ÞŒúoQUoN©w§Üi]ɶÔ ‰â‘%ˆcÉÉÛž¾œÓ£¶ž[‘ FVêÛ†6Ôšv«¤jz”Á¦é÷³Ú—vܪ@ ‰‰ÀîxíùÔ´·)W~/†pñO¦CsE¹È€}úb²€Òï$ÿK‹ensÁ•1[z€.f™až÷O[¢ ;Í×ä%µE>›áèX ­GP¼dã˶€B€w9•+Ü SX:@Èc†Ú5µ¶rŒÂ"F ¶SÎ=É®DÛØÉÔÙ²v@ÜþdW¤ê—3i¶qëö'íºÌKmui*dÂßóÎEèU¹!¸Ïl+“Ö4==¬XÐÜ6•+ìd”’ö²|·8?ðà0÷ ˆ¼]{á[›{-9a—L¸‚6– •ó"» òêÇLi­ h>5>oƒçþÉÖÏ/¢^Kû¹O"S×ýÆçÞ°u‹cyá½6åFé-­Ê`øSó§O«Â±¬“H²F ¹äƒ•ÁO·­nx?Iº°ø¥ÙjÖóZ½µâÉǵ¼¸È8 cRÐÓ8ãòNeUurÛ·‚sšÛºÔîïm?Óã‚{ô#eã¯ïHîçz`°'Þƒo/xßò¦dþã~TX.Ôîô]BYe ygt¦+ËYI)qê¿pzƒƒW®ôÙ¼)©Å©h,·þÔÁdã*ÉÕà˜Œ½s׀ó^7Àß•t½0ĦæÖKëU¼¹íU°UFG˜§¢¸äƒèx&“CLæõkÆÒ¦èq,zeʉÐJ¥ÁÏ HÆW‘Ð~µSûm¤³’;:Æo˜|‹Œ‘ßî‘è+¡»Ñt¿²McˆìeKk†ò%xä\!8!°¤s€x'½V³ðÍ¡‘¤msJ–8×{(iöÜvp3Þ€%Ñ¥¶Ã:¬ƒNHØî-!“pVÀm§Ów~¸ô«uœ^Ý«ë7>f³{km>áü³µ¿Ž~zËÆ}«_úcèÚv·â9®bº’=ðIÜ¿šŠ‹Ï¡9ƼÚöîëP»–æîy'¸•‹;¹É&…Ýç†õ«ú´Û©››½*ãÌŒ“ßË‘ù8ª·^°ÕWÃ^'ÒîJ «mzÆÎlÿÀþBIôjçôóqmq«´*°b„ 0ô>Ô“Û¯!€mˆ±(­ÔÀÐë^×ô^u]*êÚ3ÒVŒ˜ÛÜ8àþŸp'…á—–èÉ;#úÖ‡õŸi“¤õìm#B䬇ЧFüEuÞ§o41Ûj· °€´òivѪ.„…À/êWõÅ08­I’Îí_Pš+t™Ÿƒ½;uêkªÐ‡ÚígÐtë››=bÒO6ÈÈã:n ã©ÉÀèz}yõÒô‹™Ãâ8·ÿ/0ìĶP?÷„§9ücó¬Bo´ÏŠ˜Û Qž¥.ñÚèo ¸ÿ„#C€¼{æg¹;!~äyÏ^±XbÅÿŠ{uÿçù `TV#¨"·´©~×föÙÌ‹ó'ÔvüGPµŸöX—ïÝÇÿF?Ò§·6öî.'Þ ¤XÁ÷4:“[º\’M£ÞEº³e¿·aÔ2›ôÁü+ K˜'™ä‡1bB8Æ>±WôKçê–ÓÈ3í®FCÃ~„Ó¹|bi’âÝBÛÜ ž57Uÿ€¶åÿ€ÔJÔå ‚ÿMfÌšdÅã'«A!ý?öÐÔ ÔЙnZ9ãb®¤2°êï]üZš?‘âHÓtn¦¯÷'ò9õ¹¯:V­¿ ê˦_‘t¾e…ʘnc=¨ëšîo!6× pè@dqÑÔò}EF¦‹8^(¦Ñ¥6k$3ÙKÿ=íO8ëéÛ‘P«U¦Id5=Z««T€Ó`Pyjp<Š¬Ç“Q±§Ö£jc‰ªF¨ØPmPµLG DÕаV˜ËHeV-YaL+@Y*&J¶Â£eÍ+ ¦ÉQ:UÖŽ˜c¤dçµ@ÖþµÚ*‰á  cjòʱEwsµUFI5¹u—o.›§²½Üƒmݺ;ƧÓÔ÷úWAø"œ@vK"ìÿ×o¦}kœ¸ÐrcmÃõ¤Ð#•6À[ˆ”7n'×Ò¦Ò¤“L¾K˜H|e^7YŒ2°îÈ­9ìdˆœ¡â´|-gšãU¿@l´ð$e?òÒC÷ñ<Ÿ`jl;—á¾²ðu¼Z\¶hµÔ ›Rµ‘÷2Bßr0ØáÔa·cïb±¥{5Ôû¤šg.ÍŽ¤×Eá– a>‹¬¤ƒJœ™"” µ¤ØâEÁèËÜ{E†rU;O¸Ô®ÒÚÎ#$­Û ¹' ÔÕøôIÚeF’4BØ2à^™ý*ö¹/ج›LÑâ´q‰îXbK“ïýÕô_Ï&˜ŠwÚ…¶…–Z,‚k×./ÇaÝ"ô­Ôû åpêH`sšºm0~bM(µQü9¤2«Ç¬³„Ï#zŽÇÖ¬ÉäË4’”娷OSOòˆè(òý@¢Â¹fÃQ¹°™$µšUÚs´¶TûÒ»ëi´¿ijji0T—ìaDÐʰ<6ì{gœó^r#ôÍZ°¹žÆàKàŽ£=EkÞø[øå¾ð­ìå°Ëº[®Ëˆ‡}ðŸ˜}FG½r¶úuåÅêYÛÛÉ%ӶʼnGÌO¦+Ò¼@¾𾺿ñ+»¸ÔB¥ÇŸÛ@Ce6ò:úÕ˜¾$ÛÞê,ú¦˜-İ›s{jÁ®£øƒ°ù®y>¢˜/%¯`k{GŽëÄλf¸_™,Áê©êþ§µrv÷³Áz—‘LâåÌgæÝœç5Òx‹ÃX·öòǨé37ÎÒºãª?û'ðÍsRY·ð΄Kâ¨!ÕìÄÚtj‚gê¨ÿSpˆî¿_c‘ÜU+ˆóÀv±Ä Hš‰Uý¥ž*¿†ufÑ/Ýoa3é—Iä]ÃÙã>ž„u±Üi9Ò!dívQ] ëi”q+/)VÊ@þ7=Ï®¯l¤òè°\ÎKHãDUÃG¥hÅ!Ž•€Î0qÒ¡{|äÅk©µÏ\iQIÈ]§Ú²ît™cÉEÜ=«³ò}©µxY~òâ™å×qq§Ç0!Ð}GZʸЈɉ‰ö4¬9Ï.*´'²–Ã!…CŒi é>$Æe¿Ñîü·Òàr}þaý+6ù<⻟7Dð¬þ¶VÝcþ5ÎÚY4ì6Š,!<=¨ßè—ÖŠQ¶kiW|S/÷]O.Õ±ªéºuß•u§E5›I“-£üËÿa³’§Ðò=MOk§,77­ZûQËÔ.aÇ£ÂÎ ýkZ)fŠÆ;8äd·ŒåxÚzðzŠ˜¦;Rm§`1dÒa?püªÒil¿v4aì+¢(=) Q`9f³T?<~«@·‹Æ¿•tÍzŠ…ì¢~¨ÓŠ,?öXOü³ï±@zÆ+Yôïî9Æ¡{9ÓøCj¯aÙ]ÅsmòKnSèi’Ûï‘ÝRĸà}*\22}Å;4L¬©Õr=G4ä—5k4×E~ª3ë@ I+ªðn« rM¥êÃO¾Â³±Iü2/¸ ~B¹# q¿M,ñýå8õ€ömF9n-ÍÀúÙ…½è^…±òJ?ÙuÁÏøÖrµGàíy5?ιýäÖ‘y©žfµ<ïÿz3ó}7z ›P¶{ Ù-݃å\tu<†QV™,zµJ­ÈªˆÕ2E0¹`ŽM5–¥#“HE1Ȧ°â§e¦ ¦•«SJÒ¹ZiZ²V˜V€ )M+V ÓJÐrµ-Z)Ldö  ¥i¥jÑJB”ìB´›*ÖÊM´€¬c¤òêÉZB´ ¯³m©öR„  ÛhÙV‚RùtÂåM´†<Õ¿..\¥åŸJ<¢{Uß.”ÊFC«¾]&Êæ|–ªë†PG½d_è+*“Êݽ+§ÙI²•‚æn£¦5ׄü9 Éj× *†É²•â™ofF+P§µ0§µ ”ŒtÒ˜«…)Œ”ÂåFLÔ~_5q’£+E†A²›²¬m¤ÛE€ƒe O¶´¬}´ÍXÛK¶€¨Ð†#5^]>&þ§ÔVžÚ]´¬0¤ÓX«ÌUi-gª=¹®›`ô¤1Ú‹ÎS$0Á÷¥à×K%šH0ÊÔUIt˜ÛîeOµ+ÊZôºF« õ¯ßŒüËÙ׸5é”ðI¦iÿfBÖ¤µ›?v3É„ÿ¸OÄgšó‰t»ˆùŒîú×Ià‹öf—CÔÑ¢‚àî‚V,Rއ=ïõ=ñKaîj!©£<ŠˆÇ$2¼S!Y#b¬§±jDê*È5Jòx¦íúÑE0jB=PJŸJB§=(¢€©ô4݇Ҋ( JiCØQE4§µ4§µPJnÃéE›¥4Æ} Plö¤ÙíElö¥Ø}(¢€e.ßj( oµ¥P!vJO,ú( aô¤1ûQEgµ'—E€B‡Ò˜c4QLC qÒ˜Pú( cZ>:TMÏJ( òý©6CE B‡Ò“Ë>”Q@ÃèivŸJ( 'µ;gµPì>†”!ô¢ŠB'=)á=¨¢˜,~Õ*Ä3÷J(  =ªeŽ(¢€?ÿÙgeometry/inst/doc/qhull/html/rbox.man0000644000176200001440000001044513431000556017370 0ustar liggesusers.\" This is the Unix manual page for rbox, written in nroff, the standard .\" manual formatter for Unix systems. To format it, type .\" .\" nroff -man rbox.man .\" .\" This will print a formatted copy to standard output. If you want .\" to ensure that the output is plain ascii, free of any control .\" characters that nroff uses for underlining etc, pipe the output .\" through "col -b": .\" .\" nroff -man rbox.man | col -b .\" .TH rbox 1 "August 10, 1998" "Geometry Center" .SH NAME rbox \- generate point distributions for qhull .SH SYNOPSIS Command "rbox" (w/o arguments) lists the options. .SH DESCRIPTION .PP rbox generates random or regular points according to the options given, and outputs the points to stdout. The points are generated in a cube, unless 's' or 'k' option is given. The format of the output is the following: first line contains the dimension and a comment, second line contains the number of points, and the following lines contain the points, one point per line. Points are represented by their coordinate values. .SH EXAMPLES .TP rbox 10 10 random points in the unit cube centered at the origin. .TP rbox 10 s D2 10 random points on a 2\[hy]d circle. .TP rbox 100 W0 100 random points on the surface of a cube. .TP rbox 1000 s D4 1000 random points on a 4\[hy]d sphere. .TP rbox c D5 O0.5 a 5\[hy]d hypercube with one corner at the origin. .TP rbox d D10 a 10\[hy]d diamond. .TP rbox x 1000 r W0 100 random points on the surface of a fixed simplex .TP rbox y D12 a 12\[hy]d simplex. .TP rbox l 10 10 random points along a spiral .TP rbox l 10 r 10 regular points along a spiral plus two end points .TP rbox 1000 L10000 D4 s 1000 random points on the surface of a narrow lens. .TP rbox c G2 d G3 a cube with coordinates +2/\-2 and a diamond with coordinates +3/\-3. .TP rbox 64 M3,4 z a rotated, {0,1,2,3} x {0,1,2,3} x {0,1,2,3} lattice (Mesh) of integer points. 'rbox 64 M1,0' is orthogonal. .TP rbox P0 P0 P0 P0 P0 5 copies of the origin in 3\-d. Try 'rbox P0 P0 P0 P0 P0 | qhull QJ'. .TP r 100 s Z1 G0.1 two cospherical 100\-gons plus another cospherical point. .TP 100 s Z1 a cone of points. .TP 100 s Z1e\-7 a narrow cone of points with many precision errors. .SH OPTIONS .TP n number of points .TP Dn dimension n\[hy]d (default 3\[hy]d) .TP Bn bounding box coordinates (default 0.5) .TP l spiral distribution, available only in 3\[hy]d .TP Ln lens distribution of radius n. May be used with 's', 'r', 'G', and 'W'. .TP Mn,m,r lattice (Mesh) rotated by {[n,\-m,0], [m,n,0], [0,0,r], ...}. Use 'Mm,n' for a rigid rotation with r = sqrt(n^2+m^2). 'M1,0' is an orthogonal lattice. For example, '27 M1,0' is {0,1,2} x {0,1,2} x {0,1,2}. '27 M3,4 z' is a rotated integer lattice. .TP s cospherical points randomly generated in a cube and projected to the unit sphere .TP x simplicial distribution. It is fixed for option 'r'. May be used with 'W'. .TP y simplicial distribution plus a simplex. Both 'x' and 'y' generate the same points. .TP Wn restrict points to distance n of the surface of a sphere or a cube .TP c add a unit cube to the output .TP c Gm add a cube with all combinations of +m and \-m to the output .TP d add a unit diamond to the output. .TP d Gm add a diamond made of 0, +m and \-m to the output .TP Cn,r,m add n nearly coincident points within radius r of m points .TP Pn,m,r add point [n,m,r] to the output first. Pad coordinates with 0.0. .TP n Remove the command line from the first line of output. .TP On offset the data by adding n to each coordinate. .TP t use time in seconds as the random number seed (default is command line). .TP tn set the random number seed to n. .TP z generate integer coordinates. Use 'Bn' to change the range. The default is 'B1e6' for six\[hy]digit coordinates. In R^4, seven\[hy]digit coordinates will overflow hyperplane normalization. .TP Zn s restrict points to a disk about the z+ axis and the sphere (default Z1.0). Includes the opposite pole. 'Z1e\-6' generates degenerate points under single precision. .TP Zn Gm s same as Zn with an empty center (default G0.5). .TP r s D2 generate a regular polygon .TP r s Z1 G0.1 generate a regular cone .SH BUGS Some combinations of arguments generate odd results. Report bugs to qhull_bug@qhull.org, other correspondence to qhull@qhull.org .SH SEE ALSO qhull(1) .SH AUTHOR .nf C. Bradford Barber bradb@shore.net .fi geometry/inst/doc/qhull/html/qvoron_f.html0000644000176200001440000004251114664417655020464 0ustar liggesusers qvoronoi Qu -- furthest-site Voronoi diagram Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options

[delaunay]qvoronoi Qu -- furthest-site Voronoi diagram

The furthest-site Voronoi diagram is the furthest-neighbor map for a set of points. Each region contains those points that are further from one input site than any other input site. See the survey article by Aurenhammer ['91] and the brief introduction by O'Rourke ['94]. The furthest-site Voronoi diagram is the dual of the furthest-site Delaunay triangulation.

Example: rbox 10 D2 | qvoronoi Qu s o TO result
Compute the 2-d, furthest-site Voronoi diagram of 10 random points. Write a summary to the console and the Voronoi regions and vertices to 'result'. The first vertex of the result indicates unbounded regions. Almost all regions are unbounded.
Example: rbox r y c G1 D2 | qvoronoi Qu s Fn TO result
Compute the 2-d furthest-site Voronoi diagram of a square and a small triangle. Write a summary to the console and the Voronoi vertices for each input site to 'result'. The origin is the only furthest-site Voronoi vertex. The negative indices indicate vertices-at-infinity.

Qhull computes the furthest-site Voronoi diagram via the furthest-site Delaunay triangulation. Each furthest-site Voronoi vertex is the circumcenter of an upper facet of the Delaunay triangulation. Each furthest-site Voronoi region corresponds to a vertex of the Delaunay triangulation (i.e., an input site).

See Qhull FAQ (local) - Delaunay and Voronoi diagram questions.

The 'qvonoroi' program is equivalent to 'qhull v Qbb'. It disables the following Qhull options: d n m v H U Qb QB Qc Qf Qg Qi Qm Qr Qv Qx TR E V Fa FA FC Fp FS Ft FV Gt Q0,etc.

Copyright © 1995-2020 C.B. Barber


»furthest-site qvoronoi synopsis

See qvoronoi synopsis. The same program is used for both constructions. Use option 'Qu' for furthest-site Voronoi diagrams.

»furthest-site qvoronoi input

The input data on stdin consists of:

  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qvoronoi Qu < data.txt), a pipe (e.g., rbox 10 | qvoronoi Qu), or the 'TI' option (e.g., qvoronoi TI data.txt Qu).

For example, this is a square containing four random points. Its furthest-site Voronoi diagram has on vertex and four unbounded, separating hyperplanes (i.e., the coordinate axes)

rbox c 4 D2 > data
2 RBOX c 4 D2
8
-0.4999921736307369 -0.3684622117955817
0.2556053225468894 -0.0413498678629751
0.0327672376602583 -0.2810408135699488
-0.452955383763607 0.17886471718444
  -0.5   -0.5
  -0.5    0.5
   0.5   -0.5
   0.5    0.5

qvoronoi Qu s Fo < data


Furthest-site Voronoi vertices by the convex hull of 8 points in 3-d:

  Number of Voronoi regions: 8
  Number of Voronoi vertices: 1
  Number of non-simplicial Voronoi vertices: 1

Statistics for: RBOX c 4 D2 | QVORONOI Qu s Fo

  Number of points processed: 8
  Number of hyperplanes created: 20
  Number of facets in hull: 11
  Number of distance tests for qhull: 34
  Number of merged facets: 1
  Number of distance tests for merging: 107
  CPU seconds to compute hull (after input):  0

4
5 4 5      0      1      0
5 4 6      1      0      0
5 5 7      1      0      0
5 6 7      0      1      0

» furthest-site qvoronoi outputs

These options control the output of furthest-site Voronoi diagrams.

 
furthest-site Voronoi vertices
p
print the coordinates of the furthest-site Voronoi vertices. The first line is the dimension. The second line is the number of vertices. Each remaining line is a furthest-site Voronoi vertex. The points-in-square example has one furthest-site Voronoi vertex at the origin.
Fn
list the neighboring furthest-site Voronoi vertices for each furthest-site Voronoi vertex. The first line is the number of Voronoi vertices. Each remaining line starts with the number of neighboring vertices. Negative indices (e.g., -1) indicate vertices outside of the Voronoi diagram. In the points-in-square example, the Voronoi vertex at the origin has four neighbors-at-infinity.
FN
list the furthest-site Voronoi vertices for each furthest-site Voronoi region. The first line is the number of Voronoi regions. Each remaining line starts with the number of Voronoi vertices. Negative indices (e.g., -1) indicate vertices outside of the Voronoi diagram. In the points-in-square example, all regions share the Voronoi vertex at the origin.
 
 
furthest-site Voronoi regions
o
print the furthest-site Voronoi regions in OFF format. The first line is the dimension. The second line is the number of vertices, the number of input sites, and "1". The third line represents the vertex-at-infinity. Its coordinates are "-10.101". The next lines are the coordinates of the furthest-site Voronoi vertices. Each remaining line starts with the number of Voronoi vertices in a Voronoi region. In 2-d, the vertices are listed in adjacency order (unoriented). In 3-d and higher, the vertices are listed in numeric order. In the points-in-square example, each unbounded region includes the Voronoi vertex at the origin. Lines consisting of 0 indicate interior input sites.
Fi
print separating hyperplanes for inner, bounded furthest-site Voronoi regions. The first number is the number of separating hyperplanes. Each remaining line starts with 3+dim. The next two numbers are adjacent input sites. The next dim numbers are the coefficients of the separating hyperplane. The last number is its offset. The are no bounded, separating hyperplanes for the points-in-square example.
Fo
print separating hyperplanes for outer, unbounded furthest-site Voronoi regions. The first number is the number of separating hyperplanes. Each remaining line starts with 3+dim. The next two numbers are adjacent input sites on the convex hull. The next dim numbers are the coefficients of the separating hyperplane. The last number is its offset. The points-in-square example has four unbounded, separating hyperplanes.
 
 
Input sites
Fv
list ridges of furthest-site Voronoi vertices for pairs of input sites. The first line is the number of ridges. Each remaining line starts with two plus the number of Voronoi vertices in the ridge. The next two numbers are two adjacent input sites. The remaining numbers list the Voronoi vertices. As with option 'o', a 0 indicates the vertex-at-infinity and an unbounded, separating hyperplane. The perpendicular bisector (separating hyperplane) of the input sites is a flat through these vertices. In the points-in-square example, the ridge for each edge of the square is unbounded.
 
 
General
s
print summary of the furthest-site Voronoi diagram. Use 'Fs' for numeric data.
i
list input sites for each furthest-site Delaunay region. Use option 'Pp' to avoid the warning. The first line is the number of regions. The remaining lines list the input sites for each region. The regions are oriented. In the points-in-square example, the square region has four input sites. In 3-d and higher, report cospherical sites by adding extra points.
G
Geomview output for 2-d furthest-site Voronoi diagrams.

» furthest-site qvoronoi controls

These options provide additional control:

Qu
must be used.
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
QVn
select furthest-site Voronoi vertices for input site n
Tv
verify result
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
TFn
report progress after constructing n facets
PDk:1
include upper and lower facets in the output. Set k to the last dimension (e.g., 'PD2:1' for 2-d inputs).
f
facet dump. Print the data structure for each facet (i.e., furthest-site Voronoi vertex).

» furthest-site qvoronoi graphics

In 2-d, Geomview output ('G') displays a furthest-site Voronoi diagram with extra edges to close the unbounded furthest-site Voronoi regions. All regions will be unbounded. Since the points-in-box example has only one furthest-site Voronoi vertex, the Geomview output is one point.

See the Delaunay and Voronoi examples for a 2-d example. Turn off normalization (on Geomview's 'obscure' menu) when comparing the furthest-site Voronoi diagram with the corresponding Voronoi diagram.

»furthest-site qvoronoi notes

See Voronoi notes.

»furthest-site qvoronoi conventions

The following terminology is used for furthest-site Voronoi diagrams in Qhull. The underlying structure is a furthest-site Delaunay triangulation from a convex hull in one higher dimension. Upper facets of the Delaunay triangulation correspond to vertices of the furthest-site Voronoi diagram. Vertices of the furthest-site Delaunay triangulation correspond to input sites. They also define regions of the furthest-site Voronoi diagram. All vertices are extreme points of the input sites. See qconvex conventions, furthest-site delaunay conventions, and Qhull's data structures.

  • input site - a point in the input (one dimension lower than a point on the convex hull)
  • point - a point has d+1 coordinates. The last coordinate is the sum of the squares of the input site's coordinates
  • vertex - a point on the upper facets of the paraboloid. It corresponds to a unique input site.
  • furthest-site Delaunay facet - an upper facet of the paraboloid. The last coefficient of its normal is clearly positive.
  • furthest-site Voronoi vertex - the circumcenter of a furthest-site Delaunay facet
  • furthest-site Voronoi region - the region of Euclidean space further from an input site than any other input site. Qhull lists the furthest-site Voronoi vertices that define each furthest-site Voronoi region.
  • furthest-site Voronoi diagram - the graph of the furthest-site Voronoi regions with the ridges (edges) between the regions.
  • infinity vertex - the Voronoi vertex for unbounded furthest-site Voronoi regions in 'o' output format. Its coordinates are -10.101.
  • good facet - an furthest-site Voronoi vertex with optional restrictions by 'QVn', etc.

»furthest-site qvoronoi options

See qvoronoi options. The same program is used for both constructions. Use option 'Qu' for furthest-site Voronoi diagrams.

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qhull.txt0000644000176200001440000014070013431000557017606 0ustar liggesusers qhull(1) qhull(1) NAME qhull - convex hull, Delaunay triangulation, Voronoi dia- gram, halfspace intersection about a point, hull volume, facet area SYNOPSIS qhull- compute convex hulls and related structures input (stdin): dimension, #points, point coordinates first comment (non-numeric) is listed in the summary halfspace: use dim plus one with offsets after coefficients options (qh-quick.htm): d - Delaunay triangulation by lifting points to a paraboloid v - Voronoi diagram via the Delaunay triangulation H1,1 - Halfspace intersection about [1,1,0,...] d Qu - Furthest-site Delaunay triangulation (upper convex hull) v Qu - Furthest-site Voronoi diagram QJ - Joggle the input to avoid precision problems . - concise list of all options - - one-line description of all options Output options (subset): FA - compute total area and volume Fx - extreme points (convex hull vertices) G - Geomview output (2-d, 3-d and 4-d) Fp - halfspace intersection coordinates m - Mathematica output (2-d and 3-d) n - normals with offsets o - OFF file format (if Voronoi, outputs regions) TO file- output results to file, may be enclosed in single quotes f - print all fields of all facets s - summary of results (default) Tv - verify result: structure, convexity, and point inclusion p - vertex coordinates i - vertices incident to each facet example: rbox 1000 s | qhull Tv s FA - html manual: index.htm - installation: README.txt - see also: COPYING.txt, REGISTER.txt, Changes.txt - WWW: - GIT: - mirror: - news: - Geomview: - news group: - FAQ: - email: qhull@qhull.org - bug reports: qhull_bug@qhull.org Geometry Center 2003/12/30 1 qhull(1) qhull(1) The sections are: - INTRODUCTION - DESCRIPTION, a description of Qhull - IMPRECISION, how Qhull handles imprecision - OPTIONS - Input and output options - Additional input/output formats - Precision options - Geomview options - Print options - Qhull options - Trace options - BUGS - E-MAIL - SEE ALSO - AUTHORS - ACKNOWLEGEMENTS This man page briefly describes all Qhull options. Please report any mismatches with Qhull's html manual (qh- man.htm). INTRODUCTION Qhull is a general dimension code for computing convex hulls, Delaunay triangulations, Voronoi diagram, furthest- site Voronoi diagram, furthest-site Delaunay triangula- tions, and halfspace intersections about a point. It implements the Quickhull algorithm for computing the con- vex hull. Qhull handles round-off errors from floating point arithmetic. It can approximate a convex hull. The program includes options for hull volume, facet area, partial hulls, input transformations, randomization, trac- ing, multiple output formats, and execution statistics. The program can be called from within your application. You can view the results in 2-d, 3-d and 4-d with Geomview. DESCRIPTION The format of input is the following: first line contains the dimension, second line contains the number of input points, and point coordinates follow. The dimension and number of points can be reversed. Comments and line breaks are ignored. A comment starts with a non-numeric character and continues to the end of line. The first comment is reported in summaries and statistics. Error reporting is better if there is one point per line. The default printout option is a short summary. There are many other output formats. Geometry Center 2003/12/30 2 qhull(1) qhull(1) Qhull implements the Quickhull algorithm for convex hull. This algorithm combines the 2-d Quickhull algorithm with the n-d beneath-beyond algorithm [c.f., Preparata & Shamos '85]. It is similar to the randomized algorithms of Clarkson and others [Clarkson et al. '93]. The main advantages of Quickhull are output sensitive performance, reduced space requirements, and automatic handling of pre- cision problems. The data structure produced by Qhull consists of vertices, ridges, and facets. A vertex is a point of the input set. A ridge is a set of d vertices and two neighboring facets. For example in 3-d, a ridge is an edge of the polyhedron. A facet is a set of ridges, a set of neighboring facets, a set of incident vertices, and a hyperplane equation. For simplicial facets, the ridges are defined by the vertices and neighboring facets. When Qhull merges two facets, it produces a non-simplicial facet. A non-simplicial facet has more than d neighbors and may share more than one ridge with a neighbor. IMPRECISION Since Qhull uses floating point arithmetic, roundoff error may occur for each calculation. This causes problems for most geometric algorithms. Qhull automatically sets option 'C-0' in 2-d, 3-d, and 4-d, or option 'Qx' in 5-d and higher. These options han- dle precision problems by merging facets. Alternatively, use option 'QJ' to joggle the input. With 'C-0', Qhull merges non-convex facets while con- structing the hull. The remaining facets are clearly con- vex. With 'Qx', Qhull merges coplanar horizon facets, flipped facets, concave facets and duplicated ridges. It merges coplanar facets after constructing the hull. With 'Qx', coplanar points may be missed, but it appears to be unlikely. To guarantee triangular output, joggle the input with option 'QJ'. Facet merging will not occur. OPTIONS To get a list of the most important options, execute 'qhull' by itself. To get a complete list of options, execute 'qhull -'. To get a complete, concise list of options, execute 'qhull .'. Options can be in any order. Capitalized options take an argument (except 'PG' and 'F' options). Single letters are used for output formats and precision constants. The other options are grouped into menus for other output for- mats ('F'), Geomview output ('G'), printing ('P'), Qhull Geometry Center 2003/12/30 3 qhull(1) qhull(1) control ('Q'), and tracing ('T'). Main options: default Compute the convex hull of the input points. Report a summary of the result. d Compute the Delaunay triangulation by lifting the input points to a paraboloid. The 'o' option prints the input points and facets. The 'QJ' option guarantees triangular output. The 'Ft' option prints a triangulation. It adds points (the centrums) to non-simplicial facets. v Compute the Voronoi diagram from the Delaunay tri- angulation. The 'p' option prints the Voronoi ver- tices. The 'o' option prints the Voronoi vertices and the vertices in each Voronoi region. It lists regions in site id order. The 'Fv' option prints each ridge of the Voronoi diagram. The first or zero'th vertex indicates the infinity vertex. Its coordinates are qh_INFINITE (-10.101). It indi- cates unbounded Voronoi regions or degenerate Delaunay triangles. Hn,n,... Compute halfspace intersection about [n,n,0,...]. The input is a set of halfspaces defined in the same format as 'n', 'Fo', and 'Fi'. Use 'Fp' to print the intersection points. Use 'Fv' to list the intersection points for each halfspace. The other output formats display the dual convex hull. The point [n,n,n,...] is a feasible point for the halfspaces, i.e., a point that is inside all of the halfspaces (Hx+b <= 0). The default coordinate value is 0. The input may start with a feasible point. If so, use 'H' by itself. The input starts with a feasi- ble point when the first number is the dimension, the second number is "1", and the coordinates com- plete a line. The 'FV' option produces a feasible point for a convex hull. d Qu Compute the furthest-site Delaunay triangulation from the upper convex hull. The 'o' option prints the input points and facets. The 'QJ' option guar- antees triangular otuput. You can also use facets. v Qu Compute the furthest-site Voronoi diagram. The 'p' option prints the Voronoi vertices. The 'o' option prints the Voronoi vertices and the vertices in Geometry Center 2003/12/30 4 qhull(1) qhull(1) each Voronoi region. The 'Fv' option prints each ridge of the Voronoi diagram. The first or zero'th vertex indicates the infinity vertex at infinity. Its coordinates are qh_INFINITE (-10.101). It indicates unbounded Voronoi regions and degenerate Delaunay triangles. Qt Triangulated output. Input/Output options: f Print out all facets and all fields of each facet. G Output the hull in Geomview format. For imprecise hulls, Geomview displays the inner and outer hull. Geomview can also display points, ridges, vertices, coplanar points, and facet intersections. See below for a list of options. For Delaunay triangulations, 'G' displays the cor- responding paraboloid. For halfspace intersection, 'G' displays the dual polytope. i Output the incident vertices for each facet. Qhull prints the number of facets followed by the ver- tices of each facet. One facet is printed per line. The numbers are the 0-relative indices of the corresponding input points. The facets are oriented. In 4-d and higher, Qhull triangulates non-simpli- cial facets. Each apex (the first vertex) is a created point that corresponds to the facet's cen- trum. Its index is greater than the indices of the input points. Each base corresponds to a simpli- cial ridge between two facets. To print the ver- tices without triangulation, use option 'Fv'. m Output the hull in Mathematica format. Qhull writes a Mathematica file for 2-d and 3-d convex hulls and for 2-d Delaunay triangulations. Qhull produces a list of objects that you can assign to a variable in Mathematica, for example: "list= << ". If the object is 2-d, it can be visualized by "Show[Graphics[list]] ". For 3-d objects the command is "Show[Graphics3D[list]]". n Output the normal equation for each facet. Qhull prints the dimension (plus one), the number of facets, and the normals for each facet. The facet's offset follows its normal coefficients. o Output the facets in OFF file format. Qhull prints the dimension, number of points, number of facets, and number of ridges. Then it prints the Geometry Center 2003/12/30 5 qhull(1) qhull(1) coordinates of the input points and the vertices for each facet. Each facet is on a separate line. The first number is the number of vertices. The remainder are the indices of the corresponding points. The vertices are oriented in 2-d, 3-d, and in simplicial facets. For 2-d Voronoi diagrams, the vertices are sorted by adjacency, but not oriented. In 3-d and higher, the Voronoi vertices are sorted by index. See the 'v' option for more information. p Output the coordinates of each vertex point. Qhull prints the dimension, the number of points, and the coordinates for each vertex. With the 'Gc' and 'Gi' options, it also prints coplanar and interior points. For Voronoi diagrams, it prints the coor- dinates of each Voronoi vertex. s Print a summary to stderr. If no output options are specified at all, a summary goes to stdout. The summary lists the number of input points, the dimension, the number of vertices in the convex hull, the number of facets in the convex hull, the number of good facets (if 'Pg'), and statistics. The last two statistics (if needed) measure the maximum distance from a point or vertex to a facet. The number in parenthesis (e.g., 2.1x) is the ratio between the maximum distance and the worst-case distance due to merging two simplicial facets. Precision options An Maximum angle given as a cosine. If the angle between a pair of facet normals is greater than n, Qhull merges one of the facets into a neighbor. If 'n' is negative, Qhull tests angles after adding each point to the hull (pre-merging). If 'n' is posi- tive, Qhull tests angles after constructing the hull (post-merging). Both pre- and post-merging can be defined. Option 'C0' or 'C-0' is set if the corresponding 'Cn' or 'C-n' is not set. If 'Qx' is set, then 'A- n' and 'C-n' are checked after the hull is con- structed and before 'An' and 'Cn' are checked. Cn Centrum radius. If a centrum is less than n below a neighboring facet, Qhull merges one of the facets. If 'n' is negative or '-0', Qhull tests and merges facets after adding each point to the hull. This is called "pre-merging". If 'n' is Geometry Center 2003/12/30 6 qhull(1) qhull(1) positive, Qhull tests for convexity after con- structing the hull ("post-merging"). Both pre- and post-merging can be defined. For 5-d and higher, 'Qx' should be used instead of 'C-n'. Otherwise, most or all facets may be merged together. En Maximum roundoff error for distance computations. Rn Randomly perturb distance computations up to +/- n * max_coord. This option perturbs every distance, hyperplane, and angle computation. To use time as the random number seed, use option 'QR-1'. Vn Minimum distance for a facet to be visible. A facet is visible if the distance from the point to the facet is greater than 'Vn'. Without merging, the default value for 'Vn' is the round-off error ('En'). With merging, the default value is the pre-merge centrum ('C-n') in 2-d or 3--d, or three times that in other dimensions. If the outside width is specified ('Wn'), the maximum, default value for 'Vn' is 'Wn'. Un Maximum distance below a facet for a point to be coplanar to the facet. The default value is 'Vn'. Wn Minimum outside width of the hull. Points are added to the convex hull only if they are clearly outside of a facet. A point is outside of a facet if its distance to the facet is greater than 'Wn'. The normal value for 'Wn' is 'En'. If the user specifies pre-merging and does not set 'Wn', than 'Wn' is set to the premerge 'Cn' and maxco- ord*(1-An). Additional input/output formats Fa Print area for each facet. For Delaunay triangula- tions, the area is the area of the triangle. For Voronoi diagrams, the area is the area of the dual facet. Use 'PAn' for printing the n largest facets, and option 'PFn' for printing facets larger than 'n'. The area for non-simplicial facets is the sum of the areas for each ridge to the centrum. Vertices far below the facet's hyperplane are ignored. The reported area may be significantly less than the actual area. Geometry Center 2003/12/30 7 qhull(1) qhull(1) FA Compute the total area and volume for option 's'. It is an approximation for non-simplicial facets (see 'Fa'). Fc Print coplanar points for each facet. The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of coplanar points followed by the point ids. Option 'Qi' includes the interior points. Each coplanar point (interior point) is assigned to the facet it is furthest above (resp., least below). FC Print centrums for each facet. The output starts with the dimension followed by the number of facets. Then each facet centrum is printed, one per line. Fd Read input in cdd format with homogeneous points. The input starts with comments. The first comment is reported in the summary. Data starts after a "begin" line. The next line is the number of points followed by the dimension+1 and "real" or "integer". Then the points are listed with a leading "1" or "1.0". The data ends with an "end" line. For halfspaces ('Fd Hn,n,...'), the input format is the same. Each halfspace starts with its offset. The sign of the offset is the opposite of Qhull's convention. FD Print normals ('n', 'Fo', 'Fi') or points ('p') in cdd format. The first line is the command line that invoked Qhull. Data starts with a "begin" line. The next line is the number of normals or points followed by the dimension+1 and "real". Then the normals or points are listed with the offset before the coefficients. The offset for points is 1.0. The offset for normals has the opposite sign. The data ends with an "end" line. FF Print facets (as in 'f') without printing the ridges. Fi Print inner planes for each facet. The inner plane is below all vertices. Fi Print separating hyperplanes for bounded, inner regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the num- ber of indices and floats. The first pair lists adjacent input sites, the next d floats are the normalized coefficients for the hyperplane, and the Geometry Center 2003/12/30 8 qhull(1) qhull(1) last float is the offset. The hyperplane is ori- ented toward verify that the hyperplanes are per- pendicular bisectors. Use 'Fo' for unbounded regions, and 'Fv' for the corresponding Voronoi vertices. FI Print facet identifiers. Fm Print number of merges for each facet. At most 511 merges are reported for a facet. See 'PMn' for printing the facets with the most merges. FM Output the hull in Maple format. See 'm' Fn Print neighbors for each facet. The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of neighbors followed by an index for each neighbor. The indices match the other facet output formats. A negative index indicates an unprinted facet due to printing only good facets ('Pg'). It is the negation of the facet's id (option 'FI'). For example, negative indices are used for facets "at infinity" in the Delaunay triangulation. FN Print vertex neighbors or coplanar facet for each point. The first line is the number of points. Then each point is printed, one per line. If the point is coplanar, the line is "1" followed by the facet's id. If the point is not a selected vertex, the line is "0". Otherwise, each line is the num- ber of neighbors followed by the corresponding facet indices (see 'Fn'). Fo Print outer planes for each facet in the same for- mat as 'n'. The outer plane is above all points. Fo Print separating hyperplanes for unbounded, outer regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the num- ber of indices and floats. The first pair lists adjacent input sites, the next d floats are the normalized coefficients for the hyperplane, and the last float is the offset. The hyperplane is ori- ented toward verify that the hyperplanes are per- pendicular bisectors. Use 'Fi' for bounded regions, and 'Fv' for the corresponding Voronoi vertices. FO List all options to stderr, including the default values. Additional 'FO's are printed to stdout. Fp Print points for halfspace intersections (option 'Hn,n,...'). Each intersection corresponds to a Geometry Center 2003/12/30 9 qhull(1) qhull(1) facet of the dual polytope. The "infinity" point [-10.101,-10.101,...] indicates an unbounded intersection. FP For each coplanar point ('Qc') print the point id of the nearest vertex, the point id, the facet id, and the distance. FQ Print command used for qhull and input. Fs Print a summary. The first line consists of the number of integers ("7"), followed by the dimen- sion, the number of points, the number of vertices, the number of facets, the number of vertices selected for output, the number of facets selected for output, the number of coplanar points selected for output. The second line consists of the number of reals ("2"), followed by the maxmimum offset to an outer plane and and minimum offset to an inner plane. Roundoff is included. Later versions of Qhull may produce additional integers or reals. FS Print the size of the hull. The first line con- sists of the number of integers ("0"). The second line consists of the number of reals ("2"), fol- lowed by the total facet area, and the total vol- ume. Later versions of Qhull may produce addi- tional integers or reals. The total volume measures the volume of the inter- section of the halfspaces defined by each facet. Both area and volume are approximations for non- simplicial facets. See option 'Fa'. Ft Print a triangulation with added points for non- simplicial facets. The first line is the dimension and the second line is the number of points and the number of facets. The points follow, one per line, then the facets follow as a list of point indices. With option points include the point-at-infinity. Fv Print vertices for each facet. The first line is the number of facets. Then each facet is printed, one per line. Each line is the number of vertices followed by the corresponding point ids. Vertices are listed in the order they were added to the hull (the last one is first). Fv Print all ridges of a Voronoi diagram. The first line is the number of ridges. Then each ridge is printed, one per line. A line starts with the num- ber of indices. The first pair lists adjacent Geometry Center 2003/12/30 10 qhull(1) qhull(1) input sites, the remaining indices list Voronoi vertices. Vertex '0' indicates the vertex-at- infinity (i.e., an unbounded ray). In 3-d, the vertices are listed in order. See 'Fi' and 'Fo' for separating hyperplanes. FV Print average vertex. The average vertex is a fea- sible point for halfspace intersection. Fx List extreme points (vertices) of the convex hull. The first line is the number of points. The other lines give the indices of the corresponding points. The first point is '0'. In 2-d, the points occur in counter-clockwise order; otherwise they occur in input order. For Delaunay triangulations, 'Fx' lists the extreme points of the input sites. The points are unordered. Geomview options G Produce a file for viewing with Geomview. Without other options, Qhull displays edges in 2-d, outer planes in 3-d, and ridges in 4-d. A ridge can be explicit or implicit. An explicit ridge is a dim-1 dimensional simplex between two facets. In 4-d, the explicit ridges are triangles. When displaying a ridge in 4-d, Qhull projects the ridge's vertices to one of its facets' hyperplanes. Use 'Gh' to project ridges to the intersection of both hyper- planes. Ga Display all input points as dots. Gc Display the centrum for each facet in 3-d. The centrum is defined by a green radius sitting on a blue plane. The plane corresponds to the facet's hyperplane. The radius is defined by 'C-n' or 'Cn'. GDn Drop dimension n in 3-d or 4-d. The result is a 2-d or 3-d object. Gh Display hyperplane intersections in 3-d and 4-d. In 3-d, the intersection is a black line. It lies on two neighboring hyperplanes (c.f., the blue squares associated with centrums ('Gc')). In 4-d, the ridges are projected to the intersection of both hyperplanes. Gi Display inner planes in 2-d and 3-d. The inner plane of a facet is below all of its vertices. It is parallel to the facet's hyperplane. The inner plane's color is the opposite (1-r,1-g,1-b) of the Geometry Center 2003/12/30 11 qhull(1) qhull(1) outer plane. Its edges are determined by the ver- tices. Gn Do not display inner or outer planes. By default, Geomview displays the precise plane (no merging) or both inner and output planes (merging). Under merging, Geomview does not display the inner plane if the the difference between inner and outer is too small. Go Display outer planes in 2-d and 3-d. The outer plane of a facet is above all input points. It is parallel to the facet's hyperplane. Its color is determined by the facet's normal, and its edges are determined by the vertices. Gp Display coplanar points and vertices as radii. A radius defines a ball which corresponds to the imprecision of the point. The imprecision is the maximum of the roundoff error, the centrum radius, and maxcoord * (1-An). It is at least 1/20'th of the maximum coordinate, and ignores post-merging if pre-merging is done. Gr Display ridges in 3-d. A ridge connects the two vertices that are shared by neighboring facets. Ridges are always displayed in 4-d. Gt A 3-d Delaunay triangulation looks like a convex hull with interior facets. Option 'Gt' removes the outside ridges to reveal the outermost facets. It automatically sets options 'Gr' and 'GDn'. Gv Display vertices as spheres. The radius of the sphere corresponds to the imprecision of the data. See 'Gp' for determining the radius. Print options PAn Only the n largest facets are marked good for printing. Unless 'PG' is set, 'Pg' is automati- cally set. Pdk:n Drop facet from output if normal[k] <= n. The option 'Pdk' uses the default value of 0 for n. PDk:n Drop facet from output if normal[k] >= n. The option 'PDk' uses the default value of 0 for n. PFn Only facets with area at least 'n' are marked good for printing. Unless 'PG' is set, 'Pg' is automat- ically set. Geometry Center 2003/12/30 12 qhull(1) qhull(1) Pg Print only good facets. A good facet is either visible from a point (the 'QGn' option) or includes a point (the 'QVn' option). It also meets the requirements of 'Pdk' and 'PDk' options. Option 'Pg' is automatically set for options 'PAn' and 'PFn'. PG Print neighbors of good facets. PMn Only the n facets with the most merges are marked good for printing. Unless 'PG' is set, 'Pg' is automatically set. Po Force output despite precision problems. Verify ('Tv') does not check coplanar points. Flipped facets are reported and concave facets are counted. If 'Po' is used, points are not partitioned into flipped facets and a flipped facet is always visible to a point. Also, if an error occurs before the completion of Qhull and tracing is not active, 'Po' outputs a neighborhood of the erroneous facets (if any). Pp Do not report precision problems. Qhull control options Qbk:0Bk:0 Drop dimension k from the input points. This allows the user to take convex hulls of sub-dimen- sional objects. It happens before the Delaunay and Voronoi transformation. QbB Scale the input points to fit the unit cube. After scaling, the lower bound will be -0.5 and the upper bound +0.5 in all dimensions. For Delaunay and Voronoi diagrams, scaling happens after projection to the paraboloid. Under precise arithmetic, scal- ing does not change the topology of the convex hull. Qbb Scale the last coordinate to [0, m] where m is the maximum absolute value of the other coordinates. For Delaunay and Voronoi diagrams, scaling happens after projection to the paraboloid. It reduces roundoff error for inputs with integer coordinates. Under precise arithmetic, scaling does not change the topology of the convex hull. Qbk:n Scale the k'th coordinate of the input points. After scaling, the lower bound of the input points will be n. 'Qbk' scales to -0.5. Geometry Center 2003/12/30 13 qhull(1) qhull(1) QBk:n Scale the k'th coordinate of the input points. After scaling, the upper bound will be n. 'QBk' scales to +0.5. Qc Keep coplanar points with the nearest facet. Out- put formats 'p', 'f', 'Gp', 'Fc', 'FN', and 'FP' will print the points. Qf Partition points to the furthest outside facet. Qg Only build good facets. With the 'Qg' option, Qhull will only build those facets that it needs to determine the good facets in the output. See 'QGn', 'QVn', and 'PdD' for defining good facets, and 'Pg' and 'PG' for printing good facets and their neighbors. QGn A facet is good (see 'Qg' and 'Pg') if it is visi- ble from point n. If n < 0, a facet is good if it is not visible from point n. Point n is not added to the hull (unless 'TCn' or 'TPn'). With rbox, use the 'Pn,m,r' option to define your point; it will be point 0 (QG0). Qi Keep interior points with the nearest facet. Out- put formats 'p', 'f', 'Gp', 'FN', 'FP', and 'Fc' will print the points. QJn Joggle each input coordinate by adding a random number in [-n,n]. If a precision error occurs, then qhull increases n and tries again. It does not increase n beyond a certain value, and it stops after a certain number of attempts [see user.h]. Option 'QJ' selects a default value for n. The output will be simplicial. For Delaunay triangula- tions, 'QJn' sets 'Qbb' to scale the last coordi- nate (not if 'Qbk:n' or 'QBk:n' is set). 'QJn' is deprecated for Voronoi diagrams. See also 'Qt'. Qm Only process points that would otherwise increase max_outside. Other points are treated as coplanar or interior points. Qr Process random outside points instead of furthest ones. This makes Qhull equivalent to the random- ized incremental algorithms. CPU time is not reported since the randomization is inefficient. QRn Randomly rotate the input points. If n=0, use time as the random number seed. If n>0, use n as the random number seed. If n=-1, don't rotate but use time as the random number seed. For Delaunay tri- angulations ('d' and 'v'), rotate about the last axis. Geometry Center 2003/12/30 14 qhull(1) qhull(1) Qs Search all points for the initial simplex. Qt Triangulated output. Triangulate non-simplicial facets. 'Qt' is deprecated for Voronoi diagrams. See also 'QJn' Qv Test vertex neighbors for convexity after post- merging. To use the 'Qv' option, you also need to set a merge option (e.g., 'Qx' or 'C-0'). QVn A good facet (see 'Qg' and 'Pg') includes point n. If n<0, then a good facet does not include point n. The point is either in the initial simplex or it is the first point added to the hull. Option 'QVn' may not be used with merging. Qx Perform exact merges while building the hull. The "exact" merges are merging a point into a coplanar facet (defined by 'Vn', 'Un', and 'C-n'), merging concave facets, merging duplicate ridges, and merg- ing flipped facets. Coplanar merges and angle coplanar merges ('A-n') are not performed. Concav- ity testing is delayed until a merge occurs. After the hull is built, all coplanar merges are performed (defined by 'C-n' and 'A-n'), then post- merges are performed (defined by 'Cn' and 'An'). Qz Add a point "at infinity" that is above the paraboloid for Delaunay triangulations and Voronoi diagrams. This reduces precision problems and allows the triangulation of cospherical points. Qhull experiments and speedups Q0 Turn off pre-merging as a default option. With 'Q0'/'Qx' and without explicit pre-merge options, Qhull ignores precision issues while constructing the convex hull. This may lead to precision errors. If so, a descriptive warning is generated. Q1 With 'Q1', Qhull sorts merges by type (coplanar, angle coplanar, concave) instead of by angle. Q2 With 'Q2', Qhull merges all facets at once instead of using independent sets of merges and then retesting. Q3 With 'Q3', Qhull does not remove redundant ver- tices. Q4 With 'Q4', Qhull avoids merges of an old facet into a new facet. Q5 With 'Q5', Qhull does not correct outer planes at the end. The maximum outer plane is used instead. Geometry Center 2003/12/30 15 qhull(1) qhull(1) Q6 With 'Q6', Qhull does not pre-merge concave or coplanar facets. Q7 With 'Q7', Qhull processes facets in depth-first order instead of breadth-first order. Q8 With 'Q8' and merging, Qhull does not retain near- interior points for adjusting outer planes. 'Qc' will probably retain all points that adjust outer planes. Q9 With 'Q9', Qhull processes the furthest of all out- side sets at each iteration. Q10 With 'Q10', Qhull does not use special processing for narrow distributions. Q11 With 'Q11', Qhull copies normals and recomputes centrums for tricoplanar facets. Q12 With 'Q12', Qhull does not report a very wide merge due to a duplicated ridge with nearly coincident vertices Q14 With 'Q14', Qhull does not rename vertices that create a duplicate ridge Trace options Tn Trace at level n. Qhull includes full execution tracing. 'T-1' traces events. 'T1' traces the overall execution of the program. 'T2' and 'T3' trace overall execution and geometric and topologi- cal events. 'T4' traces the algorithm. 'T5' includes information about memory allocation and Gaussian elimination. Ta Annotate output with codes that identify the corresponding qh_fprintf() statement. Tc Check frequently during execution. This will catch most inconsistency errors. TCn Stop Qhull after building the cone of new facets for point n. The output for 'f' includes the cone and the old hull. See also 'TVn'. TFn Report progress whenever more than n facets are created During post-merging, 'TFn' reports progress after more than n/2 merges. TI file Input data from 'file'. The filename may not include spaces or quotes. TO file Output results to 'file'. The name may be enclosed in single quotes. TPn Turn on tracing when point n is added to the hull. Trace partitions of point n. If used with TWn, turn off tracing after adding point n to the hull. TRn Rerun qhull n times. Usually used with 'QJn' to determine the probability that a given joggle will fail. Ts Collect statistics and print to stderr at the end of execution. Tv Verify the convex hull. This checks the topologi- cal structure, facet convexity, and point inclu- sion. If precision problems occurred, facet con- vexity is tested whether or not 'Tv' is selected. Option 'Tv' does not check point inclusion if Geometry Center 2003/12/30 16 qhull(1) qhull(1) forcing output with 'Po', or if 'Q5' is set. For point inclusion testing, Qhull verifies that all points are below all outer planes (facet->max- outside). Point inclusion is exhaustive if merging or if the facet-point product is small enough; oth- erwise Qhull verifies each point with a directed search (qh_findbest). Point inclusion testing occurs after producing out- put. It prints a message to stderr unless option 'Pp' is used. This allows the user to interrupt Qhull without changing the output. TVn Stop Qhull after adding point n. If n < 0, stop Qhull before adding point n. Output shows the hull at this time. See also 'TCn' TMn Turn on tracing at n'th merge. TWn Trace merge facets when the width is greater than n. Tz Redirect stderr to stdout. BUGS Please report bugs to Brad Barber at qhull_bug@qhull.org. If Qhull does not compile, it is due to an incompatibility between your system and ours. The first thing to check is that your compiler is ANSI standard. If it is, check the man page for the best options, or find someone to help you. If you locate the cause of your problem, please send email since it might help others. If Qhull compiles but crashes on the test case (rbox D4), there's still incompatibility between your system and ours. Typically it's been due to mem.c and memory align- ment. You can use qh_NOmem in mem.h to turn off memory management. Please let us know if you figure out how to fix these problems. If you do find a problem, try to simplify it before reporting the error. Try different size inputs to locate the smallest one that causes an error. You're welcome to hunt through the code using the execution trace as a guide. This is especially true if you're incorporating Qhull into your own program. When you do report an error, please attach a data set to the end of your message. This allows us to see the error for ourselves. Qhull is maintained part-time. Geometry Center 2003/12/30 17 qhull(1) qhull(1) E-MAIL Please send correspondence to qhull@qhull.org and report bugs to qhull_bug@qhull.org. Let us know how you use Qhull. If you mention it in a paper, please send the reference and an abstract. If you would like to get Qhull announcements (e.g., a new version) and news (any bugs that get fixed, etc.), let us know and we will add you to our mailing list. If you would like to communicate with other Qhull users, we will add you to the qhull_users alias. For Internet news about geometric algorithms and convex hulls, look at comp.graph- ics.algorithms and sci.math.num-analysis SEE ALSO rbox(1) Barber, C. B., D.P. Dobkin, and H.T. Huhdanpaa, "The Quickhull Algorithm for Convex Hulls," ACM Trans. on Math- ematical Software, 22(4):469-483, Dec. 1996. http://portal.acm.org/citation.cfm?doid=235815.235821 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.117.405 Clarkson, K.L., K. Mehlhorn, and R. Seidel, "Four results on randomized incremental construction," Computational Geometry: Theory and Applications, vol. 3, p. 185-211, 1993. Preparata, F. and M. Shamos, Computational Geometry, Springer-Verlag, New York, 1985. AUTHORS C. Bradford Barber Hannu Huhdanpaa bradb@shore.net hannu@qhull.org ACKNOWLEDGEMENTS A special thanks to Albert Marden, Victor Milenkovic, the Geometry Center, Harvard University, and Endocardial Solu- tions, Inc. for supporting this work. Qhull 1.0 and 2.0 were developed under National Science Foundation grants NSF/DMS-8920161 and NSF-CCR-91-15793 750-7504. David Dobkin Geometry Center 2003/12/30 18 qhull(1) qhull(1) guided the original work at Princeton University. If you find it useful, please let us know. The Geometry Center was supported by grant DMS-8920161 from the National Science Foundation, by grant DOE/DE-FG02-92ER25137 from the Department of Energy, by the University of Minnesota, and by Minnesota Technology, Inc. Qhull is available from http://www.qhull.org Geometry Center 2003/12/30 19 geometry/inst/doc/qhull/html/qh-optt.html0000644000176200001440000003151714664417655020233 0ustar liggesusers Qhull trace options (T)

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[delaunay] Qhull trace options (T)

This section lists the trace options for Qhull. These options are indicated by 'T' followed by a letter.

Copyright © 1995-2020 C.B. Barber


» Programs OptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)

Trace options

 
General
Ta
annotate output with message codes
TFn
report progress whenever n or more facets created
TI file
input data from a file
TO file
output results to a file
Ts
print statistics
Tv
verify result: structure, convexity, and point inclusion
Tz
output error information to stdout instead of stderr
 
 
Debugging
T4
trace at level n, 4=all, 5=mem/gauss, -1= events
TAn
stop after adding n vertices
Tc
check frequently during execution
TCn
stop qhull after building cone for point n
Tf
flush each qh_fprintf for debugging segfaults
TMn
turn on tracing at merge n
TPn
turn on tracing when point n added to hull
TRn
rerun qhull n times for QJn statitics
TV-n
stop qhull before adding point n
TVn
stop qhull after adding point n
TWn
trace merge facets when width > n

»Ta - annotate output with message codes

With option 'Ta', Qhull annotates output with message codes. Programmers may use these codes to trap the corresponding print statements.

»TAn - stop Qhull after adding n vertices

With option 'TAn', Qhull stops after adding n vertices. See option 'TVn' to stop after adding point n.

»Tc - check frequently during execution

Qhull includes frequent checks of its data structures. Option 'Tc' will catch most inconsistency errors. It is slow and should not be used for production runs. Option 'Tv' performs the same checks after the hull is constructed. Tracing ('T4') adds additional calls to qh_checkconvex, qh_checkpolygon, and qh_checkfacet.

»TCn - stop qhull after building cone for point n

Qhull builds a cone from the point to its horizon facets. Option 'TCn' stops Qhull just after building the cone. The output for 'f' includes the cone and the old hull.'.

»Tf - flush each qh_fprintf for debugging segfaults

Option 'Tf' flushes each qh_fprintf for debugging segfaults.

See option 'Tz' for redirecting stderr.

»TFn - report summary whenever n or more facets created

Option 'TFn' reports progress whenever more than n facets are created. The test occurs just before adding a new point to the hull. During post-merging, 'TFn' reports progress after more than n/2 merges.

»TI file - input data from file

Input data from 'file' instead of stdin. The filename may be enclosed in single quotes. If the filename does not contain spaces, TIfile is OK.

You may use I/O redirection instead (e.g., 'rbox 10 | qdelaunay >results').

»TMn - turn on tracing at merge n

Turn on tracing at n'th merge.

»Tn - trace at level n

Qhull includes full execution tracing. 'T-1' traces events. 'T1' traces the overall execution of the program. 'T2' and 'T3' trace overall execution, and geometric, topological, and merge events. 'T4' is the detailed trace of Qhull. 'T5' adds information about memory allocation and Gaussian elimination. 'T1' is useful for logging progress of Qhull in high dimensions. See Debugging Qhull.

Option 'Tn' can produce large amounts of output. Use options 'TPn', 'TWn', and 'TMn' to selectively turn on tracing. Since all errors report the last processed point, option 'TPn' is particularly useful.

Different executions of the same program may produce different traces and different results. The reason is that Qhull uses hashing to match ridges of non-simplicial facets. For performance reasons, the hash computation uses memory addresses which may change across executions.

»TO file - output results to file

Redirect stdout to 'file'. The filename may be enclosed in single quotes. If the filename does not contain spaces, TOfile is OK. Unix and Windows NT users may use I/O redirection instead of 'TO' (e.g., 'rbox 10 | qdelaunay >results').

Windows95 users should always use 'TO file'. If they use I/O redirection, error output is not sent to the console. Qhull uses single quotes instead of double quotes because a missing double quote can freeze Windows95 (e.g., do not run, rbox 10 | qhull TO "x)

»TPn - turn on tracing when point n added to hull

Option 'TPn' turns on tracing when point n is added to the hull. It also traces partitions of point n. This option reduces the output size when tracing. It is the normal method to determine the cause of a Qhull error. All Qhull errors report the last point added.

Use option 'TP-1' to turn on tracing after qh_buildhull and qh_postmerge.

Use options 'TPn TVn' to trace the addition of point n to the convex hull and stop when done.

If used with option 'TWn', 'TPn' turns off tracing after adding point n to the hull. Use options 'TPn TWn' to trace the addition of point n to the convex hull, partitions of point n, and wide merges.

»TRn - rerun qhull n times for QJn statitics

Option 'TRn' reruns Qhull n times. It is used with 'QJn' to determine the probability that a given joggle will fail. The summary ('s') lists the failure rate and the precision errors that occurred. Option 'Ts' will report statistics for all of the runs. Trace and output options only apply to the last run. An event trace, 'T-1' reports events for all runs.

Tracing applies to the last run of Qhull. If an error is reported, the options list the run number as "_run". To trace this run, set 'TRn' to the same value.

»Ts - print statistics

Option 'Ts' collects statistics and prints them to stderr. For Delaunay triangulations, the angle statistics are restricted to the lower or upper envelope.

»Tv - verify result: structure, convexity, and point inclusion

Option 'Tv' checks the topological structure, flipped facets, and point inclusion. Facet convexity is tested if not merging or if 2-D/3-D and a merged facet. If precision problems occur, flipped facet tests and facet convexity tests occur whether or not 'Tv' is selected. Option 'Tv' does not check point inclusion if forcing output with 'Po', or if 'Q5' is set.

The convex hull of a set of points is the smallest polytope that includes the points. Option 'Tv' tests point inclusion. Qhull verifies that all points are below all outer planes (facet->maxoutside). Point inclusion is exhaustive if merging or if the facet-point product is small enough; otherwise Qhull verifies each point with a directed search (qh_findbest). To force an exhaustive test when using option 'C-0' (default), use 'C-1e-30' instead.

Point inclusion testing occurs after producing output. It prints a message to stderr unless option 'Pp' is used. This allows the user to interrupt Qhull without changing the output.

With 'qvoronoi Fi', option 'Tv' collects statistics that verify all Voronoi vertices lie on the separating hyperplane, and all separating hyperplanes are perpendicular bisectors.

»TV-n - stop qhull before adding point n

Qhull adds one point at a time to the convex hull. See how Qhull adds a point. Option 'TV-n' stops Qhull just before adding a new point. Output shows the hull at this time.

»TVn - stop qhull after adding point n

Option 'TVn' stops Qhull after it has added point n and before it deletes the visible facets. If facet merges lead to vertex merges, 'TVn' stops after vertex merges and deleting visible facets. Output shows the hull at this time. See option 'TAn' to stop after adding n vertices.

»TWn - trace merge facets when width > n

Along with TMn, this option allows the user to determine the cause of a wide merge.

»Tz - send all output to stdout

Redirect stderr to stdout. See option 'Tf' for flushing writes.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qh-impre.html0000644000176200001440000011567514664417655020371 0ustar liggesusers Imprecision in Qhull

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull imprecision: contents


[4-d cube] Imprecision in Qhull

This section of the Qhull manual discusses the problems caused by coplanar points and why Qhull uses the default options 'C-0' or 'Qx'. If you ignore precision issues with option 'Q0', the output from Qhull can be arbitrarily bad. Qhull avoids most precision problems if you merge facets (the default) or joggle the input ('QJ').

Use option 'Tv' to verify the output from Qhull. It verifies that adjacent facets are clearly convex. It verifies that all points are on or below all facets.

Qhull automatically tests for convexity if it detects precision errors while constructing the hull.

Copyright © 1995-2020 C.B. Barber


»Qhull imprecision: contents


»Precision problems

Since Qhull uses floating point arithmetic, roundoff error occurs with each calculation. This causes problems for geometric algorithms. Other floating point codes for convex hulls, Delaunay triangulations, and Voronoi diagrams also suffer from these problems. Qhull handles most of them.

There are several kinds of precision errors:

  • Representation error occurs when there are not enough digits to represent a number, e.g., 1/3.
  • Measurement error occurs when the input coordinates are from measurements.
  • Roundoff error occurs when a calculation is rounded to a fixed number of digits, e.g., a floating point calculation.
  • Approximation error occurs when the user wants an approximate result because the exact result contains too much detail.
  • Topological error occurs when the topology of mathematical convex hulls is broken by facet merging or vertex merging.

Under imprecision, calculations may return erroneous results. For example, roundoff error can turn a small, positive number into a small, negative number. See Milenkovic ['93] for a discussion of strict robust geometry. Qhull does not meet Milenkovic's criterion for accuracy. Qhull's error bound is empirical instead of theoretical.

Qhull 1.0 checked for precision errors but did not handle them. The output could contain concave facets, facets with inverted orientation ("flipped" facets), more than two facets adjacent to a ridge, and two facets with exactly the same set of vertices.

Qhull 2.4 and later automatically handles errors due to machine round-off. Option 'C-0' or 'Qx' is set by default. In 5-d and higher, the output is clearly convex but an input point could be outside of the hull. This may be corrected by using option 'C-0', but then the output may contain wide facets.

Qhull 2.5 and later provides option 'QJ' to joggled input. Each input coordinate is modified by a small, random quantity. If a precision error occurs, a larger modification is tried. When no precision errors occur, Qhull is done.

Joggled input avoids merged facets and the topological issues that may arise. If your application is sensitive to errors, consider joggled input and the corresponding flag, qh_NOmerge.

Qhull 3.1 and later provides option 'Qt' for triangulated output. Non-simplicial facets are triangulated. The facets may have zero area. Triangulated output is particularly useful for Delaunay triangulations.

Qhull 2019.1 includes an experimental option ('Q14') to merge nearly adjacent vertices due to duplicated ridges. If reports a topological error if merging fails to resolve the issue. Further work is needed.

By handling round-off errors, Qhull can provide a variety of output formats. For example, it can return the halfspace that defines each facet ('n'). The halfspaces include roundoff error. If the halfspaces were exact, their intersection would return the original extreme points. With imprecise halfspaces and exact arithmetic, nearly incident points may be returned for an original extreme point. By handling roundoff error, Qhull returns one intersection point for each of the original extreme points. Qhull may split or merge an extreme point, but this appears to be unlikely.

The following pipe implements the identity function for extreme points (with roundoff):

qconvex FV n | qhalf Fp

Bernd Gartner published his Miniball algorithm ["Fast and robust smallest enclosing balls", Algorithms - ESA '99, LNCS 1643]. It uses floating point arithmetic and a carefully designed primitive operation. It is practical to 20-D or higher, and identifies at least two points on the convex hull of the input set. Like Qhull, it is an incremental algorithm that processes points furthest from the intermediate result and ignores points that are close to the intermediate result.

»Merged facets or joggled input

This section discusses the choice between merged facets and joggled input. By default, Qhull uses merged facets to handle precision problems. With option 'QJ', the input is joggled. See examples of joggled input and triangulated output.

  • Use merged facets (the default) when you want non-simplicial output (e.g., the faces of a cube).
  • Use joggled input ('QJ') when you need clearly-convex, simplicial output.
  • Use joggled input if your code is sensitive to errors. Joggled input handles all inputs, even highly degenerate inputs such as 100 identical points. If you compile with qh_NOmerge, Qhull does not contain code for merging facets. It uses joggled input instead.
  • Otherwise, use merged facets and triangulated output ('Qt') when you want simplicial output and coplanar facets (e.g., triangles for a Delaunay triangulation).

The choice between merged facets and joggled input depends on the application. Both run about the same speed. Joggled input may be faster if the initial joggle is sufficiently large to avoid precision errors. Although less precise, joggled input is more reliable than merged facets. A future version of Qhull will provide per vertex joggle.

Use merged facets (the default, 'C-0') or triangulated output ('Qt') if

  • Your application supports non-simplicial facets, or it allows degenerate, simplicial facets (option 'Qt').
  • You do not want the input modified.
  • Your input coordinates start with the same five or more digits (i.e., it is shifted relative to the origin). This reduces the available precision.
  • You use single precision arithmetic (realT).
  • You want to set additional options for approximating the hull.

Use joggled input ('QJ') if

  • Your application needs clearly convex, simplicial output
  • Your application supports perturbed input points and narrow triangles.
  • Seven significant digits is sufficient accuracy.
  • Your application is sensitive to errors.

You may use both techniques or combine joggle with post-merging ('Cn').

Other researchers have used techniques similar to joggled input. Sullivan and Beichel [ref?] randomly perturb the input before computing the Delaunay triangulation. Corkum and Wyllie [news://comp.graphics, 1990] randomly rotate a polytope before testing point inclusion. Edelsbrunner and Mucke [Symp. Comp. Geo., 1988] and Yap [J. Comp. Sys. Sci., 1990] symbolically perturb the input to remove singularities.

Merged facets ('C-0') handles precision problems directly. If a precision problem occurs, Qhull merges one of the offending facets into one of its neighbors. With multiple merges, topological problems may lead to severe precision problems, or prevent Qhull from continuing. Otherwise, Qhull will either fix the problem or attempt to merge the last remaining facets.

»Joggled input

Joggled input is a simple work-around for precision problems in computational geometry ["joggle: to shake or jar slightly," Amer. Heritage Dictionary]. Other names are jostled input or random perturbation. Qhull joggles the input by modifying each coordinate by a small random quantity. If a precision problem occurs, Qhull joggles the input with a larger quantity and the algorithm is restarted. This process continues until no precision problems occur. Unless all inputs incur precision problems, Qhull will terminate. Qhull adjusts the inner and outer planes to account for the joggled input.

Neither joggle nor merged facets has an upper bound for the width of the output facets, but both methods work well in practice. Joggled input is easier to justify. Precision errors occur when the points are nearly singular. For example, four points may be coplanar or three points may be collinear. Consider a line and an incident point. A precision error occurs if the point is within some epsilon of the line. Now joggle the point away from the line by a small, uniformly distributed, random quantity. If the point is changed by more than epsilon, the precision error is avoided. The probability of this event depends on the maximum joggle. Once the maximum joggle is larger than epsilon, doubling the maximum joggle will halve the probability of a precision error.

With actual data, an analysis would need to account for each point changing independently and other computations. It is easier to determine the probabilities empirically ('TRn') . For example, consider computing the convex hull of the unit cube centered on the origin. The arithmetic has 16 significant decimal digits.

Convex hull of unit cube

joggle error prob.
1.0e-15 0.983
2.0e-15 0.830
4.0e-15 0.561
8.0e-15 0.325
1.6e-14 0.185
3.2e-14 0.099
6.4e-14 0.051
1.3e-13 0.025
2.6e-13 0.010
5.1e-13 0.004
1.0e-12 0.002
2.0e-12 0.001

A larger joggle is needed for multiple points. Since the number of potential singularities increases, the probability of one or more precision errors increases. Here is an example.

Convex hull of 1000 points on unit cube

joggle error prob.
1.0e-12 0.870
2.0e-12 0.700
4.0e-12 0.450
8.0e-12 0.250
1.6e-11 0.110
3.2e-11 0.065
6.4e-11 0.030
1.3e-10 0.010
2.6e-10 0.008
5.1e-09 0.003

Other distributions behave similarly. No distribution should behave significantly worse. In Euclidean space, the probability measure of all singularities is zero. With floating point numbers, the probability of a singularity is non-zero. With sufficient digits, the probability of a singularity is extremely small for random data. For a sufficiently large joggle, all data is nearly random data.

Qhull uses an initial joggle of 30,000 times the maximum roundoff error for a distance computation. This avoids most potential singularities. If a failure occurs, Qhull retries at the initial joggle (in case bad luck occurred). If it occurs again, Qhull increases the joggle by ten-fold and tries again. This process repeats until the joggle is a hundredth of the width of the input points. Qhull reports an error after 100 attempts. This should never happen with double-precision arithmetic. Once the probability of success is non-zero, the probability of success increases about ten-fold at each iteration. The probability of repeated failures becomes extremely small.

Merged facets produces a significantly better approximation. Empirically, the maximum separation between inner and outer facets is about 30 times the maximum roundoff error for a distance computation. This is about 2,000 times better than joggled input. Most applications though will not notice the difference.

»Delaunay triangulations

Programs that use Delaunay triangulations traditionally assume a triangulated input. By default, qdelaunay merges regions with cocircular or cospherical input sites. If you want a simplicial triangulation use triangulated output ('Qt') or joggled input ('QJ').

For Delaunay triangulations, triangulated output should produce good results. All points are within roundoff error of a paraboloid. If two points are nearly incident, one will be a coplanar point. So all points are clearly separated and convex. If qhull reports deleted vertices, the triangulation may contain serious precision faults. Deleted vertices are reported in the summary ('s', 'Fs'

You should use option 'Qbb' with Delaunay triangulations. It scales the last coordinate and may reduce roundoff error. It is automatically set for qdelaunay, qvoronoi, and option 'QJ'.

Edelsbrunner, H, Geometry and Topology for Mesh Generation, Cambridge University Press, 2001. Good mathematical treatise on Delaunay triangulation and mesh generation for 2-d and 3-d surfaces. The chapter on surface simplification is particularly interesting. It is similar to facet merging in Qhull.

Veron and Leon published an algorithm for shape preserving polyhedral simplification with bounded error [Computers and Graphics, 22.5:565-585, 1998]. It remove nodes using front propagation and multiple remeshing.

»Halfspace intersection

The identity pipe for Qhull reveals some precision questions for halfspace intersections. The identity pipe creates the convex hull of a set of points and intersects the facets' hyperplanes. It should return the input points, but narrow distributions may drop points while offset distributions may add points. It may be better to normalize the input set about the origin. For example, compare the first results with the later two results: [T. Abraham]

rbox 100 s t | tee r | qconvex FV n | qhalf Fp | cat - r | /bin/sort -n | tail
rbox 100 L1e5 t | tee r | qconvex FV n | qhalf Fp | cat - r | /bin/sort -n | tail
rbox 100 s O10 t | tee r | qconvex FV n | qhalf Fp | cat - r | /bin/sort -n | tail

»Merged facets

Qhull detects precision problems when computing distances. A precision problem occurs if the distance computation is less than the maximum roundoff error. Qhull treats the result of a hyperplane computation as if it were exact.

Qhull handles precision problems by merging non-convex facets. The result of merging two facets is a thick facet defined by an inner plane and an outer plane. The inner and outer planes are offsets from the facet's hyperplane. The inner plane is clearly below the facet's vertices. At the end of Qhull, the outer planes are clearly above all input points. Any exact convex hull must lie between the inner and outer planes.

Qhull tests for convexity by computing a point for each facet. This point is called the facet's centrum. It is the arithmetic center of the facet's vertices projected to the facet's hyperplane. For simplicial facets with d vertices, the centrum is equivalent to the centroid or center of gravity.

Two neighboring facets are convex if each centrum is clearly below the other hyperplane. The 'Cn' or 'C-n' options sets the centrum's radius to n . A centrum is clearly below a hyperplane if the computed distance from the centrum to the hyperplane is greater than the centrum's radius plus two maximum roundoff errors. Two are required because the centrum can be the maximum roundoff error above its hyperplane and the distance computation can be high by the maximum roundoff error.

With the 'C-n' or 'A-n' options, Qhull merges non-convex facets while constructing the hull. The remaining facets are clearly convex. With the 'Qx' option, Qhull merges coplanar facets after constructing the hull. While constructing the hull, it merges coplanar horizon facets, flipped facets, concave facets and duplicated ridges. With 'Qx', coplanar points may be missed, but it appears to be unlikely.

If the user sets the 'An' or 'A-n' option, then all neighboring facets are clearly convex and the maximum (exact) cosine of an angle is n.

If 'C-0' or 'Qx' is used without other precision options (default), Qhull tests vertices instead of centrums for adjacent simplices. In 3-d, if simplex abc is adjacent to simplex bcd, Qhull tests that vertex a is clearly below simplex bcd , and vertex d is clearly below simplex abc. When building the hull, Qhull tests vertices if the horizon is simplicial and no merges occur.

»How Qhull merges facets

If two facets are not clearly convex, then Qhull removes one or the other facet by merging the facet into a neighbor. It selects the merge which minimizes the distance from the neighboring hyperplane to the facet's vertices. Qhull also performs merges when a facet has fewer than d neighbors (called a degenerate facet), when a facet's vertices are included in a neighboring facet's vertices (called a redundant facet), when a facet's orientation is flipped, or when a ridge occurs between more than two facets.

Qhull performs merges in a series of passes sorted by merge angle. Each pass merges those facets which haven't already been merged in that pass. After a pass, Qhull checks for redundant vertices. For example, if a vertex has only two neighbors in 3-d, the vertex is redundant and Qhull merges it into an adjacent vertex.

Merging two simplicial facets creates a non-simplicial facet of d+1 vertices. Additional merges create larger facets. When merging facet A into facet B, Qhull retains facet B's hyperplane. It merges the vertices, neighbors, and ridges of both facets. It recomputes the centrum if a wide merge has not occurred (qh_WIDEcoplanar) and the number of extra vertices is smaller than a constant (qh_MAXnewcentrum).

If a topological error occurs, such as more than two neighbors for a newly created ridge, Qhull may merge nearly adjacent vertices.

»Limitations of merged facets

  • Uneven dimensions -- If one coordinate has a larger absolute value than other coordinates, it may dominate the effect of roundoff errors on distance computations. The same issue occurs if one coordinate has a narrow range of values compared to another coordinate. You may use option 'QbB' to scale points to the unit cube. For Delaunay triangulations and Voronoi diagrams, qdelaunay and qvoronoi always set option 'Qbb'. It scales the last coordinate to [0,m] where m is the maximum width of the other coordinates. Option 'Qbb' is needed for Delaunay triangulations of integer coordinates and nearly cocircular points.

    For example, compare

            rbox 1000 W0 t | qconvex Qb2:-1e-14B2:1e-14
    
    with
            rbox 1000 W0 t | qconvex
    
    The distributions are the same but the first is compressed to a 2e-14 slab.

  • Post-merging of coplanar facets -- In 5-d and higher, the default option 'Qx' delays merging of coplanar facets until post-merging. This may allow "dents" to occur in the intermediate convex hulls. A point may be poorly partitioned and force a poor approximation. See option 'Qx' for further discussion.

    This is difficult to produce in 5-d and higher. Option 'Q6' turns off merging of concave facets. This is similar to 'Qx'. It may lead to serious precision errors, for example,

            rbox 10000 W1e-13  | qhull Q6  Tv
    

  • Maximum facet width -- Qhull reports the maximum outer plane and inner planes (if more than roundoff error apart). There is no upper bound for either figure. This is an area for further research. Qhull does a good job of post-merging in all dimensions. Qhull does a good job of pre-merging in 2-d, 3-d, and 4-d. With the 'Qx' option, it does a good job in higher dimensions. In 5-d and higher, Qhull does poorly at detecting redundant vertices.

    In the summary ('s'), look at the ratio between the maximum facet width and the maximum width of a single merge, e.g., "(3.4x)". Qhull usually reports a ratio of four or lower in 3-d and six or lower in 4-d. If it reports a ratio greater than 10, this may indicate an implementation error. Narrow distributions (see following) may produce wide facets.

    For example, if special processing for narrow distributions is turned off ('Q10'), qhull may produce a wide facet:

             rbox 1000 L100000 s G1e-16 t1002074964 | qhull Tv Q10
    

  • Narrow distribution -- In 3-d, a narrow distribution may result in a poor approximation. For example, if you do not use qdelaunay nor option 'Qbb', the furthest-site Delaunay triangulation of nearly cocircular points may produce a poor approximation:
             rbox s 5000 W1e-13 D2 t1002151341 | qhull d Qt
             rbox 1000 s W1e-13 t1002231672 | qhull d Tv
    

    During construction of the hull, a point may be above two facets with opposite orientations that span the input set. Even though the point may be nearly coplanar with both facets, and can be distant from the precise convex hull of the input sites. Additional facets leave the point distant from a facet. To fix this problem, add option 'Qbb' (it scales the last coordinate). Option 'Qbb' is automatically set for qdelaunay and qvoronoi.

    Qhull generates a warning if the initial simplex is narrow. For narrow distributions, Qhull changes how it processes coplanar points -- it does not make a point coplanar until the hull is finished. Use option 'Q10' to try Qhull without special processing for narrow distributions. For example, special processing is needed for:

             rbox 1000 L100000 s G1e-16 t1002074964 | qhull Tv Q10
    

    You may turn off the warning message by reducing qh_WARNnarrow in user.h or by setting option 'Pp'.

    Similar problems occur for distributions with a large flat facet surrounded with many small facet at a sharp angle to the large facet. Qhull 3.1 fixes most of these problems, but a poor approximation can occur. A point may be left outside of the convex hull ('Tv'). Examples include the furthest-site Delaunay triangulation of nearly cocircular points plus the origin, and the convex hull of a cone of nearly cocircular points. The width of the band is 10^-13.

            rbox s 1000 W1e-13 P0 D2 t996799242 | qhull d Tv
            rbox 1000 s Z1 G1e-13 t1002152123 | qhull Tv
            rbox 1000 s Z1 G1e-13 t1002231668 | qhull Tv
    

  • Quadratic running time -- If the output contains large, non-simplicial facets, the running time for Qhull may be quadratic in the size of the triangulated output. For example, rbox 1000 s W1e-13 c G2 | qhull d is 4 times faster for 500 points. The convex hull contains two large nearly spherical facets and many nearly coplanar facets. Each new point retriangulates the spherical facet and repartitions the remaining points into all of the nearly coplanar facets. In this case, quadratic running time is avoided if you use qdelaunay, add option 'Qbb', or add the origin ('P0') to the input.

  • Nearly adjacent vertices within 1e-13 -- Multiple, nearly adjacent vertices within a 1e-13 ball in the unit cube may lead to topological errors and wide facets. The experimental option 'Q14' for Qhull 2019.1 merges nearly adjacent vertices to resolve dupridges. A dupridge is a topological error where multiple facets meet at the same ridge. Further improvements are needed, primarily for 4-D and higher. For example, the Delaunay triangulation of 400 pairs of nearly adjacent 5-D points frequently fails with a topological error (eg/qtest.sh 10 '400 C1,2e-13 D5' 'Q14 d Qbb').

    For Delaunay triangulations, the problem typically occurs for extreme points of the input set (i.e., on the edge between the upper and lower convex hull). After multiple facet merges, four facets may share a "dupridge" and must be merged. Some of these facets may be twisted relative to each other, leading to a very wide merged facet. If so, error QH6271 is reported. It may be overriden with option 'Q12'.

    A "dupridge" may occur when the horizon facets for a new point is "pinched" (i.e., two vertices are nearly adjacent). If a subridge (e.g., a line segment in 3-d) is shared by two horizon facets, the four corresponding new facets meet at the same ridge, called a "dupridge". In poly_r.c, qh_matchnewfacets calls qh_matchneighbor. qh_matchneighbor identifies dupridges for matching by qh_matchdupridge. In merge_r.c, qh_mark_dupridges identifies facets for merging across a dupridge. If vertices are nearly adjacent, qh_merge_pinchedvertices merges the vertices, otherwise qh_forcedmerges merges the facets. qh_forcedmerges checks for wide merges with qh_check_dupridge.

    It is easy to generate nearly adjacent or coincident points with rbox option 'Cn,r,m'. It generates n points within an r ball for each of m input sites. For example, the following examples successfully merge pinched vertices. Substantially smaller or larger balls do not lead to pinched horizons.

            rbox 2000 C1,1e-13 D4 s t | qhull Q14
            rbox 500 C1,1e-13 t | qhull Q14 d Qbb
    
    For Delaunay triangulations, a bounding box may alleviate this issue (e.g., rbox 500 C1,1E-13 D4 t c G1.0 | qhull Q14 d Qbb). The Delaunay triangulation of a regular mesh is likewise sensitive to nearly adjacent vertices.
            rbox 2000 M3,4,5 D4 C1,1e-8 | qhull Q14 d Qbb
    

  • Topological errors -- Merging facets and vertices may lead to topological errors that do not occur for mathematical, convex hulls. Qhull merges redundant or degenerate facets. With option 'Q14', Qhull tries to correct "dupridges" by merging vertices or facets (see previous issue). It corrects some instances of dupridges. Qhull reports a "Qhull topology error" if a topological error leads to a wide facet or if Qhull fails to create a cone of new facets. It leaves other cases as is. The orientation of nonsimplicial facets is ill-defined. Ridges may have the same vertices. Adjacent nonsimplicial facets may have incompatible triangulations. These problems may be addressed in future releases of Qhull.

  • Facet with zero-area -- It is possible for a zero-area facet to be convex with its neighbors. This can occur if the hyperplanes of neighboring facets are above the facet's centrum, and the facet's hyperplane is above the neighboring centrums. Qhull computes the facet's hyperplane so that it passes through the facet's vertices. The vertices can be collinear.

  • No more facets -- Qhull reports an error if there are d+1 facets left and two of the facets are not clearly convex. This typically occurs when the convexity constraints are too strong or the input points are degenerate. The former is more likely in 5-d and higher -- especially with option 'C-n'.

  • Deleted cone -- Lots of merging can end up deleting all of the new facets for a point. This is a rare event that has only been seen while debugging the code.

  • Triangulated output leads to precision problems -- With sufficient merging, the ridges of a non-simplicial facet may have serious topological and geometric problems. A ridge may be between more than two neighboring facets. If so, their triangulation ('Qt') will fail since two facets have the same vertex set. Furthermore, a triangulated facet may have flipped orientation compared to its neighbors.
  • The triangulation process detects degenerate facets with only two neighbors. These are marked degenerate. They have zero area.

  • Coplanar points -- Option 'Qc' is determined by qh_check_maxout() after constructing the hull. Qhull needs to retain all possible coplanar points in the facets' coplanar sets. This depends on qh_RATIOnearInside in user.h. Furthermore, the cutoff for a coplanar point is arbitrarily set at the minimum vertex. If coplanar points are important to your application, remove the interior points by hand (set 'Qc Qi') or make qh_RATIOnearInside sufficiently large.

  • Maximum roundoff error -- Qhull computes the maximum roundoff error from the maximum coordinates of the point set. Usually the maximum roundoff error is a reasonable choice for all distance computations. The maximum roundoff error could be computed separately for each point or for each distance computation. This is expensive and it conflicts with option 'C-n'.

  • All flipped or upper Delaunay -- When a lot of merging occurs for Delaunay triangulations, a new point may lead to no good facets. For example, try a strong convexity constraint:
            rbox 1000 s t993602376 | qdelaunay C-1e-3
    

»Exact arithmetic

Exact arithmetic may be used instead of floating point. Singularities such as coplanar points can either be handled directly or the input can be symbolically perturbed. Using exact arithmetic is slower than using floating point arithmetic and the output may take more space. Chaining a sequence of operations increases the time and space required. Some operations are difficult to do.

CGAL includes a practical implementation of symbolic perturbation. It uses the BOOST library to generate dimension-specific, C++ data structures. It makes good use of 64-bit memory. Input sites may be added incrementally. It is the fastest 64-bit code available.

Clarkson's hull program and Shewchuk's triangle program are practical implementations of exact arithmetic.

Clarkson limits the input precision to about fifteen digits. This reduces the number of nearly singular computations. When a determinant is nearly singular, he uses exact arithmetic to compute a precise result.

»Approximating a convex hull

Qhull may be used for approximating a convex hull. This is particularly valuable in 5-d and higher where hulls can be immense. You can use 'Qx C-n' to merge facets as the hull is being constructed. Then use 'Cn' and/or 'An' to merge small facets during post-processing. You can print the n largest facets with option 'PAn'. You can print facets whose area is at least n with option 'PFn'. You can output the outer planes and an interior point with 'FV Fo' and then compute their intersection with 'qhalf'.

To approximate a convex hull in 6-d and higher, use post-merging with 'Wn' (e.g., qhull W1e-1 C1e-2 TF2000). Pre-merging with a convexity constraint (e.g., qhull Qx C-1e-2) often produces a poor approximation or terminates with a simplex. Option 'QbB' may help to spread out the data.

You will need to experiment to determine a satisfactory set of options. Use rbox to generate test sets quickly and Geomview to view the results. You will probably want to write your own driver for Qhull using the Qhull library. For example, you could select the largest facet in each quadrant.


Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: Qhull imprecision: contents


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/index.html0000644000176200001440000013142414664417655017744 0ustar liggesusers Qhull manual

Up: Home page for Qhull (local)
Up: News about Qhull
Up: Qhull Wiki and FAQ (local)
To: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)


[random-fixed] Qhull manual

Qhull is a general dimension code for computing convex hulls, Delaunay triangulations, halfspace intersections about a point, Voronoi diagrams, furthest-site Delaunay triangulations, and furthest-site Voronoi diagrams. These structures have applications in science, engineering, statistics, and mathematics. See Fukuda's introduction to convex hulls, Delaunay triangulations, Voronoi diagrams, and linear programming. For a detailed introduction, see O'Rourke ['94], Computational Geometry in C.

There are six programs. Except for rbox, they use the same code. Each program includes instructions and examples.

  • qconvex -- convex hulls
  • qdelaunay -- Delaunay triangulations and furthest-site Delaunay triangulations
  • qhalf -- halfspace intersections about a point
  • qhull -- all structures with additional options
  • qvoronoi -- Voronoi diagrams and furthest-site Voronoi diagrams
  • rbox -- generate point distributions for qhull

Qhull implements the Quickhull algorithm for computing the convex hull. Qhull includes options for hull volume, facet area, multiple output formats, and graphical output. It can approximate a convex hull.

Qhull handles roundoff errors from floating point arithmetic. It generates a convex hull with "thick" facets. A facet's outer plane is clearly above all of the points; its inner plane is clearly below the facet's vertices. Any exact convex hull must lie between the inner and outer plane.

Qhull uses merged facets, triangulated output, or joggled input. Triangulated output triangulates non-simplicial, merged facets. Joggled input also guarantees simplicial output, but it is less accurate than merged facets. For merged facets, Qhull reports the maximum outer and inner plane.

Brad Barber, Arlington, MA

Copyright © 1995-2020 C.B. Barber


»Qhull manual: contents

»When to use Qhull

Qhull constructs convex hulls, Delaunay triangulations, halfspace intersections about a point, Voronoi diagrams, furthest-site Delaunay triangulations, and furthest-site Voronoi diagrams.

For convex hulls and halfspace intersections, Qhull may be used for 2-d up to 8-d. For Voronoi diagrams and Delaunay triangulations, Qhull may be used for 2-d up to 7-d. In higher dimensions, the size of the output grows rapidly and Qhull does not work well with virtual memory. If n is the size of the input and d is the dimension (d>=3), the size of the output and execution time grows by n^(floor(d/2) [see Performance]. For example, do not try to build a 16-d convex hull of 1000 points. It will have on the order of 1,000,000,000,000,000,000,000,000 facets.

On a 1.7 GHz i7, Qhull computes the 2-d convex hull of 3,000,000 evenly spaced, cocircular points in 4.7 seconds. It computes the 2-d Delaunay triangulation and 3-d convex hull of 600,000 points in 5.9 seconds. It computes the 3-d Delaunay triangulation and 4-d convex hull of 120,000 points in 4.6 seconds. It computes the 4-d Delaunay triangulation and 5-d convex hull of 30,000 points in 5.1 seconds. It computes the 5-d Delaunay triangulation and 6-d convex hull of 6,000 points in 7.8 seconds. It computes the 6-d Delaunay triangulation and 7-d convex hull of 1,000 points in 7.6 seconds. It computes the 7-d Delaunay triangulation and 8-d convex hull of 300 points in 8.6 seconds. It computes the 8-d Delaunay triangulation and 9-d convex hull of 120 points in 5.7 seconds. It computes the 9-d Delaunay triangulation and 10-d convex hull of 70 points in 4.8 seconds. The 10-d convex hull of 70 cospherical points has about 375,000 facets.

Qhull does not support constrained Delaunay triangulations, triangulation of non-convex surfaces, mesh generation of non-convex objects, or medium-sized inputs in 9-D and higher.

This is a big package with many options. For 32-bit code, it is one of the fastest available. It is the only 3-d and higher code that handles precision problems due to floating point arithmetic. For example, it implements the identity function for extreme points (see Imprecision in Qhull).

Qhull does not handle all precision problems (Limitations of merged facets). For example, errors may occur for the 4-D Delaunay triangulation of nearly adjacent points in the unit cube. If every input site has a nearly adjacent point within a 10^-13 ball, precision errors and topological errors are likely to occur. A bounding box may alleviate these errors. Nearly adjacent points within substantially smaller or larger balls are OK.

Joggled input, option 'QJn', is an alternative to merged facets (Merged facets or joggled input). It randomly perturbs the input. If precision problems occur, Qhull restarts with a larger, random perturbation. Joggled input is a simple solution without the limitations of merged facets. For example, Qhull constructs a convex hull even if all of the input points are identical.

If you need a short code for convex hull, Delaunay triangulation, or Voronoi volumes consider Clarkson's hull program. If you need 2-d Delaunay triangulations consider Shewchuk's triangle program. It is much faster than Qhull and it allows constraints. Both programs use exact arithmetic. They are in http://www.netlib.org/voronoi/.

If your input is in general position (i.e., no coplanar or colinear points), Tomilov's quickhull.hpp (documentation-ru), or Qhull version 1.0 may meet your needs. Both programs detect precision problems, but do not handle them.

CGAL is a library of efficient and reliable geometric algorithms. It uses C++ templates and the Boost library to produce dimension-specific code. This allows more efficient use of memory than Qhull's general-dimension code. For 64-bit code, CGAL uses significantly less memory than Qhull and runs faster. CGAL simulates arbitrary precision while Qhull handles round-off error with thick facets. Compare the two approaches with Robustness Issues in CGAL, and Imprecision in Qhull.

Leda is a library for writing computational geometry programs and other combinatorial algorithms. It includes routines for computing 3-d convex hulls, 2-d Delaunay triangulations, and 3-d Delaunay triangulations. It provides rational arithmetic and graphical output. It runs on most platforms.

If your problem is in high dimensions with a few, non-simplicial facets, try Fukuda's cdd. It is much faster than Qhull for these distributions.

Custom software for 2-d and 3-d convex hulls may be faster than Qhull. Custom software should use less memory. Qhull uses general-dimension data structures and code. The data structures support non-simplicial facets.

Qhull is not suitable for mesh generation or triangulation of arbitrary surfaces. You may use Qhull if the surface is convex or completely visible from an interior point (e.g., a star-shaped polyhedron). First, project each site to a sphere that is centered at the interior point. Then, compute the convex hull of the projected sites. The facets of the convex hull correspond to a triangulation of the surface. For mesh generation of arbitrary surfaces, see Schneiders' Finite Element Mesh Generation.

Qhull is not suitable for constrained Delaunay triangulations. With a lot of work, you can write a program that uses Qhull to add constraints by adding additional points to the triangulation.

Qhull is not suitable for the subdivision of arbitrary objects. Use qdelaunay to subdivide a convex object.

»Description of Qhull

»definition

The convex hull of a point set P is the smallest convex set that contains P. If P is finite, the convex hull defines a matrix A and a vector b such that for all x in P, Ax+b <= [0,...].

Qhull computes the convex hull in 2-d, 3-d, 4-d, and higher dimensions. Qhull represents a convex hull as a list of facets. Each facet has a set of vertices, a set of neighboring facets, and a halfspace. A halfspace is defined by a unit normal and an offset (i.e., a row of A and an element of b).

Qhull accounts for round-off error. It returns "thick" facets defined by two parallel hyperplanes. The outer planes contain all input points. The inner planes exclude all output vertices. See Imprecise convex hulls.

Qhull may be used for the Delaunay triangulation or the Voronoi diagram of a set of points. It may be used for the intersection of halfspaces.

»input format

The input data on stdin consists of:

  • first line contains the dimension
  • second line contains the number of input points
  • remaining lines contain point coordinates

For example:

    3  #sample 3-d input
    5
    0.4 -0.5 1.0
    1000 -1e-5 -100
    0.3 0.2 0.1
    1.0 1.0 1.0
    0 0 0

Input may be entered by hand. End the input with a control-D (^D) character.

To input data from a file, use I/O redirection or 'TI file'. The filename may not include spaces or quotes.

A comment starts with a non-numeric character and continues to the end of line. The first comment is reported in summaries and statistics. With multiple qhull commands, use option 'FQ' to place a comment in the output.

The dimension and number of points can be reversed. Comments and line breaks are ignored. Error reporting is better if there is one point per line.

»option format

Use options to specify the output formats and control Qhull. The qhull program takes all options. The other programs use a subset of the options. They disallow experimental and inappropriate options.

  • qconvex == qhull
  • qdelaunay == qhull d Qbb
  • qhalf == qhull H
  • qvoronoi == qhull v Qbb

Single letters are used for output formats and precision constants. The other options are grouped into menus for formats ('F'), Geomview ('G'), printing ('P'), Qhull control ('Q'), and tracing ('T'). The menu options may be listed together (e.g., 'GrD3' for 'Gr' and 'GD3'). Options may be in any order. Capitalized options take a numeric argument (except for 'PG' and 'F' options). Use option 'FO' to print the selected options.

Qhull uses zero-relative indexing. If there are n points, the index of the first point is 0 and the index of the last point is n-1.

The default options are:

  • summary output ('s')
  • merged facets ('C-0' in 2-d, 3-d, 4-d; 'Qx' in 5-d and up)

Except for bounding box ('Qbk:n', etc.), drop facets ('Pdk:n', etc.), and Qhull command ('FQ'), only the last occurence of an option counts. Bounding box and drop facets may be repeated for each dimension. Option 'FQ' may be repeated any number of times.

The Unix tcsh and ksh shells make it easy to try out different options. In Windows 95, use a command window with doskey and a window scroller (e.g., peruse).

»output format

To write the results to a file, use I/O redirection or 'TO file'. Windows 95 users should use 'TO file' or the console. If a filename is surrounded by single quotes, it may include spaces.

The default output option is a short summary ('s') to stdout. There are many others (see output and formats). You can list vertex incidences, vertices and facets, vertex coordinates, or facet normals. You can view Qhull objects with Geomview, Mathematica, or Maple. You can print the internal data structures. You can call Qhull from your application (see Qhull library).

For example, 'qhull o' lists the vertices and facets of the convex hull.

Error messages and additional summaries ('s') go to stderr. Unless redirected, stderr is the console.

»algorithm

Qhull implements the Quickhull algorithm for convex hull [Barber et al. '96]. This algorithm combines the 2-d Quickhull algorithm with the n-d beneath-beyond algorithm [c.f., Preparata & Shamos '85]. It is similar to the randomized algorithms of Clarkson and others [Clarkson & Shor '89; Clarkson et al. '93; Mulmuley '94]. For a demonstration, see How Qhull adds a point. The main advantages of Quickhull are output sensitive performance (in terms of the number of extreme points), reduced space requirements, and floating-point error handling.

»data structures

Qhull produces the following data structures for dimension d:

  • A coordinate is a real number in floating point format.
  • A point is an array of d coordinates. With option 'QJ', the coordinates are joggled by a small amount.
  • A vertex is an input point.
  • A hyperplane is d normal coefficients and an offset. The length of the normal is one. The hyperplane defines a halfspace. If V is a normal, b is an offset, and x is a point inside the convex hull, then Vx+b <0.
  • An outer plane is a positive offset from a hyperplane. When Qhull is done, all points will be below all outer planes.
  • An inner plane is a negative offset from a hyperplane. When Qhull is done, all vertices will be above the corresponding inner planes.
  • An orientation is either 'top' or 'bottom'. It is the topological equivalent of a hyperplane's geometric orientation.
  • A simplicial facet is a set of d neighboring facets, a set of d vertices, a hyperplane equation, an inner plane, an outer plane, and an orientation. For example in 3-d, a simplicial facet is a triangle.
  • A centrum is a point on a facet's hyperplane. A centrum is the average of a facet's vertices. Neighboring facets are convex if each centrum is below the neighbor facet's hyperplane.
  • A ridge is a set of d-1 vertices, two neighboring facets, and an orientation. For example in 3-d, a ridge is a line segment.
  • A non-simplicial facet is a set of ridges, a hyperplane equation, a centrum, an outer plane, and an inner plane. The ridges determine a set of neighboring facets, a set of vertices, and an orientation. Qhull produces a non-simplicial facet when it merges two facets together. For example, a cube has six non-simplicial facets.

For examples, use option 'f'. See polyhedron operations (local) for further design documentation.

»Imprecision in Qhull

See Imprecision in Qhull and Merged facets or joggled input

»Examples of Qhull

See Examples of Qhull. Most of these examples require Geomview. Some of the examples have pictures .

»Options for using Qhull

See Qhull options.

»Qhull code and internals

See Qhull code.

»Geomview, Qhull's graphical viewer

Geomview is an interactive geometry viewing program. Geomview provides a good visualization of Qhull's 2-d and 3-d results.

Qhull includes Examples of Qhull that may be viewed with Geomview.

Geomview can help visulalize a 3-d Delaunay triangulation or the surface of a 4-d convex hull, Use option 'QVn' to select the 3-D facets adjacent to a vertex.

You may use Geomview to create movies that animate your objects (c.f., How can I create a video animation?). Geomview helped create the mathematical videos "Not Knot", "Outside In", and "The Shape of Space" from the Geometry Center.

»Installing Geomview

Geomview is an open source project under SourceForge.

For build instructions see Downloading Geomview. Geomview builds under Linux, Unix, Macintosh OS X, and Windows.

Geomview has installable packages for Debian and Ubuntu. The OS X build needs Xcode, an X11 SDK, and Lesstif or Motif. The Windows build uses Cygwin (see Building Geomview below for instructions).

If using Xforms (e.g., for Geomview's External Modules), install the 'libXpm-devel' package from cygwin and move the xforms directory into your geomview directory, e.g.,
mv xforms-1.2.4 geomview-1.9.5/xforms

Geomview's ndview provides multiple views into 4-d and higher objects. This module is out-of-date (geomview-users: 4dview). Download NDview-sgi.tar.Z at newpieces and 4dview at Geomview/modules.

»Using Geomview

Use Geomview to view Examples of Qhull. You can spin the convex hull, fly a camera through its facets, and see how Qhull produces thick facets in response to round-off error.

Follow these instructions to view 'eg,01.cube' from Examples of Qhull

  1. Launch an XTerm command shell
    • If needed, start the X terminal server, Use 'xinit' or 'startx' in /usr/X11R6/bin
      xinit -- -multiwindow -clipboard
      startx
    • Start an XTerm command shell. In Windows, click the Cygwin/bash icon on your desktop.
    • Set the DISPLAY variable, e.g.,
      export DISPLAY=:0
      export DISPLAY=:0 >>~/.bashenv
  2. Use Qhull's Geomview options to create a geomview object
    • rbox c D3 | qconvex G >eg.01.cube
    • On windows, convert the output to Unix text format with 'd2u'
      rbox c D3 | qconvex G | d2u >eg.01.cube
      d2u eg.*
  3. Run Geomview
    • Start Geomview with your example
      ./geomview eg.01.cube
    • Follow the instructions in Gemoview Tutorial
    • Geomview creates the Geomview control panel with Targets and External Module, the Geomview toolbar with buttons for controlling Geomview, and the Geomview camera window showing a cube.
    • Clear the camera window by selecting your object in the Targets list and 'Edit > Delete' or 'dd'
    • Load the Geomview files panel. Select 'Open' in the 'File' menu.
    • Set 'Filter' in the files panel to your example directory followed by '/*' (e.g., '/usr/local/qhull-2015.2/eg/*')
    • Click 'Filter' in the files panel to view your examples in the 'Files' list.
    • Load another example into the camera window by selecting it and clicking 'OK'.
    • Review the instructions for Interacting with Geomview
    • When viewing multiple objects at once, you may want to turn off normalization. In the 'Inspect > Apperance' control panel, set 'Normalize' to 'None'.

Geomview defines GCL (a textual API for controlling Geomview) and OOGL (a textual file format for defining objects).

  • To control Geomview, you may use any program that reads and writes from stdin and stdout. For example, it could report Qhull's information about a vertex identified by a double-click 'pick' event.
  • GCL command language for controlling Geomview
  • OOGL file format for defining objects (tutorial).
  • External Modules for interacting with Geomview via GCL
  • Interact with your objects via pick commands in response to right-mouse double clicks. Enable pick events with the interest command.

»Building Geomview for Windows

Compile Geomview under Cygwin. For detailed instructions, see Building Savi and Geomview under Windows. These instructions are somewhat out-of-date. Updated instructions follow.

How to compile Geomview under 32-bit Cygwin (October 2015)

  1. Note: L. Wood has run into multiple issues with Geomview on Cygwin. He recommends Virtualbox/Ubuntu and a one-click install of geomview via the Ubuntu package. See his Savi/Geomview link above.
  2. Install 32-bit Cygwin as follows. For additional guidance, see Cygwin's Installing and Updating Cygwin Packages and Setup cygwin.
    • Launch the cygwin installer.
    • Select a mirror from Cygwin mirrors (e.g., http://mirrors.kernel.org/sourceware/cygwin/ in California).
    • Select the packages to install. Besides the cygwin packages listed in the Savi/Windows instructions consider adding
      • Default -- libXm-devel (required for /usr/include/Xm/Xm.h)
      • Devel -- bashdb, gcc-core (in place of gcc), gdb
      • Lib -- libGL-devel, libGLU1 (required, obsolete), libGLU-devel (required, obsolete), libjpeg-devel(XForms), libXext-devel (required), libXpm-devel (Xforms) libGL and lib
      • Math -- bc
      • Net -- autossh, inetutils, openssh
      • System -- chere
      • Utils -- dos2unix (required for qhull), keychain
      • If installing perl, ActiveState Perl may be a better choice than cygwin's perl. Perl is not used by Geomview or Qhull.
      • Cygwin Package Search -- Search for cygwin programs and packages
    • Click 'Next' to download and install the packages.
    • If the download is incomplete, try again.
    • If you try again after a successful install, cygwin will uninstall and reinstall all modules..
    • Click on the 'Cywin Terminal' icon on the Desktop. It sets up a user directory in /home from /etc/skel/...
    • Mount your disk drives
      mount c: /c # Ignore the warning /c does not exist
  3. Consider installing the Road Bash scripts (/etc/road-*) from Road. They define aliases and functions for Unix command shells (Unix, Linux, Mac OS X, Windows),
    • Download Road Bash and unzip the downloaded file
    • Copy .../bash/etc/road-* to the Cywin /etc directory (by default, C:\cygwin\etc).
    • Using the cygwin terminal, convert the road scripts to Unix format
      d2u /etc/road-*
    • Try it
      source /etc/road-home.bashrc
    • Install it
      cp /etc/road-home.bashrc ~/.bashrc
  4. Launch the X terminal server from 'Start > All programs > Cygwin-X > Xwin Server'. Alternatively, run 'startx'
  5. Launch an XTerm shell
    • Right click the Cywin icon on the system tray in the Windows taskbar.
    • Select 'System Tools > XTerm'
  6. Download and extract Geomview -- Downloading Geomview
  7. Compile Geomview
    • ./configure
    • make
  8. If './configure' fails, check 'config.log' at the failing step. Look carefully for missing libraries, etc. The Geomview FAQ contains suggestions (e.g., "configure claims it can't find OpenGl").
  9. If 'make' fails, read the output carefully for error messages. Usually it is a missing include file or package. Locate and install the missing cygwin packages (Cygwin Package Search).

»What to do if something goes wrong

Please report bugs to qhull_bug@qhull.org. Please report if Qhull crashes. Please report if Qhull generates an "internal error". Please report if Qhull produces a poor approximate hull in 2-d, 3-d or 4-d. Please report documentation errors. Please report missing or incorrect links.

If you do not understand something, try a small example. The rbox program is an easy way to generate test cases. The Geomview program helps to visualize the output from Qhull.

If Qhull does not compile, it is due to an incompatibility between your system and ours. The first thing to check is that your compiler is ANSI standard. Qhull produces a compiler error if __STDC__ is not defined. You may need to set a flag (e.g., '-A' or '-ansi').

If Qhull compiles but crashes on the test case (rbox D4), there's still incompatibility between your system and ours. Sometimes it is due to memory management. This can be turned off with qh_NOmem in mem.h. Please let us know if you figure out how to fix these problems.

If you doubt the output from Qhull, add option 'Tv'. It checks that every point is inside the outer planes of the convex hull. It checks that every facet is convex with its neighbors. It checks the topology of the convex hull.

Qhull resolves most precision issues. It reports a precision error for lower dimensional inputs. It may report a precision error for non-simplicial facets with multiple merges or nearly adjacent vertices. See Limitations of merged facets for more information.

Qhull reports precision errors if you turn off merged facets with option 'Q0'. This can get as bad as facets with flipped orientation or two facets with the same vertices. You'll get a long help message if you run into such a case. They are easy to generate with rbox.

If you do find a problem, try to simplify it before reporting the error. Try different size inputs to locate the smallest one that causes an error. You're welcome to hunt through the code using the execution trace ('T4') as a guide. This is especially true if you're incorporating Qhull into your own program.

When you report an error, please attach a data set to the end of your message. Include the options that you used with Qhull, the results of option 'FO', and any messages generated by Qhull. This allows me to see the error for myself. Qhull is maintained part-time.

»Email

Please send correspondence to Brad Barber at qhull@qhull.org and report bugs to qhull_bug@qhull.org . Let me know how you use Qhull. If you mention it in a paper, please send a reference and abstract.

If you would like to get Qhull announcements (e.g., a new version) and news (any bugs that get fixed, etc.), let us know and we will add you to our mailing list. For Internet news about geometric algorithms and convex hulls, look at comp.graphics.algorithms and sci.math.num-analysis. For Qhull news look at qhull-news.html.

»Authors

   C. Bradford Barber                    Hannu Huhdanpaa
   bradb@shore.net                       hannu@qhull.org

»Acknowledgments

A special thanks to David Dobkin for his guidance. A special thanks to Albert Marden, Victor Milenkovic, the Geometry Center, and Harvard University for supporting this work.

A special thanks to Mark Phillips, Robert Miner, and Stuart Levy for running the Geometry Center web site long after the Geometry Center closed. Stuart moved the web site to the University of Illinois at Champaign-Urbana. Mark and Robert are founders of Geometry Technologies. Mark, Stuart, and Tamara Munzner are the original authors of Geomview.

A special thanks to Endocardial Solutions, Inc. of St. Paul, Minnesota for their support of the code documentation (src/libqhull_r/index.html, local). They use Qhull to build 3-d models of heart chambers.

Qhull 1.0 and 2.0 were developed under National Science Foundation grants NSF/DMS-8920161 and NSF-CCR-91-15793 750-7504. If you find it useful, please let us know.

The Geometry Center was supported by grant DMS-8920161 from the National Science Foundation, by grant DOE/DE-FG02-92ER25137 from the Department of Energy, by the University of Minnesota, and by Minnesota Technology, Inc.

»References

Aurenhammer, F., "Voronoi diagrams -- A survey of a fundamental geometric data structure," ACM Computing Surveys, 1991, 23:345-405.

Barber, C. B., D.P. Dobkin, and H.T. Huhdanpaa, "The Quickhull Algorithm for Convex Hulls," ACM Transactions on Mathematical Software, 22(4):469-483, Dec 1996, www.qhull.org [http://portal.acm.org; http://citeseerx.ist.psu.edu].

Clarkson, K.L. and P.W. Shor, "Applications of random sampling in computational geometry, II", Discrete Computational Geometry, 4:387-421, 1989

Clarkson, K.L., K. Mehlhorn, and R. Seidel, "Four results on randomized incremental construction," Computational Geometry: Theory and Applications, vol. 3, p. 185-211, 1993.

Devillers, et. al., "Walking in a triangulation," ACM Symposium on Computational Geometry, June 3-5,2001, Medford MA.

Dobkin, D.P. and D.G. Kirkpatrick, "Determining the separation of preprocessed polyhedra--a unified approach," in Proc. 17th Inter. Colloq. Automata Lang. Program., in Lecture Notes in Computer Science, Springer-Verlag, 443:400-413, 1990.

Edelsbrunner, H, Geometry and Topology for Mesh Generation, Cambridge University Press, 2001.

Gartner, B., "Fast and robust smallest enclosing balls", Algorithms - ESA '99, LNCS 1643.

Golub, G.H. and van Loan, C.F., Matric Computations, Baltimore, Maryland, USA: John Hopkins Press, 1983

Fortune, S., "Computational geometry," in R. Martin, editor, Directions in Geometric Computation, Information Geometers, 47 Stockers Avenue, Winchester, SO22 5LB, UK, ISBN 1-874728-02-X, 1993.

Milenkovic, V., "Robust polygon modeling," Computer-Aided Design, vol. 25, p. 546-566, September 1993.

Mucke, E.P., I. Saias, B. Zhu, Fast randomized point location without preprocessing in Two- and Three-dimensional Delaunay Triangulations, ACM Symposium on Computational Geometry, p. 274-283, 1996 [GeomDir].

Mulmuley, K., Computational Geometry, An Introduction Through Randomized Algorithms, Prentice-Hall, NJ, 1994.

O'Rourke, J., Computational Geometry in C, Cambridge University Press, 1994.

Preparata, F. and M. Shamos, Computational Geometry, Springer-Verlag, New York, 1985.


Up: Home page for Qhull (local)
Up:News about Qhull
Up: Qhull Wiki and FAQ (local)
To: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
Dn: Imprecision in Qhull
Dn: Description of Qhull examples
Dn: Qhull code


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qdelau_f.html0000644000176200001440000004425214664417655020417 0ustar liggesusers qdelaunay Qu -- furthest-site Delaunay triangulation Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options

[delaunay]qdelaunay Qu -- furthest-site Delaunay triangulation

The furthest-site Delaunay triangulation corresponds to the upper facets of the Delaunay construction. Its vertices are the extreme points of the input sites. It is the dual of the furthest-site Voronoi diagram.

Example: rbox 10 D2 | qdelaunay Qu Qt s i TO result
Compute the 2-d, furthest-site Delaunay triangulation of 10 random points. Triangulate the output. Write a summary to the console and the regions to 'result'.
 
Example: rbox 10 D2 | qdelaunay Qu QJ s i TO result
Compute the 2-d, furthest-site Delaunay triangulation of 10 random points. Joggle the input to guarantee triangular output. Write a summary to the console and the regions to 'result'.
 
Example: rbox r y c G1 D2 | qdelaunay Qu s Fv TO result
Compute the 2-d, furthest-site Delaunay triangulation of a triangle inside a square. Write a summary to the console and unoriented regions to 'result'. Merge regions for cocircular input sites (e.g., the square). The square is the only furthest-site Delaunay region.

As with the Delaunay triangulation, Qhull computes the furthest-site Delaunay triangulation by lifting the input sites to a paraboloid. The lower facets correspond to the Delaunay triangulation while the upper facets correspond to the furthest-site triangulation. Neither triangulation includes "vertical" facets (i.e., facets whose last hyperplane coefficient is nearly zero). Vertical facets correspond to input sites that are coplanar to the convex hull of the input. An example is points on the boundary of a lattice.

By default, qdelaunay merges cocircular and cospherical regions. For example, the furthest-site Delaunay triangulation of a square inside a diamond ('rbox D2 c d G4 | qdelaunay Qu') consists of one region (the diamond).

If you use 'Qt' (triangulated output), all furthest-site Delaunay regions will be simplicial (e.g., triangles in 2-d). Some regions may be degenerate and have zero area.

If you use 'QJ' (joggled input), all furthest-site Delaunay regions will be simplicial (e.g., triangles in 2-d). Joggled input is less accurate than triangulated output ('Qt'). See Merged facets or joggled input.

The output for 3-d, furthest-site Delaunay triangulations may be confusing if the input contains cospherical data. See the FAQ item Why are there extra points in a 4-d or higher convex hull? Avoid these problems with triangulated output ('Qt') or joggled input ('QJ').

The 'qdelaunay' program is equivalent to 'qhull d Qbb'. It disables the following Qhull options: d n v H U Qb QB Qc Qf Qg Qi Qm Qr Qv Qx TR E V FC Fi Fo Fp Ft FV Q0,etc.

Copyright © 1995-2020 C.B. Barber


»furthest-site qdelaunay synopsis

See qdelaunay synopsis. The same program is used for both constructions. Use option 'Qu' for furthest-site Delaunay triangulations.

»furthest-site qdelaunay input

The input data on stdin consists of:

  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qdelaunay Qu < data.txt), a pipe (e.g., rbox 10 | qdelaunay Qu), or the 'TI' option (e.g., qdelaunay Qu TI data.txt).

For example, this is a square containing four random points. Its furthest-site Delaunay triangulation contains one square.

rbox c 4 D2 > data
2 RBOX c 4 D2
8
-0.4999921736307369 -0.3684622117955817
0.2556053225468894 -0.0413498678629751
0.0327672376602583 -0.2810408135699488
-0.452955383763607 0.17886471718444
  -0.5   -0.5
  -0.5    0.5
   0.5   -0.5
   0.5    0.5

qdelaunay Qu i < data


Furthest-site Delaunay triangulation by the convex hull of 8 points in 3-d:

  Number of input sites: 8
  Number of Delaunay regions: 1
  Number of non-simplicial Delaunay regions: 1

Statistics for: RBOX c 4 D2 | QDELAUNAY s Qu i

  Number of points processed: 8
  Number of hyperplanes created: 20
  Number of facets in hull: 11
  Number of distance tests for qhull: 34
  Number of merged facets: 1
  Number of distance tests for merging: 107
  CPU seconds to compute hull (after input): 0.02

1
7 6 4 5

»furthest-site qdelaunay outputs

These options control the output of furthest-site Delaunay triangulations:

furthest-site Delaunay regions
i
list input sites for each furthest-site Delaunay region. The first line is the number of regions. The remaining lines list the input sites for each region. The regions are oriented. In 3-d and higher, report cospherical sites by adding extra points. For the points-in-square example, the square is the only furthest-site Delaunay region.
Fv
list input sites for each furthest-site Delaunay region. The first line is the number of regions. Each remaining line starts with the number of input sites. The regions are unoriented. For the points-in-square example, the square is the only furthest-site Delaunay region.
Ft
print a triangulation of the furthest-site Delaunay regions in OFF format. The first line is the dimension. The second line is the number of input sites and added points, followed by the number of simplices and the number of ridges. The input coordinates are next, followed by the centrum coordinates. There is one centrum for each non-simplicial furthest-site Delaunay region. Each remaining line starts with dimension+1. The simplices are oriented. For the points-in-square example, the square has a centrum at the origin. It splits the square into four triangular regions.
Fn
list neighboring regions for each furthest-site Delaunay region. The first line is the number of regions. Each remaining line starts with the number of neighboring regions. Negative indices (e.g., -1) indicate regions outside of the furthest-site Delaunay triangulation. For the points-in-square example, the four neighboring regions are outside of the triangulation. They belong to the regular Delaunay triangulation.
FN
list the furthest-site Delaunay regions for each input site. The first line is the total number of input sites. Each remaining line starts with the number of furthest-site Delaunay regions. Negative indices (e.g., -1) indicate regions outside of the furthest-site Delaunay triangulation. For the points-in-square example, the four random points belong to no region while the square's vertices belong to region 0 and three regions outside of the furthest-site Delaunay triangulation.
Fa
print area for each furthest-site Delaunay region. The first line is the number of regions. The areas follow, one line per region. For the points-in-square example, the square has unit area.
 
 
Input sites
Fx
list extreme points of the input sites. These points are vertices of the furthest-point Delaunay triangulation. They are on the boundary of the convex hull. The first line is the number of extreme points. Each point is listed, one per line. The points-in-square example has four extreme points.
 
 
General
FA
compute total area for 's' and 'FS'. This is the same as the area of the convex hull.
o
print upper facets of the corresponding convex hull (a paraboloid)
m
Mathematica output for the upper facets of the paraboloid (2-d triangulations).
FM
Maple output for the upper facets of the paraboloid (2-d triangulations).
G
Geomview output for the paraboloid (2-d or 3-d triangulations).
s
print summary for the furthest-site Delaunay triangulation. Use 'Fs' and 'FS' for numeric data.

»furthest-site qdelaunay controls

These options provide additional control:

Qu
must be used for furthest-site Delaunay triangulation.
Qt
triangulated output. Qhull triangulates non-simplicial facets. It may produce degenerate facets of zero area.
QJ
joggle the input to avoid cospherical and coincident sites. It is less accurate than triangulated output ('Qt').
QRn
randomly rotate the input with a random seed of n. If n=0, the seed is the time. If n=-1, use time for the random seed, but do not rotate the input.
QVn
select facets adjacent to input site n (marked 'good').
Tv
verify result.
TI file
input data from file. The filename may not use spaces or quotes.
TO file
output results to file. Use single quotes if the filename contains spaces (e.g., TO 'file with spaces.txt'
TFn
report progress after constructing n facets
PDk:1
include upper and lower facets in the output. Set k to the last dimension (e.g., 'PD2:1' for 2-d inputs).
f
facet dump. Print the data structure for each facet (i.e., furthest-site Delaunay region).

»furthest-site qdelaunay graphics

See Delaunay graphics. They are the same except for Mathematica and Maple output.

»furthest-site qdelaunay notes

The furthest-site Delaunay triangulation does not record coincident input sites. Use qdelaunay instead.

qdelaunay Qu does not work for purely cocircular or cospherical points (e.g., rbox c | qdelaunay Qu). Instead, use qdelaunay Qz -- when all points are vertices of the convex hull of the input sites, the Delaunay triangulation is the same as the furthest-site Delaunay triangulation.

A non-simplicial, furthest-site Delaunay region indicates nearly cocircular or cospherical input sites. To avoid non-simplicial regions triangulate the output ('Qt') or joggle the input ('QJ'). Joggled input is less accurate than triangulated output. You may also triangulate non-simplicial regions with option 'Ft'. It adds the centrum to non-simplicial regions. Alternatively, use an exact arithmetic code.

Furthest-site Delaunay triangulations do not include facets that are coplanar with the convex hull of the input sites. A facet is coplanar if the last coefficient of its normal is nearly zero (see qh_ZEROdelaunay).

»furthest-site qdelaunay conventions

The following terminology is used for furthest-site Delaunay triangulations in Qhull. The underlying structure is the upper facets of a convex hull in one higher dimension. See convex hull conventions, Delaunay conventions, and Qhull's data structures

  • input site - a point in the input (one dimension lower than a point on the convex hull)
  • point - d+1 coordinates. The last coordinate is the sum of the squares of the input site's coordinates
  • vertex - a point on the paraboloid. It corresponds to a unique input site.
  • furthest-site Delaunay facet - an upper facet of the paraboloid. The last coefficient of its normal is clearly positive.
  • furthest-site Delaunay region - a furthest-site Delaunay facet projected to the input sites
  • non-simplicial facet - more than d points are cocircular or cospherical
  • good facet - a furthest-site Delaunay facet with optional restrictions by 'QVn', etc.

»furthest-site qdelaunay options

See qdelaunay options. The same program is used for both constructions. Use option 'Qu' for furthest-site Delaunay triangulations.

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • graphics • notes • conventions • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/html/qh--dt.gif0000644000176200001440000000727413431000556017510 0ustar liggesusersGIF87addç^+!6o$08%BL&7„Go$Z5 #4hWIC"H4i9;QW5 Fw;†<5!aU2qIc<%b<$WWLNM7YXo].XRPZ6pD_J*_:$ ÁSwHJ [_>F=D-QQEwR<:‰:<…€:AHbYN0G<@AP&FvW73TN2V1#C&IHHR5U )5x O-WW?!DY g&¯!2›-+‚BuP('z="Nh[L!O &H]I[J+(pBO&AO%,’<ŠH)F'PL:MN,(EA@'zNVNT&9CG*FA-ž-£.IJ8‹9CuDM1 pIKeLMmS0RUSXXb=$WXjOAz;McuUCn@v!NhCTTL5(_2;‚5’5;ˆ;<†<=„=?€?A|A=‚=@|@AzABxBDtD$$GnGHlHIjIN`NU1O^OP\PQZQRXRSVSTTTD$*PYF_> 7_>‰ EQBL69O`FeIT!U[\: f1 V>EyJN+§'Q3!/,R1M4”&H*b?AO&n2!H*[8"I9.W:Y"F%R-P%!\Vd?$MM!]EYK5f<.G09;?#3@%FoHJgL© R0u@UUb?%c=&\CVV^fÔ,ddþk H° Áƒ*\Ȱ¡Ã‡#JœH±¢Å‹3jÜȱ£Ç CŠI²¤É“(SªÜˆÁÇÊ— U%JÒÇ%Ì›‰ì¨RAD"j}„à|iÏŽ H‘&*tèÉpÒò$KJÕ'+Dœ’´%ML6TÃà”Ä‹VÎð¼ÊÖ)¬Û ÓÈö9»±È9i¯Þl˜öö­Oš6éR´2AÎ+1Ú®Cº¸Ââu+e*Xb¸ bÄp±Í@ãÏŽ#;f¬”S •Úšð*—7Ĉ% 9ôèÛ­&)’Z¡³ ¤q)Lƒ%Ò£k+G.z]ܲ½ Ú.œÐb&T¨ˆCZ¹dܶ?þÿ­0uNuëa íXØyŸü»ø-”_¦NçJ.cÄD3Mcì`¡,ž‚´-¶Ôig­ÆkDðЦNÚµ¡sá8_(hõÛ„4ä¢Áz|ÕšbáFwöѨÔUÌ5ÔtÀ934 ‡;lÈæârê ]:!.(ÂÉ 1 8MádpâðdŠ˜ÀF{ÍÕèžv¨šcÓTñÅ6Û@â„ZíÜ\ÉÅ&t£ˆlaÒ÷X&XUdÁ&›_¬P¢SÎùŠ `pAÝéYxb6·áÀ1Ä¡ÛdÁ8Y åÉÀÕ!Æ |pACþîãN4`Íw¦h$³.Û¸ŸÃÃŽ*Zñ8‚Hà '®ÖñL7(¢Xs">™ $ ²9DÓœN]9 ØH³Æ ®®¡G¬îô0 µ¸¥™L¶Ù:Á;ÌHJ ³à$çЇ¬«w*Ò îdïb„J/¨Õ[Œ2.Á" ( à𒄯ü ^upñ DcB4Ѷ÷¡Ó|:„ËÚjì½à€;/`Œˆ(Ø14¯¨òȯc0ÂFR¥«1¿¼Í§Okkï½Êèx+…œANI<¾ÂÇ ¿24wö`B«l”ØBí2ÌQoóŽ쬠LS±È þÆrÆ“dEǬ ðJØÐˆL65¸t£G'zX"¯Óq¿]ù6³ãFsTÂ÷(­Ð"P+ ôrÆ'&…Cø+‡=¶ÈZŒF€Np»ý´Ë›ˆ‰1Æ`‘΋´ (3ÀP)¦˜dËê­ ­¸ÈÌ C…$è AÉ _´óæÚ…߆CÌM·”*Ð  ¬RË(hRC % =k OÿJ #…ÚhRÀ-Lˆ|NƒšùèŽ@ D hE-tÀ‚^¬Í+‰ÎA8jpb›žl  ºÐÅΰ M<ã ÃhÌ2G·b¯0ýj‘ƒ^@@þ0¨EÇà5™y3@€&` Ѐt‰h½–‚V@7š  XÄ@nÀ‚R±8`EêŠ0à¯{à@ t ƒ î ¨@F<ÀŠ` ‘À©Ñ͸DàRQ˜Q°8£óذ"â!q#ãB6æ;2åšà 4Ad¨îµ'$`sP€Íj1R˜Ñ3ÈGrª"ɸ¤âÖR =èበ e(I Œg   $PDÀŽ$ÀQðÄN«½ £Ð¥@pi’ qk&(Äá ¨ã'•©Lw0bÅþ0„'° CL! aøƒ1ˆ”‚.H*b!N“ ®ˆG,¢4ƶD8`ŽwL¦25QŒ2xM@!!þ¦ O,`eÈÄh1‹P,"Y„ZÕAtuÁ›- €jhÃ%Š‘€c0"…vø…0´¡<@ŒøÅ/¾!„¢®È H1X¤â$Ï»)0'ª¸l<§ñ¤„$˜`Ma¤ð¸€0>ÀTm,Àé8*&¸éX¸`ˆ§@H!X’Ø5ÈÂ)Y_шlp£@€" )ø@r=ðK aÅ"iZ’Fµ‘¶˜±Å h,â¢Ù¨f lÞ¸‘Ãþð ]XC«8„@x ƒ‚Ìâ'é%p¾†aÖøH 6ˆÃ`Ö DáÄ'&¯’Ã+Œ|@¨*I‚À ¾å„-p€Ôãàзý¯%¦Ð$›xÉãMþ'1…)à®$ ÒÚ‘T·Ë^Þn66‡<ÀÌ6ox‘B](#¦h9 B‹S ä_÷½.Þð„8˜UÅø€0­dAwP Ã%P€†T™ E‰…#[iÐ!zXÁžá#súÌÀmšP†0(Ã-¨*úEg”ø@±õ ž¥±Ðzq0@Ê|ë·º D2à‹C˜bj0dH´P5¦Ä/hð ¡ÀP±€v(Ðdp~FÖ‡*A <#]È0S - Cþ¬U. ¨ «€½ >à}0xj~˜­ )‡4 ……j£ð È#l—¸‰_Å€á ÈIaˆˆ¨¬D‘C‡À£ Ÿ€­ˆ7¡C„È€eÁ>£pz 0ÕU-Ph ˆ _±‚$Ñ *W…PX²p1„ø<СX «0t$‹µ0]®hލ#ÇS Ì´ È8Ÿ r|(/PŽ*Ñ<2lß á†¥0aµ ÁV ´Ð„˜¸¦ ¦À>òØ/PQX–AÐ…³P…@!1k(¨N’Ô~7Qgp¡À þ¸¬5€µP …'A «°7|#÷ˆ®p‰1àhÍC 4Y5P | /@e! ¡ i“ÍseÑq8°ˆ|c Ù´P ¦v¬Ð<8y•°p KY 5ˆ a 5°„¦°UW9²A|Ó¬0c¡0¦6—¡“ƒ1¡à“F È€’€É´”KÉ#@t‹):€¥ r“™™š¹™œÙ™žù™ šš;geometry/inst/doc/qhull/html/qhull.man0000644000176200001440000011247513431000557017552 0ustar liggesusers.\" This is the Unix manual page for qhull, written in nroff, the standard .\" manual formatter for Unix systems. To format it, type .\" .\" nroff -man qhull.man .\" .\" This will print a formatted copy to standard output. If you want .\" to ensure that the output is plain ASCII, free of any control .\" characters that nroff uses for underlining etc, pipe the output .\" through "col -b": .\" .\" nroff -man qhull.man | col -b .\" .\" Warning: a leading quote "'" or dot "." will not format correctly .\" .TH qhull 1 "2003/12/30" "Geometry Center" .SH NAME qhull \- convex hull, Delaunay triangulation, Voronoi diagram, halfspace intersection about a point, hull volume, facet area .SH SYNOPSIS .nf qhull- compute convex hulls and related structures input (stdin): dimension, #points, point coordinates first comment (non-numeric) is listed in the summary halfspace: use dim plus one with offsets after coefficients options (qh-quick.htm): d - Delaunay triangulation by lifting points to a paraboloid v - Voronoi diagram via the Delaunay triangulation H1,1 - Halfspace intersection about [1,1,0,...] d Qu - Furthest-site Delaunay triangulation (upper convex hull) v Qu - Furthest-site Voronoi diagram Qt - triangulated output QJ - Joggle the input to avoid precision problems . - concise list of all options - - one-line description of all options Output options (subset): FA - compute total area and volume Fx - extreme points (convex hull vertices) G - Geomview output (2-d, 3-d and 4-d) Fp - halfspace intersection coordinates m - Mathematica output (2-d and 3-d) n - normals with offsets o - OFF file format (if Voronoi, outputs regions) TO file- output results to file, may be enclosed in single quotes f - print all fields of all facets s - summary of results (default) Tv - verify result: structure, convexity, and point inclusion p - vertex coordinates (centers for Voronoi) i - vertices incident to each facet example: rbox 1000 s | qhull Tv s FA .fi - html manual: index.htm - installation: README.txt - see also: COPYING.txt, REGISTER.txt, Changes.txt - WWW: - GIT: - mirror: - news: - Geomview: - news group: - FAQ: - email: qhull@qhull.org - bug reports: qhull_bug@qhull.org The sections are: - INTRODUCTION - DESCRIPTION, a description of Qhull - IMPRECISION, how Qhull handles imprecision - OPTIONS - Input and output options - Additional input/output formats - Precision options - Geomview options - Print options - Qhull options - Trace options - BUGS - E-MAIL - SEE ALSO - AUTHORS - ACKNOWLEGEMENTS This man page briefly describes all Qhull options. Please report any mismatches with Qhull's html manual (index.htm). .PP .SH INTRODUCTION Qhull is a general dimension code for computing convex hulls, Delaunay triangulations, Voronoi diagram, furthest\[hy]site Voronoi diagram, furthest\[hy]site Delaunay triangulations, and halfspace intersections about a point. It implements the Quickhull algorithm for computing the convex hull. Qhull handles round\[hy]off errors from floating point arithmetic. It can approximate a convex hull. The program includes options for hull volume, facet area, partial hulls, input transformations, randomization, tracing, multiple output formats, and execution statistics. The program can be called from within your application. You can view the results in 2\[hy]d, 3\[hy]d and 4\[hy]d with Geomview. .PP .SH DESCRIPTION .PP The format of input is the following: first line contains the dimension, second line contains the number of input points, and point coordinates follow. The dimension and number of points can be reversed. Comments and line breaks are ignored. A comment starts with a non\[hy]numeric character and continues to the end of line. The first comment is reported in summaries and statistics. Error reporting is better if there is one point per line. .PP The default printout option is a short summary. There are many other output formats. .PP Qhull implements the Quickhull algorithm for convex hull. This algorithm combines the 2\[hy]d Quickhull algorithm with the n\[hy]d beneath\[hy]beyond algorithm [c.f., Preparata & Shamos '85]. It is similar to the randomized algorithms of Clarkson and others [Clarkson et al. '93]. The main advantages of Quickhull are output sensitive performance, reduced space requirements, and automatic handling of precision problems. .PP The data structure produced by Qhull consists of vertices, ridges, and facets. A vertex is a point of the input set. A ridge is a set of d vertices and two neighboring facets. For example in 3\[hy]d, a ridge is an edge of the polyhedron. A facet is a set of ridges, a set of neighboring facets, a set of incident vertices, and a hyperplane equation. For simplicial facets, the ridges are defined by the vertices and neighboring facets. When Qhull merges two facets, it produces a non\[hy]simplicial facet. A non\[hy]simplicial facet has more than d neighbors and may share more than one ridge with a neighbor. .PP .SH IMPRECISION .PP Since Qhull uses floating point arithmetic, roundoff error may occur for each calculation. This causes problems for most geometric algorithms. .PP Qhull automatically sets option 'C\-0' in 2\[hy]d, 3\[hy]d, and 4\[hy]d, or option 'Qx' in 5\[hy]d and higher. These options handle precision problems by merging facets. Alternatively, use option 'QJ' to joggle the input. .PP With 'C\-0', Qhull merges non\[hy]convex facets while constructing the hull. The remaining facets are clearly convex. With 'Qx', Qhull merges coplanar horizon facets, flipped facets, concave facets and duplicated ridges. It merges coplanar facets after constructing the hull. With 'Qx', coplanar points may be missed, but it appears to be unlikely. .PP To guarantee triangular output, joggle the input with option 'QJ'. Facet merging will not occur. .SH OPTIONS .PP To get a list of the most important options, execute 'qhull' by itself. To get a complete list of options, execute 'qhull \-'. To get a complete, concise list of options, execute 'qhull .'. Options can be in any order. Capitalized options take an argument (except 'PG' and 'F' options). Single letters are used for output formats and precision constants. The other options are grouped into menus for other output formats ('F'), Geomview output ('G'), printing ('P'), Qhull control ('Q'), and tracing ('T'). .TP Main options: .TP default Compute the convex hull of the input points. Report a summary of the result. .TP d Compute the Delaunay triangulation by lifting the input points to a paraboloid. The 'o' option prints the input points and facets. The 'QJ' option guarantees triangular output. The 'Ft' option prints a triangulation. It adds points (the centrums) to non\[hy]simplicial facets. .TP v Compute the Voronoi diagram from the Delaunay triangulation. The 'p' option prints the Voronoi vertices. The 'o' option prints the Voronoi vertices and the vertices in each Voronoi region. It lists regions in site ID order. The 'Fv' option prints each ridge of the Voronoi diagram. The first or zero'th vertex indicates the infinity vertex. Its coordinates are qh_INFINITE (\-10.101). It indicates unbounded Voronoi regions or degenerate Delaunay triangles. .TP Hn,n,... Compute halfspace intersection about [n,n,0,...]. The input is a set of halfspaces defined in the same format as 'n', 'Fo', and 'Fi'. Use 'Fp' to print the intersection points. Use 'Fv' to list the intersection points for each halfspace. The other output formats display the dual convex hull. The point [n,n,n,...] is a feasible point for the halfspaces, i.e., a point that is inside all of the halfspaces (Hx+b <= 0). The default coordinate value is 0. The input may start with a feasible point. If so, use 'H' by itself. The input starts with a feasible point when the first number is the dimension, the second number is "1", and the coordinates complete a line. The 'FV' option produces a feasible point for a convex hull. .TP d Qu Compute the furthest\[hy]site Delaunay triangulation from the upper convex hull. The 'o' option prints the input points and facets. The 'QJ' option guarantees triangular otuput. You can also use 'Ft' to triangulate via the centrums of non\[hy]simplicial facets. .TP v Qu Compute the furthest\[hy]site Voronoi diagram. The 'p' option prints the Voronoi vertices. The 'o' option prints the Voronoi vertices and the vertices in each Voronoi region. The 'Fv' option prints each ridge of the Voronoi diagram. The first or zero'th vertex indicates the infinity vertex at infinity. Its coordinates are qh_INFINITE (\-10.101). It indicates unbounded Voronoi regions and degenerate Delaunay triangles. .PP .TP Input/Output options: .TP f Print out all facets and all fields of each facet. .TP G Output the hull in Geomview format. For imprecise hulls, Geomview displays the inner and outer hull. Geomview can also display points, ridges, vertices, coplanar points, and facet intersections. See below for a list of options. For Delaunay triangulations, 'G' displays the corresponding paraboloid. For halfspace intersection, 'G' displays the dual polytope. .TP i Output the incident vertices for each facet. Qhull prints the number of facets followed by the vertices of each facet. One facet is printed per line. The numbers are the 0\[hy]relative indices of the corresponding input points. The facets are oriented. In 4d and higher, Qhull triangulates non\[hy]simplicial facets. Each apex (the first vertex) is a created point that corresponds to the facet's centrum. Its index is greater than the indices of the input points. Each base corresponds to a simplicial ridge between two facets. To print the vertices without triangulation, use option 'Fv'. .TP m Output the hull in Mathematica format. Qhull writes a Mathematica file for 2\[hy]d and 3\[hy]d convex hulls and for 2\[hy]d Delaunay triangulations. Qhull produces a list of objects that you can assign to a variable in Mathematica, for example: "list= << ". If the object is 2\[hy]d, it can be visualized by "Show[Graphics[list]] ". For 3\[hy]d objects the command is "Show[Graphics3D[list]]". .TP n Output the normal equation for each facet. Qhull prints the dimension (plus one), the number of facets, and the normals for each facet. The facet's offset follows its normal coefficients. .TP o Output the facets in OFF file format. Qhull prints the dimension, number of points, number of facets, and number of ridges. Then it prints the coordinates of the input points and the vertices for each facet. Each facet is on a separate line. The first number is the number of vertices. The remainder are the indices of the corresponding points. The vertices are oriented in 2\[hy]d, 3\[hy]d, and in simplicial facets. For 2\[hy]d Voronoi diagrams, the vertices are sorted by adjacency, but not oriented. In 3\[hy]d and higher, the Voronoi vertices are sorted by index. See the 'v' option for more information. .TP p Output the coordinates of each vertex point. Qhull prints the dimension, the number of points, and the coordinates for each vertex. With the 'Gc' and 'Gi' options, it also prints coplanar and interior points. For Voronoi diagrams, it prints the coordinates of each Voronoi vertex. .TP s Print a summary to stderr. If no output options are specified at all, a summary goes to stdout. The summary lists the number of input points, the dimension, the number of vertices in the convex hull, the number of facets in the convex hull, the number of good facets (if 'Pg'), and statistics. The last two statistics (if needed) measure the maximum distance from a point or vertex to a facet. The number in parenthesis (e.g., 2.1x) is the ratio between the maximum distance and the worst\[hy]case distance due to merging two simplicial facets. .PP .TP Precision options .TP An Maximum angle given as a cosine. If the angle between a pair of facet normals is greater than n, Qhull merges one of the facets into a neighbor. If 'n' is negative, Qhull tests angles after adding each point to the hull (pre\[hy]merging). If 'n' is positive, Qhull tests angles after constructing the hull (post\[hy]merging). Both pre\[hy] and post\[hy]merging can be defined. Option 'C0' or 'C\-0' is set if the corresponding 'Cn' or 'C\-n' is not set. If 'Qx' is set, then 'A\-n' and 'C\-n' are checked after the hull is constructed and before 'An' and 'Cn' are checked. .TP Cn Centrum radius. If a centrum is less than n below a neighboring facet, Qhull merges one of the facets. If 'n' is negative or '\-0', Qhull tests and merges facets after adding each point to the hull. This is called "pre\[hy]merging". If 'n' is positive, Qhull tests for convexity after constructing the hull ("post\[hy]merging"). Both pre\[hy] and post\[hy]merging can be defined. For 5\[hy]d and higher, 'Qx' should be used instead of 'C\-n'. Otherwise, most or all facets may be merged together. .TP En Maximum roundoff error for distance computations. .TP Rn Randomly perturb distance computations up to +/\- n * max_coord. This option perturbs every distance, hyperplane, and angle computation. To use time as the random number seed, use option 'QR\-1'. .TP Vn Minimum distance for a facet to be visible. A facet is visible if the distance from the point to the facet is greater than 'Vn'. Without merging, the default value for 'Vn' is the round\[hy]off error ('En'). With merging, the default value is the pre\[hy]merge centrum ('C\-n') in 2\[hy]d or 3\[hy]d, or three times that in other dimensions. If the outside width is specified ('Wn'), the maximum, default value for 'Vn' is 'Wn'. .TP Un Maximum distance below a facet for a point to be coplanar to the facet. The default value is 'Vn'. .TP Wn Minimum outside width of the hull. Points are added to the convex hull only if they are clearly outside of a facet. A point is outside of a facet if its distance to the facet is greater than 'Wn'. The normal value for 'Wn' is 'En'. If the user specifies pre\[hy]merging and does not set 'Wn', than 'Wn' is set to the premerge 'Cn' and maxcoord*(1\-An). .PP .TP Additional input/output formats .TP Fa Print area for each facet. For Delaunay triangulations, the area is the area of the triangle. For Voronoi diagrams, the area is the area of the dual facet. Use 'PAn' for printing the n largest facets, and option 'PFn' for printing facets larger than 'n'. The area for non\[hy]simplicial facets is the sum of the areas for each ridge to the centrum. Vertices far below the facet's hyperplane are ignored. The reported area may be significantly less than the actual area. .TP FA Compute the total area and volume for option 's'. It is an approximation for non\[hy]simplicial facets (see 'Fa'). .TP Fc Print coplanar points for each facet. The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of coplanar points followed by the point ids. Option 'Qi' includes the interior points. Each coplanar point (interior point) is assigned to the facet it is furthest above (resp., least below). .TP FC Print centrums for each facet. The output starts with the dimension followed by the number of facets. Then each facet centrum is printed, one per line. .TP Fd Read input in cdd format with homogeneous points. The input starts with comments. The first comment is reported in the summary. Data starts after a "begin" line. The next line is the number of points followed by the dimension+1 and "real" or "integer". Then the points are listed with a leading "1" or "1.0". The data ends with an "end" line. For halfspaces ('Fd Hn,n,...'), the input format is the same. Each halfspace starts with its offset. The sign of the offset is the opposite of Qhull's convention. .TP FD Print normals ('n', 'Fo', 'Fi') or points ('p') in cdd format. The first line is the command line that invoked Qhull. Data starts with a "begin" line. The next line is the number of normals or points followed by the dimension+1 and "real". Then the normals or points are listed with the offset before the coefficients. The offset for points is 1.0. The offset for normals has the opposite sign. The data ends with an "end" line. .TP FF Print facets (as in 'f') without printing the ridges. .TP Fi Print inner planes for each facet. The inner plane is below all vertices. .TP Fi Print separating hyperplanes for bounded, inner regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the number of indices and floats. The first pair lists adjacent input sites, the next d floats are the normalized coefficients for the hyperplane, and the last float is the offset. The hyperplane is oriented toward 'QVn' (if defined), or the first input site of the pair. Use 'Tv' to verify that the hyperplanes are perpendicular bisectors. Use 'Fo' for unbounded regions, and 'Fv' for the corresponding Voronoi vertices. .TP FI Print facet identifiers. .TP Fm Print number of merges for each facet. At most 511 merges are reported for a facet. See 'PMn' for printing the facets with the most merges. .TP FM Output the hull in Maple format. Qhull writes a Maple file for 2\[hy]d and 3\[hy]d convex hulls and for 2\[hy]d Delaunay triangulations. Qhull produces a '.mpl' file for displaying with display3d(). .TP Fn Print neighbors for each facet. The output starts with the number of facets. Then each facet is printed one per line. Each line is the number of neighbors followed by an index for each neighbor. The indices match the other facet output formats. A negative index indicates an unprinted facet due to printing only good facets ('Pg'). It is the negation of the facet's ID (option 'FI'). For example, negative indices are used for facets "at infinity" in the Delaunay triangulation. .TP FN Print vertex neighbors or coplanar facet for each point. The first line is the number of points. Then each point is printed, one per line. If the point is coplanar, the line is "1" followed by the facet's ID. If the point is not a selected vertex, the line is "0". Otherwise, each line is the number of neighbors followed by the corresponding facet indices (see 'Fn'). .TP Fo Print outer planes for each facet in the same format as 'n'. The outer plane is above all points. .TP Fo Print separating hyperplanes for unbounded, outer regions of the Voronoi diagram. The first line is the number of ridges. Then each hyperplane is printed, one per line. A line starts with the number of indices and floats. The first pair lists adjacent input sites, the next d floats are the normalized coefficients for the hyperplane, and the last float is the offset. The hyperplane is oriented toward 'QVn' (if defined), or the first input site of the pair. Use 'Tv' to verify that the hyperplanes are perpendicular bisectors. Use 'Fi' for bounded regions, and 'Fv' for the corresponding Voronoi vertices. .TP FO List all options to stderr, including the default values. Additional 'FO's are printed to stdout. .TP Fp Print points for halfspace intersections (option 'Hn,n,...'). Each intersection corresponds to a facet of the dual polytope. The "infinity" point [\-10.101,\-10.101,...] indicates an unbounded intersection. .TP FP For each coplanar point ('Qc') print the point ID of the nearest vertex, the point ID, the facet ID, and the distance. .TP FQ Print command used for qhull and input. .TP Fs Print a summary. The first line consists of the number of integers ("8"), followed by the dimension, the number of points, the number of vertices, the number of facets, the number of vertices selected for output, the number of facets selected for output, the number of coplanar points selected for output, number of simplicial, unmerged facets in output The second line consists of the number of reals ("2"), followed by the maxmimum offset to an outer plane and and minimum offset to an inner plane. Roundoff is included. Later versions of Qhull may produce additional integers or reals. .TP FS Print the size of the hull. The first line consists of the number of integers ("0"). The second line consists of the number of reals ("2"), followed by the total facet area, and the total volume. Later versions of Qhull may produce additional integers or reals. The total volume measures the volume of the intersection of the halfspaces defined by each facet. Both area and volume are approximations for non\[hy]simplicial facets. See option 'Fa'. .TP Ft Print a triangulation with added points for non\[hy]simplicial facets. The first line is the dimension and the second line is the number of points and the number of facets. The points follow, one per line, then the facets follow as a list of point indices. With option 'Qz', the points include the point\[hy]at\[hy]infinity. .TP Fv Print vertices for each facet. The first line is the number of facets. Then each facet is printed, one per line. Each line is the number of vertices followed by the corresponding point ids. Vertices are listed in the order they were added to the hull (the last one is first). .TP Fv Print all ridges of a Voronoi diagram. The first line is the number of ridges. Then each ridge is printed, one per line. A line starts with the number of indices. The first pair lists adjacent input sites, the remaining indices list Voronoi vertices. Vertex '0' indicates the vertex\[hy]at\[hy]infinity (i.e., an unbounded ray). In 3\[hy]d, the vertices are listed in order. See 'Fi' and 'Fo' for separating hyperplanes. .TP FV Print average vertex. The average vertex is a feasible point for halfspace intersection. .TP Fx List extreme points (vertices) of the convex hull. The first line is the number of points. The other lines give the indices of the corresponding points. The first point is '0'. In 2\[hy]d, the points occur in counter\[hy]clockwise order; otherwise they occur in input order. For Delaunay triangulations, 'Fx' lists the extreme points of the input sites. The points are unordered. .PP .TP Geomview options .TP G Produce a file for viewing with Geomview. Without other options, Qhull displays edges in 2\[hy]d, outer planes in 3\[hy]d, and ridges in 4\[hy]d. A ridge can be explicit or implicit. An explicit ridge is a dim\-1 dimensional simplex between two facets. In 4\[hy]d, the explicit ridges are triangles. When displaying a ridge in 4\[hy]d, Qhull projects the ridge's vertices to one of its facets' hyperplanes. Use 'Gh' to project ridges to the intersection of both hyperplanes. .TP Ga Display all input points as dots. .TP Gc Display the centrum for each facet in 3\[hy]d. The centrum is defined by a green radius sitting on a blue plane. The plane corresponds to the facet's hyperplane. The radius is defined by 'C\-n' or 'Cn'. .TP GDn Drop dimension n in 3\[hy]d or 4\[hy]d. The result is a 2\[hy]d or 3\[hy]d object. .TP Gh Display hyperplane intersections in 3\[hy]d and 4\[hy]d. In 3\[hy]d, the intersection is a black line. It lies on two neighboring hyperplanes (c.f., the blue squares associated with centrums ('Gc')). In 4\[hy]d, the ridges are projected to the intersection of both hyperplanes. .TP Gi Display inner planes in 2\[hy]d and 3\[hy]d. The inner plane of a facet is below all of its vertices. It is parallel to the facet's hyperplane. The inner plane's color is the opposite (1\-r,1\-g,1\-b) of the outer plane. Its edges are determined by the vertices. .TP Gn Do not display inner or outer planes. By default, Geomview displays the precise plane (no merging) or both inner and output planes (merging). Under merging, Geomview does not display the inner plane if the the difference between inner and outer is too small. .TP Go Display outer planes in 2\[hy]d and 3\[hy]d. The outer plane of a facet is above all input points. It is parallel to the facet's hyperplane. Its color is determined by the facet's normal, and its edges are determined by the vertices. .TP Gp Display coplanar points and vertices as radii. A radius defines a ball which corresponds to the imprecision of the point. The imprecision is the maximum of the roundoff error, the centrum radius, and maxcoord * (1\-An). It is at least 1/20'th of the maximum coordinate, and ignores post\[hy]merging if pre\[hy]merging is done. .TP Gr Display ridges in 3\[hy]d. A ridge connects the two vertices that are shared by neighboring facets. Ridges are always displayed in 4\[hy]d. .TP Gt A 3\[hy]d Delaunay triangulation looks like a convex hull with interior facets. Option 'Gt' removes the outside ridges to reveal the outermost facets. It automatically sets options 'Gr' and 'GDn'. .TP Gv Display vertices as spheres. The radius of the sphere corresponds to the imprecision of the data. See 'Gp' for determining the radius. .PP .TP Print options .TP PAn Only the n largest facets are marked good for printing. Unless 'PG' is set, 'Pg' is automatically set. .TP Pdk:n Drop facet from output if normal[k] <= n. The option 'Pdk' uses the default value of 0 for n. .TP PDk:n Drop facet from output if normal[k] >= n. The option 'PDk' uses the default value of 0 for n. .TP PFn Only facets with area at least 'n' are marked good for printing. Unless 'PG' is set, 'Pg' is automatically set. .TP Pg Print only good facets. A good facet is either visible from a point (the 'QGn' option) or includes a point (the 'QVn' option). It also meets the requirements of 'Pdk' and 'PDk' options. Option 'Pg' is automatically set for options 'PAn' and 'PFn'. .TP PG Print neighbors of good facets. .TP PMn Only the n facets with the most merges are marked good for printing. Unless 'PG' is set, 'Pg' is automatically set. .TP Po Force output despite precision problems. Verify ('Tv') does not check coplanar points. Flipped facets are reported and concave facets are counted. If 'Po' is used, points are not partitioned into flipped facets and a flipped facet is always visible to a point. Also, if an error occurs before the completion of Qhull and tracing is not active, 'Po' outputs a neighborhood of the erroneous facets (if any). .TP Pp Do not report precision problems. .PP .TP Qhull control options .TP Qbk:0Bk:0 Drop dimension k from the input points. This allows the user to take convex hulls of sub\[hy]dimensional objects. It happens before the Delaunay and Voronoi transformation. .TP QbB Scale the input points to fit the unit cube. After scaling, the lower bound will be \-0.5 and the upper bound +0.5 in all dimensions. For Delaunay and Voronoi diagrams, scaling happens after projection to the paraboloid. Under precise arithmetic, scaling does not change the topology of the convex hull. .TP Qbb Scale the last coordinate to [0, m] where m is the maximum absolute value of the other coordinates. For Delaunay and Voronoi diagrams, scaling happens after projection to the paraboloid. It reduces roundoff error for inputs with integer coordinates. Under precise arithmetic, scaling does not change the topology of the convex hull. .TP Qbk:n Scale the k'th coordinate of the input points. After scaling, the lower bound of the input points will be n. 'Qbk' scales to \-0.5. .TP QBk:n Scale the k'th coordinate of the input points. After scaling, the upper bound will be n. 'QBk' scales to +0.5. .TP Qc Keep coplanar points with the nearest facet. Output formats 'p', 'f', 'Gp', 'Fc', 'FN', and 'FP' will print the points. .TP Qf Partition points to the furthest outside facet. .TP Qg Only build good facets. With the 'Qg' option, Qhull will only build those facets that it needs to determine the good facets in the output. See 'QGn', 'QVn', and 'PdD' for defining good facets, and 'Pg' and 'PG' for printing good facets and their neighbors. .TP QGn A facet is good (see 'Qg' and 'Pg') if it is visible from point n. If n < 0, a facet is good if it is not visible from point n. Point n is not added to the hull (unless 'TCn' or 'TPn'). With rbox, use the 'Pn,m,r' option to define your point; it will be point 0 (QG0). .TP Qi Keep interior points with the nearest facet. Output formats 'p', 'f', 'Gp', 'FN', 'FP', and 'Fc' will print the points. .TP QJn Joggle each input coordinate by adding a random number in [\-n,n]. If a precision error occurs, then qhull increases n and tries again. It does not increase n beyond a certain value, and it stops after a certain number of attempts [see user.h]. Option 'QJ' selects a default value for n. The output will be simplicial. For Delaunay triangulations, 'QJn' sets 'Qbb' to scale the last coordinate (not if 'Qbk:n' or 'QBk:n' is set). \'QJn' is deprecated for Voronoi diagrams. See also 'Qt'. .TP Qm Only process points that would otherwise increase max_outside. Other points are treated as coplanar or interior points. .TP Qr Process random outside points instead of furthest ones. This makes Qhull equivalent to the randomized incremental algorithms. CPU time is not reported since the randomization is inefficient. .TP QRn Randomly rotate the input points. If n=0, use time as the random number seed. If n>0, use n as the random number seed. If n=\-1, don't rotate but use time as the random number seed. For Delaunay triangulations ('d' and 'v'), rotate about the last axis. .TP Qs Search all points for the initial simplex. .TP Qt Triangulated output. Triangulate all non\[hy]simplicial facets. \'Qt' is deprecated for Voronoi diagrams. See also 'Qt'. .TP Qv Test vertex neighbors for convexity after post\[hy]merging. To use the 'Qv' option, you also need to set a merge option (e.g., 'Qx' or 'C\-0'). .TP QVn A good facet (see 'Qg' and 'Pg') includes point n. If n<0, then a good facet does not include point n. The point is either in the initial simplex or it is the first point added to the hull. Option 'QVn' may not be used with merging. .TP Qx Perform exact merges while building the hull. The "exact" merges are merging a point into a coplanar facet (defined by 'Vn', 'Un', and 'C\-n'), merging concave facets, merging duplicate ridges, and merging flipped facets. Coplanar merges and angle coplanar merges ('A\-n') are not performed. Concavity testing is delayed until a merge occurs. After the hull is built, all coplanar merges are performed (defined by 'C\-n' and 'A\-n'), then post\[hy]merges are performed (defined by 'Cn' and 'An'). .TP Qz Add a point "at infinity" that is above the paraboloid for Delaunay triangulations and Voronoi diagrams. This reduces precision problems and allows the triangulation of cospherical points. .PP .TP Qhull experiments and speedups .TP Q0 Turn off pre\[hy]merging as a default option. With 'Q0'/'Qx' and without explicit pre\[hy]merge options, Qhull ignores precision issues while constructing the convex hull. This may lead to precision errors. If so, a descriptive warning is generated. .TP Q1 With 'Q1', Qhull sorts merges by type (coplanar, angle coplanar, concave) instead of by angle. .TP Q2 With 'Q2', Qhull merges all facets at once instead of using independent sets of merges and then retesting. .TP Q3 With 'Q3', Qhull does not remove redundant vertices. .TP Q4 With 'Q4', Qhull avoids merges of an old facet into a new facet. .TP Q5 With 'Q5', Qhull does not correct outer planes at the end. The maximum outer plane is used instead. .TP Q6 With 'Q6', Qhull does not pre\[hy]merge concave or coplanar facets. .TP Q7 With 'Q7', Qhull processes facets in depth\[hy]first order instead of breadth\[hy]first order. .TP Q8 With 'Q8' and merging, Qhull does not retain near\[hy]interior points for adjusting outer planes. 'Qc' will probably retain all points that adjust outer planes. .TP Q9 With 'Q9', Qhull processes the furthest of all outside sets at each iteration. .TP Q10 With 'Q10', Qhull does not use special processing for narrow distributions. .TP Q11 With 'Q11', Qhull copies normals and recompute centrums for tricoplanar facets. .TP Q12 With 'Q12', Qhull does not report a very wide merge due to a duplicated ridge with nearly coincident vertices Q14 With 'Q14', Qhull does not rename vertices that create a duplicate ridge .PP .TP Trace options .TP Tn Trace at level n. Qhull includes full execution tracing. 'T\-1' traces events. 'T1' traces the overall execution of the program. 'T2' and 'T3' trace overall execution and geometric and topological events. 'T4' traces the algorithm. 'T5' includes information about memory allocation and Gaussian elimination. .TP Ta Annotate output with codes that identify the corresponding qh_fprintf() statement. .TP Tc Check frequently during execution. This will catch most inconsistency errors. .TP TCn Stop Qhull after building the cone of new facets for point n. The output for 'f' includes the cone and the old hull. See also 'TVn'. .TP TFn Report progress whenever more than n facets are created During post\[hy]merging, 'TFn' reports progress after more than n/2 merges. .TP TI file Input data from 'file'. The filename may not include spaces or quotes. .TP TO file Output results to 'file'. The name may be enclosed in single quotes. .TP TPn Turn on tracing when point n is added to the hull. Trace partitions of point n. If used with TWn, turn off tracing after adding point n to the hull. .TP TRn Rerun qhull n times. Usually used with 'QJn' to determine the probability that a given joggle will fail. .TP Ts Collect statistics and print to stderr at the end of execution. .TP Tv Verify the convex hull. This checks the topological structure, facet convexity, and point inclusion. If precision problems occurred, facet convexity is tested whether or not 'Tv' is selected. Option 'Tv' does not check point inclusion if forcing output with 'Po', or if 'Q5' is set. For point inclusion testing, Qhull verifies that all points are below all outer planes (facet\->maxoutside). Point inclusion is exhaustive if merging or if the facet\[hy]point product is small enough; otherwise Qhull verifies each point with a directed search (qh_findbest). Point inclusion testing occurs after producing output. It prints a message to stderr unless option 'Pp' is used. This allows the user to interrupt Qhull without changing the output. .TP TVn Stop Qhull after adding point n. If n < 0, stop Qhull before adding point n. Output shows the hull at this time. See also 'TCn' .TP TMn Turn on tracing at n'th merge. .TP TWn Trace merge facets when the width is greater than n. .TP Tz Redirect stderr to stdout. .PP .SH BUGS Please report bugs to Brad Barber at qhull_bug@qhull.org. If Qhull does not compile, it is due to an incompatibility between your system and ours. The first thing to check is that your compiler is ANSI standard. If it is, check the man page for the best options, or find someone to help you. If you locate the cause of your problem, please send email since it might help others. If Qhull compiles but crashes on the test case (rbox D4), there's still incompatibility between your system and ours. Typically it's been due to mem.c and memory alignment. You can use qh_NOmem in mem.h to turn off memory management. Please let us know if you figure out how to fix these problems. If you do find a problem, try to simplify it before reporting the error. Try different size inputs to locate the smallest one that causes an error. You're welcome to hunt through the code using the execution trace as a guide. This is especially true if you're incorporating Qhull into your own program. When you do report an error, please attach a data set to the end of your message. This allows us to see the error for ourselves. Qhull is maintained part\[hy]time. .PP .SH E\[hy]MAIL Please send correspondence to qhull@qhull.org and report bugs to qhull_bug@qhull.org. Let us know how you use Qhull. If you mention it in a paper, please send the reference and an abstract. If you would like to get Qhull announcements (e.g., a new version) and news (any bugs that get fixed, etc.), let us know and we will add you to our mailing list. If you would like to communicate with other Qhull users, we will add you to the qhull_users alias. For Internet news about geometric algorithms and convex hulls, look at comp.graphics.algorithms and sci.math.num\-analysis .SH SEE ALSO rbox(1) Barber, C. B., D.P. Dobkin, and H.T. Huhdanpaa, "The Quickhull Algorithm for Convex Hulls," ACM Trans. on Mathematical Software, 22(4):469\[en]483, Dec. 1996. http://portal.acm.org/citation.cfm?doid=235815.235821 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.117.405 Clarkson, K.L., K. Mehlhorn, and R. Seidel, "Four results on randomized incremental construction," Computational Geometry: Theory and Applications, vol. 3, p. 185\[en]211, 1993. Preparata, F. and M. Shamos, Computational Geometry, Springer\[hy]Verlag, New York, 1985. .PP .SH AUTHORS .nf C. Bradford Barber Hannu Huhdanpaa bradb@shore.net hannu@qhull.org .fi .SH ACKNOWLEDGEMENTS A special thanks to Albert Marden, Victor Milenkovic, the Geometry Center, Harvard University, and Endocardial Solutions, Inc. for supporting this work. Qhull 1.0 and 2.0 were developed under National Science Foundation grants NSF/DMS\[hy]8920161 and NSF\[hy]CCR\[hy]91\[hy]15793 750\[hy]7504. David Dobkin guided the original work at Princeton University. If you find it useful, please let us know. The Geometry Center is supported by grant DMS\[hy]8920161 from the National Science Foundation, by grant DOE/DE\[hy]FG02\[hy]92ER25137 from the Department of Energy, by the University of Minnesota, and by Minnesota Technology, Inc. Qhull is available from http://www.qhull.org geometry/inst/doc/qhull/html/qhull.html0000644000176200001440000004560014664417655017762 0ustar liggesusers qhull -- convex hull and related structures

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • options


[cone]qhull -- convex hull and related structures

The convex hull of a set of points is the smallest convex set containing the points. The Delaunay triangulation and furthest-site Delaunay triangulation are equivalent to a convex hull in one higher dimension. Halfspace intersection about a point is equivalent to a convex hull by polar duality.

The qhull program provides options to build these structures and to experiment with the process. Use the qconvex, qdelaunay, qhalf, and qvoronoi programs to build specific structures. You may use qhull instead. It takes the same options and uses the same code.

Example: rbox 1000 D3 | qhull C-1e-4 FO Ts
Compute the 3-d convex hull of 1000 random points. Centrums must be 10^-4 below neighboring hyperplanes. Print the options and precision constants. When done, print statistics. These options may be used with any of the Qhull programs.
 
Example: rbox 1000 D3 | qhull d Qbb R1e-4 Q0
Compute the 3-d Delaunay triangulation of 1000 random points. Randomly perturb all calculations by [0.9999,1.0001]. Do not correct precision problems. This leads to serious precision errors.

Use the following equivalences when calling qhull:

By default, Qhull merges coplanar facets. For example, the convex hull of a cube's vertices has six facets.

If you use 'Qt' (triangulated output), all facets will be simplicial (e.g., triangles in 2-d). For the cube example, it will have 12 facets. Some facets may be degenerate and have zero area.

If you use 'QJ' (joggled input), all facets will be simplicial. The corresponding vertices will be slightly perturbed. Joggled input is less accurate that triangulated output.See Merged facets or joggled input.

The output for 4-d convex hulls may be confusing if the convex hull contains non-simplicial facets (e.g., a hypercube). See Why are there extra points in a 4-d or higher convex hull?

Copyright © 1995-2020 C.B. Barber


»qhull synopsis

qhull -- compute convex hulls and related structures.
    input (stdin): dimension, number of points, point coordinates
    comments start with a non-numeric character
    halfspace: use dim+1 and put offsets after coefficients

options:
    d    - Delaunay triangulation by lifting points to a paraboloid
    d Qu - furthest-site Delaunay triangulation (upper convex hull)
    v    - Voronoi diagram as the dual of the Delaunay triangulation
    v Qu - furthest-site Voronoi diagram
    H1,1 - Halfspace intersection about [1,1,0,...] via polar duality
    Qt   - triangulated output
    QJ   - joggled input instead of merged facets
    Tv   - verify result: structure, convexity, and point inclusion
    .    - concise list of all options
    -    - one-line description of each option
    -?   - this message
    -V   - version

Output options (subset):
    s    - summary of results (default)
    i    - vertices incident to each facet
    n    - normals with offsets
    p    - vertex coordinates (if 'Qc', includes coplanar points)
           if 'v', Voronoi vertices
    FA   - report total area and volume
    Fp   - halfspace intersections
    FS   - total area and volume
    Fx   - extreme points (convex hull vertices)
    G    - Geomview output (2-d, 3-d and 4-d)
    m    - Mathematica output (2-d and 3-d)
    o    - OFF format (if 'v', outputs Voronoi regions)
    QVn  - print facets that include point n, -n if not
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes

examples:
    rbox D4 | qhull Tv                        rbox 1000 s | qhull Tv s FA
    rbox 10 D2 | qhull d QJ s i TO result     rbox 10 D2 | qhull v Qbb Qt p
    rbox 10 D2 | qhull d Qu QJ m              rbox 10 D2 | qhull v Qu QJ o
    rbox c d D2 | qhull Qc s f Fx | more      rbox c | qhull FV n | qhull H Fp
    rbox d D12 | qhull QR0 FA                 rbox c D7 | qhull FA TF1000
    rbox y 1000 W0 | qhull Qc                 rbox c | qhull n

»qhull input

The input data on stdin consists of:

  • dimension
  • number of points
  • point coordinates

Use I/O redirection (e.g., qhull < data.txt), a pipe (e.g., rbox 10 | qhull), or the 'TI' option (e.g., qhull TI data.txt).

Comments start with a non-numeric character. Error reporting is simpler if there is one point per line. Dimension and number of points may be reversed. For halfspace intersection, an interior point may be prepended (see qhalf input).

Here is the input for computing the convex hull of the unit cube. The output is the normals, one per facet.

rbox c > data

3 RBOX c
8
  -0.5   -0.5   -0.5
  -0.5   -0.5    0.5
  -0.5    0.5   -0.5
  -0.5    0.5    0.5
   0.5   -0.5   -0.5
   0.5   -0.5    0.5
   0.5    0.5   -0.5
   0.5    0.5    0.5

qhull s n < data


Convex hull of 8 points in 3-d:

  Number of vertices: 8
  Number of facets: 6
  Number of non-simplicial facets: 6

Statistics for: RBOX c | QHULL s n

  Number of points processed: 8
  Number of hyperplanes created: 11
  Number of distance tests for qhull: 35
  Number of merged facets: 6
  Number of distance tests for merging: 84
  CPU seconds to compute hull (after input): 0.081

4
6
     0      0     -1   -0.5
     0     -1      0   -0.5
     1      0      0   -0.5
    -1      0      0   -0.5
     0      1      0   -0.5
     0      0      1   -0.5

»qhull outputs

These options control the output of qhull. They may be used individually or together.

 
General
qhull
compute the convex hull of the input points. See qconvex.
qhull d Qbb
compute the Delaunay triangulation by lifting the points to a paraboloid. Use option 'Qbb' to scale the paraboloid and improve numeric precision. See qdelaunay.
qhull v Qbb
compute the Voronoi diagram by computing the Delaunay triangulation. Use option 'Qbb' to scale the paraboloid and improve numeric precision. See qvoronoi.
qhull H
compute the halfspace intersection about a point via polar duality. The point is below the hyperplanes that defines the halfspace. See qhalf.

For a full list of output options see

»qhull controls

For a full list of control options see

»qhull options

qhull -- compute convex hulls and related structures.
    http://www.qhull.org

input (stdin):
    first lines: dimension and number of points (or vice-versa).
    other lines: point coordinates, best if one point per line
    comments:    start with a non-numeric character
    halfspaces:  use dim plus one and put offset after coefficients.
                 May be preceded by a single interior point ('H').

options:
    d    - Delaunay triangulation by lifting points to a paraboloid
    d Qu - furthest-site Delaunay triangulation (upper convex hull)
    Hn,n,... - halfspace intersection about point [n,n,0,...]
    Qc   - keep coplanar points with nearest facet
    Qi   - keep interior points with nearest facet
    QJ   - joggled input instead of merged facets
    Qt   - triangulated output
    v    - Voronoi diagram (dual of the Delaunay triangulation)
    v Qu - furthest-site Voronoi diagram

Qhull control options:
    Qa   - allow input with fewer or more points than coordinates
    Qbk:n   - scale coord k so that low bound is n
      QBk:n - scale coord k so that upper bound is n (QBk is 0.5)
    QbB  - scale input to unit cube centered at the origin
    Qbb  - scale last coordinate to [0,m] for Delaunay triangulations
    Qbk:0Bk:0 - remove k-th coordinate from input
    QJn  - randomly joggle input in range [-n,n]
    QRn  - random rotation (n=seed, n=0 time, n=-1 time/no rotate)
    Qs   - search all points for the initial simplex
    Qu   - for 'd' or 'v', compute upper hull without point at-infinity
              returns furthest-site Delaunay triangulation
    QVn  - good facet if it includes point n, -n if not
    Qx   - exact pre-merges (skips coplanar and angle-coplanar facets)
    Qz   - add point-at-infinity to Delaunay triangulation

Qhull extra options:
    Qf   - partition point to furthest outside facet
    Qg   - only build good facets (needs 'QGn', 'QVn', or 'PdD')
    QGn  - good facet if visible from point n, -n for not visible
    Qm   - only process points that would increase max_outside
    Qr   - process random outside points instead of furthest ones
    Qv   - test vertex neighbors for convexity
    Qw   - allow option warnings
    Q0   - turn off default premerge with 'C-0'/'Qx'
    Q1   - merge by mergetype/angle instead of mergetype/distance
    Q2   - merge all coplanar facets instead of merging independent sets
    Q3   - do not merge redundant vertices
    Q4   - avoid old->new merges
    Q5   - do not correct outer planes at end of qhull
    Q6   - do not pre-merge concave or coplanar facets
    Q7   - depth-first processing instead of breadth-first
    Q8   - do not process near-inside points
    Q9   - process furthest of furthest points
    Q10  - no special processing for narrow distributions
    Q11  - copy normals and recompute centrums for tricoplanar facets
    Q12  - allow wide facets and wide dupridge
    Q14  - merge pinched vertices that create a dupridge
    Q15  - check for duplicate ridges with the same vertices

T options:
    TFn  - report summary when n or more facets created
    TI file - input file, may be enclosed in single quotes
    TO file - output file, may be enclosed in single quotes
    Ts   - statistics
    Tv   - verify result: structure, convexity, and point inclusion
    Tz   - send all output to stdout

Trace options:
    T4   - trace at level n, 4=all, 5=mem/gauss, -1= events
    Ta   - annotate output with message codes
    TAn  - stop qhull after adding n vertices
     TCn - stop qhull after building cone for point n
     TVn - stop qhull after adding point n, -n for before
    Tc   - check frequently during execution
    Tf   - flush each qh_fprintf for debugging segfaults
    TPn  - turn on tracing when point n added to hull
     TP-1  turn on tracing after qh_buildhull and qh_postmerge
     TMn - turn on tracing at merge n
     TWn - trace merge facets when width > n
    TRn  - rerun qhull n times for statistics to adjust 'QJn'

Precision options:
    Cn   - radius of centrum (roundoff added).  Merge facets if non-convex
     An  - cosine of maximum angle.  Merge facets if cosine > n or non-convex
           C-0 roundoff, A-0.99/C-0.01 pre-merge, A0.99/C0.01 post-merge
    En   - max roundoff error for distance computation
    Rn   - randomly perturb computations by a factor of [1-n,1+n]
    Vn   - min distance above plane for a visible facet (default 3C-n or En)
    Un   - max distance below plane for a new, coplanar point (default Vn)
    Wn   - min facet width for outside point (before roundoff, default 2Vn)

Output formats (may be combined; if none, produces a summary to stdout):
    f    - facet dump
    G    - Geomview output (see below)
    i    - vertices incident to each facet
    m    - Mathematica output (2-d and 3-d)
    n    - normals with offsets
    o    - OFF format (dim, points and facets; Voronoi regions)
    p    - vertex coordinates or Voronoi vertices (coplanar points if 'Qc')
    s    - summary (stderr)

More formats:
    Fa   - area for each facet
    FA   - compute total area and volume for option 's'
    Fc   - count plus coplanar points for each facet
           use 'Qc' (default) for coplanar and 'Qi' for interior
    FC   - centrum or Voronoi center for each facet
    Fd   - use cdd format for input (homogeneous with offset first)
    FD   - use cdd format for numeric output (offset first)
    FF   - facet dump without ridges
    Fi   - inner plane for each facet
           for 'v', separating hyperplanes for bounded Voronoi regions
    FI   - ID of each facet
    Fm   - merge count for each facet (511 max)
    FM   - Maple output (2-d and 3-d)
    Fn   - count plus neighboring facets for each facet
    FN   - count plus neighboring facets for each point
    Fo   - outer plane (or max_outside) for each facet
           for 'v', separating hyperplanes for unbounded Voronoi regions
    FO   - options and precision constants
    Fp   - dim, count, and intersection coordinates (halfspace only)
    FP   - nearest vertex and distance for each coplanar point
    FQ   - command used for qhull
    Fs   - summary: #int (8), dimension, #points, tot vertices, tot facets,
                      output: #vertices, #facets, #coplanars, #nonsimplicial
                    #real (2), max outer plane, min vertex
    FS   - sizes:   #int (0)
                    #real (2) tot area, tot volume
    Ft   - triangulation with centrums for non-simplicial facets (OFF format)
    Fv   - count plus vertices for each facet
           for 'v', Voronoi diagram as Voronoi vertices for pairs of sites
    FV   - average of vertices (a feasible point for 'H')
    Fx   - extreme points (in order for 2-d)

Geomview output (2-d, 3-d, and 4-d; 2-d Voronoi)
    Ga   - all points as dots
     Gp  -  coplanar points and vertices as radii
     Gv  -  vertices as spheres
    Gc   - centrums
    GDn  - drop dimension n in 3-d and 4-d output
    Gh   - hyperplane intersections
    Gi   - inner planes only
     Gn  -  no planes
     Go  -  outer planes only
    Gr   - ridges
    Gt   - for 3-d 'd', transparent outer ridges

Print options:
    PAn  - keep n largest facets by area
    Pdk:n - drop facet if normal[k] <= n (default 0.0)
    PDk:n - drop facet if normal[k] >= n
    PFn  - keep facets whose area is at least n
    Pg   - print good facets (needs 'QGn' or 'QVn')
    PG   - print neighbors of good facets
    PMn  - keep n facets with most merges
    Po   - force output.  If error, output neighborhood of facet
    Pp   - do not report precision problems

    .    - list of all options
    -    - one line descriptions of all options
    -?   - help with examples
    -V   - version

Up: Home page for Qhull (local)
Up: Qhull manual: contents
To: ProgramsOptionsOutputFormatsGeomviewPrintQhullPrecisionTraceFunctions (local)
To: synopsis • input • outputs • controls • options


The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: Sept. 25, 1995 --- Last modified: see top

geometry/inst/doc/qhull/index.html0000644000176200001440000003603314664417655017000 0ustar liggesusers Qhull code for Convex Hull, Delaunay Triangulation, Voronoi Diagram, and Halfspace Intersection about a Point URL: http://www.qhull.orgNewsScholarImagesGitHub
To: DownloadReadmeManualProgramsOptionsFAQCodeFunctions


Qhull

[CONE]
Qhull computes the convex hull, Delaunay triangulation, Voronoi diagram, halfspace intersection about a point, furthest-site Delaunay triangulation, and furthest-site Voronoi diagram. The source code runs in 2-d, 3-d, 4-d, and higher dimensions. Qhull implements the Quickhull algorithm for computing the convex hull. It handles roundoff errors from floating point arithmetic. It computes volumes, surface areas, and approximations to the convex hull.

Qhull does not support triangulation of non-convex surfaces, mesh generation of non-convex objects, medium-sized inputs in 9-D and higher, alpha shapes, weighted Voronoi diagrams, Voronoi volumes, or constrained Delaunay triangulations,

If you call Qhull from your program, please use reentrant Qhull (libqhull_r or libqhullstatic_r). If you use Qhull 2003.1, please upgrade or apply poly.c-qh_gethash.patch.


Introduction

Qhull Documentation and Support

Related URLs

FAQs and Newsgroups


The program includes options for input transformations, randomization, tracing, multiple output formats, and execution statistics. The program can be called from within your application.

You can view the results in 2-d, 3-d and 4-d with Geomview. An alternative is VTK.

For an article about Qhull, download from ACM or CiteSeer:

Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., "The Quickhull algorithm for convex hulls," ACM Trans. on Mathematical Software, 22(4):469-483, Dec 1996, http://www.qhull.org

Abstract:

The convex hull of a set of points is the smallest convex set that contains the points. This article presents a practical convex hull algorithm that combines the two-dimensional Quickhull Algorithm with the general dimension Beneath-Beyond Algorithm. It is similar to the randomized, incremental algorithms for convex hull and Delaunay triangulation. We provide empirical evidence that the algorithm runs faster when the input contains non-extreme points, and that it uses less memory.

Computational geometry algorithms have traditionally assumed that input sets are well behaved. When an algorithm is implemented with floating point arithmetic, this assumption can lead to serious errors. We briefly describe a solution to this problem when computing the convex hull in two, three, or four dimensions. The output is a set of "thick" facets that contain all possible exact convex hulls of the input. A variation is effective in five or more dimensions.


Up: Past Software Projects of the Geometry Center
URL: http://www.qhull.orgNewsScholarImagesGitHub
To: DownloadReadmeManualProgramsOptionsFAQCodeFunctions


[HOME] The Geometry Center Home Page

Comments to: qhull@qhull.org
Created: May 17 1995 --- geometry/inst/doc/qhull/COPYING.txt0000644000176200001440000000314313431000557016624 0ustar liggesusers Qhull, Copyright (c) 1993-2018 C.B. Barber Arlington, MA and The National Science and Technology Research Center for Computation and Visualization of Geometric Structures (The Geometry Center) University of Minnesota email: qhull@qhull.org This software includes Qhull from C.B. Barber and The Geometry Center. Qhull is copyrighted as noted above. Qhull is free software and may be obtained via http from www.qhull.org. It may be freely copied, modified, and redistributed under the following conditions: 1. All copyright notices must remain intact in all files. 2. A copy of this text file must be distributed along with any copies of Qhull that you redistribute; this includes copies that you have modified, or copies of programs or other software products that include Qhull. 3. If you modify Qhull, you must include a notice giving the name of the person performing the modification, the date of modification, and the reason for such modification. 4. When distributing modified versions of Qhull, or other software products that include Qhull, you must provide notice that the original source code may be obtained as noted above. 5. There is no warranty or other guarantee of fitness for Qhull, it is provided solely "as is". Bug reports or fixes may be sent to qhull_bug@qhull.org; the authors may or may not act on them as they desire. geometry/inst/doc/qhull/Announce.txt0000644000176200001440000000420713431000557017264 0ustar liggesusers Qhull 2015.2 2016/01/18 http://www.qhull.org git@github.com:qhull/qhull.git http://www.geomview.org Qhull computes convex hulls, Delaunay triangulations, Voronoi diagrams, furthest-site Voronoi diagrams, and halfspace intersections about a point. It runs in 2-d, 3-d, 4-d, or higher. It implements the Quickhull algorithm for computing convex hulls. Qhull handles round-off errors from floating point arithmetic. It can approximate a convex hull. The program includes options for hull volume, facet area, partial hulls, input transformations, randomization, tracing, multiple output formats, and execution statistics. The program can be called from within your application. You can view the results in 2-d, 3-d and 4-d with Geomview. To download Qhull: http://www.qhull.org/download git@github.com:qhull/qhull.git Download qhull-96.ps for: Barber, C. B., D.P. Dobkin, and H.T. Huhdanpaa, "The Quickhull Algorithm for Convex Hulls," ACM Trans. on Mathematical Software, 22(4):469-483, Dec. 1996. http://portal.acm.org/citation.cfm?doid=235815.235821 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.117.405 Abstract: The convex hull of a set of points is the smallest convex set that contains the points. This article presents a practical convex hull algorithm that combines the two-dimensional Quickhull Algorithm with the general dimension Beneath-Beyond Algorithm. It is similar to the randomized, incremental algorithms for convex hull and Delaunay triangulation. We provide empirical evidence that the algorithm runs faster when the input contains non-extreme points, and that it uses less memory. Computational geometry algorithms have traditionally assumed that input sets are well behaved. When an algorithm is implemented with floating point arithmetic, this assumption can lead to serious errors. We briefly describe a solution to this problem when computing the convex hull in two, three, or four dimensions. The output is a set of "thick" facets that contain all possible exact convex hulls of the input. A variation is effective in five or more dimensions. geometry/inst/doc/LICENSE-NOTES0000644000176200001440000000042314664417655015543 0ustar liggesusersAll files in src/ apart from Rgeometry.c, Rgeometry.h, Rconvhulln.c, Rdelaunayn.c Rtsearchn.c, Rtsearch_orig.c, Rtsearch.cpp, RcppExports.cpp, Rinhulln.c, Rhalfspacen.c and geometry_init.c are taken from or based on Qhull (http://www.qhull.org/), and covered by COPYING.txt. geometry/inst/doc/qhull-eg.pdf0000644000176200001440000061165714751720222016062 0ustar liggesusers%PDF-1.5 %ÐÔÅØ 34 0 obj << /Length 1082 /Filter /FlateDecode >> stream xÚÅVKoÛF¾ûWA$ n÷Í]´):õ¡·¢rP| ©µÈ”"’R’ßÙMÙt’KÑÓ>8óÍsçãïÛ›Ÿï˜JH(<Ù>&T؉$1]$Û}²Kÿª3*ÓsÛf9#,5_Êã©5cv¿ýôuBÒBP«¯Ã4É©BJ)¯ý¾Ìh‘^š=hÌ-òëß“†rš,J’[z ±‚{=5Õ^ò.S$5ù¾úŠ©Ö 0©%•ÖxN°FJÈ$gVíq¶u3‚Ãé¾ÏÀ³´:M—Áf²×$= f ApŽÐúG¿NµñF¹^%…B2†½µƒéfG_ºÇ"”FÁSYY“ÿdB¤åÁxç®šš¾ –?ת}’(SŠAœ.á§±ž.â×(,=Mwð[‚±%U¡¤pß6dy¯¡„#Æ¥+)†tR¤9õöHæ1Noû.ƒä]2—/€‘ü„€ŽþØtv-Rú>àÒe«`WnEHÀE™Šô¶l[ë±×aKB‚#,¦°ê»K æº5x­Àdýܸn*DÚwÆoÊáà‚˜V› š¨(4lb±™?x¥ŽR34ù´ÉrŽ©u̦÷“Üy•ÁLçÁU¾ ßtû¦2áÖõÚòëɵlß<õç,¥¢”ž Z' ¶[ðu›DWb‰ù"T+ 'DËre=ñ š:#©=’5ü týúk~,§¡ùbµAmèúáh÷ [€ })¯0«:b†sˆ¡òó4~ǩڔ{+XÕQðÙ¦cƒ‚. •ÞmȽWßmè}x€AnicG6 G±Öîiè,ÂÖœÙÑYP[½\ oÇgA¶.¹KAjŸ/yíI0¹E|’ô¿~’+€ #IU”êO~’­=PY Ž‹ð@W}È0ììBaLŒP:/˜%j–öƒ¿ºšP0Ÿ+|÷nÅÌPÌ^? N9 6°…Y`†Ü0ûc9åQE®_N9˜rÅ*Q6g ìV5¢ú_úv-¤šÃްiîæ|tœl[~—> stream xÚuTMoÛ0 ½çWÅ6P«¢¨Ïa°b+¶ÝØ!í!s\8Cbg±û±?ʲ\'u‘CdŠ|"Éw½\\Ý(™8æ´ÐÉò>Df´M´2L J–›d•~Êr%Tz8nëî–+^Tï› »[þ¸º‘n‚À“\s`Bì îB´fRpndA3}T2'ågCÜçhàÌ8 z¢©«‡Ý®žATœ¡ѳùM)èôOi™å]–#bZ¬ëpXïÚ&œÈSXïå?»¦ëÊaá‘®r£P9Í›¦\Qh *Ò´øº\øÜy#ËÈ CI±_ü]0šð½ÇäØ_ŸÁpõ}É—fñ“~ñ*˜ùôÚ÷÷ŒjË ] §ª¡G¿2‹±æWœÈô–£¬7ÁÚUƒ_Ý÷ä<ºæìö– ~¿.Ê®¥d¹“6÷gNÔÀŒÈ~Ì„IËç`«¼…šú~Žï8'=ß§³YTáÿC>|7Ôìa>|íe¸hݶ©ÛõEìŒY ÑS§-¬Êõf˜öX,¤o ½̨³Á¿ô“ÚH:Š—#ÞõoæCÈôá\’Л)§J1ô¢´b´Q[JòËi‰\8yRÄÀËJ\‹—Sœ‹Â‚7HopR§Õ„Âéø,N€œâÖqŸ‘t>#î”°æÅ6ÞÈHN€¸ÔèPãäœuci‚¤áFÏ© MVs¡‰&OCWÜYÅõX%쬵³Xz‚eGO¹1bi #8ƒ¨øŒæðSûVK?ø< ¼?øE:¶$>’»´ócÿäǽ †¢Ù=x©Ù×m0¬ýÒE€ðLWYSÆ0ÊáóLJŽš±ÁÁýFœÑPEŸ³ (0:l¶Ç²ð2ó;ÝK ›B»&Åëüæ.ÚÓtÕö¸‰’°{Ø×AT6e/> /ExtGState << >>/ColorSpace << /sRGB 54 0 R >>>> /Length 1496 /Filter /FlateDecode >> stream xœµXK‹EÝß_Ñ  ¦í÷c› B@!Î@!««"CFŒ³ÐŸï©W}‡á2Cp‘ §ªNuu×£û»Ñ½uÑݹϧwӇâzö¥¸\’ïÉ¥9}MîïßÜ{÷ç黇_~|íÞÜœ‚!¸ýïÍ›Ÿ!íÕýsúðÑ÷ë)º·øwwŠdà~:9—Gó¹»Tš/ÓÝï’îçê¾ éãB8ÝЙ¬gðµ.ýŒ¾\Cì[¬UR}ˆ7û¾ùfÄÖ¶¶ê5.á^Ä}>ÝÀ>æâΧ%RÝï’ìGjt˜©UZ(æNǨèÌÖ“\›¾Ÿ®!öÍÖ& ~ŒÅE¾Úá[ø–µM¯q)w[ö’Ê áfà­˜`ú,éèÁáüZ€ÏHg/€ÖJ5Ñ"¦Eü‹§€½Š©pŠÑx£ú´¼ `SYSµðöX5}ú,ÕՒ Êiч4)µq$_£!>®‘ýœ‡‹n\Eì[¬UR}‹·ø¼ùf$Öº¶è-.á^Ä­©HÅw¤YJCra’ê{ª~â?dEŸR§^UÄ—†Ÿyésðñàbßlm’D;_ÜÈ`¾‰o][õ—r÷¸­¬ yÅ׬e%‚FGB½•+%2en­QœµsZZ ¡ƒ'€½Z­ ûP/úqxe ¦²¦j%åm±jY•HÕQ¨];Ü$ØdJTÉ,ÔÁ™*R‘ôl¥6XúF²¸ŠØ·X«K̃d:¨ï°¦‡­­zK¹{ÜšŠ|Fê"f{’\˜¤ø‰® È)&\l>âˆΤ⃠…Îx饞Œ«ˆ}‹µJ¢Ÿåà¾PÌ7#±ÖµU¯q)w[ó‚&C¹³´ÝM’ȵdmüŸ¶s¨†¤%%yé;ÝZ‹«(í.ô*¥G¹}H»‹oA6JhmÓK\ÆÝãÖ¼tiÀ8|Ôv7 ÏîÔ#qRâÙz¢zVÄg× •ûÒW9iå*bßb]-‹®Æ¨Ï÷ ±–µM¯q)w[÷ÒßJSò²$™=4ifŒˆ†Ñ†ïÑÐYwNÓ^õX½\CìÛ¢cI ‰kÜ4©Ì· ¶ÖµM¯q ÷"në}ŒƒÀy A{_%“âáþ¤éè4¨wG0$ý9h.=&ÔÆUľÅZ%â1.’•ß‚Ö\‰‡^ãRî·]Hü5Lè¬×£JÝd±wÚxÄ•¼‚$5hì›U®!ö}Ö^dIö©ÜäÃæ›[Ûڪ׸„{·ì%g~gä† .3yI2kFñºÉà ›3Š'CüÊCqÑóÎôŽiq±o±VI al\<âá[XËڦ׸”»Ç-{i“÷ŒK5FÞŠ É騠1,p ㉀ZïÙ­…7:žƒ¦-œå)`¯lª‚ì[Z<¾=Ì+6Õ5Y`Ñ0ï"V Ÿ _ö5V ú±q'v¥0~rîæ±B*;3 Ï•Í@àf@“ Ï,3P¸`æ¥tÜ 2^Dã0P¸ìa¯]l¯oõ˜ÎOÓÃßT? !îöwœ®W…ü,Ÿ-…Ÿø·÷îëW¸=¾q·w§ïoÙùuv1¶wϧ§€±Ù7zxÉâü53.Ø/X;ãN+;ûEÏÕ;{­-Ÿ¹xꡞîõ£—è°äœ=ÒG~C2ÚÔÔ%tÍ©^ánÐø™¼ nô¶AnÌ@ánµÐ2¸`“¹7ƒŒ’Ç‹Þ î²íe°Â~ÆÛÁ¾ÚÎM<óÐ5¨P­Í'|•ñÒÃSâZm_çÓ§b¾ZÜ×ù“Çö•ê¾J§G¦å•ò¾No<µ®Ô÷UzFƒbè?*ðçÓñ¸ÀeMôt¬¾ÿ t*A²,“Ù`FÖq±²:2ø‡“»á‹çž~àÙ%9ÿ~õׇo]üø‚MFо8êî#-ÿÿ^ë "–ã‡'þ)In!ýJ•Ïäu+óU+ýª ¿o<ÃârUYEb‘ßxžŒãÒâ",6xwúºJÞ2 endstream endobj 56 0 obj << /Alternate /DeviceRGB /N 3 /Length 2596 /Filter /FlateDecode >> stream xœ–wTSهϽ7½P’Š”ÐkhRH ½H‘.*1 JÀ"6DTpDQ‘¦2(à€£C‘±"Š…Q±ëDÔqp–Id­ß¼yïÍ›ß÷~kŸ½ÏÝgï}ÖºüƒÂLX € ¡Xáçň‹g` ðlàp³³BøF™|ØŒl™ø½º ùû*Ó?ŒÁÿŸ”¹Y"1P˜ŒçòøÙ\É8=Wœ%·Oɘ¶4MÎ0JÎ"Y‚2V“sò,[|ö™e9ó2„<ËsÎâeðäÜ'ã9¾Œ‘`çø¹2¾&cƒtI†@Æoä±|N6(’Ü.æsSdl-c’(2‚-ãyàHÉ_ðÒ/XÌÏËÅÎÌZ.$§ˆ&\S†“‹áÏÏMç‹ÅÌ07#â1Ø™YárfÏüYym²";Ø8980m-m¾(Ô]ü›’÷v–^„îDøÃöW~™ °¦eµÙú‡mi]ëP»ý‡Í`/в¾u}qº|^RÄâ,g+«ÜÜ\KŸk)/èïúŸC_|ÏR¾Ýïåaxó“8’t1C^7nfz¦DÄÈÎâpù 柇øþuü$¾ˆ/”ED˦L L–µ[Ȉ™B†@øŸšøÃþ¤Ù¹–‰ÚøЖX¥!@~(* {d+Ðï} ÆGù͋љ˜ûÏ‚þ}W¸LþÈ$ŽcGD2¸QÎìšüZ4 E@ê@èÀ¶À¸àA(ˆq`1à‚D €µ ”‚­`'¨u 4ƒ6ptcà48.Ë`ÜR0ž€)ð Ì@„…ÈR‡t CȲ…XäCP”%CBH@ë R¨ª†ê¡fè[è(tº C· Qhúz#0 ¦ÁZ°l³`O8Ž„ÁÉð28.‚·À•p|î„O×àX ?§€:¢‹0ÂFB‘x$ !«¤i@Ú¤¹ŠH‘§È[EE1PL” Ê…⢖¡V¡6£ªQP¨>ÔUÔ(j õMFk¢ÍÑÎèt,:‹.FW ›Ðè³èô8úƒ¡cŒ1ŽL&³³³ÓŽ9…ÆŒa¦±X¬:ÖëŠ År°bl1¶ {{{;Ž}ƒ#âtp¶8_\¡8áú"ãEy‹.,ÖXœ¾øøÅ%œ%Gщ1‰-‰ï9¡œÎôÒ€¥µK§¸lî.îžoo’ïÊ/çO$¹&•'=JvMÞž<™âžR‘òTÀT ž§ú§Ö¥¾N MÛŸö)=&½=—‘˜qTH¦ û2µ3ó2‡³Ì³Š³¤Ëœ—í\6% 5eCÙ‹²»Å4ÙÏÔ€ÄD²^2šã–S“ó&7:÷Hžrž0o`¹ÙòMË'ò}ó¿^ZÁ]Ñ[ [°¶`t¥çÊúUЪ¥«zWë¯.Z=¾Æo͵„µik(´.,/|¹.f]O‘VÑš¢±õ~ë[‹ŠEÅ76¸l¨ÛˆÚ(Ø8¸iMKx%K­K+Jßoæn¾ø•ÍW•_}Ú’´e°Ì¡lÏVÌVáÖëÛÜ·(W.Ï/Û²½scGÉŽ—;—ì¼PaWQ·‹°K²KZ\Ù]ePµµê}uJõHWM{­fí¦Ú×»y»¯ìñØÓV§UWZ÷n¯`ïÍz¿úΣ†Š}˜}9û6F7öÍúº¹I£©´éÃ~á~éˆ}ÍŽÍÍ-š-e­p«¤uò`ÂÁËßxÓÝÆl«o§·—‡$‡›øíõÃA‡{°Ž´}gø]mµ£¤ê\Þ9Õ•Ò%íŽë>x´·Ç¥§ã{Ëï÷Ó=Vs\åx٠‰¢ŸN柜>•uêééäÓc½Kz=s­/¼oðlÐÙóç|Ïé÷ì?yÞõü± ÎŽ^d]ìºäp©sÀ~ ãû:;‡‡º/;]îž7|âŠû•ÓW½¯ž»píÒÈü‘áëQ×oÞH¸!½É»ùèVú­ç·snÏÜYs}·äžÒ½Šûš÷~4ý±]ê =>ê=:ð`Áƒ;cܱ'?eÿô~¼è!ùaÅ„ÎDó#ÛGÇ&}'/?^øxüIÖ“™§Å?+ÿ\ûÌäÙw¿xü20;5þ\ôüÓ¯›_¨¿ØÿÒîeïtØôýW¯f^—¼Qsà-ëmÿ»˜w3¹ï±ï+?˜~èùôñî§ŒOŸ~÷„óû endstream endobj 60 0 obj << /Length 889 /Filter /FlateDecode >> stream xÚ…UM›H½ûW°9µ%Óéo@Šs˜LVÉÞvåÕ¼£ˆf@bÀ ídæßoUwãÀ ŠeÉUTW½~]T?n›÷¿kqN3 öðq)ibÒÈè„ ©£C §rs.49l3EªÑ6Ýã6–J’æ­"'0œôM·cG¿˜•_mº±)«ô¡¢ßrⲿã_õìWk|8·­OúÑØz{wøXÊ9KÉ5:˜ç×t5”t>S&QF3# &ÆSfÌS*ÓÄçjࢤ&ç®°M*U6«4œj¦¯ï ͤšòмóÈ÷ÛX$$ls«Ò{¶G«ˆ…ú6-4P¤®`°˜æè²BÑÏýZ´a‹ï˜ÝÃX J‘(œ™ ªd¶ÎxŠ_*÷V¤$¶vŽúU’Œ&|:Ýpß?¯´@(siÕèÑs]ç]ùâ#?jŽ/~ÍÂôÞ-†*·×›V88ëÀëŸ|¬í]f‘#ù‘†IQó÷Ï™¤™2à$T©0Ï·±†a¶'o?ÄÞ÷Èçù_¦Y·Œí|øv/‚w³W°È]sYèê²é¾õUM£ƒ¨E½›v¾‚sj{‹ötüÍaî€Ú]¨.úvÿîqÈ_Þ]CÚ1àxjœì0CU¾E1«\.ìó`Êý᯿?O¥›Ï‡ Ž ‹øEBD’@ëUTõµÇ¿óåǸx°³¼ oa*šmxä;H冘3xu FN+V†„›ŒÂ=0¸iØYNjó?ÖÆ%€ endstream endobj 57 0 obj << /Type /XObject /Subtype /Form /FormType 1 /PTEX.FileName (./qhull-eg-005.pdf) /PTEX.PageNumber 1 /PTEX.InfoDict 62 0 R /BBox [0 0 432 432] /Resources << /ProcSet [ /PDF /Text ] /Font << /F2 63 0 R>> /ExtGState << >>/ColorSpace << /sRGB 64 0 R >>>> /Length 12710 /Filter /FlateDecode >> stream xœ¥}]¯5»mÞýû+VïZ Ù}ÌhæÖF @$Ç@. £;)R£ËhâùûŸJë$6œöâ¼$硸×h$‘¢¨òú«WyýöõÏ?þöõϯóù:úk´¯Þ_­×¯Q_õy¾Îúú—|ýýëw?þâ÷÷—¿xýò§Ç×èçkÿ÷§_þMpÏ׿þøõo^Çë~”×_Íÿ~û£_Çñúë¯W½ž¯ç†Î‰x/N;ޝ§¿ê(_å™Tý*ç¤ê×u›úާGÿ*×’Ÿ_mÂ’n>-Îøz†±õ¹ÂHéŧѶ嶔Ø»¿ü4Ÿ/õü:çÏTÆ×yãoIÎü¯IMEÓÖz|Õ{R÷Wí¦¾ñôó5ZÊþcMA7ž6çú:žÄ–þu/ݤ¨›m[.»„ÝíößÒ¾îãUæß~=ú[Ĺ¿ 5uRÏW{ ý;I_XSÐͧÅÁ´b,§ë&…§Õ¶å²‹Ø»õ^Î9×xÝ7çÆät¼às€eRgÌAõ¼b…ßî¼cRLùsBbEUÏvÉ™ßñ±°^ˆuƒâÓj[rÙ%ìn·¾—ùG7ò ßKrÚ×Uð3œÖÝ ?Ãq˜BŸnx×)G¯H¬¨ê·˜œãëꉟE_ºIñi¶-¹í"öÃný-לjæ{¼0ä¼wNU^›ïrvÖv5,/f?ˆ·N í=CòÙkž…5Ý|šœx=gbçëiK7)<­¶-§]Â~Ø­>6µXÌaáÖ·/ÎüûcÙ7§¡:;ë|³çƒQ6&%RœÁV!–wÌÆ’¢nϤàÌ/¶$6&Ì¥›Ô·féh[r[Jì‡Ýþ^Ž˜GË1ÜÇ’sG?©ó%Ʋðx¢ÕSOSîÓG[ò+¦ûÄŠîcÉ9£Ÿ$¶GJÝÝ},Û–\v »Û­qlöÙùc:}4Õ›35ÌézöðÙBL©sÍV椋R\éŽèN)¿£«%VTÍÕ¡9ËFcçÏ¿éŧնä²KØÝnû=úl™sñ8õí‹3â·9QÅ dÜá´¹’í—)ôé9Yax¥|~­eaMö@’ÓcæOl‹©?uƒ¢nµ-¹ìv·[Küíóûš]³kÞ7g~¦GŒ”³k—yFüD¢hÝü¥Ç’?ñ3%VÔ‘3¹8ôœ‰JÇÒMŠO³mËi—±»ÝÇÎø”ZÁ’à½s¬æxqÑ·ºc¸šSkæcGÊçÈt/¬)èö¨ÎwTع”ïK7©o¨Ñ¶å²KØÝn}/ó•Í_ 뚃ߋ9Oüáe\áê`½u ó\)Îä&2Éï#\0cMA7ž6çŠõš±±ÞZºIQ7Û¶\v »Ûí5ÌE'íŒßõ½sÆW;¹Ž(pXÃã‰_ò1å5L¹S>×(maM~‹Éé1f'¶á#²îæ·˜mK.»ˆý°Û}¬AÃy.}/æ\1Úµ«ci5Ǿ¹¤·¶ò|ž¡åœocEA·{$8°.±N¿uƒâÓj[rÙ%ìn·×ü÷š×cÉ™‹¡‰égŒáP±ÜpI}ËCÀ(+ùfbE5¯Ç’ƒ×“X¼žÔ]¼˶%—]Âîv»5t‡×ÿ½sNŒêó·;Í@ÂüíŽÓÔ·VÕpå%¿cˆL¬¨–_—9Óžº°%ú|ê.ùu¹mÉe—°»Ýš÷ç=æÝJÌnï3g¡ x¬øæXè“Æjææs@ÊoH¬(èæÓäT ÍÆV ÍÖMŠO³mËi—±»Ýü[ÆzŸCxoŒ+†Ë9ÐÌß ž»¾n U"¢­»Æ¯oi‹#œ hÅ£b´d«±6³Vp‹Õ&¶¸[õ‰-z Ôïs᳚cöœ›â7Œ˜cDíª)NÇó')K^c^4ÖtóiqâÆÄB­žvÛ”Û.b?ìæßòŒøéb¤SÌŒ>wüÊ1ÖE|k.…ÚaÊáñ,9z IµŒ™S¸lö@|˺‰n ä‡É~#ëåç‰8Ô{qÚl%‡ùÍÆD;‡ ÌÇ1)ÿj!°üÁ$n,(éæÓâÜÑ[„ðoMÝ¢ø4ÚN¹,v·[Ëôjâ÷ëX˼wÎCèç„gݹ2š~N­¦8àW-oÑ{Œ5ÕíÚ$§Á›5¶„Ѻ‹]›l›rÛEì‡Ý€Ÿš®¼¬æœá~D¤öˆwYžN|d—y.:è’:ïÂŽtõýôHwÿZØ“[ê.žF³mÉkºó×ÏìÖßr3€:—}ïœHãÕ.ð±¸êñÖEq9uEÏHù"±¢ ›O‹Óñ ŒådÝ ø´Ú–\v »ÛíÉdþ™}R},9Oô„4¹]R9ü‡K½œ£ºÂ“°!ŸÄŠé>›sa(%¶Æ IÝ¢ø4ÚN¹ìv·[ßKD¬Fè¡Å—9tžæÀ:=ªÕE p¶þ4SèÓÓî5ååÀ×*¬©ò’CçÉXŒE©;‡¼l[rÙ%ìn7ÿ–Äû«±j~oŒ¯>q…ؘSØ…p= Ìv7V~’Âñ0N´âQ1Jtáæ ø¤Vx”mJ*kˆÛmÕ«ðñï‘KG1¬þæ|öçÀÂp x@‚žÓ¿‘¥;Gbä¢Q ,u…‹ù9µ’à£hÓRZ#Üf«w°©Qçœ3å÷Î)Ü I7|Œf(Qܲ9bD±|®ìÎ…5Ý|šœ9}Äç)ìœ>ÆÒMŠ“'Û¶œv ûa·GÞÓÍœŒµ}šœ˜§`~œS91Þ=‡)ŽŽ‹ÉO:ÁŠê^$ËÉĬ‡­»8x‘mK.»„ÝíÖåò&†"+f`/sŽãF¨l椭[v`£YxA‰L*7v“sÆ€•Xì¨XuwTÅ S*“ü0ØÛ¦¶…ÃPß2“V™þü»køô/mdÑ­<0ÆöRø`³£Ä¼{2´OÊ[SáÒZNw×XPÒͧÅp.ˆ­‚¸Ò-ŠO£í”ËRaw»íƒÜHn‰}K ÃæTF^¤»Dº\ÄôÇE¯¢aûÉòŽÀ§±¢Ž†Å‰}ÑšØùK7){,Ѷä²KØ»K¹kC±qZ<1§£bŒŒŸ¿GÝŽ±âUÏ’ÃMH¬¨’s`fvà“µî‘ƒƒÛ–Üvûa÷ÚïLÙªkCìÃÆ6ZÀc‰ÊMs$xò†üu-9säŒÝÞWÊ×8{#lݤ¼…w=)—]Â~ØíÀ<öêáã;0/"ɱ¿vk#ïÆÞ[ÄÕH1xެ‚”_©+ ºù´8…;jÂbË;uÑtÛ’Ë®âݸkÓÍ_fºÌ_²)!Ò8øØŽ-ˆ7¶j#는·rŸ;å99š*¶ÎœQ6ccù¶t“¢n¶m9í2v·{æ£s”ËÉÉA^‚¯'‚†õfðµ™b¼Þ[Ê÷I¬¨Ü^IÎ{@‰Å¦GêÎí•l[rÙ%ìn·â-†¶J5~.fܱT/º`[pŽ7‘‰ø˜Pü!Þ…¤öH„1œ¿aÆëYál—VŠ? ðE©¬!n·u…cØnˆÈ¾7ÎìÃÀádÏÞé.ù>¢Žw`9r…KŠºgð;=Àgé&å0p´m¹,v·;S#Õb:kãqêàA_n63?´H˘nÞì¼ó;‹ , ìfÀ{°KVãD4/?̨aœq%þ`kGÕ&¶¸[µÅÓ"ŸcœöÌ(1Ú ä‘Ô9&Nßl:g1†n$¾IúpK›¸ÇûÛ °‰ÁM`á*"%ÒZs“UmJJk„ÛmõNû.3¼: PæÜS ìÝÄ£zôóa*÷ÎÏ”‡Ÿ·°¦ ›O‹sb}/ld.ݤ¸—Ͷ-—]Ä~ØíÀõÐÑ@Å{çœpñ#aù¢ tbv;º)†k*—‰’á6ÖTFE’ƒÌÓÄþÒ Š¹Ú¦Üvûa·þ–¹Œ‹uÄY2cÛd–•Iñ‘3;R×”0RÜu­Ñ RÞ¢Kkªäöƒ8™eÆv˜eݤð´Ú–\v ûa·G+$ ‡‹ó(3Eœv0 ¹Ì®nvA2²(/#¦e9™KŠºsŠ.T‰CD]ºIñi¶m¹,v·[“à@âm3 šÅ™+¶xÁ³Ï"›Á±~ Wýkº’Ïp,¬(êþV\l[ó’nRxZm[.K‰ý°[K¬#¼+;&æ4ï\hs(é#Ä*‡Ú{÷é$¿á˜+ª¤cbÎÁ]b#ãoé&ŧٶå²KØÝng@ÂxóôÉí =9ˆN†3˜¯§¤•z˜B{²)o ikêö„žœ IM¶'ý¥›žVÛ’Û.b?ìöÐÕR¬ÚˆãbPÁš{8¦qZŽ#¥GâÌS—œ“A.­ŒÍ><ÒAФH§©Ô‰՜ޗœcbQP!u—ÜsuÛ’Ë.aw»µNDÒ`ä))ËÆ dð‹‡{C%¯¬fŠÕ@ @ yÄ™8½§fFSPòàÖU[Z«“kÜ&¥²†¸ÝV»LF=p,þ½s*Zæ8bAë¦ìºÝuÉéP+êð7+N$6uCŸtó"íÄ÷ò‚,…MÆí&{Û ^Vðò¢Ä ïA›‚= þöCäéÌw`_äÁØÛ7,)êæÓâÜ<„0Ò×XºIå†ã³ä²TØÝnͦþxKüÐ͸b4¿y°»bâ™_"NGN¸b<…0àLœ™L&F‹@°q5"YÖZ3u›”Êà>luÆÀÀáÙŽ”‚÷Îáyá¹nîÜà‹³Ä—RCºó‘¨s¥9ÈÑJìÁ é>2ˆá¶)·]Ä~ØíÀ\E÷ĵ÷ι°#saÃ<ùWx7'²ÁI14}áK·üFDÎXQÝÓMrN†[áŽYwMwÍmK.»„Ýíön.²œÃÍz䆘Ó[j;ááƒ,8ÊiÊû³WKyì%/¬)èæÓÅžNY{až·nRÜÍeÛ–Ë.b?ì^AyïdŸ”§`A6—Ø®äQÚÒxúpµ-']aÉá´%VÔáOÙœ 9c/¼Së¾ò»mËi—±»ÝvC°&ÃytMìæœ±®B,Ï:Ï œ8ü$ŠŽV€)ǨĊê™ódN‹ù,±<åcÝ%ÓžÜ6å¶‹Ø»WB]œÖ8Noí&Y9‘Ôv2¶Ù¸žP²‹Æ¬ž%o1ÉkêôÖnrè‹DæÔ]Ó]sÛ”Û.b?ì^¹À‚kƒÁeÖB™MaK¦h]Ç»¶¹L‰%5ÖAYsô·vg‰ÜK÷XeÕ¶å²TØÝî”oT»åë@= rœ<˜« <=(½ÜòŠe¼°¦ú”¹â‰-ÊCwÙƒòh»8(ßöÃn—PjŒ¯“ƒ€2GÌö‹#x³­(ÌÁÀ”câN¬¨â5¤9:±ÇÍ ê&ŧ•¡(ys ò¬?³Û}¬D ’ŠóÍÅéüQ*Ruš’D‘¶’Dcý~.9‹j+j|0§pý.,Î#¤îuòÁmK.»J®ý7ÝÇz|´JxïžpŠ]¢ŠÔŠù.#Àq¦8c`‘òÅvŒ•ÙÉ)˜ýŒEr@ê΄l[rÙ%ìn·G¼¤˜¨T>ÍœÎCÍ1éÆ ;j¾ã2ÕåÓZx¡Ç’_ø %ÕÖv„97ÓÄ6lXw[ÛjÛrYz;´ylº=ŽLWT‰˜ä`S3ŒÓCj1åqlK~Æ4œXQÝÁÑä Û:±‹ë.N1ʶ%—]Âîv{;½¨rÉÁ:;Æ 8Q˜”cd¹S Ç+üæÑQaM­¢äĉ¹øˆíÂ’ºE9,\Ë’3H'ì‡ÝÎHkèÁÌWxµnœ–àN›Nê÷ÃÆš9-ÆV­åwâ„Uý^’s8 >°Ó…jK7)>Ͷ-—]ÂîvËý:™1rûH™ÓEjpx"öÁ^̽Wp”ã*ƃÝWáDP«<50F˜+Ü2]ÒJâ›þ_´)©Ì#n·U¯"rÐ ²)›r ̱$ _-²?;RGÂS<Š)á:Kùƒe‰±¢ ›O‹ÓqJÒX䡦îæü‘l[rÙ%ìn·ó"“c`Q(Õœþêƒ:M1~Þ<“RÏ:€ñ5Ô¾äô'ˆM* %i+‰EÚJêÎhÙ68ikû}Øí³&Ì}.Z’s3ùÄ:ñÑùNFŸÜ팗\Ç’+]WXQ×r<ÅщOa;󨥻/ÇSmK.»òìè±éf´…ÞE¬´3çb­/ú"›.q<¿›bD»‰)gþ¾±¢z 0¯'±Õqï³›úvÜç\rÙ%ìn·§„^"šÜ|Ö„œÊòQsž!¢âXgi‰¢»×9X?êÞ°¤¨›O‹Ã*ÂÆÅÒMŠO³mÉm)±v;\ÑÜ“³\–ä4$àËkZ% •.ìvYb3¡ô%G^SbE»,É9à… ¹ÎK7)>Ͷ-—]Âîvo.¾JVŒå✯ G!Üìˆûsß5ÜðbÊ.~dÄH.üšù^Ì9á‹©'K7©tñë’Ë.b?ìöTs…Éh>¦,Wª77ð¯qݽT'oTÿJ9ú|bEÕL7yÆÎéïZºIyÑ®”Û.b?ìö÷‚ìÈ`tÉ86‘zr±dÂů'R™Iñ·+¬'ye]=bMå®Er +¬ ˼`ëÎ]‹l[yò‹Ø»3Ç#æ+§J30ÛÂÊ8˜cs¬˜@”]eJ¹‚NDN’f`ž3S µæ é6)•5Äí¶® ìØª˜Ÿëå4[q.¼·Mcj<áy7SÞÀŽã·–_Ht0VTÏgNsöo£ðlºK¾8·-¹ìv·Û+È‘õ‘4=šÃÃwô"H[±Œ8RÜ ä[–¼pïPXSÐͧÅA~Ab‘_º‹ eÛ’¿Á£ÿÌnGô°Ý‰“šÅ@ÚW¸óƒ|.èö@²Z.’ö”^¨‰#‰ž 1*csÄæâRkÉ(†Ú,Îò- ·ÙêWq°ÜÍ‘+Hs0xĦáÍ]06Q|Ë+È£³ÎŽä—kð+êȤ8AEc b¨ÖMŠO³mËi—±»Ý^uYf@YÂæÜ,Ëãõqq]xò8ËÃ1Fò‡Ç4„55²z«9§ ûÛ]ô×% œS¬¶%—]Ä~Ø­¢8t>’öâÍÀ£¬çóãu6ì“€·£q–¢Lq"ºšfàšq8f­Å«L·I©¬!n·Õ¹jÌž·+&™s±¬iAmñ(t1³ \…k-7•¼"r`¬¨s-7ÌaYSaO3·nRض岔Ø»}¨ukc™w)žjŠÿÇv¨êv4V'Eªys§rªÛјãwnXQ‡;½9õŸÀ³t“âÓÍu; §]Æîv{ÑØ9ºu—«L¦èX¸ Î<73LêaÊ‹Æë^r[3VTwd!9¼áÀXlÛ¥îâr•Ù¶ä²KØÝnçxp S¦PÅÁ†âGœEâø…¢µ¤8kqµ(y„»ÖT÷¼N4–ɫֽ’[ݶä²+Mޛ˜ØëE£8QLs`aws…E!«ö“r$.†JËÑÃ{;i8â .‰­, *ݤ¼ Uòïu/K…ÝíΘ ²rZ-ÞÞÐH<Š”‘ku5 ””bƃàšp&š‹r˜{ãàBYëá]f·I©¬îÃV‡é ®Á`ä÷Ρ7ÓqG"CåÚë*¥£ÜjÊ/¦ä {9A¯ûiqhˆ°½3ÄOݽ¯-¶m¹ì:½×U7ÝôÝoVëY‹Äœ‡5rXu&v9y\yœ¦ðêÖ”7„?„55²‰9(ŸblÔ¬YºIÑwWÅÊm±v¯²0Ø1ѾwŽ ¼  Sì– –7 w‡Ê›9€’ÕN¬¨áÓˆÉQ™a;ËŸJwÏ[Gܶä²+KÄ<›nö±Œ’œª¶i#qå’áÛ lÞÔnŠýàÆqËVäVt{+èaÌåx«H\ÏÌ=²ÿŽsÉe—°»Ý>ŸÑx^ðòY“ä ÀD¤™¢ØÃ¤Ô‹çxŸœŽÏÁÓ‰’߈W+*k¦&iM‰E%ÓÔ5S³mÉe—°»ÝNg©áÄàp;Eœ†j¬hCR„>/>"…>—¯%ø Uò$Œ9¨Íe,ãÝÖMŠO³mËe—°»Ý^Ù³2oÔ_öÁqrZñZ=³øLy0ÙuGC–³!cEQ7UâÜ<üý8gï^ºIÙPΟ–?v·ÛS}ÑJ׾ﰓUx>€NVcj,;¾ÃNVãá€sáH´ôz‡¬2wÀ§•Ö#]^µ)©,à6[s1œ±æQØ ³~èžHN|X¦Œ¦9K$EI$ãD4¿f0¯Y8ÔØ´ÖâÁ×mR*kœ]7­ŒÌ?ÜÝ%O_šƒ“´/oÌaŠÒôÚD9ÖÞÊ’Ã{N¬¨’KqÆÃcmÄÎV[ºIñi¶MŽí"öÓîuÂWKÚ~å ßÊeb¼ÊYÄ8 È@°ÏªÝ­5Ë/Tt5ÖÔå%mr:&rc¹ŸnÝ ð´Û–\vûa·ZðsboXIÎfà”kì¶Vì?Ï‹›±"¾¹&Ã}”2Š)œˆ¬Æ)FÍ" v{ÎÔZ³§Ú””Ö·Ûêk3HŒ‚ôš8Ìá@ÐxಠYܦ¾µ,‹—–W–$&ÖÔ•¥9J#ViDÒÝÒ£tÛ”Û.b?ìö`K¾cðÞ9§‡À­µƒM#<Ðs¹ÈõòÂЂ°¦r¹‘œ#eb çé.ޥ϶%—]Ä~ؽòT”.¦ª6ɹ¸ìoÓc3óÃcÁ}›ÊÅüHya UXS#Á›ƒUº±Sk¤›”óõXò¥ýÌîu>Òqdú¾wnŠ%ß`e ܹÊb™OVЊ¯9‡,g¡McEù˜Ó™d+,]2ënvz²mÉeWw‚î¹éÆßÒ°{‹4ÕQJÎå;ò´YØY'õ8L1d‚³û)Gn`bEåE~ÉÁNIb+¦Dë®^SdÛ’Ë.aw»×r’[†ªƒlâ([ÿÄqÉ·®‰Ðr²Ö”ò˜€p"òÔŠø…ëÈL—Öž§VÔ¦¤²†¸ÝVw+„1qòÔS 9'|ÖÈÍŽ=¼8}:PZ=¼ RÜ6ãUòÂ¥¬°¢¨Û›làÜ\;»—nRìVlÛrYJì‡Ýëy\ÑEIj6•ËàÅȱs»÷j½R©ÉožÐÖÔ‘§¯Ä™ý)vJ„ý©-ݤ8±mËi—°v«[¡`bä(i¦#N!៬xw£7ÄúJ̶’ÖH!޵*Æ;¸ÅwÝÆEWK­$ð(Û”Tæ·ÛºŠ¾ÝÜVöQLsšÓO#ªàÄ î@)¦ØQnäSJ7ª,¬©<“ÞP(ìÁ«¥›”7…ºä²ëÈ—7ÝNåŠY’W¾7¯3Œc„•»Q—*N)œ¦hÆË”ó|‹±¤Îe9\Ò ·`.ݤø4Û¶\– »Û½R¹*/Þp 5sx]¤_8¦ZXåêé¦87ŒC–w^Ó!l÷¥.¡foÀ0sêÎrSÙ6å¶K÷Óìv¯Ï}ðPËyç竜V.9yåÈ@ü]T~îGÊg/. kªåUæðcYåÔºu‚Ú–\vûa·Ožñ¢¡–^}rn/Bvþà 9ZÛ©=1²|`½m¬©ôê“£:ŽÂòh¹u§WŸmK.»N'Û”M7WöE¥péÅ{ç°xQiYÞ*FÄëbyªu¬5ÎÅ%G]ÊÄŠÊ6’Ó¸Q.,.ÀHÝyÉF¶-¹ìv·ÛA<\Ò„ãxŠP˜sñÒÜ„£|*Vü˜bºO´X®OaE¡0‡ñc+SÏ¥»f„ÂmK.»„Ýí^©Â¸Ö YÄïÃÛ\_‰«`xÑRlO“ò*‹SÉ;Jº+ªÛïHNÅoklÁµ¹Ö]|Ú0Û'íöÓîm‰ÃH}Ø«OnÝŒ—X¸j;¯t$åhK©KŽÄ÷ÄŠ¹ÇnÆ9c;kBH7)G[ʹä²KØÝnG(x¯O¹}*(9¼©’5pÙeaÌà6å}iÜ*9Òš+êöFkrh¶°…÷ZJ7©oÅJTêK)v·{ب(.ëk²Èˆ“#_G\=tÆYDpÌ|¢³J:Ø+q$¨ÕC7 ”øØO­$¾5'ôšRš'Üf«§zž£ä¹á÷Îay骛¡XÌ¿25ƒÞ+y+Ü+SijQGæa‹3Tš:o—=—nRœêÙ¶å´KØ»×n©’îµ[ .2Œn[È‘–7Ð㔩üDž%çöµ±¢ÊÚÿG÷/{Ò–î3—nÛrÙ•w7›n:Œð„#œtøî[å8åÙn§ÝÅ¡Â.~:tî²ä @bII7Ÿ‡µ:ˆìþ–ºEÙ|aÉm)±vÛãzXtòÈRîæ Ü€*yÆŽ"z¸G—¯Íî÷‘5C+êÈRîâÜ*«G,«X7)>Ͷ%—]Â~ؽn:ÁQÕÇsîÂO¬"Qà®ôzX+Ô·F‡ó\ò u!Œ%EÝþ”º––ØÉ|–nRž÷’ËRaw»øª¼*¡g­+s¸"o(çXÈh?Y—m¬Œ÷‹u$‡“XQ=k]™ÓXNVX®æ­;½ìl[rÙ%ìn·÷ëÖB*yÈÜ•½VNê\%`S—|ØÈLùÉ‹"„Uò¹9c)ÄFœté&ŧٶ䶋Ø»WvAc¯9Ff4æ/œ¼/÷TååÞ1L9»à<—|° +*Ϫ$ÇŒHk±î‘gUܶå²KØÝnŠ;Ké^¾d59ÜìÈôÅÇŠlJ‹u:]T§)×EaM]«V¤8ôÂŒm¼þtll;Ìw±°ÿvÃy™¯iaó>±úb!Õ÷‹TãyfüÖ?“]d1©MÁ›Èn“\äö@䦟=¹?ð ', ¹= ›üÀnâþçoóŸo?Eäf\QÙlú4ø…ÿQ0rb¯?òÆÿ(:èçÀú_ùßüþà;ÿ£à8xp=ÿÞK×ö£üu8˜Ä>ð5iýþ&ÿéÅAèÿû#Ô¥›¹£aÞÿùß¿þOÿówÿýûŸþìõ›_ÿYùÍàO-ÌF»yý·ºjêš–¿ö¿^û1°Ï/ã_þñõ÷¯ß­ñµü?Œ¯<¦þðþªªX’9,ÔÁS9±¬{˜ÍIš¤˜)tDŒÄòp„ÖÔízQÉá6¤°×ÉËD¨›žVÛ–Ë.b?ìvFUÃóí²s™^ÍÞpƒedbD¾Lcz)Z‡s¬)g*б¢./’ƒBÖ‰åëÎ2ÙÙ¶ä²KØÝn—6Àº6öMª’ÍAŽI”°°7–uóiqPzÐØ‰+ÖMŠO7׆€\– »Û½2D⣪Ý›îc¥{«íÃéÞmÃîvûo¹y Àe‡,9¬Œ\x>úf”»&ùßvÈ¢;÷’3×ÁXQ—²ä0ÊmlCú›²l»ùîØga?ì^Y®1²Ü¸wô½qžâˤ#rø0ƒ¿ã°ž(~Ÿ‡—,Ç!BcEQ·GŠÆ5H}{óÎTé&õ­Q¨Œ”ÛRb?ìö˜Ì|™zæÑ(sè·rÇ7Ó¼àøùkF죀LôiÉ›êk*#öÉi¬-luÎñÓMQ·Ú–\v »Ûí÷¢ìyïÃ2AW÷ f55Ý0º²ž"n–wÝWJ¬©š'ÖÍ9øÙ{=žYq×È“'ÖÕ¶å²ëð'Ù7Ýþ^Èuz/<9J…|˜öucšZއ)öiìT¤\3±¦Î<ÊlNcbƒ°LØ´îšW/¹m%tÊ.b?ìößÂÄšÒ3Øoª!DÊgç|uެ÷TÖa'Õ„²\…C„µ;™ƒj ‰­<{#Ý5ƒýn[rÙ%ìn·ÿÞÝ«¯6NNǯð²اP{6S™Ž²ä¬Ñc¬¨ê°mr ß"±  ÖMŠO³mÉm±v¯êð¸É2Ëš$§ñþ«ÇgÙ#Šڢø}VžÁ—œ;Ôšʲ&Éa²°ƒIÈÒ=²¬‰Û–Üvûa·Ç1Æ‚žáœ¤äܼUìá…{øÖì§)~Ÿ•%’ã9cMì5æœL¡¶c<·îžã½Û¦Üvûa÷ZÃvŽs­aÀá4|5¸¯\gàÈY^Á…uȹäülŒ•Wp%§óÒ_a+/ý•+Û–¼ú¸°»Ýk£OG¿KÉ>pPß4>„‹w¬ÅXGœM”7ú®sÉRVT_uÅAÉáÄâÒÔ]ÖA]µ-¹ìv·{•f‹‘ðȼ±äð´BUîòÂpdæ0•É“ò88³°¦23+9¸÷HØèŸgêå¹R…Ë.aw»×ßßudÕs®ümæ+½Y ®\¦¾×וrþîÆŠZ âœ÷ÖçqÕÊÒ}®ŒµmyÏk\îŸÙí>VéLWGȓӘ‡Ùì^kh®ÅûÁŰ€äƒaaEÕôHÌA.·±‘Ѱt“òêm´%—]ÂîvûoÁYýX^+û89ôúÅk 8v&¡’ò Éã––…5uz»+9,fló¡â£›òïtžK.»„Ý펿åßc‘s0¼Kì ó ÏÀî¼GvðÜKÖà#…碜Nÿ“ùlX µ¬µ]ÿ-?{äÃ6<ò·?þ/QŽåü endstream endobj 66 0 obj << /Alternate /DeviceRGB /N 3 /Length 2596 /Filter /FlateDecode >> stream xœ–wTSهϽ7½P’Š”ÐkhRH ½H‘.*1 JÀ"6DTpDQ‘¦2(à€£C‘±"Š…Q±ëDÔqp–Id­ß¼yïÍ›ß÷~kŸ½ÏÝgï}ÖºüƒÂLX € ¡Xáçň‹g` ðlàp³³BøF™|ØŒl™ø½º ùû*Ó?ŒÁÿŸ”¹Y"1P˜ŒçòøÙ\É8=Wœ%·Oɘ¶4MÎ0JÎ"Y‚2V“sò,[|ö™e9ó2„<ËsÎâeðäÜ'ã9¾Œ‘`çø¹2¾&cƒtI†@Æoä±|N6(’Ü.æsSdl-c’(2‚-ãyàHÉ_ðÒ/XÌÏËÅÎÌZ.$§ˆ&\S†“‹áÏÏMç‹ÅÌ07#â1Ø™YárfÏüYym²";Ø8980m-m¾(Ô]ü›’÷v–^„îDøÃöW~™ °¦eµÙú‡mi]ëP»ý‡Í`/в¾u}qº|^RÄâ,g+«ÜÜ\KŸk)/èïúŸC_|ÏR¾Ýïåaxó“8’t1C^7nfz¦DÄÈÎâpù 柇øþuü$¾ˆ/”ED˦L L–µ[Ȉ™B†@øŸšøÃþ¤Ù¹–‰ÚøЖX¥!@~(* {d+Ðï} ÆGù͋љ˜ûÏ‚þ}W¸LþÈ$ŽcGD2¸QÎìšüZ4 E@ê@èÀ¶À¸àA(ˆq`1à‚D €µ ”‚­`'¨u 4ƒ6ptcà48.Ë`ÜR0ž€)ð Ì@„…ÈR‡t CȲ…XäCP”%CBH@ë R¨ª†ê¡fè[è(tº C· Qhúz#0 ¦ÁZ°l³`O8Ž„ÁÉð28.‚·À•p|î„O×àX ?§€:¢‹0ÂFB‘x$ !«¤i@Ú¤¹ŠH‘§È[EE1PL” Ê…⢖¡V¡6£ªQP¨>ÔUÔ(j õMFk¢ÍÑÎèt,:‹.FW ›Ðè³èô8úƒ¡cŒ1ŽL&³³³ÓŽ9…ÆŒa¦±X¬:ÖëŠ År°bl1¶ {{{;Ž}ƒ#âtp¶8_\¡8áú"ãEy‹.,ÖXœ¾øøÅ%œ%Gщ1‰-‰ï9¡œÎôÒ€¥µK§¸lî.îžoo’ïÊ/çO$¹&•'=JvMÞž<™âžR‘òTÀT ž§ú§Ö¥¾N MÛŸö)=&½=—‘˜qTH¦ û2µ3ó2‡³Ì³Š³¤Ëœ—í\6% 5eCÙ‹²»Å4ÙÏÔ€ÄD²^2šã–S“ó&7:÷Hžrž0o`¹ÙòMË'ò}ó¿^ZÁ]Ñ[ [°¶`t¥çÊúUЪ¥«zWë¯.Z=¾Æo͵„µik(´.,/|¹.f]O‘VÑš¢±õ~ë[‹ŠEÅ76¸l¨ÛˆÚ(Ø8¸iMKx%K­K+Jßoæn¾ø•ÍW•_}Ú’´e°Ì¡lÏVÌVáÖëÛÜ·(W.Ï/Û²½scGÉŽ—;—ì¼PaWQ·‹°K²KZ\Ù]ePµµê}uJõHWM{­fí¦Ú×»y»¯ìñØÓV§UWZ÷n¯`ïÍz¿úΣ†Š}˜}9û6F7öÍúº¹I£©´éÃ~á~éˆ}ÍŽÍÍ-š-e­p«¤uò`ÂÁËßxÓÝÆl«o§·—‡$‡›øíõÃA‡{°Ž´}gø]mµ£¤ê\Þ9Õ•Ò%íŽë>x´·Ç¥§ã{Ëï÷Ó=Vs\åx٠‰¢ŸN柜>•uêééäÓc½Kz=s­/¼oðlÐÙóç|Ïé÷ì?yÞõü± ÎŽ^d]ìºäp©sÀ~ ãû:;‡‡º/;]îž7|âŠû•ÓW½¯ž»píÒÈü‘áëQ×oÞH¸!½É»ùèVú­ç·snÏÜYs}·äžÒ½Šûš÷~4ý±]ê =>ê=:ð`Áƒ;cܱ'?eÿô~¼è!ùaÅ„ÎDó#ÛGÇ&}'/?^øxüIÖ“™§Å?+ÿ\ûÌäÙw¿xü20;5þ\ôüÓ¯›_¨¿ØÿÒîeïtØôýW¯f^—¼Qsà-ëmÿ»˜w3¹ï±ï+?˜~èùôñî§ŒOŸ~÷„óû endstream endobj 70 0 obj << /Length 821 /Filter /FlateDecode >> stream xÚUKoÛ8¾ûWÅh bH9ÑvÙ¬ôVÀÀ²9(¶b«%¯%7í¿ïP¤${WÙt 9üfæ›GwëÅíJ»Äq‡ “õK"¸Å,Ac¹“¬·É#{T7OËT çÒ*…`*žåòiý)I*%wfÀÃ_ðúoñúM¼šÅ›ï"ÞÆ³™Å㈇9üíÊè‹xmÇ¥µAûçej”aÝ©<íþwaĶ»ñ2ÍŽ-gCŠJǦ¬;tñëz! /9¦[9Å3›l‹?‰\lû«A- nÜ7‹Ïô Wé`2lÞù2•‚ê²Î ×&Fª8•UJâýK^Ue½‹ÉKM‹Üi _½Ê¶¨òs¯#ôʉq< ¯e·Ÿ3‚£ÊTsìʦnìEYR‰–kai“qȲ€ÿm™+–©–Žmòš6J°ö|ûù!g¹¥>¿œWÛN…͇4L¸± » ·ñ}|·ÊßýÓ<Ñ CSýäÃm—’ :*ŸáJ¹8|cíåS°#¸°4 éBf$ J+GdVƒÊÌ(0ä µÐÂØQ&ÐY#”˜´’)À«(ÿvò¯5:# ŽþfZ« KŒ!cÙ(äß:Î\ÈP§¸œ¶F91S¥t&%ÿ·Tõ*U]”»=±nΧvª×õ£EÇÑÿjhæÄ¬‡ÜЧýÅ endstream endobj 67 0 obj << /Type /XObject /Subtype /Form /FormType 1 /PTEX.FileName (./qhull-eg-006.pdf) /PTEX.PageNumber 1 /PTEX.InfoDict 72 0 R /BBox [0 0 432 432] /Resources << /ProcSet [ /PDF /Text ] /Font << >> /ExtGState << >>/ColorSpace << /sRGB 73 0 R >>>> /Length 891 /Filter /FlateDecode >> stream xœ­W»nTA íïWø ̼-)"RP ª…±H‚ßÇc{ww£\" ˆŽ}ŽÇc{| ÷`á;8Ì\­üúŸàçöæ÷Çwoáîq3hŒõÿÇ»dÍþlŸ¿€¯›…{ú÷}³ï7—#ÖÎz´Î`KD_ Œ~1¦ø0°1£-Ç(ûÔ„â"Æ.T õ e—ÛѪ\\èšq™ìæxÕÃ`Ê7cü;ãúŸ"–>Y,ù™º^TäÿPn”Þå‚!ƒóë3 ¼¢ÜêΞrkf_b¥—K{É8äÖ<^4èÆŒìUƒvoù¹éz\-454–ÞñÛ¤$Ë”´Ìô§V´¡Uı…-š Zx]håÌØ‚„-gw¿äÕµkÞ:cÅ Ÿ¿¬šDê%=;z\Þ‘Æ…'ˆç =>3ý´¬­"Ž-lµ$.ÕÒ|º[°åìî×¼T»æÝßKl]ïëyµPQh sjGE£­1–9#™éŠ5?n§¶#ŽÝ³kÇ/¶ku!hlA[Îî~É«k×¼õ½$z<óûºZhj"Û\ÒØ~èטÏtÊèÃôŒ‹VǶZL[½]KØ[°åìî×¼T»æÝïb±Î_[VKi“ÈK¨¶8>ðŒä¼Ô¾ßÛ×jhqìqóf¡¢š©åu5b3:õªÚé×¼T»æÝîò°ýð … endstream endobj 74 0 obj << /Alternate /DeviceRGB /N 3 /Length 2596 /Filter /FlateDecode >> stream xœ–wTSهϽ7½P’Š”ÐkhRH ½H‘.*1 JÀ"6DTpDQ‘¦2(à€£C‘±"Š…Q±ëDÔqp–Id­ß¼yïÍ›ß÷~kŸ½ÏÝgï}ÖºüƒÂLX € ¡Xáçň‹g` ðlàp³³BøF™|ØŒl™ø½º ùû*Ó?ŒÁÿŸ”¹Y"1P˜ŒçòøÙ\É8=Wœ%·Oɘ¶4MÎ0JÎ"Y‚2V“sò,[|ö™e9ó2„<ËsÎâeðäÜ'ã9¾Œ‘`çø¹2¾&cƒtI†@Æoä±|N6(’Ü.æsSdl-c’(2‚-ãyàHÉ_ðÒ/XÌÏËÅÎÌZ.$§ˆ&\S†“‹áÏÏMç‹ÅÌ07#â1Ø™YárfÏüYym²";Ø8980m-m¾(Ô]ü›’÷v–^„îDøÃöW~™ °¦eµÙú‡mi]ëP»ý‡Í`/в¾u}qº|^RÄâ,g+«ÜÜ\KŸk)/èïúŸC_|ÏR¾Ýïåaxó“8’t1C^7nfz¦DÄÈÎâpù 柇øþuü$¾ˆ/”ED˦L L–µ[Ȉ™B†@øŸšøÃþ¤Ù¹–‰ÚøЖX¥!@~(* {d+Ðï} ÆGù͋љ˜ûÏ‚þ}W¸LþÈ$ŽcGD2¸QÎìšüZ4 E@ê@èÀ¶À¸àA(ˆq`1à‚D €µ ”‚­`'¨u 4ƒ6ptcà48.Ë`ÜR0ž€)ð Ì@„…ÈR‡t CȲ…XäCP”%CBH@ë R¨ª†ê¡fè[è(tº C· Qhúz#0 ¦ÁZ°l³`O8Ž„ÁÉð28.‚·À•p|î„O×àX ?§€:¢‹0ÂFB‘x$ !«¤i@Ú¤¹ŠH‘§È[EE1PL” Ê…⢖¡V¡6£ªQP¨>ÔUÔ(j õMFk¢ÍÑÎèt,:‹.FW ›Ðè³èô8úƒ¡cŒ1ŽL&³³³ÓŽ9…ÆŒa¦±X¬:ÖëŠ År°bl1¶ {{{;Ž}ƒ#âtp¶8_\¡8áú"ãEy‹.,ÖXœ¾øøÅ%œ%Gщ1‰-‰ï9¡œÎôÒ€¥µK§¸lî.îžoo’ïÊ/çO$¹&•'=JvMÞž<™âžR‘òTÀT ž§ú§Ö¥¾N MÛŸö)=&½=—‘˜qTH¦ û2µ3ó2‡³Ì³Š³¤Ëœ—í\6% 5eCÙ‹²»Å4ÙÏÔ€ÄD²^2šã–S“ó&7:÷Hžrž0o`¹ÙòMË'ò}ó¿^ZÁ]Ñ[ [°¶`t¥çÊúUЪ¥«zWë¯.Z=¾Æo͵„µik(´.,/|¹.f]O‘VÑš¢±õ~ë[‹ŠEÅ76¸l¨ÛˆÚ(Ø8¸iMKx%K­K+Jßoæn¾ø•ÍW•_}Ú’´e°Ì¡lÏVÌVáÖëÛÜ·(W.Ï/Û²½scGÉŽ—;—ì¼PaWQ·‹°K²KZ\Ù]ePµµê}uJõHWM{­fí¦Ú×»y»¯ìñØÓV§UWZ÷n¯`ïÍz¿úΣ†Š}˜}9û6F7öÍúº¹I£©´éÃ~á~éˆ}ÍŽÍÍ-š-e­p«¤uò`ÂÁËßxÓÝÆl«o§·—‡$‡›øíõÃA‡{°Ž´}gø]mµ£¤ê\Þ9Õ•Ò%íŽë>x´·Ç¥§ã{Ëï÷Ó=Vs\åx٠‰¢ŸN柜>•uêééäÓc½Kz=s­/¼oðlÐÙóç|Ïé÷ì?yÞõü± ÎŽ^d]ìºäp©sÀ~ ãû:;‡‡º/;]îž7|âŠû•ÓW½¯ž»píÒÈü‘áëQ×oÞH¸!½É»ùèVú­ç·snÏÜYs}·äžÒ½Šûš÷~4ý±]ê =>ê=:ð`Áƒ;cܱ'?eÿô~¼è!ùaÅ„ÎDó#ÛGÇ&}'/?^øxüIÖ“™§Å?+ÿ\ûÌäÙw¿xü20;5þ\ôüÓ¯›_¨¿ØÿÒîeïtØôýW¯f^—¼Qsà-ëmÿ»˜w3¹ï±ï+?˜~èùôñî§ŒOŸ~÷„óû endstream endobj 77 0 obj << /Length 233 /Filter /FlateDecode >> stream xÚ“=à …÷œ‚‘ ¡c¯•š¡3[”­êýЦÁéPèd!ð§ççÇ9w§)Š'Øä»D—x4LÉ$“of¶ó ËÒ/ùj¼œ^ÀÒàÉÛØÈ´ž£ØQŸtŠ ˜W;LüÂìlp@9¡ÊQLla¶¶‚u-td %²¼¶ÇçlêPU ·ÜÕøŸ9²•T×"­™Æ÷ÂV“~fÚãç[.]¸Ôõ@3ÈxÚ9í$«ËЃÕ8nã&LŸ_ŽÅ!óÄàP é•‘î’»¥TÌî endstream endobj 89 0 obj << /Length1 1409 /Length2 6289 /Length3 0 /Length 7251 /Filter /FlateDecode >> stream xÚwT“ÛÒ6Ò¤¨éD¤$4é½Wé 5„¡$!‰”P¤wÞ›R•Þ‹4¥ ˆR•R¤( ½ _ôxî½çþÿZß·²V²gæ™Ù3{?ϻްßy¤Ï+g‹°*#à^P  ¥¥€@A> P€ŒÝ†q†þí'c7‚¢Ð0\ü? ((ƒó)‚18 Pâ @"â ‡â@ @ûˆ@‰Án0[€@‡¢ÉØHOÌÞƒÛçï%€Â‰‰=|ð; çEÁ `8@ Œq€ºàv„€ú ŠñüG NI )ÎÏïîîÎvAó!PöÒ\î0Œ@І¢Ü ¶€_#´Á.Ð?£ñ‘± `è¿ú;Œ;àÎ0ŽÆ¥<ÛBQÜî}5M€ ÿ ¬ùààÏá@| •û“ý« þ; \`¸' n°ƒ9C:Êš|Ìnû vF#pù`70Ìlƒün P–Ó€qþ™ AÁ4æükFþ_epǬ·U@¸¸@á4Ù¯þa((wîžü.× Žp‡{ýmÙÁà¶v¿Æ°}‚ä7„Ã\Ÿ@Õÿ`p.²ûì¡€0Pô¡ ¨0ê €z@øm`à‰„þ‚~¹q3øx!H€n ¨ÌŠû!óBƒÝ  ê ÔÇë?ÿ´È@ €- ‚Ø@íap²Wǹ¡vÙ¸ûGÁ<f@ý@à¯Ï¿V8†Ù"àΞÿ†ÿ¾b~ee9mž?#ÿ+(/ðxñ x„PHð·ðùgG`ØŸ>þ#W n‡ü*ö«_ÜAýݳÛpþQàŸÅ´8êBœÿfº9PÁ}þÏ|ÿòÿ£ù¯*ÿ+Óÿ»#å'ÎοãœþŸ8Øæìù£î NZœàÿ 5†þ¥]-¨-ì‰ËGÕ0`œäàö8Jó‚„ø€Bùahe˜Ôö qø‹6ù  ·>B a¿1¸, ð¿b8•Aœp4Ž›…Àhœä0¿/ò— ʼnêŸ}(Á!Û_ê€Q(°'îòq–0À „“©-Ôã7»ü|p—ÀÍì°C È~]4Hà÷øåûc‚üž¿Íly‚BáúøÍ\Û¿…z@!d“ˆDcuPËq¥£;ïÊ$Ñv걉ïP¾% ¦[iÄj1^?+sJã•òdHÙÒ±][Þõ8{îÓž×r k­§Ð!/«òš=«MìÄåᕱ¯#¦»xÏ“åYÄ‹PÝx˜#);Helí»õÙ)¼ïWw~Npç )V~¨Ü¢ÝÖQYœ©IË$fô틦ɦÏ`ExŸî~ΗgKQæá)Úéw5$ÛNÈâÝ+(zûûf¨º˜ßDú«»¬ì°…`¨”$ú˜…®Vͼ¸qžSä¶™Níe£rSvÓ¶»dž+ù¸Z{×aywÓâgbÇCëD»(Ð7ì 3r†F>•›·a;ÊJÐÐ+p„6êLƒ©¾+ûÂ줬á95Ö9¼pþD#EÍìCOç­x©‹Òåo>uì­Ñnv!øÍ÷+“©–•xh3¹6|ì_ô°9gÍr ˜‰¦:´HΈ5û™P ^wƒ¥–Þà¯ûÚ{µÀôÐ +tñb¯­Mžcʵ"M…]¨™ñNÏ~º âW I«ŠRÀº»,zWx,Zhöº |ʰ-.Âß>QÅD!ĬÙ/7Ú#‚¢éøšÃï–M/u…°”âÇÚâkç–œîûÓ¾ïA´à ’¹ûGnbn⧴ɵX¢WnI´Û‹ô¾è&Ç—ž|pùCº9EÇO]ÈE8øSO°~¢‰›¦Ï«çmó2µÕb0ìÉÊ­ÄeY Þ›Óœ1×htû×ãŸEµÈ-ì7åDrV1Ž}¿ÖR,åOÂ'öòkææ¾ =#Ã^¦Ô V³6+ÖK›K„Õ­y&£üùÓž€«õ»ÆwY¿Óã/×ge¼]ï®#+£u⸂óÙ·mv›Ü£´_—ªJ(úìLgÅu›&Ýhù^[r|\h_|ƒ¸dÓÖ”©þ ìmÝæ]dó”ë»ià6ÄŒ蘸Sm‚÷ÐóØžìfª½~Cð ¢§>ÔÈ Þ‘ » KølЬ›ÑYk´¾·×Û[hg¶Š†ÊVÔpãc½“ã’Œa| bƒ\1½iò!ú1óhÁÏž9å>°Œ²‰OßÁ4‘€É‚…¬ä‰—6nQÏœõ ‚¶y†§¨F¯P|3®«èG"2Ï2K Ú<¤ûí>©Öœš±Z(¾qL×ë‹ðåç9#_^¦Ý¤§RÎ:‹.cMfâ‘Õû9YªwŒŽfümëïÔûIØ ½È3( ˜°têFs¢ñŒ{fB‚ûáÖU“¨ jìu'Àí|ÝÑy÷ni°kÈ (Zí´iHƒ’#Xúqü(N*lî©^rÇQã>¬çÂyKÚ=~ÎdCò‹ªite¡‡uëM¿ee^¶Œ»64w8ë°NŠºz6‰šÞëŽù]YNäËÚô‡Be£ÄB'iûó53—ŽrÜÖö#¡º¯ªªI9 ¿J øWê^7d R@Ú¬½—•8îTÀƒ®s(›qF’½8>‰=)”¢‹FáE|Omi¶Ú/¾J5b§Cb<÷©8§øÉ pö(.Ú‰?¾œ£BøàÚ»‘⓺ñϤþU¼óš¦F_Ù|2É6>t¤•Vsªö«¾cÒÝ¡ÛVü¼7Î0¥ò0c  ê|j ÊÔ¹ðÌè‚öô\ž£ƒåg2#Á‚¬CÞ¬€ ‹´åUFl“ÿ¬v9GC¢Ê¸!H¶.„_ _¢wXíÊÆel"[a›Ÿág~ |çOv"® ¹Ì¤ždÕî>Uªªü5Üì§Ó6IN ç¦UžõŽå[)yÕú­©æžu\ðÛ2ÍÙFkêõô,'Ä<¬}ŒNàà\3ZìÌ ]j•uÊ';5îY3;z)|-jZÁQ.ö–/Ë)\_•×ëpµ›ó>¾EÏ’½©ÞI¦ÊÅ„Ò=Œ­cÖ>Ì{j@g£éÃ/=$ìDýîHJ×ý…ÎÅCZáó°{ŒâIŸ¼0´¢Õ|$W×Û[[¡|U_ëp¶=~}J:éUχ£°•k+?¹?9Þ3îÌRÜ]‹dÛõÞ;Ӡ1ß?ÑxÁ°>¥™ aõ”ÌV7Y]­¾9¹Ó´ó3­‹žëÚÍ£æz!DøÛ{…EÙÈD·0e¯‡¦âûv¹Ôˆú§?»µ ™?ê‘4#¿gÚõx¬ (r& Âs«§&2§a3ѯ> ¿ŒB_ïœl‰ürʇš#©$`ÙS2{ÉKPú³áÛÁµÀblkòÊ3T9ÅÆÂ[ü+rM|þˆØ¯âò´€‰¹O~*ŒÙ#C '"@ ´µ?Yü~’wzsg­PÎ|çúŽ|õO^*§–×MÙ=ÉN‹ûg¯5XÊ]"geç¬òåî¯~êxÜ<ÚAMò€MJê2¦hFPÝôØ)ß ''6™Iû)ê"‡<øšIhÛ¦-qw9Í—Žx8¾¸ 9ßr˜r«‘^A¥ð†_‚öǜʘ®yo €ÆÕ-ʹù£±^këå6Gq~rüÛxkžù]^²sŸŠ0šÞ«—_]L˜Š“ìßXyņ$p,óëèYwïÄóÀŠç`åùê¯Æ²ÎÇ­†Ý;è5Óæ,Ç`Ÿdæo1ª W·ûOXÒøÉW¯ûI½`Ю¥ki¥’Ï+Û6>üô~Ëç•© u>Æä…qÑN=U IåÙzÏÔÈ4ù¸ñÉàøA .¢¨eSz¯¬í‚Ç5{._¨3¯·Ëpf²{8Ýù©&î'¶þÕjˆ÷µ“¯æ°ì×ï¥o¯¨HuY–8|ÞàrªÈh‚‘ŠÚŒÆË¢-o{¨\òÅ…PlÒé…¤?ŽÜr¬XR¦1˜iùxýx;Aoºòm—X›—ÿÙÜÅâBTñ¬>% \'ô{£´j³ù@¡Üu¯“#ä§ÉÍMµ¼Œž±TBT«ùtýÛ€w—_Îô k·øÅf”ím¤Ì·cå™vã C·ˆ«^N4"CÆöœˆ_õÉå²RrNZh-Ó¢¢ ¥¤9œ‰µô/×IªržýðÑSŠi¿Ø+¬åOe»€|Ÿ8éG ŸµÊíà;¡ÐäÁ­aÖDêï.œ"[šU”Æ8Ödnòn.”3Z'e-ÉŠEÞIE˜Ëj&€ R,ô0äß(°í÷¸ßJ„ð* 3¬' ^Ø|™m^®hh?oHl“.ù¦áá*ØY°ðÎ SÄ\–±ûÑ{Øø{0oPjU)N¶¢9‘o[ÀrUS žÃɬ*] ]›z48[3&Qqô¹÷Óó ãÌuÞuZ‹rCX´5ÚÆ'6;jòg'ºQ–Æ*ÝŸ’½¤ÖD¡¯ô¶$Åy+rÎÁ\ÅÚæÊ!˜E4?½sn·ÏÒPðf…kzíØÁöÒžÑÝ’K·öÈÆÇ *¼h™ÔœÓ™9æÑ†Ua¾b´x›E/£„ª@ypkµŒs{m5„†zùïQÁÑþ(IÞô/󙟿7ÎF2$)aæ§ÓÿŠ×<ñúp""c(÷fг÷=Kß DUة‘C-ï6{´~ˆ&¾eƒèûm2 ßyŸÝ LŠø2%|'¹ÞwY‘tôž¨Äµ§Ïwk/÷ЄÌ9–•Rö ;/âjýgeNÖ6?a¯JD[Y$´ |qýT*Âù1çä{k" /ªØÇ4¥ž¼c§8‘—c;¸ú£w“Ž-ƒ»A$îà´ÏEqp'”Z*±6pÃoĸ›¯ØÖ÷H娔º8DŠ—?' Z®/ˆö€UF½r½7ØXQ’XF9üjŸ¯}ÅÝÓb~ÂúAnº{ƒæ•õ#_ýKV)ÙK¥“U ÆŒ Žž½ð<”9›)›Ù§(~ ¤`ÞæSÃ祮DuÜøÖ¹(ÀË#9ò²CÑžÞnD,7}éäºRÁ¡³S‘,\—goPB/. ž.àù!¤‚6h²Þ‡åõšÆúg #ƒÀ{%¢ ‹QÙIH%ñ6÷þ¬ìaZ%5yBNgi§”ÚÁzx‘z¯õλD.=í¹øõX‚.Ráa¾)‡â{$ÍŠªô9“À>|Hï›&Zõ‚kK!Ûþ⮄´=}ž³µÊ’¦—9ƒÏ};½wKæIǨnîð£Ú²VlËuÙl´ôæÕž-;—²;c÷é`_ô×ÅG ÚBæõ³»«2J÷~èÁGŽ’în,:Ý›ÍÙ—ÕÏ=õV'çºÜW5'd$¦ñy8âf(£(Éå7¼m‘Ÿñ3+éõN|é—¹u•½ToˆðÒ ØÖÔ´=#ñÒEi…øµ˜½+ÚïåHY‹0ôáÅa®ßuêg½X#–´9IÊÌiºB¶”CÆÃ"!u=ƒPeúéS¬(åC}’#¤š-Üé`ù½ìI]aj$XË/ìmòmš{ýÕPï³Ô}›Š/,iä×0š¡¢ÃUÀ”þ0ï£m:,\ó®W(•“0¤É:9øyRÕÍÝD‘S×?Z­vK]&PþäI©Ñ[ ‘ó¤{nN¾èiIñ@ÊÃ*êM‰!ÑëgóÏEtHBå§–De‚e‚¾®(½ŽÆ‹c2‹Ù÷TLœl¿êb\hu/Þ&|™ìíÎE¥f½@QÖ ƒ½Á=èV^>õ,ä]Á>9YŽUOÙÖï´_Fø‰‰ƒñ;’ü‡Ï0à ääI{<ƒ´Üë·U?XëJîÓÜÐ:~MWj¦Æ…SlMЧɪ1U¶NÆÈ‡+®žz#’½,‹äRû¼™na„ç*h|*M›¶°´±ýм\0ü.F󜥚éÉKÆö‘/¯\ †¤ø«(Ú9@Ê>J?ZŸÏé³3qh5zFç™*ä'’Úœ,5FóʹßÒÈ#;j0•Åe’æ)‰,3;£B%‰….޵ú­, ÂÒ|狀U0ŸÉèz’9.ÌÎ_L|ú†<Õ›·¢II´_k@H•³…õí£¢ÂϼdÔªj>¢}Cª‘„›cÐßàa‰¨ïÓÐØ{©# =íÎIoEYoÕ³Vw·6:¨Ÿ5¾ÉezÁé}i³ÂM+å‰b|IRw¶+kߣ%šÝñJ{A#‰GÏY¹YŸ)Óî¦ðwNלP=Å"„û fJjlK (•ž&œõstÒ|&î)Ê?~ªÙÄ'¬å_šÒ·V¸†ðÐjžO[$iS@ŽDbªæF*1Æ:Ö!L#;B|:lñ_©~Ä›4Òç–Ø‹j¨ÐXmkîøO ö±…Æ;ƒ0ñ^bãž]š–öó B÷¯/Ñ®¡¥m"¨©]ÍqcÓˆ®–´8À’ý«ü:M[é¨ðP|«×eÏÇÍ·ôµÅEŸçÑÞ·'\/œ'1”™ãZÓ³a>›BD5ø¥®IGˆ\_êêõåJ%Õ‰'+yÙkâ.üžÿîÀ¢·SZ1'”žŸnN½¤M…¼q!¥÷àM6PëqÏ9l°ÎÞµ»r…W/—Sº€{è”t¤ø[Ÿ€p˜CËÚv³·Ÿð“7ÖºòŽ&¸¬¼LÑÕí­_ç<¿z$” L—TcY8@£5_c&Vá¶–y¯§¬U|}¡Óïb|Ð~)fÙa75'¸ÀkîQØ–æ7Å}×èÚ¤6Ó$ólt%­•ï¨g딽OÖ/²~Çxsl(öTéV}ZÓ¶Èñƒ35ƒ7l¡ÑCž“¡[ WT“‘°¦ÕK#ˆC¶3ÇôüsåÎYñ¦·”:ùël÷ú"Hî(ŠãERá³sá_¥Ó-ehy$üìë½k¥™r*ÃôÖ–šûT¶5ànªUù§[öå`aª@h\çå-«-)­T‡!>F=+þ«Ú÷ÔŠ˜ÊIÓjªætLí {à(wÙݳ§³š1åMÏ‘? (‰Ö¼ÞWC³Lu·1cî­r >Ãzf‰0ß^-_-§4f*G"­’ÆAß’ø¨žE{?·Ï“¬Î³+£HÉp2 X¦d¢w¿ /h="Bí¶°µ~ºˆ©|×%lÃð*ô ;×Õ³øóž­´ÎXO»ƒîÇÛãÃ!!Þ2ê“Ç"r ö÷%ïE½Ö§)|²©Þ«Ð%PßW¹kºM³A˜5ùlÅåŠA.y¯ÂùìaÔÞ¨YÇE}Œ¾ÐÄ2+È­mgs,½kv´Ê»·×=vꂎÑýN(®û–%—ˆhÁR/VG7ˆušg¨¨ãׇ«‘Øqñ¨˜Ï&ƒ£Zßtʘ¿O~y>.xhƒo(ÔÊ›ÑÐÃRrÉS–ßAX…g|(±h0Õ9#;ïçå­·>Á8Ä™+«îÏf¶jšÊ}öš?´ ÖJ> stream xÚmzspfíöeìtl½aǶmÛzãŽmÛ¶“N:騶mÛ¶9ß½wîoj¦¦Î?k×^{=»Nzê‹ÛÙ:«zØ›2Ñ1Ñ3rTÄ…5™˜Œô,pää"ަFΖv¶¢FÎ¦Ü S€Š©=€‰ð„ Ž bgïáhiná  Rý;P·62±´±t¨ÛYÛ¹Z-¼®®®‚®N.ôŽ.üôÿ©˜šœ-Lf–Ö¦E-)y ¥„¼@ÂÔÖÔÑÈ èblm ÈZMmL©fvŽëÿ8 ­‰å¿89Ñÿ›€­«©£ó?ÄÌílrbªBâ òª1U€‘­ @VòŸr[g'îЦ@c÷MG pþËÚè,ãÿ±þ'ëèþ‹މ `b t›š[ÚÂ1üK7)[3;ûÂ&.öÿMýCÈé~Ê4¤˜˜šýƒv±¶–7²1PŠØÙØ»8›:äìLLmÂvÖ&1wgS[S“ÿ¢l,­=þ¿øÿr6úG![ódüOÈÒIÜÒÝÔDÑÒùÉÍŒ¬ÿ‘êßq ÓÿœÏ¿ý§úŸV€ÎÕÄÎÖÚã7üg˜·c‘R“P¤ùŸ5øwZÌhgbikPqþGQ#G“ÿ ü;­hdùŸú/•ÿî€éÿørFÎŽ–îFú- 㿞ÿZzÿ%,lçîEÇÌÌ cab0±s±¸˜Ù|þ/º@GGS[çËþÏ,ÿõÿ½N¦¦î¦@¸Õ%; O°UZSh™¯XÑL9$ÍÌ”¡Íèòd×µŠå€…‰ÁÁ%î*n¾Át€1ßÎŶÔ]#‰Qœ)ÂÑøD4q¸ÞîËoÒrsߪÍ7¥‚×Úpý+u <ÄuÄ­sÆÚj "õkVîY•´C)ŠS´áŸ¶^Hä­ø•ù[ *½Ÿ¨™Ú_¦{4•È3!…WÆ/»«`aùA;×ä8…eöaÚù{Fm˜gëÌÁ46 Ãv‘,Zm­Ù“%üÅ@¿Ã·ewV7ò ñ”Ã(؈SgW".7ï[*qòµÓ‰uq©oO£JæôùOÉ´Ôe0sOte¹Ýöp—H·dÜ X/2œF”ۀf¦T$–U)£†:i–ú¹þìòì±â#G ¨³oíjV+¬‚ÆŠÊyÜxm¥æÉ&-ÎÖš;"«‘ÕïÄ;ìQLÈe(¯1x˜%+õS¦p¥§EoÌe*RÕ‘•µU¦=zÑApí¦ÆêÃÞÂÇ[t“^Ó|P1蚬xe¥Óæ†8+l%ÅT†Ö4>I˜éà~ ¾»Ø„޾‰ù’o¾bœŠýCçuYö]ÜBË5dêßóB¡ªBQ‚¬¼ä6Sðù6ñ¶y„é„_‰Œ<Ô¹åÑ.rˆ{+³Ua‘Ý2AzT<×Ð6±ŸÙK¤–µúø®@ š×aÚÙ ^=‹üÞ-ëà± ý Aá.6µ}(ÙÝŒ›4‘½Š/Î2¬´49ÐF`Oxø¯\lŽýÍæ›úH¹ZL–C2×fеe¦JÇ¥›|¸wù¾wx-cÎãOHžÀx‚ë AÒ=ׇ‹üK‡al ¶Ìþ¬#­?†ÃX)ÒA‚\¹Ë§(fˆÍBݬ™ ?¿jW_¨3çd»uÎWIùB÷Bp ñçÍRÚ/îJõܘ¼a-œ˜E²^ª¦ûRˆÍØÚ‹R\ÎÏãÜ« ·|ÞÉiATgeиï ÝáE#qª°øQ°5+7Hì¹e‚q„-MÉŠ‘Å–Jñu1÷Oœ[ÝŠŠÂ“fþÙ~h¤Kè·¨º::?¥A+™B%Cîl»q š6ó&nYU/ä ãHÃf·èÜ›Çà²r¶d¯©ëT«lÞaR¥C&²÷LaXH°€I+ê65êoëŽ)&?å9Ô>4?Aùr+éÂk0UFƒ>ÁCó N,iàç8X°™xBQmšéçhp! è¦ÓäõN9OŒVm6mñf;e3v8VY‡¯Ç5¸£Ï6Ó/ÎOªö#âÝ+jQ´iMxá¼È¿,ëiVjš›§µ1¡œE!kJ0-ɺÀ®æüt‘ØŽö³Ygæ˜=€mv˜RÁƳfìGlÃô\UúS+)"5b_ïÁu!XŠâÙä àËÇ«½GòFA6uëŒd)ŽhOezYƒ(öø5žÀ^O7Íï è*$µŒ "'´õá-ÿ(øIèÌSY9؉ü|‚BJ§M²¢ÔœûÀÈ{­,âX¡É9(nçF“’³u® Rpé–Î?ã1•ù7åë—u‚uÀ,ÑR©Lþ&ÆrœsȱâU¶ÚŠ´ËA‚8/—Îá‚oDÇ1@¤K³ü¾tŒtìÏG±ã‹yÇÁtmGá²ÀîöïnVYœœåøÃ™J/é1mµáÊ`å‚Gæ§—Ý*Äiy•QdÕ!8¥„½r ½³_-®eÊûÄðÄÇüfSŠèUÍs±X }²$:PG¹‹/ßì÷åi~)Ž-B þ›"hë%ÖGçÕNÅ0~f+H¯§½},g?)é#[‚jÈ È™ò­û”Ãg8Ajh–çô ?˜’+‘¬k`Òoø ¥ö[>ÓÚÞ²çMgoRla;å„óxµPÄ8㞦'l¬NF{]ód•Ë Éßâ7²ÿðuÚ´oúI“1 > ·Ö@5i&•<àÛV\Wý±3¦àù¥Œ1·Ç+ååÞ|5óFþÃǵ’jߘÂ"¦ÜP£~e²4çÇ¡H¤ëx×i6ŒÎð- H÷â!Cà” ³î†›ñ‘’¥÷ø‡"™ñ„ ×"ëšÚ«Iìet¥Áö„ ¥N†YaesÀ>ïVûcú­Ñ‹ãfÞihŠc=ƒXƒ[eý¾ïÁCZæ+Yx5¶´˜aÙ[âòó Ž©íCZ45C;¹ÃåsG”¿ú;Žìõå;ç Ê™Îì ²µ 5×orõž L½j§.ù/¨4)‡©·rß]Ñ.QÖ±2 '7ŽÁ2pO9Ì^{‘]‘n2׎BóÔv³¥Eƒ¡ëŒðŸ‰þ{—­ø˜ÔHD*SŸÇèÖ¿ŠÕÙiZáÐsdæû9r,"Ù²Ìi¶F!¡7ÄWŒŸÆciÎ}Úe…Ü ³´øÍ£ubÏŒ!‰å‹Æ˜ ó4ÊGÄŠbÔ*,PÓÁ•ï0?.bO•ˆÁóR×T¨z°RP0R §CbàL÷1„†0pKNz sæü+R­Ô®dC²»ù8éòÔ‹ -´’«òâ/׎ qí~L^þ”V7DÕ¢.Ö7z•5_7Õ•¬íŸY’oªkàÀ-hÈþI²!Ï€ÔÕ±bGYðk²+ö|‡3ð‘×D¸,E ­zåÜŒgägoº ͦ?¡·idH%ºÆ»â<Ë%¾ÔøñÀÒ5$6;õõŒ@d$ƒ…wö:eòj¸Ìfê`¨aT’y–ÌÛ4؇¤šßO½–£EWV—»çG+Êe‹+èå¿*¶~STZcá ã'Ë~46º@ަMáÙ„Zóûœ¥òS?‰2ýªn$ }ùCìµ2Öy0]2é™ù®mÿóyü¼Púzó0˜ßáÒ?¡ÖþÚª¡Tõ±ÒÑ\ÿK`›‘ì‡øë°êyJ-TKk6êÉì.²+¶üaþ¾ óÕqÏï¡ÛvµýfÀ‹ÜhÙ?'q4—\³;0Ãù‘3Œ#m¦ ÑH]’ã«ýx•7ä '&LÌÕŤy?æLêøIóµ±ÍaÎobŽôâhÄÌàóѯ"Ô²ECfm’ÓFóëtEÉì 8,W»Y²ìÛùÃ"¢“’÷þI;²5ÜÄäç”±Lº‡Ê™³gõk+—þ‚qm" !1ô%bêÁéõ!Ynã߬i>!¦V P9ЊXrGSÛ&€_yæ¤Ñ´C•ê£H÷­cPm2BLëcƒ]:X>­ðM,DEs=‡HU*´ÊÂ;cs.¡Š´,^ “• OÇÙÆZ† ò X|Óà|œ£ýàÓäö⬚39fƒSà V{QI¶¡8éºy=±š]Y0å(C¾dbKEyZ¼Â+·¥DóTà ÎjÏ™ëÆè)Ð…èax&£€lF:r³tð#ÉW…#Ò8¼è€hX8ØjÙJÔÙ’;£¼GÂ(7Vë= ¸¾([ä½yˆØ½j`fJù¥Y„UhB?þ±×}Ʋ^'S yäô2t·¸ÐëdÎI«^ç·ËŠÅj¹¸Oßf10;¾q*ÓÈ&QƒMžã™t&i&3Dp®ORY%ÙPÆÙˆêtÂtv߆%¯¦hWPGWùÈøÑ å^…$^ n´™s°5ér½MÒžM [ºè|%0 8w¹IÜ8QÝ©;êmÌÜWJ‡° ~«w˜¾y²D²y‰Åܬ±ìáª`dÃ6ì?ßY$ê%jÒ§—#M>~î-á'LEzn¡4Ú¨ߩĔ 5ñƒó§¹p] Çœc'Ç,µd\çã]ð„ê+‹‚ON¾¬BG«µ­+T‹¼4´aFñ6ºówen³Ä™nCsxîè ¦Ý½ì—ZÖg…gNV<Õïì>ðÄ?ó§üx/¶ìT´÷ž=âËorjÁÖ|œÑU‘‘Ì.Z™­3øfe 7Œéã ä/Rågá”ï>ýMcñÝŠ”ɶ[·2{>hJhE˜AäŠTÙh LÁ1á7^éW2 óJ_ ë_»Kà(˜‚ÿP¯{fSNètWË\èôq0.¢,ÍœY*[^zš²*е„é¡<(ì9ûRÙù:…˜†B(ˆ;qE³1 .z8•–·Åœð-'lG'cóf‡ï(åul5‡ÁßOyBè£Pq ñ/0TÝ Û:ª„/) ¨žöÆËê>_„Új„3¢s”Z[‡Í8%ú¿?©îÓ„ø^-üŠ£'×b­dhZJ=®q  sŠ®3 °omÊË…JcSî«Á¿±oœhp¥á ™cuH2¶QVBÅGZ¯v4æ@WD·×ÊáOlÖõãñ9rß5~‹)·ð (®ÜU8¯²C¼Fò^Õ€eE+˜Cãmä6£ÔË"I`^~Óú å¾ÀÛ|ÿ0­ÚÍ&H‚ª®âR௓Áˆ E,yê>xBg¦Šq% éÁs2¤y4ÕrÂ=˜½)¶èä.ÖVl,cõO\›]õù¨Ã¥€¬uUµ²'ÀÊ6'RŠ.Eµ\ÂY†X€ÞBJйß>TÚþ¶8E´Nz¹&|sºhöCyÉ _PweYLM¯nªåHښ̢qÐó¸tÎaëCàE©¡ITæ+ÇkÇð—¯ ê¼JÒT†ø¦0ºîvèöüí±}ŒÇÝd 3Ag¦alŽê›"†ê,ò±Î@&8¶Hi {–»RÛ‹Ù^ßó½Iâœiig€rRÉ9ƒuV;_/(+ãà„ñ’?Æ7¹gÙFcUSÒ $‡­½qBSÿCîWl)[çŒw_ö§Ú^ÍësRÖZ}“铎$®«Í;q‘­¬u7Þ³^$ßhÈGëéCö`šÝ6öU u /Ÿ 2—.ÏS¼Øy-”¿¢˜…vËçi½ ‚)âÔ%/ß@[ÑGècö‚m[Œ>Q¾:‡BÜr1‰öí4V” XÙŠ Æ2RÔ ý>’èç¶óŸ‡]õ¨úS¿{õÚ–Ò‘:HÔ-G–]8kõ¿jšEM^©xÝ·e§40§œÍ/ka,ÊÁѼï ôA;ÏŽÀ€ça“Í@…‰ÆN…†­+ßwd¾HЂÅùÅ`ha×`8¥eÉßÄZÔœ;0(ÞáŠqÇ{wPÆ{‹Jºìw> 6]Î$…õŒOt0ŽW>^³2°ЙŸšøqn)”w ¤ðþ¢’²}ŸŠ1ÿœùˆÙÉ–ˆÆó»ßÑJÇðõíåûÝfÃÂx1‘6W;˜Ú © —Û>òv1›1Í{+óh⛪ o؆Á^|*4íëkéëóÏcRƒËG/މ§0 á¯ûWýïºÓÄ?|á-G¼?ncë"mlvÅÿæöµgAr@ò‘årÿÑff6ò%Ÿ5 ± ¡Éh¯P€# q#XT 𲏏ª|MÜq/׈¤Ýw„ÚØÀ=eW‹Š+`Ð9‹‡'ß´ªþã½C;bƒ…Êa­Z;ÄAÇçŒ?ß^PÌ(ƒ¬8i4Bì^Û¿A§x›â¦wÛFù•۲ɲªnâ»ÈD8¢çiò0 zò˘˜ªôí¨êtÕˆ.϶HÁŸÃSÝÔgpÁÉ­ ¥i4±~‹4Hsf‰‡o6™õm”˜!â d¦pÓG༂GãM&° nR€S0ç¸=Ø ª¬ï¡°;g£ÿb°ÁóÖ~UWžŽâóáã—ñOJÛ©n~¹S¾°Wö`gÿ^lšÝfƒños T·ë®÷JfìŠØÖß/!(ïPbë/Œ[\°t{]ð^Üõ,^¤Z5 œy® õõ €‰«š79ø–ÞôµS_¬æ*d{jÉa’Ëp£êe0‚’ÛYñÖõÑšÆ¶Û U(ØíJ)‚ NÚ Ñ#étXü;¹iÆJnéãOëÛJÂU?”Xáþæ&× ëˆªê;hg®{÷1 ±a»‚ ²‘ÖJD Ž*#Ùí±ItI2cÇϘ“øYMJ˜3)1•×6C{Þè ewça9hR4GÈeEc+éSšó<O*Ú`Àï{£*¥¿¯yv}ðéjÝ[)%%øÍ&'éùOç­/¾£à’ÓZ0%æË)â…^Z²ÀË6ªcÜ"ãÞÑ.,½©2n8kAápí `¿Ç‘. YaÒÒtPö¢E‚HÜèÓ¤nºÙÝ ò¢³«ÜóVÃDM>GIqiy7ÒÊy3ž«€¯¹ë€_דîé±íAÔš^JŸÙá3gQJ>¹–£¡·F@ž&}Ñò.äv{ç f+ŽÔ2[8§òË Á íé[;™÷jMNÉr]%z¹+¹yRç2ˆ˜·#©j”í*J½Ø³Ç˘x ±ÓƒÏÅú¡ãeÈ´óÁ(J¹ÚÇwzr¼öîczׯ|éI0øŠjŒH€<–ÔªVo5³íë4FT ÆÎI•HgóC¾0¡åM”ó”úê¦ËQ‹7wËcÝ<ñOsY¢aß4¡.ƒw›ΜhKÃòá­¡æÆ:¢EHé·ú©~ˆt— Svå>$¿îwÜ‘yV|߈ LRB„ÂÝðÏaZgãñ]¥¨rX«ª¢Sº*Ï©uò÷g´‰y&6ï…wƒ;úd¸|¢»YÁÜ­x¸288º~Ø,~eµiìÒ£Ìò ¦Ö8±SÕ©qÜY{{Á Oäçi¼ú9'g!=£ú~*…õØk¶Øå⛺ð”ìµ/ŠA™øRÎú¥O×iAo‚ÂRJˉÔ’åœf”AźCõXsy…†õjÜ«,By qÝÃì`ÿeR·Š¢©Y~ádÐf.¢ž£KÒî.èóIàÙ"‘Ú¬ÙM­°¡Yc¶lnù¾06¯¨Á2?ÁØ|Fáô†4þVŽÞ¡¸¤ÞÖóàݧêp@dx¤¡Oyl‰œÉ{†ù–âÃ!6sþšáÁg#WŠ4ä4k(LŠþ—01` ~†ª¢´êÕÍŸ3y±NvµÊ8-5“óGÿ™ëÝúè>ÜÒ¸‚2ѶŠVºÿi=R«Pm‡{–ô7‘LêsâÇhÂö½wó(Z#€+Å#HÓ+ÎÑ$+ Îû:¬m×Þ-Qj_[ÌZº€Þ¦i‹ˆlJsØó¢ˆÒªûì”ÅnÚ}AîoFPiŽkÕ£Ô{©ßÕßßäS;§öÁ©@ÐÉF¸ÑÖ¥VPÉp<ˆOxVÃx+˜Ë©‰ò3r,Çeó‡E–v<¦“á€lÌ×€¨ÜÇAp>ÉëÛ*Û<Æñ/ÍW÷D¡,«i ¹ö_É*þaKgýÌ­-Š%þdqÞrkà‘Û¼†úhË9b‘JItž¥Îut†©)Ž¡sOMAy¤<ük´™Z†himߨšl¯[а7oPÐh4f ´fO@qiíjCIºˆÃ÷>{BÉd¸È+|´´B`|@ASëXHi†ÓK)ï%È!Çd·C)ÒF LZ*ÏŠy¤_öÈR«ŸÏÜæ.«o—»lb(+ªU2ËÄ*𠌤ûr¸{ åOW`_qþÌI€CqðvsÃD;÷&Óûp’G»hÊ=ò8•6ÿc^Ìùª°Ö‡ìÐëÀ¤øš­0Þ ;ÛÈmåÐ …§¸j—¬Jÿª\Üvu99+ðûûõ¶•õåÐÄÔtûewâñ7²8YÌ®LÐàV$EÎf3úŽ?õåÛÖ"‚¸ÒØ-G¿{i]šlZÀýêŸP50‡R½#4pl+ª¡ \6’ÐIW’.Á £<ÝçžÎj‰;+í+ÇÉPÍšáÅWɧ.ôÅB¦ü vH´*,¹3Ùièç#䕸OÊyÕ¦ùu"]+Ÿ ´ºH)±õjÌq0šïì‡Ä±‚c7L ÷rø¡:M* Åæ_È¡ïsâÏ}Ð_ Gѫ͎çvz™‰“|çGwå(ÜmšÄûä$?“é®Ö0FÕ¥Â# Â`=!œ1ØN!|3* —Ç9eÓÒfòûkò/i*ëàU³]·†³àBq™šåEƒ6Éi~ò9”‰·lÁ×r°Ž“4Ãõ¤ÙœdaGû:âPÆL¡-¼ÉR)Luçêi® a¾¾¨£~{]ÉX±l$öˆ˜¸¶Úÿž¨ C»Å ¼îÂgª…B›kÍÞýÄHº-IÐOï´íªÃ.è8\F¿KÎ"yu.Zç™ìíÕ+ÆdÀ¸1önYÑ[EyËôCR…ÏŠz5'ï ѰóˆMÑð–Žc;YPBα;/“K©ò€ŸQíLÃÁŽç=×O”λœG3ECeý¾úù²iŽå¶8ÊH€µ·ºjøS¶]'Èä %EtÂ@úvÝWüQÑÂ/-’ïú@¾ ¡ “&¥©ÃøkúLðç…cýéÇvÍÇy\Ƶ1š2Æûô sDm—XºšçèlŠìgÃb²ûÚŽÄl™{§*‹IY×À¤åÝÙzmÆng«—3ù4Õ,‰*µÈŒ£O\G,·ª§fa²%QoËâÖIa'öÑ1tnE¶EtÏQ^…«Õr˜r=@Ö^‰o{Ƴ¼Ìhí¯wÌßtg&ú’¢Ä§ªNe)¸et1 šèTÒ&‡ï8¤£îÆïéÞKÕܧJƦDϵŸhß_r_6¨!#Wú#?Õ¾Í.¾å´Tô#\¡ó¡.HÇAÝÖ~ª«…£ƒµw@~—Üš¡Ó-ü£éÖf Ûé ËTWU‚í•æ)˜¤ªÉÎcÔd’Ëpz bÇfœÚ8G6O g}¦¡ÔïC}ûô†”pî¼É&Ÿý0“Þ âý˜0Üÿ6VQÂÀH8Úy[ñP0k¬Ä0k(sc|a ‡ûl‹~]¯~9®;ûÞ0y®éMc^b7òÊ^“" K¹¼ò‡àR¨¤ÞS&«ß¥Š˜ àÄݲ ¼Æ]8D¨ ´“û×ÆÓœ\ãe`Ž.áÚ$+Þ™—¥MýÜòa<ÁÑT\$GI‡ ðÇàØ¾®ÜÖÇò¸ˆÍÚÔHxò‹n˜Kq[ Ahü"ô§ëZõlLa ÷ëEP mŽ1>¤Q®_åùçßbDÄOŒhxyϯ~üg@äqE‹Ž…[>S.År}-[Š&ûµé¬1¬ÂE˜Øoq¨ùHu8Œ³»ÊÁ4-ý<Îõ—âEÚæ Íè6þšæpn.c•ÉñÌM¡iã¸;‘3æôe´$s£¤YS#ÅÛ/؉ûã*—÷q“`Ú‹¡?bÊ*éš¼±X|‡G™Z Åân3ª},© ÇÍ_–áÔÆR*½Ä–Ï¥c°NÛê=ÑԞīxá“']×vAp®¼Ú•ýu‰‡&3µü†Ü3NmÉ¡Ö†æ´ø-—9h¯÷B¤ÇãÉÌfË5‚×ȹ^mš(ƒ¾|• ÔûdxMŒ…Ï•`WØ¡ÆÜ„UC¢Ö(@èf³ð ƒ(Ñ6Ò*64ŸŸ®oÖuñW@ôÌŸÉR¶fP5 IËm|åRT›YqÇv”Óga‡¦56ÅXÝ›óšµÐzM¢S/¢@›²•ÂH½èwó¥uDåë mk£ßÖÙ¾õῲž£‡7¡tÈ´<‡ýõ&ßÏN¹íO4”ì»ÉÂ$½³õGŒ…ÆnT¡²ØU3üñÉ@¨r iq¯/™x|…N¢Ú[P¤ÜøŸøôiVIøü{F>6âE-%k80Zpñnû‡Ä(™PõWWu1B!G¼•ÕNbå(û†îÌË5:G &± »Òž'_\ª´9ir%¯ñeÿ‚ï­íÜÈ–$"üx¶”ö¹v¿©¾_`ƒ²ÎY+h‡Ô&‰©>Ÿ Ö–BD{üO‘’š§º—úì+ýÁ¢™.Œ~ú Ü.` 1±ñX$À¢ò7Æ]d«4@SóSûZ±œ£öåÂB¥9ÇVïüAÃ(£Oo&]EIÆ@ű/p Æøp`gkîû¦~¨œ:»·úɦÜÜ÷}Áêí¾©*Éõ ®±çlˆÅ ÔÔÖ‘×z|¦è32/¼Z8ðc1TÏ$/Ea"¬òþÃò‡Ù,ˆá`xË0ÿ=æ¾áÍ{:ég§Tˆrw(Žq9„yä5“.5fÅj!çì´xKN^`m.wkóì°£êŒ OÜ1Ët¹[xõ6$úYÖEÈÒß+Rø[îPŸåù„jì—%ÿþyÿõ^r/ýµ§"{ …?>ÌìMû}ŒBE@„·sß"ÿÖ‹Ëe#ë5$Ï~ø "ü¤6cêÕsŸ+À£öPÅ¿3‡xµ*yÏ?[Rn×"Gz1QïwÊ$Jû¸Q,?:%ê*âÕo·Ê*«¬'S¶M†Ý×ø¨üd‚Þª_Ø<&  D¥¤ƒw š@΢CߢÍâú‰ôì}¹Šqqƒ®?[²¡{×÷ºËÇ$˜>§Á;»¤°nW>lÓa=ý ð~O]3.ò*B»©=ùÿñœY+&ºZ²}ä:î¿™¨³u¦‹S˜W‰“<ˆšÏç( Íß."± ”ŠàÆñEèY•¸6·¨ûa†ňZµ eÅš{‚"¾g5ÖÔ&CïF Ü~ÓUô!N*]5w % ¸6ñ%q+b‡™®©ŠcT’|Ú^qxÊUÉ06©´ý-íQÅÅ|ßÚî­rIµzG¤Û¹F!¬ó®ªò5×4L!‹aÍ1ÍRõÑžN,¡@™ÌÉÇž–wúB^â“}ž×µ#ÂÁ¨Êˆñß}‘ô,}(®I \c†úu¯*š¡«À1NY5ÐFrC•®9Ô\Amœ]ü«”’ 6_ÏdFŸ¬Ü_! ,=V¶¢bÙ¹Á]ïF‰†þ²0‘;¡îÙVíÿþ]'ßϰpØé$\Í8-Yµ"ƒq6N EËYg²/Ájú½xYj¸)ÇYd‘î¨C˜Bcõ°" ùáòõ&Ò¿ôvpðA6 SìP./——È"}ÄåŠX O“‹ï|d~»Ü ª/3»ôôû2Ÿ€z }ªÝב¿« ) >×êØ¢Ùdà:ªs‹½ Yƒm‹ÚÚîRý~UñL½4¸ãõŽycÊì4ê"ú~vj†r("å Õ⺿¨è~ŠÊæD´ó¼:!ÌM Zl\ÖÕü¾ï×ÃæI–#B´›†æqäÐ)Àkk›dViET“•E[ö¨?¶ŸÃß ”QLoÂ\¬‚Åñ]u:§„òb­\µ¥²^Ëú“ò×VùÂÒªëý"R›ºaBÛÊÿƒ¶$^i×Ã%…h:¢‚iñ}´èÉÇv. #Ç—ÒW—Š ¬y… (•?Zçó#ÔQkêHn¨>á·M$x¢/¸ˆïÝVcbôËŸ zÒñW ~Ò uFO(´,ºòlâeIø âÑ (—o¾¬,Íég~ýƒ]…‰‚²±²d©ŒýŸ–ε¯Ns¹>~l¼‘І2:5ákÂÿxVN¿¾µ}¦6ïô3VŽ oA,È“ߌ-•Ä&síÇ—ö³ªm^sŒ–aó'{êM!.”£Ó¿næZ“ƒš7Ú+ѨÖPS,*½oeÆj±@ÞiC:ãŸÅ[lŸœÝâÃNÇ/5†sÿóñUeéU–¼‘¯·CA­ÖhM(y˜„I wy}î§œLÝOž®Ò@SûF-Tëüt”ð(3‰+Ì’ï LÖoLÎ ©v1úÊ?u-|ðËÎïröÆ5uovçÄ¡öKKWÂÈû‰•Âí,#ó™¨T§sÅÒÒé³Bžˆà+o‚Ý4N3Ýë¶”¡V9=œI#[ŽV—-†jý%ŸÍ„¼õ96ηҫàਛ©X z;BSOYkç±d«+(ÙV³…’—rxÀÎ^u{·*Ìß§¥·µÌt0îã˜V¢—­6]¹«Éà43GqÊË4vv%ÞkØ\Œæ­P‚N™®Á°¿_v2v¼h¾ûOnòÉ á¶à„BP(\’L¬U pÔP\k%Oöt †t÷‹“[þ«ü•‹T“GFƒIƒ ¹^¬%—ã©QêÔÞÒ¼Úàßs¯R%ÃQ²ûŽÂxø¬h…³íí¥™ÜIÕ1Ê, Û‡2è(dÏ“þ¦t_¢§ß÷–}\HP®oĽ©s-éAîÎ^ÛÞ}†‚^"‰a󉽕ý!PÈ=”ßÖÁ‹Õ’ïE¥À‰9Zû œ§½tóHjm p×|-éÇäêgxÂdI§¹žATÈÈ·ìKa¹6†”£xJ¶@;kbQݬü*mmÇ .ð]aãìº"ÛþS îùòø1ã_£|kAK/pŒ(‰§ ú¡mcGAO…CÙØlx}[ÿpྻb^Ï >L‡™åB%óáWëªßÿzP¦rwŠ5³ûŒ¢H¢˜Rhù‰´ßqǘÿ1GÒÌhÏ}ÿ»ë²: å¹!Î ýNʱºÄ#ŒÏã§›y3I ޲Ò·a Žépù_Xî-þåû9nӵ˱ hË9Ú ¸)G=óËíTòõA H-qÿ¼C¨î;D{|cÃÏÓ®¬°ßÜ´oÅóB_3T<›‚Ž9xí"¨DR†úÇí)Í<.LÓÃÁßX8bX 2YyiÝUØ*ùˆgy9§£N[+Å&q¿î·Ä­F£¢›`˜àË hšéH.ìc#k¹oožöÔueOV¨‰±ˆððÅjKnÐ^Ãðï¦U=…2¾^Môâhk^Ýô¤µwÛm謖AXsù¹ÓÅÁ$ù1Ã&“dªl¥ƒ,þpu ‘VNo‚íÜ'rû6åÊsR(®¤ãÆÚÅ¿/ki`²&‚øgD~²òsþ-–h-òµdðÝ4Ë\Xmï!#QºnSLkz”ÃÏËi3SF¤”Îú³Ó—h®o &y9Ì{©tŒig£ï9+µß÷‡Ó”ô,ÐG/ušä™ê‰wØ(¬ˆ®”Hð¦ÿ}0Ø…í‹ZÕU`Sr\ÛKdêµÎ¿ÞŸÑXÒõû¹>°+fÖ‚*ѤãØlݲâ.œˆV¦Œ-æÄ?“¡DÕÛ¬~5‡zÚ>¢h{Í©x²²« ½ßæ_|¿VÌ3„îÕöo<2E’"oß#ÿ¥\$šŸ»ŸÕ(‘sÝöÞ#øËŽvw^ŽÂ羊ˆ»KP &ùO©£O²d°dmÄ/ø9 `vt ÇëÎì´`=ô®È¨ý®}K¡ÍÚòŽxÆì ôE  Ã@à»Z„p×¢ñs¢¼Ÿ¡¡;Œ2úºûÚÓ‚úç’ÏòvV2½&_¶‹Û˜ˆ¦î×mÚ© î÷w§ÅP‚4ðé•Xå1rO‡ø=eV´‰<ÀÓ£5êèB4œ4q9˜~±vVð*Q+¶¼ì= Ë'·|Qȧר‹§‚t‰YöŶÁòi0w¦•˜b-ãu'ŸüÈG™IyˆXª‹úéP\Nü‡ÛæãbFgÍûÌAïnBÜ—o i%ëzõ÷+ø.T‹Ô(NÎÙ\½Û1üÀÃX AþŽL•2" øÎœ´2º­;”r”íŒe~£/êÃiÓE /i%ßPÕpg¥ì‰MŸl5®Üt$_ÛF¼Sâ3öJ¬¥îä;tüu’eT?ÏŒkƒ·kv®–FbÆ&Ôê#+)Ef±¥ßc¦ÛÿZýÐt– ±«*|Æäc‚¤çŠJxÖ¼t£ºV­~lŒè'«ÎZ~Mr6<ù¥fl2œ„‚Gƒw)ÿŒý’XÂÍsÏúåÙø_84äX"qÝÍ0Âû@—~̽ËP„ÊSÌ!NåδöæƒàB+ƒªüígá±jM=Ø %¸·o8¥<ßEóeV-A³ùÜÚôTðA§ÿ3×›²¹Á´5~ãúã C¿ÝLhu`¶ù(&ä²tS;¼NȯÏì'Øò?x °ÎC½aD,U+àW14QüaTÈÚ æ~–z„hÌð&¹=sAhx›VP"ÀâA¸ŒÈf#Îü6«\á6€é·Çéµ­kë *Æ ë‹J0¬ÅŽü–…ñ£¿ì„e„H b÷ǃÉìóDê1ß0žÆ‚|-g#“àØMÈzÀJ`É.étxk}7­×…¥›5í^Ç­lÏ”(WE‹Pá›Ü}< <µ\+Û;=ö÷² Ë.pLjMÍЗ¾ä[Ch­—P%v ¤3Ñöh,lEa-cÉF1%격†·({‘Y×µê²Ö)¹—"ôJЄÌuiVyáàŒ¦„ÖCtø­6V"ˆÅNs<×&6{L_ã™F€íôïrïºa_aÄwð[¦Ftpâ¥üŠp•ºŸ­kÓ4ü»0" F:Õdü÷ò×O¡ð)ÞrHf°º‚ýcÝSÐÀºÅ[aY­Q5°þžŒñ1ÃF‰P;ô^ãTÉX±Ç‚i4‚ýî³=ªF©Ï"É–y¦EØ(‚·XLÿ×S¡ßÃT´ï ¡6u¬Pmf|“á€ëüRDþQtºòÍç6Éumýîßóñ²†íĽvn%/Ém^t¿Ý/°c?=GºÆš–ï£WüCŒð‰S`¶jÝâëç¹»ÝL£e¬J\¶/즢è>¿?vµU2HX}tDd$Gÿ¹Ìà*'5~EÝö{]š»-ß¶RI(v_`vXVBΈæ÷Îמ€ýb5uŠMÓê ÂgXq‹ ³¶¦ë‚Rd2‹¿3ˆ°Ë™ñm7š7®kÀAPŠå‡‹pðƒ3ôµoŠ ôÁ3—]õ욤ÃÓ\#¿*õÁF’“›Œ+ÐQ==®&‘ClÛ±¥Ë,/ †ïÏí“Û'‡\÷DZë,0u #øÜ°VÑ,pŸUòÂø|€ˆ×¸w.’²þË%;ZýÁ¿Üî=ç€[’—.Ö›(gRæ,5ÜfKáÊ9u›M†QjRd°ÂaUºpñ >€Ý¿ÎP³J´F’¤9˜ ø>߀IrŽš¸§±í5€š½å‘ÝPMRIÎ*èæ%‰z=N¢GÈxœ‚ˆ†,Mzªä² Í Dt·ö"ñÞN d Œn—4SŸ²JDAX–¦ó’· )½–QWÂ4 ¹«ÂC°uÄ XéFÀÝ5º*n8QCž[M²[Èó«Šp;yæFͲ>³½VœCáÈ}—íù;©£¥ 8dOB/2YËXÔ¯O;VVm¦$­B’› ZOAXŒHô/Òf“úûÁ‚Ï| ž÷4}Rª¬‹¶]ý‰àåŸÍš(‰1Ó´wejOž±Ôò,Õ$åV.G„ÃägýMì]Š„9,e|ìŽHÅ!a:5¯¸7…—•ÜJX^É?a¨Ð)ggÝèD%’U5ÂáØ7~ÆÊtq^/JºdÏlȼx7C+P¢gËÍ—9×&aøÆ  ¨3FÒ3FòÄ¥&<Ò¦“’o½w$þ®v1BËk€dŽ!Ù¸œdo–å Kÿ©­]c5G+W\-µKVt4¸o7Ü»I€›÷½âiÚDV!(¹ÞË7|‚ì×Är2’‰†IþÃ[˜ú!xw”›´.bÿP§v˜_ ]"yõêmYÞ4&/¼H÷ËùJn² †gkjl±DѲ¿‘шÎR˜_>qv #²GüÞf _2ròTRÂßò” ò JÕ §Ð_™WƒŽÔY–fØXL|ÄÊêj'n=Γß)“òDѦó$3j[˜ÉC›l7 Q¬\ôæqù÷Za+^•»‘ñl(ªjë¦üfËtq׎ñ’¥ûªºÂüêD‹ÿã —€c’¬+Êtw:^«û½p1O¯;0D‹ŸÂ¹ðBjyÚ÷ L]S_«2ç‘y‚”ÕaM}k ¶t~Av¹ñ$(Ê,a+Ú᛫MJɃg•=›DÆîc\û»"Wœ?8Ñb'Jª½)— ÞË(ýþèyIiê—ëSbÂ÷ä5L|év»€6¥·Â¦w„Y´k@¸3–¦;‡‡({»7H=T«Ýã%Aza‡¹’“u,À¯î`i´yM€l¦ÞB—ƒµ¨|Ò¬L â‚Õf¶ØÏ•5ž/ê…È èkõ?ó9¹=UŸ¸^~F²š“€~¯E﵄P6!ˆÙ©ý,<™£Ùe#…;ò%tk°1Þðq 1s[QvàYç>HÊŸ endstream endobj 93 0 obj << /Length1 727 /Length2 11715 /Length3 0 /Length 12327 /Filter /FlateDecode >> stream xÚmwePœÝ²5îîÎ`Ámp„à‚»0À ƒ»w înÁÝ5xp·àîüæ¼çžsë«úêùÓ²ºzõÚ]µŸÍ@#cuÑðts³ssp Ôe$t¸yy¹\Ê(+i¤%95$ ¨9@Qîo9ÔÅYø/lfêñ¯éØ.ÿµlAÿµLÿký7ëäño‹›`1s˜‚-!P4Îé&µ°ðÿ;lîêðŸÔ_BÎù˜þjÈ 0[üE»ÚÚ*ìÀ&I{;W°à³½9Ø °·5H{¸€¡æ`óÿ Av[Ïÿ/þò. ¿z|„ZþUëß!ˆ³ Äl®qù+¹Èö¯TÿĵÁÿ>Ÿ5úwõßV€¿çjnµõü߆‡ù§§–²®ô§O¬ÿ]ƒÒÒP3{sÔ îòWQ“ùÿ¤U@ïШüg§Üÿç¹8A<ú\ÿZ®}ÿ± ÿ%!aïáÍä°ópó¸ùù€!n>ßÿ‡®™«“êòìgùÿÏ:Á`3´•E{3‘`ëÔæÐr?éÂé DÖéIMÖEnإݗú¸A+sã½s² ²„UšÛ¿ˆ©s³ zkß­uJZùö%ÛØ¶#Ɔ…™Ã3çטà?ú¬éT>n¦†?p^¹y¼þüâóûFO2¦íæùV½Aw*'jµixö€GXG#Ô`ˆñ[ó¢"H‘É$ÂûdP!*Ô–ÜêáÌæþˆ”'zå²6*ÁOÂ3¬@@ßÜ¢½ e÷ˆnƒXä¤7íîàw¦‘ØïÈ8€Óavò‰`g5ÿ˜ÆGæíùášj¼g‹{¶¶À8!˜ÍÖ8jAއfÒLò$BWÛMˆ^P;d†ÒƱ©£±¶â§0Ý­NeÜ6ŠâFElº| 4Я’y¸ï2¯ûmž P±àj=°Ó/¾.e„˜ä‰GÝ:$àŠWL®|6ÿ‚!Ba2Æý}½›¥â–‹,þ×ÞÁâÞ÷õvŪ”1Ìê«T¬5+í:-ã-–£×/i“`†»šf=›~W ùDÍǃI×£"£Õ‹ÁrŽ7LmÉå/€Ž¨Ýí¶Rp¤ëDpÅ›¯Å—q¹{ ˆeHJ~x¾ï ®RcàÄTÐX©äv,ì½¼¦•§˜“ê%b÷ =øáÕg -i÷Œj2lúÕ+÷Øç,­#ó¿BgcþŒ5è¢ø8qÌÞÒ4ˆœ`5kØ"7iDÑ ˆ»ÑE$Çd´ˆ*(5>QTÚ¸ŽÝà€• 2•f,5B”ööÕ½ÿ /F#mÛÇ”ß 8ˆ…¿æn¶V!½öØaÂ`7ˆQ'ÇeY²ôï¯Õ^8ŸSƒðFGW‘‚A¦efr\pf*í5>'ásÎ {0pT’¼@{y4­9³è즇}Þ*¨²<0L]Ø`…MÅbÆä{x+V\À°ÿûÐ;ËðÍÑë÷轃"†Š(ýü‰Ö´=†…þŸÄ.˳Œ2WQµ+ùQøhA øÆ>9Ìà,ëI),xŠaGÓjf²7io12™!½¡ôßž¦Ô‚|>­1²èG“’•×û~ð­ž¹ÍÛÀt¤¦¨97UÁ"3} U¶¹>A|%IžCDós©;z‹—¨õ+ô<âÖÌöà·ÝÉtv^oCðT·Q¸Ï‚ÔBsZÜvȋƢ]ü™$Äõ†d¸jÀ$ÝH7TЀS5îµÓ›z–Ï”4Dî¾}@2ýº<÷=Î4&W—1ûKËÏYv‚7ü ~Þ:՛ܛ§yYü“†­¢h¶ P™”¨ö3Ï¡+ŽÝ¦þlHÐouÑÈ\©µÛl«l(¿ë†‡uD¡x}Ât._Æ`’šh+'öešî]BzÔ`“7P¸[©¨ Ê¥›ÅŠïïŸ2¶šõÁ}VžaD[HwÂl›æ Þ°y+Ÿí¶^ŽJâ]êF[¡Sǵݕh¦6y§æŠ_p3FéJˆ0{n‹¥µWšê–¢”:²P’]›Œnå3ÃMdÞ÷ûʼJdsNy…7ê,Ý?‹1Î@Ì*c1¨ÇaàÏ`CK³êÃé¨ðH…K•›‡îªN*N?:oCÓ]+2¶Îél–†Ò¦9Jo«Väe(ËiÕ5V¦ÑΛõ|¸'o¥Wƾy±FìÓ<©øY2ÑcGQbpgÈXƒ4B‡Ýw(CTb sY³BT5—;™>ï‘n«[ ïÎÃV<Ê.1»5gàÃü^í¶«Î,ÈT[GŸ©¤VŸDWjAÞ/„À|æ_ý–†s?'Åå¥lÁw±<6ÙÍHq%š¤ÃJ;ê‘ÝB¿ôq±RêÆ÷¿æ•”‘²°yj¬k—f€‹Ôo$¾¸0‡ßTCø¡TŠÓþÕ‚NÂB •ÈüÏÏœnÎ÷õTš1ìÍÛzåfö×ßâX9iŽ-ÄN™¯Æ'ã GÌÙ‰\‰Ä{•''üÈtA!îuèªÛb÷VT±·kã ;/½Fæ½_aÅæslóD9žë èl€©ÞJÔ¡ÌĹž-##ÌzàŽ›h“[y°Ã 2l1?ö9ÏFÆõë»Ü@ç€J>»q{úšÀRsnC×Zð/«Fòõ£Ø<ýûC5’I´0a (¡f>nÉÒ’ï§ pq…í€VOÃëÉLú{öT x!®©çX#;ïD»¼Û¾#£´£Ý%xÕ/K óýßFaƯýÂP×^;ç‘áÌ1º)šÆoÚj¥êè·žKà§|å4´Îô;B9aÃ>MɼÇiN”2¡&ž`äÓÁ…Æ#,¦Ç§³:v·Rtþ¡b­PD7±!®ôþF¡õÞ\q˸ªN ¡hvˆ‡6Às_+'QÖö±§+Ç'Lãˆ"3}yÚÓŽ9ñ¡„$­—°¸â-¬Gt½*¿™®YÍçÁ…POªÞ•¦a}ÅãÇ3o~vGlwþ”^óÅ@‘P¬EF q“Œ±6¿{OZ ¥²ps?þò<ñX¥ zÆfGõ[ß"õÙÝü5ˆ˜ŒE8Ø!€Êµ€ÚŒ ÏC%*‰Ëó1Ö‡•#Ö+BÒJ¬`Ö•¡zªðÇ\ìù›QƸ‡ëGÀ°%—Ï$¢Ý¸¥d+µS¦ GYi.“¤Aºùœ}q$>FoŠÂŒDò@Ÿ‡Åß×Xí'F¯;õµ'ap3}èZ°ƒÏ?nÜ{$óåÓ˜ùWïOéb‰ôï^šÞÉ~ÄÑeõΛP÷–[=0@°³ü^Ä|èm£ ±vòNèfgoˆ—µ*¹ãíðì¦M€×ÌùוWŽq‚ütÚ"E¸uT-Ù(LSå_þˆ`ðq! Z[„n°œGç4¬e©(Õ«÷{o&±Ô¢é‘:‡½ÊÌÆ||—8‚ø2¨ŒçÄÐt8ù6V4¤f½¿ªh8,ßÙ¾A³€Muw̶#à èÿh.[itãïV!½1ÒE ÄšèDô±5þ:`I˜ä-ìņßôª¬ÅYC&äÁ»V ²ßÜÊ~§šX²š¡ö!¶€ˆP_L JÚso9õ"~p–[=Ù`þbÈõ€WI:z„UÙ<9˜ðP&bM$“šH"•3}4ÔÒÅÝ Ð5BT8UOœÎ} Ié–ë9 + šž¥¢Pßœ,Þ‰š,ˆ_Ë”³7‰ø’Ú;cu "PO¤÷4mFum©ÔÂ]ƒã»U­çS+Ê9öÅ Žx#U6ÅšŒÃ¢¤Çêná—f° j»nd&z2ª<` éB*”À—Vã…f[?ß qÌ}m²Ï4Äó–vhDÒý½_ICG¢;¤ª¨“Žm,ö°‹ô©•Ê̾é‚[æ“dßÓx ›R‰_tðŒL±‹G®üd% CPô”QU„—³›}mïÂÀÿ;ØæCXÞ$¥tHBY§jâì¨pnf%,³…äî$¨'øM£`eKðcmð=ï“´2õüXØ›¡‡p ׂ¶ ÃÄ,^äuüžÀªéýa‡"¼b8Äòï_‹uWËdnxþêª6ì"¥S†í²Þ2.>àØNízÁ9tJò'“%°²—ô#§·ÐÁŒ!ÀZHk­Æ=[H`ªß7¶p•d߇),hå}þ—z=ÓãÌEveWJâcF£?DìÏâÆêºß{ÖjL¸Ð{¼GÍ,y²P•]ücÖ2bg•[×:›}#¹clV-]­ízY°Ð¯¢+6Ô¬ÉõaOt2½qÿ}]#±ð óûݰ"F:1ù¶‹Vòõ*‚'Ü‘â”;ÜÝ‹#ŽÓm~r,þ·JJ–6»Ôã³ÄCeLóNY‹Òþ= ¿wèq°+i’øì ²ï(w&ð<1Óê¾·ØrÖ5é[Å hIX¬Ÿc»}t‹|{Ÿ­!Ê)ö„Öêái»÷=O¨Í¨@S¤--VÍ‹ƒ;´öI-c[ZÅø8¿a÷„U68¾kˆmSiTŠ[¢Û;П”mÒx5·½¬.˜ÕmÓXeêðKü§uñ‚œõwÍ\ß©µë E^}€B«‰O´×‰³qÎ`2…ňʢ‹ß, }γ5þJ,Óúç 'W{¤*f¹<æÜQ@š@Ü}÷d81ÜV½"Ä Œ‡…ž«ïye¦Üô†' žyVL”„Ä Jé?„üÆ•›8H»1ð5„œöþPêÔ©«¡ Ú¾¨$V\„î¾ú¬GyÂê†EZ…¸­€Ó!Löí NÜfù»±ð!@©‹Í‘“Ü£{ý@K Á´…¨âto¸MqVM„¤Ô"»eЪð*žP4Ç»‰þÏz*Þ"mUaH@6O#x9Jb,Þh¾ î|ªŒxŸ(oð®°l¶ª¼îXPda j&eɃhm:Ù0MªlgGPs/<ôË/.±ÚÓZÐeôi•7ßu~DnIÅ$¶pÆÌ ±¸Ó9º5££ÙMQ•ÕõëlEåÊìt˜R6ÔkCp${ïÉ×OŠÌÔ¦øa#ÚUÑR9ƒÑFÊãõØÌ÷`ÑËDÕ|¤kHÊ"’k=1ESlÐf?H"/õNå¤e‰€#ã—lÛ:C÷MëxêÔ¡pj—}fÒŠx¿g›dÎ?’á=§Äxºæô¸õ€ŽàÂ÷«A¡ÿ0‚¨qEˆ}ˆ»2Èô>2©õHšü¡ý3gÑ% oNëÒc„|ÊJ챈ƹâgië2SGcè¢Û3Ê7©êKLô›‘­¹o~ƒän%X<»é–i‹Å`gÞ6KBÌ›QÜCÓ†®žªÍ!ŠñŠžIÑ=‹Ñ,¨ölä·ŒM¹£HîÞ˜ÚŠŽ:¹èUÉx82°tíøœÂgÓã2Nw}÷‘‚InÉ`ü,ô¨+ëJ!űÍóùÃ#¶ ´¦DA¦ýõÏü~cØùð‡Ž¹>H`&W÷ÎÃ,¶q‘Q¤Þ‰”æÃ!¡XSEzæÍÌrÀnªÔòÕMØa+mSÚ}Õt†¶8 ˆ÷äP`¶`Ñ6~p3;(/ØóWÝQg%±ïUÜy¯%šXl$ʤÑÔz/ág#2Ì?™¯#j³#h^D¢`š½ºâ ±ÿÅO†‹ùžnÐn2 Q4.km[îEçòGäþb<>¯a ñòt+GÁ÷g/é'~ßÖ‹Ôl—÷a¼VmÊðH@Žß`¹Mþ äUy<„!ü;s°cgH¼L_$i¬„ï›3î#DïÏç/vô£½µ$„\Ž ž­Œ£‚^±Ã&n½”uqÀ[ÊÒSE›[Òl¥,¸ó ¾ —7ØX­HAfÅtKéá5IZÃÞj½”Àý×E•O‡Ÿ¡ä·—|o QŸ]ƒáRĺ¾SÝh|] L-T ]âÚàŠ¤k?e ì-Ó ø©5Ǹ kæsq` j:1eÓ¿æ«Yîq4 ¾ªvjþ梖F¤gO‘žP‚<ÄYŒ;º (qøŽò”7TjÒ* óÒgíñŽ3D»DÊB릒|"ðG=K«z-üYW„³99Ó³ð·ƒV¼`‚ôMÅϲX#Ç~Ìšö4‘®‰kPê%ÈKbIŸ=_Às“c|…Ûßbß0ÓpÕéqM>¦40ϳï½[Wë5¯*Ù¡ä0õmDÓ÷Ð1Ûl!7}gѳ.Áî«!Ϊã:¾!>A|%㪕äHìi×}¿ûÉ"riv‹ÅrfC"U¶2/c×s2ûaÚŠV†AÚðø)´€ã®L€rý]Ê5ëK.9÷¢ºó„O£F# õ|™3@8$DŠÆ8©÷"¬¶ÊW¯•±ôU# $ÅùÂZ M'“>þ¸½aƒ©ÜÏA„Õ")4œ~èN°ü|°A‰Î €¤Qÿ‰7äÀ%^*2­Ó@–“i/jn+okÿLR2n3§ÕÌÏêäÛÅD6ê±¶+ÚçÌÍC¨¦C˜ÊÄ)—¬e¦ÀJ'Vp§ØÖih‰IòûÑž†]õãDžøèÁ„=I‰f²ìª}ÏNåG V1*­Õ—£©÷p¬}çôŸ_¤4,puÒ¯›ô‰MšB1­Ré›RTþÒ´p@ŒE6Ú~£FÝðoDØ–wYéÇ“ù¾gäXùhË*íªŸSô–Š*ë ØÔÅQUkNš} !nyë—Ï<Ý{¡6Ø_® ŽèT$a¾“¯sØK“ºÜ¼1•ogÞzšÞ6^j >Í[ï$Fµ-àȪþ:-p’:3ÿBÊ^N(åN“…BÜ™t!Ó˜îZUÀµõáQŸòúæÃû®¶_ˆ]*­øçô²±L ê $¬Œ¨?úªgO)qg‡A~ÚÏÆØá¾˜Å´;‚ßâë* ÔtîÙ=ŽiC‘Sr½ï‹ŸªàŽJ1Íá5 ¼c÷ ; Ù?Îí ¨0˜QvP ª¨fË$ à' æiYfñ_‹U—fo·lõÊ S4Ba»úµ¨ r¤'¹«Ge77ÒyçÕŒd´xY¥¸iذÖ3Ä=»ü~BI+¸’$×ðŠrM54ã·íæ$ÑÓ7T5å§m 7/’õL"¹‰ý?‘ïß?ln Æå;ølJæ“ µKf„_ûŸ4£Ä2 †PàŽS'Aat©=Þ¡ÝyÑÕ¥ ?«Ú7\1UÔ?®—¸%9Šb@}˾’ZîGöh3ـ弳DÕs¼-ᘜÈLê)r¦Î¦±IšË!vŠv5©WÈ®Úó–Hà`GLþԆß’2,­–LTz‡Õ¿c‚ßÄ­*‘”.rDç ÉNÜD8ÖsŒrÔ¯4uä\¿F{Æ¥ºxà=¬Ý»ÌÝW9 ¹M{÷§%ï“KÈaw‘ØlµÙ îzœ»¦|Nù¤È;‹4ÕŠzûòƒ¯?G6£ÁgX&‘Š‘Ò™aÌD­Á­8Š«'«Q4p‚¡l|òÒ±˜–€eÁÑö¼Þ ¦PáU~ðk©¥M.ö‡ %9ÄÝÑt)œ§XwÖþV•°V7XF#M'¥{%ÔÛÜ9š‘?pA'¥Q}Ÿ•+>ÐðüÒй”¸¢4/‡CRõwn²'ǯ:è'ÌoªÇ2Œdøþ”ÃÖ¹ ÄÏ;²˜ìïkÉòC){>IUŒÐSú³ÅûNºGÒfíÿ𝵸”·st„á„Jn2¯Ö¨»éÄÖŽ‘ºs”šy/‰Ûn£içéóý¥·osÁ‹$dæ·ÂUÈ£Á»+›ÃÌ ûÕñbUôvc¨sè8¾ ì`}'·˜ó5YM9æ ÙI‘G'& 9^1¸:Ú&}x¤ í°S .Q¢€-¯±ÎA-P”ð”Šo¬o®»¥ÿƒË€î³!àÚÈ¿PWØN#ë]K(Xb—ØwC¤4êWá×° {o[‚Ëåò·áVûT8z'z÷RóƒTÚž¤ÞCYi±@Òü!½š9VvüWh¢£;©¬%K#™Þþ¡ê˜ÜËž]-¿sÀ}ñgdm‹®D&Â}Z=Øü𓦰›ÇHYbceø>PäWRÌ„‹$L²I²k;$1CîŠí¥ÇÆÌl$‰›ikz´œÁCžÍžŸ8JWŒÒù¾sŽÖSðN¦vÄ£Qõ6Û†÷Ø÷ºb¼yYŸ>:yÔZnA™zŽ?­[{ëw´Ò£KFY¶³oÀŒeÿybìæúh˜ò†Æ£Ü*ȱ§Ķ$‹•+θ•ù´Oüe-b¾7Å7&¯7MMª Ô™4âNMšê¥Fú–}oÚϰì+Ï%Jxy®¨@”¨ŽŽg¶lÃAQF˜‹PG«üŽ r =óO,™õHf;SHÂýF²ØÉ´”¸´ªõò[¦3À]-ðÅ+ê#paÀ@vQèÉçKVU#ù5ÒI2õBù°ÝÏ+ÆÐFgÄù©Ÿ4ô±0ÑŒü!ìÁ îJ‚ µ€%¡Š¨4ö]ì)±ážˆòá€û©%Ÿ§ž=5 ç^‘´bŸ’v«&Ä[‰E†õ@•¤?[ÎG¬Q0. Ы1€ ŠÍ3E¼G•²1ð5øÇoˆÅ˜/Çâ»—JX'~AEDˆžúâ†ä¼çGo1¤Ò6•Kdôº0÷f¦>7N½‡å³Td©‡*Žù§zœj°Íƒ1Sƒü+’ê5¶¿UNÍpoê ¬\eôÇÚÓ‡é|•[áŸ9…-¼ wË0_”iíDÇÄÇ.Å?TZ^~Ûƒl©æ"à¢m¼½{âUë¤áí9n¾á{‚ü·#Èàsƒ§/­8ûâTÊr}°’R‘LÄgõ:¿ÔVr>ÅCDv]ªÂíQ²½Ì_¶ß{:]Â’½|0ß0¨F?\¼-#fk¢ÃæÞ“±!1þ¦ÿ –\Ø(+p %ÈuO§èëdDh“X¼Ç^7¶˜îfE$):/ÑFC{ÈlÂ{Â)C‹ÓáHзzN$â>Ÿ„(6Q©oSªì[U®æ€î6~À[»PBË1Ûd-{½[B>ä™p6óÐR¯W Pïï/ƒ 7%Öa¶üwÑtÝ÷G3fÒGä“¶ª‰ÄÑä æ¾7‘«ñâªLé: ;¨ìI"gßZxŠuT]/(pòżNô‡ a›5îסˆ±éƒ…°©Ú$q«ïš'ìGqj{ïY á¥7…·{ÞêðÎ’†3BÞPFΊ½§kÿôÑ@ÊY­%Jß‚“[̆D1Œƒ5|CµÎ^nŪq¸ £ûÕñ}Z;î%“Æ$"u²¾7ÐhPéj× õÒ׫¸‚žx¼Sï§èQ‹Õf‹<´-ŸòÓH9M¯Çç¹Í{æŒ0tÓX˜%›.IûŠÄÂÇ\‚NŽº6ó –+…®M/wlJwÇ"˜„òŠ$¬Û‘ D½›ÛóÂn$_õáÓ´ph®}¨Ô- ¶IQ¬S'–‡‡Lº§\@ûã=Mùø6çÐñ½Õ8Ö Å.,æ则vÙš|Øv~먪_é –SþœzÙD¡ðê q+ƒ$²’jë=}&ÄÀ®‘¶ºEþÄp¯t2:„›Ñxöý˜h>@ªq¨ì6a"ë:Ÿ¾Q<[„üÁ€LBQý­Þ&y±»±•`õX7ˆR-M6êˆEÄÂoÕ3 ÅÆÕ¯’89J¿Ÿ+poó Ô¬àA¢%µ¨€•åŸì§AÞƒkžæ¢OAjR PF=…¦(©Sf˜3Ö¨7I³³›$Ê’Øü½¾wF°Èº×I(îømÖ˯¥¢5]£“ýÞn¬äoGzà{VIG›‰Ø]>úUÌp’d·š&)§ª=Gnúhì8Ÿùæ×Qø+¤,V]·Á’ã,-³tâ{|¸]U°¦7.ì\³n¯lEœ?Õˆ^D]®[‘>·¡†Þà& ?Éí.)Ölæ]¡À•ÃÜÎØ2Ž«J66ª®b•Ä LìÌ1ý ä"EÀiMë#µrϪO‚N)]5:†j,‹R2µ®ê¸(ïXXÙeÌ·|çy0Œ Cïž„|à‘C$Z9úðÛm^ £m/o¿‹X¯È/$Ì<;vôr<ößàì0il¤L§ƒs›“Tæ‘3=†Á~Æ¢ñ X­nŒÕ9;†0xÀ ì˜Ñ®‹¼ïŸÈ°ƒÅ6‹èH> ìT¤$³œf†o«9Øà£óøŽd*-/‡~êl-ÃUߊ*j·ý)á6qÀ;×§ŽÙ }Ú„{«¬¸†TÓB¯úg½3_þ8ĸñ,éëÿú¦ÀµZKµ²ãNp! ìô-R2=ÒÍ“ÁwÛóœ ¦ühÔ/­öu[Fæ!Í.´‘£s¦m¾¸ýˆ¯¦Þ–0Yõ¢­+Q¯ïƒÃÂ¥Emõ—¶á4ÅXm–:3϶Ðß}¹Ùê#µ`·ULüy Båx—¢—øÝnô ¬‡±Ë¥û};±+êƒ$'“9N ]xÚ?ê´ÝÅÄwÁåkæ}’¸ˆ|xtnË)è÷Ä[¼¤‹1åæÕH´ì°š÷RÆÀT›â„픡0ä0®'‰K0å»ý8/9–ø±oß— °Š#z¿¹é¾â^B½‚%^uñBüpIŸ4o1@Ö™äB‚¾cÎÈXCLt×5«ž+ø€±ø‘†ä°ªW¤KÚSôb<7£Xñ!(×IÁ'ÌÅ.÷ ó³lŒ¬&W¹ª±þo½7Ó\Ø1(IÓpØxîÕHtñømáOm1” °x“g_U…×±è'ë~Õå.²íOaºÅç_í XÊt,åZ¿òTÝͽ¯%þ53¹JFËq⟘AלÙ9º¯ñm+Åj,Ñ––åŠþ7B‘ú™¼O²’­ù¸ÒÎÃÙb±ú‰ß!’>]T±‘1k©D˜<ŽÎÇ ÄÒ˜]Ø0Su– S4^·™~V[Ú*/c n»O~] èì6f»Õè‰Ï$‡Ü—!`ëÈf₃rá§ú]”ͤ¥ò_}r}õ!þ*ƒnÇZ-°?!U\äÒÁmŠžÖÜõ·=õźLï†ñ 0×Îiïi´CeýÁ!ñkŠd¾B Æ›Þ@ŽO ,Ð#\â6]ê9 «Ñ¶P#sô¤Ì¦N¦Ûû ÏqKŽe ÖùRN(œNeêס¿Oˆ)ÉÀ:V÷à!ÔŽk±‘å=»¨oöùjMc•ñÂÛ»÷óèÜ´ˆk¥Ž¿Ÿƒ¼©:YQ'lc8¾}€Óõ˜Ô®âPÜf«„OøûNèÄ­’d­m«hÞq— ©3¸ë7úÙî= »áòY›´%³v… JÐÚ:8‰¶}øHñY¹ìëbGK"ªet“©0kbÛÇnx™ÈO —ëçÛƒ¿ã®Y&¡¾‡©zë Öƒ­Ëòý®/°—áŸ0„ü{¿Áƒâ‘îk"¿-G̉OîË]EÃR*·«½Ùþf#×^WùþA]¥¢}ŽL\mu(Çs¾&TÓwý.ÛÓh”ÔXMzvæ09É÷†Þ¦wÖ¶·öÞx~"W%ˆ¬D¹`Af©½‡§¦pw½Z~‚Þ»ÛÅùÖzH百N6ع”.~GrìÁé¹Ý …µIlðöÓ ÈîCa;ÍYœÃbHv@0Æ ¹þ|b¾š+z¥’t¡W–æ":ç;q}/Œçwc¦*o¼ FÒ£t/\·PÊ hÖõãWžmàžòƒýlª6ý(Å*“Ò%²OVŒý!ºß~Ñ «[<‘Ö÷ÅfÒEŸ“üàÑQFzܧÒ,p“M¸Ö«éúd´>û9§s;ØOµ³OçÚɯ1>½hhACï÷ص¸9ô–ë#”ÂgQÉ0çžy‘æãÁüwI›‹‘s¶¥9½ZŠdSÂwª“O”%©‡Ãn«·EZÖâÖ˜él6˜­,=R»-¤º;\ãßøeßû’Ѣ̆~–,-¿¶ìò ÄM„'àÛE1 ®¥D]ãKc†ªxq<Ò*Ñ­4FÊOñ(ŽÐêÒR4¿þôg^IäsJEÑ·”Sø“žP9Ò'E“dåâò阣ðÑ^r÷i±ñÑ¡¯j´Ìö¤ÅÜeúvü ‘ ý†{VôU@fæ4!LÕª{äî+¨¤V ĨõÙóh- X"á.ÿ5¹‹@Ì-7rr!9G¹ÐÖw+ÿíuîŒv y(¢éÕ«F/Í»dç0^Þ«)«¸HÆÞ¶•¥NÐ<%éâìøœþ‹¼ô8 is’au€Ý`í’… OõåÏ[œ»rê_öèj ÅÝtu}Q"›áj$»LKý»I;M^¢3ˆõÕ§ 6Œ{ÆÔŠy·ôo œòU§)1áñI¿,Œ:ùùÞ©»ÃYÙkë­²M¤Í $ÕÊ´ïbd åH-NÛ0 D¼R·îÆüK‹LŒé.ÓµÔCÏÌÄ,këUÒÏò%÷ *¨Éþ{§ûߨä­³§ðk}òåÖàúoJ‰1 endstream endobj 95 0 obj << /Length1 721 /Length2 17075 /Length3 0 /Length 17679 /Filter /FlateDecode >> stream xÚl¶cp.L-ÛvžØ¶mÛ¶mÛ¶mû'ÖIrbÛ¶ûÎ̹õU}Õ6Ö®^{õ®î&#w°wUõr4c¢c¢g䨈+Ë1122éY`ÈÈDœÍŒ\­ìE\͸f¦3G3€™‘‘ † âàèåleaé  4¡úw nkdjegå Pw°up·2±𺻻 º»¸Ñ;»ñÓÿS¤bfpµ4˜[ÙšDµ¤ä%”òj 3{3g#[€¢›±­• @ÖÊÄÌÞÅŒ `îà °ý0q°7µú'ú°w7svý‡˜¹³ƒ@NLUH\A^ & *0²7ÈJþSnïêÂýÚÌÄÙî_ÝÑ\ÿgÙýÏ2þŸõ¿¬³ç,z&&€©•‰+ÀØÌÂʆá_ºIÙ›;Øÿ6usüoêB.ÿðPþ£!ÀÔÌü´›­­¼‘€RÄÁÎÑÍÕÌ ç`jælPv°3²ÿ/ÊÈÎÊÖëÿ÷R®Fÿè doñrŒÿ Y¹ˆ[yš™*Z¹þ#µ¹‘í?ý;®aöŸs‘33µr³ûO½Ù?züs¢¦ö¶^ÿwËÚø÷† Ú Êšê4ÿ€§ÅìML­ì-*®ÿhiälú¿À¿ÓŠFVÿ™žÿ’ùï4˜þŸ/gäêlå Ða¤ÿ×x0þký×Òû(aaO:&N. 3€‰•ÀÅÂá÷ÿ¡kâæìlfïúoÁÿéå¿þ¿ÉÌÌÓÌfmÙÁ„'Ô:£=¼Ê_¬d¶œfvÚPf™ xåoï²Õ°¥©Ááν*N¡þL1ßîåŽÔ}±Q‚ÜñäT,Q¤Þ2ÎkIµ…ýÖ»RÑ[S¤þ5˜:¶‰<ØMÔkÖúZ°"õkNþy½´S²S¬ae×8Òvâꣽ•J¶ö7œÙ>MÒ¬eXñµ±ÀëÞHDaÈ.Ü ¶eqUãa„Ö½Å7 ¬ÆŽ±}ŸË¼G¶´8õñöQDWiäý7Rj…Ù_ÒõE î…ÖCrÇØ[{ÿ¾ÏÞ'-U(${¢¨G¬9ï%¤+kåø(jnÄ'êƒíHæ[“ý˜_ÁT»â?Ñl6¿·ƒw¨±èÉ'€–´$ÈŠB*³Ù%ý«÷j™h“s7 ‰ßmµlÉ ä<—Gk^t§„V„# ïÑãÒ]+j5õx{œ§~‘¾íMÿ†ªßà.Ö­{tz©Yk¼mp©¤PXêÁŽ,ÇÌ ³—pDWZV²¬_¯ÝRx”,êÚ[¯aü„ÃAå7âv‘¾>F=/ùˆCƒ£àÜÃÁrõòGnëÁ\ TS§m |Ô¹Ä÷Ñà:4Å–+<©É“áÍ8ê•$ŽªžeC²M&Öd$ “çX¹i ðñ÷}§ní!¼rÝKÌÇm $F‘ú8âçyo\‡Œ ö­¡3’/·.ײݠã*EáêÇb¶SCï9h,0fýUœ×ó½\.÷Kb<º+þè-ˆQØ û™£Òª89æàW ר~ï¼Yú£½feÿ6¦¯h Db:­øÊlki/•€Yû“Ñãõä‹Y˜Øª=9É–õñ’ÆôI…Iò€¦Ýã ì•2ìŒýû¯»‘øÛP¹¡OBü<ÀOÅ*å–‹A2ÂàVÝ^ù4±´’·ýóT‰\Šxû’‹,´îÌlÿ¦ºögBx—÷€›û5–ºWýõ–eXŽw\tÊtàÝÏ£yÁþ¸HÉ8Â÷c˜;…¯-¬SŸMÑÖþ;hjBÏÕáhž lââ+/ë–T¾#…yy°C]V™xÕ(+P«ÿ:N:Íî5P…7À0jÈÔ²F8_ß·c6²žxdV÷wæÑˆØC¼GBßׄS¹N >áÙÄ¡KÎ_Ï~:VÊG/EGázZožb§WÜ„¡J“Ÿ(‹Ýú5µ1eë,DÞà.;¶¾ï¤B€¿yõx|j—#)íÓ•Äî4íÈu/9& Sú Ùe Ìùƒi½là‘¡ïÍ+3Rz¨;#H€‚½vñxò<¹ÉˆLQ02ÒFözPN[R•žïðþëÁB6|iG×e¬èÚ™ãNÚÛã^;¹ÔË®ï.ms­eD/Q!]“!pç ¥Bñ×òážB‹¸Å_䯳UÙ¥TñdÙÉÆj²Ê׌²ÁQ&gNÔm…-¬RÒî´ô~"å´by ìÖH»¤;_¼‹7·az Z¾!<Ò: ÛVqhRŒÍYC'@ñîVštßIû~èà±/Ô‹e{¸uºÌ“Ü2@Š-N ®ÞƒIKZö Ð[#²NŸëªà“ÿñ„>÷ü±7K ²Ì†ê*¦wŸ¯ÓB°/ÿ”éùÔ gË@ÔfbMÐdBœJ»»Îï‘ûZ¤c˜Ïh$3·V^öéZù’üþ—#océÊâë&æR,ië*‡ÏØC‚ú€Úû ´Ž6Jç‰cØ»?ÓÜßË‚¾óJLb£øä¸0OÄ¿Ø>=Ö.¯3ЊU!úD—ÐIx¿S_œ1…>0“ÅkE í\ڠ؆EBá’)vpã>Ìßã vÚ«?°ø¦2$b‰Ðe”2óHT(C"%>CÚ‚y b_Óóâ8nmaxÊ–WZ¤´·Ø”©&ÈÞ›ŒÉ;ŒúŽGt¨ N;D¬ZˆçëUc¾¦¯ånæÛ½ÕÐÈ“ÅM2X;Z#\Ï%RÆ=–…ŸÎU)TcGF+°ŽùxЇP7&p W´,åQº°7mŒÇ"j¢h«u~³.“÷è@܉Dë MeŽ.*O  ¼1dÔŸ?Á´bååyjšA–m6449Ðp31 ÕKk*q‚ó˜|:qñ¾PЗ¡¥˜£‰£ÔOR´#³ˆß¼'½L-‚†u+Ùs¥“eÀÒÀp.ß¹zÍJoN*Ú ð‰ç·]%bcôÖOñ­ÎèRÍôAõU3º²å;ÀZHºú¿ŠðŠ1ß±¤‡fèÞíô6 ¹Vë„û;‘ºaí5§§]³¼ž€‹®µ‚ŽÃ8×—»ß?‹0f~^Ã"ü,dhŸÛîÜö§_íZo‡¦é¬—q’9—ßägG@¥kGÏ“ J([z–·ã*ú_†Ǻf9Èj«ÍDÒ¯]¯Œ‹Ë;zÆgÇØó"`;3lÇ3ÄM±ç¯Ac<´WЊšçë—Æž$£šõàBm~×~Ñ|™5ÿæt¯=HMñ=Ò:ë˜õÊU4ù0p¬8y¡™çæ¦ãT :¸§9Ô¥sÀ‡œ¸ý>²äã›]¦]pƒH¿ê‰‚h·ûÑöÈGzZTýÆ ǽ6ÿ€Ã/5^¯5“Ëo‘¤0ÛÂê㵚wñµí €­­KÅŠk·9l¡^X÷г˜»#ÞKJ þ;ݧÚÓ»ü2o¤âNðÆÿ§ ­çMvAbÌHàÙ´X]•“ÍŒ¿v¶g=.>Cч0¤˜ÝŠ8 ö·×˜K¯–Q»*P?‰hÂâ9÷ÜX‹Q÷²E:Ê—º‰çâ~D7õp-"Ï/#ç;¡øˆ5X£aƳ­˜¤$ˆÎE`8¼.&ˆ"æ9a´¢\Õ‰k†ËP7e„Å™eÆV½FM³¤ÝÇ ½ýpú zÝŒê¦Hô˜ÝïRgPý^1eï”îb|„sš¡\¢Ùõ~LfYr\­_ZÍ.>rè š~“‰îÁ:Òõ£_?¤$kH‘ö?qª¾¦O¾èö§Ñ09˜sÉ›½¤âfm‰OmP ß#E*Úó#p1rˆ"ÆR¿JòI¢gâ׎õ ¿rnæg¥¼^¶¾íîj¹“žØÏWÔa–ÁjŠ™Ðb—šÇ­ª.÷Ø?9¢v×]Ž-—B\‘9¤¼®BËaa~¢|pBê³m0¬_VŒrq¹j£³ÔÁ!£MNf¢‡a“÷]Œ›;U=ÈðÀɯ%tî¯Q0e}—Óñƒ0×f”í\ée‚Ÿk|„Ê`º²ÃbÐÝß< m÷6³ËÛëuyÖ0Š'‰‡ƒÂ½¦ßFrû}:²`¨R¶ÙÓlÐÅÖ,€'@ÅwÒÿðUqÞ·ýø|ÆÂ7±+âYõ ^v ’i(éš´‡d~®£Ë)+P7åÉ«ûËþž}Ø=ø~g/FŸ}wHÌ:1ÜPXŠv»(bó´Iò¤Ð=˾ߢ"uج”KÀgk¢;º'“ú¶¼TWí)cœ±õfé©©´Lârã5kúT`ýxznFo`¸)[uUÎäom@ŸðŽéÌ4ÍÌ£0x¢™G“7²kã¹pŒüŠ­â•5ˆ‚÷¥»¸Ê>ÆùĹk7=ë®A½>ω Ti9C>;¦Þ0¹…9]e‚öü‹—:˜~òkÙ^C`šgŸŠJ¤ª\Àû>ebmg•XÃÉoެÉ ?µRî‘0¶zæÑ‹$–Ûac¥-*§ÈþãsG±MvSk6K. §bÓ²@V…‚ó0ßZnºÔ †ŸYR€½îO—¡ Ùvä²é‚ºåÀÕ1Aý¨ÛMn±ÔÔƒŠÞéô@eE„hƒ¤*»ýYÕz¶=»½eú<¾E˽ȯcìë`#‹Û4`PóFà¨Êþ ¡y[ìÍ“&bü}O—ÀƵct``4¤!$É–ït=M"‹¿ñÙÏû¡¡@²ëôâl'ôØ“qÈB@üÁ\t uôÉ ÙûG%Ê_x+†¨øÆŽ„vKƒ4ë¸ÛT\ŠšBù54xÆÑàŒ5R5„Ô<˜ouêW­£6™Ýïa5qx°ëZ+ü£MvAô_âXèaÂÅkãÆúg¸FêL J²¶e©p¶w¦O%XBMÎ1©ÔM×ó5 ëÎkÑ ¤ šT¦h?Vxúí"d}Âû‡9“6¼\r'¾ä§ ¦•° å¿}TV©Ç¾ ¯›€y £ 1º¾LrëK ¡è¤·· …_‹•‘ôиÅwPz‹¦;û½¼‰„oÁ€òñ¹Ã¦ÞÊûgšŠá“ˆ¥oÖßÜ €æ£nËí¯F¡YÄŠÚíP´`´RIô»þ ;_ómxÍÑ ©ž‚½‚•fö0ð2T«ÚñÖé¼|u§%þUKMí {Ñø÷©–K”à Æ[Žîo$Àäü)õKÿVÊâ’Ò¹ð9͹ð¯#l&ôâNfº¶¾ít]çd2ÿ‹þn‹åɘgHb'‰”ø‹ ]¦.Éw¥…Eù"\ÿŽ`G²3"t’Á7,Cºe³M׬2:ûöih¼úÚ8|Þ]£UnOô†kH\#¿dÚÓÌ:ù ô@˜µªŽu*+ÖY^méA•äY™ÛfåQÐv@ üë£E¢oh¼Àx5'!,R4¬¨ ì/¯EÝcØ^®Ë8¦u§_ɱ v¤ôñ´¿"{ìÏö0éCÓt´à4|RÍãbÚæpýPªu“ƒ‰,yè+wq—±ž7­C›–ô¹þ²÷7¤\–d/'WSêÒÓªó¢ÜÁÛ¦[Erñ:­÷¥ëÛWèɸ€-èí½Ý½–ß&òÃ1§­á}Î}‚•;Û˜*ˆŒM:»Ké$d>¯Hè2kÆgÎ9vp³¬}Íw›÷ :ÁR¡´}×—aÔÈèåË@ýý4‡ w™¡}¤TóG­§=±{y#£A˜á–kºh½ZÎΗ“§WEýÍð?¯tÂ(+VÒ‰wY‰P—TèÔkÏêÓ ü*|´neG¯yölq `¦\tnÎÄeÂWi)àÛ6¿ýK&§Þˆ’“XÍN<.c¨¡Û‚a?ÖWƒ§‡špí(B,Ù\ôf§·“ûevx%Š3~Õr»Ñ9pgÝÐh|)Xlà܈‘Lî7\ÿK50ÄJÆ3D?ßiÔ7ããH••Úÿö[Õõ#£,IºÅ/ ƒ‘$èÐÑJ{¸’Ä$ŸÑeãö?àÑ ƒ «\ðÄ‘"#ñÂÊ›ú[¼“}HÕjaJ3s&#¹ÝU¯qŒ¤­Ú¾f+"RC[”vªªµbÜØ¨HPà[ĵC™_äºZ© geïë¢äx $ÿ–drHÔæ•ÂÁj‚÷.E&‘"ÛVAÅ'Û»>y·bèh0„¾”¥È•A5‰:R¼­wî¯$Þž+5¤Â­HºÉMIÆ>ÝT Q×PŽÎtAì.D$³¼iûÞŽ#4„²K >ÀÖ 6gb×ûY·ˆBŠ_?Ær à?|­"¸¢’ÐA*òyÈŠÁêõeúK·3Nx¨JÔhkÊzy$s» Ù®F…'Ÿ/ EI¾Ì?€R <ÃH̳ç¢_°ŽØ)`èXÛL7áócê¥H ±íûAùýë$Ê«^ë75¶íì `{Æ&‹¤ÓíãcRº(sö§YÞ…ÐÓZ˜>dô€Ášh£hlñ75yº2á6&25Dt‡6þ®Ö9sxw3»gxž¹}¿©´´¹QŪÞz3]¤oºS§câg y¸Š©÷,Ö„îÎÅŒÜ9£ÖtöâQ-k…º m¥9ñ‰˜9%f´…@z³·¨ƒnë«þ½#Ó‹,ñá š…A7¯nËŒÆ##z/m”#8Ãô%h:âý«„§ûºeâ¡äRTС%[~0Ûß fRr¤¨§s‘ƒy1ècÕêEäªMWñÆyZ5qãrH“ª⽇z©rÒ ì4ɸ¥’)«1ÂÞô]«<Óº«…¬^çÌ…nøÒ`_ðšÊ ©g‡?È1Þ´Ì óÁOçÔÝP‹$´!¡e°I™ `ãؼs‰â‰‚~"ýÜHì^ü8ߨ÷Öæ¯©y®?rPÉŽ–|éS•" ó³*æ×‚´!á.øšÕÁ #Q$ LW÷ëOÔWÛÅ>Ûœã0å…àbIN@Øç”îÀn支ԩ/Ô2l¨÷í’¬åËx»I‡ª. ù ±ˆ‘ãÂÍ<Ñfÿöæz)aöˆºæZWÖÓï±Y˜"kðTÙh’@vß wz»â$É…€¦ó\ŽM½ˆzõÒN`ˆ–úBmµ„Ý? 1¯ wï¦q–‹aÔKâZV‡!»£‰)9Baª çÅÌÀtdÕUéK÷剦ˆ¦i”"Ô£´%«¶`‚éÑÚHÛHYÌ Øs (hÓ«¾sÈ"‘â+… Ъü^{¤)f?ïrÉ«kà—Ђ-õEéüŽ*ëÀ[ñ1a΢,¨y¨ú tJÄâWp¶¤炉CçBsxý=Ë!&æøF8‡m¶ïƒFVSNå`%Ê'¸-b„æéÀÂ`gGqÅ‹CUÚupVKéÕd'½¿aϺigÊCÚ&µc*|Ië‚vîàë‘™ ÜW9›—f\(ÉÕžFÅ_t³U™>oqÂåuG^í8–P2,ÕýI5cÌóSX\žVm¦\#õ\^:qN¯D[äXD¤,ˆÓw¡ëUŽÓ}N«!?þnPÿQ1Ÿäšqûw+í´V&^ƒ¨íÁ¯8ò™“Hòt ž4¼½µõWj!3’ÆjËbÚS¸PiÊÍŸ1óÆ!¥!“â”ö»UÝ k%7Ú¹àœë]›Ò>Øþ½ÒÝñ…„ º\ùÛË ÞŽ}€«CéxÐQðåÂaÑÑ¡ó—Õ…oEV=~÷éÉ<` ‡g› KÆ» wBÉ1MŽ™ˆ¼c±Žmí˜ßðÀ>Yeh “¤Ç·€»šfµ÷z”%ÇeàïQÿŸz)1ÈS÷‘µy5ëâåÝ¢ãm>Ÿðëv&$y ÄÏŸ?Ža»Ÿ0i’¦dOŸPÍ@·R缬£Úo+¨ ÌM+þÄg±)XëìkåoÎÁƒA2ë}%dä*yœlê÷œcžI]N…&øSLζf6}ÂsêHÌ®¨òÒï÷%µºÛq§–ΕÞ5›t.yoÏ+è¢r yÂa^ÃfI ¼N¤äZ$þºyí¡þ©\Ó­”„= G{à ½Õ ΫjT¤ïä´ç¥÷ƒ‰-êpô,±ý…»ðöžÔްÁ[B¤Ÿ¥jE™¶Æ7ê­÷¦XôL°ãÝóFD¶Œõ{ê÷ Ô'"_ÊgâKàÇy²ÐÊ1;½r×Ü„fw‡‡îüÌ,ÙTøÏøT%Þ€?Fœ]dž R¬@¦¨¼!â×ÙÑóá7”.Á­Pkí›,[ðñЗáíµ¢#åV@f%©Iôc‰M­Í‚gökð`Xä@0ÓbA5SÉ ±ôšïYÃ!mݺÆûö°†ü†³UÁNÓ¼­Î¯Ó\*‹ÅÊ[ ”«×™§£-à„˜´@R"j&—CÇÍ"¨º›œ2À>€É')õ­?‚~È™ ¼åýLÐDî`œU¾sÎZ:_ŪŽ6vï.u>“’%ªÄfi>Â@äq~¡âµ{Üñîà5tŠ÷]³“ã¼^”¢¡ŽE9Yú³M©!ó½î`ª{{‡L ít~ }Ü+bØ*Ó“>ï =èö((¸‰/åT”Ä–};¦Uü©å=*¼&’Ú†z^â(DÖ€˜éåÊúK½Ê¨¶u7 ³’^3ÇëÌ‹ÞËêÆ('þ*ª°T’CÂ'"õ&ºÅ{µP6Á˜ÛS¢÷?Kò«^€“óª e°nߘ Ó~K>¡ñµEGTl2—MØ·íj\*©#º45¬¯ûˆyÈ-ï-© "Ç_[SÎYëý’jE&='L2ëwÓv6º÷.óÔ‘ä{ãøÜ(=šRô’8ðÈÛJ}íúêJ½û¶Xn]Hä+,¸¶ª~C6__jÖØxÉ÷éÜÆÅšèÉJ#ÎyÚý„6­g0 “›égæk#ŽÇrœsíý%‰÷Y±®ä8/W[’'*Œ%¢ãË”™r@¾ÞèLÈ–/óïXwTÑ«®õ݉œºQú¯£ŒÏ’Í×k¸t¡Ö¬¹ÈàI(“ üK0„Þê=‰‰”ß|ÙØF8´“(–ÒÇbtÕzùÌ‘"=°TªïùÊ3V5îõò°ÚWÕb´ŽO…µ2šç· ¶ VáŽA^xrM28‹ G÷@}h¥W$”M"~N?Ę—­bª> !ÑõÕ$ .0ø4»ª=%5Ãö„ãŒ,/¦W`zˆJ`éÕ!|˜á°LÃFãÞ죽֜çöcÊ‹DñÂÐöÚ¸f2Z{¿}އœ!‹ ~U{£±Ü ov„¥úy¸.3.y¨D"@WÆ1?Ç ßŽvÞ^Áã¡Î2$ôÝ’ê&…Q»v6].¤"Ï©$7³âù!là?ÆÅ%ÑÍÌùIT¼_V½¦ÄF¹^œâcøzÊ"¤¼(T{EŸeTØ öÇ‘•ã·9œ±Ke¿>w›õ€$óÕå(}¬/1¾¿á­u‘½ºT³èŒµßµb9nD<¥’åùIç<ã#Ì)9Ñó‹mB>a´\ÉNÑŽóÕ™ªúY2ÅHù­³©„V”Em(Y`±¹,ÿQÊ é€åÉÿÖêéÁűr'nsðú¾Ÿ\dÌHæ$ÃBQÝv“¾­_¾ÆáJ£k|xݦî­~öó ß÷i~x u7þ˜vC#B$ÕùÕ<ŒàióÏG¸]Ü·‚¶A ¤Ÿ«vw‡æ“ʾƒvü‰©:¼ÐÒ®é(ô+=¦ËaìÔ 9cô86ª¿cÌTZbÇ\pu`‚¼ «5/ ¨?yT)Äd\;9sC ôõÈ µÑ:BC…÷ze‹‡°¾ÊË+õç1ó«z* ·7”U”ùÁ±ôÆL4&È€ŠËˆèŠ Òyùƒh˜õ›î¡Ôg ùÒ²9™ÿÆéñÝr™¼*9çùWqP%.}ƒœ ¨ö%µ›îÌáY/âhɆX à9 GáI‹XóXþxWvgÄBó½|è3ƪ’­rˆ¶Q~ËçöO$l’E#>a A÷`cÉlJ¸;·oÐÖçg‘âŠ'ÞüQh«W´ÎS¤ w¾\;gMŠsvŒa-›ª\gjyÃvÚ_ÿ–Þ4^ŒblñÈѨ•&Bs²ß_æŒúÉ݇‘VûK|}]½”¼ÏFzâ@ä®&ó–ܺ·%UÊIɉ[QèúQ¬á×?óo)<>zGA•ÑÞD1Sñ²#Úö¢ÝJÖ zТ?ߌƒ›JèówëR-‹Å ´[BÕ¼÷úÄ|¸íŸé¿õ‘Ñ-æíÞH¸x~<ÚÃqÇu/~ƒ§iÁ}T*mG„z#_CÐsk Yê-©çí¢@ÐMX¢©êMP÷‘+c!&4·5p>Ô>úÔ‘4¢zÄãŸý¬içB%þ6o¹w™Nÿƒ£‰ïg³^ÖÊl…&lîŸfR§âwÿØÂ‘€Z§kªn7Û&? †‡AUHž[t£b)ìX£ÄšÌÊnéŒAÊ4ØfyIB†6×cݵ”¼ºF{aâ6v„­±Þ&­•Á¬Ì­¶m(T·¼ª â~Ø2ÓÛT=jj.Õ„ZQkß’ÐÏÚ$*“YÄåÖr®óEmº­¯±üpÝ?Mº ?mp?‹u†'a0‹ˆ%?h¦¸mÛK' ž­µ•¬ä½âáæˆ'ú”6«Ì<ùØÌÌ×ýGáGÑSÕø¿ºKK"±ë¢¨ KÎ@ç–ÁŒj7FÊn¾§}°i¿‚è+tsîã¸ÉÌ,§xuÃûû Låàóo'ÂÛ³Gl´YK£±5þ2ÁlRfÛ’õ¨#·BI…ðx3ñÿ0B‘O¾M‰¹Øg…©{ê”Êx‘—¹5@Ýòº–Oçcª¿{äüéŠàWÒNî(XR¥Je^#DOijlØ2ncò^òâi¡’ÓfÄÓ5ìǪ§¸¤Ãž–—Kä«§KKàz<½6—ÄÏ]ï‡Ç_ ä r1ý\Þ òåNc¼Ò ÷#ÑpY´"$y¼PŒ)xKÜûõ‹u¸ÛÃÕɺÛÞÓÏÆùT¶•\bŸÕaV:î®%ü¼¡Ø.e®dñˆs—CF'¬›*7›göTúĹPüg¥EÀá…ÜÖG›£¬UϲàßnXF!.ç §’ÐË}VU4ü­²iWJª›;I¢.¹cÍÏ j–}‰õèz7h޲— FwyŽU²Ã=xNÖ€FìÉRpÏL§x:C¢ÂEè ëÒ%¡ýîÓ1‚µ8‡øÓð*¦Çž‡$9žxއšÚ.¼qײ@ï|½ g†Îa¹è·Cˆ§OÑ Un2—IºØ“«JrRêú9NXÌ h¬“rÕl7ˆç÷1iþ|ù _D­B¼±fJóSvIj}GÀ@nCÌÓa[–8pîÒäE=†œO ×}ôffñ+kãh>[ÓØ,u×Þ[kâf‰æóJo #l¥RŽ}ìÎc±ò§-ª lVáÌŸ)¸&«èº ¯‹ûL™,Ë£ìf»ƒöKrdˆÆÑ¿#$);xûެ„¼çÍ,v^²z%;Z–:q‘Ï2ƒ§…GŸIºá­ÄBüh‘ÅZ¹Tý!;ÏbåS†¾-¢T{B`xœø‘›=rË·uz{$g|°gXA¿æ%žðÞ+§ØxàÁ—2þO ùõ¶Î:içøôaÈóåæ 'æü¶5~!ŽXo:쀗֢ã4æºìîa’ßß)¡aÍßFSÐsÊ1¶›+‘ô3ç[m$‹CÜÞf¤xâÁ¨Îçuq·¬ê9 :‹S§‚“=)`C£;äuï˜ËÆz€Ë-ç¿¢òÕ‹‘Ä$«rt¯cŠÇPdjw*sbuàÚó;ƒ3åˆ6ŠQÁÒIíÛuTŠH› ³)ÕU¨ Yü»*SÉjÄ&(,ÀÕJA-ésÃ!Nûßž¥·ƒÁÉúAöž–îi+ÿÂ#,´0Ò9·Piý Æ =£ÜoúBÐô‡\ŠZâÈ®.÷¹Ô0¬]û©™ð“Çç-'ð®XþAߦ¤tež\îkß`Uõy‘XPB °ˆå† ª²—‘DꃩõñÞuSG0°D hÏlí„kq0öÄnK•Ì{áš <¼ -yÌ {ÖÀdpCµ¹!c|þCj¿=¹˜u÷¾Vl[«né?Wgd >Ù_8°±„»zÄU°;­X»auÂßw•ç¿öå—Ï"ŠfÉ\æ6ŽB>o˜YηQ±CÙÙ 3Q@[æ#"T‘¾·…#2 ÈYœ#JѰ‡Âoò…I>ùðtúÎoör#ðteÖ­i¥ÙH,ú=HÎô’Q/ŒLÞ5y™Ã{¢ ºUçêp‘F¡XÄ|,.¤GU5F5t·kÁ6js‹x5Ï{Ʋ[䔎gÓ¿^šðiÆ€W§Ïܪ¹¹³Ó¥ó ÎÑsÇækXö²k%Cºkü×~¿ïµšV/š-RÑâ<ÿÛçÚ_bÃÙ‘ú•Ê{Ìàþ‹ÝàNr1®í³ÈröÐßT°˜çù9q^Ùp:ó]D(¢Ž•פ¸2iBŒæ[è_»*† 3>~œXN\ÆÊ„IÕ¦Þt]´—  r|ý1ó0òòˆC„ñ}8i4‘£‹ªø¦A×KV7Š I;+×=T¸‡ëúö&v!µþÌ…ûìQ ˜Ø)áä°É×üêõiâ3C¸M‚ÿy]ï³ÄÇÁ¬æñ§|Ë(MèÚÎ0¦/+?â¸Ýʪ®Ǥþ-yÓÉwîón7B‚Iã•pŠ‚Ê̹ÂÖÄÃçëØ³)O²ì-¶}r‹Ë·«lýÀº‹Iïi0šç²Æ²5¢Jdžfƒ·U@ï4:ãÝà™ëÎÌÛU´nÎ@ÙÞ-†úc’3ú|”ÐÍÌÛM$0 ÁfSæ»Å¨#¬LÉK¢Žg‰›ïâÞ¬“šŒÍ6y8øŸr"'-ê´ ˜-–V)Û#«5Ôº~6‹,±Þ¦â­âÔ€ö›l˜~¢¯Í_†xYIz»Ià„CXå ÊöúÜ<YÄénÞX5rÆÌÇž9°ÃØ8ñÀ$‘}ÈÆo6=„Z/ñÌìàòN,5[\b¥#>]Äðécµ¿àS‘U¼rÆ« ¨ ¹ÃÂ0ö?ç9"é³qž•̨°2ŠºJJ"H™^ª_»%X€þJBPJÍÃ…r« ø¨|kÆ&RœñÖ…º3ðŪæÆ#ÿÎÀ1cŸš0íòŒ·Á–– ‘2‚ßÒè7‚Á«ÙU+žI\oùSÌNŠâú8lØFàsdù¹ñšnL%ކ÷áªØ˜€yÅÈçŒC`ýÛRK/>Åï(„°œÐÄTÖ"rð¾ö Q°~¤¹©e$±lvÈ æ„&öåß+<Ã¥bìUù|bN£MãÁæãî៕£Ó¹D¬Ç—£0@y¬žÕ›–sÒ°Ÿ¹”ÄØ0ñäeàÝC«¼èa?“‘{bo¾z$” $`=“w5Íİè–Ý‚‰ò»‘¥1F—Ëw­ìœ†k ðž–ºnwc¡7±½ î'i¿æÈæ—÷¤VrúN"l]YÝõ7Gã4oÎTDç åi©/QÙªž†Ëèˆ/Æ¢håÊ®ŠéÉU‚¼éãÀ¬Ê¹¬@ûýò|Œ l²®ž?®\—Iþ¾µÂÇË—©ÈL^?ém/wX˰=ö¯Z%R*‡ÿŠŠßW]@ux§Õ£–Xd?Q]€þDü¸¾ˆSR¬mp'˜G*"³ÞõƼ¿˜#U>Ú)ÃJÞ¡çaŠ-:r‡Dð×GžSˆÔ ÒƒRñ$ÂPxegEz¥naÉÈu§42w ÄN2òuxmήJýýD6¬¨…)B&„„#{dÁŠÂS‘6™LâáQæÔ4ÛÁáì,Ÿ¡î“„ñs Ö´ƒ.k˜€È®»3¡nžVdu7-¨™ƒ‹¨l¸‡HÂÎ$“¡JGÖF»ñ.)¬¡é¹3e¥h¤]f ä™oJ›•Á]åAú c“0í¦,#N~'n˜9ì˜i_%–iÙ-ü4Köé2&ÿ%åßo)˜¡‡i†¸4c ¹á†Ú·Á¬é­Œ™³‚Zpæ°ˆ¿3¥AЄbHÂÛ2ê¬ÆunsôåÎc AFµâ~k‚‰»ãü±™F…¶Þ¨xøÛ'ƒÕ€*hgŽ]­E|+‘ùU²Ø›ò¹" ŠßíÔr4åZ5 ‡Á¿ƒý˜Œ›o¶_Y¼nÙX!c3‹]ÝTseLwÏqÒoÖ·ˆÌ^òÆ7°N}ƒ=e7Ê…]…âäN)²;ùð÷z@º`p‡Å3¶¥ÜÂÏ`in%¶ä­Fq›¡xmüyÆ¢yõ±QiÒk¯^·M®)>^ûöí ¤¥I Œð¼;ñ<«ü‹œÇn ¡ÑSäÀÁ9O1Öšl]9; Î{Å™4n‹ÓnÉ¢.j˜Í°íŸ²7^œÏPÛV—Šc¥>—Ýp³Û î¸È¹º™!ïȯ\èÙ‰¢¨Þ#ÝmÇE#;£ óe}ã ¥Né¾Î\sˆPø.Àx13˜¡gÇdƒŽnÏoÔv&ÎÒî:Ó>~Ù±ßЭ>rlF±¿ã7Gâs^ÃO“NúJSÅ×íqêÖ‹ö©íþ,‘Zb»Î0óû%êøÄ=FÈiÕî i2½²w—c߆(0Ù÷eta¡ãP­ôûfœ_Á]ÁÒ"ÔåŒ ­[ý ¹zq†n¼wæVà÷Ýhõ Î*߀Uǵ̦JÕ'L—fÞaާÿ¤·L‘ž°…éþΰͥþF*±­Éá“à¬N˜AîrÆ_²ÿôqX—Üò¯’]ä_†¥ä"À¥»!èÜ¿³x†4þp±¿‚€¿JP—}»‡ªº ûkíµï£ÁFw3MðÃŽ¡ñ·#‹-É…î­Ã<@ý}P?¼xÑ—EpØî2©ª·½–žUhó)ÇÔ_©çózèWCîY(]¢üÒ‚Uªég¾“<ë~]‚è´è– ÉÁ,žº(Á/ŒÄ_ÑðÃÚÝš ïÓ– àœÿnðž<§ ÖBWî žef©9x#ø agg6Àx(”–e2Œ5&Q¦½±W™¥A7Ò è„±º°èiÅ«®kЉãÏP«u6[§D“À’êÏ“ à$ûiëB©‰Ö fJûõ³2¢»Ò…Á.å¥y×À¢Å†HÓTÃ)ëµ +6š4my˜h9™ô¾"^B}…Ïg(Tf­Ì©Â £ùž[bÙ,Ð?Í› ׃3r('±ø^Ì=îeä[€îgu»{lš6<¤R ^Ås{—á(ø V«R«fÕ~A "m¶í5:=à=>¦®†lù5ÎoŠ,X§0öŽ ²o”D{Y#fbцí&ç0ÙʦÏgññ…ÕÚHÓ³ÚB™h cq¡º¾îJÁ1=6ôħu«DØ!ÈétïøÞ4‡ñ„µVs¥^ Å“h÷ÐZ‹ž…|þ\¼v`ªIp~.Œ- ~¡ôú©Hd©WWó~ ˜Þ_&k±*¢ø+Z´ÕâJ%@f!¬$pº=y8s9‰‰ÃöaB"˜ÖS²\0joÿÅh’\tè;XôÍ£~ É[‘ÔÕˆ\aåý»âx‡†¼Î©fvý‚š~´°  ènnëÁt:P\á,v ùJ`“ÏÇý¯„õÐhÖùÒRTb= É‹µ£¡à\é$hr(OʽŸ ÕãL­bú— áëpJE‚ÜXe$©&Y96úfÁ¡¤HL ®RìKn}±ÚJ‘õq°·`u…`€t NÔGR-¹&ÂÃËåÝå:Ž(ß‘eê0ÅêE¡£¤]ir¹b“ ‚ÍrÀÐãæg[2vzÿ\|HZÚb+5Q')ÿˆÚḭNæË:G`±§èû©D‡S²`Š‹k䢀–ÍØÔý•4 vg“â ëä­bûþL< • ¯ƒ*uTÉ'O¹DyŸé1Þ ʶ²Fñg‰NXÔrUoh¨Ë¨pÂóGµƒš0„gúì»rA¢‘“Z…ÝÊæv¼Å~ÔM•' 9·};×³Ø…Šš5n¦Õ—Ü´e.~q ³ç¯¿yà`˳VÓ‹Vùßi>Bh¼9íË÷——O£ŽÁ¿4Ò‡NQýéθ}÷÷|4Çá5ú¦uWmõ;¥f·˜`àË N +„ÊÚž›DØðpî”LdºÀð£ÙDŠ¢Åºhåé’6Ī#á&•ÔiŠ T‰\rù¬¡-¸qÂ3¿FCð4™\E¨UêSчX¿.|Ò¨‰OXÎУÌy¸øG¿£]ï‚ô$ȫ•*•±+-kè v2Øûã\ù5̪€µÏkd¸cù15£QejiåçˆPEWQÜQ%vm703¹‡]˜QÀñA@Iï}—®žúÕ2øÈûÑw·6Më,bâðŠøk/o€¢6è5¤0#É«:æÞ´¿‹À%Y±#=â…ELã56š,ˆw‡’‰Ë«twË2Çɯîä‡W#šcüµpå—쨀x&/¹ ¹®p/Ùÿ€UqÔþÄ ÖiÌgÖŸ›]Ô5Æ=žrÛlF/؈™_Ù_2R{›dY%{L5¥dè|  Çç˜_*w2 ROŠ>Òv’I`÷ÖÿrÂ;îL1iݸFÑ×ã „U1µlEÞc&BU­\Ä¿šàpp#XÇÕÌö+MW•”NÚGœ,žƒG¬`ô- U¢Ë¨vP­‚5ó¶ÓÎýTN³˜ö\2NkøX†òêzSíé瓽+øÖ1-ñf!—¹jÓŠö7öF=e<¿ŸßÀðÍÂU ð$ÊK?E=ßÚÚvgR<Áãê2Ýܘ•ýrsçù#Am¾x˜cƒñ{_岫xGàiN·8C`(e™´¿¤¿úT*…Xú«Ä^ ³^¨JÄ ÔJ%2Lò0ôO©‡-ÕUšÈ’“«¾œP>~°þLF¡ã\|.ó’§2ÂØÁbÉ|‰þGRŽ=U™x³_œ€~ÊãNÒk‹šúäSó±†~öc€ƒã8Óo;â¥wÒv÷l"¼Xñ뵃iöîÊÉP†§µþ+4[©Ö?IŸ"8Ê/S×Ãv­ðYunàÀz ȾÐ*ô¨ªËR‘Þ¼5ÈÙŽ\›ˆ ˆÐÄ&)s ^a&yÕ (­˜™¦ÈŠ?ªòdb¤Û§x¨#ö滟ÑÃÌn>id€T+¹«ÁÊÍ[)Ú+­süsË«R×s£ ÞŸ÷¸öí„jsXå¯Õò/ó@ohq;!BdòÃo½ëI„ËX¤ïÜ“èËŽÅ’ü‡çÃd°¡Õ d%¢9¬$þC5åúf+~Ìæ]HÇ$&Ÿ1m&,£ÖhF¢¤ô"›ä?¸ÂìõAKÙ ½¶G2j#¯VÚäEY§6>µo!FL ƨ¥×Ì×O^á…&u}>ï~ä§ïœá´ ìzd1w6wÁ³ÛOYî*>%M"r¶ÆH¾ÕSu‡À#LuÊã¸%Ÿa]àÙ®N§b~Æý&D2Ε®Pè"ö”ƒ‘‰n_¾*¸m溬øOÑÁZùô1ŽBóªFžÜÙsw°šþà(Ô1b›ÿ?n‘ûPw‘šóG’ž­ňã)-ñîÞŽ¬ì¢ºßÞ©“-Ñ:gl§µ¾é;¶D–ÛËÍýÒ쿽E6h W*^  ×¨žŠ¹–=–Z’×òÀûô;l¬ƒ!SÁ¸e#ýE`.XÏ¥þ. Œ.NýVÔÍpÉÔ7JÝ =Øh 芛ù>û§ŽÕ?×ꃠŒŽÏè› $µT@䙎”¾µÎdy@æ3ÞëžéóÞÈex¶²8ì—`s¿ðÛÕ•É´Ò8¹zñ2M×ÏÄêÙ³|¿õ)ù _çKáP`ëß"ÿ%í,îN6ãÊÜm™9XVõôI¨Ôå¶G¿Ÿ^ì¢hE÷I SP£‡“ƒE iLjú=µöœä¤ 1Ü©¤´`ð\"ª]'ç½Fj+½Ñ¼W·s‚œ ¾è|f9ª³<úIÒ›–™Ù{*dJ8qRôàëpŠXW±EX0>>¯VS9µ½*3-ž[ô!+R%ŒæM—§hdÈൌ“£ï䊒ãÁlYcë-±Ôïîxû×gõ1œû Þbûì®é_7CâöP½ìz¸šö Öòç¯V”Qqº]Ýg(s+àŠ\ LbuEÛ¹C›þÁ£\Ø‹ #+xriîÖSs¦ŽKkB/£Çž@Uꮵ*ý•®ºƒÖ±ú´W1[ñ„ìéõZPwl T‚ûD2¤¼NË—h÷$ƒ© èáa^¢A5¦”êE:Ã>1 • e;†ã·²Ôùä#8àʵâ†PnÄb, P¢ Å4ªä–9·xkãñ›¹=µ×É\5& MÉHdléSýPZù1d²EOp–M^oOŧD’[Tq$Øä9fÆ/5âW‘G¤´‹&ä£ñ Rib7eYo!Õœuü r¤:eï‘Üí?4o)k>üõWLåž@I‡­¤«`¿;ÙfÌŽBNð×Zw¢ïü™vœ§±µªØA®¹U™ds™´1ê6ªÙª1E¿IȺîžÙPì<Á¬m$c¦|‚ÿ•_‹’Q|Zeÿj“yŠZ÷¹0‹><êq!o1<ópYUãÐCrx}gÚÉ}!+òÙ»»o\ÌÚC§+@orŽMÎ3Ðzíþ¦N'èMbA☓Pyþ”©F#—[¿˜›æEÃ~Cx.!æ”ó=zOÌ{ƒÇ”£ceÈIø\ÌïË‘ö¿MsÅI­r&-:œlÅ9aØ,©Â••C wÓ±Vµ•¢ÁÀíD_b§}šBŽ“‹ƒ°Û”ãàˆÿ|ñ¸¡ @;æKöcfñC3Í; endstream endobj 97 0 obj << /Length1 721 /Length2 12854 /Length3 0 /Length 13428 /Filter /FlateDecode >> stream xÚmyLÏö-î/(îVÜÝÝ]»w/ÅâVÜÝÝKqw{½¿û¿÷åI¾äË–µ3k¯ÙÉL2”d’Ž uO' +#+ /@MRU•…ÀÂÄŽDI)æ4Y;:ˆ›€€¼- 9@ è`eü…°"QÄ<]¬-­@3Ú‚M;sk{k€¦££›µ™€ßÍÍMØÍÌädú[¤@V@€…µ ¦¤¬#£( ‘RÔH€.&ve°©µ@ÞÚ èà ¤X8ºìþíÌÌ­ÿÅÉ•én@Ð_b.Žö uI%Eu€„³ºÀÄÁ /ý·ÜäÊû 4s±ÿWw Ð-;“ÿZ¦ÿµþ›uñø·Å„ÄÊ 0·6L–ÖHÌÿÒMÆÁÂðõßas°ÓR ¹þå ù«!-Àhñ ¶³S4±hÄíÀ   @ÁÑèâPu´7qøÊÄÞÚÎóÿ‹û„ Èä¯"–•cùwÈÚUÒÚh®l ú+µ…‰Ý_‰þ‰kÿ½/ @sk°ý¿ëõø»£æŽvžÿ³äß6þYYU]RSJ‡þ¿ðOZÂÁÌÑÜÚÁ ú«¥‰‹ùÿ¤•M¬ÿ==ÿ!óŸi°þo_ÁäbíÐcaú×x°üëûeð¿Q¢¢ŽÞŒ¬ÜœFv6+Çß›ïÿA× ìâtý#øß^þãÿ3H@ Ð ieÑÑŒ/Ä&­)¬ÌO¢pº–~zÒXƒ~‘ri¢ëBúßÊÜhÿŒàZ Ï…x*ÐT`ûtK溑Ü$ˆò{l<š,Ü`‘àñE¹¥_õƳJþS]¸á9Œ&¾½™"ÌEÄ(cu%H™nœã{Îqµ¬s‰†k´qi[,úfüòÜ­ƒ­5f¦î; p—¾ }Ú*´àÜTèqgê[^ð6Ê%¾‘UAY Óþ7Nšž­ùVÆK™kû6÷g@“ŠÞAx|4_• á5™ ¶?–‹»â ±E=W•±3£qÇs°–üÀc¤­¤§Mãx›Lœ¨‹”5…GªÎhø×ë·2njÒ‚Ñ(÷%Ä4Xcæ# Ps9ê@øHÅxgŽ1éÄË„W,ÿk‰s¬–©úÝ¥Qå:%£ÉéWP¢Xõ‚[DìÈ÷5\ãÚQðdµÐï+'4ó»Ð®DËÊN##VrWêÄ'òk>RÉ÷¸ÔƒÞæ˜m©\Ä&gk8 ½iºªì^µ½]ƒ\"V'±Ñ£"‡Ã1Éñr\eÃáÍ1Ô)g†2®î7p9ŒVèÚz4/˜ïÈÅþQKÚèu'tÇÝÓïˆþñ>f±^P4¡]ŸÅô”ÙvRüL´}¤a£*ån%ë§kµ|jæû@$ÂÖ‰Ui¼f(­uœ¼#-ª€-m°u’&™M¢O½SWÆÍ@ö¦bÅ¥í \¡Ú/4Λû-áÛı5Ÿz@[¥Xþ%©à?ŸŽÁÂR:kÝXkh"g£õ¯1Šû9z#’º:€¥møÕ8+¦¿G¤äzªR®¿ Š/)²{Ú¥¬±·gè]Ìf€H'ƒ¹¬ª5Ð ÔýÎ-û.Ëí_œbS£öâŽz”²p¸úí¥3bçvÛO×™ÎÞ¦(6B ÙG«hk¤ߤ¨•DzeB† ¸ó ¼îg6Š`z02j³þnÃ)wÿð}=?‹‹.ýk‚«©6±å—ïO.aXnjÞ!qħœÉ=;Û:%ÞUv¹Qg“Áq–æ* ‰[éÉ -Ëر:&É,`>έq/óÏ,p›býÄà‹ŒÊø«¶˜öêS8+³ÍÍå/þÚÙZñŽŽ€Ë^¹9Ñš!÷ìéJØŠÝ‹ Y`˜"ýµ“5à’²X;EÆË6~ÊÂÆû‘TcXb:ñç!Íc¼ŠÐ%Ifj,·Ù²º‡'XÖzTÅ´\¿ª1H¦kÆñåö‹PÌAl@Ú¦ ‚!ºâèÉN_6÷„oû´õõ¥]·æÓ;#™Þ¦É·S®®Ç^2Ÿ,Ҽџm y½¼-¦"åÈÞüu´7\…Qâ×µ¯@N²±Ã‰‰ÜXž²ÄgqÅ0‚*™ó"Æ£j™mr@ÒuwUX:®†1‘‹“¨•ñ8ÿ¾a¢•C[|ýG6E]…ºç岘OR챿Tó&Â6Zž.iÏ‚¯¦¸Å¨×m{æÎnÅŠqº‘OY|2Î⯴Ðo›ßâÓθ ȱM¥r)Š­²Ã–=v]Ò‹ÎJ‘©¨ÄŠÓD¢¶ 7_ûÌ?:û ÷Nù$ŸÑl…‹’Oj9êƒË¬Í:ø¢êïïx{­¶ÆžäKË%.ž¤ÌÉÓé“ åÄ$îW͈ýF¾zJ5azWiTÏ»jw•åÂýº‚°¼Ð ±F»U‹„i¶·y0Z‰‘œ ${ÓúÒ†éÎI·‰3E¨à.Zß½(ý8 Q£J^£ ð ÿÔ¡@İ5–MÌv¥´fê\¨=Ad,`³òÇÃ<´V»hÀÁ‹ƒ¯Tu®»5uI×-m¹I­×ã-Lý{h\!넲X¶è}XÒ÷C~$®•ƒˆ,âT7ž0Ø»Lk+í¬d86ý°zã¯AÇÖi×—åaö´ŽÕ1h¨çoô_®gÐTWk""qq LxsD2õ¼P }>XùÎRe·ÊTöÄ eõ1ÇZ(‚·žøŠÃ¦„££°N‚¤…†?¬Ö4¡¶2oÔÐÁ¥Þ“%\'Nfœ¾ :üše_Ì€•»;éu=§Äm‚G†\LI1ЏƒñÖÆØé\þѳOàEÓIgT:ÛÂq1º~Ü—ƒÌ@t_×B{V¬&o4ò0ÍvÔ??G†š¶µ}«Š¬Ø•˜¡ ÚEàZù´ýà’vÅèDõõÕ݈†&x^g†w…¥FÆ RZ=Ôè…£UÇØ×ÇË:&'NÉ£]âÅ`«škµYü6oÍWI—§{:†2Z(LTd×» eo5ý6…V¿Ö2AÈtEÁ\ˆCÒþü'iÒ†€Úz;ì6Ï$'E2Ä‹;<Î{c4•.|†Ìé+Ë8,1S@Ø„\±×QË“Og*÷›u9~£Gü¦´õp¿Åþ ›ìí7þº+Ì$h3_úç—_ƒ¼uüYx?ÈÏDen®=t#Ta“‘‰ªoð’V Îëb·ð×\[‹Ã§º.XáɲúÍ­ô¤Ü|«7Ó£wDéQ˜ „SPnÙZÖìxxú½¦‡ÜýÒˆfxºä¾ðËÎâÁƒ=½óÁñ9žÄfÿ­Nɲ§O¢ü3ŸÐ™Ó7èé c‘•^úI¨†¤/¸íÚéÕR]ú!ã0»‡óha&•xZ”h’ á™}\Hk3)s ­ß5L[‚.è)"ˆ4º2÷eˆUÔË/ëê‹f8¸ÖAZÊ„²ð¿(;GçmseC(ß5¡ °ñT`“S—uá€ó]8ß—K¾‘ò÷Í »Ò@ô Ø ï}6xü‰¡¬/¥Ú÷­uEÇ+ \ ÅÅêBm:àf%P^èE|‹ìÆ©Îøú³|_µøFÍÿ Q?D€¾-ª—éK=¡…SX8À÷Ò?0DN×hXƒTPýY\m‰vÙÅS[’p9.)úô>Žhf8êñ6#í²do gˆáo “ÜFtk¿Wgë'w˜ÍÀý‘±ý]í4udw «‘K»° ¿•|ÆÆRKÚâmo©op ß7¸oucR[1K[Ò&ÌñßBãqêt£xníÅl£:Xr¡¤›:~CôV`ÒŒwïõvK¨~Øï `ñ€ï‰‡Q\z¾JŽÔ[“a¿2¯¿Ôú^t#2Ü^r‘ r åv±¥!£#ÈtjnZæÑlRãyõŠl¡êÕ´ˆÀ,çÚÏÜÐ)2´:áfc{Çúx{þaÏ¢¹{ïÿvH¦2¢¨ùÙ ! »l¸¹×,Qéûh²ß’}ËPž«)ZÓo –Íü5@#³I|¾ùE„hcñJÏx=|JðÀ©S „3ÅZÃ䊣5F¯ˆËçJõ vŒI C!¦8Ù³lÉPwôð $ŸsœÈ!‘ •.½ Žš¼³(,| î·€Ev)§Š±%ÍÍ"6ø_fcÉ]¿ WXÙðÕ~œºÌá;f¼ò¨Ï@b ž†>(>æT?Ë´™;:R„»É€ !ú¾Ìëã? Ic¾R´,‹ŸlèB ÅŠ¯âÙXD„$`:™ñÉÔÂÑ< õV-`ö«ØQv;{ûÄJA^qÛŒYA]i£üÜ¥Y#õÌ-[—WaQ¤KO€ ¶Õ÷W,|´jQ¯7`Ô–ŽØàÓp3žvžÀ81æ›h¼¹‰ŒÝ™\ì“Ì—a]×#Â÷K}ÒÙüceESy<‹é 9Þ¾FˆKù6 EDÌ\ÁvÕ5óœï¾\‰°4üGhæä±=/4„L5—°›Û̺-»êé²Ì‰)„¥ð)mȶb¾Îdà€9çÁv!G3;C|IøÒbÄ''!¤›–/O”Ë3¼]–{2^C­èÌ{ÍŽôÚNàapþ&õ——¼2_î#\ŸpaRäèRÈ|ªÀ %¡¸7x^…¼©‘'‰j”ƒá7ºß9ÝÈšáø4é¥, Kiû0·êµ+ í@6Ö²÷Ëäƒ7œ$Æ’èï9hïÜn ¸8¥oÐìÐU9 :&ÈãC ´øý´ÂÉ^‘Q pWÆ[?I¼½ÎÇüÔ/ÈøÖ“ÅÆYYߣyd}ôçx-‡fÒîèˆì>âª*õ {jöë&tÛæ«­gîN€ÇºÎ»0¡ÒðrëŠõö×ÍD‚JrÒ²ón°ó¨ð–f¬ØnqÙ)­Á&p£$™Ý1Ÿ•|+¬#PqÔt\s‚'±Y¶¥›¬NÅøkÇ€è¶ÇŸ«ñ ‰3çïG zE]¥I;`Ó¦¡÷ëKÚ»LÃ#ž: „]efJ…ä¬ÇfmuÑ6ŠÑ0â>$°h4„X7óZ¾|YŸ¡–3ÎŽÇKâ9Ù‹¥‹k9¿Gõ…˜c[—bñpsïl_&H˜BõŒy.¢…uƒŒ™evw›‚qüS‚¢pÏ=®ó ±þôœ6¶:]¯\Þ&æ[J%oÒ¸ÌZä„=wo¨:üEFz¸©ÿó.^9rå+ f"þp¥ÚNÎRK$èVZUÇŠsAºL–ìïƒöé¼Déì…ÒÙ ÞdC…›œšÖ¯¶Üo^8€6ëúyNZԊ˃.”ŒK„`ÜÇá_T€sÃ4sP™!nÕë ´&ư¹ÜˆˆPw qÖmo}epé£~S6æ^ÿÜú©v3 }¼)d·4þ¡¸&bÁûƒú[DÌ\([Þô2ÐCÍËx«ÍìrLvƒ¾Qd1 Û› 1#©ÑÞÌû¸={³:)^ÛBo¿¡0Â¥§h÷cà$ÿj½îÞŠéK ,KƵoV’§Ë(€}R˜Ø$Ý–@‡¥2œ8UvW£†Cºzsç[G[†˜JÜá3X‡'§œ††h|àI` ÚF©Ít›†ÚÜÅåŒ}ˆÿðöD÷6hK¤b ½AkaÐ3û³ãQ‰˜ ö’¿ æ%`Ô¡×§ôøèô አé*=ø ]©¼UŸÏD.8çårÑuômoD»Á-Áë>¨*œ¤ŒÌ±½.›Ð(„ŽN?)‚ ‚ë}{š——Йo 5¾°y—o«ª‘"h‡„~Ã:“4Äf`G³¯û`‡'}„I )JF,"…猪gêzôÌ,Ä4UÓÝ`Åu[§YºŒc¸Xhfeb]),\5–#c嚀Ueº†û©”×e²”z×ÝúŒ©ÑÚ†ÇÓƒT¨â%rí³íP^Þ›¸?|„¹ÿx¬±ðRÉP8¬ÕjX;ˆPv¢ï=Òç·©5’>H4Åñ/Æ] ©À˜ÁtÙD\)\é±I­‘7¤t•˜ óyò—_OÈT'ê›±‘½!N—ò°fZk`ã„Qù˜6Yô3dZüÁïJ¾H«Ú8MÁÁUR}²_ðã Ž£x¤Øq-© 8|³¥-%Í;Ü"{²ºáw4$C™R1J…‘‚y^xÓfñù‡µ/å“ÍHãSù£Ùnº1™»„Ö“SóíOjsõŠ6{¶Ò¦q?矅¸ì¤m~Èúªƒ@ffE¼ÝÏwºØ ”òÁ ¼o®9@LBµaAïLÃ$'ú‡ukŒ±íì#õŽZ*Šã³Ç€ŸrBÐE tŒ®D_°_ĨvÝW> /¥ogœïÏã?ð-»ê݉s"¬Ô»aBµÒÇßG¬¾¥aDX‰›ùùöÒ‘Bš4Aúãj§³«ë%ôrýü*6h ymGÆžeƨ£Ã˜yƒ¤VÙû&L¥jÉ…D ´mdøxBuÇþ db¦cÆçÐË¢O“{,ùE6 ¥pÉh$fßaÍ©`ô'Ùv·k Û24ž{¦·Îá´R^ÿÓÝô×gœãóÎÍÙÇDÍ\Ê€I³©å U/Rìt(ÉšŠX:‰ì-”}‡æyy*E‹¥‚ô'ûO/$½_Üo7´°í£„ST#²¥’'±©%t.º·é ÿ(±;^Òµ Oð3{n(CBáNš¿è%n:¦þ¶4©ZfÆ‚/q!eªï5R¿˜[>NÇ”œ*§WWŽLu¾8(¦0tØÕ<¾!]ñxí =vq’"Žux#þèŒö×û²žqË ¾SGÏv²7ñ™³ ç0ƒ„WŒd:ï´×ÉûDú)@¢|>ß ×î5}ÅSÌžÁ¡ýÚ‹'ÿµºªlÌ~„9±©Qª;ýñv•g©„ß[]Úrƒû £‰ .Ð'g\溇 ›ºÍ–’5…@›ý[¤æròõ˜}OÇGà´odíEùPò·ºH„à壶 ¹\¿ X¦O1Í^@JiJõãÏ ›G "Ë÷§Ù(^ÝVX2gÒù˜û•qQ^bõ"Ó²– éAªr6V0rTNæ‰3MöÆÞÃkÚ­¢…è̈©Ôù®·^=Ûs'0WIþ)—Jû ò›hÇj‚‰êw6ƒÖ§i—z|{çØç_É3œ1ÓC–3eR¾µoÎ2æþ }’:*fÇ&ß,Ãb2sg~V oÞÞFkD0E·¶-[mà«C1Ðʺ3#WøñÇkŠv&›Îë_!n®ûjEìçí0;Íý4ú1Ò£º­¿¸kwÕÅ&Óëâ.†(Týø',Ò }è-8{ÌvP¤íZ røôÈ¢KžGЈ£øÅ & «¡Z ·ëGKOîÐïŠÚá•dLº%ã(ËãÊ„4ÚœiÒºÿØ›÷Ùæd‹‡@+@š£ªÛÌSòФ¸’J3êzí<•y˜¨0š§0(P9™y÷Y(7\(‹œ¾ù $êñBu·p—·Q)é»wïÆ‹¥¨oàÿD…f†ªX(z’&Ùfc›Î[•e&Ž>zC®¾!¢{¥m‡§.7ªßÿÜŽu›8£+iƒÐ›hpj <‘5üµ—éºÅQkïkˆ;ï°î<ªœ:ÜT mYàM’BÐLÔ|Áçg}t’—ghˆêbªcXãð-³³øqéùÊXx¯£ÿ¤ì@LeÚJ‰uWbz7z î}l àˆ¯{ý=èl:HŸL©‚^-®Hyñ¬Ñ)ncíð®•B¬1Œ·æ+£y:¸«eºŒt§5y¾@3é2ãàïjí¨êñL &Now·ÜrKd\©+ØÙ‰¦Ü¡Ãõñ¦~é¼LÀ£0<+>§±îIØàƒuCm!Å&a:Âή؈yÍnWAÝo¬ÛlûòŠé«!mA&ÇÚúÞè‰7FÄ.#x¶ŽÊÇ\Ëoµ¸i¶¥e^-9gE±T=­~~fs©lž» õÀ¤ÊéVÄ»²Ó‡F:*7Ë8‡¯¿ñGâ†LSÒql;Ã<ÆñÁs7ßAù'Ãá7RËŸ:}pŠq‰ü.Þ‰»—Í}Ó9©°ž†“<݅׎6}Ú0ü¿›'öÁíÆåO£ñ9*-±?ao¨Î\-{Ys¿d…+î¬9/÷£ÐK¹I­—&O£â!ZUáŒL@éÁmêW¥þD50­TÒgªö(D(N„Ú÷ÁXm\lŠé kધÅõä;Ú²ü‰§¡†\$ íX˜þJ-ˆ§9–ÊÝ’aùxSÀ19™1<™Lú’ßÁ…›6’À«à+B¤úlË,Ì{ÌÓÙRàÛ´'’­hã&Tuq‰Æj›ÄuJ±ö,Ê®ÕÁ Íã·J³¥¨ß'ˆÏ 4Ãã½hÇt‚Ö‘–÷Á!²£¨H¢ÅD©ìÕÿ¦ ª?2jóbm*E[½VÍ!Ê© ì6±Ríž s)ô^¾¡E fIhðWª§ØmÓ«=ðd–Z‚ðÚ&¹åõŶÙ,*᳉FÑU=nòHŠªAPÌù¾Ðh×D8ˆVM -®PUâÜ~0“ÕmœÅFgøE6•hlÝ)[2QpmÙŸö³}H†neŠˆV>§rw j.{f–•ž;éÞ/hd/MÇë„Ý+_òv¹Qª wÑS3$cK|‰9h´,ê…!쪊 ŠR”lüFÏ‚ëƒ××k¨R=‚þ\ñÖòçb8%Åm§˜C­ª¨-¿Öv8ïãÁ¼GÂñWî‚x$¢ ¡~¿ÜÛÌ{£˜6ùeÔп®íV ô‹(·f,tUfáhü¡™ž>ïùœ†JÕDFÍr:Xþ[E*Ìn_V>ÔS®Y÷•à?Ÿ%VºÀ‘¡n«\AºÃأ‚¡õ¡µËÏÁuʤÆ*9/³UH7wœ2† EY2¯ u—â3và#]+=d0÷c‰šPÄUÕô–þž§±Ã^\öÎ=ó Œ{ p¥:‚QL Jÿ²f.èýF až‚Á2ÔǦ­í4ùjU¥«ö@-u®ëm®S‚´õÃNsYúÖöàÿyóZ¼_-ø½Ö iy‘§©˜í%Œ^9', ‚ŸuøQl¥Y>„v­±½¦qÒ/˜×·Šã_DÀHo¾¼w¸®ªêvÉ„ùƒþ¹J¦MGG8_õó×X§/,7þŸ<è¡¥„;ß‘©0ÑÄ¿S9M;d-e^¢ë„uÜ5Þ©§ÂOºdÖ/ʪ¿ŠÚi÷ÆZÃzåã±ZÁÍP 3»×@ùQíµP¡¥HÕœ(s'eµ7œÈ Ë:ÝHÀùÓ#‰[è8‹õ¶Ó?ðK¬7³0…¼mo d¡]ÒÍÿõhHµ0€5b‘bð}ô€iÈœ4î?JShËžø²výtP¡ùLü ÌU’–.‡ewVu©ô›ýC P; ’×k"^¼¢ÆÎZÆe‰Í£1F/üÈnªCqtv·ÑËæo%6og2È ˆïKž †6‘"o-<3vø)Y{e}#‘!ß(A^Ëz#Rä\Q—ÿ©÷mzŠ’d¤ï¬.xßYûÙ*€Û¦¸޾°½WÉQ\¶K²Â,‡µ!Uæ .ù%ÅvÑÊ©«d‹¤”üU? !w‰¥þÝ„}øgåÓêd¯¡O3[ÂÇ­n½|ŒÓÒ†±AQ=OëÜËÉG%TÁšÛ/ùzª¤°Å‹-·Ãàäúþ;‡µ‘ê6ßÛ° šËgÿËêΉ)ZÍ• íXKÇoöD€÷On àÖ 1ÕoÔAÏÌŸs ‹Ë,ú¼UlHêjM¦^÷·ä×ÛÞÖ %hÇž|åv¯Iˆ—Wô>†RIÎ/mô0ZNóèÒœ5ó O1AÍrë“ûû%©bœ¯ƒÛ±rÜîÁÕã's†•á1Ã)¡]Ò-îɦ+5ümV¬»æ)ådhK© +n[Œ€Oh5¾"©[´K9…äÝÕû®ˆ†}B7Ñáíè”E´Ewß96ÀôR§LP7CÌ ïš š³Ãj)îÔÆ½ãT>ôófÖj‡°9ÓN'×îcÕÇq×ðäeŒ­³.ɰä£è/'5,)l#àfúøÂ7¸¤i‘åª1e£(cž,ÐD(&×99“ôX'¼½Êh?NUYu†‚[¡îÃe–Œ4T©BNÉ ’»’œ#q·áÇ>YrÄ nv˜ZøM’r%‘egpûb…LO-(¯\Œ¦ó…iˆ %{ò`³RMï q“­„íœÄÁ ¬bøÛIÆ ”æg·¸)ju˜¯_Má,ú•ŠNíf?¦E„Õ—¶D–Ýgz®@)„†!Ó ÇsļƒŽô;¥µ"ÂÌXèþËàK¨pÏáL_É£ßé[Ož†Òp3{6¬.ӯo죒r5ÆW„¶ë’¯Sdé*Ö†d}v­Qù„7…®ÎÑ2ÿJR ZN!Y¨j('y½åâ€ñ§<¼­ ^±â¦‚Åkºt.Uâ6úṵ««Vd‚9B€ w$|«™N=ßx¡lòmËçCu®™s_†Ò¦øu1>o#RˆtÔ(cKx)‹vÿ‰Þ¤psS™o¯¾šÀ{ #h+c[ÓV̉úžz×6åÑÌûÇÍ9õ3¢7¿º­út3L9…x]@ª€ þ|V÷¹7¨ } íéz£ˆšVðѵ*eöI‘‰zÏòó¬r{œD k÷ÂBÞ¸¹[@¥3spºù¿ß¼ý§~ï\–µZc-F¤•õŸ‹žì.9Dûî ¹ÐéyM#é&ãwc^ž²/FÁá„!jEŒÏÐòŒšwøÿ:(øoà;Ù1•‘):6äp sìMƒ´`Ï£ÏÅˬ¢rš#°ZÔè[“ÔG*3‚±Ð ¢ÐÖâ’p°¨ ¼ôXòÖ0õ"®|Ë¢êHž¤|u2g¾7„Q°·±a«žÑŽN6iúËN7YÞ%N4á½ú96r%´ú–*Æ:Ï=èò¾¥\]äÇ“ïa)Œ"ö¡ÜÉKæñwBDµÂ'ºŠûfžÃBM³2GÛ9TÔ¸µQ>˜½k>:ÚÓë¿ÿFd©ý—”6wCö+R͸ÑðÏ´,*ÍÊz·Ïm2¢~}Àb!·9~yÂ\1ï“ÖËç‰åj¥H.Øi‰¢m(ë·Ò Šj»×-}£à QÀ8xŒ_wûü2‰SH¤Gš•¹o7ð'8¡>ÃÖlC‹AyBXÁÊíJö—ÙÇ= ?LMí2ë5a $›·­é&u«ô‰ËRMÍšð1‚Æ`uzûïCƒ |Â?b‡ BÕÇ“éÞ¾BàÄ4Y‹³hv…#aÖ®yòLyú/½¹»šªÁCYIµŽCí¶ª ^Ì‹öÎ6“S¡^|¡ÌÒ›5Œ75£×õ1~Wr1Ç¡ŽÙ |h¨z,]*KZÚûº¯¶w À o-“ü¡ò›V™ÌóÙÀø¥ßúP…î"ˆuä“ý+¿ÞáfF*Î BØ?q«úÄ×ÜÄäÍr¢À·°«ýÒdÄ,Ž\ñǘîV4„ØOÄÚ™»¬›þ_jAæ”ñ¿UX'¥ü¾+ Ǹ0¡§ˆ$kÕ‘ˆ{N;6¸s]Eéø#d ¯Õîí…ØJö >¤/cS·J_a>ÈÚ\Ñ.°šF <­¹T”§ÓÆ3ì½kf)4ëꌊÕê0¡ +"[£ÎEJ’Ux¬…7ì@Ó;_ ¿v1#îtÉÈ èU¬ ïòÆyMuªxEÉn[Cg´Îëž,í«:䆒Hú¿òŒQ ÃèÔý„Þ)äO.;U©<ùÂH¢3¢Z%¢•r2?ôO©7~9u§Úh‡–'½™nìÏ>ц·N¦KOÄa•<ĪÃÖãÃÇnuº¸Ý}«Ì¡G–µB¹zÝ<3lÖ+tôd¢ý½!Ò®èL ÚýJù52j(3ƒ÷•†ÒhÑ]“…ác'³¹šÂmîgû‰wg!ÌIŸ×/´3A†…>‘‰—(s¡O(hÌ á:À ›÷ìÜ¿7ª¤d#žFЧ*mó½ˆN{_H?Y 8C™¢8Œ7—(õßÂ0Z’B³ß°¯»W±WÇ˲¿¢PAJŠÜÍ/> Ì\‘µZ¤E§]oað@tËå‡^3j:ŒgôÒÖj¡û益ê¢Þ·ÄÅ„C]B}W ißÃŒ¶e]îÞ~ÎÕCøm!;µ`A(ê0qïZHć=ÊÍ™hMãiºœLŽš 5*£¿÷j×ùú-øØòBÒ±K ÊÀ“{$-úÈ Âv,°Ÿ‰bü‡ lHy—ÄìJ+ÆÙ¦!ñb~¾¸ÈÓÎ;„ ž·,ÓRµßJ‹Ë–‹T¨¶ßˆT›ëÒ)NVw:]lyøÆ_q•Ø‚·h~F‡TY]oM…$5Ïÿºééc¤(±;ôIÁ? úJeܯ†Ø…†É˜a™Hàqüåâ¦ùyDˆ-_¼,Ñ/†c¢¤ÀfjÀI0ßл4@ÑBfו×i ÌxÀçýÐçÌ<·JykS1âe H>£dÜf£áñdLÄghMˆË³™!M¾á÷}шIû•5I BC/¶SUuÜpŸéOª@BK›@.y1YMÁ/ª*,ûÀf¦œÿž·¬ÏÂ-WY‰(1í ãR—b›aê³È¬OJß«LÀ¸/w5Ëç Òpi£åMR£­S4‰ü€ÿ\Ãi!Íb†²’?Œö¼­‚KgüÛ­˜¦‘Àñ~%­wñø™œÏm36 3¾‚ûïÛUî|Ea¨¤ }íæMÊjÃ*§Ü¬-òNöΕ™‹åx2¢ä7—¯°¯Â½ÑÅ´/@²fTæ¯r>l·UåÍMÒºC\PT;"»’9:Ç,Y?›}µá˜™WG*~0Ê–KzŠÆcMüé?Ègü·$ —oX[ÿg>Ûw'åKàZ»¥%Ï„ÌRE{-V¸ ØD:Ié‚Ö&£Xc0þób¹Sw^R»É9蓚R‡TIŵ«_ímw H$±@€cíO»SÚçM 2'¿/g³Dí,øS˜ón:k6¬´—…Ë÷Ðq…Õ dµ“o$|ÖÄÝ”, mÆÎ šH¹HVÒœúþíŽÃP-aÉ'ˆ²I¯ ÷R·K©V ÏÊÎeSüšÛ8ükÜŒT™Â k–Kôgxd¯õ<“$øöõõì˜Dš—Ÿ»cßéBIùp¹S^O1mKú‘hè0íq‰ìk°èo䦅Šßô¬¸ûçJu«mžH.…‚yÏŽüUŒËQI½Îò§óÊÖÈxð(àÂØ:9'ßO?CL{š$|#‰ôdŠ·å ¼e;+Üóç ¸ËS1õ=kA «»5¿Ãbñ,ÂéKS–¥|9 ›'vbõÛÁJÚô bëO˜|RÐ9g&Œé®„$PÐËûˆ¡)áúspûX—‘;àÆ /â~8Ë2 ½háêŸià§¶'Lòg:_÷s™½Š¯5Ç„ øx']¤ ãI5KíñjV8Ó~L²ÎP@mÁÉjxZhäs´ù݇ŸnSaN‹)Øbèp‚uò>( ®ÜôX)ä+V$ <­SØe˜ie9³Áw] „9y4(ù¯åÕ\Ü9îïáû#ó£LÄ{f.ò/®•ººÑ» ôù Û`jî9böSe)Xöôɧ{ãíå8 §t‡SÅ~PŒöí‘õò¤}M=Øn¾.ž §Ò¦C2ÿpøìt3º>÷ž¼ðΊc“›4Wðö‰ &~2”9±ÅXé>轋 ßtŸ›üݦѳàa_[jËKAØg£¨ …£2åÝ ‹/…g"m/Ž>>Ÿi“õQL®7Ò“º“Ë é%VÎëkçðî’–"–âuôÄþ&ò÷?ª ’À¸åbÚ¶ž"—;Óuî\aKL¢Îïkåeyц&ÂÛ‹?âQÈå8ù>²-¾Û*H¦#-OFbí.$°Oú†Ã`ÒÓº4<óõz¥ð°›‡®wè˜`åËs~PL7¾"fr÷ˆž^E©–Uþ¤Æ—<²K“‹·'¼›(“¦¹o2…ÊkÉŠÞôéË#â3¡CôÔØoz]6ãž·G»Û”47¯EÃ…?µ•ÖfnlÖ¦ÿ_ºhµ endstream endobj 99 0 obj << /Length1 721 /Length2 9653 /Length3 0 /Length 10250 /Filter /FlateDecode >> stream xÚmxeP]ݲ-î66w—àîî®gãîîîîN€àNpw îîBЛó{έWõjýé=ºæè1ûÏ\¤ö`5O  #óW ª„Š< +7™‘ ‰‚BÔ dìbe3v}j‚Ì€ª  +•™™‰(jïàédeaé¤6¥ùjØ›YÙY95ìmíݬL-|nnnBnήŒN®Œ›TA  ‹%hne Š**iK+H©%Ô’ 0ÈÉØ¨äjbke ”³2A4@s{' í¿ ©=ØÌê_šœÿv9¹üfîdo”W–PTPŠ‹2©‰Áf@9©¿í`ç¯Ù S'»MGtùodküßÈä¿Ñ«NÿŽ‘XX€fV¦.@…‰é_¾IƒÍíœÿ†Í\þSú+Èù¯> õ_i€f ó¿lW[[c;ZÔÞÎÁÕä”·79*övÆàÿ°Œí¬l=ÿ¿¼ÿeH»ÿõAlñ×9æCVÎV 3%+—¿V›Ûþµè\ôï{‘™Y¹Úý»ô׿7jf¶õüß#ÿŽñÏL:J¢ŠÂtÿ]€Êâ`S{3+°PÕ寗ÆNfÿþ)+[ý{{þ#æ?Ûdù¿\ÞØÅÉʨËÌø¯õ`þ×÷ŸHÿÿX""öÞ ,\ì@6n ;‡Ç÷ÿ‘kêêä»ücøßYþ“ÿ³H ÈiuÙÞ”7Ä:½%¬ÒO¼x¶ –nvÚHn™reªçZÓjÐÒÌðà’àN À…x&Єçb[ú®™Ì8„r41C¡¿LðTú¥Ê¯vóY¹ðÏ÷ƒ+ €©Ìuä­KæÚjí${vÞY­Œc9?¦$KŒQEG,ÆVÂÏ…°$>V–Î; hîƬehÑ•‰àÓî*TxAðÊ5Àв¨2Ðá \§dêˆûÑÖQŒàÉ«šzñæ¶° 9U±‡ç‰pz¿²CÏ@CW§ì5}¤¥Å/„ûDކ«ÊE°Á½Ó%‘¡xÏÀbÖ“)yšQÓÀš{ÒqÓš4«34 ÷À_ÖÔZLCu7ü”Pæ‡üSŽUõ>+j7×™Ýòô—ägÌÛ)3œ:8ÅÑóźT󽲫 î‹”‰¢9ËË"13£žcöâõÆ<£¯"Ź„  ‰ºï†-x\dß ±…ÞäÆúßÃÄêg†z¨6»nžªŒ,µÎÛ‚GÔ€™o3ƒ–,ï!‰ã¤á °É>úÐÑ‘?Õê>‡L°*±vŒµ:Š‹ßðKjÚKŸ~ã„…Õ¸ ™çT±œcÓ´óWîfëEJcD¶óMVαäjê‡a<œ¤BŸêºˆlŒNÜÉi Pf  …'%K\<êëÞ䣇?_3_°B,2?tï€ÔD×~rÊÖR_‡ICC⇳[,`/ϦÏu1g©&c%¨Þ;”£ѤÒS‹éweÝÒŠHÅAC;üŠÕmÑ©Súð®vÚ|É16/Ü•C@®ã‘ÔÔó÷•š­ÊÑ´L°&ѳ>1¥>*&óÖ>Mf¿³Tz„$yMaâë8Íbc?æÈ¼ÏeÇX»Z¢ùlÎf9HÊ¡æäðV ¡ F%$ujAÀCÜ!j¾êæ—h~ðBò'tìµ Ie§³¤d´—Årä5tµ_&a!œÏVLK4>›-òG@f½^¤~±:©o;'T-ó9W@pcͬGU©NØ%'=ÁŠÏÔÓG8!¨d²YÕŒÁ– Úqœ÷˜†áIj÷퀞Ơ°d@Ñq?kNœ?ÿÑIX"˜¼ .±le*,ŒýBÄÕ0ü›Ööà¨rþ1ÉÄùׯ/N”ŽËdcŠçÈ_úÑjºæ3›ElŸñ ÿ$¿:.ÛBåD] 8ewR“ÿH —œ=S2ŒB¦"¬> ל%›¯‹ 2 &ۻݙi ;FC® Is…x„þŒÁIÌž Ù¢ò IÓ¬>a‘áío—“ÂCCM¨Ñ@Câý4äðkÕ¥&kc×A/¨Y->¹ ÑÝȹG‹jû&^ y˜’eê¡•$n@åÉúÚ'ÿ`_szIŠ€‰gêXé›ó…ν›°Ú¼ÎI:J€ØtQhgzù­º¡UŠÙ¶þù‡ÎãáÁ\Ri ÿ2zMHé‚7¥)µÀÕF›þQô2½ÙŠZÐ1bèlî+¸a>¡ÜRYITá.É*x¼Éx\ÑÞvVî$Ç¿ +ˆh-“Ùè·1A½àwqö>†#:.juã<ê@߸¬‡&ì)… Ú©²DÝJs%8îñZ×§ÇTazˆãgÏ.Þs]žÉcͦ| Á‡95ÁÅYIôÎ\š\Úê(аÊ'í· •x¯çº¤Ÿ­½(*(oތԫǃÜréé³õ—tßÕ‚,* B0RgÌõš•.r»ªÑÏàÅÅBouͶ­í£Õ|D`0çëMdq܉¨(Tk1¤‹:¨Ävä»?¤óIóó7ÃVE“¸:Á"moæW%‘*78J(ÄáU†–=î¹;@&õSøy®:#I’oŸ:9ˆö¾ß :ëß3(Í7x4®ö¨rwðÖ½£ÚþæÏ§=ÉÙ¦ª¿“#eg†$°ÍŒþ(Nwaξ0`X°°Ž ,LÏÇ>7jyÕ¹H„%ó— ¦¨²ûI­ÜÜçýJ/0Èæ:øx^|ˤS`ÛæºÄM¹fî,l$»ªuÌA ˜Ï†åoñ)·-96n/<~Í=-‘¨Ø‰Í˜³7jfZû˜ï4ìêš¿f<å2¸ï«Ä:ÕÜ-Ð1*—(õóGyªÛÞu5åGÓ¶™º!T¦_`uÀº©?K…Siã‡|ØHÃÀ…Ïçà§ì¡!>ýég¹ž=-ø.)vý{„åü¸‘µ û wKgÑü–¤ºŸ*t?é¨16%n»ã&˜t¶°!ïD*Õ‚ßÚEiz–0ÒôT£|Š4ÊÏ/¾Ì¾ŽH üæçèK Æô5þ”<‡äJ¾Ôøá>Ë|³åÁlÓ—ü¸…¬ßÄç˜sN[°Íß +§!Ù0nLųBZ6¤8ò3vF¢L©)ûùJ,0E6±8͹ ƒ¾ÉŒx´‘“W£-˯Ep`„Ķ‚¤[küAÈH5FÆK9cÄXk _|Èmî*àõœšgf|s0OàÐÃùl^ÉhóV†e»õ®7/CëOëâ<[δQ±7BÚ>C! 2©=3Fžo31bsˆyŸkˆÂLZFÞäÑåŒì2òÚ$‰%.+@ãëx “8'_f‹7 Š~†’8Ëaž4È~tó³„À)Kœ©ìâ:;rsÉÐNAµïÌÃxîÈÿXf`âGYzȱ@Å“,fŒAr?~š;[±œgÄо›?Cóû¬G¡Ñ*¤.”tªóDHl»¦ÿU¡·zø ·¹Ç¬SûäE~¾“ÅÚë¦ i"på¸=ÖÊŸz[CàÎ׿ÓÄ/³µ,*ésãnžA>qÈͽ:Œ-ÖŸë}VòL~þŠðÐ`ôæÃâ c\âý`t3Ó3?„Ò&ͪ[ä>õ9x]«,–â--"Ðu@²¿ó÷Üß×LDmÏÚŸ…›GN–½Z9>>ôñ‚¨á2©/[f8ddBDµ’éëUgkh—ì<ùqÆRŒvŠèjrÍÑÛà ‹^85ƘTÞ@¬ÝT½Ô¨døî‘ß§Ý:¹gàíœ Å–šè(Á`t¢žëÇ{ƒìrÊïŽíF·/*²QŽ2”q¦[‹÷ rX¶ZÌ|LÖ¯ /8IÂCFš¬÷ÓP áÆué¥ìåá³O^÷¨ònÊB ú¢#çDlüh—„¯s\BE~ºëeS¥Þµ°f…•’d\ºóuÔÌ©i{ܽÅÔIrÅ)è©Ôì (ižÙûfõo1+m†éúÇOú–¶~iûœì›[³fDxVƒ’¼Óú,–dê:7JUE–º‹îf"Ú\„Hs ™Â ‘t¤\ÃËn‘XË.¼ÄØ)žÄYrŸÏQyµEqD¥ƒ"N­œÚf…_ú‚|ã¨Dè±™Êv‚»×se¿êÜÃЈ'Jl5ÅÊé„à퉳—Ö=£ZíîO%2™õ>Y¼ œf‘ƒh>{ ùÞËÕç± Ï™Éû7…W'^ÑÂìCÝúÞCµmB%êÔÑšâÖÖo=Ç¢g¢žvñWAtøASŒf}¯-ðƒX%8ßhÏW ãE{8ÿÖ]Q€÷ü²à¶×sÃV`—ÏB ÕæøÙÞ)t‰¾Úœ¡^·(œô¶’T¾sb.i(S˜ ¶mÙë‰Ý« -¨U Ë'œîd˜ï¸:RO7Åd05¢©}ÔÏúLüÏÀüʦÜD©d@–Ø •ºü£UtÁ¯ðº9õ …^ßÌ[êSù¢áD¦¢Œzüš@÷ %o,cBƒGŸµ+e©¶©#ŸÝeîÙ¬v¿bš™5…Ò~ë ÝK·'õYÑÉzaÉåµxºÉZe…7Eâh£ '±æuÚ‘ðˆ­!–ƒyCQÞÒÿz«<¹Ë­"bêîI#*6Õt!!óÝÕ!ñ€×Ø0ÈpR%lO N1)‘W¡'tŠŽ¿ÎÃT§ÎC•bðÂaè·YÙ<ŠÑŠ£%F‰Ý¬9vüþj9œ`*Ø{o'u/ûÆ¥$BÄìHÅßn§¼{ì3™á e‚€ÁàR194˜SÜ| (Íð/•Z°(ÍR××INf––¿-É;Ü7ÆRx— ! Œnêd. NÖºÜÚx—>B§‹"Î3‚ ä»ÌhØSšNÄ÷YÀΫ0@ütg²2—˲¥Ô€$84ŒŒY"æ«lxÌUy¿õd€ÕÜÉ®O¨lXÚÌh¦woKuö=êy¹ç 2T-¾‡â—²/¯™O‘ú üK Îú}Àíit÷ˈñ–—áËÉ…F˜@$ï[ÚøŸãÝïeÙªRÕzÐͳvâæ}h²…¡lä yM¾ ¾T›=nòGmR Ëõa¨Ä!¥¥eèlpt)¬ÑÚ @:t=ôË!!=ûá§D¢Ñ+> õT‚[ŽŒÑ Ë*[¯<щ•s›ÊH¾ÔCçë²Îí¢ÔʉòR›Î/QœiËt‘ä¤N¶Ö±ÛÕ )íæ^„j€Vû“)ÍWìÔYdD»¡bï8ªƒwä@¯\JOxÛ",»MYì4mz¢ïoرœÈ=Ë)/ų¿J|¦„ðúÔ8Ö~dí€mªh·°0¨üðö2n=?†W¬…í_-ßu,ì\Œš„|û)^`°Äæý«nG-DÛSwgÏU½TUDÓoS”iLã˜:ÎufV¿Ö¹%;òPÀ¾)‹Ã¨^ gä×:ä@N­^ŸK÷^Ž‚‘©5˜_唣~CM'˜Ѱ2µîñåEÀ-”¾»)Þîçð·C•ôx“¥¢@s+£9ÆÆœŒ;Naó»;Z i Å¡À:}W®Ù£¬ûÂ9ýá=ÏÉ–ÿ{Iô%9ï’6­ÈÈŽq¨&`õª‰ÏKýDô‚Ùÿ¨Ý2Lª_fž÷V¯àØílU­?ðú‹;½V꟬^lüh})TÚ­åèäJp_­E>|dÛâ)Sš¨û˜¼R!^@w@žÀ þ3(<£ÝÀü³´Ï!£âiÛW“¤Ù;{'Â)Pi§¨§Ãçæw°–üÄp;Æ<;=vY ίþYeYüjÂÀ©Îƒ€‡ÓŸ-øV:üþ:ù“¨Fõë~€þoÁ}C.Ç)®O‘íÓù‚ÍøNáEZ( È>~Þ. ( ²¿lïrávÞÎU:%C&Õ7¼QÊŽ‹Âð8ë³Iîvu:(§bªÈäP<búFÙ3¬8e‘-ŠyÈokèºxŒF·Ú*š^m)¿˜#ïðC¾jF†îk—fà _)&ÇÜ/oaåV«ðÈÓÑùÈmÕÄsþ&ó°ö2__ÕGGÁÌTdˬ‡=ë2ÏåbDL@m C=‰#GŽÑ›K°¦cáM¬rûìà‘ÜGž3LLËR"Œ,§ vˆgPƒ+ïŸæpqÀ‘‹q…¦œYÔÈñì2§câìR5¨7Ñ©}±Òd\\›5ù¾Ü™En¤Š2st=—HŽ`ëúŸW:Z¼ íL1HÜ㉠Û~{šêùÒ­ vÊÀ€±_2]ºÅFÄy•gšð®‘žÍÝ_®¡C¿~yu¬Gq%ÜF…W½v!­aräSUvâq]wèñÊ:!zµ“ÌO.!àµ}¾¼ŽÂz cŽÀ{‚ÞWÕ × ¨3;¼_éù¼ìá}p ¿À3Ê€Ír8<á3óB0"¯ßñÓ¹m_ì$S$ä©d¥˜ F£”¼xÔ±‰/l¶£²‘U"ô:mâô\ëa‚Utœ!,ÄvJî„:™þâr’R&ºceS`+ @>Ë…òºÞÏ%ÝsU¸’vÈçì1áQ®)+Õ ›)ûáµDå$¹öF¸ù$K} n–¨Á{õ•d ™|¤çfÕþ¨ÉÊ\S(QQˆðü¤÷?e:éfþür×B¤ž>?ÝPÍÀ›€qšЩ,7å6,¥íÂ5O"ñÕà½â„oÆõÉÂÖg¯PZÞDægšªµÁïâ5S„Ì$)ÿ2tGS–‚¡ÌÒê#õ¥b7¢Wé||*Õ‘*€ˆifȘÝtKyßÕkÖz³ÿÕ³YT.,nL–F¬Y÷È7Q=©’DðÝm‡î—²sÉWï =zó¶Û–Ô¶ü R¼¼¨ƒëÔ^oNîX&°÷õ¸6lpu&‘å—‹ Pé«dûoyïGßEÉï/š)Rëol,U“)ÇG?^áÚNä“ßJ±ÐN£ ãž{'HdŵC^ p“°I"wÈÜ[4=\É 5 ®Õ3=*eô\ñb+B›~o?«1köûFRŽÃÇ ëN]òߺÁˆ„ù¬ð¯¡Æ6G5_ý4Ü·‚K×\‡[ÞÁü›ôÛ(n±B' Fàqvн£°lì îq7c˜›;xôC¯&. ¦öiŠo¿-õ°Â”Þ—Ùh†Ü§{„¼ÙòìØY\s¦Ï€þÀž>»Ø›‘ø’ o¾á­T$G©+ý!êBÀ`QÔ(˜A¼™ìÃ.?÷y{hÀÒ¼þÍtú€x‡ÿ½¤Ú 1ÿ°TÎ=¶&¢’in4 ¤ôà9“§Q(ŠVÃmTÝe‚¨ô*9ª† 貉_K†AM%Ï=›C ô¿ž’u_íñX­Ahžd»Ž®©sñ|ôyÝÿsÝ•œ@ú8gÀfI²‘žN°<Üc^3’Ê£·†2` ëÿþ+Ý•ú7PÛ»•R¢"×ubô`Ù M†žU]wV²éÝ-óZzÁèMì§Ü·S ʧ„Dñ‚~zü¾XÁ®7·p5=[–†Ø.¡^ü؆êßæ>+J Zc_6Qa ze³Ïãs m^·˜#Y‚+» ½ήUu'SÔ¸ü½ÎgMRòžìôt0D'îF;÷¤ƒ…m I–õð.öžaˆ1£;*è´ô?³ ÂW46„Ü =ËQPl²Ï\ù9oÅ*×µ‰¤³ùDŒAÈ‹'¢ìEÜu½v(’èœNŠÜô«Ü£ ·T… âö3¨ÞðÃnº¡O^ÖéBÚVo·USþÏB³úíB  gÚ&±»²É ªÀø$ÉKÁõDˆqãO¥Ù–á¸p‹§þú!z$m~+êêJ\·’5EÀçf3þ¥sô }šEO6mÒ<~›ô ï(ÖäB>1,~Ø[·üb€æ¹a>cï:àŠ/„ÊÌæøØÏ´sH@–ÜnlírP:V¡Á˜b>®»ÁÃÜŠrGÍ$¶d^ùÇADí°³ä¤ {é8> Ηø¶´¥O_C/¿óE¾@’±àÚ‰û#ÐŽæŽÌb·‡ÄG?Kôɧ[~Î Ä}­ʽЈ62Ip}rõ©Ì ¦b¬æè¡ú“aI°¤é1Êè½Jiþr}|XS>ð¦$LÐZß Sƒ-¡³ = µrÜ‹E‹’[¾¼å·wv_$æŒ/°U@Ø(—ñß Õl¦+§¥~ŸýÃ(¬µ‘°ÐŒ %h¯²ËטXž–¶"б›ßôÈø’ÒüÆM¸Ç°Ñ™Ï""^ëY éçUüˆßk]làé`EœáèÞÔõþSoÀhz•nü‡† —g$w·à·,3Ñú‹n¾IŽr¶°:ø3¡×½á¨ûÙëhðƒÞì0‹3Êã¶½9Sþ|1þ‡Ôdî—s¯m~Çjó§=Û˜ˆd:™Gøiôxå¾#> {(ü ÖÔòÉ@_ä†X/.¢€”æÃÁ%¥*Ê÷†¡šVÈnV?+ò•ŸóÍÙ¢†_Å;_WÅiÞª`^ GBšÅ0«M\Nšj¶úY§¦ÃÙ£&èÝÈäL,<Ë]S˪¯ëðÕ}Xª÷-îî—êM>:8Ò žï++êªvާwnWPìohÆÕ»ö´ß NšL–gÃÄ”fbS°nU£˜üÉ5ÝÒû{ÓWz»RÔô‘êf£‘`^³"5èÅ:ìw6Ÿ6/©2ø¥`™ÜŽ»Oªi&)sFð^ ܆œ5ÉØ[ ¶ [ÄÄ/PýSiË„fµQ>Ëè5åúúÇý|GgmÑéão¾øn`¿u2øGä•­¥ íòÚÿÇÐ/_E닾¤bÿeÏe*›IH¶,¬p^= ·¥„›ÐŠi£¥²¦³) Wq¹£¸E& r.4£|£L¦âWÑÔ†Iw¦‹ïpÆï=%†ü#®Ì‘$‡Í2Sž÷ <5Ðë£Éë9„!±¶ýÌ‚¸6eüHE »´,§Ñ:ûî¬,§†Qãns…£€Mçù“°j·Å:"È¿ß-¡êvC&Ûƒ¬üŽ”YÝ•áLóA=éTÕOfÂ욟á“'æÊ ó×TeL'1)+C/‰Ç1Œg‘û‹U•p˃– ÀäÀÿ]}Y •häeôçþøײö;Š.ÜþƒÉæ·6½ó§Ï}Ýaºï3=Cp+eeGÂ"m¤þ þçKG:XÔÝÄ?‚¶ÈNÞe‘mjó6ÛŽÇ22ô÷(K:v#?cMgN V$@‡«_™òÑ…MÇç1pZÄé7cˆw<}¥=›WU ýhÈÝ{gÕo"·Ïz*8ž n #r†CÜ‘/¾ Û9{*f§éwdHCñµ•^ÂV†3i§tP–“}Ú†˜[  ã%MiÆBa©‹TçmßÔÔŸYÿ‚j@ºJŸv¬îÆO–÷²ŸÏjGÆ,Ÿ¾Òñv ‰ú½K÷¹[¦`Dþ.V7vѨ×R&rLÖéœÉþY²›Õ&-ý¡*?V8¢Ö΄¸†EîsË'ˆ(›·|ôÑžÉшNòëkô"SlB¦ÕÐ-…ys:KÏdúz-±ߨ“_QÀäÛ È•2 ¤ƒ*Ì>ºªÈçú¬SYŒhÆÌQ¦¯»ÕÎgÏ86íxnÅÍ}6ðs3Üò\+Øe¢¡biQ5Þ¿¿ŠE·¸éj!¨³Õ´ÆGÌÚº"“|Wˆ¹cÑGHí¡ì‘ÔXÀÅö  ÛCˆr†Æ…öÊòOÐ|hÕ|M$FRïbn¸‰±àÂG€'ëÞuqɰó5.БTË$u›‹¥ú…’ý»àÑšKغܾÿ‡ŽSìSóöÈêæÍ'£U!í÷ÝÕO"¿õõÉÄÅU7ÈŠ‚¿Ý½4ëÍH6 t~…Ú^Oï°Y®'_E’¼ ,åÏÐË.˜K%[c¸E)5d².އ†æ t­Ø†#EC«úoˆ²ˆ Pbî\âv*ÄÏ¥S8ÍzÌÇê ;ÝLs†Xg¬ÏÚ ¨‰ÇD£G¦vŸÅ[-¤TßäŒý@ÔüR‡?†H”ÑmWô‹Pú“CÕ—€0Öu¢C¦|x‰øY~±8´×m2ÅÁ·ß‹!ÙeåÖÎŒ^Îl_¦ × üÄblëÏuµŠÄ sI€ùŸü „eYPØ2:&¸0^F0×»»Ÿòn³ ¹îZ+‰Š›è¿ÍÝ!SÉÒ><~¤ßºiÌ[憕ªÿêRš×<,P uà ŒqWÒkoüÖ¯%I4]û4dÕ1»8Üc¼—CžÊB¾úÅñx|þÇZç˜~‹ŽRY¾ÛN"0 ¾Ë•,ˆLLÔ,–õ% Õ2€8Öõh­ñ3ñW¼å€å_^iÓ!PXCíÒ§ðGkÞSçHË-BµôUÖ‚á<ì!jj,c0¼Fâ*܉uEµµ¡p…Oe9Á[1ôe]vGÏçÙ=ùòPRŒèßJÀþná> stream xÚlºcpnݶ5ÛvžØ¶mÛ¶mÛ^±mcÅv²bÛ^±yß½÷wö¹ß­[£jTç­·ÞkÎùc’‰;Ø»ªz9š1Ñ1Ñ3rTÄUT™Œô,0dd"ÎfF®Vö¢F®fÜ 3S€Š™#€‰ÀÌÈÈCqpôr¶²°tPšPýÛP·52µ²³r¨;Ø:¸[™XxÝÝÝÝ]ÜèÝøéÿIR13¸ZšÌ­lÍ" ŠZRòJ y5€„™½™³‘-@ÑÍØÖÊ kebfïbF0wpØþG˜8Ø›Zý “ ý¿Ø»›9»þÌÜÙÁ '¦*$® ¯ aPÙ›d%ÿI·wuáþ'ÚÌÄÅõ_ÕÑ\ÿ+ÙýW2þ¯ô_¯³ç$z&&€©•‰+ÀØÌÂʆá_¼IÙ›;Øÿc6usü×?€\þÁ ü‡C*€©™ù?Ñn¶¶òFvfJ;G7W3g€œƒ©™³=à_Ü{8[ýË¢bkdÿO%ÿ“bdgeëõÿ›ô"¤\þ!EÈÞâé¸èYÙÿc¶r·ò43U´rý‡{Wg7³ÿ˜5ÌþÓ'93S+7»ÿaö?ÿtØÔÁÞÖëÿÜúOYÿ¾“ACFKXYæ¿ño·˜½‰ƒ©•½@ÅõnœMÿkø·[ÑÈê?Ó`üßãþ­3ý¯.gäêlå Ða¤ÿ׸0þký¤÷¿Qž>tLìŒ:–6&Nv' §ßÿ×ÄÍÙÙÌÞõß ø§–ÿÑÿ=Xffžf&0ë+&<¡Öémá•þbÅsUà4s3†j4+LÀ«zot­†-M ŽþâÜ«âxÀáÏóí]íJÝ·%˜ÁLMÇEê­à¼–’TYø×m¿+¾5Fê_ƒ©cۙȃÝDݹfn¬+RO³fç]ÔI;•ó!K0ÅVt€#í$®->ÚKPéQ diÙÐÔ"ÍY†] ¼î¯ƒD„ìÁÝaXU9Eh6þµÑÑRœgê–ÄÌ×9ÄÆÝ'ßq¯úŠÞ ºÿ˲‘±å!´r¤ûTÀ0º]~ë°µ( ‡¯pË ™³ô)SÍ«°ýÄÇZÕåu´7ëþâ?£¡¡Káè:C¡·#½ F Ì.{ä3f·Ï·!³ì*ë´)è3ɵ9±¦B_iu2—d°…A\Ó²pí|^ôî‚Íg»K&¬œáºi*É^j¶išd '+r=~ÖÞ. WÉòôHÈ04n¬ÏkŸ`)„°xc6ãqKÀÕÕêÂvJ!1.bÅ’Õ?ä#Ä& ”²Ê~p¡jÞFÆpéG·†,y©OS™åy^u4Zóø €ïž©ž¾Yªé…M^>PP5œÂ#´¦Jx›ß|À«QRØûkHrê þDHßò+®óäî»çeZZ¬eîRÉÔ†Ñ:'tôÎDùD¹¹ª„{Œ ã\ÛáåÆÃº>“Ù»žÛa“'ïwõRÄoQE öHÙÂÌ7¸{pKäÑ’ç~¹Qr\Aƒ†¾úgy`ã¼_ÓØÙÁ®XçÉb³‰Ö…%à]R€>ú½9¿IÉžMÈó¯ÈÕ5Ù°ê‰vešw+ˆ¯>L6‚½Mê^¦ÝP™À¯®£P$o8?bS‘ç1Òt³vtõÌÊÎ’"„•8måŸñÒ÷»}D—%Ÿ‡žIˆ}Àò'ûwêäö¾4Ë"ý_¬ 鯦žCÂÔ Ô€åUªüEn Â°3v .äÞ×up÷@_±BÜÎæ^Û¡.æ_B¢BÃwÒŒ|¢¡åDƇy[Ï'ª½“ÏÊ®Qx—Iû%?r\÷£›cYÊ-›¸8Ù.OLŒ¸b¹¡°çFõ·žä ¸Ã®®ÈmfíþœÃÊ<]M‚—ôô͸¡wòmæšð6|<¹û2jó—dSjyèÉ îÉårW¨´3¢h¡KçÃaShi7ͯÚÿá¡3a› à ÊÄèõ\ï’nH´üàyeŸèÖ–Â÷¾„E õÅtSG55œmvµšT>!²=‰Lu(È+º¿ý`5{£ ŒÑVœ×”4Œy›‹Œ7R­\«m¥ÍMT ˆÛZ?£aWÀtàbQhäÃ~9äߟ¦ã9µYçh”!«Š¢ÀÎÆò¯¾K´¥Êþ’ÂH[DÇKf/±Ô)lxu±ãc’61NJ½$]kd {_ñÑÅj»Q^‚a!n«øra/£@¿ˆ-Ë7¨¾²¨ÍJÈÛ™æ°Ö}Ìë,dî6–„ž jw¿°ê*­$ (~Qûi±ËZ…IÉkΫˆM4ÌO2!øÚUUÄŸ`ù ëdH9øúHÈIÇÃ#ƒÝiiØi‘ ¶PΜÃŽ*[ûÁ@»Yó¡ðYë,ÃvN¢åÜ6À¼{‰Øš™ŽÔžN ƒ’¥3|ÖŒÚO¢uÃ…ôd—ˆòÆü¢ÙÇ{‚”™»i(i"…”áý”|ŽPQ:\y«ŠÆ,4r"UÀL¯ÅÊÜÐòm¢¸Ú‘Áìc±SßÌ DG3Xúæ ½x kÍSó#…ÅÌ샩ÓÇifÑ”Žƒ´jŠ/ì•ùPWZ^¯ _£Z g+,cæ‡~uˆ¡<`LþL&sŠŠŽü:æ@ ìÙ'¹;ÿY9…1N{…T‹ÖbôÈö“mæc‰}D“3ZçV4ÿ;‘Õ8ùŽ9˜e‡ÅÎΜ¿½ËŽ‹(Ò쨕™û"›µº$ÓÂinÞÑÏVáµ™iC½¦ñÙ¿%Åpµð¥ÃZàlñòîh×BìzëLF‰&:ïmBb š³=$»yw=$m†¸Ïœ€Â£ ×HPtÅ:(›\pKÍõ•ñªÐc‚P°œSÈÖ–ŸFÀ^_ÎóôÌ+.tïæØ¢Õhp•åêiµÞ~10ÛPIáß+[^*a•wo>§Ðá]çýÕŒ‘·Ucù°6·ÁQ-;úFŽßjÕwÄèIT­ŠÉ+µ¹ ßO†¢Œ h¨~ÌŸDÿ“-ȶ:®Í”1{ô16{ö¸Í;FªßzóþMÁë’B«:¡GQñwø³¹™r6&þýò‡*õ»ˆ~ø%¾`æÉ˜Ü£ªèºé×+K›2‹.,i‰±Œïü÷°ÃƒKØ4K¾K_Æ]ÉæÚI—²a /DÄ9Ù¡y#M4›OtNIG°;Ž>±ˆâ„žûÕHóöaþ× hÇÈlg僚š]D2UŸ&ð”rkK÷žö¸™Â>I]Ëèec--‚^pÆÒ+3õõÓX!;2®ÌCÕ<>jRŒTÑ^¾ ‡˜*ÞRâ+Pqh|̼xß èKJ±Ãx®…e€ø·O¿bRÜ ÝÙä+–Í p,¢¤†-M¢ØyÚK¤j"_*«p[Ü¡!'…ñ×öt —Fû¨~þç` OwÍ#Ô_AMžÞ()3ýêôCy´ÉÃÛ7½d5Usgñtg<@êdööƒóúr²ò „1²«=ÚÆ­ÇalÍêHË»9fÛ$œ×Eë`‡X‡1zÿ„><ÙKª³:‹ÚXÏŽ*ÎfÃT#°Á™)¬sŠé+S“mxug;ÖéMÃ>-3è—ĵ¬CÆFßÎBNîˆ;¶·{Ô\¥m ó­)Žc ž)ÚôõX}û šK½…&fAU‘ÓoáìAá"/‡ XF²ÃYˆó&ñÀ-‰ OÐòD ÚCg0©ôiO"k¨neT±Rcf ´¨t„¢"GßÜo/ûþXlŒezV{Ê’Åf/³?Mn)Ñm´íýö˜ÁJzAŽésö.áËsUj#ÿþâYÙ˜Ø(Š{Y`‡b%"öï¼+†jÖ"§( 0q¨Î) |Üq¨*¥Ôc;¨¤ ¥‘Ì}˜É?YÍ6 ý°¥Ø"õÃ`Ò¶ˆ¬BüËF«4ˆËŒ¼ 㻃“¦¤öâ_pÆà{°T>R?Û³ž…Nr9‰3qˆÒ*”æ*í"r &36,<Òö‚ëΆm¿ûEì õ*„aî¯; áGó•áýôŽB™»ªÓÚ™%—ïhôµìÒæ‡¥À’Ü@Üh¾ÚGNtóm†£¥2S\ü¾ñG‚«_¢0§!œêÈ0úÅ“–‡S×Þ§ûyæÆ4ž¢¿ÑÓ"¹‹!^Ø›=yîqY2–,c'üa¸³þ6åÉ+D›UѾïí” ™u[^œ .)@@¯‹¯üåø^QßÔn (þ‡·÷¾Wî<Ç-ÈäµL–‚ß²±¹~Grë jFZt+£¦Öôyì¢|YZ@ý¼`×hº Ãft#Xh6Ï>±£çä~l“ó•*eÄbË]FcÆ\^Îé VžL—ãµ-dŽ4n¶{+g›k‹2Å£}‚ £4’᧘ёß`MŽ’¹fµ~èjçc±~“ÍO{Ë™|}DnÄ&i9"1ð1´íË&D¿¼YCw’鬮ÐÂaZ~‰ˆÕB\³µöì¹BXÏ,LJÿéªCBåzM–÷,3ó^X‹o­ƒ†£G©Õ= E„|9Mxª•Ä™]ƒ¾}f#꽨_$˜VERwÑŒÅÁ¾JÚ¬"@"ç ¡~-<CrÔMTè%][Fï÷f•>²‡Ùð@C"Üì`÷:¹óé_êÖšþ,‚ ÅB“¼(–p‘O™R·„׿°NÈp×µ_…µ´ˆ…zð?8#‡,[÷@ûÃÕ²±?áPãP; nO:O~ |EÕç.oi(’ðg+·•ˆ#ÐJg! o éd(ÌzÙMír¶wPw°eUü°û†ì .¬Î}¯úåðBî6:Äèî~I58ê&]jÐÀÌÃÀ8¯~¬ˆÐO®„ûЗp›ywÈsä,ïA0X8_lò”\+Òk‹kyQ˜ãÁkEc®8>»–„PwRC—^ì²Öú%Ku› ‰Wf ]iê_Gë6†x¬Õj³ ù³Y54ôRRN¼¸e~ºBúkµ9Ü õ¬E4S(úç`ãýN@ôÎ@`1]‰7ÁÔC ÝéôS‹*®w»:²zÒ‡BY.Gµo’^0/{£a¿q©¼ª©óc¤Êi-çv"¥Ä\v ¦†@c®äÔMåmxÚ]9â½ïnYãŒ%-É.n’xOŽL…VAµù¬×øcŸr dJŽØ1?€gÁE˜ÆŒ%/ÌÜÖ­•@>Ê)øù Q„’ïUon›¾ZðhØ=,S‹Z ‹ÒÌ‚9ÂßF‡#a£sß=°Ëzìqò®Ú ˆ:g¢Š1½"–y ÛäÐOuØl• o—ß×¥N ã16“üv*ãAcvcq*'}¦Ûö“~֤ǎ…äo6²Å¿Ùs%*ÓöXɹÞi´£p1¶M6ãÀ c0ú(ðÀÙD[51âè&öq±‰^ÎqÛ‘_áÐÓ›\=¤á`9E”¼°¾VA æ9¶ÖÈNp½ÛLy  7^1¸©´Ú…8±©³ó_–1ÞÓOðKígðàí¿ÑæÔkY¥ê¿àæ¸ _Sglªñ~µ%$ —oÎGÇäî ŽÓbíP"šÆPªœ¹ÆƒÚœˆ­ÓÝG¹7±®dÊï—²#%ûsï•÷NJ²4:èÌkÛŸèÒžRÃ÷œR‰@ÁG už‘ÞºÂü?.$G>õҵ璎rnPk€ŒZÔ|;èM!Cú¶Ü‰ÈÔAI¥|ŒþIKdüälsq§<¶ì«ý½ÙýÌn/3•ÄYÉ0GÀ”Ï~nÁ~V•ò jŠe¹>á Ä’j³¿ù!×so›VÚ,gü:’O¹í¿©qh>ÜJhüzYË/ ûùI#}uˆÓ$ø[÷^äºuyùŽ$‡¯Gw ¡œíôDél©Ä_§¥5˜Ç%$¯¨cGaÀsÈó‡ P+…?œÉIûK—7pöoNÔ9îUü´œ™ÈË ÌQYµlíßÒó^7ª¹!2ò©Ð¤l¾?.w8XNÛ¥Ã+Ç":Ðéj/H“åÄQ¿à³¨ô‹X#Òd[í qQÊD@h*ÿÜ¿§\’’ÞŒÎÂñĬÖàö“F<Ÿõê#{zš:rÝ}ò¶[3O jvñ Üð⟠yNîqOÕk–™H3Æ3¼ŸŸ_K X ¢«]s”ዾÖ5˦µ"t•àhU1ÕÝpâ™ÕA´¦H1ÅÏQ;rÓd†°+ ÙÊšò¬ÌX¢Td@sZ»vP¶Ç¤‡æ†ÁYÆFé¹Í¿£FIr8¦Ö|Æâ‚ ±?”¯ yÛÖñW™Ð2Û°OÍ[˜-ò0×ÐŒ“ɶÁHT¼Í¹CöFe{?}Ž«>—Ç¢&>qK$u1¥8*Hí¯qT£0qáŒRƒW®ïgƒçÌ5ïg»~]Ñܸ£Ãí“òï _ñ0C´0)KÚΧê×ö^@HÜlýŸ5•!hÂZöúe‹Åľ,Gjzæ×©Ø#—$!†¶À€XG û~ÖÏ‘8Xi€}]œŽZ–R€Gý f¬ÖÚèkرý:nTß’#ÿk)Í ¼K…äŠ[•„¬p¹ ú5À¬|~­•ˆI:€©Yà.0ÓÖlt"ïÝ_Œ4”9¿£á¹µ’ïuAɹyßtÙ>V¶åKBˆ’%½»‰e§üœÿ8§ÛägÂî³;xi"½m˜~^.îl±·gR >`ÑZ“r®"ý1}g3•aY$ý8F’Ó¼‘J‘¶.£U·¾¨é†¥s¡ÌM>YÙø$ð˜U&Uàÿóî -3ûCÌÊHR†ã¥ ¶( \ñצȄA1—ò|z;Kýþ·±O¶:ÒyÞA:äå1JQÌs¿·:}Y—­1NÐÈb:¨v¯™¹,Çd½d(µn—Rq¡Ž]4=Ðù|éš`M½ýŠ!hޏ“ôøŽÁ°êoIóq+S]±wÆXýô\jUؽ=ì‡T‹—ÛmŠ»Äû~•U”bå§)s#onti® ¿ùËà®õ}†ù)~Pçs+x ‡ O¯cLôÐ&&®Ñ›‚ܤ©ÍËó4sã*”QÛxæ%ZGÌ4Ömsϯ҈ba…J,§FRt#2sdÓá?ãÓxþ‰#³j…©µ çC`?­ÎɯÁß§ŽaïþLó®òûÍ+P8Ä7¡Á”ª:2Éoiðµe#ÛcÖ~3Wž/VÉpÆk¸ÜäÊh¯â+öч§È¦„®Âû,]Ä\gÄT*R9Bq«H³—©´˜ú:Á;*À,½0+.å#p3>¶AÄëY‚­^äÓ‹~Ó[Ǩ€¶‘ŸU*Çëdæu< kôaÀ6Éâ§”ÑY0b°Ð0´èÛœ0ŸÙ­4îqùé5ä’ íÖë•Wßü^ÀÌâl§%ÁJ/±|¤ì_lLûÄ M2Ú„¾FDêÖ"óäÕÆÍa¾còt¶ðÉü€$Ítíª÷Õ§U=ñÑclš÷»)²{¾ ác`\áI]žiÓÆ­ˆ$Âæ·}!ñÑí?4^ê×\ðaFà M/_–Ž¡¹RŒ™pC1OA:à‹Å¨š€W…;÷•Ü’Bxd@‚ö†ì'íkAåYŸ-ÇÊg àâ/Ÿ0ÍF¤âös b .[s%^wËz{@ÈLÜIPwÄò³ÿlúS}@…QBRkhû¸€¥A15©bøy"ŧˆfµW䘈â3V·‚ÝNbÀ†q쟊8ôêz2lÔ-ÎH#‹Þcu(·çÐO[@¡®Ë¯Âge–u âÖiº¡^•8°íÅĺ+Á¸®jG¾¥Iغ¶‘íU³a«!Õ—Z~tVÁå_!çЂJØÔŒ–C/†Ö¾³BbSÑ Ÿ¾<_+pÓè+9ôc®XteYâ_|§T‡ô $+³§ã¡œÍ"Nçl+>ï%gãC|A€ëd1÷›Cƒv0›byÞîÁ·€JÙ± úøÏ6W‚ú äI1À’g*ý:…9n–£’Ë*ˆ‘¿Ÿ³›Ú8}Iþ5ÝùãB¥Ü‹H‹Ò›[¦'aà ™-A8óqÉÙØ„hëÜA~¦l —ÇtCr¸õD—J$NÿKx %7ÈÑ™½ë™f<4›nñHxà­ž§zqÊðæ4d~µy‘Ó‘ç[fùóæ^Ÿð¥§Ì/¢É‚œú„HhxýÂ=Ð\áPÁ=‰s‘Wˆ?Ïvç 0_–Ž8;Æÿ)Õ*avˆ{Ïø…g"ºÕ° yF>»hiõ“7F"xK.~ÓÔÔÆÑ9o©ÄgªäÈJópçG@æÓcÛC{Ã>8 Mõ-ú‹(ü#p6ÿâÂ>¸žwüŒ!—‰èÊrG¨/S‰ŠˆÕ:¢7qâèkŠL×òïK5ϺÓ 6_©ÿ4ŠÆå°óp{–Bhá§”TMd†Ò$dðiˆÆ˜d™=Ïl·=qEçowÕXD$ëÙ&¦‚íª¢èN ‡Æª¸íPkš;57[ÁrkÉÑIÏmAÖÕ-h¨Çq1Yÿ¬ž¸²âïâ?T«»,7Iã¾pÊw7y:ÜÛèÂÜkIîQ¾n¼yd?èÄŠ²ÎZªØv®Ý¢òïUDëßi!L)¢Ã¼J¼l5 $øFj´ÒŒÆ6(çtÄ¿•†YK%Ž6z€N|°AŒÈl»ÖcdÞø`2¨dS›\ÀûºMÖæ©6êøìníÃTW"f¥ñ[O¢j[xéÈQ‘,ØsËG.ÄU^ygð°„L Š&oþõÅnAOŒ9²~þG8mP=‚nVuS$zÌ®§ìÜSìÈJšBˆå–ÀqÍúŽY­<'d¬æ‹°`ʼÿY/êÓû¦z ZriRõ#Ú‹ •fÔ=á¬J“Š1s¤‰îf6‘ä _¼®h ~ ®\Àž€¹õ6TÓ^;gÀÒìh\À#G&–Ÿµµ³°Ýý4ùZÓfsæN¤ñõ³“áï ©Å[ I§~œ&i¤4Irh%ŠX$^¸¹2Ÿ–IrîCìGôAá4ÔÌrL–ÆPõ3Y_Ó[s-g=œ©º²ö=>VЇ¹àªW²êŽvQJ˜gÐo!ܺþÈëw߆¼{ÚŠ[Dtýð;þäÞþ³3k¬³?GðéävöŠ—Ó!%ªÍ[S iØ^Q åj&?UîìkÙX© Iª§×YU Ÿ©èpg·7ŠMî)›Œ=GT©Ä&¯í$b]…Ô>‰`z—2ÖŽ 7Z`>/ÅÊÕïpzòç4ò•íÍn;O2ÍçñŠÀ coÏÀIß~”5Bë%àB-ò–…M\;ïó㲆¦þöѬpæ1Rœü‹òTg4z$,hÊ¢Øõ¼t;~„¼õÜí|/£à»{>·l ~|èðÁH@»Ñ™:K™3‹µ@¥)®ú4ÅÍ€a¸òõìg1Êxø¹¤?䨡¬”2öŽä º4­‡OQÂáø—ºîξNs–$Ö¬ŨŸl'ëŒÖi½Oe9õ÷Giô›Í´˜áÈÆÏ3FŒ¬á»fyÕæ7i¹Ù>L¸âß•—ãB¤Óqn=O‰ù’$M¥TÒ O³n4Û;þü~&ëUèýW‡ØÎlæƒ4…Þž:¶fNMÞBþZf®&`´Òº¿£‰›^W¹§¸Ø:_-~]!L“0·¨üqêÎhQ`d{\j•ÜÅòûÄtÍaÊÐXL;9ì·¥üuå¹û¿÷ú%÷´c2³?Å?»ƒÃ'vny7-æ±4·Ù;‰+ÛÕóÊŒÏ$Zø~}rRþŽú0‘ž“ò8&[îØùÃïÂ.Ú7AÔÚµæº-ʰAâH–¯îº¶ù=œ#3½Ò ®AX§rÊ!‘ž»9XšsG…Xÿ$$é™m-è_Çâr3“Ôô=(ö‘¦A•¼¦¸(Îë ÑRø–iû•¨P(”H¨› ìT¡éqô‰`®PæYm$½zÊמaWÒ8¯š±Õ©¨5,¶!âÀÂÔ”;§óuÓÇMNú¾P惊8:!Dò/œ¬ƒzȯ³ÑΫ†H0–ë·WrZü­î—ä@¨–ÇoÐþ ÈÓ* 좊°6å´’Øi·Ù íy_¼ÃÿL“‘%6«BÏ­Ž?Ú{œŸiÍö;Ÿ ï4dÝAsBúк67Þq¬Ëpº|'Ê:DG‘tùä ´Ûüæ 3”¾žÌ¨'qÄ)Ak‘Ò¬FOžÊœ²Å=­ùÚuÑ'gíÒ :Ûôôxú]¦ÇuF²"Œ¹,O ƒýb]v›¥oï´íÓ¬ë£ë ²¼×Õa2H"à<°žŽÁõÚªèE§Þn.÷ŒŒKYF³ÌW‘Ô0åXÖ#Þ 8÷Q¦™Q¼›’™¯<ÃÂÒÏcaïg$pÄk¨¾ØˆDøËÊ•¾ä•“KŽcõ¶q‚ܨZzVä(LB ¡iÓZ‰¹ûi€G~VZ¸eìΨ†µãtðÖY_e76À(Pô)²½œ;~TRmðe IÃ+}! *Ý[™}”…K¡ŒîH›’-U†…3^K”ôººi€ „õ“<îcð\G…ÖØæÔÀ늖OÑÎó¿U“•£Eù>'wñËÖL3te¨.4|BÉzˆ²*tÏœ0çHƒŽï*b{D¥…"&kÞáÛòD¢u!½Ï:¬zº¾…Ç©ˆ¸P´öõC¤æåŒÀ"éÄ®gdÿL¤¶;‡\ÀK¢ºÁ"°+º•é®!ÿ£6î\Ù3ãé´¥.ö~h¶&àç+©ßîÁ‡^³b†•+6LÎ7y‰Ä?h϶Šç ™¾;d¦½n-i$rHnL‰€ÿÊœ€¤¯%Éœ˜½(¨p‘¼HzzyiÎóô„îY¹Ñ·Ï´}‘Â\;ó{>LUtõMEi¡,Õ1çâöLÎN°Ë:¬¼Õ¢[!ì!ŽN£¢ðÄÀExýçˆwEŠÒ—SÜi¼'ßò ïX[;Mqq”½7§Ê™É\ÎI |f2%_s™ð‡sÔ•½h,U ùÓ¢?ým- áí+u³Z„V4í&’y€çwJn:øDè*®è=Wú‡…8øœçVnºGwÅ2@Z"Œ«]6] T³ sÎ ­OÉÁ„´U¢1ùžE¢ÙóÑúœaH#[«Ø¼¸ˆ?|’Åð@Ю'Ï,˜êkЈ*Zr{ß%èŸìž©œ¬}{GÄ)·ÜOf[ ÉßÝ%üDvõgÛAîc:ZQØåk]¯ÊWB&*Q }\).ðLºw^q¤ŽƒÌOÕ.ü=° ,´8^C”ð—0´j‘ÖUÿ†œh¸'Ü‹p]kSÛ7 N+Vn¡4fù÷,èF^1¤I`È‹¸ÑÖee¯‹\AÙíùøLJUEш÷ßi¢[7LJûøÃ…‚"­mt¬~v>±hÈx¡x_ú lð–-Bz¼0§Š7õœH&Ð~N íE %qóuâ•p´›ð’•|ai§½ê©2 ý€±ÿÈR$¡ ÷Ò½Fr6àܹKxx¦Xkg»ãµûÆçΊêh=3¼÷;Í­Cdê x(ïÂ…)ƒe(Ìv‚¿7ÑèøM@퀺ߞÉåßݶ Û®µ#Ð7Z]¼üU¾pA:Ç“ÖX)>´{3áP–Wð¶Ê'üYþôŒD"ÑÔ™õˆÌÆò·G7ëót K‰_Îá™Æ¦=Úc»2ŸiIeŸ‹_ï¾”ÆÒ“Çftu­ßÖ†<9E#œ)õu1ê©6›Î®l€3Bã¶áÕ%§Î#ヮ ŽØaè\ÇZ¼ÝLŸ ®Š·}&öUü èTN_:q zËæ.=ú³<´Ä+àIøsþÔyæg&9\?Hë|+÷–òˆ$!K£²uøFf\Ž? )§º_ +†ö«wD¥Ÿ ^éžÞá+Øß l¢W’XÞú†ô»­#v ¸ˆ&|¢x^ôæ´´ã > WJ^^Ëó4ˆÚ;žõ¹†‡|V-ºyi¥Ò®½°Mˆ­}HÅØzœžk·Ëp—»luâÚ«ù®—x %LßL õðlÇîãͶ³ÔõÒ Q¶½§ç–Ã7º|z2€g®Qn-`¯Û#±E™ÞîO LKY²P˪.þ|jo~ae=:Q.†3dñ·#HÀ7p3d¸áUÔ=kÙjP{f¨ 1…‚¶IÇS¡mõ"EøœžÐ/Ѳ ¤Š“]Wz6×±´ôPçAyžÁ¶²0Hµ–)Õgä /ðÜé¿.çÚ8„qoûUè…WZ­ýšúíUŠQ>ÙNAN¨]© fªÅ3».28ŽG|Ê*"ReºãèD¸n2ÂóŠñ5*œ_|ߨâFuqɨKTÐL­?ÑÈš@@¥$í;Ýi•Ê2 P'ZÕ ø-cBôÕQ&,Б֚5K`)Q$cjª£ªvn¸É˜y9l´§k?à04°×ûÐ’‘g?½ÔÐß8­ÑŽúãÈÊð[ÎÙ¥2ŠÞjdêKÆÝôæ8ÿ`:”è7R%¨‰;Í|`º@3hY *>®¸)àšÃä¶Ø ߊ…œíƒœÓð¤Î^ŒÂï옛*1„ø‡ Õ‰-Sš’{é¬~»†æ:×g|W¥k5Šd½h1w=—°MuÙ´>b\ëñáBˆ-G‘SE­–G® 2ä­è~£hÏmÎbŸµøÝS>B¼y (]å¨$ZGïì®_¨D¯Äo¨‰E^lš6ÂÏâöô EøÿnÎÓ³)–¼k \i¯ö’ÒpªZæA9çÏþ¡¸†b¥³l26»eÍ©j` —Vkp…8{ä‘Fb<§A^Œ‹ˆr ŽpA%'‰ý»U‚öw´E†S(§(ž#•ž§Óº-°»Í]ÂòQOù L0ÐGΊ ” J‹dnš8DD‚S²·Ÿ¬Y$å7ÖÏøÃBà ·üJè–ŠYÖXâGÞM?ȇQ˜g´«3ÛEO¸¸ó˜2Ó¹×7b¨›/êðýkzÁùX Ib÷oGœ°Êl¦Àî¬a@RÿhHK·pá©q• G^í8–P2,Õƒ™ÛÇS—Ä5X¸ë8åÎSÂ|CÞôÜ þMÔÄâ<ÝÍ'¤ÄµÑQ÷¸_Ô…¡•òþa²¬e„¡·C|¿™gõ¼OÓ©ýŽCÕ èkùƒ³ï“]f©øîCå踖ŸÍ‹Î!³¶ C¸N ¥±öLšS·[àüËCÙèÓo“RÂZh¼e»ÍE¼‹2|Åp;ù yßÖjÊèÅüÁùYi6õ•ÀƱ#fÒÎûd0î0Ô+<+£[¡ ü4aŒ@ÇakŒ­Ü%+áíáè«Xy]iKPà¿enËÑñÈÙÔxpIÖñÑ¡}ƒšêõnÆTjôy½chŸ…Ÿ{lƒ?dU"q”ú¡ÖF0å ;ByÑo'!_^Æ?;ÙøMïLm“Õ|¬§ïIù÷ž®h–g…'‹È¤«.û4j¼Å£KAM¡dpžUë&¥)õÚH0òÕs?Þ~¥½‹z׌í‚@ ÞlM±±„<®ý5ãÛ×JîŸÞ1×]ÃG'¾œU£©ô¢ù~üÍÆ…Ä߉3ñ>9.ïvð^=é’à¹:¼æAr¡TçiGéJ,zÆLœ«ÍehåzËÝ‚%XEk„,âv]Þ÷fF™3NœPy×Á˵ ô¨[°5ãí¡‰é€Àõm™¥Jô\|%ÍP,†›t„KCc.2¼Å.7ßÈy |.ÃIN8LI!À U-‚Ô¤aÏòøß¿™Åps"I¡ÆY9+=j¾uÏ¡ öøWæ¬s!é CöXc“o¤Ätv?›jÏr<-ºH—bpŒÍRŒ7lúbø¹Å Unåd,ÕªcxG¦Ë²¬q^‚ú»ÝG[Ý”Io§O(OäR2Yê• øID“M9ÆZä½M½¦sûY>Æ¿_§øìíùT”ÐÖ™ˆRFF õµ?y%pÈV郂Ãô®ÐºšOá&Šb“Çe©sáÚÊŸ½F¨6g¥ýHH%H윽IÒä¹$`ùaft_ðt¦Û¬?Mž3ª\]É+\=³Î­¿®5÷n­ö)O5”M‚ô "Ýì9 ÕVtjË&=Ï®ª#¤?0ÎüQo¯±ÎÁUº`I´ÞqI¿õ½zÓæØÐ°ŒÐÁwt^^î5Ñu×øý”„ÿVš Læ"rÐG7[F0~þª×s;èn¼çD)’ëê)5K¡“p,vl[p™ö¶ß叿Œ&Ûoª Ý—x)Ð}Ô‘8ö‚ ëqå½×E×!£Ã®jSuõΩùl1¿F”ƒxÏ‚ÂÉ6°ž?E‹|ãvÐ_·ã3gÚˆ 5n´Ý=Z×’9$›ä ã¬ñ*>Â’à÷½&÷ˆ¡'^ÚûstkzÙ@ŒQ¡ã$j«9T?jî·Ä¾²á.6ÄÒšªÎkUó6ׇ/V;Úb ¼ e dÕñ’¿ÑÔ®_5IÒ4þ` ½óȨ-½Ï³Í9á:ùúÇ}F»Üxðš%#\ûcÌ’ª¼ó*# óÍ*1ØU*¶Å?×ãÏmqµŸÎLéV O÷U•ùÓ¶D‹l¥ŠŒþ_h®ùl7L!±é´g÷‚R¨µâÝ€Aö_¦8{¬â=qr›òzè•qûsSzt¡i¥ÒQÄKæZYÆÆX³A§6”#C h,ªû̞ϡ|MZò禴âr ·‡bs-ÔXs þ»;=[Y'1jdzÆ‚Fèàï×Q 7áE÷qËh’l©–;^ò›Û=€¯)1וyFRh„|3ûãê{´z£U½µœ…DA)¼Éç‰"B—‡Þø°.#.F‹ÅHº® »”úÛ¡ù3ôæŠYŸ.ƒëΟ] žßχTëçz 8Ô¿A[zQèi-]',u®Æ¸»{ÅÿïL4v¯žöÑüS:·†á!­Tj™–õr‰­ëÇsgšf^©þfªKjx£>ötNóºs&ʧ'øWª:ÎPNí^#²X\Oú;8è÷-ÍÜ–D*ǾkwÀ¤.Ö·{š%íô¡DâaùkØEU±¡7»f-«Òþ’Nô¹fŒré"ìXöx…}2 ߎgz5a½’’@þ.ákóÞ6E±cÄv¯¦!]âð ƒ)ÚíÚ#,ˆJtZ&ûƒ.R4èÞzxÙЗ?cÀbrHÜ¢JÏ®hñÓð4Z²]»Q³[Ú=Z£D¯©²-ÎýiµQS—ÛX›‚dÞ4Ï©© 0m»kÖ— ´ìfšê6]âùßú ¿è ýÚZFhý<ã%fivôŠ(s±ˆq®Û=tú´.œcqöÔÇÏÀ†¡÷âtaæh8ò£ ñßLzlÞmŸÎ¦7+Ú% û@_6××]M ÅÂSLçáö§Žëo$*†^îåË`<³L~Û DÛ?îü*õò°‰>DW¼»‡¾Šøˆ–j'ŒCnVMO—س.áµ \®¸[é”㎡_$$¥š0ÇÉ¡¥8âžÍžå躺€§.Û‹É\5£ÇœŠœáï×Ä tå ­×4]œ¹cr¸4K«FìCøâzªá°€åR›¢|e1Ö#¹Èg Zì×ÈeȳU¶NEçÛEB8dfÌx¿_–!úÖc'Á»â{Rö›¤ÞŒÊXùt´'í¯jnaK%'ÿ¹ð–ÆÃS^\á°•“#¯ÙFÂFFYg9WËÑ÷gä^’k¢I NÄú¥O´6Æ;ÒµY Qe2gT(&f9#Ü{^{ÑÒîW¥±¾7*ÝŒ}¹Û&çe'!í ‰ø©Þ†YS·.¶þ˜Ò$›Cù!…Ûabú‡Ðs6FÝL©ìas=uÂ×Û‘P`Ñseý4ïFoZ\Ú±óss6.2\(Ó!$ÓÊVóÓ×ì°N‚ƒKì,ŒÛ:Ddû§]ðé.$(€û%gƒ¹ÚT5†K u˜™¦{õÖL¤ì»Šß#7‚hHs½™þxKsóm…ßc‘.Š(ËiyO¦A_A" ÃÇo€*×"’ŒCý’•ÔÎÌ‚äBbIìò–ï0h›¡Ö·“*PV†ÙÁ $XÇ `I6h¹Ê¢07sùM{ºÀBÁôØür£ƒŒfpÇRTRØŠ1¤á‘hG `a€)%Ü[àñºß`þÄv”=j6!›Ød}UYýã4MTd§OLéèa¤Ñd*-ßìâ/šÖü‡ùÕ»f©ÖãÎèá © $Yæ-¿Uù#ñŽÄèm¤é-®B!÷œœS?«teðõ•‚¯ÌÚ˜^­Õ%ÄkÂîÇ$9t©rœ°OŽÊíÞjªŒÚ^,ê¨íÒ %^+éÍ\Édçuá%¨\öGf5úH†KÛ)å‚ðÁ†Y»g”g|ëÜt0XôOïùÍ-Ø:;êëe€Ø‘y²åÉBµ‹WÓÕ÷û(O9rç~¹—åúŒX0[^„bÔK96W§("hàé †Ìb%,aãÚØõ¤7¬%Ó^W]2:(HaŸÉPµ†‘Ýå£RОíÝý³qK~ýÌ®IÚ…|ǵöp£â†Jy˜Ô‰óx8°Ð!”J昊 zW ‘*"È…»¯Fo†ôe¼µñ(Df2â+j'ê"<æâðî=ù6¨±õ‡­Ü©R_Yéy¾+1b m×Ù"¦rI1T—‹w¶©M¹nþJøžcqÍ\µ4àýëxÏ9ó%¹¤?mN™Ÿ…¾D¹xÃà)ÕÆãJió/w„¢eA.š|¶ç»v€¹÷䇄>Òöm,О=pêÍ#»¾0yü.и¤óÜ::#g¿ApPÑ4ÇÅÓ“mhËl¾ç×!õp3a•2ű¾%VŸÞ”v LË^ ?ì"Ó#ùòORß’¸O=kˆn•~YN©ÖãLÚoo×FZ$Týx=#ʰ8µ˜ ¯Š›¬¯á/IÖ“¨‘8%Kpž,–™µTürâ-Yz•¾mJ"Ø"ÙsÅ|ƒo*[–…;“{åF«—‹ñÇpîI¹æÒYÈQÿS…¦&Æ– qŠD‘&î»vç ÿd}Å¿.vyû¯$O½ð½™š"ÆÔ¿˜°P¿úÚœb‡pƧÁ/ [y0róŠžï ¹3%_k zænãB¤:›3ûÇä-¯,"ut¯l-1fö(aç. n£y.Ÿbü|7ù\˜XЕ5ÑÓ)˜{€4 ÔÂqúý},Uq@ ؽW&½¤Kóß¿¢|&F÷ò 泋èÃ}áîJ1é¡„áJËûv2ùê2ˆðó½DK³)¾¶åpWÐ\‘dy{ø¨@ÑÌOeÀ|]ÝÄëáQw‹¿Wœ^ƤÜykküŒ¢SìÎOuSŽVè›”l[ÂB²Õ_*ZîA¹Ãºa—ÓúÎþÁ<œÇk,Ñò»Ìê#Ç1Œ Øvè••†Fp‚fñ/mθ¯ùyÇ›{Oí‹K2H¥Øò‰w0ªÀmqž4Κ@cc„€K ¡ˆÈîQïùu­m*“’ö ¨èUyRÜá ¡ðò0‹*ç6ŸBMO¼,Ðþѹ–°ºÜ<ëÇ•Qk0Õ¼=§ „Oóû­kIuoÞÆ¾‹˜‘ùQ#*ct9‘ÌëzJ½“¡¿eLJ§¿þ·ÆGÿ(S8Â2yxòFL)hü)&ðsÝvÀÌêñMÃSÊ!A©–…7/‚ÈòÒ¢Ô,‹/Bõ×#¡zµhÁhB¯¤ÉN訾͎!4åœAÓ°óïxù›Dk”>ä8ð©cv77tåjê-£¯‡-•0ÞH÷ν(A¤+ðô›ÚÀyMþ·IÅ]5ýâºÅÕ¹º/‰2á³MŒ( =ÄNV>Œ‘Ô-c µê”+_0Âý?•gn΂=ІÑ!hìÑD‡ÞœÅw'.1<’^k iˆ9±êí¡‘Ã½æFü<öƒèÞŸ ‹2,>«üüÙ³+jå±!WEq±•=º2º?$f–¾†´<”VâE~m¿‰6]¼%ÌŒ1;©ËÌÐ*lÁY}ŠüW­z¡½ptµ°ByÆMÁáä\G4è„w!ØQÑT;Ýuk8éBA~Nq’™ %Þ«e‹œGÆîÈa^Ë&h¬[¾/gAþ .…©¹íÛy¼¿<{Ž X9Dâ½¥S~)ŸÂ™$bí^’“aZeRVƒ:ªôÀÊ¢ëþ6ûNàÕ‘£ÐII……hp½1à%¢ [ýXéN«Í£ ©™ñ+âLj”œ‰{¸Æ ÑÞù1AXÌY»¥HEw ü€ƒºàMˆHºÕÒ+uK“} €ÆGÏ!,‰3±…3gŠrž†lºÙ ‡1‚KaNŸð§K4]Ø ÆJÑlîC¿?•бôD f[,ÇRN ÁÏ÷¤QØ÷­ç¯X&•,)ä©ÉCœ–íG.bÎê«U­ñáQËGâu—hX.cæÀÃ3‘Ç‘!T’Ÿ¢„ùê^Ù›Zá·##éþ|díF}¡°ÿ@ÒºMó ÄV•låGºÁ¢[rEäÿ¢¾áPèh³®=h’×ìæŸÆ|¾.‰œ <9œn'¯!hïüñ)Ö×F8?Е0Ç3?›2hj’+_é^q”©ïÈ›°¼…¦ »›‘éeŽSÍxVTû+ðÈ¥6Bt ¿XHêÐ#ÜËž¤tÍ9»ŽçãÐtðG%¼¸†¶Î–Rˆ\N.~†ŠˆxÄ.¡6©xŽSxw¹»òo¢-7d'¬¨GðHSêòÿÑzk~ÖX«ô2q pð6éQ¯ýôÀJöat\S¨=$òƒ¡Và!wfÙ¹)ÿ\‰ó‰?,¼ÞDÐÁUÿxט.« ¦\Y}ÓÖ»Çô?ì±®úð‹¯µz¥SR´*dßr„· 5߆¶/FïQðèFÛD†ˆŸôø7ÆyŸŽ®ÍË^™¸ÀĘ̀ó >‹MŠlt1ôŠNcézG‚Z¨/Q|‡+èÆ<粉\[”k °SQ²isÒúá;Îå ¯ŽÊwî¾Òs±è¼ó¥mûËRró—FžÐ¦ÄR¹¨ur!~ÉD±sêð“׬ºÛ ssüÕ.R§W1ãÞ\ûk¹¥£ƒ‹™1¾ÀÊÇKbÒ˜‘þ'jJ޾æÈK¡Ö÷)»J—„F?­jRáäWƒ-w¢*¥÷˜ÝÎþ!½M]çuo Z“N3´¨™Œ¶ÆO3¨ùá16×Їo8pAPŸÜEQ'FÔ±açÉÜÌîT7¿‰³o™¨†„Þt³pÚOÚ«l2["ózÿ »FƘËŒà_Ýñ>ö~K~c$/á@»³ZVŽùUÑ<ì#¦è„‹9B‹²Ÿ·œû êÉøÑ•Ð×ëì op˜OQ›ìÑB3™9%!„ R`•î ””™WÒ‘ç’FJ5-@éyÎ/ýÈIt7ý€b`Å=7]7÷4sÂŽåÞ¿vë*¤#κ„'£’Œ h¬‚ǹ€-T²96 Æ' zÍü—èòÛÏf\ …þ|7u¯ß'­X~Ë‹ÑýË鉶¶D¾ôcÑU|2Ó«ãçgòóÕ°bÿ¶&g¿æÅ[)è·Ci³"0Ò¯Ä%š§º*ä –/Ûô5g:FI²…Hò…bVM~Á3329ÍvWAá'Âiz›Rád1æbÊÅø±K•.€u(ÂVœ\ˆ„ãÓÆé0¥;ÔÿQO¢ç I…û¯ÏóÈ^N-kš |sÖý4@3[ì=À3Ù½VSéÅ‚zwÛSTF±²«mLá!¬>;3Ãò Å Ž‹r¡ÎfuÈ:ñ$šCXÀ¤œ(\ñö5]¼Ïÿþaþî7{_jˆm͛ٮ?¸Î3B˜Ž¥êc¨¼­=žóÌW¹ÅV„åøú%I*E ‹§ì½o½­)ê'I½œTý^ZPÓšTÿ¹±Ä†Ôè eD(wóG)]3#¹b²žQj­ŽÓõJ4»è;·Z6bÉ`*â2KÙÝ‘Á9ê¼Iκ9ž«˜ö*C’çÞ6:úºø¡¸[ƒë#÷{vdÄÕXñ]‹‡ÞTxY5uJiÊQbªM<­µ‰;Å !·¬'ᨾß®c"ˆ¨˜m%˜ÑDìÈ«wϜŠ=­¯¨g1`ï¤_¾;¤Kþo³“ß~,0cæP åúè öóÐõâÉòE…ÃÅÕ‰PÁ¯ä±ÍZºÔ>®ioÑý|2¸R-6oÔ¶Í”¤(•éİüŠˆ›P¤ÄF3.¥ÑqoûÛ šŠ‰Ñ<Æmo¹†þ9繓“)âSyˆlzg™1¹ãÜé¯jΖ¼k¨¿ ›c¯NŒ¼$PL¡„HÖ)€&Ä ·æ‹{<уj7ÜDí¥Ë¹SF>Rw‚| Ú¤ãû¬ ¡áð¿K7>:yÖe‹+42>6Z•M7Åd¹2§"ë vlh”Ú˜Àîé°/é‹Èb6À‚:JEØ.oGÁ¥lí9åXa¯€C0NÌ^vìuì=ÙwzIÁº, äÁbaÖ+õJß¼¶3 à‰P®ný ¸xS£œ->·y¬Æê6Ï¿Îó Á^Î ü~Gº¤ºÃjg‡´ªN÷~×+¹¼ þµ‹ M+¼KªUÚœï(¦– öŒ ̼$‘Û_°ÆMÙ;`ó&改“„)Êm©"$4¥:8x×Ê"§F»&b3³8©&•±]©­aª8¼0G™Â ¶“‚vw¦Š_,çø€§Ïðc2/|' ôÿϳ܃¬ST½ÉwÑF~.EæÄ½C™‚ûÌþþ<5ï]ywnlE;¹Ð¨?•š˜ ·öUvƼ•EzëŒ-ß2ü°íëpÔ÷èd÷áÈí0Åôü;ºŒß—¡›ÿºIª1yn‘"Í‹!p—x]¤å'íK!}ûš 4q k* ÃQs¯Ž8Üqóp8̬élYŒk„¹ÍëWü‹ÿl´\ž–¥Jt¾ ²µ_¿|ÍÔ€«èçVÕ´âFêE–®6²AH«ÂÍú4 A™ M§Ô±‘BÉ?%pˆi‰ÖÈBBhìU§ã\ŸPޱ"7ê.$³× ‡ûÑú˜‰l9Í« ÆŠ~!t?ºBð1¼jòp3ë{÷¶Özè¸c/ÜfHl´<´Ôd y+ Í!w;OPêŒ[zÂý¯Ÿ «f´>9Ù¥û*{‹šH»à¦¸ŸA=1u‡’æ#O‡¸²qI2¤Sî¨QQ'›ÿêó5WM>ü@æì# ²<Ç@dï!h7!nñÚÄd®8lí8îb)cWðHëÒC–¡1Ï~ñ#êÀ™>š_f]ÀZ£é¥.&!¹è’„38ÙæÃ{txŽl(<`{k<’œßFR¿T²ÔâUkŒ°¡ø"h@ƒŠ Ǫ±–fŽ!xt½T¨ç‰æ‘Mµ  ¡z~BãÔ¿ÏŸCò‚[³…{$‹=B“Ù6L2o¯'ù¢ÂºðJ –Zu8Pù”©7Âw¡§ É׳D9Ñ64¹x¸ÅALêûH~gb j™0ÑtÍý‡êUªy€¯TJ—/ãˆtÇ@q1;®·Å_€ª¾á¬[çP½æòÕXÑUýëP­…4âi;¶Êæe(7cßåú´idÖ s®ÉÀu]Þ?u¡%ës—Ð"|ìY× é-°m?13vý8lÖwïRÿ|¥,Õ}8;Ng‚ÛK¡lYó·~$ûd Ó {§+;ñ¢F¬îð¯†dîªÉ&z äèq±Ü;ö\»!é¥nyá)2w†¢by?A+ Ýäaäê±¹˜ðœ5Qãì²G UFüH+QRLpÍ s³k«:f çɇÄý‹2èÉÆ†ÙÖoHŠŸ¡9ÍÐøåÑÍ»Ä`$£S JÖ€„Â,dþâ"Ð’¶yô¾­Y#\”-÷-”¨<Ú· ~á¥à¡ãì&Þ)Õ ™{ŠÏÙ;FÑ›}^ÂB.‰Èº­£ãˆ,ï›&cù*œ’ç1/Ê‘ŽÄûÙ6]£§—õˆ¡$£>Úlmn~Ÿ¨” 1ùñ)y-éé~Ü’\ô°3nÛκjM/°ØÓ JÏè·{ÔâºÄ&°wÍð|ãú‰”½Òرp¨¹Ê²:‘zzÖ2ÿ$ó\ë „äTz—£±é2p/#(3ƒöIK)‡yîeRÂ2sé*x5ip迼U–ìS@ôªç­êè%3Z¥ƒÐ bP¥Xñ=‡Åœ]éãtZ±.Ù"QûȨÀ¦àà%hÙ-—iÛP*»÷¤òn{ý<&9icô­Ýf¯ ”Pëöꘚèì4ÞÊP®ñÉrsìå† €ÐÙ8žqê]‘2ñqïE C(Naº0]s ´ŠR7…ÓT#J{{v樂 E¡°#¼ãÖQYUV˜ð¶<5Ø‹Òë€æ»/Öoº!Ô\êìÈ ýœœü¾‘Ÿ–Ìô|:Mų%=ŒNá Š5=ïLh`–Æ0mf¿qoé<¯i‡>¡äA)<ÚšQæÿšYÛ¦5¤qðB±x8lIÏv(uéÞŸ®ü¸­9f`wñÆP!£]ÄœUz-ìóÿÿä³Û¦L¥ïÑÍ´ŒhUUÚ a¥w]*–ïHÖlÞæŠ?~­ÒPÒ/üíþnÀ3kÈ0hqô  2î_s½ñžÚÂðíÎЉ‚·àÅtÿ xƒ‡Èå:©lfTå%Âyí“g¹åwÈÊÖ»uqÕõðµÜÇTñÈ@•©Ç+S•îïûÀ&°@ 8ºøÉ°‰›¿ÛW°_ßL¨¹°¥ò_'êéÈNC_r—;àóÈuk iîƒ9ó &JÚ¥±pV ìG¢9}Ö–(>…SM©ý!€z˜þòïwÒ³…½£ÁItr>¹ÁÂÕ6o™Çï­à©Õ*Ú€_Ëò×ŧAsÃÇÉ”~`vL~,ª³ðáØç§$/i³[Þä|L6FäMŒ‚Áï?óÆÅV&öcUZåÂ-+ +_ µLÌ'FPÐE[Ïyîrq=ä¦s}¢ŸA¼R¨¹â”q3ö_Ñ/S¡ÞS¢jI#Þ’“UäOpç± €7œ„ Ì(ÚÿÆ‘@•2I„úyŒJë»”±Œ–Š)Š;³À›¦bôÌ››ŠR—ÛæýMŽ•Ñ2+ÒÒ% ˆ_þÏJ “¿x_.Ê¢”׎ü+ô8¼y¡¤Ÿy…Fd¿¢üåÈ^{  s$Ñ0Þ]F_ª(µ8fuœr;À+“ê̸š£]ñ0Åx Dzµ6[uB*_wŸãö¤€¬”dâÛßMä ÁÂVÓ­k˜Ù½ ª=^5¢9=˽9ä °íd6*3ÞQ¸aŽÏدãAx%•õÞDvY³˜] ñCj5åÑñG)­¦ssŠG’èì˜ {×GÒ—ƒ4ç"Þ)ôZ—kD—UrâÀb%aº­3úVÕåÎo[]ÜbMpóà:RNß)”D!ÍDòeŠ%Çô15û;O.àU¸94†{ȧ ¼v<¼ž™Q,"ý%¥Âv€6É'Yy×s÷ ¶©³àqñ0Þó±ûãÑÓö V\´f ÞZßÝ”rÚ¶a+ì%i  ¢ûA"Ó{lX­u?wÜ9qšÙà/ZˆpFþäüu\µÀN-üÔÉz…W")‚þƒ#§ BZÑʸWІ§f¢Tв^êùš3µZÆÆ¡{ÀlîÇVð«OÅÌWÚ1c3aŽpäNð;‘›ç=¢Â]ƈ1Èþn\d`绯WµÚÄ^P„W£Nª‘Ï}®âº‰ fní¨ øÁàNúÓô¥IÓ ñß¼òW@¾Ò !¤ÐµüÒÑ~.œø¤qÛ¦)œfúÄV»\]^Psu‘kh—Ö¹xMj€™9]¡Ekhÿ>“ ‹ bw+†‡÷€®­Ù:ó2nºi\ˆ”K ‹†*§„Ðd kÜg(Ú“ßd«2Ô¬‹à¹Ùƒ®¶G[Ì ‹]{ë­€­ûöô6¹”_ͬc —of1øOjVNÏa*µ[. Ä–à݇¦s0«øòþ^µÆ‘TñbÿIËL3üv4Œ ¤Ù3 8§ ‰nÔý[Ù—ÄqýßÞ"CZËîY­¼Ä[FJ®:+ôQæŒGæ²& ²­5Ðwr!¢Û6kÚ·¶wÖRáÔd´¤1{eYÆQçŒ+Ž?mád­ûZ·6ÿÅb¸œ |É鲉хþômF©P\ï®H‘:)eC›Ò™5ýþz·L€sнtyS)ÅwõR¯×Ñ"’êØÜ5q`¨¾’1ðÃjø²Ý1ç~g› ‚y_4‚†ýçË~“æzg~¿äùö†O Yagë…§ýòÌ@¿ÞUoC?r÷¸-jQzϰ<âäLþN>”—À‡!éÿ‘²æ¡ßöÍ1jþ·cÎïÍá}ûÉÞ›?¢+‡-„—)W)òê²à)anÚí…Ú¾º]Ù¡³E §â½‹9/R~…¼"‰I ÅïØT›ŠO·På;GÇŸ„úÚ0¿åÆ@©ZÄÊl2Ì{°¡_É þ2Ü·Ã: ¾¤±ògLë²ÄîØÂÐèõ à5¤·gŸêò¾ú?9u±îwd£8-nÂþ@ê}šŸº¹ 9#ÇoÇS—”ò¥Óf“Òßy˃ÄZÐ#Ù—jœÖ;F,e§&wê6Õ‘7£Ÿûêý6ž±|–=3 `|=aé K ŠáK*¡ÄGëäp–bi/*/¿1ž¼ÓûDã­бs‹ÅšTý2#«§ÎÑ*žºE‚ UQ¿&ñV6¿ÜE;ô6wäz׺f=(ÌNw³´¥]êHá -v^À©­]”#Oàâl(Äeó…BëidVU>.‹~ç]K¬·a¿¿Ä¼æKaÙ¹5WñVÑkCyÓ…¥ADVÍ=¦¿È4Xø8RzMW¿¨.Nµ³aÃI=·5‡Qòä]¹ìýÖQøÀ{öþ±öà0 ³Q%˜N;«â ±DÚ|Û߈Y>ô?¥«u6®8Ûœ‘±gÀ…‰™Pª‚ÈgþEñöòfˆ”Ù9ÜOòÙÂC(åî|O*leÎVŸQUýž7ùP±òµ¡Ô¿]ÿ1$Ë\.Oš 1­Çcà§WÎÏ]§àK\|ìgîÀyç`nCep貌 GÏœéüÍ—› sXæí= ¯zHlÏÅ㯀‘ø‘E¹Šæ=ÕPÕ4&’Ñ4/²ý¨ÇD…,% ²w³y:¿—ͤÿÕ¸ôÑdj¼ãôå#âò-HYŸ–ÊÐÜ›!¢¯*°#©UFk Ýá‚r;±¨¢Ì¨£v ˜O ¢±ïÊýûß4¦[g}Qc‚ñ‰uªýóð:‹ò±©À¤ƒ‹aß߀ڳ¡¿eÑ×uî%‘I)Ç )ê{f}É ¿ˆüU:ËgVŒg ]Ô-²è§C: ËÏWàÙ 4ìŽéµ·ög~íaÞ¥é– ý;1Pívbÿ=WN`Hýt«É©N'’âã>jPc£yˆ†Í"þÜpÞ6 ð*‡´u˜ QÄÍ­«oÐx£yëùì×Ĩ­-îô*[]CFUä·GÃ8¶€§L…7sãez ó+vF3NöT1ãRÑ)¡ãørËœù¾â<_ýæI‘Ç3T‡éa€i` Ôˆ@m„ìq«Ðe¤Ž%Pp}ža{îïÑ¥9o;€ï~‘‘ œÑè-j1ýº»HÒ¼ÄßÑg8\åЯY9L¥z!+ŽM‘€„À {'îc KÍÖ{é¨Öåˆn×Þì4]q›êvý?–·å?·¸^ï•'ô·Õ<µ ‘.]Zóç¼ ÑY>(ñ\áOl½¯ÛO Íi[ò36*1>ªHÏ&„%fÞå)fj¾Í"r1ÄÎ… ²„½—£„g{K*©oYé)Iè­pÉ}"³€~Û?ÔL>ÿÒÂx¶nV®ŠªLôT ÚçGÚÐ÷ø+Άº‚VüY–6Ä+A`œEWõ®/_ƒÁ‡j“oíîh*¼„üiÌMÚÝÊù–ôU‡[ïæžiB>ŠWÀÜ ¤¾Y°RJý‰bêEs6¡¡ãEè%º³Ä&UåçR­ç§¶ÍzØže#¦±U83IyOèrÀnëªgŒï(áPêļ?TuEÉÈC»¹OüãÏÂáa>J_ˆ¨·ý Bîëùãï”J©“ú¸5t ¾™XCâj @ÉoªWs ÷‘ÉhCNÁ¸+^]±RG0h+ œ"‰’EÇ—²m]bäÈX$"÷ai²BU?œÈù†×&'X8œè¾F cpsãÖmIÿ—ñšxˆf—tï35.’>åqÊFhÛg”V”½#(r'¿ª¡ zÙ/7¨6“&ÏÑÊ„ðdé C|ËìϰÎöâÉÜmØš¾D°ƒ`6Ãß»!¸R’&¼ÐÛP”³ý6˜^î˜lFÞó%xËŽ–Q—´O}–•àâÓƒ&â‘Kà2SŽA ì¯FÚõ ´°á;ÊõüÚyÖÐÔÅqzì¢üóׯ¼kUáÓ9öïi¼Hâ6¸”‹®ïTU_J±¥ÓÊœ`¢]·K¢s¨—¦’bnfdx_5Hf¾“[¦W÷UBT"¿AõuŒˆÙö^ñƒf3âÜë­µÃø G≠ÇïûõÁÓà:cTß$é^Íf°¾)—¯”~4§X¤ˆlR`Gü[iòWÓP¡6%˜ûŽ‹q}ý1ó€7^¾å!µÍ€3÷¯-a"P--0 ¼»xŠšB½’þn¼ßEÏÁfžP²¥”±•iÖi"É–Œ0*b×°ß’,¤÷ÑÊùo"œIZ:°d©é%ôè„î.ŽŽnY‰/®¼!÷9Ⴠ㑦»w\\ÄSHE`ÏRÚ¡ ¶ÄÌ3³;l P85­r¯´›ÿ)ÝÖð8ñüEU>?ªˆ Ö•,Ö]eœÒu·ï›×I¹œGEÌ&]³³A­Eíe Á9ìqúëúR î=iÊmÖû²EŸøÞ:žr´D—ÊSê^ÍjS4 ±°TâJ†¯×\?p÷Ó:°‘I¯AN°éô:îgfþR’¡#Bæ»x‹üKÍÍ:)õp»ÀnzF…òSdœ ©˜@ƒýEÕ÷ôHg‹æ.f_Â^Öü/hÄï9娶#Ê™äÅÐŽ°«ÆXwᬞí÷fgP,qT„Þ  ôýn‹H¨uñSñÊR½49».Eªª 猶ÅÚBG¦³tR´(ϖͶo¡Û›ç €Áê„ÒQÓðªsà ¡°5!C=1AxʼæÉ¡R+‘ÒËra¶.‹Þ°¯ÝõXÓÔiífJšnˆ^Ü –Æ.kbc–jÊ »HéLñØ%^ØÁ¬!ê6yhîÌÔÞ3SÖžœ²ä›ìù.Ø9ú†Áàe3»ÊrLZ`Ÿ4,)Õ<žWŸ®ÍÚÀòD‡L×qòüºb QS(d'*ÖàγÛˆ÷’HVÜÍÔ|õ»R:ÂÜšoæ5™nþèÚA\ì:®ªXš´ù´èôׄ\!/dy.u´=‘Îj™4Ó~ [ãú€N¼ëââ^ UžÉÕ´v²[ÖºøÊŒšßÆäÇd:æÖ¼?+WIlMÉd¡lÖÏ\¡7°¹ö–/“ô[&¯E³;Æ€ÍüÉxä*”®ƒ—{æ%Ò!»¼ñõjP¾Õr÷KŒ»@eÌ‘L¼–'”¡G÷T¤]¶ym}‰#¿3>wÑPè½àÁZý*ž”æô{©^ Z*éiìóç¾KõV:CÃŽ˜/¬òQº4«¶„Š“`ʉݭ™Q‰ˆüUP\46n­®Ð§¶ù}• ¼-i{!-¶ncÉ‹M×/ÆiKû>l¼Fæ@|©œÚ¼^\³«èÅæ^ån{³;“ ö•.Gc¿Ñ§©NZÖ‰“‰êȧkÝ„xÀΔˆ»è9Õ?·|¬òô§+ˆ·zåä.u~(®çºeÌ Ç"j±i]1îŸ–nn^éQ8…YÓ6¸ð53|r@È5›&н—>iï[ºK[¡±Å¦ù3&ËJ­ËO´Ï¤†ºT/r'ø›z›õ¾j ‰·=5#`Q sh4>ñÚŠ¶mDÃëžásˆÃ*0DÝ)ä„Û…¼BÑËIwËÈ—¯Ó ãô¢ûÀü'ûÀSsR­z2€Kâþ¬ßŽƒJ¨rÛ`À3ù?`w»£ÓªšßÃ&èÀ‘ [.¤ÉI?€GK_{¡­˜¿t°XM+YÊsàµI%¥" ‡0||¦Ïž²‚pöî°­œI S+Á(sîÞ-‡˜õ@R‡`§âÙ2õÞp4¶öm?ï–¾¿ÍÀíW6ö—Ë |K0ôÇ,ˆ®q#¾9…ëf<Å–Ræ4^«ºÅQâHzÌ%Jué1㜡0„póm~Bë^ö,¨¶°UaL?€ˆñ³c¾ â‘3awýäÊÀæå rNÂß 7¢­Þúú¬zð™„>ˆ(Eg%%Çé,#nᦨπÿ»O¾^ž€ò‚›Pᙪ_æ+Î^8Ô1A·ÕæÚ£‹ðvp- Þë¿•ÜŸôþ»¼Áj¶”!ËQUС÷×—Vøo;î éA]Ü¥QGl_O½à¿ß«ÉÑià‚ìÊæ´Nº÷óãGãbU‡(lúVÅë–B¥²oñ—.˜ÊÈÆXMŽÝ! NËOÄ }úÄöÓ3eÆ{âkýíßåM'ÇÐ)©CTyMGNVHž2R¸ Ë_ô<€ˆemKgqÝet»0t]ݽ4¢¯ÐÞ5VÓsvŽœ(3ójÌöÂÕfÕ¥Äa勺¸âCá”øå¬èÿ:ÄBªmæ=,x}~—ž–_xJ}!3ÆÿËô!§?ÈÝ4ÙîƒdÒR\ŸŒóFzƒ@1úˆc·š=îD>óK†^AëCW™¿5ÖQ·†í6%»/§ÎwŠVA­fCh×8pD°ò'ÃaPNÄËä¾)cZ‰¿l·çø®¸™Hq¦6Ó%H`ðØÂ6”Û=°Âh<Œ¾Ì„\ ,\c¼ËVÓo -?0+µò«t ¾Úxߟ }~sõþÛ]5å)M —>£Í+40ÀnõMÄï(iægçÑÌíñ#,Û,m^¬®.Wr·ñ(s¾d(àíCÌ* ö‚…ê>»Áð¡¤"ãë_Eüš_;E¦ÅýHaYàc4mïþ*J%v<£Š’äã’.ÂŒ2~wNJƒ(öÜŽyUo6ÎOÕW¦#j7[bÔ…ûãÀ¾Nß ¹9€sÃ^õ’¢–~à¶{Q:ì•[b3ËV8d¿Ÿ0/o?–LÚê§É¿3|ºBRþŒlØG¡%aŠ}? "iÏäñDB ƒÁ7¦oêοí¯ë‚@k\ÖŽõÍᄟmCÍJ¼R·–ûDšâŽèd~Ž¡îV×Ì_kvÚB°VØFÆä| _+{aëŽþDò‘ŸsµÀ_‡È}áK·± ¾R—õ_ÔÁ4Q†Ï R¼!#²z©†‡ø×¸¾ê$! ¨ÆøôEŠ,ø#šž\oªOyp Ùä~±'v?i¥"“¤þ5(æÞ <¡øÚ´]gy%Nb-zÅ`êçvòÅ÷:ö÷"TvÜÚ*‘¾%*èI¦²ƒeª…ÒX.Öe<`žïœQÈRrçÍâ.z¦·xjbš#“]ÃG²~¤!v1LÉyâϹrŒ¥²C_B}+§y¼£ŠîFgÃ<³ZeRÛÆ½VHQÌ•Ÿ<6X6âm‘Ñv=’Îq'5úG&Aî£øGÈNigü hœÜym{ùÌoVÀo³ËêÒ#íÔ‹PÛeÒböD1ß_X¦¼"K|< Øì¼ÿY"É„ë„@ƒJ!Á´o]LÜ ÖZ“­Éo ²¢­¦ßÀùT9h»3ˆ>þìGwüæs‰ÎîÄ–pì¿*J–çÿäT­ £}ò öH^Ùwÿ²O蛽ìS)Xøýö‰÷Ç*®Éuá e°&´2¬¼Äl ç`MÑÚ,ÂV%Ú%X¢ /õ5÷X¼Â3Íâ?–äÑ@¯=‰Î!r4ý©½é‡jSê^&í{¾ßN5¤#–}TÃ,-äÌÙÛ]ýWä2k– ˆ®uÕ$¿Ø•$n[øÞA*ÀGä¶¢ÍÎüc¬r‹‰ì'3½…PÝœµ|oìËÍ4,—ï†ö îDŽX¹,tib™–FæCMhÕG-ÓòçM òdyàjØU¼Í—¶%]ú h†ñ«<œYÏÅ¡ endstream endobj 103 0 obj << /Length1 725 /Length2 28897 /Length3 0 /Length 29391 /Filter /FlateDecode >> stream xÚlºsp¦ÏÖ.Ûvž$ÛšØN&ÉÄÎÛ¶mÛ¶m{bÛÆÄÉùí½ÏûžÚ_}uÿ³X}­«×ÝÝUÝä$â¶6N*îv@fzf&€²¸Š 3€‰Žœ\Ähàdnk#jàä¨Ê@;3 €…‰‰Ž bkçî`njæ 2¢þ·ðÛÊÀØÜÚÜðÛÖÊÖÅÜÈ ðÓÅÅEÐÅÑ™ÁÁ™ŸáŸ$e àd˜˜[" ŠRò* yU€Ðè``Pt6´27ÈšmÔ[€Õ€‘­±ù¿092ü€ ÐÁé`&¶Ö91!qy€˜£ŠÀÀÆ +ùOº“#Ï?Ñ@#'§UGpú_ÉÊà%Ãÿ•þ×ëàö‰Ž™`lnä0ššÛÀ1þ‹7)[ÇÌÆÎvÿãúã?øTÿpH 0šüíle%o` P‰ØZÛ9;r¶Æ@À¿¸wu0ÿÇò?¡ÖæVîÿ¿Áÿ7BÊÉà2„lLÿ¡é?&sGqs7 ±¢¹Ó?|;98ÿcVþgn䀯æÎÖÿIþÃÉ?³jlkcåþGü§”Ǩ¤ö[XLŽö›àßn1#[csS€²Ó?|8ÿ¯áßnEóÿtÐÿ`ùŸŽ0ÿ?]ÎÀÉÁÜ  ÅÄð¯aú×÷?’Îÿ‹¶uó¤gaâгr0˜Y9Ù\¬\Þÿ×ÈÙÁhãôoÒÿ©åô7è4‚[[¶5â ²Hm )÷+œ«€¤›ÑW¥]f]™î¹ÑB523Ö;¼Â»WÁËsE œõ7ä۽ܑºo&5ˆ"ONE‘„é,㽓U˜úÔl½)å¿Ö‡é^CüƵ6’‡¸ ¿sJ__ P¤™bËÌ9¯‘¶/åC•`ŽÒ/ëè‡DÙŽ[ýóh#A­C‰–¡ù…ܧ­F™3 .¸6xÙ[ Í ÜE¸!ÇÕ3+(÷·; Õ̯¿²ÑÒPœgî’ÄÎÕ:ÀÅÝ ¡Øv©øŒÚ º¿b݃JÛtZ>Ô~ÊcY€Š(€¼ù©°¹í' G¨p˵ø!SùS5"v뉭¢Ó;üpwÖåÙgFMM›Ò>ÂÏi†Rg[zAŒ.€CþÐsÔz'g]fÉIÖ~CÐs‚{c|U †°Üüx.^o‹´2²-"qáÚá¬àÍ—Ïj‡\øW”Ó†±üG¸ Ćq®¿Í ‚¬ÈiìØi[›tB9ëÈ#1ãà˜i€.¼M¬™@<ÒŸàŒë~wg³#û~2¥Ä˜ˆ9kFSÌ §»€Pâ Çþ¹ŠI9ã…7ý*ªä…"myJ¸ÛYÅáHÕc€Ð%ýwêF±º;.Ei^ÅP"¯Ðª ñmnãþOµ¢ظž¤A5èÉSÄc!]³7îèŽã»¯îç)!Xˆ¾å¹ %cK&‹¬ ‘;£_Ç¿ÊQ+ Áxæ ¸±ÎtpmŸo\-jÓYL=jyl7xsZ+C[EÑ´þ`qä±BËæ§¿"ÜCš¡Žýí“¡ÀÔËbæ«ý+jøL4Õ›à„s&! 6g‘_Ù)èÕª}Йóž.qq¹NŽÆ­þÍAfGµ­ŠT“KiØLWiÖÉÖ²€²ß´â€OøFŠg:Ü%“¿ƒ†˜zhcwˆ¾œú¨a»×݃*]p€êÀ¼q6±-¦+ö¡®‘î÷9æðAºãwUT+¡U”=#Kù¤×Ÿk[PãŒð Ä¦ÐuÔÆÀ’_d gM «Tþ#c…²@ÎNw&$}6ðËÀg¿å¦dR¢„¿îÔϛϕì…"ÿ7ë+»ñœ…Yã<~. š¿î¯K3„*ƒ.Â&¡á>¼L-ŽˆY!#ºÖ;cÈ5»‹c×}›|¨}!Wèlûß:&™ÉkY6z³$0.Ø8fÃWZ¼5OU)Íf˜0YzÒ2Ç9&•–>Ô«sìÌ•ÒUÙãÑ~Ü8¨;ÒB¶Ý¦²î8)Àä«lY…ØÍ+ ç#…ùv‚r€‚ÀæQ%u8e yâo§Õ¯¡,™%ªä„vq‘À%Áky´œü€0•¦ÓŸÅ ¹S5°÷lRLóÖ2 =¦£ Ñ¥A%¥¨Y/òþæ „mÕw–Ôb1ëô,|bôŒ‡:\ ‹ÔËÑ@]1°Fš*äéb…iÜçNKÏÅú¤ÐFÖvˆŒ-–‡øTت(ŒèA‘žB ë®°\ìyAÄ}Ü‹Íóä)~q½4Öônž‚¹ª>A ÷àÕŠrU Úàh€¼"%©¡8ÖÛ+ëÃ,Óÿ :yÃ…¶’~Tq¢MûÃßaܯ{5šM­Iâg: Ïon37:ûSªX¼'GS„œ&“± ºú_!7Ìj7‹òØ$÷å^‡Ç·š­dùfY{"üùk£[Ê"R¸G#ÕÖÊtýjªrG( æÚ:ØŸ)ñ±Þ¡Ý¨tsj7in{¶° 77™«jË?xëÉuhJì¥ú´É³´¥Ñ2Ì“ŸÝ»ˆmé¢ËéŸTaº«›“ŸËb$iûz7Äú*@©'àoÄÞ8}¹ÐãÑi% ’# kvA6©Ú"ƒÇàͳlmhr¥oA|Ø}†FÆÛþé-ä’ƒðÑAÊ+i Í#ºxD¬OjÂlo°Ï7QU8ðµ¨Èd‰ˆ§K[C–Úçë¢Ïö_t\û4ªür¤¿Ö®G×mE gÔ8$küÏ…¨Dý#Åm‰ÒHB#›×úT”t8ô—8k"_yÏ'úžâwäº'ñXqõ2:jì,ýò÷4~-­±.\W°'yï¯>2?ÉMè«t0´Maל+$d…KùS¯ÀÒA¸Æ¾Ó¿(ÖÓámþ:«ófï½4Ö´½ …mŒi}j ŠkÙG ¬ ;þøÜ!72oæ™üF p @hñÈm$·Upý!b8¶ŽEܪ!µå¤ wä†,,œVâšãw¢¾ŒÊBÒ6ƒAijUÊtÖíÍ#ŠÆò“âýñZ®Ø-Ðq]H+óÃÀnMú·_ŽáÓ‡úÏSqʇïÞ©{·™–ƒíùQ÷|ŒúAºT–dÇ1ÓÛîùž‹†ªóîv-T’Væ³îrѳ¶yV}âºè«Ë ÿ}‚½þñ-©3å/+ÀÉŽ¾éÅò(ªB–,kø3s&&lKVÁ…¹‚( ‘¾¢ƒŸ¾î-$O8F:?²Ml¬%ßS\\óÚÑÜø©:Ð=Ù¨²›ÿí qÕ¤ ¬AG’™ªTÉxØ.ÕíšõÓWŒ¬ÀU—RXH4ØlŸ^ÉçìÜ,n›÷êÂBDæ¯ß²\ÿ|8¯Ìªû‡<¼šfÎqFè8 f±6œõ“Ϋ}Ž/ú ; ` ÏhéK.նΜÓùb¬º‰tÏCËb¹®_¢¾ÑÖ‘ýóC%‡a¹R™tÍaôpÔQiÍú•,–›÷Ûí¡%Lûz”‚)â$.º]4ÜTr\ë"úªHE‡ïnI¦v¬f8[”èkW`~¸ì€¢tÂõ5ÅZ«bB a;[ˆ¹ãh;Aîõ͸.XsZ[Ãmá§«`˜½I "1îˆÖØmn…·jöt˜ßÛ EfMíñ«T£ëÈ·%‡C ^ N%㘕/„¸!$Å’ŒUŸñs›W ¥]Ùx<¤fXtföÙtc`eOÍ«’ ·°4ø‡ÞÐÐs;å&”ëë®!¤6ñ?¾y¥o(àò=HØÀ6ð–õ»ÂÚ„ÒÿÚqàÆÊ Â¥ï®[û ·6ˆÓF‰O Õ;&âÑ”_-‹î=ÌO{ª±žKÝß°àcúà/Êw7ï‹N¿Íc<¿ýjækÅØƒ×¦³=ÆÉ ”5®jºïÙ¦~hvŸ‘'f#\ Òê,÷d룞Æ%f¡ˆVß¿R¾‡šg ü´Ú×iëwê¹”èì3¤²P$ךÑM¼)åMV9k¬ÎŒŒí»Ì”t‘ü*fTeîpB[üââÿz4=˜U)t¾/7ç²%‚x.«>ÐsûéÆP³ú¶&º€Ê½ëÇ÷2„±¢„bQ¹²kZìQ’»Ë0Ügÿº'’Àâ‚áÝ@šIêËkÃïÆ>»¾òW¹tM8&SˆMûvaÆ‹:‚‹-'Î4+¨ÁÈn(Â(ÌÜ…Û”æ¬ `bÅioTjÒ¢"‡æ×ËM+l˜såש›ž£rJ ðñîHöæf·S¾H¸ïÆÔ6#Î÷jÆt_½“U@' $Ï34N~ïtw«à/¬ç›}nÛ©Ák8%µ7¸úBª à!¡œÈ8Â*×óž)Qæ#ìiZ×LšÝûÒ’ þIœÁ ?zÚ ä"^ùÓIDAŸoÃlncbƒ/J…Œ¢ü ‹7 X`rhj?­¬K‚îR'Rš²sœb!j#ŸÍ®ŸUHö† ßk2„üpL‚Ú´KŸ5ÝNg“À.¿`ØÙ°¥Ê|Âþ •qê߉›ÐßíO§ÏO„1•4™. ·ûíq}ä÷Ú\±e ê¡"“||•`õRóIJsÎŽýÌîCKEÈ»©±‡¼Ã-W"LïÏÍIÐA5&¹œü•^¢Ú=UžÝ8^ϼý$íN€4ùM?_,‚þ“Þ‰¼q²iK@\Ѓù.xü"ÛÏå“/Ï]dbôOò*èØA¢¼­;ïq–‰Öȳ.üë]‡¾k ïó¬a¢|!„méõP#.gÚtì_xó×Èqåz\kæ²cQS+_âëïÐÔŠŽS=Ål&\ e—^{rW°KÅ7±ì½v ÛÀ\>ÌÉ*{®È‰Q^ò 2}Êä*d\ln§Kk>¼>²ÊÆî×r{ÙÎçë\>^ˆU’‚P"#zö‚:nýûE\¦L/‡rr:¶9˜ªx6]¸SÇD³ ) 16Ö!EæÛ!Ý`Hü<ã;ÇÍöù¨””¹_üÏb0ÛS¥ßPQa'9«˜ì‚c±aíÉÂt˜¾âè&&Ñ­=¿88ùß•Åo—¶Ç&@LãÇt½GeŸH¯ãkz©6ÌÝýäv ¬´V; Úik…;!Ì4*çê¡(‰ƒÎ[ &¨¿hd“¶åPˆ?xIŠTÅZXt [Áž Š~û: URV8br0ÓW8<îΦìËG±‹î9È%7>òÊó?LÁ¥/ ¨¾_K@9ÞÙ+£bV«t  ]>-`KðÉ1Ø4r²I»‘ö˜o­cSh,Ï–¾Œ}å“L<¡Á7ÿB–$o”°‹³&°Ò€ºOͤv¡Å~P{ƒÐú.ÿ“¸åq <—Y(¹ùXÔbý5 vâ§[ì4"Ìr˜t{¶º7”…ÿ öˆXš™\¦ÀÆGŠ…@:[¹÷†IåÚðÉá.l@W EsèŽáÉÕ” þ~30rnImŽC\û J:þò …¡ÌäýÁÙKŸòƒœ!Õ­Ñ;¤S†ç|±÷ü•ÄÍStóŠñéƒ{²®«o¾xÀē٠øÖE4ÆN­Ìh^L‡¢›ÕK'`ÿšR“ÛåÝ=Ô'Ã5ß”hÌiE‘${Ïbd‚°Z5Š˜ÂE2€È2cÐ/7™óK *g5Wäc®ÜµRÆgçÔö 8ÿq[ceÝ{Ä*ý Ò‹a¸9¿Æ- vùë#Š(s”ÍóBØÉ MÎ5N<å´Uh!’&ÀßhÜÀÝナ㠓£‘ÒžÊÔÏž8ʃú«tÆræ@å,TMš(ŠGÙ9Ó¯‡Vô²Ö#Øξ@™žµ0PosY%«ô4Çñ†y~ÝÀN=£°j'½®Êò¾„ÝzÎú|ÿ7ö„gìÄukÉOr:ý…‰;n±z‡ìR½–áaÓ…>5Ú¿ôÇÄ £WªRǪoÇ3ΧEºë×C5xwÌV¬êS¾£-ucš.s†‚¥‘—w\YŽy¼¤–·*çÂÁYŒ»9ϵl(9|Cà!ŸF¤ÁOÙ\R©‰wáí­nmF·÷X\ù~$ž˜¡ÑéèH¥¨Gj™ \Ùo§+!&NznìÎÒæJ†r?«›at c£\0 a›hî4þPgþL¡hÖ;ÝýX¿ÑˆEút‡ÂÚæç-õY*J핺.+Ê”Vq¾ëÄ‹‰#LA¯êÞ˜aÁá—W.¾tøƒk›þ•>i"8ˆ•h:ÍëQÊ'ºô<ž½»]#}p£)W +ÝÊaf—˜Š‡Ð7â×ܵ÷ˆ[瞘p»P1ÍmYß™òì¥(«&*B€•ìììa_Ô,5З'cì ¦Óòpw©”«wsrÙŸŒ~}a†þyx¸Ñ¡ÀR³ƒ%úî´¨üô¯ÿ;xÔ±S™uózÅEü+øµéÐûòÉ{7í^+!ž!°–ÁkïJ×ZÆW»^ÝÔÜ?x²ÂßS\ö d{É6ƈÃïdµ :ˆwéûI[:CHî·g-H½q8*ü”˜ª‰ýŸ•¹7ôá(—lŒæ + >§ÔsôNMñØ¡¼åvxx½¬£#+Æ™6ÆÌž)H¨^9uûÌO 3­–­#Yáä)*{óƒ6¼ÿnmd¯i¸ž&Hk©«1$Â_W™ù;b‚òƒZ)cXîØ£m~±mWÎ}Ù]Ñ}nW®8vÓ¥»ðzR¤ìnž2j¤d?ÚçÒ7é wÚÂ;pK¥\Â=ƒ0bÁÈŶ¨Y²1.<^˜©äšXqRÐe¿ZFؘ‚š | D‚|—&Œ‚0È÷uî.:?ì®…A ‹]¨¤‰©ûsx’,¶âá}ý½–2¤]w»§â]^rÕ¹Ti4w©Ú5[~a®W<–Ï‹ÛÖe¢1%mMù³r«u¨.ÒÉ©iì×›v‚'Óü„3ÚFÍ^Ç{wª0 ÓÜÐWGé)Q™ø8ÈdÂsûØg-£ÏdÃ%@‘6ŠëskáŔ𠕉äpº™`L{\휇¸˜CîKà_ǧ«ûS€e]ÍCö”y‹ËcÜ[¥%Þv/#ŽˆaacØÆâ·œ6êÞȾ@Ÿ3ßKD³›“WSËù]ÙAQy¾Œ$®Õ Ó¢B’¦mÁõt_°’ÞÆú†w|ÜûÙ0„Z8qn™ÿ+ü&™¨6,¬‹xyøUYw†pœ Ò r¯owzX <ûôÐþºÍ&JG)äŠØï癚ŠF¿C—ãð(Žn$Ä3Ç ¿Nž\ý}X>8¨èþ”½ÄÔRí?Ù@1¿rSç@€†R‰*Ô]Dù´Æ8ÃȮ܊þÈîTB<sÞÚ4ž¼Í‘?:ª¡S†AÒ;·g߯ê±TúdÁúj§¾ Œë†ƒ•´çĶÎë“GÞTá6aRV~¦„ {òÈY7›CÆ ¨K>//&uwé§žˆ6˜ Ky2=\ÓGÞIÿy–Â7ȜӇõ*†tåãÅjà³Öø¶8Ç^\Aîo8 .îdˆëå wdœâæfê|’Üw‹t;=>ÌȼÜ&&›Ç Ù¿¨^M$FVXh3M¶U%ÌÉ6(óÙÓáÊ9:®ÐxHƒM,ou@w:¡ÿPŽã‘Rü6ò’‰¤pb#ð p˜€c®¤ôÖdn‰Ép:Lš[]¬Ië -M¯üùð”«.u)k¨´—. ¶òr6øƒoHC)—”Õ»ÆCJþÓ)åsÁuK~¤Ì¼½©˜25ÌI{!y(ÛŽèÒÊ!¶T…0x¼qåϾ´¼Ž†ó%ÍêIŠM‰âéõƒ4Å1Ü+æˆw¬/·‚äsÜHº#¿¤œBàQÓÀà0+‰~@‡ò¨HܘNÛE¥`f‹^Y+Ø›ŸKÁ?§ŒPÀ‘ûÌ…b e¢EÁŒUÿµÝŸ{·ŽBfIK«ù@»Å3l}“éZg¾ÊíSÚ¹<*L÷ O›º—¢„ø$#ÿÊdî § eL]‚–äóîfð³®ûÖ¤ÑyJ8o …¢wÃQî¾Lö2[oàÐõa<*ÖÊ]e´›Sú®ðU r½îsTʇÃC)%àRW©ÈR^@†é×øU c`^…-úL DT¨%N>ÆŒÀÁœ‹¯^t”éѺ­\À0øbî´"Ì©hĆÛ"·Õ,wa’6×ÌÔ` BQ=ú‰>mm¥¥?éÇæo®¢Êì>ub[Þnxv}ˆÞ|`çÓ~6h“gë±DÐ*ß½Ÿ>/§àeê%…‡ÔØpº;ÿý4®S¼ï=!9V_B³KÏ2ðÜw¶ü3=– ™v\‰Ä¥ÎT[,“žJ½ôÁñEM¤ãìAû­öß[E doi2â §ƒNá0¯¯îXDûÝâK’è(ÞÈò·Oã"¸¸Ö¯|›“”É­@ðÐmg¹ÞÉoH‚üQ| C×´_ôꤊ"1³ÒýJÿC¯ÿQÍ?{á}ÑU †]²ë¥àªÀ:´`%Iž¥´ÁõòOˆpµŠÖÞíÝiš©/Úú¬©ŸKT*ž b¿I–•þ?ëÇ ø¸éœX…ÖöpèÖp{LPjà=…zb»ÇÒÙ‰§yÀ ´éL#Êq6Uºâôˆæ~åâSgêľž)GWúã`i¹‹%¥“”ºE™”H {–¤r—Äâûz†Û6M„âjð“½>È=Q“Ž…·ò(äFÃîQ¢Ö¢ŽÂ£ŽVšRȬô¤p’(~ˆ²$égo[f àqâ;)ã¼å\Ïõ›ò­¬0×Hèýy/Xê´ÙøcÄÇ‚§TL‚ öià¦Zów+q˘5ÚPX”ÚÕ‡“ç$Ô´Á‚¾ðî˜Hre87>Ù­x—}ÔŸˆ›Â¼½å:9|ÂîþÞðiÓ^j0v—ÞÉÞóØá5ñ>ÓõpR8§•œ}…kK~ßÏå$?J¾ð÷º,•‡ºmU8w‚¯RÃk6Ķws›òÂkà!ÄŠ6bé9¢s!(p;×&œé;ÚöXà Kü Y“» Ú›HÝGÑžK ¯ŽZ€8˜šæjºOK3Ð'•xJb€ÞŸûÆCE:ía)ê/Þú­‘ÇÉOR+/< ÇNut7•r¬-œ‘P–\i£Àrin‘ý~¡I¶îŠ9YõÓFáJ‡­É»0ÝÑŒlc oþ>1€šs“_fìØR‰Ây*C0 ÃûVz3tó¦Á£¤ôa¨â´¿\sžˆc>%™ˆ úJ7ºÃ#âBtlô ‡{¿¥¢º(«vñwî _ýq‹‡äàÞ?aU .Óèd¨Ô'Šp  w©íþ•ñ×4º`wÞ`m[PTUÈññÝ©S»À;&„ßJãa9r_ª«›1ä¾aÒ*ð•0s¿y¨èbf"žnÓÍšf“·Òaq>‰ÔLéÖYË3ÞøÒ˶aœ½¨ òMòäfV‚R›8€™?ö2] 4Èp <Îì˜{™ËõE.1«…^^§q¬{ÿ€~œ?ã1ÈqƱ–gSþø–§<”4œnûL†§à_Í/ø{ôN3Ú¸ìDZËÑ+µ{~¶#l¸T\þ³¾ý¶5çFÓM¯rÃT=7t=Ãô-»£ þ²6Vèáb–+ 9úPÞ:ý¹ÍH¡ò„* â¸ö•-Ó;–@óVÊÆ ú¯¯¼zÁ€¦Ý BI…Âú4/ü‚þýò œaÊ ´jÌ“k¦W:‡ª‹@cUš_‚= t=ìïë§3œ#E`½øàÓìÓ˜¦îx%®¯zÝã™Ç Œ.rš}“ïG~Ñ”^f39Š¿+¦å 4Ÿc<0»µ¨üÈ|¨ËjAÏâ"¢e. ðÝ*-Âu‹• ý;YÁ*éoÙü¼¹"s P5­ e»b¼Ô½O¤e²':ƒ?hËlŽ÷4˜ñnÁCòô8Ž5æHr}P8Wt®:Í+²: ÒîQŸ¿Öã•^+q‚'»Ii%á/swµåú¸`Ͱ€Õaé@¨óÁÏ1L¼ëþ¡EG{©%^ÐÌðš)ðûË H¼+IR›Lë¶é5Q‚¨š&@xC†dÇÿN~í6‘Ä{GV‚nWªlI‹#˜Nîh#ÉàÄz×£¡·Žèž$(Ò[ÔüÁæýñ’z»oÃX G÷ÌÚ{t-rfÞûŽÿÒG0‡%‰È¥ò’Yb„ää9Eêîém¿~\rCHÖŒ@˹Ôÿ„W¿ uVä¥_8@w!ÁqÑòÃË"x­æ˜•›¸ó&a&Ä$6ÜE ³À¢'ô`2·Yly/¦âF»ƒ'¨@f²€”ÛË„®_…_Xb¨½É]NDgÙ‚ž4£;Ù†Ù ]tMBÁ»àÓ~&Þ|ÖÈ4d·÷ni}Ñޥ؊ n³¦¤‡³9høFI;ÖJŽîõ…HíÄØ׳ƒ¥ ³L"‚U‹Å¨]aísc ¤)"¬–"²±‰:õô»C‚¥‹AnVmDÅ2B¤J°VŽ^9D8¡vH2ôžüÂI`è¦gIß|+lÝçÝš­e%K#8ê¼îèDQ•O}4¾¢×&Â-ÐÕEkõni–MÕ7âÕØÙ>¨§ÍͶÞtj˜ï2~ †¤³Mø®Ò–ÈÓî« ¶Ìïc‚|É>ĦÌ¢"O•ES§@D„%ÒJÚCÏ Ç*õÿ$9´ëv)@Ù—w¾!€*V¼ø%›K¦tJCú]§W\F†–Ö׌ˆg:¸ÄÜ^»ÖË m ÙWMJ…NÝz–RŠôf_µ¥Ð€ctÚÖ5kK™XÕþutÜæÞ>`*ïÁQV«DÐé<ÕØç3ZqDÛÁb.ˆcè?rN=(ñ5 ÇŠT¿a§íPytÔàoªc¯ÐDl;ööÊ^ËZo$=ˆ[þwÛ{Eàn¦gR\´*‚F¹ý²Íns5eשx†¡Å1X&È­8Ç• b…?l‘zÆ ÑÁ©ÞßÓær.ìÎK·¢þUý1GøÆ[ÄŠÛ+»,ÜÀÛýÄî *7Ì –`䯢ÑAož©_B¿P¿L¹öÐwÿaúÄ/ô¾¯˜ä¶çî{WKЩjؾ#ÍÚ-@þr(UavFõî=\?mB«a2½Aþ”+Ï7dbÒßÎl»Ün6âqy—¥ëÑô$˜+ù &E»¡úKYû*°µæ¡œ™ýÊMJ]îŠnñ´ÞT²jÍ,%lÜ+5¸ñ.~>€ëÓÀ⇗+YšÅ6±ü)8¸ÿOa•u”O» z®æ¸T¡ò‘N0¸ÖâOE¬Ûq€’`¶²ƒ–ãß}ÆÇP¼vü.î]Üd«•ްײŠÍ„Ï[Sø%õaD&{ï3º^)¬×Y1œ‡FŠœÜ3Çü«aLyè·Yd•M®¶f;h°âæ¶Br hÀAæUƒÒ£ss¸è@®6¨ÌÂ!l¬FƒJ*9,üf—Á͚Ʊù°Ò'Êâ-{_!ÖÔÌÜ“¿¼5_Hvî'sŽSyÚZl­LC²–ÌvLÊ+y4Þ»¤Ò #4Ù ñÉç"n3IôGäƒRö™·]Ö.Ã6kKRzJST¶¸á*¾P4ýwlZ؇_¼+ްë0Ðs‘õ[µ4¦=Å*Ó&Ñnwí³Æ¥Òm›‹[‘7¨µa ~]ƒO>LÍÜ 4¶¨„}Çk'¢_—Sè8 ½þn½mûìLýì Ä=\c¿›‡8‡ß_K¾ej©'óÇRnFëb›FÕ9¯< ÑÑnÏpß×,Ð,ßDh• êÌ"¿0œ+¼–Ÿ 7h‹IíòÏþß:H·= éëöd¬Zq×<|»B¨›ü8 .m®Xe<2‹øYXÉñ <Õ›—Á»ÅË’1 Á^`{¹šOŽ›Þô•p^Iã\!]Ê´Q±iÈõìrã5ìóÌ™’Ñcɽ¸rÚâƒó¤ŽŽ ÍT¼+¤ä6‘X sjWH/éâ)ûI— oÛ“û„ðˆÝË,9RH($h£G‡Ã 0Þ~Æïf+ö–Œ‡ CrEKØLljŸ}Ù£yæ#¿É“úsv¸A™µI„ö[JI· ºô—‰8„-6œ¥ƒ |3òŒuøfgòTú‹°ÃU™DoµP,£ÔÙªáòVç,©Hþ㯣´ë¼GÿËq‡/øn¢6x Ù*‰ok•XšÔ!‹.Ap„,U<9mÒEûhm6¼È„þ×øëáUê†SØw€OO2;GâBVF%×hÃùîàÚñbeDO+̧ïû:p–pˆÚgiøK³×Ȭ6G!!ø‚eBrçÏh²Ýï…1)+ì>Çs–P¹¨Á ÔƹÛRôÂ?÷ÄL|ï‡2UG˜û<çûhöhE»›rl¦z½BFs Å5OpãâÉ„ÝC쨦’7XOÃ)pöfÜ÷XŽ.ÊTš n>%£†6¡ Zu˜vJR¥›1“H‘L{ú~EÄß…í§ìU#T—Ïm(ƒ-O:o>õ¿ ¿k³ì{Ø Û亷rsX‹¤ˆI’üV¦Y¼0àPåô,ª³œ‡××ՇȠôqÆßL‘ã#>¹ü¤Rb•Û1Å@Ë æö”67Í7­£“²E¢O˜¤FAAúט{‹©ë/a¹0>¯²[£ Ç4nêľ¨“‚UèARc¡*ÁXÞ“ˆÅ®>”îˆI¾/狘¾h¸Ñ™ ï‘NÐÈò³§MÁË÷*Š`v|ñŸß~ó®9|P¼H×7¢¶`lñüønåž­Û0hšúÜ„èÖóóæ<´x@ݬåák5ŒZ OLNZ@<òÂò]Ë @Û1†à9ÆrO5M&é»åÍÜ1Ë­}vËïrt¾¹J{Dë¾hO3ʉ‰k†fÍk`”b%µw‡™¼Ui°Ís$xE&ü“ãÆC.@4J5Ù<%ãÕ´”CUj/±q´+C¼*6y»,èôòìþþÕ—j¼TêJg{=ÂÐ~ížù¹¬‰¢6<™7 `e&'|Íz.÷à;+Q‹ÀqÀý¦?ªYÝ14ð×ü :lD‹ÈUTZ¶c7yM1¨Ì‘¯‘ï–xR©¯ˆçºtý§Và/¨=°©VˆG¢æ÷ʬPRòU0±ª€¶¸hˆ”¬m–—t«<cF}ÎNÏÉ1qvÝŒ£öhé°ïô»úéþ«/ ß´Gq„Ò"ZDz) 2—ø?fý‰—r)µQ|€c¶¢¦¸N-‚1”a¯èÛtrÅ6–ˆ2"j×TÏW¡(çwÂÑW~Y×£drî¿©Hˆ$«gå×H?Ê™½fCLžœÛb ˆ,‡(ñ{­i¹D}º7iëtÃÁì®öƬ¿EEuºò)}?š¸ÇýX€‰æ? )» ¨_`UŸvm Ÿi«fÊ(jq†§:øtåy³@ÊCú\Õ:6¬ýØJýT[œl‚mV«§‰l"÷«”JmY¯ê¶j­ÉÔŒu}]haÃCª%ÜÑ^ŬúD^R€eY°é^xöí,±vÍ«Ùó^°¦G~mÊeúx:,#7„Cègä1ó9ý‘‘øÏ&ÁøFµ[dÄ•F•6à÷à†»¸>ÛОÚ4çÐ 6(’Û?/ôž¢êž/ÁV>•¨¶U[ãÄÌÓ£ê7ÑkR/H—’ “Å€µ­þ¯Êv¶£¤b‰³u6Ñ¥ùåŽ]xÅÚé+u˜’ŒrQB1¶·üY’}Ò¶—>¯iý>øùþ‘ÅŽ\Õ,!ÍàÜžûîÑÃâÅ àãÉÀÛÝmèÄÃÐRoOîܬØßå±k½žpÆfÁ©2zªÙ;b®ÏnBM`Šjf¼˜\E܇ZÍ7A« áÛ ’úÑîs<-÷)ô„| ÿ¶…. GCØž}i¯`ÀkB%þe9L+µÏ︘õÍ4Û$ù%ÆÅ‹±î³Ä >°‚h¦Ë(”Ñ{↠ô-K?x¼ý<^öÿÈÿ& /–äӇՉ릲 ù|ôŸÿP#¾p]¨¸>Ÿ9Ÿ]æN€[‚R­ºÉÕ°;Ž­äÎŦLÕ”Xcœ˜Ûib’/UM‡ÉìÂà’RÛ™³ÈS¤±±Î¥NÀúÞg¿¦ÈŸ ê… –÷2†cöFÔjŽ˜C¹ñ¾ëH_ºÈžŠ…’ÝÔ¡Eš'Â×{¯ Zè\¾rôkŸwT´€#දª|·@÷îˆk¢=/.‚wY®éQD¯ò‘m%þTóO׺WÛ ºË‰ÒQÅós²@CÏ'GË ¾yCÌÉä,g,oÊ%Jw™_ê®Ð¥§äMîfIš­Ò(sXÂI;á ´Ýøe=è¡?ë«%/àAnWzoT!ý˜2õMB¥‡x˜uñN2tp`°øèµbZä× ø‰ÒÐ4Œ©·¹ú'?Žj¯bº­–+R= FyD}†übÏÞ«S‘Ñbž¥1ÉÈu ùòÂAÑÑÖ2p{W'a½Ò:GNê£ðk’rd«Cø^.=¯r´å èœ5åö@ÚXD…ÎsàC9åkï¢Ó¦.³Wòö9«¹9ÀhL(#ÎEªXîõçI¢$‚™ö |Ö ØbܲÜ1)/ž¹m3¶ã=¸Ü¾"ýÏ:¼üÂ^Ñrb¨>ÒÖUœ )ø3Ãüä³»»:Å ´ïÁ­ìžzb°žì@–/Š˜ž h®_â-gëA]3ç[·D¶*,`û=9ÊŒeˆ™4Ãéž÷P;qBÊå¢ò;Î;të%oùýPP1Š–:ŠÜ)`Ú‘ó¦pûe›3°,”ì©ràE¤»úÏÀ룹ŽÃæÄ®›ìÊšúžŸNÄdu9,íL“LïñinÁÕäÅr÷˜ª^ˆ¡É&²t\Óï Éœ|ñÎ{Þ)”>¡Ünwxƒ0-\Eãìc‹îOGø;J:;]“ªã}L"'2W-ŸÜDJoL$Òhêi™+jž'U|†»¨^l C¼”ûѾŸ0zéï wÊs‡ÜЪÌq @7PÞI T\Ò„ŸÆè ñó6t°Y3-ÏO´(@4Ëæ»sw§l¾3FšÜ[v÷~ã8k–/½v1+4@«‚óùp F&'[žø³9E=£&;ŽŸK<>óÎ ¢-Fî/¾‹ tÁg‚{Æ…§Ý³Vð( ü¶ˆ)ŸÍ],£8Ó¯|…5Oø{³nfÊBN^€_ºêiBK¥ã˜n!ý&<,žYFJ—yáºn¸·„¤–qÇ}K©…¹ÅxÝâùªbNÆ/ÓêuÁtg´Šòuó2¸º•¤/yTôé›¶Aƒ!OÔ1±ËÒNZUJaìÈW·–²ºÌ}ÊÍSÖ "í2Âf¼;âÃ;ƒZE?ŸÅÔ‘˜ÍˆÑµy:öª´idóHâ¯áÇÓ-‚ýšßÕpó‡µ?sÁ°¿ÝrL‚¯#‰Õšè¤ «v½%³Û§“’¡ÿ÷µ¬÷°ŽûAíOEñ­O‘þ¹Ãþ’»JÿÖý3´¨Š3¼ Œ‹¯2Øí@H½4‰8Xœ@J¦bu(oÆ ’ŽE04Œû®+[š%ß›®„âðè¿òpQšH%0/ùtòføRÿ½+¬¶,ìhü®5ËÄ/Bô;ÙÌ @öZßBíM*ïWTŒ.jܪþ¬)Z½¯Õï¥pH½ûT÷¨GnVi”j £”ýhi² s…(Ïxè $q ý$uUuoìÞé¦>Šô£a/Pº·çù+ýÖ )îݬIxèi;çU½°ò}:Î_AJ±7ËzjèãFÒ&«N±õ¢»Eè|dv§õü»¦%9>š'!óB>8$Ž5^°5£²cëãè*h&eÍò,÷a¬ttc;ºÞ6 ÐàļׄžM/3>E'nÖΰ¿¢wð§ÉÄjû>˘Ty`ód_\¶FJnÈ ¯6æ{ÃU2 †%‰Dc^!™±på ÍÖù=ypÈ–6@†1-þ2zæÂæ-Ã> œfWû@¦ë0çFé6¹ä ]Ú°¯ú óÝd7êjÍfµ€ CûBõiZ8}>‹¥ CÊNú.ä.y®¾ÉÁ»)lQ.¤.ïDýDhòµçÔ"åÐ,¨aŸš`“ºðh7ÚyHnÊźDËÓÜUeßÓÊ,ù®õûÌI/ü™ò©½yž'$‡Q½ÑXÚóçJ*¨£\)¼–ý»3¯§B`‚´~l‚‘ÊÎ }¼MÝêø' CÜ.¤Q¿Õ”ßuhΘóÂà龨áÕNVa$ÿ†UB$Úeù ÒçC™KŒ‡ÃÈH… ç"½Üëk̈² #pŠ"°>‡\­8¼YXñ’™Z›wÜ4Ûš˜[ä?o"]¦c2žÛ<¾i0+Y…ˆ&Ä©õéR~» әްhE%'Ô°×bÀΩ)oTä½"«Ñ˲‘¶œf³ìu€¶<Ê@õ¯}eÄØ‰Ì¿–ø!Ê} ‘»ÊV¹ã"Ï\œ·GŒû^‹¼¿Gÿ©ü鉛|€ u„Á û¼\¶fp%í~²Ö¦£â%—»é,¤êðz¸÷lº:wÃIàã×o§˜w­Ån %~( Îôá’¨šÕ.Äe~^hÑ%8£„sQëó]1Å•9ã+±õ\ ±ë,˜÷82>ìnyI‰pbò€‰–ŽQŽ[Á]¡§3A£ëÞâÆß€,t™Éïg_Îb}0 oÀ‚$F€dd=ˆ €Ü,Ãî/NMG*„Aù!˜Q>/ïkL"`0]ë>àÃâº8ðE•v0¢„J3Y$õÕJ$€*>x{,Š;¶Ì«qŨ‰Fªú@ ×ÆÑŠåOed=WCÕ°ÒÃú m+X<­:TTH”èpÙ+·¤uÄß÷;©p(>e€;õœ¼çè_øé6‡ªOºD›)Žy¸šIÏ•O$ñÿ"vØø£mWí¤Ô5«‚ö‰©òîðpUÕe·L&â” l/«fàÇeQÒ E[ØY€­`+é×H÷Öi|2…D='ÂGœq9?«MDIX55Eþ0¢½úyåN1q3¢5}Åwç‚lüM·ØýR¥&F‡',v.ÍmȇçSÕJ]³TÄ1­9Ò?ýÐR¢ž csDÖ`ßïžÌ`Šþçü¦@ÞsAîh'óZ-™»n¢GœÁ‚m3¹*RL™-¯Åž3r0±Ä›×ÒëM$Ê\÷-’ô8²õ0üš¿‹9mRå‹Y‚ËéTÏ†à æyoQñ#àH ïuŽ\–T6Ï,Ò*1_Ÿ¯™V‘œ¼E Òæ€ç/¹eèí°¿a{SÈæsó‡*ˆ™Œ•ÛÿéÚœš+afÛ¶mÛ6&¶‰mÛ¶mcÇ6'¶m;çý.ŸóºjU÷ª¾ŸK õ¿€¯›ó063òëJ3Ós2Mªä"¬F:ä™nžK)ïKÇ”GŒ„·§ÃÇëY¯CJK ¹,“.ýùØÆ:¿B^‡Í-(Á½~ 8ŠklZ.†O—ñË&ÛÁÑÃÚXünJÏÚ̵å0—øg¥ìTœÕÕ{øWÒßtÚ-ºãžuɼ„ÁÐÂÙÉ8zªÈ ¶>Äeyx/Wÿ9Žœ¿ÿ)‚}\6†B}ÑèÕRâ•ëF^—Úêþl›¸«QÔ*tÌ­+iÔp+êMS9|æKÑ¡fŽãÃ%.±Ì&BÙ¾{sÎ);æß3ñ%¸/ú4ôìJ©¯!À|Ê[’«ÀsÕ`ÞIÜt‹¥z)ÅW:¥·>ƒÑ6i‹WË‘'Êgl;h8æCEÇc,É%ÁRÄÓ¡`„Ýy7{ßZõ$D¡Ó?ÈÀóu©’î§Ù#rÅBèC,ŒˆÂ߀1œii €VúŠ[´Ú/;z$辡Ùþ èpÉH·P̲æ4•áöé l](Úð½ðxû?×ä¿ Èåñò¡V…Á ºêpŒ”ÝC© ¯ÜͰ2`ñC¯(ܵ44â'ÔîæqÂ(že¿–[v]ÏÚ#({èÌ×zkªžõÁ§¸ÊyMvwŽœzXÉÉ·Z =F­åHN 9ê˜w³svÀ EÐÐ¥¥i°½‘@ØÐl×ZDa.²Ñ¡–EéHdS̸}ÂÀÞ*¯«r¼"Aø™*SÊ5óuž€³×žôZ?iú7Èõä³£1GèĽu ^‹Eè3n¤¶ó 0ª ÛF¿=žG‚`¼WÙFMDcUVÜž—˰H¨ƒG©à­¶½lm0™[PYjSѰk1([¾I2Cü/I0zæá ÂTçþ¬pù ªk!.&ìDÙ™¡YfŠæW‘le«™!B$”Šê jlyceíôÆòR.ÙΜ[6ýJ©Ž—Œ:G—ZϦón|þ®Äe¶Ç—%ÅÛÀíCõHlúr/§‰ˆ´—©É"Š-¥w¯_bE>±»@èoÛq™³môÃqSûÀ¬ì8ãûUàÉå`Ô&Oka^‡?9àf{ÖŽ2f v·Ïy›8£01¹³Z.÷L®k!ÄlþÅþ5"pŽP‚RäéïtFãFïgó¡7|„XŒ–1¯ÏŠÍ>æoóÝ –|? ôÚâ˜n”ß Kî-§m ZžMïî;qÐ, 1G¦][û¸ö[€ž„Û(ÇSS\0Ê£N ;¬•òÕÆ=ÌFž#¡ë Û% ÆQ6ßxUáëô{é4ɳ[¸$Á!²/SÂ9ÓÇ~…¦4ˆÝ'“ÃíYije¤cŸÃR-Y`v‚(Nצº=?ŒÓÃÕ­á´fˆËѽD컼b½¯5y ãèyå:£ºš‚?çêõ[ŽØê qš=¶.K½þ[3ëÚ$˜ð-Óìæ¢Ù5ÂQ™º¾ÎÅÝ4ÊÊT!€µ$É’YÖ®Ibª}{¢Çœ¬>G®Z¤Ð¾û, r'(U5å‹×Gß!ÜZûÞ³ì& +“biGœe(ð¶»æ@#^ñ·µ=º¤^˜œ¨OUl[!‡ã¬3cÇ ¿@?É|%àÿ|Eü~•ë.Hö>BJÄi‰Ìgƒuºˆõƒ÷œXßH;÷ óa1ÝlïÖ¬dÿ© A œaì3óM"É«pIuO „€lx¼‰pȾ…j}º·üÇ¥¿ë€ŸÇqï¨ÏRh|¯–,Æ2ë¥æ!†ÿÖžï>Úƒ±€þÎ?@Ã@ð½.ÁuÒš`ㆫf' @Y¯¼Oÿ\ÿ›±€u CŒÚúý^‹ /(a¶ /VÓØø…‘­„Y2,Á ÎPºà<D˜M±6º"§ìYø`’·`k£-ßó7ÁDWÏÚ¬@”Ùi3ijç n¯ŠK€>8œ^¬4„½Ê´ÍE ¸d„•wT‹VQËŠ«$T`«tÀ™ëÄ9aíÏ¥3J#×êoÒˆ%Ã’9ÿn!œ–_Yªm Db•ùìÕ=âðÓ=Tþ‰0šv—•ÉþTšäMÿrlµ“ý²£^N8%Ì*À¥½¼Š‘»ºòüÞ’0;ÄŒ9cúÆ3Ûêò_.χ.ú˜Íø\Mc½C—ýËUÔT×]Ñr¸UWJL îêóÚ?«!•F¨¸Ïl¨ÈVÃÄaûP£Üýû ÷­FBY®:pH‘QêÂ#-íõ}Àld#Ä!³÷ÉÚv—ð:Ó‹M*£ÞOæÁ֢᣹%Cý#Ò%_çàúŠìfÍp|X¾ñŠšpC‰O[ºÖ² +ä>½»ÐlÒŽ»¸ßÈ #áÛ…‚#ð(¶ûÊÅ©÷^q޵h3 öf„¤”¹j‘ª¢ÖÒô”ýæÃLžN:ïeÁÜ4)YÊFœ½b»ô7­Z½ÌT{œ=¦ÌXÉ`añ§E UâëÄèçJiÀÿùÅ£óz0gÊ×ÍñÝ•F`¶”tº$øY›ËRU>§Ésî`¦È•µ;Ý:I5A@·"I‹6 ÀŠÝy>TlÁ³ÒøgµØþ •B¨ÆÝâ¸Jxºãû*™ÀÒZO-]ˆPáåëµ”;“Ï-¿9a¤B}ŠCÅÆÓ8%ý©,ìŠñfðì•t×ÄB^6K¦´§EÔˆ–´ü@?ù®n 8Šn7¤Çj`¢zVf#E32–79]%Æ"Mô9†¼¬˜åН×ÂͨÌaÉ)mËБ81V•%Ù–““¦]`™H|;ü‘;ù! .¸˜pæù‚Øž¯«e¯gÿ$´9;Ù`–ÔS$šŠ°¥Râÿ½º–~©É0ò>aéò͆Õ\ª§®õ5¼È|ϧc5êeäp`y¿Ô^í4£¶5Rk_½^. bÞí±©‰|ÐS#,œªöÎuãìÐ^Û…§¯‚J2Ì–g‘`£6Ô5Ƙ{”Y çÑoËEèB…—¨{¬s aПŸIÓ”Ò„¨WVÄ}Œ¿Ç¶øÔ;ò„JY“tFä^ª÷œdB#`ÁÄå£×`±e釬, `'Ä«<šØ¼ŽÍN%µ{}†ÙÇl®È1¶Ñ]\«æÐA¹L¸C@¨»1E’lárºkp}˜H’Zztýcí“`Ôÿ ô ÑèØ©c”Ïxhô¶ tQ„ß~d©znã=0t ™;à²>ÁC·ÂW”gƒ<¤ |Å„jù£P? œÃdT¢Y&'p{ŸTúmKƒnÖ¬ ¸(ð%7°¼¹73%ÈPè˜nð!‰G®«ÚÎ|¬ž¾& ™bÓ\ÜMØy¥•$Ô׮ב²6,»|q&uV( ÉÎèNêP{qß|\p-òlHêÕÄG^q3,±3y]]1öxýiˆ+þ¾uÌÙCAïŽoòa*RªæˆOª‹'–â~DЯ¦¨¤MHtV”÷Ô­¾}gayZ, m­p&…ž¡ùì"†0¸ûRL(¸Ò:0Ã)ƒµŠ$|že7ßX µq/†‚k„”ÀeðˆǃƊ¹˜'ÿñ\Óò0‰¶%áêþà¾&«Ê؆Ý4«E | À¬«E¨ mîæ5dd}™'ˆ©Y¡bM ò_ê/ÍýË΋ü¡zŶÌ V‘$Qµˆvé)Ë(Ó#Ê2ç¹ßÕP J î,Ôã¿{‹»I÷nqÒi™]U,[…’!˜t“Ä[ÊJj$Ž °ð" ƒ¬o×Ôa—xÆ.nwìT\y&L?°–m[Hjz”ÁþmÌýIÎg>ô#'r aÍÚ#íU™×’FLŠ6!œ)åF¨{ iÜÁ L¥‹%úàúÇ/ÌUû›`E#ýà£Ewä-¼¦Š1ù,“ÓHC[ÒqÿKz?çé‚)¢bh!EÛÍ“Ãß‚$—S?¼²`iøì(t­/Joà”‡`ü^∃ïþ02Ynòåá­JŒëgúØ›%i'ð¥Í£uèþDíd—6I˜óšÖ`?9Ë~ÎÓwK±f€#Ùe–¡fÝPC4J‹wq@û}T9¬B™¾ ÆJ@GÞÜj²6 ~a¤¼ô$…9“—ÊýþoYî°-Ú¬ä:ë°Ü‡q6‰ G%Œ+²"ý0Š‚I¸ÀJHŽT°>’raÁ¯Z?(Ð$q%}nèb’?„]ò¯šæŽgP~¬d6RGÔi>,³®¶«2ŸÈÊÐ2'ÕHÊœžoD'oû§<ê¯e™Ý©Ù¶JS2éuM½°"PSD‹¾]ÄÇvÌ Ûc6”1 Ô.ñiêŠ~»á Å‹ é9].n Ne²Ã ,¦ÌÍ[à!àH$edÓAj¾ZŸ¿a«·9ºµ8cpI s]F)½AzyÝ•™$NÓ<¥˜]üQÆ [0麗©HÌkYÆ¿$:Ñ6¨|À¼Mlð³?ùù‹4†(jsN…;¥¹ï TòYí.vRg«ù}m5EžÀ5Ðršº™dßM§gÒ$ì6¥[£{‡Î‡é<ÜY„m|9¾|]UÄÕ„yÚÆ4>²¾ÉlqŸéõœò„²ó …®žO“¼žéÏ­œ—ç—`®ÎZ!àŸ£ÏhÌÄûÛ÷ó“IËK‹®rfk0 Û‚y@RñcðYÛTy’zx:QF²¨g”ü+°êî?eÝ8‹´¯·¸޼¿,ÆàˆcKÐà‚gÑPF3K¾Çòƹ šÅ#$yA´“ 5»üyü)Þ¶å;ö*O<‘OƒÞܹ\챪°ô^+„v&d‰êñ/^©ÆFYæ]À ;M³ÌF¦ÞDa¬¬°¿ u[)s•³Åƒr½j0;…ª \K4H!ìR_ÑÕö€ülnw^ñcàªò –;ëܬ—ˆ¢p¼u1?·”Ósð ——wÈNUHðîy8òo펗ÏÀúVz}>Òï¾ïû&à%ym“9ºk¥Œ¶ê"c•¡}r)?Mv:ŒH*”s¾Z\ƒ¼j狦њäs&DÚ²³{õ±sÜÂ%z:K²Ó!hcÞi‹Ö *7“»Þ׈rßÞtÞZ³ð1ø åú=¯cauÀ4&Qå|«Øe¸êSE”ÈÈR~çx©5G/úD(~Òb8œ~ç¡: „22ëLäfZ†Ê¬0¯L…Fö'—ç™OÂݡؗ†GAà$ĸ‰Ûß=0ÿgÍuÀu¯ñ¿ìÂìñ(d mžãá$„/öx3¢â74—L¿'Ê“ujþHåLß(2)ÁÄ™ö¦ÁNýhò¶2^YÞM¶?·×¦Ñ‡°k ­—ÐE³»þè²L)å êšÊ´¢¯+ºU³Vèaª0¤$¸05 xfÙQŽáqñ\p¡\öhòÓÖ™‚ûb>ó€ýĦ¥kãÏlbfWJ„N ä¿)-â4ý–0N:B£›I'ÆÒøV©B ìZŽzYù¡xLêZ¤}–Œ“æ±Á™Vÿ5¤š›þu» Ç ×tF“M;0E=­{Œ4ʺ²E05ƒ/óYì·èÉŸ#E¶ÞÏ'(n%k“o ïN“pGT›Ç@%™S-l4Éê:g#mŒQÙo'ŸŠÿÃzÓºE,äû[®@Ðy¥Þd!oÎÂ{‘Eô›!uþûï»ö¯ò'Œœ³IyÌÅ1í–UãfÀmÞZ«ùJzéqÒi[=Õµ(33qg˜®º¨Åðm“dè^ŠWб±E¬o¾hÿ>ø¼3O ¹nF„_µÄ¸`æonm$h•Ùã,›¡c‰‘aMŠöï.Ü!:…h+É•‡"g­6eø•Š,uª*—² Iè¨øCâèé_æb'ì{ýžB1 €Ÿ=« *‚JŸq“žùî/2‘¥™QR¤zûÏO‘Qì÷ŸÛÖÔŒAq“÷Ç\^¾¤é\à¤Y_µÜÞʾF^èê¾Õø¡áw nå®ì½uh³?R ^oX=NÙ¾yÎFÊ©w»@Q3ï‹|/ n‰||/c>uð»b,dæ•ÁÞ=ù›ÛðãCQÔØ'FÌÁý÷±-^nT"Á‡N¼‹Åì34Ú©¥‚Ú#KÃAW¯M [ÄøPëF}–‰‰ÕÀP•É5q•¤û–I›£i/c‰­&E¬Ø)ÿÔSóßaOîo4ñAáX[Á+ªEBÒw­ 7&Í^¸/'Úvt‘Z¾Á 2Î&YUÒ(Òý}à»å*¨·åõnd]¾Ha3ØÈ‡+t"¬X=QÓS$spe®7Ô:µêÕ»îýò˜?å¹fý)÷Ãö?9×íîüÉV5wdAc;#ã¦_|P_ŒÃZ֦נ†¦²“›Lb@FÀÔ¬­ÔÅj"À+N ~Ú~õÛ#  _@Ê'0)üDðÙ ÆÆ - í`M…ÕäxbAY}©ˆŽŽþ¡PUœÈǧ äE-º£&?ïî,g :yÍLƒ>c*®1­ðˆ@QVWc£`,–€v¥Üe€äúde(áâ×ÔÍÿÛªV„¸©(P˜ÒtöKögnñ—Xwõ™S–¤ÍÃsA·G?0ÿx9¤U±ÉóTÐ`("@Mô[kôúõûåÙ*/ÞòÛ Ç@J$"nÀûµÇS¤æh 'ZšŒ­Ò‘bx1“Ù­¸vÞ²LíXÂÿT^í@«”=Í£»ª°È-ôæIã^`²`cuÅÿip@¶FÓ\4Ë ã•ª†æO,Ñ¡÷wOêÞ6ãÙïo¶rQûhæ}qh lJÙš  1„?àŠ‚r›A±Õv7FÒa\Î|󾇞U¹•ž?òáö=éw²«þ[#Y ½)t›úG¤iÔùÆ–ÿ`ëê[ýï2âcÞŒ½kKÑÕBÖ'ÿð]nâG'd9Â}Ì‚ñ[]æÕ÷3Þ·É-€^B‡)iˆÙo]²ŽÈŠ¡z3L—G’á¼é¡é‹S²Á—´NÍÚ€â^ˆþÅ¢¾ÁÍv‹éç·êñ†4…Kº p2(f’ƒo°þdi©½2/ùC¥Rêx«Shv¯ÈÞýü°¬"‹”ÜtjÀœ»sêq×!¹‰Èþ|ž°è¿ dþUB#·ZzljLöjò¸}’ÍPˆÃ"àû[ý_3ÄèRKÌMý¥bž»5Á£’ æ±Cµùë«]ñzTg~k¬w”Õ$B;°(ˆ™Gk›†ãDDu´?­[_Üýcª~5Ùó=Žl– +m&vnDðÊ] Œ…­0mæ::í¦ÆdŽœBÐ «L M·v÷|ik“átòY`¸/÷¬EèwW8Æyû/-èyn¨èá6déuÊó;«Á‘iôØÀûµ ;'ÛìR&i;ɨ±8žµªËt…$c±ùc+Îlƒ<3b‘ (>}ØPbÙjVr…“Ý€Ìd•_,‡Ð“¤SŒƒ Љ\aÅêƒnë¼p²óšÞ|3]—MB™nq«é I»C´ïåQÎE9×zHÊZýñm4ë¦Ú– ¾åˆÒá¶…ÂÔÀHjÑÉ÷â\‚©Vf¦¦°çCX&mu¢z¿ÊŽWüyô@̱¼5QJ(jÜäöíï1ƒš8Äk³Ü´þJÂã•Ædd 帅º”ÓŠƒ»:,“ü-ú¢Ëf¹ÖЇÒüDŠ®°[“ïAgü7ߣƆH]+ñÛr·-Á>Rôàž’þù*W&©Rûj§m4Þ »6 ”ŠH—¸œ<ë6&Õr±'Q!w»#Ðøñ¡â¿cDj·®Á’G)ÚÇÀAḞf”}EÕ,<àÒz[u?C;®ÂÏ˜ÅØi/ [í­X€®@vüµŠ=Ý7a¦Â÷Â;Z࿳,à¶Ä¾G·^ÌLj<”ØGú'|<`"|ábÙKxÌë5þP •V&Ü_É…zÎeaoÑJõâ–«"q¹Ã;OìÚšôü¬±t¸`ÒŒˆxãÀõ¸àòs]ÀAõ)àŽšÌT²èÆ”b»sƒr¿«r 2üÁÉèV³¬YCëÔžïEµÖ+m ™Q7äsñvØ^…¤Ã(j+Í»|Ä9YÅÓ|“ä UÎÂÎ :o3èêÈ{+ÞO«±:—o?fѼƒ1ËêÜÁeËcA¤Ÿö/w\Çb`Òäá#2+ó3÷!£Lœm¬›Ì…‘§h­C)œ¡ä5NŸÃnÝËj0•{âñò2–âaB"ÝW[d ¨Ý-)nÐîÏŸvz3ìÄ'(ˆö;檤]Þ…›^íw ˆèn¡ØŽÉÔO3¾ñÈÅheFà¨5JD­YA—&FÜ6½ˆ¸yÆý€‡ãk–.T­rŸ•PÍ¡[ØìKgR‚Pií1Ó!ºn tÛ¿Ñ…žQÒ¹¶ÇjøÕ%÷¹ ÷¶Mޏöæ7µ‚Þ¨ÁÁD²~&ç›8O>¿É9!رbj¡êùqHÍWBX¼i¥Ï%Tð÷—…4ºÇ|e(x…³ê©­Cm¨’ hÒ±€5Kë°>Tuïòõš—¾`hêàBSH³Â¶®ô$Zšæ2(o¿nå«:\°Ý1_‹ú¦ ]Ù%™KzI)~i(Hv‡ÿoãF!ÝþªÂ5©ÔkÆÀL´±6Ë%¦Xµº ‡™<&Ê4IˆÇD Ýùú¼6åîS¿vt ´7ühЈ¬¶o¸V ÈQÖª>¿yY&(}~wàÙQ’ãŽóQèý¬?l¦SÙ9´Â WõEÑà•´-  6îø¯Á‰{¬™Ë{ÞR\ sàø?ÊrüD0ñ¼á[û#☤j+³Ö«™/>-X'(øIþ;@mÎÊØ¼ý¥Û¹ôh+‘pré~¥‡@2Ö w#U¹zG?üHb[T]#Jqv£‚uC!Yªa߬‰Éì„Ú}|þ.í&‹À ¸î_ÓUwÞ±µ»"”,tàá)‡\ A•öà^0BÔΓôBƒpÎÚEéq"ÄÎx0q.^¥ì_'v í '…Ÿ“T­²Bô6X¾¹šËr Ò´òÒã#j8à¥Ä>ò„ÎñÅc§t£MaUºa^29â¯ãGå§œaßÙ¦þ5yÒú¿8Öb¹(îËÏA•ÄÉ_¤ð_í÷v†ÜøJá(­ÒÈ.†e9“[}UêP@H‡Â­Œ¶õ%Á«„éʧÚsM0&u§¯ÒžîY˜#Z¤lä`¨ú’Hb/œf¼©†@|üË"€7«¶œÒ "s¢>P²‹pE•j¼óÅUè:¥ªIÍÇ܆©¿¹¼ò ΋D²D‹Äv¬bºhå_³ƒ€qã;}•WãÏx,jïrÆnιní,†¹^ÛâuªRsíçñz9ÇE c½Èe`O•“e%܆ú“, ŽýÞ¦aZ.q“a®·Ýæ\ųï¡þ~è\­º#!ž¨7g‚æÇÚ9¿®ÇÙ"Ù†ÔK—<®êûŠ‹÷=1•´n$ý±§WÔ‰ÈÉ™Ø*¶»WfÜü!†]©¤eVP­ìÜÝvéØö”9Ô/ýó¼‡`¯xU7ÒÔÿ4Ãf?•ª+ˆ˜wHå1"-äšœÜè²î…Ù—±üºß’v© £#æÿÒ*v›Ÿ`®²/R¢ôçʵù埣e?Ž¡Hßj‚¥»ÖU ŽÀñyÚ‚§µó¾VÚîø÷Ü¥°aÄš­±óÀ&= NìÔ1I|Ù ‰ e^âÚ÷ ¢¤:=ªïJ€»©šˆ*§ÇÜľío ÊS”j@zj:í È•<˜¾m˜ÕXÜÍZu!–Œ%×i=ʧ³Ï8ßõbûÅ·ë¸×àÅ‚aÌCS¶àËí“o4?hY¦›ë›(Ï*=[‹í¸pZ£K ¯O\‹È0tÉ›ˆ9%-±!8Ù¦†Má /œk¹¨¯7kUÚò”C CßQ.Gÿ…¨¸|a(à6ؘƒÔXM¥§XD}ô5!½u¬¢šœÊ˜e@˜¹¥‡$ÏcQä¼ö1ºOxÓZ÷r%ŸŒëƸõOŒ²‘Íwýz(Q!–o›<5||ÜpXkv=ûAðmã›fT¿•ˆ¸(P=¾ŽáW5KDX“6¢ìyHX;&ó1pâqDzSÆí¶†´¶EàeEœÞþ/!íKbIr7&ûëlã+ùl¢r3Ÿ„ 3Ái‡™ŸÏ/S£Ž®èƒðýÖO‹NàÌŠùÇ›S y”²OZŽ÷çNÖhÿFu¶O›‰B}›)*ñàSqÜÓü†ûÈ̓K¢²€ ¾^3wehÃ_‰øðSy£ i(hâpÀz'+€–n“q -Í>±#©ƒ­“™>3X ¡•$ìDdÐëϲ¼ñMÓƒJ3t=`™#ª³^íë³+ùcx„Ô)Ê #LÙZ2Ð1$mí'I3#D ßÛ^£k…–ÄÅøVç¶Íd­PgÍœ)êùÃ’“*ÙWa‹Á W÷[lòz•­ŒÂ:&Xk¨@;jú­MDsÿËjT'{þlÕM ÌG#]½ø‹±*]^l‡×Î-rcÀhçdE&z^+§EÕØ´DTA‰Ã™ü1­í¨¯±¶Ûî Gäµ1ÔHªt\áwô%Ù0“çðªw/8ŸG c*ÈpÊù0/…Í”þ=Á•îùNÂËí±M‡i÷1Ǹˆv%×ÅV U×r8l\ʼìÔú{ÖÆÍ&x¿¿µrwÜ=…cýñ¾ã7ݘƒE>žÄq[ag–ô—= (ª‚qE›«?ß_@¯¸fo¤«;¢qiŠ¢Cy]ÈLWãI¤âšƒÜxÒú¨BGJH©ÎÓB¬¯œ)0L9®¾ ÷!¥ö²Û¶ˆ›mÃýØý„Wi#lh÷Ù¼lI»$!Á‹r½t+óûŸÈPé)Z1RÁ·: t—rÄà«dÌ|loVûÏ?Ê{È*| æêÈ»±(Šõ§//‚õLTrÜŒ)¶Š#ÇÙT5ª6rxwJ®ã8ÛMŒC!Á™H*”¯ Çµ> ÉÍ5}Z‡Ï£hQÈÅΦ†<¦pýBª‘n ª>»‘w@“:¾ä…½éIÐ]Ñ—?fêÔ #Ä”Ð0Â=µÒ@üØ‹ƒW4D'³g¾Q .fN‚Iøç¯˜ð•Ô•žZ›s…F[lsÙÅn‰U÷•Dú®Ïj³ ¹)ùuµ2,ScÖ“tPAÎõåU%'VDrÒ_»€G–Á—îφ/æy'r9÷WEE̵4HåT7%\BvZÇ­¿zÔg–G ú_û'C:hõ“¯oƉ`ê'?|¨ùÍèH©… i¢Í[jÙºæ=4k¦R×èT‡qü×`8ÍŒ…§ÛMÛ7ƒ¢Q½m”2—ïvä{‚ƶ §ÇQ`6à @÷ñbõæSU$4¢ôjœ‹lQ³:•ùØ¿§‡b|~H" 1e@.0¹ÿd€h>Ýj]Üñl NnHv±_s°¹™Ê=µòšéfýY¬«rjV^]úÔAP”¿ùdˆLÁ¦>’k•D÷WR¸ ‘Ú\Ntûůð¹\f8U:åÕþ‚’÷\è¾}ã;l¥-™nSBd]ä”7úG#ÀU.> ÐŒYšµàçAµ‚ I9~J)­jsÍ[+XG{Sм~M øãµ,ÕÄ*y.AÊ‘ *aP™}_iJhЖû¶=íKñ']¯]‘c€ÔËC·&0j¼GÎ^wš¿˜Æ50-zX’<¥õ×⯦P-éHkÔÀJìîè%ú?ÐÃÏ©ûiVMHÎ<¤êx#t£hmoWVTyÖÌÃŽg‚t—‚í”úê`Z'‡Þ‡?ÛœM£Ò¤ñùŽ¿­!ä¹i§;ý þ«âžì¬"¶z"ž(HÏŽ>S0æóì…—ø–ú,Ì˜Š¦õ¿Ð©˜‘/O >eøÚ+CÆ«7ꈠ®+[“XL"y¥6$u>Œe³ #ŠN}ƒ óÒX‰œî ž!µÒ»n¿Ë憿€e¢l«3ê5ŸìÞâÉéì±Â3­;²ÂçªC2¼*¿¤ÀÞœóÛðÏ3MñP‰Ä“¶ßÿ|µ°œu$dÈÙtÎá~ [j­`çg™ëXï›#XlÅûT3MGò2zͽL°2pnµx7× pÉÁ#íÀüš‚k’þRök¥ê^¬ªZöuÕ‹ÄŽ‹k æÒB4±?ãKbƼuHVæVPð)0½,ÝÈ÷éÑ÷ˆªø%GêåüKºÿƒ§á´›Ö‹zæTYˆ¸—ÖÈŽ\+ŽVº›‚+ÙBòÔpõ:ÙYtvÁa|æ„,©L•t¼¦D*)Ü“s—êëÏH‹Ÿ¹{H)‚óÛ¥ŽÑ6¥0ôœÊÈ1‹!n@Õ–hl‚E¿c^Öçݹh[Ô€A«]ƒk¹ùÂn§ZhOy„xR;—2MwêhÕŒÄÀB~Bè¯x¬§|KBŽÍ´:#ƒ!¹¿ E\O†Rã³MLL <ÐF  u²ƒÉ V™o`Ñ1èÍ ô¡"lúÞÛ°q‹÷±+öR·6ïÚ[¢Õ©Fü!ÿú¦ùÃ8ŽD«ÖüSQJµë£ÔÒDfPÖH Üþ+³å·rµøSdC,t+Ci-æh…,|œótî2Qò·É †±Ÿ2¹¸ÝiÙŠÀ5 ‘Tò㆜éÕ­,Sf}M%*·놜«¿/Rc’ØðEþ0•œDªè¹î{D‰k©–•ºa&á™bx#bÂb §›Ÿ“p²Ž,¾ ’ìªew"ƒNÁÀ-Uö8¢þ:W¯jvÚs÷P|I :¿^;ÛÍ€ÃØJЇŒ&v­²b\zÿdÊŸÞD`ÜZ– ÛWF0P§ç6½NÈøƒe“µ\o-ÅÙ©Ås¬Ç£1é/QžCt¢.ðÓm]£¯œºñæòŠW—ìØ-¿MÃÆ}N¯Ó‰“ƒ˜hÉ•{’q¢ i¯ðfĘH‹W‡ûèF“ò¾uòSÈë±y;©›XýŪýI6ÒÏÓ?h•ƒ"yÉO~ø[éÊ)”9¡à~†ÿœ'è'Êwïøº,Q Ș“¼/Û_=¡´¦B£¯€ç?Žå×£)nZ܇ݭQÛÚU%ˆ©ýÆZû¸¥éZ1·¾‹H÷× #qédÑß*à¸Ê]ZI1F÷ÌthD ;y›,A )ºùÝœL€ïAVè0ùZþ«ÅÐ/Š2ZðT‘¸!ÞW»‘”6z¹í.¾Fÿü“º»Ç”0 3©ü_í:õ·cÓÿ¨íñ€sìCb¤ä8×ÏŠ1îÙUëÄhqâhÎWvŽ …oÛŠ§Õ׸ôH¢‡¨gJr(Ò)*þ}8òt»,ÅÀ¯4Øøoª‰qý­’ ¼×Ô¿uµæ‡Í‘cg“óK_³·»\SKÈÞþàI¦Â|cô¥\´@“²u0ÑóI¨£7ÿBóL5á.Ĉ±új–m¦Æ+D{þ–cFês5—§a]\,P}÷:l;ZâRÍš‰´£ƒü‘VËî È8=¿7V»Ï%O]¦2Xc'\ÈÛ«~|‚l;Óñ¶=¶n¶ý˜èýu‹ìøÿ‚ÿ endstream endobj 105 0 obj << /Length1 725 /Length2 24665 /Length3 0 /Length 25228 /Filter /FlateDecode >> stream xÚlºcp¦ÝÖ-;é°;è$wlÛ¶m玭Žm۶ѱmÛ¶m}ÏÞûì÷Ô{ê«ëÏÄXµÆs®ª«V-Q['e7;  -='@ITY™‘ž@OËGB"ä4p2·µ6prÔ€Æ% €ð„Ž dkçæ`njæ 7¢øw je`lnmîPµµ²u172p»¸¸ð»8:Ó:8óÒþ³H 8™&æV@€œ¼†„¬€\LV ´:Xä ­ÌÒæF@G ÀÄÖ`õ`dkclþ/NŽ´ÿ&`ãtpú‡˜‰ƒ­5@FDY@TNV "D§,0°1H‹ÿ³ÜÆÉ‘ó4ÐÈÉé_ÕQœþDz2øËð¬ÿÉ:¸þÇ¢…c`›9 ¦æ6ptÿÒMÂÆÄÀúŸ°±³ÝSÿrü‡€ü )Æ@“ÐÎVV²Ö@¹­µ³Ð ck t°üKû?æÿDþ 5°6·rûÿÿ„„“Á?bؘþ#ýB探æ®@cys§ôvrpþ'¬üOod€ÆæÎÖÿYüG“ºjlkcåövü§”ïG§ /«*¦Jõ?Cðï´ˆ‘­±¹)@Éé= Œÿ'ðï´¼ù&è¿\þ;Q†ÿëË89˜»´èiÿ5"ôÿúþkéü_”  ­« #=#€†‰•ÀÀÄÌ`gäðú_tœ€6NÿýŸZþëÿ{˜€@W Üê’­W EJSp™·HÁL9$ÕÌ”¾ Õèòd×µŠù€™±ÞÁ%ö2vîÜi?Cž‹m‰»FBƒ ÂÑøD$A¨ÎöKQ¹©wõæ›BÞk]¨î„*–µ‘,ÄuØ­SÚÚª¿<åsFöYµ¤} ŠC¤~i[/$òVìÊüƒ…jºæpª yÆ,(ÿÊïew,$7`ášKÏ,¿ÌÏî D3wïÁ  å¸ãæ7SàK¬ó_-RÈDj8ꋲ’F×y¼Š­ãÖ ÎŠÒÈ™—C£jª.V?á?~– Óé’èqÁ™^iDS+ìò R Në¬W2jïÿnl›à$÷Žj'H¶Šš‘ÍTÒ1ãD䆷Pêà‘´OIœ ÙY3fß>9_ g½ÐÃ2pªL›}ÿÎX[› MU¶–¸ )»ØÉ£ddø€sEp.fôzö·RêNÕ¸ˆˆ$özH‡gO¯CíÖ…57ÓåÝ=ÙÃj·;ýášØqõ¡‘lé42mÿ^:g>Ÿ0™84¹{î¤0uÓ/Dù²¬€4¶Ž ºùxÁ•šÅúØ ‡+ù Ü4ÅMܼ·y ! x–·ãÑ$E/GŒù¡¾Ü&iݶÐYyVÆÒp¢¼ô5Vò2„ùsѳ‹£Œ³5šDÞeXì©CÉSfí^; âWÙxy" ¶ƒYˆã@T¼`,sQ*Çȸ‚ ÿ¥&ûRöÊZÝzÇD\e&D‰œŒ??`›bÙ²W0[iàæò oÂd–ÜC» ñG¨žG1Œ×WÙ‰l¤´0¿f1ÉÂ;š¹)xê­^´Äæ o 0ýIsROîQoøÌ¥{97ð…Kí¾C´…ÃOÒÌ"l ÷îrØ—(–›£Ú6g,×»QºÌ’]íw{ýàbª6ÔX w}˜'è_Ž™”‰eS Æ^_yýÞ§Xï±bzš§0ï‹öN®—9øáj„þ¯Ièa´‚‰½wäs®…’l`2>bÿÕ[¥#¢†=ÀÚ'¶æ¬¹kÖj 7ùBîªÑ¿{¶ÔÁ=ì°¦Gߺý¼Ó] 4ôU¾T7Óš"Q†®ÇÝ­dŸïöùËø›ú¦jØÖC Ìo}§·Ã%}­æ4Ôø¼î ±Ç´p¥…†ZWûÀâ•-vM#.ðÁOHþáç«õØmy»’œ5ëÁ&ÚÔîï3>Ê^²;V¬Ì拼õ9(*^ù)‰+nòšsè—m@H ¢Ï(D?[fŒáb¾Ÿ‰¹þ,m}fj¦Í~Ë­w¦Ò·°âÂ;˜ µBÁÇý÷w‹ åV—èÏ¢ÊdðN†øqHîüÎ~•’ò¬=Y é}híîÔ |?‰(_»I2Ä|*Û¿Ù”¶@1¨2‹‘ÎLŸl²zmz9ñ1§ÚqKø—üúÃUM[­ÊåŽiTþ>æU¬áç6C>Þ)¥ã¤öõÍú¢¹àô“L†ÜŸ^ uˆ‹l,8ÉÞT”vžŒ}öf@Éz²—=еõ'²+%§ªg3©dC³jôŠÐÁqñ^ =÷¥Xsª®G#¾3±õ^õÀ]¦­ˆ^€FlÈ–S²ÝKxGå½4´éÈݸ®7×QÃu‰lœeõ¹¦ît+ÙnÚ»/ b{èŠ<§\˜Ÿ›§­´êŠaÏ­OýNÆšZ㸻m½2o[ƒ¢îÖ D}#îl{éÀÄU>Vù[SRÕƒ a¬ÊðUue'Ây¢¦¢„Áê\lŸ•fèßaÁHâÙAàSuÑÅ]*L‰AÈQ]A=ˆcÿØ€ç4,)Ké„,ñz}ÊHø»šâbk¼ ³G×íEíÇ)•µ¾Òd£‰V@6˜íºÉo‘ŽÜ´ÈRy|ûÙE·Êå«Líçí|Uß;†â'Äùñª¿§_ Q+óõ¨`k Õó-â{ŒìV˜ÇŠ¿FÅ ª÷ÝHs2É£™ÇÌcÌéÂø(¿6,™Yšx¾äLÈ픨sÆ\Î4v¬ª‰ë¿ùìÞðß[ô6 ¼ž·è]{íj.Jnÿè ¨Ï6Få ÐÚÎz(óX U‚D·¼WG H7Ññ‰ôCÚUlS•Rߤ‰:t5Ð$”65_Cä‚gM˽õ°é±œð!R¢¦y`Œ€ü…ÍD"õ4,^nZM8a†qi÷î„QíT6UñÇ·6uŸS /ÜÖ-àÞþ1ŽáZ;§Ëø‡­Ì“¢çûø¾7܈O¾/­§ÿy4®º‰ {æeô¿iOÖl8±´à¢™¸Îó½këÿUíÁJ¼MOúi5Çñsêp'YE§LÄü_AŸØõâJ|ùDa±EóQ}Ê,E0,AŸ‡ÕÈV‹j w¬ºä' ©œ>±y”¿“W¬´°t‡^nø=a±et–Ýüü—~+A£«²Ùñ÷ÃAÔo{ÿ©s=Ft¹=$Ñ2}D•óÑeðõÙ“¯h1æÊ“5°õs?!|ôž†¾Od« ﬖYqØœËÆ÷ 7ñ†Aá<š0M,Çç~G#;ÌÛ» ”W%1h´¶»K^ð\ïÏÉaø¤qŠ1ô[q&™é{ L“xüaú貉ßg ŸÓgÝ2Iã#|-‹©Òïl§¶\úð.Þð¼¼`–rK‰eoMêš§¦=¾pcå5‡™‹û ï`A"Éft_G cŸUÚÞÞ=ÖP8]tµõ£ö½Û‹Zç8y"ÿNÊž˜ûbw°ZÖÛ™äˆ}‹Ðct`ùøxºñØ6ÈÏéa¯BmB!|1¯ê}¹ZÎìŠðÀ|J3}®#:~ŽÈRGÙ.ÑîÕÆæ;£½"Í&8܉ÒUIý’UK3A_$cžÌelÆ´²ÿd³a°Ç’T9ñs%Ó¡?O•]ÐTP ¼RÎf{süb>ïôÍÓïºé¼3 S“•ÊLu”Ï•ÏaË37Áƒzg* ¦Ôì×%kc›‰0JÒU»Úr^Æ»€P ö‡±‰>µ—B,FØ ƒÿÍÜ‘+s(ˆ ³t‡:¦y~yí$Ö³ÐQ„fƒÛ'›3`ÿžåe?ŠN3þæëµÐ‰fII× uì¦KŸÑÚçº êkãžåöpð¶áSŒ§sr«Í{£§Á1P{Ìp£ƒo9»˜še2+sZÖñ y‰Ã]•E”¡Bk>‡Å0GïóN=4óét‚œN‹Œ?N-´g\Ú™\Ž‹•ôç õ=Fìõy£¿jKÆP ‡å…+­°áA©=•Çff·h`W(‰g%¾@}ŽøbâáÇ8"g€çoˆÕB"ÍÞïzûŽŒ´’xÌ_èxWÁ0ÆN#/3¬xõ™è{ÆE¿ìJ„\¬ORÿDˆàÇæçØsk!•üŠ[ä0¤bx„F„ÿ Õõ×ugþCÕ˜_%¹vL^q\$šÊAhÌ7}DtW*O2ÖÄœË9G¶%ž~vBTØ®¶Í’̱¿y…cÑé#W‰(!®Ó,v`ûÕâñ—³!GÅ'2<Ηe´ùÓwù‚ÈÁßåYôOxUnJ†á@’ìK¦ê‡ù%Æí¤žW{ z`Ð-”Ç8”óùvG$m;¥­Ç¶+"DmqzõòSBcì›\Î_õšœomÔÉtGD½KÄÓ´w°Ý`á½x£ÛYpFõHÍ⡵ƉÈîxQdÔr£¯ÄAW0:ÅõkûÒ¸ZC'SýÕ‘är¬äç"P—¨%„¼ópA6r Ru÷ñ¹ÌÅ  Á¬aàßÿ´åZé“Ý(-lÝÎQâ¬Á("ȉ̓Íy•.ÛÍ~1UŒÑù×ðY« Õ "él˜ t¼?«~"3Lú3t|ÏþÜmÔöKRW+ž¶Î®´6ØfoÝœòtÛ›eÉg*°z<¤–3·†[F£7{‘/ÜÑU«^·ñ¹O\¦5Ôj¤U/l3FÅ Â$X›.ƒ%NÓå݉wÞºŸ†VÓú(¼§CÙ8˘Z¨÷Q{½$r>­û}êrÝ–šŠhÖCØû«6 Í Õ6ÜÎÑd¬a¿ÃËѪԑïô¥±¬-<.k‹Dœ²MŒà°é8CëÅ=*²þ8a¤0¤ÄÌÖ7z–tÏÀtÁ!(Q¡1Xúýñ)MúÙÀ5Ù5‰Ý_e^| e¦ÄÎ!çî–œ UòÅþ™pF„? Ã!¤Üh2ñÑÄ0©2XôwüFpÍ©Æ"yI"Üd8ßÛ¢Íïš‹ìïÛúô D¿4kFÁ‚š ÏyÍ=oHä`à!ë ¼³ðˆ¿»¾_|¢O¡ÒÌ ©X›/Ëa •‰ø_c$ ¨àfí‰U|sØÛæw‡X(¥öWT5s•ôO–cßu=Û¸($G2mVât†{&®OœW% ’«týz»íV^ë v…þsï”{4åß\ ô3Ú]OŒ?›í ¿ýÆÙÃ1>šYgzu('£iÇWk'¢$Å-aWž­îg9ñßuŽÓ<žab‡ ¨žõ£VÎHì'£÷ú… VñîøM­J,W€¹fÌÆmÙÙâ_¾ÅNõ@7=ç ¨,åeF²Šx ¬”†^g±Ý¤fDjóüX=èÊOW‚eÐŽ^”‚š—;ª¶IbÁ*áÏ´ÇÔ4MD}‹HRLñ8NÜÚ mðs1Ðã ”ÂEjD©6¯¬]ö˜Ó,ÔRì ÿ/\°àû]{U“и¾Gá¾1]ש ´ús 9¤¬$uæ‘èT¹Ènäb²]''4ª.šº Be5ê4ÊpcöòJGb MA,†ê¿µµ*l xÉ_É=:¥‰FŠ^oÝç÷ë/ÿƒ%DQdÌÝ€WÆçi”Ù>oÐtõzßÃ)DïÉ£[QJM+&.èL…0ŸZÇì&ʛڄ:éÕùŸ¹/aòýPÂ,G’­ÆJZ}\šÀ(ÚžþÇ=„Pèð®Â ÞìAÚ ©ü½·í© ¿”—nª#Q€êm pò®·mò4ñYK\¥FÌT& –#yU{‹-ó­ùg ñ;ÛÉ3ŒfºÆŒÀÛÁµ Qn{¥k{n>傪šKdí÷=³¢™U­À‘*ôS+Ƕ¬=?O×EñTuÍw’7ºX+–þ<êzWfŠ£–+Íü£ù¥ ¯‘82Z]=¿c)lˆ˜ròç'/¨m >È1H³Tv ¬9dˆøÑn/ÏÜWåᨨ›7‡Úd`žâ‹«Záö(;¥:a'ï_»õï˜à)ÐdÚ4ó MbkŠ}:peLì7ƒ E|%‰Ä4÷šëkƳ^Js®0 Ç|ÂWKR'ÐZø•¥DñeË)ÏQlSu—²h:[®µÉo‘X[Ð:»v§K9ý~¼÷I‰]j¬ÓpI‚£Èh.\`Ò+¾¨£?Ëò‡èݨÚ(žÄ–r7}´ÀÊS ¯Úfý±v¹ùÕŽ\šô‰ËFç&ŒT_‡ž¼â[ñÌMµÝKÄ&¿¶ô@6T’NS÷1!Xê '‹Àææ$±G>D.RËóujZdºá)ùs6A ]Ñ^ʤ!¾?ðeBI£«î^Ên9†Ã&M„t8>3`• Gµ §a­°®¯•Ž9ßåP:éþv«>÷q³µ\EKóÎ'þ: (O¸7+µEùûdŠ£!ĪÛL¼Zp ª|¶Ù…P 3¿væÓV%©;J“RbsŒ³BÐzy1Y¾+²@åÉþ F<¹ÑŸÊ¦:…¨V‘YjÄe`m•wáº=Îê(߃œ§ƒ®ù†#®ƒÀ§yfì¬ÇVçL4Nîoà¿öǾðŽ(óª4aM:¥xY¬{ZøþU>qVèÒ©Âû†õX}¡tjy2èe9ßÂZú|ܯ'ß³×o…È|·åµ ÇÚTƒGxW ŽycV|7Ýò›º´þÔžé°[Œîì+ F9I§)3ßîÕ¶‘kî ƒï¬Oç]_ñ¡xCíÇD÷²R'üé§ìL3aÎ9N€#6z~»;¨éšÑЇ"ý•‹×~ƒ5§å±Î?iŠºònA ÿBW𔨠Nê X‘tXËg}'ÚµH~;[jbŸ7Ï<Á'×ßÒéå„t^X|Kš|<à‚ Ÿ¨ÌNpà)ŒÁ^ŽéÎO^˜‹@WM™ í%.$c5˜…1c—u¨f©Ù‚£ÿ?9oÜ1šáƒ²à¥^1É&ì {µa–bdUDì<ÌN5¦ xŽ0QH\T8Y=K‡9Ë!>Ø??d¶þ¹Ú“Ao/ö\O-|¨Øƒy.ìV.ú«KŒC,’pi1»våE” Ѹ`<=K}Š›ä²=· ãaæ'¢i³þ#Á=+ËëBýäe»(Þ †è]öb¥q„3ˆ˜°fU£“`š _ðs…¡”‘ög»-‰RÙwiüY:%n/\%±¦¬'‰)a}œêuÔ×A‘k)æƒ %Õ«[÷ÐÎ"»‹é;3û– ”ª}!ÛT×øMô4â;TVÂÞˆ ÁX–õ9>9Áq-¥[*£§™´ž±œ;"±0‡–@Ó?z€ w+Ì™'.ÖÞô÷;-÷hTëäØZû×=`¬›iD„»®Ü`Þ€}SC,O”K¸Ñ €Q‚Bn Ù—8‘5®÷rÁK;SÆ™ð\h©"Ì»•…ŠcþÇÕ§‹W:ÍÜ;¦%is¥×ºÝò^_ÁñÐÍ„}&ª÷±A;úƒ_¶}/[|¦ÿ¼ƒ{ÇPŠbg?ù^—€k´1¦©ópJ„Àt,§/\§~K$ ™­þ1£ïÚé0lùƒr»j§ö©ÜS=þŸŸnô¨ÜOìšBÿ†ŠŸh柗5ÔïúŠî!??è2„¼÷³öçvPMe¨Ü2~½;›HúNˬ7JL_@1Ë`Ý&t²*YÖK_n$\”‡¸y3ïõ\{´ 7 Õ!GS¦p¬ƒ­x½Î’yÉÌFf}«Þ‚DTþÞá÷ÒÄÏ’d¢×Hñú὆§BcºúK¶ê(¿ãò|àAv•ÞÓšÏ0rÚ…ïü(ƒè+Cpv5ú¢ùÓl¡¡8üì>=0öÉâ!³Ä ƒ' HÈÔi7‚ˆÉ2ìŒ+ذ*Ø ^$úl“ºo"v ã7Ú™òEæÙ»ì»²];X¢ëSÿî~£©è|VL¤\%0FM³•qXÀøÑóÖ›m©‘¿"|Îù¤… `께|áþ´± %>\†Çtœþ*ºÒ¢ÛþSøÆNŸHAd\@>€ ˜‘qVJŒ÷™«y—?B…$ÂVŽÆûq§z jáØ†´7æHÜÂc_í½þoüÝ 飔oÆêþI¿P‰¼MÑ‚>+šs'€vŸ:‡†/TDrÊ´¹ôpKO—ŸÆóÎÿ‡Cë8üwmó°2Æï:‚²Ìoâ-šrÆ1.÷ŠÂÃ`…3‘·ÿçÖ-ÓÓYljm- …;ˆÿ~¡g¥"'Æ\ ‡W&; Qïù&HéÖ=œ­#5j°ÑKÒ)|¬|½ö³£„r’å¬üoçrDÓžGù„+Ö‰9kQÀüã²›¢÷h‹FW2ŽÜî¨ÎX‹1?‡-7ª)ól€äW:åRØð<À\BöTLÜêX<¶ZôÄ×ç$)wœ,ò;¿_=4³õmæ–·¾BÚQ‚k ‚°ûª¹nÞ¾+dµš¡ür«Äû­ pÜ@:ŸÕ¦‡Ÿ´øä gû|Î,ϼô>öìS“¤‰ÎÞzÿck£¬‘QbaSÛ¼b耵@üNƒ‘îÉ´.BÛàAöæýàzu–{P%hÔ4–YÀ¶‘ŠSŒ·‹ Õ[$´#VÐE ñŠÉ†Œl3¹‰Sl3 j_‰p‡juóŸ¿4u²ç}Á^ÏåYãÏԈꈣ­º¼)0ܬ/­þèùý‚©5¨Êvš(`ØÒ÷]s!­¼¸(Þ+¼ÑØy-Èüyák¦t!:ö²ÔV_ß|óµšX¿¶¶Ë×—»2ë½ÎÜÙkï ±|HÁ´4dVaëfÍ~î€Äêº8Ó‹ÊýÞ`âö U!Tmy/?• xÐ…Ëça5c±’–b¼Úš¸Žˆ4¢ÈÀ¨ÑWhXÞ3FdeŒ¹lì¿‘×ãu^ /ÿž õò›#;=Îtþö­ô"ïÌa)tÎ݂ӲGòÓø³ÌNîf.â95Ó‡6hȱsÁWÿ»¹Á­ÇK¿ $?nþ’¡JÓ$ÙÃ9E&Vñ´‚üŽðÓ™Ï蘣Œ2/SX:…®ÂLÝ­ ÍŸIâÞ¹zÝ?ýñ–gat„èã4ðÚ^þÜa&[©g©à¦Ãs¡¯B3~y-dr{xL©ëìÐfÛ˜¼gJ_D\@]5“MK)"l♣ÆÅFºBqþ˜7Žû¯š^ÃêÊ8ž”={ëbšÕ‚•péæö{Ò‘œb²à(¡ŸÔeÎT'Œí¯Ä‡KDhz½šš…A›N“ ŽàÇL`ÓDé$Y5ÒF ¿îâ–BAv Wêô§'¬S9©¨,ºò ?ÅájzÅQÞt…Zº_iG€¤€*”ú!õ˃èo79þÒ' vG]ÙøÒ'®ñ³ý NòšÇ¸ƒoîÜr7Åÿ œe]ëÕ‘cËHjŒ}¶u ÂH`8ªÑ¼AV&‡´Á®Õ[V.L€4KG¡¾c£Gió24ؽ8 «Ó ŒÀ¥—nÁ»…Î0ñ ^m5äðÏ.r1¨ò•î|\OBVÞÆ 7ûdúÄ~2a1a¥pÑ¥_bü8Ê·.g®–Ìq«ð>Q[Íz «—õλ(hæ.§hUü¹‹èºÓÀ7†¥¼±]nŠ\÷Œ]įYLöìT<¼@ÁWÔ‹EÇ‹g•ýMtÚ ž£Éw²­Eh—‹S-:ÞN*ô ²¡…ÓŽz¬±;ì} ;ÏIp?X°ó 5I]޽ÅÒwÔ>Åå¸,QCõ ¡:â>þ ¦­•h‚Ý[yàŸaËr.@![X‹‹rW|¯t“Gò.¾ÿ­ªvUÛêK¡f·€,ÎR³÷`Á$#dÃÉcó›<##T3vf8m7X=çÔ¯ITì$·Q¾†u×·F‘«gr¯Òº§?gu*ø¨7Å`ßÐŒÒõx´_¬ØƒB8AfYzÒв k¸Òþ¡Íšõ&K=` Á¦"Líö÷½š»iëÝ„\ëÀ/Ùjº Œª2¬¡$–ä ­¼€°’>6нc’ê1þhŠ$Vx1¦Ú‚˜m©9i<Hº‹af¸îš#ðeÛïmš_ÃYüEâubåj€â,€!k-LBt¡úc€&JõN¬ÜVú°õlçÔ¨T‡-4ÁeÎr_>õ;ªíû~ÈêÏ:ÕÅ¢ÿOØ*U_*ž ß³c̆9r‡WDŸ…§§é}ÁÌÈôœ²6‹Ì 4–4ñ(ÃÄÔ¤%‡åe¯´ºñ-ã¾ £žÛÉT/y'Ç«"ÌØÆ_¿ˆÂ~ ïë:O£·V4ðò{2SE1W~ÜBfs}³”ZتÈn+s×®ü¨’d/™t[M.Z:æ[y÷BËL À3ûpV8‰èÜekGÔãmGË>&A¦”Õ0!‡&²CD‚mêi12&Bh;]€oÑ(ÁR:I v…Ú9ìñ ´OîD[¶"$—3JªšÅQûʇž~ƒþ¥þqà€ÕÃj᥼`>Å÷DëüQ²8Xm…Öl^Ãë#´BÝTÆÏ“ÃNÀ8þÛ-D[z¼PGçg‡ñ”uLÜg¼ûô–w–ƒv¯“„8yé„q’¥ƒóVª ÂFF£á[P ’êõ¬¤µ´zÁ${"sÀ´’çqæ¢=ýqïl>ΫA¦显Š7-Á¹ûê ᔿ KÈA‡³\† 9OÝ7À©7.•µ4Žëd­ÜÂÓÐð¡,¬[@öƒª‚q3Èä.A7´×¬û¹ÓA°rÁ.;yBAé§GóO ý/3 £?«j©bˆm ¡BæŒ4 úÉ% Ül‹fmÂ$Ùão[ú®v äžÜ!ƒØRœŠë·têöÊVpød«'b åü«JDöU&D2=ÛÌÔäoD´’§f1>ˆzÁn:Ìœ²W¯>!ƒñ)ÉŠ¼ˆ‡‘•É>.¤§ƒ3ôdãgdâV35ÈWê¿6‚ ŠôDÒº@#/[円Çü‡¤Ü;Å7|ºo³OœéçHdßèþâ­.i’Ò¯h=j1Ð;ÓŒïñ#¨×#îz‚¦Åßos–u:SeϦ~¼"G/MÅ0ŒÌL`²k¸9‰=ƒ®y«uÒÕSRÍ  +À€BV†ÐÔäþñ¯®î]ò]±iÀø}¼!ògR'²?Š1&l‰Ù !”JE¬ûF=„REÓ *X?ˆ+?kôèvÙϨ‚6°4Ô†›ü rbÉ]@ýÜâÎ>UKÝà˜ |Ü~â‘äõË5‰©{£Ú¢¾°úƒ“bêAQ£©—] €.ÍäF7Ízö4[°ô7\R¹qn@ø!õBÚU÷¦ZÚ2.O<ÂÈê_ú{:a©¯ï–-(u®ÁjŸ‹Ö8!·ìå)‰áOZÃ×Ñý–¾®2/ŸämÇÐñ‰ht¬lªFé .‹™EA¦ºmgPW^×^pJ¦ÐÍð7éÀVšCLMðlÆìM›wÚ)Cd˜\i´¨HN 0Í)FvC ší«PñÐW;Íz¦!À­V$ ¬’¥º³3güáì íˆÚÍ£¼^,HOøˆ¶ëšˆ£” Ol\[5Ôz+ÝöFD‚ðÛ˜–¿Ò¿b}*{šjšŠˆ¾N9cú¡ê{œ`†Ë©ÚÍùq¹ºØíA*°˞`Š]À@'>ZÜZûLeÝYKk~·ìϽÖVÖ݃ ª>'iT’÷öàS”=TEAx*àoÌ˹úí"8§ÓV¬îœÂyLîÞz\|g˪b¡ÏY3(-}+ß,}-ÿbÈZ¢DÝsÀu-FÃÀÌ­ñÿí‹9:üe6ü ùݳ!A'ãÍHúé¹Y ª—ÁÙEŸ/ì¾(éSèÛJ×YXý 9‰‰.ܤóuÒ„’ÎKyŒ£Ð:åb#Êvæ*&Š(ø¼íã"êàÑ…YÖE /oyàJ㙨s“¹#ÿÉ[-ây0“åR;sÂ}y¹›"ªi,r ~S«óËÌ0QV&¾GÕ•ûÉ/×l‹|›Q?qhh ùöal>EÙ­#³âŒc3VÇ‹yà ["oŠÁ[öÕzˆ$fzb±„>êçÒa»Í <Ñ\ßm”i 8ŽIý¼0mW‘üFp™4T¬áÙGï6¥|¯ä/xØ0Òˆ—îOq¸ï†’4^m§bé~âö%9Ë¿(‡ &¼DˆpéŠ }@ûtÇ«ðÒèå›{Ÿi¦d4Ö² uJ8 {O;(®ª`K_ZÉ<ÄVi«×¯åöìEXéNb,Û#Qµ6 ÇÔ -~VM8C?ªqÁ…eªJq+¡{ñRÅÁqì!꿘÷kZQù¬ON¤-TÜS¹ÙÙoþ÷Ó˜îÕ‘a›á–¨c\öE Á¿{z²Ã-Œš)êϰ,‹Zø&b<×\ÑBï»óñ3§:ÿî*MÃÛxÙQ²E‚s1$>Ó±dB'Õ°I"VbðW\¡j—W¸µPv6ùýõi76z”#¿µ^¹{/çCà xíi×+ÔZKxÝË‘‹î>È¿¥Å†ȸgƒõQ³ü(5}¦‹ãéÞõ‹Ûº[íwì>¢iÜ…lxDöp©&ª SºU”Žê ÐvMü }óÏ:"ÜGlwûŽ÷÷ɘ/øi– ­…,éBêugšhVf0tÍÇb›šìÜnQNÀ¯^é%@âh2%Ï›žP¦‹þtbAƒÂQÏ‹‡Læ3ÿIöó‚NÂþ-ÁØåv,jêáWO¸û¹óâJreQÚzü(°öMQVóáâbÄÜ›(œO‘_”%ˆ•ô¨•(Vs¹àǸw°“ËË‚ú+iÆH°†¨0Ó8ÇIK®¸ÍúK0vÇJ±uØñç&ýͧÚÒè˜p9X”·gž´ì’Kt¬V¼ç¿¶û&!1.QðZ£Ì•¾·¾¬!ªõ¼9ÁÝÔöÈ—bËá'A œà¡‰ÔщvÙkî~?9]¢’âra1l] _%*Y­m¸BK+ ÷ © áÈBý‚×;x2%ÚG­ã¤Rcò¶úfŒA5n¬‰¹ÖÑ:(0Ä¢0°-|+ýmÑs¯Q‡i%#ôV¸ÂS''®ÛUÏ% .±MY ¦´·¼±GSn¦ÅI:Ç\¡½§ZäíNÙp\ù­ Y3AhxþE'<‘ɱÑÒI-ÁÛÕ‚Ÿ¤YݽÃQ³ç\ñ5EÎaˆšZ#ÔˆÜàøgi,¶Vú䯘ñŒüPöº|(Â~ð}ûÑÅUîÂKÔ0‘…¨×eÃ\úÒ÷·~èmDT¾JYù°g}yíAyÀ²rŽR^f’¿«ä‡¾ã”v9Dtøm€=ïÖ2/¼ Ì@~.…è¼ TK« „:ý¹™eT2éÀ=“M©Crz£žq˜ÕR3–Ä6I.fqÈ›Ãüt UÊ»s7p…:ü ÙN%”fîœf´[È ‰”E´Öo:Ü[c #\…Z÷q¼'SS«’qw€È4áÝ&„šU©{Ì—¤p‹]‘-7¥¼mAq¯;¶ÕÃ'Z®ÙáÉ‹Eÿ3ÆwR·Ž’Ðòj û÷ØÆ6ê)Î6T!¦E€6i¥]F`Ðë&AÄd…]Ä_´|ó;b4ħ3œcbføÌU%MU%%'÷3]ü5¶é‡·pêÓ¬ˆøŸ¤“Ó–ºg þÌ¢ò^yï“cv§û‰h—â68ÑÖÈ^qŠ’ÞBfs‰¾ÍÙ ³0VÝð7˜¿Vv–v³+û̆ä ¾QVy5íûyë=Ÿ\ìZŠ žŠ ¾ã¢ù<{}{¬ÓI¢³Å¶ÏO~ ô7äÒÄI_;Ó†3q‹¤íW„yPÊ®q¾ãƒß6ͲG‘°·ÙÅa$K[qV= 'Q{ò4NyžB9Mýñ5+Š4tâÁsïÉ ìÜôµ*âÙRù4xþìµ!<²±©&ÖΰJTÃ<ü‰¯1kôÚ~oçì2šœúé—9Ä,ÌšµäÜO:¢ ¤NŒæÌ8õ 7ÔÔ-f­uŠ£î2±?ÒQò‘Ý!Fý­žЩØd‡‘ÓÞM¸‹ÎÏNÌLf{dšÊÇ9ý«ªï`Ôψ†hglsª¤ÂU$s@ÃÕ—–Ü/#ÑB׫˜f÷*Ë éÑݽÕÙ^œh2þvèCÏíPµr᳘ùD\+¹@IOn³›ÕûÝ¿³‰AûP‹b²xw¢aKÖª]¸Ì•i›•é2Ð\uÍG£_WS’|§®Üÿίh“LÆ@üÁtòZÙgÚþM3·V;Soä>ù7•tz—-µZa;6°¬÷^‚@%ðáÕ›¸w#âa‚ÑЈ'UýÑ“Ãno‚¡ÕÃy^LÃxò uŵîW^X5¿¹ “i¶GϹªy·ÝôJ[X¯îK·2…ʪtQ15ìRŽø«N=CœÓP˨žKŠ7V HÚ<ÂRÒVO8.q•yÓ·퀼ˆ_¯ËELJOgxwrƒ¯GXÄBÖ_]^C‰þv¬¨•Üd$5¢2ý¸I6¾€ì—ù·¨lÃøC©!ü6‘Y›Þì=Uóȶ>™'Â_‰Sš¿3G¨‹ŽÊ wrójY6OÚ¦/ôë®v76䥨? ~ÆJäåÂ|ѸÐÔ@727ëº_ƒ}È6ëŸí ,-ÌŠ2w8NUqºÖ~xTW1ëg…Ø “nÜfÌÚŒÞë—ÅGQ Þ9J’Y™ú„¥g'I\®¢‹%Až XU¹àýþ´™½# ó¬µÅ²ùùÁ ²ç?™jJîÛ‚¹)^ÝèÜúó»/q`×4ÂöÀRdG2ã„7zwî¥+§º­ž Ï¼uävÜhLë¨zN+œRñw@"¢p[µ×c¿Ò÷?'|lÕ›¤j—QYÉb8¿a˜8è» Ï ž©V;^÷3†@Õ.…aȉ+o§©˜§ˆmQ‡mòÊ{ûÙƒ¸ã`k À©GKý^cÚrÉ^pÛÔ`²Tkíôëí6ƒÆiÙN囊0‚6’óUgK½ßôž!ןË{W–cK'ۚး’™TØ)./Þ]”Ñ) ˆLUŸÀãl‹Ò¨Z¡Ö­’&Õ¬#öQY}HÝ ¤2ÀÄf%Ъ܊ ¡ÀNÊsÁ£Jÿ3˜w_¾Š:¹¤Ÿ¯m€ I!»( 6”§·¡÷™3/ž1mª;”ªûµ 3c»è1_‰Ã‚. ôy`H£â`Äþ},"Éyu|TKQå­Æ÷íÌ ¥è©ëL]™[»Å:OzG‡ŸqJºóÁ±ÆAàqŠ‚–†Û^v­§,a®‹»&2¼ÙÍéúx«A-}!ÿ°/v»œr”†@˜§)p,¡‰A#ueRŸZYkÍ*¨(c·æö«U6ôZõ‹øõfX€q@DñãŹƒ˜zU5}ŽSÚáç·(‹ ÕtFª5Iê,®ðÅHÅŸéÌÅ‘ È°8³™£×KEÁöIÕÂâ\(®›ÇCû§¾Œƒ9&7ªÉSzƒI»>§þI ÚƒENùéŒN–ã÷NMÆ6´ìÅÜÉ݄ۈ -Å£mÈ#î2ì´Mªa‡‘ÆŒù§^û2¤i‘t#™T ÆÒóÜ…=®Úx¯7bêééÂú”ÅaFÎ/µµ¯FЄéH@<«ü ‘DþðZ>5(Œ¯ᔼ­:þkÑ>áô|¯ÆX:Õdñ„ ›äïú±c]áBl%=S~µ€\ø=º\î‰VŽ*ò±(Öºÿq@KŽ ã.®ùX ”Z:à ÍôÊ´ë¬7ÿ³$LÀƒÞ@ʦ+Wý[¯YJmÄk»PhÅu’jÒ‰:«e,­Ž»ô§ÖSàçÕÓë“Ý'æûoƒxüu½ÆÑˆ­ÆÞ¯ÉsÄXWß±þPÃhÌLœäp°\ìÐ Pä)¤’œVÑ¢ôñ·’']ÞøkB‰ôÝøaŸn…²P*®›fª›TBÒòg„œ!"S›PÙ…ÙÚPn:¨õ+ŠNée ãß«`³—TM„“s[f´4†Cl\ôaßÀĺˆ6!.ƒØŒýÒäcÕÙø’Ä»Œë“±A-æ2&qlÅ_9¶çh!4yßæwv(ÎJØ?°ùW}qÂùSÜdé7¯Â¨¾@!{øKì¹Î3Ê ü`ÎPcsÏÆL26nöÊ™Ù߆n’2@4•š–&Ñr”ûèj” ›ÁÇ/ps3õ¾áÍçNÚ(±iWÑщÎ^•H® £·¾{SAX=–yy3¦—TJ"L/ò£Bð@Í_þäÔ´ìó·‘ë í¬éè…eí¨¤ìÖ~Æ^¿ˆÑ…ØÄâs‘0i=Ã~èlÀúzGhØ"œÌ“ܘ ‘¿ß61O/PEVá³ry qöfÝRUíæ¾üzìàŸœg¹¯ŠŸ®ß÷ rAüAßÅä-sùÎì«pùÕ‹’ iív”eSZ©pZ°À|ŒÐoøJÌI\ò½ , ±Ï*/UàŒ ÎY¯q9%‰`ØÞšÊ“!ŽÙÃu7ÅŸü™¿Õ)§Áa°6l:*Û’$Ò%øÉ69Êõï àíN9gêxäk+¯FÈâ+™ƒ&ñ#ÎíuÏ[Eub¹¬µ‰@tP[qßK[бZæ¸:±ö‚dO¢ÿ K`¸Çõ¿Î<ªù|¿Lh{‡½e k£Ù.\ñ8]#^E|ÔVyåž{m2†è¨Àþ÷ã2Óô5ï¦z0!>{ÿεRb+?!:nòî¾Cð›Ýš?Á¨EçâØð%¡Ã‰¨ÿ_Ú!%ÞGÂŒÔß]ìMîŸ ½Ì³Ž#`§àp×A±[qŽ–ë禉„f7òÏÞbYþøk‘cþµ¢*Ö§c2Öq<ýÓŠ-™±ßs|^¤ôl&ñ]ÝÛ‰7H0Ní¶á9]Ö‹à¼;¨ä6ÌÔÆÑU>m˜Qa¬¦_\`Í 3â—t•¥dŒd9¥ß¨ØÊy˜F$ V¹ŒŽìXR=&þ ´Ûç&xâEžö(7+y\nJB@XƒË£ºâN©sÐ"Âp¨ù°îf›Ïè»cx°vÙÿ{V ¶imvíEbzže¡2;©ÁüÒ~µ½ÀŽÎâ¯CužÖó®‚Çz YjðÓrÕX­hMĪ‘<^0^¹µ OÑgÒ·ÕƒÃn|!×x¯×´ð䟋 ëMÔXÚÁΉ¹y%ËD da§k¡ìV‚öFWî)>Fñ“çŒüßÀnšïü6¾j1ΛD$¾ó’¨`£ç޶õzH§mÆËb9͆ÂhÆ5pJ“Ia­ô]8ºªÿHóµ ÿpè½ñ±·ó ö^—\f÷a:† ôÍû_ôôÁrŒéú!âUíý¸Û²Iîá Η`j…F¬Øj5Ïë.bt%g`Ÿ]¯†bé5€ÞE´›Ýk9æ#'s‰¡‘ î\¼§ãB;]¾2nQ—pzÁ• °Hʾ·†ñ7eãã~[üh›‘° jpg²D1ÕG°—4p"°‚¤n NÍ†ç²ˆÒØNŠ>G›¿T­PCHîÿܵà:1òê€ß%kæ¶.‘Ž€£Z^— ª$cìu¦WD0C鎶?1Ô7.éÛÓpÀŠÔJ1Ο؎¬ª[ŽCC%½ÛeÐ8jApæîcÎÙòý·Gh;}éI§¾ü· —3«ÞFm+aŸF{ø5{CJú’>8æ1˜×f ¡aÏ»…Óù¸N“~$¿A\­ É P9uÌ£ÿе[<ƒ»"©7í¶ì™Ì*­2%“ÄxéF²dBŒîvoȳlÏ*¯JÚ‰l²>XÙh¸J±FŒE)a4ZÓ«Q(÷Ž˜lF>™X¿Ò!ƱYL27—ÌÆY;ãí;jQ#0혩0W®€8w3íC`Þ{£â@E Uö ÍEVË`´É.Q¹³Ä­hHz^‚KæáÂ^Ioû×FcðZ²x|ýe ªtÊŇmÞ1õ«Ô}}vÕêÈU(0æ·×úŽ#qEzCþœ)ä¡„ ÑJ;‰##žï³¹xRG*³Åƒ»l+¾uÀ³qï¨}£Z îíug˜¯¼ÕD"Zu`8íDà íà[š—È&âÄõ‚7ª›BÞ @1À:× UóTHŸ›)¯,ã´d„+D{W®9b„´Ü#¼#k—–÷¨(7Þ"ϳ°ÉÃà?7óŸy:TÛ÷SulÜ7ØS3CS­˜w¿†o4BajLY%KÞ·gLûøáÀ/ìÉSN«¦/À‹CqéX¦r±ÐCg¡ú()qpXÚ˜¶a¸S„Y¬—Ø*X¡ àáÛ¼bY^GP¯ãä¾í_?ý3Zsš‹˜úóyÂ6v=ÞƒTXæå|"#G‚ÈHšOÀÄK®²üMOº¯à³#tåæ}DØ”–|C–é´o³"Ú"¡éÿ+ÌùECs«ù‹ƒ ô~Q/I‚î2µIñ¯æ„â^¥èÌ÷AÖ†H]öš4íSES è}i¥Ã®šf†Â]ì7#u­mTj£õΆ ¨¡¶ ð2´Ðǖ‘p+lÆ5 Q»„P“ô1pŽÏMM–i~¿2™Ä§‹†ä‚ìZÞ(ÖÑ_ÑÿS–ËÙ×íW™å<Ã\äaÇ1^K$g‚^ÿB¾fæ;W$•0 ÈÅzG+ª#ñŽêÅË0Ú§œc:| ³EæX·r°'R¼êÂÀb%äM¸žãÓœBõ§6ûƒÄdKWás¾ Ëò¢Êî²dë­¹ÒVÛT©³Ïmoa3WVZÐÈïÊÕ´±èaHo È“ô ý¹óû&a’¤gc¯)C‰ã€J"öÓ·ÉGÐKlçì/ž$WBåºì ÏÅâŸ&¯nk`<MÛºÙˆ’²ýçïGªrDp¹»©OÒ£ûÆÄ<ØFéóŽø#Ó Ñ(»<4ûê€Úé0ÃxŠõ"T˜P„*‰°/@Þç섵|å"uŒ¤›NJ?`Æã_“ó¡âTœÀ(ÛO†„y&ìÑKÒóé꤈8à<óª¾0ÈÜ)*·ÑíXG&€i=‰îhÄï\W=ê]K ö9Æ>•ÈÎTƒÅàQG3 šúñòŒq]Lö:hCep9#² ¢$Xÿb&êÿA~BµÙóœ N6…r¾$‘„*s.™«PèÒ7+¤¨Í˜&V>Þs`^3±°âþÉ<1D±úÖ‡;Û¸hÒr/™ 5ˆ™€0Îðæ]º‡Mö2ŒJ‘åñÓ¥ž¾[£À“úe¦fmo…¨ô/‚SBí튣$;åy}sq…F£¸E_o0?0ìËÈgæPG¦`ký Ü×ÚµáåØãqé åe ^¶ : gå”ù…~Khû»º¹ ¤µù3=‰¥6%LÉ7´úŒú̠͘ëe¥ jg"ðãVÄ®pTÉâ©*¼A–¶œ¶Jð"¦ƒL|´¶Ä9¢é4äyì;C_”)PÞPkü+l'Þvš½šßwÂ`W2H9<¼ÖÀz|0ŠKø’­^Á6vJÝW`ÛãuÈG\ö<Šczìæ‡ ç÷Obmlì³ê: ®¥w áh¸–ÔMwŽÀPw¯‘بñjUnKMÁÜwtÔjãV‰è&aõ ºÅr^û` ´e’®s•&¡ÛÜÿTƒS®ß#|xÊ˵Ê]´®ÓR¾õŒVDò{ŸÌ3×4jJ>s¦jChŒÙ|¦:Íö\E(Ž+?WÀC®ÿϾzŒ  ÂÆ¦ÿHÎÙŸæ@Jœ/9… é3ÀD¨}’˜ü¹Ä$pxxa[ë{çÜᄀWl0í±_o$Ø\ÙkÁÑœ]ô=Øÿò$ÿvÞYSþ¹5vEÊ*!ᘂµ£ÍéfŒŸ>¶÷å÷KvnŠÑ˜n íQªd_úR™¦48õO¸Š%¯P.R³;Iƒ<"l‡+!>DæÃïSDªÌUÕÆjYÜêOk<ö:y£~Èõ¬–¼ÁM»³˜ÿ;‘¢¯uaŠìV×Q0±m˜g~·VöŸ‹`ðŒþ«˜1xÀ_ÒîÃJeá2ÂØŽ†6‚y2*)Ûj©2_ëCQÛ'¯ƒ]îDX%.mMá£Á.C°Í•âã¢_*süÉsÝp¶'+™ÉÑŒgÔþS‰»¹mڻࢅ2»~ºÄebMºHéRÒ±çYÃb†Lzu=’’eZíÚTiø³¬·"¶ôæÙæž?‘ vÚ Ö¢PN?§Go¯»Á)->Tq)¦?΋M7s 3ãò ç ÿÕà}nƒ'œŽTÑÂÚ^m_÷ õ8n×Mˆ+a•{€ËWÎþO“ ÍŽg2^N‰žK²ó5©3Aƒ ç)Áö˜Ü‡ELl·O 8ç{—ÝS“o@L°UaÓ¥2`Ð7 ü©A‘A.‘FøJ¬¡œÛÜ\ HtéÑó<S ŽTC`97Ÿ•ª nއP÷ñn ”iÌ„³Ú”BPê&:~˜ÍËO9FAêc|ÈÝ`ÏÒQuƒ¬”0t²Û9ÖÃè¶ ÅÆÜ^˜Hø|É/g¢ƒ*†©ŸMWÙ1‰é—ʽöQÏ^̃‡tšÐ{¬mpu.=ŒKbºõÇÖAýH@ÈÚ“ ûÁªáECåB­GkôèWäŠjÁ”ÞÀ:¤‘ FÎNO&,ˆ:sT74Yf™` ŽÔucÁ¾Ä\:ÛUË%MïGëu¤i%3Þ¹i®áçQn‹ºò"k*Ý­gŠÒ4,¦‚Ç„ÈJ\€ì ÐUV|j}oÆD@Çj òg­½‘Vï~ ç|™å1Yž@é/ŒrC˜‰‰İŸ ÍŸuÃ¥=Ð^<آˈdŒ“Šî#@ª»xlݯÞ#E'¤…Ü! >מIHÿi‰‚œwy o#4[<—äBs×!Ü„Û{*µ+Nƒ_ Wæ)7D½ át¢¥ )“A¹Ü ajÍé KrÄòÝò ±¼4ìwæl?„ªÃ[Ô^Q7Iüåa˜—Л†ÑIw6ã Âí^ 2s]*h¬õôû‡Ø“QØIœ8L 3e]÷Ó Ër|2Ü(ûgK2rÿ±›êéO“=âjôB9Y/HmmÂßnœ‡Q¡ÜôÎ7+ å”ð^€Ìi`v5p¹£²b],ttÖ‰(Å4Ö?=þ€å†/BLó<QúÀן³·÷¸à¾¢)ªº-Iѯ¸°°8ßü„fi¹»6Û/¦AÓ~ÜÔÖúÔúÇ~35jº]/ÌJΤL[ªý晳*e#Ê. ¢LÕÒT„³³;yè#/ÂPþnœ<7Hôü„>•Š¢2^SŒƒ4>‰ uú&„tKDõ  “R¯EvFåP3j¹a8ò”!ç]­ÿü÷˜Ìÿ‡,_®#·Ã<ýŸÂJF áhJÕ† ]¥•ÉÚ¥3ñäDøþL->b½ày)S:ÙÁ ó7IÈ®Yà Ÿ¸¥ÍµJaˆÇìì2¦§¦Šóž«Á}?©¸N“æª6¤·t-r–eÐÕ<7“ ŽÀ£eN¬=z)!9xr×ïåEü#/ï1è+ó.£$ÜŸ/1”Tø½"O5ß °ÖΔ ‘¢~xF"\ÒGëg˼SÀÀr@Î"Y`b>x õ¡fÿŽõÛ£ž‡X#µàÉpãw¥CÞUU4ã¬:¥æ˜{à Èlo.P ½Ã' u„Ÿø;€²Lyœ„o.¯šÅW˜Ô3Þ°Ï dpå½Hð |È5˜-—×MΡ«w:GÔ•Œ÷F²Ë@êüW>ȵgO; rðê[:°“ »¨´©àrÁãCŸ* žñܺYøS|ˆâH˜Éþ‚—)e×MÎã\Âò,Ø‚R3@ôÅÑŽž*:_0¿¤Ï™÷GD¼ÖîVœh8œ¿DZzyD«dá­¸lùõ¦U‹¥þ@ép# ö5{á°ªÑ ¾¿ÿ†ðHÈ œ"¼iÕÞO}yï€*#>ï:œ–‚ik3"­þ…mY7Þ1&}íFœd¢¤ÕŽ”åm¤1ÜFr|é¡¶]ßv„šª¬uógëf  ‘¢R–º’xæ.({í‹8f?ùÞS!9­*+˜ ?í|Oò IG,B§ªëy™üyJ“Ð.ýý(ÊA<¡ƒ¼í`fúiX‰}hÈ7ï\à®iŠ:X•OËÉÓ§/*èà$± YªÛê%˜vŸã´ $ëGZŽf„…½ÛýÔïºP´ëKvr_¡…ʪïg¦PtËê¡, ,®yͰì)\|àúÀ-½«ˆãJ³ƒ$Xì!˜7oŸ7bÖÎ!îj¡©Œ$<¹GeãŒçŽ0ýcDÜ»զغE±T„ç/nPóÏ?b[‡5Œ"¡îiMÇõr’«¡a÷,‡SÛ° ,4|/›µGæÁ¼“À{ìXUs šH0,†è|¹Ö_YH) f „*[ûꃸ‚å±Äǃ¹'Ot†Ûçß’ØÀQYþðdpÎ5ï¶Á$Ü üœ'õ¤Ò›»¾&²ÅUŒIi”w<¨ñXþ÷ÔdÔsË–²þÜ2ul๖'E@ÿTk"£[Í‚%‘öÉúcúyp=Ùä.Óý€Ç{§)„€?Ï4ûwƒTuNf­ävXÏ'}¡K½ï6¼í›Æ·¯T¦XYnË¡!@?¤TÐ9žœKÉ©­Ãø`c/ßL‘Œf†eÀCªY¢hüŽ£=¯ª|tÞF&ÞÓew€~soÆÈõ‡Ø\ÞêL#¸2¨µZ'ç7ßK3FL›XF·B¨öcæs9¡1³Æà¥V¸>ÔS.JN_dZÕ¦ãÐZ!<ôÌÝóBᄼÂI\c`•á^@\ ßà,…8Ç™8áÞ—Då}z Ö¨,; óX†b¦v­ºÂLþvÕ[ôzf/Æ+oF±‡Ð¨ù:qÎÿXEø³>ú†½…½èû™?,yŠÂ<ËxWéÔü§ÕvŠ/ÜW^ÿÔ Ë›JfNº¯láÊvæk¡‘´ñU!$f²q:&¯P7?»â™EЧOäaãU½¯“GãÊ´ cv¼3u«’ÄT5*Ä¿bƒ4Ø`úŸÊ+ ã^|ÞÞ—Ú÷ýcfájÕeÄò3ðÇ…í7È Í»BTK`¢~æ%AØad¿ðü2 µ{0xT$%²ÖaVtd3PÞ2EkÒ!¶oïúY· ¯ú)WÇGïå:´ê·/üeѼ¹¦©r|;Ö L;c>ÀárÝT{R@…Ê:“ÃsüŽ«M÷•œnö§½Æ]R}ó#fåTšÎ2€$Öúû”»Ÿ ŒËËX©TÁ¡u׌Obî¶‹rG®ÇçZö ‹¿ÔýûJE(íø:! ;ÙD·p±”Ó¹]åCqªÿÒq±Ùƒ(ãz~p®€ œ–o_ÍkË=œ›¹C5€™ªö3i1§d9–•‚%‹R®ßõ—Y§ð[–AãÚ°Ì8å¦âœÒ’=·1Ü–ºúñ#E.Eí±†ý—ÿ+¿6f¤9!¥,cÖ*g3£÷‡¢q)ˆ±>²qß —çÖÀdmæð"æ7‰šX„¢7¹µØY iÿ äh»õýl¤¥Qu\ìྛxX„¥–¶}ëIÒ¤¡9{êQ[¼m –;ˆÁÒdȃ³2¸ðijr‹ü*«X§¦ ™Ü¯*+˜iE—ıAa¯v«ïúEæõB[˜Éœ%Ó êx¥ÿQ±ÜNgœâf<"ägEoa¶þ žd8ª±žÛ;ËÃÿ»®Š0/’—GëÌxåm›ä'uò˜Š,Äú˜Ø”V^ëˆÀ•ÿÜà¢ô{?ðòt¬GÊ]‹™—3c¥Î*Žð·ä2èÍeI¸ÑÌRo¬Ti…õb’DŽñÉ!Àu¶qIagóHÖùÐ4N“É$OÌŽ:ùÈ2únÈ'ƒÏ©ì"ö,§@ Ù ™¨Ú ’â …8ݕΓ6dð*~“áå¼um'”Ú'E{Þ»Aä–}÷„Ægh'r‹d=åê« xàK¸Ž?>}d‰Ï–)c$V’,¿%C%e£[^À<a3F—Ȩ—‘Óƒa“Ç”P*–äxkeèßôr»2åÓïÕB7ГÕ’>Äj¿½Ú&´BŸ©þAXü]!4æÄí®æ‡LÐsºM #È“j2|­äX•0A'þQ_±²% E÷d½aÖE,3ü‘h¨ÆÎŒ?} û©a€÷Ù6!„ÅW˜¿:®Þãm½oI±©°9MXõ¦ >æ¶Á¼g4ŽpBZ7¯ Ó`Ý tHYÄÕs/©Ï-å>·J!<у‘) 4Xõ¡ y" g§Mó(ÿöþÕl½a)k:\¬ÇÎné(ÑhhëíÓ¥¢_djÄ‚…†)³jÕ(( ¯z#¤j°PˤêÆ)¥ƒ/£õl@eVÉÊ?ñ¤Ï#øá¶Gë®i`àõhM÷õ™*~p´ôÍ1vk#ÂŒDKŒŽ©>„W´³®xeŠ3[4¤­‡/âGˆƒU,I³Ü½ý±ÈKõßXwx•ø%gƒ†ÞzÏ IÃßS¿…r_|ïá蘑 훋È•C8gq­¬Ó”YäfóãíJ®ÏÎpÁî V;»>Å›„’£‡dÒ ÑÁ’ÈñÄ×;~3;CÆõ\/€Rý'§MÈÛd©Mèª5w«~ãÅ‹ëâuÞacÛch8°°É×-ô ÞGÒîÙÀ NÇc°cú¶¶ÆßER… râ/†"9º¸^© –ª-áªÐµ¥bl[âìCöž@^¯(‡?Õ»)Ì4 Ô\éí/õ zÙhº¹¶áàÜ.¾•~!P«dI"ƒBÉ:¬?›K0ªj×B¸ê( 0ÌYuýüÍPùå’ÔºkÔ,)@Ï*È•ÿ†Í>­KX·ÉÐÒ20E,_Á ¿m䞃kjmk¤´ués=$«Š$æ™+_vajß~I$uM‘­ÊRéoi§¤ä^F¿SÖªÃ88ÚZ·Ly)šÈ ŒÓÚÊàâ·Ø›û¯O0à;fn­›Ï²ë!)_~ÏYñ]"²ÛŠÉzHòX±Ÿù¦7uo/Ìb¸¥æJ¿³'wb–Œð^œóU¯eäz.Ú¶ðÇl·åF`t)еCn˜~óɇ@æRoš}Lø+׉§GÛ·AøG£¶5,Q԰ƘջÖF/0Ú–s–³™õ‰ü^½·7Bã‘H9þÛdHÙ…ó—¾Ý ¤.è±ä¡\žY‹ô Að)éçÕB(l€¡ÿ *¨øn„IÕ9Rrž(ízR?ân³šqžÈ+;î€û¨¥©êá2ÇÍ!$ëtžOH7]w‹q™GïgA&˶¥›ílǸÃ:¢ÇÉØ—6@ž ðz˜è|¡>>åL ÚÀ9th”Š­ÛÈJ ¥ü*×¢y¿R‰L“r¸øfùñ’F·"=ÓÖƒ‘ãZ¨öYß”±˜G_ÉÄüÅqX-NuMŠGŽ€Ø¬4ú†9Ëå%ÍÉ$eèWÚ3´9~±¬†ÔoK ‚eŽi´ó#3!´s'¥Ä®ÄϧÌNbþ‚ï“"ýbß±þ¹TR˜Ê.ð¬÷ OLA²üó0Î-É (3üõH³Tý½u‘i¸Ñ%½“ôŸG>ïÉ;—|Tf.cŸc]¢£òŒhuô¹žÔ%‡€âÝAïH¡>ÄS$´c¡Wo<@Q{šé£ô-„‘«@¶‘5ƒ:Ú¹áÚ¢ïW.RAÒ:4üé9¥ J*L†„PÈgÒL¾:[µÉúã¶ËͲÛ-ÜÔéåH`*PhÐO²úÒ‘â_W–Ëý‹M “kå?‡]n™ä@îF•½hC·?8ÉZ3SÕÉLâ}œ3 ­SÇqð®†@ÅJÆ»™›§¾ö\c çQjùß<ÞêøhÿÆ)ßc}+ü›ÄÙJäfõ l¿ ”_‰î/Fp!\Ζma  tÙiè¶‹$†Èrx àÖ¬&a†/» ”àën>FØÉ'ÍL—9¡çÈ(L£/QĈ#wpÛËÎfbØl ½]gK¦oÆ«/þ˜^Lîl$WSç²¾Àcù*–Ÿ-ʆ%qƒ4±?ãoÓz)K†^·:(u0(HïÜÄûÁQù°kåösSÆx)_Õš¼AH"ƒo„Mé~®LϽ=Üg–Uè2’©H?ƒÃ@£åºÏjNN¼½¨(ëP ¥1 D ƒttJg r§4ÅœRüKf ç’÷M0¢Mõ‘ÎtúïÂ3½ìÔà¢øyëE¢ëïç·jL _¡Ûhì_°ç9âTÏà1ú–¦ƒÒÁ ê_\./]6’ŽŒ¶yŽsyÀ0ú¼Û endstream endobj 107 0 obj << /Length 696 /Filter /FlateDecode >> stream xÚmTMoâ0½çWx•ÚÅ$ !Ù ‘8l[•jµWHL7IP‡þûõ¬V=Mžß̼ñ s÷ëu;ÑU··õÈÙ›=w—¾´“ì÷îÝÝå]yil;<[[Ùj<=?±×¾+·v`÷Ù&ß´õðàÈ›¶<^*;²~&ûQ·‚>ìþÝþ”MS >Ù_êãP·ò{=éÇsæ@öd”ôÇöçºkŸ˜xäœ;`ÝVY×`Œs4½JaÓQÜ¡n«þª‡í¡.’Uu9\ßèY6î>¼ý<¶Ù´‡.Z.ÙôÍž‡þ“4>DÓ—¾²}Ý~°û¯ÒÜÑör:-d0­V¬²WÑÍÿ¼k,›þ8ãóþy²LÒ»ðºÊ®²çÓ®´ý®ý°Ñ’ó[Å*²mõíLrŸ²?ŒÜÔqù¥ã• â5F8@ šˆ=@Šð)&°  È8Ô¹€ÂÅRx u€Dº\j2H—†ª¡ÐVÁ¹0CzL]ø Âb°ct‘I ©g$`htÑ‹0œÆ\F„áŒ0ä†sê‡á jd< —Iê6œ»õñzgóñºË»þê W ¤qÈ’£+—Ÿ#ö•ñÌÇkÄÞ .‰bªsré…¤šáæÄç†bïmŽXú¾„Kß7ǵHß7Géû„û¾nb§>&jÊØµäuœ¯¼ú•ñ1ÜV™÷•âÜãâµÇ‰Ou$ÕŸqWèS/%1{\øxB!€§ÔK(hH©—TЖ枃»J©Ïϯv×ÜëÁ=küÒ2ø¥UðKÏ‚_:~é$ø¥Óà—ÖÁ/¿Œ ~™Eð+7¿èË¢/ ÿlì¡ÛÒ(/}ïö -+ZXukoûìÔE?Z„ãæÅÛKýqíƒÄ endstream endobj 108 0 obj << /Length 867 /Filter /FlateDecode >> stream xÚ}UMkã0½ûWh…öF²ã¯²CÛ–¦,{Ml¥hìà$°ý÷«73nw—ÒƒÍÓèÍèͳ,]}{\OlÛoÝ$ºÕêÉúËиIù}s ®®ª¾¹\w¾w®uí8{ºSC߬ÝY]—«jÕíÏ7ž¼êš×KëFÖç¤Â½ì» ÖQ×ÏîçÄ5Ûß&ÔzÒ&§ËÑ “³™h¤<ïϯžúKù)õÙ”¢?ÜpÚ÷Ý2·ZkXvmÙÐØ)˜Š85åîö];ˆBµ…ÞÀ„ªÝ7gÑ»9x‡¼~;ÝaÕíú`>WÓ'?y:o¤÷&˜> ­öÝ‹ºþL '¬/Ç㫃¥ƒÅBµnçëz_î7§¦_týÎ|~;:ÒØ°Æ¦oÝé¸iܰé^\0×z¡æu½\×þ7g"NÙîFîÒsuí_¡ŽòE07H6!L‰@Œ@ÂÈBŒ€Öû@æq\s óŒ”*댌ÆTgùäÔÿÆÀ á]8 i/°n¢£ŸTv<ÊÈkã­õØ0†×YÈÚ²ˆ1êg3ÆK`òÚYÂõ³”1q2î2ñ‚Ö%/Ì ¾dchÎJÆð(«S}êßÄØYÍ:sÖcÝœõÇà笟öPÎúcèÉYB¹¬?Aï9ëO‰Ïúâ³ÎšsÖ™âç¬3¢\ÖQ.ë4ôc±Ï½Xñ=Zñ9Ÿ‰#>c-+>c_ZñëZñ~Zñ™8â3z·â3ô[ñ:­øŒÞ­ø ߬øLõÅgè·â3tâ3Ö-Ägð ñüB|†žB|¦\ñ½â3ñÅgâg|2–³½â?z)ÄìÃBü§šü¯XªÉÿIAuÄp*^+†ÇãŽ&™#ÌsU-'H8ªqɼßÍeü5A7û8ñ÷{¿¬ŽýYôÐ-7^´=ÔÁ!Uç endstream endobj 109 0 obj << /Length 868 /Filter /FlateDecode >> stream xÚ}UMkã0½ûWh…öF²ã¯²CÛ–¦,{Ml¥hìà$°ý÷«73nw—ÒƒÍÓèÍèͳ,]}{\OlÛoÝ$ºÕêÉúËиIù}s ®®ª¾¹\w¾w®uí8{ºSC߬ÝY]—«jÕíÏ7ž¼êš×KëFÖç¤Â½ì» ÖQ×ÏîçÄ5Ûßf6Ó“æ09]Žn˜œÍD#åy~õÔ/XÊO©Ï¦øá†Ó¾ïÕZûÀ²kËþ€ÆNÁTÄ©é(w·ïÚAª-ô&Tí¾9ˈÞÍÁ;„äõÛéì«n×ó¹š>ùÉÓyx#½7Áôahݰï^Ôõg=a}9_Ä(,ªu;_×ûr¿985ý¢ëwæóÛѩƆ56}ëNÇMã†M÷â‚¹Ö 5¯ëEàºö¿9qÊv7r—ž«kÿ u”/‚¹A² )`JbD>`´öØ2ãš™$`¤TY'`ä`ä9&£Ä*×ð8˜W`TœR±¤&4–`Ô(ZsJ¢5Rê’H©+¸†Çhì3Ÿ}7¿6ƒXäÅ¡°6„‹0×a™G„+˜ gıXFǯ€Æ8åÜ8ã8ñsέ-Çá´.x]â”/€+ö5MĹˆÖPN‰£é±¯<1\?‚Ãõ“Æåǘ¾tõ1¦:Ë¿ø#§þ7^ïÂYH{upÍý¤²àQF^o­Ç†1¼ÎBÆÐ–EŒQ?›1^“׆¼ÈƨŸ¥Œ‰“qÿЉ´.yafð%+CsV2†GYŘêSÿ&ÆžÈjÆÐ™³þëæ¬??gý´‡rÖCOÎúÊeý zÏYJ|ÖŸŸu¦Ðœ³Îß8gå²ÎˆrY§¡‹}¶èÅŠÏèÑŠÏ1°øLñkYñûÒŠÏX׊ÏðÓŠÏÄŸÑ»Ÿ¡ßŠÏÐiÅgônÅgøfÅgª/>C¿Ÿ¡³Ÿ±n!>ƒ_ˆÏàâ3ôâ3åŠÏ轟‰/>?ã“°œEè¥ÿÑK!þcâ?ÕäÅRMþO ª#þƒSñZ1|¨8Gxp4Éaž«j9¡èDÂQKæý.h.Ã௠º‰èÜlj¿ïÜûeuìÈ¢‡n¹ñ¢Åè¡þðç( endstream endobj 110 0 obj << /Length 866 /Filter /FlateDecode >> stream xÚ}UMo£0½ó+¼‡Jí! ᫊"R»­šjµ×œ.RIý÷ë73´»«ªÐóøÍøÍÃØWß¶3ÛÏnÝjõèNÃelܬü¾;WWÕÐ\®?ÿp®uí4{ºSãÐlÝY]—›jÓwçOÞôÍë¥uësRá^ºþƒ‚uÔõ“û5sÍx0ZëYs˜.G7ÎÎf¦‘òÔ_=õ –òSê³)E~ºñÔ ý2·~ÞÖ}[4v æ"NÍ'¹û®oGQ¨ž¡70¡j»æ,#z7ï’·o§³;lúý,—jþè'OçñôÞóû±uc׿¨ëÏzÂör<¾:ˆQ:X­Tëö¾®÷åÇîàÔü‹®ß™OoG§BÖØ ­;wwý‹ –Z¯Ô²®WëÛÿæLÄ)Ïû‰»ö\]ûW¨£|, ’MHS"#p òÐ# µÇ>y×È| #¥Ê:##Ï0)%V©¸†ÇÁ²£â” Œ55¡)°£FÑšSj­‘R—@J]!À5£w+>Ã7+>S}ñú­ø …øŒu ñüB|¿Ÿ¡§Ÿ)W|Fï…øL|ñ™øŸ „å,B/…ø^ ñû°ÿ©&ÿ+–jòRPñœŠ×ŠáCÅñ8ƒ£Iæó\UË E'Žj\2ïwAsGMÐMDç>Nü®wï—Õq8"‹ºå¦‹£û:ø‰9ç endstream endobj 111 0 obj << /Length 866 /Filter /FlateDecode >> stream xÚ}UMo£0½ó+¼‡Jí! ᫊"R»­šjµ×œ.RIý÷ë73´»«ªÐóøÍøÍÃØWß¶3ÛÏnÝjõèNÃelܬü¾;WWÕÐ\®?ÿp®uí4{ºSãÐlÝY]—›jÓwçOÞôÍë¥uësRá^ºþƒ‚uÔõ“û5sÍx0¡Ö³æ0;]ŽnœÍL#å©;¿zê,å§ÔgSŠ ütã©ú;enµÖ>°îÛr8 ±S0qj>ÉÝw};ŠBõ ½ UÛ5gÑ»9x‡¼};ÝaÓï‡`¹TóG?y:o¤÷&˜ß­»þE]&ж—ãñÕAŒÒÁj¥Z·÷u½/?v§æ_týÎ|z;:ÒØ°ÆfhÝé¸kܸë_\°Ôz¥–u½ \ßþ7g"NyÞOܵçêÚ¿Bå«`ilB ˜„‘„­=öÌã¸æ@æ )UÖ 9yŽ€IÁ(±JÅ5<–§T`¬© M55ŠÖœR£h”ºäRê ®á1ÚŸúÌSßÍïÝ(yq(¬ ábŒÆuX&Àá &èq,–Ñ1Ç+à„±N97Î8Nüœsk`Ëq8­ ^—8%Ç àŠ½FMq.â†5„Sâhú@ìkO × Ápý$Áƒqù1¦/]}Œ©Îú/þÄ©ÿ»pÒ^`ÜD3F?©ìx”‘ׯ[ë±a ¯³1´ecÔÏŒ×Àäµ!/²„1êg)câdÜ?4dâ­K^˜|É ÆÐœ•ŒáQV1¦úÔ¿‰±'²š1tæ¬?ƺ9ëÁÏY?í¡œõÇГ³þ„rY‚ÞsÖŸŸõ'Äg)4ç¬3Å7ÎYgD¹¬3¢\ÖièÇbŸ-z±â3z´âs ,>G|ÆZV|ƾ´â3Öµâ3ü´â3qÄgônÅgè·â3tZñ½[ñ¾Yñ™ê‹ÏÐoÅgè,Äg¬[ˆÏàâ3ø…ø =…øL¹â3z/Ägâ‹ÏÄÏød ,gz)ÄôRˆÿ؇…øO5ù_±T“ÿ“‚êˆÿàT¼V *ŽÇM2G˜çªZN(:‘pTã’y¿ šË8úk‚n":÷qâw½{¿¬ŽÃYôÐ-7]´Ý×ÁÎ%ç# endstream endobj 112 0 obj << /Length 867 /Filter /FlateDecode >> stream xÚ}UÁn£0½óÞC¥öƆ¦Š"R»­šjµ×œn¤"’ú÷ë73iwWU çñ›ñ›‡±¯¾=¬'®žý$¹ÕêчóØúIõ}sˆ®®ê¡=ï}úá}ç»ËìñN=ŒC»ö'u]­êU¿;Ýòªo_Ï¿°>'•þe×P°Žº~ò¿&¾÷&í¤ÝOŽçƒ''3ÑHyÚ^õ – Sê³)E~úñ¸ú;enµÖ!°ì»jØ£±c4qjz‘»ÝõÝ( Õ3ôF&VÝ®=ɈÞí>8„äõÛñä÷«~;Dó¹š>†Éãi|#½7Ñô~ìü¸ë_Ôõga}>^=Ä(-ªóÛP7øòc³÷júE×ï̧·ƒW1 kl‡Î›Ö›þÅGs­jÞ4‹È÷Ýs&á”çí…» \Ý„W¬“bÍ ’MLS!"q Ø# uÀ!`NØÈÀÈ©²ÎÀ(À( LF…Uj®p4¯Á¨9¥cIMh ,ÁhP´á”E¤4ÒÔp€Ñþ¥Ïbvé»ý½Å¢ …µ!\Î€Ñ¸Ž« 8!\Ã=#ŽÃ2:åx œ1vÀ9çæÀ–ãÄ/8·v‡Óºäu‰Sq¼®ÙkÔ4 ç"nXCI8'ަľ&ðÄpý ×Ï2<WcúÒõǘê,ÿâ_8Í¿1ðbxÏbÚ ¬Ã€›iÆè'—Ý,ym‚µÆðÚÆŒ¡Í&ŒQßÎ/ÉkC^ØŒ1êÛœ1q,÷ V¼ uÉ 3ƒ/¶d Ͷb l͘êSÿ&Åž° cè,XŠu ÖŸ‚_°~ÚCëO¡§`ýå²þ ½¬?'>ëψÏ:sh.XgŽo\°Î„rYgB¹¬ÓÐÅ>;ôâÄgôèÄçX|&ŽøŒµœøŒ}éÄg¬ëÄgøéÄgâˆÏè݉ÏÐïÄgètâ3zwâ3|sâ3ÕŸ¡ß‰ÏÐYŠÏX·ŸÁ/ÅgðKñzJñ™rÅgô^ŠÏÄŸ‰oùd ,gz)ÅôRŠÿ؇¥øO5ù_qT“ÿ“’êˆÿàÔ¼V jާ M2G˜çêFN(:‘pTã’y¿ Úó8†k‚n":÷qâïzÿ~Y†²è¡[îrÑbtßDÒÓçn endstream endobj 113 0 obj << /Length 866 /Filter /FlateDecode >> stream xÚ}UMo£0½ó+¼‡Jí! ᫊"R»­šjµ×œn¤" ‡þûõ›™´»«ªÐóøÍøÍÃØWß¶3ÛöÏnÝjõèÆþ<4nV~ß‚««ªoÎG×M?œk]{™ïÔÃÐ7[7©ërSmºÃtãÉ›®y=·îÂúœT¸—C÷AÁ:êúÉýš¹fœŒÖzÖgãùä†Ùdf)O‡éÕS¿`)?¥>›RTà§ÆCßÝ)sëç}`ݵeDcc0qj~‘»?tí Õ3ô&Tí¡™dDïæèBòömœÜqÓíû`¹TóG?9NÃé½ æ÷Cë†C÷¢®?è Ûóéôê Fé`µR­ÛûºÞ—»£Só/º~g>½œ ilXcÓ·n<í7ìº,µ^©e]¯×µÿÍ™ˆSž÷îÚsuí_¡ŽòU°4H6!L‰@Œ@ÂÈBŒ€Öû@æq\s óŒ”*댌C¿Ÿ¡³Ÿ±n!>ƒ_ˆÏàâ3ôâ3åŠÏ轟‰/>?ã“°œEè¥ÿÑK!þcâ?ÕäÅRMþO ª#þƒSñZ1|¨8Gxp4Éaž«j9¡èDÂQKæý.hÎÃ௠º‰èÜljèÜûeuêOÈ¢‡n¹ËE‹Ñ}üMçA endstream endobj 114 0 obj << /Length 866 /Filter /FlateDecode >> stream xÚ}UMo£0½ó+¼‡Jí! ᫊"R»­šjµ×œn¤"Bý÷ë73´»«ªÐóøÍøÍÃØWß¶3ÛöÏnÝjõèÎýehܬü¾;WWUß\Ž®8׺vš=ß©‡¡o¶nT×å¦Út‡ñÆ“7]óziÝÄúœT¸—C÷AÁ:êúÉýš¹fÖzÖgçËÉ ³ÑÌ4Ržã«§~ÁR~J}6¥¨ÀO7œ}w§Ì­Ÿ÷u×–ýƒ¹ˆSóIîþеƒ(TÏИPµ‡f”½›£wÉÛ·ó莛nßË¥š?úÉó8¼‘Þ›`~?´n8t/êú3ž°½œN¯b”V+Õº½¯ë}ù±;:5ÿ¢ëwæÓÛɩƆ56}ëΧ]ã†]÷â‚¥Ö+µ¬ëUàºö¿9qÊó~â®=W×þê(_KƒdRÀ”Ä$ˆ| 4Àhí±dÇ52HÀH©²NÀÈÁÈsL F‰U*®áq°¬À¨8¥cMMh ¬Á¨Q´æ”Ek¤Ô%RWp ÑþÔg¾˜ún~ï±È‹Cam `4®Ã2ŽW0A/ˆc±ŒŽ9^'Œ-pʹ)pÆqâçœ[[ŽÃi]ðºÄ)9^Wì5jšˆs7¬¡ œGÓb_#xb¸~ †ë' ŒË1}éêcLuÖñ'Nýo ¼Þ…‹öë0à&š1úIe7À£Œ¼6ÞZ cx…Œ¡-‹£~¶`¼&¯ y‘%ŒQ?K'ãþ¡!/h]òÂ,àKV0†æ¬d ²Š1Õ§þMŒ=‘ÕŒ¡3gý1ÖÍY ~Îúiå¬?†žœõ'”Ëúôž³þ”ø¬?!>ëL¡9g)¾qÎ:#Êeå²NC?ûlÑ‹ŸÑ£Ÿc`ñ™8â3Ö²â3ö¥Ÿ±®Ÿá§Ÿ‰#>£w+>C¿Ÿ¡ÓŠÏèÝŠÏðÍŠÏT_|†~+>Cg!>cÝB|¿ŸÁ/Ägè)ÄgÊŸÑ{!>_|&~Æ'a9‹ÐK!þ£—BüÇ>,ĪÉÿŠ¥šüŸTGü§âµbøPq<Žðàh’9Â> stream xÚ}UMo£0½ó+¼‡Jí! ᫊"R»­šjµ×œn¤"Bý÷ë73´»«ªÐóøÍøÍÃØWß¶3ÛöÏnÝjõèÎýehܬü¾;WWUß\Ž®8׺vš=ß©‡¡o¶nT×å¦Út‡ñÆ“7]óziÝÄúœT¸—C÷AÁ:êúÉýš¹fM¨õ¬9ÎΗ“f£™i¤<ÆWOý‚¥ü”úlJQŸn8úîN™[­µ¬»¶ìhìÌEœšOr÷‡®D¡z†ÞÀ„ª=4£ŒèݽCHÞ¾GwÜtû>X.ÕüÑOžÇáôÞóû¡uá{Qן ô„íåtzu£t°Z©Öí}]ïËÝÑ©ù]¿3ŸÞNN…46¬±é[w>í7ìº,µ^©e]¯×µÿÍ™ˆSž÷wí¹ºö¯PGù*X$›¦D F á@ä¡F@k} ó8®9ù@FJ•uFFž#`R0J¬Rq ƒeFÅ)kjBS` F¢5§Ô(Z#¥.9€”ºB€kxŒö§>óÅÔwó{7ˆE^ kC¸X£q– pD¸‚ zA‹etÌñ 8alSÎM3Ž?çÜØrNë‚×%NÉñ¸b¯QÓDœ‹¸a á”8š>ûÁÃõ#h0\?Ið`\~ŒéKWcª³þ‹?qêcà…ð.\„´X‡7ÑŒÑO*»eäµñÖzlÃë,d mYÄõ³ã50ymÈ‹,aŒúYʘ8÷ ™xAë’f_²‚14g%cx”UŒ©>õob쉬f 9ë±nÎúcðsÖO{(gý1ôä¬?¡\ÖŸ ÷œõ§Ägý ñYg Í9ëLñsÖQ.ëŒ(—uú±Øg‹^¬øŒ­ø‹ÏÄŸ±–Ÿ±/­øŒu­ø ?­øLñ½[ñú­ø V|FïV|†oV|¦úâ3ô[ñ: ñëâ3ø…ø ~!>CO!>S®øŒÞ ñ™øâ3ñ3>ËY„^ ñ½â?öa!þSMþW,Õäÿ¤ :â?8¯ÇŠãq„G“Ì湪–ŠN$Õ¸dÞï‚æ2 þš ›ˆÎ}œø‡Î½_V§þ„,zè–›.ZŒîëàÍçP endstream endobj 123 0 obj << /Producer (pdfTeX-1.40.25) /Author()/Title()/Subject()/Creator(LaTeX with hyperref)/Keywords() /CreationDate (D:20250208182106Z) /ModDate (D:20250208182106Z) /Trapped /False /PTEX.Fullbanner (This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023/Debian) kpathsea version 6.3.5) >> endobj 2 0 obj << /Type /ObjStm /N 92 /First 752 /Length 3583 /Filter /FlateDecode >> stream xÚí[[sÛ¶~ׯÀc<Äìd:ãØqšIs³[S?(cóTUŠJœóëÏ·E‘º8R=™ÓsÚÅb÷Û]`)‚‚%Ì0•0Ë„NXÊ„3L$L9Å„b:ñhgÆáâ˜E‹ð,•–IÁRc{R2!n1HÁÐ#”N™#å51Æà*põ–)ÐÛÔ1z¯=S ÷©`à›*Ós¸8 £D*¦®Ö2J™@ ‰kj™A»F?K“f ®ý “…v¸¦ªgH(c%I$³`) š…@“Xh.Iw  DÁ½N1 5&½ñŽT‰žE»s’áOy0F*…ôN(A“ã á¬ÇZ:ˆ. ÐÓ ÀZ­0TÔZºžÇ8­ó’éÔ9æ¡ÉàŒ‘‡jij€³ÂB—xÏ<±8iœ3K«z©+@ ˆ¼Æä)‘Ô ,›¤T‘,%IÐL KÝ@Ò'Ô Ö0#Z1†±/’ž¦–4hKæ†ÑX@R €µFÅBYx‘¢@!RpÖ˜pÓK5³àFJ Â0˜†L¨bÉ?PÑÐJ . ¼h °!Rf¦NG>EL¥‡ª˜ —Ðx⤄6=L…š$¥%µê=xÀøã‹ó‚ñcvo– «¼˜ôÅûé§Þ½ß”³øw¿%IrDEAÅ„ŠÏTdTÜPñ[¢º^Q1§bܳ6AÞpX´H*ŽÖe™lÄÙ*Р;Õ’ûe{ŠáÙ7IÚ‘ëKðjè}K^Y»9HS6Óî× U ¯¾¡¨ü *:múò.ÿÙ7”QëÊœ7p̺\ו ÍŸÚ-ÓfúåjÍÅ–VÈ6{Þ¬¹m6ámpîæó»`»h£‰¶Fç9nD7ZÌþáök{îªÁ(o&]Ç]2Údú;ų¼c2›é lÊÈN^ ¥‰€l·uÝQòëÈouRב,é…à =ÕrQW”ÿÔuMÙÕ1Yó fƒCŸ0~žÝT«¦_ñ4®zšvûxZÍû¨ÌdñãA•±{Ç?"Ç6‰D†ç¥H̸£­}çy5FÏ){\¦WùpÆ^Ì«é«i4š³’z-V€z®‚šºªÔC²Ð(züùàšú$Ü}0Ë‚9øÏÙøsVåÃA?š ‹Q>¹¤L¿VèrtDÄ#†Ì­Iô‘]3š¿Í'‡“Y¾ì>Î?}Êaúpñë|2Ÿ!æÌ‹*gŸ*<ÿh>* ýl–óËrð9ãƒá¼Êø0/‡óëOãì†Wùx”ñëÁ°D@},3Ð`È`8„ø(dz|ÆûèQö‰—˜›aºñxÐ4^Í'—ƒr~=Ì+^\“ìw>¿Ùt0ÌÚn­ýnQ¸të¥ vÝ·íÖ#7}÷âã¿hu¡áO®áåö.l“U6þïéÁv“Û¿››tç}¤Kzû>²‰Œ}mw¤…(xbÞE[ø­›C+ê–ÅztIfÜ]¢Ë­E—ý‹®V,8½Œ˜Éîî)v“E]Ú׉ÞfÑ­Öú¦¥×­¨˜½›ݪùVÎî»?lÞnW䃡¬ ÉIÒW¸“ºôŸòŸrY’_ /ù‹•K Ù×ÈïZF>±ôx¶ðÒ(Ñ‹öB7í[æA¯˜Áœò}„tâ˜÷Ä+ö Oú¥Gi±¸˜¾¿ÌRS òZ÷éWfO¬BÝ+f%Mç<Æ1…”4µV4rÄÒz±Êv„ÿÓõ\ÁþôjnYš9¡Œ+Cš’»Ãß‚÷IG¾R{¦§Õ¢=ƒ‡¨Ë8:ÒÇz»=Özí‚gàËHÓé Òµ¹Ý¥Œ|bgi—:Ä`Ý¢I{—„U]âßÒhClX#‰ÂÓNéè… ­¡¾×»…5§Øã,΀µ!­ñ 3DºPŠ¡i:M¦mb=¬:-¸b_mF­ÃÆz4_›¦cV¹'š©íµ¹JiñTa¹ˆ†k÷’2±J¸›D’ ø”f¿CùÄÒaÔR[ÚXê–°ÀÙTÕ›²Ó~<£[EòÒ~+j*e‚;'2r%L z÷ú#G[ó–aÔ¡/i¨BI¯a››Xš”|¨ A¬ÇöȲÝkx‡èÔ%Ì :45¡ÝŒG-^ õØ}¤QðA*-íC¡Þî%…b-”0žS”¿`§ .B;˜t”’Ä2µ†ü¹Õbs@ç°ƒjKîë±=rl÷_-\=C¬IïZ½‘:´¥¦í|pS³äúd‚s:Ú½c}Ù5õ‹•ß„Ž³Ù°Ì§xªOVõ/B'‡ÏÞýpôìÙ‘ c<¸œ1)†gºûJ²ûxš¦L²ƒOv‡3úÝÈòh0ý9Ë/¯pëžï²Øw_Pç“j0·‡“K<|ßh8«²ë7ð3<Ö£´`r5(é1î¿á_âô'9ù´ýðø-mž>9{ôøåg'ß ™lÑGJÅî+zùY*M[¡¤£ÝnW(Y¨c’–:Z·Õ9âç|À‡|Ä3þ‰_ò+žó1¿æ^ðb’ñ)Ÿfe^ŒxÉg¼âÕU™e¼úRð9ÿÌ¿ð›6©Ø‹7/Þ?zú4b¡õ6,„_`a$&øÎX‹¬AaA­z­ôФj¥}qúîí(}ú ëե鄼Z0A§jð·”öi×£Óý•VI[éàöIx3ö Îð|„C ‹q1Ay}=¨ãSŽ¿Ï¨ó2`tõuz•MÕ¿øï›&ü†:ú8¦ŸQ››’Ġβë<γÁ³V`6ûÀ|z~òæñû³Ü³!˜±ph©–ßæòY—à DOr¶&È–~ö•ÿ;+‹n/W{ytòâ0bà¤ß‚Ó_žŽ9`~O ^…èº ®2…ùç+ËÇ^KéÛ§ïžR$ßI6z–N4yKO÷-õ„è¨G·zRÊ•½!Ý)”ÂÊ`çSÒë`ëå`ø{V…¨ëÑÿ‡MlŠñxP’Oü1Œyv3®QvI?ôfe;ÚÆœÞDtÃ~É s„Zœao–îùd”•³aQfqA[s5‘ìµ–¿zûæá£g0Æù-Ɖ_Ãé»c·eídWü;Á¸¾¸Å…m’èîfCÌ>ƒb–߬-_›!Ýk§xõòù›Ço"¤ÛS…D. ç Óï é"MXnŽÓàXa±êjºa±ÞòÊMØ[6 $° DA±èE^Y‡ ÓÉFïÇÞ^¸6d´’ò`˜`H²V´[°z°?Y3Ú5:E°{Ü£–»Uˆ¿­u|âÁ4„ÿQ\@Ò†ŠÇ,z§Xö±0ïø[¤0m—ÄæÞñJls­ØÄ‚_oÆí쬽ÙNéôhßͶy±ËûÖå[ÖÕ »ã‘tF6¼C9ÉËYE¾@D{ü—AsfoóQu5£s¹ö¼x=R#ò„-[Öm­'É+"ÉU‘´íH”4ùúDQóØ'ë"úýE\Ï]WDÔk"¦[@ózÓýE\Ï4WD´k†µÛD´ßQ$û‹¸ž¥­ˆè¿aè–ˆnÅŸ@q-‰êŠHGÃWdôb›3úd”û˸ž ­Ê¸0JmÃQì £Ú_ÆõaUÆõˆÑÛd4;Ȩÿ„Œk;k!“ºm2ÊdܰKÒ;í½ÔžC"ÓãOóѬ9‡WŸ[ªO^Ô¯ë]}ö¥ÃæÅ¼cãšÕ²²\•¾7qÙ d½„Ò§(¡V¿$_ŒzYfŸ™ì¢Gšf¤Ü8ò9½ù–~ÃH±)|g$}ï°œ´í j|[£û+* ×°×öºÅ|%îâ@Õ L¶ô-åjq;L<í&q؆¹0ÅfD"˜íµg!I@dAV#¢Ì)µ„?Ý;.†÷ϪAYÐ'DäF÷¦ð<:e­Lë^ÐGAË{u@û,ïõ}¼³¼7ô±NðGþK~W+“-¨.Vj}GÏŠ´Ï®‹´nZùÀÃmh&r±¡’ ³ÖΕKµ*qKšUêuÉWoK·Æm…bµ¡aƒ]D‡ çÄkz¢Û˜aá­öå£2ÿâ²W›æ<õbÑhyYÐQÈÆ /³gXºøëY¶\a^L³I< MŸ«Õ“ýúãø endstream endobj 124 0 obj << /Type /XRef /Index [0 125] /Size 125 /W [1 3 1] /Root 122 0 R /Info 123 0 R /ID [ ] /Length 322 /Filter /FlateDecode >> stream xÚ%Ò7KÄAÆá™ÿ™Ó™sÎ9ë™=Ïœsmµµ³ÅV¬ü ~ A±µ±S‹+ 1íolž}_˜eY‘_OÄõù8ÄKƒUPð VÀË QPK 1P‹ qP  PóIà‡dÈT¿Ý/Ra&`¦a Fa¦`V%:l»¥qa5F r òTü‘¢R°nsUP¨’sfµ Š J Te!è6væl¤ªU¶n­ÖA Ôªìþ¿s34ªì[m‚†Vhƒvè€N@t«\ÛnÊÉ©¥^•û€¥>•¯Kýª¡mKª‡c–U/o,Õ‹{´4¤ÞQ‰¥zO¢ÞK£ãõÙ>w¼M9Þ¿WŽÏ=ÇO–mÌÁ¬ÃlÂl«OïÜKÙ—?ø0ß endstream endobj startxref 201069 %%EOF geometry/inst/doc/MODIFIED.txt0000644000176200001440000000162314664417655015574 0ustar liggesusersmodified function file line# date by reason ================= ==== ===== ==== == ====== qh_exit usermem_r.c 45 2012/04/03 David Sterratt To fix warnings about exit being called qh_printf_stderr usermem_r.c 71 2024/08/26 David Sterratt Use REprintf to print error messages qh_printf_stderr usermem_r.c 74 2024/08/26 David Sterratt Use REprintf to print error messages qh_option global_r.c 2234 2024/08/26 David Sterratt Use snprintf instead of sprintf qh_option global_r.c 2236 2024/08/26 David Sterratt Use snprintf instead of sprintf qh_option global_r.c 2238 2024/08/26 David Sterratt Use snprintf instead of sprintf qh_rboxpoints2 rboxlib_r.c 375 2024/08/26 David Sterratt Use snprintf instead of sprintf geometry/inst/doc/qhull-eg.R0000644000176200001440000000315414751720222015475 0ustar liggesusers### R code from vignette source 'qhull-eg.Rnw' ################################################### ### code chunk number 1: qhull-eg.Rnw:27-31 ################################################### library(geometry) ps <-matrix(rnorm(30), , 2) ch <- convhulln(ps) head(ch) ################################################### ### code chunk number 2: qhull-eg.Rnw:43-47 ################################################### ps <-matrix(rnorm(30), , 2) ch <- convhulln(ps, options="FA") print(ch$area) print(ch$vol) ################################################### ### code chunk number 3: qhull-eg.Rnw:51-52 ################################################### plot(ch) ################################################### ### code chunk number 4: qhull-eg.Rnw:56-58 ################################################### ch <- convhulln(ps, options="n") head(ch$normals) ################################################### ### code chunk number 5: qhull-eg.Rnw:70-75 ################################################### tp <- rbox(n=200, D=2, B=4) in_ch <- inhulln(ch, tp) plot(tp[!in_ch,], col="gray") points(tp[in_ch,], col="red") plot(ch, add=TRUE) ################################################### ### code chunk number 6: qhull-eg.Rnw:86-91 ################################################### ps <- rbox(n=10, D=2) dt <- delaunayn(ps) head(dt) trimesh(dt, ps) points(ps) ################################################### ### code chunk number 7: qhull-eg.Rnw:102-106 ################################################### dt2 <- delaunayn(ps, options="Fa") print(dt2$areas) dt2 <- delaunayn(ps, options="Fn") print(dt2$neighbours) geometry/inst/extdata/0000755000176200001440000000000014664423004014517 5ustar liggesusersgeometry/inst/extdata/overlap260-5034.RData0000644000176200001440000000060413460563614017732 0ustar liggesusers‹ r‰0âŠàb```b`fef`b2Y˜€# 'H¼ÀHðY<>‘-‹`pð†Ò^7!´„塀Û=M¨ŸH;CéP( ¢âW­Zu®ÔÙ!¬Ò t"„F³™9%3Hñ‚” ¡)á*ÉKÌM-²…¡êþ±X-D cŒQ e0@T¡yÓêM Ÿ˜¥U9J>s­&-fuðIX•r臃ëŽ]ÇN;øþ×óx±ÜÁÇlž4Ç,&ŸÀiA{mÌ|rÓÎ;~z×{Ic>(8¼[¢dÖiß4ñƒûh¿ÕuÏ@ü+?Ñ­'eEA´X»6“Cøñs7 ‡ˆŒ­wŽÙ‹8DË@é«{— Îyàv'6¹#Í!zïm¥ O"*„X÷0.vˆ˜ü¨Éa{ÄgLÿ‘ÂŽv¾f.ÉÏR o3Ú$ù^ú¸òšÆL¨9Œ@Ä‚.™…^²Y|™Ú×¼±™é?¦ß0\Å\’Ÿ¤@Îb´Hò½ôqå4%Œ™Psx*ºdBRå ÈU©ñgeometry/inst/extdata/issue35-intersectn.RData0000644000176200001440000021403413454046274021122 0ustar liggesusers‹„Ýw4×ÿÿø{ï”D¢$¥”(³nÏÚ)-E¥BRZF-‰"[ …ìy{Ø#{ï½çóio?Ÿß÷Ãûœ×ë¼Ïçòt<èi<îÃé~¹^8vu?ËU****ZzZ*Ú•‡t4+QSÑQ1ÿÏ+Ït VÞÌAEÅè9S¾oâˆëeÃë{ná”Κ¬'¹ï-­ó‰êÌqÝé®Y‚ñª1mU $ê´ð;/ü%`r”g¨%¥…D}}‡ã=ž8Hf Î*0ì¸;;+D„O"J<{B±oû“¦ŸÎ05Ñ\vt£‰V™æ™¬,tÚO½1hØNt;÷lÂIôû7ÅÞáxÜÂS%waló4J,Ð5…¹{ÙÈ:˜fK¾´+fç%µf|Î {Šm¨CNÕ?‹ ¥Çγ_‰x¬œTûkËÝ .å<ñä7ŽðÃ[nF?…ö§]û” R¶Þono†ÊgÞg„êÂxØ÷7Û8ÿ yê0×÷¯¯±®Hñð»t^h/ñ{©÷ Z^ŽöÜ«¼ gEƧ€|ÈûÈ çÐm?#YWK£ÙUZ[·\&Qå—Gø­ó€yöïú¯ Ê‘,ži•—‚#JM3ú«‰ìãò÷cÃŒïf–{Lm“ò™Oæ‚î•ø¥‹íêó¹›’ú &F %ù¦+[Âà¢cÏ ‚å@£L.7º¿Xgë¡ç…r{NÎ 1bÆÎcÅ?÷ïÂ4þ’Elò¸vÞÓ— ±ˆáÁ>ó^(ùý9Ò†µûµy¿@¥Oô·ë»6Cß³Ù‹ËK˜a®6NþCæþWÔlI4‡g.[| Ç2µší™_³ ®“Ç…ìz>œfßvt¼)ÃŽ¡÷ó&›ž`áÑ_ûÏ=Ï[¹®ÈÎ$ssÿxÞ° 7"ÑÆ¥0„‘˜âÅo$¶ ¿ƒ7@ÙÀ“Çdë! Âº*¿&&¯u>8§<¥»:Úv& ãŠz3-ŒÚ=™1)j‡¾pºüwŒPíqÊ$t·'48=̯bJ—ϳ‚±& S¾Û¶}ˇÝšˆz"†Öß®âg{ å¾Ô?WÃðŸZæË÷0™­÷·ÑÒY-¬®}V™]}̽_h6??e›ˆí÷ó¿ŽFlÇdFá X-º±ŸŠa šû¥M´Ô°î,§¶¶þhcvo¸.lÝ[$÷L4¬ÇžvÆGep8Èd\jŒÇ@»×ïù¢¡¿§ñA´Ö+(û À¾üø¨«çQ C“—óD%´ÄDSfmþvÝÊUZý×Û\ãµ…CF¥¬*$¬sݤxá=öI{K%3 …ëˆæåœ<õé×®ôn†Bs¦…&ÊÐ6¾Vmš`ýÖtŸ±‰`ªc“ü#-A0‹¼ÿ¨,x›`y~Ôx„Í›`ý/–‘ÂI°ŽU¾²¾JC°¸ä]3B×3òÛNÝú‹¥é›Î¿ôÇŠ¹6î{ß0ç£W³]H-Ö¯ï5À¢cRBëY±ãƲ[†Çj_avëFß³†Š´ð[ägˆ>öäÑI݋ۖ3fšŽ@¡¼]ÄcohtÝg¿ÿK6d¥ˆLI˜tÀÔpÒL W)ÖÄ6ÞŠu¸5>—k¤NA¿ž§Âö%P¨‰—ïc†èwcG—Ù!ä÷ûEQ;n¿ËRü>4Ó¤’nF–ŒÂ+ Ž;!êèH•)á÷'Ñö„‰Ùé ÀÀ'‹fçèM»Æ1Ç ä¹™Ðs $šÈøK² ý3—´ZŽcî7%×iç Ö‡§Î"X·êz—Ém hú7EžûRÓdËÝçbÚàCHO‹ŒÆ}œ{Ây—ì9AÐ<Úù0ŽìO0”æy i·Ã€ã:Íéa˜8fW*® ‚®Ûg™›ÖÅJë n_3ËuÝë°Å{äõèoo‚ÆiׄJmASn¥\Y@0ÛÔ·E]ûN°]úLzwÓLe¥§®‘ †x½mU×u1ë,Ëñ±GX"¦$q³x>iÕœò =9Ïm"ÚdÉVÛœä Òð9Ë&ÿç˜ë6¢}°–ºüÜT¯/$*¿*0йc¦×1§C¥XÿÛ°à×Í0x¾ÒòUâ28>¹Èß0F¢:~ëݾ}X+²^ó{S%Óɲ]<¼b>K) èKŒq¢?F·Ü ˜"w1ÙM0ºÉ_ggÛSrñWcNû¬éG œÏ¬1Z%å U{"ûTSV Á~‘©/è¶Áî›?ÒíhGpéêý– #Áü¡*AÅg§ÆHŠH%ÁhŽÕQ‘Ÿ,иá‘ý54>]Wµ#û¶mÀ§1»ùÄB2ýd¬S¾ÔÚzš7™®ÓfÖ†ÚËÞÒËP@%r®\½½ù„.ùÂpÁÜ&SN˜4yl(ÿQÆ’»´åÓa8„§Ûñ…*8˜t>nÄ‘3‡àË/‚CAÈÇ‚­š÷ØÞ_oÄê³÷\9X°û ˆäÓþ…rkúû=ñXýýáæW)(<ÅD·zêjò]¿ŠºUè-JcÞÀͧ&âªP¦ö…e¦$$ø -ÿp´„ª­aÓMQP,óŒúXØYl×ø¨ï×­ CîSù·£dñ›1™zÊ3 ú´e¨Š­Í±Œ®F§W[…`,èc>wqÁÉ{«7¯-Á±Ù‡”ñ’™ ÏßY{à ‰ªå ·z$Ô(mú0jÓ ),¿Ée¯«áOºŽ€P””@9OS•äÛè Ú7<¸ ÓcAí#‰¤Gˆ¯Z[i`àué íÄFh+-ã¼þ°r´åDž§@gäSñVð9@‘rþ‰ÆøöñrCìIæ&< y~Ý,• I„j¹BÀf+‰fݧœÌC(åá´Œu'8öÝWOpªµûŒ•P°pƒ¬«©²5‰Våå÷³ÐnË^>Œóc»4]£S°g[¤IÝ<Ìîû“¡Le‹,ëÍ„¤¹°î¾ì£· 9.tbQƒµ@®rtœË ‡Æ€ÉÙóEXúÆØïåc>˜èxBlÞwúûvß(`€ét©V˺4èa.|”÷;’`~YaâÚú‚ +•¸~GçÁtLæâƒ§ ¯M|WÈQ5èi’°üòmʵ?Ù½ÿe¥.-lgŽž:­ÜD¥} ÐÖï.˜]ã d¡(®“†‡aæY¬^yj«Í…^ŒÅ®ö³qÛ,#åoOå÷¶p²ï=Ê¨ì ”Œ©g†ªÆ‡™e¢Vا¹8b¥É¨Rò–‹¦\-¥©‚qY’g×%_…CúñMúè{UK“šþ%¶ÇxÜ‹œ„&‰S òŒ¿Ñƒ©´¿ßò"[ž6¸É[7„ÓXvbÞµ›¯–µ—!w3åBÜú^l¼ÒfÞ¶š¥Df—”E ¢£ï`Ï€$ôÑyvÙÞ‡Iñëg|lN =zèô¡ä‘uûU{=ˆ¦Ë¿Jº 7î´-L{Í2® ð]ÀrâÝø‘’ ÿZí—/8²óv@ÙaáË>g0/(ê‚åÀ.¨iw³Î»à ‹öÕº—òs`üfþ)½ïm° 6|9€ñ<‰Ñ¨¬üå&‚s[!Ç«Î=ØZ&aFsRˆÄE±­*þò»2Êc+³Ã8çÙ„ùÛ$(S·k}Þ h³}9›0áŽQ6ÕÇóùAõ1Û¡¬oâXä¨s*ôd=6MÐÝÒòú„}ªz©õT$Ök§4&‡ü` ¾]ç§“‰jTD¸c—8V¶™Ï›>¦q‡;\D í^8‡D`ìòÏwM×íν½¦}"ÙóB«WžÇ—ŸráaX”s35‚‹¡q¿e§ŽÏñü|1â Ýoß|dMr€žÉëº.é`‹FwOµ1A÷B9û¹–‰ßÏFÓo„¾góc¬¾à'5RHǤʞ֑¿:ýƒQ4Mv¯Ûk§:Ó«)cNÝûcZEp¼i(¡ÌA'^-½¬| ‡K{­Þ ŸµÂY%êî)˜|¤ú¹R3/ïùmq>®Ó™>ù÷‡%¦Åh‘»;˜ä›±ÿÔÜM0z¬+/MÅî›å‡dL¡ùøŸÅ)c¨;rÈ6Õÿö|)©‘«€‚î/F¾Áêš’•8Útõ½ÖÈè<ùàL„H,t\•‰xH¦lß¼xu+ ¾òÝHK]‚½D÷fûué8½ÞÉCÇú .°ï=[ľ€ãÓBnêÎXƒÏ«gaG0¯°Ú•·8çúÛaŸË ŽŸÞtu™Aç„BceULpÁðÑÞ‡õ=8]à»xëh<Á4.·ë<ËU³Q‡¯‰º:êlþÓR¨á`=º—§:bÏ<>¦ÁuçïúšœaÇ|S™7¸»Bß„h–0BoÇ܈ЛýЪn¡|ƈ §î×êmYÔ~»¨/W^Bíöû÷üä!ÿs<-ÃG_ô,a_7_§™ôî¶ßÆáuuú®Ô„Ù¤®¾Φ%ùx<ÅüÔ¡ ­Å8<•|¾Gï•Vj*ãÜö(f;ÏŸ86.k£þbåã|ÿVâç‚•‹W8$ô•HTë´ëì¹Iô—œ8ž2$XU¸OªOÁî”yîÙ¸>Ì2žo:uXZ.=”漄ÆRnÇ^ŽÕñÚ&§þ‚49çžá|œ´ýT¦q‡š=]ÞAh)dzQºåŸRÆa&ÏõÙ­±\xýÊVæàE¤Y&jÔ #1kÃ)ÝŒ}´¬ÚÁ× £H–Ö¸è7Ö¾5“13Åñ+Dü`ð‚f× ·[(,³=D®ó»qVIb.AîA3 Sã›ý– ·i!ê×ÅBÿ •¦__@í€iÕ~ ˜ g?Õr Æßé˜Ê ê­ÜßAÑ Ûö@ç]±'Ú³ ìEÇ ëìàµ~*ߊ{Æͧ¤ÃQßz‹¶7»°aúZ¥éËm8DåÅÈÁÍ„CåDãÝoÖ*zÒ2éöQÊŸ±HáŒýÅ‚&ê1>Ü*Ü…]ªª·jòb»ûÇw»›ëq@Sci0ò1’?uÖr'¹cïµJÇ­Ÿc¹Ò+ú~åE¬ô]ÈgZÀþ¯ç®~L> n™9ZâWîç]o”^2vb¾lÝ“¯FÃ@žU|f²¿†>Èν 膲zg_Þ)#1üZŠëß…Å‹œöûrÎC˶ˤ2¡þýž»±¦t,þmº-Œ‡w ÔS`6âÇí90ïGr‚è HÜwÒÓƒ˜øòÑí4•)öß+)qo†òS¿¯‹òàȾ›µÛ ®¡ýY´QÔ3cŽhÑzœ¾Rëics—T—vy|Á©ê$ 1Á™Õžç>op‘ǬHñ«.–' /*$h-·3 ðá¼M§ Ý]œàÚÞp}^~¹tÝÚ§£¯ëEÿŽÝE[¯Üû}ÉS¨r§O\ÊHĉ…ŠAÙ/þ¸xçÈRz|A«³þ-Kì(Ÿ´'ü¥a6rë}¥&˜N5ONÚ,„í§{îM@áâ…–ç mØs‹R”Ôà }==t·`ìo¢öý"^‚®Q¤ã˜Åô)]yå‚d76µO;šžwŸÒcT¦BêjÐÁe)]íóÓØciìۡɈËz:6¹Ù!™Yéê :ãÂEñvZȬHœ}&ÁÊ-F½zœªSÂÄ'UÕ·GNC…ûÓ ï‚ ˆ€È“¯î8éÇmòc¯´²eH,j}ÄŽ:QßË,70†íÙ›45Ī÷ÝŒŒópvªk=ûõg8¯ÄqÇòBÎ,LZÄfœL¬=è,õÔJÏÛkÛãÜâ¼Õã™X!¡:õì ó‰96ã9ކ}{OŒ¡ŠRçvæaâÅ /—j÷öݵ›lÁ‡t²Õ:qÚófù¯{äû™ÄðçäÀkü°Ô±a)Ü·Jå^ÌÞÔȃbþBL ]ÄüY?¿×Ø—Pì[poôYž¿X$ˆMújÔ.ÓnØkÀ—ëcK‚iO¶€Ì>U˜ xö·j”ÄüÙíw¾Í,MÝ­sR'Ϧ³söî‚Λ Ô.a¸UTõ‡“HÙ³]è…t/3—KI•Æm‡î]mÌÀB‘‰GŽÄc–‡¾Gèè]œ–Û¼?xYà4»®gƒPs|Ÿ±´/Nì[tðg«À¯!ÎâM£Ø!5ÜWlª…jKº´);!yÂIºF–'„¯~¼ óǬ •VÆeó';ž/•ãàÎOO:wt`ï+òö½û[`ÿ¥1­dÞc8{ºíÆ;ãtœU°(í?ˆóåÇ.dÝÀ±s†.^Œ8fY\YúRž>«ÿ¾,…!4__í׌…Fã” ì1a5«æ‰å«5P3øãªø±g+ógúkÁR#l.àf<ŽOwˆØÿGJvÓí²ç©8ïÊ!/úm/A•—mŸé‹%¿¼{4UÈ8z¸`CõÈ1¨})•Q®·é‡6„”¨Øa§ãÕƒw6 ÀX~ ÓÜ¥i¬ïˆ!N`Ý;ÆÓTl@yÛ}G±rîVBñŽB œ<""*ÿ+C*š>Ñéàü©*o÷Þf÷>g¥xgN®öéb;ŽÄ½j_Ü‹3Mòl¿ÌTqö¬C³g3Ö/<»e‘y“%„…<0âdg®Ní‘ã8éñëð勆8ŸÊuƒý>N'kÝØèŽÃCöèoÇú Ž€;êò8ÉóXÿ®·ç_XrjŸ¼íñ%œÐMùe# ¼ö©Ÿ”a¦pÿÁŽ¢G+?gº›®]߃K†ßž~vyãšOîÆ¹¼ç“~ûWöq¡QU玸ÌûM(¡Æéâ rsITnÃ&œ$6a‡ÃM0u¨¾þ7kLä[~öB*ø5ޱ%q½8Íx÷Ês\è4‘müÌŽ?Z5O•äÒ“¸ã³dì¤Ë1ãâ“’îÊëê…[x¥plÝŸóŸ>c—]Ø™ó¶¯pé×øÍf+œÉùR¡ó§ÄÙo±U­#1˜F þeä寸à@Í(ø£ M{ù‹^â_ã–ß_©!¥ÑCŽ'6Í{ÚùHaÅ„iaÔÓçØ5üþšÅÁplÈ•{Ôt¦[öÛç^à»ms%F,U¡ýͦ#˜(½š´; ÕèhÞ£¸Y"¤8~Kü‚Æ{§,ëͶãäž»SCŸ­|ŸQß7¯ÃÖ‹YÐëzü N„]Áì©Kem¯cWÃ{Ð`’é’Ð; s©š¦í9ÝjoÎ<| ½¸>µ³TKz~ô8Q!‘üºô'!”jc¸›qAó¾TIM'Œ¶´«(S0×J3úëUl¿bÕ·Ì탓ïÚŽ»(œÆ _Y/­íãH¦3Û½Óâ!ÖÝ»¥}å#¶|ŒšÚ]5!#",°(çgÍõ»œÐ?´þq%Æ„-3¦¯pÅÇz£%]'L ­3êzÙÝí_EîGÁø)Už¿}0²`´YDâ ôÎÇ)Û^ããƒIP+&YiÓÊ…}*g5ü†°¡6BÿL4Ë;ú_ïÅq¹Uѹ±P÷IÉ£Dk ji¨\NkÀ°Ûѹï­ |224à^'ä•]³³Ï‡ÖKÒû7ü}|÷+(ñ–»|èPve½Ò齖㦽rè=µ¼;&ýŒê>ä{+Á9­¿Ü‡~xyäÈàYZ¨¡Óùû5j©ç*÷òób½¤ç]Å A(§ý^gMÔF%ù™Ç YÙ³>ÐpºX&·÷KCÿv‘{êtPÃ3@Ä+ÉA­SÕ½Òòí0 s”b =e©³)C$lV»,¬c ½{»¼•â®@í+øÙÁJÙnÒ.ñ¾€é<¥÷–I@±1Û¶oÖÆ;ßÝsÛxê¾–òDðBÿVÛe2ªÐÆs¶ÝM±jŒ¾]Ý“vº“N./™Ag3ÅÝnAש>óÄê˜Ò}Ò'±ó+”ö¥ÏÆïÀÒã5íþÀ ¥ \.÷Žb9©ïck=t¹ ¦¯ç¯€A81’·‰-¿ƒÓüíÇ ~þAÎ ?©t×4Ÿ…‘¢Õ2VÐ5¿yý±òb(Ëä³g†¹ÚøR¯RäI’WK®@y>B?‹  sXnçêÀi[…ó‘›?â²a‰hîg‚w¼N¶*ØJWPÞëB¹‚úè¶ãKÄz«`E•asèÝѱÞ7ׯÃIf è™tˆÿ¼Èwœ ½Ì¾ùæU˜ ¦Hr:ÕÃäÜ ªÃŰ·àÚ}‚‹`OŒx3ž`N0öîønVÿ„` Øbô‹ zÁò•­î2–Ñ5Tü:› Ó‚oµF¶€ß\`¤Í3Ì>asïJ…8A•8;R? ÿFjü1©Ï…´ßÅ£–´ Ú›¥:{Øt0ÛùK¢R¼46ZKþý„«*dÕÄ¿bí¯@Šõ§=±¹'‘Q¶TÁÖ‡žFE=®X~øT;%— dëLµia”¶à§ÕòÊ:G¿äœ$ùL$Ž¿Sþ{ ɹã×w0+¢f P %,œ†©à_âq•ï`þ« ÿ£O 3Äó•öÑ.BHòÉ-¦ä •¯ú€ÅŸ0Ú&åyVbÉo9šƒ]ö_4ÜUðï ówê=‚ÏQú“èËÈæ S/á&xâ¾jî%6¼½·Ð5ñ‡»Ì›™ÕI4ŽÑí—åbp²÷E£­yØÆß5â•™ ]Ñü<Ûb´HÔÃKTÁ6 Ð÷VŠÛŒíÞÊxcê~Kv#PdïñÏ”ß$h­U”šÆìõì'J˜œûg¯é-Ì·ØýÕã­t©Ä&Z bÛc™¥èO‘ØÈH::Jpðo¿V&$Bp„6vдÆ"—+×N©”ÂØ©ß ‚jUÝ„tH5AUõ†¥³´… Þ(g1ud =|øÈÌ*F‰ŸOœú·aãù÷ìue>P»oòYgzô|ùGû‡¶snxrþÖO˜Ÿ^جï÷‹˜^;^ <…nµòýe4í$ªóþ±ßõuaaÆP‰!ß {fÏUÓð(­Œ_-¶z͘]yüoÄó˜Ò—Éåy£>ì<÷èl1š¯É°2ñt0¿&'V“` Co ÿÍ]СÇu|³7ÔŽÙÂ7) ¯‚Ml“›oaCA¯%ÃN0É,púUc¢9·ƒNåyèLåã0®ÖùÈÀ7 Dùº¤8ÈCÏt_ÅFV&HU×n~ó&§“6$çh¾ ¸>Ê<« *±ƒ¬sA×O@ͽ–¨#+ϯ͡ÂHxƒ ø«ìFBסë¡Ðs»806Lq÷ö)L^Þf¤tºX´{´Žwtýooú 4¦Cùz¥K=‰$¥¿Ÿ`Lly»+\ƒ ë{Cotž Js;ö… ºK­9PM0ˆ 4ð4Ã`ÔuQq­Ab󇹮`@à¥$^ÿG°dý¸Jzh æ6 Ÿ¾Ð3EÞ‰‹|±2–Ý(UC ºì.—ï¶_Y—¸Ø‹ßyŸEZ÷JêÝQ×Vhí˨x;,@¢‘ßA‘œü­îX·2‚fT¦Ð¼)§¥ó›}qúÂçS”ï|@±Sߥš/}N‚‰Ú.?½ñ±=‰fwì ŸjM«°6ωaÃl»]'¶$çÈN”ÁB×=åÎvkhìÚNë*fFÐ4HòÎe'hUïÈï²ÂŠœsì³¥Ë0wgø£tŒ)tqè…œ®ß¦ ËgÐe&øÄëÐ1›)¥árªÎær›—¾"2Uű!‘54—å%ô°.kukAï»'!u*4Ð$®Ïb²0.ÞH1þ©‹©îME ³½'V¢¥Â"Ü_ÇŸÿ‘…äë—Æå m—ýõï³EP¿5wÙa¿ö|s³bÚ-•†_ï #Yq2™¿5 þœáx4|¹û=Å?ùû_Ç‚~ÑœõšXxÐ+WÆRG †œß«0c™˜õ°¢Û´…ã„åþïÖaÜDZsÎÔæbÝHÿ±Ì8éÿ»6äh’+{”ª_àW€ÝÆ»—qjëËhVE¤t¾¼ì²2¾×²ªZvcJ yÞÆÒ·0ôw÷‰SúýP›?;ò:Ê$ò¢LRé¾ Ž(æ7ßõ Ÿvâžw èK+Ç“ ¬ÑÊ#š¨\Òvn»ï™[8a,F#¿q<ÆëN£²&±ƒqj¯.öµ‘^‹šwC<ß]Þ'Øw>Là‘‚5Œl¦Ë:xÌæX{¾;¼öÀòúå½× Ñ¬Ûõ¾‹öÓEì‰zƒmNžó¥sä„Å›ÝR1=Xß„ÓÛ«îæU&¾?„í©åë½)ØËxæ÷I¤øçY̱âàÒ(Û‹B¬^rø™òW *cEØe¦ }·äÆ¿ƒÊ]£dëë%8¬eÇí—Z†š2޵ÅXý4iÝ-aªú¸Kç*t^øäš6Ž£Ÿ®%±>_€(÷K÷¾`÷æ£aÙzÂ$¡c|œïîñ“ؤlµ»?A§ŒØ¨ëû•ý…ïÑ/¤M ×}IiTBz^„Ÿ^„q²»’ÉÞTˆÓI³#ïÏ‚ Λ*LX~xþé{SGÐÿ+4óûûoXqŠíÂ’‹–{Ó‚=° fs9Ïqm˜ ]ônÝ õZ´g-ZqœwWH5ÏœV¿ìüe:S™Ã÷Ôbʼn“£GMaÕf³Ü#ƒ£ §oò¨Bu¦±¤ÁLüæ—dÂZí;HµÍ/îgÏtÁVšü{¿\`žöËÅû×{Ãõ‰Àjjó*oH?x Ðë âÊ¿ëïôqh»^ [_7ݧê–$gíṗêËlízP¸p¶çÓrîÆýuÆÎIËEpêí»Œ9EZ¤ô¼˜¹v&εMõ¹¿„EµB–p![XÌút´·÷ùÿü?ÝŽ©b/L”8%cl=E'^'l‚¶þ+ÏL¸pü<”öRÅìk-›·Ú8Ü"´%Í1 3$>*nÏÍÇs‘áÓV¢Ø–ÝÅ£wd;©òçp–a¶ÞëËÒf‚ø%lÛmv`VEï‹w¡’8jGK+¥:Šýoÿ?9-‹KLÕ£Ü|Ø÷"úwä|VÎs~Êñþƒä‹ÖîJàßW¢oDeC±áô9§l…Xnøz®ù9;¶keÅ« w b?gtÒm¨Á.Ž<´N«¿¦¦`Y™«áot ¹ánþЈdy½jžŸPî¶¹£Lš‹ÕOͅœ¨_STZ¡üˆÕÁ¸§×pF<ãàa—«Ø¤ÍøGƒ’'•w§?½Šy±ówtÝ1¯õЛã¹Ð@ÞËë!ðÇPnùu9l+íf¦½ßJ šx¡*l§¥îSÇN*úêñR]h:p“}×N#ü¶|ð+ø¶a9K¾eSÑW½„cÛeÅÞ#ža» ÕFEJLÜs»˜öö;å>ì8hö Z¹yß÷n~ iþé­«€]§jÉ,}‹Ø7.ªsô˜VŒ:ÑÅÞÆ¦YæÓ\ÇIØO%-"ã|*”"~Fe3"yKÛ¾Ÿ±yaª×s];/H0nœ•ÃÖÔš%ouð' JÅ/áØà6ÿkçoâ$ýÆøæ»8×·é<û){Ëðÿ(Abaò÷=‰óõ|Œð÷‹·oଂL‰ƒGÔ,¥’˜] zý̓ƒúyp4F@Á¦x­.I Áh—uÈ™÷‰0ÅPb!“ïË„7<'è¹ëXku©péÏQÝã‘XêQèÒ{0'vo{zXoeköœõ&Œ`£ÿ¶_M€™ojf}½¡çzšDóqVŸ èÄæÏSDaá!œ^7§Îëh‰ã)ŽÃY¿âÈ>‹7IíXÕU+ÿûâ¬b~êjr‹÷I ñnøŒåÕën¾.àÄ~Ëí…y_åVÖ±©âq‰êØ·)§Æ#"F¶þ>§Š3.?fÆyPKÑ™ç.Pò ÈïD!VîQÚ•}¢î~[æ]ع™(X3èiîk·fø²_¨(’Ø÷ ͼà½KæŸ^·©rb.K„í«çÇ0`nT`'Å+‚ëCÄn‚_]kü¾“/0;…Ž7Yø/–w&¹ê·rßü­¿Û×y6«A¯‰Í£^y(ˆæ^ØØ‹”†öBØÌÙSj¦ƒü‡Žs0hâTÌŸ‹F׬ R¼úô†Æ:ì7WRúANŠ”¹”‡íƒÐ,W-lxš2]>x?y ÃÓ<_vÅAßׄË"ÆŸ G´ðÑ:±@ìR_ˆVäÂþ²äÆk¡ÎûìñÇ_X5ÒÐ8r«;cò'g{ḕª»×In,WWÌ—JÇø–ñW[dc1×ì뱯bvXv£ÿôÑ–X>hn³·œ +_‹oµÁöspÇ"pKúÌ£w»íTÆöRØÓ&Ý—"ôzºTeœ¥waïÖÆú«'«¡žt$,µ›_§¸tÖb÷¬™x­©¶;&¾ž3‘¶ò²–àcp9µmv¬;. <{P?! Áw˜‹bSå3‰åÁpìˆMÛjxzŒåÓ‡Gç°Å_½“.ù'Žß´u,7áÃÊ}ÍOÍúS±áϙЫÆØ•¿(s%¿N6‘ö‰Õ`¿Ã±hÆ+aî@5Ï5ehJqÞõ´sO}áºô*:~ûëíå§Šè¢s°ùíì{J«;ºo˜ÝÃö}%WÆù;ƒ7ªjŸÀ,ÕÇè%©^pó8r]>ɉ·6¾:‡“b)~3 +ó>¥ôáSu~¤¼È§mVÎ˯ò5¶Ã€øõ™cüÐnl$Ø‹CL¡Ú?spÀ~çÖ÷nþ8à(£_þYó.4›R„±MÊy5¡Ž‘/à—5¶\9óézM<Tä‹ÙÄYbãÉNr2©ëZO$Nñ’¨_Ú§†äžÁ¡ó¤_ñ~tòbÑ,?‰]šûUO•BAûSoãÉI®¤Þ?´¦v/? _H…Ù ënn–€‰±ï÷r7fÁ\•—£ML$Äïè¶+ƒá~8(utåëW`2öÕzæ OÝ>c¾ú÷\?{¶«ïqMãÀú™å —IŒ»ù‚ vÛ%Ä%p¯Œ?់6ì^ÄyñGU¹H4leÏ}耷¹m&œ-Xô”Á^÷k”§ì½öwŸVð—~Í8S‹%EÄïâ,U˜büú›ÐCu4«¥' ÒÖ>©4äÆl‰ÔKšXÇñ2¨m<–8OÞîåÏ„¼Ãšk¬¸¢>/r8ˆ„:NUŸN=ljdë£AO5Ht—ÖÛ‡°¾Á¶£{drz‚I´Ö›„uc{™†ÕSájl8rGaÜ®2ÖÑH|”ÖÎQwÕÇ¡“þ¶»_E=¦ž.Ìø¡NbúfÏÿëDv+Lɤn'ÑMÜI¹¿«ÚžéÇ ¼Ž€‰3i8àØ”¸dûû&œØèN§jÏ‚µqyS%ƒ8døHC—Û «É(O¾†íÚ±tnIe{{Óéx XÝŸ!=·‡¦ÇK{¶óÆáÇYö,åÌc…ýá@VÐešûxzœ.бó‡ÜÐÓì¡o¯a¹ Ý7\g.Ùý§»¾„@çÙçúÒÏH´Ø|êÃƘô½ºÜ•\ÈÌï=³¤‰Gñ— 9¬1ãYÀ`BõGƒr)˜HÆ®TÖL$‹ï¢[þ£„£ûkÂæ.VÀ ÿ£¯—βARöpõ‘Ñ2œR>Äxü';*ÌΖ`§Û£=JáØóºyn½*æÈkÇòMõ`ec¤Ù®Ó[ð¿íy3‹eŒ»ÃÛÛ}¹ šÒÄMù¹vÂT¡©Þ¦bHaŸW äÀ.ãü­ÊpQæ´åR…,’©MÕ©UL°SÑ$Ü¢L;bäý‘ú‚ÍIüW†Œ@ý­ÌVû~GØß•êÅį6o3 S‘ù¸Ãf÷žßêæ6‡Ýë*h:ÃðóþTíó—`âNqÒGëq¨¿íµçÄV=ôׄ‚ÛWj•2ÞBÅ=u®CÞ$†rs!ŽœD(³(ÝÖõÑ(ßôª/^€îÃÖ5º×B`䥣_““/L6«}üa¤ä커G"0rîRC9“/Œ•{[y NaÖkñwO£1SE|‡ðB†ÿšå ï;†Å{su°ã,Uïc‰ ¤ˆ]¶ömW ËÜ&q%=upÍŒøk$Ÿøcѽgeÿ¶óÞÓ"ÓVìIÎM ÎñÀÁ°Z;ÞóXÆŸu3!¹glNÄ›„]£÷Ï$Xì†ú×û¨cq8iÊh6I\øeðb?„~VÝ¡É- Æ61ÚeØ~Zz8óâÊø(¶í‚çs:bÃñ=7ëß™BÍ9(wº¯ ¦‹Êcÿ@ÇÖ§f×­ÌåÅÖÅ ©½y¼P7~ýd 'Ô){û_ò:†µ¶·˜‰•®ìk¦,³¾bwý³ m$¶Hg«Ò–m>ÇÚSk€Ý#W/Þ§½ ½Å&™$H<úí¾c7Y‘r‡4ùSçv®×{Åmvû›ß´8ð­¬ßF¨ç‰ÖÃÀÝØ½â8`|³Ûûƒß”aÒôçH‹ØVX2ÒŒ ³—Ú¸¸ž§VÉ0÷‹‰­Ùa L/×oû¸˜ø32nÿ0‰ÎU;Ç]úg£iï<\yÁþÿŸ¦¢îûŸãÒÿ¸„iå#‡ºÏV¯û×Q-­üáúÿ¯ýߣ®,õŸ‡ûÿóPú?eþßûýëhöýÿw4{óÌŽfjí´jQDròpÍÞM8BãYÍÓãSÖŽÕâÄ(õÕåpÈÅìYŒÂ¡áÖ~`ôãÁ ‚nè¡ò¹u-ÿ!ê›zÝv¿“Q4qö‹m7+Õ˜~í*+¥ÓD»ÿsô{2bÑåôçí0=[g/Åüî_GÁ'$gN½V ÑöË—·¿tƒEúÔ8‡;<0Ë-§¯:ÀG¢kTsÛ©òŸ#ãÊsÙQÔ7I4.Ißô–f¡ˬçïî›ÿ:Jž/òéÐé-P^}£è…Ñ(Û¤›*úô6ôH­ýÚ )Ç4k©€r¾5üÃhÌJ=>‚#Á dÄ͈ÃùëäöcòRŠó!ÁH³Éâ3FrÐ¸è»¦ãØ‘TÝ!Y‚ƒ—L âS:0´8Ðè1{Öj ßõØø;¾ë­·Z¢]=ÂŽäÝâŸô#¹ÍF …„³5Ö½3ŽSÔ:•ã°Ww.Ú/ç;´Û; «=`Z;òNuƒûêc» }#¿5Ø9ÔíçÁ ˜_ßì<™ökíHüŒD1oV^1ô›1]+Úó¯#ò”V?Å ŒÖŽÊ“Y½ü÷e¹"y¿k¢¯ÅèV½´Ã8/‡>GÜú±€}¹å¯µvÆ ík=ožžƒ‰g§œ¼SÂ!Jw´r㦗Ð÷wXóë^/˜®ŠÌ¶< ã{vVæm Q•^>V¬x¦78“|mžO¯kVYüÀŒ‚O7P¬[½¿n'Qö«Ö€J£7óúwìûécñiá¡^0í³.IŒƒöÌëF¶YÅmï¢S¼3Ìdjuøóf,÷‰Š‡ñ§q~»NÔ§ÅÚ36ð7t.k§Ûih¦.?¹iâÌh6; :EN>³ì~qâ£U+S\£{ùñº%cRÞß«Ii2W\ïb³Ü±…84€ÁAé¡0É#ðG{÷…‡¬˜ÕáYo|d/”lÛšûð9”iæ[­ûNXm^€òŽ7ÙCç…×åYP–©øîà/ ˆƒ­nŠmÐVZÌo¹ Ú‚GLª™ ÓÖØlÙX«TõG7d@õù¤ $öSdÉ#cµj®æÓ`‹<Ýæ›ãPÉ!Qi0ÎÕž™ªûUÂ`]V×Ï~X³Ë¹d{{äÇY¬o½O°ußwXI°ºvÀ­í˜^¨¸W†`ÜTç½ÿþ¡R09«íÑ`~˜Dÿ}7%ÎäÒÿIc¬’ÌßýOîÞÏ÷OÉ…çËFPÃ⋪¿Yjwê¸Ê]óAt¸'ÿ¥>–•  6-}iLPm:¬éã×EМ›ôNŸx6—`9ÙJ9¬CP _Î`ÊÉ$¨Ýoöµ©'èÎ÷Î>øLÐÏu_”$ô"º»<'p<ŸÍtWA³Ø~a×Y‚)ë‚íÇA‚Á¸ÖæF¸.A—×FÀÚ‹ ›ÚºèöNZE_\8ø/¢ÃÅ"û>°cô“ÓŸúVɈ½ù W}êëÝQ¸»ð¦Ã8´>Ø™)xíÚáQ´hÝéÞ ÚbDï}8å…muÊ cÖ+÷ãËò½Î>˜×i¸·­7ªb¾EЮ—Ç’gÞãž {aDýÑ‘<¸}¬†-{ºBÅ»æÝ  þ€ùí¡óùPý„ßBVø-4 ÛûññGl§Vß ÄŠ)t‹•2yÁÐ}qßö%MkDH׉<ÞÓO±õïY‘¹«/IÔ²ŸêMÔ_A[¼«ÈÈïq˜ë!GÃUJÊÙôÚ[¤”¡Þâð·Æ½9ÿ¤E`p±Åd¹HË.äx¼ÚÞþq[£Å ×§oůÙaò@t§ÏAfŒy'>9-’·J@õuÏû£¥8=$˜g*€Ó´iÆ?ö!±Þ¼Î$7Lâ:v¬þäÓUBV0ÿ¶Û÷$$TÛ\©Ìùot Ôç»güeë^#L¸#Sÿ¤‘þI™XƒŠž ¯‘&cžaœÚ4P·‰ƒ é¸‡Þ5Iw¬R'Ø'Aómkóa¨åÿÙÇ{F&~Æ\|m­ c¼ÍÅH´w²$Í«$ Ƽ¶N$mËŽn±°í…‰#39"¶ÁÇ;­}•LÁÞ4“#FœŽPát4ÇÅ\sr÷taçÛ žEVOìþÍÝ,½5ô{jL£æ ü;ãÆ<‚uÝWªS¹eCºE— É¹Òðîûã/kôJWXìµ7Ï>ü‹`ù{ÅxÐ:ä2´uôž×øÃémFÌï‡Ï¯Ñ,M¾´š¢VÐã÷m«ú©DˆÝÙ²]î¢:L¦}8Çî•ó¹Þ¿žw‚}KÉ„¦U.´*T»zoƒ*%jÊ®(¨Î­;©pÈi’¼c.§à¯”8·ãq*¨£?wwÏfðìï‚H0f¿Æ/Äg¿8b^y½êÖ¦¿Û9BÁ5³îòfÚW0¼¿ísYõÊÏÕm*Ú¡n}ô¾ ûPf^•q4 2‹4æ\»]?µ:[Lÿ‹iûyå鉣3Ðq&wtóîC«¤ ø/’Õê…¡'šáèñ~¿5b¦S€'óPÌñ¡/¹X Š ¯%àHÌ,õ§_Ø}áƒõß‡ÂØå×w¹ØÔi•¤Á¶S[ºf °ë±øÊÔ}¤œ¢?ñlÁÉŸoò1,‡#ùÜ蛲ôTœØ¹ÝXú9N½œ—|ÙcŽzVåôI8¤\|UÏžz‹u­TÎ\‡n›$Âpæ"Ÿezçù5ò¦öÏÒém®ØßEo¯Hø®8h•2Ð|›ægí{oÇ¡Nú™À6³Ûê÷ÝY¥q`ê)ßœ°î3è Ll]w ‹ç襌ì€^Ú$b`è$‰Ê<·Œó‹ Õæ¥‡4 ¨û8;fÉU•A¥ÕÌÏ›8A¸-ä÷º­lmÛ´ûß¼Z£v*:Æ9/1æ!¹Æ+wSÈì½í“ò®Y=*|ÏôÝL¹ ]þ³C#V±²"" 'j †½ïÞóOšZJ¨U{³›¡ðÓ s1¦œÉò3O|‰56WÞMZü‡îi}$z8ëÂÎ?£x(x‰CŸº’Èj8ÉQ9qÞo#¦Ó67ž’Ü»JúàP¦~Fä`&ÁÅ•W=Æ?@p¶îQ©øÄFp¸ GíWI&8N>rùá Dp=›Z¢÷7"Ø&m„»{BJjļ‡~ÄõŒ=çXÈÁ¾Ý_Ž}eÉïÅXV=³¶¹…‡iaènf‚cÒ¸Æá•!Áž3V«éIp Tø¹~Á5¡¤h²]‰à8´Å§œ.à|D=«{Žú¿’CÝ~1Y'â °Càê&úm*Pm×¥`Îzëžôþ\V½ˆ ïkù=o$BÉá©°XÒGœŒÔ¬{]µk•*‚øÑã:÷<‡`^ódH…`:ê¨øÌDAÌïc‰)ÁÛ°þÊG®õYœ|%p0¢¾|6Z%þ<ÊÓJ©Å Rq°‹‘¦‹ä<¹Úd‹]uóm¿õ`¿îLYiÞ‡îÇíñžPÿ“ʘÞ/rç™SZ0çÂýò…»ðƒëïDè ÂC}4=y"‡…YËöCgëmR’Lá*™„ä¯b7÷¬Øž§3©ëŒýÃòw2z˜°‹ê«û¡ë˜æÈ2€ &q_æuþE+ÕŒ~N+7v²pÏœoR/|}•›¬êÕ¹J.Aw× çjîUz #ôXã76!èñØÐ¢ÿ¨sJé:½J1A‡À±€O¹XŘ¼%“¼J3AÁ‹üß‹³°‘%Y+Âç2{pùQÊ ö˜~¹<—½J6ÁàF—X^ËkdSÅ{®c' SàV[Þ#LÆñèÐ=f\¥œHÔ Âe•ua<¶…‡þA Kx<ˆaƒ±={;ÕÄ¡ûïS¥ ˜öWpÝ—?cêµ",fè¿õ÷·Ÿ ÎýeÙý‡އ"õ9æÙKë¢í'·Ìêþv 'Öˆ(׃L¶åëIºS­†:£J$Á&ð^ÅHÉž`Ùm¸,ð3me?r+Î7¯€`pyËA0¼Êçú\ÇM°¦oñš$X7˜þM’1 ØÔ,"¨, ÖH_DDÁª²¯¨Ì’`©¿x¶VT‹`9È|O’\B0ï9¯ZoSC°VˆTÝ!× ß &Sß‹Ìi-”*2Á¤¶TalÁÐG*ªQ%˜ ¸,Ÿí%kÙbhíÌ–÷ŠeL^Jº¢’ŽËv±Ô„sÑˬú9ªÛ¯&»d]ëX‚Å(O–ýS Áèð‡»rß2ˆ/K¾xC°%׸˜Ìë]5¼u –°Õ±íY-—XÔ/#‚¥²;,;ªš`wRïg¿t’`Úr~è Áê\óv7uóÊçùêí¹,s‚ËâEChÊÁžoVæ÷X`£ofj¦|#˜…¤îšQzM7y…£‹‰ßKáÚ½‹–‡C'7Áä¨{UbX›O²±4‘¡¾‹~ `\î‰ZŒwSgLQvJè\_£×f½HƒWó‡ÿOzmBî½–Õï_kÛÄ)9mÖîÙQlÇRÇqÁŒF3¹v“LÌL¹,ÆæÁ”ÈŽzOG5Xì{ëvøå¦‘mãfê—7Í{AogùÐý5ÂmJxmVôFU¯×¼Ýƒ„5Âì7§VÛ ­ƒ|ºb$Õ‘V¶³F´«´–Ë ¾“cÔ ˜­‡Œ©UY fý×¶]­·ÿE¾Uöö5 v&Ùlõ`\£ßZÞÞbŒ¯Ô]#àŠõbWÖ'eìÒ–¢œG°Q•UÿRèÜ* ‡-T—]FEEþ+×äh•}-JzÜø×eøm…Äuóª킞AÎG÷·m‡¥ÇãT¼ú’P%HÓþã Ç*)÷†·[À Óë?lŸ®Ñr= ƒy®¡eðdž´èphµ;+8æ Œ~­¼ÍÓë ׎S?¾n‰ÆÃA³@Ù²ÀØ8¾¢«Ú$´Çä[þE÷GÁ9Êʶv¤ën V‘‹UÚÃL^j¬u9RŸ£ã2}רºæ¶\ãkuë͆ó7;þIÖAç&—ŸcWÆ_×#dk©UÂne>Q¸Òu “`¿fýqk²$Á±mÔã ü>‚sú³D,Á¦oä/â°JÝA{á³ÓµQ •÷ÂÏS¬oe} ¼uþÐElݺCéÏ΋H¹³¬4çþÛÆúîÞ8Áç]¸¨Kñs„Ò’ÆÅý$–-¬FCÛ⺫œ·?$èù>1° *âLìÏ6'¡?€p Ö¹“ÊIPU…åKòu¯Rƒ8Q@£½Óaåù(ùM*ø?À e¥y›rOœò–roÿ„SŸßæžÒÇžøº~ñ÷8çž4wfðÑQH»¾HÕ[”šRKDŠn_ráÀCómˆ¿B=7¸ƒȽ"‰Ã÷'a–JùÁ£8ÑWjF0âÌV— §žâè_óIUuY̽Òjxùjô¸?é‘|P§þÖv{F%&Qš¨?² {{øÎËMˆ€Ù±GÇxD Úwnúÿ"31ãHöÅ…°"ŒˆTÑá‰UÅ=úºˆ«”&÷Úݧèß]%5ÑïYyÈõ‹G°Ð¨íÉKÁuH|=>^àźFkv~œKçù±YÞиô[ö%ŽîÒ¯üàܹFn.Ug²%È ­Ò›¸°¯_ÊÖþ!tpçäzƒ«Ý7Q~Óóðwœœ!?ö'2&Žüºwd•è$8¼5ô½õߨN¬¼ ­u5C§¶‡£¢N ª ;š ù¡¯aîÇÿJyv\œ Hž%lÑé^G™ .QÅ '!2èÍAIûZè¶T>Eke[;R´¶8A¾ ™QŠ ·*óœÖJh ׇ+ZØÞÓ.LW¿Þ«_i˜–^¥A¡¥V™åµt –ÕÅõøë`NÏ3NZ¨MjqXÙ;÷>snƒ¶7–[o3 ƒ÷ŽyÇBå3˜6ÇÇh¨§³JŠbïä\Vù+}hœþe0ö& ’šµîÜ›Ãáι}®wmó¯ÿF L\'¾mûîN°ñP6ð&˜„›‡Zô Ž]´2ÛÒ &8ª–`»J¥ÂäüîW ì7HôÉ5OôêöJ¶ åóÇý; zH×ÓÙ;*ѼËÈ¥€Þ«.÷»ƒ%W%NÞ¨ÏGŽÌ·ö8ùô¬)Dz҈+ã™ÙX’àRùÆÿùœÁþMÒwKw2Ás~Éä·äY‚óˆQFŸÁ!k\dçCZ#XÙnŒöp÷ì 89ý4æ¤ ¶—¬§:6o"Øïïxúv/Á?VqíƒÁésIï˜_ÌÙ:©SöàÊéUº;#uŸÿ*†ªü’VQªnˆåz¦èÖAÝvÕ¾oDB ÃîcfÇå5âµø¼øÓüº×kÔë_Ûüp³~i lkÜÊ4ký4¼¬©—°›CI£þÆLܾ·;ãK$öÿ :ÝuÆÛeöûE”ãè› âùsجPäõzâøNεŸ À^ç4ò„ØCì Ÿ,™” ÄŽŸ_¯Þ‹¶'Q¿¯>4Åá£ÊY&ÛÛ 0{î ^ïÆ‰êTS½/PÑÉVÄ ³âßöÉdAɶLû!¿üUjC£Ç Ikäl÷Ü¥¤œ—'¡&ÖóäõPÓ¶-è*Tg.}ȽRN¸ò²k©#£E¡I…,ð¢è_T-q)w¶þpËY[ݶD •½sÝÄÖg7°ªÕ¥Éu·Æe;MlIé¿Ã/žXrmŒ…š™žÄÚÚå5â¶lœÕA‹Ç ¦&.¼™xº ï>CÅ®=Ǧ$`dÈbÌ^ÃZ•‹Ïîaƈäü6†2hŒ²²ˆX¥q¡QÌ«ûã{Ièüúýñ³ÊÐó—µo}Ùz ·çíÑ=¦€…'ÕN‡–>Äš«›è‚saCºm˜õõ|lMº±åHLLŽ÷îE˜5&X^ŽqB×d‡X×H=ìo E CÛÅ: ÿƒŒÐgÆdªö’&ïê…9Ùß!¸õ]b½s nžW»+® µYAqû™Ö/.\»Oüjý ”Öðç»ù^ÀX¬ûñ~5ì;3¦É·Ý{½lþMd­’¾‡Íºƒfä-§f›{à‰-«Ä/„¾j-ŸèZ£~Ã<®—MœsÄ^×÷Ñ‘þ,±…ÎóB‡´>ز{`#DÎ}{cÄØ  ¨ȺJ£÷LJÚoRÖ¿HàŽTÆÍ÷|×hàî¹J÷"Þ<è£jeºÐ½á_Tp‹‚BÉ^¯ÐÔÍüëQf{hÚÚKèCýGÓÎ~‚æú$y,3ŒKÛs'pÎÂôãë°sŸ]ì ÞÅUb\òN_-°{5t97bÔ³×Èá‘,ž=Ÿ˜¶c¹­ëžTml¬û¥TÙhÊeI„K®‘ÄEÃÌz/IA¢ˆåÅꪫDñ*M e¯ó¸Ÿ]?Qo§“í^“¡ãé:÷8;?¥©’|ª úy•ÔOÔ #'‡Dâqèδëâ' ¦¼‘¹ÆŒÕ‹Ÿ#ºë_‹ä ÆßÏË~¸J0y³þúùiš =uùw´:-Á8œwí. ÁH¢¾k䓿ØËþQ:XúLv?ë!»J$#ÙJSØ3'©Nø|P¸Fpû¾žÙê Îö Œª~H0äå0숖„‰Šœ¤ ߯5R™½U-8¢ô(ÁU"ää])L°Ûª§Dì‰&èkŸÞʤ1&ØÊ&¾ÑNfL–‹4žmuÁhäÅX ؤg⊪¹W)f‚ýÁųŠûªÚ¨§¢=]Ø•aEÕ ¾J4“¨ÈÅL“ßè׈æû¼‰.SÕÒ¹Û_C©p*-­¥Šå5´åÌ,æ^ë‚¶ÏBÝ#´ AHh’uŒq•p†,Ƹò=M¼k”sGPyõ½.¤Ð<*õÙ³J;ãèå{OÕÅ1ìß°„oÓó‹ížiÍ?‡Är\j´ËïÓ_ˆ1ÞJ¥YöˆDeªsŸ!i×ÿI@?°ÿzZ–Át•‚Æ*Ǥ?²úÏ ‹ß$Æ‹¥Ébeè|ÆJn‹6KvØdW–Î yézXõÇyY¡-Ø>s½oZ–æ³/ ~Ãð±kåíP~ÿÝ­\f HÙ«=Ô5‡mZI/¼µ‹ ©¶”í{mO™ˆÎ¼Br„ªã™Ö"ìãà^\¹#igØM°'æ •'W tê'ôå‰÷4%F¿”%?’˜:„… MhHtŠ·LŒ. “I ²;%H´OÐLxÒh<`7+n€¾ŒëàüÙ¹ÕìBŽö*q C/ÊŽ쇠˜¹Ÿù„Ì?¬þñ‹ÞƒO7¬ûþ Æ­¯õp9ŒÕcÆ+ã´Ùœ­ÚwZ˜,½b]”î Sw<){~WC¯Qß̇P4uc³gF½¤·I†îœ’±„7›ðe&¤yägYêYO\‡fEÒûXÞ‹ÿ"¶Ën驸 'Àð1Šž}â¹íÉ•àLšSÆæª™#)ܳ@pd†Ü„.wiÍT™Ê5’»–;­Ã’f*ëÛNÛpÕC£“ÊËëÜñÿ¢ºÛŽ<âyœ“†>/Gƒ:1-MR6)ü×áß̪Yý¸bò®L©¸u[[ÚsÆ®èþ½‡múîªîP=Ç:ó‘«äf|_UcÕdgh›-Ôz77Ü X#À§¦¶kGiØB éöï¼F#œºO†É±ƒNèaäq‡UsÌÄY¹åÕ°éœ@P­«(p¹¾ëê^£Â«nîV9íÄ‹­ ½ƒTBÐù-"2\$a•Çž›:_Ä›‘)ºs,h¹6†ý‹Þ¿ƒ².ô_´¸§ïËô´ÿ"Æ»nïxE7¸JCã›@ÚY)ìÙÓØb(*ƒ…^ÙåÝUàzŽõäÆÐÈ%ý`ç`<ô\ðþzUjF}[*œ„^;6«Cï]``ó«ëýÆï`¬W¶ ÜwººŽ;„ñ~ƒ!'Ï0IGעù¾ÚΜòÞosž_wÄl€LÛ–.ݘ•yБJñBÉŽìÞ?T“‚Ó92êïâŸ4‚bþ¥¸lÔ½3à­Ô*‰å bBínÐ}qœÏTÆ2^½€ïÁªKW㌃;ŒÐólKÝrº5Öw°ÂËŸïNé0Âà½þºãU]Xð=6s¤˜·•êú¦‚×A‰L“XVþ³B%Ô:HŸ#÷TAtXÃ…ˆýÐ÷væ;ï.1¬Ù»·¬oS´”ïR0³%Øœ¶\P‹oשòÝœªͳJǬï‰ýŸ*Âó'ú¹‚u{_½$èR»l¾{Cvã¿Ý‘ÂÃNΑ†úáÁõm}`ØhøÊ¥ÖDèjlþ}ÃûVðó¦²ÿþ±´LÇŽø2B·>wŒ´L¸ž=}ÈÕåé£>²@öŠ’1œK†±Ý¼cÇoü‚žx»¶ÚK¹¤ QÃw{"n´üV‡÷Áx09Ë¥àÁìwé´ñœ A·sI¹Ä^’ ’ŒÜ;?.¸JÊÃìþ²•Ó/Þø±ñûÁʼë¸ì˽k}Bðƒý—Bê•O£§Yokê1‚aÜIÃ½Š ÷W¸xêL-Á®BuRxp•¢‡ÑÍG’\?+ây§Ê}Ûw«4=Aàÿ3‚f.JůՋ øÒ~æÛY_G×f¤Ê‹ÝéÑgéÿð­ö\»>Eÿ^£ìW û²¼çoztéW){¾#fÔ¾&×Ó|að1…É=ÅâÌïì ®Äß>|7×\¼šÎÂÇKêÛÇGéŽz5ïJ^‚à’ØÍ(Ä·òöË: ÎÔýÖ‹[³ .»á2÷xi‚çC·åà*•-Luç{m!ëñümO•9ÈPîç:Z¡v»ªö-I@=ÞÏaO[%õ¡·¹®*XÒ&¶äF|üŠ~ÖòºÌfIÐMÄÞÛð‘`e÷·õòåÀhjU¾=aTXå²ôÜoÆÊèÆÃïÝŠÃdg•ANjY¬T”[®âšÃÑ™›a¬SkT?›ÂW´BíU²Ÿ`žÝ~áƒÆÁöð/›“GÁõãW§œÁü^FÿÌÕ%‚uûÛ˜‰pS‚cç¯ÓÌCB+û+A MŸ\‚£:`WÌ#‚ûÖñbɆëÍn/Žô³+÷éó}¨Ã!߈EßFÑm- @NNà|“°šÀ:¦ñ›3{zgF«_ìü)¼ ÷íH90 ¥¦>«ü`-Pü˜¶9š-ó¯m ½òçôFm ¤E¨¸uyÝþ뉈© Û =^`ÔÆç§ÎÎBû–~õþÕĶÅxE]~gc6¾ÜwžÊîÐòvÅÂÄCg+6a`úž†½Ò ì¨÷£h+-EýcŠû´4œyª¦¢ä¹š&@ò¡‘ôÛXÛóu‹¹ »£Ž¿:ù?¤uÜIO›±fûîˆ8“«8ryƒ®×C(Ÿ3 ©s]K¤ˆ<|°¿/‡ß*äß½y ۾߰ iÆÎXÚ†èœØï÷jÄ¢{›nUô1`/CZŸÖݬõ5ËÙú<;Å_ŒõEÆA hrÔ;a 5÷_‚€šµTÂÄrË‹Œ/ÿJ&TÅ} ý[üŸtÂ)zZ9Œèàæê*Âé¹ë Ï…*×’ S”O•䥯<pÏùaïÂhe™ÐjjjÙÔ>œþ*H°Ÿ T¾ƒṁu¤k6ý3Á€íÅeíLþø6CYj™]'$nl²×†šcÏ\Ô‚iGFÃç´n¹Å‹4áÛY$îáåW ° !àGMe±–jÈè rÞÿ+Ù0ã$ðÜ3¨( KQm“ÐÆGmG²™ààèٷЩ›ÆÀúzvݯs#‰a¥EëÁjÚ´ã:MCžJ20ºŸ\~ €M>¯m¯SÔ`ÀiðSŸÂ6l8øC­©Àq-1.c#“Ïï´š‚ÀÆpw¶6ËV¬e N‘Ïœ¨ˆ¯^²-íÎUûûØ(Š©ÿᨠ¾?m<¾¼[KGt¬?ÅÇ8e÷dŒzºã¡à]æG1ÞI(?4ói~q+æpçŸr-2DZ9_¿‰&«© ,8tV»­ö!ô>Ô““LƒÔùÁÇ»'0=ÛÖµ.Û Ò·d7ÏŽÝ‚ öÃ~Ìd\,†ú{)\Æ 9gçz †½ö·bÇqèäíÑz2#ƒ?X™ÏyªSi’ÄqeæÕ”þðÞ°þöU˜t({\~ä-&ïŸ×ÂÐjÍ9¾0 :Y-Àþ «òF %[ –}ó½´?Ò–½ÀÏnú‹ý{ׯ2Á„Ëó½æjЉ#·®Ƴ¾§çN¥Lþ/ŒÃ«töýójBK%Uñ²Áj{y“ ]ÎŽpÞ°}-¥Ñ}?@MìÊ–Õ¤59ÄÌÂ×_ŸËCgzfµñ«qŸß`ïÿp8ô¢U8Å®x~™$vtöQðdÕ?X,wŸì¡u¬²ÃÝ” y ,çv)}vú«#«.L]ÆÞ´ç]ÿÚ`Õ–ôÃ1÷ÖÒ¼Î;µõTlÅ;‡åÞm#8mrܨkµ Þ‚×^6ªukxäkû“‚+!eæ!`å:¥_"VSû­ó?ï~¶$¸Þ_6]º/Y¯'éJc›±_Ñ@†Ô±ÉSßK´:W“ 8ÖËç±mûZdIîÞõ9™ÕDÌξ¦5Ò³ ]Ä/ÝçL$š›ó¸öÁlFÔðHìLye0ÿÍ„ÅÒ õ#&0~ž£†»-Ú ÷ÚM»ß‚%áÜuq]â0Û’½_¸¹–“¯4=[¹n«ß¦‚ƒR‰X‘%H&j<ª–;’¨ÊXÌ>‰AùC3Ï©˜ýÆäÚ­Þ´š(!ØÓ;ºEœK¦—šU\K–ü·TI…ýÅ;ïÀø§r–JÒÿš.Pl›¿)ŽÓ™ ÎÆè™þB ÿ­ ¶úJƒ ÂßE²Úúª‰K—t]ä ò¹d×ë»`lrÚö,]'Á¼^ø;•õËàfÙý3w˜VbS1ÁâôQe¿÷Z…ÅöˆÑ”*-ÁiõäÝ©½k‰Ö;ÏïçÛ¬ìÃe¨? #h5š–?Ÿ,#¸wjÙ_²¤%XJxçDÂWS*}å¡ kÁ"«À¡(BCЖ$ÿI]¿ù¿&V¾lÞÂjþØe-µÒû×äî…7˜÷|c‰y-½Òéš/xð'´Ø•*míS\K±4Šm:pE êî’;øXÆ{·½H—‡±Ö9Ûò+wW-ÏÀŽ‘¾è¡Úw=˜étóëÆ-®%[&Ï©ñny¾šnÁÙ8v†)g$Ëï~F àTÏퟲ*«Ilv{_äMVÓ.PúzÇx±Û=¿ÖG8L¬% Šns­&_ üÉù)ñžµôË„dÓôtÛ ì e7Ú_ aUa :N@'Ýëuš*8²þíS©µ4Lý¾Lòß{™è<”ý3x »äá†Ç˜4DŸOS.Ãl€šû`¬äoô­©8ºöûø”¦W­/Cø¡Âx‰Ü­4è÷>O*Ú =ü?6Ò;BÏ˰γ “Ö­i>{-ASµIwá™ #TÑQf#ßu@ÞS5 ôÛúö¤÷«B(W`WÈà[MÓ`­Ú‡¬‡Ò™ÿJÔ´æõã7Ó‡¦“âlŒ×’5í}rïÚb`\•ºS?Ôi-IC&ÖÏv긒˜À[[þ¬%jØݼ/þ+`‹ÙTp"6˜`¿t«-ÏB’àxú5«—ˆ#Ø×”Fµ”®¼´à+$@pž›Ðß÷Ã`ßüá¯É±ÕÄ Á6T¦z®ñ9Á™øÈ¿Êceæ)?—DÒ'Øé"‡þ."nÙ6k&õâ€ä»·{§~e¹÷$U+ŒÜ([}ìùZ"gõ%ÅpsÐUºËPp*H4ÅñPæ²Âæ]0&™&Ø}i ëBÿ`t9¶{<œ˜]Mé@mSê¸à!(ûqãóàÒ(¶³ú‚—;V“:ØLk¹ß‹uËdNX\3äÃÞ£¯79TÝ‚JŽË–S›`Li{ÖRƒó4Òf©aœãßD®*ôvÚ&VÕºÀ"©‡¡N­ÈLÍøovAQ`j÷=t5Õ!‰5Ö­?×R=¡¹WÝ·ƒVQ©eCX6¨Ö?Ç3ªËuár½ÿ-åÓ£œi'ò¹{kt§6Œ‰ÒËH-¬&~H[ïpç¤} ˜gª»FÛ¯­|½ƒ(¬—°ª_ºDÁ™žÃõbF„à$¿ÛT8¢Kpô£›åû!ëƒÇWA‹Ù™FjÕÎÕTŽ‹÷jÈì‡fÛ½#;oi‘˜}¯‘R2ZKy 2éÑ$vboäf¯kÒH¦s•í©êZM açýƒÜçâY°.¬úà ëóØöê[!]Å^,c]8­î]¢t:äha¬àšMÇ,8;Ö2ꬌ/,ÃyŒßp¸ ã“!¡ cñ³±÷e™`†·¬®~HŠú%t¾.þ,ºº«7÷ºÕjºwiÎ\Û´š0¨/íWkù²¡rfø€¢¦# ¹Ö°¼Ä]¶š8$õB{©¯]ìß‹«‰#ÈU43¤h½šB¥¨»'pé‚›ò&{,-T‘Ö#¨Ó.†„5†áÜ×.ÞÆM¥8}“Ôέ숹.ŸÒiÀN ‰ØûXûYáãÏ•õôw¿ÓY§òJ ½_Q–ÿ¹ÈTÿ²»s9Ó«wGÀØÄ\lÚ40)px§ÌC™Y¸†zaÂ0͵¤ IX zð:;ĪËZý:‹Üpùx»Qéån¬•ðé¥{‚Hœï–ÆWÓ8ž¸aX¸.3b_:8Z† U.ŸˆµDÓ˜”ù6®åF t^©ýoø¯DÓtÈ5ÙxOhhRÜ8ÍWþŸdÓ½#]“²¢P'ÿGHbÑFC­ŒŠÙžbøÄÛÛ¡{»usCÈ&Ô53;ÿ„ö=†OvJ@ÇØ:s+YV(¿Á)´ñùa,à,>ÍMí åO¥¾V×^M@á_ª´lXKA«Å¾𥆞‡¬´­!´8bSën'·[>•Oð b2/mÝÆ?Ø»îÒãšê“Ðäø+8ÒTÛF¿9R«a_Ië¡õ[ÿ™’‚Cöšã¤*}p¹\Y+ö¤Þض³Ê ºžþi‡²±üνâ*8aGᾸí_ɩ֥„èI>Ðû}Ý‘f˜’ò»­žÃK¢{Hš- !q¿®zgöL'_}ø}6Iûõ†ÚÜ–(«©* ;å$»ë=d‰¥¿UÿJWMýg׻釭þJ sS‚PXèákF)ïÆ¦[YáÀ‚‹§y˜ú¶o:eú랎˜QE-n€¦<©¸qºdm×ϼ­Sj8ô˜U“‡HÀ(†öH%æ÷0pJijêö»z>·ý;¶‡G>vùÛˆã/,£S“)Øê4Ëçе–>«¿ui·6¿×{̶2nþ#…†ò´’ t0Gêt„6$êB§3VèŽ lÖ YM£‘nò—¾Ý¬M¢¶ñç2¾‚Ä$dáv„¢{¡©w ¤NøMXÁ’îæöàV4˜\ðɆá/¥¤õ!$f³]¸)Ï–)÷•ƒÙ`ÙŽ'7öL.ÌX7ܶô‰'qÑ–~·ú¶ ã\ß3¯\ž†ù9¥l+c}pÏ=k‰_«I6­¼'çBý:“±5U¦Àò‡£C¼Öa¬<Ð+4í8ŽR„•³Ö3ý·dvÔÐøðÄyÁÏ;k+]Vn«é6˜ÔÚkŸûš®'v¹!žêì^Kºµ†‰^kW^K»ý•?^6gŒ•u .£õWoH ~i{Šoœ R _ç~ùÎ klÛ« :î··„Iàø·¡}WÅ!} ›·«»ƒD)ŒW,|±Âáù9×ÑX*ç¡/¸nË_Íï•«ÁrîP‰»Ç±ì®§pY>#ÖÎæ¥<ôW†yƒÃœd­(˜`:ÂþÛ}eþoÞñºø+m²2{¡Û£ §pÛFìјúÊ?‹½N—587݇Ùi[Ï*ì€qå=‹öAâ0f.v;™Q{Ëôi$ÂvCé=ZšÝ›ra(®1ä ŒjûW<€ŠíFŒ,{ =q`wôèS¨¢í§ ;Ú co˜>'°²@†Or$øÕwéIøBõÒñÈ–[›¡Y°¤T …iÙ–Ò‘=0i“LV¨éòÔ¯'Oä~AYRíèëE˜îʸ]óð"Œžd·‘ËX™'33ɪ +ûÈ=1¡WZVÖ7E½¢Ü§±y ½¨BëVÔ+±LRc¹/ÙÑPä;t˽hàZ-?G=¦G¡C³™NÐÔ³RŲŠtó¡´SÇ2b+w4;Ýz71 WAfŽÍöÚÐ8 >æYØüEàæOœùLŸ Áñós¯lܯþ Ç)†O5àìóõƒéÒ.H1{´Ë¥Œ®2—·áxN‘öå=Žá®‘€£ç±+,÷Í¡«TX}(Ëbbà)”mýQ»»ü;ιm뛞š-6rOÏcÍ…K= Þ¬% g÷N.;ó¶t»š|F£¡Ïatþ§íK¤«ÑÛè­\g^Iy=¹–>œ\t›áwå!¨¥ì°8õÏ"æDm+e‹BòµZEé·ØÃ<³¬.”°kÞŽ"!Øþu•ôŸHÞW—mͱšLDr¯™J&W)‰*l·ÕÆ/½˜d’ “•}fº[5›Ó“aY‹ã…ØÓµ´"Y³åÇ? ô l'ÿäý¯©Å§†&Æ-Ö’‹µ‡©#¸|_þ3½H¢Šx¶Ñe\l5ÁˆmŸ«â‹ƒpÜW÷¨nVŽõÊÓ Ý.ZM3bÕBýï»Ó×pàÃúõnÝ$š?"qþßcIì]!GSHô´ßÙØ¾¬%˃f^fX`û顯Câ®àÄ"äá¬R¥Ì﮲¬%{Ù}ff}Éd¼þÆ«wùØ~_ÉØ–ÀÎ×›ìCÂVÿëi¢&!8W}µöKÁOí8[›Èm ¦ü{ø)ÖØy:xü{¨ŽÅ—.ùNád§RâTŒ=Ø›-Ljcë…niv@'}Žlï)(¾þ)ÆoÇŒÚ:þ.¬Ã‘ÍŸ¤ LãòE›÷!Ìñ8Áq”/oÅq6š#õyvPBÏÉ{ò®újòSÛÞœËóÅn£Bǃƒý8ñ¨hTØ;µ3Ô‚(8êÅ? óà Ž©ˆô¯#¨i BT‘’Á§ã½²ïïL+³y\ðŸ„ò ý"Ò[ì¬8áç}®§\ ‡3ïxÀûÑöMÜ1–8¸}2šSç¸Í²…â8pæžç‡–ý+ã¨Ë±ª¶¡XdqÜ8Ÿ~¦‡j=îbPw¿ÝÛF2ÔN['|=†dº‰ÄQ˜{ÂØ:îí óßL›3÷Û´9íÌC?³;5l‰,ÅØ?zÅA­jŽ©ëým‹ˆ…ô©J<= ú{‘ú ^¬&ŸarlÒÇýP"ä~~š+O»Ú}Ý¿ïâ,ÂAËñ{גЭïw»ïÝ m§÷oÙÎoïD$Y·˜躠“•uR£Yݳ©ÕT4P†Õ{Œ®ûýŸ©èúçΪ‡¼ÛV“ј]à¿($÷Ït4ûþ”u—~ M3Ô]‰]0àù”¡K, « Þ?¢°=ÁF™3Üo fþ™˜††W¥V^ø×;[¾Ååïjrûº(}NÓo ùIZ¢×Æ'kÉé™ fé×!HfÚâåì{œS’èû¯®¥¨»-í©öï„…#'ú²³Í`î93õ·×%ªç8Sÿ?ºÞ4šê÷ û6ÏEŠB‰Š„¥D[*T”I¢”L%")™K‘1ÊL!2œÛ<Ïó<ÏÓÞ¶y|Ük=ÿß³Ö½Öój¯õ]ûÍ÷:¯ó8>Ç~±ºß†D*9 ñ¡ƒÿUUS˜¿ä]ÚÔü¯²zõöá[õo„p1Kó]-ù2®Üd´ÿ8Vý¿*kœo7MÌåøÿ«´&R‹7 ”žÛâêÓ¿[꾩bƒo7''©„î32±oÏɉ³}Dê|™À\öÿ«À†ìÛê.»î8b«Èª}¿„ÊUØ3áì—¶¿x†‹mV>G3‘Ì[Űâ9Bd4žxò£nkï/¸?,yýôx®ÿ~¾—“Íz­—_ýÕÙ‘Ë-„ƒÿ«ÎÆyIÁý~ì!ÿUhÓrÖ¾a‰NÂþ2½ c£æÿ*µ—µ•-òòÿ«Öþ˜É’÷Ú…H}9ûÓ^^¯ÿ»b›Hý×@ÉÞ†CÂËEÿ*·W“ßÓ¯¶BÕ¹¤£¾¿ ô¯“O‹º<$°Ñ-'µÍÂÄ<ÃÙ6«ÇÿUsO:¼1ñMd…~kݧ¦· ÔÇãωúá¦ÍÓ…mžûp3˜æ›+÷Èþ~ܬŀdåùŽ+s0”¬¸ÓÖS7ã‚  YØ_ôUÉßÚ|ƒØ!<Ì{ië{K„‚¥&¡?½³>Œý¯ œ|>œå‰ý_%øÿªÀqö{QÓ3?Püô‘rOQ"vð}¼Êw¾  æ¤\úÿWŽM)¾KÙ†cA*«_&ß®È웑:aƒë…/ ~%»a¬QuG¬p|>D¿W”¶ëÕâ/¶Ú÷ùk7%£‰—ãc2a›“×øu5ÿ»rœÀDÎ4ËZþø¿êq¬3þ±ÀÊ!C`¾ý-€…o ÈÏ¿°kvø¨Dti()Dh‰®uïµ£ö­¨ÓyØÀq+f݇@à,{cuÜ$Ž@³;j×%€é•ÔÕº•hè·N¾‘©+-¢û ¦Î€Jï•Ô/Ž0•S·ö 5§aùs~ÈUç£T]’W¬ãô¨“NÀÅMýWí¾ʶž­Ðð¿Šw£ûu‚ÅÑýnªo‚åÕçâ-ñ„í+A‰1Ÿ°(å¼ë 7ULu–±hbëÄ!m©#ìþ¸Úä­À÷59éKÙk ‘XWªªŠƒ«Dú|˜º÷­œjÊ[‚Ø|gnc)îKÌìͪݳ‡^ê÷–ö‘_'áä´–Óãô"hJ{|&SEH‹ìyä·îqmògÏ0¹ÿUÍCï“¶Sv‰Ù$ñÖ`¹Ëí Ð \î·ø—õž€#fŒã’tÌ8»~»hש­‰žä4"]‡`¿’ýn¬·†IÁùBí«ÙÁ£¸·fªQòÿüR½KRÇÏüþðÛš—vüS’iüƒ‹—:_VèÀå̾‹äoàºêï½gŸã´« }®t:È5i+ogó0žïЃú€§yÁeÕ&§=öyu@A«¯8¶ãy¤ä)èaË[¿ã”5iÖ ³°üj}³ªøŽù{%[®ë;v°d[aë¡Ð›,úø‡íÙ›ÄF}3 ëÐn~Ý“&JgûÔ˜ÀrpÁ¸c’Nˆ¦ÉxâäİIãÄ\Ñ­ä ÆÍ=ÐÍÓ‹9‡Tê¶%œ˜-kÞnŽäÒø×Ï­LpmJÜðØÜÖy*l7tÔLÃéòká»b¶x1¹éÅñ;Ò¸tLÆç´·.‘÷{MO ã†ÃŠÂ¯¿¸¸Óù‚xGÎî¹XU‰”f‡áùjœÏh‘õ‘úB¤VÞ¼s#Zb+?4kŠÓð#YuïÚdïö<¼¤}ÌÛUj4>ê}Äõ“‹C¦+qŠø²çÕ`.r˜³…º™âÜiyùBw¤ùó8mà:RêîL½>‚¤SôoLNoå’Ûˆä$wœùÂe”'ljé´ëgî¬áÚã•Zj7Üt8*£aq}ëýˆ'¿ª`C¼Ø……gW±ÉêœÀ®;' ‰¡úöìV.·Þ-ìÕA$2^ÝÞ~Lò2‘þÔý%©<2‘1æwCö ί8P,RîÂÜJ“íÚÛ­÷­ ¤\ÙEÜÆì+Rõ—H·‹ãÂ8‘Úÿýɲw¹¸±w¶ …Úlžš+©ï%²ôi°?Ýó•HÝvøhÒ‘..'ON¬ &Ýï\T ´ƒ™G\ÈNCûZBˆkœa™nÄ…¬bvóÐê<'õ@®Û_×Ç|lŠü3Š/,Z”ëÞ9‰m§Jž4ÊžÚâá¤ãË× €|ÄÅó«ntÍ™^vÃ8i[¤é:, ÑÔùÔBŽKçž"ãݹ¬Á±Œ¥ËaÜ<¡ošonfÃzUËÖ¹_ÙÀìlåaÖ,ú™W߯£í¯”ë S;Z«áºŽþ­ -3=çŽë]|¿ £¯~h\¯Ü‹ ìõÏZ¨1EÐcg³s ’ÚŽ„÷òÁú£µÚVì!uøzž{„&*Ô¾‹þ8eŸõfïj?Ž<Ü]üÝ€kïü¯ü<ÅfG¶!X'n<œo‘±¡Ý.Ï^œ lkyÒzM ˜dÿ^_†–òb±Lž‡0Eû(?ëx6PºnŸ´ÙC ¶u`뼊)ŽÍOfó~ÁpŽKŒùÕó8n[A1±&P+wðlûÞ ÏH+ÜëÐJkuBM”úr³wq9ö˜äjïYŠ-Áè“„ó>8ž½½?v%ç¯äncÅ>§™Žíš0p÷D9ƒÊ ìK'ÏÝ—ñÀYÃ…ëÏ‚¥±×hâÔ±æ{HÚÔ«XÄ…©PÝ•ï£XTÒs¢wû–]UZ^ûqÇâ^%7½»„ä£Büv2#HÊžý¡&8Å\'¥˜-ƒ=µ×¤ÿXìÇÆé}®ñ;â”õ¶{¢^8~ðŒ©NGöšg0Zò…îÇJó´£Ö8§xß"¸¶ËçžS½ ¿;“Ó4ÀAݾw,°‡m§Ä:°·Ì©¤æÛ7œLžÿcl­.möÊÏjT:ÇœM= T¶ åÌÎaý—`a­-Ëö3VU¸c9ŸË¢×rPš>¥-¶`yok£MÒ'øÛ¬zÌZ&”@•L-(G!0ÈÅÜ6i àܱuÏp¶z$ îõœwËÅ¥ Iö*Þ¤x߾ʬ1ŽkŒ^1hSáX ^=ùIxjF¶¨뉗ÞÝDR麖ô^ø7ç-Ó|’çO%c8W‚s:š[>?û¶,î|D)’ÞX ÞÚƒ×$!IénÌ;s“Þ¡çÔ”/ù…¾ Ò÷~;Yø±¬hd4b¡Ìbçn\‘Í×¾õ—Õzõ]¬sqæÌ ÎÖˆ¤ÕþÃÂõ¸|úÕx͘,®MpœÂ¥èhßc@…«uJžšú¸q½>óà×å-?¨lv2E$£ý!¥¦õu{ÏðoDmùö£zß FÜxêö[(ðV¼!.%<ÚÊŽUm7e4ñ'Í××Òº©Ø+á.üÉk5uNý ÍrVØöÈ;"Wã"Í ‘*LfýM2R>=¡Ý#䌫<·:—–q¦F¤p¿( Î5åý¾€õl=ÿ¾M¼ÙÚ;#’ÇRtìî;ºŸç -¦úMú`+‚ëj~އ9^räý!9µ¦:³ó†%a‡[üNŸ“Ða¥¹íO,.F6Ž8³DRåô¹ÁI Ëœ ˜ÒGdˆ?ÂpÛ²F?Îß“Êl#´œèL¤fÕ½¸©ÓŒA’ö¿+`_P/ÕçÃ&0±yûD©ßI MeÖ¿0< “†)‰‹´O°‡äÀmµ<¦Š G¼&Dx¢–ë´·Æo æ9%aû©××Mð³¤Ï›¡EØKyÉçoMä®›eÔ~H.ì¼_û2¦›y_î3nÀÇÃûŸí†iÏšýÿ¸‰4ÛÈÅøXv¸õòƒSÅœ¢q-¬NÖU&Aò'xF,;ƒ3g˸›¦• ãÓ\jIcö©ì{m-RyuÖq.~×þkƒC2ɲ/uã› Á%hU}/»üôÝÿ}0‘ò‹â¼ºtz *ïîáËÙÒn¦•‹ØÖŸþ“ø÷"¶j¾gT£b²óÐmZœY¥s­¤Œ±aåÞߪÃå8Øg¬Ðkÿ˜HÓü¾ûJ©‡ž¨ç¹oÝ£Ð×Á'ÆqÕ²,îÌ«\$eà›âLj´' w›å¿ÆõÐÙÝAK7ÔÙ⎤Y>ûS÷aâ÷p—¶¸ƒø+L¯êRK4¶ï1^óWÀE¦S¦çÿ¨áâG?ŽHVU Ñó«P€±;J_üe5Rü­|øÕXÙ¹Œ›¥ —øj}ËžÙxòâ´¹ aÇ{º=#âëP'µM†|¦®Ÿ/î¶?ŒG•Å-åb¥Ì¼¼k uŠÌ¿±›¹åý€û løYßùÎ)·xÉ*ûìpé:Ï縙qìï ;ÿ‹(ŠÝ×Èåü`í¨]ÃÜ ˜<šØö½d f½*$´Ÿ„qõåͽ¢n@:XÆøúþÚïi~CBRÁkéà_ù¸ Éðã’¶½yÞZk€³±W*~~ÌÆ9ù¡3Ô ¸šà?0`™‡«—ƒFº|õ•¼!/6O°¾â¯uÁ©|ÏœçzûázÎúUò,ä4Κ«i©›Á湆ÕnÃ78—o ?š©‡Ói¯ûÖ¤âJÐów KÙHzw©"zÒ—­ž¶È?1Á¥N9¶› ¸|å;CW`öúÔÛ ÓÞÃ%é³÷Ãå¶ò3ƒsÑ—¾*l[{vÏ>ß 7ÂÅG¦.Ôâ?1þÀHF¤ÐÅ =¶ÂÑÓãÏ!éïvM¶Cu[üæWk-‚ÍßBN<$‡mq;_ã©P'œzÙÐeœ÷çŠ ZU1Gïj¡Ç 8~ähv+o*‘þB¤Åûza"£h¨üf¤%®ÅpèoÛÊO%ã|¥i"õQÖç’À¾”e#ˆ–q?žëÃþÜûÞ_²ÒpåÁ®É=2Ø×"òè_£-ÎsZšË!å…ÚçèœRìë:<ŽK=BÉ¥êï‘c)¨Ïqê5ùÞ!©81šUZ&wçÔô~Q @Jcºúk\%Ið¸!%û]E·è8αdKÞw 7›³éÃ'i‰Tl§þÝñ Ë4OÅ¢Ý03ª~{†käúß»êþí'–]xæÎ¼W_=ºj{{ë|ˆÏò™?¦©XÜá¿VÜ,§<ì%Fd”Ýk|òÑi"õÙ_{ï"‰4 íã}=›~˜«?éÕaóÖ4ŸޓýW"V ×|½µ,g¦ˆôMŠùî'ÁêÓ+2ÎC"ï7Ö!œ‹9qžX‰CÁ—›væ^™ƒ­š C“ƒtëϪIµCèÊ4é ­®G².!Ÿ@Ópòó}wEÌôàYÌ’ñÑ“o$&̱8‹Ñš·0 ¢ŽüXº…ú*¶ÌsY rY–J›>žr&Rµî=’«…Ó+†IŠXQÒ3fOç«ëÆËU¸T½P¡.kÁJ…ð@Iíì>ì‘?`Sºe(.wGž}®á¡ÆŒ¾?}&@–÷‰+vèbQúñ“å.ækßÙþÎ{z¨Åxmø!‡Ö1†ú‹+LPV ½½S0¦ÿ3ý“‚0´5è0á/XâÿÆéhÞ6üȈÖ|ùÒ–Žç ç—®;)€Ö¯/YÚÃxÿÎ’‡MmX?$|)ã¾=朼˜Äü›ÀüéS:•ø"68L§×ŸÇ©~3¹ç8•sC;åõS*RÛÐÓÈ@r`šå#÷4¯iR ¿!A g%¼Žef”×jJ“¿pÁwÿ€Ã["½kæAŸÀ:"UmäàÑ;q~óœ8Ç@*‘zr‡|‡ ®¬µ­‰´öi^ý½È5æ½'i`X§–ò%jkƒl+~sÇ®iÅŸú³‰ƒkN¶ÎÙ48p,ñ ãŒf„ÒõäìD¢ëòÉ_;|q¶–ã|¦Æ Ü.&tÊt2=Z»ýGq*qXlêØ2Ž;ª'˜D(AéÕ"ÜÏ›q]÷/W7 âØ•C5·Y"ùóÊ·NµL$G¸iíaÅË4ýK÷¡A³[è.柦¼lØö HšÔRÿtÒaƒúl\hÔ!X¾Ç(Ã˵H"×rÓ0ˆ׹@‰­ù?UŒ«|dãaå÷¥®aúpÝ!Ö“;pYnð÷\î;ȨKØÊ6êN¿.&RU9½Ž’ÝG {¸Æ¾÷¨+>1g˜Èë%JÀò_WX1ÿé02Ò‡½_/Ä–^†>úJ[å†åK$“°—”øzà#-v¿`äœâƲÖ'Êrópî¨Ôü§§C¸R÷õ©î)XzÂjéqK(¦gVU6nÃÈÏ65!Æ èc\ü›°3F¾•_²}ìõMn<ß…?Ñîî™™ME Lªî}=sê74ëØGU¡÷lÉ[žOýŽæõj \>öü¢˜Zràþ•+0“IgB}^Ë7|Cì0[Ó{·K¿<6«L~΃¸rƒpù‡'pÕnw¯õ4Îßd~3äŠsßl_’ÊŹ ;¥¯®é•¶·ËÏàòÝ£96 pÞÓmèÄ"‘NîÚÇSÂZDš‡æ“=²|¸|ÂÎP,2skNB¯‰îü*aëÈ•¸òðTð¬_%ÔoK;òìÍnœLxÈsx\ç­³F­jOÆê~Žà/»àwžD¢ÏÑ·DjÓ$­³!؈ã¾ø' ^Д¶r½m>Ö¤æøvÙîÄ>nC¢ú4Ž 9~üᙀãwn×ÓÅciÒ;9§’ì{;ä(2A+Œß3H|Çö`'ÉK^bPö{üsªí?Üòõ¦s]v8àr)Lƒ*S =œÛ:k°“—ƒ5Cw§ÏÖŠŸBÝ矅âݰ¶¸/ð߃hX<Ãrw<à Was­ÜU\~}Ì`ÚÁºƒHŒãµßqâ俵¼_ì¯xÊ›íi‚­ö ª)ÓØç¼z’ˆä –œë{qPü”)} ‡ Ô¿C.aã‘Óüo‹á Ó9ó³O¢ FxÜip'Þ©R¿dKÀÉ> ;¡ ŒÛæ)pÓ>ùå\’…¦ÓÂüϰwúöÉ߉þºqªiŸOÀr^ϱC/Õ°X+äY#ó5œ/R–9æÛú2yÞ< wѿؠuXç¼bK·J`qÝ.¹²ç!¬µœš'IÀïÀÖñRýrHµ»ópÇ '6ØH,{]µÁ>É¥‡ê®¡cÏþm÷´Æ¢ðÏKbBŒH¨sðoƒ ®…•}ãÑ–‡ùQ'zΫd5ÛÒk¥LoÜ8Y[‚H%]Ï_KnÃÍw7rûÛ¤ˆ4«f¬¾ü„Ý&É÷œ#;Žï>HØIö,9–øGŒøï»µsb%÷Óö?ªÉX{OàgŸ0‘šáÍ熞/&ÚÎà§êš—ž-?&pUáúŸ!¸8&¶½¾d/ÎÇ6ßuY’Ã)¶<•« V8Û6=ëåÞŽ›âTbp1Wn¿l(¬lÀµùxŸþOî¸^aôí{®‹Óµ³klñÚ7¯ëîV™˜òn¬§=Z—ª¶ieEyvi!–WgþìåžÄó Ö4͈4¿Ñ9v,áª/YŸ W·õ‚ÿŒ®UÞü»9µ—Ï‚äÒ§jÕl}a¸–8¬xW}g`$Ò<¨ŽÝ© ,±ƒFÏ,ˆ´iÓ~-ã|»_ÑkŒ :µr™6'`öo’_“5;zø,øÀFÚÉ{Šý0ÄúÈàÀ‡ây~SAœñ.¶áÞü€]æ {ú÷–âÜË›o\«±¨Ócɳú64+ŠÒÖ5bŸÁΗ´ä±d*ß+ýÈè1 š;3}¯WÅžÂJ /ë­=l«zlÒ–„£g„ä§ppNspÑæv,~ îiÇF³—ºð¤´Ú‹‹‹`ë§ÂÑBy Žþ³6ù¥6‡S,¡ûnŠH}{îAƹ_ÐO/z|iõ%Ö-ùÚGÜÄùäfÎØŸ•0õØðŒ†æÕ?O±|lõëGØ2EUqDÏròobUš ¿quޏ¢¶õÎ\,é>Ìë ì‡Ã´Î,©>K0˜ò09àÓYì~ˆ>û%ãÐÆ½WLu^Ñ/‚ñ¼m¹ú‹<8ójÚÁ§6ÇWüÝ_zJâà©hSG£j\¯JtSOÙÄÓ]÷TOÉâªId†gøÖ¼ûtSãÖ¯é²h©ˆ„œ{´K‘çDÎľúw¸† )¦R“¡—‚‰Ôãê{ͱ¡‘ybðB; ¨](û“S¦ÆšÃ´™ ¹BË^X1cMéMº#ÝI4wÈÓØ±½rÄÖ¸ãõÛ.~r‚É—ŽIu¨«(l,Ò°ùrè¸oǘ¯/ï—ø‹…W|ÃFlî˜Ký$?HôÈߟŽËÙoüê‡q¼Ç©À-R‡ïݳ @²žÔãê…¨ãq.œ­^µì¼ïóeÞ*)¦MÝG Ç#èøæv zAï~'0¨OjžœÀ¹„«£C48žt«¦Â’ª¹[,w¶&ihU„èÕ‰DZYŠƒ‹ nÌ(ÓKÈŠéwÍŽ(é¹igTÚ]#Ò‡M,}çÁÂç‹ ƒ¬ÿýOzRyïg9®<î*¯@„ç‡D+Ê{qüWñm}XƵœãÖççØx°Þ,ƒv'’• GD¤/ã±~æx•ÇH`Èyài‰óÄÛÛL‰Ô‚Ýþ'îÊbõåcr~ºóùºõì³k3Ì¡ÒÄ9㬄çdPSì³LîP’)öObia.äåÛ9 µ«¨‹eË,D…1Vƒ€"¹Sí]¬Xvìk(Êgºý†_a`×Çl­ç tQYƒê•`y¯r扸»@6“¾”Ûè2‘º?ÖžfÁrôù‡Ë¶¥zêžêÝ/>Ã$‡ ¶TL^#±~¯n€¥riÙþÊ'ÿ}®è˜pÑbÅMš ™Ž¬~"µºBõô>\øžMÖ Å…Wÿ®Uâðn™œÔHÑó¸\.ŽËY?E³Åë¶æ½¹Y²<ƒ ²7¦tàæ®oüñžý8y­e—ò-Üäþk^®>JdÚÞúΉ‹DêPÑŠÒ)\MñVJo±Çµç';>mÃj¦™€Ï71²G÷ru1=Gp\ïà ¿’–—”¡Q¹³¯ ;Ò Ž¿—©Ãvµ®„Ϧ0Ö+Y°S¢ Æ…Ž]þ2¢y×O<ï&ãÆëÛÑ6MHÊ;mJÀ¥ûÎ~{qá·rßž 8_ù×j¦°œÀas†õq ñ¦gþÎX ОgcŸüHØ¡%Y˜ÜKàB[aL £éºµ¤†³;kôØzß÷±êî¯q#r·‹æaÇãÒ£…›¿p©XðK½.ˆl»ÇÖ¸æj¯£{F`x‘<‘xˆ Úl= ÷™`æfQPZ´ŽÊݵó˜)¶®ÖrHš‘p²%æIÊcSåÎ|fŽÙ}*®¥Ð)¹—§ŠÁüëSäxaª¹#Šžî;.ñFÒé@Ù?Æ –°H$µ,î’"¿Á)7îÕÊ8ùq–Níøäß_»Í ßiްÛÂüvš…Žž6˜ìóe$Ÿ7†Ñog9oý¼ÅGo^… ­C¶¬wÑ«— ´ñ)¼=Ô䦸s+X¢ß5×ò) ¦ÆUt’(´NzªÛO¾1À`¡°—#Û<ŒŒªýè£+†<• ›ß[9ôÌfÉGsâf’÷7AÈTŽd¾í„3m f‰a;òøýw),I än|‚ƒÓ;è~?‘ÁöâSO:Õ[°[úc±æn3 pÑ|ÞÙŒu÷›–Ù:§ ÷q±Ø´ãèûF©j½ˆÄŽ“ÄMóX“þT·†ž“‡T5ïݘ+hî_/ÙK*â_M@ô©¸ÙåÒ†äžË–õ78$»}‰;sIéô´­›qyT#ÏhêèÖ½É8S0©*Ÿï®2‘¶øÌ¦ôÊp–ËT×"ã Ä”ÿ’ÚŸÅ/·:F¸as÷ U§9÷üþ…Ó'±iA.ÚÓÞ û©ôÕìµpŠgoÿÁ#0Ymú«ao,^#ô¯”AÄôy–£™vPl©¨'ùêœâ°c?OÞM”\½hózÈjN›‹˜t½‡òèp±Î1>\3+Ü%üõ Ì;•ѹ´—@¿wu3Ž™@“;àx‘áïÒÉ´ö"‡ázàS%wâv“¬/vé.G–y<êÆžv3-.äd\Œ“ò€²û싱?ÿ`· %ë¹ëÞØ:M•4‰}TííL?¦pzvn;ßÔŽQç2q൸ys{ ήÎ|ãöõÂ^ió#à†3¬ÎZHòØçÕa0$8†3óóV&œ8×Â%cTÅ‹EèÐûuËlŽÆFëd@/½²|y~ŒX<ïâÇ Õ¾ª VIŽW+¹‡8¯rW“p¨7d6+Gõqež÷ä}ÿ}DúKFfO¯eÏæþÏcê’SÍm_`tŒ½?åÑ/½+ù§ÀÁ @ ëx6w£Vóµú•â$ ÔÞÕƒ’Ç=aæ­aÂe͇°é½Bè ó……*WéØ[ÇaÕ|À4'»–'e¤´>"PÍßú²êÇ/né½"Õ`ZÏZÈtØœrùõú¦OÖGÆ,|ð»†í^ò OÌØ'}ûØ€} R¶ó½pZöƒ´ T75öÅàTÌ×ÇS=8Få¿])>éTJ·pünQ}ëüè§z5Æ!¨†Áûܙ͟bKì‘Ò#Ò¸ìH1)»‡«©G§Ü<±/.•G®Õ©FhÀŠl.=ý¿l:» ¶‚‰Näì9œSS+4J½}Ò*§8k7¡éÎËs÷e`º­P20Ý º˜5¿zSà ?£Ú÷çðÈyêYàîv,_iÓþ CSYMÖß ýÈÅ n5˜´;ò0ËÇZã«uì @] ÛÎrš[Ú ;C¥8´Õ1<ÚT>ÙmóȤ€‡^v•Ъ—S‘} È _DöÙB!£ùÚíè–.·pùª£sÐWu›IümÍþP— µ¿ßÐbMŠÝ‹×ª¿ Çó×gî&_äLÜãG”Tò·ü«0ï^ô¥ûvŒ/µùôžCççß¾[§pLOV³UmD i<ÓlíÃF{e¯n lußás™íloef÷o`í;‘õÒGPD½ý1F"93<Ø­`„;ÍñZç)h<àqf]Ef®<ç¿xvÈR2i‡Ñ¡/éÔ÷þ)§ôÔ•%KO¹ }±™äãœ,0¸8Õ¿ù †RñÀÃÎOP§M×¼˜ zKÝþAC0r]4™)“º¹­BÞ–2@QÞYÃ#g  VSšFáC4¼­­#åéBA=4šFÞã ZCh—Úž(–‡ç÷ ™©@¿¶š“Ï=ô>¯¡ÛLƒµ@.Y—œÝ8ìk½üÚçíÉŽy¶åWg¨Íl[±Çc½@m1Ùr»ÍyJh¹.Ŭó [‡ÃË.Æjã`”§¢ìQü‡]?ÅjùaŠçÛë+mKÐxÉãâëãøpžé¿ L”c‘iÆX߯EÚ±×0£”륕3ifU0òŽÃ#ª²“漇ßBk{`O"´ÒjÅÔÝ…uÏøt!X9¾xäJÚ/˜Û°dXiʖΡðâlL¶Íå¡·H‘LÖ/9Ë RK^ÁV8Ûüá^ì.-¤”ozU+Àè^¦=m*V_&½Ÿ6°r8|5Õ@ (çN¥l… Ãïv]Û ¿3üšÃS˜¼øæjw,Ékˆ­Ô¹À´šsp’ßX¾„ãöž5°B:h«b¤ 3ãGVgçÔaLGô²Â\ ̪òó ª,0wÎ× , ˜#Ï ‹¦!»ù¡ßù·¢¤Ì÷î‘æ9\sEÒJ&Þ—a¶°qÂMÈ:ßÜвw6ƒ™Ë…`o˜Vú’܉@¿Ãk}˜*Œ]<ó¥E ™`îå¾ûý½¼v*VLê¼B)ã:0ó%H0é R[kŽ$¨$ß×rŸ~X{Úy£Å•”Êã®ì@ùzC°€ñP¶UùK™=„Ù÷ô,/©?23N.Fž\ßAÛ¡Ë Z§.kûÁæ—'ßt®Ãô9¥Bôf#Òüºøöëj‘&¿pû½ËùHù¢LW³ÞI¤Ë70¸w‰Hµñ ?ì3=ÎÕ‹ýsªù…%7žE"uâ_si‡ˆüÙnʼn4®5 §ÙNãœÅþ>åód,~¥›òU'ç]zU}O«ûßÕý*LØûÐ#yA¼šó~N ž°'r”>¹lIíƒj¼eØ"ñ/¾-/ ê/Ч O|Æ,ú¬ Q¯‘\édáׇóˆ¦I=8gçþjêËWèŽÎ¹÷ŽPÞI]à¬ØÒ—Ž¤‹n y|ÝåGÚãø¥»-{ëûñ6Q®uPû|ÛOùÞ<è³üœühë>¹ ð~®xóyßß›Yý„6Æ£ÂöôÐJ¸Pmpñ L‹D'LO2CHsþžÏïR¡ºæJ7ÓŠ*–xqÐõ/BÙxäùÃu0ûK[,éç}U¾¢6¹É7ꚺØn@^9‰ÿñ€=ôÄ&““±¸G¯À?œ ×tG¿ Õb{K¼‰z;¶Vx™¯^šÂöÖ;ÎÿƆ¡KÎsoøí¤œ:Ò˜Rœ d®ÊÝÜMu0øñlµþ'2ÌÝàdsm‡Iö»fª‡€ôêß•Ä5{˜fµ44v‚ªq_5-\1Rm ÁöÑçùDß"œnw¿öðL;®Íìàzù‰HÕ¼_«sï˜ò?·òøŒ¯ºüžmvâê!S/f¨›OЉ0€’Ú[ï?æ‹@Ï iî_— Bƒ=®à1‘Yò©Çðµ*"=Í•¬“‰qõ‘‰`ÅDdjyÄýó>‘Á8ù†iG7,Ütšç ÁÊ_þ€l ßqcù±(ŒOÍëiŽãü9›Ѹ-ý”z&(À·•ÿö¬Hݨ%RSJ“¿Eø™¾|ºüøa.†'-Ñ×z9¹ R¸³F‘\'hý5XȸIiy½}‰ÈD·’›Fd::ÁZÕÝM¤Qºük5vöŽÝµ}!\£WÇ%çW’ ¤®Ji¾–˜œêaªpÑ‹$/)HõYp?ç’²¥[tó¬f¶ÎÉLf‡?‘fˆ\HG®†|á]×d[¡®Yä$P3AoÚ1º–íLÐvõHj³è$– ?o{`…åÍ™Ëµz«à˜?O–›­(’F¾© k€©–¯â"°½ò%ÛÆóì>cU›t¥ 3ÿ¾|uhN Z"þÉž;Ã÷ GHB=Mä|`ú“gÅ=‡É‰ö›ÂB±Ð꯿¯N€ Fo-i; }€…"÷îóA*çúhã?Èȧù,¿åwéß;&wœ‚Gñ7¤#ö0¨ðUën´s?Ÿë]=s¾#×Üo`öPX çYeœeHß+5u:Kã.a[{à~ïìåÛ0¯¤ÔÄ1 õFù´·vBÕwÇç!÷6¢ñ3—­uFô•å§f`r+K9ŠAcC÷¿Þ6 ;lìwHoo–l|`ÎúrÀ›à;jÅú “½J0çÀò¢>÷5¬>;ÛòPhl¬ÈDû•‹—ÏKþ™Þ ›ÚE{ƒî˜ÂzÖË‚1*[Ø$-?ÌœÛÊå»Ôu9·ô»JÈöÅŽÕ‹Ý>¬°lKËe †w)•Ï\œ4üSNÛ¾Ûâ³æ \0U(©—•0ι*×0¬ý¸»°` ¶Ò?/*SQÃö¬Å‘hUCl«ãàköä‡_Vúû¥VAë¤eŸþ*Š^°?’Ž”› æÇ›ÖaˆAØðÙB,U0K誜$p>‘»6šE`J“´<8ÖIØe)u}YB›À¡åšÁr)^þ1‹ICÐ&T»=G#'Š7M'ƒ{qò‰ѿA9%üfÔ]$¦øÏ7Š<±‡y¹Òò°¡ó0èNìH¾åVä]OOdÂjуêW®_`¸Òà;3»8´\¨>n"Ù·•ój~>ßýö¼&ìQß±o”½|²WÍ7놽qöåÄŠç+ ÞÿuA¡@'Òj‡H1Õ½Òsî+Næ.gÓMIcç=Q{^W l1j<¸3± §¹®ZâOl‰ »Û@ Ñç9QÛó?Um·¿Ð„MÙ áÃõ°r~PvÒ_ †¸èücç #+IJ—è%3—_šÃr9÷$ ÄAÓ÷óg³U°0ü!cÛ0|ùÙ”$æú£5³#çL!r#—ãòšÜ–îø¨ßs„_>b_pöÏà°BS(ü׳Úý#* ]öJXAº½šÙÓëø–ÍO&ÛR Æøèûµ®­cJ_ŽÛ’Ôy#¾"«–ÓB[€ûàa¨HÛ\É ½ÅÂù$¯ (Éþ+!ì]ë£ t¶ö´~¦š_ÆÆ>½­{”‘îÜÇŸU`k¹”rއ@.ÕþáX9}ðÔá£ûÔºŽ×Äå¯À¦Ú3.ê–0*‹=¢tú±sþ•ãK âRÔã,‡¾gåËeÌÉ0}üUÁM´…"Z=eÂP<̬LÐqæJ¥o¿ Lœ«}PÃC5âŸV¶î}þóÅíi[>Ÿä25¶Œqø¸ÚÒ&Zï^f2ýƒ =_çO$B³a»®qTþ¼-VÊ_¿mŒ4o¾&C—…«S${ßÊ}ÿiþ“HUûC•jº‡TTôù‹ã ¦ÆžÜÀüo~¦¿Ï©.:ç hô&s‘ƒ x9_÷W…|wßV&`±/ƸÙ%ÈÖ±7â9ý!YþøÇx1_|iuoS&wçýûmyÛ nöתƒëˆ[‹ä>¨×»økòŸ þÐÚ&"†]‰©<°íæçrîvÍNÆ^!)0Bä˽Ñî+ =;mÄ/hp–´¶`†<šÚ×Ba=ì_ó?Ë0wèïÌ?PéþÀ‘äG÷áû­u+e)pªèµÝq\ßÛóÒ¬&?¯KIzÂbÀb° Ë? „ÐÏŽ‚NIÞ¹¬¤ èMÌ\Ðtʵ5f !˜½ðÎB,ÍÚÓœl•ÆY uG¸âäòvhT|»Êu»îØ#%)«ë†TÌ»4”ôí.Žœ=sžªÃBµ]Öj cÿDÅÅñ#ØÕ«Ëvë-Tì.¦Ë0@—ûÚ{‚ŽÁ‘Y£ÍuåÙ“7¤Ýq¬ìË%[ë|l#ØÕ‘ÎCEújý²— ´î+©QNPÆ&£ðO÷¹@ç•·.õC0Áð”&´˜¿6˜ –y]Œb/åó ØÖ°íOØäZ•¬Æ,õý ½ž|Ø 3‰1¦d迪ø=Ï#>ŸÓ „áˆn¤ç†b=Í·Cu%÷eœœ±vùÔÛØþ,’ÝêÃÌ_Ôc/cÃd¹r]ÖcÔX15à]L÷{ø£ù*™* JbUþp{$x‡4Õs¬>i›8Ô‰·ÀÞˆ=–XÈI?ÛûIF“Øž0Tc«áÑþP¬8ýM8eÚ³#jûóa8Ÿo»žcŒê©˜W¦˜@½­Uð Åq,«|Ê[ӱś£¼ˆ•gÍÏÛ¹_ ™¥ŸcSâíà[{t±¯Rb©R[÷ÙW'Î_Þâ¿3óàïöÂO=´‡¡ìÌ'WÕf¼µ/Ûs‡>æ¾=Æ(µË߇ß|Šq€ýõ=‡ýïÀ´õŸ–°3ž8`#xåD¦.ôÜ g(¿€a û)M‡ ön|õá…K8€Þã«°n;iŸcÒ øªá okµ¥Ï)2Öè“REsà[=¦3s{³4ÜÀy‡üÝ}ìÐÈ?~ñqU V~¥¦Óĺ–"§º°MàñMùp°j‘×4£Y ]ûC:”ú)IáÛoæÅ¢´Á¤;Ã8E+îä¾ò"|hÇ’N!ñäÝùï~`K•«Ü}è\ëûô,î1/³+b„Á®Ÿ7m£aàßß’„}w åek“ð~ɪŸ«Üƒå÷I;þ2vAKat| Ã?›±É X(¦‘»Øó&O ôe†cïÏßh7‡¾ËYû‡¡Hý ë'Q ÔÛ…ÈýÓ†õÝ÷^wCkç?fÄW¼ü¡}W ß -ªŠ¿†’o½bxUåÂ{W¹®À°*U÷n:Ò¤ì›=$¹¹³~_ Ñg¯»“ìÁ5 ›i:È%3Ñ%&DÝ3PixE/ñ6¦gXz¾¸F u¶Ë;X{ü`€âË|¡:F¨‹(–ÄÀ†É—ézbÌ?Þí,Æ‹Ž³U‡DT0™F™nIå&ô†¬\/4ÁÑfµg÷Ö°¨'!`22µ¹ÿ÷˜?³-OÙ3ÆF¬Þ76AoBZ³ê®³Y¨öI Z¨W$yvÁøSø‘ˆ<(£Ð†´¾úÔÕ¥ùJÐu>°íÇ£%äc™“²÷ N—xÁ˜ é5ºù0Îÿçâ ²; ×f/gM nI¼|²_ª¯¼­ºó»Tn <ÜÚ§Cáëå‹ÍÃHº@ Û]Ú]v0Ye#SC0„iÛ=‚i—`úÍ=õÏ"!°X¢àêX–‰57 £õÉiŽVßu/–H«ëÿµ0Ýl[öÊ€‹©ÿYè~-Fjµq¯–º×0v€ï~íñ Ðþø$åÙ£sÐËy¥Ï_¾zõßu¤_€òNŸ×| ö€ÿçgÛ­ Ùâ›ÎÑ(x*ñäR9 e^ÚÜxÎ]@ñ¿ƒ—Gm3šš¡áÉ÷¹¦˜˜  ö …¡¬Ø›µ‡€|àFÎ_]˜½—|ÖÚ\Æ?5Iíæ'±ըؑ¯@âÛ`)Qˆ‡ÙcÃ;„°FµùúÇs‘Ø}ih¼¥štt¸eo@ëóËxÈïéE\«×žèÔ’€€S0²ÏÓWðûoHI1­Ž À:¨G kLf± 8gpqº„—½éB—³éCwbtNøÇYsݬX9µ ýg6¯™@Ûê=š‡EKPãFnq©Ò塿®+0ÚÑzÏ=ý* éh¤!/ ®îãRª«‚êÙüÝYaL8aõ3ù5®?ëÒ“I ñ§ZÒk‚j`ô‹×Q(äsóo~¸澆\i=Î ›Gœ¤KÒžb?Çi5éÌVœàÌ”SəľÏÁ2'F°"ÖÌþ“bÛ1‡LòÐF#&Eãá†D“½Ei°r•{é÷+/XþbGŒr/…•wÞ,z|Y¸¶nó¨èº6È¿X¸ß»Å¬¬¡|l;‘Ü×#Â+¦L¤UÓ:èú—ƒ+w†]ÀÁr»‰&¸NPs¨Œw"RÅznöqôãæ£êCÅ¿}`t¿zæ'çVÝ ¿h± Ãgßõ5ÌÉú€—Éq¥õdc´;d3é6O79Á|zOwЭS°˜Ìá–6ˆuÎbÜJ{bóÛ˜µ[gÉ÷bgåBe=9ÂÕ^‘/ß` §ÏóühBâFšÃûcO îôµ™ƒªD®WÑòÊæ±DÎw}÷-‡™cŒffGÞ@ÿ)&ãˆ;ÂÖ"Mu_wŒº¶ò÷í%r|xˆéb·ˆ;Ï'-3r‚tŸš¡áe\uœ!t&rþ~WJª rºìâ±n'îˆÊ{zˆ²D  ¥„³žzägÃ×K’Ø4V ±Gë› 4“ «zŠ4D*‚]¸ÜÔN Ì<ã!‚eOÿ\™oå‡9¢Ä÷¦ö —øû·„¹j ÷Çhì陓wÂ4¡&îÃÌ»Ôl ˜ÿ”ص‡ËÑd vï6µH‘žë Xzsâ¹E³$ ¿8üVs¥ÀÝõ–×ÏžÛÜw–o.EGK%Àæé»Çï9ÖÃüŠ>ÕÙ*Xã?J•k…YòÌÙã@aàZ¤ùÝ Kv}As ¸Q˯ÀéºûÛhw˽…ê7×Í¡Æû«e0 Ö²¤Uæ êÔN½ä÷*ýšJËs'`Ú(Ïr»° þ*+˹±¥Çs¡s_`A7tÌ3F¤îÞpzlIdŸÊñc»šMÜ–ÿ†ò×–È!F_Ü¡+Id9bÓfEdØ!~W°ø2‘z|ÿó¨"|.ãÛi"ÝMι@­DºÏAE^ BDš;y¡*B¶D&¥[µ*JD׿ïÊßÿéÌÖ²ÕéýC7µÞp©É‰ÖMâüD¦¦ËåÑ+ψl{y+îqM"¿uØKÜ&·ß}á¹ ‘úâͽ¥SÖ8Ï™5=Ü:‰Š·&¸ú-±ãE[§:cNµò…ožÃI åèO-K0îÓcu3S ÂV~$¹YÙ@'—ÂѧŸ±])Rmc4Û¾MÝø®†½¥›ŸÆ4!ÿÊ£CŸ‹A‰@—‚ï–ßD^ (ì‚F›'×SÛ ÷ûŸ÷&Ò§að‡t\MÄ–¯Õ/+…t Ÿ†cÃ×PÛ(×(½ã8Ô‡P¥´ª„AoЫ6“¿“Сi¨Ã* ã·Nu߀.ÊþÉcÃJ0ÕÎÜzÍ`ˆ>Í/\ €qNW÷§4 d÷ž „¾œ]…éEëëgÖ a¤?¸í`,aú,ç|/ ð{¹TØmù¢òÓÞ~j˜=U–Qd Ó¸QZw­j¸Å‹?@ŽGˆHò† ÆåÉ«6z¹dfâŠí¼óå3…N†½Ü”Ö]0ÓY×T1´¥ƒ÷;´?‡¾x÷V¾E×:"|þ7C7ûî Ë@O]½*†³ jûRÁ(Ÿd;·æ9è>Õ8⯱åkËÕEè#€ìµè°]úÕ£©\¤Œa°iL/îìLp[Ý6Ö'ÀìñZ‡Î‘"í݃£lXèó%C!];ÞJ$îUzµÎš/Úž´aüLñ¹ºŠ•®éð'‡çS/þ…/’¾mÏC°Îç<j,QÉ 4°gÍ#å‰`0ø–ȱ7ªÆÊØé;™æ¾Ðv­/î¤k14íËìxZ5‡”ò×nYW ‰#¬#ÇrWj¿ìÜÉdÓ2Ê£O°|†¹‰ø¬–Ýs×ýt8`MðöÙkOX>|É-<¶(£Û*êØaTqvã¼³,ÌÖ^²o5iùŒ§I½±1Cþ°õÖ¼§iŽÓ=êÀ‰æK–¢¯qypíõaÇ«Ø$øá\´LÊHpbŒ;žçî‡ÞšQh;ÀˤÞ"Iö3[iVé *ªx#'Ì ƒdÇgŒ A0‹g·­ÔýQÁ=ªJõž0ü§iqztp±|5ä:“Ï®§x CûT„´Ü¡³0VÖïCEf„.úætÆó&0£y·¼Æp÷VÞxYb·Ý†ö×?>9&—£²X²Œ`N_ó­Ü?â×áïûIÈý´»þ“ßïM[ù£§ë.þv²oõ;¹\˜+Psjô‡žÖ½²R5|0!3þKlzK·èõ8 Êa„%.9öå?ø(SÈkîtëÕ»Õ`Bè>ý½#Lu¶(0‡YŸg޶÷ Ïtzÿ†)P¾[ý-KÙc?g´·øuZ÷gÆÎ=ü0<Ô¤ø!¯ ýúÂ×ßl‡¡cÕ&Wœ“qP4&•|ÖÛ<óaÆÏ¥þòƒÐ‘ç÷fVXÉÑûrº©Ø`ñ7ÿ ³Äó\÷•PÄJ³Z%Æ÷¸±½póSÀ&nžR÷9¹ð„H¥åάŽÓl~¿HÂ[÷u.̸[âz¨È Á±ñÚš½Ñ˜`ÏËá]•õ5¹vþçq*Hȯ$ÛRfÎe qaïÓÁ3/[`|%óˆºfÎ S穤Éà‚òu™„VuÜÊüÚWn{`ö³×Àå‚ ÚwZ ê#p¤WYðçÆsL >Y½®»©t¢ý¹[zž,äæuyµ™ìŽÉ?€ç²34_uƒ ÓSþ<+yÊ)¿£›\€F>í¥×°ÑïÕ>—ö-¿0sS Õ#èæÝá¨A(:d/Q ÁŒ•ó›Ã‚Øq Gù 2øÙÛä»ä:b¾Éݸ—ۉП­åÚ°ó”V¾`õ²†qêúú“Ïeq(hÕ5˜v;ô³j~^ߣÓ¹—OÉ‘ÀzoÿÑg×¢!nò ÀŠ´VU2ë…ɧçÌîï…¾² ï¾4¹W''%zþËß~ŽÅ㛯E¡1kÛ´õ¹>QVrú«D =Þ(ÎŒàÜ+#ŽàÐXhÐë¥u+Ç.å5¿?-8e*¯»¸Wˆ—Ä#\ÙÓqjÀ"³Nî,|™ŽöØq‚ÒS¯ˆÈ~ãä蓅וÂÈÑê½÷4η'~f(pñŵ#- ù¿q`.îtÌß#HŽPH 4ŠÃN.[ñXR²ÞŒjQ€)1}½—„ ]RçX\‚If¤‹@îú£ÕLíãšï©³¿èmékµjã} Ð$^½,þÆi5³ªw'ÁŸ5ƒ0ùbïYÎaŸ?³çNçc ù×î‰{ã›ÑÖ1q}°pæã¡ÓB‡€ò©æÓ³g0›LsÏâ§6ØÊ´È-ö@ ‹7•ÔÇQ#…ˆL¥³Â¢ìÀ_k!@ —~bµïtIhMaÓŒC•[P+L+ªï¢d¤«8þaêÕ_ûí®Áqºù®ÅYü­’Èí 娢q²î¡f¬½zñ®D6Õo±«¯÷Ùæ¯w†¬ºÃ9âžYôÇ–oÌM)æ£èå…30•Ë-OàýSGÓlûT¡­kÛã–¨¨«ù0åêÀí\’ª%ÆqCò|…â0Î5RŒŠ@¿ GŸNtþ x‘>cÚ]‘°Á»óBzŒ'ÐòR0u»@$VlÜ‹tŒÊFROvö †­¼ýÕ+³í_. nö‹ÔÀ¬TC¿¨¨?¶ u;±6}ß„‡ú~œt3ÙÈS¹E±Üïã׌°÷}¬ëo+ÌR¶ýÃ%âQ ’'‚±ŸÎ­Ññú8vç Rbi™”¿Uâ^ªjzó'söÐßXÜñ“½¶_)Ž‚?¥{?Èÿ/KM:±O"‡oß~¨å%%Vo@þ~ÄsKŸ0‹¯Œ;†¦úo(ïþ,©‰}6†NÓL#É,Œq†Ó{] õ4|›˜øšÀöím6R.Zx4¨qVZãféyH¿˜ÝÙ;…9_Ê»,A çÇѽµ˜Úû5õýoKlüÄ?9ň-Ä8†â}êP$;ôÝ9Y«,l k>Ø÷gñlþñ^h‰Ÿ/ÿä—ÍV¶Ïýè¶C]ì馣{í Ñ“m&#Bÿ^0jÜ„°"×?G¿cƒ·f{fànìÝÆøÛUrëö¨×Çü…¦nØv¦¼ê绬x¡b#ë-õ#Š6IyþQ†BÅeüÙÊ—z”@‚È'\i¾x(âQ2Î|H¦û¦ñGŠLd+Ò‰TÏg™²dÒ°=º?LCÇ“P7Ÿ¿ŒãKÝö÷rT`òö’Øp{*‘©†œÆ«"ƒÍÿ´"}ûú±¨„·°e»(üò5î×Â…ÄÜ_>7HØ}ÄãïÝ3°j óòÀãn"׿¿F‹ã‰Ô6ÁC/®"Ò–öîK*„ΑyÖÃ7‰Tìß{Çã€HeñÓemÝg?¥{Ðû>ÆÍ¾ •·çžáz†ØÆÙ«D:¿Y¡ÞÐ9½b:±@¤v{ÇQíSH¤¦¦dón\ýü·»oÄ<ÁNåþ0˜ˆ¼Ø/ãÚˆóúÛwËuðiz®›Ži&àbØþ§›é@òIÕ¹+½'ìóTW(NDºoë2^uºHr90z¾bÉ÷c–UuUqΓ»K¥%{Þ¼wTÂÅšDÍÒY/l}q³Sûîuœ:-¥wMí#¬Oû›»ÿÝý–Ò‘› ŒXñoµr·®7ÐRÝ¡ÖÍ3Ñ=î(ÌhÍ|=‹yº’_nS`V«ào§ úªù˜}x-æ7ý¤¬ž#¬·n7uÞ€•ÉKo:˜ ºÇqÒÐÙ,{:ýô®}n+¾rÜØ6léEaô'¿›ÞÙ˜$qð?9#n¹7}ÒD !~¨$Ÿnæ÷‘^Œ‹„ ªÔ$ц XÙ¹|%íòVÞ2Ü™¨X_¶¥“L·wÜÚÊ_ÔvRŽÁôæ­õk:ZØå.o]yÌvd½y÷Û š™®êr¡¹Ù{ݲô4øýòóÌ7ÉÄU¡›×+^~%PÝ–›!7ãÈÇÛ¢7Wûaj÷ß™bØÔx¬˜´g,A‚~â½3Ðs|Ï_õЯ0xBQ\ˆiT~¿î.â œxÍÀ[Þí@³P.ê,~6-„A™Éúk ¸8v<`Ó2Vfk쳜 Ô  Óò\°¹Ký×RZ­áYom‹ 8}i€‰51Ñþuh|5÷-’EH±‡ô-¨ô`~Juf³4ÛôK²`ÆÝDZÚ›ÈS6ì¼sg`ö=k¬æ+˜«ÖûÝ› C§‹íKd ó›ïzvÔ–þ?á:} j«ìAáÌ=Í>í|íŒpœ¯=xÈ쮽–Maé¼ñ„+ÀDÓ2½À’Lu HÅå´‚yÂé%|µr_ëɘièQ¯ÚèÊÙîƒæ^°ôh0÷CÌ0ë¼qKivÁ?(êÃÜ^SõÚBiå¸l“8ºHia}?–{aFÔµlrÞ„ ¼©¤Ï@/ï¸\®ì˜]6×øxøŒv—DE/ÔA•©îoÈ=yu¼íuí@Š£ì>^à sÑW ‘Ÿágû¦–4ï+˜hNÞM†¾š?2ô“—«Õî@,¿ânA˜ûÔº´ñ{;[;ïÇ~5Zz,æR)Ü6X…ý†öÝé< i?º?³»{K\NBSuDüÕOÿý}ÅKúèfý™iÀµi1´ÁÇ`<1~’R­ˆ ÷òÊH;#`.‰aã_ð8´jkËnéÃBUØŸ¯iqå{²òóŒ7HÚ»*îûòŽJ¤íýÓƒ‹SÞì¹ì„£¢K7EêÝpòÈÕšþ ¿zfý˜Ž üí£‹PÕ5¹Ãò™ÊzígÓW„îÈgº?th`æH»;»¦%N4ñœ| ÃA{c>’»t…Ž• Ôùs|¶ÂCÃsSß·Ã(ž¹Kÿ)häUç;ÊJÂr‘°8Ý-Ÿá&–Ç»]A£XÇ_ÄCPÏ`µãe:ÏúÔJï…îB½ï½ßaX¨†Oå-8YT‡H~I¡Gí¶OMAÝ»ŒnB‡¡Ú 2´ooÝÚ#¶ª 0YÈ1¶¿q‹ÃD†®ôæÃ@Ò5ÖN }¿¡HdK9\:š%“ì7Ò»byÓè.j ¨7ü+FCmo…¦Ü‹ÀÚøwlQ¬ß°# ±!Šu7öÉ®Ü]}¦ˆD}×íA\}ë·îfp ¨n—ŸÜÍuÎ.¼*åXh±¯”Újë>\4­hƾþg =,FX/5\‰#÷¿9?µ‚9v÷á(Ñ˸~²QCû+‘Nç¦Á2Iç³×øÒxz‘\¡>,"ùgø<‡LvBÙ¶g÷:C›•ømF 6ˆ\Ê-íª‹ÆÚG.ñ/§aœÓ¶&Æ‚ Êè©J«ž½Á.¡…µ‹Pÿ›‹Ÿ”Äs‡L|m:`6®þ,wãg ´¬Ä÷>ÊËëRæüV0i‰ç¾«‚ ž»é¥)èv¯à:}ü= Ì4µ+èÅ…T%‡¢‚gH>L+œ¯ ãBŒ^¯.C“v )æèŽÿd|Siᕜ‹o̶݅ê#·:E žï‚é öIÄqQ™Ñ"GjZ&#¿6VÄ&(ç7¿Ãgø ŠÀèðöfVÌedÊÒ>Œí’Ó†RжWDö÷/~¿›Æl¢10&ܧù.ŒYû¦Ù_,ÄÌÒýb¶WK`| ƒ× O×KK:Þ2]ík£6–»vßzM³ÿVå½?b¯adöP %þþØú˜^ë›D¾Êݱ‡?ϧ–óëCòtÞ¨‡Ž3¬^Û€mzO_Ûì„5±Ïò§Â`óö˜£M¯`ò´A¯}?ôÙÛLd]¡÷†bŸk¡ 36}¿èˆ”gW«öá€áuþ“>Dóñ#.Oìa/pxx4(r|vyF/¡íê~fÒÿúýƒG|æÿh@$Tcºž©öŒh"´û ¼;&­ =!-WË«qòDJXW^$v¾VYÛÞ· ƒ?Ž¥xଠáõár+$ŸM¨vºŠSw=^º|I…_$eI“[X÷â÷Æ›D³|þ‡Í[t.™—êÆiÁŸ£ âe8pZýþÙ+ì/^=c½­ó¾' Žá”ªY×­uÛ_¨zˆ {bU°[/ƒÂÝ"ˆóÑk¢šÛ%pá剙k‹ð÷è‰"ƶ8+˰Yél…‹÷\s/ú]€‚æô׬cõ8Rß?Öý/Éo?M-¾„miµóÂÁã˜w‡A±ÚxlºA÷ö2’&ͬ-ø ìRø*Ø á’ßáÖß—´`ZÿÕYGeh8>[CLì騰çq Eå°TZ ¹;u™f¯ßLá……;=º¯‡›±Mcêr97žl}¡G‹äâ—9£ä{ØãSi÷Ü5ˆHç±zæz™/’HìyþµÙ5ÆØîŠÇ%ÑÏóVŸgp)õÕ’_/‘TL¹8H„E£ÇÇiÊ`YPåáéª?PÜ_½œ©ÃkÕ,',#Ô`!:A$­Á…H5ÿì4©$ˆÈøŽ•íܱ»H´•à7e¥Â¢<ñÊ ï*Ñ?Ô»UV* rÌõŒ†‰{=p+0!òKXÝcú7Gäµ3êï~UƵGîÂðÇc‚:J´@ažmûóºCo: ʶ¨B¯EF¬ÿ"Ðpæî¹ä3ý±RW”¡.).ë1Ô^;"3+´ÅóïÃþ{ŽÃ»¶O Ù¾ÄBÚ¼Õãûh¡àÞåšo’ÉJzb¹ÿ\t„›]øòú?÷fe‡¡°0ûÌy{yw7› ­žMô=ÊÁyóâÎS[ú4øñ‹V€2ÔÚ‡Ö×ÙâJ5·ið£u>¤!K Õȕ è=`¨¸>o”Rýº_úXôÔç ­I´]x1Èr‹k%nÂ%[¨TSp8IµŒuŸÚ˜ÜÇ¢õˆ[Æßj°b‰yvG¶é–öZsKá4ã›D?ýElˆÊпˆíöGŠs¡hûÁ€äzlyS*äx”H£üèäAyÜ0êÖø(L¤ ç·òêé"ÒÇ·¶&¼’'Ò­ÿ˳ݯK܃ùúhJdê­-l0o¯…f½ÄÔs±±¸ÈÿÀâ„R4Žû=ªìø¤…ÛIÔ!Õ;ˆÔ¹?íu|BdØÅöUW’ÈªŽ¿~¼J%² ÅZ)ÖâÀë·‡á¼nj•ºˆ"RºZ®M Tüï_µ$r;›® ιâÔ §mó5H¨ªHhÞÚ‡—÷ïgÂáÊÙÏeÞ¼7G±®ã7,Ä.|ç.ëÛû?o^!ÐlO½º÷RÆ+¥ï¦Ücœ×œTxVt'ž×-_‡N! ª‡%x­éšbűºoÂġʩ¿ªë¼8į5è®ãн<ƒÓAùŘœ|è›òÐ tNEw÷Õ‚¡ï³w¢j¥p9ñº”¦ÕÖóòT=ê-ýIáá<øçv 6{°ÅãSTÑn§a¾ÚEÒ÷ÃŒ:Kí°a3…E’­Tª=LÄ}bk:°›¥^âù [|ÞîÏJäïéyoNÁÔäÛçN\@‘zx˜ê7 ¤Ÿ\Ù]á¤+Ýû¼Ã€âfu‚ÿ)3ùv‘v= sˆ=¢¿èvdêù¤)ÏRÝ]"íÛ Þ ]ž¸Ô®×ty×wJeÜuÖ!R]UôägÇ…éGaJ|DÆÂñk…V 8üå¨ei­#Nþ¬ôxð_ñ^܃~ åÔ û ìµ<¾‘ò! G~0ÒÆÌÌoÕ<å[ë n‹ÏpŽ]—$nçºUË/HÜ«fí©û+}µo]V®ò p3æÍOi:É…±?§¾¨Þ¼cb‹›S¡PÓ}òF—Á”óîü ÷2.®e'OáD|ð™Ûý[ywåcÁî$‘–é5Í`Ž5®¿ëHÖú9E¤ß•yJò%3‘ªuNæg?5‘ÆâoPhèì¾é\šrHÕø†e ¦Kÿ<°¥û¤Ç;"S_©Oè<©¢< 2‰EŒp‹Ei¹÷ןÑ?C¤ÞsÊ~Añ0®•*·&Ý!Ò†69÷÷/‘¦ŽÎ=³&?~bó*fˆ¿¬¼Çb‡†ë¶ÖÚïÐÒC:<ì´›6› c»æžãí¬Õ¶Ú#ývF/9üÖ‹üƒŒ7ŸÉ܆~šWž{ØÇÎm¥qïz¨À án J[ªôÅN|uëÆ™7íHªþêzt+™œ¼ný¸ ù¿.j ݇Z?Ã5‹~OèÐx uìJ#<5ÄÄV&—U>ÁÚÒ#†R˜ù¦\÷ôã ,ô¼kw:fëÜÆ‰2Œ8¼|µ‰†SGª7Ù°M°Û½þAÎÕÔø=Qô#R‹Hü~sò0þd|ñX T+â_fAÚsÎuí°`r¼˜óÍXSËöªÛ·‡^ÖGn¾&ÂØËÙbþ s˜»»¹_) Ȫ*Qúc2˜²»óQCF$ä^2×¶aN„gþ¥3^PÁþÏ[§sC°+êSÛI‹­¼[ñ©^ª> f?¸[þû=~º+cMõá ÌJ1öfJ3Á@î—2Ù[\˜ñ ìëßn¨»s×"LôtõÆ9ˆœ^ƒ~f'RFÛVénͦðC÷Ìß'BªÎP³ª¾¨$U3IW¤5ÿâ¯ÛZÝJWY¡åìŸý»çe0–5¬ôíb-¼Ž~îþ¯ë¶—åírd8f²qÑZP{³žƒ"Ï ”y'ÔÂJìmï O\‹é<Ï̓‹™ÜÿŠtíp¶‚Qƒ.0§ö÷DHr×9<Ž?«§ªÄ5–ºãò·6qí†!mÚÄQœÿ”~?ò..ËÚ’_åhâʹôç»ÍÜ»ÍÕÙšUöé*†c'<ò½+±Å¬+Q·/YNT.OZ‡ª{«OF Ü1iêwbJ54÷o÷·ÑÁå4wÍuU$ÍÅ+Ôz×ᦲœMûC\&_æpf‡fÓîdÅ­yþ¿Ÿ8xoç^q(Êá$rgF}, 8íÓ ý]‰&nÑGaA¥°ÚçÌHkoª~€^k5ÍAXª Îð¨ ņÔmÙZ*0«´´s›}' ¾¿Y'þÑê|?Šº8Ž¿Ìàß•CØùZÊåœ_Œ¶fãj»=£yõÎS|ÐïÿäÚÓÙ˜ ™fòqÅŠ^“Ÿïh°ÉúK¡xÈ1h¿ežøÈzÈ;Rýk}a@9ùà,¯ê” ݧzf ‹Žë„žÖcºØ TÏBÿùFlÏ…Š/“ݤ+ 0ZÜú2zg¾ÖôH÷Ãi±¨œÆÖI$ËÝú9lôg©§Òäzã„„ôf6üeL èJª#I²t = §øl"¢KÏœÒêL…jQûog ©pRL湌7 *7FºîŽÍ")ô›¡A”äåˆØé“sµ’SÇMmqIxx’}äz/~OÙ÷|úߦnÜ’T0¡ÃÃõËWû$ÓK™ö=Ái’O‚ü>DZåuC9ÑWX_tuÛrÍ&ùÁ‡ï„ç¥P¿™³'ó> DF´•+°·Áiƒe0}K§Ý5[çtî «›ÃìéÁí~ªÃ`â †Í_8§o@l|€SºÆ;H*'ݾA9ó½Y$CÙÐ+úñvÈr%¾5[±õ':A/agÒº‹:‘zí&§æ›$ qͨQø„^&)Ã,‰ÖÖ¯ã˜&R9å”>ž\EJèYƒ›ò¡¸pÃ÷'“çvGug>U<ŽÄQ뙜V$±8»ü g“NÝá:¼‰ó"{ I\~8{;¶NwÖG:>OO'âȲ©ÏßnØßD~|ÒR§¯n—YB’Ñî» 7 pBä±Ñ³¿qZ/zscΞW^´FŠCÛ Qoר7aÛznÉõ÷pÏ-ú2J½»Ä)v †…Ö¸.Î*½8Y·¥®ÝVkçù8 …má!Mo Ž)QÞýµŸÆ>‹¾+gh>ÀÌùó_X] ÿoÇê¯jèzSíf,kV¯dZ“¯bwã¯FD_T¬–Ù„K4AâeŸ¶tM~þOO&üVßþdêf;Nä¹\κSÇMª%ûlq(쪳•îUì.s ¬ wÙ‰i ô–}µ¬¥[§Ç”ò/F@­Fß¶vS$38…Dÿx€óá‰-?Ïõâ8GÄû=F7±å´@<Åh §^X+ÍÜŽCNÚ_Â5qဦc «øQ%ö-¾ ]·2Äþº¯"nøïÈÍXÇAlõÌé ñ;­Ì•j¦g‡!ë¼m¨U uÞ8QõÛ$/Ë9°-b£·–ÑÆLÁ³^qcØŸd>fe³Šÿ5öÍÛ%àðÐ?yÂ,PýÒóèŽMü#sHì[Â:Š¥ÿ8ƒBtoscÐéŸHܰŸ3¶¥y=©›0‚ʬ.û]gf‘È µr×k¹ÎÖ-}„O÷¦cùÙ21e§*éãYè΀¤gбáp“™‰ ŒšˆÕ3?ÃÁ…òŒ.Ö (Ô{&7x¬Sü†s _ašjëlRÆwl8ub¤ûëg¨‚§ ûgNcÝZKe»öÖÇ…Æ}‹… ­=ßR, 'téÇ¥úX²7HñåÝkØT•*qXùvtóó+w»â]{iûƒx¤°F}4Øù&+Ä/^6ƒ–Òåi§¼W8º-›%ÛÒG©<Å”/íj%Ìžã´|i—QPŽþõ^$Ð*¿±n·ŠBrïU¡Põ{Ø$Þz¼±ÖG{ N‡l‡ };Ýn£]VØ,ºtB™¸–ÎÜù}›=÷˜šÐÂ@KÛsr«:Ö1¶"«ÆAµs™³LØÏ{‡íéˆÿ¨~5èoTìõH(¸„õNT&¾§œ°ò…½šák™;4^`^¢NüŒ"V¿Î.¸Sόջ²{a£ºí~ÜŽ=g5 ^ò†ä¸P¿ä™8¸ÿzzén;¬p×Lúu›&öL³ é܇é}t²J¡°Â:âéôëƒØ_·.šcA·ëج€9¾“3¨¹ù.kô¢:Ða3ägæ+…½_¸ýÍãðÓ"ê‚"özG®Ö¬`‡Â‡÷·¿ÈcÇ*ëkYnkÌö‘Ž XÈ…ÊÞÒÅö×±£ìÛ¾ý¡ìت»PùˆøkÕ'”Ö±²ÿŸm ’7w½¢ÿ¥„×öéî<¿ˆß3üuT>—ââíÊËûìÉØ"³ªc}<'ö²~R%†âà烪µAPº_Ò3¿‡SկEõ‹vZ‘ÎØ¨ñÈèË40 ÌûŠvâH\“yLàxptž@†’ÃKì—£Xq*ø•´ÝclZNN—½q'ÞfØìʱiÃóWV…=ÝíšÞÄ…uð­kìËYú“éÊ¢‰üÚpÛIÆbÚcôÒ×¢¯!ÅÐ'. Åé.°—/zÜ´„*]Ù´kåI»ˆ1—B çôòˆ´Ì;«þ½¾ ¢3¤··«¡cºýÀP—&ö ><<ñ<§î¼ß–]‹ãºÇ½ZªÄ°éiæÎwwp”:ã«&ë£Ù4ÙÀ5›výí~¥Ýì.¦<°¬y^„À¤ejô¢ë³køG¨Ìq˜}ù¥ Â"À&å.¯7ô§ ¿E]K†áêMßh¬ŒäHÈÇÁП,ú#š8Yn¬§vG„žDLZˆo͑ƳQBÓÆ"£äeHHòÖü~k+Ç„žû¢)ó#uLƒ  8`CaFì<äRKØ”W©Â°]Ìd•Ú:PH Ï%³a¸øûNËæã0Ï‹SåË–°VÈt1þD9¤ä¼'IÀð'/UïŠÑ-~þéÁ«‡$ÚÈ÷; qÎ/±ã²Ã59xYú3Ý öÝî‰Ã}n>ý_æp¨ýDc·üö fP°Ç¡èS*q9ò8¾÷$ƒ~¯-d²xv„Z4áÐɤn ÿóçqÿ–n”HWrsØ…Óá<ŠöŸ°Mojö{yÌ™—²è§‘ÃÎIÇðûZ8PÉÔTct±oÐÖN9îS²-±ÝêÁ¬N®Ž›TÈD-UàØ˜þ+vaQìM¨,ÚÏôÇĔ՘÷cõuGÉœèÏHáúv[Ï=µJ|ÚuËš÷ÕqªêAËòÃݺì¡0B³o¿ó-Uìãoq®š6ò/Áë×Þþ„þUMÃãîúZQ­ŽÆçh׃{$¡ÿäILò–…K¶›6gaöŠSÀùú£0©Ã3£1½ƒëOˆ§öÀ`åðÏ›¢Á0*j¿$ù«f=^ˆ†î݇[.ëñ9)äg*/dhEº œ Ó÷ùSÒKh3ïÖ[¶ïNí7Ôªn@ÑîzR*_‚”]¢?›8â ÃjWžV}²Ök) ‡îÚok¬ÓŠÐNÏ{»3²™ãâö·¨Þ|}}7j“FM2ê9¬æÁÜ]sšÅR¹ÙÃuØ7¹t„jHãó¦®0›hhsù°LÈôÕöóIaÓ‘¥ÄIÞJœ¸eÈèï>Šõ/Í(žY@’õêûµCØjÌ¡%VŽûlºñèqì}¥èZGÖÂ)*MÉtw¬Õ +ÓšÁñ–‹ú•±Êm¹ëÐßBhÊ·–xÿpæw‰H°òÀÞ[36!"4™ÉÚ~ÆŒÆ | Éÿ¢®Î˜¹c‹žáC¤:†uY‡SŽø?Îh[ša3æwàk l\ï´JÉ}c9©«°J{†åºÙ-X|)ְݘ ?”¿7nBÓ¤csÀ,`œ|ñê‘(ôþsSó0n ó¤”[dhê/Ž ž†ü˜4©“Ônª.à¦fÿúBÊŠ©0þ¾Cîõ"ìÞY%Y<‡}‘'‹Ÿ”H`k£Âp`¥#¶°Œ‰ÖÌa}_«m„[_÷Ý.©ÛB¦k°B—gö ¿4p^ê³g¿ŽDág8Þ1 ñGµmc0äÊžø$+¤»õÅKÃqÄ••pSg§ÎúÚËñs`;ûgߨõ ôpÜ+­ârg,9 Úݼ[|yâ̾E‹­ûîí1¹ŽÃ,,î}ÅÞGßž:~ÀÕûíÀ¾‡Bš4/yptãÔ³Á™cXUÒëꋃoo¿ÇÙïTgX‡cË<ÃU½Ñ4œ”<ü…^ÔÛEÛoØ?Áü4 ×oé˜Lmâ×'(¸r<µ66Úߨ˜%Üd[^Ö+ûZq¸ýajøÈ.ü}ðqtÁr³MàÕ®aø}b´qüó?À"ÍÕ„å\Í)2J«ð¶fùß>ß>cï7ÚYYéØ}ÁH°ÿ9–¾Ž²ÚfLžÚ|Kr…±°ïßšolåÒFžË;²`hÛæõžXèÓ~iñœ_¨º¬ɰÇ¢·wÜœõ ÄÁ)î•À Ñ݇]ÍëÖŸQ>èž–€SÝüûs¼rpâcЉWƒb8^+|–»g·)—(iÑàZ·à!»Í#¸d!{[dÍgW ­×ÝâqÍÍ:ç¥Á~º'q%öËOp׸TÝLå”΂-Ýk2b;VhƉ­öåÌÐoå<[Á)µW‡°S§ÐõìiSl¹Èí08¦ƒú ÒJÔ;![4ׄìW­-Ì"ðÇK7½`­ëõãžDéÖ᛽°Þ·¿X{½jÒ.`æ5”ÿf ¿•ƒl²å °Ö÷ïê‚‚)6ùNr¸£!õÄç‰ÓbêØr+¹wù¡¶ ¹[…}<…5WN=ÏøS<}æ³Na?UHЧ>¬}çÖ.¦`w§¬ÿÁHf¿è ¯bý[…"ÌdOŒ>óËŽÈ÷Êb)õ›S UÅÊÞÑñgäêV~“ýa‰ùÔn‘êö×pøMœÀ¨÷Mœön¾›Ý†mì2Zœe8œ3®íbx;å_¯K=Fr2s-ãùv¬»Vܪ Dna‡«¿q(J_æŒ! dÿâ|&›s¿\ªé9¾Oºu6ÇylNb±óe›ã›ÖZÊqâµ3vNëXð qáhÈ¿C±ã°J¹Í¶Z·[8H£¾ï±oøÞõæcXÏpá^Óàe6-x?t}Ö^ƒc:®@mîžó<Ö˜ðÄò¬w<Öѹ©9žÖî{¹Í2ðO5ÖÓ( mé¾ '3+A+‡@Ŧ„ .ŠJëî… Å¶Ýªƨ,õ=Ê »˜" ù6q:½0‘åubÙ÷RR¿p ýg›÷£e(⻯˜Ü¹ŽµÍd}—Àìf}úôeŸ»ËÊXlzûøŒªÑ}NQðÒNSìpÞ9¬[OÁvGíÌåžRl=gÎ$ºÚƒõ#v.1ØñÎè˳ì ðaù]þ¡C8þñìõ=PZÑÁ}DjÛ'ìêâÛE°÷¶éÑ$·~Ô0º«[ó=izÕC·rÇ^¹”»8æ\1e¥vûzùÄ7ž¾ÅÑî;¬æëô8óü®îy:\œsЈbG’Ž8UÖΣØü©›ÿñ¸ÎJ_ýÒCÔ7ãÂúZ0©‡r2A¼§ûn°ì;€¿~ê¿ä8‚dc«Õ~v^œ¼ucµSC çh¶ï^ßÛ„ «ìŠ‚cãý¦-.lòüYt+{jT rðaß_þTÃá l²èÙÖèƒ}w­‹ÉÝÇvû/"Žv…%ñÕâÌ_÷&%#\ädaoì®Ýâ|“\[Y [ŒÖœ¸Óè£2ö퀞¹HæW\Øw§ðQÔåH§StZØâéÚÞÃ}À¯]ÄéXÆëhî\7þtWŽëÀ©õ[ß‹ yÿ@«(-'~æY*bßÞ!‰–™£8ø8S5áéAìnŽzÉ™‡M_³H¿rb~äBKíÅçèûS?Àö±5ÿÉ=hâüuþûúkeرêÚ¥£nËÅØsôܳÍU(JNXx§ÜƒEôŽg» Aâ+Ù´§·pI$Oö¬¯ì(]âé3¹š±˜Ñï¡Á_£ñŒktV1[{÷Jû‹¸ŽEé1þÖÚ ÿæÏ‹ç>Õºëƒ‘ŽžíØÙÁÿ*•å'–x¦®`«ÒÅ Þx¨_5íR…‘“Åu·OÁè×m}Ç2]‘ÌâLm+ä1 _oÆÞš!fZ³a,bøCtÝÊ-{»†¼iqVAà–ßð»úaç.¨†z÷E)3*U ›¤¡¸­;`LNÍÙd;èþÆëÇÿF»ÖFwöáÔšãžåS[9ûB¸íš f›³ý¸˜=Ùu« p€’Z?_”‡ÝÇÒ[3Mê0·ûØÃÁ'l’H²vÙ‡c× eÄñ JýØÀž¥«Ý-g°’õ<Óª}är^‘Ô×éÃV3_•û—1-T{7¯Ž>ù‡—‡µÎî+ÈÁ0žªŒGØ•`òonÇ 6Òž9Ú÷ÝS©,JË4Ó “ö…¡:ÿަuü1,Å‚{ŽÁM œ8~Kã.Nìhz1ø÷ ÎÓ¿cLï2ÂÙ¼pÁèxœã=tR¸§pœo^vÀBE¡8¦Iœ?ü‰œèÊM`a ¦„^B2uˆ¸^$v–ÎÕVb›˜M™>.ðó6Øíã“þ·ÿ¼Î gš[ÅÊ8°jùàûi ̬j´U‹ÀáþÒmñê»lv/R˜r õ¯ßc´ÖÇåÓÇÓÛwøã¾V÷þÃiG©Lf?:ÓåËbRO¤Ý8ÆÂ6³•W|×^þN¤ÏÉî¤Gd¼4²CÛ°ÌÉüE|ãX¢Ñ¬Ÿ#²ò¼/ß[ÃDdª²P# Dd¾çÞÓ5Dªø¼l†Û ¸¦¹—O2Š„›;=.eëã¦äŠ *_ ’œ×¤Báï¹?|&kî0ö½ÚåðalrjuaX²!Ð,4¾á|B 0¢uÔÑÔjÿÔH§œ^ü‘wçšýO˜=qÛÝŠfÌ ¾ý©îšKû[ÏVHÌÙVO52Þ ÆÎ{$èÀ”öNéÏ\@~¡xew’÷S÷Âê÷AÊËï`:™¡é§½0,´Èűõ‡ò |æÄ¿–~*|¹wïlvÜû®¶¼yH\ÏÇå«»ïSTrqM;/òÞh®›î7<¶A¤Ý¶í·‹êwœS cêàU&Rõ‹^/µÜG¤âšz©ÙîËVwü"áª6Ó ‘ú^"íáÜi£ž8ÛÆ ràJ® Q›dÛKC¶™Ñ‡q8’¬#õòyŽ˜ñºÐcKŸ¡ÁBàèpа{˜ÿ¦y94š;©eWÞASõ‰}מc¨bMâÓ¹F¬¹K»oßñz¬Pyê(‹­YßòvbKÃŒzG¸¶v\³<¥FÄúùî ¾³˜˜c¬,Ü»Üу"º#††jnÜÁú¢É¡ˆwÖHjiWö|Ûƒ_}Žú×`Ë‘z…;e¸ muû&×'zh:µvŸo:áØðr‹Þ³f$…Ò%¾õ|‚ågØ=ª9CpàÓ…ó§Ýÿ਻ePýG>,|hqåsüÙžéä·ŠL"¼+[œa§ö%p}§ã“•NÆyàèu‰³=ç¶róXµm.î\¹¶Ëˇ?½ÖˆÅ^>ÓwuÑ»±OùÞ•Ñ œ¨8{’Wû!VþéÊ~š,ˆCaëaÛ'váüT™ÇN_ìKsq¸=ŒVÛõöy]!`‹©jÙ—ä#بT•7ŽœËgN§ áìB!WÍË÷Øö@ðbSý#HþõëÁ&’M¬¾¿SÕÀ)Ÿç!õð¯_g@ÌÞ³Üs¤"%ËkOë×-µ“Ù‡ƒ-r‰×¿`K2óS¿ç‘œ—{>Å»Gʬ¬+çaCãÔýNK¬:&Á¿‹ûö¹gj†c]ÓλNeì8“óvRòVöæ²Æ\®Ã6åL™PõìIã-jþœ†#qÞT>ñÓ¦®^À¥ßÈ¥YK\Ñ\­¡^ƲWnµ @š¸#ïÃi3æ•>‚\òärúLkkt«ÁYQßVƲ[9FÆÜ¨û6’ÛŽ÷¾åÞ„ùœÑú"iO=ÉÑ6Àæô_ñüùö@î2–v÷$ÂÊßm;˜ÈØ<húþ(ÎÇ$ð´~„„M›†~BPÊ©aN*¢Ç⯠ãY¯ºaiwẲã$ýï1ò0ôo>íæËªÁ‰²ÈAu¢Ðám§ËüóKFŸÚ%æØݶر®R;ønI³³ÇÞˆ NC­0ÉúÃGÇÁVÝ“÷•8°ˆ$!²œ¸Û9§yéŒ~:ú‡i×yïb~*Z©‘ ý:_^à jþ­ú}8èÁ¼%ªõ!!ÔqdÛ9CGŠ öÒùÔe4Dp|¸^‚ó ƒŸéŸ“n!b©KºËPá V <ÜâÎàiʃcPì'võföÌ<ߟ,ì(cH±I.|“Œ ³šÑƒÐ±Ž×do6¦¾v¹p>xG’ÆcRÿsÿ…/¯†~M&–{DjGJ?ÇúK#FG{ö`ç×÷-Æ[±zÏ_±av)\!ig•b—o3×íòH=½™ùœ&6ixËHM@Zêg®U[üqÂÇJÄœ ·¼¼ód±ßl<°ëšOŸåÉ_XðÜçÏa/Uœ9Ûö¬ô­vwòŠÆŒ­çö œ¼¹Y;ß6ºâÀˆ•Üêît®f¤T]ÆþëLnAÊ£8ÊÍ×y“¡Ww‹ÃB[Dés²<0„Óµ†Û˜.Þ„¦›µ ÏÞ~…¿¿;[äëCYû[=2ô´ÙEøÈôà‚óv‰ºvH*ñþ~õhc?Õcœ&I>0d¶Á‰Í< :'?à¬ÒMÎåó¸ò×ñðÜ»XŒž£ì~ÐÓÚ£OëdAâ}y«#Ø#§nûl» v2*sqèÂaîðq­¾¿8F +íîüD`¿ú÷¦c,P…Î&³½ IWí¥ê^,œbÓ?\ÿŠÊŽ'x/àDWÇyƒìdåçŸuÞ<­/yî}ðÖÙºtì 4¶ Û½i¡œ¿½EpØün©Z‚#¶µ[{_¬ÑĶzÊ9"öikËñæB¡ƒCêÆ_$DÖ¦³–[a4Ìp×"m~IÙÏŠÆáÀ™QW§Ž œîdvPü€o®²Ð<À'Ž$.gIìnr•]£~…vëµ­÷ïÀv+Q_·§¶Ø%”ðK0Zûo¶V0²Dâ˜Qä¿vl8L_žÓ Z%K¡æä~]®³#¾Æ‘Ìù8šöÄ›²å$c“2‹HþÜ ì¾z ìÌúœ¹ü,´Á}3–éµ®Ì bQ²ýîcz¢N À¦–C­E´,lR"ºxŒäaÃP!üªÃì-ÍŽûä.cgšñçófn9×MP’nÅ.Ÿ‰eÉ9l¾ùSý‰ šZ'þ¨HiÕ~el`ˆ“‰M§°Ý[ºIê³ih­oIGjšž¹l0Ó8+ªu^kci’ЀP”9väk]RY‚êÃ{«.â ÷V5Ó£X!õ]:þý|úGq­Pj#M’ó6¤!-·eŸË ÖþÉyξ®WÙÌf@ö3õï7:Í‘©©ÜYá_ò¹NÇš»H{©toÍ@ W.[ß++€%õq½cÐAôy}c˜Üqí¸¼+þ²õv7Î0Å%WqÃóÑŸodø µNÙc ÎüÇ“RlòÅ>¾>`…å†oø.} @JІUª"mBaP¢%–Àz…ƒ#F$Co„Fý ‡ÚcþQ™{ãè³è7Ýk…$!‘°X1y$…kØø2|SN_ÅÄ<'4øa¡X抴]Ó3­Š¸"—uèê첡^jn»“—ã½örÃ"SÀÏÊC˜ùãÚâPY5æjºé8nÔ…ð×Z§xaßÈÖ”€wm8es¡WM»i|¾Ñ“>㜖ߜË)$ïå“w É}ïÝž”Ãq³#l™iž8<]wÃÅT§ï—Ͱî^Þ³*ͤ`T&ÁtA[†ÞJçgvËC¿o’oöÖ!(É«Š6º¢Ãu›í“oÀìŽÉðßQ–@]“T‰ŒÍ†…'?MvÏÂØmÞ„à`äɸÎ;u 4VJûg<ÄŠ×wN[#5±Xn6Òkº¥?u¿€]ƒS9†o&YI°§b{†~]$…YåÊ“yñÃʽ «7òسUú¡É`&’jÚÙH Ÿ¡(Ÿ&SÔ(ƒÅ§÷ÖmzÕý§Ï8†Æ˜å}*7†¦ã¿ÝØ.^¡¢Ê=kIw0X´Zÿ#‡FC=Nt²cÀ‹hî Ð1ûfrž965â·$"ñù¹®Ä$¨êw‰q››ÃáÆöï£q° ,5ôø\Œ¾·çZØ} Ë­Ýøº’‹;•YŽH½î5&CZZÙ&–æ6X<µ²éò6Y˜¥½³/)U]›Þ‹ßŸÃR St¨ÌþÎÜM~^3êßX^äÆÁøìS>ê KUî´HßQ˜ý´ÊĺËŽ†ÖÆ÷„p~‡ ©âãE,áxÛÌzDÒ(d¥ùЦÓ2Gˆ¸h¯“4ÿퟚÎàšuqò=¡\\™®XæH˜ÂÕõí~ ×îîŸQ‰¸€Ëõz UqN )æ„{?ÎêüPÈâÁ¹æ5ñ{¶¸ÚålÔ®‡Ë%³~}ÁòŸÏ éÓ¿¬{ .,’»ãy6¨‘Á)3ÜÝ"1ÐÈ¿6_šì#Šû„2òp6â„} RÿzécÃÙÇ^ÝTå<¸®œy^GÜ v.”é٪¤½kžH¸ûÝäަ$l!³²â_¢ùD­VNExªªÖá°­ZTIÖŸzשµÚ„å1ݬ¾ Ø3÷Ô=¤; ˆ û½u¬pëûûaX›¶^O~uÆð‡™²c‘÷ûU÷=¬"=›÷¶,Aq’¦L†¿³6ºq«£ŽòJ}‚%Ù¢ÞØ÷ØyàPò•ðZü¥¡ÓÙs ‡HZ.Ùuq¤6KJ•cÛÈ[dÞV‚UÞ³° Þ¬9çú÷¡õ­&íCý!l u=Sǃe†3Ö>yH79r\DŸ›ãvn.7…áçŠÞ^æça$bt¹Ö[«ÆOLªöAaå§žÈsµ8XTVq3õL½0âÝ£NàÜ{èÖ{ð‡U÷̇–,I8rAF1H+ç’Ä_4säàt“_OF.Ζ¡3ãüÜÀ’áÍlœãØåõ>GÅš®¤1}ÇÙNùFÓç¸l¦™~T—Á'³5» LŸÁ²Ë¢û1ˆz“§…,6Ål+dI°­1ìÁÕˆŸ“d* „/írçíRç~ê—wøÛÅèT°×6¬qá²,'Á¸{µ—Ù !WÑüR,þõ¬ Ø)s«¥ÔÚWq‘é‹F¦ÐeœÞ/rëêõ8s½t4Ò¸ iEqñºÑ@zîêB×—†¿,!oƒ³LñkÒ Ý4ÈH´á.>¹…¹Ÿº%þ@kgïîî8 (/4Oyíêíqþ¿ÂaÁ­ôòV5 0-é¡|Á–ûnV’¡8USà)žÄŠ ›Êòz4g¯qéÖÀf‹ƒ:‘/¤ipx9‡¾;Jˆ‘k¡sCç ³Dì3¼V"fƒMþ·åDÙʰÍç–TRž6]¹å¹]/ëÝݦ-ƒ/À·_g­LŒU¯'L9ÔËv\¾|öç¸= ÕRÀ©®RÙ¼3¦gÁï| Û7>øØ7“‰ß£„³:°+žÉ9×<²îg¿¿¶8‚}¿´Þ¹–ß[$2å@{}dAŽbÁËɸkv¬âu÷lÊèÊ—õ2¤m±¾ea Ôf¢Çœíûâü’$ ÿx ¬‡D‹a•cFP¡™FlõâéËöÇt|É/Ig}£wâô/¢÷éLYœ¬üIã•ÁiÓåš Hjq[y\ë ןšå4âtæq3v‰<ì"<|Ïy×Gs…õ|Vý².úž—(6íyçêoL`;#ôiýcl6 «ºÝ[Á8W=É{t3p¤é‰.Ûû¹ÒÐÞÈÊà†ýQ¯ÉCHþu#YYp0õ/‘Å@Š1‡^ªv˜%°žò˜øBÆ9®¹à¯ÁuØòéQǺçóØÍ¤^ô"µ¾,¯Ó!ÝWÆ™·?"þ&3CY]ê‚=a/¶Ê9ØIÞ•Æþz3/—-H<¾)ǨiÒæO×pêV0ýÛéû8©Yív°Î(Ñø‰ùy\ ({33õ[î|Š>© ,!~øbó—Ms ñW`á‘ÖU6mÚ‰b®DaìÔ²94ó¼I#ò3÷d›¡hÓGÙ5蜌ÐuÞ‡mLJ¿ìôüaÝ:"®±‹­w%‹ï¾}ázÛƒÒ÷cÉy«€ßûz0ϨZ”` ù9¶Qtö>WTè7ý>$¢Í“j¾£í>ñy˜8{«¾µØfmröVÁÔrWßPW\Ûõ¸ƒÏô"P¾Òx}®×2·x§Àìî}ÅGÌ‚a!Æ©_bÝ&üáüØæé86ÎÈ2×@ /5ëÃßÏHö,Ð=r8û¦ö L7gbw¿²mÚz1s¼efËS„ ‹üašHm¾¥vlÎG×h‡œlà÷Å6Z¿Lnð¹üâx"vÔ¾ºÊèì©^R/­¡ îöï™4´»1«Y=*óWD.aE|`û<Ø)’ —ØÏ>³Üãêǹåÿ]Ç!ƒ®ñÈ&8Ñ›Îãíüéá¦U P¬n³‹ÿ”VDîø¸ÅŦmÜ©|…‰öÊ/²¦0uÈ–k)àÐ2>Äö=.öÕúßIXíY}¼Y;fü­ùCïÀЪ“ËË6ïJyFÉÊ‹ÓÒ@ùg#žÏ>æÐßRÚ6ì=ä†5®c^‡åѯÓ·Bž8ë¸1¨nòÛx]fÊNò¥˜þn÷-OЄ±«ûF›ç,Ë•öÅÛ ~H|çm‡c$‚ÕÆTlm’žޫĆ0¶„Ç|ÆX“›=øýdw_x^n”ÅÀ8Ñ—KX·3$DŒm{ ì…œ=pðxwÜ\µ/R™í¿¿ËAŠŠ£‰P¤&’‘'ä+·vˆ+ò¦5þà 5NA•Lè!»¤úÅC½iD‡Ã¦·Hö˜êYÆ‘«[Œ |µ¾žò'CüïÛйît: ž¸;pMÕ•ÀEâbºnF`E¢áÓY>ó7zŸI„>5BááŸðmÐSý±Óâ Ò*ªÆo?À•*AÏõzè7nݡ󚌿܇½ÇÎvA®¡åÇÝ&ÁíK“'ÃÚ;µŒ­>˜Ô‹ŽrŸÆ¾Sº¿üaÞ°¤4þZ*,%Ï;äGÂ"aöVJæ+sö‘JCE WåûzL‡a¯Êˆ-l®Ê·NL«PoeÃSì!Œ <Ⱦf ãÒé#û™íú»%àzƒ2Œ ;¼IÛNƒÉRs®¿®H¤‹Ép½ÄÅ >‘ïJ0ýFÜúëÓ@˜ÍARÞúb˜NŠ—SݺŠS2{ÙÖÒã˜ûtØÎ"Nª´~Y:݈ýrJÍsM8oóðàÓ8ÐrØ‹Œ“fDÎl'ã–pƒ¶<bƒP­ö!$gÜ“à»è€$§˜@kS&¤ðó ò<äÔim! ÕIwÔd‹KO“9ÏíïÂN=&»²í]:Þ¢5YôcG8›O!íÂÌíœÔ}Ú¶ì"®|c³¢(ƒ´©m/)é»qn Ñã$õ/–þõH—RÅʲ©¯½p0ü–:åðW,;x1}3‚M]?<ö‰ã#Ñg'=<×pŒò6j–0‰ßHßtÙ-0ÃFpˆ|¶ºóeîˆòízõ;±i$}bÇÁ ƒ{>¤ðëÁ7‹Då–iwÌužI–i† É÷æŽá@¶!)›¥ràòþÒ±˜*?>°¯\°„€Ci=’ò,H9ÈÝhõ3Ç­úD6fó åƒÞœåÝ$¹]íuª‡KîÍŠG_ÇH×|Ušº)®ª=ü׸Iê»óUnÃ`°Áfòãx\â7ë}Ý¥ÄîEo3†ž¹zçï…±áóSfwüwm¡â„ƒ“g7éœsÄ™†'½ª2<8¨áþÕ³þü:x+Mù ³EϹbßa¨Þ¾­L}Ԝ֭€eGÐã)v$/ÉÑÀø“ «ÊCP©¥èeÇÎEÓëÙtm¬Hÿ.Ÿâ0}Iù¦  ¤i'n6}EÌu^/<Û•Ö\11˜‰Y–_‚¡Êó½Ã§*pì)‹öô\­#Ä_ñ»#yOžÙÅ´¨æÔ˜µ©Íð¶+öüþq¦ß.Z%[OÃLkráZ°tXǧÊëÿÃlgÿÿÇÃØìL¥Æ[QqVXš™Ù‹ ‹‚ ¢÷/jB™Ø¶ý19ÜPe}®ípÃ÷¬Ìü '­@£½)ß‘ÑheÊãÜ幇õŽ]ÕQJÁ±WÛ¶Ksã¸Ø º­c'cî4¤ÄÙC½gÝ.RÀsÈí¿Û&3¿šM[V¹ª6ÂPÞ¡Ü’Ãð¦¼G,=- Z9·lÄ”QýÁ^´Úøÿã}°ª6¼þ[€$vëz{K¤ãÈÇ=œe a"?¿«q‹LÖ×2æá¨ãBÉ ï˜Ž²k9£¹c~u<Ów`¾å³óŽg` ̲[Ü`ð6ŸëP`.4üX }¥î sDÓHçû mÎáŽÅñ0ñ÷Ä“ì[;aÂäLg×{ š<•SáJ”†$C@kˆñŠÞJǾéÎKïþàÌ–r¥Æ„^(zXÞ-sØ)™¢ äËPq´6i€gˆÀœÔº ãä cìgÎÊ<‚‘àI©Îd(Wxö“óN3=‹S#¿Ä»¹íVˆÐÃ{gÇÞa¬™ìý¹¦æu2CëOìÃ)ý4O²¼.¹ñ\êð…†ÁŒà9j0^,Ÿšyú*ö]¾T­ƒ«/bÚÓ=pzÕòŒÓ‡>•bSudø¥î[ÏcØe¿Bó{—š;½ÿ±%Ërµv8I*òúÉF^Ø=!xvºI˜¾ŸcE )7ëRª)\HÍU(‚­0Äö; ØéçŽý麵}H!¼ÓÉ?»:v{Zhƚ┉‚ÆKŸA$}:ýáÈÚ¤iÄ…êGíÆÖìBËÀ"]¨}2O®5ÆØïœôañ2,¬÷§V¨T`u§ÏŠ’Ç/è×=é [„}fù^±8’¾pÞx/Ö~%Ðo*qÀpûÕNð9Dw÷~Yü]ÅmÚ#ªo¹³/8ÙÇ^Å:àd¤Ÿ‰áäfXqóÿu±žÑ‡TÇ‹O`¹ô®Soï²A{’ÁX…Ê3è¡ãœUƒŠûoûò …Ë_îxr†Ÿ²ÉHVÂö%nÃdC =£4x{3xŸy‹*§8PÝÒíSÜÛ ˜úr/EàÐ6z|”= £ï4×éyÁHëÊÔÇòIl%èÍzäó5ÔɃ@ºMï7yv [ý7êÆéíŠPÍ&è|AÄíO/BT¯BÙ‘Ï;D‰Ð¬B*m‰YDÚÛ¦rAÆ9ø.fãÆ9m;û¶â¨­ÿw‡`¡'8ù@õ1U½Uެ›¸¾»ijþÇJ×Åàô¶€½r\ZHfë,ùw¨Çë÷¯ü0®ÆŽM¢¡}ÆÂà¯/´‹‰?­mÏ®¬Ó–®ƒY –z«žg8ÂFXIE2‰Ýõã®YçDìö†/½êzvál¯õ„{¶ ,g¬§´]‡Ù;\U’°p‡Â›õ’ÂØ³û•éc.ClXœÔºÈá ñyêÙNFWa(¥6mŽK†{þ˜±lÔ†’âK7—¤ Åomd±UÉ "[zN¯B‹äQãw­àl`"±îâ?ìŠü£tó;Nº´?œÀ¯ØXíÙnÄfÈà8¯o-²>8|ÐðýË.G匟gór»ûPòN¶í}ãôát;eªé”Þ‡øwFˆ^0_¥¦øíΰH4|Ó8 m{–%Ã!¯3o-u †nö¤NÆlAúB˜póP06³³Æž/…¾˜žMe~ßqúD÷·\ÙÖûXƒw' Ù=â÷°FòÐw9Ô`ðMGÃñÀtY½š®(ã´f¶…ûí‹:t9ºŸêÌ›]Jmpm‡¹;É=Ò°pÃéÀ Õˆ¿ý®¢s3ý¢/b#3·WA¶ØÞ0«KÄ©—7­WEzÎÓ™ ¤õ­†¸çnÄ9¯Û&†¿šp55Ñ0B’ï>Â3VIœðî]8 `é×b°8Li)Þà*„ùµ©Œ4À%?ÞŸ±Ôqé†fÛ– ¼»¶CL J(Ze*N3X/Hû‰ÖKÈJö“¶VyIHdÓ~ ÈòÌÜÍÔ™ß3ÿç9gž—™v-Ww©Š¢Ä•D2©Ä`&ãp‹)Ie‚O¢(‰iåE©ýëˆÉ]ÐF4›SK64¢ŒN1Q'•9D‡;ˆÙ­œH:Ílð;DºŽÓà&AÍj+!('¥N¥˜-üpMp×1H†;Y¢YD¦šµæTàÉÉ<‘ý6Ó-]Rn!ž šº9ƒº¸‹ ÝBj™HGQ’¨œ$j ÑB[æt‰%Q upH:ç2&Uÿ2G}Ýve®m³®@*'s-ÈØ ·ý 4u(N'¤ Š´¹#Q‡›m‚ýsMjeƒ“’,IA iAGt©ú¥ ¨= »šÁó)S/PÓçèR¦²„ç‰tºRT—ÕÏŽ£­ë`Uኆok ')ã :sI(N.;`ž°FÇ& n™^1ÿq–ž'"œ}<«Az–üÙ«36vŸÁtíK„âDAó6#ýqEq䟇 ~Ôïé2‰ÛËàVÖ$ì]Þ{þóA{§/,–¹®±ïÌé…·ÚOCÆB^õ‰•Ê«åu@¼*R*Þœ0i>lŸ/'ƒV„Œ‡¨SÑß2:¦úØþÈ芌ÿ­syXç<ìÕì›t£ç#.¾Ë®œ{èör÷?ù½UC3Š‹±·Ä¹ŽœÃ^ƒÑúm`{g¿_ú°hv—ö½ÄÞ¡S;úV¯À^qþÈÛîÔß;gMu?ðŠþqxïkqqxiCwÉñ9\Ýn/n^´t'ð–Ñs´ Ø·eûõ`ÿHºñðqoþá ^8ûÂíB/®;{wöŠ7ŸpM9ÍM¸nëíW—ZÞãúü÷õ£{Nâú™ägéùM<5VU÷"5מxÖ3kÑ<ýØîac~ Oé,ûƒNŒÿõO³Õ¿ßkE—’2ºôûkùòg”£¿r¯—ÅÓgeometry/inst/extdata/halfspacen.RData0000644000176200001440000000053713300625474017546 0ustar liggesusers‹ r‰0âŠàb```b`faa`b2Y˜€# 'fÏË/ÊMÌ)ªàrö~ý/grn­ªý©ìóØ÷?[0/­Þú¬ý­ÓJ®Â{/Ù?Wïßu7Øþ¡Ã•)åA¼û_¹Ä”Hü´‡ªÛÿ¤&ùߦ—»ìß½d|TÖã Ó¿k¾ßÌã íûÊGÎØ>1m?T¿ýÃNÖ‹ Âe0ýö/¦ºœºÜ,½ÿp”5ߣ|ÆØÿæýÝ’·ý¯â.¿¼ò4ÝþÉ#ïCIeöGæ<‰æ¬ ‚*cpT¨ÌYÝÐpPãέR _•Lã/&®jvøh*=aYôcGé®àk×ä8Jï¾·nÞZ†ƒ2úìfD„ªC æ”Ì\ Å APðñ?4eLi@€ÌµöÙ|ÕaöŽš{Z¯ä\sêŒ]ÏP*Òx^Ègeometry/inst/extdata/intersectn4D.RData0000644000176200001440000000757013454046274020021 0ustar liggesusers‹m—y8Õm·Ç÷6eÎ)e*2¥<4¬_“&‰êÍÐ$$BHeNåRH‘J%©¨”hxˆÖ~HÉ”y·½ ÛÞìÛÇ{Þë}ϹÎuþ¸‡uß­ïu¯ïº?wد·'‘H$AaA’€àÂVH`a"“„Hbÿ üO_ðX¸–^8ªAÞ.é÷'%“ ‘;÷ô‡ÌRï÷ÚZ]8xt?ã™8üžxý"Ýñ!F¬»tƒ îì‰'±™©¬öMš|2tU’·tüüŠ¥ÊÍÇ-¾¸"VŠx @þ[~}¡0tÍ“HÝ{¥?z.C LLÝ®,ñ:@ˆ讉oÎ…òteè×ljjn6¼‚㢶Qß^íT,Gšê ˜uó¶È ·>ÊÀÙÖ⸡;låšÝwMã´*½Ír@ª™h-ORŠÎjm,LF¶aкgŸàï·6´oÂT¯š™âòXókgز#aö:+&ÞÊ ø²9 ‡‹_A]_ú#[ïB}šL·K´~³` ßÒn¶Œ¦™Ý ‚ĵz•xÈ>-‰ÝdÚš—{ZŸ?åߺ²S, 6F]–jB ñó›"H_· ΩÁ /=sk‹>ðïü‘l× 3Ö+‚mŠÜ`®ã~}£è—:´N8Zw+ÎDÅâ€=äÄ(Bôy¯ ´cƒU2ù9 ™'TÔë&*úVµiõ:¡Üƒ¡gü3“¦\:yr'0Z¦}ÕÈ,B`ï‰Lõ%!­¿Ã"·©Æ,–‰UØhàgãöÙ»JmrbíEOT„C×ÉßÁ¾ñH_üý´\ã:œòSÓ*A¶Wò¶sΗq4£ùe)U ÙíL÷±ÑÈÔ¼ãô’CAŽÇ‘bãÐȼg:ê£!†_n%8·‚ÉçÔ$\`&9­Æð{ °‹Åº?„·gÊý‰a8txd.¶/bF‘’-|º'ÈúŒFë뼡ñ×èc=``ë-¯q³lFnàaªêâ^h³î Û , }ó¤S8H7]/þq¨29AeÜž"rêFñì½Ýf¦o¶søæì*9éÔ h膱Ó\œ‡WE¦vRÍÀql~ˆI2Kã”é$Ø]Äa² ÛXˆŒ¸:ÿšY ýù&X$z@_‡rž\@teo(Ý´ ¨¡ovZOÂcQ ϨÁä!½î·Â‹5úœ^ú(ÔŸ»áÉHQnžã–SWçòÏ›ÛÛ¢{õBór ì¶î|[‚ŒÕ×j}Vþ%ª>Ú—ls!œ<)ýò.tÊ‘*j®eB¯”®ÛlBð|.…?rö…œ“y9ú;qÞÿ½§ßZœõ hÿ”Œ‹Çåºr¡ÄîËîòñQ3 òüØàO‘°ôK¥12€ê¢èéhô7>5¶³˜4¡¨|•¾:‡ßÍ£,ÔëÞß›ŸfÁ´?6¦êÐË)}¯ƒ>Co¦âõ'!P]OßÍÇ6?» íy6íêg“¡óæŒÀ‚Vì¼öª¦h©ú¥ó¼wÐ÷Úáþ²æ0¸_=ÁW_Xï`J#f¨Iœ´n³3À­”ªmJ~ ì'öš)k“€æßp[}5ÐT¥ež]šù*¾ëÆÃ€MÄNŸIcI‡½ëÎÐ5°>{Íílà®_ú"’ 3‘Ñ¥’_€Ù-YÛ„#s«”4ÜÅñݦ‘ÖÕ¶À{!Ÿ¨“|ÿÅò£çá]Ž ÃU±'cýq c‘`Öè(ÌZéÿ1MQ¶õ™»§µŠ¢˜ì·%Ú†²üà­égŠvÐõ¨¨èòß À=~ËâFýMh‘銘 A`¼Rvò´q^Rj½eª*p+*3¿®¤@çû¸È÷µv0÷ò/·WN¡¿|íÝMý„ùN\‘¸ 8±¬T:ÍuÐ{à‹°¹´WµŽÂ¨µÖ˜Dh3L>= þYÐÌi¨80½¥iîvš_€û×£=¡D4ÿ22ˆOÒÇï7…cd3!ç,n;æ¤AíûÄþ"4ƒkVo:{8sv²ØiØbQ“áò÷GìIHO™ù5-Ûœõª½‘• Z‘ŸŠòr›Ó´21`–ÑK:UôËÕÁ^mɳÿ˜•ηž žY‹‘ýv¼ëh­p¿+¶Ÿw„_ƒïžãCÃ8¸v^»Þ &Úv5_kߣüoñÉÊPîê¨H“*€_u;²ŒÚÀ^5Á”‹Ã”.ާ\\ô‚¾Ã™4(mÜ›ËÏjD w{C d™›‹¾q` ïÕ†%ñL=d¯ö¿â•òŸ>– ÞŽ®…ñ•[÷´ìÄOçÏËžkƒÑäÖ†l2õ&¾m‹§!•p­‘k@îzº¿ÖÑ„ØÛÅùàø­×Á“ÛM+J:‰ˆçäKa!±¤ ‡otÈ Hí)‰ ¨ÖAžý}#Q!OàhO4ÉNÅiM©)ùæ `KSTtÜanc ÿu‹ }/åÇúï¶Á»·¼JøýÜå–ã­½@`K–øÃõ?•ø'1y"Óqé˜í£—ÐüÌà“ŠŠôCûÍšôÐýðþ¹:)ð×åNeÂüš)çÝ©Èγd›oÜt×ë—„‹a½•þÒõyíØU¬s5¯Uizo6ð$°Çÿ ãº…|ó>«åî-߃ýw+ë8Ò7qh‹eõ…à#Ø›öxßý%q8¼ùa¦ˆ;†Óºü®ZbÞÚ†nýf QØà”¢Œe)6nD”p Ø\ip«¶ø]WÞ×†í»³'– —a½¤h}ò~Kü1°zÐãxv ìÈÃp•hÛ€y`Ïštìojƒ&UÛüSÊ)0%¤«}؇T­¶„Nr(¶xß#„D¯„f$”…‡P¶«æõ˜ç~H0ÔºwK\ØôzÔÆ%¶Ïs!?:—1[ðص9þ„ùôNa“JèˆJßXø®ÚGhg‘£ãjs‡Ùìý sÆ(ˆÌÞ2ÚIo¤Œ-yõ$mæÿ°© «‡÷Â"õßøJ"]ø'®.Œ¹ÿaÏþ aIÀMjÙ›ýá?ˆ:Î8#ªœ“ Ó?6‰õ- –îyù¨Ô–ôH ¼'â|Ëé#¯Nÿ‚y•æöâà¿ Y-¬ï¨ïñÿ|¡©U7ߦ0®ÂÇKáaw» zŸËPhð,r%ï¥ÎÉÕBÛEÒÅÐý«àÓ¡è|󆨰oôÄÊ¿[< çi|üG)ŽÌ¾üñd£)i¥E>e‘ûF«Þ(òt+šª³&p$|W¶{àM¨/êú,¿âß„ÝÛs›ÉÒ„HÙLذšâæ¼ÔYv„Xœ¸£Ä7BH¼,Z‡ôæŒIŽ~Ëù—6óÿK7ÑÿÑ4÷_©˜ageometry/inst/extdata/issue57-tsearch.RData0000644000176200001440000004376214664421655020415 0ustar liggesusers‹íÝyœey]üb¦—ª»ß{îÙ÷sî½UqA§ºgº'$¨¨‰Q“<pwEQ "ŠŠŠˆŠQD#*HˆûÔ@‚ ‹ÜâJŒFƒJÜy¢â’1ú¼‡ÊÔ5>>ez¦Ï¿×·zìî_Õ=Ÿ÷ç{¦«ÿþ{=úÊèÑ£ƒƒƒ[.\xÐÁ­}xpñ‘øï|ýààÂ-~ð ƒ GwχûIîþ‡3?~Ð{´/½ëEßU½“ù1zÄ^ûçüø þ›ß÷æ“¿ûóŸw§ùAkß÷3Þ‚Ÿ÷Ô¦ûø×™OÚËßýÙoů{æëþÁú¯Ý ¿þÙý­_½ù¥/üGßõ•oƒßï+ÿ¸ÿ¢w7_ô!¯øˆßº~ÿ¯{Å£îxá}xÏ‹‹7ŒÞß|é§ÁÏ¿ñíxïwþÜæÛ^tÜÿ=yåç>üú<~àù~ôŸÜ€ŸÏþáï¼Ó‹‡Ïë/üyýû|ÖÁßÀŸßöyÝ(ŸÏ}uß[úó¿ãÊõ¯Üýúüú{_¿ûç=zõˆÿFó%³õ§ý¢ù3w5ôÝçïõ!“¿ùŒ~ÖŸšÓ‹ïpõ¾¹ù½¯™~ê_bÎ>ë)¿úú·bÎZ½ò±÷æ|ã÷}Ù/¿ çâ;>þ‰¸æò)Áß|ÍÛa®®~gó°·çüÿƒWÞ3øÖ˯y×h®ÿâoøæp†ïøÈÏ.oÄùŸÿèŸwÏèk¿êJtÎø1ï;~æ 4“ö·åÖa¾îË_þI÷ÁL_ðÐ/}Ã[0—Ïø¿]˜ãw<ŠÿÃÝ¿þ9ÿ„ß5³ðìÇá+îúâðÏü‹ƒ‹O¸ëñõ‰>X¼é_œýÃK~Ï'>ñI¹çGpö£?ó ?òãïúÄ{~á=ÿpô˜»ž|׃?úI~Ï?óÓžôħ<øOÝõ ósqÛ=œÞóÁ•{>¸zÏ·ßóÁ÷|píž®ßóÁÿëƒ[n{×ón;ÿèôü£+ç]=ÿèöóî8ÿèÚùG×Ï?:¿ãôüŽÓó;NÏï8=¿ãôüŽÓó;NÏï8=¿ãôüŽÓó;®œßqåüŽ+çw\9¿ãÊùWÎï¸r~Ç•ó;®œßqåüŽ«çw\=¿ãêùWÏï¸z~ÇÕó;®žßqõüŽ«çw\=¿ãöó;n?¿ãöó;n?¿ãöó;n?¿ãöó;n?¿ãöó;n?¿ãŽó;î8¿ãŽó;î8¿ãŽó;î8¿ãŽó;î8¿ãŽó;î8¿ãÚù×Îï¸v~ǵó;®ßqíüŽkçw\;¿ãÚù×Îï¸~~Çõó;®ŸßqýüŽëçw\?¿ãúù×Ïï¸~~Çõó;î<¿ãÎó;î<¿ãÎó;î<¿ãÎó;î<¿ãÎó;î<¿ãÎ{î¸õ¶w}×ý‡·í?<ÝxeÿáÕý‡·ï?¼cÿáµý‡×÷îo»mÛmûÛnÛßvÛþ¶Ûö·Ý¶¿í¶ým·ío»mÛmûÛN÷·îo;Ýßvº¿ítÛéþ¶Óým§ûÛN÷·îo»²¿íÊþ¶+ûÛ®ìo»²¿íÊþ¶+ûÛ®ìo»²¿íÊþ¶«ûÛ®îo»º¿íêþ¶«ûÛ®îo»º¿íêþ¶«ûÛ®îo»}ÛíûÛnßßvûþ¶Û÷·Ý¾¿íöým·ïo»}ÛíûÛîØßvÇþ¶;ö·Ý±¿íŽýmwìo»cÛûÛîØßvÇþ¶kûÛ®ío»¶¿íÚþ¶kûÛ®ío»¶¿íÚþ¶kûÛ®ío»¾¿íúþ¶ëûÛ®ïo»¾¿íúþ¶ëûÛ®ïo»¾¿íúþ¶;÷·Ý¹¿íÎýmwîo»sÛûÛîÜßvçþ¶;÷·í»ätß%§û.9ÝwÉé¾KN÷]rºï’Ó}—œî»ätß%§û.9ÝwÉé¾KN÷]rºï’Ó}—œî»ätß%§û.9ÝwÉé¾KN÷]rºï’Ó}—œî»ätß%§û.9ÝwÉé¾KN÷]rºï’Ó}—œî»ätß%§û.9ÝwÉé¾KN÷]rºï’Ó}—œî»ätß%§û.9ÝwÉé¾KN÷]rºï’Ó}—œî»ätß%§û.9ÝwÉé¾KNÏ»äÂmû'{á¶?µŸNÏ;æ‚‚Ýÿ”«>>8øã?ó>ö–‡ìÁÿö¿´¥Ÿ|÷¿™ÜþôõÏûÓóôOþÛ§˜q×o½_ôfþùG>çþéKÌǼêGïáŸ÷Q¿ùŠ÷ùMó±å7¿à ߊ_÷1ïÿüß9¹~ýÇ>õ ÿÆ÷›ûÆO{þG¾ ~¿ûÙýíóñ‡ð^/¸~ÿ'\{Ÿç=ä>¼ç‰}í¿þŒùŸ{ü°Ç¿ïý„WG_˜OúÝ‹¯ÿÖèóxrûûïþ·ÍOzø¯|é/ÝÀŸ×'?í'ÿËÓîŸßS^üoZšŸòóÿòK¾ó~øù~ÚäE¿þ(ó©ùâ‡üÞàóÿôÇ}Ös¾äôu|Æóžø«ïb~æ~Ø?òþºžößÿγg>}÷×ùòMôu~ö#ßùÚW›ÏøœâY»‰¿îÏyÉø?½nøú_ú¹¿øÆÛ?Ý|æâ7¾ ^ÿÏëñùïö³¿ð2ó=ᇮÿäC^ùù‚gý‹×¼rx^÷»çõÂïzÁîƒÌúÏú´?žßýþù½(}ê?wxŽ˜çøÏßçã6W̯zÊ~ÊO Ïõû\¿úkÿÖÞýú~ÍOÝÙ‡ç|Ó<篻pòÉ_o~ý•ø‡ß{xî7ísÿ†¸\ÿÒðüoúçÿÏùoOþ,ó›^õ«?TyòðgòðÍ¿ùSåݯï‹ËW?éÑC>†|üòñ-ïÿ’ïÿý!'CNÞœ|ëS¿*¿ûõýÖoÿÇO~¹ùmßø%ÿð]‡ü ùy+óó/öé¯þQ󥇟>nÈÓ§{9OÿêÚ‡?áî×ù_ôßýÞ¯ò5äëmœ¯ýÝÏyçÿ4älÈÙ}”³—=÷Ý⇠yò6ämÈÛ8oßþêÜë†Ü ¹{;åî;~·üîÏò7äï휿ïê¦a6äpÈá ’Ã—?ü>öeC‡<Þ`y|ÅÓ^ÿÊ÷r9ärÈåË!—oq._ùâ×®þËÏ!Ÿ7x>_õóÿö±_4ätÈéý$§ß3ùŽ—o†¼y½Ÿåõ{ò ‹ïr;äö~šÛ󏝸¨ò;ä÷~žßW?ï™ßñGCއ9r<äø†Éñ÷ýàSfÏ3?ô§Ú¿ýÐ!×C®`¹þþÿþÑyÇï!ßð|ÿàî‘/û÷C·œß$9ÿ¡G¾÷䆼y¿Éòþo?çê]³!÷Cî‡Ü¹rÓäþ‡_Òÿ«oò?äÿ&ÏÿüR0ú[ƒƒÁÁààM~lyˇþÚàað0xøß<üø»½á%Ï\ .®‹ŸxÂ/¶ƒÁÇàãÍúxÍ ~âƒ_98œ N'ƒ“ÁɽääßýÈ«¾íƒ/ƒ—Á˰W'ƒ“áÿ| >†ÿ;¸\¼ ] ƒ‡ÁÁààæv0äÈÿ͘ÿ!÷Cîo¦Üyò~3ä}Èùór·|ù~ æ{ÈõëR®‡<y~ äyÈñãûsއüù½?æwÈíÛûSn‡¼y½?äuÈéÓ9§òµ·ýÁ‹†œ9½As:ärÈå˜Ë!WC®îÍ\ ¹rñ§s1<×ÖsžËõ\†×õÞy]‡×ãìõx |=7Êçsoý~oúñÁÁÁìà ýä÷xÔ‡Œï±17'ñ ¾å…Þü«?ù?¯¿%óCGïû™ùôwÿŠ»ÞšùÕŸü«¿}oÎøWžö¶œ¿ñËOOïƒ9¥?öõoyÛˇÝóŸ÷±¯¹çS^þ²»näù•¿{á÷§ùÊ¿ò÷¿àþ<ñÃþÙæ0gžû__ò@œÇ?ò‡Ý óýnùüŸ»ç®ÿôÇÝÌó‹ŸØÿá0÷ó¥_ó _:Ìÿÿù^ûª~˜où|ãjòŠaþ…ç¼zŸ|ÿa¾õó=>óë^;Ì{>楿ÿIÃ|ÛÍg¾þ=/ó¾›ßÔ>ç…Ã|ûÍ{Ô/eÃæz>úìû¿ s˜7Å|êÙ÷Óæ0oªù³ïK8ÌaÞTó{ξŸã0‡ySÎ_=û>˜ÃæÍ<Ãóï:ÌaÓ|dzï¯:ÌaóOÍ¿söýg‡9Ìaþ9óIgߟw˜Ãæ›™Ï=û¾ÅÃæ0ßÌ|þãÞ}1Ìaó-›ß~öý·9Ìa¾™ùÚ³ï÷>ÌaóÏ™|öýì‡9ÌaîgÔ}_þas˜æ{Ÿý=ÃæM=?æìûÎs˜7åü³ïƒ?ÌaÞTóÅg߇˜Ã¼)æ¿;û¾ÿÃæzþþÙß+0Ìa>gœœý=Ãæj>äìï9æ0óÃÎþ~„aó~=?ûìïQæ0ï—ókÎþ~…aó~5ðìïYæ0ïóõg¿Â0‡y#Ïd~ö÷( s˜7ä|—/ûôoæ0oÔyzö÷w s˜7Ô|äÙßÇ1ÌaÞ+óSÎþ>ŒaóMóùgÄ0 óUgOÂ0oùKgßǘoÝL/ž}_ø›~žœ}Ÿðûý|¿³ï÷üvŸO<û~»oõü’Ç~ÄüààÂ-·üÉÁÁÁ¹åàÂÁ‘yéÑïùÄ'>é1÷üèÎ~ô¦Ÿ{ë=?÷Aÿëÿ:zÌ]O¾ëÁý¤»ÿQg?ãÂÝ?czp~²yÁù8çãÇ;ÿÎùIçß;?åü´ßèNç¯:qþšóׇ:ïæü3çEÎ?w¾Êùjçkœ¯u¾Î'|Ù9t|&·Œœ±3qÜËÌñÞâ³½å Îè|‚ó$ç';Ÿäø\oyŠó)Χ:>·[|n·üçgœŸuþ£óZç真w~ÁyóŸœ_ôÊøÜoõ¹ßês¿Õç~ë»;ïá<ÌyO罜÷vþ†ó7÷qþ–󾎯íV_Û­¾¶[}m·úÚnýzçœot¾Éùfç_8/v¾ÅùVçÛœé¼ÄKíë¿àë¿àë¿àë¿àë¿p÷öõ_X:+'pÖNèDNì$NêdNîŽ×è‚×è‚×è‚×è‚×è‚×è‚×è‚×è‚×è§9Ou>Ýù ç3§9Ÿå<ÝùlçÎç8^à ^à ^à ^à ^à ^à ^à ^à ^à ^à ¿äü²ó+ί:¿æüºóŸÿâü†ózçÿqþëÁÁE¯óE¯óE¯óE¯óE¯óE¯óE¯óE¯óE¯óE¯óE¯óE¯óÅ÷sÞßùÛÎßqþ®ópçï9ßù¿œG8tþãY\ô,.z=‹‹žÅEÏâ¢gqѳ¸èY\ô,.z=‹‹žÅEÏââKåükçeη;ßá|§ó]ÎËW8¯Ä˳ºäY]ò¬.yV—<«KžÕ%Ïê’guɳºäY]ò¬.yV—<«KžÕ%Ïê’gu©t*§v§u:§w6ÎÖÙ9ÇŽgyɳ¼äY^ò,/y–—<ËKžå%Ïò’gyɳ¼äY^ò,/y–—<ËKžå%Ïò’gyésÏsžé|¾óœ/p¾Ðy–ó;Ïv¾ÈyŽãy_ò¼/yÞ—<ïKž÷%Ïû’ç}Éó¾äy_ò¼/yÞ—<ïKž÷%Ïû’ç}Éó¾äy_ò¼/yÞ—~Óù-ç·78¿ãü®ó{Îï;ÿÍùïÎ8ÿãàà²L\–‰Ë2qY&.ËÄe™¸,—eâ²L\–‰Ë2qY&.ËÄe™¸,—eâ²L\–‰Ë2qY&.ËÄåG9v>Àù@烜v>ÄùPçÜwîrdæ²Ì\–™Ë2sYf.ËÌe™¹,3—eæ²Ì\–™Ë2sYf.ËÌe™¹,3—eæ²Ì\–™Ë2sYf.ËÌåW9ßí|ó½Î¿q^í|ŸóýÎ8?èüóoåêP®åêP®åêP®åêP®åêP®åêP®åêP®åêP®åêP®åêP®åêP®åêP®Oœ¿â¼ƒóŽÎ;9ïì<Øyç]ÛœSçŠ#{‡²w({‡²w({‡²w({‡²w({‡²w({‡²w({‡²w({‡²w({‡²w({‡²w({‡²w({‡²w({‡²wøÅΗ8ÿØùRç¹Î—9_î|…ó<ç+ç;ÿÄ‘ÏCù<”ÏCù<”ÏCù<”ÏCù<”ÏCù<”ÏCù<”ÏCù<”ÏCù<”ÏCù<”ÏCù<”ÏCù<”ÏCù<”ÏCù<”ÏCù<üCçÎ9ÿÓùcÇþ¼{±=ȱOnuìÑ#ù=’ß#ù=’ß#ù=’ß#ù=’ß#ù=’ß#ù=’ß#ù=’ß#ù=’ß#ù=’ß#ù=’ß#ù=’ß#ù=’ß#ù=’ß#ù=’ß#ù=úç#ÛÿÈ~?úhç±ÎÇ8ë<αßì÷#ûýHÆdüHÆdüHÆdüHÆdüHÆdüHÆdüHÆdüHÆdüHÆdüHÆdüHÆdüHÆdüHÆdüHÆdüHÆdüHÆ~ØùçGs~Üù ç5Ž÷GÞwyßqd·Ùí#FŒ8q0â`ÄÁˆƒ#FŒ8q0â`ÄÁˆƒ#FŒ8q0â`ÄÁˆƒ#FŒ8q0â`ÄÁˆƒ#FWÛ;œkÎuÇû¡‘÷C#ï‡FÞSŒ¼§yO1âdÄɈ“'#NFœŒ8q2âdÄɈ“'#NFœŒ8q2âdÄɈ“'#NFœŒ8q2âdÄɈ“'#NFœŒ8q2âdÄɈ“Ñ œ:ÿÔñmä=ÚÈ{´‘÷1#ïcFÞÇŒìΑÝ9âhÄш£G#ŽF8q4âhÄш£G#ŽF8q4âhÄш£G#ŽF8q4âhÄш£G#ŽF8òvè`Ìј£1GcŽÆKŽ÷Žcïǰ½wûÉcïÆöñØ>ÛÇc½9fmÌÚ˜µ1kcÖÆ¬Y³6fmÌÚ˜µ1kcÖÆ¬Y³6fmÌÚ˜µ1kcÖÆ¬Y³6fmÌÚ˜µ1kcÖÆ¬Y³6fmÌÚ˜µ1kcÖÆ¬½§{O;öžvìýÚØûµ±÷kc;~lÇíø±žëÙ±ž39frÌä˜É1“c&ÇLŽ™39frÌä˜É1“c&ÇLŽ™39frÌä˜É1“c&ÇLŽ™39frÌä˜É1“c&ÇLŽ™39frÌä˜É1“c&ÇLŽ™39ö~{ì½âØ{ű÷ŠcïÆÞ;Œ½wëæ±nëæ±LM¸p;ávÂí„Û ·n'ÜN¸p;ávÂí„Û ·n'ÜN¸p;ávÂí„Û ·n'ÜN¸p;ávÂí„Û ·n'ÜN¸p;ávÂí„Û ·n'ÜN¸p;ñuâ=êÄ{Ô‰÷#ïG&ÞLôùDŸOôùDÆ&26‘± ß¾'|Oøžð=á{Â÷„ï ß¾'|Oøžð=á{Â÷„ï ß¾'|Oøžð=á{Â÷„ï ß¾'|Oøžð=á{Â÷„ï ß¾'|Oøžð=á{Â÷„ï ß¾'|Oøžxo<ñ>gâ}ÎÄûœ‰0±&ò6‘·‰¼Mäm"oy›è‰˜è‰˜è‰˜è‰˜è‰˜è‰˜è‰˜è‰˜è‰˜è‰˜è‰˜è‰˜è‰˜è‰˜üÉ›þßу©˜ê©˜ê©˜ê©˜ê©˜ê©˜ê©_4ÕS=0ÕSÞ?Mí©½1•¿©üMåo*Sù›ÊßTþ¦žãTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLuÅTWLíš©]3•Å©,Neq*‹SYœÊâT§²8•Å©g;õl§žíT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉT—LuÉÔ~šÊåT.§r9•Ë©\Når*—S¹œÊåT.§r9ó¼gž÷ÌóžyÞ3}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó73}3Ó739ÉéLNgr:“Ó™œÎät&§39ÉéLNgr:“Ó™Ìä`&39˜ÉÁLf:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“f:i¦“fr;“Û™ÜÎäv&·3¹ÉíLngr;“Û™ÜÎäv&·3¹ÉÆL6f²1“™lÌdc&³»³¡³f:k¦³f:k¦³f:k¦³f:k¦³f:k¦³f:k¦³f:k¦³f:k¦³f:KíÌuÖ\gÍuÖ\gÍuÖ\gÍuÖ\gÍuÖ\gÍuÖ\gÍuÖ\gÍýâ¹Îšë¬¹Îšë¬¹Îšë¬¹Îšë¬¹ Ïex.ÃsžËð\†ç2<—á¹ Ïex.ÃsžËð\†ç2<—á¹¼Ìåe./sy™ËË\^æò2——¹¼Ìåe®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm®×æzm.ÏsyžËó\žçò<—ç¹<Ïåy.ÏsyžËó\žçò<—ç¹<Ïåy.ÏsyžËÐ\†æ24—¡¹ Íeh.CsšËÐ\†æ24×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sÝ7×}sùžË÷\¾çò=—ï¹|Ïå{.ßsùžË÷\¾çò=—ï¹|Ïå{.ßsùžË÷\¾rµ«…\-äj!W ¹ZÈÕB®rµ«…\-äj!W ݸРݸРݸРݸРݸРݸРݸРݸРݸРݸРݸРݸРݸРݸРݸРݸРݸРݸРݸõ…¬/d}!ë Y_ÈúBÖ²¾õ…¬/d}!ë Y_ÈúBÖ²¾õ…¬/d}!ë Y_ÈúBÞò¶·…¼-äm!o y[ÈÛBÞò¶·…¼-äm!o y[èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…þ\èÏ…ì/d!û Ù_ÈþBö²¿ý…ì/d!û Ù_ÈþBö²¿ý…ì/d!û Ù_ÈþBö²¿ý….äp!‡ 9\ÈáBr¸Ã….äp!‡ 9\ÈáBr¸¸;‡zv¡gzv¡gzv¡gzVE,õìRÏ.õìRÏ.õìRÏ.õìRÏ.õìRÏ.õìRÏ.õìRÏ.õìRÏ.ý&K=»Ô³K=»Ô³K=»Ô³K=»Ô³K=»äaÉÃ’‡%K–<,yXò°äaÉÃ’‡%K–<,yXò°äaÉÃ’‡%K–<,yXò°äaÉÃRF—2º”Ñ¥Œ.et)£K]ÊèRF—2º”Ñ¥Œ.et)£K]ÊèRF—2º”Ñ¥>^êã¥>^êã¥>^êã¥>^êã¥>^êã¥>^êã¥>^êã¥>^êã¥>^êã¥>^êã¥>^êã¥>^êã¥>^êã¥>^êã¥>^êã¥>^ò±äcÉÇ’%K>–|,ùXò±äcÉÇ’%K>–|,ùXò±äcÉÇ’%K>–|,ùXò±äcÉÇRn—r»”Û¥Ü.åv)·K¹]ÊíRn—r»”Û¥Ü.åv)·K¹]ÊíRn—r»”Û¥Ü.åv©³—:{©³—:{©³—:{©³—:{©³—:{©³—:{©³—:{©³—:{©³—:{©³—:{©³—:{©³—:{©³—:{©³—:{©³—¬,YY²²deÉÊ’•%+KV–¬,YY²²deÉÊ’•%+KV–¬,YY²²deÉÊ’•%+"~°beÅÊŠ•++9^ÉñJŽWr¼’㕯äx%Ç+9^ÉñJŽWr¼’㕯äx%Ç+9^ÉñJŽWr¼’㕯äx¥×Wz}¥×Wz}¥×Wz}¥×Wz}¥×Wz}¥×Wz}¥×Wz}¥×Wz}¥×Wz}¥×Wz}¥×Wz}¥×Wz}¥×Wz}¥×W̬˜Y1³bfÅÌŠ™3+fV̬˜Y1³bfÅÌŠ™3+fV̬˜Y1³bfÅÌŠ™3+fV̬˜Y1³bf%Ï+y^ÉóJžWò¼’ç•<¯äy%Ï+y^ÉóJžWò¼’ç•<¯äy%Ï+y^ÉóJžWò¼’ç•<¯äy¥ïWú~¥ïWú~¥ïWú~¥ïWú~¥ïWú~¥ïWú~¥ïWú~¥ïWú~¥ïWú~¥ïWú~¥ïWú~¥ïWú~¥ïWú~ÅÍŠ›7+nVܬ¸Yq³âfÅÍŠ›7+nVܬ¸Yq³âfÅÍŠ›7+nVܬ¸Yq³âfÅÍŠ›7+nVܬäz%×+¹^ÉõJ®Wr½’ë•\¯äz%×+¹^ÉõJ®Wr½’ë•\¯äz%×+¹^ɵÚ>ä:ë@®¹ì€Àì€Àì€Àì€Àì€Àì€Àì€ÀoØØØØØ°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°Èw ß|òÈw ß|òÈw ß|òÈw ß|òÈw ß|òÈw ß|òÈw`'vB`'vB`'vB`'vB`'vB`'vB`'vB`'vB`'vB`'vB`'vB`'vB`'                               ²Èz 묲Èz 묲Èz 묲Èz 묲Èz 묲Èz 묲Èz`GvD`GvD`GvD`GvD`GvD`GvD`GvD`GvD`GvD`GvD`GvD`GvDÀRÀRÀRÀRÀRÀRÀRÀRÀRÀRÀRÀRÀRÀRÀRÀRÀRÀRÀRÀ’è¬YZ³´fiÍÒš¥5Kk–Ö,­YZ³´fi-÷k¹_ËýZî×r¿–ûµÜ¯å~-÷k¹_ËýZî×r¿–ûµÜ¯å~-÷k¹_ËýZî×r¿–ûµÜ¯å~-÷k¹_ËýÚÎXÛk;cmg¬íŒµ±¶3ÖvÆÚÎXÛk;cmg¬íŒµ±¶3ÖvÆÚÎXÛk;cmg¬íŒµ±¶3ÖL­™Z3µfjÍÔš©5Sk¦ÖL­™Z3µfjÍÔš©5Sk¦ÖL­™Z3µfjÍÔš©5Sk¦ÖL­™Z3µfjÍÔš©5Sk¦ÖL­X3°f`ÍÀš5kÖ ¬X3°f`ÍÀš5kÖ ¬X3°f`ÍÀš5kÖ ¬X3°f`ÍÀÚYÛ#k{dm¬í‘µ=²¶GÖöÈÚYÛ#k{dm¬í‘µ=²¶GÖöÈÚYÛ#k{dm¬í‘µ=²fkÍÖš­5[k¶Öl­ÙZ³µfkÍÖš­5[k¶Öl­ÙZ³µfkÍÖš­5[k¶Öl­ÙZ³µfkÍÖš­5[k¶Öl­ÙZ³µfkÍš…5 kÖ,¬YX³°faÍš…5 kÖ,¬YX³°faÍ‚p²²²²²²²²²²²Ú+¡½Ú+¡½Ú+¡½Ú+¡½ÂúMC{%´WB{%´WB{%´WB{%´WB{%´WB{%ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+ä+d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"d"´gB{&´gB{&´gB{&´gB{&´gB{&´gB{&´gB{&´gB{&´gB{&´gB{&d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#d#´wB{'´wB{'´wB{'´wB{'´wB{'´wB{'´wB{'´wB{'´wB{'´wB{'d-d-d-d-d-d-d-d-d-d-d-d-d-d-d-d-d ‰ƒˆµˆµˆµˆµˆµˆµˆµˆµˆµˆµˆµˆµˆµˆµˆµˆµˆµˆµˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ˆ“ÈŠì¡ÈŠì¡ÈŠì¡ÈŠì¡ÈŠì¡ÈŠì¡ÈŠì¡ÈŠì¡ÈŠì¡ÈŠ˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‹˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰˜‰ì¥È^Šì¥È^Šì¥È^Šì¥È^Šì¥È^Šì¥È^Šì¥È^Šì¥È^Šì¥È^ŠØ‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹Ø‹ø‰ø‰ø‰ø‰ø‰ø‰ø‰ø‰ø‰ø‰ø‰ø‰ø‰ø±Nb~b~b~b~b~b~b~b~b~b~b~b~b~b~b~b~b~b~b»*¶«b»*3ö›ÇvUlWÅvUlWÅvUlWÅvUlWÅvUlWÅvUlWÅ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ Æ,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,Å,ÅöWlÅöWlÅöWlÅöWlÅöWlÅöWlÅöWlÅöWlÅ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,Æ,ÆLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅLÅöYlŸÅöYlŸÅöYlŸÅöYlŸÅöYlŸÅöYlŸÅöYlŸÅöYÌcÌcÌcÌcÌcÌcÌcÌcÌcÌcÌcÌcÌcÌ#. ‰ ¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾¾;.±ã;.±ã;.±ã;.±ã;.±ã;.±ã;.±ã.........................................ÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖ{/±÷{/±÷{/±÷{/±÷{/±÷{/±÷{/±÷FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFöööööööööööö°8HÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙKÙK]’Ú…©]˜Ú…©]˜Ú…©]˜Ú…©]˜Ú…©]˜Ú…©]˜²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²š²šr˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜r˜~ÒÙŸ7J9L9L9L9L9L9L9L9L9L9L9LíÇÔ~LíÇÔ~LíÇÔ~LíÇÔ~LíÇÔ~LíǔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔٔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔɔÉÔÞLíÍÔÞLíÍÔÞLíÍÔÞLíÍÔÞLí͔ݔݔݔݔݔݔݔݔݔݔݔ]¤2v3v3v3v3v3v3v3v3v3v3v3v3v3v3v3v3v3v3v3v3v3v3v3v3v3eìfìfìfìfìfìflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflflföhfföhfföhfföhfföhÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆoÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhÆhf¯föjf¯föjf¯föjf¯föjÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆpÆjÆjÆjÆjÆjÆjÆjÆjÆ*>9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«9«¹ËrVsVsVsVsVs{6·gs{6·gs{6·gs{6·gs–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–s–snsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsnsns{7·ws{7·ws{7·ws{7g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g:g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8g8·‡s{8·‡s{8·‡s{8g;g;g;g;g;g;g;g;gµƒ‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚í‚íÂ…ÛÛÛÛÛÛÛÛÛÛÛÛÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏÏ…Ý\ØÍ…Ý\ØÍ…Ý\0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^0^°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]°]Ø×…}]Ø×…}]°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^°^0^0^0^0^0^0ŽÛAÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxÉxéÒ’ñ’ñ’ñ’ñ’ñ’ñ’ñ’ñ’ñ’ñ’ñÒþ.íïÒþ.y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/íóÒ>/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/™/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/íõÒ^/™/™/™/™/™/™Gï b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾b¾rqÅ|Å|Å|Å|Å|Å|Å|Å|Å|Å|Å|Å|Å|ÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅyÅye¯W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬W¬WlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWlWöyeŸWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒWŒW‰–É–É–É–É–É–É–É–ÉÖ~mí×Ö~mí×Ö~mí×Ö~míזٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖٖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÖÃÖ.míÒÖ.míÒÖ.míÒÖ.míÒÖ.mYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmYmÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkÙkï¶go¶öfko¶öfko¶öfko¶öfko¶ö&£££££££££££££££££££££££££££££££££O¤c´c´c´c´c´ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­ã­³#;;²³#;;²³#;;²³#;;²³#;;²³#;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;6;Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:Æ:û°³;û°³;û°³;û°³;û°³;û°³;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&;&{®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z®z»¯·ûz»¯·ûz»¯·ûz»¯·ûz»¯·ûz»¯·ûz»¯g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g±g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©g©·çz{®·çz{®·çz{®·çz{®·çz{®·çz{®·çz{®g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°g°ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§ç§¿ÛÖÛi½ÖÛi½ÖÛi½ÖÛi½ÖÛi½ÖÛi¢~°±Ó6vÚ†½ {ö6ìmØÛ°·aoÃÞ†½ {ö6ìmØÛ°·aoÃÞ†½ {ö6ìmØÛ°·aoÃÞ†½ {ö6ìmØÛ°·aoÃÞ†½OhÃÞ†™ 3f6Ìl˜Ù0³afÃ̆™ 3f6Ìl˜Ù0³afÃ̆™ 3f6Ìl˜Ù0³afÃ̆™ 3f6Ìl˜Ù0³afÃ̆™ 3ûkcmì¯ýµ±¿6öׯþÚØ_ûkcmì¯ýµ±¿6öׯþÚØ_æ6Ìm˜Û0·anÃ܆¹ sæ6Ìm˜Û0·anÃ܆¹ sæ6Ìm˜Û0·anÃ܆¹ sæ6Ìm˜Û0·anÃ܆¹ sæ6ÌmXÙ°²aeÃʆ• +V6¬lXÙ°²aeÃʆ• +V6¬lXÙ°²aeÃʆ• +V6¬lXÙ°²aeÃʆ• +V6¬lXÙ°²±¯6öÕÆ¾ÚØWûjc_mì«}µ±¯6öÕÆ¾ÚØWûjc_mì«}µ±¯6¼mxÛð¶ámÃÛ†· oÞ6¼mxÛð¶ámÃÛ†· oÞ6¼mxÛð¶ámÃÛ†· oÞ6¼mxÛð¶ámÃÛ†· oÞ6¼mùØò±åcËÇ–-[>¶|lùØò±åcËÇ–-[>¶|lùØò±åcËÇ–-[>¶|lùØò±åcËÇ–-[>¶|lí¦­Ý´µ›¶vÓÖnÚÚM[»ik7mí¦­Ý´µ›¶vÓÖnÚÚM[»ik7mí¦­Ý´ålËÙ–³-g[ζœm9Ûr¶ålËÙ–³-g[ζœm9Ûr¶ålËÙ–³-g[ζœm9Ûr¶ålËÙ–³-g[ζœm9Ûr¶ål+÷[¹ßÊýVî·r¿•û­Üoå~+÷[¹ßÊýVî·r¿•û­Üoå~+÷[¹ßÊýVî·r¿•û­Üoíš­]³µk¶vÍÖ®ÙÚ5[»fk×líš­]³µk¶vÍÖ®ÙÚ5[»fk×líš­]³ågËÏ–Ÿ-?[~¶ülùÙò³ågËÏ–Ÿ-?[~¶ülùÙò³ågËÏ–Ÿ-?[~¶ülùÙò³ågËÏ–Ÿ-?[~¶ülùÙò³åg+¯[yÝÊëV^·òº•×­¼nåu+¯[yÝÊëV^·òº•×íÝyµ¶öÃÖ~ØÚ[ûak?l퇭ý°µ¶öÃÖ~ØÚ[ûak?ˆÙÁÎ~ØÙ;ûag?ìì‡üïä'ÿ;ùßÉÿNþwò¿“ÿüïä'ÿ;ùßÉÿNþwò¿“ÿüïä'ÿ;ùßÉÿNþwò¿“ÿüïä'ÿ;ùßÉÿNþwò¿“§<íäi'O;yÚÉÓNžvò´ÓÛ;½½ÓÛ;½½ÓÛ;½½ÓÛ;½½ÓÛ;½½ÓÛ;½½ÓÛ;½½ÓÛ;½½ÓÛ;½½ÓÛ;½½ÓÛ;½½ÓÛ;½½ÓÛ;½½ÓÛ;½½“ßüîäw'¿;ùÝÉïN~wò»“ßüîäw'¿;ùÝÉïN~wò»“ßüîäw'¿;ùÝÉïN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåN_îôåNþvò·“¿üíäo';ùÛÉßNþvò·“¿üíäo'ÇúèXë£c}t¬Žõѱ>:ÖGÇúèXë£c}t¬Žõѱ>:ÖGÇúèXë£c}t¬Žõѱ>:ÖGÇúèXë£c}t¬Žõѱ>:ÖGÇúèXë£c}t,?Çòs,?Çòs,?Ǭ³~Ìú1ëǬ³~Ìú1ëǬ³~Ìú1ëǬ³~Ìú1ëǬ³~Ìú1ëǬ³~Ìú1ëǬ³~Ìú1ëǬ³~Ìú1ëǬŸptÂÑ G'ptÂÑ G'ptÂÑ G'ptÂÑ G'ptÂÑ G'ptÂÑ G'pt"£'2z"£'2z"£'2z"£'2z"£'2z"£'2z"£'2z"£'2z"£'žÿ‰çâùŸxþ'žÿ‰çâùŸxþ'žÿ_ñÚüñÝçÿFµR…Mgeometry/inst/extdata/ordination.Rdata0000644000176200001440000000064312424764776017665 0ustar liggesusers‹ r‰0âŠàb```b`fdd`b2Y˜€# 'æÊ/JÉÌK,ÉÌÏc``I1óÚù£õímó–Ìw·Æº} ¶ÿ±òKø CUûü‰¤÷ZîŸeTõ¤ªn;½Jï‚ÑPsüÑi¸}ùÖm7#vÿ1÷?{Döÿš-¾5‡Syÿ¯öÔõñÙ¿T™·>\code{ncol(x)} and \code{ncol(x)}<30. If \code{ncol(x)}>30 then \code{matsort} simply calls `\code{t(apply(x,1,sort))}'. \code{matorder} returns a permutation which rearranges its first argument into ascending order, breaking ties by further arguments. } \description{ Compute maximum or minimum of each row, or sort each row of a matrix, or a set of (equal length) vectors. } \examples{ example(Unique) } \author{ Raoul Grasman } \keyword{arith} \keyword{array} geometry/man/distmesh2d.Rd0000644000176200001440000001142414662314120015216 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/distmesh2d.R \name{distmesh2d} \alias{distmesh2d} \title{A simple mesh generator for non-convex regions} \usage{ distmesh2d( fd, fh, h0, bbox, p = NULL, pfix = array(0, dim = c(0, 2)), ..., dptol = 0.001, ttol = 0.1, Fscale = 1.2, deltat = 0.2, geps = 0.001 * h0, deps = sqrt(.Machine$double.eps) * h0, maxiter = 1000, plot = TRUE ) } \arguments{ \item{fd}{Vectorized signed distance function, for example \code{\link{mesh.dcircle}} or \code{\link{mesh.diff}}, accepting an \code{n}-by-\code{2} matrix, where \code{n} is arbitrary, as the first argument.} \item{fh}{Vectorized function, for example \code{\link{mesh.hunif}}, that returns desired edge length as a function of position. Accepts an \code{n}-by-\code{2} matrix, where \code{n} is arbitrary, as its first argument.} \item{h0}{Initial distance between mesh nodes. (Ignored of \code{p} is supplied)} \item{bbox}{Bounding box \code{cbind(c(xmin,xmax), c(ymin,ymax))}} \item{p}{An \code{n}-by-\code{2} matrix. The rows of \code{p} represent locations of starting mesh nodes.} \item{pfix}{\code{nfix}-by-2 matrix with fixed node positions.} \item{\dots}{parameters to be passed to \code{fd} and/or \code{fh}} \item{dptol}{Algorithm stops when all node movements are smaller than \code{dptol}} \item{ttol}{Controls how far the points can move (relatively) before a retriangulation with \code{\link{delaunayn}}.} \item{Fscale}{\dQuote{Internal pressure} in the edges.} \item{deltat}{Size of the time step in Euler's method.} \item{geps}{Tolerance in the geometry evaluations.} \item{deps}{Stepsize \eqn{\Delta x} in numerical derivative computation for distance function.} \item{maxiter}{Maximum iterations.} \item{plot}{logical. If \code{TRUE} (default), the mesh is plotted as it is generated.} } \value{ \code{n}-by-\code{2} matrix with node positions. } \description{ An unstructured simplex requires a choice of mesh points (vertex nodes) and a triangulation. This is a simple and short algorithm that improves the quality of a mesh by relocating the mesh points according to a relaxation scheme of forces in a truss structure. The topology of the truss is reset using Delaunay triangulation. A (sufficiently smooth) user supplied signed distance function (\code{fd}) indicates if a given node is inside or outside the region. Points outside the region are projected back to the boundary. } \details{ This is an implementation of original Matlab software of Per-Olof Persson. Excerpt (modified) from the reference below: \sQuote{The algorithm is based on a mechanical analogy between a triangular mesh and a 2D truss structure. In the physical model, the edges of the Delaunay triangles of a set of points correspond to bars of a truss. Each bar has a force-displacement relationship \eqn{f(\ell, \ell_{0})}{F(L,L0)} depending on its current length \eqn{\ell}{L} and its unextended length \eqn{\ell_{0}}{L0}.} \sQuote{External forces on the structure come at the boundaries, on which external forces have normal orientations. These external forces are just large enough to prevent nodes from moving outside the boundary. The position of the nodes are the unknowns, and are found by solving for a static force equilibrium. The hope is that (when \code{fh = function(p) return(rep(1,nrow(p)))}), the lengths of all the bars at equilibrium will be nearly equal, giving a well-shaped triangular mesh.} See the references below for all details. Also, see the comments in the source file. } \section{Wishlist }{ \itemize{ \item Implement in C/Fortran \item Implement an \code{n}D version as provided in the Matlab package \item Translate other functions of the Matlab package } } \examples{ # examples distmesh2d fd <- function(p, ...) sqrt((p^2)\%*\%c(1,1)) - 1 # also predefined as `mesh.dcircle' fh <- function(p,...) rep(1,nrow(p)) bbox <- matrix(c(-1,1,-1,1),2,2) p <- distmesh2d(fd,fh,0.2,bbox, maxiter=100) # this may take a while: # press Esc to get result of current iteration # example with non-convex region fd <- function(p, ...) mesh.diff(p , mesh.drectangle, mesh.dcircle, radius=.3) # fd defines difference of square and circle p <- distmesh2d(fd,fh,0.05,bbox,radius=0.3,maxiter=4) p <- distmesh2d(fd,fh,0.05,bbox,radius=0.3, maxiter=10) # continue on previous mesh } \references{ \url{http://persson.berkeley.edu/distmesh/} \cite{P.-O. Persson, G. Strang, A Simple Mesh Generator in MATLAB. SIAM Review, Volume 46 (2), pp. 329-345, June 2004} } \seealso{ \code{\link[interp]{tri.mesh}}, \code{\link{delaunayn}}, \code{\link{mesh.dcircle}}, \code{\link{mesh.drectangle}}, \code{\link{mesh.diff}}, \code{\link{mesh.union}}, \code{\link{mesh.intersect}} } \author{ Raoul Grasman } \keyword{dplot} \keyword{graphs} \keyword{math} \keyword{optimize} geometry/man/mesh.drectangle.Rd0000644000176200001440000000236313100737575016226 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/mesh.drectangle.R \name{mesh.drectangle} \alias{mesh.drectangle} \title{Rectangle distance function} \usage{ mesh.drectangle(p, x1 = -1/2, y1 = -1/2, x2 = 1/2, y2 = 1/2, ...) } \arguments{ \item{p}{A matrix with 2 columns, each row representing a point in the plane.} \item{x1}{lower left corner of rectangle} \item{y1}{lower left corner of rectangle} \item{x2}{upper right corner of rectangle} \item{y2}{upper right corner of rectangle} \item{\dots}{additional arguments (not used)} } \value{ a vector of length \code{nrow(p)} containing the signed distances } \description{ Signed distance from points \code{p} to boundary of rectangle to allow easy definition of regions in \code{\link{distmesh2d}}. } \examples{ example(distmesh2d) } \references{ \url{http://persson.berkeley.edu/distmesh/} \cite{P.-O. Persson, G. Strang, A Simple Mesh Generator in MATLAB. SIAM Review, Volume 46 (2), pp. 329-345, June 2004} } \seealso{ \code{\link{distmesh2d}}, \code{\link{mesh.drectangle}}, \code{\link{mesh.diff}}, \code{\link{mesh.intersect}}, \code{\link{mesh.union}} } \author{ Raoul Grasman; translated from original Matlab sources of Per-Olof Persson. } \keyword{arith} \keyword{math} geometry/man/surf.tri.Rd0000644000176200001440000000461614662314120014731 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/surf.tri.R \name{surf.tri} \alias{surf.tri} \title{Find surface triangles from tetrahedral mesh} \usage{ surf.tri(p, t) } \arguments{ \item{p}{An \code{n}-by-\code{3} matrix. The rows of \code{p} represent \code{n} points in \code{dim}-dimensional space.} \item{t}{Matrix with 4 columns, interpreted as output of \code{\link{delaunayn}}.} } \value{ An \code{m}-by-\code{3} index matrix of which each row defines a triangle. The indices refer to the rows in \code{p}. } \description{ Find surface triangles from tetrahedral mesh typically obtained with \code{\link{delaunayn}}. } \details{ \code{surf.tri} and \code{\link{convhulln}} serve a similar purpose in 3D, but \code{surf.tri} also works for non-convex meshes obtained e.g. with \code{\link{distmeshnd}}. It also does not produce currently unavoidable diagnostic output on the console as \code{convhulln} does at the Rterm console--i.e., \code{surf.tri} is silent. } \note{ \code{surf.tri} was based on Matlab code for mesh of Per-Olof Persson (\url{http://persson.berkeley.edu/distmesh/}). } \examples{ \dontrun{ # more extensive example of surf.tri # url's of publically available data: data1.url = "http://neuroimage.usc.edu/USCPhantom/mesh_data.bin" data2.url = "http://neuroimage.usc.edu/USCPhantom/CT_PCS_trans.bin" meshdata = R.matlab::readMat(url(data1.url)) elec = R.matlab::readMat(url(data2.url))$eeg.ct2pcs/1000 brain = meshdata$mesh.brain[,c(1,3,2)] scalp = meshdata$mesh.scalp[,c(1,3,2)] skull = meshdata$mesh.skull[,c(1,3,2)] tbr = t(surf.tri(brain, delaunayn(brain))) tsk = t(surf.tri(skull, delaunayn(skull))) tsc = t(surf.tri(scalp, delaunayn(scalp))) rgl::triangles3d(brain[tbr,1], brain[tbr,2], brain[tbr,3],col="gray") rgl::triangles3d(skull[tsk,1], skull[tsk,2], skull[tsk,3],col="white", alpha=0.3) rgl::triangles3d(scalp[tsc,1], scalp[tsc,2], scalp[tsc,3],col="#a53900", alpha=0.6) rgl::view3d(-40,30,.4,zoom=.03) lx = c(-.025,.025); ly = -c(.02,.02); rgl::spheres3d(elec[,1],elec[,3],elec[,2],radius=.0025,col='gray') rgl::spheres3d( lx, ly,.11,radius=.015,col="white") rgl::spheres3d( lx, ly,.116,radius=.015*.7,col="brown") rgl::spheres3d( lx, ly,.124,radius=.015*.25,col="black") } } \seealso{ \code{\link[interp]{tri.mesh}}, \code{\link{convhulln}}, \code{\link{surf.tri}}, \code{\link{distmesh2d}} } \author{ Raoul Grasman } \keyword{dplot} \keyword{math} \keyword{optimize} geometry/man/mesh.dsphere.Rd0000644000176200001440000000175613100737575015555 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/mesh.dsphere.R \name{mesh.dsphere} \alias{mesh.dsphere} \title{Sphere distance function} \usage{ mesh.dsphere(p, radius = 1, ...) } \arguments{ \item{p}{A matrix with 2 columns (3 in \code{mesh.dsphere}), each row representing a point in the plane.} \item{radius}{radius of sphere} \item{...}{additional arguments (not used)} } \value{ A vector of length \code{nrow(p)} containing the signed distances to the sphere } \description{ Signed distance from points \code{p} to boundary of sphere to allow easy definition of regions in \code{\link{distmeshnd}}. } \examples{ example(distmeshnd) } \references{ \url{http://persson.berkeley.edu/distmesh/} \cite{P.-O. Persson, G. Strang, A Simple Mesh Generator in MATLAB. SIAM Review, Volume 46 (2), pp. 329-345, June 2004} } \seealso{ \code{\link{distmeshnd}} } \author{ Raoul Grasman; translated from original Matlab sources of Per-Olof Persson. } \keyword{arith} \keyword{math} geometry/man/delaunayn.Rd0000644000176200001440000001152114662314120015126 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/delaunayn.R \name{delaunayn} \alias{delaunayn} \title{Delaunay triangulation in N dimensions} \usage{ delaunayn(p, options = NULL, output.options = NULL, full = FALSE) } \arguments{ \item{p}{An \eqn{M}-by-\eqn{N} matrix whose rows represent \eqn{M} points in \eqn{N}-dimensional space.} \item{options}{String containing extra control options for the underlying Qhull command; see the Qhull documentation (\url{../doc/qhull/html/qdelaun.html}) for the available options. The \code{Qbb} option is always passed to Qhull. The remaining default options are \code{Qcc Qc Qt Qz} for \eqn{N<4} and \code{Qcc Qc Qt Qx} for \eqn{N>=4}. If neither of the \code{QJ} or \code{Qt} options are supplied, the \code{Qt} option is passed to Qhull. The \code{Qt} option ensures all Delaunay regions are simplical (e.g., triangles in 2D). See \url{../doc/qhull/html/qdelaun.html} for more details. Contrary to the Qhull documentation, no degenerate (zero area) regions are returned with the \code{Qt} option since the R function removes them from the triangulation. \emph{If \code{options} is specified, the default options are overridden.} It is recommended to use \code{output.options} for options controlling the outputs.} \item{output.options}{String containing Qhull options to control output. Currently \code{Fn} (neighbours) and \code{Fa} (areas) are supported. Causes an object of return value for details. If \code{output.options} is \code{TRUE}, select all supported options.} \item{full}{Deprecated and will be removed in a future release. Adds options \code{Fa} and \code{Fn}.} } \value{ If \code{output.options} is \code{NULL} (the default), return the Delaunay triangulation as a matrix with \eqn{M} rows and \eqn{N+1} columns in which each row contains a set of indices to the input points \code{p}. Thus each row describes a simplex of dimension \eqn{N}, e.g. a triangle in 2D or a tetrahedron in 3D. If the \code{output.options} argument is \code{TRUE} or is a string containing \code{Fn} or \code{Fa}, return a list with class \code{delaunayn} comprising the named elements: \describe{ \item{\code{tri}}{The Delaunay triangulation described above} \item{\code{areas}}{If \code{TRUE} or if \code{Fa} is specified, an \eqn{M}-dimensional vector containing the generalised area of each simplex (e.g. in 2D the areas of triangles; in 3D the volumes of tetrahedra). See \url{../doc/qhull/html/qh-optf.html#Fa}.} \item{\code{neighbours}}{If \code{TRUE} or if \code{Fn} is specified, a list of neighbours of each simplex. Note that a negative number corresponds to "facet" (="edge" in 2D or "face" in 3D) that has no neighbour, as will be the case for some simplices on the boundary of the triangulation. See \url{../doc/qhull/html/qh-optf.html#Fn}} } } \description{ The Delaunay triangulation is a tessellation of the convex hull of the points such that no \eqn{N}-sphere defined by the \eqn{N}- triangles contains any other points from the set. } \note{ This function interfaces the Qhull library and is a port from Octave (\url{https://octave.org/}) to R. Qhull computes convex hulls, Delaunay triangulations, halfspace intersections about a point, Voronoi diagrams, furthest-site Delaunay triangulations, and furthest-site Voronoi diagrams. It runs in 2D, 3D, 4D, and higher dimensions. It implements the Quickhull algorithm for computing the convex hull. Qhull handles round-off errors from floating point arithmetic. It computes volumes, surface areas, and approximations to the convex hull. See the Qhull documentation included in this distribution (the doc directory \url{../doc/qhull/index.html}). Qhull does not support constrained Delaunay triangulations, triangulation of non-convex surfaces, mesh generation of non-convex objects, or medium-sized inputs in 9D and higher. A rudimentary algorithm for mesh generation in non-convex regions using Delaunay triangulation is implemented in \link{distmesh2d} (currently only 2D). } \examples{ # example delaunayn d <- c(-1,1) pc <- as.matrix(rbind(expand.grid(d,d,d),0)) tc <- delaunayn(pc) # example tetramesh \dontrun{ rgl::view3d(60) rgl::light3d(120,60) tetramesh(tc,pc, alpha=0.9) } tc1 <- delaunayn(pc, output.options="Fa") ## sum of generalised areas is total volume of cube sum(tc1$areas) } \references{ \cite{Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., \dQuote{The Quickhull algorithm for convex hulls,} \emph{ACM Trans. on Mathematical Software,} Dec 1996.} \url{http://www.qhull.org} } \seealso{ \code{\link[interp]{tri.mesh}}, \code{\link{convhulln}}, \code{\link{surf.tri}}, \code{\link{distmesh2d}} } \author{ Raoul Grasman and Robert B. Gramacy; based on the corresponding Octave sources of Kai Habel. } \keyword{dplot} \keyword{graphs} \keyword{math} geometry/man/cart2bary.Rd0000644000176200001440000000431614662314120015043 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/tsearch.R \name{cart2bary} \alias{cart2bary} \title{Conversion of Cartesian to Barycentric coordinates.} \usage{ cart2bary(X, P) } \arguments{ \item{X}{Reference simplex in \eqn{N} dimensions represented by a \eqn{N+1}-by-\eqn{N} matrix} \item{P}{\eqn{M}-by-\eqn{N} matrix in which each row is the Cartesian coordinates of a point.} } \value{ \eqn{M}-by-\eqn{N+1} matrix in which each row is the barycentric coordinates of corresponding row of \code{P}. If the simplex is degenerate a warning is issued and the function returns \code{NULL}. } \description{ Given the Cartesian coordinates of one or more points, compute the barycentric coordinates of these points with respect to a simplex. } \details{ Given a reference simplex in \eqn{N} dimensions represented by a \eqn{N+1}-by-\eqn{N} matrix an arbitrary point \eqn{P} in Cartesian coordinates, represented by a 1-by-\eqn{N} row vector, can be written as \deqn{P = \beta X} where \eqn{\beta} is an \eqn{N+1} vector of the barycentric coordinates. A criterion on \eqn{\beta} is that \deqn{\sum_i\beta_i = 1} Now partition the simplex into its first \eqn{N} rows \eqn{X_N} and its \eqn{N+1}th row \eqn{X_{N+1}}. Partition the barycentric coordinates into the first \eqn{N} columns \eqn{\beta_N} and the \eqn{N+1}th column \eqn{\beta_{N+1}}. This allows us to write \deqn{P_{N+1} - X_{N+1} = \beta_N X_N + \beta_{N+1} X_{N+1} - X_{N+1}} which can be written \deqn{P_{N+1} - X_{N+1} = \beta_N(X_N - 1_N X_{N+1})} where \eqn{1_N} is an \eqn{N}-by-1 matrix of ones. We can then solve for \eqn{\beta_N}: \deqn{\beta_N = (P_{N+1} - X_{N+1})(X_N - 1_N X_{N+1})^{-1}} and compute \deqn{\beta_{N+1} = 1 - \sum_{i=1}^N\beta_i} This can be generalised for multiple values of \eqn{P}, one per row. } \note{ Based on the Octave function by David Bateman. } \examples{ ## Define simplex in 2D (i.e. a triangle) X <- rbind(c(0, 0), c(0, 1), c(1, 0)) ## Cartesian coordinates of points P <- rbind(c(0.5, 0.5), c(0.1, 0.8)) ## Plot triangle and points trimesh(rbind(1:3), X) text(X[,1], X[,2], 1:3) # Label vertices points(P) cart2bary(X, P) } \seealso{ \code{\link{bary2cart}} } \author{ David Sterratt } geometry/man/trimesh.Rd0000644000176200001440000000234013100737575014631 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/trimesh.R \name{trimesh} \alias{trimesh} \title{Display triangles mesh (2D)} \usage{ trimesh(T, p, p2, add = FALSE, axis = FALSE, boxed = FALSE, ...) } \arguments{ \item{T}{T is a \code{m}-by-3 matrix. A row of \code{T} contains indices into \code{X} of the vertices of a triangle. \code{T} is usually the output of \code{\link{delaunayn}}.} \item{p}{A vector or a matrix.} \item{p2}{if \code{p} is not a matrix \code{p} and \code{p2} are bind to a matrix with \code{cbind}.} \item{add}{Add to existing plot in current active device?} \item{axis}{Draw axes?} \item{boxed}{Plot box?} \item{\dots}{Parameters to the rendering device. See the \link[rgl]{rgl} package.} } \description{ \code{trimesh(T, p)} displays the triangles defined in the m-by-3 matrix \code{T} and points \code{p} as a mesh. Each row of \code{T} specifies a triangle by giving the 3 indices of its points in \code{X}. } \examples{ #example trimesh p = cbind(x=rnorm(30), y=rnorm(30)) tt = delaunayn(p) trimesh(tt,p) } \seealso{ \code{\link{tetramesh}}, \code{\link[rgl]{rgl}}, \code{\link{delaunayn}}, \code{\link{convhulln}}, \code{\link{surf.tri}} } \author{ Raoul Grasman } \keyword{hplot} geometry/man/tetramesh.Rd0000644000176200001440000000267014662314120015147 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/tetramesh.R \name{tetramesh} \alias{tetramesh} \title{Render tetrahedron mesh (3D)} \usage{ tetramesh(T, X, col = grDevices::heat.colors(nrow(T)), clear = TRUE, ...) } \arguments{ \item{T}{T is a \code{m}-by-3 matrix in trimesh and \code{m}-by-4 in tetramesh. A row of \code{T} contains indices into \code{X} of the vertices of a triangle/tetrahedron. \code{T} is usually the output of delaunayn.} \item{X}{X is an n-by-2/n-by-3 matrix. The rows of X represent \code{n} points in 2D/3D space.} \item{col}{The tetrahedron colour. See rgl documentation for details.} \item{clear}{Should the current rendering device be cleared?} \item{\dots}{Parameters to the rendering device. See the \link[rgl]{rgl} package.} } \description{ \code{tetramesh(T, X, col)} uses the \link[rgl]{rgl} package to display the tetrahedrons defined in the m-by-4 matrix T as mesh. Each row of \code{T} specifies a tetrahedron by giving the 4 indices of its points in \code{X}. } \examples{ \dontrun{ # example delaunayn d = c(-1,1) pc = as.matrix(rbind(expand.grid(d,d,d),0)) tc = delaunayn(pc) # example tetramesh clr = rep(1,3) \%o\% (1:nrow(tc)+1) rgl::view3d(60,fov=20) rgl::light3d(270,60) tetramesh(tc,pc,alpha=0.7,col=clr) } } \seealso{ \code{\link{trimesh}}, \code{\link[rgl]{rgl}}, \code{\link{delaunayn}}, \code{\link{convhulln}}, \code{\link{surf.tri}} } \author{ Raoul Grasman } \keyword{hplot} geometry/man/cart2sph.Rd0000644000176200001440000000156714662314120014705 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/cart2sph.R \name{cart2sph} \alias{cart2sph} \title{Transform Cartesian to spherical coordinates} \usage{ cart2sph(x, y = NULL, z = NULL) } \arguments{ \item{x}{x-coordinates or matrix with three columns} \item{y}{y-coordinates (optional, if \code{x}) is a matrix} \item{z}{z-coordinates (optional, if \code{x}) is a matrix} } \value{ Matrix with columns: \item{\code{theta}}{the angle relative to the positive x-axis} \item{\code{phi}}{the angle relative to the xy-plane} \item{\code{r}}{the distance to the origin \code{(0, 0, 0)}} } \description{ If called with a single matrix argument then each row of \code{c} represents the Cartesian coordinate (\code{x}, \code{y}, \code{z}). } \seealso{ \code{\link{sph2cart}}, \code{\link{cart2pol}}, \code{\link{pol2cart}} } \author{ Kai Habel David Sterratt } geometry/man/distmeshnd.Rd0000644000176200001440000001033014662314120015305 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/distmeshnd.R \name{distmeshnd} \alias{distmeshnd} \title{A simple mesh generator for non-convex regions in n-D space} \usage{ distmeshnd( fdist, fh, h, box, pfix = array(dim = c(0, ncol(box))), ..., ptol = 0.001, ttol = 0.1, deltat = 0.1, geps = 0.1 * h, deps = sqrt(.Machine$double.eps) * h ) } \arguments{ \item{fdist}{Vectorized signed distance function, for example \code{\link{mesh.dsphere}}, accepting an \code{m}-by-\code{n} matrix, where \code{m} is arbitrary, as the first argument.} \item{fh}{Vectorized function, for example \code{\link{mesh.hunif}}, that returns desired edge length as a function of position. Accepts an \code{m}-by-\code{n} matrix, where \code{n} is arbitrary, as its first argument.} \item{h}{Initial distance between mesh nodes.} \item{box}{\code{2}-by-\code{n} matrix that specifies the bounding box. (See \link{distmesh2d} for an example.)} \item{pfix}{\code{nfix}-by-2 matrix with fixed node positions.} \item{\dots}{parameters that are passed to \code{fdist} and \code{fh}} \item{ptol}{Algorithm stops when all node movements are smaller than \code{dptol}} \item{ttol}{Controls how far the points can move (relatively) before a retriangulation with \code{\link{delaunayn}}.} \item{deltat}{Size of the time step in Euler's method.} \item{geps}{Tolerance in the geometry evaluations.} \item{deps}{Stepsize \eqn{\Delta x} in numerical derivative computation for distance function.} } \value{ \code{m}-by-\code{n} matrix with node positions. } \description{ An unstructured simplex requires a choice of mesh points (vertex nodes) and a triangulation. This is a simple and short algorithm that improves the quality of a mesh by relocating the mesh points according to a relaxation scheme of forces in a truss structure. The topology of the truss is reset using Delaunay triangulation. A (sufficiently smooth) user supplied signed distance function (\code{fd}) indicates if a given node is inside or outside the region. Points outside the region are projected back to the boundary. } \details{ This is an implementation of original Matlab software of Per-Olof Persson. Excerpt (modified) from the reference below: \sQuote{The algorithm is based on a mechanical analogy between a triangular mesh and a n-D truss structure. In the physical model, the edges of the Delaunay triangles of a set of points correspond to bars of a truss. Each bar has a force-displacement relationship \eqn{f(\ell, \ell_{0})}{F(L,L0)} depending on its current length \eqn{\ell}{L} and its unextended length \eqn{\ell_{0}}{L0}.} \sQuote{External forces on the structure come at the boundaries, on which external forces have normal orientations. These external forces are just large enough to prevent nodes from moving outside the boundary. The position of the nodes are the unknowns, and are found by solving for a static force equilibrium. The hope is that (when \code{fh = function(p) return(rep(1,nrow(p)))}), the lengths of all the bars at equilibrium will be nearly equal, giving a well-shaped triangular mesh.} See the references below for all details. Also, see the comments in the source file of \code{distmesh2d}. } \section{Wishlist }{ \itemize{ \item Implement in C/Fortran \item Translate other functions of the Matlab package } } \examples{ \dontrun{ # examples distmeshnd require(rgl) fd = function(p, ...) sqrt((p^2)\%*\%c(1,1,1)) - 1 # also predefined as `mesh.dsphere' fh = function(p,...) rep(1,nrow(p)) # also predefined as `mesh.hunif' bbox = matrix(c(-1,1),2,3) p = distmeshnd(fd,fh,0.2,bbox, maxiter=100) # this may take a while: # press Esc to get result of current iteration } } \references{ \url{http://persson.berkeley.edu/distmesh/} \cite{P.-O. Persson, G. Strang, A Simple Mesh Generator in MATLAB. SIAM Review, Volume 46 (2), pp. 329-345, June 2004} } \seealso{ \code{\link{distmesh2d}}, \code{\link[interp]{tri.mesh}}, \code{\link{delaunayn}}, \code{\link{mesh.dsphere}}, \code{\link{mesh.hunif}},\cr \code{\link{mesh.diff}}, \code{\link{mesh.union}}, \code{\link{mesh.intersect}} } \author{ Raoul Grasman; translated from original Matlab sources of Per-Olof Persson. } \keyword{dplot} \keyword{graphs} \keyword{math} \keyword{optimize} geometry/man/halfspacen.Rd0000644000176200001440000000310113450441023015242 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/halfspacen.R \name{halfspacen} \alias{halfspacen} \title{Compute halfspace intersection about a point} \usage{ halfspacen(p, fp, options = "Tv") } \arguments{ \item{p}{An \eqn{M}-by-\eqn{N+1} matrix. Each row of \code{p} represents a halfspace by a \eqn{N}-dimensional normal to a hyperplane and the offset of the hyperplane.} \item{fp}{A \dQuote{feasible} point that is within the space contained within all the halfspaces.} \item{options}{String containing extra options, separated by spaces, for the underlying Qhull command; see Qhull documentation at \url{../doc/qhull/html/qhalf.html}.} } \value{ A \eqn{N}-column matrix containing the intersection points of the hyperplanes \url{../doc/qhull/html/qhalf.html}. } \description{ Compute halfspace intersection about a point } \note{ \code{halfspacen} was introduced in geometry 0.4.0, and is still under development. It is worth checking results for unexpected behaviour. } \examples{ p <- rbox(0, C=0.5) # Generate points on a unit cube centered around the origin ch <- convhulln(p, "n") # Generate convex hull, including normals to facets, with "n" option # Intersections of half planes # These points should be the same as the orginal points pn <- halfspacen(ch$normals, c(0, 0, 0)) } \references{ \cite{Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., \dQuote{The Quickhull algorithm for convex hulls,} \emph{ACM Trans. on Mathematical Software,} Dec 1996.} \url{http://www.qhull.org} } \seealso{ \code{\link{convhulln}} } \author{ David Sterratt } geometry/man/dot.Rd0000644000176200001440000000122613100737575013746 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/dotprod.R \name{dot} \alias{dot} \title{Compute the dot product of two vectors} \usage{ dot(x, y, d = NULL) } \arguments{ \item{x}{Matrix of vectors} \item{y}{Matrix of vectors} \item{d}{Dimension along which to calculate the dot product} } \value{ Vector with length of \code{d}th dimension } \description{ If \code{x} and \code{y} are matrices, calculate the dot-product along the first non-singleton dimension. If the optional argument \code{d} is given, calculate the dot-product along this dimension. } \author{ David Sterratt } \keyword{arith} \keyword{array} \keyword{math} geometry/man/tsearch.Rd0000644000176200001440000000350113433536400014600 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/tsearch.R \name{tsearch} \alias{tsearch} \title{Search for the enclosing Delaunay convex hull} \usage{ tsearch(x, y, t, xi, yi, bary = FALSE, method = "quadtree") } \arguments{ \item{x}{X-coordinates of triangulation points} \item{y}{Y-coordinates of triangulation points} \item{t}{Triangulation, e.g. produced by \code{t <- delaunayn(cbind(x, y))}} \item{xi}{X-coordinates of points to test} \item{yi}{Y-coordinates of points to test} \item{bary}{If \code{TRUE} return barycentric coordinates as well as index of triangle.} \item{method}{One of \code{"quadtree"} or \code{"orig"}. The Quadtree algorithm is much faster and new from version 0.4.0. The \code{orig} option uses the tsearch algorithm adapted from Octave code. Its use is deprecated and it may be removed from a future version of the package.} } \value{ If \code{bary} is \code{FALSE}, the index in \code{t} containing the points \code{(xi, yi)}. For points outside the convex hull the index is \code{NA}. If \code{bary} is \code{TRUE}, a list containing: \describe{ \item{list("idx")}{the index in \code{t} containing the points \code{(xi, yi)}} \item{list("p")}{a 3-column matrix containing the barycentric coordinates with respect to the enclosing triangle of each point \code{(xi, yi)}.} } } \description{ For \code{t <- delaunay(cbind(x, y))}, where \code{(x, y)} is a 2D set of points, \code{tsearch(x, y, t, xi, yi)} finds the index in \code{t} containing the points \code{(xi, yi)}. For points outside the convex hull the index is \code{NA}. } \note{ The original Octave function is Copyright (C) 2007-2012 David Bateman } \seealso{ \code{\link{tsearchn}}, \code{\link{delaunayn}} } \author{ Jean-Romain Roussel (Quadtree algorithm), David Sterratt (Octave-based implementation) } geometry/man/sph2cart.Rd0000644000176200001440000000166513433536400014706 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/sph2cart.R \name{sph2cart} \alias{sph2cart} \title{Transform spherical coordinates to Cartesian coordinates} \usage{ sph2cart(theta, phi = NULL, r = NULL) } \arguments{ \item{theta}{describes the angle relative to the positive x-axis.} \item{phi}{is the angle relative to the xy-plane.} \item{r}{is the distance to the origin \code{(0, 0, 0)}. If only a single return argument is requested then return a matrix \code{C} where each row represents one Cartesian coordinate (\code{x}, \code{y}, \code{z}).} } \description{ The inputs \code{theta}, \code{phi}, and \code{r} must be the same shape, or scalar. If called with a single matrix argument then each row of \code{S} represents the spherical coordinate (\code{theta}, \code{phi}, \code{r}). } \seealso{ \code{\link{cart2sph}}, \code{\link{pol2cart}}, \code{\link{cart2pol}} } \author{ Kai Habel David Sterratt } geometry/man/entry.value.Rd0000644000176200001440000000220013100737575015425 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/entry.value.R \name{entry.value} \alias{entry.value} \alias{entry.value<-} \title{Retrieve or set a list of array element values} \usage{ entry.value(a, idx) } \arguments{ \item{a}{An array.} \item{idx}{Numerical matrix with the same number of columns as the number of dimensions of \code{a}. Each row indices a cell in \code{a} of which the value is to be retrieved or set.} \item{value}{An array of length \code{nrow(idx)}.} } \value{ \code{entry.value(a,idx)} returns a vector of values at the indicated cells. \code{entry.value(a,idx) <- val} changes the indicated cells of \code{a} to \code{val}. } \description{ \code{entry.value} retrieves or sets the values in an array \code{a} at the positions indicated by the rows of a matrix \code{idx}. } \examples{ a = array(1:(4^4),c(4,4,4,4)) entry.value(a,cbind(1:4,1:4,1:4,1:4)) entry.value(a,cbind(1:4,1:4,1:4,1:4)) <- 0 entry.value(a, as.matrix(expand.grid(1:4,1:4,1:4,1:4))) # same as `c(a[1:4,1:4,1:4,1:4])' which is same as `c(a)' } \author{ Raoul Grasman } \keyword{arith} \keyword{array} \keyword{math} geometry/man/mesh.hunif.Rd0000644000176200001440000000136013100737575015223 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/mesh.hunif.R \name{mesh.hunif} \alias{mesh.hunif} \title{Uniform desired edge length} \usage{ mesh.hunif(p, ...) } \arguments{ \item{p}{A \code{n}-by-\code{m} matrix, each row representing a point in an \code{m}-dimensional space.} \item{...}{additional arguments (not used)} } \value{ Vector of ones of length \code{n}. } \description{ Uniform desired edge length function of position to allow easy definition of regions when passed as the \code{fh} argument of \code{\link{distmesh2d}} or \code{\link{distmeshnd}}. } \seealso{ \code{\link{distmesh2d}} and \code{\link{distmeshnd}}. } \author{ Raoul Grasman; translated from original Matlab sources of Per-Olof Persson. } geometry/man/to.mesh3d.Rd0000644000176200001440000000112313431000557014746 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/convhulln.R \name{to.mesh3d} \alias{to.mesh3d} \title{Convert convhulln object to RGL mesh} \usage{ to.mesh3d(x, ...) } \arguments{ \item{x}{\code{\link{convhulln}} object} \item{...}{Arguments to \code{\link[rgl]{qmesh3d}} or \code{\link[rgl]{tmesh3d}}} } \value{ \code{\link[rgl]{mesh3d}} object, which can be displayed in RGL with \code{\link[rgl]{dot3d}}, \code{\link[rgl]{wire3d}} or \code{\link[rgl]{shade3d}} } \description{ Convert convhulln object to RGL mesh } \seealso{ \code{\link[rgl]{as.mesh3d}} } geometry/man/mesh.dcircle.Rd0000644000176200001440000000213613100737575015521 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/mesh.dcircle.R \name{mesh.dcircle} \alias{mesh.dcircle} \title{Circle distance function} \usage{ mesh.dcircle(p, radius = 1, ...) } \arguments{ \item{p}{A matrix with 2 columns (3 in \code{mesh.dsphere}), each row representing a point in the plane.} \item{radius}{radius of circle} \item{...}{additional arguments (not used)} } \value{ A vector of length \code{nrow(p)} containing the signed distances to the circle } \description{ Signed distance from points \code{p} to boundary of circle to allow easy definition of regions in \code{\link{distmesh2d}}. } \examples{ example(distmesh2d) } \references{ \url{http://persson.berkeley.edu/distmesh/} \cite{P.-O. Persson, G. Strang, A Simple Mesh Generator in MATLAB. SIAM Review, Volume 46 (2), pp. 329-345, June 2004} } \seealso{ \code{\link{distmesh2d}}, \code{\link{mesh.drectangle}}, \code{\link{mesh.diff}}, \code{\link{mesh.intersect}}, \code{\link{mesh.union}} } \author{ Raoul Grasman; translated from original Matlab sources of Per-Olof Persson. } \keyword{arith} \keyword{math} geometry/man/cart2pol.Rd0000644000176200001440000000163113433536400014677 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/cart2pol.R \name{cart2pol} \alias{cart2pol} \title{Transform Cartesian coordinates to polar or cylindrical coordinates.} \usage{ cart2pol(x, y = NULL, z = NULL) } \arguments{ \item{x}{x-coordinates or matrix with three columns} \item{y}{y-coordinates (optional, if \code{x}) is a matrix} \item{z}{z-coordinates (optional, if \code{x}) is a matrix} } \value{ A matrix \code{P} where each row represents one polar/(cylindrical) coordinate (\code{theta}, \code{r}, (, \code{z})). } \description{ The inputs \code{x}, \code{y} (, and \code{z}) must be the same shape, or scalar. If called with a single matrix argument then each row of \code{C} represents the Cartesian coordinate (\code{x}, \code{y} (, \code{z})). } \seealso{ \code{\link{pol2cart}}, \code{\link{cart2sph}}, \code{\link{sph2cart}} } \author{ Kai Habel David Sterratt } geometry/man/bary2cart.Rd0000644000176200001440000000215013433536400015037 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/tsearch.R \name{bary2cart} \alias{bary2cart} \title{Conversion of Barycentric to Cartesian coordinates} \usage{ bary2cart(X, Beta) } \arguments{ \item{X}{Reference simplex in \eqn{N} dimensions represented by a \eqn{N+1}-by-\eqn{N} matrix} \item{Beta}{\eqn{M} points in barycentric coordinates with respect to the simplex \code{X} represented by a \eqn{M}-by-\eqn{N+1} matrix} } \value{ \eqn{M}-by-\eqn{N} matrix in which each row is the Cartesian coordinates of corresponding row of \code{Beta} } \description{ Given the barycentric coordinates of one or more points with respect to a simplex, compute the Cartesian coordinates of these points. } \examples{ ## Define simplex in 2D (i.e. a triangle) X <- rbind(c(0, 0), c(0, 1), c(1, 0)) ## Cartesian cooridinates of points beta <- rbind(c(0, 0.5, 0.5), c(0.1, 0.8, 0.1)) ## Plot triangle and points trimesh(rbind(1:3), X) text(X[,1], X[,2], 1:3) # Label vertices P <- bary2cart(X, beta) points(P) } \seealso{ \code{\link{cart2bary}} } \author{ David Sterratt } geometry/man/rbox.Rd0000644000176200001440000000112513161753572014132 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/rbox.R \name{rbox} \alias{rbox} \title{Generate various point distributions} \usage{ rbox(n = 3000, D = 3, B = 0.5, C = NA) } \arguments{ \item{n}{number of random points in hypercube} \item{D}{number of dimensions of hypercube} \item{B}{bounding box coordinate - faces will be \code{-B} and \code{B} from origin} \item{C}{add a unit hypercube to the output - faces will be \code{-C} and \code{C} from origin} } \value{ Matrix of points } \description{ Default is corners of a hypercube. } \author{ David Sterratt } geometry/man/mesh.diff.Rd0000644000176200001440000000264313162524123015016 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/mesh.diff.R \name{mesh.diff} \alias{mesh.diff} \alias{mesh.union} \alias{mesh.intersect} \title{Difference, union and intersection operation on two regions} \usage{ mesh.diff(p, regionA, regionB, ...) } \arguments{ \item{p}{A matrix with 2 columns (3 in \code{mesh.dsphere}), each row representing a point in the plane.} \item{regionA}{vectorized function describing region A in the union / intersection / difference} \item{regionB}{vectorized function describing region B in the union / intersection / difference} \item{...}{additional arguments passed to \code{regionA} and \code{regionB}} } \value{ A vector of length \code{nrow(p)} containing the signed distances to the boundary of the region. } \description{ Compute the signed distances from points \code{p} to a region defined by the difference, union or intersection of regions specified by the functions \code{regionA} and \code{regionB}. \code{regionA} and \code{regionB} must accept a matrix \code{p} with 2 columns as their first argument, and must return a vector of length \code{nrow(p)} containing the signed distances of the supplied points in \code{p} to their respective regions. } \seealso{ \code{\link{distmesh2d}}, \code{\link{mesh.dcircle}}, \code{\link{mesh.drectangle}} \code{\link{mesh.dsphere}} } \author{ Raoul Grasman; translated from original Matlab sources of Per-Olof Persson. } geometry/man/tsearchn.Rd0000644000176200001440000000361213433536400014761 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/tsearch.R \name{tsearchn} \alias{tsearchn} \title{Search for the enclosing Delaunay convex hull} \usage{ tsearchn(x, t, xi, ...) } \arguments{ \item{x}{An \eqn{N}-column matrix, in which each row represents a point in \eqn{N}-dimensional space.} \item{t}{A matrix with \eqn{N+1} columns. A row of \code{t} contains indices into \code{x} of the vertices of an \eqn{N}-dimensional simplex. \code{t} is usually the output of delaunayn.} \item{xi}{An \eqn{M}-by-\eqn{N} matrix. The rows of \code{xi} represent \eqn{M} points in \eqn{N}-dimensional space whose positions in the mesh are being sought.} \item{...}{Additional arguments} } \value{ A list containing: \describe{ \item{\code{idx}}{An \eqn{M}-long vector containing the indices of the row of \code{t} in which each point in \code{xi} is found.} \item{\code{p}}{An \eqn{M}-by-\eqn{N+1} matrix containing the barycentric coordinates with respect to the enclosing simplex of each point in \code{xi}.}} } \description{ For \code{t = delaunayn(x)}, where \code{x} is a set of points in \eqn{N} dimensions, \code{tsearchn(x, t, xi)} finds the index in \code{t} containing the points \code{xi}. For points outside the convex hull, \code{idx} is \code{NA}. \code{tsearchn} also returns the barycentric coordinates \code{p} of the enclosing triangles. } \details{ If \code{x} is \code{NA} and the \code{t} is a \code{delaunayn} object produced by \code{\link{delaunayn}} with the \code{full} option, then use the Qhull library to perform the search. Please note that this is experimental in geometry version 0.4.0 and is only partly tested for 3D hulls, and does not yet work for hulls of 4 dimensions and above. } \note{ Based on the Octave function Copyright (C) 2007-2012 David Bateman. } \seealso{ \code{\link{tsearch}}, \code{\link{delaunayn}} } \author{ David Sterratt } geometry/man/pol2cart.Rd0000644000176200001440000000161713433536400014703 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/pol2cart.R \name{pol2cart} \alias{pol2cart} \title{Transform polar or cylindrical coordinates to Cartesian coordinates.} \usage{ pol2cart(theta, r = NULL, z = NULL) } \arguments{ \item{theta}{describes the angle relative to the positive x-axis.} \item{r}{is the distance to the z-axis (0, 0, z).} \item{z}{(optional) is the z-coordinate} } \value{ a matrix \code{C} where each row represents one Cartesian coordinate (\code{x}, \code{y} (, \code{z})). } \description{ The inputs \code{theta}, \code{r}, (and \code{z}) must be the same shape, or scalar. If called with a single matrix argument then each row of \code{P} represents the polar/(cylindrical) coordinate (\code{theta}, \code{r} (, \code{z})). } \seealso{ \code{\link{cart2pol}}, \code{\link{sph2cart}}, \code{\link{cart2sph}} } \author{ Kai Habel David Sterratt } geometry/man/intersectn.Rd0000644000176200001440000000503114662314120015323 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/intersectn.R \name{intersectn} \alias{intersectn} \title{Compute convex hull of intersection of two sets of points} \usage{ intersectn( ps1, ps2, tol = 0, return.chs = TRUE, options = "Tv", fp = NULL, autoscale = FALSE ) } \arguments{ \item{ps1}{First set of points} \item{ps2}{Second set of points} \item{tol}{Tolerance used to determine if a feasible point lies within the convex hulls of both points and to round off the points generated by the halfspace intersection, which sometimes produces points very close together.} \item{return.chs}{If \code{TRUE} (default) return the convex hulls of the first and second sets of points, as well as the convex hull of the intersection.} \item{options}{Options passed to \code{\link{halfspacen}}. By default this is \code{Tv}.} \item{fp}{Coordinates of feasible point, i.e. a point known to lie in the hulls of \code{ps1} and \code{ps2}. The feasible point is required for \code{\link{halfspacen}} to find the intersection. \code{intersectn} tries to find the feasible point automatically using the linear program in \code{\link{feasible.point}}, but currently the linear program fails on some examples where there is an obvious solution. This option overrides the automatic search for a feasible point} \item{autoscale}{\emph{Experimental in v0.4.2} Automatically scale the points to lie in a sensible numeric range. May help to correct some numerical issues.} } \value{ List containing named elements: \code{ch1}, the convex hull of the first set of points, with volumes, areas and normals (see \code{\link{convhulln}}; \code{ch2}, the convex hull of the first set of points, with volumes, areas and normals; \code{ps}, the intersection points of convex hulls \code{ch1} and \code{ch2}; and \code{ch}, the convex hull of the intersection points, with volumes, areas and normals. } \description{ Compute convex hull of intersection of two sets of points } \note{ \code{intersectn} was introduced in geometry 0.4.0, and is still under development. It is worth checking results for unexpected behaviour. } \examples{ # Two overlapping boxes ps1 <- rbox(0, C=0.5) ps2 <- rbox(0, C=0.5) + 0.5 out <- intersectn(ps1, ps2) message("Volume of 1st convex hull: ", out$ch1$vol) message("Volume of 2nd convex hull: ", out$ch2$vol) message("Volume of intersection convex hull: ", out$ch$vol) } \seealso{ \code{\link{convhulln}}, \code{\link{halfspacen}}, \code{\link{inhulln}}, \code{\link{feasible.point}} } \author{ David Sterratt } geometry/man/convhulln.Rd0000644000176200001440000001037114662314120015160 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/convhulln.R \name{convhulln} \alias{convhulln} \title{Compute smallest convex hull that encloses a set of points} \usage{ convhulln( p, options = "Tv", output.options = NULL, return.non.triangulated.facets = FALSE ) } \arguments{ \item{p}{An \eqn{M}-by-\eqn{N} matrix. The rows of \code{p} represent \eqn{M} points in \eqn{N}-dimensional space.} \item{options}{String containing extra options for the underlying Qhull command; see details below and Qhull documentation at \url{../doc/qhull/html/qconvex.html#synopsis}.} \item{output.options}{String containing Qhull options to generate extra output. Currently \code{n} (normals) and \code{FA} (generalised areas and volumes) are supported; see \sQuote{Value} for details. If \code{output.options} is \code{TRUE}, select all supported options.} \item{return.non.triangulated.facets}{logical defining whether the output facets should be triangulated; \code{FALSE} by default.} } \value{ By default (\code{return.non.triangulated.facets} is \code{FALSE}), return an \eqn{M}-by-\eqn{N} matrix in which each row contains the indices of the points in \code{p} forming an \eqn{N-1}-dimensional facet. e.g In 3 dimensions, there are 3 indices in each row describing the vertices of 2-dimensional triangles. If \code{return.non.triangulated.facets} is \code{TRUE} then the number of columns equals the maximum number of vertices in a facet, and each row defines a polygon corresponding to a facet of the convex hull with its vertices followed by \code{NA}s until the end of the row. If the \code{output.options} or \code{options} argument contains \code{FA} or \code{n}, return a list with class \code{convhulln} comprising the named elements: \describe{ \item{\code{p}}{The points passed to \code{convnhulln}} \item{\code{hull}}{The convex hull, represented as a matrix indexing \code{p}, as described above} \item{\code{area}}{If \code{FA} is specified, the generalised area of the hull. This is the surface area of a 3D hull or the length of the perimeter of a 2D hull. See \url{../doc/qhull/html/qh-optf.html#FA}.} \item{\code{vol}}{If \code{FA} is specified, the generalised volume of the hull. This is volume of a 3D hull or the area of a 2D hull. See \url{../doc/qhull/html/qh-optf.html#FA}. } \item{\code{normals}}{If \code{n} is specified, this is a matrix hyperplane normals with offsets. See \url{../doc/qhull/html/qh-opto.html#n}.} } } \description{ Returns information about the smallest convex complex of a set of input points in \eqn{N}-dimensional space (the convex hull of the points). By default, indices to points forming the facets of the hull are returned; optionally normals to the facets and the generalised surface area and volume can be returned. This function interfaces the \href{http://www.qhull.org}{Qhull} library. } \note{ This function was originally a port of the \href{https://octave.org/}{Octave} convhulln function written by Kai Habel. See further notes in \code{\link{delaunayn}}. } \examples{ ## Points in a sphere ps <- matrix(rnorm(3000), ncol=3) ps <- sqrt(3)*ps/drop(sqrt((ps^2) \%*\% rep(1, 3))) ts.surf <- t(convhulln(ps)) # see the qhull documentations for the options \dontrun{ rgl::triangles3d(ps[ts.surf,1],ps[ts.surf,2],ps[ts.surf,3],col="blue",alpha=.2) for(i in 1:(8*360)) rgl::view3d(i/8) } ## Square pq <- rbox(0, C=0.5, D=2) # Return indices only convhulln(pq) # Return convhulln object with normals, generalised area and volume ch <- convhulln(pq, output.options=TRUE) plot(ch) ## Cube pc <- rbox(0, C=0.5, D=3) # Return indices of triangles on surface convhulln(pc) # Return indices of squares on surface convhulln(pc, return.non.triangulated.facets=TRUE) } \references{ \cite{Barber, C.B., Dobkin, D.P., and Huhdanpaa, H.T., \dQuote{The Quickhull algorithm for convex hulls,} \emph{ACM Trans. on Mathematical Software,} Dec 1996.} \url{http://www.qhull.org} } \seealso{ \code{\link{intersectn}}, \code{\link{delaunayn}}, \code{\link{surf.tri}}, \code{\link[interp]{convex.hull}} } \author{ Raoul Grasman, Robert B. Gramacy, Pavlo Mozharovskyi and David Sterratt \email{david.c.sterratt@ed.ac.uk} } \keyword{dplot} \keyword{graphs} \keyword{math} geometry/man/inhulln.Rd0000644000176200001440000000255314112721316014623 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/inhulln.R \name{inhulln} \alias{inhulln} \title{Test if points lie in convex hull} \usage{ inhulln(ch, p) } \arguments{ \item{ch}{Convex hull produced using \code{\link{convhulln}}} \item{p}{An \eqn{M}-by-\eqn{N} matrix of points to test. The rows of \code{p} represent \eqn{M} points in \eqn{N}-dimensional space.} } \value{ A boolean vector with \eqn{M} elements } \description{ Tests if a set of points lies within a convex hull, returning a boolean vector in which each element is \code{TRUE} if the corresponding point lies within the hull and \code{FALSE} if it lies outwith the hull or on one of its facets. } \note{ \code{inhulln} was introduced in geometry 0.4.0, and is still under development. It is worth checking results for unexpected behaviour. } \examples{ p <- cbind(c(-1, -1, 1), c(-1, 1, -1)) ch <- convhulln(p) ## First point should be in the hull; last two outside inhulln(ch, rbind(c(-0.5, -0.5), c( 1 , 1), c(10 , 0))) ## Test hypercube p <- rbox(D=4, B=1) ch <- convhulln(p) tp <- cbind(seq(-1.9, 1.9, by=0.2), 0, 0, 0) pin <- inhulln(ch, tp) ## Points on x-axis should be in box only betw,een -1 and 1 pin == (tp[,1] < 1 & tp[,1] > -1) } \seealso{ \code{\link{convhulln}}, \code{point.in.polygon} in \pkg{sp} } \author{ David Sterratt } geometry/man/Unique.Rd0000644000176200001440000000213513100737575014426 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/Unique.R \name{Unique} \alias{Unique} \title{Extract Unique Rows} \usage{ Unique(X, rows.are.sets = FALSE) } \arguments{ \item{X}{Numerical matrix.} \item{rows.are.sets}{If \sQuote{\code{TRUE}}, rows are treated as sets - i.e., to define uniqueness, the order of the rows does not matter.} } \value{ Matrix of the same number of columns as \code{x}, with the unique rows in \code{x} sorted according to the columns of \code{x}. If \code{rows.are.sets = TRUE} the rows are also sorted. } \description{ \sQuote{Unique} returns a vector, data frame or array like 'x' but with duplicate elements removed. } \note{ \sQuote{\code{Unique}} is (under circumstances) much quicker than the more generic base function \sQuote{\code{unique}}. } \examples{ # `Unique' is faster than `unique' x = matrix(sample(1:(4*8),4*8),ncol=4) y = x[sample(1:nrow(x),3000,TRUE), ] gc(); system.time(unique(y)) gc(); system.time(Unique(y)) # z = Unique(y) x[matorder(x),] z[matorder(z),] } \author{ Raoul Grasman } \keyword{arith} \keyword{array} \keyword{math} geometry/man/extprod3d.Rd0000644000176200001440000000210214664604533015071 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/extprod3d.R \name{extprod3d} \alias{extprod3d} \title{Compute external- or \sQuote{cross}- product of 3D vectors.} \usage{ extprod3d(x, y, drop = TRUE) } \arguments{ \item{x}{\code{n}-by-3 matrix. Each row is one \bold{x}-vector} \item{y}{\code{n}-by-3 matrix. Each row is one \bold{y}-vector} \item{drop}{logical. If \code{TRUE} and if the inputs are one row matrices or vectors, then delete the dimensions of the array returned.} } \value{ If \code{n} is greater than 1 or \code{drop} is \code{FALSE}, \code{n}-by-3 matrix; if \code{n} is 1 and \code{drop} is \code{TRUE}, a vector of length 3. } \description{ Computes the external product \deqn{ \left(x_2 y_3 - x_3 y_2,\; x_3 y_1 - x_1 y_3,\; x_1 y_2 - x_2 y_1 \right) }{ (x2 * y3 - x3 * y2, x3 * y1 - x1 * y3, x1 * y2 - x2 * y1) } of the 3D vectors in \bold{x} and \bold{y}. } \seealso{ \code{\link[base]{drop}} } \author{ Raoul Grasman } \keyword{arith} \keyword{array} \keyword{math} geometry/man/polyarea.Rd0000644000176200001440000000215713162524123014767 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/polyarea.R \name{polyarea} \alias{polyarea} \title{Determines area of a polygon by triangle method.} \usage{ polyarea(x, y, d = 1) } \arguments{ \item{x}{X coordinates of vertices.} \item{y}{Y coordinates of vertices.} \item{d}{Dimension of array to work along.} } \value{ Area(s) of polygon(s). } \description{ Determines area of a polygon by triangle method. The variables \code{x} and \code{y} define the vertex pairs, and must therefore have the same shape. They can be either vectors or arrays. If they are arrays then the columns of \code{x} and \code{y} are treated separately and an area returned for each. } \details{ If the optional \code{dim} argument is given, then \code{polyarea} works along this dimension of the arrays \code{x} and \code{y}. } \examples{ x <- c(1, 1, 3, 3, 1) y <- c(1, 3, 3, 1, 1) polyarea(x, y) polyarea(cbind(x, x), cbind(y, y)) ## c(4, 4) polyarea(cbind(x, x), cbind(y, y), 1) ## c(4, 4) polyarea(rbind(x, x), rbind(y, y), 2) ## c(4, 4) } \author{ David Sterratt based on the octave sources by David M. Doolin } geometry/man/feasible.point.Rd0000644000176200001440000000124713431000557016053 0ustar liggesusers% Generated by roxygen2: do not edit by hand % Please edit documentation in R/intersectn.R \name{feasible.point} \alias{feasible.point} \title{Find point in intersection of convex hulls} \usage{ feasible.point(ch1, ch2, tol = 0) } \arguments{ \item{ch1}{First convex hull with normals} \item{ch2}{Second convex hull with normals} \item{tol}{The point must be at least this far within the facets of both convex hulls} } \description{ Find point that lies somewhere in interesction of two convex hulls. If such a point does not exist, return \code{NA}. The feasible point is found using a linear program similar to the one suggested at \url{../doc/qhull/html/qhalf.html#notes} } geometry/DESCRIPTION0000644000176200001440000000400714751753072013627 0ustar liggesusersPackage: geometry License: GPL (>= 3) Title: Mesh Generation and Surface Tessellation Authors@R: c( person("Jean-Romain", "Roussel" , role=c("cph", "ctb"), comment = "wrote tsearch function with QuadTrees"), person("C. B.", "Barber" , role="cph"), person("Kai", "Habel", role=c("cph","aut")), person("Raoul", "Grasman", role=c("cph","aut")), person("Robert B.", "Gramacy", role=c("cph","aut")), person("Pavlo", "Mozharovskyi", role=c("cph","aut")), person("David C.", "Sterratt", role=c("cph","aut","cre"), email="david.c.sterratt@ed.ac.uk", comment=c(ORCID="0000-0001-9092-9099"))) Description: Makes the 'Qhull' library available in R, in a similar manner as in Octave and MATLAB. Qhull computes convex hulls, Delaunay triangulations, halfspace intersections about a point, Voronoi diagrams, furthest-site Delaunay triangulations, and furthest-site Voronoi diagrams. It runs in 2D, 3D, 4D, and higher dimensions. It implements the Quickhull algorithm for computing the convex hull. Qhull does not support constrained Delaunay triangulations, or mesh generation of non-convex objects, but the package does include some R functions that allow for this. Version: 0.5.2 URL: https://davidcsterratt.github.io/geometry/ Date: 2025-02-08 BugReports: https://github.com/davidcsterratt/geometry/issues Depends: R (>= 3.5.0) Imports: magic, Rcpp, lpSolve, linprog Suggests: spelling, testthat, rgl, R.matlab, interp LinkingTo: Rcpp, RcppProgress Encoding: UTF-8 Language: en-GB RoxygenNote: 7.3.2 NeedsCompilation: yes Packaged: 2025-02-08 18:21:07 UTC; dcs Author: Jean-Romain Roussel [cph, ctb] (wrote tsearch function with QuadTrees), C. B. Barber [cph], Kai Habel [cph, aut], Raoul Grasman [cph, aut], Robert B. Gramacy [cph, aut], Pavlo Mozharovskyi [cph, aut], David C. Sterratt [cph, aut, cre] () Maintainer: David C. Sterratt Repository: CRAN Date/Publication: 2025-02-08 22:10:02 UTC