IPAL15174 (Dump study works wrong for Concatenate):

fix of Problem 2 (there is no Concatenate command in file).
This commit is contained in:
akl 2007-03-07 13:40:41 +00:00
parent 5dc951b4bf
commit 170717dd40

View File

@ -1173,6 +1173,9 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Concatenate(const SMESH::mesh_array& theMeshe
// create mesh // create mesh
SMESH::SMESH_Mesh_var aNewMesh = CreateEmptyMesh(); SMESH::SMESH_Mesh_var aNewMesh = CreateEmptyMesh();
// to update Python script
TPythonDump aPythonDump;
if ( !aNewMesh->_is_nil() ) { if ( !aNewMesh->_is_nil() ) {
SMESH_Mesh_i* aNewImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( aNewMesh ).in() ); SMESH_Mesh_i* aNewImpl = dynamic_cast<SMESH_Mesh_i*>( GetServant( aNewMesh ).in() );
if ( aNewImpl ) { if ( aNewImpl ) {
@ -1248,17 +1251,19 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Concatenate(const SMESH::mesh_array& theMeshe
SMESH::SMESH_GroupBase_ptr aGroup; SMESH::SMESH_GroupBase_ptr aGroup;
// loop on groups of mesh // loop on groups of mesh
SMESH::long_array_var anInitIDs = new SMESH::long_array();
SMESH::long_array_var anNewIDs = new SMESH::long_array();
SMESH::SMESH_Group_var aNewGroup;
for (int i = 0; i < aListOfGroups->length(); i++) { for (int i = 0; i < aListOfGroups->length(); i++) {
aGroup = aListOfGroups[i]; aGroup = aListOfGroups[i];
aListOfNewGroups.clear(); aListOfNewGroups.clear();
SMESH::ElementType aGroupType = aGroup->GetType(); SMESH::ElementType aGroupType = aGroup->GetType();
const char* aGroupName = aGroup->GetName(); CORBA::String_var aGroupName = aGroup->GetName();
TGroupsMap::iterator anIter = aGroupsMap.find(make_pair(aGroupName, aGroupType)); TGroupsMap::iterator anIter = aGroupsMap.find(make_pair(aGroupName, aGroupType));
// convert a list of IDs // convert a list of IDs
SMESH::long_array_var anInitIDs = aGroup->GetListOfID(); anInitIDs = aGroup->GetListOfID();
SMESH::long_array_var anNewIDs = new SMESH::long_array();
anNewIDs->length(anInitIDs->length()); anNewIDs->length(anInitIDs->length());
if ( aGroupType == SMESH::NODE ) if ( aGroupType == SMESH::NODE )
for (int j = 0; j < anInitIDs->length(); j++) { for (int j = 0; j < anInitIDs->length(); j++) {
@ -1272,8 +1277,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Concatenate(const SMESH::mesh_array& theMeshe
// check that current group name and type don't have identical ones in union mesh // check that current group name and type don't have identical ones in union mesh
if ( anIter == aGroupsMap.end() ) { if ( anIter == aGroupsMap.end() ) {
// add a new group in the mesh // add a new group in the mesh
SMESH::SMESH_Group_var aNewGroup = aNewGroup = aNewImpl->CreateGroup(aGroupType, aGroupName);
aNewImpl->CreateGroup(aGroupType, aGroupName);
// add elements into new group // add elements into new group
aNewGroup->Add( anNewIDs ); aNewGroup->Add( anNewIDs );
@ -1289,23 +1293,25 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Concatenate(const SMESH::mesh_array& theMeshe
else { else {
// rename identical groups // rename identical groups
SMESH::SMESH_Group_var aNewGroup = aNewGroup = aNewImpl->CreateGroup(aGroupType, aGroupName);
aNewImpl->CreateGroup(aGroupType, aGroupName);
aNewGroup->Add( anNewIDs ); aNewGroup->Add( anNewIDs );
TListOfNewGroups& aNewGroups = anIter->second; TListOfNewGroups& aNewGroups = anIter->second;
string aNewGroupName;
if (aNewGroups.size() == 1) if (aNewGroups.size() == 1) {
aNewGroups.front()->SetName( strcat(aNewGroup->GetName(), "_1")); aNewGroupName = string(aGroupName) + "_1";
aNewGroups.front()->SetName(aNewGroupName.c_str());
}
char aGroupNum[128]; char aGroupNum[128];
sprintf(aGroupNum, "%u", aNewGroups.size()+1); sprintf(aGroupNum, "%u", aNewGroups.size()+1);
aNewGroup->SetName( strcat( strcat(aNewGroup->GetName(), "_"), aGroupNum) ); aNewGroupName = string(aGroupName) + "_" + string(aGroupNum);
aNewGroup->SetName(aNewGroupName.c_str());
aNewGroups.push_back(aNewGroup); aNewGroups.push_back(aNewGroup);
} }
}//groups loop
} }
} }
}//meshes loop
if (theMergeNodesAndElements) { if (theMergeNodesAndElements) {
// merge nodes // merge nodes
@ -1317,20 +1323,22 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Concatenate(const SMESH::mesh_array& theMeshe
aNewEditor.MergeEqualElements(); aNewEditor.MergeEqualElements();
} }
} }
}
}//meshes loop // Update Python script
RemoveLastFromPythonScript( GetCurrentStudyID() );
aPythonDump << aNewMesh << " = " << this << ".Concatenate(";
aPythonDump << "[";
for ( int i = 0; i < theMeshesArray.length(); i++) {
if (i > 0) aPythonDump << ", ";
aPythonDump << theMeshesArray[i];
}
aPythonDump << "], ";
aPythonDump << theUniteIdenticalGroups << ", "
<< theMergeNodesAndElements << ", "
<< theMergeTolerance << ")";
return aNewMesh._retn(); return aNewMesh._retn();
}
}
return SMESH::SMESH_Mesh::_nil();
} }
//================================================================================ //================================================================================