refactor: consolidate ray verification debug logging
This commit is contained in:
parent
23a79cee42
commit
aad395a804
@ -2914,18 +2914,13 @@ CreoManager::ProjectionAnalysisData CreoManager::PerformMultiDirectionalProjecti
|
||||
}
|
||||
}
|
||||
|
||||
// Perform ray verification from global center
|
||||
if (targetComponent && !IsComponentBlockedFromCenter(globalCenter, *targetComponent, result.components)) {
|
||||
// Component passed both 2D projection and ray verification
|
||||
result.visibilityVotes[componentId]++;
|
||||
}
|
||||
// If blocked by ray test, this direction votes 0 (no increment)
|
||||
|
||||
// Debug output for specific component
|
||||
for (const auto& comp : result.components) {
|
||||
if (comp.featureId == componentId &&
|
||||
(comp.name.find("12v4000g03_herhang") != std::string::npos ||
|
||||
comp.name.find("12V4000G03_HERHANG") != std::string::npos)) {
|
||||
bool isDebugComponent = false;
|
||||
if (targetComponent) {
|
||||
isDebugComponent = (targetComponent->name.find("12v4000g03_herhang") != std::string::npos ||
|
||||
targetComponent->name.find("12V4000G03_HERHANG") != std::string::npos);
|
||||
|
||||
if (isDebugComponent) {
|
||||
static bool firstTime = true;
|
||||
if (firstTime) {
|
||||
try {
|
||||
@ -2937,17 +2932,19 @@ CreoManager::ProjectionAnalysisData CreoManager::PerformMultiDirectionalProjecti
|
||||
std::ofstream logFile(logPath, std::ios::out | std::ios::trunc);
|
||||
if (logFile.is_open()) {
|
||||
logFile << "=== 12V4000G03_HERHANG.prt Visibility Analysis ===" << std::endl;
|
||||
logFile << "Component Name: " << comp.name << std::endl;
|
||||
logFile << "Feature ID: " << comp.featureId << std::endl;
|
||||
logFile << "Component Name: " << targetComponent->name << std::endl;
|
||||
logFile << "Feature ID: " << targetComponent->featureId << std::endl;
|
||||
logFile << "\nBounding Box:" << std::endl;
|
||||
logFile << " Min: (" << comp.worldAABB.minPoint.x << ", "
|
||||
<< comp.worldAABB.minPoint.y << ", "
|
||||
<< comp.worldAABB.minPoint.z << ")" << std::endl;
|
||||
logFile << " Max: (" << comp.worldAABB.maxPoint.x << ", "
|
||||
<< comp.worldAABB.maxPoint.y << ", "
|
||||
<< comp.worldAABB.maxPoint.z << ")" << std::endl;
|
||||
Vector3D size = comp.worldAABB.diagonal();
|
||||
logFile << " Min: (" << targetComponent->worldAABB.minPoint.x << ", "
|
||||
<< targetComponent->worldAABB.minPoint.y << ", "
|
||||
<< targetComponent->worldAABB.minPoint.z << ")" << std::endl;
|
||||
logFile << " Max: (" << targetComponent->worldAABB.maxPoint.x << ", "
|
||||
<< targetComponent->worldAABB.maxPoint.y << ", "
|
||||
<< targetComponent->worldAABB.maxPoint.z << ")" << std::endl;
|
||||
Vector3D size = targetComponent->worldAABB.diagonal();
|
||||
logFile << " Size: " << size.x << " x " << size.y << " x " << size.z << std::endl;
|
||||
logFile << "\nGlobal Center: (" << globalCenter.x << ", "
|
||||
<< globalCenter.y << ", " << globalCenter.z << ")" << std::endl;
|
||||
logFile << "\nGlobal AABB:" << std::endl;
|
||||
logFile << " Min: (" << result.globalAABB.minPoint.x << ", "
|
||||
<< result.globalAABB.minPoint.y << ", "
|
||||
@ -2965,8 +2962,22 @@ CreoManager::ProjectionAnalysisData CreoManager::PerformMultiDirectionalProjecti
|
||||
firstTime = false;
|
||||
} catch (...) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Append visibility data for each direction
|
||||
// Perform ray verification from global center
|
||||
bool rayBlocked = false;
|
||||
if (targetComponent) {
|
||||
rayBlocked = IsComponentBlockedFromCenter(globalCenter, *targetComponent, result.components);
|
||||
|
||||
if (!rayBlocked) {
|
||||
// Component passed both 2D projection and ray verification
|
||||
result.visibilityVotes[componentId]++;
|
||||
}
|
||||
// If blocked by ray test, this direction votes 0 (no increment)
|
||||
|
||||
// Log ray verification result for debug component
|
||||
if (isDebugComponent) {
|
||||
try {
|
||||
SessionInfo sessionInfo = GetSessionInfo();
|
||||
if (sessionInfo.is_valid) {
|
||||
@ -2977,10 +2988,28 @@ CreoManager::ProjectionAnalysisData CreoManager::PerformMultiDirectionalProjecti
|
||||
if (logFile.is_open()) {
|
||||
static int directionCount = 0;
|
||||
directionCount++;
|
||||
logFile << "Direction " << directionCount << ": cells=" << cellCount
|
||||
|
||||
// Calculate component center for logging
|
||||
Vector3D componentCenter = Vector3D(
|
||||
(targetComponent->worldAABB.minPoint.x + targetComponent->worldAABB.maxPoint.x) * 0.5,
|
||||
(targetComponent->worldAABB.minPoint.y + targetComponent->worldAABB.maxPoint.y) * 0.5,
|
||||
(targetComponent->worldAABB.minPoint.z + targetComponent->worldAABB.maxPoint.z) * 0.5
|
||||
);
|
||||
|
||||
logFile << "\n--- Direction " << directionCount << " ---" << std::endl;
|
||||
logFile << "2D Projection: cells=" << cellCount
|
||||
<< ", ratio=" << visibilityRatio
|
||||
<< ", voted=" << (visibilityRatio >= SHELL_ANALYSIS_MIN_VISIBLE_RATIO_PER_DIR ? "YES" : "NO")
|
||||
<< std::endl;
|
||||
<< ", visible=" << (visibilityRatio >= SHELL_ANALYSIS_MIN_VISIBLE_RATIO_PER_DIR ? "YES" : "NO") << std::endl;
|
||||
|
||||
if (visibilityRatio >= SHELL_ANALYSIS_MIN_VISIBLE_RATIO_PER_DIR) {
|
||||
logFile << "Ray Test: from (" << globalCenter.x << ", " << globalCenter.y << ", " << globalCenter.z
|
||||
<< ") to (" << componentCenter.x << ", " << componentCenter.y << ", " << componentCenter.z << ")" << std::endl;
|
||||
logFile << "Ray Result: " << (rayBlocked ? "BLOCKED (internal)" : "CLEAR (outer shell)") << std::endl;
|
||||
logFile << "Final Vote: " << (rayBlocked ? "NO (0)" : "YES (1)") << std::endl;
|
||||
} else {
|
||||
logFile << "Ray Test: SKIPPED (not visible in 2D)" << std::endl;
|
||||
logFile << "Final Vote: NO (0)" << std::endl;
|
||||
}
|
||||
logFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user