How to compute surface area of TopoDS_Face in OpenCASCADE
In order to compute the surface area of a TopoDS_Face, in OpenCASCADE, simply use BRepGProp::SurfaceProperties and call .Mass() on the resulting GProp_GProps object:
surface_area_example.cpp
GProp_GProps gprops;
BRepGProp::SurfaceProperties(face, gprops); // Stores results in gprops
double area = gprops.Mass();Alternatively, you can use my OCCUtils library which also also providers a lot of other utility functions:
surface_area_header_example.cpp
#include <occutils/Surface.hxx>
using namespace OCCUtils;
double Surface::Area(const TopoDS_Shape& face);Example:
surface_area_usage_example.cpp
#include <occutils/Surface.hxx>
using namespace OCCUtils;
// ...
double area = Surface::Area(myFace);
// ...
Check out similar posts by category:
C/C++, OpenCASCADE
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow