1 // Copyright (C) 2007-2024 CEA, EDF, 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 "SMESH_TypeDefs.hxx"
30 #include <Bnd_B3d.hxx>
31 #include <GeomAPI_ProjectPointOnCurve.hxx>
32 #include <GeomAPI_ProjectPointOnSurf.hxx>
33 #include <Quantity_Color.hxx>
34 #include <TColStd_MapOfInteger.hxx>
35 #include <TCollection_AsciiString.hxx>
36 #include <NCollection_Map.hxx>
38 #include <TopoDS_Face.hxx>
45 #include <boost/shared_ptr.hpp>
47 class SMDS_MeshElement;
53 class SMESHDS_SubMesh;
54 class SMESHDS_GroupBase;
56 class BRepClass3d_SolidClassifier;
57 class ShapeAnalysis_Surface;
61 typedef NCollection_Map< smIdType, smIdHasher > TIDsMap;
62 typedef NCollection_Sequence<smIdType> TIDsSeq;
67 class SMESHCONTROLS_EXPORT TSequenceOfXYZ
69 typedef std::vector<gp_XYZ>::size_type size_type;
74 explicit TSequenceOfXYZ(size_type n);
76 TSequenceOfXYZ(size_type n, const gp_XYZ& t);
78 TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ);
80 template <class InputIterator>
81 TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd);
85 TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ);
87 gp_XYZ& operator()(size_type n);
89 const gp_XYZ& operator()(size_type n) const;
93 void reserve(size_type n);
95 void push_back(const gp_XYZ& v);
97 size_type size() const;
100 void setElement(const SMDS_MeshElement* e) { myElem = e; }
102 const SMDS_MeshElement* getElement() const { return myElem; }
104 SMDSAbs_EntityType getElementEntity() const;
107 std::vector<gp_XYZ> myArray;
108 const SMDS_MeshElement* myElem;
112 * \brief Class used to detect mesh modification: IsMeshModified() returns
113 * true if a mesh has changed since last calling IsMeshModified()
115 class SMESHCONTROLS_EXPORT TMeshModifTracer
117 unsigned long myMeshModifTime;
118 const SMDS_Mesh* myMesh;
121 void SetMesh( const SMDS_Mesh* theMesh );
122 const SMDS_Mesh* GetMesh() const { return myMesh; }
123 bool IsMeshModified();
127 Class : NumericalFunctor
128 Description : Root of all Functors returning numeric value
130 class SMESHCONTROLS_EXPORT NumericalFunctor: public virtual Functor{
133 virtual void SetMesh( const SMDS_Mesh* theMesh );
134 virtual double GetValue( long theElementId );
135 virtual double GetValue(const TSequenceOfXYZ& /*thePoints*/) { return -1.0;};
136 void GetHistogram(int nbIntervals,
137 std::vector<int>& nbEvents,
138 std::vector<double>& funValues,
139 const std::vector<::smIdType>& elements,
140 const double* minmax=0,
141 const bool isLogarithmic = false);
142 bool IsApplicable( long theElementId ) const;
143 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
144 virtual SMDSAbs_ElementType GetType() const = 0;
145 virtual double GetBadRate( double Value, int nbNodes ) const = 0;
146 long GetPrecision() const;
147 void SetPrecision( const long thePrecision );
148 double Round( const double & value );
150 bool GetPoints(const ::smIdType theId, TSequenceOfXYZ& theRes) const;
151 static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes);
153 const SMDS_Mesh* myMesh;
154 const SMDS_MeshElement* myCurrElement;
156 double myPrecisionValue;
162 Description : Functor calculating volume of 3D mesh element
164 class SMESHCONTROLS_EXPORT Volume: public virtual NumericalFunctor{
166 virtual double GetValue( long theElementId );
167 //virtual double GetValue( const TSequenceOfXYZ& thePoints );
168 virtual double GetBadRate( double Value, int nbNodes ) const;
169 virtual SMDSAbs_ElementType GetType() const;
174 Class : MaxElementLength2D
175 Description : Functor calculating maximum length of 2D element
177 class SMESHCONTROLS_EXPORT MaxElementLength2D: public virtual NumericalFunctor{
179 virtual double GetValue( long theElementId );
180 virtual double GetValue( const TSequenceOfXYZ& P );
181 virtual double GetBadRate( double Value, int nbNodes ) const;
182 virtual SMDSAbs_ElementType GetType() const;
187 Class : MaxElementLength3D
188 Description : Functor calculating maximum length of 3D element
190 class SMESHCONTROLS_EXPORT MaxElementLength3D: public virtual NumericalFunctor{
192 virtual double GetValue( long theElementId );
193 virtual double GetBadRate( double Value, int nbNodes ) const;
194 virtual SMDSAbs_ElementType GetType() const;
199 Class : SMESH_MinimumAngle
200 Description : Functor for calculation of minimum angle
202 class SMESHCONTROLS_EXPORT MinimumAngle: public virtual NumericalFunctor{
204 virtual double GetValue( const TSequenceOfXYZ& thePoints );
205 virtual double GetBadRate( double Value, int nbNodes ) const;
206 virtual SMDSAbs_ElementType GetType() const;
212 Description : Functor for calculating aspect ratio
214 class SMESHCONTROLS_EXPORT AspectRatio: 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;
220 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
225 Class : AspectRatio3D
226 Description : Functor for calculating aspect ratio of 3D elems.
228 class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
230 virtual double GetValue( long theElementId );
231 virtual double GetValue( const TSequenceOfXYZ& thePoints );
232 virtual double GetBadRate( double Value, int nbNodes ) const;
233 virtual SMDSAbs_ElementType GetType() const;
234 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
240 Description : Functor for calculating warping
242 class SMESHCONTROLS_EXPORT Warping: 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;
247 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
250 double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
251 double ComputeValue( const TSequenceOfXYZ& thePoints ) const;
256 Description : Functor for calculating warping
258 class SMESHCONTROLS_EXPORT Warping3D: public virtual Warping {
260 virtual bool IsApplicable(const SMDS_MeshElement* element) const;
261 virtual double GetValue(const TSequenceOfXYZ& thePoints);
262 virtual double GetValue(long theId);
263 virtual SMDSAbs_ElementType GetType() const;
267 std::vector<long> myPntIds;
268 bool operator<(const Value& x) const;
271 typedef std::vector<Value> WValues;
272 void GetValues(WValues& theValues);
275 void ProcessVolumeELement(WValues& theValues);
277 typedef boost::shared_ptr<Warping3D> Warping3DPtr;
282 Description : Functor for calculating taper
284 class SMESHCONTROLS_EXPORT Taper: 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;
289 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
294 Description : Functor for calculating skew in degrees
296 class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
298 virtual double GetValue( const TSequenceOfXYZ& thePoints );
299 virtual double GetBadRate( double Value, int nbNodes ) const;
300 virtual SMDSAbs_ElementType GetType() const;
301 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
307 Description : Functor for calculating area
309 class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
311 virtual double GetValue( const TSequenceOfXYZ& thePoints );
312 virtual double GetBadRate( double Value, int nbNodes ) const;
313 virtual SMDSAbs_ElementType GetType() const;
319 Description : Functor for calculating length of edge
321 class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
323 virtual double GetValue( const TSequenceOfXYZ& thePoints );
324 virtual double GetBadRate( double Value, int nbNodes ) const;
325 virtual SMDSAbs_ElementType GetType() const;
330 Description : Functor for calculating minimal length of edges of element
332 class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
334 Length2D( SMDSAbs_ElementType type = SMDSAbs_Face );
335 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
336 virtual double GetValue( const TSequenceOfXYZ& thePoints );
337 virtual double GetBadRate( double Value, int nbNodes ) const;
338 virtual SMDSAbs_ElementType GetType() const;
342 Value(double theLength, long thePntId1, long thePntId2);
343 bool operator<(const Value& x) const;
345 typedef std::set<Value> TValues;
346 void GetValues(TValues& theValues);
349 SMDSAbs_ElementType myType;
351 typedef boost::shared_ptr<Length2D> Length2DPtr;
355 Description : Functor for calculating minimal length of edges of 3D element
357 class SMESHCONTROLS_EXPORT Length3D: public virtual Length2D {
361 typedef boost::shared_ptr<Length3D> Length3DPtr;
365 Description : Functor for calculating distance between a face and geometry
367 class SMESHCONTROLS_EXPORT Deflection2D: public virtual NumericalFunctor{
369 virtual void SetMesh( const SMDS_Mesh* theMesh );
370 virtual double GetValue( const TSequenceOfXYZ& thePoints );
371 virtual double GetBadRate( double Value, int nbNodes ) const;
372 virtual SMDSAbs_ElementType GetType() const;
374 Handle(ShapeAnalysis_Surface) mySurface;
376 boost::shared_ptr<gp_Pln> myPlane;
380 Class : MultiConnection
381 Description : Functor for calculating number of faces connected to the edge
383 class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
385 virtual double GetValue( long theElementId );
386 virtual double GetValue( const TSequenceOfXYZ& thePoints );
387 virtual double GetBadRate( double Value, int nbNodes ) const;
388 virtual SMDSAbs_ElementType GetType() const;
392 Class : MultiConnection2D
393 Description : Functor for calculating number of faces connected to the edge
395 class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
397 virtual double GetValue( long theElementId );
398 virtual double GetValue( const TSequenceOfXYZ& thePoints );
399 virtual double GetBadRate( double Value, int nbNodes ) const;
400 virtual SMDSAbs_ElementType GetType() const;
403 Value(long thePntId1, long thePntId2);
404 bool operator<(const Value& x) const;
406 typedef std::map<Value,int> MValues;
408 void GetValues(MValues& theValues);
410 typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
414 Description : Functor returning diameter of a ball element
416 class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{
418 virtual double GetValue( long theElementId );
419 virtual double GetBadRate( double Value, int nbNodes ) const;
420 virtual SMDSAbs_ElementType GetType() const;
424 Class : NodeConnectivityNumber
425 Description : Functor returning number of elements connected to a node
427 class SMESHCONTROLS_EXPORT NodeConnectivityNumber: public virtual NumericalFunctor{
429 virtual double GetValue( long theNodeId );
430 virtual double GetBadRate( double Value, int nbNodes ) const;
431 virtual SMDSAbs_ElementType GetType() const;
435 Class : ScaledJacobian
436 Description : Functor returning the ScaledJacobian as implemeted in VTK for volumetric elements
438 class SMESHCONTROLS_EXPORT ScaledJacobian: public virtual NumericalFunctor{
440 virtual double GetValue( long theNodeId );
441 virtual double GetBadRate( double Value, int nbNodes ) const;
442 virtual SMDSAbs_ElementType GetType() const;
450 Class : CoincidentNodes
451 Description : Predicate of Coincident Nodes
452 Note : This class is suitable only for visualization of Coincident Nodes
454 class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
457 //virtual Predicate* clone() const { return new CoincidentNodes( *this ); }
458 virtual void SetMesh( const SMDS_Mesh* theMesh );
459 virtual bool IsSatisfy( long theElementId );
460 virtual SMDSAbs_ElementType GetType() const;
462 void SetTolerance (const double theToler);
463 double GetTolerance () const { return myToler; }
467 TIDsMap myCoincidentIDs;
468 TMeshModifTracer myMeshModifTracer;
470 typedef boost::shared_ptr<CoincidentNodes> CoincidentNodesPtr;
473 Class : CoincidentElements
474 Description : Predicate of Coincident Elements
475 Note : This class is suitable only for visualization of Coincident Elements
477 class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate {
479 CoincidentElements();
480 virtual void SetMesh( const SMDS_Mesh* theMesh );
481 virtual bool IsSatisfy( long theElementId );
484 const SMDS_Mesh* myMesh;
486 class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
488 virtual SMDSAbs_ElementType GetType() const;
489 //virtual Predicate* clone() const { return new CoincidentElements1D( *this ); }
491 class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
493 virtual SMDSAbs_ElementType GetType() const;
494 //virtual Predicate* clone() const { return new CoincidentElements2D( *this ); }
496 class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
498 virtual SMDSAbs_ElementType GetType() const;
499 //virtual Predicate* clone() const { return new CoincidentElements3D( *this ); }
504 Description : Predicate for free borders
506 class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
509 //virtual Predicate* clone() const { return new FreeBorders( *this ); }
510 virtual void SetMesh( const SMDS_Mesh* theMesh );
511 virtual bool IsSatisfy( long theElementId );
512 virtual SMDSAbs_ElementType GetType() const;
515 const SMDS_Mesh* myMesh;
520 Class : BadOrientedVolume
521 Description : Predicate bad oriented volumes
523 class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
526 //virtual Predicate* clone() const { return new BadOrientedVolume( *this ); }
527 virtual void SetMesh( const SMDS_Mesh* theMesh );
528 virtual bool IsSatisfy( long theElementId );
529 virtual SMDSAbs_ElementType GetType() const;
532 const SMDS_Mesh* myMesh;
536 Class : ElemEntityType
537 Description : Functor for calculating entity type
539 class SMESHCONTROLS_EXPORT ElemEntityType: public virtual Predicate{
542 //virtual Predicate* clone() const { return new ElemEntityType( *this ); }
543 virtual void SetMesh( const SMDS_Mesh* theMesh );
544 virtual bool IsSatisfy( long theElementId );
545 void SetType( SMDSAbs_ElementType theType );
546 virtual SMDSAbs_ElementType GetType() const;
547 void SetElemEntityType( SMDSAbs_EntityType theEntityType );
548 SMDSAbs_EntityType GetElemEntityType() const;
551 const SMDS_Mesh* myMesh;
552 SMDSAbs_ElementType myType;
553 SMDSAbs_EntityType myEntityType;
555 typedef boost::shared_ptr<ElemEntityType> ElemEntityTypePtr;
561 class SMESHCONTROLS_EXPORT BareBorderVolume: public Predicate
564 BareBorderVolume():myMesh(0) {}
565 virtual Predicate* clone() const { return new BareBorderVolume( *this ); }
566 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
567 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
568 virtual bool IsSatisfy( long theElementId );
570 const SMDS_Mesh* myMesh;
572 typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
577 class SMESHCONTROLS_EXPORT BareBorderFace: public Predicate
580 BareBorderFace():myMesh(0) {}
581 //virtual Predicate* clone() const { return new BareBorderFace( *this ); }
582 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
583 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
584 virtual bool IsSatisfy( long theElementId );
586 const SMDS_Mesh* myMesh;
587 std::vector< const SMDS_MeshNode* > myLinkNodes;
589 typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
592 OverConstrainedVolume
594 class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
597 OverConstrainedVolume():myMesh(0) {}
598 virtual Predicate* clone() const { return new OverConstrainedVolume( *this ); }
599 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
600 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
601 virtual bool IsSatisfy( long theElementId );
603 const SMDS_Mesh* myMesh;
605 typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
610 class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
613 OverConstrainedFace():myMesh(0) {}
614 //virtual Predicate* clone() const { return new OverConstrainedFace( *this ); }
615 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
616 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
617 virtual bool IsSatisfy( long theElementId );
619 const SMDS_Mesh* myMesh;
621 typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
625 Description : Predicate for free Edges
627 class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
630 //virtual Predicate* clone() const { return new FreeEdges( *this ); }
631 virtual void SetMesh( const SMDS_Mesh* theMesh );
632 virtual bool IsSatisfy( long theElementId );
633 virtual SMDSAbs_ElementType GetType() const;
634 static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const ::smIdType theFaceId );
635 typedef long TElemId;
639 Border(long theElemId, long thePntId1, long thePntId2);
640 bool operator<(const Border& x) const;
642 typedef std::set<Border> TBorders;
643 void GetBoreders(TBorders& theBorders);
646 const SMDS_Mesh* myMesh;
648 typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
653 Description : Predicate for free nodes
655 class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
658 //virtual Predicate* clone() const { return new FreeNodes( *this ); }
659 virtual void SetMesh( const SMDS_Mesh* theMesh );
660 virtual bool IsSatisfy( long theNodeId );
661 virtual SMDSAbs_ElementType GetType() const;
664 const SMDS_Mesh* myMesh;
670 Description : Predicate for Range of Ids.
671 Range may be specified with two ways.
672 1. Using AddToRange method
673 2. With SetRangeStr method. Parameter of this method is a string
674 like as "1,2,3,50-60,63,67,70-"
676 class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
680 //virtual Predicate* clone() const { return new RangeOfIds( *this ); }
681 virtual void SetMesh( const SMDS_Mesh* theMesh );
682 virtual bool IsSatisfy( long theNodeId );
683 virtual SMDSAbs_ElementType GetType() const;
684 virtual void SetType( SMDSAbs_ElementType theType );
686 bool AddToRange( long theEntityId );
687 void GetRangeStr( TCollection_AsciiString& );
688 bool SetRangeStr( const TCollection_AsciiString& );
691 const SMDS_Mesh* myMesh;
693 std::vector< ::smIdType > myMin;
694 std::vector< ::smIdType > myMax;
697 SMDSAbs_ElementType myType;
700 typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
705 Description : Base class for comparators
707 class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
710 virtual ~Comparator();
711 virtual void SetMesh( const SMDS_Mesh* theMesh );
712 virtual void SetMargin(double theValue);
713 virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
714 virtual bool IsSatisfy( long theElementId ) = 0;
715 virtual SMDSAbs_ElementType GetType() const;
720 NumericalFunctorPtr myFunctor;
722 typedef boost::shared_ptr<Comparator> ComparatorPtr;
727 Description : Comparator "<"
729 class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
731 virtual bool IsSatisfy( long theElementId );
732 //virtual Predicate* clone() const { return new LessThan( *this ); }
738 Description : Comparator ">"
740 class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
742 virtual bool IsSatisfy( long theElementId );
743 //virtual Predicate* clone() const { return new MoreThan( *this ); }
749 Description : Comparator "="
751 class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
754 //virtual Predicate* clone() const { return new EqualTo( *this ); }
755 virtual bool IsSatisfy( long theElementId );
756 virtual void SetTolerance( double theTol );
757 virtual double GetTolerance();
762 typedef boost::shared_ptr<EqualTo> EqualToPtr;
767 Description : Logical NOT predicate
769 class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
772 //virtual Predicate* clone() const { return new LogicalNOT( *this ); }
773 virtual ~LogicalNOT();
774 virtual bool IsSatisfy( long theElementId );
775 virtual void SetMesh( const SMDS_Mesh* theMesh );
776 virtual void SetPredicate(PredicatePtr thePred);
777 virtual SMDSAbs_ElementType GetType() const;
780 PredicatePtr myPredicate;
782 typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
786 Class : LogicalBinary
787 Description : Base class for binary logical predicate
789 class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
792 virtual ~LogicalBinary();
793 virtual void SetMesh( const SMDS_Mesh* theMesh );
794 virtual void SetPredicate1(PredicatePtr thePred);
795 virtual void SetPredicate2(PredicatePtr thePred);
796 virtual SMDSAbs_ElementType GetType() const;
799 PredicatePtr myPredicate1;
800 PredicatePtr myPredicate2;
802 typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
807 Description : Logical AND
809 class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
811 virtual bool IsSatisfy( long theElementId );
812 //virtual Predicate* clone() const { return new LogicalAND( *this ); }
818 Description : Logical OR
820 class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
822 virtual bool IsSatisfy( long theElementId );
823 //virtual Predicate* clone() const { return new LogicalOR( *this ); }
829 Description : Predicate for manifold part of mesh
831 class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
834 /* internal class for algorithm uses */
838 Link( SMDS_MeshNode* theNode1,
839 SMDS_MeshNode* theNode2 );
842 bool IsEqual( const ManifoldPart::Link& theLink ) const;
843 bool operator<(const ManifoldPart::Link& x) const;
845 SMDS_MeshNode* myNode1;
846 SMDS_MeshNode* myNode2;
849 bool IsEqual( const ManifoldPart::Link& theLink1,
850 const ManifoldPart::Link& theLink2 );
852 typedef std::set<ManifoldPart::Link> TMapOfLink;
853 typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
854 typedef std::vector<ManifoldPart::Link> TVectorOfLink;
855 typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
856 typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
860 //virtual Predicate* clone() const { return new ManifoldPart( *this ); }
861 virtual void SetMesh( const SMDS_Mesh* theMesh );
862 // invoke when all parameters already set
863 virtual bool IsSatisfy( long theElementId );
864 virtual SMDSAbs_ElementType GetType() const;
866 void SetAngleTolerance( const double theAngToler );
867 double GetAngleTolerance() const;
868 void SetIsOnlyManifold( const bool theIsOnly );
869 void SetStartElem( const long theStartElemId );
873 bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
874 SMDS_MeshFace* theStartFace,
875 TMapOfLink& theNonManifold,
876 TIDsMap& theResFaces );
877 bool isInPlane( const SMDS_MeshFace* theFace1,
878 const SMDS_MeshFace* theFace2 );
879 void expandBoundary( TMapOfLink& theMapOfBoundary,
880 TVectorOfLink& theSeqOfBoundary,
881 TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
882 TMapOfLink& theNonManifold,
883 SMDS_MeshFace* theNextFace ) const;
885 void getFacesByLink( const Link& theLink,
886 TVectorOfFacePtr& theFaces ) const;
889 const SMDS_Mesh* myMesh;
891 TIDsMap myMapBadGeomIds;
892 TVectorOfFacePtr myAllFacePtr;
893 TDataMapFacePtrInt myAllFacePtrIntDMap;
895 bool myIsOnlyManifold;
899 typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
902 Class : BelongToMeshGroup
903 Description : Verify whether a mesh element is included into a mesh group
905 class SMESHCONTROLS_EXPORT BelongToMeshGroup : public virtual Predicate
909 //virtual Predicate* clone() const { return new BelongToMeshGroup( *this ); }
910 virtual void SetMesh( const SMDS_Mesh* theMesh );
911 virtual bool IsSatisfy( long theElementId );
912 virtual SMDSAbs_ElementType GetType() const;
914 void SetGroup( SMESHDS_GroupBase* g );
915 void SetStoreName( const std::string& sn );
916 const SMESHDS_GroupBase* GetGroup() const { return myGroup; }
919 SMESHDS_GroupBase* myGroup;
920 std::string myStoreName;
922 typedef boost::shared_ptr<BelongToMeshGroup> BelongToMeshGroupPtr;
925 Class : ElementsOnSurface
926 Description : Predicate elements that lying on indicated surface
929 class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
932 ~ElementsOnSurface();
933 //virtual Predicate* clone() const { return new ElementsOnSurface( *this ); }
934 virtual void SetMesh( const SMDS_Mesh* theMesh );
935 virtual bool IsSatisfy( long theElementId );
936 virtual SMDSAbs_ElementType GetType() const;
938 void SetTolerance( const double theToler );
939 double GetTolerance() const;
940 void SetSurface( const TopoDS_Shape& theShape,
941 const SMDSAbs_ElementType theType );
942 void SetUseBoundaries( bool theUse );
943 bool GetUseBoundaries() const { return myUseBoundaries; }
947 void process( const SMDS_MeshElement* theElem );
948 bool isOnSurface( const SMDS_MeshNode* theNode );
951 TMeshModifTracer myMeshModifTracer;
953 SMDSAbs_ElementType myType;
956 bool myUseBoundaries;
957 GeomAPI_ProjectPointOnSurf myProjector;
960 typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
964 Class : ElementsOnShape
965 Description : Predicate elements that lying on indicated shape
968 class SMESHCONTROLS_EXPORT ElementsOnShape : public Predicate
974 virtual Predicate* clone() const;
975 virtual void SetMesh (const SMDS_Mesh* theMesh);
976 virtual bool IsSatisfy (long theElementId);
977 virtual SMDSAbs_ElementType GetType() const;
979 void SetTolerance (const double theToler);
980 double GetTolerance() const;
981 void SetAllNodes (bool theAllNodes);
982 bool GetAllNodes() const { return myAllNodesFlag; }
983 void SetShape (const TopoDS_Shape& theShape,
984 const SMDSAbs_ElementType theType);
985 bool IsSatisfy (const SMDS_MeshElement* elem);
986 bool IsSatisfy (const SMDS_MeshNode* node, TopoDS_Shape* okShape=0);
987 void GetParams( double & u, double & v ) const { u = myU; v = myV; }
992 struct OctreeClassifier;
994 void clearClassifiers();
995 bool getNodeIsOut( const SMDS_MeshNode* n, bool& isOut );
996 void setNodeIsOut( const SMDS_MeshNode* n, bool isOut );
998 std::vector< Classifier > myClassifiers;
999 std::vector< Classifier* > myWorkClassifiers;
1000 OctreeClassifier* myOctree;
1001 SMDSAbs_ElementType myType;
1002 TopoDS_Shape myShape;
1004 double myU, myV; // result of node projection on EDGE or FACE
1005 bool myAllNodesFlag;
1007 TMeshModifTracer myMeshModifTracer;
1008 std::vector<bool> myNodeIsChecked;
1009 std::vector<bool> myNodeIsOut;
1012 typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
1016 Class : BelongToGeom
1017 Description : Predicate for verifying whether entiy belong to
1018 specified geometrical support
1020 class SMESHCONTROLS_EXPORT BelongToGeom: public virtual Predicate
1024 virtual Predicate* clone() const;
1026 virtual void SetMesh( const SMDS_Mesh* theMesh );
1027 virtual void SetGeom( const TopoDS_Shape& theShape );
1029 virtual bool IsSatisfy( long theElementId );
1031 virtual void SetType( SMDSAbs_ElementType theType );
1032 virtual SMDSAbs_ElementType GetType() const;
1034 TopoDS_Shape GetShape();
1035 const SMESHDS_Mesh* GetMeshDS() const;
1037 void SetTolerance( double );
1038 double GetTolerance();
1041 virtual void init();
1043 TopoDS_Shape myShape;
1044 TColStd_MapOfInteger mySubShapesIDs;
1045 const SMESHDS_Mesh* myMeshDS;
1046 SMDSAbs_ElementType myType;
1048 double myTolerance; // only if myIsSubshape == false
1049 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
1051 typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
1055 Description : Predicate for verifying whether entiy lying or partially lying on
1056 specified geometrical support
1058 class SMESHCONTROLS_EXPORT LyingOnGeom: public virtual Predicate
1062 virtual Predicate* clone() const;
1064 virtual void SetMesh( const SMDS_Mesh* theMesh );
1065 virtual void SetGeom( const TopoDS_Shape& theShape );
1067 virtual bool IsSatisfy( long theElementId );
1069 virtual void SetType( SMDSAbs_ElementType theType );
1070 virtual SMDSAbs_ElementType GetType() const;
1072 TopoDS_Shape GetShape();
1073 const SMESHDS_Mesh* GetMeshDS() const;
1075 void SetTolerance( double );
1076 double GetTolerance();
1079 virtual void init();
1081 TopoDS_Shape myShape;
1082 TColStd_MapOfInteger mySubShapesIDs;
1083 const SMESHDS_Mesh* myMeshDS;
1084 SMDSAbs_ElementType myType;
1086 double myTolerance; // only if myIsSubshape == false
1087 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
1089 typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
1093 Description : Predicate for free faces
1095 class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
1098 //virtual Predicate* clone() const { return new FreeFaces( *this ); }
1099 virtual void SetMesh( const SMDS_Mesh* theMesh );
1100 virtual bool IsSatisfy( long theElementId );
1101 virtual SMDSAbs_ElementType GetType() const;
1104 const SMDS_Mesh* myMesh;
1108 Class : LinearOrQuadratic
1109 Description : Predicate for free faces
1111 class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
1113 LinearOrQuadratic();
1114 //virtual Predicate* clone() const { return new LinearOrQuadratic( *this ); }
1115 virtual void SetMesh( const SMDS_Mesh* theMesh );
1116 virtual bool IsSatisfy( long theElementId );
1117 void SetType( SMDSAbs_ElementType theType );
1118 virtual SMDSAbs_ElementType GetType() const;
1121 const SMDS_Mesh* myMesh;
1122 SMDSAbs_ElementType myType;
1124 typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
1128 Description : Functor for check color of group to which mesh element belongs to
1130 class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
1133 //virtual Predicate* clone() const { return new GroupColor( *this ); }
1134 virtual void SetMesh( const SMDS_Mesh* theMesh );
1135 virtual bool IsSatisfy( long theElementId );
1136 void SetType( SMDSAbs_ElementType theType );
1137 virtual SMDSAbs_ElementType GetType() const;
1138 void SetColorStr( const TCollection_AsciiString& );
1139 void GetColorStr( TCollection_AsciiString& ) const;
1142 typedef std::set< long > TIDs;
1144 Quantity_Color myColor;
1145 SMDSAbs_ElementType myType;
1148 typedef boost::shared_ptr<GroupColor> GroupColorPtr;
1151 Class : ElemGeomType
1152 Description : Predicate to check element geometry type
1154 class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
1157 //virtual Predicate* clone() const { return new ElemGeomType( *this ); }
1158 virtual void SetMesh( const SMDS_Mesh* theMesh );
1159 virtual bool IsSatisfy( long theElementId );
1160 void SetType( SMDSAbs_ElementType theType );
1161 virtual SMDSAbs_ElementType GetType() const;
1162 void SetGeomType( SMDSAbs_GeometryType theType );
1163 SMDSAbs_GeometryType GetGeomType() const;
1166 const SMDS_Mesh* myMesh;
1167 SMDSAbs_ElementType myType;
1168 SMDSAbs_GeometryType myGeomType;
1170 typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
1173 Class : CoplanarFaces
1174 Description : Predicate to check angle between faces
1176 class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
1180 //virtual Predicate* clone() const { return new CoplanarFaces( *this ); }
1181 void SetFace( long theID ) { myFaceID = theID; }
1182 long GetFace() const { return myFaceID; }
1183 void SetTolerance (const double theToler) { myToler = theToler; }
1184 double GetTolerance () const { return myToler; }
1185 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
1187 virtual void SetMesh( const SMDS_Mesh* theMesh );
1188 virtual bool IsSatisfy( long theElementId );
1191 TMeshModifTracer myMeshModifTracer;
1194 TIDsMap myCoplanarIDs;
1196 typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
1199 Class : ConnectedElements
1200 Description : Predicate to get elements of one domain
1202 class SMESHCONTROLS_EXPORT ConnectedElements: public virtual Predicate
1205 ConnectedElements();
1206 //virtual Predicate* clone() const { return new ConnectedElements( *this ); }
1207 void SetNode( ::smIdType nodeID );
1208 void SetPoint( double x, double y, double z );
1209 ::smIdType GetNode() const;
1210 std::vector<double> GetPoint() const;
1212 void SetType( SMDSAbs_ElementType theType );
1213 virtual SMDSAbs_ElementType GetType() const;
1215 virtual void SetMesh( const SMDS_Mesh* theMesh );
1216 virtual bool IsSatisfy( long theElementId );
1218 //const std::set<long>& GetDomainIDs() const { return myOkIDs; }
1221 ::smIdType myNodeID;
1222 std::vector<double> myXYZ;
1223 SMDSAbs_ElementType myType;
1224 TMeshModifTracer myMeshModifTracer;
1228 std::set<::smIdType> myOkIDs; // empty means that there is one domain
1230 typedef boost::shared_ptr<ConnectedElements> ConnectedElementsPtr;
1235 class SMESHCONTROLS_EXPORT Filter {
1239 virtual void SetPredicate(PredicatePtr thePred);
1241 typedef std::vector<long> TIdSequence;
1245 GetElementsId( const SMDS_Mesh* theMesh,
1246 TIdSequence& theSequence,
1247 SMDS_ElemIteratorPtr theElements=0);
1251 GetElementsId( const SMDS_Mesh* theMesh,
1252 PredicatePtr thePredicate,
1253 TIdSequence& theSequence,
1254 SMDS_ElemIteratorPtr theElements=0 );
1257 PredicatePtr myPredicate;