]> SALOME platform Git repositories - plugins/hexablockplugin.git/commitdiff
Salome HOME
Compute method view globally the generation (all solids in one step) like HexoticPlugin
authorfkl <fkl>
Fri, 4 Nov 2011 13:44:52 +0000 (13:44 +0000)
committerfkl <fkl>
Fri, 4 Nov 2011 13:44:52 +0000 (13:44 +0000)
Francis Kloss

src/HEXABLOCKPlugin/HEXABLOCKPlugin_HEXABLOCK.cxx
src/HEXABLOCKPlugin/HEXABLOCKPlugin_HEXABLOCK.hxx

index 3c2a889b04b75148c22852b3d4da7490a35764eb..2e025c8316bb58a98690f06c4fed7c99f0cff8dc 100755 (executable)
@@ -28,6 +28,8 @@
 #include "HEXABLOCKPlugin_HEXABLOCK.hxx"
 #include "HEXABLOCKPlugin_Hypothesis.hxx"
 
+#include "TopExp_Explorer.hxx"
+
 #include <Basics_Utils.hxx>
 
 #include "SMESH_Gen.hxx"
@@ -62,9 +64,10 @@ HEXABLOCKPlugin_HEXABLOCK::HEXABLOCKPlugin_HEXABLOCK(int hypId, int studyId, SME
   _compatibleHypothesis.push_back("HEXABLOCK_Parameters");
   _requireShape = false; // can work without shape
   _requireDescretBoundary = false;
-  _onlyUnaryInput = false; // Compute() will be called on a compound of solids
   _hyp = NULL;
   _supportSubmeshes = false;
+  _iShape  = 0;
+  _nbShape = 0;
 }
 
 //=============================================================================
@@ -105,16 +108,37 @@ bool HEXABLOCKPlugin_HEXABLOCK::CheckHypothesis ( SMESH_Mesh& aMesh,
  */
 //=============================================================================
 
-bool HEXABLOCKPlugin_HEXABLOCK::Compute(SMESH_Mesh& theMesh,
-                                const TopoDS_Shape& theShape)
-{
+bool HEXABLOCKPlugin_HEXABLOCK::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theShape) {
   MESSAGE("HEXABLOCKPlugin_HEXABLOCK::Compute with a shape");
 
-  switch (_hyp->GetDimension()) {
-    case 0 : return( Compute0D(theMesh) );
-    case 1 : return( Compute1D(theMesh) );
-    case 2 : return( Compute2D(theMesh) );
-    default: return( Compute3D(theMesh) );
+  SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
+  if ( (_iShape == 0) && (_nbShape == 0) ) {
+    TopExp_Explorer expShape ( meshDS->ShapeToMesh(), TopAbs_SOLID );
+    for ( ; expShape.More(); expShape.Next() ) {
+      _nbShape++;
+    }
+    _tabNode = new SMDS_MeshNode*[_nbShape];
+  }
+
+  _tabNode[_iShape] = meshDS->AddNode(0, 0, 0);
+  meshDS->NewSubMesh( meshDS->ShapeToIndex(theShape))->AddElement( _tabNode[_iShape] );
+
+  _iShape++;
+
+  if ( _iShape == _nbShape ) {
+    for (int i=0; i<_nbShape; i++) {
+      meshDS->RemoveNode( _tabNode[i] );
+    }
+    delete [] _tabNode;
+    _nbShape = 0;
+    _iShape  = 0;
+
+    switch (_hyp->GetDimension()) {
+      case 0 : return( Compute0D(theMesh) );
+      case 1 : return( Compute1D(theMesh) );
+      case 2 : return( Compute2D(theMesh) );
+      default: return( Compute3D(theMesh) );
+    };
   }
 }
 
index 7218424d630596f5f9866ae5080c5d325cfe94e3..f926b62e4a6b21bb147c7670a08b20523b72ca26 100755 (executable)
@@ -28,6 +28,7 @@
 #define _HEXABLOCKPlugin_HEXABLOCK_HXX_
 
 #include "SMESH_3D_Algo.hxx"
+#include "SMESH_Mesh.hxx"
 
 class SMESH_Mesh;
 class HEXABLOCKPlugin_Hypothesis;
@@ -58,6 +59,9 @@ public:
 
 private:
   const HEXABLOCKPlugin_Hypothesis* _hyp;
+  int  _iShape;
+  int  _nbShape;
+  SMDS_MeshNode** _tabNode;
 };
 
 #endif