From e75955eb542a98a06bf68e5a2290d94d9752d391 Mon Sep 17 00:00:00 2001 From: Christian Van Wambeke Date: Fri, 27 Jun 2014 16:36:16 +0200 Subject: [PATCH] new combo for element generation etc... --- idl/HYBRIDPlugin_Algorithm.idl | 20 +- resources/HYBRIDPlugin.xml | 2 +- src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx | 59 +++-- src/GUI/HYBRIDPluginGUI_HypothesisCreator.h | 17 +- src/GUI/HYBRIDPlugin_msg_en.ts | 36 ++- src/HYBRIDPlugin/HYBRIDPluginBuilder.py | 43 +++- src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx | 4 +- src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx | 231 +++++++++++++----- src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx | 40 +-- .../HYBRIDPlugin_Hypothesis_i.cxx | 69 ++++-- .../HYBRIDPlugin_Hypothesis_i.hxx | 13 +- 11 files changed, 384 insertions(+), 150 deletions(-) diff --git a/idl/HYBRIDPlugin_Algorithm.idl b/idl/HYBRIDPlugin_Algorithm.idl index 35f57b2..f54103d 100644 --- a/idl/HYBRIDPlugin_Algorithm.idl +++ b/idl/HYBRIDPlugin_Algorithm.idl @@ -99,17 +99,21 @@ module HYBRIDPlugin /*! - * To mesh Boundary Layers growing inward or outward. - * Default is inward. + * Collision mode: 0-decrease, 1-stop. Default is decrease */ - void SetBoundaryLayersInward(in boolean toBoundaryLayersInward); - boolean GetBoundaryLayersInward(); + void SetCollisionMode(in short level) raises (SALOME::SALOME_Exception); + short GetCollisionMode(); /*! - * To mesh with element type Tetra Dominant or hexa Dominant in the boundary layers. - * Default is Tetra Dominant. + * BoundaryLayersGrowth: 0-Layer_Growth_Inward, 1-Layer_Growth_Outward. Default is Layer_Growth_Inward */ - void SetElemGenTetraDominant(in boolean toElemGenTetraDominant); - boolean GetElemGenTetraDominant(); + void SetBoundaryLayersGrowth(in short level) raises (SALOME::SALOME_Exception); + short GetBoundaryLayersGrowth(); + /*! + * ElementGeneration: 0-Generation_Tetra_Dominant, 1-Generation_Hexa_Dominant. Default is Generation_Tetra_Dominant + */ + void SetElementGeneration(in short level) raises (SALOME::SALOME_Exception); + short GetElementGeneration(); + /*! * To mesh adding extra normals at opening ridges and corners. * Default is no. diff --git a/resources/HYBRIDPlugin.xml b/resources/HYBRIDPlugin.xml index e72e347..562bb00 100644 --- a/resources/HYBRIDPlugin.xml +++ b/resources/HYBRIDPlugin.xml @@ -55,7 +55,7 @@ setMargin( 5 ); @@ -406,9 +405,13 @@ QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame() types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" ) << tr( "LEVEL_STRONG" ); myOptimizationLevelCombo->addItems( types ); - myBoundaryLayersInwardCheck = new QCheckBox( tr( "HYBRID_LAYERS_INWARD" ), myStdGroup ); - aStdLayout->addWidget( myBoundaryLayersInwardCheck, row++, 0, 1, 1 ); - myBoundaryLayersInwardCheck->setToolTip(tr( "HYBRID_LAYERS_Outward" ) ); //"Outward growth if deselected"); + aStdLayout->addWidget( new QLabel( tr( "HYBRID_BOUNDARY_LAYERS_GROWTH" ), myStdGroup ), row, 0, 1, 1 ); + myBoundaryLayersGrowthCombo = new QComboBox( myStdGroup ); + aStdLayout->addWidget( myBoundaryLayersGrowthCombo, row++, 1, 1, 1 ); + + QStringList typesBoundaryLayersGrowth; + typesBoundaryLayersGrowth << tr( "HYBRID_LAYER_GROWTH_INWARD" ) << tr( "HYBRID_LAYER_GROWTH_OUTWARD" ); + myBoundaryLayersGrowthCombo->addItems( typesBoundaryLayersGrowth ); aStdLayout->addWidget( new QLabel( tr( "HYBRID_HeightFirstLayer" ), myStdGroup ), row, 0, 1, 1 ); myHeightFirstLayerSpin = new SMESHGUI_SpinBox( myStdGroup ); @@ -424,9 +427,22 @@ QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame() myBoundaryLayersProgressionSpin->RangeStepAndValidator(0., 10., .1, "BoundaryLayersProgression"); aStdLayout->addWidget( myBoundaryLayersProgressionSpin, row++, 1, 1, 1 ); - myElemGenTetraDominantCheck = new QCheckBox( tr( "HYBRID_TETRA_DOMINANT" ), myStdGroup ); - aStdLayout->addWidget( myElemGenTetraDominantCheck, row++, 0, 1, 1 ); + aStdLayout->addWidget( new QLabel( tr( "COLLISION_MODE" ), myStdGroup ), row, 0, 1, 1 ); + myCollisionModeCombo = new QComboBox( myStdGroup ); + aStdLayout->addWidget( myCollisionModeCombo, row++, 1, 1, 1 ); + + QStringList typescoll; + typescoll << tr( "COLLISION_DECREASE" ) << tr( "COLLISION_STOP" ); + myCollisionModeCombo->addItems( typescoll ); + aStdLayout->addWidget( new QLabel( tr( "HYBRID_GENERATION_ELEMENT" ), myStdGroup ), row, 0, 1, 1 ); + myElementGenerationCombo = new QComboBox( myStdGroup ); + aStdLayout->addWidget( myElementGenerationCombo, row++, 1, 1, 1 ); + + QStringList typesElementGeneration; + typesElementGeneration << tr( "HYBRID_GENERATION_TETRA_DOMINANT" ) << tr( "HYBRID_GENERATION_HEXA_DOMINANT" ); + myElementGenerationCombo->addItems( typesElementGeneration ); + myAddMultinormalsCheck = new QCheckBox( tr( "HYBRID_ADD_MULTINORMALS" ), myStdGroup ); aStdLayout->addWidget( myAddMultinormalsCheck, row++, 0, 1, 1 ); @@ -662,8 +678,8 @@ QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame() //connect( myAdvWidget->initialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); //connect( myAdvWidget->boundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); - connect( myBoundaryLayersInwardCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); - connect( myElemGenTetraDominantCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); + //connect( myBoundaryLayersGrowthCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); + //connect( myElementGenerationCombo, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); connect( myAddMultinormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); connect( mySmoothNormalsCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) ); @@ -694,7 +710,6 @@ QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame() // connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) ); // connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) ); - std::cout << std::endl << "!!!!!!!!!!!!!!!!!!!!buildFrame TOVERIFY end" << std::endl; return fr; } @@ -1474,8 +1489,9 @@ void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const myAdvWidget->initialMemorySpin ->setValue ( qMax( data.myInitialMemory, myAdvWidget->initialMemorySpin->minimum() )); - myBoundaryLayersInwardCheck -> setChecked ( data.myBoundaryLayersInward ); - myElemGenTetraDominantCheck -> setChecked ( data.myElemGenTetraDominant ); + myCollisionModeCombo ->setCurrentIndex( data.myCollisionMode ); + myBoundaryLayersGrowthCombo ->setCurrentIndex( data.myBoundaryLayersGrowth ); + myElementGenerationCombo ->setCurrentIndex( data.myElementGeneration ); myAddMultinormalsCheck -> setChecked ( data.myAddMultinormals ); mySmoothNormalsCheck -> setChecked ( data.mySmoothNormals ); myHeightFirstLayerSpin -> setValue( data.myHeightFirstLayer ); @@ -1728,8 +1744,9 @@ bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData h_data.myInitialMemory = h->GetInitialMemory(); h_data.myOptimizationLevel = h->GetOptimizationLevel(); - h_data.myBoundaryLayersInward = h->GetBoundaryLayersInward(); - h_data.myElemGenTetraDominant = h->GetElemGenTetraDominant(); + h_data.myCollisionMode = h->GetCollisionMode(); + h_data.myBoundaryLayersGrowth = h->GetBoundaryLayersGrowth(); + h_data.myElementGeneration = h->GetElementGeneration(); h_data.myAddMultinormals = h->GetAddMultinormals(); h_data.mySmoothNormals = h->GetSmoothNormals(); h_data.myHeightFirstLayer = h->GetHeightFirstLayer(); @@ -1819,10 +1836,13 @@ bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesi if ( h->GetOptimizationLevel() != h_data.myOptimizationLevel ) h->SetOptimizationLevel( h_data.myOptimizationLevel ); - if ( h->GetBoundaryLayersInward() != h_data.myBoundaryLayersInward ) - h->SetBoundaryLayersInward ( h_data.myBoundaryLayersInward ); - if ( h->GetElemGenTetraDominant() != h_data.myElemGenTetraDominant ) - h->SetElemGenTetraDominant ( h_data.myElemGenTetraDominant ); + if ( h->GetCollisionMode() != h_data.myCollisionMode ) + h->SetCollisionMode( h_data.myCollisionMode ); + if ( h->GetBoundaryLayersGrowth() != h_data.myBoundaryLayersGrowth ) + h->SetBoundaryLayersGrowth( h_data.myBoundaryLayersGrowth ); + if ( h->GetElementGeneration() != h_data.myElementGeneration ) + h->SetElementGeneration( h_data.myElementGeneration ); + if ( h->GetAddMultinormals() != h_data.myAddMultinormals ) h->SetAddMultinormals ( h_data.myAddMultinormals ); if ( h->GetSmoothNormals() != h_data.mySmoothNormals ) @@ -1950,8 +1970,9 @@ bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisD h_data.myInitialMemory = myAdvWidget->initialMemoryCheck->isChecked() ? myAdvWidget->initialMemorySpin->value() : -1; h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex(); - h_data.myBoundaryLayersInward = myBoundaryLayersInwardCheck->isChecked(); - h_data.myElemGenTetraDominant = myElemGenTetraDominantCheck->isChecked(); + h_data.myCollisionMode = myCollisionModeCombo->currentIndex(); + h_data.myBoundaryLayersGrowth = myBoundaryLayersGrowthCombo->currentIndex(); + h_data.myElementGeneration = myElementGenerationCombo->currentIndex(); h_data.myAddMultinormals = myAddMultinormalsCheck->isChecked(); h_data.mySmoothNormals = mySmoothNormalsCheck->isChecked(); diff --git a/src/GUI/HYBRIDPluginGUI_HypothesisCreator.h b/src/GUI/HYBRIDPluginGUI_HypothesisCreator.h index 55e230e..9014cbd 100644 --- a/src/GUI/HYBRIDPluginGUI_HypothesisCreator.h +++ b/src/GUI/HYBRIDPluginGUI_HypothesisCreator.h @@ -141,18 +141,22 @@ typedef std::set< TEnfMesh*, CompareEnfMeshes > TEnfMeshList; typedef struct { - bool myToMeshHoles,myToMakeGroupsOfDomains,myKeepFiles,myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint, + bool myToMeshHoles, myToMakeGroupsOfDomains, + myKeepFiles, myToCreateNewNodes, + myBoundaryRecovery, myFEMCorrection, + myRemoveInitialCentralPoint, myLogInStandardOutput, myRemoveLogOnSuccess; double myMaximumMemory,myInitialMemory; int myOptimizationLevel; + int myCollisionMode; + int myBoundaryLayersGrowth; + int myElementGeneration; QString myName,myWorkingDir,myTextOption; double myGradation; short myVerboseLevel; TEnfVertexList myEnforcedVertices; TEnfMeshList myEnforcedMeshes; - bool myBoundaryLayersInward, - myElemGenTetraDominant, - myAddMultinormals, + bool myAddMultinormals, mySmoothNormals; double myHeightFirstLayer, myBoundaryLayersProgression, @@ -223,8 +227,9 @@ private: QCheckBox* myToMeshHolesCheck; QCheckBox* myToMakeGroupsOfDomains; QComboBox* myOptimizationLevelCombo; - QCheckBox* myBoundaryLayersInwardCheck; - QCheckBox* myElemGenTetraDominantCheck; + QComboBox* myCollisionModeCombo; + QComboBox* myBoundaryLayersGrowthCombo; + QComboBox* myElementGenerationCombo; QCheckBox* myAddMultinormalsCheck; QCheckBox* mySmoothNormals; QWidget* myAdvGroup; diff --git a/src/GUI/HYBRIDPlugin_msg_en.ts b/src/GUI/HYBRIDPlugin_msg_en.ts index d9e22f3..08d3254 100644 --- a/src/GUI/HYBRIDPlugin_msg_en.ts +++ b/src/GUI/HYBRIDPlugin_msg_en.ts @@ -28,16 +28,28 @@ Hypothesis Construction - HYBRID_LAYERS_INWARD - Inward growth of boundary layers + HYBRID_BOUNDARY_LAYERS_GROWTH + Growth of boundary layers - HYBRID_LAYERS_Outward - Outward growth growth of boundary layers if deselected + HYBRID_LAYER_GROWTH_INWARD + Inward growth - HYBRID_TETRA_DOMINANT - Mesh with tetrahedra in the remaining volume + HYBRID_LAYER_GROWTH_OUTWARD + Outward growth + + + HYBRID_GENERATION_ELEMENT + Element type for mesh in the remaining volume + + + HYBRID_GENERATION_TETRA_DOMINANT + Tetrahedra dominant + + + HYBRID_GENERATION_HEXA_DOMINANT + Hexahedra dominant HYBRID_ADD_MULTINORMALS @@ -83,6 +95,18 @@ KEEP_WORKING_FILES Keep all working files + + COLLISION_MODE + Behavior in case of collision between layers + + + COLLISION_DECREASE + Decrease height of layers + + + COLLISION_STOP + Reduce number of layers locally + LEVEL_NONE None diff --git a/src/HYBRIDPlugin/HYBRIDPluginBuilder.py b/src/HYBRIDPlugin/HYBRIDPluginBuilder.py index b289070..4bf9d22 100644 --- a/src/HYBRIDPlugin/HYBRIDPluginBuilder.py +++ b/src/HYBRIDPlugin/HYBRIDPluginBuilder.py @@ -39,6 +39,15 @@ None_Optimization, Light_Optimization, Medium_Optimization, Strong_Optimization # V4.1 (partialy redefines V3.1). Issue 0020574 None_Optimization, Light_Optimization, Standard_Optimization, StandardPlus_Optimization, Strong_Optimization = 0,1,2,3,4 +# Collision Mode +Decrease_Collision_Mode, Stop_Collision_Mode = 0,1 + +# Boundary Layers growing inward or outward. +Layer_Growth_Inward, Layer_Growth_Outward = 0,1 + +# Mesh with element type Tetra Dominant or hexa Dominant in the remaining volume (outside layers). +Generation_Tetra_Dominant, Generation_Hexa_Dominant = 0,1 + #---------------------------- # Mesh algo type identifiers #---------------------------- @@ -124,18 +133,34 @@ class HYBRID_Algorithm(Mesh_Algorithm): pass """ + ## Set Collision Mode: + # @param mode Collision Mode, one of the following values + # - Decrease_Collision_Mode + # - Stop_Collision_Mode + # . + # Default is Decrease_Collision_Mode + def SetCollisionMode(self, mode): + self.Parameters().SetCollisionMode(mode) + pass + ## To mesh Boundary Layers growing inward or outward. - # Default is inward. - # @param inward boolean value - def SetBoundaryLayersInward(self, inward): - self.Parameters().SetBoundaryLayersInward(inward) + # @param mode, one of the following values + # - Layer_Growth_Inward + # - Layer_Growth_Outward + # . + # Default is Layer_Growth_Inward + def SetBoundaryLayersGrowth(self, mode): + self.Parameters().SetBoundaryLayersGrowth(mode) pass - ## To mesh with element type Tetra Dominant or hexa Dominant in the boundary layers. - # Default is Tetra Dominant. - # @param tetraDominant boolean value - def SetElemGenTetraDominant(self, tetraDominant); - self.Parameters().SetElemGenTetraDominant(tetraDominant) + ## To mesh with element type Tetra Dominant or hexa Dominant in the remaining volume (outside layers). + # @param mode, one of the following values + # - Generation_Tetra_Dominant + # - Generation_Hexa_Dominant + # . + # Default is Generation_Tetra_Dominant + def SetElementGeneration(self, mode); + self.Parameters().SetElementGeneration(mode) pass ## To mesh adding extra normals at opening ridges and corners. diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx index 9153b2b..da2e0ab 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_HYBRID.cxx @@ -3303,8 +3303,8 @@ bool HYBRIDPlugin_HYBRID::Compute(SMESH_Mesh& theMesh, TCollection_AsciiString cmd = TCollection_AsciiString((char*)HYBRIDPlugin_Hypothesis::CommandToRun( _hyp, false ).c_str()); cmd += TCollection_AsciiString(" --in ") + aGMFFileName; - if ( nbEnforcedVertices + nbEnforcedNodes) - cmd += TCollection_AsciiString(" --required_vertices ") + aGenericNameRequired; + //if ( nbEnforcedVertices + nbEnforcedNodes) + // cmd += TCollection_AsciiString(" --required_vertices ") + aGenericNameRequired; cmd += TCollection_AsciiString(" --out ") + aResultFileName; if ( !_logInStandardOutput ) cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx index 9fd8e6d..8fb9b63 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx @@ -46,8 +46,9 @@ HYBRIDPlugin_Hypothesis::HYBRIDPlugin_Hypothesis(int hypId, int studyId, SMESH_G myMaximumMemory(-1), myInitialMemory(-1), myOptimizationLevel(DefaultOptimizationLevel()), - myBoundaryLayersInward(DefaultBoundaryLayersInward()), - myElemGenTetraDominant(DefaultElemGenTetraDominant()), + myCollisionMode(DefaultCollisionMode()), + myBoundaryLayersGrowth(DefaultBoundaryLayersGrowth()), + myElementGeneration(DefaultElementGeneration()), myAddMultinormals(DefaultAddMultinormals()), mySmoothNormals(DefaultSmoothNormals()), myHeightFirstLayer(DefaultHeightFirstLayer()), @@ -198,59 +199,71 @@ void HYBRIDPlugin_Hypothesis::SetOptimizationLevel(OptimizationLevel level) //======================================================================= //function : GetOptimizationLevel //======================================================================= - HYBRIDPlugin_Hypothesis::OptimizationLevel HYBRIDPlugin_Hypothesis::GetOptimizationLevel() const { return (OptimizationLevel) myOptimizationLevel; } - //======================================================================= -//function : SetBoundaryLayersInward +//function : SetCollisionMode //======================================================================= - -void HYBRIDPlugin_Hypothesis::SetBoundaryLayersInward(bool toBoundaryLayersInward) +void HYBRIDPlugin_Hypothesis::SetCollisionMode(CollisionMode mode) { - if ( myBoundaryLayersInward != toBoundaryLayersInward ) { - myBoundaryLayersInward = toBoundaryLayersInward; + if ( myCollisionMode != mode ) { + myCollisionMode = mode; NotifySubMeshesHypothesisModification(); } } //======================================================================= -//function : GetBoundaryLayersInward +//function : GetCollisionMode //======================================================================= +HYBRIDPlugin_Hypothesis::CollisionMode HYBRIDPlugin_Hypothesis::GetCollisionMode() const +{ + return (CollisionMode) myCollisionMode; +} -bool HYBRIDPlugin_Hypothesis::GetBoundaryLayersInward() const +//======================================================================= +//function : SetBoundaryLayersGrowth +//======================================================================= +void HYBRIDPlugin_Hypothesis::SetBoundaryLayersGrowth(BoundaryLayersGrowth mode) { - return myBoundaryLayersInward; + if ( myBoundaryLayersGrowth != mode ) { + myBoundaryLayersGrowth = mode; + NotifySubMeshesHypothesisModification(); + } } //======================================================================= -//function : SetElemGenTetraDominant +//function : GetBoundaryLayersGrowth //======================================================================= +HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth HYBRIDPlugin_Hypothesis::GetBoundaryLayersGrowth() const +{ + return (BoundaryLayersGrowth) myBoundaryLayersGrowth; +} -void HYBRIDPlugin_Hypothesis::SetElemGenTetraDominant(bool toElemGenTetraDominant) +//======================================================================= +//function : SetElementGeneration +//======================================================================= +void HYBRIDPlugin_Hypothesis::SetElementGeneration(ElementGeneration mode) { - if ( myElemGenTetraDominant != toElemGenTetraDominant ) { - myElemGenTetraDominant = toElemGenTetraDominant; + if ( myElementGeneration != mode ) { + myElementGeneration = mode; NotifySubMeshesHypothesisModification(); } } //======================================================================= -//function : GetElemGenTetraDominant +//function : GetElementGeneration //======================================================================= - -bool HYBRIDPlugin_Hypothesis::GetElemGenTetraDominant() const +HYBRIDPlugin_Hypothesis::ElementGeneration HYBRIDPlugin_Hypothesis::GetElementGeneration() const { - return myElemGenTetraDominant; + return (ElementGeneration) myElementGeneration; } //======================================================================= //function : SetAddMultinormals //======================================================================= - void HYBRIDPlugin_Hypothesis::SetAddMultinormals(bool toAddMultinormals) { if ( myAddMultinormals != toAddMultinormals ) { @@ -1068,9 +1081,32 @@ double HYBRIDPlugin_Hypothesis::DefaultInitialMemory() } //======================================================================= -//function : DefaultOptimizationLevel +//function : DefaultCollisionMode //======================================================================= +short HYBRIDPlugin_Hypothesis::DefaultCollisionMode() +{ + return Decrease; +} +//======================================================================= +//function : DefaultBoundaryLayersGrowth +//======================================================================= +short HYBRIDPlugin_Hypothesis::DefaultBoundaryLayersGrowth() +{ + return Layer_Growth_Inward; +} + +//======================================================================= +//function : DefaultElementGeneration +//======================================================================= +short HYBRIDPlugin_Hypothesis::DefaultElementGeneration() +{ + return Generation_Tetra_Dominant; +} + +//======================================================================= +//function : DefaultOptimizationLevel +//======================================================================= short HYBRIDPlugin_Hypothesis::DefaultOptimizationLevel() { return Medium; @@ -1189,22 +1225,6 @@ bool HYBRIDPlugin_Hypothesis::DefaultStandardOutputLog() // return HYBRIDPlugin_Hypothesis::TID2SizeMap(); // } -//======================================================================= -//function : DefaultBoundaryLayersInward -//======================================================================= -bool HYBRIDPlugin_Hypothesis::DefaultBoundaryLayersInward() -{ - return true; -} - -//======================================================================= -//function : DefaultElemGenTetraDominant -//======================================================================= -bool HYBRIDPlugin_Hypothesis::DefaultElemGenTetraDominant() -{ - return true; -} - //======================================================================= //function : DefaultAddMultinormals //======================================================================= @@ -1259,8 +1279,8 @@ short HYBRIDPlugin_Hypothesis::DefaultNbOfBoundaryLayers() std::ostream & HYBRIDPlugin_Hypothesis::SaveTo(std::ostream & save) { - save << (int) myBoundaryLayersInward << " "; - save << (int) myElemGenTetraDominant << " "; + save << (int) myBoundaryLayersGrowth << " "; + save << (int) myElementGeneration << " "; save << (int) myAddMultinormals << " "; save << (int) mySmoothNormals << " "; @@ -1361,13 +1381,13 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load) isOK = (load >> i); if (isOK) - myBoundaryLayersInward = (bool) i; + myBoundaryLayersGrowth = (short) i; else load.clear(ios::badbit | load.rdstate()); isOK = (load >> i); if (isOK) - myElemGenTetraDominant = (bool) i; + myElementGeneration = (short) i; else load.clear(ios::badbit | load.rdstate()); @@ -1701,39 +1721,120 @@ bool HYBRIDPlugin_Hypothesis::SetParametersByDefaults(const TDefaults& dflts, //================================================================================ std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis* hyp, - const bool hasShapeToMesh) + const bool hasShapeToMesh) { TCollection_AsciiString cmd = GetExeName().c_str(); // check if any option is overridden by hyp->myTextOption - bool p_v = hyp ? ( hyp->myTextOption.find("-v") == std::string::npos ) : true; - //bool p_i = hyp ? ( hyp->myTextOption.find("-i") == std::string::npos ) : true; - bool p_o = hyp ? ( hyp->myTextOption.find("-o") == std::string::npos ) : true; - bool p_blsi = hyp ? ( hyp->myTextOption.find("-blsi") == std::string::npos ) : true; - bool p_blsd = hyp ? ( hyp->myTextOption.find("-blsd") == std::string::npos ) : true; - bool p_hotfl = hyp ? ( hyp->myTextOption.find("-hotfl") == std::string::npos ) : true; - bool p_nobl = hyp ? ( hyp->myTextOption.find("-nobl") == std::string::npos ) : true; - bool p_blgp = hyp ? ( hyp->myTextOption.find("-blgp") == std::string::npos ) : true; - bool p_eg = hyp ? ( hyp->myTextOption.find("-eg") == std::string::npos ) : true; - bool p_am = hyp ? ( hyp->myTextOption.find("-am") == std::string::npos ) : true; - bool p_mat = hyp ? ( hyp->myTextOption.find("-mat") == std::string::npos ) : true; - bool p_sn = hyp ? ( hyp->myTextOption.find("-sn") == std::string::npos ) : true; - - // verbose mode - if ( p_v && hyp ) { - cmd += " -v "; + bool p_h = ( hyp->myTextOption.find("-h") != std::string::npos ); + bool p_v = ( hyp->myTextOption.find("-v ") != std::string::npos ); + //bool p_i = ( hyp->myTextOption.find("-i") != std::string::npos ); + //bool p_o = ( hyp->myTextOption.find("-o") != std::string::npos ); + bool p_mnot = ( hyp->myTextOption.find("--max_number_of_threads ") != std::string::npos ); + bool p_blsi = ( hyp->myTextOption.find("--boundary_layers_surface_ids ") != std::string::npos ); + bool p_blii = ( hyp->myTextOption.find("--boundary_layers_imprint_ids ") != std::string::npos ); + bool p_blsd = ( hyp->myTextOption.find("--boundary_layers_subdomain_direction ") != std::string::npos ); + bool p_hotfl = ( hyp->myTextOption.find("--height_of_the_first_layer ") != std::string::npos ); + bool p_nobl = ( hyp->myTextOption.find("--number_of_boundary_layers ") != std::string::npos ); + bool p_blgp = ( hyp->myTextOption.find("--boundary_layers_geometric_progression ") != std::string::npos ); + bool p_eg = ( hyp->myTextOption.find("--element_generation ") != std::string::npos ); + bool p_cm = ( hyp->myTextOption.find("--collision_mode ") != std::string::npos ); + bool p_am = ( hyp->myTextOption.find("--add_multinormals ") != std::string::npos ); + bool p_mat = ( hyp->myTextOption.find("--multinormals_angle_threshold ") != std::string::npos ); + bool p_sn = ( hyp->myTextOption.find("--smooth_normals ") != std::string::npos ); + + //help mode + if ( p_h ) { + cmd += " --help "; +#ifdef WIN32 + cmd += " < NUL"; +#endif + std::cout << "!!!!! CommandToRun help only !!!! " << cmd.ToCString() << std::endl; + return cmd.ToCString(); + } + + if ( !p_v && hyp ) { + cmd += " --verbose "; cmd += hyp->myVerboseLevel; } - // options as text - if ( hyp && !hyp->myTextOption.empty() ) { - cmd += " "; - cmd += (char*) hyp->myTextOption.c_str(); + if ( !p_mnot && hyp ) { + cmd += " --max_number_of_threads "; + cmd += 8; //TODO getenv NB CPU } - + + //if ( !p_blsi && hyp ) { + // cmd += " --boundary_layers_surface_ids "; + // cmd += 0; //TODO hyp->my; + //} + + //if ( !p_blii && hyp ) { + // cmd += " --boundary_layers_imprint_ids "; + // cmd += 0; //TODO hyp->my; + //} + + if ( !p_blsd && hyp ) { + if ( hyp->myBoundaryLayersGrowth >= 0 && hyp->myBoundaryLayersGrowth <= 1 ) { + const char* value[] = { "1" , "-1" }; + cmd += " --boundary_layers_subdomain_direction "; + cmd += value[ hyp->myBoundaryLayersGrowth ]; + } + } + + if ( !p_hotfl && hyp ) { + cmd += " --height_of_the_first_layer "; + cmd += hyp->myHeightFirstLayer; + } + + if ( !p_nobl && hyp ) { + cmd += " --number_of_boundary_layers "; + cmd += hyp->myNbOfBoundaryLayers; + } + + if ( !p_blgp && hyp ) { + cmd += " --boundary_layers_geometric_progression "; + cmd += hyp->myBoundaryLayersProgression; + } + + if ( !p_eg && hyp ) { + if ( hyp->myElementGeneration >= 0 && hyp->myElementGeneration <= 1 ) { + const char* value[] = { "tetra-dominant" , "hexa-dominant" }; + cmd += " --element_generation "; + cmd += value[ hyp->myElementGeneration ]; + } + } + + if ( !p_cm && hyp ) { + if ( hyp->myCollisionMode >= 0 && hyp->myCollisionMode <= 1 ) { + const char* value[] = { "decrease" , "stop" }; + cmd += " --collision_mode "; + cmd += value[ hyp->myCollisionMode ]; + } + } + + if ( !p_am && hyp ) { + int res = hyp->myAddMultinormals ? 0 : 1 ; + const char* value[] = { "yes" , "no" }; + cmd += " --add_multinormals "; + cmd += value[ res ]; + } + + if ( !p_mat && hyp ) { + cmd += " --multinormals_angle_threshold "; + cmd += hyp->myMultinormalsAngle; + } + + if ( !p_sn && hyp ) { + int res = hyp->mySmoothNormals ? 0 : 1 ; + const char* value[] = { "yes" , "no" }; + cmd += " --smooth_normals "; + cmd += value[ res ]; + } + #ifdef WIN32 cmd += " < NUL"; #endif - + //std::cout << "!!!!!CommandToRun end " << cmd.ToCString() << std::endl; + return cmd.ToCString(); } diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx index 0580024..7a6b5c1 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx @@ -149,18 +149,24 @@ public: void SetOptimizationLevel(OptimizationLevel level); OptimizationLevel GetOptimizationLevel() const; - /*! - * To mesh Boundary Layers growing inward or outward. - * Default is inward. - */ - void SetBoundaryLayersInward(bool toBoundaryLayersInward); - bool GetBoundaryLayersInward() const; - /*! - * To mesh with element type Tetra Dominant or hexa Dominant in the boundary layers. - * Default is Tetra Dominant. - */ - void SetElemGenTetraDominant(bool toElemGenTetraDominant); - bool GetElemGenTetraDominant() const; + /*! + * Collision Mode: 0-decrease, 1-stop. Default is decrease + */ + enum CollisionMode { Decrease = 0, Stop }; + void SetCollisionMode(CollisionMode level); + CollisionMode GetCollisionMode() const; + /*! + * BoundaryLayersGrowth: 0-Layer_Growth_Inward, 1-Layer_Growth_Outward. Default is Layer_Growth_Inward + */ + enum BoundaryLayersGrowth { Layer_Growth_Inward = 0, Layer_Growth_Outward }; + void SetBoundaryLayersGrowth(BoundaryLayersGrowth level); + BoundaryLayersGrowth GetBoundaryLayersGrowth() const; + /*! + * ElementGeneration: 0-Generation_Tetra_Dominant, 1-Generation_Hexa_Dominant. Default is Generation_Tetra_Dominant + */ + enum ElementGeneration { Generation_Tetra_Dominant = 0, Generation_Hexa_Dominant }; + void SetElementGeneration(ElementGeneration level); + ElementGeneration GetElementGeneration() const; /*! * To mesh adding extra normals at opening ridges and corners. * Default is no. @@ -342,6 +348,9 @@ public: static double DefaultMaximumMemory(); static double DefaultInitialMemory(); static short DefaultOptimizationLevel(); + static short DefaultCollisionMode(); + static short DefaultBoundaryLayersGrowth(); + static short DefaultElementGeneration(); static std::string DefaultWorkingDirectory(); static bool DefaultKeepFiles(); static short DefaultVerboseLevel(); @@ -352,8 +361,6 @@ public: static bool DefaultStandardOutputLog(); static bool DefaultRemoveLogOnSuccess(); static double DefaultGradation(); - static bool DefaultBoundaryLayersInward(); - static bool DefaultElemGenTetraDominant(); static bool DefaultAddMultinormals(); static bool DefaultSmoothNormals(); static short DefaultNbOfBoundaryLayers(); @@ -400,6 +407,9 @@ private: double myMaximumMemory; double myInitialMemory; short myOptimizationLevel; + short myCollisionMode; + short myBoundaryLayersGrowth; + short myElementGeneration; bool myKeepFiles; std::string myWorkingDirectory; short myVerboseLevel; @@ -412,8 +422,6 @@ private: std::string myTextOption; double myGradation; - bool myBoundaryLayersInward; - bool myElemGenTetraDominant; bool myAddMultinormals; bool mySmoothNormals; double myHeightFirstLayer; diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx index 0a8cb7a..47838aa 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx @@ -185,6 +185,33 @@ CORBA::Short HYBRIDPlugin_Hypothesis_i::GetOptimizationLevel() return this->GetImpl()->GetOptimizationLevel(); } + +//======================================================================= +//function : SetCollisionMode +//======================================================================= +void HYBRIDPlugin_Hypothesis_i::SetCollisionMode(CORBA::Short level) + throw ( SALOME::SALOME_Exception ) +{ + ::HYBRIDPlugin_Hypothesis::CollisionMode l = + (::HYBRIDPlugin_Hypothesis::CollisionMode) level; + if ( l < ::HYBRIDPlugin_Hypothesis::Decrease || + l > ::HYBRIDPlugin_Hypothesis::Stop ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid collision mode",SALOME::BAD_PARAM ); + + ASSERT(myBaseImpl); + this->GetImpl()->SetCollisionMode(l); + SMESH::TPythonDump() << _this() << ".SetCollisionMode( " << level << " )"; +} + +//======================================================================= +//function : GetCollisionMode +//======================================================================= +CORBA::Short HYBRIDPlugin_Hypothesis_i::GetCollisionMode() +{ + ASSERT(myBaseImpl); + return this->GetImpl()->GetCollisionMode(); +} + //======================================================================= //function : SetWorkingDirectory //======================================================================= @@ -426,41 +453,55 @@ CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetRemoveLogOnSuccess() } //======================================================================= -//function : SetBoundaryLayersInward +//function : SetBoundaryLayersGrowth //======================================================================= -void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersInward(CORBA::Boolean toBoundaryLayersInward) +void HYBRIDPlugin_Hypothesis_i::SetBoundaryLayersGrowth(CORBA::Short level) + throw ( SALOME::SALOME_Exception ) { + ::HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth l = + (::HYBRIDPlugin_Hypothesis::BoundaryLayersGrowth) level; + if ( l < ::HYBRIDPlugin_Hypothesis::Layer_Growth_Inward || + l > ::HYBRIDPlugin_Hypothesis::Layer_Growth_Outward ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid BoundaryLayersGrowth mode",SALOME::BAD_PARAM ); + ASSERT(myBaseImpl); - this->GetImpl()->SetBoundaryLayersInward(toBoundaryLayersInward); - SMESH::TPythonDump() << _this() << ".SetBoundaryLayersInward( " << toBoundaryLayersInward << " )"; + this->GetImpl()->SetBoundaryLayersGrowth(l); + SMESH::TPythonDump() << _this() << ".SetBoundaryLayersGrowth( " << level << " )"; } //======================================================================= -//function : GetBoundaryLayersInward +//function : GetBoundaryLayersGrowth //======================================================================= -CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersInward() +CORBA::Short HYBRIDPlugin_Hypothesis_i::GetBoundaryLayersGrowth() { ASSERT(myBaseImpl); - return this->GetImpl()->GetBoundaryLayersInward(); + return this->GetImpl()->GetBoundaryLayersGrowth(); } //======================================================================= -//function : SetElemGenTetraDominant +//function : SetElementGeneration //======================================================================= -void HYBRIDPlugin_Hypothesis_i::SetElemGenTetraDominant(CORBA::Boolean toElemGenTetraDominant) +void HYBRIDPlugin_Hypothesis_i::SetElementGeneration(CORBA::Short level) + throw ( SALOME::SALOME_Exception ) { + ::HYBRIDPlugin_Hypothesis::ElementGeneration l = + (::HYBRIDPlugin_Hypothesis::ElementGeneration) level; + if ( l < ::HYBRIDPlugin_Hypothesis::Generation_Tetra_Dominant || + l > ::HYBRIDPlugin_Hypothesis::Generation_Hexa_Dominant ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid ElementGeneration mode",SALOME::BAD_PARAM ); + ASSERT(myBaseImpl); - this->GetImpl()->SetElemGenTetraDominant(toElemGenTetraDominant); - SMESH::TPythonDump() << _this() << ".SetElemGenTetraDominant( " << toElemGenTetraDominant << " )"; + this->GetImpl()->SetElementGeneration(l); + SMESH::TPythonDump() << _this() << ".SetElementGeneration( " << level << " )"; } //======================================================================= -//function : GetElemGenTetraDominant +//function : GetElementGeneration //======================================================================= -CORBA::Boolean HYBRIDPlugin_Hypothesis_i::GetElemGenTetraDominant() +CORBA::Short HYBRIDPlugin_Hypothesis_i::GetElementGeneration() { ASSERT(myBaseImpl); - return this->GetImpl()->GetElemGenTetraDominant(); + return this->GetImpl()->GetElementGeneration(); } //======================================================================= diff --git a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.hxx b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.hxx index 9359d3b..b85f966 100644 --- a/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.hxx +++ b/src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.hxx @@ -78,6 +78,11 @@ class HYBRIDPLUGIN_EXPORT HYBRIDPlugin_Hypothesis_i: */ void SetOptimizationLevel(CORBA::Short level) throw ( SALOME::SALOME_Exception ); CORBA::Short GetOptimizationLevel(); + /*! + * Collision Mode: 0-decrease, 1-stop. Default is decrease + */ + void SetCollisionMode(CORBA::Short mode) throw ( SALOME::SALOME_Exception ); + CORBA::Short GetCollisionMode(); /*! * Path to working directory */ @@ -145,11 +150,11 @@ class HYBRIDPLUGIN_EXPORT HYBRIDPlugin_Hypothesis_i: void SetRemoveLogOnSuccess(CORBA::Boolean removeLogOnSuccess); CORBA::Boolean GetRemoveLogOnSuccess(); - void SetBoundaryLayersInward(CORBA::Boolean toBoundaryLayersInward); - CORBA::Boolean GetBoundaryLayersInward(); + void SetBoundaryLayersGrowth(CORBA::Short mode) throw ( SALOME::SALOME_Exception ); + CORBA::Short GetBoundaryLayersGrowth(); - void SetElemGenTetraDominant(CORBA::Boolean toElemGenTetraDominant); - CORBA::Boolean GetElemGenTetraDominant(); + void SetElementGeneration(CORBA::Short mode) throw ( SALOME::SALOME_Exception ); + CORBA::Short GetElementGeneration(); void SetAddMultinormals(CORBA::Boolean toAddMultinormals); CORBA::Boolean GetAddMultinormals(); -- 2.39.2