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