Skip to content

Commit

Permalink
App: bring mesh area+volume computation back
Browse files Browse the repository at this point in the history
  • Loading branch information
HuguesDelorme committed Jan 8, 2021
1 parent ec0a6f6 commit a8cd9ad
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
19 changes: 13 additions & 6 deletions src/app/document_tree_node_properties_providers.cpp
Expand Up @@ -9,6 +9,7 @@
#include "../base/caf_utils.h"
#include "../base/document.h"
#include "../base/document_tree_node.h"
#include "../base/mesh_utils.h"
#include "../base/meta_enum.h"
#include "../base/string_utils.h"
#include "../base/xcaf.h"
Expand Down Expand Up @@ -182,9 +183,11 @@ XCaf_DocumentTreeNodePropertiesProvider::properties(const DocumentTreeNode& tree
class Mesh_DocumentTreeNodePropertiesProvider::Properties : public PropertyGroupSignals {
MAYO_DECLARE_TEXT_ID_FUNCTIONS(Mayo::Mesh_DocumentTreeNodeProperties)
public:
Properties(const DocumentTreeNode& treeNode)
Properties(const DocumentTreeNode& treeNode)
: m_propertyNodeCount(this, textId("NodeCount")),
m_propertyTriangleCount(this, textId("TriangleCount"))
m_propertyTriangleCount(this, textId("TriangleCount")),
m_propertyArea(this, textId("Area")),
m_propertyVolume(this, textId("Volume"))
{
auto attrTriangulation = CafUtils::findAttribute<TDataXtd_Triangulation>(treeNode.label());
Handle_Poly_Triangulation polyTri;
Expand All @@ -193,12 +196,16 @@ class Mesh_DocumentTreeNodePropertiesProvider::Properties : public PropertyGroup

m_propertyNodeCount.setValue(!polyTri.IsNull() ? polyTri->NbNodes() : 0);
m_propertyTriangleCount.setValue(!polyTri.IsNull() ? polyTri->NbTriangles() : 0);
m_propertyNodeCount.setUserReadOnly(true);
m_propertyTriangleCount.setUserReadOnly(true);
m_propertyArea.setQuantity(MeshUtils::triangulationArea(polyTri) * Quantity_SquaredMillimeter);
m_propertyVolume.setQuantity(MeshUtils::triangulationVolume(polyTri) * Quantity_CubicMillimeter);
for (Property* property : this->properties())
property->setUserReadOnly(true);
}

PropertyInt m_propertyNodeCount; // Read-only
PropertyInt m_propertyTriangleCount; // Read-only
PropertyInt m_propertyNodeCount;
PropertyInt m_propertyTriangleCount;
PropertyArea m_propertyArea;
PropertyVolume m_propertyVolume;
};

bool Mesh_DocumentTreeNodePropertiesProvider::supports(const DocumentTreeNode& treeNode) const
Expand Down
6 changes: 6 additions & 0 deletions src/base/mesh_utils.cpp
Expand Up @@ -31,6 +31,9 @@ double MeshUtils::triangleArea(const gp_XYZ& p1, const gp_XYZ& p2, const gp_XYZ&

double MeshUtils::triangulationVolume(const Handle_Poly_Triangulation& triangulation)
{
if (!triangulation)
return 0;

double volume = 0;
const TColgp_Array1OfPnt& vecNode = triangulation->Nodes();
// TODO Parallelize computation
Expand All @@ -48,6 +51,9 @@ double MeshUtils::triangulationVolume(const Handle_Poly_Triangulation& triangula

double MeshUtils::triangulationArea(const Handle_Poly_Triangulation& triangulation)
{
if (!triangulation)
return 0;

double area = 0;
const TColgp_Array1OfPnt& vecNode = triangulation->Nodes();
// TODO Parallelize computation
Expand Down
2 changes: 1 addition & 1 deletion src/base/occ_static_variables_rollback.h
Expand Up @@ -28,7 +28,7 @@ namespace IO {
// varsRollback.change("write.surfacecurve.mode", 0);
// // Write STEP file(s) ...
// }
// // Changed OpenCascade variables automatically rolled back to they previous values ...
// // Changed OpenCascade variables automatically rolled back to their previous values ...
class OccStaticVariablesRollback {
public:
~OccStaticVariablesRollback();
Expand Down

0 comments on commit a8cd9ad

Please sign in to comment.