From c59e8cb1c356879b5ee76a6fbd10867031ac4f69 Mon Sep 17 00:00:00 2001 From: fkl Date: Fri, 4 Nov 2011 13:44:52 +0000 Subject: [PATCH] Compute method view globally the generation (all solids in one step) like HexoticPlugin Francis Kloss --- .../HEXABLOCKPlugin_HEXABLOCK.cxx | 42 +++++++++++++++---- .../HEXABLOCKPlugin_HEXABLOCK.hxx | 4 ++ 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/HEXABLOCKPlugin/HEXABLOCKPlugin_HEXABLOCK.cxx b/src/HEXABLOCKPlugin/HEXABLOCKPlugin_HEXABLOCK.cxx index 3c2a889..2e025c8 100755 --- a/src/HEXABLOCKPlugin/HEXABLOCKPlugin_HEXABLOCK.cxx +++ b/src/HEXABLOCKPlugin/HEXABLOCKPlugin_HEXABLOCK.cxx @@ -28,6 +28,8 @@ #include "HEXABLOCKPlugin_HEXABLOCK.hxx" #include "HEXABLOCKPlugin_Hypothesis.hxx" +#include "TopExp_Explorer.hxx" + #include #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) ); + }; } } diff --git a/src/HEXABLOCKPlugin/HEXABLOCKPlugin_HEXABLOCK.hxx b/src/HEXABLOCKPlugin/HEXABLOCKPlugin_HEXABLOCK.hxx index 7218424..f926b62 100755 --- a/src/HEXABLOCKPlugin/HEXABLOCKPlugin_HEXABLOCK.hxx +++ b/src/HEXABLOCKPlugin/HEXABLOCKPlugin_HEXABLOCK.hxx @@ -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 -- 2.39.2