1 // Copyright (C) 2007-2020 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 "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 <TColStd_SequenceOfInteger.hxx>
36 #include <TCollection_AsciiString.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;
64 class SMESHCONTROLS_EXPORT TSequenceOfXYZ
66 typedef std::vector<gp_XYZ>::size_type size_type;
71 explicit TSequenceOfXYZ(size_type n);
73 TSequenceOfXYZ(size_type n, const gp_XYZ& t);
75 TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ);
77 template <class InputIterator>
78 TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd);
82 TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ);
84 gp_XYZ& operator()(size_type n);
86 const gp_XYZ& operator()(size_type n) const;
90 void reserve(size_type n);
92 void push_back(const gp_XYZ& v);
94 size_type size() const;
97 void setElement(const SMDS_MeshElement* e) { myElem = e; }
99 const SMDS_MeshElement* getElement() const { return myElem; }
101 SMDSAbs_EntityType getElementEntity() const;
104 std::vector<gp_XYZ> myArray;
105 const SMDS_MeshElement* myElem;
109 * \brief Class used to detect mesh modification: IsMeshModified() returns
110 * true if a mesh has changed since last calling IsMeshModified()
112 class SMESHCONTROLS_EXPORT TMeshModifTracer
114 unsigned long myMeshModifTime;
115 const SMDS_Mesh* myMesh;
118 void SetMesh( const SMDS_Mesh* theMesh );
119 const SMDS_Mesh* GetMesh() const { return myMesh; }
120 bool IsMeshModified();
124 Class : NumericalFunctor
125 Description : Root of all Functors returning numeric value
127 class SMESHCONTROLS_EXPORT NumericalFunctor: public virtual Functor{
130 virtual void SetMesh( const SMDS_Mesh* theMesh );
131 virtual double GetValue( long theElementId );
132 virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
133 void GetHistogram(int nbIntervals,
134 std::vector<int>& nbEvents,
135 std::vector<double>& funValues,
136 const std::vector<int>& elements,
137 const double* minmax=0,
138 const bool isLogarithmic = false);
139 bool IsApplicable( long theElementId ) const;
140 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
141 virtual SMDSAbs_ElementType GetType() const = 0;
142 virtual double GetBadRate( double Value, int nbNodes ) const = 0;
143 long GetPrecision() const;
144 void SetPrecision( const long thePrecision );
145 double Round( const double & value );
147 bool GetPoints(const int theId, TSequenceOfXYZ& theRes) const;
148 static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes);
150 const SMDS_Mesh* myMesh;
151 const SMDS_MeshElement* myCurrElement;
153 double myPrecisionValue;
159 Description : Functor calculating volume of 3D mesh element
161 class SMESHCONTROLS_EXPORT Volume: public virtual NumericalFunctor{
163 virtual double GetValue( long theElementId );
164 //virtual double GetValue( const TSequenceOfXYZ& thePoints );
165 virtual double GetBadRate( double Value, int nbNodes ) const;
166 virtual SMDSAbs_ElementType GetType() const;
171 Class : MaxElementLength2D
172 Description : Functor calculating maximum length of 2D element
174 class SMESHCONTROLS_EXPORT MaxElementLength2D: public virtual NumericalFunctor{
176 virtual double GetValue( long theElementId );
177 virtual double GetValue( const TSequenceOfXYZ& P );
178 virtual double GetBadRate( double Value, int nbNodes ) const;
179 virtual SMDSAbs_ElementType GetType() const;
184 Class : MaxElementLength3D
185 Description : Functor calculating maximum length of 3D element
187 class SMESHCONTROLS_EXPORT MaxElementLength3D: public virtual NumericalFunctor{
189 virtual double GetValue( long theElementId );
190 virtual double GetBadRate( double Value, int nbNodes ) const;
191 virtual SMDSAbs_ElementType GetType() const;
196 Class : SMESH_MinimumAngle
197 Description : Functor for calculation of minimum angle
199 class SMESHCONTROLS_EXPORT MinimumAngle: public virtual NumericalFunctor{
201 virtual double GetValue( const TSequenceOfXYZ& thePoints );
202 virtual double GetBadRate( double Value, int nbNodes ) const;
203 virtual SMDSAbs_ElementType GetType() const;
209 Description : Functor for calculating aspect ratio
211 class SMESHCONTROLS_EXPORT AspectRatio: public virtual NumericalFunctor{
213 virtual double GetValue( long theElementId );
214 virtual double GetValue( const TSequenceOfXYZ& thePoints );
215 virtual double GetBadRate( double Value, int nbNodes ) const;
216 virtual SMDSAbs_ElementType GetType() const;
217 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
222 Class : AspectRatio3D
223 Description : Functor for calculating aspect ratio of 3D elems.
225 class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
227 virtual double GetValue( long theElementId );
228 virtual double GetValue( const TSequenceOfXYZ& thePoints );
229 virtual double GetBadRate( double Value, int nbNodes ) const;
230 virtual SMDSAbs_ElementType GetType() const;
231 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
237 Description : Functor for calculating warping
239 class SMESHCONTROLS_EXPORT Warping: public virtual NumericalFunctor{
241 virtual double GetValue( const TSequenceOfXYZ& thePoints );
242 virtual double GetBadRate( double Value, int nbNodes ) const;
243 virtual SMDSAbs_ElementType GetType() const;
244 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
247 double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
253 Description : Functor for calculating taper
255 class SMESHCONTROLS_EXPORT Taper: public virtual NumericalFunctor{
257 virtual double GetValue( const TSequenceOfXYZ& thePoints );
258 virtual double GetBadRate( double Value, int nbNodes ) const;
259 virtual SMDSAbs_ElementType GetType() const;
260 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
265 Description : Functor for calculating skew in degrees
267 class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
269 virtual double GetValue( const TSequenceOfXYZ& thePoints );
270 virtual double GetBadRate( double Value, int nbNodes ) const;
271 virtual SMDSAbs_ElementType GetType() const;
272 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
278 Description : Functor for calculating area
280 class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
282 virtual double GetValue( const TSequenceOfXYZ& thePoints );
283 virtual double GetBadRate( double Value, int nbNodes ) const;
284 virtual SMDSAbs_ElementType GetType() const;
290 Description : Functor for calculating length of edge
292 class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
294 virtual double GetValue( const TSequenceOfXYZ& thePoints );
295 virtual double GetBadRate( double Value, int nbNodes ) const;
296 virtual SMDSAbs_ElementType GetType() const;
301 Description : Functor for calculating minimal length of edges of element
303 class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
305 Length2D( SMDSAbs_ElementType type = SMDSAbs_Face );
306 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
307 virtual double GetValue( const TSequenceOfXYZ& thePoints );
308 virtual double GetBadRate( double Value, int nbNodes ) const;
309 virtual SMDSAbs_ElementType GetType() const;
313 Value(double theLength, long thePntId1, long thePntId2);
314 bool operator<(const Value& x) const;
316 typedef std::set<Value> TValues;
317 void GetValues(TValues& theValues);
320 SMDSAbs_ElementType myType;
322 typedef boost::shared_ptr<Length2D> Length2DPtr;
326 Description : Functor for calculating minimal length of edges of 3D element
328 class SMESHCONTROLS_EXPORT Length3D: public virtual Length2D {
332 typedef boost::shared_ptr<Length3D> Length3DPtr;
336 Description : Functor for calculating distance between a face and geometry
338 class SMESHCONTROLS_EXPORT Deflection2D: public virtual NumericalFunctor{
340 virtual void SetMesh( const SMDS_Mesh* theMesh );
341 virtual double GetValue( const TSequenceOfXYZ& thePoints );
342 virtual double GetBadRate( double Value, int nbNodes ) const;
343 virtual SMDSAbs_ElementType GetType() const;
345 Handle(ShapeAnalysis_Surface) mySurface;
347 boost::shared_ptr<gp_Pln> myPlane;
351 Class : MultiConnection
352 Description : Functor for calculating number of faces connected to the edge
354 class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
356 virtual double GetValue( long theElementId );
357 virtual double GetValue( const TSequenceOfXYZ& thePoints );
358 virtual double GetBadRate( double Value, int nbNodes ) const;
359 virtual SMDSAbs_ElementType GetType() const;
363 Class : MultiConnection2D
364 Description : Functor for calculating number of faces connected to the edge
366 class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
368 virtual double GetValue( long theElementId );
369 virtual double GetValue( const TSequenceOfXYZ& thePoints );
370 virtual double GetBadRate( double Value, int nbNodes ) const;
371 virtual SMDSAbs_ElementType GetType() const;
374 Value(long thePntId1, long thePntId2);
375 bool operator<(const Value& x) const;
377 typedef std::map<Value,int> MValues;
379 void GetValues(MValues& theValues);
381 typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
385 Description : Functor returning diameter of a ball element
387 class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{
389 virtual double GetValue( long theElementId );
390 virtual double GetBadRate( double Value, int nbNodes ) const;
391 virtual SMDSAbs_ElementType GetType() const;
395 Class : NodeConnectivityNumber
396 Description : Functor returning number of elements connected to a node
398 class SMESHCONTROLS_EXPORT NodeConnectivityNumber: public virtual NumericalFunctor{
400 virtual double GetValue( long theNodeId );
401 virtual double GetBadRate( double Value, int nbNodes ) const;
402 virtual SMDSAbs_ElementType GetType() const;
410 Class : CoincidentNodes
411 Description : Predicate of Coincident Nodes
412 Note : This class is suitable only for visualization of Coincident Nodes
414 class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
417 //virtual Predicate* clone() const { return new CoincidentNodes( *this ); }
418 virtual void SetMesh( const SMDS_Mesh* theMesh );
419 virtual bool IsSatisfy( long theElementId );
420 virtual SMDSAbs_ElementType GetType() const;
422 void SetTolerance (const double theToler);
423 double GetTolerance () const { return myToler; }
427 TColStd_MapOfInteger myCoincidentIDs;
428 TMeshModifTracer myMeshModifTracer;
430 typedef boost::shared_ptr<CoincidentNodes> CoincidentNodesPtr;
433 Class : CoincidentElements
434 Description : Predicate of Coincident Elements
435 Note : This class is suitable only for visualization of Coincident Elements
437 class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate {
439 CoincidentElements();
440 virtual void SetMesh( const SMDS_Mesh* theMesh );
441 virtual bool IsSatisfy( long theElementId );
444 const SMDS_Mesh* myMesh;
446 class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
448 virtual SMDSAbs_ElementType GetType() const;
449 //virtual Predicate* clone() const { return new CoincidentElements1D( *this ); }
451 class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
453 virtual SMDSAbs_ElementType GetType() const;
454 //virtual Predicate* clone() const { return new CoincidentElements2D( *this ); }
456 class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
458 virtual SMDSAbs_ElementType GetType() const;
459 //virtual Predicate* clone() const { return new CoincidentElements3D( *this ); }
464 Description : Predicate for free borders
466 class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
469 //virtual Predicate* clone() const { return new FreeBorders( *this ); }
470 virtual void SetMesh( const SMDS_Mesh* theMesh );
471 virtual bool IsSatisfy( long theElementId );
472 virtual SMDSAbs_ElementType GetType() const;
475 const SMDS_Mesh* myMesh;
480 Class : BadOrientedVolume
481 Description : Predicate bad oriented volumes
483 class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
486 //virtual Predicate* clone() const { return new BadOrientedVolume( *this ); }
487 virtual void SetMesh( const SMDS_Mesh* theMesh );
488 virtual bool IsSatisfy( long theElementId );
489 virtual SMDSAbs_ElementType GetType() const;
492 const SMDS_Mesh* myMesh;
496 Class : ElemEntityType
497 Description : Functor for calculating entity type
499 class SMESHCONTROLS_EXPORT ElemEntityType: public virtual Predicate{
502 //virtual Predicate* clone() const { return new ElemEntityType( *this ); }
503 virtual void SetMesh( const SMDS_Mesh* theMesh );
504 virtual bool IsSatisfy( long theElementId );
505 void SetType( SMDSAbs_ElementType theType );
506 virtual SMDSAbs_ElementType GetType() const;
507 void SetElemEntityType( SMDSAbs_EntityType theEntityType );
508 SMDSAbs_EntityType GetElemEntityType() const;
511 const SMDS_Mesh* myMesh;
512 SMDSAbs_ElementType myType;
513 SMDSAbs_EntityType myEntityType;
515 typedef boost::shared_ptr<ElemEntityType> ElemEntityTypePtr;
521 class SMESHCONTROLS_EXPORT BareBorderVolume: public Predicate
524 BareBorderVolume():myMesh(0) {}
525 virtual Predicate* clone() const { return new BareBorderVolume( *this ); }
526 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
527 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
528 virtual bool IsSatisfy( long theElementId );
530 const SMDS_Mesh* myMesh;
532 typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
537 class SMESHCONTROLS_EXPORT BareBorderFace: public Predicate
540 BareBorderFace():myMesh(0) {}
541 //virtual Predicate* clone() const { return new BareBorderFace( *this ); }
542 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
543 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
544 virtual bool IsSatisfy( long theElementId );
546 const SMDS_Mesh* myMesh;
547 std::vector< const SMDS_MeshNode* > myLinkNodes;
549 typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
552 OverConstrainedVolume
554 class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
557 OverConstrainedVolume():myMesh(0) {}
558 virtual Predicate* clone() const { return new OverConstrainedVolume( *this ); }
559 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
560 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
561 virtual bool IsSatisfy( long theElementId );
563 const SMDS_Mesh* myMesh;
565 typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
570 class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
573 OverConstrainedFace():myMesh(0) {}
574 //virtual Predicate* clone() const { return new OverConstrainedFace( *this ); }
575 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
576 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
577 virtual bool IsSatisfy( long theElementId );
579 const SMDS_Mesh* myMesh;
581 typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
585 Description : Predicate for free Edges
587 class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
590 //virtual Predicate* clone() const { return new FreeEdges( *this ); }
591 virtual void SetMesh( const SMDS_Mesh* theMesh );
592 virtual bool IsSatisfy( long theElementId );
593 virtual SMDSAbs_ElementType GetType() const;
594 static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId );
595 typedef long TElemId;
599 Border(long theElemId, long thePntId1, long thePntId2);
600 bool operator<(const Border& x) const;
602 typedef std::set<Border> TBorders;
603 void GetBoreders(TBorders& theBorders);
606 const SMDS_Mesh* myMesh;
608 typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
613 Description : Predicate for free nodes
615 class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
618 //virtual Predicate* clone() const { return new FreeNodes( *this ); }
619 virtual void SetMesh( const SMDS_Mesh* theMesh );
620 virtual bool IsSatisfy( long theNodeId );
621 virtual SMDSAbs_ElementType GetType() const;
624 const SMDS_Mesh* myMesh;
630 Description : Predicate for Range of Ids.
631 Range may be specified with two ways.
632 1. Using AddToRange method
633 2. With SetRangeStr method. Parameter of this method is a string
634 like as "1,2,3,50-60,63,67,70-"
636 class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
640 //virtual Predicate* clone() const { return new RangeOfIds( *this ); }
641 virtual void SetMesh( const SMDS_Mesh* theMesh );
642 virtual bool IsSatisfy( long theNodeId );
643 virtual SMDSAbs_ElementType GetType() const;
644 virtual void SetType( SMDSAbs_ElementType theType );
646 bool AddToRange( long theEntityId );
647 void GetRangeStr( TCollection_AsciiString& );
648 bool SetRangeStr( const TCollection_AsciiString& );
651 const SMDS_Mesh* myMesh;
653 TColStd_SequenceOfInteger myMin;
654 TColStd_SequenceOfInteger myMax;
655 TColStd_MapOfInteger myIds;
657 SMDSAbs_ElementType myType;
660 typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
665 Description : Base class for comparators
667 class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
670 virtual ~Comparator();
671 virtual void SetMesh( const SMDS_Mesh* theMesh );
672 virtual void SetMargin(double theValue);
673 virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
674 virtual bool IsSatisfy( long theElementId ) = 0;
675 virtual SMDSAbs_ElementType GetType() const;
680 NumericalFunctorPtr myFunctor;
682 typedef boost::shared_ptr<Comparator> ComparatorPtr;
687 Description : Comparator "<"
689 class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
691 virtual bool IsSatisfy( long theElementId );
692 //virtual Predicate* clone() const { return new LessThan( *this ); }
698 Description : Comparator ">"
700 class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
702 virtual bool IsSatisfy( long theElementId );
703 //virtual Predicate* clone() const { return new MoreThan( *this ); }
709 Description : Comparator "="
711 class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
714 //virtual Predicate* clone() const { return new EqualTo( *this ); }
715 virtual bool IsSatisfy( long theElementId );
716 virtual void SetTolerance( double theTol );
717 virtual double GetTolerance();
722 typedef boost::shared_ptr<EqualTo> EqualToPtr;
727 Description : Logical NOT predicate
729 class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
732 //virtual Predicate* clone() const { return new LogicalNOT( *this ); }
733 virtual ~LogicalNOT();
734 virtual bool IsSatisfy( long theElementId );
735 virtual void SetMesh( const SMDS_Mesh* theMesh );
736 virtual void SetPredicate(PredicatePtr thePred);
737 virtual SMDSAbs_ElementType GetType() const;
740 PredicatePtr myPredicate;
742 typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
746 Class : LogicalBinary
747 Description : Base class for binary logical predicate
749 class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
752 virtual ~LogicalBinary();
753 virtual void SetMesh( const SMDS_Mesh* theMesh );
754 virtual void SetPredicate1(PredicatePtr thePred);
755 virtual void SetPredicate2(PredicatePtr thePred);
756 virtual SMDSAbs_ElementType GetType() const;
759 PredicatePtr myPredicate1;
760 PredicatePtr myPredicate2;
762 typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
767 Description : Logical AND
769 class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
771 virtual bool IsSatisfy( long theElementId );
772 //virtual Predicate* clone() const { return new LogicalAND( *this ); }
778 Description : Logical OR
780 class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
782 virtual bool IsSatisfy( long theElementId );
783 //virtual Predicate* clone() const { return new LogicalOR( *this ); }
789 Description : Predicate for manifold part of mesh
791 class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
794 /* internal class for algorithm uses */
798 Link( SMDS_MeshNode* theNode1,
799 SMDS_MeshNode* theNode2 );
802 bool IsEqual( const ManifoldPart::Link& theLink ) const;
803 bool operator<(const ManifoldPart::Link& x) const;
805 SMDS_MeshNode* myNode1;
806 SMDS_MeshNode* myNode2;
809 bool IsEqual( const ManifoldPart::Link& theLink1,
810 const ManifoldPart::Link& theLink2 );
812 typedef std::set<ManifoldPart::Link> TMapOfLink;
813 typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
814 typedef std::vector<ManifoldPart::Link> TVectorOfLink;
815 typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
816 typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
820 //virtual Predicate* clone() const { return new ManifoldPart( *this ); }
821 virtual void SetMesh( const SMDS_Mesh* theMesh );
822 // invoke when all parameters already set
823 virtual bool IsSatisfy( long theElementId );
824 virtual SMDSAbs_ElementType GetType() const;
826 void SetAngleTolerance( const double theAngToler );
827 double GetAngleTolerance() const;
828 void SetIsOnlyManifold( const bool theIsOnly );
829 void SetStartElem( const long theStartElemId );
833 bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
834 SMDS_MeshFace* theStartFace,
835 TMapOfLink& theNonManifold,
836 TColStd_MapOfInteger& theResFaces );
837 bool isInPlane( const SMDS_MeshFace* theFace1,
838 const SMDS_MeshFace* theFace2 );
839 void expandBoundary( TMapOfLink& theMapOfBoundary,
840 TVectorOfLink& theSeqOfBoundary,
841 TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
842 TMapOfLink& theNonManifold,
843 SMDS_MeshFace* theNextFace ) const;
845 void getFacesByLink( const Link& theLink,
846 TVectorOfFacePtr& theFaces ) const;
849 const SMDS_Mesh* myMesh;
850 TColStd_MapOfInteger myMapIds;
851 TColStd_MapOfInteger myMapBadGeomIds;
852 TVectorOfFacePtr myAllFacePtr;
853 TDataMapFacePtrInt myAllFacePtrIntDMap;
855 bool myIsOnlyManifold;
859 typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
862 Class : BelongToMeshGroup
863 Description : Verify whether a mesh element is included into a mesh group
865 class SMESHCONTROLS_EXPORT BelongToMeshGroup : public virtual Predicate
869 //virtual Predicate* clone() const { return new BelongToMeshGroup( *this ); }
870 virtual void SetMesh( const SMDS_Mesh* theMesh );
871 virtual bool IsSatisfy( long theElementId );
872 virtual SMDSAbs_ElementType GetType() const;
874 void SetGroup( SMESHDS_GroupBase* g );
875 void SetStoreName( const std::string& sn );
876 const SMESHDS_GroupBase* GetGroup() const { return myGroup; }
879 SMESHDS_GroupBase* myGroup;
880 std::string myStoreName;
882 typedef boost::shared_ptr<BelongToMeshGroup> BelongToMeshGroupPtr;
885 Class : ElementsOnSurface
886 Description : Predicate elements that lying on indicated surface
889 class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
892 ~ElementsOnSurface();
893 //virtual Predicate* clone() const { return new ElementsOnSurface( *this ); }
894 virtual void SetMesh( const SMDS_Mesh* theMesh );
895 virtual bool IsSatisfy( long theElementId );
896 virtual SMDSAbs_ElementType GetType() const;
898 void SetTolerance( const double theToler );
899 double GetTolerance() const;
900 void SetSurface( const TopoDS_Shape& theShape,
901 const SMDSAbs_ElementType theType );
902 void SetUseBoundaries( bool theUse );
903 bool GetUseBoundaries() const { return myUseBoundaries; }
907 void process( const SMDS_MeshElement* theElem );
908 bool isOnSurface( const SMDS_MeshNode* theNode );
911 TMeshModifTracer myMeshModifTracer;
912 TColStd_MapOfInteger myIds;
913 SMDSAbs_ElementType myType;
916 bool myUseBoundaries;
917 GeomAPI_ProjectPointOnSurf myProjector;
920 typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
924 Class : ElementsOnShape
925 Description : Predicate elements that lying on indicated shape
928 class SMESHCONTROLS_EXPORT ElementsOnShape : public Predicate
934 virtual Predicate* clone() const;
935 virtual void SetMesh (const SMDS_Mesh* theMesh);
936 virtual bool IsSatisfy (long theElementId);
937 virtual SMDSAbs_ElementType GetType() const;
939 void SetTolerance (const double theToler);
940 double GetTolerance() const;
941 void SetAllNodes (bool theAllNodes);
942 bool GetAllNodes() const { return myAllNodesFlag; }
943 void SetShape (const TopoDS_Shape& theShape,
944 const SMDSAbs_ElementType theType);
945 bool IsSatisfy (const SMDS_MeshElement* elem);
946 bool IsSatisfy (const SMDS_MeshNode* node, TopoDS_Shape* okShape=0);
951 struct OctreeClassifier;
953 void clearClassifiers();
954 bool getNodeIsOut( const SMDS_MeshNode* n, bool& isOut );
955 void setNodeIsOut( const SMDS_MeshNode* n, bool isOut );
957 std::vector< Classifier > myClassifiers;
958 std::vector< Classifier* > myWorkClassifiers;
959 OctreeClassifier* myOctree;
960 SMDSAbs_ElementType myType;
961 TopoDS_Shape myShape;
965 TMeshModifTracer myMeshModifTracer;
966 std::vector<bool> myNodeIsChecked;
967 std::vector<bool> myNodeIsOut;
970 typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
975 Description : Predicate for verifying whether entiy belong to
976 specified geometrical support
978 class SMESHCONTROLS_EXPORT BelongToGeom: public virtual Predicate
982 virtual Predicate* clone() const;
984 virtual void SetMesh( const SMDS_Mesh* theMesh );
985 virtual void SetGeom( const TopoDS_Shape& theShape );
987 virtual bool IsSatisfy( long theElementId );
989 virtual void SetType( SMDSAbs_ElementType theType );
990 virtual SMDSAbs_ElementType GetType() const;
992 TopoDS_Shape GetShape();
993 const SMESHDS_Mesh* GetMeshDS() const;
995 void SetTolerance( double );
996 double GetTolerance();
1001 TopoDS_Shape myShape;
1002 TColStd_MapOfInteger mySubShapesIDs;
1003 const SMESHDS_Mesh* myMeshDS;
1004 SMDSAbs_ElementType myType;
1006 double myTolerance; // only if myIsSubshape == false
1007 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
1009 typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
1013 Description : Predicate for verifying whether entiy lying or partially lying on
1014 specified geometrical support
1016 class SMESHCONTROLS_EXPORT LyingOnGeom: public virtual Predicate
1020 virtual Predicate* clone() const;
1022 virtual void SetMesh( const SMDS_Mesh* theMesh );
1023 virtual void SetGeom( const TopoDS_Shape& theShape );
1025 virtual bool IsSatisfy( long theElementId );
1027 virtual void SetType( SMDSAbs_ElementType theType );
1028 virtual SMDSAbs_ElementType GetType() const;
1030 TopoDS_Shape GetShape();
1031 const SMESHDS_Mesh* GetMeshDS() const;
1033 void SetTolerance( double );
1034 double GetTolerance();
1037 virtual void init();
1039 TopoDS_Shape myShape;
1040 TColStd_MapOfInteger mySubShapesIDs;
1041 const SMESHDS_Mesh* myMeshDS;
1042 SMDSAbs_ElementType myType;
1044 double myTolerance; // only if myIsSubshape == false
1045 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
1047 typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
1051 Description : Predicate for free faces
1053 class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
1056 //virtual Predicate* clone() const { return new FreeFaces( *this ); }
1057 virtual void SetMesh( const SMDS_Mesh* theMesh );
1058 virtual bool IsSatisfy( long theElementId );
1059 virtual SMDSAbs_ElementType GetType() const;
1062 const SMDS_Mesh* myMesh;
1066 Class : LinearOrQuadratic
1067 Description : Predicate for free faces
1069 class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
1071 LinearOrQuadratic();
1072 //virtual Predicate* clone() const { return new LinearOrQuadratic( *this ); }
1073 virtual void SetMesh( const SMDS_Mesh* theMesh );
1074 virtual bool IsSatisfy( long theElementId );
1075 void SetType( SMDSAbs_ElementType theType );
1076 virtual SMDSAbs_ElementType GetType() const;
1079 const SMDS_Mesh* myMesh;
1080 SMDSAbs_ElementType myType;
1082 typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
1086 Description : Functor for check color of group to which mesh element belongs to
1088 class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
1091 //virtual Predicate* clone() const { return new GroupColor( *this ); }
1092 virtual void SetMesh( const SMDS_Mesh* theMesh );
1093 virtual bool IsSatisfy( long theElementId );
1094 void SetType( SMDSAbs_ElementType theType );
1095 virtual SMDSAbs_ElementType GetType() const;
1096 void SetColorStr( const TCollection_AsciiString& );
1097 void GetColorStr( TCollection_AsciiString& ) const;
1100 typedef std::set< long > TIDs;
1102 Quantity_Color myColor;
1103 SMDSAbs_ElementType myType;
1106 typedef boost::shared_ptr<GroupColor> GroupColorPtr;
1109 Class : ElemGeomType
1110 Description : Predicate to check element geometry type
1112 class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
1115 //virtual Predicate* clone() const { return new ElemGeomType( *this ); }
1116 virtual void SetMesh( const SMDS_Mesh* theMesh );
1117 virtual bool IsSatisfy( long theElementId );
1118 void SetType( SMDSAbs_ElementType theType );
1119 virtual SMDSAbs_ElementType GetType() const;
1120 void SetGeomType( SMDSAbs_GeometryType theType );
1121 SMDSAbs_GeometryType GetGeomType() const;
1124 const SMDS_Mesh* myMesh;
1125 SMDSAbs_ElementType myType;
1126 SMDSAbs_GeometryType myGeomType;
1128 typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
1131 Class : CoplanarFaces
1132 Description : Predicate to check angle between faces
1134 class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
1138 //virtual Predicate* clone() const { return new CoplanarFaces( *this ); }
1139 void SetFace( long theID ) { myFaceID = theID; }
1140 long GetFace() const { return myFaceID; }
1141 void SetTolerance (const double theToler) { myToler = theToler; }
1142 double GetTolerance () const { return myToler; }
1143 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
1145 virtual void SetMesh( const SMDS_Mesh* theMesh );
1146 virtual bool IsSatisfy( long theElementId );
1149 TMeshModifTracer myMeshModifTracer;
1152 TColStd_MapOfInteger myCoplanarIDs;
1154 typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
1157 Class : ConnectedElements
1158 Description : Predicate to get elements of one domain
1160 class SMESHCONTROLS_EXPORT ConnectedElements: public virtual Predicate
1163 ConnectedElements();
1164 //virtual Predicate* clone() const { return new ConnectedElements( *this ); }
1165 void SetNode( int nodeID );
1166 void SetPoint( double x, double y, double z );
1167 int GetNode() const;
1168 std::vector<double> GetPoint() const;
1170 void SetType( SMDSAbs_ElementType theType );
1171 virtual SMDSAbs_ElementType GetType() const;
1173 virtual void SetMesh( const SMDS_Mesh* theMesh );
1174 virtual bool IsSatisfy( long theElementId );
1176 //const std::set<long>& GetDomainIDs() const { return myOkIDs; }
1180 std::vector<double> myXYZ;
1181 SMDSAbs_ElementType myType;
1182 TMeshModifTracer myMeshModifTracer;
1186 std::set< int > myOkIDs; // empty means that there is one domain
1188 typedef boost::shared_ptr<ConnectedElements> ConnectedElementsPtr;
1193 class SMESHCONTROLS_EXPORT Filter {
1197 virtual void SetPredicate(PredicatePtr thePred);
1199 typedef std::vector<long> TIdSequence;
1203 GetElementsId( const SMDS_Mesh* theMesh,
1204 TIdSequence& theSequence,
1205 SMDS_ElemIteratorPtr theElements=0);
1209 GetElementsId( const SMDS_Mesh* theMesh,
1210 PredicatePtr thePredicate,
1211 TIdSequence& theSequence,
1212 SMDS_ElemIteratorPtr theElements=0 );
1215 PredicatePtr myPredicate;