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