Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 155974 | Differences between
and this patch

Collapse All | Expand All

(-)SMESH_SRC_3.2.2/doc/salome/gui/SMESH/files/importing_and_exporting_meshes.htm (-2 / +2 lines)
Lines 93-100 Link Here
93
<h1>Importing and exporting meshes</h1>
93
<h1>Importing and exporting meshes</h1>
94
94
95
<p><img src="../i_blue.jpg" x-maintain-ratio="TRUE" width="30px" height="30px" border="0" class="img_whs1"> In MESH there is a functionality allowing importation/exportation 
95
<p><img src="../i_blue.jpg" x-maintain-ratio="TRUE" width="30px" height="30px" border="0" class="img_whs1"> In MESH there is a functionality allowing importation/exportation 
96
 of meshes from <span style="font-weight: bold;"><B>MED</B></span>, <span style="font-weight: bold;"><B>UNV</B></span> 
96
 of meshes from <span style="font-weight: bold;"><B>MED</B></span> and <span style="font-weight: bold;"><B>UNV 
97
 format files. </p>
97
 </B></span>(I-DEAS 10) format files. </p>
98
98
99
<p>&nbsp;</p>
99
<p>&nbsp;</p>
100
100
(-)SMESH_SRC_3.2.2/idl/SMESH_Gen.idl (-1 / +3 lines)
Lines 121-126 Link Here
121
    
121
    
122
    /*!
122
    /*!
123
     * Create Mesh object importing data from given UNV file
123
     * Create Mesh object importing data from given UNV file
124
     * (UNV supported version is I-DEAS 10)
124
     */
125
     */
125
    SMESH_Mesh CreateMeshesFromUNV( in string theFileName )
126
    SMESH_Mesh CreateMeshesFromUNV( in string theFileName )
126
      raises ( SALOME::SALOME_Exception );
127
      raises ( SALOME::SALOME_Exception );
Lines 169-175 Link Here
169
      raises ( SALOME::SALOME_Exception );
170
      raises ( SALOME::SALOME_Exception );
170
171
171
    /*!
172
    /*!
172
     * 
173
     * Return indeces of faces, edges and vertices of given subshapes
174
     * within theMainObject
173
     */
175
     */
174
    long_array GetSubShapesId( in GEOM::GEOM_Object theMainObject,
176
    long_array GetSubShapesId( in GEOM::GEOM_Object theMainObject,
175
                               in object_array      theListOfSubObjects )
177
                               in object_array      theListOfSubObjects )
(-)SMESH_SRC_3.2.2/idl/SMESH_Mesh.idl (-3 / +33 lines)
Lines 374-379 Link Here
374
374
375
    /*!
375
    /*!
376
     * Export Mesh to DAT, UNV and STL Formats
376
     * Export Mesh to DAT, UNV and STL Formats
377
     * (UNV supported version is I-DEAS 10)
377
     */
378
     */
378
    void ExportDAT( in string file )
379
    void ExportDAT( in string file )
379
      raises (SALOME::SALOME_Exception);
380
      raises (SALOME::SALOME_Exception);
Lines 508-520 Link Here
508
509
509
    /*!
510
    /*!
510
     * If given element is node returns IDs of shape from position
511
     * If given element is node returns IDs of shape from position
511
     * else - return ID of result shape after ::FindShape()
512
     * If there is not node for given ID - returns -1
512
     * from SMESH_MeshEditor
513
     * If there is not element for given ID - returns -1
514
     */
513
     */
515
    long GetShapeID(in long id);
514
    long GetShapeID(in long id);
516
515
517
    /*!
516
    /*!
517
     * For given element returns ID of result shape after 
518
     * ::FindShape() from SMESH_MeshEditor
519
     * If there is not element for given ID - returns -1
520
     */
521
    long GetShapeIDForElem(in long id);
522
523
    /*!
518
     * Returns number of nodes for given element
524
     * Returns number of nodes for given element
519
     * If there is not element for given ID - returns -1
525
     * If there is not element for given ID - returns -1
520
     */
526
     */
Lines 642-653 Link Here
642
648
643
    long AddNode(in double x, in double y, in double z);
649
    long AddNode(in double x, in double y, in double z);
644
650
651
    /*!
652
     *  Create edge both similar and quadratic (this is determed
653
     *  by number of given nodes).
654
     *  \param IdsOfNodes List of node IDs for creation of element.
655
     *  Needed order of nodes in this list corresponds to description
656
     *  of MED. This description is located by the following link:
657
     *   http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
658
     */
645
    long AddEdge(in long_array IDsOfNodes);
659
    long AddEdge(in long_array IDsOfNodes);
646
660
661
    /*!
662
     *  Create face both similar and quadratic (this is determed
663
     *  by number of given nodes).
664
     *  \param IdsOfNodes List of node IDs for creation of element.
665
     *  Needed order of nodes in this list corresponds to description
666
     *  of MED. This description is located by the following link:
667
     *   http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
668
     */
647
    long AddFace(in long_array IDsOfNodes);
669
    long AddFace(in long_array IDsOfNodes);
648
670
649
    long AddPolygonalFace(in long_array IdsOfNodes);
671
    long AddPolygonalFace(in long_array IdsOfNodes);
650
672
673
    /*!
674
     *  Create volume both similar and quadratic (this is determed
675
     *  by number of given nodes).
676
     *  \param IdsOfNodes List of node IDs for creation of element.
677
     *  Needed order of nodes in this list corresponds to description
678
     *  of MED. This description is located by the following link:
679
     *   http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
680
     */
651
    long AddVolume(in long_array IDsOfNodes);
681
    long AddVolume(in long_array IDsOfNodes);
652
682
653
    /*!
683
    /*!
(-)SMESH_SRC_3.2.2/resources/SalomeApp.xml (-2 / +8 lines)
Lines 41-47 Link Here
41
  </section>
41
  </section>
42
  <section name="resources">
42
  <section name="resources">
43
    <!-- Module resources -->
43
    <!-- Module resources -->
44
    <parameter name="SMESH"      value="${SMESH_ROOT_DIR}/share/salome/resources/smesh"/>
44
    <parameter name="SMESH"        value="${SMESH_ROOT_DIR}/share/salome/resources/smesh"/>
45
    <parameter name="StdMeshers" value="${SMESH_ROOT_DIR}/share/salome/resources/smesh"/>
45
    <parameter name="StdMeshers"   value="${SMESH_ROOT_DIR}/share/salome/resources/smesh"/>
46
    <!-- NETGENPlugin and GHS3DPlugin -->
47
    <!-- Here the environment variables are used as case-sensitive, -->
48
    <!-- In GUI/src/SalomeApp/resources/SalomeApp.xml upper-case notation is used. -->
49
    <!-- As a result, both variants are acceptable. -->
50
    <parameter name="NETGENPlugin" value="${NETGENPlugin_ROOT_DIR}/share/salome/resources/netgenplugin"/>
51
    <parameter name="GHS3DPlugin"  value="${GHS3DPlugin_ROOT_DIR}/share/salome/resources/ghs3dplugin"/>
46
  </section>
52
  </section>
47
</document>
53
</document>
(-)SMESH_SRC_3.2.2/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx (+2 lines)
Lines 987-995 Link Here
987
  }
987
  }
988
  catch(const std::exception& exc) {
988
  catch(const std::exception& exc) {
989
    INFOS("Follow exception was cought:\n\t"<<exc.what());
989
    INFOS("Follow exception was cought:\n\t"<<exc.what());
990
    throw;
990
  }
991
  }
991
  catch(...) {
992
  catch(...) {
992
    INFOS("Unknown exception was cought !!!");
993
    INFOS("Unknown exception was cought !!!");
994
    throw;
993
  }
995
  }
994
996
995
  myMeshId = -1;
997
  myMeshId = -1;
(-)SMESH_SRC_3.2.2/src/MEFISTO2/Rn.h (-1 / +9 lines)
Lines 66-72 Link Here
66
66
67
//le type Z des nombres entiers relatifs
67
//le type Z des nombres entiers relatifs
68
//=========
68
//=========
69
typedef long int Z;
69
// 64-bit porting: "long" replaced with "int". 
70
// On 64-bit, C++ long type is 8 byte long. MEFISTO2D C code calls several Fortran subroutines passing
71
// arguments of this type, however Fortran knows nothing about changed size of arguments, 
72
// therefore stack gets corrupted. With "int" used instead of "long", Fortran calls from C do no harm to the stack
73
// After this modification, behavior on 32-bit platforms does not change: on all platforms supported by
74
// SALOME 3, "int" and "long" have the same size of 4 bytes. 
75
//========
76
//typedef long int Z;
77
typedef int Z;
70
78
71
//le type R des nombres "reels"
79
//le type R des nombres "reels"
72
//=========
80
//=========
(-)SMESH_SRC_3.2.2/src/OBJECT/Makefile.in (+1 lines)
Lines 51-56 Link Here
51
LIB_CLIENT_IDL = SALOME_Exception.idl \
51
LIB_CLIENT_IDL = SALOME_Exception.idl \
52
		 SALOME_GenericObj.idl \
52
		 SALOME_GenericObj.idl \
53
		 SALOME_Comm.idl \
53
		 SALOME_Comm.idl \
54
		 SALOME_Component.idl \
54
		 MED.idl \
55
		 MED.idl \
55
		 SMESH_Mesh.idl \
56
		 SMESH_Mesh.idl \
56
		 SMESH_Group.idl \
57
		 SMESH_Group.idl \
(-)SMESH_SRC_3.2.2/src/SMESH/SMESH_subMesh.cxx (-6 / +15 lines)
Lines 468-474 Link Here
468
468
469
//=======================================================================
469
//=======================================================================
470
//function : IsApplicableHypotesis
470
//function : IsApplicableHypotesis
471
//purpose  : 
471
//purpose  :
472
//=======================================================================
472
//=======================================================================
473
473
474
bool SMESH_subMesh::IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis,
474
bool SMESH_subMesh::IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis,
Lines 480-490 Link Here
480
480
481
  // hypothesis
481
  // hypothesis
482
  switch ( theShapeType ) {
482
  switch ( theShapeType ) {
483
  case TopAbs_EDGE: 
483
  case TopAbs_EDGE:
484
  case TopAbs_FACE: 
484
  case TopAbs_FACE:
485
  case TopAbs_SHELL:
486
  case TopAbs_SOLID:
485
  case TopAbs_SOLID:
487
    return SMESH_Gen::GetShapeDim( theShapeType ) == theHypothesis->GetDim();
486
    return SMESH_Gen::GetShapeDim( theShapeType ) == theHypothesis->GetDim();
487
488
  case TopAbs_SHELL:
489
    // Special case for algorithms, building 2D mesh on a whole shell.
490
    // Before this fix there was a problem after restoring from study,
491
    // because in that case algorithm is assigned before hypothesis
492
    // (on shell in problem case) and hypothesis is checked on faces
493
    // (because it is 2D), where we have NO_ALGO state.
494
    // Now 2D hypothesis is also applicable to shells.
495
    return (theHypothesis->GetDim() == 2 || theHypothesis->GetDim() == 3);
496
488
//   case TopAbs_WIRE:
497
//   case TopAbs_WIRE:
489
//   case TopAbs_COMPSOLID:
498
//   case TopAbs_COMPSOLID:
490
//   case TopAbs_COMPOUND:
499
//   case TopAbs_COMPOUND:
Lines 842-848 Link Here
842
        f.And(    SMESH_HypoFilter::IsApplicableTo( _subShape ));
851
        f.And(    SMESH_HypoFilter::IsApplicableTo( _subShape ));
843
        f.AndNot( SMESH_HypoFilter::Is( algo ));
852
        f.AndNot( SMESH_HypoFilter::Is( algo ));
844
        const SMESH_Hypothesis * prevAlgo = _father->GetHypothesis( _subShape, f, true );
853
        const SMESH_Hypothesis * prevAlgo = _father->GetHypothesis( _subShape, f, true );
845
        if (prevAlgo && 
854
        if (prevAlgo &&
846
            string(algo->GetName()) != string(prevAlgo->GetName()) )
855
            string(algo->GetName()) != string(prevAlgo->GetName()) )
847
          modifiedHyp = true;
856
          modifiedHyp = true;
848
      }
857
      }
Lines 900-906 Link Here
900
          f.And(    SMESH_HypoFilter::IsApplicableTo( _subShape ));
909
          f.And(    SMESH_HypoFilter::IsApplicableTo( _subShape ));
901
          f.AndNot( SMESH_HypoFilter::Is( algo ));
910
          f.AndNot( SMESH_HypoFilter::Is( algo ));
902
          const SMESH_Hypothesis* prevAlgo = _father->GetHypothesis( _subShape, f, true );
911
          const SMESH_Hypothesis* prevAlgo = _father->GetHypothesis( _subShape, f, true );
903
          if (prevAlgo && 
912
          if (prevAlgo &&
904
              string(algo->GetName()) != string(prevAlgo->GetName()) )
913
              string(algo->GetName()) != string(prevAlgo->GetName()) )
905
            modifiedHyp = true;
914
            modifiedHyp = true;
906
        }
915
        }
(-)SMESH_SRC_3.2.2/src/SMESHDS/SMESHDS_Group.hxx (-2 / +2 lines)
Lines 51-59 Link Here
51
51
52
  virtual SMDS_ElemIteratorPtr GetElements();
52
  virtual SMDS_ElemIteratorPtr GetElements();
53
53
54
  bool SMESHDS_Group::Add (const int theID);
54
  bool Add (const int theID);
55
55
56
  bool SMESHDS_Group::Remove (const int theID);
56
  bool Remove (const int theID);
57
57
58
  void Clear();
58
  void Clear();
59
59
(-)SMESH_SRC_3.2.2/src/SMESHGUI/SMESHGUI.cxx (-20 / +39 lines)
Lines 145-151 Link Here
145
145
146
using namespace std;
146
using namespace std;
147
147
148
namespace{
148
//namespace{
149
  // Declarations
149
  // Declarations
150
  //=============================================================
150
  //=============================================================
151
  void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
151
  void ImportMeshesFromFile(SMESH::SMESH_Gen_ptr theComponentMesh,
Lines 352-372 Link Here
352
	  if ( aFile.exists() )
352
	  if ( aFile.exists() )
353
	    aFile.remove();
353
	    aFile.remove();
354
	  SUIT_OverrideCursor wc;
354
	  SUIT_OverrideCursor wc;
355
	  switch ( theCommandID ) {
355
356
	  case 125:
356
	  try {
357
	  case 122:
357
	    switch ( theCommandID ) {
358
	    aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
358
	    case 125:
359
	    break;
359
	    case 122:
360
	  case 124:
360
	      aMesh->ExportToMED( aFilename.latin1(), toCreateGroups, aFormat );
361
	  case 121:
361
	      break;
362
	    aMesh->ExportDAT( aFilename.latin1() );
362
	    case 124:
363
	    break;
363
	    case 121:
364
	  case 126:
364
	      aMesh->ExportDAT( aFilename.latin1() );
365
	  case 123:
365
	      break;
366
	    aMesh->ExportUNV( aFilename.latin1() );
366
	    case 126:
367
	    break;
367
	    case 123:
368
	  default:
368
	      aMesh->ExportUNV( aFilename.latin1() );
369
	    break;
369
	      break;
370
	    default:
371
	      break;
372
	    }
373
	  }
374
	  catch (const SALOME::SALOME_Exception& S_ex){
375
	    wc.suspend();
376
	    SUIT_MessageBox::warn1(SMESHGUI::desktop(),
377
				    QObject::tr("SMESH_WRN_WARNING"),
378
				    QObject::tr("SMESH_EXPORT_FAILED"),
379
				    QObject::tr("SMESH_BUT_OK"));
380
	    wc.resume();
370
	  }
381
	  }
371
	}
382
	}
372
      }
383
      }
Lines 815-821 Link Here
815
826
816
    SMESHGUI::GetSMESHGUI()->updateObjBrowser();
827
    SMESHGUI::GetSMESHGUI()->updateObjBrowser();
817
  }
828
  }
818
}
829
//}
819
830
820
extern "C" {
831
extern "C" {
821
  Standard_EXPORT CAM_Module* createModule()
832
  Standard_EXPORT CAM_Module* createModule()
Lines 1217-1222 Link Here
1217
	  }
1228
	  }
1218
	}
1229
	}
1219
      }
1230
      }
1231
      
1232
      // PAL13338 -->
1233
      if ( ( theCommandID==301 || theCommandID==302 ) && !checkLock(aStudy) && !automaticUpdate() ) 
1234
	SMESH::UpdateView();
1235
      // PAL13338 <--
1220
1236
1221
      if (anAction == SMESH::eErase) {
1237
      if (anAction == SMESH::eErase) {
1222
	SALOME_ListIO l1;
1238
	SALOME_ListIO l1;
Lines 1224-1229 Link Here
1224
      }
1240
      }
1225
      else
1241
      else
1226
	aSel->setSelectedObjects( to_process );
1242
	aSel->setSelectedObjects( to_process );
1243
1227
      break;
1244
      break;
1228
    }
1245
    }
1229
1246
Lines 2155-2166 Link Here
2155
      LightApp_SelectionMgr* mgr = selectionMgr();
2172
      LightApp_SelectionMgr* mgr = selectionMgr();
2156
      SALOME_ListIO selected; mgr->selectedObjects( selected );
2173
      SALOME_ListIO selected; mgr->selectedObjects( selected );
2157
2174
2158
      if (selected.Extent() == 1)	{
2175
      SALOME_ListIteratorOfListIO it(selected);
2159
	Handle(SALOME_InteractiveObject) anIObject = selected.First();
2176
      for(; it.More(); it.Next()) {
2160
	if(anIObject->hasEntry())
2177
        Handle(SALOME_InteractiveObject) anIObject = it.Value();
2178
	if(anIObject->hasEntry()) {
2161
	  if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2179
	  if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){
2162
	    anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2180
	    anActor->SetPointsLabeled( !anActor->GetPointsLabeled() );
2163
	  }
2181
	  }
2182
	}
2164
      }
2183
      }
2165
      break;
2184
      break;
2166
    }
2185
    }
(-)SMESH_SRC_3.2.2/src/SMESHGUI/SMESHGUI_MeshOp.cxx (-19 / +23 lines)
Lines 1-18 Link Here
1
// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
1
// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
2
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3
// 
3
//
4
// This library is free software; you can redistribute it and/or
4
// This library is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU Lesser General Public
5
// modify it under the terms of the GNU Lesser General Public
6
// License as published by the Free Software Foundation; either 
6
// License as published by the Free Software Foundation; either
7
// version 2.1 of the License.
7
// version 2.1 of the License.
8
// 
8
//
9
// This library is distributed in the hope that it will be useful 
9
// This library is distributed in the hope that it will be useful
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of 
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
// Lesser General Public License for more details.
12
// Lesser General Public License for more details.
13
//
13
//
14
// You should have received a copy of the GNU Lesser General Public  
14
// You should have received a copy of the GNU Lesser General Public
15
// License along with this library; if not, write to the Free Software 
15
// License along with this library; if not, write to the Free Software
16
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17
//
17
//
18
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
Lines 81-87 Link Here
81
       SUBMESH_ON_SHELL_TAG   =8,
81
       SUBMESH_ON_SHELL_TAG   =8,
82
       SUBMESH_ON_SOLID_TAG   =9,
82
       SUBMESH_ON_SOLID_TAG   =9,
83
       SUBMESH_ON_COMPOUND_TAG=10 };
83
       SUBMESH_ON_COMPOUND_TAG=10 };
84
       
84
85
//================================================================================
85
//================================================================================
86
/*!
86
/*!
87
 * \brief Constructor
87
 * \brief Constructor
Lines 212-218 Link Here
212
    connect( myDlg, SIGNAL( hypoSet( const QString& )), SLOT( onHypoSet( const QString& )));
212
    connect( myDlg, SIGNAL( hypoSet( const QString& )), SLOT( onHypoSet( const QString& )));
213
    connect( myDlg, SIGNAL( geomSelectionByMesh( bool )), SLOT( onGeomSelectionByMesh( bool )));
213
    connect( myDlg, SIGNAL( geomSelectionByMesh( bool )), SLOT( onGeomSelectionByMesh( bool )));
214
214
215
    if ( myToCreate ) 
215
    if ( myToCreate )
216
      if ( myIsMesh ) myHelpFileName = "/files/constructing_meshes.htm";
216
      if ( myIsMesh ) myHelpFileName = "/files/constructing_meshes.htm";
217
      else myHelpFileName = "/files/constructing_submeshes.htm";
217
      else myHelpFileName = "/files/constructing_submeshes.htm";
218
    else myHelpFileName = "files/reassigning_hypotheses_and_algorithms.htm";
218
    else myHelpFileName = "files/reassigning_hypotheses_and_algorithms.htm";
Lines 379-385 Link Here
379
          }
379
          }
380
        }
380
        }
381
      }
381
      }
382
    }     
382
    }
383
  }
383
  }
384
  return _PTR(SObject)();
384
  return _PTR(SObject)();
385
}
385
}
Lines 421-427 Link Here
421
      case GEOM::SOLID:
421
      case GEOM::SOLID:
422
      case GEOM::SHELL:  shapeDim = 3; break;
422
      case GEOM::SHELL:  shapeDim = 3; break;
423
      case GEOM::FACE:   shapeDim = 2; break;
423
      case GEOM::FACE:   shapeDim = 2; break;
424
      case GEOM::WIRE:   
424
      case GEOM::WIRE:
425
      case GEOM::EDGE:   shapeDim = 1; break;
425
      case GEOM::EDGE:   shapeDim = 1; break;
426
      case GEOM::VERTEX: shapeDim = 0; break;
426
      case GEOM::VERTEX: shapeDim = 0; break;
427
      default:
427
      default:
Lines 464-470 Link Here
464
    {
464
    {
465
      // if a submesh on the selected shape already exist, pass to submesh edition mode
465
      // if a submesh on the selected shape already exist, pass to submesh edition mode
466
      if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) {
466
      if ( _PTR(SObject) pSubmesh = getSubmeshByGeom() ) {
467
        SMESH::SMESH_subMesh_var sm = 
467
        SMESH::SMESH_subMesh_var sm =
468
          SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pSubmesh );
468
          SMESH::SObjectToInterface<SMESH::SMESH_subMesh>( pSubmesh );
469
        bool editSubmesh = ( !sm->_is_nil() &&
469
        bool editSubmesh = ( !sm->_is_nil() &&
470
                             SUIT_MessageBox::question2( myDlg, tr( "SMESH_WARNING" ),
470
                             SUIT_MessageBox::question2( myDlg, tr( "SMESH_WARNING" ),
Lines 586-592 Link Here
586
      }
586
      }
587
    }
587
    }
588
  }
588
  }
589
    
589
590
  return true;
590
  return true;
591
}
591
}
592
592
Lines 756-762 Link Here
756
  const int nbColonsInMeshEntry = 3;
756
  const int nbColonsInMeshEntry = 3;
757
  bool isSubMesh = myToCreate ?
757
  bool isSubMesh = myToCreate ?
758
    !myIsMesh :
758
    !myIsMesh :
759
    myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).contains(':') > nbColonsInMeshEntry; 
759
    myDlg->selectedObject( SMESHGUI_MeshDlg::Obj ).contains(':') > nbColonsInMeshEntry;
760
760
761
  if ( isSubMesh )
761
  if ( isSubMesh )
762
  {
762
  {
Lines 797-803 Link Here
797
797
798
//================================================================================
798
//================================================================================
799
/*!
799
/*!
800
 * \Brief Returns tab dimention  
800
 * \Brief Returns tab dimention
801
  * \param tab - the tab in the dlg
801
  * \param tab - the tab in the dlg
802
  * \param dlg - my dialogue
802
  * \param dlg - my dialogue
803
  * \retval int - dimention
803
  * \retval int - dimention
Lines 852-857 Link Here
852
                                        const int theType,
852
                                        const int theType,
853
                                        const QString& theTypeName)
853
                                        const QString& theTypeName)
854
{
854
{
855
  // During a hypothesis creation we might need to select some objects.
856
  // Main dialog must not update it's own selected objects in this case.
857
  dlg()->deactivateAll();
858
855
  HypothesisData* aData = SMESH::GetHypothesisData(theTypeName.latin1());
859
  HypothesisData* aData = SMESH::GetHypothesisData(theTypeName.latin1());
856
  if (!aData)
860
  if (!aData)
857
    return;
861
    return;
Lines 922-928 Link Here
922
926
923
//================================================================================
927
//================================================================================
924
/*!
928
/*!
925
 * \brief access to hypothesis data 
929
 * \brief access to hypothesis data
926
  * \param theDim - hyp dimension
930
  * \param theDim - hyp dimension
927
  * \param theHypType - hyp type (Algo,MainHyp or AddHyp)
931
  * \param theHypType - hyp type (Algo,MainHyp or AddHyp)
928
  * \param theIndex - index in the list
932
  * \param theIndex - index in the list
Lines 1105-1111 Link Here
1105
1109
1106
//================================================================================
1110
//================================================================================
1107
/*!
1111
/*!
1108
 * \brief Creates and selects hypothesis of hypotheses set 
1112
 * \brief Creates and selects hypothesis of hypotheses set
1109
 * \param theSetName - The name of hypotheses set
1113
 * \param theSetName - The name of hypotheses set
1110
 */
1114
 */
1111
//================================================================================
1115
//================================================================================
Lines 1201-1207 Link Here
1201
1205
1202
    for ( int aDim = SMESH::DIM_1D; aDim <= SMESH::DIM_3D; aDim++ ) {
1206
    for ( int aDim = SMESH::DIM_1D; aDim <= SMESH::DIM_3D; aDim++ ) {
1203
      if ( !isAccessibleDim( aDim )) continue;
1207
      if ( !isAccessibleDim( aDim )) continue;
1204
        
1208
1205
      // assign hypotheses
1209
      // assign hypotheses
1206
      for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ ) {
1210
      for ( int aHypType = MainHyp; aHypType <= AddHyp; aHypType++ ) {
1207
        int aHypIndex = currentHyp( aDim, aHypType );
1211
        int aHypIndex = currentHyp( aDim, aHypType );
(-)SMESH_SRC_3.2.2/src/SMESHGUI/SMESH_msg_en.po (+4 lines)
Lines 173-178 Link Here
173
msgid "SMESH_POLYEDRE_CREATE_ERROR"
173
msgid "SMESH_POLYEDRE_CREATE_ERROR"
174
msgstr "Polyedron creation error"
174
msgstr "Polyedron creation error"
175
175
176
#Export mesh
177
msgid "SMESH_EXPORT_FAILED"
178
msgstr "Mesh export failed.\nProbably, there is not enough space on disk."
179
176
#-------------------------------------------------------------------------
180
#-------------------------------------------------------------------------
177
# MEN
181
# MEN
178
#-------------------------------------------------------------------------
182
#-------------------------------------------------------------------------
(-)SMESH_SRC_3.2.2/src/SMESH_I/SMESH_Gen_i.cxx (-8 / +17 lines)
Lines 426-443 Link Here
426
  myIsEmbeddedMode = theMode;
426
  myIsEmbeddedMode = theMode;
427
427
428
  if ( !myIsEmbeddedMode ) {
428
  if ( !myIsEmbeddedMode ) {
429
    bool raiseFPE;
429
    //PAL10867: disable signals catching with "noexcepthandler" option
430
    char* envNoCatchSignals = getenv("NOT_INTERCEPT_SIGNALS");
431
    if (!envNoCatchSignals || !atoi(envNoCatchSignals))
432
    {
433
      bool raiseFPE;
430
#ifdef _DEBUG_
434
#ifdef _DEBUG_
431
    raiseFPE = true;
435
      raiseFPE = true;
432
    char* envDisableFPE = getenv("DISABLE_FPE");
436
      char* envDisableFPE = getenv("DISABLE_FPE");
433
    if (envDisableFPE && atoi(envDisableFPE))
437
      if (envDisableFPE && atoi(envDisableFPE))
434
      raiseFPE = false;
438
        raiseFPE = false;
435
#else
439
#else
436
    raiseFPE = false;
440
      raiseFPE = false;
437
#endif
441
#endif
438
    OSD::SetSignal( raiseFPE );
442
      OSD::SetSignal( raiseFPE );
443
    }
444
    // else OSD::SetSignal() is called in GUI
439
  }
445
  }
440
  // else OSD::SetSignal() is called in GUI
441
}
446
}
442
447
443
//=============================================================================
448
//=============================================================================
Lines 1095-1100 Link Here
1095
      return myGen.Compute( myLocMesh, myLocShape);
1100
      return myGen.Compute( myLocMesh, myLocShape);
1096
    }
1101
    }
1097
  }
1102
  }
1103
  catch ( std::bad_alloc& exc ) {
1104
    THROW_SALOME_CORBA_EXCEPTION( "Memory allocation problem",
1105
                                  SALOME::INTERNAL_ERROR );
1106
  }
1098
  catch ( SALOME_Exception& S_ex ) {
1107
  catch ( SALOME_Exception& S_ex ) {
1099
    INFOS( "Compute(): catch exception "<< S_ex.what() );
1108
    INFOS( "Compute(): catch exception "<< S_ex.what() );
1100
  }
1109
  }
(-)SMESH_SRC_3.2.2/src/SMESH_I/SMESH_MEDSupport_i.cxx (+12 lines)
Lines 327-332 Link Here
327
327
328
//=============================================================================
328
//=============================================================================
329
/*!
329
/*!
330
 * CORBA: get Nodes from file
331
 */
332
//=============================================================================
333
334
SALOME_MED::long_array * SMESH_MEDSupport_i::getNumberFromFile(
335
	SALOME_MED::medGeometryElement geomElement) throw(SALOME::SALOME_Exception)
336
{
337
  return getNumber(geomElement);
338
}
339
340
//=============================================================================
341
/*!
330
 * CORBA: Global Nodes Index (optionnaly designed by the user)
342
 * CORBA: Global Nodes Index (optionnaly designed by the user)
331
 * CORBA:  ??????????????????????????????
343
 * CORBA:  ??????????????????????????????
332
 */
344
 */
(-)SMESH_SRC_3.2.2/src/SMESH_I/SMESH_MEDSupport_i.hxx (+7 lines)
Lines 66-71 Link Here
66
	getNumber(SALOME_MED::medGeometryElement geomElement)
66
	getNumber(SALOME_MED::medGeometryElement geomElement)
67
	  throw(SALOME::SALOME_Exception);
67
	  throw(SALOME::SALOME_Exception);
68
68
69
  /*!
70
   * Same function as getNumber.
71
   */
72
	SALOME_MED::long_array *
73
	getNumberFromFile(SALOME_MED::medGeometryElement geomElement)
74
	  throw(SALOME::SALOME_Exception);
75
69
	SALOME_MED::long_array * getNumberIndex()
76
	SALOME_MED::long_array * getNumberIndex()
70
	  throw(SALOME::SALOME_Exception);
77
	  throw(SALOME::SALOME_Exception);
71
78
(-)SMESH_SRC_3.2.2/src/SMESH_I/SMESH_Mesh_i.cxx (-4 / +26 lines)
Lines 49-54 Link Here
49
//#include "SMDS_ElemIterator.hxx"
49
//#include "SMDS_ElemIterator.hxx"
50
#include "SMDS_VolumeTool.hxx"
50
#include "SMDS_VolumeTool.hxx"
51
#include "SMESH_MesherHelper.hxx"
51
#include "SMESH_MesherHelper.hxx"
52
#include "SMESH_MeshEditor.hxx"
52
53
53
// OCCT Includes
54
// OCCT Includes
54
#include <OSD_Path.hxx>
55
#include <OSD_Path.hxx>
Lines 1857-1865 Link Here
1857
//=============================================================================
1858
//=============================================================================
1858
/*!
1859
/*!
1859
 * If given element is node returns IDs of shape from position
1860
 * If given element is node returns IDs of shape from position
1860
 * else - return ID of result shape after ::FindShape()
1861
 * If there is not node for given ID - returns -1
1861
 * from SMESH_MeshEditor
1862
 * If there is not element for given ID - returns -1
1863
 */
1862
 */
1864
//=============================================================================
1863
//=============================================================================
1865
1864
Lines 1879-1890 Link Here
1879
      return pos->GetShapeId();
1878
      return pos->GetShapeId();
1880
  }
1879
  }
1881
1880
1881
  return -1;
1882
}
1883
1884
1885
//=============================================================================
1886
/*!
1887
 * For given element returns ID of result shape after 
1888
 * ::FindShape() from SMESH_MeshEditor
1889
 * If there is not element for given ID - returns -1
1890
 */
1891
//=============================================================================
1892
1893
CORBA::Long SMESH_Mesh_i::GetShapeIDForElem(const CORBA::Long id)
1894
{
1895
  SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS();
1896
  if ( aSMESHDS_Mesh == NULL )
1897
    return -1;
1898
1882
  // try to find element
1899
  // try to find element
1883
  const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
1900
  const SMDS_MeshElement* elem = aSMESHDS_Mesh->FindElement(id);
1884
  if(!elem)
1901
  if(!elem)
1885
    return -1;
1902
    return -1;
1886
1903
1887
  // need implementation???????????????????????????????????????????????
1904
  //SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor();
1905
  ::SMESH_MeshEditor aMeshEditor(_impl);
1906
  int index = aMeshEditor.FindShape( elem );
1907
  if(index>0)
1908
    return index;
1909
1888
  return -1;
1910
  return -1;
1889
}
1911
}
1890
1912
(-)SMESH_SRC_3.2.2/src/SMESH_I/SMESH_Mesh_i.hxx (-3 / +8 lines)
Lines 321-333 Link Here
321
321
322
  /*!
322
  /*!
323
   * If given element is node returns IDs of shape from position
323
   * If given element is node returns IDs of shape from position
324
   * else - return ID of result shape after ::FindShape()
324
   * If there is not node for given ID - returns -1
325
   * from SMESH_MeshEditor
326
   * If there is not element for given ID - returns -1
327
   */
325
   */
328
  CORBA::Long GetShapeID(const CORBA::Long id);
326
  CORBA::Long GetShapeID(const CORBA::Long id);
329
327
330
  /*!
328
  /*!
329
   * For given element returns ID of result shape after 
330
   * ::FindShape() from SMESH_MeshEditor
331
   * If there is not element for given ID - returns -1
332
   */
333
  CORBA::Long GetShapeIDForElem(const CORBA::Long id);
334
335
  /*!
331
   * Returns number of nodes for given element
336
   * Returns number of nodes for given element
332
   * If there is not element for given ID - returns -1
337
   * If there is not element for given ID - returns -1
333
   */
338
   */
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/PAL_MESH_041_mesh.py (-45 / +21 lines)
Lines 17-26 Link Here
17
#
17
#
18
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
#
19
#
20
import geompy
21
import salome
20
import salome
21
import geompy
22
import smesh
22
23
23
import StdMeshers
24
24
25
#-----------------------------GEOM----------------------------------------
25
#-----------------------------GEOM----------------------------------------
26
26
Lines 51-122 Link Here
51
51
52
52
53
#-----------------------------SMESH-------------------------------------------
53
#-----------------------------SMESH-------------------------------------------
54
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
55
56
# -- Init --
57
plane_mesh = salome.IDToObject( Id_face1)
58
smesh.SetCurrentStudy(salome.myStudy)
59
60
mesh = smesh.CreateMesh(plane_mesh)
61
62
smeshgui = salome.ImportComponentGUI("SMESH")
63
smeshgui.Init(salome.myStudyId)
64
54
65
id_mesh = salome.ObjectToID(mesh)
66
smeshgui.SetName( id_mesh, "Mesh_1")
67
55
56
# -- Init mesh --
57
plane_mesh = salome.IDToObject( Id_face1)
68
58
69
print"---------------------Hypothesis"
59
mesh = smesh.Mesh(plane_mesh, "Mesh_1")
70
60
61
print"---------------------Hypothesis and Algorithms"
71
62
72
#---------------- NumberOfSegments
63
#---------------- NumberOfSegments
64
73
numberOfSegment = 9
65
numberOfSegment = 9
74
66
75
hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
67
algoWireDes = mesh.Segment()
76
hypNbSeg.SetNumberOfSegments( numberOfSegment )
68
listHyp = algoWireDes.GetCompatibleHypothesis()
69
print algoWireDes.GetName()
70
algoWireDes.SetName("Ware descritisation")
77
71
72
hypNbSeg = algoWireDes.NumberOfSegments(numberOfSegment)
78
print hypNbSeg.GetName()
73
print hypNbSeg.GetName()
79
print hypNbSeg.GetNumberOfSegments()
74
print hypNbSeg.GetNumberOfSegments()
80
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "Nb. Segments")
75
smesh.SetName(hypNbSeg, "Nb. Segments")
81
76
82
77
83
#--------------------------Max. Element Area
78
#--------------------------Max. Element Area
84
maxElementArea = 200
79
maxElementArea = 200
85
80
86
hypArea200 = smesh.CreateHypothesis("MaxElementArea","libStdMeshersEngine.so")
81
algoMef = mesh.Triangle()
87
hypArea200.SetMaxElementArea( maxElementArea )
88
print hypArea200.GetName()
89
print hypArea200.GetMaxElementArea()
90
91
smeshgui.SetName(salome.ObjectToID(hypArea200), "Max. Element Area")
92
93
print"---------------------Algorithms"
94
95
#----------------------------Wire discretisation
96
algoWireDes = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
97
listHyp = algoWireDes.GetCompatibleHypothesis()
98
99
print algoWireDes.GetName()
100
smeshgui.SetName(salome.ObjectToID(algoWireDes), "Ware descritisation")
101
102
#----------------------------Triangle (Mefisto)
103
algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
104
listHyp = algoMef.GetCompatibleHypothesis()
82
listHyp = algoMef.GetCompatibleHypothesis()
105
106
print algoMef.GetName()
83
print algoMef.GetName()
84
algoMef.SetName("Triangle (Mefisto)")
107
85
108
#----------------------------Add hipothesis to the plane
86
hypArea200 = algoMef.MaxElementArea(maxElementArea)
109
mesh.AddHypothesis( plane_mesh, hypNbSeg )     # nb segments
87
print hypArea200.GetName()
110
mesh.AddHypothesis( plane_mesh, hypArea200 )   # max area
88
print hypArea200.GetMaxElementArea()
111
89
smesh.SetName(hypArea200, "Max. Element Area")
112
mesh.AddHypothesis( plane_mesh, algoWireDes )  # Regular 1D/wire discretisation
113
mesh.AddHypothesis( plane_mesh, algoMef )      # MEFISTO 2D
114
90
115
smeshgui.SetName(salome.ObjectToID(algoMef), "Triangle (Mefisto)")
116
91
117
print "---------------------Compute the mesh"
92
print "---------------------Compute the mesh"
118
93
119
smesh.Compute(mesh, plane_mesh)
94
ret = mesh.Compute()
95
print ret
120
96
121
salome.sg.updateObjBrowser(1)
97
salome.sg.updateObjBrowser(1)
122
98
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/PAL_MESH_043_2D.py (-41 / +15 lines)
Lines 25-32 Link Here
25
25
26
import salome
26
import salome
27
import geompy
27
import geompy
28
import SMESH
28
import smesh
29
import StdMeshers
29
30
30
31
#----------------------------------GEOM
31
#----------------------------------GEOM
32
32
Lines 51-101 Link Here
51
51
52
52
53
#---------------------------------SMESH
53
#---------------------------------SMESH
54
# get smesh engine
55
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
56
smesh.SetCurrentStudy(salome.myStudy)
57
58
# get SMESH GUI
59
smeshgui = salome.ImportComponentGUI("SMESH")
60
smeshgui.Init(salome.myStudyId)
61
62
# create hypoteses
63
hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
64
hypNbSeg1.SetNumberOfSegments(18)
65
id_hypNbSeg1 = salome.ObjectToID(hypNbSeg1) 
66
smeshgui.SetName(id_hypNbSeg1, "NumberOfSegments 1");
67
68
hypNbSeg2 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
69
hypNbSeg2.SetNumberOfSegments(34)
70
id_hypNbSeg2 = salome.ObjectToID(hypNbSeg2) 
71
smeshgui.SetName(id_hypNbSeg2, "NumberOfSegments 2");
72
73
# create algorithmes
74
algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
75
id_algoReg = salome.ObjectToID(algoReg)
76
smeshgui.SetName(id_algoReg, "Regular_1D");
77
54
78
# create the path mesh
55
# create the path mesh
79
mesh1 = smesh.CreateMesh(ellipse1)
56
mesh1 = smesh.Mesh(ellipse1, "Path Mesh")
80
id_mesh1 = salome.ObjectToID(mesh1)
57
81
smeshgui.SetName(id_mesh1, "Path Mesh");
58
algoReg1 = mesh1.Segment()
82
59
algoReg1.SetName("Regular_1D")
83
# set hypotheses and algos
60
hypNbSeg1 = algoReg1.NumberOfSegments(18)
84
mesh1.AddHypothesis(ellipse1,algoReg)
61
smesh.SetName(hypNbSeg1, "NumberOfSegments 1")
85
mesh1.AddHypothesis(ellipse1,hypNbSeg1)
86
62
87
# create the tool mesh
63
# create the tool mesh
88
mesh2 = smesh.CreateMesh(ellipse2)
64
mesh2 = smesh.Mesh(ellipse2, "Tool Mesh")
89
id_mesh2 = salome.ObjectToID(mesh2)
65
algoReg2 = mesh2.Segment()
90
smeshgui.SetName(id_mesh2, "Tool Mesh");
66
algoReg2.SetName("Regular_1D")
91
67
hypNbSeg2 = algoReg2.NumberOfSegments(34)
92
# set hypotheses and algos
68
smesh.SetName(hypNbSeg2, "NumberOfSegments 2")
93
mesh2.AddHypothesis(ellipse2,algoReg)
94
mesh2.AddHypothesis(ellipse2,hypNbSeg2)
95
69
96
# compute meshes
70
# compute meshes
97
smesh.Compute(mesh1,ellipse1)
71
mesh1.Compute()
98
smesh.Compute(mesh2,ellipse2)
72
mesh2.Compute()
99
73
100
74
101
# ---- udate object browser
75
# ---- udate object browser
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/PAL_MESH_043_3D.py (-46 / +28 lines)
Lines 25-36 Link Here
25
25
26
import salome
26
import salome
27
import geompy
27
import geompy
28
import SMESH
28
import smesh
29
import StdMeshers
30
29
31
# get smesh engine
32
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
33
smesh.SetCurrentStudy(salome.myStudy)
34
30
35
# create points to build two circles
31
# create points to build two circles
36
p1 = geompy.MakeVertex(0,  100,  0)
32
p1 = geompy.MakeVertex(0,  100,  0)
Lines 52-104 Link Here
52
idcircle = geompy.addToStudy(circle, "Circle")
48
idcircle = geompy.addToStudy(circle, "Circle")
53
idface   = geompy.addToStudy(face,   "Circular face")
49
idface   = geompy.addToStudy(face,   "Circular face")
54
50
55
# get SMESH GUI
51
56
smeshgui = salome.ImportComponentGUI("SMESH")
57
smeshgui.Init(salome.myStudyId)
58
59
# create hypoteses
60
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
61
hypNbSeg.SetNumberOfSegments(12)
62
idseg = salome.ObjectToID(hypNbSeg) 
63
smeshgui.SetName(idseg, "NumberOfSegments_10");
64
65
hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
66
hypArea.SetMaxElementArea(30)
67
idarea = salome.ObjectToID(hypArea)
68
smeshgui.SetName(idarea, "MaxElementArea_20");
69
70
# create algorithmes
71
algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
72
idreg = salome.ObjectToID(algoReg)
73
smeshgui.SetName(idreg, "Regular_1D");
74
75
algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
76
idmef = salome.ObjectToID(algoMef)
77
smeshgui.SetName(idmef, "MEFISTO_2D");
78
52
79
# init a Mesh with the circular face
53
# init a Mesh with the circular face
80
mesh1 = smesh.CreateMesh(face)
54
mesh1 = smesh.Mesh(face, "Mesh on circular face")
81
idmesh1 = salome.ObjectToID(mesh1)
55
82
smeshgui.SetName(idmesh1, "Mesh on circular face");
56
# set hypotheses and algos to the first mesh
83
57
numberOfSegments1 = 12
84
# set hypotheses and algos
58
algoReg1 = mesh1.Segment()
85
mesh1.AddHypothesis(face,algoReg)
59
algoReg1.SetName("Regular_1D")
86
mesh1.AddHypothesis(face,hypNbSeg)
60
hypNbSeg1 = algoReg1.NumberOfSegments(numberOfSegments1)
87
mesh1.AddHypothesis(face,algoMef)
61
smesh.SetName(hypNbSeg1, "NumberOfSegments_" + str(numberOfSegments1))
88
mesh1.AddHypothesis(face,hypArea)
62
63
maxElementArea = 30
64
65
algoMef = mesh1.Triangle()
66
algoMef.SetName("MEFISTO_2D")
67
hypArea = algoMef.MaxElementArea(maxElementArea)
68
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
69
89
70
90
# init a Mesh with the second circle
71
# init a Mesh with the second circle
91
mesh2 = smesh.CreateMesh(circle)
72
mesh2 = smesh.Mesh(circle, "Mesh on circular edge")
92
idmesh2 = salome.ObjectToID(mesh2)
73
93
smeshgui.SetName(idmesh2, "Mesh on circular edge");
74
numberOfSegments2 = 12
94
75
algoReg2 = mesh2.Segment()
95
# set hypotheses and algos
76
algoReg2.SetName("Regular_1D")
96
mesh2.AddHypothesis(circle,algoReg)
77
hypNbSeg2 = algoReg2.NumberOfSegments(numberOfSegments2)
97
mesh2.AddHypothesis(circle,hypNbSeg)
78
smesh.SetName(hypNbSeg2, "NumberOfSegments_" + str(numberOfSegments2))
79
98
80
99
# compute meshes
81
# compute meshes
100
smesh.Compute(mesh1,face)
82
mesh1.Compute()
101
smesh.Compute(mesh2,circle)
83
mesh2.Compute()
102
84
103
# ---- udate object browser
85
# ---- udate object browser
104
salome.sg.updateObjBrowser(1);
86
salome.sg.updateObjBrowser(1);
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_AdvancedEditor.py (-47 / +45 lines)
Lines 18-24 Link Here
18
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
#
19
#
20
import smesh
20
import smesh
21
import SMESH
22
import math
21
import math
23
22
24
def GetNewNodes(mesh,Elems,OldNodes):
23
def GetNewNodes(mesh,Elems,OldNodes):
Lines 51-95 Link Here
51
            
50
            
52
    
51
    
53
# create empty mesh
52
# create empty mesh
54
mesh = smesh.smesh.CreateEmptyMesh()
53
mesh = smesh.Mesh()
55
54
56
ed = mesh.GetMeshEditor()
57
tol = 0.001
55
tol = 0.001
58
56
59
# create a cross from quadrangle faces
57
# create a cross from quadrangle faces
60
# 1. create first edge and make extrusion along 0x
58
# 1. create first edge and make extrusion along 0x
61
n1 = ed.AddNode(55,-5,0)
59
n1 = mesh.AddNode(55,-5,0)
62
n2 = ed.AddNode(55,5,0)
60
n2 = mesh.AddNode(55,5,0)
63
e1 = ed.AddEdge([n1,n2])
61
e1 = mesh.AddEdge([n1,n2])
64
dir1 = SMESH.DirStruct(SMESH.PointStruct(-10,0,0))
62
dir1 = smesh.DirStruct(smesh.PointStruct(-10,0,0))
65
ed.ExtrusionSweep([e1],dir1,11)
63
mesh.ExtrusionSweep([e1],dir1,11)
66
# 2. create second edge and make extrusion along 0y
64
# 2. create second edge and make extrusion along 0y
67
n3 = ed.AddNode(-5,-55,0)
65
n3 = mesh.AddNode(-5,-55,0)
68
n4 = ed.AddNode(5,-55,0)
66
n4 = mesh.AddNode(5,-55,0)
69
e2 = ed.AddEdge([n3,n4])
67
e2 = mesh.AddEdge([n3,n4])
70
dir2 = SMESH.DirStruct(SMESH.PointStruct(0,10,0))
68
dir2 = smesh.DirStruct(smesh.PointStruct(0,10,0))
71
ed.ExtrusionSweep([e2],dir2,11)
69
mesh.ExtrusionSweep([e2],dir2,11)
72
70
73
# since result has coincident nodes and faces
71
# since result has coincident nodes and faces
74
# we have to make merge
72
# we have to make merge
75
nodes = ed.FindCoincidentNodes(0.001)
73
nodes = mesh.FindCoincidentNodes(0.001)
76
ed.MergeNodes(nodes)
74
mesh.MergeNodes(nodes)
77
ed.MergeEqualElements()
75
mesh.MergeEqualElements()
78
76
79
# make extrusion faces along 0z
77
# make extrusion faces along 0z
80
faces = mesh.GetElementsByType(SMESH.FACE)
78
faces = mesh.GetElementsByType(smesh.FACE)
81
nbf = len(faces)
79
nbf = len(faces)
82
maxang = 2.0
80
maxang = 2.0
83
zstep = 5
81
zstep = 5
84
nbzsteps = 50
82
nbzsteps = 50
85
dir3 = SMESH.DirStruct(SMESH.PointStruct(0,0,zstep))
83
dir3 = smesh.DirStruct(smesh.PointStruct(0,0,zstep))
86
newfaces = [] # list for keeping created top faces
84
newfaces = [] # list for keeping created top faces
87
              # during extrusion
85
              # during extrusion
88
86
89
for i in range(0,nbzsteps):
87
for i in range(0,nbzsteps):
90
    ed.ExtrusionSweep(faces,dir3,1)
88
    mesh.ExtrusionSweep(faces,dir3,1)
91
    # find top faces after each extrusion and keep them
89
    # find top faces after each extrusion and keep them
92
    res = ed.GetLastCreatedElems()
90
    res = mesh.GetLastCreatedElems()
93
    nbr = len(res)
91
    nbr = len(res)
94
    nfaces = []
92
    nfaces = []
95
    for j in res:
93
    for j in res:
Lines 115-137 Link Here
115
    pass
113
    pass
116
    
114
    
117
# rotate faces from newfaces
115
# rotate faces from newfaces
118
axisr1 = SMESH.AxisStruct(0,0,0,0,0,1)
116
axisr1 = smesh.AxisStruct(0,0,0,0,0,1)
119
for i in range(0,nbzsteps):
117
for i in range(0,nbzsteps):
120
    ang = maxang*(1-math.cos((i+1)*math.pi/nbzsteps))
118
    ang = maxang*(1-math.cos((i+1)*math.pi/nbzsteps))
121
    ed.Rotate(newfaces[i],axisr1,ang,0)
119
    mesh.Rotate(newfaces[i],axisr1,ang,0)
122
120
123
121
124
# create circles
122
# create circles
125
# create two edges and rotate them for creation
123
# create two edges and rotate them for creation
126
# full circle
124
# full circle
127
n5 = ed.AddNode(65,0,0)
125
n5 = mesh.AddNode(65,0,0)
128
n6 = ed.AddNode(67.5,0,0)
126
n6 = mesh.AddNode(67.5,0,0)
129
n7 = ed.AddNode(70,0,0)
127
n7 = mesh.AddNode(70,0,0)
130
e56 = ed.AddEdge([n5,n6])
128
e56 = mesh.AddEdge([n5,n6])
131
e67 = ed.AddEdge([n6,n7])
129
e67 = mesh.AddEdge([n6,n7])
132
axisr2 = SMESH.AxisStruct(65,0,0,0,1,0)
130
axisr2 = smesh.AxisStruct(65,0,0,0,1,0)
133
ed.RotationSweep([e56,e67],axisr2, math.pi/6, 12, tol)
131
mesh.RotationSweep([e56,e67],axisr2, math.pi/6, 12, tol)
134
res = ed.GetLastCreatedElems()
132
res = mesh.GetLastCreatedElems()
135
faces1 = []
133
faces1 = []
136
for i in res:
134
for i in res:
137
    nbn = mesh.GetElemNbNodes(i)
135
    nbn = mesh.GetElemNbNodes(i)
Lines 141-154 Link Here
141
139
142
# create other two edges and rotate them for creation
140
# create other two edges and rotate them for creation
143
# other full circle
141
# other full circle
144
n8 = ed.AddNode(-65,0,0)
142
n8 = mesh.AddNode(-65,0,0)
145
n9 = ed.AddNode(-67.5,0,0)
143
n9 = mesh.AddNode(-67.5,0,0)
146
n10 = ed.AddNode(-70,0,0)
144
n10 = mesh.AddNode(-70,0,0)
147
e8 = ed.AddEdge([n8,n9])
145
e8 = mesh.AddEdge([n8,n9])
148
e9 = ed.AddEdge([n9,n10])
146
e9 = mesh.AddEdge([n9,n10])
149
axisr3 = SMESH.AxisStruct(-65,0,0,0,-1,0)
147
axisr3 = smesh.AxisStruct(-65,0,0,0,-1,0)
150
ed.RotationSweep([e8,e9],axisr3, math.pi/6, 12, tol)
148
mesh.RotationSweep([e8,e9],axisr3, math.pi/6, 12, tol)
151
res = ed.GetLastCreatedElems()
149
res = mesh.GetLastCreatedElems()
152
faces2 = []
150
faces2 = []
153
for i in res:
151
for i in res:
154
    nbn = mesh.GetElemNbNodes(i)
152
    nbn = mesh.GetElemNbNodes(i)
Lines 158-165 Link Here
158
156
159
# there are coincident nodes after rotation
157
# there are coincident nodes after rotation
160
# therefore we have to merge nodes
158
# therefore we have to merge nodes
161
nodes = ed.FindCoincidentNodes(0.001)
159
nodes = mesh.FindCoincidentNodes(0.001)
162
ed.MergeNodes(nodes)
160
mesh.MergeNodes(nodes)
163
161
164
nbcircs = 2
162
nbcircs = 2
165
nbrsteps = 24
163
nbrsteps = 24
Lines 172-179 Link Here
172
oldnodes = newnodes
170
oldnodes = newnodes
173
171
174
nodes = []
172
nodes = []
175
ed.RotationSweep(faces1,axisr1, math.pi*2/nbrsteps, nbrs, tol)
173
mesh.RotationSweep(faces1,axisr1, math.pi*2/nbrsteps, nbrs, tol)
176
res = ed.GetLastCreatedElems()
174
res = mesh.GetLastCreatedElems()
177
175
178
for i in range(0,nbrs):
176
for i in range(0,nbrs):
179
    volumes = []
177
    volumes = []
Lines 181-187 Link Here
181
    newnodes = GetNewNodes(mesh,volumes,oldnodes)
179
    newnodes = GetNewNodes(mesh,volumes,oldnodes)
182
    for j in newnodes:
180
    for j in newnodes:
183
        xyz = mesh.GetNodeXYZ(j)
181
        xyz = mesh.GetNodeXYZ(j)
184
        ed.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
182
        mesh.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
185
        pass
183
        pass
186
    oldnodes = newnodes
184
    oldnodes = newnodes
187
    pass
185
    pass
Lines 192-199 Link Here
192
oldnodes = newnodes
190
oldnodes = newnodes
193
191
194
nodes = []
192
nodes = []
195
ed.RotationSweep(faces2,axisr1, math.pi*2/nbrsteps, nbrs, tol)
193
mesh.RotationSweep(faces2,axisr1, math.pi*2/nbrsteps, nbrs, tol)
196
res = ed.GetLastCreatedElems()
194
res = mesh.GetLastCreatedElems()
197
195
198
for i in range(0,nbrs):
196
for i in range(0,nbrs):
199
    volumes = []
197
    volumes = []
Lines 201-209 Link Here
201
    newnodes = GetNewNodes(mesh,volumes,oldnodes)
199
    newnodes = GetNewNodes(mesh,volumes,oldnodes)
202
    for j in newnodes:
200
    for j in newnodes:
203
        xyz = mesh.GetNodeXYZ(j)
201
        xyz = mesh.GetNodeXYZ(j)
204
        ed.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
202
        mesh.MoveNode(j,xyz[0],xyz[1],xyz[2]+dz*(i+1))
205
        pass
203
        pass
206
    oldnodes = newnodes
204
    oldnodes = newnodes
207
    pass
205
    pass
208
206
209
    
207
smesh.salome.sg.updateObjBrowser(1)
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_BelongToGeom.py (-5 / +22 lines)
Lines 17-26 Link Here
17
#
17
#
18
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
#
19
#
20
import SMESH
20
21
from SMESH_test1 import *
21
from SMESH_test1 import *
22
22
23
def CheckBelongToGeomFilter(theMeshGen, theMesh, theShape, theSubShape, theElemType):
23
## Old style
24
def CheckBelongToGeomFilterOld(theMeshGen, theMesh, theShape, theSubShape, theElemType):
24
    import geompy
25
    import geompy
25
    if theShape != theSubShape:
26
    if theShape != theSubShape:
26
        aName = str(theSubShape)
27
        aName = str(theSubShape)
Lines 38-47 Link Here
38
    aFilter.SetPredicate(aBelongToGeom)
39
    aFilter.SetPredicate(aBelongToGeom)
39
    return aFilter.GetElementsId(theMesh)
40
    return aFilter.GetElementsId(theMesh)
40
41
41
anElemType = SMESH.ALL;
42
## Current style
43
def CheckBelongToGeomFilter(theMesh, theShape, theSubShape, theElemType):
44
    import geompy
45
    if theShape != theSubShape:
46
        aName = str(theSubShape)
47
        geompy.addToStudyInFather(theShape,theSubShape,aName)
48
49
    theMesh.Compute()
50
    aFilter = theMesh.GetFilter(theElemType, smesh.FT_BelongToGeom, theSubShape)
51
    return aFilter.GetElementsId(theMesh.GetMesh())
52
    
53
54
anElemType = smesh.FACE;
42
print "anElemType =", anElemType
55
print "anElemType =", anElemType
43
#anIds = CheckBelongToGeomFilter(smesh,mesh,box,subShapeList[1],SMESH.FACE)
56
#anIds = CheckBelongToGeomFilter(mesh,box,subShapeList[1],anElemType)
44
anIds = CheckBelongToGeomFilter(smesh,mesh,box,box,SMESH.FACE)
57
anIds = CheckBelongToGeomFilter(mesh,box,box,anElemType)
58
print "Number of ids = ", len(anIds)
45
print "anIds = ", anIds
59
print "anIds = ", anIds
60
## Check old version
61
#anIds = CheckBelongToGeomFilterOld(smesh.smesh,mesh.GetMesh(),box,box,anElemType)
62
#print "anIds = ", anIds
46
63
47
salome.sg.updateObjBrowser(1);
64
salome.sg.updateObjBrowser(1);
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_GroupFromGeom.py (-4 / +3 lines)
Lines 23-33 Link Here
23
#  Module : SMESH
23
#  Module : SMESH
24
24
25
from SMESH_test1 import *
25
from SMESH_test1 import *
26
import SMESH
27
26
28
# Compute the mesh created in SMESH_test1
27
# Compute the mesh created in SMESH_test1
29
28
30
smesh.Compute(mesh, box)
29
mesh.Compute()
31
30
32
# Create geometry groups on plane:
31
# Create geometry groups on plane:
33
aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"])
32
aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"])
Lines 43-49 Link Here
43
geompy.addToStudy(aGeomGroup1, "Group on Faces")
42
geompy.addToStudy(aGeomGroup1, "Group on Faces")
44
geompy.addToStudy(aGeomGroup2, "Group on Edges")
43
geompy.addToStudy(aGeomGroup2, "Group on Edges")
45
44
46
aSmeshGroup1 = mesh.CreateGroupFromGEOM(SMESH.FACE, "SMESHGroup1", aGeomGroup1)
45
aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", smesh.FACE)
47
aSmeshGroup2 = mesh.CreateGroupFromGEOM(SMESH.EDGE, "SMESHGroup2", aGeomGroup2)
46
aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", smesh.EDGE)
48
47
49
salome.sg.updateObjBrowser(1);
48
salome.sg.updateObjBrowser(1);
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_GroupFromGeom2.py (-6 / +6 lines)
Lines 25-35 Link Here
25
#  Project                  : PAL/SALOME
25
#  Project                  : PAL/SALOME
26
#============================================================================== 
26
#============================================================================== 
27
from SMESH_test1 import *
27
from SMESH_test1 import *
28
import SMESH
28
29
29
30
# Compute the mesh created in SMESH_test1
30
# Compute the mesh created in SMESH_test1
31
31
32
smesh.Compute(mesh, box)
32
mesh.Compute()
33
33
34
# Create geometry groups on plane:
34
# Create geometry groups on plane:
35
aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"])
35
aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"])
Lines 45-55 Link Here
45
geompy.addToStudy(aGeomGroup1, "Group on Faces")
45
geompy.addToStudy(aGeomGroup1, "Group on Faces")
46
geompy.addToStudy(aGeomGroup2, "Group on Edges")
46
geompy.addToStudy(aGeomGroup2, "Group on Edges")
47
47
48
aSmeshGroup1 = mesh.CreateGroupFromGEOM(SMESH.FACE, "SMESHGroup1", aGeomGroup1)
48
aSmeshGroup1 = mesh.GroupOnGeom(aGeomGroup1, "SMESHGroup1", smesh.FACE)
49
aSmeshGroup2 = mesh.CreateGroupFromGEOM(SMESH.EDGE, "SMESHGroup2", aGeomGroup2)
49
aSmeshGroup2 = mesh.GroupOnGeom(aGeomGroup2, "SMESHGroup2", smesh.EDGE)
50
50
51
print "Create aGroupOnShell - a group linked to a shell"
51
print "Create aGroupOnShell - a group linked to a shell"
52
aGroupOnShell = mesh.CreateGroupFromGEOM(SMESH.EDGE, "GroupOnShell", shell)
52
aGroupOnShell = mesh.GroupOnGeom(shell, "GroupOnShell", smesh.EDGE)
53
print "aGroupOnShell type =", aGroupOnShell.GetType()
53
print "aGroupOnShell type =", aGroupOnShell.GetType()
54
print "aGroupOnShell size =", aGroupOnShell.Size()
54
print "aGroupOnShell size =", aGroupOnShell.Size()
55
print "aGroupOnShell ids :", aGroupOnShell.GetListOfID()
55
print "aGroupOnShell ids :", aGroupOnShell.GetListOfID()
Lines 65-71 Link Here
65
print " "
65
print " "
66
66
67
print "Re-compute mesh, contents of aGroupOnShell changes again:"
67
print "Re-compute mesh, contents of aGroupOnShell changes again:"
68
smesh.Compute(mesh, box)
68
mesh.Compute()
69
print "aGroupOnShell size =", aGroupOnShell.Size()
69
print "aGroupOnShell size =", aGroupOnShell.Size()
70
print "aGroupOnShell ids :", aGroupOnShell.GetListOfID()
70
print "aGroupOnShell ids :", aGroupOnShell.GetListOfID()
71
71
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_GroupLyingOnGeom.py (-4 / +9 lines)
Lines 17-26 Link Here
17
#
17
#
18
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
#
19
#
20
from smesh import *
20
import smesh
21
21
22
def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
22
def BuildGroupLyingOn(theMesh, theElemType, theName, theShape):
23
    aFilterMgr = smesh.CreateFilterManager()
23
    aFilterMgr = smesh.smesh.CreateFilterManager()
24
    aFilter = aFilterMgr.CreateFilter()
24
    aFilter = aFilterMgr.CreateFilter()
25
   
25
   
26
    aLyingOnGeom = aFilterMgr.CreateLyingOnGeom()
26
    aLyingOnGeom = aFilterMgr.CreateLyingOnGeom()
Lines 36-42 Link Here
36
#Example
36
#Example
37
from SMESH_test1 import *
37
from SMESH_test1 import *
38
38
39
smesh.Compute(mesh, box)
39
mesh.Compute()
40
BuildGroupLyingOn(mesh, SMESH.FACE, "Group of faces lying on edge", edge )
40
41
# First way
42
BuildGroupLyingOn(mesh.GetMesh(), smesh.FACE, "Group of faces lying on edge #1", edge )
43
44
# Second way
45
mesh.MakeGroup("Group of faces lying on edge #2", smesh.FACE, smesh.FT_LyingOnGeom, edge)
41
46
42
salome.sg.updateObjBrowser(1);
47
salome.sg.updateObjBrowser(1);
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_Nut.py (-58 / +21 lines)
Lines 24-33 Link Here
24
24
25
import geompy
25
import geompy
26
import salome
26
import salome
27
import smesh
27
import os
28
import os
28
import math
29
import math
29
import StdMeshers
30
import SMESH
31
30
32
#Sketcher_1 creation
31
#Sketcher_1 creation
33
print "Sketcher creation..."
32
print "Sketcher creation..."
Lines 94-172 Link Here
94
Cut_1_ID = geompy.addToStudy(Cut_1, "Cut_1")
93
Cut_1_ID = geompy.addToStudy(Cut_1, "Cut_1")
95
94
96
#Mesh creation
95
#Mesh creation
97
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
98
96
99
# -- Init --
97
# -- Init --
100
shape_mesh = salome.IDToObject( Cut_1_ID )
98
shape_mesh = salome.IDToObject( Cut_1_ID )
101
smesh.SetCurrentStudy(salome.myStudy)
99
102
mesh = smesh.CreateMesh(shape_mesh)
100
mesh = smesh.Mesh(shape_mesh, "Nut")
103
smeshgui = salome.ImportComponentGUI("SMESH")
104
smeshgui.Init(salome.myStudyId)
105
idmesh = salome.ObjectToID(mesh)
106
smeshgui.SetName( idmesh, "Nut" )
107
101
108
#HYPOTHESIS CREATION
102
#HYPOTHESIS CREATION
109
print "-------------------------- Average length"
103
print "-------------------------- Average length"
110
theAverageLength = 5
104
theAverageLength = 5
111
hAvLength = smesh.CreateHypothesis( "LocalLength", "libStdMeshersEngine.so" )
105
algoReg1D = mesh.Segment()
112
hAvLength.SetLength( theAverageLength )
106
hAvLength = algoReg1D.LocalLength(theAverageLength)
113
print hAvLength.GetName()
107
print hAvLength.GetName()
114
print hAvLength.GetId()
108
print hAvLength.GetId()
115
smeshgui.SetName(salome.ObjectToID(hAvLength), "AverageLength_5")
109
print hAvLength.GetLength()
110
smesh.SetName(hAvLength, "AverageLength_"+str(theAverageLength))
116
111
117
print "-------------------------- MaxElementArea"
112
print "-------------------------- MaxElementArea"
118
theMaxElementArea = 20
113
theMaxElementArea = 20
119
hArea20 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
114
algoMef = mesh.Triangle(smesh.MEFISTO)
120
hArea20.SetMaxElementArea( theMaxElementArea )
115
hArea = algoMef.MaxElementArea( theMaxElementArea )
121
print hArea20.GetName()
116
print hArea.GetName()
122
print hArea20.GetId()
117
print hArea.GetId()
123
print hArea20.GetMaxElementArea()
118
print hArea.GetMaxElementArea()
124
smeshgui.SetName(salome.ObjectToID(hArea20), "MaxElementArea_20")
119
smesh.SetName(hArea, "MaxElementArea_"+str(theMaxElementArea))
125
120
126
print "-------------------------- MaxElementVolume"
121
print "-------------------------- MaxElementVolume"
127
theMaxElementVolume = 150
122
theMaxElementVolume = 150
128
hVolume150 = smesh.CreateHypothesis( "MaxElementVolume", "libStdMeshersEngine.so" )
123
algoNg = mesh.Tetrahedron(smesh.NETGEN)
129
hVolume150.SetMaxElementVolume( theMaxElementVolume )
124
hVolume = algoNg.MaxElementVolume( theMaxElementVolume )
130
print hVolume150.GetName()
125
print hVolume.GetName()
131
print hVolume150.GetId()
126
print hVolume.GetId()
132
print hVolume150.GetMaxElementVolume()
127
print hVolume.GetMaxElementVolume()
133
smeshgui.SetName(salome.ObjectToID(hVolume150), "MaxElementVolume_150")
128
smesh.SetName(hVolume, "MaxElementVolume_"+str(theMaxElementVolume))
134
129
135
mesh.AddHypothesis(shape_mesh, hAvLength)
136
mesh.AddHypothesis(shape_mesh, hArea20)
137
mesh.AddHypothesis(shape_mesh, hVolume150)
138
139
print "-------------------------- Regular_1D"
140
141
algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
142
listHyp = algoReg1D.GetCompatibleHypothesis()
143
for hyp in listHyp:
144
    print hyp
145
print algoReg1D.GetName()
146
print algoReg1D.GetId()
147
smeshgui.SetName(salome.ObjectToID(algoReg1D), "Wire discretisation")
148
149
print "-------------------------- MEFISTO_2D"
150
algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
151
listHyp = algoMef.GetCompatibleHypothesis()
152
for hyp in listHyp:
153
    print hyp
