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