Salome HOME
IPAL53870: Dump study script creates an excess sub-mesh
[modules/smesh.git] / src / SMESH_I / SMESH_Filter_i.hxx
index d874819a807e01cc112bcf1c1a96ff30e4b3e98b..b9d290c47d0bd55c731e09828cd742ebdb14f148 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  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
@@ -6,7 +6,7 @@
 // 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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -18,6 +18,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
 //  File   : SMESH_Filter_i.hxx
 
 #include <list>
 
-class SMESHDS_Mesh;
+class SMESH_GroupBase_i;
+
 
 namespace SMESH
 {
-
-  // ================================================================================
-  namespace Controls
+  /*!
+   * \brief Object notified on change of base objects and
+   *        notifying dependent objects in its turn.
+   *        This interface is used to track the following dependencies:
+   *        - GroupOnFiler depending on Filter predicates
+   *        - Filter depending on a Group via FT_BelongToMeshGroup predicate 
+   */
+  struct NotifyerAndWaiter
   {
+    virtual void OnBaseObjModified(NotifyerAndWaiter* obj, bool removed) {};
+    // specific reaction on modification of a base object
 
-    /*
-      Class       : BelongToGeom
-      Description : Predicate for verifying whether entiy belong to
-      specified geometrical support
-    */
-    class SMESH_I_EXPORT BelongToGeom: public virtual Predicate
-    {
-    public:
-      BelongToGeom();
-
-      virtual void                    SetMesh( const SMDS_Mesh* theMesh );
-      virtual void                    SetGeom( const TopoDS_Shape& theShape );
-
-      virtual bool                    IsSatisfy( long theElementId );
-
-      virtual void                    SetType( SMDSAbs_ElementType theType );
-      virtual                         SMDSAbs_ElementType GetType() const;
-
-      TopoDS_Shape                    GetShape();
-      const SMESHDS_Mesh*             GetMeshDS() const;
-
-      void                            SetTolerance( double );
-      double                          GetTolerance();
-
-    private:
-      virtual void                    init();
-
-      TopoDS_Shape                    myShape;
-      const SMESHDS_Mesh*             myMeshDS;
-      SMDSAbs_ElementType             myType;
-      bool                            myIsSubshape;
-      double                          myTolerance;          // only if myIsSubshape == false
-      Controls::ElementsOnShapePtr    myElementsOnShapePtr; // only if myIsSubshape == false
-    };
-    typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
-
-    /*
-      Class       : LyingOnGeom
-      Description : Predicate for verifying whether entiy lying or partially lying on
-      specified geometrical support
-    */
-    class SMESH_I_EXPORT LyingOnGeom: public virtual Predicate
-    {
-    public:
-      LyingOnGeom();
-      
-      virtual void                    SetMesh( const SMDS_Mesh* theMesh );
-      virtual void                    SetGeom( const TopoDS_Shape& theShape );
-      
-      virtual bool                    IsSatisfy( long theElementId );
-      
-      virtual void                    SetType( SMDSAbs_ElementType theType );
-      virtual                         SMDSAbs_ElementType GetType() const;
-      
-      TopoDS_Shape                    GetShape();
-      const SMESHDS_Mesh*             GetMeshDS() const;
-
-      void                            SetTolerance( double );
-      double                          GetTolerance();
-      
-      virtual bool                    Contains( const SMESHDS_Mesh*     theMeshDS,
-                                                const TopoDS_Shape&     theShape,
-                                                const SMDS_MeshElement* theElem,
-                                                TopAbs_ShapeEnum        theFindShapeEnum,
-                                                TopAbs_ShapeEnum        theAvoidShapeEnum = TopAbs_SHAPE );
-    private:
-      virtual void                    init();
-
-      TopoDS_Shape                    myShape;
-      const SMESHDS_Mesh*             myMeshDS;
-      SMDSAbs_ElementType             myType;
-      bool                            myIsSubshape;
-      double                          myTolerance;          // only if myIsSubshape == false
-      Controls::ElementsOnShapePtr    myElementsOnShapePtr; // only if myIsSubshape == false
-    };
-    typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
-
-  } // namespace Controls
+    void Modified( bool removed=false, NotifyerAndWaiter* who = 0);
+    // calls OnBaseObjModified(), if who != 0, and myWaiters[i]->Modified(who)
 
+    void AddModifWaiter    ( NotifyerAndWaiter* waiter ); // adds a dependent object to notify
+    void RemoveModifWaiter ( NotifyerAndWaiter* waiter ); // CALL IT when a waiter dies!!!
+    bool ContainModifWaiter( NotifyerAndWaiter* waiter );
+    std::list<NotifyerAndWaiter*> myWaiters;
+  };
   // ================================================================================
   /*
     FUNCTORS
@@ -141,10 +79,10 @@ namespace SMESH
                                   public virtual SALOME::GenericObj_i
   {
   public:
-    void                            SetMesh( SMESH_Mesh_ptr theMesh );
-    Controls::FunctorPtr            GetFunctor(){ return myFunctorPtr;}
+    virtual void                    SetMesh( SMESH_Mesh_ptr theMesh );
+    Controls::FunctorPtr            GetFunctor() { return myFunctorPtr; }
     ElementType                     GetElementType();
-    
+
   protected:
     Functor_i();
     ~Functor_i();
@@ -161,7 +99,11 @@ namespace SMESH
   {
   public:
     CORBA::Double                   GetValue( CORBA::Long theElementId );
-    SMESH::Histogram*               GetHistogram(CORBA::Short nbIntervals, CORBA::Boolean isLogarithmic);
+    SMESH::Histogram*               GetHistogram(CORBA::Short   nbIntervals,
+                                                 CORBA::Boolean isLogarithmic);
+    SMESH::Histogram*               GetLocalHistogram(CORBA::Short               nbIntervals,
+                                                      CORBA::Boolean            isLogarithmic,
+                                                      SMESH::SMESH_IDSource_ptr object);
     void                            SetPrecision( CORBA::Long thePrecision );
     CORBA::Long                     GetPrecision();
     Controls::NumericalFunctorPtr   GetNumericalFunctor();
@@ -329,7 +271,6 @@ namespace SMESH
     Controls::Length2DPtr          myLength2DPtr;
   };
   
-  
   /*
     Class       : MultiConnection_i
     Description : Functor for calculating number of faces conneted to the edge
@@ -370,6 +311,18 @@ namespace SMESH
     FunctorType                     GetFunctorType();
   };
   
+  /*
+    Class       : NodeConnectivityNumber_i
+    Description : Functor returning diameter of a ball element
+  */
+  class SMESH_I_EXPORT NodeConnectivityNumber_i: public virtual POA_SMESH::NodeConnectivityNumber,
+                                       public virtual NumericalFunctor_i
+  {
+  public:
+    NodeConnectivityNumber_i();
+    FunctorType                     GetFunctorType();
+  };
+  
   
   /*
     PREDICATES
@@ -383,6 +336,7 @@ namespace SMESH
   {
   public:
     CORBA::Boolean                  IsSatisfy( CORBA::Long theElementId );
+    CORBA::Long                     NbSatisfying( SMESH::SMESH_IDSource_ptr obj );
     Controls::PredicatePtr          GetPredicate();
     
   protected:
@@ -450,7 +404,29 @@ namespace SMESH
     OverConstrainedFace_i();
     FunctorType                     GetFunctorType();
   };
-  
+
+  /*
+    Class       : BelongToMeshGroup_i
+    Description : Verify whether a mesh element is included into a mesh group
+  */
+  class SMESH_I_EXPORT BelongToMeshGroup_i: public virtual POA_SMESH::BelongToMeshGroup,
+                                            public virtual Predicate_i
+  {
+    std::string                    myID; // IOR or StoreName
+    SMESH::SMESH_GroupBase_var     myGroup;
+    Controls::BelongToMeshGroupPtr myBelongToMeshGroup;
+  public:
+    BelongToMeshGroup_i();
+    ~BelongToMeshGroup_i();
+    void                       SetGroup( SMESH::SMESH_GroupBase_ptr theGroup );
+    void                       SetGroupID( const char* theID ); // IOR or StoreName
+    SMESH::SMESH_GroupBase_ptr GetGroup();
+
+    std::string                GetGroupID();
+    FunctorType                GetFunctorType();
+    //virtual void               SetMesh( SMESH_Mesh_ptr theMesh );
+  };
+
   /*
     Class       : BelongToGeom_i
     Description : Predicate for selection on geometrical support
@@ -763,6 +739,25 @@ namespace SMESH
   private:
     Controls::ElemGeomTypePtr myElemGeomTypePtr;
   };
+
+  /*
+    Class       : ElemEntityType_i
+    Description : Functor for check element entity type
+  */
+  class SMESH_I_EXPORT ElemEntityType_i: public virtual POA_SMESH::ElemEntityType,
+                                         public virtual Predicate_i
+  {
+  public:
+    ElemEntityType_i();
+    FunctorType             GetFunctorType();
+
+    void                    SetElementType ( ElementType  theType );
+    void                    SetEntityType( EntityType theEntityType );
+    EntityType              GetEntityType() const;
+
+  private:
+    Controls::ElemEntityTypePtr myElemEntityTypePtr;
+  };
   
   /*
     Class       : CoplanarFaces_i
@@ -783,6 +778,34 @@ namespace SMESH
   private:
     Controls::CoplanarFacesPtr myCoplanarFacesPtr;
   };
+
+  /*
+   * Class       : ConnectedElements_i
+   * Description : Returns true if an element is connected via other elements to the element
+   *               located at a given point.
+   */
+  class SMESH_I_EXPORT ConnectedElements_i: public virtual POA_SMESH::ConnectedElements,
+                                            public virtual Predicate_i
+  {
+  public:
+    ConnectedElements_i();
+    FunctorType             GetFunctorType();
+
+    void                    SetElementType( ElementType theType );
+    void                    SetPoint( CORBA::Double x, CORBA::Double y, CORBA::Double z );
+    void                    SetVertex( GEOM::GEOM_Object_ptr vertex )
+      throw (SALOME::SALOME_Exception);
+    void                    SetNode ( CORBA::Long nodeID )
+      throw (SALOME::SALOME_Exception);
+    void                    SetThreshold ( const char* threshold,
+                                           SMESH::ConnectedElements::ThresholdType type )
+      throw (SALOME::SALOME_Exception);
+    char*                   GetThreshold ( SMESH::ConnectedElements::ThresholdType& type );
+
+  private:
+    Controls::ConnectedElementsPtr          myConnectedElementsPtr;
+    std::string                             myVertexID;
+  };
   
   /*
     Class       : Comparator_i
@@ -930,7 +953,8 @@ namespace SMESH
     FILTER
   */
   class SMESH_I_EXPORT Filter_i: public virtual POA_SMESH::Filter,
