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;
256 Description : Functor for calculating taper
258 class SMESHCONTROLS_EXPORT Taper: public virtual NumericalFunctor{
260 virtual double GetValue( const TSequenceOfXYZ& thePoints );
261 virtual double GetBadRate( double Value, int nbNodes ) const;
262 virtual SMDSAbs_ElementType GetType() const;
263 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
268 Description : Functor for calculating skew in degrees
270 class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
272 virtual double GetValue( const TSequenceOfXYZ& thePoints );
273 virtual double GetBadRate( double Value, int nbNodes ) const;
274 virtual SMDSAbs_ElementType GetType() const;
275 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
281 Description : Functor for calculating area
283 class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
285 virtual double GetValue( const TSequenceOfXYZ& thePoints );
286 virtual double GetBadRate( double Value, int nbNodes ) const;
287 virtual SMDSAbs_ElementType GetType() const;
293 Description : Functor for calculating length of edge
295 class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
297 virtual double GetValue( const TSequenceOfXYZ& thePoints );
298 virtual double GetBadRate( double Value, int nbNodes ) const;
299 virtual SMDSAbs_ElementType GetType() const;
304 Description : Functor for calculating minimal length of edges of element
306 class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
308 Length2D( SMDSAbs_ElementType type = SMDSAbs_Face );
309 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
310 virtual double GetValue( const TSequenceOfXYZ& thePoints );
311 virtual double GetBadRate( double Value, int nbNodes ) const;
312 virtual SMDSAbs_ElementType GetType() const;
316 Value(double theLength, long thePntId1, long thePntId2);
317 bool operator<(const Value& x) const;
319 typedef std::set<Value> TValues;
320 void GetValues(TValues& theValues);
323 SMDSAbs_ElementType myType;
325 typedef boost::shared_ptr<Length2D> Length2DPtr;
329 Description : Functor for calculating minimal length of edges of 3D element
331 class SMESHCONTROLS_EXPORT Length3D: public virtual Length2D {
335 typedef boost::shared_ptr<Length3D> Length3DPtr;
339 Description : Functor for calculating distance between a face and geometry
341 class SMESHCONTROLS_EXPORT Deflection2D: public virtual NumericalFunctor{
343 virtual void SetMesh( const SMDS_Mesh* theMesh );
344 virtual double GetValue( const TSequenceOfXYZ& thePoints );
345 virtual double GetBadRate( double Value, int nbNodes ) const;
346 virtual SMDSAbs_ElementType GetType() const;
348 Handle(ShapeAnalysis_Surface) mySurface;
350 boost::shared_ptr<gp_Pln> myPlane;
354 Class : MultiConnection
355 Description : Functor for calculating number of faces connected to the edge
357 class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
359 virtual double GetValue( long theElementId );
360 virtual double GetValue( const TSequenceOfXYZ& thePoints );
361 virtual double GetBadRate( double Value, int nbNodes ) const;
362 virtual SMDSAbs_ElementType GetType() const;
366 Class : MultiConnection2D
367 Description : Functor for calculating number of faces connected to the edge
369 class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
371 virtual double GetValue( long theElementId );
372 virtual double GetValue( const TSequenceOfXYZ& thePoints );
373 virtual double GetBadRate( double Value, int nbNodes ) const;
374 virtual SMDSAbs_ElementType GetType() const;
377 Value(long thePntId1, long thePntId2);
378 bool operator<(const Value& x) const;
380 typedef std::map<Value,int> MValues;
382 void GetValues(MValues& theValues);
384 typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
388 Description : Functor returning diameter of a ball element
390 class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{
392 virtual double GetValue( long theElementId );
393 virtual double GetBadRate( double Value, int nbNodes ) const;
394 virtual SMDSAbs_ElementType GetType() const;
398 Class : NodeConnectivityNumber
399 Description : Functor returning number of elements connected to a node
401 class SMESHCONTROLS_EXPORT NodeConnectivityNumber: public virtual NumericalFunctor{
403 virtual double GetValue( long theNodeId );
404 virtual double GetBadRate( double Value, int nbNodes ) const;
405 virtual SMDSAbs_ElementType GetType() const;
409 Class : ScaledJacobian
410 Description : Functor returning the ScaledJacobian as implemeted in VTK for volumetric elements
412 class SMESHCONTROLS_EXPORT ScaledJacobian: public virtual NumericalFunctor{
414 virtual double GetValue( long theNodeId );
415 virtual double GetBadRate( double Value, int nbNodes ) const;
416 virtual SMDSAbs_ElementType GetType() const;
424 Class : CoincidentNodes
425 Description : Predicate of Coincident Nodes
426 Note : This class is suitable only for visualization of Coincident Nodes
428 class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
431 //virtual Predicate* clone() const { return new CoincidentNodes( *this ); }
432 virtual void SetMesh( const SMDS_Mesh* theMesh );
433 virtual bool IsSatisfy( long theElementId );
434 virtual SMDSAbs_ElementType GetType() const;
436 void SetTolerance (const double theToler);
437 double GetTolerance () const { return myToler; }
441 TIDsMap myCoincidentIDs;
442 TMeshModifTracer myMeshModifTracer;
444 typedef boost::shared_ptr<CoincidentNodes> CoincidentNodesPtr;
447 Class : CoincidentElements
448 Description : Predicate of Coincident Elements
449 Note : This class is suitable only for visualization of Coincident Elements
451 class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate {
453 CoincidentElements();
454 virtual void SetMesh( const SMDS_Mesh* theMesh );
455 virtual bool IsSatisfy( long theElementId );
458 const SMDS_Mesh* myMesh;
460 class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
462 virtual SMDSAbs_ElementType GetType() const;
463 //virtual Predicate* clone() const { return new CoincidentElements1D( *this ); }
465 class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
467 virtual SMDSAbs_ElementType GetType() const;
468 //virtual Predicate* clone() const { return new CoincidentElements2D( *this ); }
470 class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
472 virtual SMDSAbs_ElementType GetType() const;
473 //virtual Predicate* clone() const { return new CoincidentElements3D( *this ); }
478 Description : Predicate for free borders
480 class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
483 //virtual Predicate* clone() const { return new FreeBorders( *this ); }
484 virtual void SetMesh( const SMDS_Mesh* theMesh );
485 virtual bool IsSatisfy( long theElementId );
486 virtual SMDSAbs_ElementType GetType() const;
489 const SMDS_Mesh* myMesh;
494 Class : BadOrientedVolume
495 Description : Predicate bad oriented volumes
497 class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
500 //virtual Predicate* clone() const { return new BadOrientedVolume( *this ); }
501 virtual void SetMesh( const SMDS_Mesh* theMesh );
502 virtual bool IsSatisfy( long theElementId );
503 virtual SMDSAbs_ElementType GetType() const;
506 const SMDS_Mesh* myMesh;
510 Class : ElemEntityType
511 Description : Functor for calculating entity type
513 class SMESHCONTROLS_EXPORT ElemEntityType: public virtual Predicate{
516 //virtual Predicate* clone() const { return new ElemEntityType( *this ); }
517 virtual void SetMesh( const SMDS_Mesh* theMesh );
518 virtual bool IsSatisfy( long theElementId );
519 void SetType( SMDSAbs_ElementType theType );
520 virtual SMDSAbs_ElementType GetType() const;
521 void SetElemEntityType( SMDSAbs_EntityType theEntityType );
522 SMDSAbs_EntityType GetElemEntityType() const;
525 const SMDS_Mesh* myMesh;
526 SMDSAbs_ElementType myType;
527 SMDSAbs_EntityType myEntityType;
529 typedef boost::shared_ptr<ElemEntityType> ElemEntityTypePtr;
535 class SMESHCONTROLS_EXPORT BareBorderVolume: public Predicate
538 BareBorderVolume():myMesh(0) {}
539 virtual Predicate* clone() const { return new BareBorderVolume( *this ); }
540 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
541 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
542 virtual bool IsSatisfy( long theElementId );
544 const SMDS_Mesh* myMesh;
546 typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
551 class SMESHCONTROLS_EXPORT BareBorderFace: public Predicate
554 BareBorderFace():myMesh(0) {}
555 //virtual Predicate* clone() const { return new BareBorderFace( *this ); }
556 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
557 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
558 virtual bool IsSatisfy( long theElementId );
560 const SMDS_Mesh* myMesh;
561 std::vector< const SMDS_MeshNode* > myLinkNodes;
563 typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
566 OverConstrainedVolume
568 class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
571 OverConstrainedVolume():myMesh(0) {}
572 virtual Predicate* clone() const { return new OverConstrainedVolume( *this ); }
573 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
574 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
575 virtual bool IsSatisfy( long theElementId );
577 const SMDS_Mesh* myMesh;
579 typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
584 class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
587 OverConstrainedFace():myMesh(0) {}
588 //virtual Predicate* clone() const { return new OverConstrainedFace( *this ); }
589 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
590 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
591 virtual bool IsSatisfy( long theElementId );
593 const SMDS_Mesh* myMesh;
595 typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
599 Description : Predicate for free Edges
601 class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
604 //virtual Predicate* clone() const { return new FreeEdges( *this ); }
605 virtual void SetMesh( const SMDS_Mesh* theMesh );
606 virtual bool IsSatisfy( long theElementId );
607 virtual SMDSAbs_ElementType GetType() const;
608 static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const ::smIdType theFaceId );
609 typedef long TElemId;
613 Border(long theElemId, long thePntId1, long thePntId2);
614 bool operator<(const Border& x) const;
616 typedef std::set<Border> TBorders;
617 void GetBoreders(TBorders& theBorders);
620 const SMDS_Mesh* myMesh;
622 typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
627 Description : Predicate for free nodes
629 class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
632 //virtual Predicate* clone() const { return new FreeNodes( *this ); }
633 virtual void SetMesh( const SMDS_Mesh* theMesh );
634 virtual bool IsSatisfy( long theNodeId );
635 virtual SMDSAbs_ElementType GetType() const;
638 const SMDS_Mesh* myMesh;
644 Description : Predicate for Range of Ids.
645 Range may be specified with two ways.
646 1. Using AddToRange method
647 2. With SetRangeStr method. Parameter of this method is a string
648 like as "1,2,3,50-60,63,67,70-"
650 class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
654 //virtual Predicate* clone() const { return new RangeOfIds( *this ); }
655 virtual void SetMesh( const SMDS_Mesh* theMesh );
656 virtual bool IsSatisfy( long theNodeId );
657 virtual SMDSAbs_ElementType GetType() const;
658 virtual void SetType( SMDSAbs_ElementType theType );
660 bool AddToRange( long theEntityId );
661 void GetRangeStr( TCollection_AsciiString& );
662 bool SetRangeStr( const TCollection_AsciiString& );
665 const SMDS_Mesh* myMesh;
667 std::vector< ::smIdType > myMin;
668 std::vector< ::smIdType > myMax;
671 SMDSAbs_ElementType myType;
674 typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
679 Description : Base class for comparators
681 class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
684 virtual ~Comparator();
685 virtual void SetMesh( const SMDS_Mesh* theMesh );
686 virtual void SetMargin(double theValue);
687 virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
688 virtual bool IsSatisfy( long theElementId ) = 0;
689 virtual SMDSAbs_ElementType GetType() const;
694 NumericalFunctorPtr myFunctor;
696 typedef boost::shared_ptr<Comparator> ComparatorPtr;
701 Description : Comparator "<"
703 class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
705 virtual bool IsSatisfy( long theElementId );
706 //virtual Predicate* clone() const { return new LessThan( *this ); }
712 Description : Comparator ">"
714 class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
716 virtual bool IsSatisfy( long theElementId );
717 //virtual Predicate* clone() const { return new MoreThan( *this ); }
723 Description : Comparator "="
725 class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
728 //virtual Predicate* clone() const { return new EqualTo( *this ); }
729 virtual bool IsSatisfy( long theElementId );
730 virtual void SetTolerance( double theTol );
731 virtual double GetTolerance();
736 typedef boost::shared_ptr<EqualTo> EqualToPtr;
741 Description : Logical NOT predicate
743 class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
746 //virtual Predicate* clone() const { return new LogicalNOT( *this ); }
747 virtual ~LogicalNOT();
748 virtual bool IsSatisfy( long theElementId );
749 virtual void SetMesh( const SMDS_Mesh* theMesh );
750 virtual void SetPredicate(PredicatePtr thePred);
751 virtual SMDSAbs_ElementType GetType() const;
754 PredicatePtr myPredicate;
756 typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
760 Class : LogicalBinary
761 Description : Base class for binary logical predicate
763 class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
766 virtual ~LogicalBinary();
767 virtual void SetMesh( const SMDS_Mesh* theMesh );
768 virtual void SetPredicate1(PredicatePtr thePred);
769 virtual void SetPredicate2(PredicatePtr thePred);
770 virtual SMDSAbs_ElementType GetType() const;
773 PredicatePtr myPredicate1;
774 PredicatePtr myPredicate2;
776 typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
781 Description : Logical AND
783 class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
785 virtual bool IsSatisfy( long theElementId );
786 //virtual Predicate* clone() const { return new LogicalAND( *this ); }
792 Description : Logical OR
794 class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
796 virtual bool IsSatisfy( long theElementId );
797 //virtual Predicate* clone() const { return new LogicalOR( *this ); }
803 Description : Predicate for manifold part of mesh
805 class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
808 /* internal class for algorithm uses */
812 Link( SMDS_MeshNode* theNode1,
813 SMDS_MeshNode* theNode2 );
816 bool IsEqual( const ManifoldPart::Link& theLink ) const;
817 bool operator<(const ManifoldPart::Link& x) const;
819 SMDS_MeshNode* myNode1;
820 SMDS_MeshNode* myNode2;
823 bool IsEqual( const ManifoldPart::Link& theLink1,
824 const ManifoldPart::Link& theLink2 );
826 typedef std::set<ManifoldPart::Link> TMapOfLink;
827 typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
828 typedef std::vector<ManifoldPart::Link> TVectorOfLink;
829 typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
830 typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
834 //virtual Predicate* clone() const { return new ManifoldPart( *this ); }
835 virtual void SetMesh( const SMDS_Mesh* theMesh );
836 // invoke when all parameters already set
837 virtual bool IsSatisfy( long theElementId );
838 virtual SMDSAbs_ElementType GetType() const;
840 void SetAngleTolerance( const double theAngToler );
841 double GetAngleTolerance() const;
842 void SetIsOnlyManifold( const bool theIsOnly );
843 void SetStartElem( const long theStartElemId );
847 bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
848 SMDS_MeshFace* theStartFace,
849 TMapOfLink& theNonManifold,
850 TIDsMap& theResFaces );
851 bool isInPlane( const SMDS_MeshFace* theFace1,
852 const SMDS_MeshFace* theFace2 );
853 void expandBoundary( TMapOfLink& theMapOfBoundary,
854 TVectorOfLink& theSeqOfBoundary,
855 TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
856 TMapOfLink& theNonManifold,
857 SMDS_MeshFace* theNextFace ) const;
859 void getFacesByLink( const Link& theLink,
860 TVectorOfFacePtr& theFaces ) const;
863 const SMDS_Mesh* myMesh;
865 TIDsMap myMapBadGeomIds;
866 TVectorOfFacePtr myAllFacePtr;
867 TDataMapFacePtrInt myAllFacePtrIntDMap;
869 bool myIsOnlyManifold;
873 typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
876 Class : BelongToMeshGroup
877 Description : Verify whether a mesh element is included into a mesh group
879 class SMESHCONTROLS_EXPORT BelongToMeshGroup : public virtual Predicate
883 //virtual Predicate* clone() const { return new BelongToMeshGroup( *this ); }
884 virtual void SetMesh( const SMDS_Mesh* theMesh );
885 virtual bool IsSatisfy( long theElementId );
886 virtual SMDSAbs_ElementType GetType() const;
888 void SetGroup( SMESHDS_GroupBase* g );
889 void SetStoreName( const std::string& sn );
890 const SMESHDS_GroupBase* GetGroup() const { return myGroup; }
893 SMESHDS_GroupBase* myGroup;
894 std::string myStoreName;
896 typedef boost::shared_ptr<BelongToMeshGroup> BelongToMeshGroupPtr;
899 Class : ElementsOnSurface
900 Description : Predicate elements that lying on indicated surface
903 class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
906 ~ElementsOnSurface();
907 //virtual Predicate* clone() const { return new ElementsOnSurface( *this ); }
908 virtual void SetMesh( const SMDS_Mesh* theMesh );
909 virtual bool IsSatisfy( long theElementId );
910 virtual SMDSAbs_ElementType GetType() const;
912 void SetTolerance( const double theToler );
913 double GetTolerance() const;
914 void SetSurface( const TopoDS_Shape& theShape,
915 const SMDSAbs_ElementType theType );
916 void SetUseBoundaries( bool theUse );
917 bool GetUseBoundaries() const { return myUseBoundaries; }
921 void process( const SMDS_MeshElement* theElem );
922 bool isOnSurface( const SMDS_MeshNode* theNode );
925 TMeshModifTracer myMeshModifTracer;
927 SMDSAbs_ElementType myType;
930 bool myUseBoundaries;
931 GeomAPI_ProjectPointOnSurf myProjector;
934 typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
938 Class : ElementsOnShape
939 Description : Predicate elements that lying on indicated shape
942 class SMESHCONTROLS_EXPORT ElementsOnShape : public Predicate
948 virtual Predicate* clone() const;
949 virtual void SetMesh (const SMDS_Mesh* theMesh);
950 virtual bool IsSatisfy (long theElementId);
951 virtual SMDSAbs_ElementType GetType() const;
953 void SetTolerance (const double theToler);
954 double GetTolerance() const;
955 void SetAllNodes (bool theAllNodes);
956 bool GetAllNodes() const { return myAllNodesFlag; }
957 void SetShape (const TopoDS_Shape& theShape,
958 const SMDSAbs_ElementType theType);
959 bool IsSatisfy (const SMDS_MeshElement* elem);
960 bool IsSatisfy (const SMDS_MeshNode* node, TopoDS_Shape* okShape=0);
961 void GetParams( double & u, double & v ) const { u = myU; v = myV; }
966 struct OctreeClassifier;
968 void clearClassifiers();
969 bool getNodeIsOut( const SMDS_MeshNode* n, bool& isOut );
970 void setNodeIsOut( const SMDS_MeshNode* n, bool isOut );
972 std::vector< Classifier > myClassifiers;
973 std::vector< Classifier* > myWorkClassifiers;
974 OctreeClassifier* myOctree;
975 SMDSAbs_ElementType myType;
976 TopoDS_Shape myShape;
978 double myU, myV; // result of node projection on EDGE or FACE
981 TMeshModifTracer myMeshModifTracer;
982 std::vector<bool> myNodeIsChecked;
983 std::vector<bool> myNodeIsOut;
986 typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
991 Description : Predicate for verifying whether entiy belong to
992 specified geometrical support
994 class SMESHCONTROLS_EXPORT BelongToGeom: public virtual Predicate
998 virtual Predicate* clone() const;
1000 virtual void SetMesh( const SMDS_Mesh* theMesh );
1001 virtual void SetGeom( const TopoDS_Shape& theShape );
1003 virtual bool IsSatisfy( long theElementId );
1005 virtual void SetType( SMDSAbs_ElementType theType );
1006 virtual SMDSAbs_ElementType GetType() const;
1008 TopoDS_Shape GetShape();
1009 const SMESHDS_Mesh* GetMeshDS() const;
1011 void SetTolerance( double );
1012 double GetTolerance();
1015 virtual void init();
1017 TopoDS_Shape myShape;
1018 TColStd_MapOfInteger mySubShapesIDs;
1019 const SMESHDS_Mesh* myMeshDS;
1020 SMDSAbs_ElementType myType;
1022 double myTolerance; // only if myIsSubshape == false
1023 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
1025 typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
1029 Description : Predicate for verifying whether entiy lying or partially lying on
1030 specified geometrical support
1032 class SMESHCONTROLS_EXPORT LyingOnGeom: public virtual Predicate
1036 virtual Predicate* clone() const;
1038 virtual void SetMesh( const SMDS_Mesh* theMesh );
1039 virtual void SetGeom( const TopoDS_Shape& theShape );
1041 virtual bool IsSatisfy( long theElementId );
1043 virtual void SetType( SMDSAbs_ElementType theType );
1044 virtual SMDSAbs_ElementType GetType() const;
1046 TopoDS_Shape GetShape();
1047 const SMESHDS_Mesh* GetMeshDS() const;
1049 void SetTolerance( double );
1050 double GetTolerance();
1053 virtual void init();
1055 TopoDS_Shape myShape;
1056 TColStd_MapOfInteger mySubShapesIDs;
1057 const SMESHDS_Mesh* myMeshDS;
1058 SMDSAbs_ElementType myType;
1060 double myTolerance; // only if myIsSubshape == false
1061 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
1063 typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
1067 Description : Predicate for free faces
1069 class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
1072 //virtual Predicate* clone() const { return new FreeFaces( *this ); }
1073 virtual void SetMesh( const SMDS_Mesh* theMesh );
1074 virtual bool IsSatisfy( long theElementId );
1075 virtual SMDSAbs_ElementType GetType() const;
1078 const SMDS_Mesh* myMesh;
1082 Class : LinearOrQuadratic
1083 Description : Predicate for free faces
1085 class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
1087 LinearOrQuadratic();
1088 //virtual Predicate* clone() const { return new LinearOrQuadratic( *this ); }
1089 virtual void SetMesh( const SMDS_Mesh* theMesh );
1090 virtual bool IsSatisfy( long theElementId );
1091 void SetType( SMDSAbs_ElementType theType );
1092 virtual SMDSAbs_ElementType GetType() const;
1095 const SMDS_Mesh* myMesh;
1096 SMDSAbs_ElementType myType;
1098 typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
1102 Description : Functor for check color of group to which mesh element belongs to
1104 class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
1107 //virtual Predicate* clone() const { return new GroupColor( *this ); }
1108 virtual void SetMesh( const SMDS_Mesh* theMesh );
1109 virtual bool IsSatisfy( long theElementId );
1110 void SetType( SMDSAbs_ElementType theType );
1111 virtual SMDSAbs_ElementType GetType() const;
1112 void SetColorStr( const TCollection_AsciiString& );
1113 void GetColorStr( TCollection_AsciiString& ) const;
1116 typedef std::set< long > TIDs;
1118 Quantity_Color myColor;
1119 SMDSAbs_ElementType myType;
1122 typedef boost::shared_ptr<GroupColor> GroupColorPtr;
1125 Class : ElemGeomType
1126 Description : Predicate to check element geometry type
1128 class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
1131 //virtual Predicate* clone() const { return new ElemGeomType( *this ); }
1132 virtual void SetMesh( const SMDS_Mesh* theMesh );
1133 virtual bool IsSatisfy( long theElementId );
1134 void SetType( SMDSAbs_ElementType theType );
1135 virtual SMDSAbs_ElementType GetType() const;
1136 void SetGeomType( SMDSAbs_GeometryType theType );
1137 SMDSAbs_GeometryType GetGeomType() const;
1140 const SMDS_Mesh* myMesh;
1141 SMDSAbs_ElementType myType;
1142 SMDSAbs_GeometryType myGeomType;
1144 typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
1147 Class : CoplanarFaces
1148 Description : Predicate to check angle between faces
1150 class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
1154 //virtual Predicate* clone() const { return new CoplanarFaces( *this ); }
1155 void SetFace( long theID ) { myFaceID = theID; }
1156 long GetFace() const { return myFaceID; }
1157 void SetTolerance (const double theToler) { myToler = theToler; }
1158 double GetTolerance () const { return myToler; }
1159 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
1161 virtual void SetMesh( const SMDS_Mesh* theMesh );
1162 virtual bool IsSatisfy( long theElementId );
1165 TMeshModifTracer myMeshModifTracer;
1168 TIDsMap myCoplanarIDs;
1170 typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
1173 Class : ConnectedElements
1174 Description : Predicate to get elements of one domain
1176 class SMESHCONTROLS_EXPORT ConnectedElements: public virtual Predicate
1179 ConnectedElements();
1180 //virtual Predicate* clone() const { return new ConnectedElements( *this ); }
1181 void SetNode( ::smIdType nodeID );
1182 void SetPoint( double x, double y, double z );
1183 ::smIdType GetNode() const;
1184 std::vector<double> GetPoint() const;
1186 void SetType( SMDSAbs_ElementType theType );
1187 virtual SMDSAbs_ElementType GetType() const;
1189 virtual void SetMesh( const SMDS_Mesh* theMesh );
1190 virtual bool IsSatisfy( long theElementId );
1192 //const std::set<long>& GetDomainIDs() const { return myOkIDs; }
1195 ::smIdType myNodeID;
1196 std::vector<double> myXYZ;
1197 SMDSAbs_ElementType myType;
1198 TMeshModifTracer myMeshModifTracer;
1202 std::set<::smIdType> myOkIDs; // empty means that there is one domain
1204 typedef boost::shared_ptr<ConnectedElements> ConnectedElementsPtr;
1209 class SMESHCONTROLS_EXPORT Filter {
1213 virtual void SetPredicate(PredicatePtr thePred);
1215 typedef std::vector<long> TIdSequence;
1219 GetElementsId( const SMDS_Mesh* theMesh,
1220 TIdSequence& theSequence,
1221 SMDS_ElemIteratorPtr theElements=0);
1225 GetElementsId( const SMDS_Mesh* theMesh,
1226 PredicatePtr thePredicate,
1227 TIdSequence& theSequence,
1228 SMDS_ElemIteratorPtr theElements=0 );
1231 PredicatePtr myPredicate;