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 <TopoDS_Face.hxx>
47 #include <boost/shared_ptr.hpp>
49 class SMDS_MeshElement;
55 class SMESHDS_SubMesh;
56 class SMESHDS_GroupBase;
63 class SMESHCONTROLS_EXPORT TSequenceOfXYZ
65 typedef std::vector<gp_XYZ>::size_type size_type;
70 explicit 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 void setElement(const SMDS_MeshElement* e) { myElem = e; }
98 const SMDS_MeshElement* getElement() const { return myElem; }
100 SMDSAbs_EntityType getElementEntity() const;
103 std::vector<gp_XYZ> myArray;
104 const SMDS_MeshElement* myElem;
108 * \brief Class used to detect mesh modification: IsMeshModified() returns
109 * true if a mesh has changed since last calling IsMeshModified()
111 class SMESHCONTROLS_EXPORT TMeshModifTracer
113 unsigned long myMeshModifTime;
114 const SMDS_Mesh* myMesh;
117 void SetMesh( const SMDS_Mesh* theMesh );
118 const SMDS_Mesh* GetMesh() const { return myMesh; }
119 bool IsMeshModified();
123 Class : NumericalFunctor
124 Description : Root of all Functors returning numeric value
126 class SMESHCONTROLS_EXPORT NumericalFunctor: public virtual Functor{
129 virtual void SetMesh( const SMDS_Mesh* theMesh );
130 virtual double GetValue( long theElementId );
131 virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
132 void GetHistogram(int nbIntervals,
133 std::vector<int>& nbEvents,
134 std::vector<double>& funValues,
135 const std::vector<int>& elements,
136 const double* minmax=0,
137 const bool isLogarithmic = false);
138 virtual SMDSAbs_ElementType GetType() const = 0;
139 virtual double GetBadRate( double Value, int nbNodes ) const = 0;
140 long GetPrecision() const;
141 void SetPrecision( const long thePrecision );
142 double Round( const double & value );
144 bool GetPoints(const int theId, TSequenceOfXYZ& theRes) const;
145 static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes);
147 const SMDS_Mesh* myMesh;
148 const SMDS_MeshElement* myCurrElement;
150 double myPrecisionValue;
156 Description : Functor calculating volume of 3D mesh element
158 class SMESHCONTROLS_EXPORT Volume: public virtual NumericalFunctor{
160 virtual double GetValue( long theElementId );
161 //virtual double GetValue( const TSequenceOfXYZ& thePoints );
162 virtual double GetBadRate( double Value, int nbNodes ) const;
163 virtual SMDSAbs_ElementType GetType() const;
168 Class : MaxElementLength2D
169 Description : Functor calculating maximum length of 2D element
171 class SMESHCONTROLS_EXPORT MaxElementLength2D: public virtual NumericalFunctor{
173 virtual double GetValue( long theElementId );
174 virtual double GetValue( const TSequenceOfXYZ& P );
175 virtual double GetBadRate( double Value, int nbNodes ) const;
176 virtual SMDSAbs_ElementType GetType() const;
181 Class : MaxElementLength3D
182 Description : Functor calculating maximum length of 3D element
184 class SMESHCONTROLS_EXPORT MaxElementLength3D: public virtual NumericalFunctor{
186 virtual double GetValue( long theElementId );
187 virtual double GetBadRate( double Value, int nbNodes ) const;
188 virtual SMDSAbs_ElementType GetType() const;
193 Class : SMESH_MinimumAngle
194 Description : Functor for calculation of minimum angle
196 class SMESHCONTROLS_EXPORT MinimumAngle: public virtual NumericalFunctor{
198 virtual double GetValue( const TSequenceOfXYZ& thePoints );
199 virtual double GetBadRate( double Value, int nbNodes ) const;
200 virtual SMDSAbs_ElementType GetType() const;
206 Description : Functor for calculating aspect ratio
208 class SMESHCONTROLS_EXPORT AspectRatio: public virtual NumericalFunctor{
210 virtual double GetValue( long theElementId );
211 virtual double GetValue( const TSequenceOfXYZ& thePoints );
212 virtual double GetBadRate( double Value, int nbNodes ) const;
213 virtual SMDSAbs_ElementType GetType() const;
218 Class : AspectRatio3D
219 Description : Functor for calculating aspect ratio of 3D elems.
221 class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
223 virtual double GetValue( long theElementId );
224 virtual double GetValue( const TSequenceOfXYZ& thePoints );
225 virtual double GetBadRate( double Value, int nbNodes ) const;
226 virtual SMDSAbs_ElementType GetType() const;
232 Description : Functor for calculating warping
234 class SMESHCONTROLS_EXPORT Warping: public virtual NumericalFunctor{
236 virtual double GetValue( const TSequenceOfXYZ& thePoints );
237 virtual double GetBadRate( double Value, int nbNodes ) const;
238 virtual SMDSAbs_ElementType GetType() const;
241 double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
247 Description : Functor for calculating taper
249 class SMESHCONTROLS_EXPORT Taper: public virtual NumericalFunctor{
251 virtual double GetValue( const TSequenceOfXYZ& thePoints );
252 virtual double GetBadRate( double Value, int nbNodes ) const;
253 virtual SMDSAbs_ElementType GetType() const;
258 Description : Functor for calculating skew in degrees
260 class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
262 virtual double GetValue( const TSequenceOfXYZ& thePoints );
263 virtual double GetBadRate( double Value, int nbNodes ) const;
264 virtual SMDSAbs_ElementType GetType() const;
270 Description : Functor for calculating area
272 class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
274 virtual double GetValue( const TSequenceOfXYZ& thePoints );
275 virtual double GetBadRate( double Value, int nbNodes ) const;
276 virtual SMDSAbs_ElementType GetType() const;
282 Description : Functor for calculating length of edge
284 class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
286 virtual double GetValue( const TSequenceOfXYZ& thePoints );
287 virtual double GetBadRate( double Value, int nbNodes ) const;
288 virtual SMDSAbs_ElementType GetType() const;
293 Description : Functor for calculating length of edge
295 class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
297 virtual double GetValue( long theElementId );
298 virtual double GetBadRate( double Value, int nbNodes ) const;
299 virtual SMDSAbs_ElementType GetType() const;
303 Value(double theLength, long thePntId1, long thePntId2);
304 bool operator<(const Value& x) const;
306 typedef std::set<Value> TValues;
307 void GetValues(TValues& theValues);
309 typedef boost::shared_ptr<Length2D> Length2DPtr;
312 Class : MultiConnection
313 Description : Functor for calculating number of faces connected to the edge
315 class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
317 virtual double GetValue( long theElementId );
318 virtual double GetValue( const TSequenceOfXYZ& thePoints );
319 virtual double GetBadRate( double Value, int nbNodes ) const;
320 virtual SMDSAbs_ElementType GetType() const;
324 Class : MultiConnection2D
325 Description : Functor for calculating number of faces connected to the edge
327 class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
329 virtual double GetValue( long theElementId );
330 virtual double GetValue( const TSequenceOfXYZ& thePoints );
331 virtual double GetBadRate( double Value, int nbNodes ) const;
332 virtual SMDSAbs_ElementType GetType() const;
335 Value(long thePntId1, long thePntId2);
336 bool operator<(const Value& x) const;
338 typedef std::map<Value,int> MValues;
340 void GetValues(MValues& theValues);
342 typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
346 Description : Functor returning diameter of a ball element
348 class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{
350 virtual double GetValue( long theElementId );
351 virtual double GetBadRate( double Value, int nbNodes ) const;
352 virtual SMDSAbs_ElementType GetType() const;
360 Class : CoincidentNodes
361 Description : Predicate of Coincident Nodes
362 Note : This class is suitable only for visualization of Coincident Nodes
364 class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
367 virtual void SetMesh( const SMDS_Mesh* theMesh );
368 virtual bool IsSatisfy( long theElementId );
369 virtual SMDSAbs_ElementType GetType() const;
371 void SetTolerance (const double theToler) { myToler = theToler; }
372 double GetTolerance () const { return myToler; }
376 TColStd_MapOfInteger myCoincidentIDs;
377 TMeshModifTracer myMeshModifTracer;
379 typedef boost::shared_ptr<CoincidentNodes> CoincidentNodesPtr;
382 Class : CoincidentElements
383 Description : Predicate of Coincident Elements
384 Note : This class is suitable only for visualization of Coincident Elements
386 class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate {
388 CoincidentElements();
389 virtual void SetMesh( const SMDS_Mesh* theMesh );
390 virtual bool IsSatisfy( long theElementId );
393 const SMDS_Mesh* myMesh;
395 class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
397 virtual SMDSAbs_ElementType GetType() const;
399 class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
401 virtual SMDSAbs_ElementType GetType() const;
403 class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
405 virtual SMDSAbs_ElementType GetType() const;
410 Description : Predicate for free borders
412 class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
415 virtual void SetMesh( const SMDS_Mesh* theMesh );
416 virtual bool IsSatisfy( long theElementId );
417 virtual SMDSAbs_ElementType GetType() const;
420 const SMDS_Mesh* myMesh;
425 Class : BadOrientedVolume
426 Description : Predicate bad oriented volumes
428 class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
431 virtual void SetMesh( const SMDS_Mesh* theMesh );
432 virtual bool IsSatisfy( long theElementId );
433 virtual SMDSAbs_ElementType GetType() const;
436 const SMDS_Mesh* myMesh;
440 Class : ElemEntityType
441 Description : Functor for calculating entity type
443 class SMESHCONTROLS_EXPORT ElemEntityType: public virtual Predicate{
446 virtual void SetMesh( const SMDS_Mesh* theMesh );
447 virtual bool IsSatisfy( long theElementId );
448 void SetType( SMDSAbs_ElementType theType );
449 virtual SMDSAbs_ElementType GetType() const;
450 void SetElemEntityType( SMDSAbs_EntityType theEntityType );
451 SMDSAbs_EntityType GetElemEntityType() const;
454 const SMDS_Mesh* myMesh;
455 SMDSAbs_ElementType myType;
456 SMDSAbs_EntityType myEntityType;
458 typedef boost::shared_ptr<ElemEntityType> ElemEntityTypePtr;
464 class SMESHCONTROLS_EXPORT BareBorderVolume: public Predicate
467 BareBorderVolume():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 );
472 const SMDS_Mesh* myMesh;
474 typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
479 class SMESHCONTROLS_EXPORT BareBorderFace: public Predicate
482 BareBorderFace():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 );
487 const SMDS_Mesh* myMesh;
488 std::vector< const SMDS_MeshNode* > myLinkNodes;
490 typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
493 OverConstrainedVolume
495 class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
498 OverConstrainedVolume():myMesh(0) {}
499 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
500 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
501 virtual bool IsSatisfy( long theElementId );
503 const SMDS_Mesh* myMesh;
505 typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
510 class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
513 OverConstrainedFace():myMesh(0) {}
514 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
515 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
516 virtual bool IsSatisfy( long theElementId );
518 const SMDS_Mesh* myMesh;
520 typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
524 Description : Predicate for free Edges
526 class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
529 virtual void SetMesh( const SMDS_Mesh* theMesh );
530 virtual bool IsSatisfy( long theElementId );
531 virtual SMDSAbs_ElementType GetType() const;
532 static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId );
533 typedef long TElemId;
537 Border(long theElemId, long thePntId1, long thePntId2);
538 bool operator<(const Border& x) const;
540 typedef std::set<Border> TBorders;
541 void GetBoreders(TBorders& theBorders);
544 const SMDS_Mesh* myMesh;
546 typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
551 Description : Predicate for free nodes
553 class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
556 virtual void SetMesh( const SMDS_Mesh* theMesh );
557 virtual bool IsSatisfy( long theNodeId );
558 virtual SMDSAbs_ElementType GetType() const;
561 const SMDS_Mesh* myMesh;
567 Description : Predicate for Range of Ids.
568 Range may be specified with two ways.
569 1. Using AddToRange method
570 2. With SetRangeStr method. Parameter of this method is a string
571 like as "1,2,3,50-60,63,67,70-"
573 class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
577 virtual void SetMesh( const SMDS_Mesh* theMesh );
578 virtual bool IsSatisfy( long theNodeId );
579 virtual SMDSAbs_ElementType GetType() const;
580 virtual void SetType( SMDSAbs_ElementType theType );
582 bool AddToRange( long theEntityId );
583 void GetRangeStr( TCollection_AsciiString& );
584 bool SetRangeStr( const TCollection_AsciiString& );
587 const SMDS_Mesh* myMesh;
589 TColStd_SequenceOfInteger myMin;
590 TColStd_SequenceOfInteger myMax;
591 TColStd_MapOfInteger myIds;
593 SMDSAbs_ElementType myType;
596 typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
601 Description : Base class for comparators
603 class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
606 virtual ~Comparator();
607 virtual void SetMesh( const SMDS_Mesh* theMesh );
608 virtual void SetMargin(double theValue);
609 virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
610 virtual bool IsSatisfy( long theElementId ) = 0;
611 virtual SMDSAbs_ElementType GetType() const;
616 NumericalFunctorPtr myFunctor;
618 typedef boost::shared_ptr<Comparator> ComparatorPtr;
623 Description : Comparator "<"
625 class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
627 virtual bool IsSatisfy( long theElementId );
633 Description : Comparator ">"
635 class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
637 virtual bool IsSatisfy( long theElementId );
643 Description : Comparator "="
645 class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
648 virtual bool IsSatisfy( long theElementId );
649 virtual void SetTolerance( double theTol );
650 virtual double GetTolerance();
655 typedef boost::shared_ptr<EqualTo> EqualToPtr;
660 Description : Logical NOT predicate
662 class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
665 virtual ~LogicalNOT();
666 virtual bool IsSatisfy( long theElementId );
667 virtual void SetMesh( const SMDS_Mesh* theMesh );
668 virtual void SetPredicate(PredicatePtr thePred);
669 virtual SMDSAbs_ElementType GetType() const;
672 PredicatePtr myPredicate;
674 typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
678 Class : LogicalBinary
679 Description : Base class for binary logical predicate
681 class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
684 virtual ~LogicalBinary();
685 virtual void SetMesh( const SMDS_Mesh* theMesh );
686 virtual void SetPredicate1(PredicatePtr thePred);
687 virtual void SetPredicate2(PredicatePtr thePred);
688 virtual SMDSAbs_ElementType GetType() const;
691 PredicatePtr myPredicate1;
692 PredicatePtr myPredicate2;
694 typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
699 Description : Logical AND
701 class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
703 virtual bool IsSatisfy( long theElementId );
709 Description : Logical OR
711 class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
713 virtual bool IsSatisfy( long theElementId );
719 Description : Predicate for manifold part of mesh
721 class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
724 /* internal class for algorithm uses */
728 Link( SMDS_MeshNode* theNode1,
729 SMDS_MeshNode* theNode2 );
732 bool IsEqual( const ManifoldPart::Link& theLink ) const;
733 bool operator<(const ManifoldPart::Link& x) const;
735 SMDS_MeshNode* myNode1;
736 SMDS_MeshNode* myNode2;
739 bool IsEqual( const ManifoldPart::Link& theLink1,
740 const ManifoldPart::Link& theLink2 );
742 typedef std::set<ManifoldPart::Link> TMapOfLink;
743 typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
744 typedef std::vector<ManifoldPart::Link> TVectorOfLink;
745 typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
746 typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
750 virtual void SetMesh( const SMDS_Mesh* theMesh );
751 // inoke when all parameters already set
752 virtual bool IsSatisfy( long theElementId );
753 virtual SMDSAbs_ElementType GetType() const;
755 void SetAngleTolerance( const double theAngToler );
756 double GetAngleTolerance() const;
757 void SetIsOnlyManifold( const bool theIsOnly );
758 void SetStartElem( const long theStartElemId );
762 bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
763 SMDS_MeshFace* theStartFace,
764 TMapOfLink& theNonManifold,
765 TColStd_MapOfInteger& theResFaces );
766 bool isInPlane( const SMDS_MeshFace* theFace1,
767 const SMDS_MeshFace* theFace2 );
768 void expandBoundary( TMapOfLink& theMapOfBoundary,
769 TVectorOfLink& theSeqOfBoundary,
770 TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
771 TMapOfLink& theNonManifold,
772 SMDS_MeshFace* theNextFace ) const;
774 void getFacesByLink( const Link& theLink,
775 TVectorOfFacePtr& theFaces ) const;
778 const SMDS_Mesh* myMesh;
779 TColStd_MapOfInteger myMapIds;
780 TColStd_MapOfInteger myMapBadGeomIds;
781 TVectorOfFacePtr myAllFacePtr;
782 TDataMapFacePtrInt myAllFacePtrIntDMap;
784 bool myIsOnlyManifold;
788 typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
791 Class : BelongToMeshGroup
792 Description : Verify whether a mesh element is included into a mesh group
794 class SMESHCONTROLS_EXPORT BelongToMeshGroup : public virtual Predicate
798 virtual void SetMesh( const SMDS_Mesh* theMesh );
799 virtual bool IsSatisfy( long theElementId );
800 virtual SMDSAbs_ElementType GetType() const;
802 void SetGroup( SMESHDS_GroupBase* g );
803 void SetStoreName( const std::string& sn );
804 const SMESHDS_GroupBase* GetGroup() const { return myGroup; }
807 SMESHDS_GroupBase* myGroup;
808 std::string myStoreName;
810 typedef boost::shared_ptr<BelongToMeshGroup> BelongToMeshGroupPtr;
813 Class : ElementsOnSurface
814 Description : Predicate elements that lying on indicated surface
817 class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
820 ~ElementsOnSurface();
821 virtual void SetMesh( const SMDS_Mesh* theMesh );
822 virtual bool IsSatisfy( long theElementId );
823 virtual SMDSAbs_ElementType GetType() const;
825 void SetTolerance( const double theToler );
826 double GetTolerance() const;
827 void SetSurface( const TopoDS_Shape& theShape,
828 const SMDSAbs_ElementType theType );
829 void SetUseBoundaries( bool theUse );
830 bool GetUseBoundaries() const { return myUseBoundaries; }
834 void process( const SMDS_MeshElement* theElem );
835 bool isOnSurface( const SMDS_MeshNode* theNode );
838 TMeshModifTracer myMeshModifTracer;
839 TColStd_MapOfInteger myIds;
840 SMDSAbs_ElementType myType;
843 bool myUseBoundaries;
844 GeomAPI_ProjectPointOnSurf myProjector;
847 typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
851 Class : ElementsOnShape
852 Description : Predicate elements that lying on indicated shape
855 class SMESHCONTROLS_EXPORT ElementsOnShape : public virtual Predicate
861 virtual void SetMesh (const SMDS_Mesh* theMesh);
862 virtual bool IsSatisfy (long theElementId);
863 virtual SMDSAbs_ElementType GetType() const;
865 void SetTolerance (const double theToler);
866 double GetTolerance() const;
867 void SetAllNodes (bool theAllNodes);
868 bool GetAllNodes() const { return myAllNodesFlag; }
869 void SetShape (const TopoDS_Shape& theShape,
870 const SMDSAbs_ElementType theType);
876 TClassifier(const TopoDS_Shape& s, double tol) { Init(s,tol); }
877 void Init(const TopoDS_Shape& s, double tol);
878 bool IsOut(const gp_Pnt& p);
879 TopAbs_ShapeEnum ShapeType() const;
881 bool isOutOfSolid (const gp_Pnt& p);
882 bool isOutOfBox (const gp_Pnt& p);
883 bool isOutOfFace (const gp_Pnt& p);
884 bool isOutOfEdge (const gp_Pnt& p);
885 bool isOutOfVertex(const gp_Pnt& p);
886 bool isBox (const TopoDS_Shape& s);
888 bool (TClassifier::* myIsOutFun)(const gp_Pnt& p);
889 BRepClass3d_SolidClassifier mySolidClfr;
891 GeomAPI_ProjectPointOnSurf myProjFace;
892 GeomAPI_ProjectPointOnCurve myProjEdge;
894 TopoDS_Shape myShape;
897 void clearClassifiers();
898 bool getNodeIsOut( const SMDS_MeshNode* n, bool& isOut );
899 void setNodeIsOut( const SMDS_MeshNode* n, bool isOut );
901 std::vector< TClassifier* > myClassifiers;
902 SMDSAbs_ElementType myType;
903 TopoDS_Shape myShape;
907 TMeshModifTracer myMeshModifTracer;
908 std::vector<bool> myNodeIsChecked;
909 std::vector<bool> myNodeIsOut;
912 typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
917 Description : Predicate for verifying whether entiy belong to
918 specified geometrical support
920 class SMESHCONTROLS_EXPORT BelongToGeom: public virtual Predicate
925 virtual void SetMesh( const SMDS_Mesh* theMesh );
926 virtual void SetGeom( const TopoDS_Shape& theShape );
928 virtual bool IsSatisfy( long theElementId );
930 virtual void SetType( SMDSAbs_ElementType theType );
931 virtual SMDSAbs_ElementType GetType() const;
933 TopoDS_Shape GetShape();
934 const SMESHDS_Mesh* GetMeshDS() const;
936 void SetTolerance( double );
937 double GetTolerance();
942 TopoDS_Shape myShape;
943 const SMESHDS_Mesh* myMeshDS;
944 SMDSAbs_ElementType myType;
946 double myTolerance; // only if myIsSubshape == false
947 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
949 typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
953 Description : Predicate for verifying whether entiy lying or partially lying on
954 specified geometrical support
956 class SMESHCONTROLS_EXPORT LyingOnGeom: public virtual Predicate
961 virtual void SetMesh( const SMDS_Mesh* theMesh );
962 virtual void SetGeom( const TopoDS_Shape& theShape );
964 virtual bool IsSatisfy( long theElementId );
966 virtual void SetType( SMDSAbs_ElementType theType );
967 virtual SMDSAbs_ElementType GetType() const;
969 TopoDS_Shape GetShape();
970 const SMESHDS_Mesh* GetMeshDS() const;
972 void SetTolerance( double );
973 double GetTolerance();
975 virtual bool Contains( const SMESHDS_Mesh* theMeshDS,
976 const TopoDS_Shape& theShape,
977 const SMDS_MeshElement* theElem,
978 TopAbs_ShapeEnum theFindShapeEnum,
979 TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE );
983 TopoDS_Shape myShape;
984 TColStd_MapOfInteger mySubShapesIDs;
985 const SMESHDS_Mesh* myMeshDS;
986 SMDSAbs_ElementType myType;
988 double myTolerance; // only if myIsSubshape == false
989 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
991 typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
995 Description : Predicate for free faces
997 class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
1000 virtual void SetMesh( const SMDS_Mesh* theMesh );
1001 virtual bool IsSatisfy( long theElementId );
1002 virtual SMDSAbs_ElementType GetType() const;
1005 const SMDS_Mesh* myMesh;
1009 Class : LinearOrQuadratic
1010 Description : Predicate for free faces
1012 class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
1014 LinearOrQuadratic();
1015 virtual void SetMesh( const SMDS_Mesh* theMesh );
1016 virtual bool IsSatisfy( long theElementId );
1017 void SetType( SMDSAbs_ElementType theType );
1018 virtual SMDSAbs_ElementType GetType() const;
1021 const SMDS_Mesh* myMesh;
1022 SMDSAbs_ElementType myType;
1024 typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
1028 Description : Functor for check color of group to whic mesh element belongs to
1030 class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
1033 virtual void SetMesh( const SMDS_Mesh* theMesh );
1034 virtual bool IsSatisfy( long theElementId );
1035 void SetType( SMDSAbs_ElementType theType );
1036 virtual SMDSAbs_ElementType GetType() const;
1037 void SetColorStr( const TCollection_AsciiString& );
1038 void GetColorStr( TCollection_AsciiString& ) const;
1041 typedef std::set< long > TIDs;
1043 Quantity_Color myColor;
1044 SMDSAbs_ElementType myType;
1047 typedef boost::shared_ptr<GroupColor> GroupColorPtr;
1050 Class : ElemGeomType
1051 Description : Predicate to check element geometry type
1053 class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
1056 virtual void SetMesh( const SMDS_Mesh* theMesh );
1057 virtual bool IsSatisfy( long theElementId );
1058 void SetType( SMDSAbs_ElementType theType );
1059 virtual SMDSAbs_ElementType GetType() const;
1060 void SetGeomType( SMDSAbs_GeometryType theType );
1061 SMDSAbs_GeometryType GetGeomType() const;
1064 const SMDS_Mesh* myMesh;
1065 SMDSAbs_ElementType myType;
1066 SMDSAbs_GeometryType myGeomType;
1068 typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
1071 Class : CoplanarFaces
1072 Description : Predicate to check angle between faces
1074 class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
1078 void SetFace( long theID ) { myFaceID = theID; }
1079 long GetFace() const { return myFaceID; }
1080 void SetTolerance (const double theToler) { myToler = theToler; }
1081 double GetTolerance () const { return myToler; }
1082 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
1084 virtual void SetMesh( const SMDS_Mesh* theMesh );
1085 virtual bool IsSatisfy( long theElementId );
1088 TMeshModifTracer myMeshModifTracer;
1091 std::set< long > myCoplanarIDs;
1093 typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
1096 Class : ConnectedElements
1097 Description : Predicate to get elements of one domain
1099 class SMESHCONTROLS_EXPORT ConnectedElements: public virtual Predicate
1102 ConnectedElements();
1103 void SetNode( int nodeID );
1104 void SetPoint( double x, double y, double z );
1105 int GetNode() const;
1106 std::vector<double> GetPoint() const;
1108 void SetType( SMDSAbs_ElementType theType );
1109 virtual SMDSAbs_ElementType GetType() const;
1111 virtual void SetMesh( const SMDS_Mesh* theMesh );
1112 virtual bool IsSatisfy( long theElementId );
1114 //const std::set<long>& GetDomainIDs() const { return myOkIDs; }
1118 std::vector<double> myXYZ;
1119 SMDSAbs_ElementType myType;
1120 TMeshModifTracer myMeshModifTracer;
1124 std::set< int > myOkIDs; // empty means that there is one domain
1126 typedef boost::shared_ptr<ConnectedElements> ConnectedElementsPtr;
1131 class SMESHCONTROLS_EXPORT Filter {
1135 virtual void SetPredicate(PredicatePtr thePred);
1137 typedef std::vector<long> TIdSequence;
1141 GetElementsId( const SMDS_Mesh* theMesh,
1142 TIdSequence& theSequence );
1146 GetElementsId( const SMDS_Mesh* theMesh,
1147 PredicatePtr thePredicate,
1148 TIdSequence& theSequence );
1151 PredicatePtr myPredicate;