1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef _SMESH_CONTROLSDEF_HXX_
24 #define _SMESH_CONTROLSDEF_HXX_
26 #include "SMESH_Controls.hxx"
28 #include "SMDS_MeshNode.hxx"
29 #include "SMESH_TypeDefs.hxx"
31 #include <BRepClass3d_SolidClassifier.hxx>
32 #include <Bnd_B3d.hxx>
33 #include <GeomAPI_ProjectPointOnCurve.hxx>
34 #include <GeomAPI_ProjectPointOnSurf.hxx>
35 #include <Quantity_Color.hxx>
36 #include <TColStd_MapOfInteger.hxx>
37 #include <TColStd_SequenceOfInteger.hxx>
38 #include <TCollection_AsciiString.hxx>
40 #include <TopTools_MapOfShape.hxx>
41 #include <TopoDS_Face.hxx>
48 #include <boost/shared_ptr.hpp>
50 class SMDS_MeshElement;
56 class SMESHDS_SubMesh;
63 class SMESHCONTROLS_EXPORT TSequenceOfXYZ
65 typedef std::vector<gp_XYZ>::size_type size_type;
70 TSequenceOfXYZ(size_type n);
72 TSequenceOfXYZ(size_type n, const gp_XYZ& t);
74 TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ);
76 template <class InputIterator>
77 TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd);
81 TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ);
83 gp_XYZ& operator()(size_type n);
85 const gp_XYZ& operator()(size_type n) const;
89 void reserve(size_type n);
91 void push_back(const gp_XYZ& v);
93 size_type size() const;
96 std::vector<gp_XYZ> myArray;
100 * \brief Class used to detect mesh modification: IsMeshModified() returns
101 * true if a mesh has changed since last calling IsMeshModified()
103 class SMESHCONTROLS_EXPORT TMeshModifTracer
105 unsigned long myMeshModifTime;
106 const SMDS_Mesh* myMesh;
109 void SetMesh( const SMDS_Mesh* theMesh );
110 const SMDS_Mesh* GetMesh() const { return myMesh; }
111 bool IsMeshModified();
115 Class : NumericalFunctor
116 Description : Root of all Functors returning numeric value
118 class SMESHCONTROLS_EXPORT NumericalFunctor: public virtual Functor{
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 const bool isLogarithmic = false);
130 virtual SMDSAbs_ElementType GetType() const = 0;
131 virtual double GetBadRate( double Value, int nbNodes ) const = 0;
132 long GetPrecision() const;
133 void SetPrecision( const long thePrecision );
134 double Round( const double & value );
136 bool GetPoints(const int theId, TSequenceOfXYZ& theRes) const;
137 static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes);
139 const SMDS_Mesh* myMesh;
140 const SMDS_MeshElement* myCurrElement;
142 double myPrecisionValue;
148 Description : Functor calculating volume of 3D mesh element
150 class SMESHCONTROLS_EXPORT Volume: public virtual NumericalFunctor{
152 virtual double GetValue( long theElementId );
153 //virtual double GetValue( const TSequenceOfXYZ& thePoints );
154 virtual double GetBadRate( double Value, int nbNodes ) const;
155 virtual SMDSAbs_ElementType GetType() const;
160 Class : MaxElementLength2D
161 Description : Functor calculating maximum length of 2D element
163 class SMESHCONTROLS_EXPORT MaxElementLength2D: public virtual NumericalFunctor{
165 virtual double GetValue( long theElementId );
166 virtual double GetValue( const TSequenceOfXYZ& P );
167 virtual double GetBadRate( double Value, int nbNodes ) const;
168 virtual SMDSAbs_ElementType GetType() const;
173 Class : MaxElementLength3D
174 Description : Functor calculating maximum length of 3D element
176 class SMESHCONTROLS_EXPORT MaxElementLength3D: public virtual NumericalFunctor{
178 virtual double GetValue( long theElementId );
179 virtual double GetBadRate( double Value, int nbNodes ) const;
180 virtual SMDSAbs_ElementType GetType() const;
185 Class : SMESH_MinimumAngle
186 Description : Functor for calculation of minimum angle
188 class SMESHCONTROLS_EXPORT MinimumAngle: public virtual NumericalFunctor{
190 virtual double GetValue( const TSequenceOfXYZ& thePoints );
191 virtual double GetBadRate( double Value, int nbNodes ) const;
192 virtual SMDSAbs_ElementType GetType() const;
198 Description : Functor for calculating aspect ratio
200 class SMESHCONTROLS_EXPORT AspectRatio: public virtual NumericalFunctor{
202 virtual double GetValue( long theElementId );
203 virtual double GetValue( const TSequenceOfXYZ& thePoints );
204 virtual double GetBadRate( double Value, int nbNodes ) const;
205 virtual SMDSAbs_ElementType GetType() const;
210 Class : AspectRatio3D
211 Description : Functor for calculating aspect ratio of 3D elems.
213 class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
215 virtual double GetValue( long theElementId );
216 virtual double GetValue( const TSequenceOfXYZ& thePoints );
217 virtual double GetBadRate( double Value, int nbNodes ) const;
218 virtual SMDSAbs_ElementType GetType() const;
224 Description : Functor for calculating warping
226 class SMESHCONTROLS_EXPORT Warping: public virtual NumericalFunctor{
228 virtual double GetValue( const TSequenceOfXYZ& thePoints );
229 virtual double GetBadRate( double Value, int nbNodes ) const;
230 virtual SMDSAbs_ElementType GetType() const;
233 double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
239 Description : Functor for calculating taper
241 class SMESHCONTROLS_EXPORT Taper: public virtual NumericalFunctor{
243 virtual double GetValue( const TSequenceOfXYZ& thePoints );
244 virtual double GetBadRate( double Value, int nbNodes ) const;
245 virtual SMDSAbs_ElementType GetType() const;
250 Description : Functor for calculating skew in degrees
252 class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
254 virtual double GetValue( const TSequenceOfXYZ& thePoints );
255 virtual double GetBadRate( double Value, int nbNodes ) const;
256 virtual SMDSAbs_ElementType GetType() const;
262 Description : Functor for calculating area
264 class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
266 virtual double GetValue( const TSequenceOfXYZ& thePoints );
267 virtual double GetBadRate( double Value, int nbNodes ) const;
268 virtual SMDSAbs_ElementType GetType() const;
274 Description : Functor for calculating length of edge
276 class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
278 virtual double GetValue( const TSequenceOfXYZ& thePoints );
279 virtual double GetBadRate( double Value, int nbNodes ) const;
280 virtual SMDSAbs_ElementType GetType() const;
285 Description : Functor for calculating length of edge
287 class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
289 virtual double GetValue( long theElementId );
290 virtual double GetBadRate( double Value, int nbNodes ) const;
291 virtual SMDSAbs_ElementType GetType() const;
295 Value(double theLength, long thePntId1, long thePntId2);
296 bool operator<(const Value& x) const;
298 typedef std::set<Value> TValues;
299 void GetValues(TValues& theValues);
301 typedef boost::shared_ptr<Length2D> Length2DPtr;
304 Class : MultiConnection
305 Description : Functor for calculating number of faces connected to the edge
307 class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
309 virtual double GetValue( long theElementId );
310 virtual double GetValue( const TSequenceOfXYZ& thePoints );
311 virtual double GetBadRate( double Value, int nbNodes ) const;
312 virtual SMDSAbs_ElementType GetType() const;
316 Class : MultiConnection2D
317 Description : Functor for calculating number of faces connected to the edge
319 class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
321 virtual double GetValue( long theElementId );
322 virtual double GetValue( const TSequenceOfXYZ& thePoints );
323 virtual double GetBadRate( double Value, int nbNodes ) const;
324 virtual SMDSAbs_ElementType GetType() const;
327 Value(long thePntId1, long thePntId2);
328 bool operator<(const Value& x) const;
330 typedef std::map<Value,int> MValues;
332 void GetValues(MValues& theValues);
334 typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
338 Description : Functor returning diameter of a ball element
340 class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{
342 virtual double GetValue( long theElementId );
343 virtual double GetBadRate( double Value, int nbNodes ) const;
344 virtual SMDSAbs_ElementType GetType() const;
352 Class : CoincidentNodes
353 Description : Predicate of Coincident Nodes
354 Note : This class is suitable only for visualization of Coincident Nodes
356 class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
359 virtual void SetMesh( const SMDS_Mesh* theMesh );
360 virtual bool IsSatisfy( long theElementId );
361 virtual SMDSAbs_ElementType GetType() const;
363 void SetTolerance (const double theToler) { myToler = theToler; }
364 double GetTolerance () const { return myToler; }
368 TColStd_MapOfInteger myCoincidentIDs;
369 TMeshModifTracer myMeshModifTracer;
371 typedef boost::shared_ptr<CoincidentNodes> CoincidentNodesPtr;
374 Class : CoincidentElements
375 Description : Predicate of Coincident Elements
376 Note : This class is suitable only for visualization of Coincident Elements
378 class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate {
380 CoincidentElements();
381 virtual void SetMesh( const SMDS_Mesh* theMesh );
382 virtual bool IsSatisfy( long theElementId );
385 const SMDS_Mesh* myMesh;
387 class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
389 virtual SMDSAbs_ElementType GetType() const;
391 class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
393 virtual SMDSAbs_ElementType GetType() const;
395 class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
397 virtual SMDSAbs_ElementType GetType() const;
402 Description : Predicate for free borders
404 class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
407 virtual void SetMesh( const SMDS_Mesh* theMesh );
408 virtual bool IsSatisfy( long theElementId );
409 virtual SMDSAbs_ElementType GetType() const;
412 const SMDS_Mesh* myMesh;
417 Class : BadOrientedVolume
418 Description : Predicate bad oriented volumes
420 class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
423 virtual void SetMesh( const SMDS_Mesh* theMesh );
424 virtual bool IsSatisfy( long theElementId );
425 virtual SMDSAbs_ElementType GetType() const;
428 const SMDS_Mesh* myMesh;
432 Class : ElemEntityType
433 Description : Functor for calculating entity type
435 class SMESHCONTROLS_EXPORT ElemEntityType: public virtual Predicate{
438 virtual void SetMesh( const SMDS_Mesh* theMesh );
439 virtual bool IsSatisfy( long theElementId );
440 void SetType( SMDSAbs_ElementType theType );
441 virtual SMDSAbs_ElementType GetType() const;
442 void SetElemEntityType( SMDSAbs_EntityType theEntityType );
443 SMDSAbs_EntityType GetElemEntityType() const;
446 const SMDS_Mesh* myMesh;
447 SMDSAbs_ElementType myType;
448 SMDSAbs_EntityType myEntityType;
450 typedef boost::shared_ptr<ElemEntityType> ElemEntityTypePtr;
456 class SMESHCONTROLS_EXPORT BareBorderVolume: public Predicate
459 BareBorderVolume():myMesh(0) {}
460 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
461 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
462 virtual bool IsSatisfy( long theElementId );
464 const SMDS_Mesh* myMesh;
466 typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
471 class SMESHCONTROLS_EXPORT BareBorderFace: public Predicate
474 BareBorderFace():myMesh(0) {}
475 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
476 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
477 virtual bool IsSatisfy( long theElementId );
479 const SMDS_Mesh* myMesh;
480 std::vector< const SMDS_MeshNode* > myLinkNodes;
482 typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
485 OverConstrainedVolume
487 class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
490 OverConstrainedVolume():myMesh(0) {}
491 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
492 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
493 virtual bool IsSatisfy( long theElementId );
495 const SMDS_Mesh* myMesh;
497 typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
502 class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
505 OverConstrainedFace():myMesh(0) {}
506 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
507 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
508 virtual bool IsSatisfy( long theElementId );
510 const SMDS_Mesh* myMesh;
512 typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
516 Description : Predicate for free Edges
518 class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
521 virtual void SetMesh( const SMDS_Mesh* theMesh );
522 virtual bool IsSatisfy( long theElementId );
523 virtual SMDSAbs_ElementType GetType() const;
524 static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId );
525 typedef long TElemId;
529 Border(long theElemId, long thePntId1, long thePntId2);
530 bool operator<(const Border& x) const;
532 typedef std::set<Border> TBorders;
533 void GetBoreders(TBorders& theBorders);
536 const SMDS_Mesh* myMesh;
538 typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
543 Description : Predicate for free nodes
545 class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
548 virtual void SetMesh( const SMDS_Mesh* theMesh );
549 virtual bool IsSatisfy( long theNodeId );
550 virtual SMDSAbs_ElementType GetType() const;
553 const SMDS_Mesh* myMesh;
559 Description : Predicate for Range of Ids.
560 Range may be specified with two ways.
561 1. Using AddToRange method
562 2. With SetRangeStr method. Parameter of this method is a string
563 like as "1,2,3,50-60,63,67,70-"
565 class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
569 virtual void SetMesh( const SMDS_Mesh* theMesh );
570 virtual bool IsSatisfy( long theNodeId );
571 virtual SMDSAbs_ElementType GetType() const;
572 virtual void SetType( SMDSAbs_ElementType theType );
574 bool AddToRange( long theEntityId );
575 void GetRangeStr( TCollection_AsciiString& );
576 bool SetRangeStr( const TCollection_AsciiString& );
579 const SMDS_Mesh* myMesh;
581 TColStd_SequenceOfInteger myMin;
582 TColStd_SequenceOfInteger myMax;
583 TColStd_MapOfInteger myIds;
585 SMDSAbs_ElementType myType;
588 typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
593 Description : Base class for comparators
595 class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
598 virtual ~Comparator();
599 virtual void SetMesh( const SMDS_Mesh* theMesh );
600 virtual void SetMargin(double theValue);
601 virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
602 virtual bool IsSatisfy( long theElementId ) = 0;
603 virtual SMDSAbs_ElementType GetType() const;
608 NumericalFunctorPtr myFunctor;
610 typedef boost::shared_ptr<Comparator> ComparatorPtr;
615 Description : Comparator "<"
617 class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
619 virtual bool IsSatisfy( long theElementId );
625 Description : Comparator ">"
627 class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
629 virtual bool IsSatisfy( long theElementId );
635 Description : Comparator "="
637 class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
640 virtual bool IsSatisfy( long theElementId );
641 virtual void SetTolerance( double theTol );
642 virtual double GetTolerance();
647 typedef boost::shared_ptr<EqualTo> EqualToPtr;
652 Description : Logical NOT predicate
654 class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
657 virtual ~LogicalNOT();
658 virtual bool IsSatisfy( long theElementId );
659 virtual void SetMesh( const SMDS_Mesh* theMesh );
660 virtual void SetPredicate(PredicatePtr thePred);
661 virtual SMDSAbs_ElementType GetType() const;
664 PredicatePtr myPredicate;
666 typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
670 Class : LogicalBinary
671 Description : Base class for binary logical predicate
673 class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
676 virtual ~LogicalBinary();
677 virtual void SetMesh( const SMDS_Mesh* theMesh );
678 virtual void SetPredicate1(PredicatePtr thePred);
679 virtual void SetPredicate2(PredicatePtr thePred);
680 virtual SMDSAbs_ElementType GetType() const;
683 PredicatePtr myPredicate1;
684 PredicatePtr myPredicate2;
686 typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
691 Description : Logical AND
693 class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
695 virtual bool IsSatisfy( long theElementId );
701 Description : Logical OR
703 class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
705 virtual bool IsSatisfy( long theElementId );
711 Description : Predicate for manifold part of mesh
713 class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
716 /* internal class for algorithm uses */
720 Link( SMDS_MeshNode* theNode1,
721 SMDS_MeshNode* theNode2 );
724 bool IsEqual( const ManifoldPart::Link& theLink ) const;
725 bool operator<(const ManifoldPart::Link& x) const;
727 SMDS_MeshNode* myNode1;
728 SMDS_MeshNode* myNode2;
731 bool IsEqual( const ManifoldPart::Link& theLink1,
732 const ManifoldPart::Link& theLink2 );
734 typedef std::set<ManifoldPart::Link> TMapOfLink;
735 typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
736 typedef std::vector<ManifoldPart::Link> TVectorOfLink;
737 typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
738 typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
742 virtual void SetMesh( const SMDS_Mesh* theMesh );
743 // inoke when all parameters already set
744 virtual bool IsSatisfy( long theElementId );
745 virtual SMDSAbs_ElementType GetType() const;
747 void SetAngleTolerance( const double theAngToler );
748 double GetAngleTolerance() const;
749 void SetIsOnlyManifold( const bool theIsOnly );
750 void SetStartElem( const long theStartElemId );
754 bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
755 SMDS_MeshFace* theStartFace,
756 TMapOfLink& theNonManifold,
757 TColStd_MapOfInteger& theResFaces );
758 bool isInPlane( const SMDS_MeshFace* theFace1,
759 const SMDS_MeshFace* theFace2 );
760 void expandBoundary( TMapOfLink& theMapOfBoundary,
761 TVectorOfLink& theSeqOfBoundary,
762 TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
763 TMapOfLink& theNonManifold,
764 SMDS_MeshFace* theNextFace ) const;
766 void getFacesByLink( const Link& theLink,
767 TVectorOfFacePtr& theFaces ) const;
770 const SMDS_Mesh* myMesh;
771 TColStd_MapOfInteger myMapIds;
772 TColStd_MapOfInteger myMapBadGeomIds;
773 TVectorOfFacePtr myAllFacePtr;
774 TDataMapFacePtrInt myAllFacePtrIntDMap;
776 bool myIsOnlyManifold;
780 typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
784 Class : ElementsOnSurface
785 Description : Predicate elements that lying on indicated surface
788 class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
791 ~ElementsOnSurface();
792 virtual void SetMesh( const SMDS_Mesh* theMesh );
793 virtual bool IsSatisfy( long theElementId );
794 virtual SMDSAbs_ElementType GetType() const;
796 void SetTolerance( const double theToler );
797 double GetTolerance() const;
798 void SetSurface( const TopoDS_Shape& theShape,
799 const SMDSAbs_ElementType theType );
800 void SetUseBoundaries( bool theUse );
801 bool GetUseBoundaries() const { return myUseBoundaries; }
805 void process( const SMDS_MeshElement* theElem );
806 bool isOnSurface( const SMDS_MeshNode* theNode );
809 TMeshModifTracer myMeshModifTracer;
810 TColStd_MapOfInteger myIds;
811 SMDSAbs_ElementType myType;
812 //Handle(Geom_Surface) mySurf;
815 bool myUseBoundaries;
816 GeomAPI_ProjectPointOnSurf myProjector;
819 typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
823 Class : ElementsOnShape
824 Description : Predicate elements that lying on indicated shape
827 class SMESHCONTROLS_EXPORT ElementsOnShape : public virtual Predicate
833 virtual void SetMesh (const SMDS_Mesh* theMesh);
834 virtual bool IsSatisfy (long theElementId);
835 virtual SMDSAbs_ElementType GetType() const;
837 void SetTolerance (const double theToler);
838 double GetTolerance() const;
839 void SetAllNodes (bool theAllNodes);
840 bool GetAllNodes() const { return myAllNodesFlag; }
841 void SetShape (const TopoDS_Shape& theShape,
842 const SMDSAbs_ElementType theType);
848 TClassifier(const TopoDS_Shape& s, double tol) { Init(s,tol); }
849 void Init(const TopoDS_Shape& s, double tol);
850 bool IsOut(const gp_Pnt& p);
851 TopAbs_ShapeEnum ShapeType() const;
853 bool isOutOfSolid (const gp_Pnt& p);
854 bool isOutOfBox (const gp_Pnt& p);
855 bool isOutOfFace (const gp_Pnt& p);
856 bool isOutOfEdge (const gp_Pnt& p);
857 bool isOutOfVertex(const gp_Pnt& p);
858 bool isBox (const TopoDS_Shape& s);
860 bool (TClassifier::* myIsOutFun)(const gp_Pnt& p);
861 BRepClass3d_SolidClassifier mySolidClfr;
863 GeomAPI_ProjectPointOnSurf myProjFace;
864 GeomAPI_ProjectPointOnCurve myProjEdge;
866 TopoDS_Shape myShape;
869 void clearClassifiers();
871 std::vector< TClassifier* > myClassifiers;
872 const SMDS_Mesh* myMesh;
873 SMDSAbs_ElementType myType;
874 TopoDS_Shape myShape;
880 typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
885 Description : Predicate for verifying whether entiy belong to
886 specified geometrical support
888 class SMESHCONTROLS_EXPORT BelongToGeom: public virtual Predicate
893 virtual void SetMesh( const SMDS_Mesh* theMesh );
894 virtual void SetGeom( const TopoDS_Shape& theShape );
896 virtual bool IsSatisfy( long theElementId );
898 virtual void SetType( SMDSAbs_ElementType theType );
899 virtual SMDSAbs_ElementType GetType() const;
901 TopoDS_Shape GetShape();
902 const SMESHDS_Mesh* GetMeshDS() const;
904 void SetTolerance( double );
905 double GetTolerance();
910 TopoDS_Shape myShape;
911 const SMESHDS_Mesh* myMeshDS;
912 SMDSAbs_ElementType myType;
914 double myTolerance; // only if myIsSubshape == false
915 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
917 typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
921 Description : Predicate for verifying whether entiy lying or partially lying on
922 specified geometrical support
924 class SMESHCONTROLS_EXPORT LyingOnGeom: public virtual Predicate
929 virtual void SetMesh( const SMDS_Mesh* theMesh );
930 virtual void SetGeom( const TopoDS_Shape& theShape );
932 virtual bool IsSatisfy( long theElementId );
934 virtual void SetType( SMDSAbs_ElementType theType );
935 virtual SMDSAbs_ElementType GetType() const;
937 TopoDS_Shape GetShape();
938 const SMESHDS_Mesh* GetMeshDS() const;
940 void SetTolerance( double );
941 double GetTolerance();
943 virtual bool Contains( const SMESHDS_Mesh* theMeshDS,
944 const TopoDS_Shape& theShape,
945 const SMDS_MeshElement* theElem,
946 TopAbs_ShapeEnum theFindShapeEnum,
947 TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE );
951 TopoDS_Shape myShape;
952 const SMESHDS_Mesh* myMeshDS;
953 SMDSAbs_ElementType myType;
955 double myTolerance; // only if myIsSubshape == false
956 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
958 typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
962 Description : Predicate for free faces
964 class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
967 virtual void SetMesh( const SMDS_Mesh* theMesh );
968 virtual bool IsSatisfy( long theElementId );
969 virtual SMDSAbs_ElementType GetType() const;
972 const SMDS_Mesh* myMesh;
976 Class : LinearOrQuadratic
977 Description : Predicate for free faces
979 class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
982 virtual void SetMesh( const SMDS_Mesh* theMesh );
983 virtual bool IsSatisfy( long theElementId );
984 void SetType( SMDSAbs_ElementType theType );
985 virtual SMDSAbs_ElementType GetType() const;
988 const SMDS_Mesh* myMesh;
989 SMDSAbs_ElementType myType;
991 typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
995 Description : Functor for check color of group to whic mesh element belongs to
997 class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
1000 virtual void SetMesh( const SMDS_Mesh* theMesh );
1001 virtual bool IsSatisfy( long theElementId );
1002 void SetType( SMDSAbs_ElementType theType );
1003 virtual SMDSAbs_ElementType GetType() const;
1004 void SetColorStr( const TCollection_AsciiString& );
1005 void GetColorStr( TCollection_AsciiString& ) const;
1008 typedef std::set< long > TIDs;
1010 Quantity_Color myColor;
1011 SMDSAbs_ElementType myType;
1014 typedef boost::shared_ptr<GroupColor> GroupColorPtr;
1017 Class : ElemGeomType
1018 Description : Predicate to check element geometry type
1020 class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
1023 virtual void SetMesh( const SMDS_Mesh* theMesh );
1024 virtual bool IsSatisfy( long theElementId );
1025 void SetType( SMDSAbs_ElementType theType );
1026 virtual SMDSAbs_ElementType GetType() const;
1027 void SetGeomType( SMDSAbs_GeometryType theType );
1028 SMDSAbs_GeometryType GetGeomType() const;
1031 const SMDS_Mesh* myMesh;
1032 SMDSAbs_ElementType myType;
1033 SMDSAbs_GeometryType myGeomType;
1035 typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
1038 Class : CoplanarFaces
1039 Description : Predicate to check angle between faces
1041 class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
1045 void SetFace( long theID ) { myFaceID = theID; }
1046 long GetFace() const { return myFaceID; }
1047 void SetTolerance (const double theToler) { myToler = theToler; }
1048 double GetTolerance () const { return myToler; }
1049 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
1051 virtual void SetMesh( const SMDS_Mesh* theMesh );
1052 virtual bool IsSatisfy( long theElementId );
1055 TMeshModifTracer myMeshModifTracer;
1058 std::set< long > myCoplanarIDs;
1060 typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
1063 Class : ConnectedElements
1064 Description : Predicate to get elements of one domain
1066 class SMESHCONTROLS_EXPORT ConnectedElements: public virtual Predicate
1069 ConnectedElements();
1070 void SetNode( int nodeID );
1071 void SetPoint( double x, double y, double z );
1072 int GetNode() const;
1073 std::vector<double> GetPoint() const;
1075 void SetType( SMDSAbs_ElementType theType );
1076 virtual SMDSAbs_ElementType GetType() const;
1078 virtual void SetMesh( const SMDS_Mesh* theMesh );
1079 virtual bool IsSatisfy( long theElementId );
1081 //const std::set<long>& GetDomainIDs() const { return myOkIDs; }
1085 std::vector<double> myXYZ;
1086 SMDSAbs_ElementType myType;
1087 TMeshModifTracer myMeshModifTracer;
1091 std::set< int > myOkIDs; // empty means that there is one domain
1093 typedef boost::shared_ptr<ConnectedElements> ConnectedElementsPtr;
1098 class SMESHCONTROLS_EXPORT Filter {
1102 virtual void SetPredicate(PredicatePtr thePred);
1104 typedef std::vector<long> TIdSequence;
1108 GetElementsId( const SMDS_Mesh* theMesh,
1109 TIdSequence& theSequence );
1113 GetElementsId( const SMDS_Mesh* theMesh,
1114 PredicatePtr thePredicate,
1115 TIdSequence& theSequence );
1118 PredicatePtr myPredicate;