Skip to content

Commit

Permalink
[geogram] Update to 1.6.12
Browse files Browse the repository at this point in the history
Small bugfixes and updates ImGui.
Change Log
* Updated ImGui to ver. 1.7 - docking branch.
* Fixed problem with undeclared file_system_changed() with some versions of Emscripten
* Minor bugfixes and improvements.
  • Loading branch information
fabiencastan committed May 11, 2019
1 parent ee093be commit 1f34fcb
Show file tree
Hide file tree
Showing 66 changed files with 15,298 additions and 4,107 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ include(cmake/geogram.cmake)

set(VORPALINE_VERSION_MAJOR 1)
set(VORPALINE_VERSION_MINOR 6)
set(VORPALINE_VERSION_PATCH 11)
set(VORPALINE_VERSION_PATCH 12)
set(VORPALINE_VERSION ${VORPALINE_VERSION_MAJOR}.${VORPALINE_VERSION_MINOR}.${VORPALINE_VERSION_PATCH})

set(VORPALINE_INCLUDE_SUBPATH geogram${VORPALINE_VERSION_MAJOR})
Expand Down
2 changes: 1 addition & 1 deletion src/examples/geogram/simple_raytrace/raytracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ namespace GEO {
I.material = material_;
I.position = R.origin + t * R.direction;
I.normal = normalize(
Geom::mesh_facet_normal(AABB_.mesh(),f)
Geom::mesh_facet_normal(*AABB_.mesh(),f)
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/exploragram/optimal_transport/VSDM.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ namespace GEO {
* subdivision surface.
* \param[in] nb_subdiv the number of Catmull-Clark subdivisions.
*/
void set_subdivision_surface(Mesh* mesh, index_t nb_subdiv);
void set_subdivision_surface(Mesh* mesh, index_t nb_subdiv);

/**
* \brief The callback to evaluate the objective function, used by
Expand Down
73 changes: 53 additions & 20 deletions src/lib/geogram/basic/command_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ namespace {
using namespace CmdLine;

std::string config_file_name = "geogram.ini";
bool auto_create_args = false;
bool loaded_config_file = false;

int geo_argc = 0;
char** geo_argv = nullptr;
Expand Down Expand Up @@ -253,34 +255,22 @@ namespace {
return false;
}


/**
* \brief Parses the configuration file in the home directory.
* \details The configuration file "geogram.ini" in the home directory
* has name=value pairs for pre-initializing command line arguments.
* In addition it has sections indicated by square-breacketed names.
* Only the arguments in the section with the same name as the program
* are taken into account. Section [*] refers to all possible programs.
* \param[in] argc number of arguments passed to main()
* \param[in] argv array of command line arguments passed to main()
* \param[in] config_filename the name of the configuration file
* \param[in] program_name the name of the program
*/
void parse_config_file(int argc, char** argv) {
geo_assert(argc >= 1);
std::string program_name = String::to_uppercase(FileSystem::base_name(argv[0]));
static bool init = false;
if(init) {
return;
}
init = true;
Logger::out("config") << "Configuration file name:" << config_file_name
<< std::endl;
Logger::out("config") << "Home directory:" << FileSystem::home_directory()
<< std::endl;
std::string config_filename = FileSystem::home_directory() + "/" + config_file_name;
void parse_config_file(
const std::string& config_filename, const std::string& program_name
) {
std::string section = "*";
if(FileSystem::is_file(config_filename)) {
Logger::out("config") << "Using configuration file:"
<< config_filename
<< std::endl;
std::ifstream in(config_filename.c_str());
std::string line;
while(std::getline(in,line)) {
Expand All @@ -294,14 +284,45 @@ namespace {
if(CmdLine::arg_is_declared(argname)) {
CmdLine::set_arg(argname, argval);
} else {
Logger::warn("config") << argname << "=" << argval << " ignored" << std::endl;
if(auto_create_args) {
CmdLine::declare_arg(argname, argval, "...");
} else {
Logger::warn("config") << argname << "=" << argval << " ignored" << std::endl;
}
}
}
}
}
loaded_config_file= true;
}
}

/**
* \brief Parses the configuration file in the home directory.
* \details The configuration file "geogram.ini" in the home directory
* has name=value pairs for pre-initializing command line arguments.
* In addition it has sections indicated by square-breacketed names.
* Only the arguments in the section with the same name as the program
* are taken into account. Section [*] refers to all possible programs.
* \param[in] argc number of arguments passed to main()
* \param[in] argv array of command line arguments passed to main()
*/
void parse_config_file(int argc, char** argv) {
geo_assert(argc >= 1);
std::string program_name = String::to_uppercase(FileSystem::base_name(argv[0]));
static bool init = false;
if(init) {
return;
}
init = true;
Logger::out("config") << "Configuration file name:" << config_file_name
<< std::endl;
Logger::out("config") << "Home directory:" << FileSystem::home_directory()
<< std::endl;
std::string config_filename = FileSystem::home_directory() + "/" + config_file_name;
parse_config_file(config_filename, program_name);
}

/**
* \brief Parses the command line arguments
* \details This analyzes command line arguments passed to the main()
Expand Down Expand Up @@ -534,13 +555,25 @@ namespace GEO {
return geo_argv;
}

void set_config_file_name(const std::string& filename) {
void set_config_file_name(const std::string& filename, bool auto_create) {
config_file_name = filename;
auto_create_args = auto_create;
}

std::string get_config_file_name() {
return config_file_name;
}

void load_config(
const std::string& filename, const std::string& program_name
) {
parse_config_file(filename, program_name);
}


bool config_file_loaded() {
return loaded_config_file;
}

bool parse(
int argc, char** argv, std::vector<std::string>& unparsed_args,
Expand Down
29 changes: 28 additions & 1 deletion src/lib/geogram/basic/command_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,43 @@ namespace GEO {
* parsing command line arguments, arguments are set according
* to this file, loaded from the home directory (or 'My Documents'
* under Windows). Default is 'geogram.ini'.
* \param[in] auto_create_args if set, all the args present in the
* configuration file are created if they do not already exist, else
* a warning message is displayed for args that do not exist.
*/
void GEOGRAM_API set_config_file_name(const std::string& filename);
void GEOGRAM_API set_config_file_name(
const std::string& filename,
bool auto_create_args = false
);

/**
* \brief Tests whether the configuration file was loaded.
* \details The default configuration file, or the one specified
* by set_config_file_name() may not exist, in this case this
* function returns false.
* \retval true if the configuration file was loaded.
* \retval false otherwise.
*/
bool GEOGRAM_API config_file_loaded();

/**
* \brief Gets the name of the configuration file.
* \return the name of the configuration file, as
* specified by set_config_file_name(). User's home directory
* needs to be prepended to have the complete file path.
*/
std::string GEOGRAM_API get_config_file_name();

/**
* \brief Loads command line argument values from a file.
* \details only args in the section with \p program_name
* are loaded.
* \param[in] filename the complete path to the file.
* \param[in] program_name the name of the program.
*/
void GEOGRAM_API load_config(
const std::string& filename, const std::string& program_name
);

/**
* \brief Command line argument types
Expand Down
31 changes: 28 additions & 3 deletions src/lib/geogram/basic/file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
#include <stdio.h>
#endif

#ifdef GEO_OS_EMSCRIPTEN
#include <emscripten.h>
#endif

namespace GEO {

namespace FileSystem {
Expand Down Expand Up @@ -622,9 +626,30 @@ namespace GEO {
#endif
return home;
}

}


#ifdef GEO_OS_EMSCRIPTEN
static void (*file_system_changed_callback_)() = nullptr;

void set_file_system_changed_callback(void(*callback)()) {
file_system_changed_callback_ = callback;
}

#endif

} // end namespace FileSystem
} // end namespace GEO


#ifdef GEO_OS_EMSCRIPTEN

extern "C" {
void file_system_changed_callback();
}

EMSCRIPTEN_KEEPALIVE void file_system_changed_callback() {
if(GEO::FileSystem::file_system_changed_callback_ != nullptr) {
(*GEO::FileSystem::file_system_changed_callback_)();
}
}

#endif
12 changes: 12 additions & 0 deletions src/lib/geogram/basic/file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,18 @@ namespace GEO {
* \return The path to the current user's home directory as a string.
*/
std::string GEOGRAM_API documents_directory();

#ifdef GEO_OS_EMSCRIPTEN
/**
* \brief Declares a function to be called whenever the file system
* changes.
* \details The function will be called when the user loads a file
* using the button in the webpage.
* \param[in] callback the function to be called.
*/
void set_file_system_changed_callback(void(*callback)());
#endif

}
}

Expand Down
22 changes: 22 additions & 0 deletions src/lib/geogram/basic/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,28 @@ namespace GEO {
return y;
}

/**
* \brief Computes a matrix vector product.
* \param[in] M the matrix
* \param[in] x the vector
* \return \p M times \p x
* \note This function copies the resulting vector, thus it is not
* very efficient and should be only used when prototyping.
*/
template <index_t DIM, class FT> inline
vecng<DIM,FT> mult(
const Matrix<DIM, FT>& M, const vecng<DIM,FT>& x
) {
vecng<DIM,FT> y;
for(index_t i = 0; i < DIM; i++) {
y[i] = 0;
for(index_t j = 0; j < DIM; j++) {
y[i] += M(i, j) * x[j];
}
}
return y;
}

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

}
Expand Down
8 changes: 8 additions & 0 deletions src/lib/geogram/basic/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
#include <geogram/basic/string.h>
#include <geogram/basic/command_line.h>
#include <geogram/basic/stopwatch.h>
#include <thread>
#include <chrono>

