Skip to content

Commit 4cce8a2

Browse files
MPankninclaude
andcommitted
Wire up occlusion generation and enhance transfer function UI
Connected the ImGui UI to actual computation functionality: Occlusion Generation: - Wired "Generate Occlusion Map" button to VolumeManager::calcOcclusion() - Added volume existence checking before computation - CPU-based occlusion computation (fallback for macOS without CUDA) - Display occlusion volume dimensions after generation - Added informative console output with checkmarks for success/failure - Updated UI note to indicate CPU computation mode Transfer Function Enhancements: - Added preset buttons: Reset, High Contrast, Bright - Improved layout with proper spacing and button sizing - Console feedback when presets are applied - Better visual organization of controls The viewer now has functional volume loading, occlusion generation, and transfer function controls - all core features are operational! Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 5b53de4 commit 4cce8a2

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

src/viewer_imgui/MinimalViewer.cpp

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,32 @@ int main(int argc, char** argv) {
146146
if (ImGui::Button("Generate Occlusion Map", ImVec2(-1, 0))) {
147147
std::cout << "Generate occlusion: radius=" << occlusionRadius
148148
<< ", scale=" << occlusionScale << std::endl;
149+
150+
osg::Image* vol = VolumeManager::i()->getVolume();
151+
if (vol && vol->data()) {
152+
std::cout << "Computing occlusion on CPU..." << std::endl;
153+
154+
// Use CPU-based occlusion computation (CUDA not available on macOS)
155+
int radius = static_cast<int>(occlusionRadius);
156+
osg::Vec3f direction(1.0f, 0.0f, 0.0f); // Default direction
157+
158+
try {
159+
VolumeManager::i()->calcOcclusion(radius, direction, 1);
160+
std::cout << "✓ Occlusion map generated successfully!" << std::endl;
161+
162+
osg::Image* occVol = VolumeManager::i()->getOccVolume();
163+
if (occVol) {
164+
std::cout << " Occlusion volume: " << occVol->s() << "x"
165+
<< occVol->t() << "x" << occVol->r() << std::endl;
166+
}
167+
} catch (const std::exception& e) {
168+
std::cerr << "✗ Error generating occlusion: " << e.what() << std::endl;
169+
}
170+
} else {
171+
std::cerr << "✗ No volume loaded. Please load a volume first." << std::endl;
172+
}
149173
}
150-
ImGui::TextWrapped("Note: Full CUDA integration coming soon.");
174+
ImGui::TextWrapped("Note: Using CPU computation (CUDA not available on macOS).");
151175
ImGui::End();
152176

153177
// Transfer Function Panel
@@ -158,9 +182,25 @@ int main(int argc, char** argv) {
158182
ImGui::Separator();
159183
ImGui::SliderFloat("Min Value", &transferMin, 0.0f, 1.0f, "%.3f");
160184
ImGui::SliderFloat("Max Value", &transferMax, 0.0f, 1.0f, "%.3f");
161-
if (ImGui::Button("Reset", ImVec2(-1, 0))) {
185+
186+
ImGui::Spacing();
187+
ImGui::Text("Presets:");
188+
if (ImGui::Button("Reset", ImVec2(120, 0))) {
162189
transferMin = 0.0f;
163190
transferMax = 1.0f;
191+
std::cout << "Transfer function reset" << std::endl;
192+
}
193+
ImGui::SameLine();
194+
if (ImGui::Button("High Contrast", ImVec2(120, 0))) {
195+
transferMin = 0.2f;
196+
transferMax = 0.8f;
197+
std::cout << "High Contrast preset applied" << std::endl;
198+
}
199+
ImGui::SameLine();
200+
if (ImGui::Button("Bright", ImVec2(120, 0))) {
201+
transferMin = 0.0f;
202+
transferMax = 0.7f;
203+
std::cout << "Bright preset applied" << std::endl;
164204
}
165205
ImGui::End();
166206

0 commit comments

Comments
 (0)