Version: 6.3.1

src/SMESH/SMESH_subMesh.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SMESH SMESH : implementaion of SMESH idl descriptions
00024 //  File   : SMESH_subMesh.hxx
00025 //  Author : Paul RASCLE, EDF
00026 //  Module : SMESH
00027 //  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/SMESH/SMESH_subMesh.hxx,v 1.13.2.5.6.4.2.1 2011-06-02 05:57:26 vsr Exp $
00028 //
00029 #ifndef _SMESH_SUBMESH_HXX_
00030 #define _SMESH_SUBMESH_HXX_
00031 
00032 #include "SMESH_SMESH.hxx"
00033 
00034 #include "SMESHDS_Mesh.hxx"
00035 #include "SMESHDS_SubMesh.hxx"
00036 #include "SMESH_Hypothesis.hxx"
00037 #include "SMESH_ComputeError.hxx"
00038 #include "SMESH_Algo.hxx"
00039 
00040 #include "Utils_SALOME_Exception.hxx"
00041 
00042 #include <TopoDS_Shape.hxx>
00043 
00044 #include <list>
00045 #include <map>
00046 
00047 class SMESH_Mesh;
00048 class SMESH_Hypothesis;
00049 class SMESH_Algo;
00050 class SMESH_Gen;
00051 class SMESH_subMeshEventListener;
00052 class SMESH_subMeshEventListenerData;
00053 class SMESH_subMesh;
00054 
00055 typedef SMESH_subMeshEventListener     EventListener;
00056 typedef SMESH_subMeshEventListenerData EventListenerData;
00057 
00058 typedef boost::shared_ptr< SMDS_Iterator<SMESH_subMesh*> > SMESH_subMeshIteratorPtr;
00059 
00060 
00061 class SMESH_EXPORT SMESH_subMesh
00062 {
00063  public:
00064   SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS,
00065                 const TopoDS_Shape & aSubShape);
00066   virtual ~ SMESH_subMesh();
00067 
00068   int GetId() const;
00069 
00070   SMESH_Mesh* GetFather() { return _father; }
00071   
00072   SMESHDS_SubMesh * GetSubMeshDS();
00073 
00074   SMESHDS_SubMesh* CreateSubMeshDS();
00075   // Explicit SMESHDS_SubMesh creation method, required for persistence mechanism
00076 
00077   SMESH_subMesh *GetFirstToCompute();
00078 
00079   const std::map < int, SMESH_subMesh * >& DependsOn();
00080   //const map < int, SMESH_subMesh * >&Dependants();
00084   SMESH_subMeshIteratorPtr getDependsOnIterator(const bool includeSelf,
00085                                                 const bool complexShapeFirst);
00086 
00087   const TopoDS_Shape & GetSubShape() const;
00088 
00089   enum compute_state
00090   {
00091     NOT_READY, READY_TO_COMPUTE,
00092     COMPUTE_OK, FAILED_TO_COMPUTE
00093     };
00094   enum algo_state
00095   {
00096     NO_ALGO, MISSING_HYP, HYP_OK
00097     };
00098   enum algo_event
00099   {
00100     ADD_HYP          , ADD_ALGO,
00101     REMOVE_HYP       , REMOVE_ALGO,
00102     ADD_FATHER_HYP   , ADD_FATHER_ALGO,
00103     REMOVE_FATHER_HYP, REMOVE_FATHER_ALGO,
00104     MODIF_HYP
00105     };
00106   enum compute_event
00107   {
00108     MODIF_ALGO_STATE, COMPUTE,
00109 #ifdef WITH_SMESH_CANCEL_COMPUTE
00110     COMPUTE_CANCELED,
00111 #endif
00112     CLEAN, SUBMESH_COMPUTED, SUBMESH_RESTORED,
00113     MESH_ENTITY_REMOVED, CHECK_COMPUTE_STATE
00114     };
00115   enum event_type
00116   {
00117     ALGO_EVENT, COMPUTE_EVENT
00118   };
00119 
00120   // ==================================================================
00121   // Members to track non hierarchical dependencies between submeshes 
00122   // ==================================================================
00123 
00134   void SetEventListener(EventListener*     listener,
00135                         EventListenerData* data,
00136                         SMESH_subMesh*     where);
00137 
00143   EventListenerData* GetEventListenerData(EventListener* listener) const;
00144 
00149   void DeleteEventListener(EventListener* listener);
00150 
00151 protected:
00152 
00154   std::map< EventListener*, EventListenerData* >           myEventListeners;
00156   std::list< std::pair< SMESH_subMesh*, EventListener* > > myOwnListeners;
00157 
00165   void SetEventListener(EventListener* listener, EventListenerData* data);
00166 
00173   void NotifyListenersOnEvent( const int         event,
00174                                const event_type  eventType,
00175                                SMESH_Hypothesis* hyp = 0);
00176 
00180   void DeleteOwnListeners();
00181 
00182   // ==================================================================
00183 
00184 public:
00185 
00186   SMESH_Hypothesis::Hypothesis_Status
00187     AlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
00188 
00189   SMESH_Hypothesis::Hypothesis_Status
00190     SubMeshesAlgoStateEngine(int event, SMESH_Hypothesis * anHyp);
00191 
00192   int GetAlgoState() const { return _algoState; }
00193   int GetComputeState() const { return _computeState; };
00194   SMESH_ComputeErrorPtr& GetComputeError() { return _computeError; }
00195 
00196   void DumpAlgoState(bool isMain);
00197 
00198   bool ComputeStateEngine(int event);
00199   void ComputeSubMeshStateEngine(int event);
00200 
00201   bool Evaluate(MapShapeNbElems& aResMap);
00202 
00203   bool IsConform(const SMESH_Algo* theAlgo);
00204   // check if a conform mesh will be produced by the Algo
00205 
00206   bool CanAddHypothesis(const SMESH_Hypothesis* theHypothesis) const;
00207   // return true if theHypothesis can be attached to me:
00208   // its dimention is checked
00209 
00210   static bool IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis,
00211                                     const TopAbs_ShapeEnum  theShapeType);
00212 
00213   bool IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis) const
00214   { return IsApplicableHypotesis( theHypothesis, _subShape.ShapeType() ); }
00215   // return true if theHypothesis can be used to mesh me:
00216   // its shape type is checked
00217   
00218   SMESH_Hypothesis::Hypothesis_Status CheckConcurentHypothesis (const int theHypType);
00219   // check if there are several applicable hypothesis on fathers
00220 
00224   bool IsEmpty() const;
00225 
00226   bool IsMeshComputed() const;
00227   // check if _subMeshDS contains mesh elements
00228 
00233   void SetIsAlwaysComputed(bool isAlCo);
00234   bool IsAlwaysComputed() { return _alwaysComputed; }
00235 
00236   
00243   bool FindIntersection( const SMESH_subMesh *           theOther,
00244                          std::set<const SMESH_subMesh*>& theSetOfCommon ) const;
00245 
00246 protected:
00247   // ==================================================================
00248   void InsertDependence(const TopoDS_Shape aSubShape);
00249 
00250   bool SubMeshesComputed();
00251 
00252   bool SubMeshesReady();
00253 
00254   void RemoveSubMeshElementsAndNodes();
00255   void UpdateDependantsState(const compute_event theEvent);
00256   void UpdateSubMeshState(const compute_state theState);
00257   void CleanDependants();
00258   void CleanDependsOn();
00259   void SetAlgoState(int state);
00260 
00265   TopoDS_Shape GetCollection(SMESH_Gen * theGen,
00266                              SMESH_Algo* theAlgo,
00267                              bool &      theSubComputed);
00268 
00272   bool ApplyToCollection (SMESH_Algo*         theAlgo,
00273                           const TopoDS_Shape& theCollection);
00274 
00279   bool CheckComputeError(SMESH_Algo* theAlgo, const TopoDS_Shape& theShape=TopoDS_Shape());
00280 
00288   const SMESH_Hypothesis* GetSimilarAttached(const TopoDS_Shape&      theShape,
00289                                              const SMESH_Hypothesis * theHyp,
00290                                              const int                theHypType = 0);
00291   // 
00292 
00293 protected:
00294 
00295   TopoDS_Shape          _subShape;
00296   SMESHDS_SubMesh *     _subMeshDS;
00297   SMESH_Mesh *          _father;
00298   int                   _Id;
00299 
00300   std::map < int, SMESH_subMesh * >_mapDepend;
00301   bool                  _dependenceAnalysed;
00302 
00303   int                   _algoState;
00304   int                   _computeState;
00305   SMESH_ComputeErrorPtr _computeError;
00306 
00307   // allow algo->Compute() if a subshape of lower dim is meshed but
00308   // none mesh entity is bound to it. Eg StdMeshers_CompositeSegment_1D can
00309   // mesh several edges as a whole and leave some of them  without mesh entities
00310   bool                  _alwaysComputed;
00311 
00312 };
00313 
00314 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS