diff --git a/src/SMESH/SMESH_Algo.cxx b/src/SMESH/SMESH_Algo.cxx index 582e554ee..215879d3c 100644 --- a/src/SMESH/SMESH_Algo.cxx +++ b/src/SMESH/SMESH_Algo.cxx @@ -281,6 +281,9 @@ SMESH_Algo::GetUsedHypothesis(SMESH_Mesh & aMesh, if ( _usedHypList == savedHyps ) savedHyps.swap( me->_usedHypList ); + for(auto hyp:_usedHypList){ + std::cout << hyp << std::endl; + } return _usedHypList; } diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 9f81f7494..a67b6f09b 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -262,6 +262,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, std::cout << "Waiting" << std::endl; it->wait(); } + cout << "Number of segments: " << aMesh.NbEdges() << endl; //Resetting threaded pool info previousShapeType = shapeType; pending.clear(); diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index d37172d90..cf6ba0b98 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -65,6 +65,7 @@ using namespace std; //#define PRINT_WHO_COMPUTE_WHAT #endif +#define PRINT_WHO_COMPUTE_WHAT //============================================================================= /*! * \brief Allocate some memory at construction and release it at destruction. @@ -206,6 +207,20 @@ SMESH_Algo* SMESH_subMesh::GetAlgo() const return _algo; } +//================================================================================ +/*! + * \brief Returns a current algorithm + */ +//================================================================================ + +SMESH_Algo* SMESH_subMesh::CopyAlgo() const +{ + //SMESH_Algo* algo = (SMESH_Algo*) new StdMeshers_Regular_1D(666, _father->GetGent()); + SMESH_Algo* algo; + + return algo; +} + //================================================================================ /*! * \brief Allow algo->Compute() if a sub-shape of lower dim is meshed but @@ -1392,6 +1407,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) else if (( event == COMPUTE || event == COMPUTE_SUBMESH ) && !_alwaysComputed ) { + // LOCK: Adding node to mesh _father->Lock(); const TopoDS_Vertex & V = TopoDS::Vertex( _subShape ); gp_Pnt P = BRep_Tool::Pnt(V); @@ -1400,6 +1416,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) _computeState = COMPUTE_OK; } _father->Unlock(); + // UNLOCK } if ( event == MODIF_ALGO_STATE ) cleanDependants(); @@ -1502,10 +1519,13 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) case COMPUTE: case COMPUTE_SUBMESH: { - _father->Lock(); algo = GetAlgo(); + SMESH_Algo* algo2 = CopyAlgo(); + cout << "Algo2" << algo2; ASSERT(algo); - ret = algo->CheckHypothesis((*_father), _subShape, hyp_status); + //_father->Lock(); + //ret = algo->CheckHypothesis((*_father), _subShape, hyp_status); + //_father->Unlock(); if (!ret) { MESSAGE("***** verify compute state *****"); @@ -1516,7 +1536,9 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) TopoDS_Shape shape = _subShape; algo->SubMeshesToCompute().assign( 1, this ); // check submeshes needed - if (_father->HasShapeToMesh() ) { + // Forcing to false for parallel run + // TODO: Remove forced false + if (_father->HasShapeToMesh() && false) { bool subComputed = false, subFailed = false; if (!algo->OnlyUnaryInput()) { // --- commented for bos#22320 to compute all sub-shapes at once if possible; @@ -1544,7 +1566,6 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) break; // goto exit } } - _father->Unlock(); // Compute // to restore cout that may be redirected by algo @@ -1647,8 +1668,10 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) #ifdef PRINT_WHO_COMPUTE_WHAT for (subS.ReInit(); subS.More(); subS.Next()) { - const std::list & hyps = + _father->Lock(); + const std::list hyps = _algo->GetUsedHypothesis( *_father, _subShape ); + _father->Unlock(); SMESH_Comment hypStr; if ( !hyps.empty() ) { @@ -1734,9 +1757,9 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) updateDependantsState( SUBMESH_COMPUTED ); } // let algo clear its data gathered while algo->Compute() - _father->Lock(); - algo->CheckHypothesis((*_father), _subShape, hyp_status); - _father->Unlock(); + //_father->Lock(); + //algo->CheckHypothesis((*_father), _subShape, hyp_status); + //_father->Unlock(); } break; case COMPUTE_CANCELED: // nothing to do @@ -2172,8 +2195,10 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * /*theGen*/, return _subShape; const bool skipAuxHyps = false; + _father->Lock(); list usedHyps = theAlgo->GetUsedHypothesis( *_father, _subShape, skipAuxHyps ); // copy + _father->Lock(); std::list < TopoDS_Shape > assiShapes = theAlgo->GetAssignedShapes(); // put in a compound all shapes with the same hypothesis assigned @@ -2201,6 +2226,7 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * /*theGen*/, } else if ( subMesh->GetComputeState() == READY_TO_COMPUTE ) { + _father->Lock(); SMESH_Algo* anAlgo = subMesh->GetAlgo(); if (( anAlgo->IsSameName( *theAlgo )) && // same algo ( anAlgo->GetUsedHypothesis( *_father, S, skipAuxHyps ) == usedHyps ) && // same hyps @@ -2212,6 +2238,7 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * /*theGen*/, theSubComputed = false; theSubs.push_back( subMesh ); } + _father->Unlock(); } } diff --git a/src/SMESH/SMESH_subMesh.hxx b/src/SMESH/SMESH_subMesh.hxx index fbfd222c2..0f925570a 100644 --- a/src/SMESH/SMESH_subMesh.hxx +++ b/src/SMESH/SMESH_subMesh.hxx @@ -69,7 +69,7 @@ class SMESH_EXPORT SMESH_subMesh int GetId() const; // == meshDS->ShapeToIndex( aSubShape ) SMESH_Mesh* GetFather() { return _father; } - + SMESHDS_SubMesh * GetSubMeshDS(); const SMESHDS_SubMesh * GetSubMeshDS() const; @@ -79,6 +79,7 @@ class SMESH_EXPORT SMESH_subMesh SMESH_subMesh *GetFirstToCompute(); SMESH_Algo* GetAlgo() const; + SMESH_Algo* CopyAlgo() const; const std::map < int, SMESH_subMesh * >& DependsOn(); bool DependsOn( const SMESH_subMesh* other ) const; @@ -123,7 +124,7 @@ class SMESH_EXPORT SMESH_subMesh }; // ================================================================== - // Members to track non hierarchical dependencies between sub-meshes + // Members to track non hierarchical dependencies between sub-meshes // ================================================================== /*! @@ -131,7 +132,7 @@ class SMESH_EXPORT SMESH_subMesh * \param listener - the listener to store * \param data - the listener data to store * \param where - the submesh to store the listener and it's data - * + * * The method remembers the submesh \awhere it puts the listener in order to delete * it when HYP_OK algo_state is lost * After being set, event listener is notified on each event of \awhere submesh. @@ -185,7 +186,7 @@ protected: * \brief Sets an event listener and its data to a submesh * \param listener - the listener to store * \param data - the listener data to store - * + * * After being set, event listener is notified on each event of a submesh. */ void setEventListener(EventListener* listener, EventListenerData* data); @@ -245,7 +246,7 @@ public: bool IsApplicableHypothesis(const SMESH_Hypothesis* theHypothesis) const; // return true if theHypothesis can be used to mesh me: // its shape type is checked - + SMESH_Hypothesis::Hypothesis_Status CheckConcurrentHypothesis (SMESH_Hypothesis* theHypothesis); // check if there are several applicable hypothesis on fathers @@ -277,7 +278,7 @@ public: int GetComputeCost() const; // how costly is to compute this sub-mesh - + /*! * \brief Find common submeshes (based on shared subshapes with other * \param theOther submesh to check @@ -319,7 +320,7 @@ protected: /*! * \brief Return a hypothesis attached to theShape. - * + * * If theHyp is provided, similar but not same hypotheses * is returned; else an applicable ones having theHypType * is returned @@ -327,7 +328,7 @@ protected: const SMESH_Hypothesis* getSimilarAttached(const TopoDS_Shape& theShape, const SMESH_Hypothesis * theHyp, const int theHypType = 0); - // + // int computeCost() const; protected: diff --git a/src/StdMeshers/StdMeshers_Regular_1D.cxx b/src/StdMeshers/StdMeshers_Regular_1D.cxx index bd20e30fa..c26113ab3 100644 --- a/src/StdMeshers/StdMeshers_Regular_1D.cxx +++ b/src/StdMeshers/StdMeshers_Regular_1D.cxx @@ -126,14 +126,22 @@ bool StdMeshers_Regular_1D::CheckHypothesis( SMESH_Mesh& aMesh, _onlyUnaryInput = true; // check propagation in a redefined GetUsedHypothesis() - const list & hyps = + const list hyps = GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliaryHyps=*/false); - const SMESH_HypoFilter & propagFilter = StdMeshers_Propagation::GetFilter(); // find non-auxiliary hypothesis const SMESHDS_Hypothesis *theHyp = 0; set< string > propagTypes; + std::cout << "For shape " << aShape.HashCode(1) << " of type "<< aShape.ShapeType() << + "CheckHypothesis" << std::endl; + for(auto hyp:hyps){ + SMESH_Comment hypStr; + hypStr << hyp << " " << hyp->GetName() << " "; + ((SMESHDS_Hypothesis*)hyp)->SaveTo( hypStr.Stream() ); + hypStr << " "; + std::cout << hypStr << std::endl; + } list ::const_iterator h = hyps.begin(); for ( ; h != hyps.end(); ++h ) { if ( static_cast(*h)->IsAuxiliary() ) { @@ -848,8 +856,12 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh, { // Number Of Segments hypothesis nbSegments = _ivalue[ NB_SEGMENTS_IND ]; - if ( nbSegments < 1 ) return false; - if ( nbSegments == 1 ) return true; + if ( nbSegments < 1 ) { + return false; + } + if ( nbSegments == 1 ) { + return true; + } switch (_ivalue[ DISTR_TYPE_IND ]) { @@ -1170,10 +1182,16 @@ bool StdMeshers_Regular_1D::computeInternalParameters(SMESH_Mesh & theMesh, bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & theShape) { - if ( _hypType == NONE ) - return false; + SMESH_Hypothesis::Hypothesis_Status hyp_status; + theMesh.Lock(); + bool ret = this->CheckHypothesis(theMesh, theShape, hyp_status); + int hypType = _hypType; + theMesh.Unlock(); - if ( _hypType == ADAPTIVE ) + if ( hypType == NONE ) + return false; + + if ( hypType == ADAPTIVE ) { _adaptiveHyp->GetAlgo()->InitComputeError(); _adaptiveHyp->GetAlgo()->Compute( theMesh, theShape ); @@ -1183,6 +1201,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t SMESHDS_Mesh * meshDS = theMesh.GetMeshDS(); theMesh.Lock(); + const TopoDS_Edge & EE = TopoDS::Edge(theShape); TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); int shapeID = meshDS->ShapeToIndex( E ); @@ -1199,6 +1218,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t const SMDS_MeshNode * nLast = SMESH_Algo::VertexNode( VLast, meshDS ); if ( !nFirst || !nLast ){ theMesh.Unlock(); + std::cout << "exit no node" << std::endl; return error( COMPERR_BAD_INPUT_MESH, "No node on vertex"); } // remove elements created by e.g. pattern mapping (PAL21999) @@ -1232,7 +1252,7 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t // take into account reversing the edge the hypothesis is propagated from // (_mainEdge.Orientation() marks mutual orientation of EDGEs in propagation chain) reversed = ( _mainEdge.Orientation() == TopAbs_REVERSED ); - if ( _hypType != DISTRIB_PROPAGATION ) { + if ( hypType != DISTRIB_PROPAGATION ) { int mainID = meshDS->ShapeToIndex(_mainEdge); if ( std::find( _revEdgesIDs.begin(), _revEdgesIDs.end(), mainID) != _revEdgesIDs.end()) reversed = !reversed; @@ -1245,6 +1265,8 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t BRepAdaptor_Curve C3d( E ); if ( ! computeInternalParameters( theMesh, C3d, length, f, l, params, reversed, true )) { theMesh.Unlock(); + std::cout << "exit Compute internal failed" << std::endl; + return false; } redistributeNearVertices( theMesh, C3d, length, params, VFirst, VLast ); @@ -1336,6 +1358,8 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t } } theMesh.Unlock(); + std::cout << "exit normal" << std::endl; + return true; }