Salome HOME
Merge from V5_1_main 14/05/2010
[modules/smesh.git] / src / Controls / SMESH_ControlsDef.hxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef _SMESH_CONTROLSDEF_HXX_
24 #define _SMESH_CONTROLSDEF_HXX_
25
26 #include <set>
27 #include <map>
28 #include <vector>
29
30 #include <boost/shared_ptr.hpp>
31
32 #include <gp_XYZ.hxx>
33 #include <GeomAPI_ProjectPointOnSurf.hxx>
34 #include <GeomAPI_ProjectPointOnCurve.hxx>
35 #include <TColStd_SequenceOfInteger.hxx>
36 #include <TColStd_MapOfInteger.hxx>
37 #include <TCollection_AsciiString.hxx>
38 #include <TopAbs.hxx>
39 #include <TopoDS_Face.hxx>
40 #include <TopTools_MapOfShape.hxx>
41 #include <BRepClass3d_SolidClassifier.hxx>
42 #include <Quantity_Color.hxx>
43
44 #include "SMDSAbs_ElementType.hxx"
45 #include "SMDS_MeshNode.hxx"
46
47 #include "SMESH_Controls.hxx"
48
49 #ifdef WNT
50  #if defined SMESHCONTROLS_EXPORTS || defined SMESHControls_EXPORTS
51   #define SMESHCONTROLS_EXPORT __declspec( dllexport )
52  #else
53   #define SMESHCONTROLS_EXPORT __declspec( dllimport )
54  #endif
55 #else
56  #define SMESHCONTROLS_EXPORT
57 #endif
58
59 class SMDS_MeshElement;
60 class SMDS_MeshFace;
61 class SMDS_MeshNode;
62 class SMDS_Mesh;
63
64 class SMESHDS_Mesh;
65 class SMESHDS_SubMesh;
66
67 class gp_Pnt;
68
69 namespace SMESH{
70   namespace Controls{
71
72     class SMESHCONTROLS_EXPORT TSequenceOfXYZ
73     {
74       typedef std::vector<gp_XYZ>::size_type size_type;
75
76     public:
77       TSequenceOfXYZ();
78
79       TSequenceOfXYZ(size_type n);
80
81       TSequenceOfXYZ(size_type n, const gp_XYZ& t);
82
83       TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ);
84
85       template <class InputIterator>
86       TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd);
87
88       ~TSequenceOfXYZ();
89
90       TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ);
91
92       gp_XYZ& operator()(size_type n);
93
94       const gp_XYZ& operator()(size_type n) const;
95
96       void clear();
97
98       void reserve(size_type n);
99
100       void push_back(const gp_XYZ& v);
101
102       size_type size() const;
103
104     private:
105       std::vector<gp_XYZ> myArray;
106     };
107
108     /*
109       Class       : Functor
110       Description : Root of all Functors
111     */
112     class SMESHCONTROLS_EXPORT Functor
113     {
114     public:
115       ~Functor(){}
116       virtual void SetMesh( const SMDS_Mesh* theMesh ) = 0;
117       virtual SMDSAbs_ElementType GetType() const = 0;
118     };
119
120     /*
121       Class       : NumericalFunctor
122       Description : Root of all Functors returning numeric value
123     */
124     class SMESHCONTROLS_EXPORT NumericalFunctor: public virtual Functor{
125     public:
126       NumericalFunctor();
127       virtual void SetMesh( const SMDS_Mesh* theMesh );
128       virtual double GetValue( long theElementId );
129       virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
130       virtual SMDSAbs_ElementType GetType() const = 0;
131       virtual double GetBadRate( double Value, int nbNodes ) const = 0;
132       long  GetPrecision() const;
133       void  SetPrecision( const long thePrecision );
134       
135       bool GetPoints(const int theId,
136                      TSequenceOfXYZ& theRes) const;
137       static bool GetPoints(const SMDS_MeshElement* theElem,
138                             TSequenceOfXYZ& theRes);
139     protected:
140       const SMDS_Mesh* myMesh;
141       const SMDS_MeshElement* myCurrElement;
142       long       myPrecision;
143     };
144
145
146     /*
147       Class       : Volume
148       Description : Functor calculating volume of 3D mesh element
149     */
150     class SMESHCONTROLS_EXPORT Volume: public virtual NumericalFunctor{
151     public:
152       virtual double GetValue( long theElementId );
153       //virtual double GetValue( const TSequenceOfXYZ& thePoints );
154       virtual double GetBadRate( double Value, int nbNodes ) const;
155       virtual SMDSAbs_ElementType GetType() const;
156     };
157   
158   
159     /*
160       Class       : SMESH_MinimumAngle
161       Description : Functor for calculation of minimum angle
162     */
163     class SMESHCONTROLS_EXPORT MinimumAngle: public virtual NumericalFunctor{
164     public:
165       virtual double GetValue( const TSequenceOfXYZ& thePoints );
166       virtual double GetBadRate( double Value, int nbNodes ) const;
167       virtual SMDSAbs_ElementType GetType() const;
168     };
169   
170   
171     /*
172       Class       : AspectRatio
173       Description : Functor for calculating aspect ratio
174     */
175     class SMESHCONTROLS_EXPORT AspectRatio: public virtual NumericalFunctor{
176     public:
177       virtual double GetValue( const TSequenceOfXYZ& thePoints );
178       virtual double GetBadRate( double Value, int nbNodes ) const;
179       virtual SMDSAbs_ElementType GetType() const;
180     };
181   
182   
183     /*
184       Class       : AspectRatio3D
185       Description : Functor for calculating aspect ratio of 3D elems.
186     */
187     class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
188     public:
189       virtual double GetValue( const TSequenceOfXYZ& thePoints );
190       virtual double GetBadRate( double Value, int nbNodes ) const;
191       virtual SMDSAbs_ElementType GetType() const;
192     };
193   
194   
195     /*
196       Class       : Warping
197       Description : Functor for calculating warping
198     */
199     class SMESHCONTROLS_EXPORT Warping: public virtual NumericalFunctor{
200     public:
201       virtual double GetValue( const TSequenceOfXYZ& thePoints );
202       virtual double GetBadRate( double Value, int nbNodes ) const;
203       virtual SMDSAbs_ElementType GetType() const;
204       
205     private:
206       double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
207     };
208   
209   
210     /*
211       Class       : Taper
212       Description : Functor for calculating taper
213     */
214     class SMESHCONTROLS_EXPORT Taper: public virtual NumericalFunctor{
215     public:
216       virtual double GetValue( const TSequenceOfXYZ& thePoints );
217       virtual double GetBadRate( double Value, int nbNodes ) const;
218       virtual SMDSAbs_ElementType GetType() const;
219     };
220
221
222     /*
223       Class       : Skew
224       Description : Functor for calculating skew in degrees
225     */
226     class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
227     public:
228       virtual double GetValue( const TSequenceOfXYZ& thePoints );
229       virtual double GetBadRate( double Value, int nbNodes ) const;
230       virtual SMDSAbs_ElementType GetType() const;
231     };
232
233
234     /*
235       Class       : Area
236       Description : Functor for calculating area
237     */
238     class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
239     public:
240       virtual double GetValue( const TSequenceOfXYZ& thePoints );
241       virtual double GetBadRate( double Value, int nbNodes ) const;
242       virtual SMDSAbs_ElementType GetType() const;
243     };
244   
245   
246     /*
247       Class       : Length
248       Description : Functor for calculating length of edge
249     */
250     class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
251     public:
252       virtual double GetValue( const TSequenceOfXYZ& thePoints );
253       virtual double GetBadRate( double Value, int nbNodes ) const;
254       virtual SMDSAbs_ElementType GetType() const;
255     };
256
257     /*
258       Class       : Length2D
259       Description : Functor for calculating length of edge
260     */
261     class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
262     public:
263       virtual double GetValue( long theElementId );
264       virtual double GetBadRate( double Value, int nbNodes ) const;
265       virtual SMDSAbs_ElementType GetType() const;
266       struct Value{
267         double myLength;
268         long myPntId[2];
269         Value(double theLength, long thePntId1, long thePntId2);
270         bool operator<(const Value& x) const;
271       };
272       typedef std::set<Value> TValues;
273       void GetValues(TValues& theValues);
274     };
275     typedef boost::shared_ptr<Length2D> Length2DPtr;
276
277     /*
278       Class       : MultiConnection
279       Description : Functor for calculating number of faces conneted to the edge
280     */
281     class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
282     public:
283       virtual double GetValue( long theElementId );
284       virtual double GetValue( const TSequenceOfXYZ& thePoints );
285       virtual double GetBadRate( double Value, int nbNodes ) const;
286       virtual SMDSAbs_ElementType GetType() const;
287     };
288     
289     /*
290       Class       : MultiConnection2D
291       Description : Functor for calculating number of faces conneted to the edge
292     */
293     class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
294     public:
295       virtual double GetValue( long theElementId );
296       virtual double GetValue( const TSequenceOfXYZ& thePoints );
297       virtual double GetBadRate( double Value, int nbNodes ) const;
298       virtual SMDSAbs_ElementType GetType() const;
299       struct Value{
300         long myPntId[2];
301         Value(long thePntId1, long thePntId2);
302         bool operator<(const Value& x) const;
303       };
304       typedef std::map<Value,int> MValues;
305
306       void GetValues(MValues& theValues);
307     };
308     typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
309     /*
310       PREDICATES
311     */
312     /*
313       Class       : Predicate
314       Description : Base class for all predicates
315     */
316     class SMESHCONTROLS_EXPORT Predicate: public virtual Functor{
317     public:
318       virtual bool IsSatisfy( long theElementId ) = 0;
319       virtual SMDSAbs_ElementType GetType() const = 0;
320     };
321   
322   
323     /*
324       Class       : FreeBorders
325       Description : Predicate for free borders
326     */
327     class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
328     public:
329       FreeBorders();
330       virtual void SetMesh( const SMDS_Mesh* theMesh );
331       virtual bool IsSatisfy( long theElementId );
332       virtual SMDSAbs_ElementType GetType() const;
333
334     protected:
335       const SMDS_Mesh* myMesh;
336     };
337    
338
339     /*
340       Class       : BadOrientedVolume
341       Description : Predicate bad oriented volumes
342     */
343     class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
344     public:
345       BadOrientedVolume();
346       virtual void SetMesh( const SMDS_Mesh* theMesh );
347       virtual bool IsSatisfy( long theElementId );
348       virtual SMDSAbs_ElementType GetType() const;
349             
350     protected:
351       const SMDS_Mesh* myMesh;
352     };
353    
354
355     /*
356       Class       : FreeEdges
357       Description : Predicate for free Edges
358     */
359     class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
360     public:
361       FreeEdges();
362       virtual void SetMesh( const SMDS_Mesh* theMesh );
363       virtual bool IsSatisfy( long theElementId );
364       virtual SMDSAbs_ElementType GetType() const;
365       static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId  );
366       typedef long TElemId;
367       struct Border{
368         TElemId myElemId;
369         TElemId myPntId[2];
370         Border(long theElemId, long thePntId1, long thePntId2);
371         bool operator<(const Border& x) const;
372       };
373       typedef std::set<Border> TBorders;
374       void GetBoreders(TBorders& theBorders);
375       
376     protected:
377       const SMDS_Mesh* myMesh;
378     };
379     typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
380     
381     
382     /*
383       Class       : FreeNodes
384       Description : Predicate for free nodes
385     */
386     class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
387     public:
388       FreeNodes();
389       virtual void SetMesh( const SMDS_Mesh* theMesh );
390       virtual bool IsSatisfy( long theNodeId );
391       virtual SMDSAbs_ElementType GetType() const;
392
393     protected:
394       const SMDS_Mesh* myMesh;
395     };
396     
397
398     /*
399       Class       : RangeOfIds
400       Description : Predicate for Range of Ids.
401                     Range may be specified with two ways.
402                     1. Using AddToRange method
403                     2. With SetRangeStr method. Parameter of this method is a string
404                        like as "1,2,3,50-60,63,67,70-"
405     */
406     class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
407     {
408     public:
409                                     RangeOfIds();
410       virtual void                  SetMesh( const SMDS_Mesh* theMesh );
411       virtual bool                  IsSatisfy( long theNodeId );
412       virtual SMDSAbs_ElementType   GetType() const;
413       virtual void                  SetType( SMDSAbs_ElementType theType );
414
415       bool                          AddToRange( long theEntityId );
416       void                          GetRangeStr( TCollection_AsciiString& );
417       bool                          SetRangeStr( const TCollection_AsciiString& );
418
419     protected:
420       const SMDS_Mesh*              myMesh;
421
422       TColStd_SequenceOfInteger     myMin;
423       TColStd_SequenceOfInteger     myMax;
424       TColStd_MapOfInteger          myIds;
425
426       SMDSAbs_ElementType           myType;
427     };
428     
429     typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
430    
431     
432     /*
433       Class       : Comparator
434       Description : Base class for comparators
435     */
436     class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
437     public:
438       Comparator();
439       virtual ~Comparator();
440       virtual void SetMesh( const SMDS_Mesh* theMesh );
441       virtual void SetMargin(double theValue);
442       virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
443       virtual bool IsSatisfy( long theElementId ) = 0;
444       virtual SMDSAbs_ElementType GetType() const;
445       double  GetMargin();
446   
447     protected:
448       double myMargin;
449       NumericalFunctorPtr myFunctor;
450     };
451     typedef boost::shared_ptr<Comparator> ComparatorPtr;
452   
453   
454     /*
455       Class       : LessThan
456       Description : Comparator "<"
457     */
458     class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
459     public:
460       virtual bool IsSatisfy( long theElementId );
461     };
462   
463   
464     /*
465       Class       : MoreThan
466       Description : Comparator ">"
467     */
468     class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
469     public:
470       virtual bool IsSatisfy( long theElementId );
471     };
472   
473   
474     /*
475       Class       : EqualTo
476       Description : Comparator "="
477     */
478     class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
479     public:
480       EqualTo();
481       virtual bool IsSatisfy( long theElementId );
482       virtual void SetTolerance( double theTol );
483       virtual double GetTolerance();
484   
485     private:
486       double myToler;
487     };
488     typedef boost::shared_ptr<EqualTo> EqualToPtr;
489   
490     
491     /*
492       Class       : LogicalNOT
493       Description : Logical NOT predicate
494     */
495     class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
496     public:
497       LogicalNOT();
498       virtual ~LogicalNOT();
499       virtual bool IsSatisfy( long theElementId );
500       virtual void SetMesh( const SMDS_Mesh* theMesh );
501       virtual void SetPredicate(PredicatePtr thePred);
502       virtual SMDSAbs_ElementType GetType() const;
503   
504     private:
505       PredicatePtr myPredicate;
506     };
507     typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
508     
509   
510     /*
511       Class       : LogicalBinary
512       Description : Base class for binary logical predicate
513     */
514     class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
515     public:
516       LogicalBinary();
517       virtual ~LogicalBinary();
518       virtual void SetMesh( const SMDS_Mesh* theMesh );
519       virtual void SetPredicate1(PredicatePtr thePred);
520       virtual void SetPredicate2(PredicatePtr thePred);
521       virtual SMDSAbs_ElementType GetType() const;
522   
523     protected:
524       PredicatePtr myPredicate1;
525       PredicatePtr myPredicate2;
526     };
527     typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
528   
529   
530     /*
531       Class       : LogicalAND
532       Description : Logical AND
533     */
534     class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
535     public:
536       virtual bool IsSatisfy( long theElementId );
537     };
538   
539   
540     /*
541       Class       : LogicalOR
542       Description : Logical OR
543     */
544     class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
545     public:
546       virtual bool IsSatisfy( long theElementId );
547     };
548   
549   
550     /*
551       Class       : ManifoldPart
552       Description : Predicate for manifold part of mesh
553     */
554     class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
555     public:
556
557       /* internal class for algorithm uses */
558       class Link
559       {
560       public:
561         Link( SMDS_MeshNode* theNode1,
562               SMDS_MeshNode* theNode2 );
563         ~Link();
564         
565         bool IsEqual( const ManifoldPart::Link& theLink ) const;
566         bool operator<(const ManifoldPart::Link& x) const;
567         
568         SMDS_MeshNode* myNode1;
569         SMDS_MeshNode* myNode2;
570       };
571
572       bool IsEqual( const ManifoldPart::Link& theLink1,
573                     const ManifoldPart::Link& theLink2 );
574       
575       typedef std::set<ManifoldPart::Link>                TMapOfLink;
576       typedef std::vector<SMDS_MeshFace*>                 TVectorOfFacePtr;
577       typedef std::vector<ManifoldPart::Link>             TVectorOfLink;
578       typedef std::map<SMDS_MeshFace*,int>                TDataMapFacePtrInt;
579       typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
580       
581       ManifoldPart();
582       ~ManifoldPart();
583       virtual void SetMesh( const SMDS_Mesh* theMesh );
584       // inoke when all parameters already set
585       virtual bool IsSatisfy( long theElementId );
586       virtual      SMDSAbs_ElementType GetType() const;
587
588       void    SetAngleTolerance( const double theAngToler );
589       double  GetAngleTolerance() const;
590       void    SetIsOnlyManifold( const bool theIsOnly );
591       void    SetStartElem( const long  theStartElemId );
592
593     private:
594       bool    process();
595       bool    findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
596                              SMDS_MeshFace*            theStartFace,
597                              TMapOfLink&               theNonManifold,
598                              TColStd_MapOfInteger&     theResFaces );
599       bool    isInPlane( const SMDS_MeshFace* theFace1,
600                           const SMDS_MeshFace* theFace2 );
601       void    expandBoundary( TMapOfLink&            theMapOfBoundary,
602                               TVectorOfLink&         theSeqOfBoundary,
603                               TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
604                               TMapOfLink&            theNonManifold,
605                               SMDS_MeshFace*         theNextFace ) const;
606
607      void     getFacesByLink( const Link& theLink,
608                               TVectorOfFacePtr& theFaces ) const;
609
610     private:
611       const SMDS_Mesh*      myMesh;
612       TColStd_MapOfInteger  myMapIds;
613       TColStd_MapOfInteger  myMapBadGeomIds;
614       TVectorOfFacePtr      myAllFacePtr;
615       TDataMapFacePtrInt    myAllFacePtrIntDMap;
616       double                myAngToler;
617       bool                  myIsOnlyManifold;
618       long                  myStartElemId;
619
620     };
621     typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
622
623
624     /*
625       Class       : ElementsOnSurface
626       Description : Predicate elements that lying on indicated surface
627                     (plane or cylinder)
628     */
629     class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
630     public:
631       ElementsOnSurface();
632       ~ElementsOnSurface();
633       virtual void SetMesh( const SMDS_Mesh* theMesh );
634       virtual bool IsSatisfy( long theElementId );
635       virtual      SMDSAbs_ElementType GetType() const;
636
637       void    SetTolerance( const double theToler );
638       double  GetTolerance() const;
639       void    SetSurface( const TopoDS_Shape& theShape,
640                           const SMDSAbs_ElementType theType );
641       void    SetUseBoundaries( bool theUse );
642       bool    GetUseBoundaries() const { return myUseBoundaries; }
643
644     private:
645       void    process();
646       void    process( const SMDS_MeshElement* theElem  );
647       bool    isOnSurface( const SMDS_MeshNode* theNode );
648
649     private:
650       const SMDS_Mesh*      myMesh;
651       TColStd_MapOfInteger  myIds;
652       SMDSAbs_ElementType   myType;
653       //Handle(Geom_Surface)  mySurf;
654       TopoDS_Face           mySurf;
655       double                myToler;
656       bool                  myUseBoundaries;
657       GeomAPI_ProjectPointOnSurf myProjector;
658     };
659
660     typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
661
662
663     /*
664       Class       : ElementsOnShape
665       Description : Predicate elements that lying on indicated shape
666                     (1D, 2D or 3D)
667     */
668     class SMESHCONTROLS_EXPORT ElementsOnShape : public virtual Predicate
669     {
670     public:
671       ElementsOnShape();
672       ~ElementsOnShape();
673
674       virtual void SetMesh (const SMDS_Mesh* theMesh);
675       virtual bool IsSatisfy (long theElementId);
676       virtual SMDSAbs_ElementType GetType() const;
677
678       void    SetTolerance (const double theToler);
679       double  GetTolerance() const;
680       void    SetAllNodes (bool theAllNodes);
681       bool    GetAllNodes() const { return myAllNodesFlag; }
682       void    SetShape (const TopoDS_Shape& theShape,
683                         const SMDSAbs_ElementType theType);
684
685     private:
686       void    addShape (const TopoDS_Shape& theShape);
687       void    process();
688       void    process (const SMDS_MeshElement* theElem);
689
690     private:
691       const SMDS_Mesh*      myMesh;
692       TColStd_MapOfInteger  myIds;
693       SMDSAbs_ElementType   myType;
694       TopoDS_Shape          myShape;
695       double                myToler;
696       bool                  myAllNodesFlag;
697
698       TopTools_MapOfShape         myShapesMap;
699       TopAbs_ShapeEnum            myCurShapeType; // type of current sub-shape
700       BRepClass3d_SolidClassifier myCurSC;        // current SOLID
701       GeomAPI_ProjectPointOnSurf  myCurProjFace;  // current FACE
702       TopoDS_Face                 myCurFace;      // current FACE
703       GeomAPI_ProjectPointOnCurve myCurProjEdge;  // current EDGE
704       gp_Pnt                      myCurPnt;       // current VERTEX
705     };
706
707     typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
708
709
710     /*
711       Class       : FreeFaces
712       Description : Predicate for free faces
713     */
714     class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
715     public:
716       FreeFaces();
717       virtual void SetMesh( const SMDS_Mesh* theMesh );
718       virtual bool IsSatisfy( long theElementId );
719       virtual SMDSAbs_ElementType GetType() const;
720
721     private:
722       const SMDS_Mesh* myMesh;
723     };
724
725     /*
726       Class       : LinearOrQuadratic
727       Description : Predicate for free faces
728     */
729     class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
730     public:
731       LinearOrQuadratic();
732       virtual void        SetMesh( const SMDS_Mesh* theMesh );
733       virtual bool        IsSatisfy( long theElementId );
734       void                SetType( SMDSAbs_ElementType theType );
735       virtual SMDSAbs_ElementType GetType() const;
736
737     private:
738       const SMDS_Mesh*    myMesh;
739       SMDSAbs_ElementType myType;
740     };
741     typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
742
743     /*
744       Class       : GroupColor
745       Description : Functor for check color of group to whic mesh element belongs to
746     */
747     class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
748     public:
749       GroupColor();
750       virtual void        SetMesh( const SMDS_Mesh* theMesh );
751       virtual bool        IsSatisfy( long theElementId );
752       void                SetType( SMDSAbs_ElementType theType );
753       virtual             SMDSAbs_ElementType GetType() const;
754       void                SetColorStr( const TCollection_AsciiString& );
755       void                GetColorStr( TCollection_AsciiString& ) const;
756       
757     private:
758       typedef std::set< long > TIDs;
759
760       Quantity_Color      myColor;
761       SMDSAbs_ElementType myType;
762       TIDs                myIDs;
763     };
764     typedef boost::shared_ptr<GroupColor> GroupColorPtr;
765
766     /*
767       Class       : ElemGeomType
768       Description : Predicate to check element geometry type
769     */
770     class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
771     public:
772       ElemGeomType();
773       virtual void        SetMesh( const SMDS_Mesh* theMesh );
774       virtual bool        IsSatisfy( long theElementId );
775       void                SetType( SMDSAbs_ElementType theType );
776       virtual             SMDSAbs_ElementType GetType() const;
777       void                SetGeomType( SMDSAbs_GeometryType theType );
778       virtual SMDSAbs_GeometryType GetGeomType() const;
779
780     private:
781       const SMDS_Mesh*     myMesh;
782       SMDSAbs_ElementType  myType;
783       SMDSAbs_GeometryType myGeomType;
784     };
785     typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
786
787     /*
788       FILTER
789     */
790     class SMESHCONTROLS_EXPORT Filter{
791     public:
792       Filter();
793       virtual ~Filter();
794       virtual void SetPredicate(PredicatePtr thePred);
795
796       typedef std::vector<long> TIdSequence;
797
798       virtual
799       void
800       GetElementsId( const SMDS_Mesh* theMesh,
801                      TIdSequence& theSequence );
802
803       static
804       void
805       GetElementsId( const SMDS_Mesh* theMesh,
806                      PredicatePtr thePredicate,
807                      TIdSequence& theSequence );
808       
809     protected:
810       PredicatePtr myPredicate;
811     };
812   };
813 };
814
815
816 #endif