// check the name
if ( strncmp( name, refName, refLen ) == 0 && // starts from refName;
isdigit( *( name + refLen )) && // refName is followed by a digit;
- strtol( name + refLen, &end, 10) && // there are only digits ...
+ strtol( name + refLen, &end, 10) >= 0 && // there are only digits ...
*end == '\0') // ... till a string end.
{
mesh->RemoveGroup( *id );
}
}
+//================================================================================
+/*!
+ * \brief Create the groups corresponding to domains
+ */
+//================================================================================
+
+static void makeDomainGroups( std::vector< std::vector< const SMDS_MeshElement* > >& elemsOfDomain,
+ SMESH_MesherHelper* theHelper)
+{
+ // int nbDomains = 0;
+ // for ( size_t i = 0; i < elemsOfDomain.size(); ++i )
+ // nbDomains += ( elemsOfDomain[i].size() > 0 );
+
+ // if ( nbDomains > 1 )
+ for ( size_t iDomain = 0; iDomain < elemsOfDomain.size(); ++iDomain )
+ {
+ std::vector< const SMDS_MeshElement* > & elems = elemsOfDomain[ iDomain ];
+ if ( elems.empty() ) continue;
+
+ // find existing groups
+ std::vector< SMESH_Group* > groupOfType( SMDSAbs_NbElementTypes, (SMESH_Group*)NULL );
+ const std::string domainName = ( SMESH_Comment( theDomainGroupNamePrefix ) << iDomain );
+ SMESH_Mesh::GroupIteratorPtr groupIt = theHelper->GetMesh()->GetGroups();
+ while ( groupIt->more() )
+ {
+ SMESH_Group* group = groupIt->next();
+ if ( domainName == group->GetName() &&
+ dynamic_cast< SMESHDS_Group* >( group->GetGroupDS()) )
+ groupOfType[ group->GetGroupDS()->GetType() ] = group;
+ }
+ // create and fill the groups
+ size_t iElem = 0;
+ int groupID;
+ do
+ {
+ SMESH_Group* group = groupOfType[ elems[ iElem ]->GetType() ];
+ if ( !group )
+ group = theHelper->GetMesh()->AddGroup( elems[ iElem ]->GetType(),
+ domainName.c_str(), groupID );
+ SMDS_MeshGroup& groupDS =
+ static_cast< SMESHDS_Group* >( group->GetGroupDS() )->SMDSGroup();
+
+ while ( iElem < elems.size() && groupDS.Add( elems[iElem] ))
+ ++iElem;
+
+ } while ( iElem < elems.size() );
+ }
+}
+
//=======================================================================
//function : readGMFFile
//purpose : read GMF file w/o geometry associated to mesh
// 0022172: [CEA 790] create the groups corresponding to domains
if ( toMakeGroupsOfDomains )
- {
- int nbDomains = 0;
- for ( size_t i = 0; i < elemsOfDomain.size(); ++i )
- nbDomains += ( elemsOfDomain[i].size() > 0 );
-
- if ( nbDomains > 1 )
- for ( size_t iDomain = 0; iDomain < elemsOfDomain.size(); ++iDomain )
- {
- std::vector< const SMDS_MeshElement* > & elems = elemsOfDomain[ iDomain ];
- if ( elems.empty() ) continue;
-
- // find existing groups
- std::vector< SMESH_Group* > groupOfType( SMDSAbs_NbElementTypes, (SMESH_Group*)NULL );
- const std::string domainName = ( SMESH_Comment( theDomainGroupNamePrefix ) << iDomain );
- SMESH_Mesh::GroupIteratorPtr groupIt = theHelper->GetMesh()->GetGroups();
- while ( groupIt->more() )
- {
- SMESH_Group* group = groupIt->next();
- if ( domainName == group->GetName() &&
- dynamic_cast< SMESHDS_Group* >( group->GetGroupDS()) )
- groupOfType[ group->GetGroupDS()->GetType() ] = group;
- }
- // create and fill the groups
- size_t iElem = 0;
- int groupID;
- do
- {
- SMESH_Group* group = groupOfType[ elems[ iElem ]->GetType() ];
- if ( !group )
- group = theHelper->GetMesh()->AddGroup( elems[ iElem ]->GetType(),
- domainName.c_str(), groupID );
- SMDS_MeshGroup& groupDS =
- static_cast< SMESHDS_Group* >( group->GetGroupDS() )->SMDSGroup();
-
- while ( iElem < elems.size() && groupDS.Add( elems[iElem] ))
- ++iElem;
-
- } while ( iElem < elems.size() );
- }
- }
+ makeDomainGroups( elemsOfDomain, theHelper );
#ifdef _DEBUG_
MESSAGE("Nb subdomains " << subdomainId2tetraId.size());
int nbEnforcedVertices,
int nbEnforcedNodes,
GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedEdges,
- GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles)
+ GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap & theEnforcedTriangles,
+ bool toMakeGroupsOfDomains)
{
MESSAGE("GHS3DPlugin_GHS3D::readResultFile()");
Kernel_Utils::Localizer loc;
if ( nbTriangle <= nbShape ) // no holes
toMeshHoles = true; // not avoid creating tetras in holes
+ // IMP 0022172: [CEA 790] create the groups corresponding to domains
+ std::vector< std::vector< const SMDS_MeshElement* > > elemsOfDomain( Max( nbTriangle, nbShape ));
+
// Associating the tetrahedrons to the shapes
shapeID = compoundID;
for (int iElem = 0; iElem < nbElems; iElem++) {
// tetras within holes depending on hypo option,
// so we first check if aTet is inside a hole and then create it
//aTet = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] );
+ ghs3dShapeID = 0; // domain ID
if ( nbTriangle > 1 ) {
shapeID = HOLE_ID; // negative shapeID means not to create tetras if !toMeshHoles
ghs3dShapeID = strtol(shapePtr, &shapePtr, 10) - IdShapeRef;
aTet = theHelper.AddVolume( node[1], node[0], node[2], node[3],
/*id=*/0, /*force3d=*/false);
theMeshDS->SetMeshElementOnShape( aTet, shapeID );
+ if ( toMakeGroupsOfDomains )
+ {
+ if ( int( elemsOfDomain.size() ) < ghs3dShapeID+1 )
+ elemsOfDomain.resize( ghs3dShapeID+1 );
+ elemsOfDomain[ ghs3dShapeID ].push_back( aTet );
+ }
}
#ifdef _DEBUG_
shapeIDs.insert( shapeID );
#endif
}
+ if ( toMakeGroupsOfDomains )
+ makeDomainGroups( elemsOfDomain, &theHelper );
// Add enforced elements
GHS3DPlugin_Hypothesis::TIDSortedElemGroupMap::const_iterator elemIt;
else {
bool toMeshHoles =
_hyp ? _hyp->GetToMeshHoles(true) : GHS3DPlugin_Hypothesis::DefaultMeshHoles();
+ const bool toMakeGroupsOfDomains = GHS3DPlugin_Hypothesis::GetToMakeGroupsOfDomains( _hyp );
helper.IsQuadraticSubMesh( theShape );
helper.SetElementsOnShape( false );
aGhs3dIdToNodeMap, aNodeId2NodeIndexMap,
toMeshHoles,
nbEnforcedVertices, nbEnforcedNodes,
- enforcedEdges, enforcedTriangles );
+ enforcedEdges, enforcedTriangles,
+ toMakeGroupsOfDomains );
// Ok = readGMFFile(
// #ifndef GMF_HAS_SUBDOMAIN_INFO
// _nbShape, tabShape, tabBox,
// aGhs3dIdToNodeMap, toMeshHoles,
// nbEnforcedVertices, nbEnforcedNodes);
+
+ removeEmptyGroupsOfDomains( helper.GetMesh(), /*notEmptyAsWell =*/ !toMakeGroupsOfDomains );
}
if ( !_keepFiles )
removeFile( aLogFileName );
- if ( _hyp && _hyp->GetToMakeGroupsOfDomains() )
- error( COMPERR_WARNING, "'toMakeGroupsOfDomains' is ignored since the mesh is on shape" );
+ // if ( _hyp && _hyp->GetToMakeGroupsOfDomains() )
+ // error( COMPERR_WARNING, "'toMakeGroupsOfDomains' is ignored since the mesh is on shape" );
}
else if ( OSD_File( aLogFileName ).Size() > 0 )
{
groupsToRemove, toMakeGroupsOfDomains);
updateMeshGroups(theHelper->GetMesh(), groupsToRemove);
- removeEmptyGroupsOfDomains( theHelper->GetMesh() );
+ removeEmptyGroupsOfDomains( theHelper->GetMesh(), /*notEmptyAsWell =*/ !toMakeGroupsOfDomains );
if ( Ok ) {
GHS3DPlugin_Hypothesis* that = (GHS3DPlugin_Hypothesis*)this->_hyp;
if ( !_keepFiles )
removeFile( aLogFileName );
- if ( !toMakeGroupsOfDomains && _hyp && _hyp->GetToMakeGroupsOfDomains() )
- error( COMPERR_WARNING, "'toMakeGroupsOfDomains' is ignored since 'toMeshHoles' is OFF." );
+ //if ( !toMakeGroupsOfDomains && _hyp && _hyp->GetToMakeGroupsOfDomains() )
+ //error( COMPERR_WARNING, "'toMakeGroupsOfDomains' is ignored since 'toMeshHoles' is OFF." );
}
else if ( OSD_File( aLogFileName ).Size() > 0 )
{
tab->setCurrentIndex( STD_TAB );
// connections
- connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
+ //connect( myToMeshHolesCheck, SIGNAL( toggled( bool ) ), this, SLOT( onToMeshHoles(bool)));
connect( myMaximumMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
connect( myInitialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
connect( myBoundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
void GHS3DPluginGUI_HypothesisCreator::onToMeshHoles(bool isOn)
{
- myToMakeGroupsOfDomains->setEnabled( isOn );
- if ( !isOn )
- myToMakeGroupsOfDomains->setChecked( false );
+ // myToMakeGroupsOfDomains->setEnabled( isOn );
+ // if ( !isOn )
+ // myToMakeGroupsOfDomains->setChecked( false );
}
void GHS3DPluginGUI_HypothesisCreator::onDirBtnClicked()
void GHS3DPluginGUI_HypothesisCreator::updateWidgets()
{
- myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
+ //myToMakeGroupsOfDomains->setEnabled( myToMeshHolesCheck->isChecked() );
myMaximumMemorySpin->setEnabled( myMaximumMemoryCheck->isChecked() );
myInitialMemoryCheck->setEnabled( !myBoundaryRecoveryCheck->isChecked() );
myInitialMemorySpin->setEnabled( myInitialMemoryCheck->isChecked() && !myBoundaryRecoveryCheck->isChecked() );
h_data.myName = isCreation() && data ? hypName() : "";
h_data.myToMeshHoles = h->GetToMeshHoles();
- h_data.myToMakeGroupsOfDomains = h->GetToMeshHoles() && h->GetToMakeGroupsOfDomains();
+ h_data.myToMakeGroupsOfDomains = /*h->GetToMeshHoles() &&*/ h->GetToMakeGroupsOfDomains();
h_data.myMaximumMemory = h->GetMaximumMemory();
h_data.myInitialMemory = h->GetInitialMemory();
h_data.myInitialMemory = h->GetInitialMemory();