-                                 public virtual SALOME::GenericObj_i
+                                 public virtual SALOME::GenericObj_i,
+                                 public NotifyerAndWaiter
   {
   public:
     Filter_i();
@@ -977,34 +1001,32 @@ namespace SMESH
 
     Predicate_i*     GetPredicate_i();
 
+    void FindBaseObjects();
+    // finds groups it depends on
+
+    virtual void OnBaseObjModified(NotifyerAndWaiter* group, bool removed);
+    // notified on change of myBaseGroups[i]
+
     // =========================
     // SMESH_IDSource interface
     // =========================
     virtual SMESH::long_array*           GetIDs();
     virtual SMESH::long_array*           GetMeshInfo();
+    virtual SMESH::long_array*           GetNbElementsByType();
     virtual SMESH::array_of_ElementType* GetTypes();
     virtual SMESH::SMESH_Mesh_ptr        GetMesh();
     virtual bool                         IsMeshInfoCorrect() { return true; }
-
-    /*!
-     * \brief Object notified on change of predicate
-     */
-    struct TPredicateChangeWaiter
-    {
-      virtual void PredicateChanged() = 0;
-    };
-    void AddWaiter( TPredicateChangeWaiter* waiter );
-    void RemoveWaiter( TPredicateChangeWaiter* waiter );
+    virtual SALOMEDS::TMPFile*           GetVtkUgStream();
 
   private:
     Controls::Filter myFilter;
     Predicate_i*     myPredicate;
     SMESH_Mesh_var   myMesh;
 
-    std::list<TPredicateChangeWaiter*> myWaiters;
+    std::vector< SMESH_GroupBase_i* > myBaseGroups;
   };
