Skip to content

Commit

Permalink
Propagate updates from internal branch (3c4d356)
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonCernWq committed Nov 16, 2023
1 parent 6bfe24f commit 5e03f08
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cmake-build-*/
/data/images/
/data/outputs/
/data/vortices/
/data/
*.png
*.jpg
*.ppm
Expand Down
3 changes: 3 additions & 0 deletions extern/gdt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ add_library(gdt OBJECT
gdt/gdt.cpp)

target_include_directories(gdt PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
set_target_properties(gdt PROPERTIES
POSITION_INDEPENDENT_CODE ON
)
3 changes: 3 additions & 0 deletions ovr/serializer/serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ create_scene(std::string filename);
}
}
// namespace ovr::scene

ovr::scene::TransferFunction
create_scene_tfn_vidi3d(std::string filename);
10 changes: 7 additions & 3 deletions ovr/serializer/serializer_diva.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "serializer.h"

#include <filesystem> // C++17 is required by this project
// #include <filesystem> // C++17 is required by this project

namespace ovr::scene {

Expand All @@ -17,8 +17,12 @@ create_json_scene(std::string filename)
std::string text((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
json root = json::parse(text, nullptr, true, true);

std::filesystem::path p = filename;
std::string workdir = p.remove_filename().string();
// std::filesystem::path p = filename;
// std::string workdir = p.remove_filename().string();
// workdir = workdir.empty() ? "." : workdir; // make sure workdir is never empty

// find the base path from filename using pure c++ 11
std::string workdir = filename.substr(0, filename.find_last_of("/\\"));
workdir = workdir.empty() ? "." : workdir; // make sure workdir is never empty

assert(root.is_object());
Expand Down
37 changes: 31 additions & 6 deletions ovr/serializer/serializer_vidi3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ typedef ovr::math::vec4i vec4i;
#include "tfn/json.h"
using json = nlohmann::json;

#include <filesystem> // C++17 (or Microsoft-specific implementation in C++14)
// #include <filesystem> // C++17 (or Microsoft-specific implementation in C++14)

// ------------------------------------------------------------------
// ------------------------------------------------------------------
Expand Down Expand Up @@ -150,15 +150,30 @@ range_from_json(json jsrange)
// using namespace ovr::scene;

static bool
file_exists_test(std::string name, const std::string& dir, std::string& out)
file_exists_test(std::string name)
{
std::filesystem::path path(name);
if (path.is_relative()) path = dir / path;
std::ifstream f(path.c_str());
out = path.string();
std::ifstream f(name.c_str());
return f.good();
}

static bool
file_exists_test(std::string name, const std::string& dir, std::string& out)
{
if (file_exists_test(name)) {
out = name;
return true;
}
else if (file_exists_test(dir + "/" + name)) {
out = name;
return true;
}
else if (file_exists_test(dir + "\\" + name)) {
out = name;
return true;
}
return false;
}

static std::string
valid_filename(const json& in, std::string dir, const std::string& key)
{
Expand Down Expand Up @@ -387,3 +402,13 @@ create_json_scene_vidi3d(json root, std::string workdir)
}

} // namespace ovr::scene

ovr::scene::TransferFunction
create_scene_tfn_vidi3d(std::string filename)
{
std::ifstream file(filename);
std::string text((std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>());
json root = json::parse(text, nullptr, true, true);

return ovr::vidi3d::create_scene_tfn(root[VIEW], ovr::ValueType::VALUE_TYPE_DOUBLE);
}

0 comments on commit 5e03f08

Please sign in to comment.