154
print algoMef.GetName()
155
print algoMef.GetId()
156
smeshgui.SetName(salome.ObjectToID(algoMef), "Triangle (Mefisto)")
157
158
print "-------------------------- NETGEN_3D"
159
160
algoNg = smesh.CreateHypothesis( "NETGEN_3D", "libNETGENEngine.so" )
161
print algoNg.GetName()
162
print algoNg.GetId()
163
smeshgui.SetName(salome.ObjectToID(algoNg), "Tetrahedron (NETGEN)")
164
mesh.AddHypothesis(shape_mesh, algoReg1D)
165
mesh.AddHypothesis(shape_mesh, algoMef)
166
mesh.AddHypothesis(shape_mesh, algoNg)
167
130
168
print "-------------------------- compute the mesh of the mechanic piece"
131
print "-------------------------- compute the mesh of the mechanic piece"
169
smesh.Compute(mesh,shape_mesh)
132
mesh.Compute()
170
133
171
print "Information about the Nut:"
134
print "Information about the Nut:"
172
print "Number of nodes       : ", mesh.NbNodes()
135
print "Number of nodes       : ", mesh.NbNodes()
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_Partition1_tetra.py (-57 / +16 lines)
Lines 26-41 Link Here
26
26
27
import salome
27
import salome
28
import geompy
28
import geompy
29
import smesh
29
from math import sqrt
30
from math import sqrt
30
31
31
import StdMeshers
32
import NETGENPlugin
33
34
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
35
smesh.SetCurrentStudy(salome.myStudy)
36
37
smeshgui = salome.ImportComponentGUI("SMESH")
38
smeshgui.Init(salome.myStudyId)
39
32
40
#---------------------------------------------------------------
33
#---------------------------------------------------------------
41
34
Lines 125-206 Link Here
125
118
126
# ---- launch SMESH
119
# ---- launch SMESH
127
120
121
# ---- init a Mesh with the alveole
122
shape_mesh = salome.IDToObject( idalveole )
123
124
mesh = smesh.Mesh(shape_mesh, "MeshAlveole")
125
128
print "-------------------------- create Hypothesis (In this case global hypothesis are used)"
126
print "-------------------------- create Hypothesis (In this case global hypothesis are used)"
129
127
130
print "-------------------------- NumberOfSegments"
128
print "-------------------------- NumberOfSegments"
131
129
132
numberOfSegments = 10
130
numberOfSegments = 10
133
131
134
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
132
regular1D = mesh.Segment()
135
hypNbSeg.SetNumberOfSegments(numberOfSegments)
133
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
136
print hypNbSeg.GetName()
134
print hypNbSeg.GetName()
137
print hypNbSeg.GetId()
135
print hypNbSeg.GetId()
138
print hypNbSeg.GetNumberOfSegments()
136
print hypNbSeg.GetNumberOfSegments()
139
137
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
140
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
141
138
142
print "-------------------------- MaxElementArea"
139
print "-------------------------- MaxElementArea"
143
140
144
maxElementArea = 0.1
141
maxElementArea = 0.1
145
142
146
hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
143
mefisto2D = mesh.Triangle()
147
hypArea.SetMaxElementArea(maxElementArea)
144
hypArea = mefisto2D.MaxElementArea(maxElementArea)
148
print hypArea.GetName()
145
print hypArea.GetName()
149
print hypArea.GetId()
146
print hypArea.GetId()
150
print hypArea.GetMaxElementArea()
147
print hypArea.GetMaxElementArea()
151
148
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
152
smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_0.1")
153
149
154
print "-------------------------- MaxElementVolume"
150
print "-------------------------- MaxElementVolume"
155
151
156
maxElementVolume = 0.5
152
maxElementVolume = 0.5
157
153
158
hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
154
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
159
hypVolume.SetMaxElementVolume(maxElementVolume)
155
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
160
print hypVolume.GetName()
156
print hypVolume.GetName()
161
print hypVolume.GetId()
157
print hypVolume.GetId()
162
print hypVolume.GetMaxElementVolume()
158
print hypVolume.GetMaxElementVolume()
163
159
smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
164
smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_0.5")
165
166
print "-------------------------- create Algorithms"
167
168
print "-------------------------- Regular_1D"
169
170
regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
171
smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
172
173
print "-------------------------- MEFISTO_2D"
174
175
mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
176
smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
177
178
print "-------------------------- NETGEN_3D"
179
180
netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
181
smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
182
183
# ---- init a Mesh with the alveole
184
shape_mesh = salome.IDToObject( idalveole )
185
186
mesh = smesh.CreateMesh(shape_mesh)
187
smeshgui.SetName(salome.ObjectToID(mesh), "MeshAlveole")
188
189
# ---- add hypothesis to alveole
190
191
print "-------------------------- add hypothesis to alveole"
192
193
mesh.AddHypothesis(shape_mesh,regular1D)
194
mesh.AddHypothesis(shape_mesh,hypNbSeg)
195
196
mesh.AddHypothesis(shape_mesh,mefisto2D)
197
mesh.AddHypothesis(shape_mesh,hypArea)
198
199
mesh.AddHypothesis(shape_mesh,netgen3D)
200
mesh.AddHypothesis(shape_mesh,hypVolume)
201
160
202
print "-------------------------- compute the mesh of alveole "
161
print "-------------------------- compute the mesh of alveole "
203
ret = smesh.Compute(mesh,shape_mesh)
162
ret = mesh.Compute()
204
163
205
if ret != 0:
164
if ret != 0:
206
    log=mesh.GetLog(0) # no erase trace
165
    log=mesh.GetLog(0) # no erase trace
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_blocks.py (-4 / +2 lines)
Lines 28-43 Link Here
28
import salome
28
import salome
29
import geompy
29
import geompy
30
import math
30
import math
31
import smesh
31
32
32
import GEOM_Spanner
33
import GEOM_Spanner
33
34
34
isBlocksTest = 0 # False
35
isBlocksTest = 0 # False
35
isMeshTest   = 1 # True
36
isMeshTest   = 1 # True
36
hasGUI       = 1 # True
37
37
38
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
39
smesh.SetCurrentStudy(salome.myStudy)
40
38
41
GEOM_Spanner.MakeSpanner(salome, geompy, math, isBlocksTest, isMeshTest, smesh, hasGUI)
39
GEOM_Spanner.MakeSpanner(geompy, math, isBlocksTest, isMeshTest, smesh)
42
40
43
salome.sg.updateObjBrowser(1);
41
salome.sg.updateObjBrowser(1);
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_box.py (-38 / +16 lines)
Lines 30-92 Link Here
30
import salome
30
import salome
31
from salome import sg
31
from salome import sg
32
import geompy
32
import geompy
33
import smesh
33
34
34
import StdMeshers
35
35
36
# ---- launch GEOM
36
# ---- launch GEOM
37
37
38
geom          = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
38
geom          = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
39
meshgenerator = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
40
39
41
###geom.GetCurrentStudy(salome.myStudy._get_StudyId())
40
###geom.GetCurrentStudy(salome.myStudy._get_StudyId())
42
meshgenerator.SetCurrentStudy(salome.myStudy)
43
41
44
# Plate
42
# Plate
45
43
46
box    = geompy.MakeBox(0.,0.,0.,1.,1.,1.)
44
box    = geompy.MakeBox(0.,0.,0.,1.,1.,1.)
47
boxId  = geompy.addToStudy(box,"box")
45
boxId  = geompy.addToStudy(box,"box")
48
46
49
# ---- launch SMESH
47
# ---- SMESH
50
48
51
smeshgui = salome.ImportComponentGUI("SMESH")
49
# ---- init a Mesh
52
smeshgui.Init(salome.myStudyId)
53
# meshgenerator=smeshpy.smeshpy()
54
55
56
# Hypothesis
57
58
hypL1=meshgenerator.CreateHypothesis("LocalLength","libStdMeshersEngine.so")
59
hypL1.SetLength(0.25)
60
hypL1Id = salome.ObjectToID(hypL1) 
61
smeshgui.SetName(hypL1Id, "LocalLength")
62
50
63
# Algorithm
51
box_mesh=smesh.Mesh(box, "box_mesh")
64
52
65
alg1D=meshgenerator.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
53
# set Hypothesis and Algorithm
66
alg1DId = salome.ObjectToID(alg1D) 
67
smeshgui.SetName(alg1DId, "algo1D")
68
54
69
alg2D=meshgenerator.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
55
alg1D = box_mesh.Segment()
70
alg2DId = salome.ObjectToID(alg2D) 
56
alg1D.SetName("algo1D")
71
smeshgui.SetName(alg2DId, "algo2D")
57
hypL1 = alg1D.LocalLength(0.25)
58
smesh.SetName(hypL1, "LocalLength")
59
    
60
alg2D = box_mesh.Quadrangle()
61
alg2D.SetName("algo2D")
72
62
73
alg3D=meshgenerator.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
63
alg3D = box_mesh.Hexahedron()
74
alg3DId = salome.ObjectToID(alg3D) 
64
alg3D.SetName("algo3D")
75
smeshgui.SetName(alg3DId, "algo3D")
76
 
77
# ---- init a Mesh
78
65
79
box_mesh=meshgenerator.CreateMesh(box)
66
# compute mesh
80
box_meshId = salome.ObjectToID(box_mesh)
81
smeshgui.SetName(box_meshId, "box_mesh")
82
83
# ---- set Hypothesis & Algorithm
84
85
box_mesh.AddHypothesis(box,alg1D)
86
box_mesh.AddHypothesis(box,alg2D)
87
box_mesh.AddHypothesis(box,alg3D)
88
box_mesh.AddHypothesis(box,hypL1)
89
67
90
meshgenerator.Compute(box_mesh,box)
68
box_mesh.Compute()
91
69
92
sg.updateObjBrowser(1)
70
sg.updateObjBrowser(1)
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_box2_tetra.py (-61 / +16 lines)
Lines 24-37 Link Here
24
24
25
import salome
25
import salome
26
import geompy
26
import geompy
27
import smesh
27
28
28
import StdMeshers
29
import NETGENPlugin
30
31
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
32
33
smeshgui = salome.ImportComponentGUI("SMESH")
34
smeshgui.Init(salome.myStudyId);
35
29
36
# ---- define 2 boxes box1 and box2
30
# ---- define 2 boxes box1 and box2
37
31
Lines 79-168 Link Here
79
73
80
### ---------------------------- SMESH --------------------------------------
74
### ---------------------------- SMESH --------------------------------------
81
75
82
# ---- create Hypothesis
76
# ---- init a Mesh with the shell
77
78
mesh = smesh.Mesh(shell, "MeshBox2")
83
79
84
print "-------------------------- create Hypothesis"
80
81
# ---- set Hypothesis and Algorithm
85
82
86
print "-------------------------- NumberOfSegments"
83
print "-------------------------- NumberOfSegments"
87
84
88
numberOfSegments = 10
85
numberOfSegments = 10
89
86
90
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
87
regular1D = mesh.Segment()
91
hypNbSeg.SetNumberOfSegments(numberOfSegments)
88
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
92
93
print hypNbSeg.GetName()
89
print hypNbSeg.GetName()
94
print hypNbSeg.GetId()
90
print hypNbSeg.GetId()
95
print hypNbSeg.GetNumberOfSegments()
91
print hypNbSeg.GetNumberOfSegments()
96
92
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
97
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
98
93
99
print "-------------------------- MaxElementArea"
94
print "-------------------------- MaxElementArea"
100
95
101
maxElementArea = 500
96
maxElementArea = 500
102
97
103
hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
98
mefisto2D = mesh.Triangle()
104
hypArea.SetMaxElementArea(maxElementArea)
99
hypArea = mefisto2D.MaxElementArea(maxElementArea)
105
106
print hypArea.GetName()
100
print hypArea.GetName()
107
print hypArea.GetId()
101
print hypArea.GetId()
108
print hypArea.GetMaxElementArea()
102
print hypArea.GetMaxElementArea()
109
103
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
110
smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
111
104
112
print "-------------------------- MaxElementVolume"
105
print "-------------------------- MaxElementVolume"
113
106
114
maxElementVolume = 500
107
maxElementVolume = 500
115
108
116
hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
109
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
117
hypVolume.SetMaxElementVolume(maxElementVolume)
110
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
118
119
print hypVolume.GetName()
111
print hypVolume.GetName()
120
print hypVolume.GetId()
112
print hypVolume.GetId()
121
print hypVolume.GetMaxElementVolume()
113
print hypVolume.GetMaxElementVolume()
114
smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
122
115
123
smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
124
125
# ---- create Algorithms
126
127
print "-------------------------- create Algorithms"
128
129
print "-------------------------- Regular_1D"
130
131
regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
132
smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
133
134
print "-------------------------- MEFISTO_2D"
135
136
mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
137
smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
138
139
print "-------------------------- NETGEN_3D"
140
141
netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
142
smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
143
144
# ---- init a Mesh with the shell
145
146
mesh = smesh.CreateMesh(shell)
147
smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox2")
148
149
# ---- add hypothesis to shell
150
151
print "-------------------------- add hypothesis to shell"
152
153
mesh.AddHypothesis(shell,regular1D)
154
mesh.AddHypothesis(shell,hypNbSeg)
155
156
mesh.AddHypothesis(shell,mefisto2D)
157
mesh.AddHypothesis(shell,hypArea)
158
159
mesh.AddHypothesis(shell,netgen3D)
160
mesh.AddHypothesis(shell,hypVolume)
161
116
162
salome.sg.updateObjBrowser(1)
117
salome.sg.updateObjBrowser(1)
163
118
164
print "-------------------------- compute shell"
119
print "-------------------------- compute shell"
165
ret = smesh.Compute(mesh,shell)
120
ret = mesh.Compute()
166
print ret
121
print ret
167
if ret != 0:
122
if ret != 0:
168
    log = mesh.GetLog(0) # no erase trace
123
    log = mesh.GetLog(0) # no erase trace
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_box3_tetra.py (-61 / +17 lines)
Lines 25-38 Link Here
25
25
26
import salome
26
import salome
27
import geompy
27
import geompy
28
import smesh
28
29
29
import StdMeshers
30
import NETGENPlugin
31
32
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
33
34
smeshgui = salome.ImportComponentGUI("SMESH")
35
smeshgui.Init(salome.myStudyId);
36
30
37
# ---- define 3 boxes box1, box2 and box3
31
# ---- define 3 boxes box1, box2 and box3
38
32
Lines 90-179 Link Here
90
84
91
### ---------------------------- SMESH --------------------------------------
85
### ---------------------------- SMESH --------------------------------------
92
86
93
# ---- create Hypothesis
94
87
95
print "-------------------------- create Hypothesis"
88
# ---- init a Mesh with the shell
89
90
mesh = smesh.Mesh(shell, "MeshBox3")
91
92
93
# ---- set Hypothesis and Algorithm
96
94
97
print "-------------------------- NumberOfSegments"
95
print "-------------------------- NumberOfSegments"
98
96
99
numberOfSegments = 10
97
numberOfSegments = 10
100
98
101
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
99
regular1D = mesh.Segment()
102
hypNbSeg.SetNumberOfSegments(numberOfSegments)
100
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
103
104
print hypNbSeg.GetName()
101
print hypNbSeg.GetName()
105
print hypNbSeg.GetId()
102
print hypNbSeg.GetId()
106
print hypNbSeg.GetNumberOfSegments()
103
print hypNbSeg.GetNumberOfSegments()
107
104
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
108
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
109
105
110
print "-------------------------- MaxElementArea"
106
print "-------------------------- MaxElementArea"
111
107
112
maxElementArea = 500
108
maxElementArea = 500
113
109
114
hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
110
mefisto2D = mesh.Triangle()
115
hypArea.SetMaxElementArea(maxElementArea)
111
hypArea = mefisto2D.MaxElementArea(maxElementArea)
116
117
print hypArea.GetName()
112
print hypArea.GetName()
118
print hypArea.GetId()
113
print hypArea.GetId()
119
print hypArea.GetMaxElementArea()
114
print hypArea.GetMaxElementArea()
120
115
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
121
smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
122
116
123
print "-------------------------- MaxElementVolume"
117
print "-------------------------- MaxElementVolume"
124
118
125
maxElementVolume = 500
119
maxElementVolume = 500
126
120
127
hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
121
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
128
hypVolume.SetMaxElementVolume(maxElementVolume)
122
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
129
130
print hypVolume.GetName()
123
print hypVolume.GetName()
131
print hypVolume.GetId()
124
print hypVolume.GetId()
132
print hypVolume.GetMaxElementVolume()
125
print hypVolume.GetMaxElementVolume()
126
smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
133
127
134
smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
135
136
# ---- create Algorithms
137
138
print "-------------------------- create Algorithms"
139
140
print "-------------------------- Regular_1D"
141
142
regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
143
smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
144
145
print "-------------------------- MEFISTO_2D"
146
147
mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
148
smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
149
150
print "-------------------------- NETGEN_3D"
151
152
netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
153
smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
154
155
# ---- init a Mesh with the shell
156
157
mesh = smesh.CreateMesh(shell)
158
smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox3")
159
160
# ---- add hypothesis to shell
161
162
print "-------------------------- add hypothesis to shell"
163
164
mesh.AddHypothesis(shell,regular1D)
165
mesh.AddHypothesis(shell,hypNbSeg)
166
167
mesh.AddHypothesis(shell,mefisto2D)
168
mesh.AddHypothesis(shell,hypArea)
169
170
mesh.AddHypothesis(shell,netgen3D)
171
mesh.AddHypothesis(shell,hypVolume)
172
128
173
salome.sg.updateObjBrowser(1)
129
salome.sg.updateObjBrowser(1)
174
130
175
print "-------------------------- compute shell"
131
print "-------------------------- compute shell"
176
ret = smesh.Compute(mesh,shell)
132
ret = mesh.Compute()
177
print ret
133
print ret
178
if ret != 0:
134
if ret != 0:
179
    log = mesh.GetLog(0) # no erase trace
135
    log = mesh.GetLog(0) # no erase trace
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_box_tetra.py (-63 / +15 lines)
Lines 24-37 Link Here
24
24
25
import salome
25
import salome
26
import geompy
26
import geompy
27
import smesh
27
28
28
import StdMeshers
29
import NETGENPlugin
30
31
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
32
33
smeshgui = salome.ImportComponentGUI("SMESH")
34
smeshgui.Init(salome.myStudyId);
35
29
36
# ---- define a boxe
30
# ---- define a boxe
37
31
Lines 51-140 Link Here
51
45
52
### ---------------------------- SMESH --------------------------------------
46
### ---------------------------- SMESH --------------------------------------
53
47
54
# ---- create Hypothesis
48
# ---- init a Mesh with the boxe
55
49
56
print "-------------------------- create Hypothesis"
50
mesh = smesh.Mesh(box, "MeshBox")
57
51
58
print "-------------------------- NumberOfSegments"
52
# ---- set Hypothesis and Algorithm
59
53
54
print "-------------------------- NumberOfSegments"
60
numberOfSegments = 10
55
numberOfSegments = 10
61
56
62
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
57
regular1D = mesh.Segment()
63
hypNbSeg.SetNumberOfSegments(numberOfSegments)
58
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
64
65
print hypNbSeg.GetName()
59
print hypNbSeg.GetName()
66
print hypNbSeg.GetId()
60
print hypNbSeg.GetId()
67
print hypNbSeg.GetNumberOfSegments()
61
print hypNbSeg.GetNumberOfSegments()
68
62
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
69
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
70
63
71
print "-------------------------- MaxElementArea"
64
print "-------------------------- MaxElementArea"
72
65
73
maxElementArea = 500
66
maxElementArea = 500
74
67
75
hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
68
mefisto2D = mesh.Triangle()
76
hypArea.SetMaxElementArea(maxElementArea)
69
hypArea = mefisto2D.MaxElementArea(maxElementArea)
77
78
print hypArea.GetName()
70
print hypArea.GetName()
79
print hypArea.GetId()
71
print hypArea.GetId()
80
print hypArea.GetMaxElementArea()
72
print hypArea.GetMaxElementArea()
81
73
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
82
smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_500")
83
74
84
print "-------------------------- MaxElementVolume"
75
print "-------------------------- MaxElementVolume"
85
76
86
maxElementVolume = 500
77
maxElementVolume = 500
87
78
88
hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
79
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
89
hypVolume.SetMaxElementVolume(maxElementVolume)
80
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
90
91
print hypVolume.GetName()
81
print hypVolume.GetName()
92
print hypVolume.GetId()
82
print hypVolume.GetId()
93
print hypVolume.GetMaxElementVolume()
83
print hypVolume.GetMaxElementVolume()
94
84
smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
95
smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_500")
96
97
# ---- create Algorithms
98
99
print "-------------------------- create Algorithms"
100
101
print "-------------------------- Regular_1D"
102
103
regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
104
smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
105
106
print "-------------------------- MEFISTO_2D"
107
108
mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
109
smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
110
111
print "-------------------------- NETGEN_3D"
112
113
netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
114
smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
115
116
# ---- init a Mesh with the boxe
117
118
mesh = smesh.CreateMesh(box)
119
smeshgui.SetName(salome.ObjectToID(mesh), "MeshBox")
120
121
# ---- add hypothesis to the boxe
122
123
print "-------------------------- add hypothesis to the box"
124
125
mesh.AddHypothesis(box,regular1D)
126
mesh.AddHypothesis(box,hypNbSeg)
127
128
mesh.AddHypothesis(box,mefisto2D)
129
mesh.AddHypothesis(box,hypArea)
130
131
mesh.AddHypothesis(box,netgen3D)
132
mesh.AddHypothesis(box,hypVolume)
133
85
134
salome.sg.updateObjBrowser(1)
86
salome.sg.updateObjBrowser(1)
135
87
136
print "-------------------------- compute the mesh of the boxe"
88
print "-------------------------- compute the mesh of the boxe"
137
ret = smesh.Compute(mesh,box)
89
ret = mesh.Compute()
138
print ret
90
print ret
139
if ret != 0:
91
if ret != 0:
140
    log = mesh.GetLog(0) # no erase trace
92
    log = mesh.GetLog(0) # no erase trace
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_controls.py (-111 / +32 lines)
Lines 24-209 Link Here
24
#  Module : SMESH
24
#  Module : SMESH
25
25
26
26
27
import SMESH
27
import smesh
28
import SMESH_mechanic
28
import SMESH_mechanic
29
29
30
smesh  = SMESH_mechanic.smesh
30
salome = smesh.salome
31
mesh   = SMESH_mechanic.mesh
31
mesh   = SMESH_mechanic.mesh
32
salome = SMESH_mechanic.salome
33
32
34
33
35
aFilterMgr = smesh.CreateFilterManager()
34
# ---- Criterion : AREA > 100
36
35
37
# Criterion : AREA > 100
36
# create group
38
37
aGroup = mesh.MakeGroup("Area > 100", smesh.FACE, smesh.FT_Area, smesh.FT_MoreThan, 100)
39
aFunctor = aFilterMgr.CreateArea()
40
aPredicate = aFilterMgr.CreateMoreThan()
41
aPredicate.SetNumFunctor( aFunctor )
42
aPredicate.SetMargin( 100 )
43
44
aFilter = aFilterMgr.CreateFilter()
45
aFilter.SetPredicate( aPredicate )
46
47
anIds = aFilter.GetElementsId( mesh )
48
38
49
# print result
39
# print result
40
anIds = aGroup.GetIDs()
50
print "Criterion: Area > 100 Nb = ", len( anIds )
41
print "Criterion: Area > 100 Nb = ", len( anIds )
51
#for i in range( len( anIds ) ):
42
#for i in range( len( anIds ) ):
52
  #print anIds[ i ]
43
  #print anIds[ i ]
53
44
54
# create group
55
aGroup = mesh.CreateGroup( SMESH.FACE, "Area > 100" )
56
aGroup.Add( anIds )
57
58
59
# Criterion : Taper > 3e-15
60
61
aFunctor = aFilterMgr.CreateTaper()
62
aPredicate = aFilterMgr.CreateMoreThan()
63
aPredicate.SetNumFunctor( aFunctor )
64
aPredicate.SetMargin( 3e-15 )
65
45
66
aFilter = aFilterMgr.CreateFilter()
46
# ----  Criterion : Taper > 3e-15
67
aFilter.SetPredicate( aPredicate )
68
47
69
anIds = aFilter.GetElementsId( mesh )
48
# create group
49
aGroup = mesh.MakeGroup("Taper > 3e-15", smesh.FACE, smesh.FT_Taper, smesh.FT_MoreThan, 3e-15)
70
50
71
# print result
51
# print result
52
anIds = aGroup.GetIDs()
72
print "Criterion: Taper > 3e-15 Nb = ", len( anIds )
53
print "Criterion: Taper > 3e-15 Nb = ", len( anIds )
73
#for i in range( len( anIds ) ):
54
#for i in range( len( anIds ) ):
74
  #print anIds[ i ]
55
  #print anIds[ i ]
75
56
76
# create group
77
aGroup = mesh.CreateGroup( SMESH.FACE, "Taper > 3e-15" )
78
aGroup.Add( anIds )
79
57
58
# ----  Criterion : ASPECT RATIO > 1.3
80
59
81
# Criterion : ASPECT RATIO > 1.3
60
# create group
82
61
aGroup = mesh.MakeGroup("Aspect Ratio > 1.3", smesh.FACE, smesh.FT_AspectRatio, smesh.FT_MoreThan, 1.3)
83
aFunctor = aFilterMgr.CreateAspectRatio()
84
aPredicate = aFilterMgr.CreateMoreThan()
85
aPredicate.SetNumFunctor( aFunctor )
86
aPredicate.SetMargin( 1.3 )
87
88
aFilter = aFilterMgr.CreateFilter()
89
aFilter.SetPredicate( aPredicate )
90
91
anIds = aFilter.GetElementsId( mesh )
92
62
93
# print result
63
# print result
64
anIds = aGroup.GetIDs()
94
print "Criterion: Aspect Ratio > 1.3 Nb = ", len( anIds )
65
print "Criterion: Aspect Ratio > 1.3 Nb = ", len( anIds )
95
#for i in range( len( anIds ) ):
66
#for i in range( len( anIds ) ):
96
  #print anIds[ i ]
67
  #print anIds[ i ]
97
68
98
# create group
99
aGroup = mesh.CreateGroup( SMESH.FACE, "Aspect Ratio > 1.3" )
100
aGroup.Add( anIds )
101
69
70
# ----  Criterion : MINIMUM ANGLE < 30
102
71
103
# Criterion : MINIMUM ANGLE < 30
72
# create group
104
73
aGroup = mesh.MakeGroup("Minimum Angle < 30", smesh.FACE, smesh.FT_MinimumAngle, smesh.FT_LessThan, 30)
105
aFunctor = aFilterMgr.CreateMinimumAngle()
106
aPredicate = aFilterMgr.CreateLessThan()
107
aPredicate.SetNumFunctor( aFunctor )
108
aPredicate.SetMargin( 30 )
109
110
aFilter = aFilterMgr.CreateFilter()
111
aFilter.SetPredicate( aPredicate )
112
113
anIds = aFilter.GetElementsId( mesh )
114
74
115
# print result
75
# print result
76
anIds = aGroup.GetIDs()
116
print "Criterion: Minimum Angle < 30 Nb = ", len( anIds )
77
print "Criterion: Minimum Angle < 30 Nb = ", len( anIds )
117
#for i in range( len( anIds ) ):
78
#for i in range( len( anIds ) ):
118
  #print anIds[ i ]
79
  #print anIds[ i ]
119
80
120
# create group
121
aGroup = mesh.CreateGroup( SMESH.FACE, "Minimum Angle < 30" )
122
aGroup.Add( anIds )
123
124
# Criterion : Warp > 2e-13
125
126
aFunctor = aFilterMgr.CreateWarping()
127
aPredicate = aFilterMgr.CreateMoreThan()
128
aPredicate.SetNumFunctor( aFunctor )
129
aPredicate.SetMargin( 2e-13 )
130
81
131
aFilter = aFilterMgr.CreateFilter()
82
# ---- Criterion : Warp > 2e-13
132
aFilter.SetPredicate( aPredicate )
133
83
134
anIds = aFilter.GetElementsId( mesh )
84
# create group
85
aGroup = mesh.MakeGroup("Warp > 2e-13", smesh.FACE, smesh.FT_Warping, smesh.FT_MoreThan, 2e-13 )
135
86
136
# print result
87
# print result
88
anIds = aGroup.GetIDs()
137
print "Criterion: Warp > 2e-13 Nb = ", len( anIds )
89
print "Criterion: Warp > 2e-13 Nb = ", len( anIds )
138
#for i in range( len( anIds ) ):
90
#for i in range( len( anIds ) ):
139
  #print anIds[ i ]
91
  #print anIds[ i ]
140
92
141
# create group
142
aGroup = mesh.CreateGroup( SMESH.FACE, "Warp > 2e-13" )
143
aGroup.Add( anIds )
144
93
145
# Criterion : Skew > 18
94
# ---- Criterion : Skew > 18
146
95
147
aFunctor = aFilterMgr.CreateSkew()
96
# create group
148
aPredicate = aFilterMgr.CreateMoreThan()
97
aGroup = mesh.MakeGroup("Skew > 18", smesh.FACE, smesh.FT_Skew, smesh.FT_MoreThan, 18 )
149
aPredicate.SetNumFunctor( aFunctor )
150
aPredicate.SetMargin( 18 )
151
152
aFilter = aFilterMgr.CreateFilter()
153
aFilter.SetPredicate( aPredicate )
154
155
anIds = aFilter.GetElementsId( mesh )
156
98
157
# print result
99
# print result
100
anIds = aGroup.GetIDs()
158
print "Criterion: Skew > 18 Nb = ", len( anIds )
101
print "Criterion: Skew > 18 Nb = ", len( anIds )
159
#for i in range( len( anIds ) ):
102
#for i in range( len( anIds ) ):
160
  #print anIds[ i ]
103
  #print anIds[ i ]
161
104
162
# create group
163
aGroup = mesh.CreateGroup( SMESH.FACE, "Skew > 18" )
164
aGroup.Add( anIds )
165
105
166
# Criterion : Length > 10
106
# Criterion : Length > 10
167
107
168
aFunctor = aFilterMgr.CreateLength()
108
# create group
169
aPredicate = aFilterMgr.CreateMoreThan()
109
aGroup = mesh.MakeGroup("Length > 10", smesh.FACE, smesh.FT_Length, smesh.FT_MoreThan, 10 )
170
aPredicate.SetNumFunctor( aFunctor )
171
aPredicate.SetMargin( 10 )
172
173
aFilter = aFilterMgr.CreateFilter()
174
aFilter.SetPredicate( aPredicate )
175
176
anIds = aFilter.GetElementsId( mesh )
177
110
178
# print result
111
# print result
112
anIds = aGroup.GetIDs()
179
print "Criterion: Length > 10 Nb = ", len( anIds )
113
print "Criterion: Length > 10 Nb = ", len( anIds )
180
#for i in range( len( anIds ) ):
114
#for i in range( len( anIds ) ):
181
  #print anIds[ i ]
115
  #print anIds[ i ]
182
116
183
# create group
184
aGroup = mesh.CreateGroup( SMESH.EDGE, "Length > 10" )
185
aGroup.Add( anIds )
186
117
187
# Criterion : Borders at multi-connections = 2
118
# Criterion : Borders at multi-connections = 2
188
119
189
aFunctor = aFilterMgr.CreateMultiConnection()
120
# create group
190
aPredicate = aFilterMgr.CreateEqualTo()
121
aGroup = mesh.MakeGroup("Borders at multi-connections = 2", smesh.EDGE, smesh.FT_MultiConnection, smesh.FT_EqualTo, 2)
191
aPredicate.SetNumFunctor( aFunctor )
192
aPredicate.SetMargin( 2 )
193
194
aFilter = aFilterMgr.CreateFilter()
195
aFilter.SetPredicate( aPredicate )
196
197
anIds = aFilter.GetElementsId( mesh )
198
122
199
# print result
123
# print result
124
anIds = aGroup.GetIDs()
200
print "Criterion: Borders at multi-connections = 2 Nb = ", len( anIds )
125
print "Criterion: Borders at multi-connections = 2 Nb = ", len( anIds )
201
#for i in range( len( anIds ) ):
126
#for i in range( len( anIds ) ):
202
  #print anIds[ i ]
127
  #print anIds[ i ]
203
128
204
# create group
205
aGroup = mesh.CreateGroup( SMESH.EDGE, "Borders at multi-connections = 2" )
206
aGroup.Add( anIds )
207
208
129
209
salome.sg.updateObjBrowser(1)
130
salome.sg.updateObjBrowser(1)
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_demo_hexa2_upd.py (-62 / +23 lines)
Lines 31-48 Link Here
31
31
32
import salome
32
import salome
33
import geompy
33
import geompy
34
34
import smesh
35
import StdMeshers
36
import NETGENPlugin
37
38
geom  = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
39
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
40
41
smeshgui = salome.ImportComponentGUI("SMESH")
42
smeshgui.Init(salome.myStudyId);
43
35
44
import math
36
import math
45
37
38
46
# -----------------------------------------------------------------------------
39
# -----------------------------------------------------------------------------
47
40
48
ShapeTypeShell     = 3
41
ShapeTypeShell     = 3
Lines 130-215 Link Here
130
123
131
### ---------------------------- SMESH --------------------------------------
124
### ---------------------------- SMESH --------------------------------------
132
125
133
# ---- create Hypothesis
126
# ---- init a Mesh with the volume
127
128
mesh = smesh.Mesh(vol, "meshVolume")
134
129
135
print "-------------------------- create Hypothesis"
130
# ---- set Hypothesis and Algorithm to main shape
136
131
137
print "-------------------------- NumberOfSegments the global one"
132
print "-------------------------- NumberOfSegments the global one"
138
133
139
numberOfSegments = 10
134
numberOfSegments = 10
140
135
141
hypNbSeg=smesh.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
136
regular1D = mesh.Segment()
142
hypNbSeg.SetNumberOfSegments(numberOfSegments)
137
regular1D.SetName("Wire Discretisation")
143
hypNbSegID = hypNbSeg.GetId()
138
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
144
print hypNbSeg.GetName()
139
print hypNbSeg.GetName()
145
print hypNbSegID
140
print hypNbSeg.GetId()
146
print hypNbSeg.GetNumberOfSegments()
141
print hypNbSeg.GetNumberOfSegments()
142
smesh.SetName(hypNbSeg, "NumberOfSegments")
147
143
148
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments")
149
150
print "-------------------------- NumberOfSegments in the Z direction"
151
152
numberOfSegmentsZ = 40
153
154
hypNbSegZ=smesh.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so")
155
hypNbSegZ.SetNumberOfSegments(numberOfSegmentsZ)
156
hypNbSegZID = hypNbSegZ.GetId()
157
print hypNbSegZ.GetName()
158
print hypNbSegZID
159
print hypNbSegZ.GetNumberOfSegments()
160
161
smeshgui.SetName(salome.ObjectToID(hypNbSegZ), "NumberOfSegmentsZ")
162
163
# ---- create Algorithms
164
165
print "-------------------------- create Algorithms"
166
167
print "-------------------------- Regular_1D"
168
169
regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
170
smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
171
144
172
print "-------------------------- Quadrangle_2D"
145
print "-------------------------- Quadrangle_2D"
173
146
174
quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
147
quad2D=mesh.Quadrangle()
175
smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D")
148
quad2D.SetName("Quadrangle_2D")
176
149
177
print "-------------------------- Hexa_3D"
150
print "-------------------------- Hexa_3D"
178
151
179
hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
152
hexa3D=mesh.Hexahedron()
180
smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D")
153
hexa3D.SetName("Hexa_3D")
181
154
182
# ---- init a Mesh with the volume
183
155
184
mesh = smesh.CreateMesh(vol)
156
print "-------------------------- NumberOfSegments in the Z direction"
185
smeshgui.SetName(salome.ObjectToID(mesh), "meshVolume")
186
187
# ---- add hypothesis to the volume
188
189
print "-------------------------- add hypothesis to the volume"
190
157
191
ret=mesh.AddHypothesis(vol,regular1D)
158
numberOfSegmentsZ = 40
192
print ret
193
ret=mesh.AddHypothesis(vol,hypNbSeg)
194
print ret
195
ret=mesh.AddHypothesis(vol,quad2D)
196
print ret
197
ret=mesh.AddHypothesis(vol,hexa3D)
198
print ret
199
159
200
for i in range(8):
160
for i in range(8):
201
    print "-------------------------- add hypothesis to edge in the Z directions", (i+1)
161
    print "-------------------------- add hypothesis to edge in the Z directions", (i+1)
202
162
203
    subMeshEdgeZ = mesh.GetSubMesh(edgeZ[i],"SubMeshEdgeZ_"+str(i+1))
163
    algo = mesh.Segment(edgeZ[i])
204
164
    hyp = algo.NumberOfSegments(numberOfSegmentsZ)
205
    retZ = mesh.AddHypothesis(edgeZ[i],hypNbSegZ)
165
    smesh.SetName(hyp, "NumberOfSegmentsZ")
206
    print " add hyp Z ", retZ
166
    smesh.SetName(algo.GetSubMesh(), "SubMeshEdgeZ_"+str(i+1))
167
  
