From 95e7e98096ab57a7335931d05d378026420ae0e0 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 13 Jan 2009 12:48:00 +0000 Subject: [PATCH] 0019923: EDF 765 SMESH : default values of hypothesis add access methods to new fields + double _shapeDiagonal; //!< diagonal size of bounding box of shape to mesh + int _nbElemPerDiagonal; //!< nb elements per diagonal --- src/SMESH/SMESH_Mesh.cxx | 32 ++++++++++++++++++++++++++++++++ src/SMESH/SMESH_Mesh.hxx | 15 +++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index a07089b8d..9fbd4acab 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -50,7 +50,9 @@ #include "DriverUNV_R_SMDS_Mesh.h" #include "DriverSTL_R_SMDS_Mesh.h" +#include #include +#include #include #include #include @@ -95,6 +97,7 @@ SMESH_Mesh::SMESH_Mesh(int theLocalId, _myMeshDS = theDocument->GetMesh(_idDoc); _isShapeToMesh = false; _isAutoColor = false; + _shapeDiagonal = 0.0; _myMeshDS->ShapeToMesh( PseudoShape() ); } @@ -155,6 +158,8 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape) // clear SMESHDS TopoDS_Shape aNullShape; _myMeshDS->ShapeToMesh( aNullShape ); + + _shapeDiagonal = 0.0; } // set a new geometry @@ -202,6 +207,33 @@ const TopoDS_Solid& SMESH_Mesh::PseudoShape() return aSolid; } +//======================================================================= +/*! + * \brief Return diagonal size of bounding box of a shape + */ +//======================================================================= + +double SMESH_Mesh::GetShapeDiagonalSize(const TopoDS_Shape & aShape) +{ + Bnd_Box Box; + BRepBndLib::Add(aShape, Box); + return sqrt( Box.SquareExtent() ); +} + +//======================================================================= +/*! + * \brief Return diagonal size of bounding box of shape to mesh + */ +//======================================================================= + +double SMESH_Mesh::GetShapeDiagonalSize() const +{ + if ( _shapeDiagonal == 0. && _isShapeToMesh ) + const_cast(this)->_shapeDiagonal = GetShapeDiagonalSize( GetShapeToMesh() ); + + return _shapeDiagonal; +} + //======================================================================= /*! * \brief Remove all nodes and elements diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 8ba8f082c..38012a223 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -76,6 +76,14 @@ public: * \brief Return true if there is a geometry to be meshed, not PseudoShape() */ bool HasShapeToMesh() const { return _isShapeToMesh; } + /*! + * \brief Return diagonal size of bounding box of shape to mesh. + */ + double GetShapeDiagonalSize() const; + /*! + * \brief Return diagonal size of bounding box of a shape. + */ + static double GetShapeDiagonalSize(const TopoDS_Shape & aShape); /*! * \brief Return a solid which is returned by GetShapeToMesh() if * a real geometry to be meshed was not set @@ -122,6 +130,10 @@ public: std::list & aHypList, const bool andAncestors) const; + void SetNbElementsPerDiagonal(int nb) { _nbElemPerDiagonal = nb ;} + + int GetNbElementsPerDiagonal() { return _nbElemPerDiagonal; } + const std::list & GetLog() throw(SALOME_Exception); void ClearLog() throw(SALOME_Exception); @@ -260,6 +272,9 @@ protected: SMESH_Gen * _gen; bool _isAutoColor; + + double _shapeDiagonal; //!< diagonal size of bounding box of shape to mesh + int _nbElemPerDiagonal; //!< nb elements per diagonal TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors; -- 2.39.2