Skip to content

Commit

Permalink
Made small corrections to FEPlane creation; Added the bUseCGALInMin f…
Browse files Browse the repository at this point in the history
…lag to check custom projections.
  • Loading branch information
Azzinoth committed May 6, 2024
1 parent 555884a commit e76328e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
33 changes: 27 additions & 6 deletions SubSystems/ComplexityCore/Layers/RugosityLayerProducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,17 +263,38 @@ void RugosityLayerProducer::CalculateOneNodeRugosity(GridNode* CurrentNode)
else
{
std::vector<float> Rugosities;
Point_3 PointA(0.0f, 0.0f, 0.0f);
Plane_3 PlaneToProjectOnto(PointA, Vector_3(PlaneNormal.x, PlaneNormal.y, PlaneNormal.z));

for (int l = 0; l < CurrentNode->TrianglesInCell.size(); l++)
{
std::vector<glm::vec3> CurrentTriangle = COMPLEXITY_METRIC_MANAGER.ActiveComplexityMetricInfo->Triangles[CurrentNode->TrianglesInCell[l]];

glm::dvec3 AProjection = ProjectionPlane->ProjectPoint(CurrentTriangle[0]);
glm::dvec3 BProjection = ProjectionPlane->ProjectPoint(CurrentTriangle[1]);
glm::dvec3 CProjection = ProjectionPlane->ProjectPoint(CurrentTriangle[2]);
double ProjectionArea = 0.0;
double OriginalArea = 0.0;

if (!RUGOSITY_LAYER_PRODUCER.bUseCGALInMin)
{
glm::dvec3 AProjection = ProjectionPlane->ProjectPoint(CurrentTriangle[0]);
glm::dvec3 BProjection = ProjectionPlane->ProjectPoint(CurrentTriangle[1]);
glm::dvec3 CProjection = ProjectionPlane->ProjectPoint(CurrentTriangle[2]);

ProjectionArea = GEOMETRY.CalculateTriangleArea(AProjection, BProjection, CProjection);
OriginalArea = COMPLEXITY_METRIC_MANAGER.ActiveComplexityMetricInfo->TrianglesArea[CurrentNode->TrianglesInCell[l]];
Rugosities.push_back(static_cast<float>(OriginalArea / ProjectionArea));
}
else
{
std::vector<Point_2> ProjectedPoints;
for (size_t j = 0; j < CurrentTriangle.size(); j++)
{
ProjectedPoints.push_back(RUGOSITY_LAYER_PRODUCER.ProjectPointOntoPlane(Point_3(CurrentTriangle[j].x, CurrentTriangle[j].y, CurrentTriangle[j].z), PlaneToProjectOnto));
}

double ProjectionArea = GEOMETRY.CalculateTriangleArea(AProjection, BProjection, CProjection);
double OriginalArea = COMPLEXITY_METRIC_MANAGER.ActiveComplexityMetricInfo->TrianglesArea[CurrentNode->TrianglesInCell[l]];
Rugosities.push_back(static_cast<float>(OriginalArea / ProjectionArea));
ProjectionArea = abs(CGAL::to_double(CGAL::area(ProjectedPoints[0], ProjectedPoints[1], ProjectedPoints[2])));
OriginalArea = COMPLEXITY_METRIC_MANAGER.ActiveComplexityMetricInfo->TrianglesArea[CurrentNode->TrianglesInCell[l]];
Rugosities.push_back(OriginalArea / ProjectionArea);
}

if (OriginalArea == 0.0 || ProjectionArea == 0.0 || OriginalArea < FLT_EPSILON || ProjectionArea < FLT_EPSILON)
Rugosities.back() = 1.0f;
Expand Down
5 changes: 4 additions & 1 deletion SubSystems/ComplexityCore/Layers/RugosityLayerProducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace FocalEngine
{
glm::dvec3 PointOnPlane;
glm::dvec3 Normal;
float Distance = 0.0f;
double Distance = 0.0;

FEPlane(const glm::dvec3 PointOnPlane, const glm::dvec3 Normal)
{
Expand All @@ -21,6 +21,7 @@ namespace FocalEngine

// Distance is the length of the perpendicular line from the origin to the plane.
double PlaneD = glm::length(glm::dot(PointOnPlane, Normal));
Distance = PlaneD;
}

glm::vec3 ProjectPoint(const glm::dvec3& Point) const
Expand Down Expand Up @@ -75,6 +76,8 @@ namespace FocalEngine

void RenderDebugInfoForSelectedNode(MeasurementGrid* Grid);
float GetLastTimeTookForCalculation();

bool bUseCGALInMin = false;
private:
SINGLETON_PRIVATE_PART(RugosityLayerProducer)

Expand Down
2 changes: 2 additions & 0 deletions SubSystems/UI/NewLayerWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ void NewLayerWindow::RenderRugosityLayerSettings()
}
ImGui::EndCombo();
}

ImGui::Checkbox("Use CGAL in Min Rugosity", &RUGOSITY_LAYER_PRODUCER.bUseCGALInMin);
}

if (!bRunOnWholeModel)
Expand Down

0 comments on commit e76328e

Please sign in to comment.