207
168
208
salome.sg.updateObjBrowser(1)
169
salome.sg.updateObjBrowser(1)
209
170
210
print "-------------------------- compute the mesh of the volume"
171
print "-------------------------- compute the mesh of the volume"
211
172
212
ret=smesh.Compute(mesh,vol)
173
ret=mesh.Compute()
213
174
214
print ret
175
print ret
215
if ret != 0:
176
if ret != 0:
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_fixation_hexa.py (-40 / +16 lines)
Lines 24-31 Link Here
24
#
24
#
25
25
26
import SMESH_fixation
26
import SMESH_fixation
27
27
import smesh
28
import StdMeshers
29
28
30
compshell = SMESH_fixation.compshell
29
compshell = SMESH_fixation.compshell
31
idcomp = SMESH_fixation.idcomp
30
idcomp = SMESH_fixation.idcomp
Lines 45-109 Link Here
45
print " check status ", status
44
print " check status ", status
46
45
47
### ---------------------------- SMESH --------------------------------------
46
### ---------------------------- SMESH --------------------------------------
48
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
49
47
50
smeshgui = salome.ImportComponentGUI("SMESH")
48
# ---- init a Mesh with the compshell
51
smeshgui.Init(salome.myStudyId)
49
shape_mesh = salome.IDToObject( idcomp  )
50
51
mesh = smesh.Mesh(shape_mesh, "MeshCompShell")
52
52
53
53
print "-------------------------- create Hypothesis"
54
# ---- set Hypothesis and Algorithm
54
55
55
print "-------------------------- NumberOfSegments"
56
print "-------------------------- NumberOfSegments"
56
57
57
numberOfSegments = 5
58
numberOfSegments = 5
58
59
59
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
60
regular1D = mesh.Segment()
60
hypNbSeg.SetNumberOfSegments(numberOfSegments)
61
regular1D.SetName("Wire Discretisation")
61
62
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
62
print hypNbSeg.GetName()
63
print hypNbSeg.GetName()
63
print hypNbSeg.GetId()
64
print hypNbSeg.GetId()
64
print hypNbSeg.GetNumberOfSegments()
65
print hypNbSeg.GetNumberOfSegments()
65
66
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
66
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_5")
67
68
print "-------------------------- create Algorithms"
69
70
print "-------------------------- Regular_1D"
71
72
regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
73
74
smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
75
67
76
print "-------------------------- Quadrangle_2D"
68
print "-------------------------- Quadrangle_2D"
77
69
78
quad2D = smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
70
quad2D = mesh.Quadrangle()
79
71
quad2D.SetName("Quadrangle_2D")
80
smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D")
81
72
82
print "-------------------------- Hexa_3D"
73
print "-------------------------- Hexa_3D"
83
74
84
hexa3D = smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
75
hexa3D = mesh.Hexahedron()
85
76
hexa3D.SetName("Hexa_3D")
86
smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D")
87
88
# ---- init a Mesh with the compshell
89
shape_mesh = salome.IDToObject( idcomp  )
90
91
mesh = smesh.CreateMesh(shape_mesh)
92
smeshgui.SetName(salome.ObjectToID(mesh), "MeshCompShell")
93
94
95
print "-------------------------- add hypothesis to compshell"
96
97
mesh.AddHypothesis(shape_mesh,regular1D)
98
mesh.AddHypothesis(shape_mesh,hypNbSeg)
99
77
100
mesh.AddHypothesis(shape_mesh,quad2D)
101
mesh.AddHypothesis(shape_mesh,hexa3D)
102
78
103
salome.sg.updateObjBrowser(1)
79
salome.sg.updateObjBrowser(1)
104
80
105
print "-------------------------- compute compshell"
81
print "-------------------------- compute compshell"
106
ret = smesh.Compute(mesh, shape_mesh)
82
ret = mesh.Compute()
107
print ret
83
print ret
108
if ret != 0:
84
if ret != 0:
109
    log = mesh.GetLog(0) # no erase trace
85
    log = mesh.GetLog(0) # no erase trace
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_fixation_netgen.py (-8 / +5 lines)
Lines 23-30 Link Here
23
# The new Netgen algorithm is used that discretizes baoundaries itself
23
# The new Netgen algorithm is used that discretizes baoundaries itself
24
#
24
#
25
25
26
import StdMeshers
27
import NETGENPlugin
28
import SMESH_fixation
26
import SMESH_fixation
29
import smesh
27
import smesh
30
28
Lines 50-61 Link Here
50
print "-------------------------- create Mesh, algorithm, hypothesis"
48
print "-------------------------- create Mesh, algorithm, hypothesis"
51
49
52
mesh = smesh.Mesh(compshell, "MeshcompShel");
50
mesh = smesh.Mesh(compshell, "MeshcompShel");
53
netgen = mesh.Netgen(1)
51
netgen = mesh.Tetrahedron(smesh.FULL_NETGEN)
54
hyp = netgen.Parameters()
52
netgen.SetMaxSize( 50 )
55
hyp.SetMaxSize( 50 )
53
#netgen.SetSecondOrder( 0 )
56
#hyp.SetSecondOrder( 0 )
54
netgen.SetFineness( smesh.Fine )
57
hyp.SetFineness( 3 )
55
#netgen.SetOptimize( 1 )
58
#hyp.SetOptimize( 1 )
59
56
60
salome.sg.updateObjBrowser(1)
57
salome.sg.updateObjBrowser(1)
61
58
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_fixation_tetra.py (-58 / +28 lines)
Lines 23-31 Link Here
23
# Hypothesis and algorithms for the mesh generation are global
23
# Hypothesis and algorithms for the mesh generation are global
24
#
24
#
25
25
26
import StdMeshers
27
import NETGENPlugin
28
import SMESH_fixation
26
import SMESH_fixation
27
import smesh
29
28
30
compshell = SMESH_fixation.compshell
29
compshell = SMESH_fixation.compshell
31
idcomp = SMESH_fixation.idcomp
30
idcomp = SMESH_fixation.idcomp
Lines 45-138 Link Here
45
print " check status ", status
44
print " check status ", status
46
45
47
### ---------------------------- SMESH --------------------------------------
46
### ---------------------------- SMESH --------------------------------------
48
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
49
47
50
smeshgui = salome.ImportComponentGUI("SMESH")
48
# ---- init a Mesh with the compshell
51
smeshgui.Init(salome.myStudyId)
49
50
mesh = smesh.Mesh(compshell, "MeshcompShell")
51
52
52
53
print "-------------------------- create Hypothesis"
53
# ---- set Hypothesis and Algorithm
54
54
55
print "-------------------------- NumberOfSegments"
55
print "-------------------------- NumberOfSegments"
56
56
57
numberOfSegments = 5
57
numberOfSegments = 5
58
58
59
hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
59
regular1D = mesh.Segment()
60
hypNbSeg.SetNumberOfSegments(numberOfSegments)
60
regular1D.SetName("Wire Discretisation")
61
61
hypNbSeg = regular1D.NumberOfSegments(numberOfSegments)
62
print hypNbSeg.GetName()
62
print hypNbSeg.GetName()
63
print hypNbSeg.GetId()
63
print hypNbSeg.GetId()
64
print hypNbSeg.GetNumberOfSegments()
64
print hypNbSeg.GetNumberOfSegments()
65
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegments))
65
66
66
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_5")
67
## print "-------------------------- MaxElementArea"
67
68
print "-------------------------- MaxElementArea"
69
68
70
## maxElementArea = 80
69
## maxElementArea = 80
71
70
72
## hypArea=smesh.CreateHypothesis("MaxElementArea")
71
## mefisto2D = mesh.Triangle()
73
## hypArea.SetMaxElementArea(maxElementArea)
72
## mefisto2D.SetName("MEFISTO_2D")
73
## hypArea = mefisto2D.MaxElementArea(maxElementArea)
74
## print hypArea.GetName()
74
## print hypArea.GetName()
75
## print hypArea.GetId()
75
## print hypArea.GetId()
76
## print hypArea.GetMaxElementArea()
76
## print hypArea.GetMaxElementArea()
77
## smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_160")
77
## smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
78
79
print "-------------------------- LengthFromEdges"
78
80
79
hypLengthFromEdges = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
81
mefisto2D = mesh.Triangle()
80
smeshgui.SetName(salome.ObjectToID(hypLengthFromEdges), "LengthFromEdges")
82
mefisto2D.SetName("MEFISTO_2D")
83
hypLengthFromEdges = mefisto2D.LengthFromEdges()
84
print hypLengthFromEdges.GetName()
85
print hypLengthFromEdges.GetId()
86
smesh.SetName(hypLengthFromEdges, "LengthFromEdges")
81
87
82
88
83
print "-------------------------- MaxElementVolume"
89
print "-------------------------- MaxElementVolume"
84
90
85
maxElementVolume = 1000
91
maxElementVolume = 1000
86
92
87
hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so")
93
netgen3D = mesh.Tetrahedron(smesh.NETGEN)
88
hypVolume.SetMaxElementVolume(maxElementVolume)
94
netgen3D.SetName("NETGEN_3D")
89
95
hypVolume = netgen3D.MaxElementVolume(maxElementVolume)
90
print hypVolume.GetName()
96
print hypVolume.GetName()
91
print hypVolume.GetId()
97
print hypVolume.GetId()
92
print hypVolume.GetMaxElementVolume()
98
print hypVolume.GetMaxElementVolume()
99
smesh.SetName(hypVolume, "MaxElementVolume_" + str(maxElementVolume))
93
100
94
smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_1000")
95
96
print "-------------------------- create Algorithms"
97
98
print "-------------------------- Regular_1D"
99
100
regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
101
102
smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
103
104
print "-------------------------- MEFISTO_2D"
105
106
mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
107
108
smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
109
110
print "-------------------------- NETGEN_3D"
111
112
netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so")
113
114
smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D")
115
116
# ---- init a Mesh with the compshell
117
118
mesh = smesh.CreateMesh(compshell)
119
smeshgui.SetName(salome.ObjectToID(mesh), "MeshcompShel")
120
121
print "-------------------------- add hypothesis to compshell"
122
123
mesh.AddHypothesis(compshell,regular1D)
124
mesh.AddHypothesis(compshell,hypNbSeg)
125
126
mesh.AddHypothesis(compshell,mefisto2D)
127
mesh.AddHypothesis(compshell,hypLengthFromEdges)
128
129
mesh.AddHypothesis(compshell,netgen3D)
130
mesh.AddHypothesis(compshell,hypVolume)
131
101
132
salome.sg.updateObjBrowser(1)
102
salome.sg.updateObjBrowser(1)
133
103
134
print "-------------------------- compute compshell"
104
print "-------------------------- compute compshell"
135
ret = smesh.Compute(mesh,compshell)
105
ret = mesh.Compute(mesh)
136
print ret
106
print ret
137
if ret != 0:
107
if ret != 0:
138
    log = mesh.GetLog(0) # no erase trace
108
    log = mesh.GetLog(0) # no erase trace
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_flight_skin.py (-45 / +15 lines)
Lines 26-37 Link Here
26
import os
26
import os
27
import salome
27
import salome
28
import geompy
28
import geompy
29
import StdMeshers
29
import smesh
30
31
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
32
33
smeshgui = salome.ImportComponentGUI("SMESH")
34
smeshgui.Init(salome.myStudyId)
35
30
36
31
37
# ---------------------------- GEOM --------------------------------------
32
# ---------------------------- GEOM --------------------------------------
Lines 61-124 Link Here
61
56
62
### ---------------------------- SMESH --------------------------------------
57
### ---------------------------- SMESH --------------------------------------
63
58
64
print "-------------------------- create Hypothesis"
59
# ---- init a Mesh with the shell
60
shape_mesh = salome.IDToObject( idShape )
61
62
mesh = smesh.Mesh(shape_mesh, "MeshFlight")
63
64
65
# ---- set Hypothesis and Algorithm
65
66
66
print "-------------------------- LocalLength"
67
print "-------------------------- LocalLength"
67
68
68
lengthOfSegments = 0.3
69
lengthOfSegments = 0.3
69
70
70
hypLength = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
71
regular1D = mesh.Segment()
71
hypLength.SetLength(lengthOfSegments)
72
hypLength = regular1D.LocalLength(lengthOfSegments)
72
73
print hypLength.GetName()
73
print hypLength.GetName()
74
print hypLength.GetId()
74
print hypLength.GetId()
75
print hypLength.GetLength()
75
print hypLength.GetLength()
76
76
smesh.SetName(hypLength, "LocalLength_" + str(lengthOfSegments))
77
smeshgui.SetName(salome.ObjectToID(hypLength), "LocalLength_0.3")
78
77
79
print "-------------------------- LengthFromEdges"
78
print "-------------------------- LengthFromEdges"
80
79
81
hypLengthFromEdge = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
80
mefisto2D = mesh.Triangle()
82
81
hypLengthFromEdge = mefisto2D.LengthFromEdges()
83
print hypLengthFromEdge.GetName()
82
print hypLengthFromEdge.GetName()
84
print hypLengthFromEdge.GetId()
83
print hypLengthFromEdge.GetId()
84
smesh.SetName(hypLengthFromEdge,"LengthFromEdge")
85
85
86
smeshgui.SetName(salome.ObjectToID(hypLengthFromEdge), "LengthFromEdge")
87
88
print "-------------------------- create Algorithms"
89
90
print "-------------------------- Regular_1D"
91
92
regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
93
94
smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation")
95
96
print "-------------------------- MEFISTO_2D"
97
98
mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
99
100
smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D")
101
102
# ---- init a Mesh with the shell
103
shape_mesh = salome.IDToObject( idShape )
104
105
mesh = smesh.CreateMesh(shape_mesh)
106
smeshgui.SetName(salome.ObjectToID(mesh), "MeshFlight")
107
108
# ---- add hypothesis to flight
109
110
print "-------------------------- add hypothesis to flight"
111
112
mesh.AddHypothesis(shape_mesh,regular1D)
113
mesh.AddHypothesis(shape_mesh,hypLength)
114
mesh.AddHypothesis(shape_mesh,mefisto2D)
115
mesh.AddHypothesis(shape_mesh,hypLengthFromEdge)
116
86
117
salome.sg.updateObjBrowser(1)
87
salome.sg.updateObjBrowser(1)
118
88
119
89
120
print "-------------------------- compute the skin flight"
90
print "-------------------------- compute the skin flight"
121
ret = smesh.Compute(mesh,shape_mesh)
91
ret = mesh.Compute()
122
print ret
92
print ret
123
if ret != 0:
93
if ret != 0:
124
    log = mesh.GetLog(0) # no erase trace
94
    log = mesh.GetLog(0) # no erase trace
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_freebord.py (-66 / +48 lines)
Lines 17-85 Link Here
17
#
17
#
18
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
#
19
#
20
import salome
20
import salome
21
import geompy
21
import geompy
22
import SMESH
22
import smesh
23
import StdMeshers
23
24
24
25
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
25
# Create box without one plane
26
smesh.SetCurrentStudy(salome.myStudy)
26
27
27
box = geompy.MakeBox(0., 0., 0., 10., 20., 30.)
28
# Create box without one plane
28
subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
29
29
30
box = geompy.MakeBox(0., 0., 0., 10., 20., 30.)
30
FaceList  = []
31
subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"])
31
for i in range( 5 ):
32
32
  FaceList.append( subShapeList[ i ] )
33
FaceList  = []
33
34
for i in range( 5 ):
34
aComp = geompy.MakeCompound( FaceList )
35
  FaceList.append( subShapeList[ i ] )
35
aBox = geompy.Sew( aComp, 1. )
36
36
idbox = geompy.addToStudy( aBox, "box" )
37
aComp = geompy.MakeCompound( FaceList )
37
38
aBox = geompy.Sew( aComp, 1. )
38
aBox  = salome.IDToObject( idbox )
39
idbox = geompy.addToStudy( aBox, "box" )
39
40
  
40
# Create mesh
41
aBox  = salome.IDToObject( idbox )
41
42
42
mesh = smesh.Mesh(aBox, "Mesh_freebord")
43
# Create mesh
43
44
44
algoReg = mesh.Segment()
45
hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
45
hypNbSeg = algoReg.NumberOfSegments(5)
46
hyp1.SetNumberOfSegments(5)
46
47
hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
47
algoMef = mesh.Triangle()
48
hyp2.SetMaxElementArea(20)
48
hypArea = algoMef.MaxElementArea(20)
49
hyp3 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
49
50
hyp3.SetMaxElementArea(50)
50
51
51
mesh.Compute()
52
algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
52
53
algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
53
54
54
# Criterion : Free edges. Create group.
55
mesh = smesh.CreateMesh(aBox)
55
56
mesh.AddHypothesis(aBox,hyp1)
56
aCriterion = smesh.GetCriterion(smesh.EDGE, smesh.FT_FreeEdges)
57
mesh.AddHypothesis(aBox,hyp2)
57
58
mesh.AddHypothesis(aBox,algo1)
58
aGroup = mesh.MakeGroupByCriterion("Free edges", aCriterion)
59
mesh.AddHypothesis(aBox,algo2)
59
60
60
anIds = aGroup.GetIDs()
61
smesh.Compute(mesh,aBox)
61
62
62
# print result
63
smeshgui = salome.ImportComponentGUI("SMESH")
63
print "Criterion: Free edges Nb = ", len( anIds )
64
smeshgui.Init(salome.myStudyId);
64
for i in range( len( anIds ) ):
65
smeshgui.SetName( salome.ObjectToID( mesh ), "Mesh_freebord" );
65
  print anIds[ i ]
66
66
67
# Criterion : Free edges
67
salome.sg.updateObjBrowser(1)
68
aFilterMgr = smesh.CreateFilterManager()
69
aPredicate = aFilterMgr.CreateFreeBorders()
70
aFilter = aFilterMgr.CreateFilter()
71
aFilter.SetPredicate( aPredicate )
72
73
anIds = aFilter.GetElementsId( mesh )
74
75
# print result
76
print "Criterion: Free edges Nb = ", len( anIds )
77
for i in range( len( anIds ) ):
78
  print anIds[ i ]
79
80
# create group
81
aGroup = mesh.CreateGroup( SMESH.EDGE, "Free edges" )
82
aGroup.Add( anIds )
83
84
85
salome.sg.updateObjBrowser(1)
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_hexaedre.py (-55 / +48 lines)
Lines 26-34 Link Here
26
#==============================================================================
26
#==============================================================================
27
27
28
import salome
28
import salome
29
from salome import sg
30
31
import geompy
29
import geompy
30
import smesh
32
31
33
import math
32
import math
34
33
Lines 37-43 Link Here
37
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
36
geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM")
38
myBuilder = salome.myStudy.NewBuilder()
37
myBuilder = salome.myStudy.NewBuilder()
39
gg = salome.ImportComponentGUI("GEOM")
38
gg = salome.ImportComponentGUI("GEOM")
40
from salome import sg
41
39
42
ShapeTypeCompSolid = 1
40
ShapeTypeCompSolid = 1
43
ShapeTypeSolid     = 2
41
ShapeTypeSolid     = 2
Lines 95-166 Link Here
95
93
96
print "-------------------------- mesh"
94
print "-------------------------- mesh"
97
95
98
import SMESH
99
import StdMeshers
100
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
101
smesh.SetCurrentStudy(salome.myStudy)
102
103
# ---- create Hypothesis
104
print "-------------------------- create Hypothesis"
105
numberOfSegments = 4
106
hypNbSegA=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
107
hypNbSegA.SetNumberOfSegments(numberOfSegments)
108
numberOfSegments = 10
109
hypNbSegB=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
110
hypNbSegB.SetNumberOfSegments(numberOfSegments)
111
numberOfSegments = 15
112
hypNbSegC=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
113
hypNbSegC.SetNumberOfSegments(numberOfSegments)
114
115
# ---- create Algorithms
116
print "-------------------------- create Algorithms"
117
regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
118
quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so")
119
hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so")
120
121
# ---- init a Mesh with the geom shape
96
# ---- init a Mesh with the geom shape
122
shape_mesh = blob
97
shape_mesh = blob
123
myMesh=smesh.CreateMesh(shape_mesh)
98
mesh=smesh.Mesh(shape_mesh, "MeshBlob")
124
99
125
# ---- add hypothesis and algorithms to mesh
100
# ---- add hypothesis and algorithms to mesh
126
print "-------------------------- add hypothesis to mesh"
101
print "-------------------------- add hypothesis to mesh"
127
myMesh.AddHypothesis(shape_mesh,regular1D)
102
algo1 = mesh.Segment()
128
myMesh.AddHypothesis(shape_mesh,quad2D)
103
algo2 = mesh.Quadrangle()
129
myMesh.AddHypothesis(shape_mesh,hexa3D)
104
algo3 = mesh.Hexahedron()
130
105
131
#myMesh.AddHypothesis(shape_mesh,hypNbSeg)
106
numberOfSegmentsA = 4
132
107
133
myMesh.AddHypothesis(aretes[0],hypNbSegA)
108
algo = mesh.Segment(aretes[0])
134
myMesh.AddHypothesis(aretes[2],hypNbSegA)
109
algo.NumberOfSegments(numberOfSegmentsA)
135
myMesh.AddHypothesis(aretes[8],hypNbSegA)
110
algo = mesh.Segment(aretes[2])
136
myMesh.AddHypothesis(aretes[10],hypNbSegA)
111
algo.NumberOfSegments(numberOfSegmentsA)
137
112
algo = mesh.Segment(aretes[8])
138
myMesh.AddHypothesis(aretes[1],hypNbSegC)
113
algo.NumberOfSegments(numberOfSegmentsA)
139
myMesh.AddHypothesis(aretes[3],hypNbSegC)
114
algo = mesh.Segment(aretes[10])
140
myMesh.AddHypothesis(aretes[9],hypNbSegC)
115
algo.NumberOfSegments(numberOfSegmentsA)
141
myMesh.AddHypothesis(aretes[11],hypNbSegC)
116
142
117
143
myMesh.AddHypothesis(aretes[4],hypNbSegB)
118
numberOfSegmentsC = 15
144
myMesh.AddHypothesis(aretes[5],hypNbSegB)
119
145
myMesh.AddHypothesis(aretes[6],hypNbSegB)
120
algo = mesh.Segment(aretes[1])
146
myMesh.AddHypothesis(aretes[7],hypNbSegB)
121
algo.NumberOfSegments(numberOfSegmentsC)
122
algo = mesh.Segment(aretes[3])
123
algo.NumberOfSegments(numberOfSegmentsC)
124
algo = mesh.Segment(aretes[9])
125
algo.NumberOfSegments(numberOfSegmentsC)
126
algo = mesh.Segment(aretes[11])
127
algo.NumberOfSegments(numberOfSegmentsC)
128
129
130
numberOfSegmentsB = 10
131
algo = mesh.Segment(aretes[4])
132
algo.NumberOfSegments(numberOfSegmentsB)
133
algo = mesh.Segment(aretes[5])
134
algo.NumberOfSegments(numberOfSegmentsB)
135
algo = mesh.Segment(aretes[6])
136
algo.NumberOfSegments(numberOfSegmentsB)
137
algo = mesh.Segment(aretes[7])
138
algo.NumberOfSegments(numberOfSegmentsB)
139
147
140
148
# ---- compute mesh
141
# ---- compute mesh
149
142
150
print "-------------------------- compute mesh"
143
print "-------------------------- compute mesh"
151
ret=smesh.Compute(myMesh, shape_mesh)
144
ret=mesh.Compute()
152
print ret
145
print ret
153
if ret != 0:
146
if ret != 0:
154
    #log=myMesh.GetLog(0) # no erase trace
147
    #log=mesh.GetLog(0) # no erase trace
155
    #for linelog in log:
148
    #for linelog in log:
156
    #    print linelog
149
    #    print linelog
157
    print "Information about the Mesh:"
150
    print "Information about the Mesh:"
158
    print "Number of nodes       : ", myMesh.NbNodes()
151
    print "Number of nodes       : ", mesh.NbNodes()
159
    print "Number of edges       : ", myMesh.NbEdges()
152
    print "Number of edges       : ", mesh.NbEdges()
160
    print "Number of faces       : ", myMesh.NbFaces()
153
    print "Number of faces       : ", mesh.NbFaces()
161
    print "Number of quadrangles : ", myMesh.NbQuadrangles()
154
    print "Number of quadrangles : ", mesh.NbQuadrangles()
162
    print "Number of volumes     : ", myMesh.NbVolumes()
155
    print "Number of volumes     : ", mesh.NbVolumes()
163
    print "Number of hexahedrons : ", myMesh.NbHexas()
156
    print "Number of hexahedrons : ", mesh.NbHexas()
164
else:
157
else:
165
    print "problem when Computing the mesh"
158
    print "problem when Computing the mesh"
166
159
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_mechanic.py (-100 / +26 lines)
Lines 28-33 Link Here
28
28
29
import salome
29
import salome
30
import geompy
30
import geompy
31
import smesh
31
32
32
import StdMeshers
33
import StdMeshers
33
34
Lines 120-249 Link Here
120
121
121
# ---------------------------- SMESH --------------------------------------
122
# ---------------------------- SMESH --------------------------------------
122
123
123
# ---- launch SMESH, init a Mesh with shape 'mechanic'
124
125
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
126
127
# -- Init --
124
# -- Init --
128
shape_mesh = salome.IDToObject( Id_mechanic )
125
shape_mesh = salome.IDToObject( Id_mechanic )
129
smesh.SetCurrentStudy(salome.myStudy)
130
131
mesh = smesh.CreateMesh(shape_mesh)
132
126
133
smeshgui = salome.ImportComponentGUI("SMESH")
127
mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic")
134
smeshgui.Init(salome.myStudyId)
135
136
idmesh = salome.ObjectToID(mesh)
137
smeshgui.SetName( idmesh, "Mesh_mechanic" )
138
128
139
print "-------------------------- NumberOfSegments"
129
print "-------------------------- NumberOfSegments"
140
130
141
numberOfSegment = 10
131
numberOfSegment = 10
142
132
143
hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
133
algo = mesh.Segment()
144
hypNbSeg.SetNumberOfSegments( numberOfSegment )
134
hypNbSeg = algo.NumberOfSegments(numberOfSegment)
145
print hypNbSeg.GetName()
135
print hypNbSeg.GetName()
146
print hypNbSeg.GetId()
136
print hypNbSeg.GetId()
147
print hypNbSeg.GetNumberOfSegments()
137
print hypNbSeg.GetNumberOfSegments()
148
138
smesh.SetName(hypNbSeg, "NumberOfSegments_10")
149
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
150
139
151
print "-------------------------- MaxElementArea"
140
print "-------------------------- MaxElementArea"
152
141
153
maxElementArea = 25
142
maxElementArea = 25
154
143
155
hypArea25 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
144
algo = mesh.Triangle()
156
hypArea25.SetMaxElementArea( maxElementArea )
145
hypArea25 = algo.MaxElementArea(maxElementArea)
157
print hypArea25.GetName()
146
print hypArea25.GetName()
158
print hypArea25.GetId()
147
print hypArea25.GetId()
159
print hypArea25.GetMaxElementArea()
148
print hypArea25.GetMaxElementArea()
149
smesh.SetName(hypArea25, "MaxElementArea_25")
160
150
161
smeshgui.SetName(salome.ObjectToID(hypArea25), "MaxElementArea_25")
151
# Create submesh on sub_face1 - sub_face4
162
152
# ---------------------------------------
163
print "-------------------------- MaxElementArea"
164
165
maxElementArea = 35
166
167
hypArea35 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
168
hypArea35.SetMaxElementArea( maxElementArea )
169
print hypArea35.GetName()
170
print hypArea35.GetId()
171
print hypArea35.GetMaxElementArea()
172
173
smeshgui.SetName(salome.ObjectToID(hypArea35), "MaxElementArea_35")
174
175
print "-------------------------- Regular_1D"
176
177
algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
178
listHyp = algoReg1D.GetCompatibleHypothesis()
179
for hyp in listHyp:
180
    print hyp
181
print algoReg1D.GetName()
182
print algoReg1D.GetId()
183
184
smeshgui.SetName(salome.ObjectToID(algoReg1D), "Regular_1D")
185
186
print "-------------------------- MEFISTO_2D"
187
188
algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
189
listHyp = algoMef.GetCompatibleHypothesis()
190
for hyp in listHyp:
191
    print hyp
192
print algoMef.GetName()
193
print algoMef.GetId()
194
195
smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D")
196
197
print "-------------------------- SMESH_Quadrangle_2D"
198
199
algoQuad = smesh.CreateHypothesis( "Quadrangle_2D", "libStdMeshersEngine.so" )
200
listHyp = algoQuad.GetCompatibleHypothesis()
201
for hyp in listHyp:
202
    print hyp
203
print algoQuad.GetName()
204
print algoQuad.GetId()
205
206
smeshgui.SetName(salome.ObjectToID(algoQuad), "SMESH_Quadrangle_2D")
207
208
print "-------------------------- add hypothesis to main shape"
209
210
mesh.AddHypothesis( shape_mesh, hypNbSeg )   # nb segments
211
mesh.AddHypothesis( shape_mesh, hypArea25 )  # max area
212
213
mesh.AddHypothesis( shape_mesh, algoReg1D )  # Regular 1D/wire discretisation
214
mesh.AddHypothesis( shape_mesh, algoMef )    # MEFISTO 2D
215
216
print "-------------------------- add hypothesis and algorithm to sub face 1"
217
218
submesh = mesh.GetSubMesh(sub_face1, "SubMeshFace1")
219
220
mesh.AddHypothesis( sub_face1, algoQuad )   # Quadrangle 2D
221
mesh.AddHypothesis( sub_face1, hypArea35 )  # max area
222
223
print "-------------------------- add hypothesis and algorithm to sub face 2"
224
225
submesh = mesh.GetSubMesh(sub_face2, "SubMeshFace2")
226
227
mesh.AddHypothesis( sub_face2, algoQuad )   # Quadrangle 2D
228
mesh.AddHypothesis( sub_face2, hypArea35 )  # max area
229
230
print "-------------------------- add hypothesis and algorith to sub face 3"
231
232
submesh = mesh.GetSubMesh(sub_face3, "SubMeshFace3")
233
234
mesh.AddHypothesis( sub_face3, algoQuad )   # Quadrangle 2D
235
mesh.AddHypothesis( sub_face3, hypArea35 )  # max area
236
237
print "-------------------------- add hypothesis and algorith to sub face 4"
238
239
submesh = mesh.GetSubMesh(sub_face4, "SubMeshFace4")
240
153
241
mesh.AddHypothesis( sub_face4, algoQuad )   # Quadrangle 2D
154
# Set 2D algorithm to submesh on sub_face1
242
mesh.AddHypothesis( sub_face4, hypArea35 )  # max area
155
algo = mesh.Quadrangle(sub_face1)
156
smesh.SetName(algo.GetSubMesh(), "SubMeshFace1")
157
158
# Set 2D algorithm to submesh on sub_face2
159
algo = mesh.Quadrangle(sub_face2)
160
smesh.SetName(algo.GetSubMesh(), "SubMeshFace2")
161
162
# Set 2D algorithm to submesh on sub_face3
163
algo = mesh.Quadrangle(sub_face3)
164
smesh.SetName(algo.GetSubMesh(), "SubMeshFace3")
165
166
# Set 2D algorithm to submesh on sub_face4
167
algo = mesh.Quadrangle(sub_face4)
168
smesh.SetName(algo.GetSubMesh(), "SubMeshFace4")
243
169
244
print "-------------------------- compute the mesh of the mechanic piece"
170
print "-------------------------- compute the mesh of the mechanic piece"
245
171
246
smesh.Compute(mesh, shape_mesh)
172
mesh.Compute()
247
173
248
print "Information about the Mesh_mechanic:"
174
print "Information about the Mesh_mechanic:"
249
print "Number of nodes       : ", mesh.NbNodes()
175
print "Number of nodes       : ", mesh.NbNodes()
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_mechanic_editor.py (-127 / +49 lines)
Lines 28-37 Link Here
28
28
29
import salome
29
import salome
30
import geompy
30
import geompy
31
31
import smesh
32
import StdMeshers
33
34
import SMESH
35
32
36
# ---------------------------- GEOM --------------------------------------
33
# ---------------------------- GEOM --------------------------------------
37
34
Lines 122-251 Link Here
122
119
123
# ---------------------------- SMESH --------------------------------------
120
# ---------------------------- SMESH --------------------------------------
124
121
125
# ---- launch SMESH, init a Mesh with shape 'mechanic'
126
127
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
128
129
# -- Init --
122
# -- Init --
130
shape_mesh = salome.IDToObject( Id_mechanic )
123
shape_mesh = salome.IDToObject( Id_mechanic )
131
smesh.SetCurrentStudy(salome.myStudy)
132
133
mesh = smesh.CreateMesh(shape_mesh)
134
124
135
smeshgui = salome.ImportComponentGUI("SMESH")
125
mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic")
136
smeshgui.Init(salome.myStudyId)
137
138
idmesh = salome.ObjectToID(mesh)
139
smeshgui.SetName( idmesh, "Mesh_mechanic" )
140
126
141
print "-------------------------- NumberOfSegments"
127
print "-------------------------- NumberOfSegments"
142
128
143
numberOfSegment = 10
129
numberOfSegment = 10
144
130
145
hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
131
algo = mesh.Segment()
146
hypNbSeg.SetNumberOfSegments( numberOfSegment )
132
hypNbSeg = algo.NumberOfSegments(numberOfSegment)
147
print hypNbSeg.GetName()
133
print hypNbSeg.GetName()
148
print hypNbSeg.GetId()
134
print hypNbSeg.GetId()
149
print hypNbSeg.GetNumberOfSegments()
135
print hypNbSeg.GetNumberOfSegments()
136
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegment))
150
137
151
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
152
138
153
print "-------------------------- MaxElementArea"
139
print "-------------------------- MaxElementArea"
154
140
155
maxElementArea = 25
141
maxElementArea = 25
156
142
157
hypArea25 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
143
algo = mesh.Triangle()
158
hypArea25.SetMaxElementArea( maxElementArea )
144
hypArea25 = algo.MaxElementArea(maxElementArea)
159
print hypArea25.GetName()
145
print hypArea25.GetName()
160
print hypArea25.GetId()
146
print hypArea25.GetId()
161
print hypArea25.GetMaxElementArea()
147
print hypArea25.GetMaxElementArea()
148
smesh.SetName(hypArea25, "MaxElementArea_" + str(maxElementArea))
162
149
163
smeshgui.SetName(salome.ObjectToID(hypArea25), "MaxElementArea_25")
164
165
print "-------------------------- MaxElementArea"
166
167
maxElementArea = 35
168
169
hypArea35 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
170
hypArea35.SetMaxElementArea( maxElementArea )
171
print hypArea35.GetName()
172
print hypArea35.GetId()
173
print hypArea35.GetMaxElementArea()
174
175
smeshgui.SetName(salome.ObjectToID(hypArea35), "MaxElementArea_35")
176
177
print "-------------------------- Regular_1D"
178
179
algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
180
listHyp = algoReg1D.GetCompatibleHypothesis()
181
for hyp in listHyp:
182
    print hyp
183
print algoReg1D.GetName()
184
print algoReg1D.GetId()
185
186
smeshgui.SetName(salome.ObjectToID(algoReg1D), "Regular_1D")
187
188
print "-------------------------- MEFISTO_2D"
189
190
algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
191
listHyp = algoMef.GetCompatibleHypothesis()
192
for hyp in listHyp:
193
    print hyp
194
print algoMef.GetName()
195
print algoMef.GetId()
196
197
smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D")
198
150
199
print "-------------------------- SMESH_Quadrangle_2D"
151
# Create submesh on sub_face1 - sub_face4
152
# ---------------------------------------
200
153
201
algoQuad = smesh.CreateHypothesis( "Quadrangle_2D", "libStdMeshersEngine.so" )
154
# Set 2D algorithm to submesh on sub_face1
202
listHyp = algoQuad.GetCompatibleHypothesis()
155
algo = mesh.Quadrangle(sub_face1)
203
for hyp in listHyp:
156
smesh.SetName(algo.GetSubMesh(), "SubMeshFace1")
204
    print hyp
