-
-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Add an option to control the discretization of colormap #1678
base: master
Are you sure you want to change the base?
Conversation
library/options.json
Outdated
@@ -246,6 +246,10 @@ | |||
"type": "double_vector", | |||
"default_value": "0.0, 0.0, 0.0, 0.0, 0.4, 0.9, 0.0, 0.0, 0.8, 0.9, 0.9, 0.0, 1.0, 1.0, 1.0, 1.0" | |||
}, | |||
"discretization" : { | |||
"type": "bool", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option definitely should not be a bool but an int I think.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1678 +/- ##
=======================================
Coverage 96.90% 96.90%
=======================================
Files 105 105
Lines 8629 8634 +5
=======================================
+ Hits 8362 8367 +5
Misses 267 267 ☔ View full report in Codecov by Sentry. |
@gapry any news on this ? |
Dear @mwestphal, I apologize for the delayed response. Here is my current progress: Part 1 - VTKI have learned some VTK examples from the official document, https://examples.vtk.org/site/Cxx/. I have chosen the Cube example as a starting point to learn the VTK API and successfully compile and execute in my Ubuntu. The experiment code is host here, https://github.com/gapry/code-for-blog/tree/main/2024/VTK_Cube. Next, I will learn how to use vtkDiscretizableColorTransferFunction to change to Cube. Also, I have spent the time to read the book, https://book.vtk.org/en/latest/ to learn VTK knowledge Part 2 - F3D APIAccording to the document of https://github.com/f3d-app/f3d/tree/master/examples, I need to use the flag Here is the step to reproduce the issue
As you can see, it just has some So, I decided to try to use
The experiment code is host here, https://github.com/gapry/code-for-blog/tree/main/2024/F3D_RenderImage, you can see I use Do I miss some important thing? |
You need to install the SDK:
from: https://f3d.app/doc/dev/BUILD.html but you do not need really to build the libf3d examples to do this :) |
Thank you for your help, I can see in the But it appears another issue I can't solve, When I use And I do the following checking:
Am I missing something important, doing something wrong? |
I know I can add some unit tests for the new features, but I find VTK have a lot of examples, https://examples.vtk.org/site/Cxx/, to help the new developers, so I think I can do similar things, write a new example application for libf3d. Just want to share my thoughts to you. |
Hi @gapry Do you need any help moving forward with this ? |
Hi @gapry Do you need any help moving forward with this ? |
@mwestphal I sincerely apologize for my delayed response. Question:
so, I don't know how to define the type. e.g.
|
What do you mean ? You do not need to define a new type. You can just change the discretization of the colormap in the vtkF3DRenderer in |
According to the document, Gallery, I find the colormap the usage as following First Usage
I can get two RGBA groups
Second Usage
I can get three RGBA groups
Third Usage
I can get four RGBA groups
So, I think the colormap is used RGBA as unit, but according to the https://github.com/f3d-app/f3d/blob/master/vtkext/private/module/vtkF3DRenderer.cxx#L2548 void vtkF3DRenderer::ConfigureRangeAndCTFForColoring(
const F3DColoringInfoHandler::ColoringInfo& info)
{
...
for (size_t i = 0; i < this->Colormap.size(); i += 4)
{
double val = this->Colormap[i];
double r = this->Colormap[i + 1];
double g = this->Colormap[i + 2];
double b = this->Colormap[i + 3];
this->ColorTransferFunction->AddRGBPoint(
this->ColorRange[0] + val * (this->ColorRange[1] - this->ColorRange[0]), r, g, b);
}
...
} It appears the colormap is decomposed into |
From https://f3d.app/doc/user/OPTIONS.html
Opacity is never mentioned. There are four values because the first value is the scalar value. VAL R G B |
@mwestphal Thank you! I understand now. I apologize for not reading the documentation carefully. I will use |
Current ProgressI pushed the new commits and the following screenshots are my testing results. The key changes
Test Case 1: don't use the option
|
@@ -557,6 +563,10 @@ class vtkF3DRenderer : public vtkOpenGLRenderer | |||
vtkF3DMetaImporter* Importer = nullptr; | |||
vtkMTimeType ImporterTimeStamp = 0; | |||
|
|||
vtkNew<vtkDiscretizableColorTransferFunction> DiscretizableColorTransferFunction; | |||
bool DiscretizableColorTransferFunctionConfigured = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think you need this
@@ -2472,6 +2489,12 @@ void vtkF3DRenderer::ConfigureRangeAndCTFForColoring( | |||
return; | |||
} | |||
|
|||
// Set Discretization | |||
if(!this->DiscretizableColorTransferFunctionConfigured) { | |||
this->DiscretizableColorTransferFunction->SetNumberOfValues(this->Discretization); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do that directly on the existing colorTransferFunction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can.
Related Issue:
This work addresses the Issue: #228
Current Progress
Over the past two weeks, I have made significant progress on #228, with my work available for review in the following commits:
These commits introduce a new CLI option and extend the vtkF3DRenderer class to handle this option.
Please note that the PR isn’t fully complete yet, as it does not fully resolve #228. I will continue to work on it to ensure that all aspects are addressed.
Since I’ve already spent two weeks on this task, I wanted to report my progress, especially as we’re working remotely.
Next Steps
I will review the VTK documentation to learn how to adjust color settings, specifically focusing on the vtkDiscretizableColorTransferFunction.