SMESH_Homard.hxx
SMESH_DriverMesh.hxx
SMESH_DriverShape.hxx
+ SMESH_MeshLocker.hxx
)
# --- sources ---
SMESH_Homard.cxx
SMESH_DriverMesh.cxx
SMESH_DriverShape.cxx
+ SMESH_MeshLocker.cxx
)
# --- rules ---
/*!
* \brief Return a list of compatible hypotheses used to mesh a shape
- * \param aMesh - the mesh
+ * \param aMesh - the mesh
* \param aShape - the shape
* \param ignoreAuxiliary - do not include auxiliary hypotheses in the list
* \retval const std::list <const SMESHDS_Hypothesis*> - hypotheses list
- *
+ *
* List the hypothesis used by the algorithm associated to the shape.
* Hypothesis associated to father shape -are- taken into account (see
* GetAppliedHypothesis). Relevant hypothesis have a name (type) listed in
- * the algorithm. This method could be surcharged by specific algorithms, in
+ * the algorithm. This method could be surcharged by specific algorithms, in
* case of several hypothesis simultaneously applicable.
*/
virtual const std::list <const SMESHDS_Hypothesis *> &
// 6 - if algo !NeedDiscreteBoundary() but requires presence of
// hypotheses of dimension <dim> to generate all-dimensional mesh.
// This info is used not to issue warnings on hiding of lower global algos.
+ //
+
+ virtual void setSubMeshesToCompute(SMESH_subMesh * aSubMesh) {SubMeshesToCompute().assign( 1, aSubMesh );}
public:
// ==================================================================
- // Methods to track non hierarchical dependencies between submeshes
+ // Methods to track non hierarchical dependencies between submeshes
// ==================================================================
/*!
* By default none listener is set
*/
virtual void SetEventListener(SMESH_subMesh* subMesh);
-
+
/*!
* \brief Allow algo to do something after persistent restoration
* \param subMesh - restored submesh
* This method is called only if a submesh has HYP_OK algo_state.
*/
virtual void SubmeshRestored(SMESH_subMesh* subMesh);
-
+
public:
// ==================================================================
// Common algo utilities
enum EMeshError { MEr_OK = 0, MEr_HOLES, MEr_BAD_ORI, MEr_EMPTY };
/*!
- * \brief Finds topological errors of a sub-mesh
+ * \brief Finds topological errors of a sub-mesh
*/
static EMeshError GetMeshError(SMESH_subMesh* subMesh);
std::vector<std::string> _compatibleHypothesis;
std::list<const SMESHDS_Hypothesis *> _usedHypList;
std::list<TopoDS_Shape> _assigedShapeList; // _usedHypList assigned to
-
+
// Algo features influencing which Compute() and how is called:
// in what turn and with what input shape.
//
#include <utilities.h>
+#include <Utils_SALOME_Exception.hxx>
#include "SMESH_DriverShape.hxx"
// step include
Interface_Static::SetIVal("read.step.nonmanifold", 1);
IFSelect_ReturnStatus aStat = reader.ReadFile(shape_file.c_str());
if(aStat != IFSelect_RetDone){
- std::cerr << "Reading error for " << shape_file << std::endl;
- return true;
+ throw SALOME_Exception("Reading error for " + shape_file);
}
int NbTrans = reader.TransferRoots();
IFSelect_ReturnStatus aStat = aWriter.Transfer(aShape,STEPControl_AsIs);
if(aStat != IFSelect_RetDone){
- std::cerr << "Transfer error for " << shape_file << std::endl;
- return true;
+ throw SALOME_Exception("Reading error for " + shape_file);
}
aStat = aWriter.Write(shape_file.c_str());
if(aStat != IFSelect_RetDone){
- std::cerr << "Writing error for " << shape_file << std::endl;
- return true;
+ throw SALOME_Exception("Writing error for " + shape_file);
}
return aStat;
}
} else if (type == ".step"){
return importSTEPShape(shape_file, aShape);
} else {
- std::cerr << "Unknow format: " << type << std::endl;
- return true;
+ throw SALOME_Exception("Unknow format for importShape: " + type);
}
}
} else if (type == ".step"){
return exportSTEPShape(shape_file, aShape);
} else {
- std::cerr << "Unknow format: " << type << std::endl;
- return true;
+ throw SALOME_Exception("Unknow format for exportShape: " + type);
}
}
SMESH_Mesh();
SMESH_Mesh(const SMESH_Mesh&) {};
};
-
#endif
--- /dev/null
+// Copyright (C) 2007-2022 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
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : SMESH_MeshLocker.cxx
+// Author : Yoann AUDOUIN, EDF
+// Module : SMESH
+//
+
+#include "SMESH_MeshLocker.hxx"
+
+#include "SMESH_Mesh.hxx"
+
+SMESH_MeshLocker::SMESH_MeshLocker(SMESH_Mesh * aMesh) : _myMesh(aMesh)
+{
+ _myMesh->Lock();
+}
+
+SMESH_MeshLocker::~SMESH_MeshLocker()
+{
+ _myMesh->Unlock();
+}
--- /dev/null
+// Copyright (C) 2007-2022 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
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// File : SMESH_Mesh.hxx
+// Author : Paul RASCLE, EDF
+// Module : SMESH
+//
+#ifndef _SMESH_MESHLOCKER_HXX_
+#define _SMESH_MESHLOCKER_HXX_
+
+class SMESH_Mesh;
+
+class SMESH_MeshLocker{
+public:
+ SMESH_MeshLocker(SMESH_Mesh * aMesh);
+ ~SMESH_MeshLocker();
+
+protected:
+ SMESH_MeshLocker();
+
+private:
+ SMESH_Mesh * _myMesh=nullptr;
+};
+
+#endif
#include "SMESH_Mesh.hxx"
#include "SMESH_MesherHelper.hxx"
#include "SMESH_subMeshEventListener.hxx"
+#include "SMESH_MeshLocker.hxx"
#include "utilities.h"
#include "Basics_Utils.hxx"
else if (( event == COMPUTE || event == COMPUTE_SUBMESH )
&& !_alwaysComputed )
{
- // LOCK: Adding node to mesh
- _father->Lock();
+ SMESH_MeshLocker myLocker(_father);
const TopoDS_Vertex & V = TopoDS::Vertex( _subShape );
gp_Pnt P = BRep_Tool::Pnt(V);
if ( SMDS_MeshNode * n = _father->GetMeshDS()->AddNode(P.X(), P.Y(), P.Z()) ) {
_father->GetMeshDS()->SetNodeOnVertex(n,_Id);
_computeState = COMPUTE_OK;
}
- _father->Unlock();
- // UNLOCK
}
if ( event == MODIF_ALGO_STATE )
cleanDependants();
break;
}
TopoDS_Shape shape = _subShape;
- _father->Lock();
- algo->SubMeshesToCompute().assign( 1, this );
- _father->Unlock();
+ algo->setSubMeshesToCompute(this);
// check submeshes needed
// In parallel there would be no submesh to check
if (_father->HasShapeToMesh() && !_father->IsParallel()) {
#ifdef PRINT_WHO_COMPUTE_WHAT
for (subS.ReInit(); subS.More(); subS.Next())
{
- _father->Lock();
- const std::list <const SMESHDS_Hypothesis *> & hyps =
- _algo->GetUsedHypothesis( *_father, _subShape );
- _father->Unlock();
+ const std::list <const SMESHDS_Hypothesis *> & hyps
+ {
+ SMESH_MeshLocker myLocker(_father);
+ hyps = _algo->GetUsedHypothesis( *_father, _subShape );
+ }
SMESH_Comment hypStr;
if ( !hyps.empty() )
{