Skip to content

Commit 090e9ad

Browse files
authored
Allocate rasterized buffer on heap (#37)
1 parent 4e6cd7d commit 090e9ad

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [2.1.5-RC2] - 2020-03-11
10+
11+
### Changed
12+
- Allocate rasterized buffer on heap [#37](https://github.com/PDAL/java/pull/37)
13+
914
## [2.1.5-RC1] - 2020-03-09
1015
### Added
1116
- Add a native mesh rasterization [#36](https://github.com/PDAL/java/pull/36)
@@ -93,7 +98,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9398
### Changed
9499
- Moved from the PDAL repo and established own lifecycle.
95100

96-
[Unreleased]: https://github.com/PDAL/java/compare/2.1.5-RC1...HEAD
101+
[Unreleased]: https://github.com/PDAL/java/compare/2.1.5-RC2...HEAD
102+
[2.1.5-RC2]: https://github.com/PDAL/java/compare/2.1.5-RC1...2.1.5-RC2
97103
[2.1.5-RC1]: https://github.com/PDAL/java/compare/2.1.4...2.1.5-RC1
98104
[2.1.4]: https://github.com/PDAL/java/compare/2.1.3...2.1.4
99105
[2.1.3]: https://github.com/PDAL/java/compare/2.1.2...2.1.3

examples/pdal-jni/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ resolvers ++= Seq(
2121

2222
fork := true
2323

24-
val pdalVersion = "2.1.5-RC1"
24+
val pdalVersion = "2.1.5-RC2"
2525

2626
libraryDependencies ++= Seq(
2727
"io.pdal" %% "pdal" % pdalVersion,

native/src/io_pdal_PointView.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,10 @@ using pdal::pdal_error;
6464
/// \param[in] dims JavaArray of DimTypes
6565
/// \param[in] bufSize Dims sum size
6666
/// \param[in] dimTypes Vector of DimTypes
67-
void convertDimTypeJavaArrayToVector(JNIEnv *env, jobjectArray dims, std::size_t *pointSize, DimTypeList *dimTypes, PointLayoutPtr pl) {
68-
for (jint i = 0; i < env->GetArrayLength(dims); i++) {
67+
void convertDimTypeJavaArrayToVector(JNIEnv *env, jobjectArray dims, std::size_t *pointSize, DimTypeList *dimTypes, PointLayoutPtr pl)
68+
{
69+
for (jint i = 0; i < env->GetArrayLength(dims); i++)
70+
{
6971
jobject jDimType = reinterpret_cast<jobject>(env->GetObjectArrayElement(dims, i));
7072
jclass cDimType = env->GetObjectClass(jDimType);
7173
jfieldID fid = env->GetFieldID(cDimType, "id", "Ljava/lang/String;");
@@ -192,7 +194,8 @@ JNIEXPORT jbyteArray JNICALL Java_io_pdal_PointView_getPackedPoints
192194
std::size_t bufSize = pointSize * pv->size();
193195
char *buf = new char[bufSize];
194196

195-
for (PointId idx = 0; idx < pv->size(); idx++) {
197+
for (PointId idx = 0; idx < pv->size(); idx++)
198+
{
196199
appendPackedPoint(pv, dimTypes, idx, pointSize, buf);
197200
}
198201

@@ -269,8 +272,8 @@ JNIEXPORT jdoubleArray JNICALL Java_io_pdal_PointView_rasterizeTriangularMesh
269272

270273
jdoubleArray result = env->NewDoubleArray(length);
271274

272-
double buffer[length];
273-
std::fill(buffer, buffer + sizeof(buffer) / sizeof(double), strtod("NaN", NULL));
275+
double *buffer = new double[length];
276+
std::fill(buffer, buffer + length, strtod("NaN", NULL));
274277

275278
for (int id = 0; id < size; id++)
276279
{
@@ -391,6 +394,8 @@ JNIEXPORT jdoubleArray JNICALL Java_io_pdal_PointView_rasterizeTriangularMesh
391394

392395
env->SetDoubleArrayRegion(result, 0, length, buffer);
393396

397+
delete[] buffer;
398+
394399
return result;
395400
}
396401

0 commit comments

Comments
 (0)