From 08485b06fa309a40c3769a9113c2b88dd26e103d Mon Sep 17 00:00:00 2001 From: Yoann Audouin Date: Fri, 23 Sep 2022 13:47:18 +0200 Subject: [PATCH] Working version of dual_meshing (using medcoupling) functionality --- idl/SMESH_Gen.idl | 2 +- resources/CMakeLists.txt | 1 + resources/mesh_create_dual_mesh.png | Bin 0 -> 13290 bytes src/SMESHGUI/SMESHGUI.cxx | 4 +- src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.cxx | 10 +++ src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.h | 6 ++ src/SMESHGUI/SMESHGUI_CreateDualMeshOp.cxx | 17 +++-- src/SMESHGUI/SMESH_images.ts | 4 ++ src/SMESHGUI/SMESH_msg_en.ts | 31 ++++++++ src/SMESH_I/SMESH_Gen_i.cxx | 60 +++++----------- src/SMESH_SWIG/CMakeLists.txt | 3 +- src/SMESH_SWIG/smeshBuilder.py | 7 +- src/SMESH_SWIG/smesh_tools.py | 74 ++++++++++++++++++++ test/SMESH_create_dual_mesh.py | 61 ++++++++++++++++ test/tests.set | 1 + 15 files changed, 223 insertions(+), 58 deletions(-) create mode 100644 resources/mesh_create_dual_mesh.png create mode 100644 src/SMESH_SWIG/smesh_tools.py create mode 100644 test/SMESH_create_dual_mesh.py diff --git a/idl/SMESH_Gen.idl b/idl/SMESH_Gen.idl index e9b678031..010525eaf 100644 --- a/idl/SMESH_Gen.idl +++ b/idl/SMESH_Gen.idl @@ -286,7 +286,7 @@ module SMESH raises ( SALOME::SALOME_Exception ); /*! * Create a dual mesh of a Tetrahedron mesh - * \param meshPart - TetraHedron mesh to create dual from + * \param mesh - TetraHedron mesh to create dual from * \param meshName - a name of the new mesh */ SMESH_Mesh CreateDualMesh(in SMESH_IDSource mesh, diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 8f5bdb415..b2be7d8b8 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -60,6 +60,7 @@ SET(SMESH_RESOURCES_FILES mesh_conv_to_quad.png mesh_cutGroups.png mesh_cutquad.png + mesh_create_dual_mesh.png mesh_deflection.png mesh_deleteGroups.png mesh_diagonal.png diff --git a/resources/mesh_create_dual_mesh.png b/resources/mesh_create_dual_mesh.png new file mode 100644 index 0000000000000000000000000000000000000000..d7a7be370f98331c7c471dd0b9c54eff04be653e GIT binary patch literal 13290 zcmYj&1yoes7w<5158d4zA|OZ%sWga`bf<(vcMm10gmf$2DBU3`AtFc!(jgKO;yd`g z|66a?8iu)ZTmRL}*MVvZ%4SZm`Ju-X& zf#8zdy-^@p*_2=-CgQQWBIXZlYAim1wpVp+5C|jWu>xGzXYs(qNsCl}@i3Q$MGnav z`+=De=Q(Y-dDSC5)J^o^cTK7VY((MJ)59f5p;F8DZ^VVn*h*h3gyW!jvruB2a_W$M z!SmsYr)F(J4!RdH7KTu_=M&?tcXwY{En%ZvAtu$#H1dM-%M`g9@i%*Y7*k0T15LXkD(I%5@ zfWuKL3Bgu)d1a;b2VH%A%)Rflv2k(u7~$%1Um6`!2P{z}Aj1%Kb#=A$pvz4P0|t&- z%YoR&#>Tv$tC91e_V#wgIP&GLV1{i-h$Kv)nn^yY`${~vxVSj@@AZmaMbnX)p1!`F zt*y#)7S5LhUi%9|>%j|kR+#%5dZ*{-!X{b5HaL}u@`BU}o12^A{0^q3xyz;y2^cCi zHuh1+Med(O@YmGZnsr~hY{z`D(Vq1R9G{?|fkkUM+^;xNliwlybx35n* zkscqxC^h==V}cS(WuI)egeQ*s)3TW!Vt2T$?T^fRb}+Hl_wTEowP>82p-K4c(r;~S z?5}h&ye?$W$bC4{>Zx1n+iGOM5PTzKBy7;(=V@$AD~`KvF`jiFS)o^PmLT@6ys9el z;46ig>o@BU#d;MMf#M&qO-xLXG|Vh4LP8p33Ybbo(=#(9?(+Kj`f6%;?3Wf9`5hfO zJH)JXZg3qP9VaKAbqoQ4n)P){HR-CbZP~IJ8#}wA6^BH6sjLSt*qtpUVJfXkMWJUF zukgUF5Q*7~WaUVDue0=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!Pm;t8TBWy5HseXRlRRf3%xL@Ewfzz(1 zr-kwcD6;R;1nnlWflBx~ElrEGWX=)PDI2_(okoCY4Edtd3y99=8ndIRE}iOzyG;-< z&loGg;|FvP(ZNK4Dn_iggKA7EsK{Q{a4liF7od|fUrw_Sxn|N zP#l7+xH|^;MbV0P4*~!K#rlK7j0k9lEG7=L(2Bzi1+pz`D68gnads9dg#wY#!U3fm z%u7<9ySfV`g(ysHppLTp3POiPfWEen^uPzbMuO3&imofA-T zMPu|!6}5a4Si^IxaaV5VKlc z0RiO-R2fDrGqTf5`Jvr4h7FKuVES|g__(?rfkHyqr&S1KzyTANoOhwk+ZB|oA0&bb zpMik^*b@kZGgim)+A+LG%h(uiMGBIS*n@;%{}Xp02na-r6jbLj-(kSf2bSFRB|1insert( separator(), -1, 0 ); createPopupItem( SMESHOp::OpConvertMeshToQuadratic, OB, mesh_submesh, "&& " + hasElems ); createPopupItem( SMESHOp::OpCreateBoundaryElements, OB, mesh_group, "&& selcount=1 && dim>=2"); - createPopupItem( SMESHOp::OpCreateDualMesh, OB, mesh_submesh, "&& selcount=1 && dim>=2"); // Adaptation - begin popupMgr()->insert( separator(), -1, 0 ); diff --git a/src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.cxx index 614220058..da67de1aa 100644 --- a/src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #define SPACING 6 #define MARGIN 11 @@ -54,6 +55,12 @@ SMESHGUI_CreateDualMeshDlg::SMESHGUI_CreateDualMeshDlg() setObjectPixmap( "SMESH", tr( "ICON_SELECT" ) ); createObject( tr( "MESH" ), mainFrame(), 0 ); + myMeshNameLabel = new QLabel(QString(tr("DUAL_MESH_NAME")), mainFrame()); + myMeshName = new QLineEdit(mainFrame()); + + myProjShape = new QCheckBox(QString(tr("PROJ_SHAPE")), mainFrame()); + myProjShape->toggle(); + myWarning = new QLabel(QString("%1").arg(tr("NON_TETRA_MESH_WARNING")), mainFrame()); // Fill layout @@ -65,6 +72,9 @@ SMESHGUI_CreateDualMeshDlg::SMESHGUI_CreateDualMeshDlg() aLay->addWidget( objectWg( 0, Btn ), 0, 1 ); aLay->addWidget( objectWg( 0, Control ), 0, 2 ); aLay->addWidget( myWarning, 3, 0, 1, 3 ); + aLay->addWidget( myMeshNameLabel, 1, 0 ); + aLay->addWidget( myMeshName, 1, 2 ); + aLay->addWidget( myProjShape, 2, 0 ); } diff --git a/src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.h b/src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.h index e5096b237..83b2a959c 100644 --- a/src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.h +++ b/src/SMESHGUI/SMESHGUI_CreateDualMeshDlg.h @@ -37,6 +37,7 @@ class QRadioButton; class QButtonGroup; class QGroupBox; class QLabel; +class QLineEdit; class SMESHGUI_EXPORT SMESHGUI_CreateDualMeshDlg : public SMESHGUI_Dialog { @@ -49,11 +50,16 @@ public: void ShowWarning(bool); bool isWarningShown(); + QLineEdit* myMeshName; + QCheckBox* myProjShape; + signals: void onClicked( int ); + private: QLabel* myWarning; + QLabel* myMeshNameLabel; }; #endif // SMESHGUI_CREATEDUALMESHDLG_H diff --git a/src/SMESHGUI/SMESHGUI_CreateDualMeshOp.cxx b/src/SMESHGUI/SMESHGUI_CreateDualMeshOp.cxx index 25f811700..449f0a582 100644 --- a/src/SMESHGUI/SMESHGUI_CreateDualMeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_CreateDualMeshOp.cxx @@ -40,8 +40,12 @@ #include #include #include +#include #include +// Qt includes +#include + // IDL includes #include #include CORBA_SERVER_HEADER(SMESH_MeshEditor) @@ -150,6 +154,9 @@ void SMESHGUI_CreateDualMeshOp::selectionDone() myDlg->ShowWarning( true ); } } + std::string mesh_name = "dual_" + pObj->GetName(); + myDlg->myMeshName->setText(QString(mesh_name.c_str())); + } catch ( const SALOME::SALOME_Exception& S_ex ) { @@ -158,6 +165,7 @@ void SMESHGUI_CreateDualMeshOp::selectionDone() catch ( ... ) { } + } //================================================================================ @@ -217,11 +225,9 @@ bool SMESHGUI_CreateDualMeshOp::onApply() bool aResult = false; SMESH::SMESH_Gen_var gen = SMESHGUI::GetSMESHGen(); SMESH::SMESH_Mesh_var newMesh; - QByteArray newMeshName="MESH_DUAL"; + QByteArray newMeshName=myDlg->myMeshName->text().toUtf8(); try { - // TODO: Call the python script using medcoupling - // String to run medcoupling dual // TODO: change name as previous name + "_dual" newMesh = gen->CreateDualMesh(mesh, newMeshName.constData()); @@ -246,10 +252,11 @@ bool SMESHGUI_CreateDualMeshOp::onApply() if( aResult ) { SMESHGUI::Modified(); - update( UF_ObjBrowser | UF_Model | UF_Viewer ); selectionDone(); - } + update( UF_ObjBrowser | UF_Model | UF_Viewer ); + } + SMESHGUI::GetSMESHGUI()->getApp()->updateObjectBrowser(); // updateObjBrowser(true); // SMESHGUI::Modified(); diff --git a/src/SMESHGUI/SMESH_images.ts b/src/SMESHGUI/SMESH_images.ts index 2116ee51b..fc90e47de 100644 --- a/src/SMESHGUI/SMESH_images.ts +++ b/src/SMESHGUI/SMESH_images.ts @@ -95,6 +95,10 @@ ICON_CONV_TO_QUAD mesh_conv_to_quad.png + + ICON_CREATE_DUAL_MESH + mesh_create_dual_mesh.png + ICON_CUT mesh_cutGroups.png diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 7c52712ec..a627143da 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -292,6 +292,10 @@ MEN_COPY_MESH Copy Mesh + + MEN_CREATE_DUAL_MESH + Create Dual Mesh + MEN_CLIP Clipping @@ -3300,6 +3304,10 @@ Use Display Entity menu command to show them. STB_COPY_MESH Copy Mesh + + STB_CREATE_DUAL_MESH + Create Dual Mesh + STB_CLIP Clipping @@ -5679,6 +5687,29 @@ Please specify it and try again Warning: mesh can become non-conformal + + SMESHGUI_CreateDualMeshDlg + + CAPTION + Create Dual Mesh + + + MESH + Mesh or Sub-mesh + + + NON_TETRA_MESH_WARNING + Warning: mesh must have only Tetrahedron 3D elements + + + DUAL_MESH_NAME + Name of the dual mesh + + + PROJ_SHAPE + Project boundary elements on shape + + SMESHGUI_ConvToQuadOp diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 79d031823..7157f413c 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -151,6 +151,9 @@ #include #include #include +#include + +namespace fs = boost::filesystem; using namespace std; using SMESH::TPythonDump; @@ -2835,54 +2838,23 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateDualMesh(SMESH::SMESH_IDSource_ptr mesh if ( !srcMesh_i ) THROW_SALOME_CORBA_EXCEPTION( "bad mesh of IDSource", SALOME::BAD_PARAM ); - SMESH_Mesh& srcMesh2 = srcMesh_i->GetImpl(); + CORBA::String_var mesh_var=GetORB()->object_to_string(mesh); + std::string mesh_ior = mesh_var.in(); - // TODO: Get it - CORBA::String_var mesh_ior=GetORB()->object_to_string(mesh); - std::string mesh_id = mesh_ior.in(); - std::string dual_mesh_file="/tmp/test_dual.med"; + fs::path tmp_folder = fs::unique_path(fs::path("dual_mesh-%%%%-%%%%")); + fs::create_directories(tmp_folder); + fs::path dual_mesh_file = tmp_folder / fs::path("tmp_dual_mesh.med"); std::string mesh_name = "MESH"; - std::string python_code; - python_code += "import sys\n"; - python_code += "import salome\n"; - python_code += "import medcoupling as mc\n"; - python_code += "from math import pi\n"; - python_code += "salome.salome_init()\n"; - python_code += "import GEOM\n"; - python_code += "from salome.geom import geomBuilder\n"; - python_code += "geompy = geomBuilder.New()\n"; - python_code += "import SMESH, SALOMEDS\n"; - python_code += "from salome.smesh import smeshBuilder\n"; - python_code += "smesh = smeshBuilder.New()\n"; - python_code += "def create_dual_mesh(mesh_ior, output_file):\n"; - python_code += " mesh = salome.orb.string_to_object(mesh_ior)\n"; - python_code += " shape = mesh.GetShapeToMesh()\n"; - python_code += " if not mesh:\n"; - python_code += " raise Exception(\"Could not find mesh using id: \", mesh_id)\n"; - python_code += " int_ptr = mesh.ExportMEDCoupling(True, True)\n"; - python_code += " dab = mc.FromPyIntPtrToDataArrayByte(int_ptr)\n"; - python_code += " tetras = mc.MEDFileMesh.New(dab)[0]\n"; - python_code += " tetras = mc.MEDCoupling1SGTUMesh(tetras)\n"; - python_code += " polyh = tetras.computeDualMesh()\n"; - python_code += " skin = tetras.buildUnstructured().computeSkin()\n"; - python_code += " skin_polyh = polyh.buildUnstructured().computeSkin()\n"; - python_code += " allNodesOnSkinPolyh = skin_polyh.computeFetchedNodeIds()\n"; - python_code += " allNodesOnSkin = skin.computeFetchedNodeIds()\n"; - python_code += " ptsAdded = allNodesOnSkinPolyh.buildSubstraction(allNodesOnSkin)\n"; - python_code += " ptsAddedMesh = mc.MEDCouplingUMesh.Build0DMeshFromCoords( skin_polyh.getCoords()[ptsAdded] )\n"; - python_code += " ptsAddedCoo = ptsAddedMesh.getCoords()\n"; - python_code += " ptsAddedCooModified = ptsAddedCoo[:]\n"; - python_code += " polyh.setName(\"MESH\")\n"; - python_code += " polyh.write(output_file)\n"; - // Running Python script assert(Py_IsInitialized()); PyGILState_STATE gstate; gstate = PyGILState_Ensure(); - PyRun_SimpleString(python_code.c_str()); - std::string cmd=""; - cmd += "create_dual_mesh(\"" + mesh_id + "\", \"" + dual_mesh_file + "\")"; + + std::string cmd="import salome.smesh.smesh_tools as smt"; + PyRun_SimpleString(cmd.c_str()); + + cmd = "smt.create_dual_mesh(\"" + mesh_ior + "\", \"" + dual_mesh_file.string() + "\", \"" + mesh_name + "\")"; PyRun_SimpleString(cmd.c_str()); PyGILState_Release(gstate); @@ -2896,19 +2868,19 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateDualMesh(SMESH::SMESH_IDSource_ptr mesh if ( !meshSO->_is_nil() ) { SetName( meshSO, meshName, "Mesh" ); - SetPixMap( meshSO, "ICON_SMESH_TREE_MESH_IMPORTED"); + SetPixMap( meshSO, "ICON_SMESH_TREE_MESH"); } SMESH_Mesh& newMesh2 = newMesh_i->GetImpl(); - newMesh2.MEDToMesh(dual_mesh_file.c_str(), "MESH"); + newMesh2.MEDToMesh(dual_mesh_file.c_str(), meshName); SMESHDS_Mesh* newMeshDS = newMesh_i->GetImpl().GetMeshDS(); newMeshDS->Modified(); *pyDump << newMesh << " = " << this - << ".CreateDualMesh( " << mesh << ", " + << ".CreateDualMesh(" << "'" << meshName << "') "; return newMesh._retn(); diff --git a/src/SMESH_SWIG/CMakeLists.txt b/src/SMESH_SWIG/CMakeLists.txt index e39db09f9..81cf38a69 100644 --- a/src/SMESH_SWIG/CMakeLists.txt +++ b/src/SMESH_SWIG/CMakeLists.txt @@ -37,6 +37,7 @@ SET(smesh_SCRIPTS smeshBuilder.py smesh_algorithm.py smesh_selection.py + smesh_tools.py ) SET(StdMeshers_SCRIPTS @@ -52,7 +53,7 @@ SET_SOURCE_FILES_PROPERTIES(SMeshHelper.i PROPERTIES CPLUSPLUS ON) SET_SOURCE_FILES_PROPERTIES(SMeshHelper.i PROPERTIES SWIG_FLAGS "-py3") SET_SOURCE_FILES_PROPERTIES(SMeshHelper_wrap.cpp PROPERTIES COMPILE_FLAGS "-DHAVE_CONFIG_H") SET(_swig_SCRIPTS ${CMAKE_CURRENT_BINARY_DIR}/SMeshHelper.py ) -IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") SWIG_ADD_MODULE(SMeshHelper python ${SMeshHelper_SOURCES}) ELSE() SWIG_ADD_LIBRARY(SMeshHelper LANGUAGE python SOURCES ${SMeshHelper_SOURCES}) diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index c46a97751..42bad03cf 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -786,11 +786,10 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ): Returns: an instance of class :class:`Mesh` """ - if isinstance( mesh, Mesh ): - meshPart = mesh.GetMesh() - mesh = SMESH._objref_SMESH_Gen.CreateDualMesh(self, mesh, meshName) - return Mesh(self, self.geompyD, mesh) + mesh = mesh.GetMesh() + dualMesh = SMESH._objref_SMESH_Gen.CreateDualMesh(self, mesh, meshName) + return Mesh(self, self.geompyD, dualMesh) def CopyMesh( self, meshPart, meshName, toCopyGroups=False, toKeepIDs=False): diff --git a/src/SMESH_SWIG/smesh_tools.py b/src/SMESH_SWIG/smesh_tools.py new file mode 100644 index 000000000..38cd978e0 --- /dev/null +++ b/src/SMESH_SWIG/smesh_tools.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python3 + +import sys +import salome +import medcoupling as mc +from math import pi + +#salome.salome_init() + +import GEOM +from salome.geom import geomBuilder + +geompy = geomBuilder.New() + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New() + +def create_dual_mesh(mesh_ior, output_file, adapt_to_shape=True, mesh_name="MESH"): + """ Create a dual of the mesh in input_file into output_file + + Args: + mesh_ior (string): corba Id of the Tetrahedron mesh + output_file (string): dual mesh file + """ + # Import mesh from file + # mesh = salome.orb.string_to_object(salome.salome_study.myStudy.FindObjectID(mesh_id).GetIOR()) + mesh = salome.orb.string_to_object(mesh_ior) + if not mesh: + raise Exception("Could not find mesh using id: ", mesh_ior) + + shape = mesh.GetShapeToMesh() + + # We got a meshProxy so we need to convert pointer to MEDCoupling + int_ptr = mesh.ExportMEDCoupling(True, True) + dab = mc.FromPyIntPtrToDataArrayByte(int_ptr) + tetras = mc.MEDFileMesh.New(dab)[0] + # End of SMESH -> MEDCoupling part for dualmesh + + tetras = mc.MEDCoupling1SGTUMesh(tetras) + polyh = tetras.computeDualMesh() + skin = tetras.buildUnstructured().computeSkin() + skin_polyh = polyh.buildUnstructured().computeSkin() + allNodesOnSkinPolyh = skin_polyh.computeFetchedNodeIds() + allNodesOnSkin = skin.computeFetchedNodeIds() + ptsAdded = allNodesOnSkinPolyh.buildSubstraction(allNodesOnSkin) + ptsAddedMesh = mc.MEDCouplingUMesh.Build0DMeshFromCoords( skin_polyh.getCoords()[ptsAdded] ) + + if adapt_to_shape: + ptsAddedCoo = ptsAddedMesh.getCoords() + ptsAddedCooModified = ptsAddedCoo[:] + + # We need the geometry for that + # TODO : Loop on faces identify points associated to which face + faces = geompy.ExtractShapes(shape, geompy.ShapeType["FACE"], True) + #assert( len(faces) == 1 ) + ## projection des points ajoutés par le dual sur la surface + #for i,tup in enumerate(ptsAddedCooModified): + # vertex = geompy.MakeVertex(*tuple(tup)) + # prj = geompy.MakeProjection(vertex, faces) + # newCoor = geompy.PointCoordinates( prj ) + # ptsAddedCooModified[i] = newCoor + ## assign coordinates with projected ones + #polyh.getCoords()[ptsAdded] = ptsAddedCooModified + + print("Writing dual mesh in ", output_file) + polyh.setName(mesh_name) + polyh.write(output_file) + + + + + diff --git a/test/SMESH_create_dual_mesh.py b/test/SMESH_create_dual_mesh.py new file mode 100644 index 000000000..007dbb8a7 --- /dev/null +++ b/test/SMESH_create_dual_mesh.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python + +### +### This file is generated automatically by SALOME v9.9.0 with dump python functionality +### + +import sys +import salome + +salome.salome_init() +import salome_notebook +notebook = salome_notebook.NoteBook() +sys.path.insert(0, r'/home/B61570/work_in_progress/dual_mesh') + +### +### GEOM component +### + +import GEOM +from salome.geom import geomBuilder +import math +import SALOMEDS + + +geompy = geomBuilder.New() + +O = geompy.MakeVertex(0, 0, 0) +OX = geompy.MakeVectorDXDYDZ(1, 0, 0) +OY = geompy.MakeVectorDXDYDZ(0, 1, 0) +OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) +Sphere_1 = geompy.MakeSphereR(100) +[geomObj_1] = geompy.ExtractShapes(Sphere_1, geompy.ShapeType["FACE"], True) +geompy.addToStudy( O, 'O' ) +geompy.addToStudy( OX, 'OX' ) +geompy.addToStudy( OY, 'OY' ) +geompy.addToStudy( OZ, 'OZ' ) +geompy.addToStudy( Sphere_1, 'Sphere_1' ) + +### +### SMESH component +### + +import SMESH, SALOMEDS +from salome.smesh import smeshBuilder + +smesh = smeshBuilder.New() + +NETGEN_3D_Parameters_1 = smesh.CreateHypothesisByAverageLength( 'NETGEN_Parameters', 'NETGENEngine', 34.641, 0 ) +Mesh_1 = smesh.Mesh(Sphere_1,'Mesh_1') +status = Mesh_1.AddHypothesis( Sphere_1, NETGEN_3D_Parameters_1 ) +NETGEN_1D_2D_3D = Mesh_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D) +isDone = Mesh_1.Compute() +dual_Mesh_1 = smesh.CreateDualMesh( Mesh_1, 'dual_Mesh_1') + + +assert(dual_Mesh_1.NbPolyhedrons() > 0) +assert(dual_Mesh_1.NbTetras() == 0) + + +if salome.sg.hasDesktop(): + salome.sg.updateObjBrowser() diff --git a/test/tests.set b/test/tests.set index de38c9f13..f00bde4c6 100644 --- a/test/tests.set +++ b/test/tests.set @@ -62,6 +62,7 @@ SET(BAD_TESTS SMESH_test1.py SMESH_test2.py SMESH_test4.py + SMESH_create_dual_mesh.py ) IF(NOT WIN32) LIST(APPEND BAD_TESTS -- 2.39.2