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