1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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;
57 class SMESHDS_GroupBase;
64 class SMESHCONTROLS_EXPORT TSequenceOfXYZ
66 typedef std::vector<gp_XYZ>::size_type size_type;
71 TSequenceOfXYZ(size_type n);
73 TSequenceOfXYZ(size_type n, const gp_XYZ& t);
75 TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ);
77 template <class InputIterator>
78 TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd);
82 TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ);
84 gp_XYZ& operator()(size_type n);
86 const gp_XYZ& operator()(size_type n) const;
90 void reserve(size_type n);
92 void push_back(const gp_XYZ& v);
94 size_type size() const;
97 std::vector<gp_XYZ> myArray;
101 * \brief Class used to detect mesh modification: IsMeshModified() returns
102 * true if a mesh has changed since last calling IsMeshModified()
104 class SMESHCONTROLS_EXPORT TMeshModifTracer
106 unsigned long myMeshModifTime;
107 const SMDS_Mesh* myMesh;
110 void SetMesh( const SMDS_Mesh* theMesh );
111 const SMDS_Mesh* GetMesh() const { return myMesh; }
112 bool IsMeshModified();
116 Class : NumericalFunctor
117 Description : Root of all Functors returning numeric value
119 class SMESHCONTROLS_EXPORT NumericalFunctor: public virtual Functor{
122 virtual void SetMesh( const SMDS_Mesh* theMesh );
123 virtual double GetValue( long theElementId );
124 virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
125 void GetHistogram(int nbIntervals,
126 std::vector<int>& nbEvents,
127 std::vector<double>& funValues,
128 const std::vector<int>& elements,
129 const double* minmax=0,
130 const bool isLogarithmic = false);
131 virtual SMDSAbs_ElementType GetType() const = 0;
132 virtual double GetBadRate( double Value, int nbNodes ) const = 0;
133 long GetPrecision() const;
134 void SetPrecision( const long thePrecision );
135 double Round( const double & value );
137 bool GetPoints(const int theId, TSequenceOfXYZ& theRes) const;
138 static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes);
140 const SMDS_Mesh* myMesh;
141 const SMDS_MeshElement* myCurrElement;
143 double myPrecisionValue;
149 Description : Functor calculating volume of 3D mesh element
151 class SMESHCONTROLS_EXPORT Volume: public virtual NumericalFunctor{
153 virtual double GetValue( long theElementId );
154 //virtual double GetValue( const TSequenceOfXYZ& thePoints );
155 virtual double GetBadRate( double Value, int nbNodes ) const;
156 virtual SMDSAbs_ElementType GetType() const;
161 Class : MaxElementLength2D
162 Description : Functor calculating maximum length of 2D element
164 class SMESHCONTROLS_EXPORT MaxElementLength2D: public virtual NumericalFunctor{
166 virtual double GetValue( long theElementId );
167 virtual double GetValue( const TSequenceOfXYZ& P );
168 virtual double GetBadRate( double Value, int nbNodes ) const;
169 virtual SMDSAbs_ElementType GetType() const;
174 Class : MaxElementLength3D
175 Description : Functor calculating maximum length of 3D element
177 class SMESHCONTROLS_EXPORT MaxElementLength3D: public virtual NumericalFunctor{
179 virtual double GetValue( long theElementId );
180 virtual double GetBadRate( double Value, int nbNodes ) const;
181 virtual SMDSAbs_ElementType GetType() const;
186 Class : SMESH_MinimumAngle
187 Description : Functor for calculation of minimum angle
189 class SMESHCONTROLS_EXPORT MinimumAngle: public virtual NumericalFunctor{
191 virtual double GetValue( const TSequenceOfXYZ& thePoints );
192 virtual double GetBadRate( double Value, int nbNodes ) const;
193 virtual SMDSAbs_ElementType GetType() const;
199 Description : Functor for calculating aspect ratio
201 class SMESHCONTROLS_EXPORT AspectRatio: public virtual NumericalFunctor{
203 virtual double GetValue( long theElementId );
204 virtual double GetValue( const TSequenceOfXYZ& thePoints );
205 virtual double GetBadRate( double Value, int nbNodes ) const;
206 virtual SMDSAbs_ElementType GetType() const;
211 Class : AspectRatio3D
212 Description : Functor for calculating aspect ratio of 3D elems.
214 class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
216 virtual double GetValue( long theElementId );
217 virtual double GetValue( const TSequenceOfXYZ& thePoints );
218 virtual double GetBadRate( double Value, int nbNodes ) const;
219 virtual SMDSAbs_ElementType GetType() const;
225 Description : Functor for calculating warping
227 class SMESHCONTROLS_EXPORT Warping: public virtual NumericalFunctor{
229 virtual double GetValue( const TSequenceOfXYZ& thePoints );
230 virtual double GetBadRate( double Value, int nbNodes ) const;
231 virtual SMDSAbs_ElementType GetType() const;
234 double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
240 Description : Functor for calculating taper
242 class SMESHCONTROLS_EXPORT Taper: public virtual NumericalFunctor{
244 virtual double GetValue( const TSequenceOfXYZ& thePoints );
245 virtual double GetBadRate( double Value, int nbNodes ) const;
246 virtual SMDSAbs_ElementType GetType() const;
251 Description : Functor for calculating skew in degrees
253 class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
255 virtual double GetValue( const TSequenceOfXYZ& thePoints );
256 virtual double GetBadRate( double Value, int nbNodes ) const;
257 virtual SMDSAbs_ElementType GetType() const;
263 Description : Functor for calculating area
265 class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
267 virtual double GetValue( const TSequenceOfXYZ& thePoints );
268 virtual double GetBadRate( double Value, int nbNodes ) const;
269 virtual SMDSAbs_ElementType GetType() const;
275 Description : Functor for calculating length of edge
277 class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
279 virtual double GetValue( const TSequenceOfXYZ& thePoints );
280 virtual double GetBadRate( double Value, int nbNodes ) const;
281 virtual SMDSAbs_ElementType GetType() const;
286 Description : Functor for calculating length of edge
288 class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
290 virtual double GetValue( long theElementId );
291 virtual double GetBadRate( double Value, int nbNodes ) const;
292 virtual SMDSAbs_ElementType GetType() const;
296 Value(double theLength, long thePntId1, long thePntId2);
297 bool operator<(const Value& x) const;
299 typedef std::set<Value> TValues;
300 void GetValues(TValues& theValues);
302 typedef boost::shared_ptr<Length2D> Length2DPtr;
305 Class : MultiConnection
306 Description : Functor for calculating number of faces connected to the edge
308 class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
310 virtual double GetValue( long theElementId );
311 virtual double GetValue( const TSequenceOfXYZ& thePoints );
312 virtual double GetBadRate( double Value, int nbNodes ) const;
313 virtual SMDSAbs_ElementType GetType() const;
317 Class : MultiConnection2D
318 Description : Functor for calculating number of faces connected to the edge
320 class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
322 virtual double GetValue( long theElementId );
323 virtual double GetValue( const TSequenceOfXYZ& thePoints );
324 virtual double GetBadRate( double Value, int nbNodes ) const;
325 virtual SMDSAbs_ElementType GetType() const;
328 Value(long thePntId1, long thePntId2);
329 bool operator<(const Value& x) const;
331 typedef std::map<Value,int> MValues;
333 void GetValues(MValues& theValues);
335 typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
339 Description : Functor returning diameter of a ball element
341 class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{
343 virtual double GetValue( long theElementId );
344 virtual double GetBadRate( double Value, int nbNodes ) const;
345 virtual SMDSAbs_ElementType GetType() const;
353 Class : CoincidentNodes
354 Description : Predicate of Coincident Nodes
355 Note : This class is suitable only for visualization of Coincident Nodes
357 class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
360 virtual void SetMesh( const SMDS_Mesh* theMesh );
361 virtual bool IsSatisfy( long theElementId );
362 virtual SMDSAbs_ElementType GetType() const;
364 void SetTolerance (const double theToler) { myToler = theToler; }
365 double GetTolerance () const { return myToler; }
369 TColStd_MapOfInteger myCoincidentIDs;
370 TMeshModifTracer myMeshModifTracer;
372 typedef boost::shared_ptr<CoincidentNodes> CoincidentNodesPtr;
375 Class : CoincidentElements
376 Description : Predicate of Coincident Elements
377 Note : This class is suitable only for visualization of Coincident Elements
379 class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate {
381 CoincidentElements();
382 virtual void SetMesh( const SMDS_Mesh* theMesh );
383 virtual bool IsSatisfy( long theElementId );
386 const SMDS_Mesh* myMesh;
388 class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
390 virtual SMDSAbs_ElementType GetType() const;
392 class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
394 virtual SMDSAbs_ElementType GetType() const;
396 class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
398 virtual SMDSAbs_ElementType GetType() const;
403 Description : Predicate for free borders
405 class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
408 virtual void SetMesh( const SMDS_Mesh* theMesh );
409 virtual bool IsSatisfy( long theElementId );
410 virtual SMDSAbs_ElementType GetType() const;
413 const SMDS_Mesh* myMesh;
418 Class : BadOrientedVolume
419 Description : Predicate bad oriented volumes
421 class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
424 virtual void SetMesh( const SMDS_Mesh* theMesh );
425 virtual bool IsSatisfy( long theElementId );
426 virtual SMDSAbs_ElementType GetType() const;
429 const SMDS_Mesh* myMesh;
433 Class : ElemEntityType
434 Description : Functor for calculating entity type
436 class SMESHCONTROLS_EXPORT ElemEntityType: public virtual Predicate{
439 virtual void SetMesh( const SMDS_Mesh* theMesh );
440 virtual bool IsSatisfy( long theElementId );
441 void SetType( SMDSAbs_ElementType theType );
442 virtual SMDSAbs_ElementType GetType() const;
443 void SetElemEntityType( SMDSAbs_EntityType theEntityType );
444 SMDSAbs_EntityType GetElemEntityType() const;
447 const SMDS_Mesh* myMesh;
448 SMDSAbs_ElementType myType;
449 SMDSAbs_EntityType myEntityType;
451 typedef boost::shared_ptr<ElemEntityType> ElemEntityTypePtr;
457 class SMESHCONTROLS_EXPORT BareBorderVolume: public Predicate
460 BareBorderVolume():myMesh(0) {}
461 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
462 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
463 virtual bool IsSatisfy( long theElementId );
465 const SMDS_Mesh* myMesh;
467 typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
472 class SMESHCONTROLS_EXPORT BareBorderFace: public Predicate
475 BareBorderFace():myMesh(0) {}
476 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
477 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
478 virtual bool IsSatisfy( long theElementId );
480 const SMDS_Mesh* myMesh;
481 std::vector< const SMDS_MeshNode* > myLinkNodes;
483 typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
486 OverConstrainedVolume
488 class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
491 OverConstrainedVolume():myMesh(0) {}
492 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
493 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
494 virtual bool IsSatisfy( long theElementId );
496 const SMDS_Mesh* myMesh;
498 typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
503 class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
506 OverConstrainedFace():myMesh(0) {}
507 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
508 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
509 virtual bool IsSatisfy( long theElementId );
511 const SMDS_Mesh* myMesh;
513 typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
517 Description : Predicate for free Edges
519 class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
522 virtual void SetMesh( const SMDS_Mesh* theMesh );
523 virtual bool IsSatisfy( long theElementId );
524 virtual SMDSAbs_ElementType GetType() const;
525 static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId );
526 typedef long TElemId;
530 Border(long theElemId, long thePntId1, long thePntId2);
531 bool operator<(const Border& x) const;
533 typedef std::set<Border> TBorders;
534 void GetBoreders(TBorders& theBorders);
537 const SMDS_Mesh* myMesh;
539 typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
544 Description : Predicate for free nodes
546 class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
549 virtual void SetMesh( const SMDS_Mesh* theMesh );
550 virtual bool IsSatisfy( long theNodeId );
551 virtual SMDSAbs_ElementType GetType() const;
554 const SMDS_Mesh* myMesh;
560 Description : Predicate for Range of Ids.
561 Range may be specified with two ways.
562 1. Using AddToRange method
563 2. With SetRangeStr method. Parameter of this method is a string
564 like as "1,2,3,50-60,63,67,70-"
566 class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
570 virtual void SetMesh( const SMDS_Mesh* theMesh );
571 virtual bool IsSatisfy( long theNodeId );
572 virtual SMDSAbs_ElementType GetType() const;
573 virtual void SetType( SMDSAbs_ElementType theType );
575 bool AddToRange( long theEntityId );
576 void GetRangeStr( TCollection_AsciiString& );
577 bool SetRangeStr( const TCollection_AsciiString& );
580 const SMDS_Mesh* myMesh;
582 TColStd_SequenceOfInteger myMin;
583 TColStd_SequenceOfInteger myMax;
584 TColStd_MapOfInteger myIds;
586 SMDSAbs_ElementType myType;
589 typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
594 Description : Base class for comparators
596 class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
599 virtual ~Comparator();
600 virtual void SetMesh( const SMDS_Mesh* theMesh );
601 virtual void SetMargin(double theValue);
602 virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
603 virtual bool IsSatisfy( long theElementId ) = 0;
604 virtual SMDSAbs_ElementType GetType() const;
609 NumericalFunctorPtr myFunctor;
611 typedef boost::shared_ptr<Comparator> ComparatorPtr;
616 Description : Comparator "<"
618 class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
620 virtual bool IsSatisfy( long theElementId );
626 Description : Comparator ">"
628 class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
630 virtual bool IsSatisfy( long theElementId );
636 Description : Comparator "="
638 class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
641 virtual bool IsSatisfy( long theElementId );
642 virtual void SetTolerance( double theTol );
643 virtual double GetTolerance();
648 typedef boost::shared_ptr<EqualTo> EqualToPtr;
653 Description : Logical NOT predicate
655 class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
658 virtual ~LogicalNOT();
659 virtual bool IsSatisfy( long theElementId );
660 virtual void SetMesh( const SMDS_Mesh* theMesh );
661 virtual void SetPredicate(PredicatePtr thePred);
662 virtual SMDSAbs_ElementType GetType() const;
665 PredicatePtr myPredicate;
667 typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
671 Class : LogicalBinary
672 Description : Base class for binary logical predicate
674 class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
677 virtual ~LogicalBinary();
678 virtual void SetMesh( const SMDS_Mesh* theMesh );
679 virtual void SetPredicate1(PredicatePtr thePred);
680 virtual void SetPredicate2(PredicatePtr thePred);
681 virtual SMDSAbs_ElementType GetType() const;
684 PredicatePtr myPredicate1;
685 PredicatePtr myPredicate2;
687 typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
692 Description : Logical AND
694 class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
696 virtual bool IsSatisfy( long theElementId );
702 Description : Logical OR
704 class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
706 virtual bool IsSatisfy( long theElementId );
712 Description : Predicate for manifold part of mesh
714 class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
717 /* internal class for algorithm uses */
721 Link( SMDS_MeshNode* theNode1,
722 SMDS_MeshNode* theNode2 );
725 bool IsEqual( const ManifoldPart::Link& theLink ) const;
726 bool operator<(const ManifoldPart::Link& x) const;
728 SMDS_MeshNode* myNode1;
729 SMDS_MeshNode* myNode2;
732 bool IsEqual( const ManifoldPart::Link& theLink1,
733 const ManifoldPart::Link& theLink2 );
735 typedef std::set<ManifoldPart::Link> TMapOfLink;
736 typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
737 typedef std::vector<ManifoldPart::Link> TVectorOfLink;
738 typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
739 typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
743 virtual void SetMesh( const SMDS_Mesh* theMesh );
744 // inoke when all parameters already set
745 virtual bool IsSatisfy( long theElementId );
746 virtual SMDSAbs_ElementType GetType() const;
748 void SetAngleTolerance( const double theAngToler );
749 double GetAngleTolerance() const;
750 void SetIsOnlyManifold( const bool theIsOnly );
751 void SetStartElem( const long theStartElemId );
755 bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
756 SMDS_MeshFace* theStartFace,
757 TMapOfLink& theNonManifold,
758 TColStd_MapOfInteger& theResFaces );
759 bool isInPlane( const SMDS_MeshFace* theFace1,
760 const SMDS_MeshFace* theFace2 );
761 void expandBoundary( TMapOfLink& theMapOfBoundary,
762 TVectorOfLink& theSeqOfBoundary,
763 TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
764 TMapOfLink& theNonManifold,
765 SMDS_MeshFace* theNextFace ) const;
767 void getFacesByLink( const Link& theLink,
768 TVectorOfFacePtr& theFaces ) const;
771 const SMDS_Mesh* myMesh;
772 TColStd_MapOfInteger myMapIds;
773 TColStd_MapOfInteger myMapBadGeomIds;
774 TVectorOfFacePtr myAllFacePtr;
775 TDataMapFacePtrInt myAllFacePtrIntDMap;
777 bool myIsOnlyManifold;
781 typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
784 Class : BelongToMeshGroup
785 Description : Verify whether a mesh element is included into a mesh group
787 class SMESHCONTROLS_EXPORT BelongToMeshGroup : public virtual Predicate
791 virtual void SetMesh( const SMDS_Mesh* theMesh );
792 virtual bool IsSatisfy( long theElementId );
793 virtual SMDSAbs_ElementType GetType() const;
795 void SetGroup( SMESHDS_GroupBase* g );
796 void SetStoreName( const std::string& sn );
797 const SMESHDS_GroupBase* GetGroup() const { return myGroup; }
800 SMESHDS_GroupBase* myGroup;
801 std::string myStoreName;
803 typedef boost::shared_ptr<BelongToMeshGroup> BelongToMeshGroupPtr;
806 Class : ElementsOnSurface
807 Description : Predicate elements that lying on indicated surface
810 class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
813 ~ElementsOnSurface();
814 virtual void SetMesh( const SMDS_Mesh* theMesh );
815 virtual bool IsSatisfy( long theElementId );
816 virtual SMDSAbs_ElementType GetType() const;
818 void SetTolerance( const double theToler );
819 double GetTolerance() const;
820 void SetSurface( const TopoDS_Shape& theShape,
821 const SMDSAbs_ElementType theType );
822 void SetUseBoundaries( bool theUse );
823 bool GetUseBoundaries() const { return myUseBoundaries; }
827 void process( const SMDS_MeshElement* theElem );
828 bool isOnSurface( const SMDS_MeshNode* theNode );
831 TMeshModifTracer myMeshModifTracer;
832 TColStd_MapOfInteger myIds;
833 SMDSAbs_ElementType myType;
836 bool myUseBoundaries;
837 GeomAPI_ProjectPointOnSurf myProjector;
840 typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
844 Class : ElementsOnShape
845 Description : Predicate elements that lying on indicated shape
848 class SMESHCONTROLS_EXPORT ElementsOnShape : public virtual Predicate
854 virtual void SetMesh (const SMDS_Mesh* theMesh);
855 virtual bool IsSatisfy (long theElementId);
856 virtual SMDSAbs_ElementType GetType() const;
858 void SetTolerance (const double theToler);
859 double GetTolerance() const;
860 void SetAllNodes (bool theAllNodes);
861 bool GetAllNodes() const { return myAllNodesFlag; }
862 void SetShape (const TopoDS_Shape& theShape,
863 const SMDSAbs_ElementType theType);
869 TClassifier(const TopoDS_Shape& s, double tol) { Init(s,tol); }
870 void Init(const TopoDS_Shape& s, double tol);
871 bool IsOut(const gp_Pnt& p);
872 TopAbs_ShapeEnum ShapeType() const;
874 bool isOutOfSolid (const gp_Pnt& p);
875 bool isOutOfBox (const gp_Pnt& p);
876 bool isOutOfFace (const gp_Pnt& p);
877 bool isOutOfEdge (const gp_Pnt& p);
878 bool isOutOfVertex(const gp_Pnt& p);
879 bool isBox (const TopoDS_Shape& s);
881 bool (TClassifier::* myIsOutFun)(const gp_Pnt& p);
882 BRepClass3d_SolidClassifier mySolidClfr;
884 GeomAPI_ProjectPointOnSurf myProjFace;
885 GeomAPI_ProjectPointOnCurve myProjEdge;
887 TopoDS_Shape myShape;
890 void clearClassifiers();
891 bool getNodeIsOut( const SMDS_MeshNode* n, bool& isOut );
892 void setNodeIsOut( const SMDS_MeshNode* n, bool isOut );
894 std::vector< TClassifier* > myClassifiers;
895 SMDSAbs_ElementType myType;
896 TopoDS_Shape myShape;
900 TMeshModifTracer myMeshModifTracer;
901 std::vector<bool> myNodeIsChecked;
902 std::vector<bool> myNodeIsOut;
905 typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
910 Description : Predicate for verifying whether entiy belong to
911 specified geometrical support
913 class SMESHCONTROLS_EXPORT BelongToGeom: public virtual Predicate
918 virtual void SetMesh( const SMDS_Mesh* theMesh );
919 virtual void SetGeom( const TopoDS_Shape& theShape );
921 virtual bool IsSatisfy( long theElementId );
923 virtual void SetType( SMDSAbs_ElementType theType );
924 virtual SMDSAbs_ElementType GetType() const;
926 TopoDS_Shape GetShape();
927 const SMESHDS_Mesh* GetMeshDS() const;
929 void SetTolerance( double );
930 double GetTolerance();
935 TopoDS_Shape myShape;
936 const SMESHDS_Mesh* myMeshDS;
937 SMDSAbs_ElementType myType;
939 double myTolerance; // only if myIsSubshape == false
940 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
942 typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
946 Description : Predicate for verifying whether entiy lying or partially lying on
947 specified geometrical support
949 class SMESHCONTROLS_EXPORT LyingOnGeom: public virtual Predicate
954 virtual void SetMesh( const SMDS_Mesh* theMesh );
955 virtual void SetGeom( const TopoDS_Shape& theShape );
957 virtual bool IsSatisfy( long theElementId );
959 virtual void SetType( SMDSAbs_ElementType theType );
960 virtual SMDSAbs_ElementType GetType() const;
962 TopoDS_Shape GetShape();
963 const SMESHDS_Mesh* GetMeshDS() const;
965 void SetTolerance( double );
966 double GetTolerance();
968 virtual bool Contains( const SMESHDS_Mesh* theMeshDS,
969 const TopoDS_Shape& theShape,
970 const SMDS_MeshElement* theElem,
971 TopAbs_ShapeEnum theFindShapeEnum,
972 TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE );
976 TopoDS_Shape myShape;
977 const SMESHDS_Mesh* myMeshDS;
978 SMDSAbs_ElementType myType;
980 double myTolerance; // only if myIsSubshape == false
981 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
983 typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
987 Description : Predicate for free faces
989 class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
992 virtual void SetMesh( const SMDS_Mesh* theMesh );
993 virtual bool IsSatisfy( long theElementId );
994 virtual SMDSAbs_ElementType GetType() const;
997 const SMDS_Mesh* myMesh;
1001 Class : LinearOrQuadratic
1002 Description : Predicate for free faces
1004 class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
1006 LinearOrQuadratic();
1007 virtual void SetMesh( const SMDS_Mesh* theMesh );
1008 virtual bool IsSatisfy( long theElementId );
1009 void SetType( SMDSAbs_ElementType theType );
1010 virtual SMDSAbs_ElementType GetType() const;
1013 const SMDS_Mesh* myMesh;
1014 SMDSAbs_ElementType myType;
1016 typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
1020 Description : Functor for check color of group to whic mesh element belongs to
1022 class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
1025 virtual void SetMesh( const SMDS_Mesh* theMesh );
1026 virtual bool IsSatisfy( long theElementId );
1027 void SetType( SMDSAbs_ElementType theType );
1028 virtual SMDSAbs_ElementType GetType() const;
1029 void SetColorStr( const TCollection_AsciiString& );
1030 void GetColorStr( TCollection_AsciiString& ) const;
1033 typedef std::set< long > TIDs;
1035 Quantity_Color myColor;
1036 SMDSAbs_ElementType myType;
1039 typedef boost::shared_ptr<GroupColor> GroupColorPtr;
1042 Class : ElemGeomType
1043 Description : Predicate to check element geometry type
1045 class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
1048 virtual void SetMesh( const SMDS_Mesh* theMesh );
1049 virtual bool IsSatisfy( long theElementId );
1050 void SetType( SMDSAbs_ElementType theType );
1051 virtual SMDSAbs_ElementType GetType() const;
1052 void SetGeomType( SMDSAbs_GeometryType theType );
1053 SMDSAbs_GeometryType GetGeomType() const;
1056 const SMDS_Mesh* myMesh;
1057 SMDSAbs_ElementType myType;
1058 SMDSAbs_GeometryType myGeomType;
1060 typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
1063 Class : CoplanarFaces
1064 Description : Predicate to check angle between faces
1066 class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
1070 void SetFace( long theID ) { myFaceID = theID; }
1071 long GetFace() const { return myFaceID; }
1072 void SetTolerance (const double theToler) { myToler = theToler; }
1073 double GetTolerance () const { return myToler; }
1074 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
1076 virtual void SetMesh( const SMDS_Mesh* theMesh );
1077 virtual bool IsSatisfy( long theElementId );
1080 TMeshModifTracer myMeshModifTracer;
1083 std::set< long > myCoplanarIDs;
1085 typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
1088 Class : ConnectedElements
1089 Description : Predicate to get elements of one domain
1091 class SMESHCONTROLS_EXPORT ConnectedElements: public virtual Predicate
1094 ConnectedElements();
1095 void SetNode( int nodeID );
1096 void SetPoint( double x, double y, double z );
1097 int GetNode() const;
1098 std::vector<double> GetPoint() const;
1100 void SetType( SMDSAbs_ElementType theType );
1101 virtual SMDSAbs_ElementType GetType() const;
1103 virtual void SetMesh( const SMDS_Mesh* theMesh );
1104 virtual bool IsSatisfy( long theElementId );
1106 //const std::set<long>& GetDomainIDs() const { return myOkIDs; }
1110 std::vector<double> myXYZ;
1111 SMDSAbs_ElementType myType;
1112 TMeshModifTracer myMeshModifTracer;
1116 std::set< int > myOkIDs; // empty means that there is one domain
1118 typedef boost::shared_ptr<ConnectedElements> ConnectedElementsPtr;
1123 class SMESHCONTROLS_EXPORT Filter {
1127 virtual void SetPredicate(PredicatePtr thePred);
1129 typedef std::vector<long> TIdSequence;
1133 GetElementsId( const SMDS_Mesh* theMesh,
1134 TIdSequence& theSequence );
1138 GetElementsId( const SMDS_Mesh* theMesh,
1139 PredicatePtr thePredicate,
1140 TIdSequence& theSequence );
1143 PredicatePtr myPredicate;