-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expose texture filtering options for surface mesh quantities (#310)
* initial implementation of texture filtering option * factor out texture map options * templated texture options for scalars too
- Loading branch information
Showing
13 changed files
with
143 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright 2017-2023, Nicholas Sharp and the Polyscope contributors. https://polyscope.run | ||
|
||
#pragma once | ||
|
||
#include "polyscope/persistent_value.h" | ||
#include "polyscope/polyscope.h" | ||
#include "polyscope/render/engine.h" | ||
#include "polyscope/render/managed_buffer.h" | ||
#include "polyscope/standardize_data_array.h" | ||
|
||
namespace polyscope { | ||
|
||
// Encapsulates logic which is common to all texture map quantities | ||
|
||
template <typename QuantityT> | ||
class TextureMapQuantity { | ||
public: | ||
TextureMapQuantity(QuantityT& parent, size_t dimX, size_t dimY, ImageOrigin origin_); | ||
|
||
// Build the ImGUI UIs for texture maps | ||
virtual void buildTextureMapOptionsUI(); // called inside of an options menu | ||
|
||
// === Members | ||
QuantityT& quantity; | ||
|
||
// NOTE: the main quantity types (scalar quantity, color quantity, etc) provide the buffer members, so this class just | ||
// has secondary options and such | ||
|
||
// what kind of texture filtering is used | ||
QuantityT* setFilterMode(FilterMode newFilterMode); | ||
FilterMode getFilterMode(); | ||
|
||
protected: | ||
size_t dimX, dimY; | ||
ImageOrigin imageOrigin; | ||
|
||
// === Visualization parameters | ||
PersistentValue<FilterMode> filterMode; // default is FilterMode::Linear | ||
}; | ||
|
||
} // namespace polyscope | ||
|
||
#include "polyscope/texture_map_quantity.ipp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2017-2023, Nicholas Sharp and the Polyscope contributors. https://polyscope.run | ||
|
||
namespace polyscope { | ||
|
||
template <typename QuantityT> | ||
TextureMapQuantity<QuantityT>::TextureMapQuantity(QuantityT& quantity_, size_t dimX_, size_t dimY_, ImageOrigin origin_) | ||
: quantity(quantity_), dimX(dimX_), dimY(dimY_), imageOrigin(origin_), | ||
filterMode(quantity.uniquePrefix() + "filterMode", FilterMode::Linear) {} | ||
|
||
template <typename QuantityT> | ||
void TextureMapQuantity<QuantityT>::buildTextureMapOptionsUI() { | ||
|
||
if (ImGui::BeginMenu("Filter Mode")) { | ||
if (ImGui::MenuItem("linear", NULL, filterMode.get() == FilterMode::Linear)) setFilterMode(FilterMode::Linear); | ||
if (ImGui::MenuItem("nearest", NULL, filterMode.get() == FilterMode::Nearest)) setFilterMode(FilterMode::Nearest); | ||
ImGui::EndMenu(); | ||
} | ||
} | ||
|
||
template <typename QuantityT> | ||
QuantityT* TextureMapQuantity<QuantityT>::setFilterMode(FilterMode newFilterMode) { | ||
filterMode = newFilterMode; | ||
quantity.refresh(); | ||
return &quantity; | ||
} | ||
|
||
template <typename QuantityT> | ||
FilterMode TextureMapQuantity<QuantityT>::getFilterMode() { | ||
return filterMode.get(); | ||
} | ||
|
||
} // namespace polyscope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters