mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-11-12 00:29:17 +05:00
022501: [CEA 1076] Impossible to mesh at its position a translated without copy shape if the shape has already been meshed
This commit is contained in:
parent
dc749f7053
commit
be0348c630
@ -50,13 +50,16 @@ class SMDS_MeshVolume ;
|
||||
class SMDS_Mesh0DElement;
|
||||
class SMDS_BallElement;
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include <map>
|
||||
|
||||
/*
|
||||
* Using of native hash_map isn't portable and don't work on WIN32 platform.
|
||||
* So this functionality implement on new NCollection_DataMap technology
|
||||
*/
|
||||
#include <NCollection_DataMap.hxx>
|
||||
#include "SMESHDS_DataMapOfShape.hxx"
|
||||
typedef std::list<const SMESHDS_Hypothesis*> THypList;
|
||||
typedef NCollection_DataMap< TopoDS_Shape, THypList, SMESHDS_Hasher > ShapeToHypothesis;
|
||||
|
||||
class SMESHDS_GroupBase;
|
||||
class DownIdType;
|
||||
@ -570,8 +573,11 @@ public:
|
||||
bool HasHypothesis(const TopoDS_Shape & S);
|
||||
const std::list<const SMESHDS_Hypothesis*>& GetHypothesis(const TopoDS_Shape & S) const;
|
||||
bool IsUsedHypothesis(const SMESHDS_Hypothesis * H) const;
|
||||
const ShapeToHypothesis & GetHypotheses() const { return myShapeToHypothesis; }
|
||||
|
||||
SMESHDS_Script * GetScript();
|
||||
void ClearScript();
|
||||
|
||||
int ShapeToIndex(const TopoDS_Shape & aShape) const;
|
||||
const TopoDS_Shape& IndexToShape(int ShapeIndex) const;
|
||||
int MaxShapeIndex() const { return myIndexToShape.Extent(); }
|
||||
@ -604,10 +610,6 @@ private:
|
||||
it->second->AddNode( aNode ); // add aNode to submesh
|
||||
}
|
||||
|
||||
typedef std::list<const SMESHDS_Hypothesis*> THypList;
|
||||
|
||||
typedef NCollection_DataMap< TopoDS_Shape, THypList, SMESHDS_Hasher > ShapeToHypothesis;
|
||||
|
||||
ShapeToHypothesis myShapeToHypothesis;
|
||||
|
||||
int myMeshID, myPersistentID;
|
||||
|
@ -640,7 +640,7 @@ void SMESH_Gen_i::setCurrentStudy( SALOMEDS::Study_ptr theStudy,
|
||||
SALOMEDS::SObject_wrap so = anIter->Value();
|
||||
CORBA::Object_var ior = SObjectToObject( so );
|
||||
if ( SMESH_Mesh_i* mesh = SMESH::DownCast<SMESH_Mesh_i*>( ior ))
|
||||
mesh->CheckGeomGroupModif();
|
||||
mesh->CheckGeomModif();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1742,7 +1742,7 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
|
||||
ASSERT( meshServant );
|
||||
if ( meshServant ) {
|
||||
// NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation"
|
||||
meshServant->CheckGeomGroupModif();
|
||||
meshServant->CheckGeomModif();
|
||||
// get local TopoDS_Shape
|
||||
TopoDS_Shape myLocShape;
|
||||
if(theMesh->HasShapeToMesh())
|
||||
@ -1824,7 +1824,7 @@ SMESH::MeshPreviewStruct* SMESH_Gen_i::Precompute( SMESH::SMESH_Mesh_ptr theMesh
|
||||
ASSERT( meshServant );
|
||||
if ( meshServant ) {
|
||||
// NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation"
|
||||
meshServant->CheckGeomGroupModif();
|
||||
meshServant->CheckGeomModif();
|
||||
// get local TopoDS_Shape
|
||||
TopoDS_Shape myLocShape;
|
||||
if(theMesh->HasShapeToMesh())
|
||||
@ -2020,7 +2020,7 @@ SMESH::long_array* SMESH_Gen_i::Evaluate(SMESH::SMESH_Mesh_ptr theMesh,
|
||||
ASSERT( meshServant );
|
||||
if ( meshServant ) {
|
||||
// NPAL16168: "geometrical group edition from a submesh don't modifiy mesh computation"
|
||||
meshServant->CheckGeomGroupModif();
|
||||
meshServant->CheckGeomModif();
|
||||
// get local TopoDS_Shape
|
||||
TopoDS_Shape myLocShape;
|
||||
if(theMesh->HasShapeToMesh())
|
||||
|
@ -125,6 +125,7 @@ SMESH_Mesh_i::SMESH_Mesh_i( PortableServer::POA_ptr thePOA,
|
||||
_editor = NULL;
|
||||
_previewEditor = NULL;
|
||||
_preMeshInfo = NULL;
|
||||
_mainShapeTick = 0;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
@ -198,6 +199,7 @@ void SMESH_Mesh_i::SetShape( GEOM::GEOM_Object_ptr theShapeObject )
|
||||
// to track changes of GEOM groups
|
||||
SMESH::SMESH_Mesh_var mesh = _this();
|
||||
addGeomGroupData( theShapeObject, mesh );
|
||||
_mainShapeTick = theShapeObject->GetTick();
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
@ -280,7 +282,7 @@ void SMESH_Mesh_i::Clear() throw (SALOME::SALOME_Exception)
|
||||
|
||||
try {
|
||||
_impl->Clear();
|
||||
CheckGeomGroupModif(); // issue 20145
|
||||
//CheckGeomGroupModif(); // issue 20145
|
||||
}
|
||||
catch(SALOME_Exception & S_ex) {
|
||||
THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM);
|
||||
@ -1780,22 +1782,152 @@ TopoDS_Shape SMESH_Mesh_i::newGroupShape( TGeomGroupData & groupData)
|
||||
|
||||
namespace
|
||||
{
|
||||
//=============================================================================
|
||||
//-----------------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Storage of shape and index used in CheckGeomGroupModif()
|
||||
*/
|
||||
//=============================================================================
|
||||
struct TIndexedShape
|
||||
{
|
||||
int _index;
|
||||
TopoDS_Shape _shape;
|
||||
TIndexedShape( int i, const TopoDS_Shape& s ):_index(i), _shape(s) {}
|
||||
};
|
||||
//-----------------------------------------------------------------------------
|
||||
/*!
|
||||
* \brief Data to re-create a group on geometry
|
||||
*/
|
||||
struct TGroupOnGeomData
|
||||
{
|
||||
int _oldID;
|
||||
int _shapeID;
|
||||
SMDSAbs_ElementType _type;
|
||||
std::string _name;
|
||||
Quantity_Color _color;
|
||||
};
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* \brief Update data if geometry changes
|
||||
*
|
||||
* Issue 0022501
|
||||
*/
|
||||
//=============================================================================
|
||||
|
||||
void SMESH_Mesh_i::CheckGeomModif()
|
||||
{
|
||||
if ( !_impl->HasShapeToMesh() ) return;
|
||||
|
||||
SALOMEDS::Study_var study = _gen_i->GetCurrentStudy();
|
||||
if ( study->_is_nil() ) return;
|
||||
|
||||
GEOM::GEOM_Object_var mainGO = _gen_i->ShapeToGeomObject( _impl->GetShapeToMesh() );
|
||||
if ( mainGO->_is_nil() ) return;
|
||||
|
||||
if ( mainGO->GetType() == GEOM_GROUP )
|
||||
{
|
||||
CheckGeomGroupModif();
|
||||
return;
|
||||
}
|
||||
if ( mainGO->GetTick() == _mainShapeTick )
|
||||
return;
|
||||
|
||||
GEOM_Client* geomClient = _gen_i->GetShapeReader();
|
||||
if ( !geomClient ) return;
|
||||
GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine();
|
||||
if ( geomGen->_is_nil() ) return;
|
||||
|
||||
CORBA::String_var ior = geomGen->GetStringFromIOR( mainGO );
|
||||
geomClient->RemoveShapeFromBuffer( ior.in() );
|
||||
|
||||
// Update data taking into account that
|
||||
// all sub-shapes change but IDs of sub-shapes remain
|
||||
|
||||
_impl->Clear();
|
||||
TopoDS_Shape newShape = _gen_i->GeomObjectToShape( mainGO );
|
||||
if ( newShape.IsNull() )
|
||||
return;
|
||||
|
||||
_mainShapeTick = mainGO->GetTick();
|
||||
|
||||
SMESHDS_Mesh * meshDS = _impl->GetMeshDS();
|
||||
|
||||
// store data of groups on geometry
|
||||
vector< TGroupOnGeomData > groupsData;
|
||||
const set<SMESHDS_GroupBase*>& groups = meshDS->GetGroups();
|
||||
groupsData.reserve( groups.size() );
|
||||
set<SMESHDS_GroupBase*>::const_iterator g = groups.begin();
|
||||
for ( ; g != groups.end(); ++g )
|
||||
if ( const SMESHDS_GroupOnGeom* group = dynamic_cast< SMESHDS_GroupOnGeom* >( *g ))
|
||||
{
|
||||
TGroupOnGeomData data;
|
||||
data._oldID = group->GetID();
|
||||
data._shapeID = meshDS->ShapeToIndex( group->GetShape() );
|
||||
data._type = group->GetType();
|
||||
data._name = group->GetStoreName();
|
||||
data._color = group->GetColor();
|
||||
groupsData.push_back( data );
|
||||
}
|
||||
// store assigned hypotheses
|
||||
vector< pair< int, THypList > > ids2Hyps;
|
||||
const ShapeToHypothesis & hyps = meshDS->GetHypotheses();
|
||||
for ( ShapeToHypothesis::Iterator s2hyps( hyps ); s2hyps.More(); s2hyps.Next() )
|
||||
{
|
||||
const TopoDS_Shape& s = s2hyps.Key();
|
||||
const THypList& hyps = s2hyps.ChangeValue();
|
||||
ids2Hyps.push_back( make_pair( meshDS->ShapeToIndex( s ), hyps ));
|
||||
}
|
||||
|
||||
// change shape to mesh
|
||||
_impl->ShapeToMesh( TopoDS_Shape() );
|
||||
_impl->ShapeToMesh( newShape );
|
||||
|
||||
// re-assign hypotheses
|
||||
for ( size_t i = 0; i < ids2Hyps.size(); ++i )
|
||||
{
|
||||
const TopoDS_Shape& s = meshDS->IndexToShape( ids2Hyps[i].first );
|
||||
const THypList& hyps = ids2Hyps[i].second;
|
||||
THypList::const_iterator h = hyps.begin();
|
||||
for ( ; h != hyps.end(); ++h )
|
||||
_impl->AddHypothesis( s, (*h)->GetID() );
|
||||
}
|
||||
|
||||
// restore groups
|
||||
for ( size_t i = 0; i < groupsData.size(); ++i )
|
||||
{
|
||||
const TGroupOnGeomData& data = groupsData[i];
|
||||
|
||||
map<int, SMESH::SMESH_GroupBase_ptr>::iterator i2g = _mapGroups.find( data._oldID );
|
||||
if ( i2g == _mapGroups.end() ) continue;
|
||||
|
||||
SMESH_GroupBase_i* gr_i = SMESH::DownCast<SMESH_GroupBase_i*>( i2g->second );
|
||||
if ( !gr_i ) continue;
|
||||
|
||||
int id;
|
||||
SMESH_Group* g = _impl->AddGroup( data._type, data._name.c_str(), id,
|
||||
meshDS->IndexToShape( data._shapeID ));
|
||||
if ( !g )
|
||||
{
|
||||
_mapGroups.erase( i2g );
|
||||
}
|
||||
else
|
||||
{
|
||||
gr_i->changeLocalId( id );
|
||||
g->GetGroupDS()->SetColor( data._color );
|
||||
}
|
||||
}
|
||||
|
||||
// update _mapSubMesh
|
||||
map<int, ::SMESH_subMesh*>::iterator i_sm = _mapSubMesh.begin();
|
||||
for ( ; i_sm != _mapSubMesh.end(); ++i_sm )
|
||||
i_sm->second = _impl->GetSubMesh( meshDS->IndexToShape( i_sm->first ));
|
||||
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* \brief Update objects depending on changed geom groups
|
||||
*
|
||||
*
|
||||
* NPAL16168: geometrical group edition from a submesh don't modifiy mesh computation
|
||||
* issue 0020210: Update of a smesh group after modification of the associated geom group
|
||||
*/
|
||||
|
@ -440,6 +440,12 @@ public:
|
||||
|
||||
void checkMeshLoaded();
|
||||
|
||||
/*!
|
||||
* \brief Update data if geometry changes
|
||||
*
|
||||
* Issue 0022501
|
||||
*/
|
||||
void CheckGeomModif();
|
||||
/*!
|
||||
* \brief Update hypotheses assigned to geom groups if the latter change
|
||||
*
|
||||
@ -702,6 +708,7 @@ private:
|
||||
CORBA::Object_var _smeshObject; // SMESH object depending on GEOM group
|
||||
};
|
||||
std::list<TGeomGroupData> _geomGroupData;
|
||||
int _mainShapeTick; // to track modifications of the meshed shape
|
||||
|
||||
/*!
|
||||
* Remember GEOM group data
|
||||
|
Loading…
Reference in New Issue
Block a user