-// 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()
{
typedef std::map< std::string, std::string > TStr2StrMap;
typedef std::map< std::string, std::set< std::string > > TStr2StrSetMap;
+ //typedef std::map< std::set<int>, int > TIdSet2IndexMap;
//================================================================================
/*!
TStr2StrMap myOld2NewEntryMap; // map of study entries
+ //GEOM::ListOfGO_var mySubshapes; // sub-shapes existing in the new geometry
+ //TIdSet2IndexMap myIds2SubshapeIndex; // to find an existing sub-shape
+
bool myGIPMapDone;
GEOM::ListOfListOfLong_var myGIPMap; // filled by GetInPlaceMap()
if ( 0 < oldID && oldID < (int)myGIPMap->length() )
{
if ( myGIPMap[ oldID ].length() == 1 )
+ {
newID = myGIPMap[ oldID ][ 0 ];
+ }
+ else if ( myGIPMap[ oldID ].length() > 1 &&
+ getShapeType( mySrcMesh_i, oldID ) == TopAbs_VERTEX )
+ {
+ // select a meshed VERTEX
+ SMESH_subMesh* newSM;
+ for ( CORBA::ULong i = 0; i < myGIPMap[ oldID ].length() && !newID; ++i )
+ if (( newSM = myNewMesh_i->GetImpl().GetSubMeshContaining( myGIPMap[ oldID ][ i ] )) &&
+ ( !newSM->IsEmpty() ))
+ newID = myGIPMap[ oldID ][ i ];
+ }
}
return newID;
}
seq[ seq->length() - 1 ] = item;
}
}
-}
+} // namespace // utils for CopyMeshWithGeom()
//================================================================================
/*!
* \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
*/
//================================================================================
SMESH_Mesh_i* srcMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSourceMesh );
SMESH_Mesh_i* newMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theNewMesh );
+ srcMesh_i->Load();
ShapeMapper shapeMapper( srcMesh_i, newMesh_i, this );
// copy mesh elements, keeping IDs
+ SMESHDS_Mesh* newMeshDS = newMesh_i->GetImpl().GetMeshDS();
if ( theToCopyElements && theSourceMesh->NbNodes() > 0 )
{
- SMESHDS_Mesh* newMeshDS = newMesh_i->GetImpl().GetMeshDS();
::SMESH_MeshEditor editor( &newMesh_i->GetImpl() );
::SMESH_MeshEditor::ElemFeatures elemData;
if ( SMESH_subMesh* newSM = newMesh_i->GetImpl().GetSubMeshContaining( newID ))
newSM->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE );
}
+
+ newMeshDS->Modified();
}
SALOME::GenericObj_wrap< SMESH::FilterManager > filterMgr = CreateFilterManager();
SMESH::ListOfGroups_var groups = theSourceMesh->GetGroups();
- CORBA::ULong nbGroups = groups->length(), nbAddedGroups = 0;
+ CORBA::ULong nbGroups = theToCopyGroups ? groups->length() : 0, nbAddedGroups = 0;
for ( CORBA::ULong i = 0; i < nbGroups + nbAddedGroups; ++i )
{
SMESH::SMESH_Group_var stdlGroup = SMESH::SMESH_Group::_narrow ( groups[ i ]);
if ( !stdlGroup->_is_nil() )
{
- if ( theToCopyElements )
+ if ( newMeshDS->GetMeshInfo().NbElements( SMDSAbs_ElementType( elemType )) > 0 )
{
SMESH::long_array_var elemIDs = stdlGroup->GetIDs();
- stdlGroup = theNewMesh->CreateGroup( elemType, name );
- stdlGroup->Add( elemIDs );
- newGroup = SMESH::SMESH_GroupBase::_narrow( stdlGroup );
+ const bool isElem = ( elemType != SMESH::NODE );
+ CORBA::ULong iE = 0;
+ for ( ; iE < elemIDs->length(); ++iE ) // check if any element has been copied
+ if ( newMeshDS->GetElementType( elemIDs[ iE ], isElem ) != SMDSAbs_All )
+ break;
+ if ( iE < elemIDs->length() )
+ {
+ stdlGroup = theNewMesh->CreateGroup( elemType, name );
+ stdlGroup->Add( elemIDs );
+ newGroup = SMESH::SMESH_GroupBase::_narrow( stdlGroup );
+ }
}
}
else if ( !geomGroup->_is_nil() )
SALOMEDS::SObject_wrap newSO = ObjectToSObject( newGroup );
if ( !srcSO->_is_nil() )
{
- CORBA::String_var srcID, newID;
+ CORBA::String_var srcID, newID("");
srcID = srcSO->GetID();
if ( !newSO->_is_nil() )
newID = newSO->GetID();
} // loop on groups
+ newMeshDS->CompactMesh();
+
// set mesh name
if ( !theMeshName || !theMeshName[0] )
{
cmd+="\" \"";
cmd+=meshfile;
cmd+="\"";
+#ifdef WIN32
+ cmd+=" 2>NUL";
+#endif
system(cmd.ToCString());
// MED writer to be used by storage process
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 );
}