Skip to content

Commit

Permalink
Added functionality for specifying transfer function range in Python …
Browse files Browse the repository at this point in the history
…module.
  • Loading branch information
chrismile committed Sep 5, 2024
1 parent 122873f commit 6647d29
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/PyTorch/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ TORCH_LIBRARY(vpt, m) {
m.def("vpt::set_use_transfer_function", setUseTransferFunction);
m.def("vpt::load_transfer_function_file", loadTransferFunctionFile);
m.def("vpt::load_transfer_function_file_gradient", loadTransferFunctionFileGradient);
m.def("vpt::set_transfer_function_range", setTransferFunctionRange);
m.def("vpt::set_transfer_function_range_gradient", setTransferFunctionRangeGradient);
m.def("vpt::get_camera_position", getCameraPosition);
m.def("vpt::get_camera_view_matrix", getCameraViewMatrix);
m.def("vpt::get_camera_fovy", getCameraFOVy);
Expand Down Expand Up @@ -967,6 +969,18 @@ void loadTransferFunctionFileGradient(const std::string& tfFilePath) {
tfWindow->loadFunctionFromFile(1, tfFilePath);
}

void setTransferFunctionRange(double _minVal, double _maxVal) {
auto* tfWindow = vptRenderer->getTransferFunctionWindow();
tfWindow->setSelectedRange(0, glm::vec2(float(_minVal), float(_maxVal)));
tfWindow->setIsSelectedRangeFixed(0, true);
}

void setTransferFunctionRangeGradient(double _minVal, double _maxVal) {
auto* tfWindow = vptRenderer->getTransferFunctionWindow();
tfWindow->setSelectedRange(1, glm::vec2(float(_minVal), float(_maxVal)));
tfWindow->setIsSelectedRangeFixed(1, true);
}


std::vector<double> getCameraPosition() {
auto pos = vptRenderer->getCameraPosition();
Expand Down
2 changes: 2 additions & 0 deletions src/PyTorch/Module.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ MODULE_OP_API void setPhaseG(double phaseG);
MODULE_OP_API void setUseTransferFunction(bool _useTf);
MODULE_OP_API void loadTransferFunctionFile(const std::string& tfFilePath);
MODULE_OP_API void loadTransferFunctionFileGradient(const std::string& tfFilePath);
MODULE_OP_API void setTransferFunctionRange(double _minVal, double _maxVal);
MODULE_OP_API void setTransferFunctionRangeGradient(double _minVal, double _maxVal);

MODULE_OP_API std::vector<double> getCameraPosition();
MODULE_OP_API std::vector<double> getCameraViewMatrix();
Expand Down

0 comments on commit 6647d29

Please sign in to comment.