157
submesh1 = algo.GetSubMesh()
205
print algoQuad.GetName()
158
206
print algoQuad.GetId()
159
# Set 2D algorithm to submesh on sub_face2
160
algo = mesh.Quadrangle(sub_face2)
161
smesh.SetName(algo.GetSubMesh(), "SubMeshFace2")
162
submesh2 = algo.GetSubMesh()
163
164
# Set 2D algorithm to submesh on sub_face3
165
algo = mesh.Quadrangle(sub_face3)
166
smesh.SetName(algo.GetSubMesh(), "SubMeshFace3")
167
submesh3 = algo.GetSubMesh()
168
169
# Set 2D algorithm to submesh on sub_face4
170
algo = mesh.Quadrangle(sub_face4)
171
smesh.SetName(algo.GetSubMesh(), "SubMeshFace4")
172
submesh4 = algo.GetSubMesh()
207
173
208
smeshgui.SetName(salome.ObjectToID(algoQuad), "SMESH_Quadrangle_2D")
209
210
print "-------------------------- add hypothesis to main shape"
211
212
mesh.AddHypothesis( shape_mesh, hypNbSeg )   # nb segments
213
mesh.AddHypothesis( shape_mesh, hypArea25 )  # max area
214
215
mesh.AddHypothesis( shape_mesh, algoReg1D )  # Regular 1D/wire discretisation
216
mesh.AddHypothesis( shape_mesh, algoMef )    # MEFISTO 2D
217
218
print "-------------------------- add hypothesis and algorithm to sub face 1"
219
220
submesh = mesh.GetSubMesh(sub_face1, "SubMeshFace1")
221
222
mesh.AddHypothesis( sub_face1, algoQuad )   # Quadrangle 2D
223
mesh.AddHypothesis( sub_face1, hypArea35 )  # max area
224
225
print "-------------------------- add hypothesis and algorithm to sub face 2"
226
227
submesh = mesh.GetSubMesh(sub_face2, "SubMeshFace2")
228
229
mesh.AddHypothesis( sub_face2, algoQuad )   # Quadrangle 2D
230
mesh.AddHypothesis( sub_face2, hypArea35 )  # max area
231
232
print "-------------------------- add hypothesis and algorith to sub face 3"
233
234
submesh = mesh.GetSubMesh(sub_face3, "SubMeshFace3")
235
236
mesh.AddHypothesis( sub_face3, algoQuad )   # Quadrangle 2D
237
mesh.AddHypothesis( sub_face3, hypArea35 )  # max area
238
239
print "-------------------------- add hypothesis and algorith to sub face 4"
240
241
submesh = mesh.GetSubMesh(sub_face4, "SubMeshFace4")
242
243
mesh.AddHypothesis( sub_face4, algoQuad )   # Quadrangle 2D
244
mesh.AddHypothesis( sub_face4, hypArea35 )  # max area
245
174
246
print "-------------------------- compute the mesh of the mechanic piece"
175
print "-------------------------- compute the mesh of the mechanic piece"
247
176
248
smesh.Compute(mesh, shape_mesh)
177
mesh.Compute()
249
178
250
print "Information about the Mesh_mechanic:"
179
print "Information about the Mesh_mechanic:"
251
print "Number of nodes       : ", mesh.NbNodes()
180
print "Number of nodes       : ", mesh.NbNodes()
Lines 257-308 Link Here
257
print "Number of tetrahedrons: ", mesh.NbTetras()
186
print "Number of tetrahedrons: ", mesh.NbTetras()
258
187
259
188
260
MeshEditor = mesh.GetMeshEditor()
261
262
#1 cutting of quadrangles of the 'SubMeshFace2' submesh
189
#1 cutting of quadrangles of the 'SubMeshFace2' submesh
263
submesh = mesh.GetSubMesh(sub_face2, "SubMeshFace2")
190
mesh.SplitQuadObject(submesh2, 1)
264
MeshEditor.SplitQuadObject(submesh, 1)
265
191
266
#2 cutting of triangles of the group
192
#2 cutting of triangles of the group
267
FacesTriToQuad = [2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422]
193
FacesTriToQuad = [2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422]
268
GroupTriToQuad = mesh.CreateGroup(SMESH.FACE,"Group of faces (quad)")
194
GroupTriToQuad = mesh.MakeGroupByIds("Group of faces (quad)", smesh.FACE, FacesTriToQuad)
269
GroupTriToQuad.Add(FacesTriToQuad)
195
mesh.TriToQuadObject(GroupTriToQuad, None , 1.57)
270
MeshEditor.TriToQuadObject(GroupTriToQuad, None , 1.57)
271
196
272
#3 extrusion of the group
197
#3 extrusion of the group
273
point = SMESH.PointStruct(0, 0, 5)
198
point = smesh.PointStruct(0, 0, 5)
274
vector = SMESH.DirStruct(point) 
199
vector = smesh.DirStruct(point) 
275
MeshEditor.ExtrusionSweepObject(GroupTriToQuad, vector, 5)
200
mesh.ExtrusionSweepObject(GroupTriToQuad, vector, 5)
276
201
277
#4 mirror object
202
#4 mirror object
278
MeshEditor.MirrorObject(mesh, SMESH.AxisStruct(0, 0, 0, 0, 0, 0), SMESH.SMESH_MeshEditor.POINT, 0) 
203
mesh.Mirror([], smesh.AxisStruct(0, 0, 0, 0, 0, 0), smesh.POINT, 0) 
279
204
280
#5 mesh translation
205
#5 mesh translation
281
point = SMESH.PointStruct(10, 10, 10)
206
point = smesh.PointStruct(10, 10, 10)
282
vector = SMESH.DirStruct(point) 
207
vector = smesh.DirStruct(point) 
283
MeshEditor.TranslateObject(mesh, vector, 0)
208
mesh.Translate([], vector, 0)
284
209
285
#6 mesh rotation
210
#6 mesh rotation
286
axisXYZ = SMESH.AxisStruct(0, 0, 0, 10, 10, 10)
211
axisXYZ = smesh.AxisStruct(0, 0, 0, 10, 10, 10)
287
angle180 =  180*3.141/180
212
angle180 =  180*3.141/180
288
MeshEditor.RotateObject(mesh, axisXYZ, angle180, 0)
213
mesh.Rotate([], axisXYZ, angle180, 0)
289
214
290
#7 group smoothing
215
#7 group smoothing
291
FacesSmooth = [864, 933, 941, 950, 1005, 1013]
216
FacesSmooth = [864, 933, 941, 950, 1005, 1013]
292
GroupSmooth = mesh.CreateGroup(SMESH.FACE,"Group of faces (smooth)")
217
GroupSmooth = mesh.MakeGroupByIds("Group of faces (smooth)", smesh.FACE, FacesSmooth)
293
GroupSmooth.Add(FacesSmooth)
218
mesh.SmoothObject(GroupSmooth, [], 20, 2, smesh.CENTROIDAL_SMOOTH)
294
MeshEditor.SmoothObject(GroupSmooth, [], 20, 2, SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH)
295
219
296
#8 rotation sweep object
220
#8 rotation sweep object
297
FacesRotate = [492, 493, 502, 503]
221
FacesRotate = [492, 493, 502, 503]
298
GroupRotate = mesh.CreateGroup(SMESH.FACE,"Group of faces (rotate)")
222
GroupRotate = mesh.MakeGroupByIds("Group of faces (rotate)", smesh.FACE, FacesRotate)
299
GroupRotate.Add(FacesRotate)
300
angle45 =  45*3.141/180
223
angle45 =  45*3.141/180
301
axisXYZ = SMESH.AxisStruct(-38.3128, -73.3658, -133.321, -13.3402, -13.3265, 6.66632)
224
axisXYZ = smesh.AxisStruct(-38.3128, -73.3658, -133.321, -13.3402, -13.3265, 6.66632)
302
MeshEditor.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5)
225
mesh.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5)
303
226
304
#9 reorientation of the whole mesh
227
#9 reorientation of the submesh1
305
submesh = mesh.GetSubMesh(sub_face1, "SubMeshFace1")
228
mesh.ReorientObject(submesh1)
306
MeshEditor.ReorientObject(submesh)
307
229
308
salome.sg.updateObjBrowser(1)
230
salome.sg.updateObjBrowser(1)
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_mechanic_netgen.py (-16 / +13 lines)
Lines 28-35 Link Here
28
28
29
geom  = geompy.geom
29
geom  = geompy.geom
30
30
31
import StdMeshers
32
import NETGENPlugin
33
import smesh
31
import smesh
34
32
35
# ---------------------------- GEOM --------------------------------------
33
# ---------------------------- GEOM --------------------------------------
Lines 109-121 Link Here
109
print "-------------------------- create Mesh, algorithm, hypothesis"
107
print "-------------------------- create Mesh, algorithm, hypothesis"
110
108
111
mesh = smesh.Mesh(mechanic, "Mesh_mechanic");
109
mesh = smesh.Mesh(mechanic, "Mesh_mechanic");
112
netgen = mesh.Netgen(0)
110
netgen = mesh.Triangle(smesh.NETGEN)
113
hyp = netgen.Parameters()
111
netgen.SetMaxSize( 50 )
114
hyp.SetMaxSize( 50 )
112
#netgen.SetSecondOrder( 0 )
115
#hyp.SetSecondOrder( 0 )
113
netgen.SetFineness( smesh.Fine )
116
hyp.SetFineness( 3 )
114
netgen.SetQuadAllowed( 1 )
117
hyp.SetQuadAllowed( 1 )
115
#netgen.SetOptimize( 1 )
118
#hyp.SetOptimize( 1 )
119
116
120
salome.sg.updateObjBrowser(1)
117
salome.sg.updateObjBrowser(1)
121
118
Lines 124-136 Link Here
124
print ret
121
print ret
125
if ret != 0:
122
if ret != 0:
126
    print "Information about the MeshcompShel:"
123
    print "Information about the MeshcompShel:"
127
    print "Number of nodes        : ", mesh.GetMesh().NbNodes()
124
    print "Number of nodes        : ", mesh.NbNodes()
128
    print "Number of edges        : ", mesh.GetMesh().NbEdges()
125
    print "Number of edges        : ", mesh.NbEdges()
129
    print "Number of faces        : ", mesh.GetMesh().NbFaces()
126
    print "Number of faces        : ", mesh.NbFaces()
130
    print "Number of triangles    : ", mesh.GetMesh().NbTriangles()
127
    print "Number of triangles    : ", mesh.NbTriangles()
131
    print "Number of quadrangles  : ", mesh.GetMesh().NbQuadrangles()
128
    print "Number of quadrangles  : ", mesh.NbQuadrangles()
132
    print "Number of volumes      : ", mesh.GetMesh().NbVolumes()
129
    print "Number of volumes      : ", mesh.NbVolumes()
133
    print "Number of tetrahedrons : ", mesh.GetMesh().NbTetras()
130
    print "Number of tetrahedrons : ", mesh.NbTetras()
134
    
131
    
135
else:
132
else:
136
    print "problem when computing the mesh"
133
    print "problem when computing the mesh"
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_mechanic_tetra.py (-73 / +16 lines)
Lines 26-41 Link Here
26
26
27
import salome
27
import salome
28
import geompy
28
import geompy
29
import smesh
29
30
30
geom  = geompy.geom
31
geom  = geompy.geom
31
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
32
smesh.SetCurrentStudy(salome.myStudy)
33
34
smeshgui = salome.ImportComponentGUI("SMESH")
35
smeshgui.Init(salome.myStudyId)
36
37
import StdMeshers
38
import NETGENPlugin
39
32
40
# ---------------------------- GEOM --------------------------------------
33
# ---------------------------- GEOM --------------------------------------
41
34
Lines 111-204 Link Here
111
104
112
### ---------------------------- SMESH --------------------------------------
105
### ---------------------------- SMESH --------------------------------------
113
106
114
print "-------------------------- NumberOfSegments"
107
shape_mesh = salome.IDToObject( Id_mechanic  )
108
109
mesh = smesh.Mesh(shape_mesh, "Mesh_mechanic_tetra")
110
111
print "-------------------------- add hypothesis to main mechanic"
115
112
116
numberOfSegment = 10
113
numberOfSegment = 10
117
114
118
hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" )
115
algo1 = mesh.Segment()
119
hypNbSeg.SetNumberOfSegments( numberOfSegment )
116
hypNbSeg = algo1.NumberOfSegments(numberOfSegment)
120
print hypNbSeg.GetName()
117
print hypNbSeg.GetName()
121
print hypNbSeg.GetId()
118
print hypNbSeg.GetId()
122
print hypNbSeg.GetNumberOfSegments()
119
print hypNbSeg.GetNumberOfSegments()
120
smesh.SetName(hypNbSeg, "NumberOfSegments_" + str(numberOfSegment))
123
121
124
smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10")
125
126
print "-------------------------- MaxElementArea"
127
122
128
maxElementArea = 20
123
maxElementArea = 20
129
124
130
hypArea = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" )
125
algo2 = mesh.Triangle(smesh.MEFISTO)
131
hypArea.SetMaxElementArea( maxElementArea )
126
hypArea = algo2.MaxElementArea(maxElementArea)
132
print hypArea.GetName()
127
print hypArea.GetName()
133
print hypArea.GetId()
128
print hypArea.GetId()
134
print hypArea.GetMaxElementArea()
129
print hypArea.GetMaxElementArea()
130
smesh.SetName(hypArea, "MaxElementArea_" + str(maxElementArea))
135
131
136
smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_20")
137
138
print "-------------------------- MaxElementVolume"
139
132
140
maxElementVolume = 20
133
maxElementVolume = 20
141
134
142
hypVolume = smesh.CreateHypothesis( "MaxElementVolume", "libStdMeshersEngine.so" )
135
algo3 = mesh.Tetrahedron(smesh.NETGEN)
143
hypVolume.SetMaxElementVolume( maxElementVolume )
136
hypVolume = algo3.MaxElementVolume(maxElementVolume)
144
print hypVolume.GetName()
137
print hypVolume.GetName()
145
print hypVolume.GetId()
138
print hypVolume.GetId()
146
print hypVolume.GetMaxElementVolume()
139
print hypVolume.GetMaxElementVolume()
140
smesh.SetName(hypVolume, "maxElementVolume_" + str(maxElementVolume))
147
141
148
smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_20")
149
150
print "-------------------------- Regular_1D"
151
152
algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" )
153
listHyp =algoReg1D.GetCompatibleHypothesis()
154
for hyp in listHyp:
155
    print hyp
156
print algoReg1D.GetName()
157
print algoReg1D.GetId()
158
159
smeshgui.SetName(salome.ObjectToID(algoReg1D), "Regular_1D")
160
161
print "-------------------------- MEFISTO_2D"
162
163
algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" )
164
listHyp = algoMef.GetCompatibleHypothesis()
165
for hyp in listHyp:
166
    print hyp
167
print algoMef.GetName()
168
print algoMef.GetId()
169
170
smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D")
171
172
print "-------------------------- NETGEN_3D"
173
174
algoNg = smesh.CreateHypothesis( "NETGEN_3D", "libNETGENEngine.so" )
175
listHyp = algoNg.GetCompatibleHypothesis()
176
for hyp in listHyp:
177
    print hyp
178
print algoNg.GetName()
179
print algoNg.GetId()
180
181
smeshgui.SetName(salome.ObjectToID(algoNg), "NETGEN_3D")
182
183
print "-------------------------- add hypothesis to main mechanic"
184
185
shape_mesh = salome.IDToObject( Id_mechanic  )
186
187
mesh = smesh.CreateMesh(shape_mesh)
188
189
idmesh = salome.ObjectToID(mesh)
190
smeshgui.SetName( idmesh, "Mesh_mechanic_tetra" )
191
192
mesh.AddHypothesis( shape_mesh, hypNbSeg )   # nb segments
193
mesh.AddHypothesis( shape_mesh, hypArea )    # max area
194
mesh.AddHypothesis( shape_mesh, hypVolume )  # max volume
195
196
mesh.AddHypothesis( shape_mesh, algoReg1D )  # Regular 1D/wire discretisation
197
mesh.AddHypothesis( shape_mesh, algoMef )    # MEFISTO 2D
198
mesh.AddHypothesis( shape_mesh, algoNg )     # NETGEN 3D
199
142
200
print "-------------------------- compute the mesh of the mechanic piece"
143
print "-------------------------- compute the mesh of the mechanic piece"
201
smesh.Compute(mesh,shape_mesh)
144
mesh.Compute()
202
145
203
print "Information about the Mesh_mechanic_tetra:"
146
print "Information about the Mesh_mechanic_tetra:"
204
print "Number of nodes       : ", mesh.NbNodes()
147
print "Number of nodes       : ", mesh.NbNodes()
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_reg.py (-116 / +44 lines)
Lines 24-34 Link Here
24
24
25
import salome
25
import salome
26
import geompy
26
import geompy
27
import smesh
27
28
28
import StdMeshers
29
import StdMeshers
29
30
30
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
31
smesh.SetCurrentStudy(salome.myStudy)
32
31
33
# ---- define a box
32
# ---- define a box
34
print "Define box"
33
print "Define box"
Lines 60-183 Link Here
60
smeshgui.Init(salome.myStudyId)
59
smeshgui.Init(salome.myStudyId)
61
60
62
61
63
print "-------------------------- create Hypothesis"
62
# ---- Creating meshes
64
63
65
print "-------------------------- LocalLength"
64
box = salome.IDToObject(idbox)
66
hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
65
names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ]
67
hypLen1.SetLength(100)
68
print hypLen1.GetName()
69
print hypLen1.GetId()
70
print hypLen1.GetLength()
71
72
idlength = salome.ObjectToID(hypLen1)
73
smeshgui.SetName(idlength, "Local_Length_100");
74
75
hypNbSeg = []
76
print "-------------------------- NumberOfSegments"
77
hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
78
hypNbSeg1.SetDistrType(0)
79
hypNbSeg1.SetNumberOfSegments(7)
80
print hypNbSeg1.GetName()
81
print hypNbSeg1.GetId()
82
print hypNbSeg1.GetNumberOfSegments()
83
idseg1 = salome.ObjectToID(hypNbSeg1)
84
smeshgui.SetName(idseg1, "NumberOfSegmentsReg");
85
hypNbSeg.append(hypNbSeg1)
86
87
hypNbSeg2 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
88
hypNbSeg2.SetDistrType(1)
89
hypNbSeg2.SetNumberOfSegments(7)
90
hypNbSeg2.SetScaleFactor(2)
91
print hypNbSeg2.GetName()
92
print hypNbSeg2.GetId()
93
print hypNbSeg2.GetNumberOfSegments()
94
idseg2 = salome.ObjectToID(hypNbSeg2)
95
smeshgui.SetName(idseg2, "NumberOfSegmentsScale");
96
hypNbSeg.append(hypNbSeg2)
97
98
hypNbSeg3 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
99
hypNbSeg3.SetDistrType(2)
100
hypNbSeg3.SetNumberOfSegments(7)
101
hypNbSeg3.SetTableFunction( [0, 0.1, 0.5, 1.0, 1.0, 0.1] )
102
hypNbSeg3.SetConversionMode(0)
103
print hypNbSeg3.GetName()
104
print hypNbSeg3.GetId()
105
print hypNbSeg3.GetNumberOfSegments()
106
idseg3 = salome.ObjectToID(hypNbSeg3)
107
smeshgui.SetName(idseg3, "NumberOfSegmentsTable");
108
hypNbSeg.append(hypNbSeg3)
109
110
hypNbSeg4 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
111
hypNbSeg4.SetDistrType(3)
112
hypNbSeg4.SetNumberOfSegments(10)
113
hypNbSeg4.SetExpressionFunction("sin(3*t)")
114
hypNbSeg4.SetConversionMode(1)
115
print hypNbSeg4.GetName()
116
print hypNbSeg4.GetId()
117
print hypNbSeg4.GetNumberOfSegments()
118
idseg4 = salome.ObjectToID(hypNbSeg4)
119
smeshgui.SetName(idseg4, "NumberOfSegmentsExpr");
120
hypNbSeg.append(hypNbSeg4)
121
122
print "-------------------------- MaxElementArea"
123
hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
124
hypArea1.SetMaxElementArea(2500)
125
print hypArea1.GetName()
126
print hypArea1.GetId()
127
print hypArea1.GetMaxElementArea()
128
129
idarea1 = salome.ObjectToID(hypArea1)
130
smeshgui.SetName(idarea1, "MaxElementArea_2500");
131
132
print "-------------------------- MaxElementArea"
133
hypArea2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
134
hypArea2.SetMaxElementArea(500)
135
print hypArea2.GetName()
136
print hypArea2.GetId()
137
print hypArea2.GetMaxElementArea()
138
139
idarea2 = salome.ObjectToID(hypArea2)
140
smeshgui.SetName(idarea2, "MaxElementArea_500");
141
142
print "-------------------------- Regular_1D"
143
algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
144
listHyp = algoReg.GetCompatibleHypothesis()
145
for hyp in listHyp:
146
    print hyp
147
print algoReg.GetName()
148
print algoReg.GetId()
149
150
idreg = salome.ObjectToID(algoReg)
151
smeshgui.SetName(idreg, "Regular_1D");
152
153
print "-------------------------- MEFISTO_2D"
154
algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
155
listHyp = algoMef.GetCompatibleHypothesis()
156
for hyp in listHyp:
157
    print hyp
158
print algoMef.GetName()
159
print algoMef.GetId()
160
161
idmef = salome.ObjectToID(algoMef)
162
smeshgui.SetName(idmef, "MEFISTO_2D");
163
66
164
salome.sg.updateObjBrowser(1);
165
67
166
# ---- Init a Mesh with the box
68
print "-------------------------- Create ", names[0], " mesh"
69
mesh = smesh.Mesh(box, names[0])
70
algo = mesh.Segment()
71
hyp = algo.NumberOfSegments(7)
72
hyp.SetDistrType(0)
73
smesh.SetName(hyp, "NumberOfSegmentsReg")
74
algo = mesh.Triangle()
75
algo.MaxElementArea(2500)
76
77
print "-------------------------- Create ", names[1], " mesh"
78
mesh = smesh.Mesh(box, names[1])
79
algo = mesh.Segment()
80
hyp = algo.NumberOfSegments(7)
81
hyp.SetDistrType(1)
82
hyp.SetScaleFactor(2)
83
smesh.SetName(hyp, "NumberOfSegmentsScale")
84
algo = mesh.Triangle()
85
algo.MaxElementArea(2500)
86
87
print "-------------------------- Create ", names[2], " mesh"
88
mesh = smesh.Mesh(box,names[2])
89
algo = mesh.Segment()
90
hyp = algo.NumberOfSegments(7)
91
hyp.SetDistrType(2)
92
hyp.SetTableFunction( [0, 0.1, 0.5, 1.0, 1.0, 0.1] )
93
hyp.SetConversionMode(0)
94
smesh.SetName(hyp, "NumberOfSegmentsTable")
95
algo = mesh.Triangle()
96
algo.MaxElementArea(2500)
97
98
print "-------------------------- Create ", names[3], " mesh"
99
mesh = smesh.Mesh(box, names[3])
100
algo = mesh.Segment()
101
hyp = algo.NumberOfSegments(10)
102
hyp.SetDistrType(3)
103
hyp.SetExpressionFunction("sin(3*t)")
104
hyp.SetConversionMode(1)
105
smesh.SetName(hyp, "NumberOfSegmentsExpr")
106
algo = mesh.Triangle()
107
algo.MaxElementArea(2500)
167
108
168
box = salome.IDToObject(idbox)
169
names = [ "MeshBoxReg", "MeshBoxScale", "MeshBoxTable", "MeshBoxExpr" ];
170
j = 0
171
for i in range(4):
172
  mesh = smesh.CreateMesh(box)
173
  idmesh = salome.ObjectToID(mesh)
174
  smeshgui.SetName(idmesh, names[j]);
175
  print "-------------------------- add hypothesis to box"
176
  mesh.AddHypothesis(box,algoReg)
177
  mesh.AddHypothesis(box,hypNbSeg[j])
178
  mesh.AddHypothesis(box,algoMef)
179
  mesh.AddHypothesis(box,hypArea1)
180
  j=j+1
181
109
182
salome.sg.updateObjBrowser(1);
110
salome.sg.updateObjBrowser(1);
183
111
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_test.py (-92 / +26 lines)
Lines 26-35 Link Here
26
26
27
import salome
27
import salome
28
import geompy
28
import geompy
29
import smeshpy
29
import smesh
30
31
import SMESH
32
import StdMeshers
33
30
34
# ---- define a box
31
# ---- define a box
35
32
Lines 57-150 Link Here
57
name = geompy.SubShapeName(edge, face)
54
name = geompy.SubShapeName(edge, face)
58
ide = geompy.addToStudyInFather(face, edge, name)
55
ide = geompy.addToStudyInFather(face, edge, name)
59
56
60
# ---- launch SMESH, init a Mesh with the box
57
# ---- SMESH
61
62
gen = smeshpy.smeshpy()
63
mesh = gen.CreateMesh(idb)
64
65
print "-------------------------- create Hypothesis"
66
67
print "-------------------------- LocalLength"
68
69
hypo1 = gen.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
70
print hypo1.GetName()
71
print hypo1.GetId()
72
print hypo1.GetLength()
73
hypo1.SetLength(100)
74
print hypo1.GetLength()
75
76
print "-------------------------- bidon"
77
58
78
hyp3 = gen.CreateHypothesis("bidon", "")
59
box = salome.IDToObject(idb)
79
60
mesh = smesh.Mesh(box, "Meshbox")
80
print "-------------------------- NumberOfSegments"
81
82
hypo3 = gen.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
83
hypo3.SetNumberOfSegments(7)
84
print hypo3.GetName()
85
print hypo3.GetNumberOfSegments()
86
print hypo3.GetId()
87
88
print "-------------------------- MaxElementArea"
89
90
hypo4 = gen.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
91
hypo4.SetMaxElementArea(5000)
92
print hypo4.GetName()
93
print hypo4.GetMaxElementArea()
94
print hypo4.GetId()
95
61
96
print "-------------------------- Regular_1D"
62
print "-------------------------- add hypothesis to box"
97
63
98
algo_1 = gen.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
64
algo_1 = mesh.Segment(box)
99
print algo_1.GetName()
65
hyp = algo_1.LocalLength(100)
100
print algo_1.GetId()
66
print hyp.GetName()
101
listHyp = algo_1.GetCompatibleHypothesis()
67
print hyp.GetId()
102
for hyp in listHyp:
68
print hyp.GetLength()
103
    print hyp
69
104
print algo_1.GetId()
70
algo_2 = mesh.Triangle(smesh.MEFISTO, box)
71
hyp = algo_2.MaxElementArea(5000)
72
print hyp.GetName()
73
print hyp.GetId()
74
print hyp.GetMaxElementArea()
105
75
106
print "-------------------------- MEFISTO_2D"
76
smesh.SetName(algo_2.GetSubMesh(), "SubMeshBox")
107
77
108
algo_2 = gen.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
109
print algo_2.GetName()
110
print algo_2.GetId()
111
listHyp = algo_2.GetCompatibleHypothesis()
112
for hyp in listHyp:
113
    print hyp
114
print algo_2.GetId()
115
78
116
print "-------------------------- add hypothesis to edge"
79
print "-------------------------- add hypothesis to edge"
117
80
118
edge = salome.IDToObject(ide)
81
edge = salome.IDToObject(ide)
119
submesh = mesh.GetSubMesh(edge, "SubMeshEdge")
120
ret = mesh.AddHypothesis(edge,algo_1)
121
print ret
122
ret = mesh.AddHypothesis(edge,hypo1)
123
print ret
124
82
125
##print "-------------------------- compute edge"
83
algo_3 = mesh.Segment(edge)
126
##ret=gen.Compute(mesh,ide)
84
hyp = algo_3.LocalLength(100)
127
##print ret
85
print hyp.GetName()
128
##log=mesh.GetLog(1);
86
print hyp.GetId()
129
##for a in log:
87
print hyp.GetLength()
130
##    print a
131
88
132
print "-------------------------- add hypothesis to box"
89
smesh.SetName(algo_3.GetSubMesh(), "SubMeshEdge")
133
90
134
box = salome.IDToObject(idb)
135
submesh = mesh.GetSubMesh(box, "SubMeshBox")
136
ret = mesh.AddHypothesis(box,algo_1)
137
print ret
138
ret = mesh.AddHypothesis(box,hypo1)
139
print ret
140
ret = mesh.AddHypothesis(box,algo_2)
141
print ret
142
ret = mesh.AddHypothesis(box,hypo4)
143
print ret
144
91
145
print "-------------------------- compute face"
92
print "-------------------------- compute face"
146
93
147
ret = gen.Compute(mesh,idf)
94
face = salome.IDToObject(idf)
95
96
ret = mesh.Compute(face)
148
print ret
97
print ret
149
log = mesh.GetLog(0) # 0 - GetLog without ClearLog after, else if 1 - ClearLog after
98
log = mesh.GetLog(0) # 0 - GetLog without ClearLog after, else if 1 - ClearLog after
150
for a in log:
99
for a in log:
Lines 183-200 Link Here
183
            i3 = a.indexes[ii]
132
            i3 = a.indexes[ii]
184
            ii = ii+1
133
            ii = ii+1
185
            print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)
134
            print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3)
186
187
##print "-------------------------- compute box"
188
##ret=gen.Compute(mesh,idb)
189
##print ret
190
##log=mesh.GetLog(1);
191
##print log
192
193
##shell=salome.IDToObject(ids)
194
##submesh=mesh.GetElementsOnShape(shell)
195
##ret=mesh.AddHypothesis(shell,algo_1)
196
##print ret
197
##ret=mesh.AddHypothesis(shell,hypo1)
198
##print ret
199
##ret=gen.Compute(mesh,ids)
200
##print ret
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_test0.py (-1 lines)
Lines 26-32 Link Here
26
import geompy
26
import geompy
27
from geompy import geom
27
from geompy import geom
28
28
29
import SMESH
30
29
31
myBuilder = salome.myStudy.NewBuilder()
30
myBuilder = salome.myStudy.NewBuilder()
32
31
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_test1.py (-80 / +29 lines)
Lines 24-34 Link Here
24
24
25
import salome
25
import salome
26
import geompy
26
import geompy
27
import smesh
27
28
28
import StdMeshers
29
30
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
31
smesh.SetCurrentStudy(salome.myStudy)
32
29
33
# ---- define a box
30
# ---- define a box
34
31
Lines 59-157 Link Here
59
print name
56
print name
60
idedge = geompy.addToStudyInFather(face, edge, name)
57
idedge = geompy.addToStudyInFather(face, edge, name)
61
58
62
# ---- launch SMESH
63
64
smeshgui = salome.ImportComponentGUI("SMESH")
65
smeshgui.Init(salome.myStudyId)
66
59
67
print "-------------------------- create Hypothesis"
60
# ---- SMESH
68
61
69
print "-------------------------- LocalLength"
62
# ---- Init a Mesh with the box
70
hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
71
hypLen1.SetLength(100)
72
print hypLen1.GetName()
73
print hypLen1.GetId()
74
print hypLen1.GetLength()
75
63
76
idlength = salome.ObjectToID(hypLen1) 
64
mesh = smesh.Mesh(box, "Meshbox")
77
smeshgui.SetName(idlength, "Local_Length_100");
78
65
79
print "-------------------------- NumberOfSegments"
66
print "-------------------------- add hypothesis to box"
80
hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
67
algoReg1 = mesh.Segment()
81
hypNbSeg1.SetNumberOfSegments(7)
68
hypNbSeg1 = algoReg1.NumberOfSegments(7)
82
print hypNbSeg1.GetName()
69
print hypNbSeg1.GetName()
83
print hypNbSeg1.GetId()
70
print hypNbSeg1.GetId()
84
print hypNbSeg1.GetNumberOfSegments()
71
print hypNbSeg1.GetNumberOfSegments()
72
smesh.SetName(hypNbSeg1, "NumberOfSegments_7")
85
73
86
idseg = salome.ObjectToID(hypNbSeg1) 
74
algoMef1 = mesh.Triangle()
87
smeshgui.SetName(idseg, "NumberOfSegments_7");
75
hypArea1 = algoMef1.MaxElementArea(2500)
88
89
print "-------------------------- MaxElementArea"
90
hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
91
hypArea1.SetMaxElementArea(2500)
92
print hypArea1.GetName()
76
print hypArea1.GetName()
93
print hypArea1.GetId()
77
print hypArea1.GetId()
94
print hypArea1.GetMaxElementArea()
78
print hypArea1.GetMaxElementArea()
95
79
smesh.SetName(hypArea1, "MaxElementArea_2500")
96
idarea1 = salome.ObjectToID(hypArea1)
97
smeshgui.SetName(idarea1, "MaxElementArea_2500");
98
99
print "-------------------------- MaxElementArea"
100
hypArea2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
101
hypArea2.SetMaxElementArea(500)
102
print hypArea2.GetName()
103
print hypArea2.GetId()
104
print hypArea2.GetMaxElementArea()
105
106
idarea2 = salome.ObjectToID(hypArea2)
107
smeshgui.SetName(idarea2, "MaxElementArea_500");
108
109
print "-------------------------- Regular_1D"
110
algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
111
listHyp = algoReg.GetCompatibleHypothesis()
112
for hyp in listHyp:
113
    print hyp
114
print algoReg.GetName()
115
print algoReg.GetId()
116
117
idreg = salome.ObjectToID(algoReg)
118
smeshgui.SetName(idreg, "Regular_1D");
119
120
print "-------------------------- MEFISTO_2D"
121
algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
122
listHyp = algoMef.GetCompatibleHypothesis()
123
for hyp in listHyp:
124
    print hyp
125
print algoMef.GetName()
126
print algoMef.GetId()
127
128
idmef = salome.ObjectToID(algoMef)
129
smeshgui.SetName(idmef, "MEFISTO_2D");
130
131
# ---- Init a Mesh with the box
132
133
box = salome.IDToObject(idbox)
134
mesh = smesh.CreateMesh(box)
135
idmesh = salome.ObjectToID(mesh)
136
smeshgui.SetName(idmesh, "Meshbox");
137
138
print "-------------------------- add hypothesis to box"
139
mesh.AddHypothesis(box,algoReg)
140
mesh.AddHypothesis(box,hypNbSeg1)
141
mesh.AddHypothesis(box,algoMef)
142
mesh.AddHypothesis(box,hypArea1)
143
80
144
# ---- add hypothesis to edge
81
# ---- add hypothesis to edge
145
146
print "-------------------------- add hypothesis to edge"
82
print "-------------------------- add hypothesis to edge"
147
edge = salome.IDToObject(idedge)
83
edge = salome.IDToObject(idedge)
148
submesh = mesh.GetSubMesh(edge, "SubMeshEdge")
149
mesh.AddHypothesis(edge, algoReg)
150
mesh.AddHypothesis(edge, hypLen1)
151
84
85
algoReg2 = mesh.Segment(edge)
86
hypLen1 = algoReg2.LocalLength(100)
87
smesh.SetName(algoReg2.GetSubMesh(), "SubMeshEdge")
88
print hypLen1.GetName()
89
print hypLen1.GetId()
90
print hypLen1.GetLength()
91
smesh.SetName(hypLen1, "Local_Length_100")
92
93
# ---- add hypothesis to face
152
print "-------------------------- add hypothesis to face"
94
print "-------------------------- add hypothesis to face"
153
face = salome.IDToObject(idface)
95
face = salome.IDToObject(idface)
154
submesh = mesh.GetSubMesh(face, "SubMeshFace")
96
155
mesh.AddHypothesis(face, hypArea2)
97
algoMef2 = mesh.Triangle(face)
98
hypArea2 = algoMef2.MaxElementArea(500)
99
smesh.SetName(algoMef2.GetSubMesh(), "SubMeshFace")
100
print hypArea2.GetName()
101
print hypArea2.GetId()
102
print hypArea2.GetMaxElementArea()
103
smesh.SetName(hypArea2, "MaxElementArea_500")
104
156
105
157
salome.sg.updateObjBrowser(1);
106
salome.sg.updateObjBrowser(1);
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_test2.py (-31 / +2 lines)
Lines 27-65 Link Here
27
# ---- compute box
27
# ---- compute box
28
28
29
print "-------------------------- compute box"
29
print "-------------------------- compute box"
30
ret = smesh.Compute(mesh,box)
30
ret = mesh.Compute()
31
print ret
31
print ret
32
log = mesh.GetLog(0); # no erase trace
32
log = mesh.GetLog(0); # no erase trace
33
for linelog in log:
33
for linelog in log:
34
    print linelog
