+ MEMOSTAT;
+
+ SMESHDS_Mesh *myMesh = aMesh.GetMeshDS();
+ myMesh->adjustStructure();
+ MESSAGE("*** compactMesh after compute");
+ myMesh->compactMesh();
+ //myMesh->adjustStructure();
+ list<int> listind = myMesh->SubMeshIndices();
+ list<int>::iterator it = listind.begin();
+ int total = 0;
+ for(; it != listind.end(); ++it)
+ {
+ ::SMESHDS_SubMesh *subMesh = myMesh->MeshElements(*it);
+ total += subMesh->getSize();
+ }
+ MESSAGE("total elements and nodes in submesh sets:" << total);
+ MESSAGE("Number of node objects " << SMDS_MeshNode::nbNodes);
+ MESSAGE("Number of cell objects " << SMDS_MeshCell::nbCells);
+ //myMesh->dumpGrid();
+ //aMesh.GetMeshDS()->Modified();
+
+ // fix quadratic mesh by bending iternal links near concave boundary
+ if ( aShape.IsSame( aMesh.GetShapeToMesh() ) &&
+ !aShapesId ) // not preview
+ {
+ SMESH_MesherHelper aHelper( aMesh );
+ if ( aHelper.IsQuadraticMesh() != SMESH_MesherHelper::LINEAR )
+ aHelper.FixQuadraticElements();
+ }
+ return ret;
+}
+
+
+#ifdef WITH_SMESH_CANCEL_COMPUTE
+//=============================================================================
+/*!
+ * Prepare Compute a mesh
+ */
+//=============================================================================
+void SMESH_Gen::PrepareCompute(SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape)
+{
+ _compute_canceled = false;
+ _sm_current = NULL;
+}
+//=============================================================================
+/*!
+ * Cancel Compute a mesh
+ */
+//=============================================================================
+void SMESH_Gen::CancelCompute(SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape)
+{
+ _compute_canceled = true;
+ if(_sm_current)
+ {
+ _sm_current->ComputeStateEngine( SMESH_subMesh::COMPUTE_CANCELED );
+ }
+}
+#endif
+
+//=============================================================================
+/*!
+ * Evaluate a mesh
+ */
+//=============================================================================
+
+bool SMESH_Gen::Evaluate(SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape,
+ MapShapeNbElems& aResMap,
+ const bool anUpward,
+ TSetOfInt* aShapesId)
+{
+ MESSAGE("SMESH_Gen::Evaluate");
+
+ bool ret = true;
+
+ SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
+
+ const bool includeSelf = true;
+ const bool complexShapeFirst = true;
+ SMESH_subMeshIteratorPtr smIt;
+
+ if ( anUpward ) { // is called from below code here
+ // -----------------------------------------------
+ // 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 )
+ // continue;
+ if ( !aMesh.HasShapeToMesh() ) {
+ if( aShType == TopAbs_VERTEX || aShType == TopAbs_WIRE ||
+ aShType == TopAbs_SHELL )
+ continue;
+ }
+
+ smToCompute->Evaluate(aResMap);
+ if( aShapesId )
+ aShapesId->insert( smToCompute->GetId() );
+ }
+ return 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
+ // -----------------------------------------------------------------
+ list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes;
+ 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 ( aShapeDim < 1 ) break;
+
+ SMESH_Algo* algo = GetAlgo( aMesh, aSubShape );
+ if ( algo && !algo->NeedDiscreteBoundary() ) {
+ if ( algo->SupportSubmeshes() ) {
+ smWithAlgoSupportingSubmeshes.push_front( smToCompute );
+ }
+ else {
+ smToCompute->Evaluate(aResMap);
+ if ( aShapesId )
+ aShapesId->insert( smToCompute->GetId() );
+ }
+ }
+ }
+
+ // ------------------------------------------------------------
+ // sort list of meshes according to mesh order
+ // ------------------------------------------------------------
+ aMesh.SortByMeshOrder( smWithAlgoSupportingSubmeshes );
+
+ // ------------------------------------------------------------
+ // 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 ) {
+ sm = *subIt;
+
+ // get a shape the algo is assigned to
+ TopoDS_Shape algoShape;
+ if ( !GetAlgo( aMesh, sm->GetSubShape(), & algoShape ))
+ continue; // strange...
+
+ // 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 ( aShapeDim < 1 ) continue;
+
+ //const TopAbs_ShapeEnum aShType = smToCompute->GetSubShape().ShapeType();
+
+ 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 )) {
+ SMESH_Hypothesis::Hypothesis_Status status;
+ if ( subAlgo->CheckHypothesis( aMesh, aSubShape, status ))
+ // mesh a lower smToCompute starting from vertices
+ Evaluate( aMesh, aSubShape, aResMap, /*anUpward=*/true, aShapesId );
+ }
+ }
+ }
+ // ----------------------------------------------------------
+ // apply the algos that do not require Discreteized boundaries
+ // ----------------------------------------------------------
+ for ( subIt = smWithAlgoSupportingSubmeshes.begin(); subIt != subEnd; ++subIt )
+ {
+ sm = *subIt;
+ sm->Evaluate(aResMap);
+ if ( aShapesId )
+ aShapesId->insert( sm->GetId() );
+ }
+
+ // -----------------------------------------------
+ // mesh the rest sub-shapes starting from vertices
+ // -----------------------------------------------
+ ret = Evaluate( aMesh, aShape, aResMap, /*anUpward=*/true, aShapesId );
+ }
+
+ MESSAGE( "VSR - SMESH_Gen::Evaluate() finished, OK = " << ret);