PAL13473 (Build repetitive mesh):

add classes and methods to track non hierarchical dependencies
	between submeshes
This commit is contained in:
eap 2006-12-06 15:48:09 +00:00
parent 56c9db3f13
commit 03ad183b77
3 changed files with 181 additions and 6 deletions

View File

@ -38,6 +38,7 @@ EXPORT_HEADERS= \
SMESH_Gen.hxx \
SMESH_Mesh.hxx \
SMESH_subMesh.hxx \
SMESH_subMeshEventListener.hxx \
SMESH_Hypothesis.hxx \
SMESH_HypoFilter.hxx \
SMESH_Algo.hxx \

View File

@ -45,6 +45,11 @@ class SMESH_Mesh;
class SMESH_Hypothesis;
class SMESH_Algo;
class SMESH_Gen;
class SMESH_subMeshEventListener;
class SMESH_subMeshEventListenerData;
typedef SMESH_subMeshEventListener EventListener;
typedef SMESH_subMeshEventListenerData EventListenerData;
class SMESH_subMesh
{
@ -72,8 +77,6 @@ class SMESH_subMesh
const TopoDS_Shape & GetSubShape() const;
// bool _vertexSet; // only for vertex subMesh, set to false for dim > 0
enum compute_state
{
NOT_READY, READY_TO_COMPUTE,
@ -96,6 +99,78 @@ class SMESH_subMesh
CLEAN, SUBMESH_COMPUTED, SUBMESH_RESTORED,
MESH_ENTITY_REMOVED, CHECK_COMPUTE_STATE
};
enum event_type
{
ALGO_EVENT, COMPUTE_EVENT
};
// ==================================================================
// Members to track non hierarchical dependencies between submeshes
// ==================================================================
/*!
* \brief Sets an event listener and its data to a submesh
* \param listener - the listener to store
* \param data - the listener data to store
* \param where - the submesh to store the listener and it's data
* \param deleteListener - if true then the listener will be deleted as
* it is removed from where submesh
*
* It remembers the submesh where it puts the listener in order to delete
* them when HYP_OK algo_state is lost
* After being set, event listener is notified on each event of where submesh.
*/
void SetEventListener(EventListener* listener,
EventListenerData* data,
SMESH_subMesh* where);
/*!
* \brief Return an event listener data
* \param listener - the listener whose data is
* \retval EventListenerData* - found data, maybe NULL
*/
EventListenerData* GetEventListenerData(EventListener* listener) const;
/*!
* \brief Unregister the listener and delete it and it's data
* \param listener - the event listener to delete
*/
void DeleteEventListener(EventListener* listener);
protected:
//!< event listeners to notify
std::map< EventListener*, EventListenerData* > myEventListeners;
//!< event listeners to delete when HYP_OK algo_state is lost
std::list< std::pair< SMESH_subMesh*, EventListener* > > myOwnListeners;
/*!
* \brief Sets an event listener and its data to a submesh
* \param listener - the listener to store
* \param data - the listener data to store
*
* After being set, event listener is notified on each event of a submesh.
*/
void SetEventListener(EventListener* listener, EventListenerData* data);
/*!
* \brief Notify stored event listeners on the occured event
* \param event - algo_event or compute_event itself
* \param eventType - algo_event or compute_event
* \param hyp - hypothesis, if eventType is algo_event
*/
void NotifyListenersOnEvent( const int event,
const event_type eventType,
SMESH_Hypothesis* hyp = 0);
/*!
* \brief Delete event listeners depending on algo of this submesh
*/
void DeleteOwnListeners();
// ==================================================================
public:
SMESH_Hypothesis::Hypothesis_Status
AlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
@ -128,7 +203,11 @@ class SMESH_subMesh
SMESH_Hypothesis::Hypothesis_Status CheckConcurentHypothesis (const int theHypType);
// check if there are several applicable hypothesis on fathers
protected:
bool IsMeshComputed() const;
// check if _subMeshDS contains mesh elements
protected:
// ==================================================================
void InsertDependence(const TopoDS_Shape aSubShape);
bool SubMeshesComputed();
@ -143,9 +222,6 @@ class SMESH_subMesh
void CleanDependsOn();
void SetAlgoState(int state);
bool IsMeshComputed() const;
// check if _subMeshDS contains mesh elements
TopoDS_Shape GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlgo);
// return a shape containing all sub-shapes of the MainShape that can be
// meshed at once along with _subShape

View File

@ -0,0 +1,98 @@
// SMESH SMESH : implementaion of SMESH idl descriptions
//
// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
//
//
// File : SMESH_subMeshEventListener.hxx
// Created : Mon Nov 13 10:45:49 2006
// Author : Edward AGAPOV (eap)
#ifndef SMESH_subMeshEventListener_HeaderFile
#define SMESH_subMeshEventListener_HeaderFile
#include <list>
class SMESH_subMesh;
class SMESH_Hypothesis;
struct SMESH_subMeshEventListenerData;
// ------------------------------------------------------------------
/*!
* \brief A base for objects reacting on submesh events
*/
// ------------------------------------------------------------------
class SMESH_subMeshEventListener {
public:
/*!
* \brief Do something on a certain event
* \param event - algo_event or compute_event itself (of SMESH_subMesh)
* \param eventType - ALGO_EVENT or COMPUTE_EVENT (of SMESH_subMesh)
* \param subMesh - the submesh where the event occures
* \param data - listener data stored in the subMesh
* \param hyp - hypothesis, if eventType is algo_event
*
* The base implementation translates CLEAN event to the subMesh stored
* in the listener data
*/
virtual void ProcessEvent(const int event,
const int eventType,
SMESH_subMesh* subMesh,
SMESH_subMeshEventListenerData* data,
SMESH_Hypothesis* hyp = 0);
};
// ------------------------------------------------------------------
/*!
* \brief Data specific for EventListener and to be stored in a submesh
*/
// ------------------------------------------------------------------
struct SMESH_subMeshEventListenerData
{
//!< to recognize data type
int myType;
//!< generally: submeshes depending on the one storing this data
std::list<SMESH_subMesh*> mySubMeshes;
//!< subMesh where data
/*!
* \brief Create a default listener data.
* \param dependentSM - subMesh to store
* \param type - data type
* \retval SMESH_subMeshEventListenerData* - a new listener data
*
* See SMESH_subMeshEventListener::ProcessEvent() to know how the default
* listener uses it
*/
static SMESH_subMeshEventListenerData* MakeData(SMESH_subMesh* dependentSM,
const int type = 0)
{
SMESH_subMeshEventListenerData* data = new SMESH_subMeshEventListenerData;
data->mySubMeshes.push_back( dependentSM );
data->myType = type;
return data;
}
};
#endif