X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_Gen.cxx;h=793566ed987c44d9a27decbfa39e4cd4e229eede;hp=0930eec8278ec5ca629d973ebe027647492ecc30;hb=e33e8e2029a4e91779b9c1d5f480979fa7b51d0b;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 0930eec82..793566ed9 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -43,10 +43,11 @@ #include "Utils_ExceptHandlers.hxx" #include +#include #include "memoire.h" -#ifdef WNT +#ifdef WIN32 #include #endif @@ -65,7 +66,7 @@ SMESH_Gen::SMESH_Gen() { MESSAGE("SMESH_Gen::SMESH_Gen"); _localId = 0; - _hypId = 0; + _hypId = 0; _segmentation = _nbSegments = 10; SMDS_Mesh::_meshList.clear(); MESSAGE(SMDS_Mesh::_meshList.size()); @@ -120,16 +121,17 @@ SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode) } //============================================================================= -/*! +/* * Compute a mesh */ //============================================================================= bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape, - const bool anUpward, - const ::MeshDimension aDim, - TSetOfInt* aShapesId) + const bool aShapeOnly /*=false*/, + const bool anUpward /*=false*/, + const ::MeshDimension aDim /*=::MeshDim_3D*/, + TSetOfInt* aShapesId /*=0*/) { MESSAGE("SMESH_Gen::Compute"); MEMOSTAT; @@ -143,29 +145,32 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const int globalAlgoDim = 100; SMESH_subMeshIteratorPtr smIt; - SMESH_subMesh::compute_event computeEvent; - if ( !anUpward && aShape.IsSame( aMesh.GetShapeToMesh() )) - computeEvent = SMESH_subMesh::COMPUTE; - else - computeEvent = SMESH_subMesh::COMPUTE_SUBMESH; - if ( anUpward ) // is called from below code here + // Fix of Issue 22150. Due to !BLSURF->OnlyUnaryInput(), BLSURF computes edges + // that must be computed by Projection 1D-2D when Projection asks to compute + // one face only. + SMESH_subMesh::compute_event computeEvent = + aShapeOnly ? SMESH_subMesh::COMPUTE_SUBMESH : SMESH_subMesh::COMPUTE; + + if ( anUpward ) // is called from the below code in this method { - // ----------------------------------------------- - // mesh all the sub-shapes starting from vertices - // ----------------------------------------------- + // =============================================== + // Mesh all the sub-shapes starting from vertices + // =============================================== + smIt = sm->getDependsOnIterator(includeSelf, !complexShapeFirst); while ( smIt->more() ) { SMESH_subMesh* smToCompute = smIt->next(); // do not mesh vertices of a pseudo shape - const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType(); - if ( !aMesh.HasShapeToMesh() && aShType == TopAbs_VERTEX ) + const TopoDS_Shape& shape = smToCompute->GetSubShape(); + const TopAbs_ShapeEnum shapeType = shape.ShapeType(); + if ( !aMesh.HasShapeToMesh() && shapeType == TopAbs_VERTEX ) continue; // check for preview dimension limitations - if ( aShapesId && GetShapeDim( aShType ) > (int)aDim ) + if ( aShapesId && GetShapeDim( shapeType ) > (int)aDim ) { // clear compute state not to show previous compute errors // if preview invoked less dimension less than previous @@ -182,8 +187,9 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, _sm_current = NULL; } - // we check all the submeshes here and detect if any of them failed to compute - if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE) + // we check all the sub-meshes here and detect if any of them failed to compute + if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE && + ( shapeType != TopAbs_EDGE || !SMESH_Algo::isDegenerated( TopoDS::Edge( shape )))) ret = false; else if ( aShapesId ) aShapesId->insert( smToCompute->GetId() ); @@ -193,19 +199,23 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, } else { - // ----------------------------------------------------------------- - // apply algos that DO NOT require Discreteized boundaries and DO NOT - // support submeshes, starting from the most complex shapes - // and collect submeshes with algos that DO support submeshes - // ----------------------------------------------------------------- - list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes; + // ================================================================ + // Apply algos that do NOT require discreteized boundaries + // ("all-dimensional") and do NOT support sub-meshes, starting from + // the most complex shapes and collect sub-meshes with algos that + // DO support sub-meshes + // ================================================================ + + list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes[4]; // for each dim // map to sort sm with same dim algos according to dim of - // the shape the algo assigned to (issue 0021217) + // the shape the algo assigned to (issue 0021217). + // Other issues influenced the algo applying order: + // 21406, 21556, 21893, 20206 multimap< int, SMESH_subMesh* > shDim2sm; multimap< int, SMESH_subMesh* >::reverse_iterator shDim2smIt; TopoDS_Shape algoShape; - int prevShapeDim = -1; + int prevShapeDim = -1, aShapeDim; smIt = sm->getDependsOnIterator(includeSelf, complexShapeFirst); while ( smIt->more() ) @@ -215,7 +225,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, continue; const TopoDS_Shape& aSubShape = smToCompute->GetSubShape(); - int aShapeDim = GetShapeDim( aSubShape ); + aShapeDim = GetShapeDim( aSubShape ); if ( aShapeDim < 1 ) break; // check for preview dimension limitations @@ -234,9 +244,9 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, prevShapeDim = aShapeDim; for ( shDim2smIt = shDim2sm.rbegin(); shDim2smIt != shDim2sm.rend(); ++shDim2smIt ) if ( shDim2smIt->first == globalAlgoDim ) - smWithAlgoSupportingSubmeshes.push_back( shDim2smIt->second ); + smWithAlgoSupportingSubmeshes[ aShapeDim ].push_back( shDim2smIt->second ); else - smWithAlgoSupportingSubmeshes.push_front( shDim2smIt->second ); + smWithAlgoSupportingSubmeshes[ aShapeDim ].push_front( shDim2smIt->second ); shDim2sm.clear(); } // add smToCompute to shDim2sm map @@ -255,7 +265,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, } shDim2sm.insert( make_pair( aShapeDim, smToCompute )); } - else + else // Compute w/o support of sub-meshes { if (_compute_canceled) return false; @@ -270,86 +280,95 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, // reload sub-meshes from shDim2sm into smWithAlgoSupportingSubmeshes for ( shDim2smIt = shDim2sm.rbegin(); shDim2smIt != shDim2sm.rend(); ++shDim2smIt ) if ( shDim2smIt->first == globalAlgoDim ) - smWithAlgoSupportingSubmeshes.push_back( shDim2smIt->second ); + smWithAlgoSupportingSubmeshes[3].push_back( shDim2smIt->second ); else - smWithAlgoSupportingSubmeshes.push_front( shDim2smIt->second ); + smWithAlgoSupportingSubmeshes[0].push_front( shDim2smIt->second ); - // ------------------------------------------------------------ - // sort list of submeshes according to mesh order - // ------------------------------------------------------------ - aMesh.SortByMeshOrder( smWithAlgoSupportingSubmeshes ); + // ====================================================== + // Apply all-dimensional algorithms supporing sub-meshes + // ====================================================== - // ------------------------------------------------------------ - // compute submeshes under shapes with algos that DO NOT require - // Discreteized boundaries and DO support submeshes - // ------------------------------------------------------------ - list< SMESH_subMesh* >::iterator subIt, subEnd; - subIt = smWithAlgoSupportingSubmeshes.begin(); - subEnd = smWithAlgoSupportingSubmeshes.end(); - // start from lower shapes - for ( ; subIt != subEnd; ++subIt ) + for ( aShapeDim = 0; aShapeDim < 4; ++aShapeDim ) { - sm = *subIt; - - // get a shape the algo is assigned to - if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape )) - continue; // strange... - - // look for more local algos - smIt = sm->getDependsOnIterator(!includeSelf, !complexShapeFirst); - while ( smIt->more() ) + // ------------------------------------------------ + // sort list of sub-meshes according to mesh order + // ------------------------------------------------ + aMesh.SortByMeshOrder( smWithAlgoSupportingSubmeshes[ aShapeDim ] ); + + // ------------------------------------------------------------ + // compute sub-meshes with local uni-dimensional algos under + // sub-meshes with all-dimensional algos + // ------------------------------------------------------------ + list< SMESH_subMesh* >::iterator subIt, subEnd; + subIt = smWithAlgoSupportingSubmeshes[ aShapeDim ].begin(); + subEnd = smWithAlgoSupportingSubmeshes[ aShapeDim ].end(); + // start from lower shapes + for ( ; subIt != subEnd; ++subIt ) { - SMESH_subMesh* smToCompute = smIt->next(); + sm = *subIt; - const TopoDS_Shape& aSubShape = smToCompute->GetSubShape(); - const int aShapeDim = GetShapeDim( aSubShape ); - //if ( aSubShape.ShapeType() == TopAbs_VERTEX ) continue; - if ( aShapeDim < 1 ) continue; + // get a shape the algo is assigned to + if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape )) + continue; // strange... - // check for preview dimension limitations - if ( aShapesId && GetShapeDim( aSubShape.ShapeType() ) > (int)aDim ) - continue; - - SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() ); - filter - .And( SMESH_HypoFilter::IsApplicableTo( aSubShape )) - .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh )); - - if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) { - if ( ! subAlgo->NeedDiscreteBoundary() ) continue; - SMESH_Hypothesis::Hypothesis_Status status; - if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status )) - // mesh a lower smToCompute starting from vertices - Compute( aMesh, aSubShape, /*anUpward=*/true, aDim, aShapesId ); + // look for more local algos + smIt = sm->getDependsOnIterator(!includeSelf, !complexShapeFirst); + while ( smIt->more() ) + { + SMESH_subMesh* smToCompute = smIt->next(); + + const TopoDS_Shape& aSubShape = smToCompute->GetSubShape(); + const int aShapeDim = GetShapeDim( aSubShape ); + //if ( aSubShape.ShapeType() == TopAbs_VERTEX ) continue; + if ( aShapeDim < 1 ) continue; + + // check for preview dimension limitations + if ( aShapesId && GetShapeDim( aSubShape.ShapeType() ) > (int)aDim ) + continue; + + SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() ); + filter + .And( SMESH_HypoFilter::IsApplicableTo( aSubShape )) + .And( SMESH_HypoFilter::IsMoreLocalThan( algoShape, aMesh )); + + if ( SMESH_Algo* subAlgo = (SMESH_Algo*) aMesh.GetHypothesis( aSubShape, filter, true )) { + if ( ! subAlgo->NeedDiscreteBoundary() ) continue; + SMESH_Hypothesis::Hypothesis_Status status; + if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status )) + // mesh a lower smToCompute starting from vertices + Compute( aMesh, aSubShape, aShapeOnly, /*anUpward=*/true, aDim, aShapesId ); + } } } - } - // ---------------------------------------------------------- - // apply the algos that do not require Discreteized boundaries - // ---------------------------------------------------------- - for ( subIt = smWithAlgoSupportingSubmeshes.begin(); subIt != subEnd; ++subIt ) - { - sm = *subIt; - if ( sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) + // -------------------------------- + // apply the all-dimensional algos + // -------------------------------- + subIt = smWithAlgoSupportingSubmeshes[ aShapeDim ].begin(); + for ( ; subIt != subEnd; ++subIt ) { - const TopAbs_ShapeEnum aShType = sm->GetSubShape().ShapeType(); - // check for preview dimension limitations - if ( aShapesId && GetShapeDim( aShType ) > (int)aDim ) - continue; + sm = *subIt; + if ( sm->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) + { + const TopAbs_ShapeEnum shapeType = sm->GetSubShape().ShapeType(); + // check for preview dimension limitations + if ( aShapesId && GetShapeDim( shapeType ) > (int)aDim ) + continue; - if (_compute_canceled) - return false; - _sm_current = sm; - sm->ComputeStateEngine( computeEvent ); - _sm_current = NULL; - if ( aShapesId ) - aShapesId->insert( sm->GetId() ); + if (_compute_canceled) + return false; + _sm_current = sm; + sm->ComputeStateEngine( computeEvent ); + _sm_current = NULL; + if ( aShapesId ) + aShapesId->insert( sm->GetId() ); + } } - } + } // loop on shape dimensions + // ----------------------------------------------- // mesh the rest sub-shapes starting from vertices // ----------------------------------------------- - ret = Compute( aMesh, aShape, /*anUpward=*/true, aDim, aShapesId ); + ret = Compute( aMesh, aShape, aShapeOnly, /*anUpward=*/true, aDim, aShapesId ); } MESSAGE( "VSR - SMESH_Gen::Compute() finished, OK = " << ret); @@ -433,12 +452,12 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh, SMESH_subMesh* smToCompute = smIt->next(); // do not mesh vertices of a pseudo shape - const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType(); - //if ( !aMesh.HasShapeToMesh() && aShType == TopAbs_VERTEX ) + const TopAbs_ShapeEnum shapeType = smToCompute->GetSubShape().ShapeType(); + //if ( !aMesh.HasShapeToMesh() && shapeType == TopAbs_VERTEX ) // continue; if ( !aMesh.HasShapeToMesh() ) { - if( aShType == TopAbs_VERTEX || aShType == TopAbs_WIRE || - aShType == TopAbs_SHELL ) + if( shapeType == TopAbs_VERTEX || shapeType == TopAbs_WIRE || + shapeType == TopAbs_SHELL ) continue; } @@ -451,8 +470,8 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh, else { // ----------------------------------------------------------------- // apply algos that DO NOT require Discreteized boundaries and DO NOT - // support submeshes, starting from the most complex shapes - // and collect submeshes with algos that DO support submeshes + // support sub-meshes, starting from the most complex shapes + // and collect sub-meshes with algos that DO support sub-meshes // ----------------------------------------------------------------- list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes; smIt = sm->getDependsOnIterator(includeSelf, complexShapeFirst); @@ -481,8 +500,8 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh, aMesh.SortByMeshOrder( smWithAlgoSupportingSubmeshes ); // ------------------------------------------------------------ - // compute submeshes under shapes with algos that DO NOT require - // Discreteized boundaries and DO support submeshes + // compute sub-meshes under shapes with algos that DO NOT require + // Discreteized boundaries and DO support sub-meshes // ------------------------------------------------------------ list< SMESH_subMesh* >::iterator subIt, subEnd; subIt = smWithAlgoSupportingSubmeshes.begin(); @@ -505,8 +524,6 @@ bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh, const int aShapeDim = GetShapeDim( aSubShape ); if ( aShapeDim < 1 ) continue; - //const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType(); - SMESH_HypoFilter filter( SMESH_HypoFilter::IsAlgo() ); filter .And( SMESH_HypoFilter::IsApplicableTo( aSubShape )) @@ -613,7 +630,9 @@ static bool checkConformIgnoredAlgos(SMESH_Mesh& aMesh, theErrors.back().Set( SMESH_Hypothesis::HYP_NOTCONFORM, algo, false ); } - // sub-algos will be hidden by a local + // sub-algos will be hidden by a local if does not support sub-meshes + if ( algo->SupportSubmeshes() ) + algo = 0; SMESH_subMeshIteratorPtr revItSub = aSubMesh->getDependsOnIterator( /*includeSelf=*/false, /*complexShapeFirst=*/true); bool checkConform2 = false; @@ -650,9 +669,9 @@ static bool checkMissing(SMESH_Gen* aGen, { case TopAbs_EDGE: case TopAbs_FACE: - case TopAbs_SOLID: break; // check this submesh, it can be meshed + case TopAbs_SOLID: break; // check this sub-mesh, it can be meshed default: - return true; // not meshable submesh + return true; // not meshable sub-mesh } if ( aCheckedMap.count( aSubMesh )) return true; @@ -893,7 +912,6 @@ bool SMESH_Gen::GetAlgoState(SMESH_Mesh& theMesh, if ( !hasAlgo ) { ret = false; - INFOS( "None algorithm attached" ); theErrors.push_back( TAlgoStateError() ); theErrors.back().Set( SMESH_Hypothesis::HYP_MISSING, 1, true ); } @@ -961,7 +979,7 @@ std::vector< std::string > SMESH_Gen::GetPluginXMLPaths() sep = rootDir[pos]; break; } -#ifdef WNT +#ifdef WIN32 if (sep.empty() ) sep = "\\"; #else if (sep.empty() ) sep = "/"; @@ -976,7 +994,7 @@ std::vector< std::string > SMESH_Gen::GetPluginXMLPaths() xmlPath += tolower( pluginSubDir[pos] ); xmlPath += sep + plugin + ".xml"; bool fileOK; -#ifdef WNT +#ifdef WIN32 fileOK = (GetFileAttributes(xmlPath.c_str()) != INVALID_FILE_ATTRIBUTES); #else fileOK = (access(xmlPath.c_str(), F_OK) == 0);