34
    print linelog
35
35
36
salome.sg.updateObjBrowser(1);
36
salome.sg.updateObjBrowser(1)
37
38
# ---- compute edge
39
40
##print "-------------------------- compute edge"
41
##ret=gen.Compute(mesh,idedge)
42
##print ret
43
##log=mesh.GetLog(1);
44
##for a in log:
45
##    print a
46
47
# ---- add hypothesis to face
48
49
# ---- compute face
50
51
#print "-------------------------- compute face"
52
#ret=gen.Compute(mesh,idface)
53
#print ret
54
#log=mesh.GetLog(1);
55
#for a in log:
56
#    print a
57
58
##shell=salome.IDToObject(ids)
59
##submesh=mesh.GetElementsOnShape(shell)
60
##ret=mesh.AddHypothesis(shell,algoReg)
61
##print ret
62
##ret=mesh.AddHypothesis(shell,hypLen1)
63
##print ret
64
##ret=gen.Compute(mesh,ids)
65
##print ret
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_test4.py (-29 / +27 lines)
Lines 19-29 Link Here
19
#
19
#
20
import salome
20
import salome
21
import geompy
21
import geompy
22
import SMESH
22
import smesh
23
import StdMeshers
24
23
25
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
24
26
smesh.SetCurrentStudy(salome.myStudy)
25
# ---- GEOM
27
26
28
box   = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
27
box   = geompy.MakeBox(0., 0., 0., 100., 200., 300.)
29
idbox = geompy.addToStudy(box, "box")
28
idbox = geompy.addToStudy(box, "box")
Lines 36-70 Link Here
36
box  = salome.IDToObject(idbox)
35
box  = salome.IDToObject(idbox)
37
face = salome.IDToObject(idface)
36
face = salome.IDToObject(idface)
38
37
39
hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
38
# ---- SMESH
40
hyp1.SetNumberOfSegments(10)
39
41
hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
40
mesh = smesh.Mesh(box, "Meshbox")
42
hyp2.SetMaxElementArea(10)
41
43
hyp3 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
42
# Set 1D algorithm/hypotheses to mesh
44
hyp3.SetMaxElementArea(100)
43
algo1 = mesh.Segment()
45
44
algo1.NumberOfSegments(10)
46
algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
45
47
algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
46
# Set 2D algorithm/hypotheses to mesh
48
47
algo2 = mesh.Triangle(smesh.MEFISTO)
49
mesh = smesh.CreateMesh(box)
48
algo2.MaxElementArea(10)
50
mesh.AddHypothesis(box,hyp1)
49
51
mesh.AddHypothesis(box,hyp2)
50
# Create submesh on face
52
mesh.AddHypothesis(box,algo1)
51
algo3 = mesh.Segment(face)
53
mesh.AddHypothesis(box,algo2)
52
algo3.NumberOfSegments(10)
54
53
algo4 = mesh.Triangle(smesh.MEFISTO, face)
55
submesh = mesh.GetSubMesh(face, "SubMeshFace")
54
algo4.MaxElementArea(100)
56
mesh.AddHypothesis(face,hyp1)
55
submesh = algo4.GetSubMesh()
57
mesh.AddHypothesis(face,hyp3)
56
smesh.SetName(submesh, "SubMeshFace")
58
mesh.AddHypothesis(face,algo1)
57
59
mesh.AddHypothesis(face,algo2)
60
58
61
smesh.Compute(mesh,box)
59
mesh.Compute()
62
60
63
faces = submesh.GetElementsByType(SMESH.FACE)
61
faces = submesh.GetElementsByType(smesh.FACE)
64
if len(faces) > 1:
62
if len(faces) > 1:
65
    print len(faces), len(faces)/2
63
    print len(faces), len(faces)/2
66
    group1 = mesh.CreateGroup(SMESH.FACE,"Group of faces")
64
    group1 = mesh.CreateEmptyGroup(smesh.FACE,"Group of faces")
67
    group2 = mesh.CreateGroup(SMESH.FACE,"Another group of faces")
65
    group2 = mesh.CreateEmptyGroup(smesh.FACE,"Another group of faces")
68
    group1.Add(faces[:int(len(faces)/2)])
66
    group1.Add(faces[:int(len(faces)/2)])
69
    group2.Add(faces[int(len(faces)/2):])
67
    group2.Add(faces[int(len(faces)/2):])
70
68
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/SMESH_test5.py (-13 / +8 lines)
Lines 19-29 Link Here
19
#
19
#
20
#
20
#
21
#
21
#
22
#  File   : SMESH_test1.py
22
#  File   : SMESH_test5.py
23
#  Module : SMESH
23
#  Module : SMESH
24
24
25
import salome
25
import salome
26
import SMESH
26
import smesh
27
import SALOMEDS
27
import SALOMEDS
28
import CORBA
28
import CORBA
29
import os
29
import os
Lines 43-68 Link Here
43
43
44
    for iMesh in range(len(aMeshes)) :
44
    for iMesh in range(len(aMeshes)) :
45
        aMesh = aMeshes[iMesh]
45
        aMesh = aMeshes[iMesh]
46
        anSObj = salome.ObjectToSObject(aMesh)
46
        print aMesh.GetName(),
47
        print anSObj.GetName(),
48
        aFileName = anInitFileName
47
        aFileName = anInitFileName
49
        aFileName = os.path.basename(aFileName)
48
        aFileName = os.path.basename(aFileName)
50
        SetSObjName(anSObj,aFileName)
49
        aMesh.SetName(aFileName)
51
        print anSObj.GetName()
50
        print aMesh.GetName()
52
51
53
        aOutPath = '/tmp/'
52
        aOutPath = '/tmp/'
54
        aFileName = aOutPath + theFile + "." + str(iMesh) + ".unv"
53
        aFileName = aOutPath + theFile + "." + str(iMesh) + ".unv"
55
        aMesh.ExportUNV(aFileName)
54
        aMesh.ExportUNV(aFileName)
56
        aMesh = smesh.CreateMeshesFromUNV(aFileName)
55
        aMesh = smesh.CreateMeshesFromUNV(aFileName)
57
        anSObj = salome.ObjectToSObject(aMesh)
56
        print aMesh.GetName(),
58
        print anSObj.GetName(),
59
        os.remove(aFileName)
57
        os.remove(aFileName)
60
        aFileName = os.path.basename(aFileName)
58
        aFileName = os.path.basename(aFileName)
61
        SetSObjName(anSObj,aFileName)
59
        aMesh.SetName(aFileName)
62
        print anSObj.GetName()
60
        print aMesh.GetName()
63
64
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
65
smesh.SetCurrentStudy(salome.myStudy)
66
61
67
aPath = os.getenv('DATA_DIR') + '/MedFiles/'
62
aPath = os.getenv('DATA_DIR') + '/MedFiles/'
68
aListDir = os.listdir(aPath)
63
aListDir = os.listdir(aPath)
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/batchmode_mefisto.py (-43 / +11 lines)
Lines 49-92 Link Here
49
49
50
50
51
    # ---- SMESH
51
    # ---- SMESH
52
    print "-------------------------- create mesh"
53
    mesh = smesh.Mesh(shape_mesh)
52
      
54
      
53
    print "-------------------------- create Hypothesis"
55
    print "-------------------------- create Hypothesis"
54
    if (len is not None):
56
    if (len is not None):
55
        print "-------------------------- LocalLength"
57
        print "-------------------------- LocalLength"
56
        hypLength1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so")
58
        algoReg = mesh.Segment()
57
        hypLength1.SetLength(len)
59
        hypLength1 = algoReg.LocalLength(len)
58
        print "Hypothesis type : ", hypLength1.GetName()
60
        print "Hypothesis type : ", hypLength1.GetName()
59
        print "Hypothesis ID   : ", hypLength1.GetId()
61
        print "Hypothesis ID   : ", hypLength1.GetId()
60
        print "Hypothesis Value: ", hypLength1.GetLength()
62
        print "Hypothesis Value: ", hypLength1.GetLength()
61
    
63
    
62
    if (nbseg is not None):   
64
    if (nbseg is not None):   
63
        print "-------------------------- NumberOfSegments"
65
        print "-------------------------- NumberOfSegments"
64
        hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so")
66
        algoReg = mesh.Segment()
65
        hypNbSeg1.SetNumberOfSegments(nbseg)
67
        hypNbSeg1 = algoReg.NumberOfSegments(nbseg)
66
        print "Hypothesis type : ", hypNbSeg1.GetName()
68
        print "Hypothesis type : ", hypNbSeg1.GetName()
67
        print "Hypothesis ID   : ", hypNbSeg1.GetId()
69
        print "Hypothesis ID   : ", hypNbSeg1.GetId()
68
        print "Hypothesis Value: ", hypNbSeg1.GetNumberOfSegments()
70
        print "Hypothesis Value: ", hypNbSeg1.GetNumberOfSegments()
69
71
70
    if (area == "LengthFromEdges"):
72
    if (area == "LengthFromEdges"):
71
        print "-------------------------- LengthFromEdges"
73
        print "-------------------------- LengthFromEdges"
72
        hypLengthFromEdges = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so")
74
        algoMef = mesh.Triangle()
73
        hypLengthFromEdges.SetMode(1)
75
        hypLengthFromEdges = algoMef.LengthFromEdges(1)
74
        print "Hypothesis type     : ", hypLengthFromEdges.GetName()
76
        print "Hypothesis type     : ", hypLengthFromEdges.GetName()
75
        print "Hypothesis ID       : ", hypLengthFromEdges.GetId()
77
        print "Hypothesis ID       : ", hypLengthFromEdges.GetId()
76
        print "LengthFromEdges Mode: ", hypLengthFromEdges.GetMode()
78
        print "LengthFromEdges Mode: ", hypLengthFromEdges.GetMode()
77
       
79
       
78
    else:
80
    else:
79
        print "-------------------------- MaxElementArea"
81
        print "-------------------------- MaxElementArea"
80
        hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so")
82
        algoMef = mesh.Triangle()
81
        hypArea1.SetMaxElementArea(area)
83
        hypArea1 = algoMef.MaxElementArea(area)
82
        print "Hypothesis type : ", hypArea1.GetName()
84
        print "Hypothesis type : ", hypArea1.GetName()
83
        print "Hypothesis ID   : ", hypArea1.GetId()
85
        print "Hypothesis ID   : ", hypArea1.GetId()
84
        print "Hypothesis Value: ", hypArea1.GetMaxElementArea()
86
        print "Hypothesis Value: ", hypArea1.GetMaxElementArea()
85
              
87
              
86
    
88
    
87
    print "-------------------------- Regular_1D"
89
    print "-------------------------- Regular_1D"
88
    algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so")
89
   
90
    listHyp = algoReg.GetCompatibleHypothesis()
90
    listHyp = algoReg.GetCompatibleHypothesis()
91
    for hyp in listHyp:
91
    for hyp in listHyp:
92
        print hyp
92
        print hyp
Lines 95-102 Link Here
95
    print "Algo ID  : ", algoReg.GetId()
95
    print "Algo ID  : ", algoReg.GetId()
96
   
96
   
97
    print "-------------------------- MEFISTO_2D"
97
    print "-------------------------- MEFISTO_2D"
98
    algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so")
99
    
100
    listHyp = algoMef.GetCompatibleHypothesis()
98
    listHyp = algoMef.GetCompatibleHypothesis()
101
    for hyp in listHyp:
99
    for hyp in listHyp:
102
        print hyp
100
        print hyp
Lines 107-144 Link Here
107
105
108
    # ---- add hypothesis to shape
106
    # ---- add hypothesis to shape
109
107
110
    print "-------------------------- add hypothesis to shape"
111
    mesh = smesh.CreateMesh(shape_mesh) 
112
113
    ret = mesh.AddHypothesis(shape_mesh, algoReg)
114
    print "Add Regular_1D algo .... ", 
115
    print ret
116
    
117
    if (nbseg is not None):
118
        ret = mesh.AddHypothesis(shape_mesh, hypNbSeg1)
119
        print "Add Number Of Segements algo .... ", 
120
        print ret
121
122
    if (len is not None):
123
        ret = mesh.AddHypothesis(shape_mesh,hypLength1)
124
        print "Add  Local Length algo .... ", 
125
        print ret
126
127
    ret = mesh.AddHypothesis(shape_mesh, algoMef)
128
    print "Add MEFISTO_2D algo....", 
129
    print ret
130
    
131
    if (area == "LengthFromEdges"):
132
        ret = mesh.AddHypothesis( shape_mesh, hypLengthFromEdges)    # length from edge 
133
        print "Add Length From Edges algo .... ",
134
        print ret
135
    else:
136
        ret = mesh.AddHypothesis(shape_mesh, hypArea1)
137
        print "Add Max Triangle Area algo .... ", 
138
        print ret
139
    
140
    print "-------------------------- compute mesh"
108
    print "-------------------------- compute mesh"
141
    ret = smesh.Compute(mesh,shape_mesh)
109
    ret = mesh.Compute()
142
    print  "Compute Mesh .... ", 
110
    print  "Compute Mesh .... ", 
143
    print ret
111
    print ret
144
    log = mesh.GetLog(0); # no erase trace
112
    log = mesh.GetLog(0); # no erase trace
(-)SMESH_SRC_3.2.2/src/SMESH_SWIG/smesh.py (-128 / +1436 lines)
Lines 1-26 Link Here
1
#  Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2
#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3
#
4
#  This library is free software; you can redistribute it and/or
5
#  modify it under the terms of the GNU Lesser General Public
6
#  License as published by the Free Software Foundation; either
7
#  version 2.1 of the License.
8
#
9
#  This library is distributed in the hope that it will be useful,
10
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
#  Lesser General Public License for more details.
13
#
14
#  You should have received a copy of the GNU Lesser General Public
15
#  License along with this library; if not, write to the Free Software
16
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17
#
18
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
#
20
#  File   : smesh.py
21
#  Author : Francis KLOSS, OCC
22
#  Module : SMESH
23
24
"""
1
"""
25
 \namespace smesh
2
 \namespace smesh
26
 \brief Module smesh
3
 \brief Module smesh
Lines 30-49 Link Here
30
import geompy
7
import geompy
31
import StdMeshers
8
import StdMeshers
32
import SMESH
9
import SMESH
10
from   SMESH import *
33
11
34
12
## Types of algo
35
REGULAR = 1
13
REGULAR = 1
36
PYTHON  = 2
14
PYTHON  = 2
37
15
38
NETGEN  = 3
16
MEFISTO = 3
39
GHS3D   = 4
17
NETGEN  = 4
18
GHS3D   = 5
19
FULL_NETGEN = 6
20
21
## MirrorType enumeration
22
POINT = SMESH_MeshEditor.POINT
23
AXIS =  SMESH_MeshEditor.AXIS 
24
PLANE = SMESH_MeshEditor.PLANE
25
26
## Smooth_Method enumeration
27
LAPLACIAN_SMOOTH = SMESH_MeshEditor.LAPLACIAN_SMOOTH
28
CENTROIDAL_SMOOTH = SMESH_MeshEditor.CENTROIDAL_SMOOTH
29
30
## Fineness enumeration(for NETGEN)
31
VeryCoarse = 0
32
Coarse = 1
33
Moderate = 2
34
Fine = 3
35
VeryFine = 4
36
Custom = 5
37
38
39
NO_NAME = "NoName"
40
40
41
41
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
42
smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH")
42
smesh.SetCurrentStudy(salome.myStudy)
43
smesh.SetCurrentStudy(salome.myStudy)
43
44
45
## Global functions
44
46
45
NO_NAME = "NoName"
47
## Gets object name
46
47
def GetName(obj):
48
def GetName(obj):
48
    ior  = salome.orb.object_to_string(obj)
49
    ior  = salome.orb.object_to_string(obj)
49
    sobj = salome.myStudy.FindObjectIOR(ior)
50
    sobj = salome.myStudy.FindObjectIOR(ior)
Lines 53-65 Link Here
53
        attr = sobj.FindAttribute("AttributeName")[1]
54
        attr = sobj.FindAttribute("AttributeName")[1]
54
        return attr.Value()
55
        return attr.Value()
55
56
57
## Sets name to object
56
def SetName(obj, name):
58
def SetName(obj, name):
57
    ior  = salome.orb.object_to_string(obj)
59
    ior  = salome.orb.object_to_string(obj)
58
    sobj = salome.myStudy.FindObjectIOR(ior)
60
    sobj = salome.myStudy.FindObjectIOR(ior)
59
    if not sobj is None:
61
    if not sobj is None:
60
        attr = sobj.FindAttribute("AttributeName")[1]
62
        attr = sobj.FindAttribute("AttributeName")[1]
61
        attr.SetValue(name)
63
        attr.SetValue(name)
64
        
65
## Returns long value from enumeration
66
#  Uses for FT_... enumeration
67
def EnumToLong(theItem):
68
    return theItem._v
69
70
## Get PointStruct from vertex
71
#  @param theVertex is GEOM object(vertex)
72
#  @return SMESH.PointStruct
73
def GetPointStruct(theVertex):
74
    [x, y, z] = geompy.PointCoordinates(theVertex)
75
    return PointStruct(x,y,z)
76
77
## Get DirStruct from vector
78
#  @param theVector is GEOM object(vector)
79
#  @return SMESH.DirStruct
80
def GetDirStruct(theVector):
81
    vertices = geompy.SubShapeAll( theVector, geompy.ShapeType["VERTEX"] )
82
    if(len(vertices) != 2):
83
        print "Error: vector object is incorrect."
84
        return None
85
    p1 = geompy.PointCoordinates(vertices[0])
86
    p2 = geompy.PointCoordinates(vertices[1])
87
    pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
88
    dir = DirStruct(pnt)
89
    return dir
90
91
## Get AxisStruct from object
92
#  @param theObj is GEOM object(line or plane)
93
#  @return SMESH.AxisStruct
94
def GetAxisStruct(theObj):
95
    edges = geompy.SubShapeAll( theObj, geompy.ShapeType["EDGE"] )
96
    if len(edges) > 1:
97
        vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] )
98
        vertex3, vertex4 = geompy.SubShapeAll( edges[1], geompy.ShapeType["VERTEX"] )
99
        vertex1 = geompy.PointCoordinates(vertex1)
100
        vertex2 = geompy.PointCoordinates(vertex2)
101
        vertex3 = geompy.PointCoordinates(vertex3)
102
        vertex4 = geompy.PointCoordinates(vertex4)
103
        v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
104
        v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
105
        normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
106
        axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
107
        return axis
108
    elif len(edges) == 1:
109
        vertex1, vertex2 = geompy.SubShapeAll( edges[0], geompy.ShapeType["VERTEX"] )
110
        p1 = geompy.PointCoordinates( vertex1 )
111
        p2 = geompy.PointCoordinates( vertex2 )
112
        axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
113
        return axis
114
    return None
115
116
## From SMESH_Gen interface:
117
#  ------------------------
118
119
## Set the current mode
120
def SetEmbeddedMode( theMode ):
121
    smesh.SetEmbeddedMode(theMode)
122
123
## Get the current mode
124
def IsEmbeddedMode():
125
    return smesh.IsEmbeddedMode()
126
127
## Set the current study
128
def SetCurrentStudy( theStudy ):
129
    smesh.SetCurrentStudy(theStudy)
130
131
## Get the current study
132
def GetCurrentStudy():
133
    return smesh.GetCurrentStudy()
134
135
## Create Mesh object importing data from given UNV file
136
#  @return an instance of Mesh class
137
def CreateMeshesFromUNV( theFileName ):
138
    aSmeshMesh = smesh.CreateMeshesFromUNV(theFileName)
139
    aMesh = Mesh(aSmeshMesh)
140
    return aMesh
141
142
## Create Mesh object(s) importing data from given MED file
143
#  @return a list of Mesh class instances
144
def CreateMeshesFromMED( theFileName ):
145
    aSmeshMeshes, aStatus = smesh.CreateMeshesFromMED(theFileName)
146
    aMeshes = []
147
    for iMesh in range(len(aSmeshMeshes)) :
148
        aMesh = Mesh(aSmeshMeshes[iMesh])
149
        aMeshes.append(aMesh)
150
    return aMeshes, aStatus
151
152
## Create Mesh object importing data from given STL file
153
#  @return an instance of Mesh class
154
def CreateMeshesFromSTL( theFileName ):
155
    aSmeshMesh = smesh.CreateMeshesFromSTL(theFileName)
156
    aMesh = Mesh(aSmeshMesh)
157
    return aMesh
158
159
## From SMESH_Gen interface
160
def GetSubShapesId( theMainObject, theListOfSubObjects ):
161
    return smesh.GetSubShapesId(theMainObject, theListOfSubObjects)
162
163
164
## Filtering. Auxiliary functions:
165
#  ------------------------------
166
167
## Creates an empty criterion
168
#  @return SMESH.Filter.Criterion
169
def GetEmptyCriterion():
170
    Type = EnumToLong(FT_Undefined)
171
    Compare = EnumToLong(FT_Undefined)
172
    Threshold = 0
173
    ThresholdStr = ""
174
    ThresholdID = ""
175
    UnaryOp = EnumToLong(FT_Undefined)
176
    BinaryOp = EnumToLong(FT_Undefined)
177
    Tolerance = 1e-07
178
    TypeOfElement = ALL
179
    Precision = -1 ##@1e-07
180
    return Filter.Criterion(Type, Compare, Threshold, ThresholdStr, ThresholdID,
181
                            UnaryOp, BinaryOp, Tolerance, TypeOfElement, Precision)
182
      
183
## Creates a criterion by given parameters
184
#  @param elementType is the type of elements(NODE, EDGE, FACE, VOLUME)
185
#  @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
186
#  @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
187
#  @param Treshold is threshold value (range of ids as string, shape, numeric)
188
#  @param UnaryOp is FT_LogicalNOT or FT_Undefined
189
#  @param BinaryOp is binary logical operation FT_LogicalAND, FT_LogicalOR or
190
#                  FT_Undefined(must be for the last criterion in criteria)
191
#  @return SMESH.Filter.Criterion
192
def GetCriterion(elementType,
193
                 CritType,
194
                 Compare = FT_EqualTo,
195
                 Treshold="",
196
                 UnaryOp=FT_Undefined,
197
                 BinaryOp=FT_Undefined):
198
    aCriterion = GetEmptyCriterion()
199
    aCriterion.TypeOfElement = elementType
200
    aCriterion.Type = EnumToLong(CritType)
201
        
202
    aTreshold = Treshold
203
        
204
    if Compare in [FT_LessThan, FT_MoreThan, FT_EqualTo]:
205
        aCriterion.Compare = EnumToLong(Compare)
206
    else:
207
        aCriterion.Compare = EnumToLong(FT_EqualTo)
208
        aTreshold = Compare
62
209
210
    if CritType in [FT_BelongToGeom,     FT_BelongToPlane,
211
                    FT_BelongToCylinder, FT_LyingOnGeom]:
212
        # Check treshold
213
        if isinstance(aTreshold, geompy.GEOM._objref_GEOM_Object):
214
            aCriterion.ThresholdStr = GetName(aTreshold)
215
            aCriterion.ThresholdID = salome.ObjectToID(aTreshold)
216
        else:
217
            print "Error: Treshold should be a shape."
218
            return None
219
    elif CritType == FT_RangeOfIds:
220
        # Check treshold
221
        if isinstance(aTreshold, str):
222
            aCriterion.ThresholdStr = aTreshold
223
        else:
224
            print "Error: Treshold should be a string."
225
            return None
226
    elif CritType in [FT_FreeBorders, FT_FreeEdges, FT_BadOrientedVolume]:
227
        # Here we don't need treshold
228
        if aTreshold ==  FT_LogicalNOT:
229
            aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
230
        elif aTreshold in [FT_LogicalAND, FT_LogicalOR]:
231
            aCriterion.BinaryOp = aTreshold
232
    else:
233
        # Check treshold
234
        try:
235
            aTreshold = float(aTreshold)
236
            aCriterion.Threshold = aTreshold
237
        except:
238
            print "Error: Treshold should be a number."
239
            return None
240
241
    if Treshold ==  FT_LogicalNOT or UnaryOp ==  FT_LogicalNOT:
242
        aCriterion.UnaryOp = EnumToLong(FT_LogicalNOT)
243
244
    if Treshold in [FT_LogicalAND, FT_LogicalOR]:
245
        aCriterion.BinaryOp = EnumToLong(Treshold)
246
247
    if UnaryOp in [FT_LogicalAND, FT_LogicalOR]:
248
        aCriterion.BinaryOp = EnumToLong(UnaryOp)
249
250
    if BinaryOp in [FT_LogicalAND, FT_LogicalOR]:
251
        aCriterion.BinaryOp = EnumToLong(BinaryOp)
252
253
    return aCriterion
254
  
255
    
63
## Mother class to define algorithm, recommended to don't use directly.
256
## Mother class to define algorithm, recommended to don't use directly.
64
#
257
#
65
#  More details.
258
#  More details.
Lines 83-118 Link Here
83
    def GetAlgorithm(self):
276
    def GetAlgorithm(self):
84
        return self.algo
277
        return self.algo
85
278
279
    ## Get list of hypothesis that can be used with this algorithm
280
    def GetCompatibleHypothesis(self):
281
        list = []
282
        if self.algo:
283
            list = self.algo.GetCompatibleHypothesis()
284
        return list
285
286
    ## Get name of algo
287
    def GetName(self):
288
        GetName(self.algo)
289
290
    ## Set name to algo
291
    def SetName(self, name):
292
        SetName(self.algo, name)
293
294
    ## Get id of algo
295
    def GetId(self):
296
        return self.algo.GetId()
297
    
86
    ## Private method. Print error message if a hypothesis was not assigned.
298
    ## Private method. Print error message if a hypothesis was not assigned.
87
    def TreatHypoStatus(self, status, hypName, geomName, isAlgo):
299
    def TreatHypoStatus(self, status, hypName, geomName, isAlgo):
88
        if isAlgo:
300
        if isAlgo:
89
            hypType = "algorithm"
301
            hypType = "algorithm"
90
        else:
302
        else:
91
            hypType = "hypothesis"
303
            hypType = "hypothesis"
92
        if status == SMESH.HYP_UNKNOWN_FATAL :
304
        if status == HYP_UNKNOWN_FATAL :
93
            reason = "for unknown reason"
305
            reason = "for unknown reason"
94
        elif status == SMESH.HYP_INCOMPATIBLE :
306
        elif status == HYP_INCOMPATIBLE :
95
            reason = "this hypothesis mismatches algorithm"
307
            reason = "this hypothesis mismatches algorithm"
96
        elif status == SMESH.HYP_NOTCONFORM :
308
        elif status == HYP_NOTCONFORM :
97
            reason = "not conform mesh would be built"
309
            reason = "not conform mesh would be built"
98
        elif status == SMESH.HYP_ALREADY_EXIST :
310
        elif status == HYP_ALREADY_EXIST :
99
            reason = hypType + " of the same dimension already assigned to this shape"
311
            reason = hypType + " of the same dimension already assigned to this shape"
100
        elif status == SMESH.HYP_BAD_DIM :
312
        elif status == HYP_BAD_DIM :
101
            reason = hypType + " mismatches shape"
313
            reason = hypType + " mismatches shape"
102
        elif status == SMESH.HYP_CONCURENT :
314
        elif status == HYP_CONCURENT :
103
            reason = "there are concurrent hypotheses on sub-shapes"
315
            reason = "there are concurrent hypotheses on sub-shapes"
104
        elif status == SMESH.HYP_BAD_SUBSHAPE :
316
        elif status == HYP_BAD_SUBSHAPE :
105
            reason = "shape is neither the main one, nor its subshape, nor a valid group"
317
            reason = "shape is neither the main one, nor its subshape, nor a valid group"
106
        else:
318
        else:
107
            return
319
            return
108
        hypName = '"' + hypName + '"'
320
        hypName = '"' + hypName + '"'
109
        geomName= '"' + geomName+ '"'
321
        geomName= '"' + geomName+ '"'
110
        if status < SMESH.HYP_UNKNOWN_FATAL:
322
        if status < HYP_UNKNOWN_FATAL:
111
            print hypName, "was assigned to",    geomName,"but", reason
323
            print hypName, "was assigned to",    geomName,"but", reason
112
        else:
324
        else:
113
            print hypName, "was not assigned to",geomName,":", reason
325
            print hypName, "was not assigned to",geomName,":", reason
114
        pass
326
        pass
115
327
        
116
    ## Private method.
328
    ## Private method.
117
    def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
329
    def Create(self, mesh, geom, hypo, so="libStdMeshersEngine.so"):
118
        if geom is None:
330
        if geom is None:
Lines 134-140 Link Here
134
        SetName(self.algo, name + "/" + hypo)
346
        SetName(self.algo, name + "/" + hypo)
135
        status = mesh.mesh.AddHypothesis(self.geom, self.algo)
347
        status = mesh.mesh.AddHypothesis(self.geom, self.algo)
136
        self.TreatHypoStatus( status, hypo, name, 1 )
348
        self.TreatHypoStatus( status, hypo, name, 1 )
137
349
        
138
    ## Private method
350
    ## Private method
139
    def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"):
351
    def Hypothesis(self, hyp, args=[], so="libStdMeshersEngine.so"):
140
        hypo = smesh.CreateHypothesis(hyp, so)
352
        hypo = smesh.CreateHypothesis(hyp, so)
Lines 151-157 Link Here
151
        status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
363
        status = self.mesh.mesh.AddHypothesis(self.geom, hypo)
152
        self.TreatHypoStatus( status, hyp, name, 0 )
364
        self.TreatHypoStatus( status, hyp, name, 0 )
153
        return hypo
365
        return hypo
154
366
       
155
# Public class: Mesh_Segment
367
# Public class: Mesh_Segment
156
# --------------------------
368
# --------------------------
157
369
Lines 163-176 Link Here
163
    ## Private constructor.
375
    ## Private constructor.
164
    def __init__(self, mesh, geom=0):
376
    def __init__(self, mesh, geom=0):
165
        self.Create(mesh, geom, "Regular_1D")
377
        self.Create(mesh, geom, "Regular_1D")
166
378
        
167
    ## Define "LocalLength" hypothesis to cut an edge in several segments with the same length
379
    ## Define "LocalLength" hypothesis to cut an edge in several segments with the same length
168
    #  @param l for the length of segments that cut an edge
380
    #  @param l for the length of segments that cut an edge
169
    def LocalLength(self, l):
381
    def LocalLength(self, l):
170
        hyp = self.Hypothesis("LocalLength", [l])
382
        hyp = self.Hypothesis("LocalLength", [l])
171
        hyp.SetLength(l)
383
        hyp.SetLength(l)
172
        return hyp
384
        return hyp
173
385
        
174
    ## Define "NumberOfSegments" hypothesis to cut an edge in several fixed number of segments
386
    ## Define "NumberOfSegments" hypothesis to cut an edge in several fixed number of segments
175
    #  @param n for the number of segments that cut an edge
387
    #  @param n for the number of segments that cut an edge
176
    #  @param s for the scale factor (optional)
388
    #  @param s for the scale factor (optional)
Lines 183-189 Link Here
183
            hyp.SetScaleFactor(s)
395
            hyp.SetScaleFactor(s)
184
        hyp.SetNumberOfSegments(n)
396
        hyp.SetNumberOfSegments(n)
185
        return hyp
397
        return hyp
186
398
        
187
    ## Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing
399
    ## Define "Arithmetic1D" hypothesis to cut an edge in several segments with arithmetic length increasing
188
    #  @param start for the length of the first segment
400
    #  @param start for the length of the first segment
189
    #  @param end   for the length of the last  segment
401
    #  @param end   for the length of the last  segment
Lines 192-198 Link Here
192
        hyp.SetLength(start, 1)
404
        hyp.SetLength(start, 1)
193
        hyp.SetLength(end  , 0)
405
        hyp.SetLength(end  , 0)
194
        return hyp
406
        return hyp
195
407
        
196
    ## Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing
408
    ## Define "StartEndLength" hypothesis to cut an edge in several segments with geometric length increasing
197
    #  @param start for the length of the first segment
409
    #  @param start for the length of the first segment
198
    #  @param end   for the length of the last  segment
410
    #  @param end   for the length of the last  segment
Lines 201-214 Link Here
201
        hyp.SetLength(start, 1)
413
        hyp.SetLength(start, 1)
202
        hyp.SetLength(end  , 0)
414
        hyp.SetLength(end  , 0)
203
        return hyp
415
        return hyp
204
416
        
205
    ## Define "Deflection1D" hypothesis
417
    ## Define "Deflection1D" hypothesis
206
    #  @param d for the deflection
418
    #  @param d for the deflection
207
    def Deflection1D(self, d):
419
    def Deflection1D(self, d):
208
        hyp = self.Hypothesis("Deflection1D", [d])
420
        hyp = self.Hypothesis("Deflection1D", [d])
209
        hyp.SetDeflection(d)
421
        hyp.SetDeflection(d)
210
        return hyp
422
        return hyp
211
423
        
212
    ## Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in
424
    ## Define "Propagation" hypothesis that propagate all other hypothesis on all others edges that are in
213
    #  the opposite side in the case of quadrangular faces
425
    #  the opposite side in the case of quadrangular faces
214
    def Propagation(self):
426
    def Propagation(self):
Lines 243-249 Link Here
243
    def __init__(self, mesh, geom=0):
455
    def __init__(self, mesh, geom=0):
244
        import Python1dPlugin
456
        import Python1dPlugin
245
        self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
457
        self.Create(mesh, geom, "Python_1D", "libPython1dEngine.so")
246
458
    
247
    ## Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality
459
    ## Define "PythonSplit1D" hypothesis based on the Erwan Adam patch, awaiting equivalent SALOME functionality
248
    #  @param n for the number of segments that cut an edge
460
    #  @param n for the number of segments that cut an edge
249
    #  @param func for the python function that calculate the length of all segments
461
    #  @param func for the python function that calculate the length of all segments
Lines 252-258 Link Here
252
        hyp.SetNumberOfSegments(n)
464
        hyp.SetNumberOfSegments(n)
253
        hyp.SetPythonLog10RatioFunction(func)
465
        hyp.SetPythonLog10RatioFunction(func)
254
        return hyp
466
        return hyp
255
467
        
256
# Public class: Mesh_Triangle
468
# Public class: Mesh_Triangle
257
# ---------------------------
469
# ---------------------------
258
470
Lines 261-281 Link Here
261
#  More details.
473
#  More details.
262
class Mesh_Triangle(Mesh_Algorithm):
474
class Mesh_Triangle(Mesh_Algorithm):
263
475
476
    algoType = 0
477
    params = 0
478
   
264
    ## Private constructor.
479
    ## Private constructor.
265
    def __init__(self, mesh, geom=0):
480
    def __init__(self, mesh, algoType, geom=0):
266
        self.Create(mesh, geom, "MEFISTO_2D")
481
        if algoType == MEFISTO:
482
            self.Create(mesh, geom, "MEFISTO_2D")
483
        elif algoType == NETGEN:
484
            self.Create(mesh, geom, "NETGEN_2D", "libNETGENEngine.so")
485
        self.algoType = algoType
267
486
268
    ## Define "MaxElementArea" hypothesis to give the maximun area of each triangles
487
    ## Define "MaxElementArea" hypothesis to give the maximun area of each triangles
269
    #  @param area for the maximum area of each triangles
488
    #  @param area for the maximum area of each triangles
