salome.salome_init()
import GEOM
from salome.geom import geomBuilder
-geompy = geomBuilder.New(salome.myStudy)
+geompy = geomBuilder.New()
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New(salome.myStudy)
+smesh = smeshBuilder.New()
# create a box
box = geompy.MakeBoxDXDYDZ(200., 200., 200.)
# Retrieve and print the list of enforced vertices defines on Face_1
enfList = algo2d.GetEnforcedVertices(Face_1)
- print "List of enforced vertices for Face_1: "
- print enfList
+ print("List of enforced vertices for Face_1: ")
+ print(enfList)
# compute the mesh
cadsurfMesh.Compute()
# Remove an enforced vertex and print the list
algo2d.UnsetEnforcedVertex(Face_1, 50, 50, 50)
enfList = algo2d.GetEnforcedVertices(Face_1)
- print "List of enforced vertices for Face_1: "
- print enfList
+ print("List of enforced vertices for Face_1: ")
+ print(enfList)
# compute the mesh
cadsurfMesh.Compute()
def __init__(self, mesh, geom=0):
Mesh_Algorithm.__init__(self)
if noBLSURFPlugin:
- print "Warning: BLSURFPlugin module unavailable"
+ print("Warning: BLSURFPlugin module unavailable")
if mesh.GetMesh().HasShapeToMesh():
self.Create(mesh, geom, self.algoType, LIBRARY)
else:
# <li>PreCAD - by pre-processing with PreCAD a CAD model</li></ul>
def SetTopology(self, way):
if way != PreCAD and way != FromCAD:
- print "Warning: topology mode %d is no longer supported. Mode FromCAD is used."%way
+ print("Warning: topology mode %d is no longer supported. Mode FromCAD is used."%way)
way = FromCAD
self.Parameters().SetTopology(way)
pass
def SetJacobianRectification( self, allowRectification ):
self.Parameters().SetJacobianRectification( allowRectification )
+ ## Set use_deprecated_patch_mesher parameter (compatibility with older versions of Meshgems)
+ #
+ # the use_deprecated_patch_mesher parameter allows to keep the same behaviour than
+ # in salome < 8.3 (meshgems 2.1.11 instead of meshgems >= 2.4.5)
+ #
+ def SetUseDeprecatedPatchMesher( self, useDeprecatedPatchMesher ):
+ self.Parameters().SetUseDeprecatedPatchMesher( useDeprecatedPatchMesher )
+
## Set respect_geometry parameter
#
# This patch independent option can be deactivated to allow MeshGems-CADSurf
for f in faces:
ids.append( self.mesh.geompyD.GetSubShapeID( self.mesh.geom, f ))
else:
- raise TypeError, \
- "Face of hyper-patch should be either ID or GEOM_Object, not %s" % type(face)
+ raise TypeError("Face of hyper-patch should be either ID or GEOM_Object, not %s" % type(face))
pass
hpl.append( ids )
pass
"""
Obsolete function. Use SetMinSize.
"""
- print "Warning: SetPhyMin is obsolete. Please use SetMinSize"
+ print("Warning: SetPhyMin is obsolete. Please use SetMinSize")
self.SetMinSize(theVal)
pass
"""
Obsolete function. Use SetMaxSize.
"""
- print "Warning: SetPhyMax is obsolete. Please use SetMaxSize"
+ print("Warning: SetPhyMax is obsolete. Please use SetMaxSize")
self.SetMaxSize(theVal)
pass
"""
Obsolete function. Use SetAngleMesh.
"""
- print "Warning: SetAngleMeshS is obsolete. Please use SetAngleMesh"
+ print("Warning: SetAngleMeshS is obsolete. Please use SetAngleMesh")
self.SetAngleMesh(theVal)
pass
"""
Obsolete function. Use SetAngleMesh.
"""
- print "Warning: SetAngleMeshC is obsolete. Please use SetAngleMesh"
+ print("Warning: SetAngleMeshC is obsolete. Please use SetAngleMesh")
self.SetAngleMesh(theVal)
pass
"""
Obsolete function. Use SetMinSize.
"""
- print "Warning: SetGeoMin is obsolete. Please use SetMinSize"
+ print("Warning: SetGeoMin is obsolete. Please use SetMinSize")
self.SetMinSize(theVal)
pass
"""
Obsolete function. Use SetMaxSize.
"""
- print "Warning: SetGeoMax is obsolete. Please use SetMaxSize"
+ print("Warning: SetGeoMax is obsolete. Please use SetMaxSize")
self.SetMaxSize(theVal)
pass
static PyTypeObject PyStdOut_Type = {
/* The ob_type field must be initialized in the module init function
* to be portable to Windows without using C++. */
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"PyOut", /*tp_name*/
sizeof(PyStdOut), /*tp_basicsize*/
0, /*tp_itemsize*/
//=============================================================================
BLSURFPlugin_BLSURF::BLSURFPlugin_BLSURF(int hypId,
- int studyId,
SMESH_Gen* gen,
bool theHasGEOM)
- : SMESH_2D_Algo(hypId, studyId, gen)
+ : SMESH_2D_Algo(hypId, gen)
{
_name = theHasGEOM ? "MG-CADSurf" : "MG-CADSurf_NOGEOM";//"BLSURF";
_shapeType = (1 << TopAbs_FACE); // 1 bit /shape type
_supportSubmeshes = true;
_requireShape = theHasGEOM;
- smeshGen_i = SMESH_Gen_i::GetSMESHGen();
- CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
- SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
-
- myStudy = NULL;
- myStudy = aStudyMgr->GetStudyByID(_studyId);
-
/* Initialize the Python interpreter */
assert(Py_IsInitialized());
PyGILState_STATE gstate;
/////////////////////////////////////////////////////////
TopoDS_Shape BLSURFPlugin_BLSURF::entryToShape(std::string entry)
{
- TopoDS_Shape S;
- if ( !entry.empty() )
- {
- GEOM::GEOM_Object_var aGeomObj;
- SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
- if (!aSObj->_is_nil()) {
- CORBA::Object_var obj = aSObj->GetObject();
- aGeomObj = GEOM::GEOM_Object::_narrow(obj);
- aSObj->UnRegister();
- }
- if ( !aGeomObj->_is_nil() )
- S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
+ GEOM::GEOM_Object_var aGeomObj;
+ TopoDS_Shape S = TopoDS_Shape();
+ SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.c_str() );
+ if (!aSObj->_is_nil()) {
+ CORBA::Object_var obj = aSObj->GetObject();
+ aGeomObj = GEOM::GEOM_Object::_narrow(obj);
+ aSObj->UnRegister();
}
+ if ( !aGeomObj->_is_nil() )
+ S = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( aGeomObj.in() );
return S;
}
//int _precadProcess3DTopology = BLSURFPlugin_Hypothesis::GetDefaultPreCADProcess3DTopology();
//int _precadDiscardInput = BLSURFPlugin_Hypothesis::GetDefaultPreCADDiscardInput();
+ const BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector preCadFacesPeriodicityVector = BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(hyp);
if (hyp) {
_physicalMesh = (int) hyp->GetPhysicalMesh();
const BLSURFPlugin_Hypothesis::TOptionValues& opts = hyp->GetOptionValues();
BLSURFPlugin_Hypothesis::TOptionValues::const_iterator opIt;
- for ( opIt = opts.begin(); opIt != opts.end(); ++opIt )
+ for ( opIt = opts.begin(); opIt != opts.end(); ++opIt ){
+ MESSAGE("OptionValue: " << opIt->first.c_str() << ", value: " << opIt->second.c_str());
if ( !opIt->second.empty() ) {
- set_param(css, opIt->first.c_str(), opIt->second.c_str());
+ // With MeshGems 2.4-5, there are issues with periodicity and multithread
+ // => As a temporary workaround, we enforce to use only one thread if periodicity is used.
+ if (opIt->first == "max_number_of_threads" && opIt->second != "1" && ! preCadFacesPeriodicityVector.empty()){
+ std::cout << "INFO: Disabling multithread to avoid periodicity issues" << std::endl;
+ set_param(css, opIt->first.c_str(), "1");
+ }
+ else
+ set_param(css, opIt->first.c_str(), opIt->second.c_str());
}
+ }
const BLSURFPlugin_Hypothesis::TOptionValues& custom_opts = hyp->GetCustomOptionValues();
for ( opIt = custom_opts.begin(); opIt != custom_opts.end(); ++opIt )
_preCadFacesIDsPeriodicityVector.clear();
_preCadEdgesIDsPeriodicityVector.clear();
- const BLSURFPlugin_Hypothesis::TPreCadPeriodicityVector preCadFacesPeriodicityVector = BLSURFPlugin_Hypothesis::GetPreCadFacesPeriodicityVector(hyp);
-
for (std::size_t i = 0; i<preCadFacesPeriodicityVector.size(); i++){
createPreCadFacesPeriodicity(theGeomShape, preCadFacesPeriodicityVector[i]);
}
// cout << o.str() << endl;
if (_preCadFacesIDsPeriodicityVector[i].theSourceVerticesCoords.empty())
{
- // If no source points, call peridoicity without transformation function
+ // If no source points, call periodicity without transformation function
meshgems_cad_periodicity_transformation_t periodicity_transformation = NULL;
status = cad_add_face_multiple_periodicity_with_transformation_function(c, theFace1_ids_c, theFace1_ids.size(),
theFace2_ids_c, theFace2_ids.size(), periodicity_transformation, NULL);
for (std::size_t i=0; i < _preCadEdgesIDsPeriodicityVector.size(); i++){
std::vector<int> theEdge1_ids = _preCadEdgesIDsPeriodicityVector[i].shape1IDs;
std::vector<int> theEdge2_ids = _preCadEdgesIDsPeriodicityVector[i].shape2IDs;
- // Use the address of the first element of the vector to initialise the array
+ // Use the address of the first element of the vector to initialize the array
int* theEdge1_ids_c = &theEdge1_ids[0];
int* theEdge2_ids_c = &theEdge2_ids[0];
if (_preCadEdgesIDsPeriodicityVector[i].theSourceVerticesCoords.empty())
{
- // If no source points, call peridoicity without transformation function
+ // If no source points, call periodicity without transformation function
meshgems_cad_periodicity_transformation_t periodicity_transformation = NULL;
status = cad_add_edge_multiple_periodicity_with_transformation_function(c, theEdge1_ids_c, theEdge1_ids.size(),
theEdge2_ids_c, theEdge2_ids.size(), periodicity_transformation, NULL);
static PyTypeObject PyStdOut_Type = {
/* The ob_type field must be initialized in the module init function
* to be portable to Windows without using C++. */
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
+ PyVarObject_HEAD_INIT(NULL, 0)
"PyOut", /*tp_name*/
sizeof(PyStdOut), /*tp_basicsize*/
0, /*tp_itemsize*/
GeomSelectionTools* BLSURFPluginGUI_HypothesisCreator::getGeomSelectionTool() const
{
BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
- if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
- that->GeomToolSelected = new GeomSelectionTools(aStudy);
+ if (that->GeomToolSelected == NULL) {
+ that->GeomToolSelected = new GeomSelectionTools();
}
return that->GeomToolSelected;
}
myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
- GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
+ GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
if (CORBA::is_nil(measureOp))
return;
if ( CORBA::is_nil(getGeomEngine()))
return;
- GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
+ GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations();
if (CORBA::is_nil(measureOp))
return;
CORBA::Object_var BLSURFPluginGUI_HypothesisCreator::entryToObject(QString entry)
{
- SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::Study_var myStudy = smeshGen_i->GetCurrentStudy();
CORBA::Object_var obj;
- SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.toStdString().c_str() );
+ SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.toStdString().c_str() );
if (!aSObj->_is_nil()) {
obj = aSObj->GetObject();
aSObj->UnRegister();
import GEOM
from salome.geom import geomBuilder
-geompy = geomBuilder.New(salome.myStudy)
+geompy = geomBuilder.New()
O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
import SMESH
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New(salome.myStudy)
+smesh = smeshBuilder.New()
Mesh = smesh.Mesh(part, "Mesh")
non_coincident_nodes = list(set(mesh_nodes) - set(coincident_nodes))
mesh_check.MakeGroupByIds("non_coincident_nodes", SMESH.NODE, non_coincident_nodes)
#raise Exception("Projection failed for %s"%name)
- print "Projection failed for %s"%name
+ print("Projection failed for %s"%name)
checkProjection(gr_right, bottom_rotated)
-#salome.myStudyManager.SaveAs("test.hdf", salome.myStudy, 0)
+#salome.myStudy.SaveAs("test.hdf", 0, 0)
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(True)
+ salome.sg.updateObjBrowser()
import salome
salome.salome_init()
-theStudy = salome.myStudy
###
### GEOM component
import SALOMEDS
-geompy = geomBuilder.New(theStudy)
+geompy = geomBuilder.New()
# Create a box
box = geompy.MakeBoxDXDYDZ(100, 100, 100)
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New(theStudy)
+smesh = smeshBuilder.New()
Mesh_1 = smesh.Mesh(part, "Mesh_part")
BLSURF = Mesh_1.Triangle(algo=smeshBuilder.BLSURF)
BLSURF_Parameters_1 = BLSURF.Parameters()
# Check the minimal area of the box faces to check the proximity
min_area, max_area = Mesh_1.GetMinMax(SMESH.FT_Area, gr_mesh_box)
- print "min_area: ", min_area
+ print("min_area: ", min_area)
if min_area > 1.5:
raise Exception("Wrong minimal area on box. Proximity has not worked.")
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(True)
+ salome.sg.updateObjBrowser()
import GEOM
from salome.geom import geomBuilder
-geompy = geomBuilder.New(salome.myStudy)
+geompy = geomBuilder.New()
import math
import SMESH
from salome.smesh import smeshBuilder
-smesh = smeshBuilder.New(salome.myStudy)
+smesh = smeshBuilder.New()
Mesh = smesh.Mesh(part, "Mesh")
min_length = min(edges_length)
x1, y1, z1 = Mesh.GetNodeXYZ(node)
- print min_length
+ print(min_length)
if min_length<tiny_edge_length:
raise Exception("Small edge has not been removed")
if salome.sg.hasDesktop():
- salome.sg.updateObjBrowser(True)
+ salome.sg.updateObjBrowser()