fix: consolidate 12V4000G03 debug logging to single visibility file
- Remove redundant log files (debug.txt, analysis.txt, ray_summary.txt) - Consolidate all debugging info into 12v4000g03_visibility.txt - Use component ID (7) instead of name matching for reliable detection - Add ray test results to each direction's output - Simplify logging logic to ensure all directions are logged
This commit is contained in:
parent
854bc2edc9
commit
a6d32180cb
181
CreoManager.cpp
181
CreoManager.cpp
@ -2805,24 +2805,19 @@ std::pair<double, double> CreoManager::CalculateOBBProjectionRange(const OBB& ob
|
||||
CreoManager::ProjectionAnalysisData CreoManager::PerformMultiDirectionalProjectionAnalysis(pfcAssembly_ptr assembly) {
|
||||
ProjectionAnalysisData result;
|
||||
|
||||
// Create projection analysis log file
|
||||
try {
|
||||
SessionInfo sessionInfo = GetSessionInfo();
|
||||
if (sessionInfo.is_valid) {
|
||||
xstring workdir = sessionInfo.session->GetCurrentDirectory();
|
||||
std::string workingDir = XStringToString(workdir);
|
||||
std::string logPath = workingDir + "\\projection_analysis.txt";
|
||||
std::ofstream logFile(logPath);
|
||||
logFile << "Projection Analysis Started" << std::endl;
|
||||
logFile << "Time: " << GetCurrentTimeString() << std::endl;
|
||||
logFile << "Working Directory: " << workingDir << std::endl;
|
||||
logFile.close();
|
||||
}
|
||||
} catch (...) {}
|
||||
|
||||
// Step 1: Collect all components
|
||||
result.components = CollectAllComponents(assembly);
|
||||
|
||||
// Log 12v4000g03 component info if found
|
||||
const ComponentItem* target12v = nullptr;
|
||||
for (const ComponentItem& comp : result.components) {
|
||||
if (comp.name.find("12v4000g03") != std::string::npos ||
|
||||
comp.name.find("12V4000G03") != std::string::npos) {
|
||||
target12v = ∁
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Step 2: Calculate global assembly AABB
|
||||
for (const ComponentItem& comp : result.components) {
|
||||
result.globalAABB.expand(comp.worldAABB.minPoint);
|
||||
@ -2883,8 +2878,13 @@ CreoManager::ProjectionAnalysisData CreoManager::PerformMultiDirectionalProjecti
|
||||
featureIdToName[comp.featureId] = comp.name;
|
||||
}
|
||||
|
||||
// Remove 12v4000g03_debug.txt creation - will use visibility file instead
|
||||
|
||||
int directionIndex = 0;
|
||||
|
||||
// Step 4: For each direction, determine visible components using 2D grid-based occlusion detection
|
||||
for (const Vector3D& direction : directions) {
|
||||
directionIndex++;
|
||||
// Create screen grid for this viewing direction
|
||||
ScreenGrid grid(result.globalAABB, direction, SHELL_ANALYSIS_GRID_RESOLUTION);
|
||||
|
||||
@ -2934,6 +2934,44 @@ CreoManager::ProjectionAnalysisData CreoManager::PerformMultiDirectionalProjecti
|
||||
auto visibilityCounts = grid.getVisibilityCount();
|
||||
int totalCells = grid.gridSizeU * grid.gridSizeV;
|
||||
|
||||
// Log visibility counts for debugging
|
||||
if (target12v) {
|
||||
try {
|
||||
SessionInfo sessionInfo = GetSessionInfo();
|
||||
if (sessionInfo.is_valid) {
|
||||
xstring workdir = sessionInfo.session->GetCurrentDirectory();
|
||||
std::string workingDir = XStringToString(workdir);
|
||||
std::string logPath = workingDir + "\\12v4000g03_visibility.txt";
|
||||
|
||||
if (directionIndex == 1) {
|
||||
// First direction - create file with header
|
||||
std::ofstream logFile(logPath);
|
||||
if (logFile.is_open()) {
|
||||
logFile << "=== 12V4000G03 Analysis ===" << std::endl;
|
||||
logFile << "Target ID: " << target12v->featureId << std::endl;
|
||||
logFile << "Target Name: " << target12v->name << std::endl;
|
||||
logFile << "\n=== Direction Analysis ===" << std::endl;
|
||||
logFile.close();
|
||||
}
|
||||
}
|
||||
|
||||
// Append direction info
|
||||
std::ofstream logFile(logPath, std::ios::app);
|
||||
if (logFile.is_open()) {
|
||||
auto it = visibilityCounts.find(target12v->featureId);
|
||||
logFile << "\nDirection " << directionIndex << ":" << std::endl;
|
||||
if (it != visibilityCounts.end()) {
|
||||
logFile << " 2D Projection: cells=" << it->second
|
||||
<< ", ratio=" << ((double)it->second / totalCells) << std::endl;
|
||||
} else {
|
||||
logFile << " 2D Projection: NOT VISIBLE" << std::endl;
|
||||
}
|
||||
logFile.close();
|
||||
}
|
||||
}
|
||||
} catch (...) {}
|
||||
}
|
||||
|
||||
// Update visibility votes based on grid visibility with ray verification
|
||||
for (const auto& kvp : visibilityCounts) {
|
||||
int componentId = kvp.first;
|
||||
@ -2968,79 +3006,18 @@ CreoManager::ProjectionAnalysisData CreoManager::PerformMultiDirectionalProjecti
|
||||
}
|
||||
// If blocked by ray test, this direction votes 0 (no increment)
|
||||
|
||||
// Debug output for specific component
|
||||
if (targetComponent->name.find("12v4000g03") != std::string::npos ||
|
||||
targetComponent->name.find("12V4000G03") != std::string::npos) {
|
||||
static bool firstTime = true;
|
||||
if (firstTime) {
|
||||
try {
|
||||
SessionInfo sessionInfo = GetSessionInfo();
|
||||
if (sessionInfo.is_valid) {
|
||||
xstring workdir = sessionInfo.session->GetCurrentDirectory();
|
||||
std::string workingDir = XStringToString(workdir);
|
||||
std::string logPath = workingDir + "\\12v4000g03_analysis.txt";
|
||||
std::ofstream logFile(logPath, std::ios::out | std::ios::trunc);
|
||||
if (logFile.is_open()) {
|
||||
logFile << "=== 12V4000G03 Component Visibility Analysis ===" << std::endl;
|
||||
logFile << "Component Name: " << targetComponent->name << std::endl;
|
||||
logFile << "Feature ID: " << targetComponent->featureId << std::endl;
|
||||
logFile << "\nBounding Box:" << std::endl;
|
||||
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 << ", "
|
||||
<< result.globalAABB.minPoint.z << ")" << std::endl;
|
||||
logFile << " Max: (" << result.globalAABB.maxPoint.x << ", "
|
||||
<< result.globalAABB.maxPoint.y << ", "
|
||||
<< result.globalAABB.maxPoint.z << ")" << std::endl;
|
||||
logFile << "\nGrid Resolution: " << grid.gridSizeU << " x " << grid.gridSizeV << std::endl;
|
||||
logFile << "Total Cells: " << totalCells << std::endl;
|
||||
logFile << "Minimum Visibility Ratio Per Direction: " << SHELL_ANALYSIS_MIN_VISIBLE_RATIO_PER_DIR << std::endl;
|
||||
logFile << "\nVisibility per direction:" << std::endl;
|
||||
logFile.close();
|
||||
}
|
||||
}
|
||||
firstTime = false;
|
||||
} catch (...) {}
|
||||
}
|
||||
|
||||
// Append visibility data for each direction
|
||||
// Log ray test result for target12v in same visibility file
|
||||
if (target12v && componentId == target12v->featureId) {
|
||||
try {
|
||||
SessionInfo sessionInfo = GetSessionInfo();
|
||||
if (sessionInfo.is_valid) {
|
||||
xstring workdir = sessionInfo.session->GetCurrentDirectory();
|
||||
std::string workingDir = XStringToString(workdir);
|
||||
std::string logPath = workingDir + "\\12v4000g03_analysis.txt";
|
||||
std::ofstream logFile(logPath, std::ios::out | std::ios::app);
|
||||
std::string logPath = workingDir + "\\12v4000g03_visibility.txt";
|
||||
std::ofstream logFile(logPath, std::ios::app);
|
||||
if (logFile.is_open()) {
|
||||
static int directionCount = 0;
|
||||
directionCount++;
|
||||
|
||||
// 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
|
||||
<< ", visible=" << (visibilityRatio >= SHELL_ANALYSIS_MIN_VISIBLE_RATIO_PER_DIR ? "YES" : "NO") << std::endl;
|
||||
|
||||
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;
|
||||
logFile << " Ray Test: " << (rayBlocked ? "BLOCKED" : "CLEAR") << std::endl;
|
||||
logFile << " Vote: " << (rayBlocked ? "0" : "1") << std::endl;
|
||||
logFile.close();
|
||||
}
|
||||
}
|
||||
@ -3061,6 +3038,27 @@ CreoManager::ProjectionAnalysisData CreoManager::PerformMultiDirectionalProjecti
|
||||
}
|
||||
}
|
||||
|
||||
// Log final votes in same visibility file
|
||||
if (target12v) {
|
||||
try {
|
||||
SessionInfo sessionInfo = GetSessionInfo();
|
||||
if (sessionInfo.is_valid) {
|
||||
xstring workdir = sessionInfo.session->GetCurrentDirectory();
|
||||
std::string workingDir = XStringToString(workdir);
|
||||
std::string logPath = workingDir + "\\12v4000g03_visibility.txt";
|
||||
std::ofstream logFile(logPath, std::ios::app);
|
||||
if (logFile.is_open()) {
|
||||
logFile << "\n=== FINAL RESULTS ===" << std::endl;
|
||||
auto votesIt = result.visibilityVotes.find(target12v->featureId);
|
||||
int totalVotes = (votesIt != result.visibilityVotes.end()) ? votesIt->second : 0;
|
||||
logFile << "Total Votes: " << totalVotes << " out of " << numDirections << " directions" << std::endl;
|
||||
logFile << "Classification: " << (totalVotes >= minVotes ? "OUTER SHELL" : "INTERNAL") << std::endl;
|
||||
logFile.close();
|
||||
}
|
||||
}
|
||||
} catch (...) {}
|
||||
}
|
||||
|
||||
// Step 6 removed: Same-path sharing mechanism deleted to ensure independent component evaluation
|
||||
|
||||
return result;
|
||||
@ -3561,12 +3559,22 @@ bool CreoManager::IsComponentBlockedFromCenter(const Vector3D& globalCenter,
|
||||
// We only care about intersections beyond this distance (outward extension)
|
||||
double distToComponentCenter = (componentCenter - globalCenter).length();
|
||||
|
||||
// Debug for 12V4000G03
|
||||
bool isTarget12v = (component.name.find("12v4000g03") != std::string::npos ||
|
||||
component.name.find("12V4000G03") != std::string::npos);
|
||||
|
||||
int checkedCount = 0;
|
||||
int intersectionCount = 0;
|
||||
std::string nearestBlocker;
|
||||
double nearestDistance = 1e9;
|
||||
|
||||
// Check intersection with all other components
|
||||
for (const ComponentItem& otherComp : allComponents) {
|
||||
// Skip self
|
||||
if (otherComp.featureId == component.featureId) {
|
||||
continue;
|
||||
}
|
||||
checkedCount++;
|
||||
|
||||
// AABB ray intersection test
|
||||
// We check if ray intersects other component's AABB beyond the component center
|
||||
@ -3613,6 +3621,14 @@ bool CreoManager::IsComponentBlockedFromCenter(const Vector3D& globalCenter,
|
||||
if (tMin <= tMax && tMin >= 0) {
|
||||
// Calculate the actual distance of the intersection point
|
||||
double intersectionDistance = tMin;
|
||||
intersectionCount++;
|
||||
|
||||
// Track nearest potential blocker for debugging
|
||||
if (isTarget12v && intersectionDistance < nearestDistance) {
|
||||
nearestDistance = intersectionDistance;
|
||||
nearestBlocker = otherComp.name + " (ID:" + std::to_string(otherComp.featureId) +
|
||||
") at dist=" + std::to_string(intersectionDistance);
|
||||
}
|
||||
|
||||
// Only consider it blocked if intersection is beyond the component center
|
||||
if (intersectionDistance > distToComponentCenter) {
|
||||
@ -3621,6 +3637,7 @@ bool CreoManager::IsComponentBlockedFromCenter(const Vector3D& globalCenter,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false; // Component is not blocked (is outer shell)
|
||||
}
|
||||
|
||||
|
||||
3648
CreoManager.cpp.backup
Normal file
3648
CreoManager.cpp.backup
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user