270
    def MaxElementArea(self, area):
489
    def MaxElementArea(self, area):
271
        hyp = self.Hypothesis("MaxElementArea", [area])
490
        if self.algoType == MEFISTO:
272
        hyp.SetMaxElementArea(area)
491
            hyp = self.Hypothesis("MaxElementArea", [area])
273
        return hyp
492
            hyp.SetMaxElementArea(area)
274
493
            return hyp
494
        elif self.algoType == NETGEN:
495
            print "Netgen 1D-2D algo doesn't support this hypothesis"
496
            return None
497
            
275
    ## Define "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire
498
    ## Define "LengthFromEdges" hypothesis to build triangles based on the length of the edges taken from the wire
276
    def LengthFromEdges(self):
499
    def LengthFromEdges(self):
277
        return self.Hypothesis("LengthFromEdges")
500
        if self.algoType == MEFISTO:
278
501
            hyp = self.Hypothesis("LengthFromEdges")
502
            return hyp
503
        elif self.algoType == NETGEN:
504
            print "Netgen 1D-2D algo doesn't support this hypothesis"
505
            return None
506
        
507
    ## Define "Netgen 2D Parameters" hypothesis
508
    def Parameters(self):
509
        if self.algoType == NETGEN:
510
            self.params = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so")
511
            return self.params
512
        elif self.algoType == MEFISTO:
513
            print "Mefisto algo doesn't support this hypothesis"
514
            return None
515
516
    ## Set MaxSize
517
    def SetMaxSize(self, theSize):
518
        if self.params == 0:
519
            self.Parameters()
520
        self.params.SetMaxSize(theSize)
521
        
522
    ## Set SecondOrder flag
523
    def SetSecondOrder(seld, theVal):
524
        if self.params == 0:
525
            self.Parameters()
526
        self.params.SetSecondOrder(theVal)
527
528
    ## Set Optimize flag
529
    def SetOptimize(self, theVal):
530
        if self.params == 0:
531
            self.Parameters()
532
        self.params.SetOptimize(theVal)
533
534
    ## Set Fineness
535
    #  @param theFineness is:
536
    #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
537
    def SetFineness(self, theFineness):
538
        if self.params == 0:
539
            self.Parameters()
540
        self.params.SetFineness(theFineness)
541
        
542
    ## Set GrowthRate  
543
    def SetGrowthRate(self, theRate):
544
        if self.params == 0:
545
            self.Parameters()
546
        self.params.SetGrowthRate(theRate)
547
548
    ## Set NbSegPerEdge
549
    def SetNbSegPerEdge(self, theVal):
550
        if self.params == 0:
551
            self.Parameters()
552
        self.params.SetNbSegPerEdge(theVal)
553
554
    ## Set NbSegPerRadius
555
    def SetNbSegPerRadius(self, theVal):
556
        if self.params == 0:
557
            self.Parameters()
558
        self.params.SetNbSegPerRadius(theVal)
559
560
    ## Set QuadAllowed flag
561
    def SetQuadAllowed(self, toAllow):
562
        if self.params == 0:
563
            self.Parameters()
564
        self.params.SetQuadAllowed(toAllow)
565
        
566
    
279
# Public class: Mesh_Quadrangle
567
# Public class: Mesh_Quadrangle
280
# -----------------------------
568
# -----------------------------
281
569
Lines 287-300 Link Here
287
    ## Private constructor.
575
    ## Private constructor.
288
    def __init__(self, mesh, geom=0):
576
    def __init__(self, mesh, geom=0):
289
        self.Create(mesh, geom, "Quadrangle_2D")
577
        self.Create(mesh, geom, "Quadrangle_2D")
290
578
    
291
    ## Define "QuadranglePreference" hypothesis, forcing construction
579
    ## Define "QuadranglePreference" hypothesis, forcing construction
292
    #  of quadrangles if the number of nodes on opposite edges is not the same
580
    #  of quadrangles if the number of nodes on opposite edges is not the same
293
    #  in the case where the global number of nodes on edges is even
581
    #  in the case where the global number of nodes on edges is even
294
    def QuadranglePreference(self):
582
    def QuadranglePreference(self):
295
        hyp = self.Hypothesis("QuadranglePreference")
583
        hyp = self.Hypothesis("QuadranglePreference")
296
        return hyp
584
        return hyp
297
585
    
298
# Public class: Mesh_Tetrahedron
586
# Public class: Mesh_Tetrahedron
299
# ------------------------------
587
# ------------------------------
300
588
Lines 303-315 Link Here
303
#  More details.
591
#  More details.
304
class Mesh_Tetrahedron(Mesh_Algorithm):
592
class Mesh_Tetrahedron(Mesh_Algorithm):
305
593
594
    params = 0
595
    algoType = 0
596
306
    ## Private constructor.
597
    ## Private constructor.
307
    def __init__(self, mesh, algo, geom=0):
598
    def __init__(self, mesh, algoType, geom=0):
308
        if algo == NETGEN:
599
        if algoType == NETGEN:
309
            self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
600
            self.Create(mesh, geom, "NETGEN_3D", "libNETGENEngine.so")
310
        elif algo == GHS3D:
601
        elif algoType == GHS3D:
311
            import GHS3DPlugin
602
            import GHS3DPlugin
312
            self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
603
            self.Create(mesh, geom, "GHS3D_3D" , "libGHS3DEngine.so")
604
        elif algoType == FULL_NETGEN:
605
            self.Create(mesh, geom, "NETGEN_2D3D", "libNETGENEngine.so")
606
        self.algoType = algoType
313
607
314
    ## Define "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedral
608
    ## Define "MaxElementVolume" hypothesis to give the maximun volume of each tetrahedral
315
    #  @param vol for the maximum volume of each tetrahedral
609
    #  @param vol for the maximum volume of each tetrahedral
Lines 318-323 Link Here
318
        hyp.SetMaxElementVolume(vol)
612
        hyp.SetMaxElementVolume(vol)
319
        return hyp
613
        return hyp
320
614
615
    ## Define "Netgen 3D Parameters" hypothesis
616
    def Parameters(self):
617
        if (self.algoType == FULL_NETGEN):
618
            self.params = self.Hypothesis("NETGEN_Parameters", [], "libNETGENEngine.so")
619
            return self.params
620
        else:
621
            print "Algo doesn't support this hypothesis"
622
            return None 
623
            
624
    ## Set MaxSize
625
    def SetMaxSize(self, theSize):
626
        if self.params == 0:
627
            self.Parameters()
628
        self.params.SetMaxSize(theSize)
629
        
630
    ## Set SecondOrder flag
631
    def SetSecondOrder(self, theVal):
632
        if self.params == 0:
633
            self.Parameters()
634
        self.params.SetSecondOrder(theVal)
635
636
    ## Set Optimize flag
637
    def SetOptimize(self, theVal):
638
        if self.params == 0:
639
            self.Parameters()
640
        self.params.SetOptimize(theVal)
641
642
    ## Set Fineness
643
    #  @param theFineness is:
644
    #  VeryCoarse, Coarse, Moderate, Fine, VeryFine or Custom
645
    def SetFineness(self, theFineness):
646
        if self.params == 0:
647
            self.Parameters()
648
        self.params.SetFineness(theFineness)
649
        
650
    ## Set GrowthRate  
651
    def SetGrowthRate(self, theRate):
652
        if self.params == 0:
653
            self.Parameters()
654
        self.params.SetGrowthRate(theRate)
655
656
    ## Set NbSegPerEdge
657
    def SetNbSegPerEdge(self, theVal):
658
        if self.params == 0:
659
            self.Parameters()
660
        self.params.SetNbSegPerEdge(theVal)
661
662
    ## Set NbSegPerRadius
663
    def SetNbSegPerRadius(self, theVal):
664
        if self.params == 0:
665
            self.Parameters()
666
        self.params.SetNbSegPerRadius(theVal)
667
321
# Public class: Mesh_Hexahedron
668
# Public class: Mesh_Hexahedron
322
# ------------------------------
669
# ------------------------------
323
670
Lines 330-335 Link Here
330
    def __init__(self, mesh, geom=0):
677
    def __init__(self, mesh, geom=0):
331
        self.Create(mesh, geom, "Hexa_3D")
678
        self.Create(mesh, geom, "Hexa_3D")
332
679
680
# Deprecated, only for compatibility!
333
# Public class: Mesh_Netgen
681
# Public class: Mesh_Netgen
334
# ------------------------------
682
# ------------------------------
335
683
Lines 356-395 Link Here
356
        else:
704
        else:
357
            hyp = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so")
705
            hyp = self.Hypothesis("NETGEN_Parameters_2D", [], "libNETGENEngine.so")
358
        return hyp
706
        return hyp
359
707
        
360
# Public class: Mesh
708
# Public class: Mesh
361
# ==================
709
# ==================
362
710
363
## Class to define a mesh
711
## Class to define a mesh
364
#
712
#
713
#  The class contains mesh shape, SMESH_Mesh, SMESH_MeshEditor
365
#  More details.
714
#  More details.
366
class Mesh:
715
class Mesh:
367
716
368
    geom = 0
717
    geom = 0
369
    mesh = 0
718
    mesh = 0
719
    editor = 0
370
720
371
    ## Constructor
721
    ## Constructor
372
    #
722
    #
373
    #  Creates mesh on the shape \a geom,
723
    #  Creates mesh on the shape \a geom(or the empty mesh if geom equal to 0),
374
    #  sets GUI name of this mesh to \a name.
724
    #  sets GUI name of this mesh to \a name.
375
    #  @param geom Shape to be meshed
725
    #  @param obj Shape to be meshed or SMESH_Mesh object
376
    #  @param name Study name of the mesh
726
    #  @param name Study name of the mesh
377
    def __init__(self, geom, name=0):
727
    def __init__(self, obj=0, name=0):
378
        self.geom = geom
728
        if obj != 0:
379
        self.mesh = smesh.CreateMesh(geom)
729
            if isinstance(obj, geompy.GEOM._objref_GEOM_Object):
380
        if name == 0:
730
                self.geom = obj
381
            SetName(self.mesh, GetName(geom))
731
                self.mesh = smesh.CreateMesh(self.geom)
732
            elif isinstance(obj, SMESH._objref_SMESH_Mesh):
733
                self.SetMesh(obj)
382
        else:
734
        else:
735
            self.mesh = smesh.CreateEmptyMesh()
736
        if name != 0:
383
            SetName(self.mesh, name)
737
            SetName(self.mesh, name)
738
        elif obj != 0:
739
            SetName(self.mesh, GetName(obj))
384
740
741
        self.editor = self.mesh.GetMeshEditor()
742
743
    ## Method that inits the Mesh object from SMESH_Mesh interface
744
    #  @param theMesh is SMESH_Mesh object
745
    def SetMesh(self, theMesh):
746
        self.mesh = theMesh
747
        self.geom = self.mesh.GetShapeToMesh()
748
            
385
    ## Method that returns the mesh
749
    ## Method that returns the mesh
750
    #  @return SMESH_Mesh object
386
    def GetMesh(self):
751
    def GetMesh(self):
387
        return self.mesh
752
        return self.mesh
388
753
754
    ## Get mesh name
755
    def GetName(self):
756
        name = GetName(self.GetMesh())
757
        return name
758
759
    ## Set name to mesh
760
    def SetName(self, name):
761
        SetName(self.GetMesh(), name)
762
    
763
    ## Get the subMesh object associated to a subShape. The subMesh object
764
    #  gives access to nodes and elements IDs.
765
    #  SubMesh will be used instead of SubShape in a next idl version to
766
    #  adress a specific subMesh...
767
    def GetSubMesh(self, theSubObject, name):
768
        submesh = self.mesh.GetSubMesh(theSubObject, name)
769
        return submesh
770
        
389
    ## Method that returns the shape associated to the mesh
771
    ## Method that returns the shape associated to the mesh
772
    #  @return GEOM_Object
390
    def GetShape(self):
773
    def GetShape(self):
391
        return self.geom
774
        return self.geom
392
775
776
    ## Method that associates given shape to the mesh(entails the mesh recreation)
777
    #  @param geom shape to be meshed(GEOM_Object)
778
    def SetShape(self, geom):
779
        self.mesh = smesh.CreateMesh(geom)  
780
                
781
    ## Return true if hypotheses are defined well
782
    #  @param theMesh is an instance of Mesh class
783
    #  @param theSubObject subshape of a mesh shape
784
    def IsReadyToCompute(self, theSubObject):
785
        return smesh.IsReadyToCompute(self.mesh, theSubObject)
786
787
    ## Return errors of hypotheses definintion
788
    #  error list is empty if everything is OK
789
    #  @param theMesh is an instance of Mesh class
790
    #  @param theSubObject subshape of a mesh shape
791
    #  @return a list of errors
792
    def GetAlgoState(self, theSubObject):
793
        return smesh.GetAlgoState(self.mesh, theSubObject)
794
    
795
    ## Return geometrical object the given element is built on.
796
    #  The returned geometrical object, if not nil, is either found in the 
797
    #  study or is published by this method with the given name
798
    #  @param theMesh is an instance of Mesh class
799
    #  @param theElementID an id of the mesh element
800
    #  @param theGeomName user defined name of geometrical object
801
    #  @return GEOM::GEOM_Object instance
802
    def GetGeometryByMeshElement(self, theElementID, theGeomName):
803
        return smesh.GetGeometryByMeshElement( self.mesh, theElementID, theGeomName )
804
        
393
    ## Returns mesh dimension depending on shape one
805
    ## Returns mesh dimension depending on shape one
394
    def MeshDimension(self):
806
    def MeshDimension(self):
395
        shells = geompy.SubShapeAllIDs( self.geom, geompy.ShapeType["SHELL"] )
807
        shells = geompy.SubShapeAllIDs( self.geom, geompy.ShapeType["SHELL"] )
Lines 402-408 Link Here
402
        else:
814
        else:
403
            return 0;
815
            return 0;
404
        pass
816
        pass
405
817
        
406
    ## Creates a segment discretization 1D algorithm.
818
    ## Creates a segment discretization 1D algorithm.
407
    #  If the optional \a algo parameter is not sets, this algorithm is REGULAR.
819
    #  If the optional \a algo parameter is not sets, this algorithm is REGULAR.
408
    #  If the optional \a geom parameter is not sets, this algorithm is global.
820
    #  If the optional \a geom parameter is not sets, this algorithm is global.
Lines 420-433 Link Here
420
            return Mesh_Segment_Python(self, geom)
832
            return Mesh_Segment_Python(self, geom)
421
        else:
833
        else:
422
            return Mesh_Segment(self, geom)
834
            return Mesh_Segment(self, geom)
423
835
        
424
    ## Creates a triangle 2D algorithm for faces.
836
    ## Creates a triangle 2D algorithm for faces.
425
    #  If the optional \a geom parameter is not sets, this algorithm is global.
837
    #  If the optional \a geom parameter is not sets, this algorithm is global.
426
    #  Otherwise, this algorithm define a submesh based on \a geom subshape.
838
    #  Otherwise, this algorithm define a submesh based on \a geom subshape.
839
    #  @param algo values are: smesh.MEFISTO or smesh.NETGEN
427
    #  @param geom If defined, subshape to be meshed
840
    #  @param geom If defined, subshape to be meshed
428
    def Triangle(self, geom=0):
841
    def Triangle(self, algo=MEFISTO, geom=0):
429
        return Mesh_Triangle(self, geom)
842
        ## if Triangle(geom) is called by mistake
430
843
        if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
844
            geom = algo
845
            algo = MEFISTO
846
        
847
        return Mesh_Triangle(self, algo, geom)
848
        
431
    ## Creates a quadrangle 2D algorithm for faces.
849
    ## Creates a quadrangle 2D algorithm for faces.
432
    #  If the optional \a geom parameter is not sets, this algorithm is global.
850
    #  If the optional \a geom parameter is not sets, this algorithm is global.
433
    #  Otherwise, this algorithm define a submesh based on \a geom subshape.
851
    #  Otherwise, this algorithm define a submesh based on \a geom subshape.
Lines 439-453 Link Here
439
    #  The parameter \a algo permits to choice the algorithm: NETGEN or GHS3D
857
    #  The parameter \a algo permits to choice the algorithm: NETGEN or GHS3D
440
    #  If the optional \a geom parameter is not sets, this algorithm is global.
858
    #  If the optional \a geom parameter is not sets, this algorithm is global.
441
    #  Otherwise, this algorithm define a submesh based on \a geom subshape.
859
    #  Otherwise, this algorithm define a submesh based on \a geom subshape.
442
    #  @param algo values are: smesh.NETGEN, smesh.GHS3D
860
    #  @param algo values are: smesh.NETGEN, smesh.GHS3D, smesh.FULL_NETGEN
443
    #  @param geom If defined, subshape to be meshed
861
    #  @param geom If defined, subshape to be meshed
444
    def Tetrahedron(self, algo, geom=0):
862
    def Tetrahedron(self, algo=NETGEN, geom=0):
445
        ## if Tetrahedron(geom) is called by mistake
863
        ## if Tetrahedron(geom) is called by mistake
446
        if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
864
        if ( isinstance( algo, geompy.GEOM._objref_GEOM_Object)):
447
            algo, geom = geom, algo
865
            algo, geom = geom, algo
448
            pass
866
            pass
449
        return Mesh_Tetrahedron(self, algo, geom)
867
        return Mesh_Tetrahedron(self, algo, geom)
450
868
        
451
    ## Creates a hexahedron 3D algorithm for solids.
869
    ## Creates a hexahedron 3D algorithm for solids.
452
    #  If the optional \a geom parameter is not sets, this algorithm is global.
870
    #  If the optional \a geom parameter is not sets, this algorithm is global.
453
    #  Otherwise, this algorithm define a submesh based on \a geom subshape.
871
    #  Otherwise, this algorithm define a submesh based on \a geom subshape.
Lines 455-461 Link Here
455
    def Hexahedron(self, geom=0):
873
    def Hexahedron(self, geom=0):
456
        return Mesh_Hexahedron(self, geom)
874
        return Mesh_Hexahedron(self, geom)
457
875
458
    ## Creates a NETGEN-based 2D or 3D independent algorithm (i.e. needs no
876
    ## Deprecated, only for compatibility!
877
    #  Creates a NETGEN-based 2D or 3D independent algorithm (i.e. needs no
459
    #  discrete boundary).
878
    #  discrete boundary).
460
    #  If the optional \a geom parameter is not sets, this algorithm is global.
879
    #  If the optional \a geom parameter is not sets, this algorithm is global.
461
    #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
880
    #  Otherwise, this algorithm defines a submesh based on \a geom subshape.
Lines 463-474 Link Here
463
    #  @param geom If defined, subshape to be meshed
882
    #  @param geom If defined, subshape to be meshed
464
    def Netgen(self, is3D, geom=0):
883
    def Netgen(self, is3D, geom=0):
465
        return Mesh_Netgen(self, is3D, geom)
884
        return Mesh_Netgen(self, is3D, geom)
466
885
      
467
    ## Compute the mesh and return the status of the computation
886
    ## Compute the mesh and return the status of the computation
468
    def Compute(self):
887
    def Compute(self, geom=0):
469
        ok = smesh.Compute(self.mesh, self.geom)
888
        if geom == 0 or not isinstance(geom, geompy.GEOM._objref_GEOM_Object):
889
            if self.geom == 0:
890
                print "Compute impossible: mesh is not constructed on geom shape."
891
                return 0
892
            else:
893
                geom = self.geom
894
        ok = smesh.Compute(self.mesh, geom)
470
        if not ok:
895
        if not ok:
471
            errors = smesh.GetAlgoState( self.mesh, self.geom )
896
            errors = smesh.GetAlgoState( self.mesh, geom )
472
            allReasons = ""
897
            allReasons = ""
473
            for err in errors:
898
            for err in errors:
474
                if err.isGlobalAlgo:
899
                if err.isGlobalAlgo:
Lines 477-485 Link Here
477
                    glob = " local "
902
                    glob = " local "
478
                    pass
903
                    pass
479
                dim = str(err.algoDim)
904
                dim = str(err.algoDim)
480
                if err.name == SMESH.MISSING_ALGO:
905
                if err.name == MISSING_ALGO:
481
                    reason = glob + dim + "D algorithm is missing"
906
                    reason = glob + dim + "D algorithm is missing"
482
                elif err.name == SMESH.MISSING_HYPO:
907
                elif err.name == MISSING_HYPO:
483
                    name = '"' + err.algoName + '"'
908
                    name = '"' + err.algoName + '"'
484
                    reason = glob + dim + "D algorithm " + name + " misses " + dim + "D hypothesis"
909
                    reason = glob + dim + "D algorithm " + name + " misses " + dim + "D hypothesis"
485
                else:
910
                else:
Lines 517-523 Link Here
517
            self.Tetrahedron(NETGEN)
942
            self.Tetrahedron(NETGEN)
518
            pass
943
            pass
519
        return self.Compute()
944
        return self.Compute()
520
945
        
521
    ## Compute hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
946
    ## Compute hexahedral mesh using AutomaticLength + Quadrangle + Hexahedron
522
    #  The parameter \a fineness [0.-1.] defines mesh fineness
947
    #  The parameter \a fineness [0.-1.] defines mesh fineness
523
    def AutomaticHexahedralization(self, fineness=0):
948
    def AutomaticHexahedralization(self, fineness=0):
Lines 532-538 Link Here
532
            self.Hexahedron()            
957
            self.Hexahedron()            
533
            pass
958
            pass
534
        return self.Compute()
959
        return self.Compute()
535
960
    
961
    ## Get the list of hypothesis added on a geom
962
    #  @param geom is subhape of mesh geometry
963
    def GetHypothesisList(self, geom):
964
        return self.mesh.GetHypothesisList( geom )
965
                
536
    ## Removes all global hypotheses
966
    ## Removes all global hypotheses
537
    def RemoveGlobalHypotheses(self):
967
    def RemoveGlobalHypotheses(self):
538
        current_hyps = self.mesh.GetHypothesisList( self.geom )
968
        current_hyps = self.mesh.GetHypothesisList( self.geom )
Lines 540-610 Link Here
540
            self.mesh.RemoveHypothesis( self.geom, hyp )
970
            self.mesh.RemoveHypothesis( self.geom, hyp )
541
            pass
971
            pass
542
        pass
972
        pass
543
973
        
544
    ## Create a mesh group based on geometric object \a grp
974
    ## Create a mesh group based on geometric object \a grp
545
    #  and give a \a name, if this parameter is not defined
975
    #  and give a \a name, if this parameter is not defined
546
    #  the name is the same as the geometric group name
976
    #  the name is the same as the geometric group name
977
    #  Note: this function is obsolete. Works like GroupOnGeom(). 
547
    #  @param grp  is a geometric group, a vertex, an edge, a face or a solid
978
    #  @param grp  is a geometric group, a vertex, an edge, a face or a solid
548
    #  @param name is the name of the mesh group
979
    #  @param name is the name of the mesh group
980
    #  @return SMESH_GroupOnGeom
549
    def Group(self, grp, name=""):
981
    def Group(self, grp, name=""):
550
        if name == "":
982
        return self.GroupOnGeom(grp, name)
551
            name = grp.GetName()
983
       
552
984
    ## Deprecated, only for compatibility! Please, use ExportMED() method instead.
553
        type = []
985
    #  Export the mesh in a file with the MED format and choice the \a version of MED format
554
        tgeo = str(grp.GetShapeType())
555
        if tgeo == "VERTEX":
556
            type = SMESH.NODE
557
        elif tgeo == "EDGE":
558
            type = SMESH.EDGE
559
        elif tgeo == "FACE":
560
            type = SMESH.FACE
561
        elif tgeo == "SOLID":
562
            type = SMESH.VOLUME
563
        elif tgeo == "SHELL":
564
            type = SMESH.VOLUME
565
        elif tgeo == "COMPOUND":
566
            if len( geompy.GetObjectIDs( grp )) == 0:
567
                print "Mesh.Group: empty geometric group", GetName( grp )
568
                return 0
569
            tgeo = geompy.GetType(grp)
570
            if tgeo == geompy.ShapeType["VERTEX"]:
571
                type = SMESH.NODE
572
            elif tgeo == geompy.ShapeType["EDGE"]:
573
                type = SMESH.EDGE
574
            elif tgeo == geompy.ShapeType["FACE"]:
575
                type = SMESH.FACE
576
            elif tgeo == geompy.ShapeType["SOLID"]:
577
                type = SMESH.VOLUME
578
579
        if type == []:
580
            print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
581
            return 0
582
        else:
583
            return self.mesh.CreateGroupFromGEOM(type, name, grp)
584
585
    ## Export the mesh in a file with the MED format and choice the \a version of MED format
586
    #  @param f is the file name
986
    #  @param f is the file name
587
    #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
987
    #  @param version values are SMESH.MED_V2_1, SMESH.MED_V2_2
588
    def ExportToMED(self, f, version, opt=0):
988
    def ExportToMED(self, f, version, opt=0):
589
        self.mesh.ExportToMED(f, opt, version)
989
        self.mesh.ExportToMED(f, opt, version)
590
990
        
591
    ## Export the mesh in a file with the MED format
991
    ## Export the mesh in a file with the MED format
592
    #  @param f is the file name
992
    #  @param f is the file name
593
    def ExportMED(self, f, opt=0):
993
    #  @param auto_groups boolean parameter for creating/not creating
594
        self.mesh.ExportMED(f, opt)
994
    #  the groups Group_On_All_Nodes, Group_On_All_Faces, ... ;
595
995
    #  the typical use is auto_groups=false.
996
    #  @param version MED format version(MED_V2_1 or MED_V2_2)
997
    def ExportMED(self, f, auto_groups=0, version=MED_V2_2):
998
        self.mesh.ExportToMED(f, auto_groups, version)
999
        
596
    ## Export the mesh in a file with the DAT format
1000
    ## Export the mesh in a file with the DAT format
597
    #  @param f is the file name
1001
    #  @param f is the file name
598
    def ExportDAT(self, f):
1002
    def ExportDAT(self, f):
599
        self.mesh.ExportDAT(f)
1003
        self.mesh.ExportDAT(f)
600
1004
        
601
    ## Export the mesh in a file with the UNV format
1005
    ## Export the mesh in a file with the UNV format
602
    #  @param f is the file name
1006
    #  @param f is the file name
603
    def ExportUNV(self, f):
1007
    def ExportUNV(self, f):
604
        self.mesh.ExportUNV(f)
1008
        self.mesh.ExportUNV(f)
605
1009
        
606
    ## Export the mesh in a file with the STL format
1010
    ## Export the mesh in a file with the STL format
607
    #  @param f is the file name
1011
    #  @param f is the file name
608
    #  @param ascii defined the kind of file contents
1012
    #  @param ascii defined the kind of file contents
609
    def ExportSTL(self, f, ascii=1):
1013
    def ExportSTL(self, f, ascii=1):
610
        self.mesh.ExportSTL(f, ascii)
1014
        self.mesh.ExportSTL(f, ascii)
1015
    
1016
    ###################################################################################
1017
        
1018
    ## Operations with groups
1019
    #  ----------------------
1020
1021
    ## Creates an empty mesh group
1022
    #  @param elementType is the type of elements in the group
1023
    #  @param name is the name of the mesh group
1024
    #  @return SMESH_Group
1025
    def CreateEmptyGroup(self, elementType, name):
1026
        return self.mesh.CreateGroup(elementType, name)
1027
    
1028
    ## Creates a mesh group based on geometric object \a grp
1029
    #  and give a \a name, if this parameter is not defined
1030
    #  the name is the same as the geometric group name
1031
    #  @param grp  is a geometric group, a vertex, an edge, a face or a solid
1032
    #  @param name is the name of the mesh group
1033
    #  @return SMESH_GroupOnGeom
1034
    def GroupOnGeom(self, grp, name="", type=None):
1035
        if name == "":
1036
            name = grp.GetName()
1037
1038
        if type == None:
1039
            tgeo = str(grp.GetShapeType())
1040
            if tgeo == "VERTEX":
1041
                type = NODE
1042
            elif tgeo == "EDGE":
1043
                type = EDGE
1044
            elif tgeo == "FACE":
1045
                type = FACE
1046
            elif tgeo == "SOLID":
1047
                type = VOLUME
1048
            elif tgeo == "SHELL":
1049
                type = VOLUME
1050
            elif tgeo == "COMPOUND":
1051
                if len( geompy.GetObjectIDs( grp )) == 0:
1052
                    print "Mesh.Group: empty geometric group", GetName( grp )
1053
                    return 0
1054
                tgeo = geompy.GetType(grp)
1055
                if tgeo == geompy.ShapeType["VERTEX"]:
1056
                    type = NODE
1057
                elif tgeo == geompy.ShapeType["EDGE"]:
1058
                    type = EDGE
1059
                elif tgeo == geompy.ShapeType["FACE"]:
1060
                    type = FACE
1061
                elif tgeo == geompy.ShapeType["SOLID"]:
1062
                    type = VOLUME
1063
1064
        if type == None:
1065
            print "Mesh.Group: bad first argument: expected a group, a vertex, an edge, a face or a solid"
1066
            return 0
1067
        else:
1068
            return self.mesh.CreateGroupFromGEOM(type, name, grp)
1069
1070
    ## Create a mesh group by the given ids of elements
1071
    #  @param groupName is the name of the mesh group
1072
    #  @param elementType is the type of elements in the group
1073
    #  @param elemIDs is the list of ids
1074
    #  @return SMESH_Group
1075
    def MakeGroupByIds(self, groupName, elementType, elemIDs):
1076
        group = self.mesh.CreateGroup(elementType, groupName)
1077
        group.Add(elemIDs)
1078
        return group
1079
    
1080
    ## Create a mesh group by the given conditions
1081
    #  @param groupName is the name of the mesh group
1082
    #  @param elementType is the type of elements in the group
1083
    #  @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1084
    #  @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1085
    #  @param Treshold is threshold value (range of id ids as string, shape, numeric)
1086
    #  @param UnaryOp is FT_LogicalNOT or FT_Undefined
1087
    #  @return SMESH_Group
1088
    def MakeGroup(self,
1089
                  groupName,
1090
                  elementType,
1091
                  CritType=FT_Undefined,
1092
                  Compare=FT_EqualTo,
1093
                  Treshold="",
1094
                  UnaryOp=FT_Undefined):
1095
        aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1096
        group = self.MakeGroupByCriterion(groupName, aCriterion)
1097
        return group
1098
1099
    ## Create a mesh group by the given criterion
1100
    #  @param groupName is the name of the mesh group
1101
    #  @param Criterion is the instance of Criterion class
1102
    #  @return SMESH_Group
1103
    def MakeGroupByCriterion(self, groupName, Criterion):
1104
        aFilterMgr = smesh.CreateFilterManager()
1105
        aFilter = aFilterMgr.CreateFilter()
1106
        aCriteria = []
1107
        aCriteria.append(Criterion)
1108
        aFilter.SetCriteria(aCriteria)
1109
        group = self.MakeGroupByFilter(groupName, aFilter)
1110
        return group
1111
    
1112
    ## Create a mesh group by the given criteria(list of criterions)
1113
    #  @param groupName is the name of the mesh group
1114
    #  @param Criteria is the list of criterions
1115
    #  @return SMESH_Group
1116
    def MakeGroupByCriteria(self, groupName, theCriteria):
1117
        aFilterMgr = smesh.CreateFilterManager()
1118
        aFilter = aFilterMgr.CreateFilter()
1119
        aFilter.SetCriteria(theCriteria)
1120
        group = self.MakeGroupByFilter(groupName, aFilter)
1121
        return group
1122
    
1123
    ## Create a mesh group by the given filter
1124
    #  @param groupName is the name of the mesh group
1125
    #  @param Criterion is the instance of Filter class
1126
    #  @return SMESH_Group
1127
    def MakeGroupByFilter(self, groupName, theFilter):
1128
        anIds = theFilter.GetElementsId(self.mesh)
1129
        anElemType = theFilter.GetElementType()
1130
        group = self.MakeGroupByIds(groupName, anElemType, anIds)
1131
        return group
1132
1133
    ## Creates filter by given parameters of criterion
1134
    #  @param elementType is the type of elements in the group
1135
    #  @param CritType is type of criterion( FT_Taper, FT_Area, FT_RangeOfIds, FT_LyingOnGeom etc. )
1136
    #  @param Compare belong to {FT_LessThan, FT_MoreThan, FT_EqualTo}
1137
    #  @param Treshold is threshold value (range of id ids as string, shape, numeric)
1138
    #  @param UnaryOp is FT_LogicalNOT or FT_Undefined
1139
    #  @return SMESH_Filter
1140
    def GetFilter(self,
1141
                  elementType,
1142
                  CritType=FT_Undefined,
1143
                  Compare=FT_EqualTo,
1144
                  Treshold="",
1145
                  UnaryOp=FT_Undefined):
1146
        aCriterion = GetCriterion(elementType, CritType, Compare, Treshold, UnaryOp, FT_Undefined)
1147
        aFilterMgr = smesh.CreateFilterManager()
1148
        aFilter = aFilterMgr.CreateFilter()
1149
        aCriteria = []
1150
        aCriteria.append(aCriterion)
1151
        aFilter.SetCriteria(aCriteria)
1152
        return aFilter
1153
        
1154
    ## Remove a group
1155
    def RemoveGroup(self, group):
1156
        self.mesh.RemoveGroup(group)
1157
1158
    ## Remove group with its contents
1159
    def RemoveGroupWithContents(self, group):
1160
        self.mesh.RemoveGroupWithContents(group)
1161
        
1162
    ## Get the list of groups existing in the mesh
1163
    def GetGroups(self):
1164
        return self.mesh.GetGroups()
1165
1166
    ## Get the list of names of groups existing in the mesh
1167
    def GetGroupNames(self):
1168
        groups = self.GetGroups()
1169
        names = []
1170
        for group in groups:
1171
            names.append(group.GetName())
1172
        return names
1173
1174
    ## Union of two groups
1175
    #  New group is created. All mesh elements that are
1176
    #  present in initial groups are added to the new one
1177
    def UnionGroups(self, group1, group2, name):
1178
        return self.mesh.UnionGroups(group1, group2, name)
1179
1180
    ## Intersection of two groups
1181
    #  New group is created. All mesh elements that are
1182
    #  present in both initial groups are added to the new one.
1183
    def IntersectGroups(self, group1, group2, name):
1184
        return self.mesh.IntersectGroups(group1, group2, name)
1185
    
1186
    ## Cut of two groups
1187
    #  New group is created. All mesh elements that are present in
1188
    #  main group but do not present in tool group are added to the new one
1189
    def CutGroups(self, mainGroup, toolGroup, name):
1190
        return self.mesh.CutGroups(mainGroup, toolGroup, name)
1191
         
1192
    
1193
    ## Get some info about mesh:
1194
    #  ------------------------
1195
1196
    ## Get the log of nodes and elements added or removed since previous
1197
    #  clear of the log.
1198
    #  @param clearAfterGet log is emptied after Get (safe if concurrents access)
1199
    #  @return list of log_block structures:
1200
    #                                        commandType
1201
    #                                        number
1202
    #                                        coords
1203
    #                                        indexes
1204
    def GetLog(self, clearAfterGet):
1205
        return self.mesh.GetLog(clearAfterGet)
1206
1207
    ## Clear the log of nodes and elements added or removed since previous
1208
    #  clear. Must be used immediately after GetLog if clearAfterGet is false.
1209
    def ClearLog(self):
1210
        self.mesh.ClearLog()
1211
1212
    ## Get the internal Id
1213
    def GetId(self):
1214
        return self.mesh.GetId()
1215
1216
    ## Get the study Id
1217
    def GetStudyId(self):
1218
        return self.mesh.GetStudyId()
1219
1220
    ## Check group names for duplications.
1221
    #  Consider maximum group name length stored in MED file.
1222
    def HasDuplicatedGroupNamesMED(self):
