-// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
}
//=============================================================================
-/*!
+/*
* 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;
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() )
{
}
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() )
continue;
const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
- int aShapeDim = GetShapeDim( aSubShape );
+ aShapeDim = GetShapeDim( aSubShape );
if ( aShapeDim < 1 ) break;
// check for preview dimension limitations
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
}
shDim2sm.insert( make_pair( aShapeDim, smToCompute ));
}
- else
+ else // Compute w/o support of sub-meshes
{
if (_compute_canceled)
return false;
// 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();
-
- const TopoDS_Shape& aSubShape = smToCompute->GetSubShape();
- const int aShapeDim = GetShapeDim( aSubShape );
- //if ( aSubShape.ShapeType() == TopAbs_VERTEX ) continue;
- if ( aShapeDim < 1 ) continue;
+ sm = *subIt;
- // 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 ));
+ // get a shape the algo is assigned to
+ if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape ))
+ continue; // strange...
- 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 aShType = sm->GetSubShape().ShapeType();
+ // check for preview dimension limitations
+ if ( aShapesId && GetShapeDim( aShType ) > (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);
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);
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();
theErrors.back().Set( SMESH_Hypothesis::HYP_NOTCONFORM, algo, false );
}
- // sub-algos will be hidden by a local <algo>
+ // sub-algos will be hidden by a local <algo> if <algo> does not support sub-meshes
+ if ( algo->SupportSubmeshes() )
+ algo = 0;
SMESH_subMeshIteratorPtr revItSub =
aSubMesh->getDependsOnIterator( /*includeSelf=*/false, /*complexShapeFirst=*/true);
bool checkConform2 = false;
{
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;