Back to index

salome-smesh  6.5.0
SMESH_ControlsDef.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  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 #ifndef _SMESH_CONTROLSDEF_HXX_
00024 #define _SMESH_CONTROLSDEF_HXX_
00025 
00026 #include <set>
00027 #include <map>
00028 #include <vector>
00029 
00030 #include <boost/shared_ptr.hpp>
00031 
00032 #include <gp_XYZ.hxx>
00033 #include <GeomAPI_ProjectPointOnSurf.hxx>
00034 #include <GeomAPI_ProjectPointOnCurve.hxx>
00035 #include <TColStd_SequenceOfInteger.hxx>
00036 #include <TColStd_MapOfInteger.hxx>
00037 #include <TCollection_AsciiString.hxx>
00038 #include <TopAbs.hxx>
00039 #include <TopoDS_Face.hxx>
00040 #include <TopTools_MapOfShape.hxx>
00041 #include <BRepClass3d_SolidClassifier.hxx>
00042 #include <Quantity_Color.hxx>
00043 
00044 #include "SMDSAbs_ElementType.hxx"
00045 #include "SMDS_MeshNode.hxx"
00046 #include "SMESH_TypeDefs.hxx"
00047 
00048 #include "SMESH_Controls.hxx"
00049 
00050 class SMDS_MeshElement;
00051 class SMDS_MeshFace;
00052 class SMDS_MeshNode;
00053 class SMDS_Mesh;
00054 
00055 class SMESHDS_Mesh;
00056 class SMESHDS_SubMesh;
00057 
00058 class gp_Pnt;
00059 
00060 namespace SMESH{
00061   namespace Controls{
00062 
00063     class SMESHCONTROLS_EXPORT TSequenceOfXYZ
00064     {
00065       typedef std::vector<gp_XYZ>::size_type size_type;
00066 
00067     public:
00068       TSequenceOfXYZ();
00069 
00070       TSequenceOfXYZ(size_type n);
00071 
00072       TSequenceOfXYZ(size_type n, const gp_XYZ& t);
00073 
00074       TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ);
00075 
00076       template <class InputIterator>
00077       TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd);
00078 
00079       ~TSequenceOfXYZ();
00080 
00081       TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ);
00082 
00083       gp_XYZ& operator()(size_type n);
00084 
00085       const gp_XYZ& operator()(size_type n) const;
00086 
00087       void clear();
00088 
00089       void reserve(size_type n);
00090 
00091       void push_back(const gp_XYZ& v);
00092 
00093       size_type size() const;
00094 
00095     private:
00096       std::vector<gp_XYZ> myArray;
00097     };
00098 
00103     class SMESHCONTROLS_EXPORT TMeshModifTracer
00104     {
00105       unsigned long    myMeshModifTime;
00106       const SMDS_Mesh* myMesh;
00107     public:
00108       TMeshModifTracer();
00109       void SetMesh( const SMDS_Mesh* theMesh );
00110       const SMDS_Mesh* GetMesh() const { return myMesh; }
00111       bool IsMeshModified();
00112     };
00113 
00114     /*
00115       Class       : NumericalFunctor
00116       Description : Root of all Functors returning numeric value
00117     */
00118     class SMESHCONTROLS_EXPORT NumericalFunctor: public virtual Functor{
00119     public:
00120       NumericalFunctor();
00121       virtual void SetMesh( const SMDS_Mesh* theMesh );
00122       virtual double GetValue( long theElementId );
00123       virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
00124       void GetHistogram(int                     nbIntervals,
00125                         std::vector<int>&       nbEvents,
00126                         std::vector<double>&    funValues,
00127                         const std::vector<int>& elements,
00128                         const double*           minmax=0);
00129       virtual SMDSAbs_ElementType GetType() const = 0;
00130       virtual double GetBadRate( double Value, int nbNodes ) const = 0;
00131       long  GetPrecision() const;
00132       void  SetPrecision( const long thePrecision );
00133       double Round( const double & value );
00134       
00135       bool GetPoints(const int theId, TSequenceOfXYZ& theRes) const;
00136       static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes);
00137     protected:
00138       const SMDS_Mesh*        myMesh;
00139       const SMDS_MeshElement* myCurrElement;
00140       long                    myPrecision;
00141       double                  myPrecisionValue;
00142     };
00143 
00144 
00145     /*
00146       Class       : Volume
00147       Description : Functor calculating volume of 3D mesh element
00148     */
00149     class SMESHCONTROLS_EXPORT Volume: public virtual NumericalFunctor{
00150     public:
00151       virtual double GetValue( long theElementId );
00152       //virtual double GetValue( const TSequenceOfXYZ& thePoints );
00153       virtual double GetBadRate( double Value, int nbNodes ) const;
00154       virtual SMDSAbs_ElementType GetType() const;
00155     };
00156   
00157   
00158     /*
00159       Class       : MaxElementLength2D
00160       Description : Functor calculating maximum length of 2D element
00161     */
00162     class SMESHCONTROLS_EXPORT MaxElementLength2D: public virtual NumericalFunctor{
00163     public:
00164       virtual double GetValue( long theElementId );
00165       virtual double GetBadRate( double Value, int nbNodes ) const;
00166       virtual SMDSAbs_ElementType GetType() const;
00167     };
00168   
00169   
00170     /*
00171       Class       : MaxElementLength3D
00172       Description : Functor calculating maximum length of 3D element
00173     */
00174     class SMESHCONTROLS_EXPORT MaxElementLength3D: public virtual NumericalFunctor{
00175     public:
00176       virtual double GetValue( long theElementId );
00177       virtual double GetBadRate( double Value, int nbNodes ) const;
00178       virtual SMDSAbs_ElementType GetType() const;
00179     };
00180   
00181   
00182     /*
00183       Class       : SMESH_MinimumAngle
00184       Description : Functor for calculation of minimum angle
00185     */
00186     class SMESHCONTROLS_EXPORT MinimumAngle: public virtual NumericalFunctor{
00187     public:
00188       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00189       virtual double GetBadRate( double Value, int nbNodes ) const;
00190       virtual SMDSAbs_ElementType GetType() const;
00191     };
00192   
00193   
00194     /*
00195       Class       : AspectRatio
00196       Description : Functor for calculating aspect ratio
00197     */
00198     class SMESHCONTROLS_EXPORT AspectRatio: public virtual NumericalFunctor{
00199     public:
00200       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00201       virtual double GetBadRate( double Value, int nbNodes ) const;
00202       virtual SMDSAbs_ElementType GetType() const;
00203     };
00204   
00205   
00206     /*
00207       Class       : AspectRatio3D
00208       Description : Functor for calculating aspect ratio of 3D elems.
00209     */
00210     class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
00211     public:
00212       virtual double GetValue( long theElementId );
00213       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00214       virtual double GetBadRate( double Value, int nbNodes ) const;
00215       virtual SMDSAbs_ElementType GetType() const;
00216     };
00217   
00218   
00219     /*
00220       Class       : Warping
00221       Description : Functor for calculating warping
00222     */
00223     class SMESHCONTROLS_EXPORT Warping: public virtual NumericalFunctor{
00224     public:
00225       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00226       virtual double GetBadRate( double Value, int nbNodes ) const;
00227       virtual SMDSAbs_ElementType GetType() const;
00228       
00229     private:
00230       double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
00231     };
00232   
00233   
00234     /*
00235       Class       : Taper
00236       Description : Functor for calculating taper
00237     */
00238     class SMESHCONTROLS_EXPORT Taper: public virtual NumericalFunctor{
00239     public:
00240       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00241       virtual double GetBadRate( double Value, int nbNodes ) const;
00242       virtual SMDSAbs_ElementType GetType() const;
00243     };
00244 
00245 
00246     /*
00247       Class       : Skew
00248       Description : Functor for calculating skew in degrees
00249     */
00250     class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
00251     public:
00252       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00253       virtual double GetBadRate( double Value, int nbNodes ) const;
00254       virtual SMDSAbs_ElementType GetType() const;
00255     };
00256 
00257 
00258     /*
00259       Class       : Area
00260       Description : Functor for calculating area
00261     */
00262     class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
00263     public:
00264       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00265       virtual double GetBadRate( double Value, int nbNodes ) const;
00266       virtual SMDSAbs_ElementType GetType() const;
00267     };
00268   
00269   
00270     /*
00271       Class       : Length
00272       Description : Functor for calculating length of edge
00273     */
00274     class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
00275     public:
00276       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00277       virtual double GetBadRate( double Value, int nbNodes ) const;
00278       virtual SMDSAbs_ElementType GetType() const;
00279     };
00280 
00281     /*
00282       Class       : Length2D
00283       Description : Functor for calculating length of edge
00284     */
00285     class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
00286     public:
00287       virtual double GetValue( long theElementId );
00288       virtual double GetBadRate( double Value, int nbNodes ) const;
00289       virtual SMDSAbs_ElementType GetType() const;
00290       struct Value{
00291         double myLength;
00292         long myPntId[2];
00293         Value(double theLength, long thePntId1, long thePntId2);
00294         bool operator<(const Value& x) const;
00295       };
00296       typedef std::set<Value> TValues;
00297       void GetValues(TValues& theValues);
00298     };
00299     typedef boost::shared_ptr<Length2D> Length2DPtr;
00300 
00301     /*
00302       Class       : MultiConnection
00303       Description : Functor for calculating number of faces conneted to the edge
00304     */
00305     class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
00306     public:
00307       virtual double GetValue( long theElementId );
00308       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00309       virtual double GetBadRate( double Value, int nbNodes ) const;
00310       virtual SMDSAbs_ElementType GetType() const;
00311     };
00312     
00313     /*
00314       Class       : MultiConnection2D
00315       Description : Functor for calculating number of faces conneted to the edge
00316     */
00317     class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
00318     public:
00319       virtual double GetValue( long theElementId );
00320       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00321       virtual double GetBadRate( double Value, int nbNodes ) const;
00322       virtual SMDSAbs_ElementType GetType() const;
00323       struct Value{
00324         long myPntId[2];
00325         Value(long thePntId1, long thePntId2);
00326         bool operator<(const Value& x) const;
00327       };
00328       typedef std::map<Value,int> MValues;
00329 
00330       void GetValues(MValues& theValues);
00331     };
00332     typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
00333     /*
00334       PREDICATES
00335     */
00336     /*
00337       Class       : CoincidentNodes
00338       Description : Predicate of Coincident Nodes
00339       Note        : This class is suitable only for visualization of Coincident Nodes
00340     */
00341     class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
00342     public:
00343       CoincidentNodes();
00344       virtual void SetMesh( const SMDS_Mesh* theMesh );
00345       virtual bool IsSatisfy( long theElementId );
00346       virtual SMDSAbs_ElementType GetType() const;
00347 
00348       void SetTolerance (const double theToler)  { myToler = theToler; }
00349       double GetTolerance () const { return myToler; }
00350 
00351     private:
00352       double               myToler;
00353       TColStd_MapOfInteger myCoincidentIDs;
00354       TMeshModifTracer     myMeshModifTracer;
00355     };
00356     typedef boost::shared_ptr<CoincidentNodes> CoincidentNodesPtr;
00357    
00358     /*
00359       Class       : CoincidentElements
00360       Description : Predicate of Coincident Elements
00361       Note        : This class is suitable only for visualization of Coincident Elements
00362     */
00363     class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate {
00364     public:
00365       CoincidentElements();
00366       virtual void SetMesh( const SMDS_Mesh* theMesh );
00367       virtual bool IsSatisfy( long theElementId );
00368 
00369     private:
00370       const SMDS_Mesh* myMesh;
00371     };
00372     class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
00373     public:
00374       virtual SMDSAbs_ElementType GetType() const;
00375     };
00376     class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
00377     public:
00378       virtual SMDSAbs_ElementType GetType() const;
00379     };
00380     class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
00381     public:
00382       virtual SMDSAbs_ElementType GetType() const;
00383     };
00384 
00385     /*
00386       Class       : FreeBorders
00387       Description : Predicate for free borders
00388     */
00389     class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
00390     public:
00391       FreeBorders();
00392       virtual void SetMesh( const SMDS_Mesh* theMesh );
00393       virtual bool IsSatisfy( long theElementId );
00394       virtual SMDSAbs_ElementType GetType() const;
00395 
00396     protected:
00397       const SMDS_Mesh* myMesh;
00398     };
00399    
00400 
00401     /*
00402       Class       : BadOrientedVolume
00403       Description : Predicate bad oriented volumes
00404     */
00405     class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
00406     public:
00407       BadOrientedVolume();
00408       virtual void SetMesh( const SMDS_Mesh* theMesh );
00409       virtual bool IsSatisfy( long theElementId );
00410       virtual SMDSAbs_ElementType GetType() const;
00411 
00412     protected:
00413       const SMDS_Mesh* myMesh;
00414     };
00415 
00416     /*
00417       BareBorderVolume
00418     */
00419     class SMESHCONTROLS_EXPORT BareBorderVolume: public Predicate
00420     {
00421     public:
00422       BareBorderVolume():myMesh(0) {}
00423       virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
00424       virtual SMDSAbs_ElementType GetType() const      { return SMDSAbs_Volume; }
00425       virtual bool IsSatisfy( long theElementId );
00426     protected:
00427       const SMDS_Mesh* myMesh;
00428     };
00429     typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
00430 
00431     /*
00432       BareBorderFace
00433     */
00434     class SMESHCONTROLS_EXPORT BareBorderFace: public Predicate
00435     {
00436     public:
00437       BareBorderFace():myMesh(0) {}
00438       virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
00439       virtual SMDSAbs_ElementType GetType() const      { return SMDSAbs_Face; }
00440       virtual bool IsSatisfy( long theElementId );
00441     protected:
00442       const SMDS_Mesh* myMesh;
00443       std::vector< const SMDS_MeshNode* > myLinkNodes;
00444     };
00445     typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
00446 
00447     /*
00448       OverConstrainedVolume
00449     */
00450     class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
00451     {
00452     public:
00453       OverConstrainedVolume():myMesh(0) {}
00454       virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
00455       virtual SMDSAbs_ElementType GetType() const      { return SMDSAbs_Volume; }
00456       virtual bool IsSatisfy( long theElementId );
00457     protected:
00458       const SMDS_Mesh* myMesh;
00459     };
00460     typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
00461 
00462     /*
00463       OverConstrainedFace
00464     */
00465     class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
00466     {
00467     public:
00468       OverConstrainedFace():myMesh(0) {}
00469       virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
00470       virtual SMDSAbs_ElementType GetType() const      { return SMDSAbs_Face; }
00471       virtual bool IsSatisfy( long theElementId );
00472     protected:
00473       const SMDS_Mesh* myMesh;
00474     };
00475     typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
00476 
00477     /*
00478       Class       : FreeEdges
00479       Description : Predicate for free Edges
00480     */
00481     class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
00482     public:
00483       FreeEdges();
00484       virtual void SetMesh( const SMDS_Mesh* theMesh );
00485       virtual bool IsSatisfy( long theElementId );
00486       virtual SMDSAbs_ElementType GetType() const;
00487       static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId  );
00488       typedef long TElemId;
00489       struct Border{
00490         TElemId myElemId;
00491         TElemId myPntId[2];
00492         Border(long theElemId, long thePntId1, long thePntId2);
00493         bool operator<(const Border& x) const;
00494       };
00495       typedef std::set<Border> TBorders;
00496       void GetBoreders(TBorders& theBorders);
00497 
00498     protected:
00499       const SMDS_Mesh* myMesh;
00500     };
00501     typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
00502     
00503     
00504     /*
00505       Class       : FreeNodes
00506       Description : Predicate for free nodes
00507     */
00508     class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
00509     public:
00510       FreeNodes();
00511       virtual void SetMesh( const SMDS_Mesh* theMesh );
00512       virtual bool IsSatisfy( long theNodeId );
00513       virtual SMDSAbs_ElementType GetType() const;
00514 
00515     protected:
00516       const SMDS_Mesh* myMesh;
00517     };
00518     
00519 
00520     /*
00521       Class       : RangeOfIds
00522       Description : Predicate for Range of Ids.
00523                     Range may be specified with two ways.
00524                     1. Using AddToRange method
00525                     2. With SetRangeStr method. Parameter of this method is a string
00526                        like as "1,2,3,50-60,63,67,70-"
00527     */
00528     class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
00529     {
00530     public:
00531                                     RangeOfIds();
00532       virtual void                  SetMesh( const SMDS_Mesh* theMesh );
00533       virtual bool                  IsSatisfy( long theNodeId );
00534       virtual SMDSAbs_ElementType   GetType() const;
00535       virtual void                  SetType( SMDSAbs_ElementType theType );
00536 
00537       bool                          AddToRange( long theEntityId );
00538       void                          GetRangeStr( TCollection_AsciiString& );
00539       bool                          SetRangeStr( const TCollection_AsciiString& );
00540 
00541     protected:
00542       const SMDS_Mesh*              myMesh;
00543 
00544       TColStd_SequenceOfInteger     myMin;
00545       TColStd_SequenceOfInteger     myMax;
00546       TColStd_MapOfInteger          myIds;
00547 
00548       SMDSAbs_ElementType           myType;
00549     };
00550     
00551     typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
00552    
00553     
00554     /*
00555       Class       : Comparator
00556       Description : Base class for comparators
00557     */
00558     class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
00559     public:
00560       Comparator();
00561       virtual ~Comparator();
00562       virtual void SetMesh( const SMDS_Mesh* theMesh );
00563       virtual void SetMargin(double theValue);
00564       virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
00565       virtual bool IsSatisfy( long theElementId ) = 0;
00566       virtual SMDSAbs_ElementType GetType() const;
00567       double  GetMargin();
00568   
00569     protected:
00570       double myMargin;
00571       NumericalFunctorPtr myFunctor;
00572     };
00573     typedef boost::shared_ptr<Comparator> ComparatorPtr;
00574   
00575   
00576     /*
00577       Class       : LessThan
00578       Description : Comparator "<"
00579     */
00580     class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
00581     public:
00582       virtual bool IsSatisfy( long theElementId );
00583     };
00584   
00585   
00586     /*
00587       Class       : MoreThan
00588       Description : Comparator ">"
00589     */
00590     class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
00591     public:
00592       virtual bool IsSatisfy( long theElementId );
00593     };
00594   
00595   
00596     /*
00597       Class       : EqualTo
00598       Description : Comparator "="
00599     */
00600     class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
00601     public:
00602       EqualTo();
00603       virtual bool IsSatisfy( long theElementId );
00604       virtual void SetTolerance( double theTol );
00605       virtual double GetTolerance();
00606   
00607     private:
00608       double myToler;
00609     };
00610     typedef boost::shared_ptr<EqualTo> EqualToPtr;
00611   
00612     
00613     /*
00614       Class       : LogicalNOT
00615       Description : Logical NOT predicate
00616     */
00617     class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
00618     public:
00619       LogicalNOT();
00620       virtual ~LogicalNOT();
00621       virtual bool IsSatisfy( long theElementId );
00622       virtual void SetMesh( const SMDS_Mesh* theMesh );
00623       virtual void SetPredicate(PredicatePtr thePred);
00624       virtual SMDSAbs_ElementType GetType() const;
00625   
00626     private:
00627       PredicatePtr myPredicate;
00628     };
00629     typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
00630     
00631   
00632     /*
00633       Class       : LogicalBinary
00634       Description : Base class for binary logical predicate
00635     */
00636     class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
00637     public:
00638       LogicalBinary();
00639       virtual ~LogicalBinary();
00640       virtual void SetMesh( const SMDS_Mesh* theMesh );
00641       virtual void SetPredicate1(PredicatePtr thePred);
00642       virtual void SetPredicate2(PredicatePtr thePred);
00643       virtual SMDSAbs_ElementType GetType() const;
00644   
00645     protected:
00646       PredicatePtr myPredicate1;
00647       PredicatePtr myPredicate2;
00648     };
00649     typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
00650   
00651   
00652     /*
00653       Class       : LogicalAND
00654       Description : Logical AND
00655     */
00656     class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
00657     public:
00658       virtual bool IsSatisfy( long theElementId );
00659     };
00660   
00661   
00662     /*
00663       Class       : LogicalOR
00664       Description : Logical OR
00665     */
00666     class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
00667     public:
00668       virtual bool IsSatisfy( long theElementId );
00669     };
00670   
00671   
00672     /*
00673       Class       : ManifoldPart
00674       Description : Predicate for manifold part of mesh
00675     */
00676     class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
00677     public:
00678 
00679       /* internal class for algorithm uses */
00680       class Link
00681       {
00682       public:
00683         Link( SMDS_MeshNode* theNode1,
00684               SMDS_MeshNode* theNode2 );
00685         ~Link();
00686         
00687         bool IsEqual( const ManifoldPart::Link& theLink ) const;
00688         bool operator<(const ManifoldPart::Link& x) const;
00689         
00690         SMDS_MeshNode* myNode1;
00691         SMDS_MeshNode* myNode2;
00692       };
00693 
00694       bool IsEqual( const ManifoldPart::Link& theLink1,
00695                     const ManifoldPart::Link& theLink2 );
00696       
00697       typedef std::set<ManifoldPart::Link>                TMapOfLink;
00698       typedef std::vector<SMDS_MeshFace*>                 TVectorOfFacePtr;
00699       typedef std::vector<ManifoldPart::Link>             TVectorOfLink;
00700       typedef std::map<SMDS_MeshFace*,int>                TDataMapFacePtrInt;
00701       typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
00702       
00703       ManifoldPart();
00704       ~ManifoldPart();
00705       virtual void SetMesh( const SMDS_Mesh* theMesh );
00706       // inoke when all parameters already set
00707       virtual bool IsSatisfy( long theElementId );
00708       virtual      SMDSAbs_ElementType GetType() const;
00709 
00710       void    SetAngleTolerance( const double theAngToler );
00711       double  GetAngleTolerance() const;
00712       void    SetIsOnlyManifold( const bool theIsOnly );
00713       void    SetStartElem( const long  theStartElemId );
00714 
00715     private:
00716       bool    process();
00717       bool    findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
00718                              SMDS_MeshFace*            theStartFace,
00719                              TMapOfLink&               theNonManifold,
00720                              TColStd_MapOfInteger&     theResFaces );
00721       bool    isInPlane( const SMDS_MeshFace* theFace1,
00722                           const SMDS_MeshFace* theFace2 );
00723       void    expandBoundary( TMapOfLink&            theMapOfBoundary,
00724                               TVectorOfLink&         theSeqOfBoundary,
00725                               TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
00726                               TMapOfLink&            theNonManifold,
00727                               SMDS_MeshFace*         theNextFace ) const;
00728 
00729      void     getFacesByLink( const Link& theLink,
00730                               TVectorOfFacePtr& theFaces ) const;
00731 
00732     private:
00733       const SMDS_Mesh*      myMesh;
00734       TColStd_MapOfInteger  myMapIds;
00735       TColStd_MapOfInteger  myMapBadGeomIds;
00736       TVectorOfFacePtr      myAllFacePtr;
00737       TDataMapFacePtrInt    myAllFacePtrIntDMap;
00738       double                myAngToler;
00739       bool                  myIsOnlyManifold;
00740       long                  myStartElemId;
00741 
00742     };
00743     typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
00744 
00745 
00746     /*
00747       Class       : ElementsOnSurface
00748       Description : Predicate elements that lying on indicated surface
00749                     (plane or cylinder)
00750     */
00751     class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
00752     public:
00753       ElementsOnSurface();
00754       ~ElementsOnSurface();
00755       virtual void SetMesh( const SMDS_Mesh* theMesh );
00756       virtual bool IsSatisfy( long theElementId );
00757       virtual      SMDSAbs_ElementType GetType() const;
00758 
00759       void    SetTolerance( const double theToler );
00760       double  GetTolerance() const;
00761       void    SetSurface( const TopoDS_Shape& theShape,
00762                           const SMDSAbs_ElementType theType );
00763       void    SetUseBoundaries( bool theUse );
00764       bool    GetUseBoundaries() const { return myUseBoundaries; }
00765 
00766     private:
00767       void    process();
00768       void    process( const SMDS_MeshElement* theElem  );
00769       bool    isOnSurface( const SMDS_MeshNode* theNode );
00770 
00771     private:
00772       const SMDS_Mesh*      myMesh;
00773       TColStd_MapOfInteger  myIds;
00774       SMDSAbs_ElementType   myType;
00775       //Handle(Geom_Surface)  mySurf;
00776       TopoDS_Face           mySurf;
00777       double                myToler;
00778       bool                  myUseBoundaries;
00779       GeomAPI_ProjectPointOnSurf myProjector;
00780     };
00781 
00782     typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
00783 
00784 
00785     /*
00786       Class       : ElementsOnShape
00787       Description : Predicate elements that lying on indicated shape
00788                     (1D, 2D or 3D)
00789     */
00790     class SMESHCONTROLS_EXPORT ElementsOnShape : public virtual Predicate
00791     {
00792     public:
00793       ElementsOnShape();
00794       ~ElementsOnShape();
00795 
00796       virtual void SetMesh (const SMDS_Mesh* theMesh);
00797       virtual bool IsSatisfy (long theElementId);
00798       virtual SMDSAbs_ElementType GetType() const;
00799 
00800       void    SetTolerance (const double theToler);
00801       double  GetTolerance() const;
00802       void    SetAllNodes (bool theAllNodes);
00803       bool    GetAllNodes() const { return myAllNodesFlag; }
00804       void    SetShape (const TopoDS_Shape& theShape,
00805                         const SMDSAbs_ElementType theType);
00806 
00807     private:
00808       void    addShape (const TopoDS_Shape& theShape);
00809       void    process();
00810       void    process (const SMDS_MeshElement* theElem);
00811 
00812     private:
00813       TMeshModifTracer      myMeshModifTracer;
00814       TColStd_MapOfInteger  myIds;
00815       SMDSAbs_ElementType   myType;
00816       TopoDS_Shape          myShape;
00817       double                myToler;
00818       bool                  myAllNodesFlag;
00819 
00820       TopTools_MapOfShape         myShapesMap;
00821       TopAbs_ShapeEnum            myCurShapeType; // type of current sub-shape
00822       BRepClass3d_SolidClassifier myCurSC;        // current SOLID
00823       GeomAPI_ProjectPointOnSurf  myCurProjFace;  // current FACE
00824       TopoDS_Face                 myCurFace;      // current FACE
00825       GeomAPI_ProjectPointOnCurve myCurProjEdge;  // current EDGE
00826       gp_Pnt                      myCurPnt;       // current VERTEX
00827     };
00828 
00829     typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
00830 
00831 
00832     /*
00833       Class       : FreeFaces
00834       Description : Predicate for free faces
00835     */
00836     class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
00837     public:
00838       FreeFaces();
00839       virtual void SetMesh( const SMDS_Mesh* theMesh );
00840       virtual bool IsSatisfy( long theElementId );
00841       virtual SMDSAbs_ElementType GetType() const;
00842 
00843     private:
00844       const SMDS_Mesh* myMesh;
00845     };
00846 
00847     /*
00848       Class       : LinearOrQuadratic
00849       Description : Predicate for free faces
00850     */
00851     class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
00852     public:
00853       LinearOrQuadratic();
00854       virtual void        SetMesh( const SMDS_Mesh* theMesh );
00855       virtual bool        IsSatisfy( long theElementId );
00856       void                SetType( SMDSAbs_ElementType theType );
00857       virtual SMDSAbs_ElementType GetType() const;
00858 
00859     private:
00860       const SMDS_Mesh*    myMesh;
00861       SMDSAbs_ElementType myType;
00862     };
00863     typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
00864 
00865     /*
00866       Class       : GroupColor
00867       Description : Functor for check color of group to whic mesh element belongs to
00868     */
00869     class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
00870     public:
00871       GroupColor();
00872       virtual void        SetMesh( const SMDS_Mesh* theMesh );
00873       virtual bool        IsSatisfy( long theElementId );
00874       void                SetType( SMDSAbs_ElementType theType );
00875       virtual             SMDSAbs_ElementType GetType() const;
00876       void                SetColorStr( const TCollection_AsciiString& );
00877       void                GetColorStr( TCollection_AsciiString& ) const;
00878       
00879     private:
00880       typedef std::set< long > TIDs;
00881 
00882       Quantity_Color      myColor;
00883       SMDSAbs_ElementType myType;
00884       TIDs                myIDs;
00885     };
00886     typedef boost::shared_ptr<GroupColor> GroupColorPtr;
00887 
00888     /*
00889       Class       : ElemGeomType
00890       Description : Predicate to check element geometry type
00891     */
00892     class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
00893     public:
00894       ElemGeomType();
00895       virtual void         SetMesh( const SMDS_Mesh* theMesh );
00896       virtual bool         IsSatisfy( long theElementId );
00897       void                 SetType( SMDSAbs_ElementType theType );
00898       virtual              SMDSAbs_ElementType GetType() const;
00899       void                 SetGeomType( SMDSAbs_GeometryType theType );
00900       virtual SMDSAbs_GeometryType GetGeomType() const;
00901 
00902     private:
00903       const SMDS_Mesh*     myMesh;
00904       SMDSAbs_ElementType  myType;
00905       SMDSAbs_GeometryType myGeomType;
00906     };
00907     typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
00908 
00909     /*
00910       Class       : CoplanarFaces
00911       Description : Predicate to check angle between faces
00912     */
00913     class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
00914     {
00915     public:
00916       CoplanarFaces();
00917       void                 SetFace( long theID )                   { myFaceID = theID; }
00918       long                 GetFace() const                         { return myFaceID; }
00919       void                 SetTolerance (const double theToler)    { myToler = theToler; }
00920       double               GetTolerance () const                   { return myToler; }
00921       virtual              SMDSAbs_ElementType GetType() const     { return SMDSAbs_Face; }
00922 
00923       virtual void         SetMesh( const SMDS_Mesh* theMesh );
00924       virtual bool         IsSatisfy( long theElementId );
00925 
00926     private:
00927       TMeshModifTracer     myMeshModifTracer;
00928       long                 myFaceID;
00929       double               myToler;
00930       std::set< long >     myCoplanarIDs;
00931     };
00932     typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
00933 
00934     /*
00935       FILTER
00936     */
00937     class SMESHCONTROLS_EXPORT Filter{
00938     public:
00939       Filter();
00940       virtual ~Filter();
00941       virtual void SetPredicate(PredicatePtr thePred);
00942 
00943       typedef std::vector<long> TIdSequence;
00944 
00945       virtual
00946       void
00947       GetElementsId( const SMDS_Mesh* theMesh,
00948                      TIdSequence& theSequence );
00949 
00950       static
00951       void
00952       GetElementsId( const SMDS_Mesh* theMesh,
00953                      PredicatePtr thePredicate,
00954                      TIdSequence& theSequence );
00955       
00956     protected:
00957       PredicatePtr myPredicate;
00958     };
00959   };
00960 };
00961 
00962 
00963 #endif