1223
        return self.mesh.GetStudyId()
1224
        
1225
    ## Obtain instance of SMESH_MeshEditor
1226
    def GetMeshEditor(self):
1227
        return self.mesh.GetMeshEditor()
1228
1229
    ## Get MED Mesh
1230
    def GetMEDMesh(self):
1231
        return self.mesh.GetMEDMesh()
1232
    
1233
    
1234
    ## Get informations about mesh contents:
1235
    #  ------------------------------------
1236
1237
    ## Returns number of nodes in mesh
1238
    def NbNodes(self):
1239
        return self.mesh.NbNodes()
1240
1241
    ## Returns number of elements in mesh
1242
    def NbElements(self):
1243
        return self.mesh.NbElements()
1244
1245
    ## Returns number of edges in mesh
1246
    def NbEdges(self):
1247
        return self.mesh.NbEdges()
1248
1249
    ## Returns number of edges with given order in mesh
1250
    #  @param elementOrder is order of elements:
1251
    #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1252
    def NbEdgesOfOrder(self, elementOrder):
1253
        return self.mesh.NbEdgesOfOrder(elementOrder)
1254
    
1255
    ## Returns number of faces in mesh
1256
    def NbFaces(self):
1257
        return self.mesh.NbFaces()
1258
1259
    ## Returns number of faces with given order in mesh
1260
    #  @param elementOrder is order of elements:
1261
    #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1262
    def NbFacesOfOrder(self, elementOrder):
1263
        return self.mesh.NbFacesOfOrder(elementOrder)
1264
1265
    ## Returns number of triangles in mesh
1266
    def NbTriangles(self):
1267
        return self.mesh.NbTriangles()
1268
1269
    ## Returns number of triangles with given order in mesh
1270
    #  @param elementOrder is order of elements:
1271
    #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1272
    def NbTrianglesOfOrder(self, elementOrder):
1273
        return self.mesh.NbTrianglesOfOrder(elementOrder)
1274
1275
    ## Returns number of quadrangles in mesh
1276
    def NbQuadrangles(self):
1277
        return self.mesh.NbQuadrangles()
1278
1279
    ## Returns number of quadrangles with given order in mesh
1280
    #  @param elementOrder is order of elements:
1281
    #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1282
    def NbQuadranglesOfOrder(self, elementOrder):
1283
        return self.mesh.NbQuadranglesOfOrder(elementOrder)
1284
1285
    ## Returns number of polygons in mesh
1286
    def NbPolygons(self):
1287
        return self.mesh.NbPolygons()
1288
1289
    ## Returns number of volumes in mesh
1290
    def NbVolumes(self):
1291
        return self.mesh.NbVolumes()
1292
1293
    ## Returns number of volumes with given order in mesh
1294
    #  @param elementOrder is order of elements:
1295
    #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1296
    def NbVolumesOfOrder(self, elementOrder):
1297
        return self.mesh.NbVolumesOfOrder(elementOrder)
1298
1299
    ## Returns number of tetrahedrons in mesh
1300
    def NbTetras(self):
1301
        return self.mesh.NbTetras()
1302
1303
    ## Returns number of tetrahedrons with given order in mesh
1304
    #  @param elementOrder is order of elements:
1305
    #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1306
    def NbTetrasOfOrder(self, elementOrder):
1307
        return self.mesh.NbTetrasOfOrder(elementOrder)
1308
1309
    ## Returns number of hexahedrons in mesh
1310
    def NbHexas(self):
1311
        return self.mesh.NbHexas()
1312
1313
    ## Returns number of hexahedrons with given order in mesh
1314
    #  @param elementOrder is order of elements:
1315
    #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1316
    def NbHexasOfOrder(self, elementOrder):
1317
        return self.mesh.NbHexasOfOrder(elementOrder)
1318
1319
    ## Returns number of pyramids in mesh
1320
    def NbPyramids(self):
1321
        return self.mesh.NbPyramids()
1322
1323
    ## Returns number of pyramids with given order in mesh
1324
    #  @param elementOrder is order of elements:
1325
    #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1326
    def NbPyramidsOfOrder(self, elementOrder):
1327
        return self.mesh.NbPyramidsOfOrder(elementOrder)
1328
1329
    ## Returns number of prisms in mesh
1330
    def NbPrisms(self):
1331
        return self.mesh.NbPrisms()
1332
1333
    ## Returns number of prisms with given order in mesh
1334
    #  @param elementOrder is order of elements:
1335
    #  ORDER_ANY, ORDER_LINEAR or ORDER_QUADRATIC
1336
    def NbPrismsOfOrder(self, elementOrder):
1337
        return self.mesh.NbPrismsOfOrder(elementOrder)
1338
1339
    ## Returns number of polyhedrons in mesh
1340
    def NbPolyhedrons(self):
1341
        return self.mesh.NbPolyhedrons()
1342
1343
    ## Returns number of submeshes in mesh
1344
    def NbSubMesh(self):
1345
        return self.mesh.NbSubMesh()
1346
1347
    ## Returns list of mesh elements ids
1348
    def GetElementsId(self):
1349
        return self.mesh.GetElementsId()
1350
1351
    ## Returns list of ids of mesh elements with given type
1352
    #  @param elementType is required type of elements
1353
    def GetElementsByType(self, elementType):
1354
        return self.mesh.GetElementsByType(elementType)
1355
1356
    ## Returns list of mesh nodes ids
1357
    def GetNodesId(self):
1358
        return self.mesh.GetNodesId()
1359
    
1360
    ## Get informations about mesh elements:
1361
    #  ------------------------------------
1362
    
1363
    ## Returns type of mesh element
1364
    def GetElementType(self, id, iselem):
1365
        return self.mesh.GetElementType(id, iselem)
1366
1367
    ## Returns list of submesh elements ids
1368
    #  @param shapeID is geom object(subshape) IOR
1369
    def GetSubMeshElementsId(self, shapeID):
1370
        return self.mesh.GetSubMeshElementsId(shapeID)
1371
1372
    ## Returns list of submesh nodes ids
1373
    #  @param shapeID is geom object(subshape) IOR
1374
    def GetSubMeshNodesId(self, shapeID, all):
1375
        return self.mesh.GetSubMeshNodesId(shapeID, all)
1376
    
1377
    ## Returns list of ids of submesh elements with given type
1378
    #  @param shapeID is geom object(subshape) IOR
1379
    def GetSubMeshElementType(self, shapeID):
1380
        return self.mesh.GetSubMeshElementType(shapeID)
1381
      
1382
    ## Get mesh description
1383
    def Dump(self):
1384
        return self.mesh.Dump()
1385
1386
    
1387
    ## Get information about nodes and elements of mesh by its ids:
1388
    #  -----------------------------------------------------------
1389
1390
    ## Get XYZ coordinates of node as list of double
1391
    #  If there is not node for given ID - returns empty list
1392
    def GetNodeXYZ(self, id):
1393
        return self.mesh.GetNodeXYZ(id)
1394
1395
    ## For given node returns list of IDs of inverse elements
1396
    #  If there is not node for given ID - returns empty list
1397
    def GetNodeInverseElements(self, id):
1398
        return self.mesh.GetNodeInverseElements(id)
1399
    
1400
    ## If given element is node returns IDs of shape from position
1401
    # else - return ID of result shape after Mesh.FindShape()
1402
    # If there is not element for given ID - returns -1
1403
    def GetShapeID(self, id):
1404
        return self.mesh.GetShapeID(id)
1405
1406
    ## Returns number of nodes for given element
1407
    #  If there is not element for given ID - returns -1
1408
    def GetElemNbNodes(self, id):
1409
        return self.mesh.GetElemNbNodes(id)
1410
1411
    ## Returns ID of node by given index for given element
1412
    #  If there is not element for given ID - returns -1
1413
    #  If there is not node for given index - returns -2
1414
    def GetElemNode(self, id, index):
1415
        return self.mesh.GetElemNode(id, index)
1416
1417
    ## Returns true if given node is medium node
1418
    #  in given quadratic element
1419
    def IsMediumNode(self, elementID, nodeID):
1420
        return self.mesh.IsMediumNode(elementID, nodeID)
1421
    
1422
    ## Returns true if given node is medium node
1423
    #  in one of quadratic elements
1424
    def IsMediumNodeOfAnyElem(self, nodeID, elementType):
1425
        return self.mesh.IsMediumNodeOfAnyElem(nodeID, elementType)
1426
1427
    ## Returns number of edges for given element
1428
    def ElemNbEdges(self, id):
1429
        return self.mesh.ElemNbEdges(id)
1430
        
1431
    ## Returns number of faces for given element
1432
    def ElemNbFaces(self, id):
1433
        return self.mesh.ElemNbFaces(id)
1434
1435
    ## Returns true if given element is polygon
1436
    def IsPoly(self, id):
1437
        return self.mesh.IsPoly(id)
1438
1439
    ## Returns true if given element is quadratic
1440
    def IsQuadratic(self, id):
1441
        return self.mesh.IsQuadratic(id)
1442
1443
    ## Returns XYZ coordinates of bary center for given element
1444
    #  as list of double
1445
    #  If there is not element for given ID - returns empty list
1446
    def BaryCenter(self, id):
1447
        return self.mesh.BaryCenter(id)
1448
    
1449
    
1450
    ## Mesh edition (SMESH_MeshEditor functionality):
1451
    #  ---------------------------------------------
1452
1453
    ## Removes elements from mesh by ids
1454
    #  @param IDsOfElements is list of ids of elements to remove
1455
    def RemoveElements(self, IDsOfElements):
1456
        return self.editor.RemoveElements(IDsOfElements)
1457
1458
    ## Removes nodes from mesh by ids
1459
    #  @param IDsOfNodes is list of ids of nodes to remove
1460
    def RemoveNodes(self, IDsOfNodes):
1461
        return self.editor.RemoveNodes(IDsOfNodes)
1462
1463
    ## Add node to mesh by coordinates
1464
    def AddNode(self, x, y, z):
1465
        return self.editor.AddNode( x, y, z)
1466
1467
    
1468
    ## Create edge both similar and quadratic (this is determed
1469
    #  by number of given nodes).
1470
    #  @param IdsOfNodes List of node IDs for creation of element.
1471
    #  Needed order of nodes in this list corresponds to description
1472
    #  of MED. This description is located by the following link:
1473
    #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1474
    def AddEdge(self, IDsOfNodes):
1475
        return self.editor.AddEdge(IDsOfNodes)
1476
1477
    ## Create face both similar and quadratic (this is determed
1478
    #  by number of given nodes).
1479
    #  @param IdsOfNodes List of node IDs for creation of element.
1480
    #  Needed order of nodes in this list corresponds to description
1481
    #  of MED. This description is located by the following link:
1482
    #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1483
    def AddFace(self, IDsOfNodes):
1484
        return self.editor.AddFace(IDsOfNodes)
1485
    
1486
    ## Add polygonal face to mesh by list of nodes ids
1487
    def AddPolygonalFace(self, IdsOfNodes):
1488
        return self.editor.AddPolygonalFace(IdsOfNodes)
1489
    
1490
    ## Create volume both similar and quadratic (this is determed
1491
    #  by number of given nodes).
1492
    #  @param IdsOfNodes List of node IDs for creation of element.
1493
    #  Needed order of nodes in this list corresponds to description
1494
    #  of MED. This description is located by the following link:
1495
    #  http://www.salome-platform.org/salome2/web_med_internet/logiciels/medV2.2.2_doc_html/html/modele_de_donnees.html#3.
1496
    def AddVolume(self, IDsOfNodes):
1497
        return self.editor.AddVolume(IDsOfNodes)
1498
1499
    ## Create volume of many faces, giving nodes for each face.
1500
    #  @param IdsOfNodes List of node IDs for volume creation face by face.
1501
    #  @param Quantities List of integer values, Quantities[i]
1502
    #         gives quantity of nodes in face number i.
1503
    def AddPolyhedralVolume (self, IdsOfNodes, Quantities):
1504
        return self.editor.AddPolyhedralVolume(IdsOfNodes, Quantities)
1505
1506
    ## Create volume of many faces, giving IDs of existing faces.
1507
    #  @param IdsOfFaces List of face IDs for volume creation.
1508
    #
1509
    #  Note:  The created volume will refer only to nodes
1510
    #         of the given faces, not to the faces itself.
1511
    def AddPolyhedralVolumeByFaces (self, IdsOfFaces):
1512
        return self.editor.AddPolyhedralVolumeByFaces(IdsOfFaces)
1513
    
1514
    ## Move node with given id
1515
    #  @param NodeID id of the node
1516
    #  @param x displacing along the X axis
1517
    #  @param y displacing along the Y axis
1518
    #  @param z displacing along the Z axis
1519
    def MoveNode(self, NodeID, x, y, z):
1520
        return self.editor.MoveNode(NodeID, x, y, z)
1521
1522
    ## Replace two neighbour triangles sharing Node1-Node2 link
1523
    #  with ones built on the same 4 nodes but having other common link.
1524
    #  @param NodeID1 first node id
1525
    #  @param NodeID2 second node id
1526
    #  @return false if proper faces not found
1527
    def InverseDiag(self, NodeID1, NodeID2):
1528
        return self.editor.InverseDiag(NodeID1, NodeID2)
1529
1530
    ## Replace two neighbour triangles sharing Node1-Node2 link
1531
    #  with a quadrangle built on the same 4 nodes.
1532
    #  @param NodeID1 first node id
1533
    #  @param NodeID2 second node id
1534
    #  @return false if proper faces not found
1535
    def DeleteDiag(self, NodeID1, NodeID2):
1536
        return self.editor.DeleteDiag(NodeID1, NodeID2)
1537
1538
    ## Reorient elements by ids
1539
    #  @param IDsOfElements if undefined reorient all mesh elements
1540
    def Reorient(self, IDsOfElements=None):
1541
        if IDsOfElements == None:
1542
            IDsOfElements = self.GetElementsId()
1543
        return self.editor.Reorient(IDsOfElements)
1544
1545
    ## Reorient all elements of the object
1546
    #  @param theObject is mesh, submesh or group
1547
    def ReorientObject(self, theObject):
1548
        return self.editor.ReorientObject(theObject)
1549
1550
    ## Fuse neighbour triangles into quadrangles.
1551
    #  @param IDsOfElements The triangles to be fused,
1552
    #  @param Criterion     is used to choose a neighbour to fuse with.
1553
    #  @param MaxAngle      is a max angle between element normals at which fusion
1554
    #                       is still performed; theMaxAngle is mesured in radians.
1555
    #  @return TRUE in case of success, FALSE otherwise.
1556
    def TriToQuad(self, IDsOfElements, Criterion, MaxAngle):
1557
        if IDsOfElements == []:
1558
            IDsOfElements = self.GetElementsId()
1559
        return self.editor.TriToQuad(IDsOfElements, Criterion, MaxAngle)
1560
1561
    ## Fuse neighbour triangles of the object into quadrangles
1562
    #  @param theObject is mesh, submesh or group
1563
    #  @param Criterion is used to choose a neighbour to fuse with.
1564
    #  @param MaxAngle  is a max angle between element normals at which fusion
1565
    #                   is still performed; theMaxAngle is mesured in radians.
1566
    #  @return TRUE in case of success, FALSE otherwise.
1567
    def TriToQuadObject (self, theObject, Criterion, MaxAngle):
1568
        return self.editor.TriToQuadObject(theObject, Criterion, MaxAngle)
1569
1570
    ## Split quadrangles into triangles.
1571
    #  @param IDsOfElements the faces to be splitted.
1572
    #  @param theCriterion  is used to choose a diagonal for splitting.
1573
    #  @param @return TRUE in case of success, FALSE otherwise.
1574
    def QuadToTri (self, IDsOfElements, Criterion):
1575
        if IDsOfElements == []:
1576
            IDsOfElements = self.GetElementsId()
1577
        return self.editor.QuadToTri(IDsOfElements, Criterion)
1578
1579
    ## Split quadrangles into triangles.
1580
    #  @param theObject object to taking list of elements from, is mesh, submesh or group
1581
    def QuadToTriObject (self, theObject, Criterion):
1582
        return self.editor.QuadToTriObject(theObject, Criterion)
1583
1584
    ## Split quadrangles into triangles.
1585
    #  @param theElems  The faces to be splitted
1586
    #  @param the13Diag is used to choose a diagonal for splitting.
1587
    #  @return TRUE in case of success, FALSE otherwise.
1588
    def SplitQuad (self, IDsOfElements, Diag13):
1589
        if IDsOfElements == []:
1590
            IDsOfElements = self.GetElementsId()
1591
        return self.editor.SplitQuad(IDsOfElements, Diag13)
1592
1593
    ## Split quadrangles into triangles.
1594
    #  @param theObject is object to taking list of elements from, is mesh, submesh or group
1595
    def SplitQuadObject (self, theObject, Diag13):
1596
        return self.editor.SplitQuadObject(theObject, Diag13)
1597
1598
    ## Find better splitting of the given quadrangle.
1599
    #  @param IDOfQuad  ID of the quadrangle to be splitted.
1600
    #  @param Criterion is a criterion to choose a diagonal for splitting.
1601
    #  @return 1 if 1-3 diagonal is better, 2 if 2-4
1602
    #          diagonal is better, 0 if error occurs.
1603
    def BestSplit (self, IDOfQuad, Criterion):
1604
        return self.editor.BestSplit(IDOfQuad, Criterion)
1605
    
1606
    ## Smooth elements
1607
    #  @param IDsOfElements list if ids of elements to smooth
1608
    #  @param IDsOfFixedNodes list of ids of fixed nodes.
1609
    #  Note that nodes built on edges and boundary nodes are always fixed.
1610
    #  @param MaxNbOfIterations maximum number of iterations
1611
    #  @param MaxAspectRatio varies in range [1.0, inf]
1612
    #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1613
    def Smooth(self, IDsOfElements, IDsOfFixedNodes,
1614
               MaxNbOfIterations, MaxAspectRatio, Method):
1615
        if IDsOfElements == []:
1616
            IDsOfElements = self.GetElementsId()
1617
        return self.editor.Smooth(IDsOfElements, IDsOfFixedNodes,
1618
                                  MaxNbOfIterations, MaxAspectRatio, Method)
1619
    
1620
    ## Smooth elements belong to given object
1621
    #  @param theObject object to smooth
1622
    #  @param IDsOfFixedNodes list of ids of fixed nodes.
1623
    #  Note that nodes built on edges and boundary nodes are always fixed.
1624
    #  @param MaxNbOfIterations maximum number of iterations
1625
    #  @param MaxAspectRatio varies in range [1.0, inf]
1626
    #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1627
    def SmoothObject(self, theObject, IDsOfFixedNodes, 
1628
                     MaxNbOfIterations, MaxxAspectRatio, Method):
1629
        return self.editor.SmoothObject(theObject, IDsOfFixedNodes, 
1630
                                        MaxNbOfIterations, MaxxAspectRatio, Method)
1631
1632
    ## Parametric smooth the given elements
1633
    #  @param IDsOfElements list if ids of elements to smooth
1634
    #  @param IDsOfFixedNodes list of ids of fixed nodes.
1635
    #  Note that nodes built on edges and boundary nodes are always fixed.
1636
    #  @param MaxNbOfIterations maximum number of iterations
1637
    #  @param MaxAspectRatio varies in range [1.0, inf]
1638
    #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1639
    def SmoothParametric(IDsOfElements, IDsOfFixedNodes,
1640
                         MaxNbOfIterations, MaxAspectRatio, Method):
1641
        if IDsOfElements == []:
1642
            IDsOfElements = self.GetElementsId()
1643
        return self.editor.SmoothParametric(IDsOfElements, IDsOfFixedNodes,
1644
                                            MaxNbOfIterations, MaxAspectRatio, Method)
1645
    
1646
    ## Parametric smooth elements belong to given object
1647
    #  @param theObject object to smooth
1648
    #  @param IDsOfFixedNodes list of ids of fixed nodes.
1649
    #  Note that nodes built on edges and boundary nodes are always fixed.
1650
    #  @param MaxNbOfIterations maximum number of iterations
1651
    #  @param MaxAspectRatio varies in range [1.0, inf]
1652
    #  @param Method is Laplacian(LAPLACIAN_SMOOTH) or Centroidal(CENTROIDAL_SMOOTH)
1653
    def SmoothParametricObject(self, theObject, IDsOfFixedNodes,
1654
                               MaxNbOfIterations, MaxAspectRatio, Method):
1655
        return self.editor.SmoothParametricObject(theObject, IDsOfFixedNodes,
1656
                                                  MaxNbOfIterations, MaxAspectRatio, Method)
1657
1658
    ## Converts all mesh to quadratic one, deletes old elements, replacing 
1659
    #  them with quadratic ones with the same id.
1660
    def ConvertToQuadratic(self, theForce3d):
1661
        self.editor.ConvertToQuadratic(theForce3d)
1662
1663
    ## Converts all mesh from quadratic to ordinary ones,
1664
    #  deletes old quadratic elements, replacing 
1665
    #  them with ordinary mesh elements with the same id.
1666
    def ConvertFromQuadratic(self):
1667
        return self.editor.ConvertFromQuadratic()
1668
1669
    ## Renumber mesh nodes
1670
    def RenumberNodes(self):
1671
        self.editor.RenumberNodes()
1672
1673
    ## Renumber mesh elements
1674
    def RenumberElements(self):
1675
        self.editor.RenumberElements()
1676
1677
    ## Generate new elements by rotation of the elements around the axis
1678
    #  @param IDsOfElements list of ids of elements to sweep
1679
    #  @param Axix axis of rotation, AxisStruct or line(geom object)
1680
    #  @param AngleInRadians angle of Rotation
1681
    #  @param NbOfSteps number of steps
1682
    #  @param Tolerance tolerance
1683
    def RotationSweep(self, IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance):
1684
        if IDsOfElements == []:
1685
            IDsOfElements = self.GetElementsId()
1686
        if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
1687
            Axix = GetAxisStruct(Axix)
1688
        self.editor.RotationSweep(IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance)
1689
1690
    ## Generate new elements by rotation of the elements of object around the axis
1691
    #  @param theObject object wich elements should be sweeped
1692
    #  @param Axix axis of rotation, AxisStruct or line(geom object)
1693
    #  @param AngleInRadians angle of Rotation
1694
    #  @param NbOfSteps number of steps
1695
    #  @param Tolerance tolerance
1696
    def RotationSweepObject(self, theObject, Axix, AngleInRadians, NbOfSteps, Tolerance):
1697
        if ( isinstance( Axix, geompy.GEOM._objref_GEOM_Object)):
1698
            Axix = GetAxisStruct(Axix)
1699
        self.editor.RotationSweepObject(theObject, Axix, AngleInRadians, NbOfSteps, Tolerance)
1700
1701
    ## Generate new elements by extrusion of the elements with given ids
1702
    #  @param IDsOfElements list of elements ids for extrusion
1703
    #  @param StepVector vector, defining the direction and value of extrusion 
1704
    #  @param NbOfSteps the number of steps
1705
    def ExtrusionSweep(self, IDsOfElements, StepVector, NbOfSteps):
1706
        if IDsOfElements == []:
1707
            IDsOfElements = self.GetElementsId()
1708
        if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
1709
            StepVector = GetDirStruct(StepVector)
1710
        self.editor.ExtrusionSweep(IDsOfElements, StepVector, NbOfSteps)
1711
1712
    ## Generate new elements by extrusion of the elements with given ids
1713
    #  @param IDsOfElements is ids of elements
1714
    #  @param StepVector vector, defining the direction and value of extrusion 
1715
    #  @param NbOfSteps the number of steps
1716
    #  @param ExtrFlags set flags for performing extrusion
1717
    #  @param SewTolerance uses for comparing locations of nodes if flag
1718
    #         EXTRUSION_FLAG_SEW is set
1719
    def AdvancedExtrusion(self, IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance):
1720
        if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
1721
            StepVector = GetDirStruct(StepVector)
1722
        self.editor.AdvancedExtrusion(IDsOfElements, StepVector, NbOfSteps, ExtrFlags, SewTolerance)
1723
1724
    ## Generate new elements by extrusion of the elements belong to object
1725
    #  @param theObject object wich elements should be processed
1726
    #  @param StepVector vector, defining the direction and value of extrusion 
1727
    #  @param NbOfSteps the number of steps
1728
    def ExtrusionSweepObject(self, theObject, StepVector, NbOfSteps):
1729
        if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
1730
            StepVector = GetDirStruct(StepVector)
1731
        self.editor.ExtrusionSweepObject(theObject, StepVector, NbOfSteps)
1732
1733
    ## Generate new elements by extrusion of the elements belong to object
1734
    #  @param theObject object wich elements should be processed
1735
    #  @param StepVector vector, defining the direction and value of extrusion 
1736
    #  @param NbOfSteps the number of steps
1737
    def ExtrusionSweepObject1D(self, theObject, StepVector, NbOfSteps):
1738
        if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
1739
            StepVector = GetDirStruct(StepVector)
1740
        self.editor.ExtrusionSweepObject1D(theObject, StepVector, NbOfSteps)
1741
    
1742
    ## Generate new elements by extrusion of the elements belong to object
1743
    #  @param theObject object wich elements should be processed
1744
    #  @param StepVector vector, defining the direction and value of extrusion 
1745
    #  @param NbOfSteps the number of steps    
1746
    def ExtrusionSweepObject2D(self, theObject, StepVector, NbOfSteps):
1747
        if ( isinstance( StepVector, geompy.GEOM._objref_GEOM_Object)):
1748
            StepVector = GetDirStruct(StepVector)
1749
        self.editor.ExtrusionSweepObject2D(theObject, StepVector, NbOfSteps)
1750
1751
    ## Generate new elements by extrusion of the given elements
1752
    #  A path of extrusion must be a meshed edge.
1753
    #  @param IDsOfElements is ids of elements
1754
    #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
1755
    #  @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
1756
    #  @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
1757
    #  @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
1758
    #  @param Angles list of angles
1759
    #  @param HasRefPoint allows to use base point 
1760
    #  @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
1761
    #         User can specify any point as the Base Point and the shape will be rotated with respect to this point.
1762
    def ExtrusionAlongPath(self, IDsOfElements, PathMesh, PathShape, NodeStart,
1763
                           HasAngles, Angles, HasRefPoint, RefPoint):
1764
        if IDsOfElements == []:
1765
            IDsOfElements = self.GetElementsId()
1766
        if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
1767
            RefPoint = GetPointStruct(RefPoint) 
1768
        return self.editor.ExtrusionAlongPath(IDsOfElements, PathMesh, PathShape, NodeStart,
1769
                                              HasAngles, Angles, HasRefPoint, RefPoint)
1770
1771
    ## Generate new elements by extrusion of the elements belong to object
1772
    #  A path of extrusion must be a meshed edge.
1773
    #  @param IDsOfElements is ids of elements
1774
    #  @param PathMesh mesh containing a 1D sub-mesh on the edge, along which proceeds the extrusion
1775
    #  @param PathShape is shape(edge); as the mesh can be complex, the edge is used to define the sub-mesh for the path
1776
    #  @param NodeStart the first or the last node on the edge. It is used to define the direction of extrusion
1777
    #  @param HasAngles allows the shape to be rotated around the path to get the resulting mesh in a helical fashion
1778
    #  @param Angles list of angles
1779
    #  @param HasRefPoint allows to use base point 
1780
    #  @param RefPoint point around which the shape is rotated(the mass center of the shape by default).
1781
    #         User can specify any point as the Base Point and the shape will be rotated with respect to this point.
1782
    def ExtrusionAlongPathObject(self, theObject, PathMesh, PathShape, NodeStart,
1783
                                 HasAngles, Angles, HasRefPoint, RefPoint):
1784
        if ( isinstance( RefPoint, geompy.GEOM._objref_GEOM_Object)):
1785
            RefPoint = GetPointStruct(RefPoint) 
1786
        return self.editor.ExtrusionAlongPathObject(theObject, PathMesh, PathShape, NodeStart,
1787
                                                    HasAngles, Angles, HasRefPoint, RefPoint)
1788
    
1789
    ## Symmetrical copy of mesh elements
1790
    #  @param IDsOfElements list of elements ids
1791
    #  @param Mirror is AxisStruct or geom object(point, line, plane)
1792
    #  @param theMirrorType is  POINT, AXIS or PLANE
1793
    #  If the Mirror is geom object this parameter is unnecessary
1794
    #  @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
1795
    def Mirror(self, IDsOfElements, Mirror, theMirrorType, Copy=0):
1796
        if IDsOfElements == []:
1797
            IDsOfElements = self.GetElementsId()
1798
        if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
1799
            Mirror = GetAxisStruct(Mirror)
1800
        self.editor.Mirror(IDsOfElements, Mirror, theMirrorType, Copy)
1801
1802
    ## Symmetrical copy of object
1803
    #  @param theObject mesh, submesh or group
1804
    #  @param Mirror is AxisStruct or geom object(point, line, plane)
1805
    #  @param theMirrorType is  POINT, AXIS or PLANE
1806
    #  If the Mirror is geom object this parameter is unnecessary
1807
    #  @param Copy allows to copy element(Copy is 1) or to replace with its mirroring(Copy is 0)
1808
    def MirrorObject (self, theObject, Mirror, theMirrorType, Copy=0):
1809
        if ( isinstance( Mirror, geompy.GEOM._objref_GEOM_Object)):
1810
            Mirror = GetAxisStruct(Mirror)
1811
        self.editor.MirrorObject(theObject, Mirror, theMirrorType, Copy)
1812
1813
    ## Translates the elements
1814
    #  @param IDsOfElements list of elements ids
1815
    #  @param Vector direction of translation(DirStruct or vector)
1816
    #  @param Copy allows to copy the translated elements
1817
    def Translate(self, IDsOfElements, Vector, Copy):
1818
        if IDsOfElements == []:
1819
            IDsOfElements = self.GetElementsId()
1820
        if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
1821
            Vector = GetDirStruct(Vector)
1822
        self.editor.Translate(IDsOfElements, Vector, Copy)
1823
1824
    ## Translates the object
1825
    #  @param theObject object to translate(mesh, submesh, or group)
1826
    #  @param Vector direction of translation(DirStruct or geom vector)
1827
    #  @param Copy allows to copy the translated elements
1828
    def TranslateObject(self, theObject, Vector, Copy):
1829
        if ( isinstance( Vector, geompy.GEOM._objref_GEOM_Object)):
1830
            Vector = GetDirStruct(Vector)
1831
        self.editor.TranslateObject(theObject, Vector, Copy)
1832
1833
    ## Rotates the elements
1834
    #  @param IDsOfElements list of elements ids
1835
    #  @param Axis axis of rotation(AxisStruct or geom line)
1836
    #  @param AngleInRadians angle of rotation(in radians)
1837
    #  @param Copy allows to copy the rotated elements   
1838
    def Rotate (self, IDsOfElements, Axis, AngleInRadians, Copy):
1839
        if IDsOfElements == []:
1840
            IDsOfElements = self.GetElementsId()
1841
        if ( isinstance( Axis, geompy.GEOM._objref_GEOM_Object)):
1842
            Axis = GetAxisStruct(Axis)
1843
        self.editor.Rotate(IDsOfElements, Axis, AngleInRadians, Copy)
1844
1845
    ## Rotates the object
1846
    #  @param theObject object to rotate(mesh, submesh, or group)
1847
    #  @param Axis axis of rotation(AxisStruct or geom line)
1848
    #  @param AngleInRadians angle of rotation(in radians)
1849
    #  @param Copy allows to copy the rotated elements
1850
    def RotateObject (self, theObject, Axis, AngleInRadians, Copy):
1851
        self.editor.RotateObject(theObject, Axis, AngleInRadians, Copy)
1852
1853
    ## Find group of nodes close to each other within Tolerance.
1854
    #  @param Tolerance tolerance value
1855
    #  @param list of group of nodes
1856
    def FindCoincidentNodes (self, Tolerance):
1857
        return self.editor.FindCoincidentNodes(Tolerance)
1858
1859
    ## Merge nodes
1860
    #  @param list of group of nodes
1861
    def MergeNodes (self, GroupsOfNodes):
1862
        self.editor.MergeNodes(GroupsOfNodes)
1863
1864
    ## Remove all but one of elements built on the same nodes.
1865
    def MergeEqualElements(self):
1866
        self.editor.MergeEqualElements()
1867
        
1868
    ## Sew free borders
1869
    def SewFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
1870
                        FirstNodeID2, SecondNodeID2, LastNodeID2,
1871
                        CreatePolygons, CreatePolyedrs):
1872
        return self.editor.SewFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
1873
                                          FirstNodeID2, SecondNodeID2, LastNodeID2,
1874
                                          CreatePolygons, CreatePolyedrs)
1875
1876
    ## Sew conform free borders
1877
    def SewConformFreeBorders (self, FirstNodeID1, SecondNodeID1, LastNodeID1,
1878
                               FirstNodeID2, SecondNodeID2):
1879
        return self.editor.SewConformFreeBorders(FirstNodeID1, SecondNodeID1, LastNodeID1,
1880
                                                 FirstNodeID2, SecondNodeID2)
1881
    
1882
    ## Sew border to side
1883
    def SewBorderToSide (self, FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
1884
                         FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs):
1885
        return self.editor.SewBorderToSide(FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder,
1886
                                           FirstNodeIDOnSide, LastNodeIDOnSide, CreatePolygons, CreatePolyedrs)
1887
1888
    ## Sew two sides of a mesh. Nodes belonging to Side1 are
1889
    #  merged with nodes of elements of Side2.
1890
    #  Number of elements in theSide1 and in theSide2 must be
1891
    #  equal and they should have similar node connectivity.
1892
    #  The nodes to merge should belong to sides borders and
1893
    #  the first node should be linked to the second.
1894
    def SewSideElements (self, IDsOfSide1Elements, IDsOfSide2Elements,
1895
                         NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
1896
                         NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge):
1897
        return self.editor.SewSideElements(IDsOfSide1Elements, IDsOfSide2Elements,
1898
                                           NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge,
1899
                                           NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge)
1900
1901
    ## Set new nodes for given element.
1902
    #  @param ide the element id
1903
    #  @param newIDs nodes ids
1904
    #  @return If number of nodes is not corresponded to type of element - returns false
1905
    def ChangeElemNodes(self, ide, newIDs):
1906
        return self.editor.ChangeElemNodes(ide, newIDs)
1907
    
1908
    ## If during last operation of MeshEditor some nodes were
1909
    #  created this method returns list of it's IDs, if new nodes
1910
    #  not created - returns empty list
1911
    def GetLastCreatedNodes(self):
1912
        return self.editor.GetLastCreatedNodes()
1913
1914
    ## If during last operation of MeshEditor some elements were
1915
    #  created this method returns list of it's IDs, if new elements
1916
    #  not creared - returns empty list
1917
    def GetLastCreatedElems(self):
1918
        return self.editor.GetLastCreatedElems()
(-)SMESH_SRC_3.2.2/src/StdMeshers_I/Makefile.in (-1 / +1 lines)
Lines 85-91 Link Here
85
	SALOMEDS.idl SALOME_Exception.idl \
85
	SALOMEDS.idl SALOME_Exception.idl \
86
	GEOM_Gen.idl MED.idl SALOMEDS_Attributes.idl \
86
	GEOM_Gen.idl MED.idl SALOMEDS_Attributes.idl \
87
	SMESH_Gen.idl SMESH_Hypothesis.idl SMESH_Group.idl \
87
	SMESH_Gen.idl SMESH_Hypothesis.idl SMESH_Group.idl \
88
	SALOME_Comm.idl
88
	SALOME_Comm.idl SALOME_Component.idl SALOME_GenericObj.idl SMESH_Mesh.idl
89
89
90
# Executables targets
90
# Executables targets
91
BIN = 
91
BIN = 

Return to bug 155974