Skip to content

Commit f44f6db

Browse files
committed
v4.3.1
1 parent dd1346b commit f44f6db

12 files changed

Lines changed: 69 additions & 20 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: lidR
22
Type: Package
33
Title: Airborne LiDAR Data Manipulation and Visualization for Forestry
44
Applications
5-
Version: 4.3.0
5+
Version: 4.3.1
66
Authors@R: c(
77
person("Jean-Romain", "Roussel", email = "info@r-lidar.com", role = c("aut", "cre", "cph")),
88
person("David", "Auty", email = "", role = c("aut", "ctb"), comment = "Reviews the documentation"),

NEWS.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
If you are viewing this file on CRAN, please check [the latest news on GitHub](https://github.com/r-lidar/lidR/blob/master/NEWS.md) where the formatting is also better
22

3-
## lidR v4.3.0 (Release date: 2026-04)
3+
## lidR v4.3.1 (Release date: 2026-04)
4+
5+
- Fix: CRAN stuff
6+
- New: `point_metrics()` is back.
7+
8+
## lidR v4.3.0 (Release date: 2026-04-02)
49

510
- New: Progressive TIN Densification for ground classification (`ptd()`)
611
- New: Spike-free algorithm for CHM (`spikefree()`)
712
- New: Locally Adaptive Spike-free algorithm for CHM (`lspikefree()`)
813
- New: function `catalog_split_clusters()`
914
- Doc: [lidR book](https://github.com/r-lidar/lidRbook) updated
10-
- New: `point_metrics()` is back.
15+
1116

1217
## lidR v4.2.3 (Release date: 2026-01-07)
1318

R/RcppExports.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ C_tsearch <- function(D, P, X, ncpu) {
3333
.Call(`_lidR_C_tsearch`, D, P, X, ncpu)
3434
}
3535

36-
C_ptd <- function(df, res, angle, distance, spacing, verbose) {
37-
.Call(`_lidR_C_ptd`, df, res, angle, distance, spacing, verbose)
36+
C_ptd <- function(df, res, angle, distance, spacing, verbose, ncores) {
37+
.Call(`_lidR_C_ptd`, df, res, angle, distance, spacing, verbose, ncores)
3838
}
3939

4040
C_spikefree <- function(df, grid, d_f, h_b, slope = 1.96, intercept = 1.42) {

R/algorithm-gnd.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ ptd = function(res = 10, angle = 30, distance = 2, spacing = 0.25, verbose = FAL
301301

302302
las@data[["idx"]] <- 1:npoints(las)
303303
cloud <- las@data[filter, .(X,Y,Z, idx)]
304-
gnd <- C_ptd(cloud, res, angle, distance, spacing, verbose)
304+
gnd <- C_ptd(cloud, res, angle, distance, spacing, verbose, get_lidr_threads())
305305
idx <- cloud$idx[gnd+1]
306306
return(idx)
307307
}

src/C_ptd.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using namespace Rcpp;
66

77
// [[Rcpp::export]]
8-
NumericVector C_ptd(DataFrame df, double res, double angle, double distance, double spacing, bool verbose)
8+
NumericVector C_ptd(DataFrame df, double res, double angle, double distance, double spacing, bool verbose, int ncores)
99
{
1010
NumericVector x = df[0];
1111
NumericVector y = df[1];
@@ -18,6 +18,7 @@ NumericVector C_ptd(DataFrame df, double res, double angle, double distance, dou
1818
params.spacing = spacing;
1919
params.seed_resolution_search = res;
2020
params.verbose = verbose;
21+
params.ncores = ncores;
2122

2223
// Register the bounding box of the points
2324
PTD::Bbox bb;

src/RcppExports.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ BEGIN_RCPP
121121
END_RCPP
122122
}
123123
// C_ptd
124-
NumericVector C_ptd(DataFrame df, double res, double angle, double distance, double spacing, bool verbose);
125-
RcppExport SEXP _lidR_C_ptd(SEXP dfSEXP, SEXP resSEXP, SEXP angleSEXP, SEXP distanceSEXP, SEXP spacingSEXP, SEXP verboseSEXP) {
124+
NumericVector C_ptd(DataFrame df, double res, double angle, double distance, double spacing, bool verbose, int ncores);
125+
RcppExport SEXP _lidR_C_ptd(SEXP dfSEXP, SEXP resSEXP, SEXP angleSEXP, SEXP distanceSEXP, SEXP spacingSEXP, SEXP verboseSEXP, SEXP ncoresSEXP) {
126126
BEGIN_RCPP
127127
Rcpp::RObject rcpp_result_gen;
128128
Rcpp::RNGScope rcpp_rngScope_gen;
@@ -132,7 +132,8 @@ BEGIN_RCPP
132132
Rcpp::traits::input_parameter< double >::type distance(distanceSEXP);
133133
Rcpp::traits::input_parameter< double >::type spacing(spacingSEXP);
134134
Rcpp::traits::input_parameter< bool >::type verbose(verboseSEXP);
135-
rcpp_result_gen = Rcpp::wrap(C_ptd(df, res, angle, distance, spacing, verbose));
135+
Rcpp::traits::input_parameter< int >::type ncores(ncoresSEXP);
136+
rcpp_result_gen = Rcpp::wrap(C_ptd(df, res, angle, distance, spacing, verbose, ncores));
136137
return rcpp_result_gen;
137138
END_RCPP
138139
}
@@ -717,7 +718,7 @@ static const R_CallMethodDef CallEntries[] = {
717718
{"_lidR_C_interpolate_delaunay", (DL_FUNC) &_lidR_C_interpolate_delaunay, 7},
718719
{"_lidR_C_tinfo", (DL_FUNC) &_lidR_C_tinfo, 2},
719720
{"_lidR_C_tsearch", (DL_FUNC) &_lidR_C_tsearch, 4},
720-
{"_lidR_C_ptd", (DL_FUNC) &_lidR_C_ptd, 6},
721+
{"_lidR_C_ptd", (DL_FUNC) &_lidR_C_ptd, 7},
721722
{"_lidR_C_spikefree", (DL_FUNC) &_lidR_C_spikefree, 6},
722723
{"_lidR_C_lmf", (DL_FUNC) &_lidR_C_lmf, 5},
723724
{"_lidR_C_smooth", (DL_FUNC) &_lidR_C_smooth, 6},

src/hporro/geometry.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ struct Vec2
1717
bool operator==(const Vec2& other) const { return x == other.x && y == other.y; }
1818
Vec2 operator-(const Vec2& other) const { return Vec2{x - other.x, y - other.y}; }
1919
Vec2 operator+(const Vec2& other) const { return Vec2{x + other.x, y + other.y}; }
20-
Vec2 operator/(float a) const { return Vec2{x / a, y / a}; }
21-
Vec2 operator*(float a) const { return Vec2{x * a, y * a}; }
20+
Vec2 operator/(double a) const { return Vec2{x / a, y / a}; }
21+
Vec2 operator*(double a) const { return Vec2{x * a, y * a}; }
2222
Vec2& operator+=(const Vec2& other) { x += other.x; y += other.y; return *this; }
2323
double dot(const Vec2& other) { return x*other.x + y*other.y; }
2424
};
@@ -54,4 +54,4 @@ class Triangle
5454

5555
}
5656

57-
#endif
57+
#endif

src/hporro/index.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ int Grid::cell_from_xy(double x, double y) const
3939

4040
void Grid::get_cells(double xmin, double ymin, double xmax, double ymax, std::vector<int>& cells) const
4141
{
42-
int colmin = (xmin - this->xmin) / xres;
43-
int colmax = (xmax - this->xmin) / xres;
44-
int rowmin = (this->ymax - ymax) / yres;
45-
int rowmax = (this->ymax - ymin) / yres;
42+
int colmin = static_cast<int>(std::floor((xmin - this->xmin) / xres));
43+
int colmax = static_cast<int>(std::floor((xmax - this->xmin) / xres));
44+
int rowmin = static_cast<int>(std::floor((this->ymax - ymax) / yres));
45+
int rowmax = static_cast<int>(std::floor((this->ymax - ymin) / yres));
4646
cells.clear();
4747

4848
for (int col = std::max(colmin,0) ; col <= std::min(colmax, (int)ncols-1) ; col++) {
@@ -52,4 +52,4 @@ void Grid::get_cells(double xmin, double ymin, double xmax, double ymax, std::ve
5252
}
5353
}
5454

55-
}
55+
}

src/hporro/pred3d.cpp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,9 @@ REAL exactinit()
421421
#ifdef LINUX
422422
int cword;
423423
#endif /* LINUX */
424+
#ifdef __APPLE__
425+
unsigned short cw;
426+
#endif /* __APPLE__ */
424427

425428
#ifdef CPU86
426429
#ifdef SINGLE
@@ -439,6 +442,22 @@ REAL exactinit()
439442
#endif /* not SINGLE */
440443
_FPU_SETCW(cword);
441444
#endif /* LINUX */
445+
#ifdef __APPLE__
446+
/* Set FPU to use 53-bit precision for double on x86-64 macOS.
447+
This prevents use of 80-bit extended precision which can cause
448+
inconsistencies in geometric predicates. */
449+
#if defined(__i386__) || defined(__x86_64__)
450+
/* x86/x86-64: Use inline assembly to set FPU control word */
451+
#ifdef SINGLE
452+
cw = 0x007f; /* 24-bit precision (single), round to nearest, all exceptions masked */
453+
#else /* not SINGLE */
454+
cw = 0x027f; /* 53-bit precision (double), round to nearest, all exceptions masked */
455+
#endif /* not SINGLE */
456+
__asm__ __volatile__ ("fldcw %0" : : "m" (cw));
457+
#endif /* x86/x86-64 */
458+
/* Note: On ARM-based Macs, this is not needed as they use IEEE 754 compliant
459+
floating-point without extended precision. */
460+
#endif /* __APPLE__ */
442461

443462
every_other = 1;
444463
half = 0.5;
@@ -506,6 +525,9 @@ void exactinit(int verbose, int noexact, int o3dfilter, int ispfilter,
506525
#ifdef LINUX
507526
int cword;
508527
#endif /* LINUX */
528+
#ifdef __APPLE__
529+
unsigned short cw;
530+
#endif /* __APPLE__ */
509531

510532
#ifdef CPU86
511533
#ifdef SINGLE
@@ -524,6 +546,22 @@ void exactinit(int verbose, int noexact, int o3dfilter, int ispfilter,
524546
#endif /* not SINGLE */
525547
_FPU_SETCW(cword);
526548
#endif /* LINUX */
549+
#ifdef __APPLE__
550+
/* Set FPU to use 53-bit precision for double on x86-64 macOS.
551+
This prevents use of 80-bit extended precision which can cause
552+
inconsistencies in geometric predicates. */
553+
#if defined(__i386__) || defined(__x86_64__)
554+
/* x86/x86-64: Use inline assembly to set FPU control word */
555+
#ifdef SINGLE
556+
cw = 0x007f; /* 24-bit precision (single), round to nearest, all exceptions masked */
557+
#else /* not SINGLE */
558+
cw = 0x027f; /* 53-bit precision (double), round to nearest, all exceptions masked */
559+
#endif /* not SINGLE */
560+
__asm__ __volatile__ ("fldcw %0" : : "m" (cw));
561+
#endif /* x86/x86-64 */
562+
/* Note: On ARM-based Macs, this is not needed as they use IEEE 754 compliant
563+
floating-point without extended precision. */
564+
#endif /* __APPLE__ */
527565

528566
/*if (verbose) {
529567
printf(" Initializing robust predicates.\n");
@@ -4069,4 +4107,4 @@ REAL incircle(const REAL *pa, const REAL *pb, const REAL *pc, const REAL *pd)
40694107
}
40704108

40714109
return incircleadapt(pa, pb, pc, pd, permanent);
4072-
}
4110+
}

src/ptd/PTD.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <random>
66
#include <cmath>
77
#include <chrono>
8+
#include <unordered_map>
89

910
#include "PTD.h"
1011

0 commit comments

Comments
 (0)