X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FBLSURFPlugin%2FBLSURFPlugin_BLSURF.cxx;h=8222eafd243b208eb5b332b19903d3e0e0c91cfe;hb=a8efd24a7464d216301a8d6238a2cd987bc3119c;hp=af32973357447b70326c189f5553a14492505109;hpb=953e51afe39c4e4d619244abdeb7465be283e80b;p=plugins%2Fblsurfplugin.git diff --git a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx index af32973..8222eaf 100644 --- a/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx +++ b/src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2019 CEA/DEN, EDF R&D +// Copyright (C) 2007-2020 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -58,6 +58,7 @@ extern "C"{ #include // OPENCASCADE includes +#include #include #include #include @@ -1001,11 +1002,12 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, case BLSURFPlugin_Hypothesis::PhysicalGlobalSize: set_param(css, "physical_size_mode", "global"); set_param(css, "global_physical_size", _phySizeRel ? val_to_string_rel(_phySize).c_str() : val_to_string(_phySize).c_str()); + //useGradation = true; break; case BLSURFPlugin_Hypothesis::PhysicalLocalSize: set_param(css, "physical_size_mode", "local"); set_param(css, "global_physical_size", _phySizeRel ? val_to_string_rel(_phySize).c_str() : val_to_string(_phySize).c_str()); - useGradation = true; + //useGradation = true; break; default: set_param(css, "physical_size_mode", "none"); @@ -1017,13 +1019,13 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, set_param(css, "geometric_size_mode", "global"); set_param(css, "geometric_approximation", val_to_string(_angleMesh).c_str()); set_param(css, "chordal_error", val_to_string(_chordalError).c_str()); - useGradation = true; + //useGradation = true; break; case BLSURFPlugin_Hypothesis::GeometricalLocalSize: set_param(css, "geometric_size_mode", "local"); set_param(css, "geometric_approximation", val_to_string(_angleMesh).c_str()); set_param(css, "chordal_error", val_to_string(_chordalError).c_str()); - useGradation = true; + //useGradation = true; break; default: set_param(css, "geometric_size_mode", "none"); @@ -1054,6 +1056,7 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, // - if maxsize is not explicitly specified, we pass default value computed automatically, in this case "relative" flag is ignored set_param(css, "max_size", _maxSizeRel ? val_to_string_rel(_maxSize).c_str() : val_to_string(_maxSize).c_str()); } + useGradation = true; // bos #18758 // anisotropic and quadrangle mesh requires disabling gradation if ( _anisotropic && _elementType != BLSURFPlugin_Hypothesis::Triangles ) useGradation = false; // limitation of V1.3 @@ -1546,7 +1549,7 @@ namespace //double tol = (( u2node.rbegin()->first - u2node.begin()->first ) / 20.) / u2node.size(); Standard_Real f,l; BRep_Tool::Range( TopoDS::Edge( shape ), f,l ); - double tol = (( l - f ) / 20.) / u2node.size(); + double tol = (( l - f ) / 10.) / u2node.size(); // 10. - adjusted for #17262 std::multimap< double, const SMDS_MeshNode* >::iterator un2, un1; for ( un2 = u2node.begin(), un1 = un2++; un2 != u2node.end(); un1 = un2++ ) @@ -1921,6 +1924,7 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, typedef set< SMESHDS_SubMesh*, ShapeTypeCompare > TSubMeshSet; TSubMeshSet edgeSubmeshes; TSubMeshSet& mergeSubmeshes = edgeSubmeshes; + double existingPhySize = 0; TopTools_IndexedMapOfShape pmap, emap, fmap; @@ -2219,6 +2223,8 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, // tmin and tmax can change in case of viscous layer on an adjacent edge tmin = nodeDataVec.front().param; tmax = nodeDataVec.back().param; + + existingPhySize += nodeData->Length() / ( nodeDataVec.size() - 1 ); } else { @@ -2368,44 +2374,6 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, } // for edge } //for face - // Clear mesh from already meshed edges if possible else - // remember that merge is needed - TSubMeshSet::iterator smIt = edgeSubmeshes.begin(); - for ( ; smIt != edgeSubmeshes.end(); ++smIt ) // loop on already meshed EDGEs - { - SMESHDS_SubMesh* smDS = *smIt; - if ( !smDS ) continue; - SMDS_NodeIteratorPtr nIt = smDS->GetNodes(); - if ( nIt->more() ) - { - const SMDS_MeshNode* n = nIt->next(); - if ( n->NbInverseElements( SMDSAbs_Face ) > 0 ) - { - needMerge = true; // to correctly sew with viscous mesh - // add existing medium nodes to helper - if ( aMesh.NbEdges( ORDER_QUADRATIC ) > 0 ) - { - SMDS_ElemIteratorPtr edgeIt = smDS->GetElements(); - while ( edgeIt->more() ) - helper.AddTLinks( static_cast(edgeIt->next())); - } - continue; - } - } - if ( allowSubMeshClearing ) - { - SMDS_ElemIteratorPtr eIt = smDS->GetElements(); - while ( eIt->more() ) meshDS->RemoveFreeElement( eIt->next(), 0 ); - SMDS_NodeIteratorPtr nIt = smDS->GetNodes(); - while ( nIt->more() ) meshDS->RemoveFreeNode( nIt->next(), 0 ); - smDS->Clear(); - } - else - { - needMerge = true; - } - } - /////////////////////// // PERIODICITY // /////////////////////// @@ -2497,6 +2465,22 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, } } + if ( !_hypothesis && !edgeSubmeshes.empty() && existingPhySize != 0 ) + { + // prevent failure due to the default PhySize incompatible with size of existing 1D mesh + // and with face size + // double minFaceSize = existingPhySize / edgeSubmeshes.size(); + // for ( int iF = 1; iF <= fmap.Extent(); ++iF ) + // { + // Bnd_Box box; + // BRepBndLib::Add( fmap( iF ), box ); + // gp_XYZ delta = box.CornerMax().XYZ() - box.CornerMin().XYZ(); + // std::sort( delta.ChangeData(), delta.ChangeData() + 3 ); + // minFaceSize = Min( minFaceSize, delta.Coord(2) ); + // } + // set_param(css, "global_physical_size", val_to_string( minFaceSize * 0.5 ).c_str()); + // set_param(css, "max_size", val_to_string( minFaceSize * 5 ).c_str()); + } // TODO: be able to use a mesh in input. // See imsh usage in Products/templates/mg-cadsurf_template_common.cpp @@ -2539,12 +2523,51 @@ bool BLSURFPlugin_BLSURF::compute(SMESH_Mesh& aMesh, mesh_t *msh = NULL; cadsurf_get_mesh(css, &msh); - if(!msh){ + if ( !msh || STATUS_IS_ERROR( status )) + { /* release the mesh object */ cadsurf_regain_mesh(css, msh); return error(_comment); } + // Clear mesh from already meshed edges if possible else + // remember that merge is needed + TSubMeshSet::iterator smIt = edgeSubmeshes.begin(); + for ( ; smIt != edgeSubmeshes.end(); ++smIt ) // loop on already meshed EDGEs + { + SMESHDS_SubMesh* smDS = *smIt; + if ( !smDS ) continue; + SMDS_NodeIteratorPtr nIt = smDS->GetNodes(); + if ( nIt->more() ) + { + const SMDS_MeshNode* n = nIt->next(); + if ( n->NbInverseElements( SMDSAbs_Face ) > 0 ) + { + needMerge = true; // to correctly sew with viscous mesh + // add existing medium nodes to helper + if ( aMesh.NbEdges( ORDER_QUADRATIC ) > 0 ) + { + SMDS_ElemIteratorPtr edgeIt = smDS->GetElements(); + while ( edgeIt->more() ) + helper.AddTLinks( static_cast(edgeIt->next())); + } + continue; + } + } + if ( allowSubMeshClearing ) + { + SMDS_ElemIteratorPtr eIt = smDS->GetElements(); + while ( eIt->more() ) meshDS->RemoveFreeElement( eIt->next(), 0 ); + SMDS_NodeIteratorPtr nIt = smDS->GetNodes(); + while ( nIt->more() ) meshDS->RemoveFreeNode( nIt->next(), 0 ); + smDS->Clear(); + } + else + { + needMerge = true; + } + } + std::string GMFFileName = BLSURFPlugin_Hypothesis::GetDefaultGMFFile(); if (_hypothesis) GMFFileName = _hypothesis->GetGMFFile();