-  
-  
+
+
   /*
     FILTER LIBRARY
   */
@@ -1065,10 +1087,12 @@ namespace SMESH
     MaxElementLength3D_ptr    CreateMaxElementLength3D();
     Length_ptr                CreateLength();
     Length2D_ptr              CreateLength2D();
+    NodeConnectivityNumber_ptr CreateNodeConnectivityNumber();
     MultiConnection_ptr       CreateMultiConnection();
     MultiConnection2D_ptr     CreateMultiConnection2D();
     BallDiameter_ptr          CreateBallDiameter();
     
+    BelongToMeshGroup_ptr     CreateBelongToMeshGroup();
     BelongToGeom_ptr          CreateBelongToGeom();
     BelongToPlane_ptr         CreateBelongToPlane();
     BelongToCylinder_ptr      CreateBelongToCylinder();
@@ -1095,7 +1119,9 @@ namespace SMESH
     LinearOrQuadratic_ptr     CreateLinearOrQuadratic();
     GroupColor_ptr            CreateGroupColor();
     ElemGeomType_ptr          CreateElemGeomType();
+    ElemEntityType_ptr        CreateElemEntityType();
     CoplanarFaces_ptr         CreateCoplanarFaces();
+    ConnectedElements_ptr     CreateConnectedElements();
 
     LessThan_ptr              CreateLessThan();
     MoreThan_ptr              CreateMoreThan();