1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef _SMESH_CONTROLSDEF_HXX_
24 #define _SMESH_CONTROLSDEF_HXX_
26 #include "SMESH_Controls.hxx"
28 #include "SMDS_MeshNode.hxx"
29 #include "SMESH_TypeDefs.hxx"
31 #include <BRepClass3d_SolidClassifier.hxx>
32 #include <Bnd_B3d.hxx>
33 #include <GeomAPI_ProjectPointOnCurve.hxx>
34 #include <GeomAPI_ProjectPointOnSurf.hxx>
35 #include <Quantity_Color.hxx>
36 #include <TColStd_MapOfInteger.hxx>
37 #include <TColStd_SequenceOfInteger.hxx>
38 #include <TCollection_AsciiString.hxx>
40 #include <TopoDS_Face.hxx>
47 #include <boost/shared_ptr.hpp>
49 class SMDS_MeshElement;
55 class SMESHDS_SubMesh;
56 class SMESHDS_GroupBase;
63 class SMESHCONTROLS_EXPORT TSequenceOfXYZ
65 typedef std::vector<gp_XYZ>::size_type size_type;
70 explicit TSequenceOfXYZ(size_type n);
72 TSequenceOfXYZ(size_type n, const gp_XYZ& t);
74 TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ);
76 template <class InputIterator>
77 TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd);
81 TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ);
83 gp_XYZ& operator()(size_type n);
85 const gp_XYZ& operator()(size_type n) const;
89 void reserve(size_type n);
91 void push_back(const gp_XYZ& v);
93 size_type size() const;
96 void setElement(const SMDS_MeshElement* e) { myElem = e; }
98 const SMDS_MeshElement* getElement() const { return myElem; }
100 SMDSAbs_EntityType getElementEntity() const;
103 std::vector<gp_XYZ> myArray;
104 const SMDS_MeshElement* myElem;
108 * \brief Class used to detect mesh modification: IsMeshModified() returns
109 * true if a mesh has changed since last calling IsMeshModified()
111 class SMESHCONTROLS_EXPORT TMeshModifTracer
113 unsigned long myMeshModifTime;
114 const SMDS_Mesh* myMesh;
117 void SetMesh( const SMDS_Mesh* theMesh );
118 const SMDS_Mesh* GetMesh() const { return myMesh; }
119 bool IsMeshModified();
123 Class : NumericalFunctor
124 Description : Root of all Functors returning numeric value
126 class SMESHCONTROLS_EXPORT NumericalFunctor: public virtual Functor{
129 virtual void SetMesh( const SMDS_Mesh* theMesh );
130 virtual double GetValue( long theElementId );
131 virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
132 void GetHistogram(int nbIntervals,
133 std::vector<int>& nbEvents,
134 std::vector<double>& funValues,
135 const std::vector<int>& elements,
136 const double* minmax=0,
137 const bool isLogarithmic = false);
138 virtual SMDSAbs_ElementType GetType() const = 0;
139 virtual double GetBadRate( double Value, int nbNodes ) const = 0;
140 long GetPrecision() const;
141 void SetPrecision( const long thePrecision );
142 double Round( const double & value );
144 bool GetPoints(const int theId, TSequenceOfXYZ& theRes) const;
145 static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes);
147 const SMDS_Mesh* myMesh;
148 const SMDS_MeshElement* myCurrElement;
150 double myPrecisionValue;
156 Description : Functor calculating volume of 3D mesh element
158 class SMESHCONTROLS_EXPORT Volume: public virtual NumericalFunctor{
160 virtual double GetValue( long theElementId );
161 //virtual double GetValue( const TSequenceOfXYZ& thePoints );
162 virtual double GetBadRate( double Value, int nbNodes ) const;
163 virtual SMDSAbs_ElementType GetType() const;
168 Class : MaxElementLength2D
169 Description : Functor calculating maximum length of 2D element
171 class SMESHCONTROLS_EXPORT MaxElementLength2D: public virtual NumericalFunctor{
173 virtual double GetValue( long theElementId );
174 virtual double GetValue( const TSequenceOfXYZ& P );
175 virtual double GetBadRate( double Value, int nbNodes ) const;
176 virtual SMDSAbs_ElementType GetType() const;
181 Class : MaxElementLength3D
182 Description : Functor calculating maximum length of 3D element
184 class SMESHCONTROLS_EXPORT MaxElementLength3D: public virtual NumericalFunctor{
186 virtual double GetValue( long theElementId );
187 virtual double GetBadRate( double Value, int nbNodes ) const;
188 virtual SMDSAbs_ElementType GetType() const;
193 Class : SMESH_MinimumAngle
194 Description : Functor for calculation of minimum angle
196 class SMESHCONTROLS_EXPORT MinimumAngle: public virtual NumericalFunctor{
198 virtual double GetValue( const TSequenceOfXYZ& thePoints );
199 virtual double GetBadRate( double Value, int nbNodes ) const;
200 virtual SMDSAbs_ElementType GetType() const;
206 Description : Functor for calculating aspect ratio
208 class SMESHCONTROLS_EXPORT AspectRatio: public virtual NumericalFunctor{
210 virtual double GetValue( long theElementId );
211 virtual double GetValue( const TSequenceOfXYZ& thePoints );
212 virtual double GetBadRate( double Value, int nbNodes ) const;
213 virtual SMDSAbs_ElementType GetType() const;
218 Class : AspectRatio3D
219 Description : Functor for calculating aspect ratio of 3D elems.
221 class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
223 virtual double GetValue( long theElementId );
224 virtual double GetValue( const TSequenceOfXYZ& thePoints );
225 virtual double GetBadRate( double Value, int nbNodes ) const;
226 virtual SMDSAbs_ElementType GetType() const;
232 Description : Functor for calculating warping
234 class SMESHCONTROLS_EXPORT Warping: public virtual NumericalFunctor{
236 virtual double GetValue( const TSequenceOfXYZ& thePoints );
237 virtual double GetBadRate( double Value, int nbNodes ) const;
238 virtual SMDSAbs_ElementType GetType() const;
241 double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
247 Description : Functor for calculating taper
249 class SMESHCONTROLS_EXPORT Taper: public virtual NumericalFunctor{
251 virtual double GetValue( const TSequenceOfXYZ& thePoints );
252 virtual double GetBadRate( double Value, int nbNodes ) const;
253 virtual SMDSAbs_ElementType GetType() const;
258 Description : Functor for calculating skew in degrees
260 class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
262 virtual double GetValue( const TSequenceOfXYZ& thePoints );
263 virtual double GetBadRate( double Value, int nbNodes ) const;
264 virtual SMDSAbs_ElementType GetType() const;
270 Description : Functor for calculating area
272 class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
274 virtual double GetValue( const TSequenceOfXYZ& thePoints );
275 virtual double GetBadRate( double Value, int nbNodes ) const;
276 virtual SMDSAbs_ElementType GetType() const;
282 Description : Functor for calculating length of edge
284 class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
286 virtual double GetValue( const TSequenceOfXYZ& thePoints );
287 virtual double GetBadRate( double Value, int nbNodes ) const;
288 virtual SMDSAbs_ElementType GetType() const;
293 Description : Functor for calculating length of edge
295 class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
297 virtual double GetValue( long theElementId );
298 virtual double GetBadRate( double Value, int nbNodes ) const;
299 virtual SMDSAbs_ElementType GetType() const;
303 Value(double theLength, long thePntId1, long thePntId2);
304 bool operator<(const Value& x) const;
306 typedef std::set<Value> TValues;
307 void GetValues(TValues& theValues);
309 typedef boost::shared_ptr<Length2D> Length2DPtr;
312 Class : MultiConnection
313 Description : Functor for calculating number of faces connected to the edge
315 class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
317 virtual double GetValue( long theElementId );
318 virtual double GetValue( const TSequenceOfXYZ& thePoints );
319 virtual double GetBadRate( double Value, int nbNodes ) const;
320 virtual SMDSAbs_ElementType GetType() const;
324 Class : MultiConnection2D
325 Description : Functor for calculating number of faces connected to the edge
327 class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
329 virtual double GetValue( long theElementId );
330 virtual double GetValue( const TSequenceOfXYZ& thePoints );
331 virtual double GetBadRate( double Value, int nbNodes ) const;
332 virtual SMDSAbs_ElementType GetType() const;
335 Value(long thePntId1, long thePntId2);
336 bool operator<(const Value& x) const;
338 typedef std::map<Value,int> MValues;
340 void GetValues(MValues& theValues);
342 typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
346 Description : Functor returning diameter of a ball element
348 class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{
350 virtual double GetValue( long theElementId );
351 virtual double GetBadRate( double Value, int nbNodes ) const;
352 virtual SMDSAbs_ElementType GetType() const;
360 Class : CoincidentNodes
361 Description : Predicate of Coincident Nodes
362 Note : This class is suitable only for visualization of Coincident Nodes
364 class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
367 //virtual Predicate* clone() const { return new CoincidentNodes( *this ); }
368 virtual void SetMesh( const SMDS_Mesh* theMesh );
369 virtual bool IsSatisfy( long theElementId );
370 virtual SMDSAbs_ElementType GetType() const;
372 void SetTolerance (const double theToler) { myToler = theToler; }
373 double GetTolerance () const { return myToler; }
377 TColStd_MapOfInteger myCoincidentIDs;
378 TMeshModifTracer myMeshModifTracer;
380 typedef boost::shared_ptr<CoincidentNodes> CoincidentNodesPtr;
383 Class : CoincidentElements
384 Description : Predicate of Coincident Elements
385 Note : This class is suitable only for visualization of Coincident Elements
387 class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate {
389 CoincidentElements();
390 virtual void SetMesh( const SMDS_Mesh* theMesh );
391 virtual bool IsSatisfy( long theElementId );
394 const SMDS_Mesh* myMesh;
396 class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
398 virtual SMDSAbs_ElementType GetType() const;
399 //virtual Predicate* clone() const { return new CoincidentElements1D( *this ); }
401 class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
403 virtual SMDSAbs_ElementType GetType() const;
404 //virtual Predicate* clone() const { return new CoincidentElements2D( *this ); }
406 class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
408 virtual SMDSAbs_ElementType GetType() const;
409 //virtual Predicate* clone() const { return new CoincidentElements3D( *this ); }
414 Description : Predicate for free borders
416 class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
419 //virtual Predicate* clone() const { return new FreeBorders( *this ); }
420 virtual void SetMesh( const SMDS_Mesh* theMesh );
421 virtual bool IsSatisfy( long theElementId );
422 virtual SMDSAbs_ElementType GetType() const;
425 const SMDS_Mesh* myMesh;
430 Class : BadOrientedVolume
431 Description : Predicate bad oriented volumes
433 class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
436 //virtual Predicate* clone() const { return new BadOrientedVolume( *this ); }
437 virtual void SetMesh( const SMDS_Mesh* theMesh );
438 virtual bool IsSatisfy( long theElementId );
439 virtual SMDSAbs_ElementType GetType() const;
442 const SMDS_Mesh* myMesh;
446 Class : ElemEntityType
447 Description : Functor for calculating entity type
449 class SMESHCONTROLS_EXPORT ElemEntityType: public virtual Predicate{
452 //virtual Predicate* clone() const { return new ElemEntityType( *this ); }
453 virtual void SetMesh( const SMDS_Mesh* theMesh );
454 virtual bool IsSatisfy( long theElementId );
455 void SetType( SMDSAbs_ElementType theType );
456 virtual SMDSAbs_ElementType GetType() const;
457 void SetElemEntityType( SMDSAbs_EntityType theEntityType );
458 SMDSAbs_EntityType GetElemEntityType() const;
461 const SMDS_Mesh* myMesh;
462 SMDSAbs_ElementType myType;
463 SMDSAbs_EntityType myEntityType;
465 typedef boost::shared_ptr<ElemEntityType> ElemEntityTypePtr;
471 class SMESHCONTROLS_EXPORT BareBorderVolume: public Predicate
474 BareBorderVolume():myMesh(0) {}
475 virtual Predicate* clone() const { return new BareBorderVolume( *this ); }
476 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
477 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
478 virtual bool IsSatisfy( long theElementId );
480 const SMDS_Mesh* myMesh;
482 typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
487 class SMESHCONTROLS_EXPORT BareBorderFace: public Predicate
490 BareBorderFace():myMesh(0) {}
491 //virtual Predicate* clone() const { return new BareBorderFace( *this ); }
492 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
493 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
494 virtual bool IsSatisfy( long theElementId );
496 const SMDS_Mesh* myMesh;
497 std::vector< const SMDS_MeshNode* > myLinkNodes;
499 typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
502 OverConstrainedVolume
504 class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
507 OverConstrainedVolume():myMesh(0) {}
508 virtual Predicate* clone() const { return new OverConstrainedVolume( *this ); }
509 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
510 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
511 virtual bool IsSatisfy( long theElementId );
513 const SMDS_Mesh* myMesh;
515 typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
520 class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
523 OverConstrainedFace():myMesh(0) {}
524 //virtual Predicate* clone() const { return new OverConstrainedFace( *this ); }
525 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
526 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
527 virtual bool IsSatisfy( long theElementId );
529 const SMDS_Mesh* myMesh;
531 typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
535 Description : Predicate for free Edges
537 class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
540 //virtual Predicate* clone() const { return new FreeEdges( *this ); }
541 virtual void SetMesh( const SMDS_Mesh* theMesh );
542 virtual bool IsSatisfy( long theElementId );
543 virtual SMDSAbs_ElementType GetType() const;
544 static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId );
545 typedef long TElemId;
549 Border(long theElemId, long thePntId1, long thePntId2);
550 bool operator<(const Border& x) const;
552 typedef std::set<Border> TBorders;
553 void GetBoreders(TBorders& theBorders);
556 const SMDS_Mesh* myMesh;
558 typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
563 Description : Predicate for free nodes
565 class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
568 //virtual Predicate* clone() const { return new FreeNodes( *this ); }
569 virtual void SetMesh( const SMDS_Mesh* theMesh );
570 virtual bool IsSatisfy( long theNodeId );
571 virtual SMDSAbs_ElementType GetType() const;
574 const SMDS_Mesh* myMesh;
580 Description : Predicate for Range of Ids.
581 Range may be specified with two ways.
582 1. Using AddToRange method
583 2. With SetRangeStr method. Parameter of this method is a string
584 like as "1,2,3,50-60,63,67,70-"
586 class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
590 //virtual Predicate* clone() const { return new RangeOfIds( *this ); }
591 virtual void SetMesh( const SMDS_Mesh* theMesh );
592 virtual bool IsSatisfy( long theNodeId );
593 virtual SMDSAbs_ElementType GetType() const;
594 virtual void SetType( SMDSAbs_ElementType theType );
596 bool AddToRange( long theEntityId );
597 void GetRangeStr( TCollection_AsciiString& );
598 bool SetRangeStr( const TCollection_AsciiString& );
601 const SMDS_Mesh* myMesh;
603 TColStd_SequenceOfInteger myMin;
604 TColStd_SequenceOfInteger myMax;
605 TColStd_MapOfInteger myIds;
607 SMDSAbs_ElementType myType;
610 typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
615 Description : Base class for comparators
617 class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
620 virtual ~Comparator();
621 virtual void SetMesh( const SMDS_Mesh* theMesh );
622 virtual void SetMargin(double theValue);
623 virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
624 virtual bool IsSatisfy( long theElementId ) = 0;
625 virtual SMDSAbs_ElementType GetType() const;
630 NumericalFunctorPtr myFunctor;
632 typedef boost::shared_ptr<Comparator> ComparatorPtr;
637 Description : Comparator "<"
639 class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
641 virtual bool IsSatisfy( long theElementId );
642 //virtual Predicate* clone() const { return new LessThan( *this ); }
648 Description : Comparator ">"
650 class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
652 virtual bool IsSatisfy( long theElementId );
653 //virtual Predicate* clone() const { return new MoreThan( *this ); }
659 Description : Comparator "="
661 class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
664 //virtual Predicate* clone() const { return new EqualTo( *this ); }
665 virtual bool IsSatisfy( long theElementId );
666 virtual void SetTolerance( double theTol );
667 virtual double GetTolerance();
672 typedef boost::shared_ptr<EqualTo> EqualToPtr;
677 Description : Logical NOT predicate
679 class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
682 //virtual Predicate* clone() const { return new LogicalNOT( *this ); }
683 virtual ~LogicalNOT();
684 virtual bool IsSatisfy( long theElementId );
685 virtual void SetMesh( const SMDS_Mesh* theMesh );
686 virtual void SetPredicate(PredicatePtr thePred);
687 virtual SMDSAbs_ElementType GetType() const;
690 PredicatePtr myPredicate;
692 typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
696 Class : LogicalBinary
697 Description : Base class for binary logical predicate
699 class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
702 virtual ~LogicalBinary();
703 virtual void SetMesh( const SMDS_Mesh* theMesh );
704 virtual void SetPredicate1(PredicatePtr thePred);
705 virtual void SetPredicate2(PredicatePtr thePred);
706 virtual SMDSAbs_ElementType GetType() const;
709 PredicatePtr myPredicate1;
710 PredicatePtr myPredicate2;
712 typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
717 Description : Logical AND
719 class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
721 virtual bool IsSatisfy( long theElementId );
722 //virtual Predicate* clone() const { return new LogicalAND( *this ); }
728 Description : Logical OR
730 class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
732 virtual bool IsSatisfy( long theElementId );
733 //virtual Predicate* clone() const { return new LogicalOR( *this ); }
739 Description : Predicate for manifold part of mesh
741 class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
744 /* internal class for algorithm uses */
748 Link( SMDS_MeshNode* theNode1,
749 SMDS_MeshNode* theNode2 );
752 bool IsEqual( const ManifoldPart::Link& theLink ) const;
753 bool operator<(const ManifoldPart::Link& x) const;
755 SMDS_MeshNode* myNode1;
756 SMDS_MeshNode* myNode2;
759 bool IsEqual( const ManifoldPart::Link& theLink1,
760 const ManifoldPart::Link& theLink2 );
762 typedef std::set<ManifoldPart::Link> TMapOfLink;
763 typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
764 typedef std::vector<ManifoldPart::Link> TVectorOfLink;
765 typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
766 typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
770 //virtual Predicate* clone() const { return new ManifoldPart( *this ); }
771 virtual void SetMesh( const SMDS_Mesh* theMesh );
772 // inoke when all parameters already set
773 virtual bool IsSatisfy( long theElementId );
774 virtual SMDSAbs_ElementType GetType() const;
776 void SetAngleTolerance( const double theAngToler );
777 double GetAngleTolerance() const;
778 void SetIsOnlyManifold( const bool theIsOnly );
779 void SetStartElem( const long theStartElemId );
783 bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
784 SMDS_MeshFace* theStartFace,
785 TMapOfLink& theNonManifold,
786 TColStd_MapOfInteger& theResFaces );
787 bool isInPlane( const SMDS_MeshFace* theFace1,
788 const SMDS_MeshFace* theFace2 );
789 void expandBoundary( TMapOfLink& theMapOfBoundary,
790 TVectorOfLink& theSeqOfBoundary,
791 TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
792 TMapOfLink& theNonManifold,
793 SMDS_MeshFace* theNextFace ) const;
795 void getFacesByLink( const Link& theLink,
796 TVectorOfFacePtr& theFaces ) const;
799 const SMDS_Mesh* myMesh;
800 TColStd_MapOfInteger myMapIds;
801 TColStd_MapOfInteger myMapBadGeomIds;
802 TVectorOfFacePtr myAllFacePtr;
803 TDataMapFacePtrInt myAllFacePtrIntDMap;
805 bool myIsOnlyManifold;
809 typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
812 Class : BelongToMeshGroup
813 Description : Verify whether a mesh element is included into a mesh group
815 class SMESHCONTROLS_EXPORT BelongToMeshGroup : public virtual Predicate
819 //virtual Predicate* clone() const { return new BelongToMeshGroup( *this ); }
820 virtual void SetMesh( const SMDS_Mesh* theMesh );
821 virtual bool IsSatisfy( long theElementId );
822 virtual SMDSAbs_ElementType GetType() const;
824 void SetGroup( SMESHDS_GroupBase* g );
825 void SetStoreName( const std::string& sn );
826 const SMESHDS_GroupBase* GetGroup() const { return myGroup; }
829 SMESHDS_GroupBase* myGroup;
830 std::string myStoreName;
832 typedef boost::shared_ptr<BelongToMeshGroup> BelongToMeshGroupPtr;
835 Class : ElementsOnSurface
836 Description : Predicate elements that lying on indicated surface
839 class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
842 ~ElementsOnSurface();
843 //virtual Predicate* clone() const { return new ElementsOnSurface( *this ); }
844 virtual void SetMesh( const SMDS_Mesh* theMesh );
845 virtual bool IsSatisfy( long theElementId );
846 virtual SMDSAbs_ElementType GetType() const;
848 void SetTolerance( const double theToler );
849 double GetTolerance() const;
850 void SetSurface( const TopoDS_Shape& theShape,
851 const SMDSAbs_ElementType theType );
852 void SetUseBoundaries( bool theUse );
853 bool GetUseBoundaries() const { return myUseBoundaries; }
857 void process( const SMDS_MeshElement* theElem );
858 bool isOnSurface( const SMDS_MeshNode* theNode );
861 TMeshModifTracer myMeshModifTracer;
862 TColStd_MapOfInteger myIds;
863 SMDSAbs_ElementType myType;
866 bool myUseBoundaries;
867 GeomAPI_ProjectPointOnSurf myProjector;
870 typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
874 Class : ElementsOnShape
875 Description : Predicate elements that lying on indicated shape
878 class SMESHCONTROLS_EXPORT ElementsOnShape : public Predicate
884 virtual Predicate* clone() const;
885 virtual void SetMesh (const SMDS_Mesh* theMesh);
886 virtual bool IsSatisfy (long theElementId);
887 virtual SMDSAbs_ElementType GetType() const;
889 void SetTolerance (const double theToler);
890 double GetTolerance() const;
891 void SetAllNodes (bool theAllNodes);
892 bool GetAllNodes() const { return myAllNodesFlag; }
893 void SetShape (const TopoDS_Shape& theShape,
894 const SMDSAbs_ElementType theType);
899 struct OctreeClassifier;
901 void clearClassifiers();
902 bool getNodeIsOut( const SMDS_MeshNode* n, bool& isOut );
903 void setNodeIsOut( const SMDS_MeshNode* n, bool isOut );
905 std::vector< Classifier > myClassifiers;
906 std::vector< Classifier* > myWorkClassifiers;
907 OctreeClassifier* myOctree;
908 SMDSAbs_ElementType myType;
909 TopoDS_Shape myShape;
913 TMeshModifTracer myMeshModifTracer;
914 std::vector<bool> myNodeIsChecked;
915 std::vector<bool> myNodeIsOut;
918 typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
923 Description : Predicate for verifying whether entiy belong to
924 specified geometrical support
926 class SMESHCONTROLS_EXPORT BelongToGeom: public virtual Predicate
930 virtual Predicate* clone() const;
932 virtual void SetMesh( const SMDS_Mesh* theMesh );
933 virtual void SetGeom( const TopoDS_Shape& theShape );
935 virtual bool IsSatisfy( long theElementId );
937 virtual void SetType( SMDSAbs_ElementType theType );
938 virtual SMDSAbs_ElementType GetType() const;
940 TopoDS_Shape GetShape();
941 const SMESHDS_Mesh* GetMeshDS() const;
943 void SetTolerance( double );
944 double GetTolerance();
949 TopoDS_Shape myShape;
950 TColStd_MapOfInteger mySubShapesIDs;
951 const SMESHDS_Mesh* myMeshDS;
952 SMDSAbs_ElementType myType;
954 double myTolerance; // only if myIsSubshape == false
955 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
957 typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
961 Description : Predicate for verifying whether entiy lying or partially lying on
962 specified geometrical support
964 class SMESHCONTROLS_EXPORT LyingOnGeom: public virtual Predicate
968 virtual Predicate* clone() const;
970 virtual void SetMesh( const SMDS_Mesh* theMesh );
971 virtual void SetGeom( const TopoDS_Shape& theShape );
973 virtual bool IsSatisfy( long theElementId );
975 virtual void SetType( SMDSAbs_ElementType theType );
976 virtual SMDSAbs_ElementType GetType() const;
978 TopoDS_Shape GetShape();
979 const SMESHDS_Mesh* GetMeshDS() const;
981 void SetTolerance( double );
982 double GetTolerance();
987 TopoDS_Shape myShape;
988 TColStd_MapOfInteger mySubShapesIDs;
989 const SMESHDS_Mesh* myMeshDS;
990 SMDSAbs_ElementType myType;
992 double myTolerance; // only if myIsSubshape == false
993 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
995 typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
999 Description : Predicate for free faces
1001 class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
1004 //virtual Predicate* clone() const { return new FreeFaces( *this ); }
1005 virtual void SetMesh( const SMDS_Mesh* theMesh );
1006 virtual bool IsSatisfy( long theElementId );
1007 virtual SMDSAbs_ElementType GetType() const;
1010 const SMDS_Mesh* myMesh;
1014 Class : LinearOrQuadratic
1015 Description : Predicate for free faces
1017 class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
1019 LinearOrQuadratic();
1020 //virtual Predicate* clone() const { return new LinearOrQuadratic( *this ); }
1021 virtual void SetMesh( const SMDS_Mesh* theMesh );
1022 virtual bool IsSatisfy( long theElementId );
1023 void SetType( SMDSAbs_ElementType theType );
1024 virtual SMDSAbs_ElementType GetType() const;
1027 const SMDS_Mesh* myMesh;
1028 SMDSAbs_ElementType myType;
1030 typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
1034 Description : Functor for check color of group to whic mesh element belongs to
1036 class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
1039 //virtual Predicate* clone() const { return new GroupColor( *this ); }
1040 virtual void SetMesh( const SMDS_Mesh* theMesh );
1041 virtual bool IsSatisfy( long theElementId );
1042 void SetType( SMDSAbs_ElementType theType );
1043 virtual SMDSAbs_ElementType GetType() const;
1044 void SetColorStr( const TCollection_AsciiString& );
1045 void GetColorStr( TCollection_AsciiString& ) const;
1048 typedef std::set< long > TIDs;
1050 Quantity_Color myColor;
1051 SMDSAbs_ElementType myType;
1054 typedef boost::shared_ptr<GroupColor> GroupColorPtr;
1057 Class : ElemGeomType
1058 Description : Predicate to check element geometry type
1060 class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
1063 //virtual Predicate* clone() const { return new ElemGeomType( *this ); }
1064 virtual void SetMesh( const SMDS_Mesh* theMesh );
1065 virtual bool IsSatisfy( long theElementId );
1066 void SetType( SMDSAbs_ElementType theType );
1067 virtual SMDSAbs_ElementType GetType() const;
1068 void SetGeomType( SMDSAbs_GeometryType theType );
1069 SMDSAbs_GeometryType GetGeomType() const;
1072 const SMDS_Mesh* myMesh;
1073 SMDSAbs_ElementType myType;
1074 SMDSAbs_GeometryType myGeomType;
1076 typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
1079 Class : CoplanarFaces
1080 Description : Predicate to check angle between faces
1082 class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
1086 //virtual Predicate* clone() const { return new CoplanarFaces( *this ); }
1087 void SetFace( long theID ) { myFaceID = theID; }
1088 long GetFace() const { return myFaceID; }
1089 void SetTolerance (const double theToler) { myToler = theToler; }
1090 double GetTolerance () const { return myToler; }
1091 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
1093 virtual void SetMesh( const SMDS_Mesh* theMesh );
1094 virtual bool IsSatisfy( long theElementId );
1097 TMeshModifTracer myMeshModifTracer;
1100 TColStd_MapOfInteger myCoplanarIDs;
1102 typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
1105 Class : ConnectedElements
1106 Description : Predicate to get elements of one domain
1108 class SMESHCONTROLS_EXPORT ConnectedElements: public virtual Predicate
1111 ConnectedElements();
1112 //virtual Predicate* clone() const { return new ConnectedElements( *this ); }
1113 void SetNode( int nodeID );
1114 void SetPoint( double x, double y, double z );
1115 int GetNode() const;
1116 std::vector<double> GetPoint() const;
1118 void SetType( SMDSAbs_ElementType theType );
1119 virtual SMDSAbs_ElementType GetType() const;
1121 virtual void SetMesh( const SMDS_Mesh* theMesh );
1122 virtual bool IsSatisfy( long theElementId );
1124 //const std::set<long>& GetDomainIDs() const { return myOkIDs; }
1128 std::vector<double> myXYZ;
1129 SMDSAbs_ElementType myType;
1130 TMeshModifTracer myMeshModifTracer;
1134 std::set< int > myOkIDs; // empty means that there is one domain
1136 typedef boost::shared_ptr<ConnectedElements> ConnectedElementsPtr;
1141 class SMESHCONTROLS_EXPORT Filter {
1145 virtual void SetPredicate(PredicatePtr thePred);
1147 typedef std::vector<long> TIdSequence;
1151 GetElementsId( const SMDS_Mesh* theMesh,
1152 TIdSequence& theSequence );
1156 GetElementsId( const SMDS_Mesh* theMesh,
1157 PredicatePtr thePredicate,
1158 TIdSequence& theSequence );
1161 PredicatePtr myPredicate;