-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
void SMESH_Gen_i::CancelCompute( SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_ptr theShapeObject )
{
- SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( theMesh ).in() );
- ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
- TopoDS_Shape myLocShape;
- if(theMesh->HasShapeToMesh())
- myLocShape = GeomObjectToShape( theShapeObject );
- else
- myLocShape = SMESH_Mesh::PseudoShape();
- myGen.CancelCompute( myLocMesh, myLocShape);
+ if ( SMESH_Mesh_i* meshServant = dynamic_cast<SMESH_Mesh_i*>( GetServant( theMesh ).in() ))
+ {
+ ::SMESH_Mesh& myLocMesh = meshServant->GetImpl();
+ TopoDS_Shape myLocShape;
+ if(theMesh->HasShapeToMesh())
+ myLocShape = GeomObjectToShape( theShapeObject );
+ else
+ myLocShape = SMESH_Mesh::PseudoShape();
+ myGen.CancelCompute( myLocMesh, myLocShape);
+ }
}
//=============================================================================
SMESH_Gen_i::Concatenate(const SMESH::ListOfIDSources& theMeshesArray,
CORBA::Boolean theUniteIdenticalGroups,
CORBA::Boolean theMergeNodesAndElements,
- CORBA::Double theMergeTolerance)
+ CORBA::Double theMergeTolerance,
+ SMESH::SMESH_Mesh_ptr theMeshToAppendTo)
throw ( SALOME::SALOME_Exception )
{
return ConcatenateCommon(theMeshesArray,
theUniteIdenticalGroups,
theMergeNodesAndElements,
theMergeTolerance,
- false);
+ false,
+ theMeshToAppendTo);
}
//================================================================================
SMESH_Gen_i::ConcatenateWithGroups(const SMESH::ListOfIDSources& theMeshesArray,
CORBA::Boolean theUniteIdenticalGroups,
CORBA::Boolean theMergeNodesAndElements,
- CORBA::Double theMergeTolerance)
+ CORBA::Double theMergeTolerance,
+ SMESH::SMESH_Mesh_ptr theMeshToAppendTo)
throw ( SALOME::SALOME_Exception )
{
return ConcatenateCommon(theMeshesArray,
theUniteIdenticalGroups,
theMergeNodesAndElements,
theMergeTolerance,
- true);
+ true,
+ theMeshToAppendTo);
}
//================================================================================
CORBA::Boolean theUniteIdenticalGroups,
CORBA::Boolean theMergeNodesAndElements,
CORBA::Double theMergeTolerance,
- CORBA::Boolean theCommonGroups)
+ CORBA::Boolean theCommonGroups,
+ SMESH::SMESH_Mesh_ptr theMeshToAppendTo)
throw ( SALOME::SALOME_Exception )
{
std::unique_ptr< TPythonDump > pPythonDump( new TPythonDump );
TPythonDump& pythonDump = *pPythonDump; // prevent dump of called methods
- // create mesh
- SMESH::SMESH_Mesh_var newMesh = CreateEmptyMesh();
- SMESH_Mesh_i* newImpl = SMESH::DownCast<SMESH_Mesh_i*>( newMesh );
+ // create mesh if theMeshToAppendTo not provided
+ SMESH::SMESH_Mesh_var newMesh;
+ if ( CORBA::is_nil( theMeshToAppendTo ))
+ newMesh = CreateEmptyMesh();
+ else
+ newMesh = SMESH::SMESH_Mesh::_duplicate( theMeshToAppendTo );
+ SMESH_Mesh_i* newImpl = SMESH::DownCast<SMESH_Mesh_i*>( newMesh );
if ( !newImpl ) return newMesh._retn();
+ newImpl->Load();
::SMESH_Mesh& locMesh = newImpl->GetImpl();
SMESHDS_Mesh* newMeshDS = locMesh.GetMeshDS();
TGroupsMap groupsMap;
TListOfNewGroups listOfNewGroups;
+ if ( !CORBA::is_nil( theMeshToAppendTo ))
+ {
+ // fill groupsMap with existing groups
+ SMESH::ListOfGroups_var groups = theMeshToAppendTo->GetGroups();
+ for ( CORBA::ULong i = 0; i < groups->length(); ++i )
+ {
+ SMESH::SMESH_Group_var group = SMESH::SMESH_Group::_narrow( groups[ i ]);
+ if ( !group->_is_nil() )
+ {
+ CORBA::String_var name = group->GetName();
+ SMESH::ElementType type = group->GetType();
+ groupsMap[ TNameAndType( name.in(), type ) ].push_back( group );
+ }
+ }
+ }
+
::SMESH_MeshEditor newEditor( &locMesh );
::SMESH_MeshEditor::ElemFeatures elemType;
SMESH::SMESH_Mesh_var initMesh = theMeshesArray[i]->GetMesh();
SMESH_Mesh_i* initImpl = SMESH::DownCast<SMESH_Mesh_i*>( initMesh );
if ( !initImpl ) continue;
+ if ( initMesh->_is_equivalent( theMeshToAppendTo ))
+ continue;
initImpl->Load();
// assure that IDs increments by one during iteration
// Update Python script
pythonDump << newMesh << " = " << this
- << "." << ( theCommonGroups ? "ConcatenateWithGroups" : "Concatenate" ) << "("
+ << "." << ( theCommonGroups ? "ConcatenateWithGroups" : "Concatenate" ) << "( "
<< theMeshesArray << ", "
<< theUniteIdenticalGroups << ", "
<< theMergeNodesAndElements << ", "
- << TVar( theMergeTolerance ) << ")";
+ << TVar( theMergeTolerance ) << ", "
+ << theMeshToAppendTo << " )";
pPythonDump.reset(); // enable python dump from GetGroups()
* \param [out] invalidEntries - return study entries of objects whose
* counterparts are not found in the newGeometry, followed by entries
* of mesh sub-objects that are invalid because they depend on a not found
- * preceeding sub-shape
+ * preceding sub-shape
* \return CORBA::Boolean - is a success
*/
//================================================================================
CORBA::String_var objStr = GetORB()->object_to_string( grImpl->_this() );
int anId = myStudyContext->findId( string( objStr.in() ) );
char grpName[ 30 ];
- sprintf( grpName, "Group %d", anId );
+ sprintf( grpName, "Group %d %d", anId, grImpl->GetLocalID() );
SMESHDS_GroupBase* aGrpBaseDS = grImpl->GetGroupDS();
aGrpBaseDS->SetStoreName( grpName );
}
// get mesh old id
CORBA::String_var iorString = GetORB()->object_to_string( myNewMeshImpl->_this() );
int newId = myStudyContext->findId( iorString.in() );
- int id = myStudyContext->getOldId( newId );
+ int meshOldId = myStudyContext->getOldId( newId );
// try to find mesh data dataset
if ( aTopGroup->ExistInternalObject( "Has data" ) ) {
aDataset->ReadFromDisk( strHasData );
aDataset->CloseOnDisk();
if ( strcmp( strHasData, "1") == 0 ) {
- // read mesh data from MED file
- // myReader.SetMesh( mySMESHDSMesh );
- // myReader.SetMeshId( id );
- // myReader.Perform();
hasData = true;
}
delete [] strHasData;
// check if it is a group
if ( name_dataset.substr( 0, 5 ) == "Group" ) {
// --> get group id
- int subid = atoi( name_dataset.substr( 5 ).c_str() );
+ char * endptr;
+ int subid = strtol( name_dataset.data() + 5, &endptr, 10 );
if ( subid <= 0 )
continue;
+ int groupID = -1; // group local ID (also persistent)
+ if ( *endptr )
+ groupID = atoi( endptr + 1 );
aDataset = new HDFdataset( name_dataset.c_str(), aGroup );
aDataset->OpenOnDisk();
// Create group servant
SMESH::ElementType type = (SMESH::ElementType)(ii - GetNodeGroupsTag() + 1);
SMESH::SMESH_GroupBase_var aNewGroup = SMESH::SMESH_GroupBase::_duplicate
- ( myNewMeshImpl->createGroup( type, nameFromFile, aShape, predicate ) );
+ ( myNewMeshImpl->createGroup( type, nameFromFile, groupID, aShape, predicate ) );
delete [] nameFromFile;
// Obtain a SMESHDS_Group object
if ( aNewGroup->_is_nil() )
} // reading GROUPs
// instead of reading mesh data, we read only brief information of all
- // objects: mesh, groups, sub-meshes (issue 0021208 )
+ // objects: mesh, groups, sub-meshes (issue 0021208)
if ( hasData )
{
- SMESH_PreMeshInfo::LoadFromFile( myNewMeshImpl, id,
+ SMESH_PreMeshInfo::LoadFromFile( myNewMeshImpl, meshOldId,
meshfile.ToCString(), filename.ToCString(),
!isMultiFile );
}