mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-04-25 02:12:03 +05:00
PAL13639 (EDF PAL 317 : SMESH : Create "0D Hypothesis")
change EventListener implementation
This commit is contained in:
parent
fccd8b61f0
commit
03f7cb2bb9
@ -40,6 +40,7 @@
|
|||||||
#include "SMESH_Mesh.hxx"
|
#include "SMESH_Mesh.hxx"
|
||||||
#include "SMESH_MeshEditor.hxx"
|
#include "SMESH_MeshEditor.hxx"
|
||||||
#include "SMESH_subMesh.hxx"
|
#include "SMESH_subMesh.hxx"
|
||||||
|
#include "SMESH_subMeshEventListener.hxx"
|
||||||
#include "SMDS_EdgePosition.hxx"
|
#include "SMDS_EdgePosition.hxx"
|
||||||
|
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
@ -1128,7 +1129,7 @@ TopoDS_Shape StdMeshers_ProjectionUtils::OuterShape( const TopoDS_Face& face,
|
|||||||
|
|
||||||
//================================================================================
|
//================================================================================
|
||||||
/*!
|
/*!
|
||||||
* \brief Check that submeshis is computed and try to compute it if is not
|
* \brief Check that submesh is computed and try to compute it if is not
|
||||||
* \param sm - submesh to compute
|
* \param sm - submesh to compute
|
||||||
* \param iterationNb - int used to stop infinite recursive call
|
* \param iterationNb - int used to stop infinite recursive call
|
||||||
* \retval bool - true if computed
|
* \retval bool - true if computed
|
||||||
@ -1221,21 +1222,87 @@ int StdMeshers_ProjectionUtils::Count(const TopoDS_Shape& shape,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// bull shit
|
namespace {
|
||||||
// Standard_Real f1,l1, f2,l2;
|
|
||||||
// BRep_Tool::Range( edge1, f1,l1 );
|
SMESH_subMeshEventListener* GetSrcSubMeshListener();
|
||||||
// BRep_Tool::Range( edge2, f2,l2 );
|
|
||||||
// BRepAdaptor_Curve e1( edge1 ), e2( edge2 );
|
//================================================================================
|
||||||
// gp_Pnt pf1, pf2;
|
/*!
|
||||||
// gp_Vec dirX1, dirX2; // 1st derivatives
|
* \brief Listener that resets an event listener on source submesh when
|
||||||
// e1.D1( f1, pf1, dirX1 );
|
* "ProjectionSource*D" hypothesis is modified
|
||||||
// e2.D1( f2, pf2, dirX2 );
|
*/
|
||||||
// gp_Pnt pm1 = e1.Value( 0.5 * ( f1 + l1 ));
|
//================================================================================
|
||||||
// gp_Pnt pm2 = e2.Value( 0.5 * ( f2 + l2 ));
|
|
||||||
// gp_Vec dirZ1( pf1, pm1 ), dirZ2( pf2, pm2 );
|
struct HypModifWaiter: SMESH_subMeshEventListener
|
||||||
// gp_Trsf trsf;
|
{
|
||||||
// gp_Ax3 fromSys( pf1, dirZ1, dirX1 ), toSys( pf2, dirZ2, dirX2 );
|
HypModifWaiter():SMESH_subMeshEventListener(0){} // won't be deleted by submesh
|
||||||
// trsf.SetTransformation( fromSys, toSys );
|
|
||||||
// dirX1.Transform( trsf );
|
void ProcessEvent(const int event, const int eventType, SMESH_subMesh* subMesh,
|
||||||
// bool reverse = ( dirX1 * dirX2 < 0 );
|
EventListenerData*, SMESH_Hypothesis*)
|
||||||
// if ( reverse ) edge2.Reverse();
|
{
|
||||||
|
if ( event == SMESH_subMesh::MODIF_HYP &&
|
||||||
|
eventType == SMESH_subMesh::ALGO_EVENT)
|
||||||
|
{
|
||||||
|
// delete current source listener
|
||||||
|
subMesh->DeleteEventListener( GetSrcSubMeshListener() );
|
||||||
|
// let algo set a new one
|
||||||
|
SMESH_Gen* gen = subMesh->GetFather()->GetGen();
|
||||||
|
if ( SMESH_Algo* algo = gen->GetAlgo( *subMesh->GetFather(),
|
||||||
|
subMesh->GetSubShape() ))
|
||||||
|
algo->SetEventListener( subMesh );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief return static HypModifWaiter
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
SMESH_subMeshEventListener* GetHypModifWaiter() {
|
||||||
|
static HypModifWaiter aHypModifWaiter;
|
||||||
|
return &aHypModifWaiter;
|
||||||
|
}
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief return static listener for source shape submeshes
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
SMESH_subMeshEventListener* GetSrcSubMeshListener() {
|
||||||
|
static SMESH_subMeshEventListener srcListener(0); // won't be deleted by submesh
|
||||||
|
return &srcListener;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//================================================================================
|
||||||
|
/*!
|
||||||
|
* \brief Set event listeners to submesh with projection algo
|
||||||
|
* \param subMesh - submesh with projection algo
|
||||||
|
* \param srcShape - source shape
|
||||||
|
* \param srcMesh - source mesh
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
|
void StdMeshers_ProjectionUtils::SetEventListener(SMESH_subMesh* subMesh,
|
||||||
|
TopoDS_Shape srcShape,
|
||||||
|
SMESH_Mesh* srcMesh)
|
||||||
|
{
|
||||||
|
// Set listener that resets an event listener on source submesh when
|
||||||
|
// "ProjectionSource*D" hypothesis is modified
|
||||||
|
subMesh->SetEventListener( GetHypModifWaiter(),0,subMesh);
|
||||||
|
|
||||||
|
// Set an event listener to submesh of the source shape
|
||||||
|
if ( !srcShape.IsNull() )
|
||||||
|
{
|
||||||
|
if ( !srcMesh )
|
||||||
|
srcMesh = subMesh->GetFather();
|
||||||
|
|
||||||
|
SMESH_subMesh* srcShapeSM = srcMesh->GetSubMesh( srcShape );
|
||||||
|
|
||||||
|
if ( srcShapeSM != subMesh )
|
||||||
|
subMesh->SetEventListener( GetSrcSubMeshListener(),
|
||||||
|
SMESH_subMeshEventListenerData::MakeData( subMesh ),
|
||||||
|
srcShapeSM );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -193,6 +193,16 @@ class StdMeshers_ProjectionUtils
|
|||||||
static int Count(const TopoDS_Shape& shape,
|
static int Count(const TopoDS_Shape& shape,
|
||||||
const TopAbs_ShapeEnum type,
|
const TopAbs_ShapeEnum type,
|
||||||
const bool ignoreSame);
|
const bool ignoreSame);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Set event listeners to submesh with projection algo
|
||||||
|
* \param subMesh - submesh with projection algo
|
||||||
|
* \param srcShape - source shape
|
||||||
|
* \param srcMesh - source mesh
|
||||||
|
*/
|
||||||
|
static void SetEventListener(SMESH_subMesh* subMesh,
|
||||||
|
TopoDS_Shape srcShape,
|
||||||
|
SMESH_Mesh* srcMesh);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -357,19 +357,7 @@ bool StdMeshers_Projection_1D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
|
|||||||
|
|
||||||
void StdMeshers_Projection_1D::SetEventListener(SMESH_subMesh* subMesh)
|
void StdMeshers_Projection_1D::SetEventListener(SMESH_subMesh* subMesh)
|
||||||
{
|
{
|
||||||
if ( _sourceHypo && ! _sourceHypo->GetSourceEdge().IsNull() )
|
TAssocTool::SetEventListener( subMesh,
|
||||||
{
|
_sourceHypo->GetSourceEdge(),
|
||||||
SMESH_Mesh* srcMesh = _sourceHypo->GetSourceMesh();
|
_sourceHypo->GetSourceMesh() );
|
||||||
if ( !srcMesh )
|
|
||||||
srcMesh = subMesh->GetFather();
|
|
||||||
|
|
||||||
SMESH_subMesh* srcEdgeSM =
|
|
||||||
srcMesh->GetSubMesh( _sourceHypo->GetSourceEdge() );
|
|
||||||
|
|
||||||
if ( srcEdgeSM != subMesh )
|
|
||||||
subMesh->SetEventListener( new SMESH_subMeshEventListener(true),
|
|
||||||
SMESH_subMeshEventListenerData::MakeData( subMesh ),
|
|
||||||
srcEdgeSM );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -626,17 +626,7 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
|
|||||||
|
|
||||||
void StdMeshers_Projection_2D::SetEventListener(SMESH_subMesh* subMesh)
|
void StdMeshers_Projection_2D::SetEventListener(SMESH_subMesh* subMesh)
|
||||||
{
|
{
|
||||||
if ( _sourceHypo && ! _sourceHypo->GetSourceFace().IsNull() )
|
TAssocTool::SetEventListener( subMesh,
|
||||||
{
|
_sourceHypo->GetSourceFace(),
|
||||||
SMESH_Mesh* srcMesh = _sourceHypo->GetSourceMesh();
|
_sourceHypo->GetSourceMesh() );
|
||||||
if ( !srcMesh )
|
|
||||||
srcMesh = subMesh->GetFather();
|
|
||||||
|
|
||||||
SMESH_subMesh* srcFaceSM =
|
|
||||||
srcMesh->GetSubMesh( _sourceHypo->GetSourceFace() );
|
|
||||||
|
|
||||||
subMesh->SetEventListener( new SMESH_subMeshEventListener(true),
|
|
||||||
SMESH_subMeshEventListenerData::MakeData( subMesh ),
|
|
||||||
srcFaceSM );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -420,19 +420,8 @@ bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aS
|
|||||||
|
|
||||||
void StdMeshers_Projection_3D::SetEventListener(SMESH_subMesh* subMesh)
|
void StdMeshers_Projection_3D::SetEventListener(SMESH_subMesh* subMesh)
|
||||||
{
|
{
|
||||||
if ( _sourceHypo && ! _sourceHypo->GetSource3DShape().IsNull() )
|
TAssocTool::SetEventListener( subMesh,
|
||||||
{
|
_sourceHypo->GetSource3DShape(),
|
||||||
SMESH_Mesh* srcMesh = _sourceHypo->GetSourceMesh();
|
_sourceHypo->GetSourceMesh() );
|
||||||
if ( !srcMesh )
|
|
||||||
srcMesh = subMesh->GetFather();
|
|
||||||
|
|
||||||
SMESH_subMesh* srcShapeSM =
|
|
||||||
srcMesh->GetSubMesh( _sourceHypo->GetSource3DShape() );
|
|
||||||
|
|
||||||
if ( srcShapeSM != subMesh )
|
|
||||||
subMesh->SetEventListener( new SMESH_subMeshEventListener(true),
|
|
||||||
SMESH_subMeshEventListenerData::MakeData( subMesh ),
|
|
||||||
srcShapeSM );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user