feat: Implement new MIP Rainbow and Additive rendering presets and add interactive test controls.

This commit is contained in:
AndreaRigoni
2026-03-19 16:44:00 +00:00
parent 6234dffaa7
commit 85e1f1448f
2 changed files with 27 additions and 1 deletions

View File

@@ -43,6 +43,12 @@ void KeyPressCallbackFunction(vtkObject* caller, long unsigned int eventId, void
for (auto* img : state->images) img->SetRepresentation(Vtk::Puppet::Surface);
state->viewer->GetRenderWindow()->Render();
}
else if (key >= "0" && key <= "5") {
int preset = key[0] - '0';
std::cout << "--> Switching all images to Rendering Preset " << preset << std::endl;
for (auto* img : state->images) img->setShadingPreset(preset);
state->viewer->GetRenderWindow()->Render();
}
}
int main(int argc, char** argv) {
@@ -118,7 +124,14 @@ int main(int argc, char** argv) {
std::cout << " [RIGHT] Axes Gradient (Composite)" << std::endl;
std::cout << "-----------------------------------------" << std::endl;
std::cout << " Press [w] to show Wireframe Bounding Boxes" << std::endl;
std::cout << " Press [s] to switch back to Volume Rendering" << std::endl;
std::cout << " Press [s] to show Volume Rendering" << std::endl;
std::cout << " Press [0..5] to switch Rendering Presets:" << std::endl;
std::cout << " 0: MIP (Grayscale)" << std::endl;
std::cout << " 1: Composite (Grayscale)" << std::endl;
std::cout << " 2: Composite (Shaded)" << std::endl;
std::cout << " 3: CT Bone/Tissue (Bone colors)" << std::endl;
std::cout << " 4: MIP (Rainbow)" << std::endl;
std::cout << " 5: Additive (Total path sum)" << std::endl;
std::cout << " Press [q] to quit" << std::endl;
std::cout << "=========================================" << std::endl;

View File

@@ -256,6 +256,19 @@ void vtkVoxImage::setShadingPreset(int blendType) {
property->SetSpecularPower(10.0);
property->SetScalarOpacityUnitDistance(0.8919);
break;
case 4:
colorFun->AddRGBPoint(0.0, 0, 0, 1); // Blue
colorFun->AddRGBPoint(level, 0, 1, 0); // Green
colorFun->AddRGBPoint(level + 0.5*window, 1, 1, 0); // Yellow
colorFun->AddRGBPoint(level + window, 1, 0, 0); // Red
opacityFun->AddSegment(level - 0.5 * window, 0.0, level + 0.5 * window, 1.0);
mapper->SetBlendModeToMaximumIntensity();
break;
case 5:
colorFun->AddRGBSegment(0.0, 1.0, 1.0, 1.0, 255.0, 1.0, 1.0, 1.0);
opacityFun->AddSegment(level - 0.5 * window, 0.0, level + 0.5 * window, 1.0);
mapper->SetBlendModeToAdditive();
break;
default:
vtkGenericWarningMacro("Unknown blend type.");
break;