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