Skip to content

Commit

Permalink
[geogram] Update to 1.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
simogasp committed Jan 15, 2018
1 parent 0fbcf25 commit a75a86e
Show file tree
Hide file tree
Showing 25 changed files with 4,262 additions and 2,027 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ include(cmake/geogram.cmake)

set(VORPALINE_VERSION_MAJOR 1)
set(VORPALINE_VERSION_MINOR 5)
set(VORPALINE_VERSION_PATCH 4)
set(VORPALINE_VERSION_PATCH 5)
set(VORPALINE_VERSION ${VORPALINE_VERSION_MAJOR}.${VORPALINE_VERSION_MINOR}.${VORPALINE_VERSION_PATCH})

set(VORPALINE_INCLUDE_SUBPATH geogram${VORPALINE_VERSION_MAJOR})
Expand Down
3 changes: 1 addition & 2 deletions src/examples/graphics/GLUP_basic_example/main.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -852,9 +852,8 @@ namespace {

static void overlay() {
// Displays ImGui demo window.
static bool dummy = true;
ImGui::SetNextWindowPos(ImVec2(650, 20), ImGuiSetCond_FirstUseEver);
ImGui::ShowTestWindow(&dummy);
ImGui::ShowDemoWindow();
}

int main(int argc, char** argv) {
Expand Down
23 changes: 20 additions & 3 deletions src/lib/geogram/NL/nl_arpack.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ static NLMatrix create_OP(NLboolean symmetric) {
symmetric ? NL_SYMMETRIC_SUPERLU_EXT : NL_PERM_SUPERLU_EXT
);
if(nlCurrentContext->verbose) {
nl_printf("Matrix factorized\n");
if(result == NULL) {
nl_printf("Could not factorize matrix\n");
} else {
nl_printf("Matrix factorized\n");
}
}
nlDeleteMatrix((NLMatrix)A);
} else {
Expand All @@ -271,11 +275,19 @@ static NLMatrix create_OP(NLboolean symmetric) {
result = nlMatrixFactorize(
nlCurrentContext->M,
symmetric ? NL_SYMMETRIC_SUPERLU_EXT : NL_PERM_SUPERLU_EXT
);
);
if(nlCurrentContext->verbose) {
nl_printf("Matrix factorized\n");
if(result == NULL) {
nl_printf("Could not factorize matrix\n");
} else {
nl_printf("Matrix factorized\n");
}
}
}

if(result == NULL) {
return NULL;
}

if(nlCurrentContext->B != NULL) {
/*
Expand Down Expand Up @@ -337,6 +349,11 @@ void nlEigenSolve_ARPACK(void) {
int index;
int* sorted; /* indirection array for sorting eigenpairs */

if(OP == NULL) {
nlError("nlEigenSolve_ARPACK","Could not factorize matrix");
return;
}

if(ncv > n) {
ncv = n;
}
Expand Down
14 changes: 14 additions & 0 deletions src/lib/geogram/basic/command_line.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ namespace {
using namespace GEO;
using namespace CmdLine;

int geo_argc = 0;
char** geo_argv = nil;

// True if displaying help in a way that
// it will be easily processed by help2man
bool man_mode = false;
Expand Down Expand Up @@ -310,6 +313,9 @@ namespace {
bool parse_internal(
int argc, char** argv, std::vector<std::string>& unparsed_args
) {
geo_argc = argc;
geo_argv = argv;

parse_config_file(argc, argv);

bool ok = true;
Expand Down Expand Up @@ -520,6 +526,14 @@ namespace GEO {
desc_ = nil;
}

int argc() {
return geo_argc;
}

char** argv() {
return geo_argv;
}

bool parse(
int argc, char** argv, std::vector<std::string>& unparsed_args,
const std::string& additional_arg_specs
Expand Down
20 changes: 20 additions & 0 deletions src/lib/geogram/basic/command_line.h
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,26 @@ namespace GEO {
int argc, char** argv
);

/**
* \brief Gets the number of arguments of the command line.
* \return the number of arguments plus one.
* \details parse() should be called before.
*/
int GEOGRAM_API argc();


typedef char** charptrptr; // Need to do that else the compiler thinks
// that GEOGRAM_API qualifies the ptr instead
// of the function.

/**
* \brief Gets the command line arguments.
* \return a pointer to an array of null-terminated strings with
* the command line arguments. The first one is the program name.
* \details parse() should be called before.
*/
charptrptr GEOGRAM_API argv();

/**
* \brief Displays program help
* \details Displays a list of all declared arguments (sorted by
Expand Down
6 changes: 5 additions & 1 deletion src/lib/geogram/basic/command_line_args.cpp
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,13 @@ namespace {
"one of auto, GLUP150, GLUP440, VanillaGL"
);
declare_arg("gfx:full_screen", false, "full screen mode");
declare_arg(
"gfx:no_decoration", false,
"no window decoration (full screen mode)"
);
declare_arg(
"gfx:transparent", false,
"use transparent backsgroung (desktop integration)"
"use transparent backgroung (desktop integration)"
);
declare_arg(
"gfx:GLSL_tesselation", true, "use tesselation shaders if available"
Expand Down
58 changes: 35 additions & 23 deletions src/lib/geogram/points/kd_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,9 @@ namespace GEO {
double box_dist = 0.0;
double* bbox_min = (double*) (alloca(dimension() * sizeof(double)));
double* bbox_max = (double*) (alloca(dimension() * sizeof(double)));

for(coord_index_t c = 0; c < dimension(); ++c) {
bbox_min[c] = bbox_min_[c];
bbox_max[c] = bbox_max_[c];
if(query_point[c] < bbox_min_[c]) {
box_dist += geo_sqr(bbox_min_[c] - query_point[c]);
} else if(query_point[c] > bbox_max_[c]) {
box_dist += geo_sqr(bbox_max_[c] - query_point[c]);
}
}
init_bbox_and_bbox_dist_for_traversal(
bbox_min, bbox_max, box_dist, query_point
);
NearestNeighbors NN(
nb_neighbors,
neighbors,
Expand All @@ -206,10 +199,8 @@ namespace GEO {
double* neighbors_sq_dist,
KeepInitialValues KV
) const {

geo_debug_assert(nb_neighbors <= nb_points());
geo_argused(KV);

// Compute distance between query point and global bounding box
// and copy global bounding box to local variables (bbox_min, bbox_max),
// allocated on the stack. bbox_min and bbox_max are updated during the
Expand All @@ -220,16 +211,9 @@ namespace GEO {
double box_dist = 0.0;
double* bbox_min = (double*) (alloca(dimension() * sizeof(double)));
double* bbox_max = (double*) (alloca(dimension() * sizeof(double)));

for(coord_index_t c = 0; c < dimension(); ++c) {
bbox_min[c] = bbox_min_[c];
bbox_max[c] = bbox_max_[c];
if(query_point[c] < bbox_min_[c]) {
box_dist += geo_sqr(bbox_min_[c] - query_point[c]);
} else if(query_point[c] > bbox_max_[c]) {
box_dist += geo_sqr(bbox_max_[c] - query_point[c]);
}
}
init_bbox_and_bbox_dist_for_traversal(
bbox_min, bbox_max, box_dist, query_point
);
NearestNeighbors NN(
nb_neighbors,
neighbors,
Expand All @@ -243,7 +227,6 @@ namespace GEO {
);
NN.copy_to_user();
}


void KdTree::get_nearest_neighbors(
index_t nb_neighbors,
Expand Down Expand Up @@ -407,6 +390,27 @@ namespace GEO {
}
}

void KdTree::init_bbox_and_bbox_dist_for_traversal(
double* bbox_min, double* bbox_max,
double& box_dist, const double* query_point
) const {
// Compute distance between query point and global bounding box
// and copy global bounding box to local variables (bbox_min, bbox_max),
// allocated on the stack. bbox_min and bbox_max are updated during the
// traversal of the KdTree (see get_nearest_neighbors_recursive()). They
// are necessary to compute the distance between the query point and the
// bbox of the current node.
box_dist = 0.0;
for(coord_index_t c = 0; c < dimension(); ++c) {
bbox_min[c] = bbox_min_[c];
bbox_max[c] = bbox_max_[c];
if(query_point[c] < bbox_min_[c]) {
box_dist += geo_sqr(bbox_min_[c] - query_point[c]);
} else if(query_point[c] > bbox_max_[c]) {
box_dist += geo_sqr(bbox_max_[c] - query_point[c]);
}
}
}

/****************************************************************************/

Expand Down Expand Up @@ -590,6 +594,14 @@ namespace GEO {

AdaptiveKdTree::AdaptiveKdTree(coord_index_t dim) : KdTree(dim) {
}

index_t AdaptiveKdTree::new_node() {
splitting_coord_.push_back(0);
splitting_val_.push_back(0.0);
node_m_.push_back(0);
node_right_child_.push_back(0);
return nb_nodes()-1;
}

index_t AdaptiveKdTree::build_tree() {
// Create kd-tree. Local copy of the bbox is used, because it
Expand Down
Loading

0 comments on commit a75a86e

Please sign in to comment.