From: akl Date: Wed, 7 Mar 2007 13:40:41 +0000 (+0000) Subject: IPAL15174 (Dump study works wrong for Concatenate): X-Git-Tag: V3_2_6pre2~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=170717dd40e51630e3b2d08e7314c55aa3b9b0f9;p=modules%2Fsmesh.git IPAL15174 (Dump study works wrong for Concatenate): fix of Problem 2 (there is no Concatenate command in file). --- diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index af22cd11f..b1a879f93 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -1173,6 +1173,9 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Concatenate(const SMESH::mesh_array& theMeshe // create mesh SMESH::SMESH_Mesh_var aNewMesh = CreateEmptyMesh(); + // to update Python script + TPythonDump aPythonDump; + if ( !aNewMesh->_is_nil() ) { SMESH_Mesh_i* aNewImpl = dynamic_cast( GetServant( aNewMesh ).in() ); if ( aNewImpl ) { @@ -1248,17 +1251,19 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Concatenate(const SMESH::mesh_array& theMeshe SMESH::SMESH_GroupBase_ptr aGroup; // 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++) { aGroup = aListOfGroups[i]; aListOfNewGroups.clear(); 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)); // convert a list of IDs - SMESH::long_array_var anInitIDs = aGroup->GetListOfID(); - SMESH::long_array_var anNewIDs = new SMESH::long_array(); + anInitIDs = aGroup->GetListOfID(); anNewIDs->length(anInitIDs->length()); if ( aGroupType == SMESH::NODE ) 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 if ( anIter == aGroupsMap.end() ) { // add a new group in the mesh - SMESH::SMESH_Group_var aNewGroup = - aNewImpl->CreateGroup(aGroupType, aGroupName); + aNewGroup = aNewImpl->CreateGroup(aGroupType, aGroupName); // add elements into new group aNewGroup->Add( anNewIDs ); @@ -1289,48 +1293,52 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::Concatenate(const SMESH::mesh_array& theMeshe else { // rename identical groups - SMESH::SMESH_Group_var aNewGroup = - aNewImpl->CreateGroup(aGroupType, aGroupName); + aNewGroup = aNewImpl->CreateGroup(aGroupType, aGroupName); aNewGroup->Add( anNewIDs ); TListOfNewGroups& aNewGroups = anIter->second; - - if (aNewGroups.size() == 1) - aNewGroups.front()->SetName( strcat(aNewGroup->GetName(), "_1")); - + string aNewGroupName; + if (aNewGroups.size() == 1) { + aNewGroupName = string(aGroupName) + "_1"; + aNewGroups.front()->SetName(aNewGroupName.c_str()); + } char aGroupNum[128]; 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); } - - } - } - - if (theMergeNodesAndElements) { - // merge nodes - set aMeshNodes; // no input nodes - SMESH_MeshEditor::TListOfListOfNodes aGroupsOfNodes; - aNewEditor.FindCoincidentNodes( aMeshNodes, theMergeTolerance, aGroupsOfNodes ); - aNewEditor.MergeNodes( aGroupsOfNodes ); - // merge elements - aNewEditor.MergeEqualElements(); + }//groups loop } } - }//meshes loop - - return aNewMesh._retn(); + + if (theMergeNodesAndElements) { + // merge nodes + set aMeshNodes; // no input nodes + SMESH_MeshEditor::TListOfListOfNodes aGroupsOfNodes; + aNewEditor.FindCoincidentNodes( aMeshNodes, theMergeTolerance, aGroupsOfNodes ); + aNewEditor.MergeNodes( aGroupsOfNodes ); + // merge elements + aNewEditor.MergeEqualElements(); + } } } + + // 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 SMESH::SMESH_Mesh::_nil(); - - - - - - + return aNewMesh._retn(); } //================================================================================