From: skl Date: Mon, 29 Jun 2009 13:15:29 +0000 (+0000) Subject: Implememtation of evaluation for improvement 0019296. X-Git-Tag: V5_1_3rc1~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d34aaf1aee2463302a5dae8764ff4c88affb715a;p=plugins%2Fghs3dplugin.git Implememtation of evaluation for improvement 0019296. --- diff --git a/src/GHS3DPlugin_GHS3D.cxx b/src/GHS3DPlugin_GHS3D.cxx index d3b3d4d..b1a89b8 100644 --- a/src/GHS3DPlugin_GHS3D.cxx +++ b/src/GHS3DPlugin_GHS3D.cxx @@ -58,8 +58,9 @@ using namespace std; #include #include //#include -//#include -//#include +#include +#include +#include #include "utilities.h" @@ -1735,3 +1736,77 @@ const SMDS_MeshElement* _Ghs2smdsConvertor::getElement(const vector& ghsNod return 0; } + +//============================================================================= +/*! + * + */ +//============================================================================= +bool GHS3DPlugin_GHS3D::Evaluate(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap) +{ + int nbtri = 0, nbqua = 0; + double fullArea = 0.0; + for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) { + TopoDS_Face F = TopoDS::Face( exp.Current() ); + SMESH_subMesh *sm = aMesh.GetSubMesh(F); + MapShapeNbElemsItr anIt = aResMap.find(sm); + std::vector aVec = (*anIt).second; + nbtri += Max(aVec[3],aVec[4]); + nbqua += Max(aVec[5],aVec[6]); + GProp_GProps G; + BRepGProp::SurfaceProperties(F,G); + double anArea = G.Mass(); + fullArea += anArea; + } + + // collect info from edges + int nb0d_e = 0, nb1d_e = 0; + bool IsQuadratic = false; + bool IsFirst = true; + TopTools_MapOfShape tmpMap; + for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next()) { + TopoDS_Edge E = TopoDS::Edge(exp.Current()); + if( tmpMap.Contains(E) ) + continue; + tmpMap.Add(E); + SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current()); + MapShapeNbElemsItr anIt = aResMap.find(aSubMesh); + std::vector aVec = (*anIt).second; + nb0d_e += aVec[0]; + nb1d_e += Max(aVec[1],aVec[2]); + if(IsFirst) { + IsQuadratic = (aVec[2] > aVec[1]); + IsFirst = false; + } + } + tmpMap.Clear(); + + double ELen = sqrt(2.* ( fullArea/(nbtri+nbqua*2) ) / sqrt(3.0) ); + + GProp_GProps G; + BRepGProp::VolumeProperties(aShape,G); + double aVolume = G.Mass(); + double tetrVol = 0.1179*ELen*ELen*ELen; + double CoeffQuality = 0.9; + int nbVols = (int)aVolume/tetrVol/CoeffQuality; + int nb1d_f = (nbtri*3 + nbqua*4 - nb1d_e) / 2; + int nb1d_in = (int) ( nbVols*6 - nb1d_e - nb1d_f ) / 5; + std::vector aVec(17); + for(int i=0; i<17; i++) aVec[i]=0; + if( IsQuadratic ) { + aVec[0] = nb1d_in/6 + 1 + nb1d_in; + aVec[9] = nbVols - nbqua*2; + aVec[11] = nbqua; + } + else { + aVec[0] = nb1d_in/6 + 1; + aVec[8] = nbVols - nbqua*2; + aVec[10] = nbqua; + } + SMESH_subMesh *sm = aMesh.GetSubMesh(aShape); + aResMap.insert(std::make_pair(sm,aVec)); + + return true; +} diff --git a/src/GHS3DPlugin_GHS3D.hxx b/src/GHS3DPlugin_GHS3D.hxx index 8c9d7e3..865243e 100644 --- a/src/GHS3DPlugin_GHS3D.hxx +++ b/src/GHS3DPlugin_GHS3D.hxx @@ -50,6 +50,9 @@ public: virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); + virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap); + virtual bool Compute(SMESH_Mesh& theMesh, SMESH_MesherHelper* aHelper);