Version: 8.3.0
SMESH_ControlsDef.hxx
Go to the documentation of this file.
1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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 "SMESH_Controls.hxx"
27 
28 #include "SMESH_TypeDefs.hxx"
29 
30 #include <BRepClass3d_SolidClassifier.hxx>
31 #include <Bnd_B3d.hxx>
32 #include <GeomAPI_ProjectPointOnCurve.hxx>
33 #include <GeomAPI_ProjectPointOnSurf.hxx>
34 #include <Quantity_Color.hxx>
35 #include <TColStd_MapOfInteger.hxx>
36 #include <TColStd_SequenceOfInteger.hxx>
37 #include <TCollection_AsciiString.hxx>
38 #include <TopAbs.hxx>
39 #include <TopoDS_Face.hxx>
40 #include <gp_XYZ.hxx>
41 
42 #include <set>
43 #include <map>
44 #include <vector>
45 
46 #include <boost/shared_ptr.hpp>
47 
48 class SMDS_MeshElement;
49 class SMDS_MeshFace;
50 class SMDS_MeshNode;
51 class SMDS_Mesh;
52 
53 class SMESHDS_Mesh;
54 class SMESHDS_SubMesh;
55 class SMESHDS_GroupBase;
56 
57 class gp_Pnt;
58 
59 namespace SMESH{
60  namespace Controls{
61 
63  {
64  typedef std::vector<gp_XYZ>::size_type size_type;
65 
66  public:
68 
69  explicit TSequenceOfXYZ(size_type n);
70 
71  TSequenceOfXYZ(size_type n, const gp_XYZ& t);
72 
73  TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ);
74 
75  template <class InputIterator>
76  TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd);
77 
78  ~TSequenceOfXYZ();
79 
80  TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ);
81 
82  gp_XYZ& operator()(size_type n);
83 
84  const gp_XYZ& operator()(size_type n) const;
85 
86  void clear();
87 
88  void reserve(size_type n);
89 
90  void push_back(const gp_XYZ& v);
91 
92  size_type size() const;
93 
94 
95  void setElement(const SMDS_MeshElement* e) { myElem = e; }
96 
97  const SMDS_MeshElement* getElement() const { return myElem; }
98 
99  SMDSAbs_EntityType getElementEntity() const;
100 
101  private:
102  std::vector<gp_XYZ> myArray;
104  };
105 
111  {
112  unsigned long myMeshModifTime;
114  public:
116  void SetMesh( const SMDS_Mesh* theMesh );
117  const SMDS_Mesh* GetMesh() const { return myMesh; }
118  bool IsMeshModified();
119  };
120 
121  /*
122  Class : NumericalFunctor
123  Description : Root of all Functors returning numeric value
124  */
126  public:
128  virtual void SetMesh( const SMDS_Mesh* theMesh );
129  virtual double GetValue( long theElementId );
130  virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
131  void GetHistogram(int nbIntervals,
132  std::vector<int>& nbEvents,
133  std::vector<double>& funValues,
134  const std::vector<int>& elements,
135  const double* minmax=0,
136  const bool isLogarithmic = false);
137  virtual SMDSAbs_ElementType GetType() const = 0;
138  virtual double GetBadRate( double Value, int nbNodes ) const = 0;
139  long GetPrecision() const;
140  void SetPrecision( const long thePrecision );
141  double Round( const double & value );
142 
143  bool GetPoints(const int theId, TSequenceOfXYZ& theRes) const;
144  static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes);
145  protected:
150  };
151 
152 
153  /*
154  Class : Volume
155  Description : Functor calculating volume of 3D mesh element
156  */
158  public:
159  virtual double GetValue( long theElementId );
160  //virtual double GetValue( const TSequenceOfXYZ& thePoints );
161  virtual double GetBadRate( double Value, int nbNodes ) const;
162  virtual SMDSAbs_ElementType GetType() const;
163  };
164 
165 
166  /*
167  Class : MaxElementLength2D
168  Description : Functor calculating maximum length of 2D element
169  */
171  public:
172  virtual double GetValue( long theElementId );
173  virtual double GetValue( const TSequenceOfXYZ& P );
174  virtual double GetBadRate( double Value, int nbNodes ) const;
175  virtual SMDSAbs_ElementType GetType() const;
176  };
177 
178 
179  /*
180  Class : MaxElementLength3D
181  Description : Functor calculating maximum length of 3D element
182  */
184  public:
185  virtual double GetValue( long theElementId );
186  virtual double GetBadRate( double Value, int nbNodes ) const;
187  virtual SMDSAbs_ElementType GetType() const;
188  };
189 
190 
191  /*
192  Class : SMESH_MinimumAngle
193  Description : Functor for calculation of minimum angle
194  */
196  public:
197  virtual double GetValue( const TSequenceOfXYZ& thePoints );
198  virtual double GetBadRate( double Value, int nbNodes ) const;
199  virtual SMDSAbs_ElementType GetType() const;
200  };
201 
202 
203  /*
204  Class : AspectRatio
205  Description : Functor for calculating aspect ratio
206  */
208  public:
209  virtual double GetValue( long theElementId );
210  virtual double GetValue( const TSequenceOfXYZ& thePoints );
211  virtual double GetBadRate( double Value, int nbNodes ) const;
212  virtual SMDSAbs_ElementType GetType() const;
213  };
214 
215 
216  /*
217  Class : AspectRatio3D
218  Description : Functor for calculating aspect ratio of 3D elems.
219  */
221  public:
222  virtual double GetValue( long theElementId );
223  virtual double GetValue( const TSequenceOfXYZ& thePoints );
224  virtual double GetBadRate( double Value, int nbNodes ) const;
225  virtual SMDSAbs_ElementType GetType() const;
226  };
227 
228 
229  /*
230  Class : Warping
231  Description : Functor for calculating warping
232  */
234  public:
235  virtual double GetValue( const TSequenceOfXYZ& thePoints );
236  virtual double GetBadRate( double Value, int nbNodes ) const;
237  virtual SMDSAbs_ElementType GetType() const;
238 
239  private:
240  double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
241  };
242 
243 
244  /*
245  Class : Taper
246  Description : Functor for calculating taper
247  */
249  public:
250  virtual double GetValue( const TSequenceOfXYZ& thePoints );
251  virtual double GetBadRate( double Value, int nbNodes ) const;
252  virtual SMDSAbs_ElementType GetType() const;
253  };
254 
255  /*
256  Class : Skew
257  Description : Functor for calculating skew in degrees
258  */
260  public:
261  virtual double GetValue( const TSequenceOfXYZ& thePoints );
262  virtual double GetBadRate( double Value, int nbNodes ) const;
263  virtual SMDSAbs_ElementType GetType() const;
264  };
265 
266 
267  /*
268  Class : Area
269  Description : Functor for calculating area
270  */
272  public:
273  virtual double GetValue( const TSequenceOfXYZ& thePoints );
274  virtual double GetBadRate( double Value, int nbNodes ) const;
275  virtual SMDSAbs_ElementType GetType() const;
276  };
277 
278 
279  /*
280  Class : Length
281  Description : Functor for calculating length of edge
282  */
284  public:
285  virtual double GetValue( const TSequenceOfXYZ& thePoints );
286  virtual double GetBadRate( double Value, int nbNodes ) const;
287  virtual SMDSAbs_ElementType GetType() const;
288  };
289 
290  /*
291  Class : Length2D
292  Description : Functor for calculating length of edge
293  */
295  public:
296  virtual double GetValue( long theElementId );
297  virtual double GetBadRate( double Value, int nbNodes ) const;
298  virtual SMDSAbs_ElementType GetType() const;
299  struct Value{
300  double myLength;
301  long myPntId[2];
302  Value(double theLength, long thePntId1, long thePntId2);
303  bool operator<(const Value& x) const;
304  };
305  typedef std::set<Value> TValues;
306  void GetValues(TValues& theValues);
307  };
308  typedef boost::shared_ptr<Length2D> Length2DPtr;
309 
310  /*
311  Class : MultiConnection
312  Description : Functor for calculating number of faces connected to the edge
313  */
315  public:
316  virtual double GetValue( long theElementId );
317  virtual double GetValue( const TSequenceOfXYZ& thePoints );
318  virtual double GetBadRate( double Value, int nbNodes ) const;
319  virtual SMDSAbs_ElementType GetType() const;
320  };
321 
322  /*
323  Class : MultiConnection2D
324  Description : Functor for calculating number of faces connected to the edge
325  */
327  public:
328  virtual double GetValue( long theElementId );
329  virtual double GetValue( const TSequenceOfXYZ& thePoints );
330  virtual double GetBadRate( double Value, int nbNodes ) const;
331  virtual SMDSAbs_ElementType GetType() const;
332  struct Value{
333  long myPntId[2];
334  Value(long thePntId1, long thePntId2);
335  bool operator<(const Value& x) const;
336  };
337  typedef std::map<Value,int> MValues;
338 
339  void GetValues(MValues& theValues);
340  };
341  typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
342 
343  /*
344  Class : BallDiameter
345  Description : Functor returning diameter of a ball element
346  */
348  public:
349  virtual double GetValue( long theElementId );
350  virtual double GetBadRate( double Value, int nbNodes ) const;
351  virtual SMDSAbs_ElementType GetType() const;
352  };
353 
354  /*
355  Class : NodeConnectivityNumber
356  Description : Functor returning number of elements connected to a node
357  */
359  public:
360  virtual double GetValue( long theNodeId );
361  virtual double GetBadRate( double Value, int nbNodes ) const;
362  virtual SMDSAbs_ElementType GetType() const;
363  };
364 
365 
366  /*
367  PREDICATES
368  */
369  /*
370  Class : CoincidentNodes
371  Description : Predicate of Coincident Nodes
372  Note : This class is suitable only for visualization of Coincident Nodes
373  */
375  public:
376  CoincidentNodes();
377  //virtual Predicate* clone() const { return new CoincidentNodes( *this ); }
378  virtual void SetMesh( const SMDS_Mesh* theMesh );
379  virtual bool IsSatisfy( long theElementId );
380  virtual SMDSAbs_ElementType GetType() const;
381 
382  void SetTolerance (const double theToler) { myToler = theToler; }
383  double GetTolerance () const { return myToler; }
384 
385  private:
386  double myToler;
387  TColStd_MapOfInteger myCoincidentIDs;
389  };
390  typedef boost::shared_ptr<CoincidentNodes> CoincidentNodesPtr;
391 
392  /*
393  Class : CoincidentElements
394  Description : Predicate of Coincident Elements
395  Note : This class is suitable only for visualization of Coincident Elements
396  */
398  public:
400  virtual void SetMesh( const SMDS_Mesh* theMesh );
401  virtual bool IsSatisfy( long theElementId );
402 
403  private:
405  };
407  public:
408  virtual SMDSAbs_ElementType GetType() const;
409  //virtual Predicate* clone() const { return new CoincidentElements1D( *this ); }
410  };
412  public:
413  virtual SMDSAbs_ElementType GetType() const;
414  //virtual Predicate* clone() const { return new CoincidentElements2D( *this ); }
415  };
417  public:
418  virtual SMDSAbs_ElementType GetType() const;
419  //virtual Predicate* clone() const { return new CoincidentElements3D( *this ); }
420  };
421 
422  /*
423  Class : FreeBorders
424  Description : Predicate for free borders
425  */
427  public:
428  FreeBorders();
429  //virtual Predicate* clone() const { return new FreeBorders( *this ); }
430  virtual void SetMesh( const SMDS_Mesh* theMesh );
431  virtual bool IsSatisfy( long theElementId );
432  virtual SMDSAbs_ElementType GetType() const;
433 
434  protected:
436  };
437 
438 
439  /*
440  Class : BadOrientedVolume
441  Description : Predicate bad oriented volumes
442  */
444  public:
446  //virtual Predicate* clone() const { return new BadOrientedVolume( *this ); }
447  virtual void SetMesh( const SMDS_Mesh* theMesh );
448  virtual bool IsSatisfy( long theElementId );
449  virtual SMDSAbs_ElementType GetType() const;
450 
451  protected:
453  };
454 
455  /*
456  Class : ElemEntityType
457  Description : Functor for calculating entity type
458  */
460  public:
461  ElemEntityType();
462  //virtual Predicate* clone() const { return new ElemEntityType( *this ); }
463  virtual void SetMesh( const SMDS_Mesh* theMesh );
464  virtual bool IsSatisfy( long theElementId );
465  void SetType( SMDSAbs_ElementType theType );
466  virtual SMDSAbs_ElementType GetType() const;
467  void SetElemEntityType( SMDSAbs_EntityType theEntityType );
468  SMDSAbs_EntityType GetElemEntityType() const;
469 
470  private:
474  };
475  typedef boost::shared_ptr<ElemEntityType> ElemEntityTypePtr;
476 
477 
478  /*
479  BareBorderVolume
480  */
482  {
483  public:
484  BareBorderVolume():myMesh(0) {}
485  virtual Predicate* clone() const { return new BareBorderVolume( *this ); }
486  virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
487  virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
488  virtual bool IsSatisfy( long theElementId );
489  protected:
491  };
492  typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
493 
494  /*
495  BareBorderFace
496  */
498  {
499  public:
500  BareBorderFace():myMesh(0) {}
501  //virtual Predicate* clone() const { return new BareBorderFace( *this ); }
502  virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
503  virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
504  virtual bool IsSatisfy( long theElementId );
505  protected:
507  std::vector< const SMDS_MeshNode* > myLinkNodes;
508  };
509  typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
510 
511  /*
512  OverConstrainedVolume
513  */
515  {
516  public:
517  OverConstrainedVolume():myMesh(0) {}
518  virtual Predicate* clone() const { return new OverConstrainedVolume( *this ); }
519  virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
520  virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
521  virtual bool IsSatisfy( long theElementId );
522  protected:
524  };
525  typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
526 
527  /*
528  OverConstrainedFace
529  */
531  {
532  public:
533  OverConstrainedFace():myMesh(0) {}
534  //virtual Predicate* clone() const { return new OverConstrainedFace( *this ); }
535  virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
536  virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
537  virtual bool IsSatisfy( long theElementId );
538  protected:
540  };
541  typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
542 
543  /*
544  Class : FreeEdges
545  Description : Predicate for free Edges
546  */
547  class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
548  public:
549  FreeEdges();
550  //virtual Predicate* clone() const { return new FreeEdges( *this ); }
551  virtual void SetMesh( const SMDS_Mesh* theMesh );
552  virtual bool IsSatisfy( long theElementId );
553  virtual SMDSAbs_ElementType GetType() const;
554  static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId );
555  typedef long TElemId;
556  struct Border{
558  TElemId myPntId[2];
559  Border(long theElemId, long thePntId1, long thePntId2);
560  bool operator<(const Border& x) const;
561  };
562  typedef std::set<Border> TBorders;
563  void GetBoreders(TBorders& theBorders);
564 
565  protected:
567  };
568  typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
569 
570 
571  /*
572  Class : FreeNodes
573  Description : Predicate for free nodes
574  */
575  class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
576  public:
577  FreeNodes();
578  //virtual Predicate* clone() const { return new FreeNodes( *this ); }
579  virtual void SetMesh( const SMDS_Mesh* theMesh );
580  virtual bool IsSatisfy( long theNodeId );
581  virtual SMDSAbs_ElementType GetType() const;
582 
583  protected:
585  };
586 
587 
588  /*
589  Class : RangeOfIds
590  Description : Predicate for Range of Ids.
591  Range may be specified with two ways.
592  1. Using AddToRange method
593  2. With SetRangeStr method. Parameter of this method is a string
594  like as "1,2,3,50-60,63,67,70-"
595  */
597  {
598  public:
599  RangeOfIds();
600  //virtual Predicate* clone() const { return new RangeOfIds( *this ); }
601  virtual void SetMesh( const SMDS_Mesh* theMesh );
602  virtual bool IsSatisfy( long theNodeId );
603  virtual SMDSAbs_ElementType GetType() const;
604  virtual void SetType( SMDSAbs_ElementType theType );
605 
606  bool AddToRange( long theEntityId );
607  void GetRangeStr( TCollection_AsciiString& );
608  bool SetRangeStr( const TCollection_AsciiString& );
609 
610  protected:
612 
613  TColStd_SequenceOfInteger myMin;
614  TColStd_SequenceOfInteger myMax;
615  TColStd_MapOfInteger myIds;
616 
618  };
619 
620  typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
621 
622 
623  /*
624  Class : Comparator
625  Description : Base class for comparators
626  */
628  public:
629  Comparator();
630  virtual ~Comparator();
631  virtual void SetMesh( const SMDS_Mesh* theMesh );
632  virtual void SetMargin(double theValue);
633  virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
634  virtual bool IsSatisfy( long theElementId ) = 0;
635  virtual SMDSAbs_ElementType GetType() const;
636  double GetMargin();
637 
638  protected:
639  double myMargin;
641  };
642  typedef boost::shared_ptr<Comparator> ComparatorPtr;
643 
644 
645  /*
646  Class : LessThan
647  Description : Comparator "<"
648  */
649  class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
650  public:
651  virtual bool IsSatisfy( long theElementId );
652  //virtual Predicate* clone() const { return new LessThan( *this ); }
653  };
654 
655 
656  /*
657  Class : MoreThan
658  Description : Comparator ">"
659  */
660  class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
661  public:
662  virtual bool IsSatisfy( long theElementId );
663  //virtual Predicate* clone() const { return new MoreThan( *this ); }
664  };
665 
666 
667  /*
668  Class : EqualTo
669  Description : Comparator "="
670  */
671  class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
672  public:
673  EqualTo();
674  //virtual Predicate* clone() const { return new EqualTo( *this ); }
675  virtual bool IsSatisfy( long theElementId );
676  virtual void SetTolerance( double theTol );
677  virtual double GetTolerance();
678 
679  private:
680  double myToler;
681  };
682  typedef boost::shared_ptr<EqualTo> EqualToPtr;
683 
684 
685  /*
686  Class : LogicalNOT
687  Description : Logical NOT predicate
688  */
690  public:
691  LogicalNOT();
692  //virtual Predicate* clone() const { return new LogicalNOT( *this ); }
693  virtual ~LogicalNOT();
694  virtual bool IsSatisfy( long theElementId );
695  virtual void SetMesh( const SMDS_Mesh* theMesh );
696  virtual void SetPredicate(PredicatePtr thePred);
697  virtual SMDSAbs_ElementType GetType() const;
698 
699  private:
701  };
702  typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
703 
704 
705  /*
706  Class : LogicalBinary
707  Description : Base class for binary logical predicate
708  */
710  public:
711  LogicalBinary();
712  virtual ~LogicalBinary();
713  virtual void SetMesh( const SMDS_Mesh* theMesh );
714  virtual void SetPredicate1(PredicatePtr thePred);
715  virtual void SetPredicate2(PredicatePtr thePred);
716  virtual SMDSAbs_ElementType GetType() const;
717 
718  protected:
721  };
722  typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
723 
724 
725  /*
726  Class : LogicalAND
727  Description : Logical AND
728  */
730  public:
731  virtual bool IsSatisfy( long theElementId );
732  //virtual Predicate* clone() const { return new LogicalAND( *this ); }
733  };
734 
735 
736  /*
737  Class : LogicalOR
738  Description : Logical OR
739  */
741  public:
742  virtual bool IsSatisfy( long theElementId );
743  //virtual Predicate* clone() const { return new LogicalOR( *this ); }
744  };
745 
746 
747  /*
748  Class : ManifoldPart
749  Description : Predicate for manifold part of mesh
750  */
752  public:
753 
754  /* internal class for algorithm uses */
755  class Link
756  {
757  public:
758  Link( SMDS_MeshNode* theNode1,
759  SMDS_MeshNode* theNode2 );
760  ~Link();
761 
762  bool IsEqual( const ManifoldPart::Link& theLink ) const;
763  bool operator<(const ManifoldPart::Link& x) const;
764 
767  };
768 
769  bool IsEqual( const ManifoldPart::Link& theLink1,
770  const ManifoldPart::Link& theLink2 );
771 
772  typedef std::set<ManifoldPart::Link> TMapOfLink;
773  typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
774  typedef std::vector<ManifoldPart::Link> TVectorOfLink;
775  typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
776  typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
777 
778  ManifoldPart();
779  ~ManifoldPart();
780  //virtual Predicate* clone() const { return new ManifoldPart( *this ); }
781  virtual void SetMesh( const SMDS_Mesh* theMesh );
782  // inoke when all parameters already set
783  virtual bool IsSatisfy( long theElementId );
784  virtual SMDSAbs_ElementType GetType() const;
785 
786  void SetAngleTolerance( const double theAngToler );
787  double GetAngleTolerance() const;
788  void SetIsOnlyManifold( const bool theIsOnly );
789  void SetStartElem( const long theStartElemId );
790 
791  private:
792  bool process();
793  bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
794  SMDS_MeshFace* theStartFace,
795  TMapOfLink& theNonManifold,
796  TColStd_MapOfInteger& theResFaces );
797  bool isInPlane( const SMDS_MeshFace* theFace1,
798  const SMDS_MeshFace* theFace2 );
799  void expandBoundary( TMapOfLink& theMapOfBoundary,
800  TVectorOfLink& theSeqOfBoundary,
801  TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
802  TMapOfLink& theNonManifold,
803  SMDS_MeshFace* theNextFace ) const;
804 
805  void getFacesByLink( const Link& theLink,
806  TVectorOfFacePtr& theFaces ) const;
807 
808  private:
810  TColStd_MapOfInteger myMapIds;
811  TColStd_MapOfInteger myMapBadGeomIds;
814  double myAngToler;
817 
818  };
819  typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
820 
821  /*
822  Class : BelongToMeshGroup
823  Description : Verify whether a mesh element is included into a mesh group
824  */
826  {
827  public:
829  //virtual Predicate* clone() const { return new BelongToMeshGroup( *this ); }
830  virtual void SetMesh( const SMDS_Mesh* theMesh );
831  virtual bool IsSatisfy( long theElementId );
832  virtual SMDSAbs_ElementType GetType() const;
833 
834  void SetGroup( SMESHDS_GroupBase* g );
835  void SetStoreName( const std::string& sn );
836  const SMESHDS_GroupBase* GetGroup() const { return myGroup; }
837 
838  private:
840  std::string myStoreName;
841  };
842  typedef boost::shared_ptr<BelongToMeshGroup> BelongToMeshGroupPtr;
843 
844  /*
845  Class : ElementsOnSurface
846  Description : Predicate elements that lying on indicated surface
847  (plane or cylinder)
848  */
850  public:
853  //virtual Predicate* clone() const { return new ElementsOnSurface( *this ); }
854  virtual void SetMesh( const SMDS_Mesh* theMesh );
855  virtual bool IsSatisfy( long theElementId );
856  virtual SMDSAbs_ElementType GetType() const;
857 
858  void SetTolerance( const double theToler );
859  double GetTolerance() const;
860  void SetSurface( const TopoDS_Shape& theShape,
861  const SMDSAbs_ElementType theType );
862  void SetUseBoundaries( bool theUse );
863  bool GetUseBoundaries() const { return myUseBoundaries; }
864 
865  private:
866  void process();
867  void process( const SMDS_MeshElement* theElem );
868  bool isOnSurface( const SMDS_MeshNode* theNode );
869 
870  private:
872  TColStd_MapOfInteger myIds;
874  TopoDS_Face mySurf;
875  double myToler;
877  GeomAPI_ProjectPointOnSurf myProjector;
878  };
879 
880  typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
881 
882 
883  /*
884  Class : ElementsOnShape
885  Description : Predicate elements that lying on indicated shape
886  (1D, 2D or 3D)
887  */
889  {
890  public:
891  ElementsOnShape();
892  ~ElementsOnShape();
893 
894  virtual Predicate* clone() const;
895  virtual void SetMesh (const SMDS_Mesh* theMesh);
896  virtual bool IsSatisfy (long theElementId);
897  virtual SMDSAbs_ElementType GetType() const;
898 
899  void SetTolerance (const double theToler);
900  double GetTolerance() const;
901  void SetAllNodes (bool theAllNodes);
902  bool GetAllNodes() const { return myAllNodesFlag; }
903  void SetShape (const TopoDS_Shape& theShape,
904  const SMDSAbs_ElementType theType);
905 
906  private:
907 
908  struct Classifier;
909  struct OctreeClassifier;
910 
911  void clearClassifiers();
912  bool getNodeIsOut( const SMDS_MeshNode* n, bool& isOut );
913  void setNodeIsOut( const SMDS_MeshNode* n, bool isOut );
914 
915  std::vector< Classifier > myClassifiers;
916  std::vector< Classifier* > myWorkClassifiers;
919  TopoDS_Shape myShape;
920  double myToler;
922 
924  std::vector<bool> myNodeIsChecked;
925  std::vector<bool> myNodeIsOut;
926  };
927 
928  typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
929 
930 
931  /*
932  Class : BelongToGeom
933  Description : Predicate for verifying whether entiy belong to
934  specified geometrical support
935  */
937  {
938  public:
939  BelongToGeom();
940  virtual Predicate* clone() const;
941 
942  virtual void SetMesh( const SMDS_Mesh* theMesh );
943  virtual void SetGeom( const TopoDS_Shape& theShape );
944 
945  virtual bool IsSatisfy( long theElementId );
946 
947  virtual void SetType( SMDSAbs_ElementType theType );
948  virtual SMDSAbs_ElementType GetType() const;
949 
950  TopoDS_Shape GetShape();
951  const SMESHDS_Mesh* GetMeshDS() const;
952 
953  void SetTolerance( double );
954  double GetTolerance();
955 
956  private:
957  virtual void init();
958 
959  TopoDS_Shape myShape;
960  TColStd_MapOfInteger mySubShapesIDs;
964  double myTolerance; // only if myIsSubshape == false
965  Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
966  };
967  typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
968 
969  /*
970  Class : LyingOnGeom
971  Description : Predicate for verifying whether entiy lying or partially lying on
972  specified geometrical support
973  */
975  {
976  public:
977  LyingOnGeom();
978  virtual Predicate* clone() const;
979 
980  virtual void SetMesh( const SMDS_Mesh* theMesh );
981  virtual void SetGeom( const TopoDS_Shape& theShape );
982 
983  virtual bool IsSatisfy( long theElementId );
984 
985  virtual void SetType( SMDSAbs_ElementType theType );
986  virtual SMDSAbs_ElementType GetType() const;
987 
988  TopoDS_Shape GetShape();
989  const SMESHDS_Mesh* GetMeshDS() const;
990 
991  void SetTolerance( double );
992  double GetTolerance();
993 
994  private:
995  virtual void init();
996 
997  TopoDS_Shape myShape;
998  TColStd_MapOfInteger mySubShapesIDs;
1002  double myTolerance; // only if myIsSubshape == false
1003  Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
1004  };
1005  typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
1006 
1007  /*
1008  Class : FreeFaces
1009  Description : Predicate for free faces
1010  */
1012  public:
1013  FreeFaces();
1014  //virtual Predicate* clone() const { return new FreeFaces( *this ); }
1015  virtual void SetMesh( const SMDS_Mesh* theMesh );
1016  virtual bool IsSatisfy( long theElementId );
1017  virtual SMDSAbs_ElementType GetType() const;
1018 
1019  private:
1021  };
1022 
1023  /*
1024  Class : LinearOrQuadratic
1025  Description : Predicate for free faces
1026  */
1028  public:
1030  //virtual Predicate* clone() const { return new LinearOrQuadratic( *this ); }
1031  virtual void SetMesh( const SMDS_Mesh* theMesh );
1032  virtual bool IsSatisfy( long theElementId );
1033  void SetType( SMDSAbs_ElementType theType );
1034  virtual SMDSAbs_ElementType GetType() const;
1035 
1036  private:
1039  };
1040  typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
1041 
1042  /*
1043  Class : GroupColor
1044  Description : Functor for check color of group to which mesh element belongs to
1045  */
1047  public:
1048  GroupColor();
1049  //virtual Predicate* clone() const { return new GroupColor( *this ); }
1050  virtual void SetMesh( const SMDS_Mesh* theMesh );
1051  virtual bool IsSatisfy( long theElementId );
1052  void SetType( SMDSAbs_ElementType theType );
1053  virtual SMDSAbs_ElementType GetType() const;
1054  void SetColorStr( const TCollection_AsciiString& );
1055  void GetColorStr( TCollection_AsciiString& ) const;
1056 
1057  private:
1058  typedef std::set< long > TIDs;
1059 
1060  Quantity_Color myColor;
1063  };
1064  typedef boost::shared_ptr<GroupColor> GroupColorPtr;
1065 
1066  /*
1067  Class : ElemGeomType
1068  Description : Predicate to check element geometry type
1069  */
1071  public:
1072  ElemGeomType();
1073  //virtual Predicate* clone() const { return new ElemGeomType( *this ); }
1074  virtual void SetMesh( const SMDS_Mesh* theMesh );
1075  virtual bool IsSatisfy( long theElementId );
1076  void SetType( SMDSAbs_ElementType theType );
1077  virtual SMDSAbs_ElementType GetType() const;
1078  void SetGeomType( SMDSAbs_GeometryType theType );
1079  SMDSAbs_GeometryType GetGeomType() const;
1080 
1081  private:
1085  };
1086  typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
1087 
1088  /*
1089  Class : CoplanarFaces
1090  Description : Predicate to check angle between faces
1091  */
1093  {
1094  public:
1095  CoplanarFaces();
1096  //virtual Predicate* clone() const { return new CoplanarFaces( *this ); }
1097  void SetFace( long theID ) { myFaceID = theID; }
1098  long GetFace() const { return myFaceID; }
1099  void SetTolerance (const double theToler) { myToler = theToler; }
1100  double GetTolerance () const { return myToler; }
1101  virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
1102 
1103  virtual void SetMesh( const SMDS_Mesh* theMesh );
1104  virtual bool IsSatisfy( long theElementId );
1105 
1106  private:
1108  long myFaceID;
1109  double myToler;
1110  TColStd_MapOfInteger myCoplanarIDs;
1111  };
1112  typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
1113 
1114  /*
1115  Class : ConnectedElements
1116  Description : Predicate to get elements of one domain
1117  */
1119  {
1120  public:
1122  //virtual Predicate* clone() const { return new ConnectedElements( *this ); }
1123  void SetNode( int nodeID );
1124  void SetPoint( double x, double y, double z );
1125  int GetNode() const;
1126  std::vector<double> GetPoint() const;
1127 
1128  void SetType( SMDSAbs_ElementType theType );
1129  virtual SMDSAbs_ElementType GetType() const;
1130 
1131  virtual void SetMesh( const SMDS_Mesh* theMesh );
1132  virtual bool IsSatisfy( long theElementId );
1133 
1134  //const std::set<long>& GetDomainIDs() const { return myOkIDs; }
1135 
1136  private:
1138  std::vector<double> myXYZ;
1141 
1142  void clearOkIDs();
1144  std::set< int > myOkIDs; // empty means that there is one domain
1145  };
1146  typedef boost::shared_ptr<ConnectedElements> ConnectedElementsPtr;
1147 
1148  /*
1149  FILTER
1150  */
1152  public:
1153  Filter();
1154  virtual ~Filter();
1155  virtual void SetPredicate(PredicatePtr thePred);
1156 
1157  typedef std::vector<long> TIdSequence;
1158 
1159  virtual
1160  void
1161  GetElementsId( const SMDS_Mesh* theMesh,
1162  TIdSequence& theSequence );
1163 
1164  static
1165  void
1166  GetElementsId( const SMDS_Mesh* theMesh,
1167  PredicatePtr thePredicate,
1168  TIdSequence& theSequence );
1169 
1170  protected:
1172  };
1173  };
1174 };
1175 
1176 
1177 #endif