Skip to content

Commit

Permalink
Add min/max dihedral angle to the Statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
afabri committed Jan 3, 2025
1 parent 29be2c9 commit 8035ebb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
20 changes: 19 additions & 1 deletion Lab/demo/Lab/Scene_surface_mesh_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <CGAL/Polygon_mesh_processing/orient_polygon_soup.h>
#include <CGAL/Polygon_mesh_processing/polygon_soup_to_polygon_mesh.h>
#include <CGAL/Polygon_mesh_processing/repair_polygon_soup.h>
#include <CGAL/Polygon_mesh_processing/detect_features.h>
#include "triangulate_primitive.h"

#include <CGAL/IO/OBJ.h>
Expand Down Expand Up @@ -1636,6 +1637,15 @@ QString Scene_surface_mesh_item::computeStats(int type)
case MEAN_ANGLE:
angles(d->smesh_, mini, maxi, ave);
}

double minda(0), maxda(0);
switch (type)
{
case MIN_DIHEDRAL_ANGLE:
case MAX_DIHEDRAL_ANGLE:
dihedral_angles(d->smesh_, minda, maxda);
}

double min_area, max_area, med_area, mean_area;
switch (type)
{
Expand Down Expand Up @@ -1798,6 +1808,12 @@ QString Scene_surface_mesh_item::computeStats(int type)
return QString::number(maxi);
case MEAN_ANGLE:
return QString::number(ave);

case MIN_DIHEDRAL_ANGLE:
return QString::number(minda);
case MAX_DIHEDRAL_ANGLE:
return QString::number(maxda);

case NB_HOLES:
return QString::number(nb_holes(d->smesh_));

Expand Down Expand Up @@ -1840,7 +1856,7 @@ CGAL::Three::Scene_item::Header_data Scene_surface_mesh_item::header() const
data.categories.append(std::pair<QString,int>(QString("Vertices"),2));
data.categories.append(std::pair<QString,int>(QString("Faces"),10));
data.categories.append(std::pair<QString,int>(QString("Edges"),7));
data.categories.append(std::pair<QString,int>(QString("Angles"),3));
data.categories.append(std::pair<QString,int>(QString("Angles"),5));


//titles
Expand Down Expand Up @@ -1879,6 +1895,8 @@ CGAL::Three::Scene_item::Header_data Scene_surface_mesh_item::header() const
data.titles.append(QString("Minimum"));
data.titles.append(QString("Maximum"));
data.titles.append(QString("Average"));
data.titles.append(QString("Dihedral Minimum"));
data.titles.append(QString("Dihedral Maximum"));

return data;
}
Expand Down
4 changes: 3 additions & 1 deletion Lab/demo/Lab/Scene_surface_mesh_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ class SCENE_SURFACE_MESH_ITEM_EXPORT Scene_surface_mesh_item
// Angles
MIN_ANGLE,
MAX_ANGLE,
MEAN_ANGLE
MEAN_ANGLE,
MIN_DIHEDRAL_ANGLE,
MAX_DIHEDRAL_ANGLE
};

bool has_stats()const override{return true;}
Expand Down
8 changes: 8 additions & 0 deletions Lab/demo/Lab/include/CGAL/statistics_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ void angles(Mesh* poly, double& mini, double& maxi, double& ave)
compute_angles(poly, Angles_test(), mini, maxi, ave);
}

template<typename Mesh>
void dihedral_angles(Mesh* poly, double& minda, double& maxda)
{
auto da = CGAL::Polygon_mesh_processing::detect_sharp_edges(*poly);
minda = da.first.second;
maxda = da.second.second;
}

template<typename Mesh, typename Face_set>
void angles(Mesh* poly, const Face_set& faces, double& mini, double& maxi, double& ave)
{
Expand Down

0 comments on commit 8035ebb

Please sign in to comment.