#ifdef GEO_OPENMP
#include <omp.h>
Expand Down Expand Up @@ -850,5 +852,11 @@ namespace GEO {
Process::run_threads(threads);
}
}

namespace Process {
void sleep(index_t microseconds) {
std::this_thread::sleep_for(std::chrono::microseconds(microseconds));
}
}
}

9 changes: 9 additions & 0 deletions src/lib/geogram/basic/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ namespace GEO {
*/
static Thread* current();


protected:
/** Thread destructor */
virtual ~Thread();
Expand Down Expand Up @@ -372,6 +373,14 @@ namespace GEO {
*/
void GEOGRAM_API terminate();


/**
* \brief Sleeps for a period of time.
* \param[in] microseconds the time to sleep,
* in microseconds.
*/
void GEOGRAM_API sleep(index_t microseconds);

/**
* \brief Displays statistics about the current process
* \details Displays the maximum used amount of memory.
Expand Down
3 changes: 3 additions & 0 deletions src/lib/geogram/basic/process_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,9 @@ namespace GEO {
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);

// Do not open dialog box on error
SetErrorMode(SEM_NOGPFAULTERRORBOX);
}
#else
void os_install_signal_handlers() {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/geogram/delaunay/Delaunay.psm
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ SOURCES="../basic/memory.h \
../numerics/predicates/det3d.h \
../numerics/predicates/det4d.h \
../numerics/predicates/aligned3d.h \
../numerics/predicates/dot_compare_3d.h \
../numerics/predicates/det_compare_4d.h \
../numerics/predicates.cpp \
delaunay_2d.h \
cavity.h \
Expand Down
2 changes: 2 additions & 0 deletions src/lib/geogram/image/image_serializer_stb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
// [Bruno] I got too many complaints in STB so I "close my eyes" :-)
#ifdef __GNUC__
#ifndef __ICC
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wfloat-conversion"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#pragma GCC diagnostic ignored "-Wdouble-promotion"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/geogram/image/image_serializer_xpm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace {

/**
* \brief Decodes an XPM colormap entry.
* \param[in] the string with the colormap entry.
* \param[in] colormap_entry the string with the colormap entry.
* \param[out] colorcell the corresponding color.
*/
bool decode_colormap_entry(
Expand Down
Loading

0 comments on commit 1f34fcb

Please sign in to comment.