Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allocate rasterized buffer on heap #37

Merged
merged 1 commit into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.1.5-RC2] - 2020-03-11

### Changed
- Allocate rasterized buffer on heap [#37](https://github.com/PDAL/java/pull/37)

## [2.1.5-RC1] - 2020-03-09
### Added
- Add a native mesh rasterization [#36](https://github.com/PDAL/java/pull/36)
Expand Down Expand Up @@ -93,7 +98,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Moved from the PDAL repo and established own lifecycle.

[Unreleased]: https://github.com/PDAL/java/compare/2.1.5-RC1...HEAD
[Unreleased]: https://github.com/PDAL/java/compare/2.1.5-RC2...HEAD
[2.1.5-RC2]: https://github.com/PDAL/java/compare/2.1.5-RC1...2.1.5-RC2
[2.1.5-RC1]: https://github.com/PDAL/java/compare/2.1.4...2.1.5-RC1
[2.1.4]: https://github.com/PDAL/java/compare/2.1.3...2.1.4
[2.1.3]: https://github.com/PDAL/java/compare/2.1.2...2.1.3
Expand Down
2 changes: 1 addition & 1 deletion examples/pdal-jni/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ resolvers ++= Seq(

fork := true

val pdalVersion = "2.1.5-RC1"
val pdalVersion = "2.1.5-RC2"

libraryDependencies ++= Seq(
"io.pdal" %% "pdal" % pdalVersion,
Expand Down
15 changes: 10 additions & 5 deletions native/src/io_pdal_PointView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@ using pdal::pdal_error;
/// \param[in] dims JavaArray of DimTypes
/// \param[in] bufSize Dims sum size
/// \param[in] dimTypes Vector of DimTypes
void convertDimTypeJavaArrayToVector(JNIEnv *env, jobjectArray dims, std::size_t *pointSize, DimTypeList *dimTypes, PointLayoutPtr pl) {
for (jint i = 0; i < env->GetArrayLength(dims); i++) {
void convertDimTypeJavaArrayToVector(JNIEnv *env, jobjectArray dims, std::size_t *pointSize, DimTypeList *dimTypes, PointLayoutPtr pl)
{
for (jint i = 0; i < env->GetArrayLength(dims); i++)
{
jobject jDimType = reinterpret_cast<jobject>(env->GetObjectArrayElement(dims, i));
jclass cDimType = env->GetObjectClass(jDimType);
jfieldID fid = env->GetFieldID(cDimType, "id", "Ljava/lang/String;");
Expand Down Expand Up @@ -192,7 +194,8 @@ JNIEXPORT jbyteArray JNICALL Java_io_pdal_PointView_getPackedPoints
std::size_t bufSize = pointSize * pv->size();
char *buf = new char[bufSize];

for (PointId idx = 0; idx < pv->size(); idx++) {
for (PointId idx = 0; idx < pv->size(); idx++)
{
appendPackedPoint(pv, dimTypes, idx, pointSize, buf);
}

Expand Down Expand Up @@ -269,8 +272,8 @@ JNIEXPORT jdoubleArray JNICALL Java_io_pdal_PointView_rasterizeTriangularMesh

jdoubleArray result = env->NewDoubleArray(length);

double buffer[length];
std::fill(buffer, buffer + sizeof(buffer) / sizeof(double), strtod("NaN", NULL));
double *buffer = new double[length];
std::fill(buffer, buffer + length, strtod("NaN", NULL));

for (int id = 0; id < size; id++)
{
Expand Down Expand Up @@ -391,6 +394,8 @@ JNIEXPORT jdoubleArray JNICALL Java_io_pdal_PointView_rasterizeTriangularMesh

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

delete[] buffer;

return result;
}

Expand Down