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 <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 > TIDsMap;
66 class SMESHCONTROLS_EXPORT TSequenceOfXYZ
68 typedef std::vector<gp_XYZ>::size_type size_type;
73 explicit TSequenceOfXYZ(size_type n);
75 TSequenceOfXYZ(size_type n, const gp_XYZ& t);
77 TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ);
79 template <class InputIterator>
80 TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd);
84 TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ);
86 gp_XYZ& operator()(size_type n);
88 const gp_XYZ& operator()(size_type n) const;
92 void reserve(size_type n);
94 void push_back(const gp_XYZ& v);
96 size_type size() const;
99 void setElement(const SMDS_MeshElement* e) { myElem = e; }
101 const SMDS_MeshElement* getElement() const { return myElem; }
103 SMDSAbs_EntityType getElementEntity() const;
106 std::vector<gp_XYZ> myArray;
107 const SMDS_MeshElement* myElem;
111 * \brief Class used to detect mesh modification: IsMeshModified() returns
112 * true if a mesh has changed since last calling IsMeshModified()
114 class SMESHCONTROLS_EXPORT TMeshModifTracer
116 unsigned long myMeshModifTime;
117 const SMDS_Mesh* myMesh;
120 void SetMesh( const SMDS_Mesh* theMesh );
121 const SMDS_Mesh* GetMesh() const { return myMesh; }
122 bool IsMeshModified();
126 Class : NumericalFunctor
127 Description : Root of all Functors returning numeric value
129 class SMESHCONTROLS_EXPORT NumericalFunctor: public virtual Functor{
132 virtual void SetMesh( const SMDS_Mesh* theMesh );
133 virtual double GetValue( long theElementId );
134 virtual double GetValue(const TSequenceOfXYZ& /*thePoints*/) { return -1.0;};
135 void GetHistogram(int nbIntervals,
136 std::vector<int>& nbEvents,
137 std::vector<double>& funValues,
138 const std::vector<smIdType>& elements,
139 const double* minmax=0,
140 const bool isLogarithmic = false);
141 bool IsApplicable( long theElementId ) const;
142 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
143 virtual SMDSAbs_ElementType GetType() const = 0;
144 virtual double GetBadRate( double Value, int nbNodes ) const = 0;
145 long GetPrecision() const;
146 void SetPrecision( const long thePrecision );
147 double Round( const double & value );
149 bool GetPoints(const smIdType theId, TSequenceOfXYZ& theRes) const;
150 static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes);
152 const SMDS_Mesh* myMesh;
153 const SMDS_MeshElement* myCurrElement;
155 double myPrecisionValue;
161 Description : Functor calculating volume of 3D mesh element
163 class SMESHCONTROLS_EXPORT Volume: public virtual NumericalFunctor{
165 virtual double GetValue( long theElementId );
166 //virtual double GetValue( const TSequenceOfXYZ& thePoints );
167 virtual double GetBadRate( double Value, int nbNodes ) const;
168 virtual SMDSAbs_ElementType GetType() const;
173 Class : MaxElementLength2D
174 Description : Functor calculating maximum length of 2D element
176 class SMESHCONTROLS_EXPORT MaxElementLength2D: public virtual NumericalFunctor{
178 virtual double GetValue( long theElementId );
179 virtual double GetValue( const TSequenceOfXYZ& P );
180 virtual double GetBadRate( double Value, int nbNodes ) const;
181 virtual SMDSAbs_ElementType GetType() const;
186 Class : MaxElementLength3D
187 Description : Functor calculating maximum length of 3D element
189 class SMESHCONTROLS_EXPORT MaxElementLength3D: public virtual NumericalFunctor{
191 virtual double GetValue( long theElementId );
192 virtual double GetBadRate( double Value, int nbNodes ) const;
193 virtual SMDSAbs_ElementType GetType() const;
198 Class : SMESH_MinimumAngle
199 Description : Functor for calculation of minimum angle
201 class SMESHCONTROLS_EXPORT MinimumAngle: public virtual NumericalFunctor{
203 virtual double GetValue( const TSequenceOfXYZ& thePoints );
204 virtual double GetBadRate( double Value, int nbNodes ) const;
205 virtual SMDSAbs_ElementType GetType() const;
211 Description : Functor for calculating aspect ratio
213 class SMESHCONTROLS_EXPORT AspectRatio: public virtual NumericalFunctor{
215 virtual double GetValue( long theElementId );
216 virtual double GetValue( const TSequenceOfXYZ& thePoints );
217 virtual double GetBadRate( double Value, int nbNodes ) const;
218 virtual SMDSAbs_ElementType GetType() const;
219 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
224 Class : AspectRatio3D
225 Description : Functor for calculating aspect ratio of 3D elems.
227 class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
229 virtual double GetValue( long theElementId );
230 virtual double GetValue( const TSequenceOfXYZ& thePoints );
231 virtual double GetBadRate( double Value, int nbNodes ) const;
232 virtual SMDSAbs_ElementType GetType() const;
233 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
239 Description : Functor for calculating warping
241 class SMESHCONTROLS_EXPORT Warping: public virtual NumericalFunctor{
243 virtual double GetValue( const TSequenceOfXYZ& thePoints );
244 virtual double GetBadRate( double Value, int nbNodes ) const;
245 virtual SMDSAbs_ElementType GetType() const;
246 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
249 double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
255 Description : Functor for calculating taper
257 class SMESHCONTROLS_EXPORT Taper: public virtual NumericalFunctor{
259 virtual double GetValue( const TSequenceOfXYZ& thePoints );
260 virtual double GetBadRate( double Value, int nbNodes ) const;
261 virtual SMDSAbs_ElementType GetType() const;
262 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
267 Description : Functor for calculating skew in degrees
269 class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
271 virtual double GetValue( const TSequenceOfXYZ& thePoints );
272 virtual double GetBadRate( double Value, int nbNodes ) const;
273 virtual SMDSAbs_ElementType GetType() const;
274 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
280 Description : Functor for calculating area
282 class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
284 virtual double GetValue( const TSequenceOfXYZ& thePoints );
285 virtual double GetBadRate( double Value, int nbNodes ) const;
286 virtual SMDSAbs_ElementType GetType() const;
292 Description : Functor for calculating length of edge
294 class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
296 virtual double GetValue( const TSequenceOfXYZ& thePoints );
297 virtual double GetBadRate( double Value, int nbNodes ) const;
298 virtual SMDSAbs_ElementType GetType() const;
303 Description : Functor for calculating minimal length of edges of element
305 class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
307 Length2D( SMDSAbs_ElementType type = SMDSAbs_Face );
308 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
309 virtual double GetValue( const TSequenceOfXYZ& thePoints );
310 virtual double GetBadRate( double Value, int nbNodes ) const;
311 virtual SMDSAbs_ElementType GetType() const;
315 Value(double theLength, long thePntId1, long thePntId2);
316 bool operator<(const Value& x) const;
318 typedef std::set<Value> TValues;
319 void GetValues(TValues& theValues);
322 SMDSAbs_ElementType myType;
324 typedef boost::shared_ptr<Length2D> Length2DPtr;
328 Description : Functor for calculating minimal length of edges of 3D element
330 class SMESHCONTROLS_EXPORT Length3D: public virtual Length2D {
334 typedef boost::shared_ptr<Length3D> Length3DPtr;
338 Description : Functor for calculating distance between a face and geometry
340 class SMESHCONTROLS_EXPORT Deflection2D: public virtual NumericalFunctor{
342 virtual void SetMesh( const SMDS_Mesh* theMesh );
343 virtual double GetValue( const TSequenceOfXYZ& thePoints );
344 virtual double GetBadRate( double Value, int nbNodes ) const;
345 virtual SMDSAbs_ElementType GetType() const;
347 Handle(ShapeAnalysis_Surface) mySurface;
349 boost::shared_ptr<gp_Pln> myPlane;
353 Class : MultiConnection
354 Description : Functor for calculating number of faces connected to the edge
356 class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
358 virtual double GetValue( long theElementId );
359 virtual double GetValue( const TSequenceOfXYZ& thePoints );
360 virtual double GetBadRate( double Value, int nbNodes ) const;
361 virtual SMDSAbs_ElementType GetType() const;
365 Class : MultiConnection2D
366 Description : Functor for calculating number of faces connected to the edge
368 class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
370 virtual double GetValue( long theElementId );
371 virtual double GetValue( const TSequenceOfXYZ& thePoints );
372 virtual double GetBadRate( double Value, int nbNodes ) const;
373 virtual SMDSAbs_ElementType GetType() const;
376 Value(long thePntId1, long thePntId2);
377 bool operator<(const Value& x) const;
379 typedef std::map<Value,int> MValues;
381 void GetValues(MValues& theValues);
383 typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
387 Description : Functor returning diameter of a ball element
389 class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{
391 virtual double GetValue( long theElementId );
392 virtual double GetBadRate( double Value, int nbNodes ) const;
393 virtual SMDSAbs_ElementType GetType() const;
397 Class : NodeConnectivityNumber
398 Description : Functor returning number of elements connected to a node
400 class SMESHCONTROLS_EXPORT NodeConnectivityNumber: public virtual NumericalFunctor{
402 virtual double GetValue( long theNodeId );
403 virtual double GetBadRate( double Value, int nbNodes ) const;
404 virtual SMDSAbs_ElementType GetType() const;
412 Class : CoincidentNodes
413 Description : Predicate of Coincident Nodes
414 Note : This class is suitable only for visualization of Coincident Nodes
416 class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
419 //virtual Predicate* clone() const { return new CoincidentNodes( *this ); }
420 virtual void SetMesh( const SMDS_Mesh* theMesh );
421 virtual bool IsSatisfy( long theElementId );
422 virtual SMDSAbs_ElementType GetType() const;
424 void SetTolerance (const double theToler);
425 double GetTolerance () const { return myToler; }
429 TIDsMap myCoincidentIDs;
430 TMeshModifTracer myMeshModifTracer;
432 typedef boost::shared_ptr<CoincidentNodes> CoincidentNodesPtr;
435 Class : CoincidentElements
436 Description : Predicate of Coincident Elements
437 Note : This class is suitable only for visualization of Coincident Elements
439 class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate {
441 CoincidentElements();
442 virtual void SetMesh( const SMDS_Mesh* theMesh );
443 virtual bool IsSatisfy( long theElementId );
446 const SMDS_Mesh* myMesh;
448 class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
450 virtual SMDSAbs_ElementType GetType() const;
451 //virtual Predicate* clone() const { return new CoincidentElements1D( *this ); }
453 class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
455 virtual SMDSAbs_ElementType GetType() const;
456 //virtual Predicate* clone() const { return new CoincidentElements2D( *this ); }
458 class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
460 virtual SMDSAbs_ElementType GetType() const;
461 //virtual Predicate* clone() const { return new CoincidentElements3D( *this ); }
466 Description : Predicate for free borders
468 class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
471 //virtual Predicate* clone() const { return new FreeBorders( *this ); }
472 virtual void SetMesh( const SMDS_Mesh* theMesh );
473 virtual bool IsSatisfy( long theElementId );
474 virtual SMDSAbs_ElementType GetType() const;
477 const SMDS_Mesh* myMesh;
482 Class : BadOrientedVolume
483 Description : Predicate bad oriented volumes
485 class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
488 //virtual Predicate* clone() const { return new BadOrientedVolume( *this ); }
489 virtual void SetMesh( const SMDS_Mesh* theMesh );
490 virtual bool IsSatisfy( long theElementId );
491 virtual SMDSAbs_ElementType GetType() const;
494 const SMDS_Mesh* myMesh;
498 Class : ElemEntityType
499 Description : Functor for calculating entity type
501 class SMESHCONTROLS_EXPORT ElemEntityType: public virtual Predicate{
504 //virtual Predicate* clone() const { return new ElemEntityType( *this ); }
505 virtual void SetMesh( const SMDS_Mesh* theMesh );
506 virtual bool IsSatisfy( long theElementId );
507 void SetType( SMDSAbs_ElementType theType );
508 virtual SMDSAbs_ElementType GetType() const;
509 void SetElemEntityType( SMDSAbs_EntityType theEntityType );
510 SMDSAbs_EntityType GetElemEntityType() const;
513 const SMDS_Mesh* myMesh;
514 SMDSAbs_ElementType myType;
515 SMDSAbs_EntityType myEntityType;
517 typedef boost::shared_ptr<ElemEntityType> ElemEntityTypePtr;
523 class SMESHCONTROLS_EXPORT BareBorderVolume: public Predicate
526 BareBorderVolume():myMesh(0) {}
527 virtual Predicate* clone() const { return new BareBorderVolume( *this ); }
528 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
529 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
530 virtual bool IsSatisfy( long theElementId );
532 const SMDS_Mesh* myMesh;
534 typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
539 class SMESHCONTROLS_EXPORT BareBorderFace: public Predicate
542 BareBorderFace():myMesh(0) {}
543 //virtual Predicate* clone() const { return new BareBorderFace( *this ); }
544 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
545 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
546 virtual bool IsSatisfy( long theElementId );
548 const SMDS_Mesh* myMesh;
549 std::vector< const SMDS_MeshNode* > myLinkNodes;
551 typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
554 OverConstrainedVolume
556 class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
559 OverConstrainedVolume():myMesh(0) {}
560 virtual Predicate* clone() const { return new OverConstrainedVolume( *this ); }
561 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
562 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
563 virtual bool IsSatisfy( long theElementId );
565 const SMDS_Mesh* myMesh;
567 typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
572 class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
575 OverConstrainedFace():myMesh(0) {}
576 //virtual Predicate* clone() const { return new OverConstrainedFace( *this ); }
577 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
578 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
579 virtual bool IsSatisfy( long theElementId );
581 const SMDS_Mesh* myMesh;
583 typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
587 Description : Predicate for free Edges
589 class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
592 //virtual Predicate* clone() const { return new FreeEdges( *this ); }
593 virtual void SetMesh( const SMDS_Mesh* theMesh );
594 virtual bool IsSatisfy( long theElementId );
595 virtual SMDSAbs_ElementType GetType() const;
596 static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const smIdType theFaceId );
597 typedef long TElemId;
601 Border(long theElemId, long thePntId1, long thePntId2);
602 bool operator<(const Border& x) const;
604 typedef std::set<Border> TBorders;
605 void GetBoreders(TBorders& theBorders);
608 const SMDS_Mesh* myMesh;
610 typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
615 Description : Predicate for free nodes
617 class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
620 //virtual Predicate* clone() const { return new FreeNodes( *this ); }
621 virtual void SetMesh( const SMDS_Mesh* theMesh );
622 virtual bool IsSatisfy( long theNodeId );
623 virtual SMDSAbs_ElementType GetType() const;
626 const SMDS_Mesh* myMesh;
632 Description : Predicate for Range of Ids.
633 Range may be specified with two ways.
634 1. Using AddToRange method
635 2. With SetRangeStr method. Parameter of this method is a string
636 like as "1,2,3,50-60,63,67,70-"
638 class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
642 //virtual Predicate* clone() const { return new RangeOfIds( *this ); }
643 virtual void SetMesh( const SMDS_Mesh* theMesh );
644 virtual bool IsSatisfy( long theNodeId );
645 virtual SMDSAbs_ElementType GetType() const;
646 virtual void SetType( SMDSAbs_ElementType theType );
648 bool AddToRange( long theEntityId );
649 void GetRangeStr( TCollection_AsciiString& );
650 bool SetRangeStr( const TCollection_AsciiString& );
653 const SMDS_Mesh* myMesh;
655 std::vector< smIdType> myMin;
656 std::vector< smIdType > myMax;
659 SMDSAbs_ElementType myType;
662 typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
667 Description : Base class for comparators
669 class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
672 virtual ~Comparator();
673 virtual void SetMesh( const SMDS_Mesh* theMesh );
674 virtual void SetMargin(double theValue);
675 virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
676 virtual bool IsSatisfy( long theElementId ) = 0;
677 virtual SMDSAbs_ElementType GetType() const;
682 NumericalFunctorPtr myFunctor;
684 typedef boost::shared_ptr<Comparator> ComparatorPtr;
689 Description : Comparator "<"
691 class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
693 virtual bool IsSatisfy( long theElementId );
694 //virtual Predicate* clone() const { return new LessThan( *this ); }
700 Description : Comparator ">"
702 class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
704 virtual bool IsSatisfy( long theElementId );
705 //virtual Predicate* clone() const { return new MoreThan( *this ); }
711 Description : Comparator "="
713 class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
716 //virtual Predicate* clone() const { return new EqualTo( *this ); }
717 virtual bool IsSatisfy( long theElementId );
718 virtual void SetTolerance( double theTol );
719 virtual double GetTolerance();
724 typedef boost::shared_ptr<EqualTo> EqualToPtr;
729 Description : Logical NOT predicate
731 class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
734 //virtual Predicate* clone() const { return new LogicalNOT( *this ); }
735 virtual ~LogicalNOT();
736 virtual bool IsSatisfy( long theElementId );
737 virtual void SetMesh( const SMDS_Mesh* theMesh );
738 virtual void SetPredicate(PredicatePtr thePred);
739 virtual SMDSAbs_ElementType GetType() const;
742 PredicatePtr myPredicate;
744 typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
748 Class : LogicalBinary
749 Description : Base class for binary logical predicate
751 class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
754 virtual ~LogicalBinary();
755 virtual void SetMesh( const SMDS_Mesh* theMesh );
756 virtual void SetPredicate1(PredicatePtr thePred);
757 virtual void SetPredicate2(PredicatePtr thePred);
758 virtual SMDSAbs_ElementType GetType() const;
761 PredicatePtr myPredicate1;
762 PredicatePtr myPredicate2;
764 typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
769 Description : Logical AND
771 class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
773 virtual bool IsSatisfy( long theElementId );
774 //virtual Predicate* clone() const { return new LogicalAND( *this ); }
780 Description : Logical OR
782 class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
784 virtual bool IsSatisfy( long theElementId );
785 //virtual Predicate* clone() const { return new LogicalOR( *this ); }
791 Description : Predicate for manifold part of mesh
793 class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
796 /* internal class for algorithm uses */
800 Link( SMDS_MeshNode* theNode1,
801 SMDS_MeshNode* theNode2 );
804 bool IsEqual( const ManifoldPart::Link& theLink ) const;
805 bool operator<(const ManifoldPart::Link& x) const;
807 SMDS_MeshNode* myNode1;
808 SMDS_MeshNode* myNode2;
811 bool IsEqual( const ManifoldPart::Link& theLink1,
812 const ManifoldPart::Link& theLink2 );
814 typedef std::set<ManifoldPart::Link> TMapOfLink;
815 typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
816 typedef std::vector<ManifoldPart::Link> TVectorOfLink;
817 typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
818 typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
822 //virtual Predicate* clone() const { return new ManifoldPart( *this ); }
823 virtual void SetMesh( const SMDS_Mesh* theMesh );
824 // invoke when all parameters already set
825 virtual bool IsSatisfy( long theElementId );
826 virtual SMDSAbs_ElementType GetType() const;
828 void SetAngleTolerance( const double theAngToler );
829 double GetAngleTolerance() const;
830 void SetIsOnlyManifold( const bool theIsOnly );
831 void SetStartElem( const long theStartElemId );
835 bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
836 SMDS_MeshFace* theStartFace,
837 TMapOfLink& theNonManifold,
838 TIDsMap& theResFaces );
839 bool isInPlane( const SMDS_MeshFace* theFace1,
840 const SMDS_MeshFace* theFace2 );
841 void expandBoundary( TMapOfLink& theMapOfBoundary,
842 TVectorOfLink& theSeqOfBoundary,
843 TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
844 TMapOfLink& theNonManifold,
845 SMDS_MeshFace* theNextFace ) const;
847 void getFacesByLink( const Link& theLink,
848 TVectorOfFacePtr& theFaces ) const;
851 const SMDS_Mesh* myMesh;
853 TIDsMap myMapBadGeomIds;
854 TVectorOfFacePtr myAllFacePtr;
855 TDataMapFacePtrInt myAllFacePtrIntDMap;
857 bool myIsOnlyManifold;
861 typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
864 Class : BelongToMeshGroup
865 Description : Verify whether a mesh element is included into a mesh group
867 class SMESHCONTROLS_EXPORT BelongToMeshGroup : public virtual Predicate
871 //virtual Predicate* clone() const { return new BelongToMeshGroup( *this ); }
872 virtual void SetMesh( const SMDS_Mesh* theMesh );
873 virtual bool IsSatisfy( long theElementId );
874 virtual SMDSAbs_ElementType GetType() const;
876 void SetGroup( SMESHDS_GroupBase* g );
877 void SetStoreName( const std::string& sn );
878 const SMESHDS_GroupBase* GetGroup() const { return myGroup; }
881 SMESHDS_GroupBase* myGroup;
882 std::string myStoreName;
884 typedef boost::shared_ptr<BelongToMeshGroup> BelongToMeshGroupPtr;
887 Class : ElementsOnSurface
888 Description : Predicate elements that lying on indicated surface
891 class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
894 ~ElementsOnSurface();
895 //virtual Predicate* clone() const { return new ElementsOnSurface( *this ); }
896 virtual void SetMesh( const SMDS_Mesh* theMesh );
897 virtual bool IsSatisfy( long theElementId );
898 virtual SMDSAbs_ElementType GetType() const;
900 void SetTolerance( const double theToler );
901 double GetTolerance() const;
902 void SetSurface( const TopoDS_Shape& theShape,
903 const SMDSAbs_ElementType theType );
904 void SetUseBoundaries( bool theUse );
905 bool GetUseBoundaries() const { return myUseBoundaries; }
909 void process( const SMDS_MeshElement* theElem );
910 bool isOnSurface( const SMDS_MeshNode* theNode );
913 TMeshModifTracer myMeshModifTracer;
915 SMDSAbs_ElementType myType;
918 bool myUseBoundaries;
919 GeomAPI_ProjectPointOnSurf myProjector;
922 typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
926 Class : ElementsOnShape
927 Description : Predicate elements that lying on indicated shape
930 class SMESHCONTROLS_EXPORT ElementsOnShape : public Predicate
936 virtual Predicate* clone() const;
937 virtual void SetMesh (const SMDS_Mesh* theMesh);
938 virtual bool IsSatisfy (long theElementId);
939 virtual SMDSAbs_ElementType GetType() const;
941 void SetTolerance (const double theToler);
942 double GetTolerance() const;
943 void SetAllNodes (bool theAllNodes);
944 bool GetAllNodes() const { return myAllNodesFlag; }
945 void SetShape (const TopoDS_Shape& theShape,
946 const SMDSAbs_ElementType theType);
947 bool IsSatisfy (const SMDS_MeshElement* elem);
948 bool IsSatisfy (const SMDS_MeshNode* node, TopoDS_Shape* okShape=0);
953 struct OctreeClassifier;
955 void clearClassifiers();
956 bool getNodeIsOut( const SMDS_MeshNode* n, bool& isOut );
957 void setNodeIsOut( const SMDS_MeshNode* n, bool isOut );
959 std::vector< Classifier > myClassifiers;
960 std::vector< Classifier* > myWorkClassifiers;
961 OctreeClassifier* myOctree;
962 SMDSAbs_ElementType myType;
963 TopoDS_Shape myShape;
967 TMeshModifTracer myMeshModifTracer;
968 std::vector<bool> myNodeIsChecked;
969 std::vector<bool> myNodeIsOut;
972 typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
977 Description : Predicate for verifying whether entiy belong to
978 specified geometrical support
980 class SMESHCONTROLS_EXPORT BelongToGeom: public virtual Predicate
984 virtual Predicate* clone() const;
986 virtual void SetMesh( const SMDS_Mesh* theMesh );
987 virtual void SetGeom( const TopoDS_Shape& theShape );
989 virtual bool IsSatisfy( long theElementId );
991 virtual void SetType( SMDSAbs_ElementType theType );
992 virtual SMDSAbs_ElementType GetType() const;
994 TopoDS_Shape GetShape();
995 const SMESHDS_Mesh* GetMeshDS() const;
997 void SetTolerance( double );
998 double GetTolerance();
1001 virtual void init();
1003 TopoDS_Shape myShape;
1004 TColStd_MapOfInteger mySubShapesIDs;
1005 const SMESHDS_Mesh* myMeshDS;
1006 SMDSAbs_ElementType myType;
1008 double myTolerance; // only if myIsSubshape == false
1009 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
1011 typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
1015 Description : Predicate for verifying whether entiy lying or partially lying on
1016 specified geometrical support
1018 class SMESHCONTROLS_EXPORT LyingOnGeom: public virtual Predicate
1022 virtual Predicate* clone() const;
1024 virtual void SetMesh( const SMDS_Mesh* theMesh );
1025 virtual void SetGeom( const TopoDS_Shape& theShape );
1027 virtual bool IsSatisfy( long theElementId );
1029 virtual void SetType( SMDSAbs_ElementType theType );
1030 virtual SMDSAbs_ElementType GetType() const;
1032 TopoDS_Shape GetShape();
1033 const SMESHDS_Mesh* GetMeshDS() const;
1035 void SetTolerance( double );
1036 double GetTolerance();
1039 virtual void init();
1041 TopoDS_Shape myShape;
1042 TColStd_MapOfInteger mySubShapesIDs;
1043 const SMESHDS_Mesh* myMeshDS;
1044 SMDSAbs_ElementType myType;
1046 double myTolerance; // only if myIsSubshape == false
1047 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
1049 typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
1053 Description : Predicate for free faces
1055 class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
1058 //virtual Predicate* clone() const { return new FreeFaces( *this ); }
1059 virtual void SetMesh( const SMDS_Mesh* theMesh );
1060 virtual bool IsSatisfy( long theElementId );
1061 virtual SMDSAbs_ElementType GetType() const;
1064 const SMDS_Mesh* myMesh;
1068 Class : LinearOrQuadratic
1069 Description : Predicate for free faces
1071 class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
1073 LinearOrQuadratic();
1074 //virtual Predicate* clone() const { return new LinearOrQuadratic( *this ); }
1075 virtual void SetMesh( const SMDS_Mesh* theMesh );
1076 virtual bool IsSatisfy( long theElementId );
1077 void SetType( SMDSAbs_ElementType theType );
1078 virtual SMDSAbs_ElementType GetType() const;
1081 const SMDS_Mesh* myMesh;
1082 SMDSAbs_ElementType myType;
1084 typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
1088 Description : Functor for check color of group to which mesh element belongs to
1090 class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
1093 //virtual Predicate* clone() const { return new GroupColor( *this ); }
1094 virtual void SetMesh( const SMDS_Mesh* theMesh );
1095 virtual bool IsSatisfy( long theElementId );
1096 void SetType( SMDSAbs_ElementType theType );
1097 virtual SMDSAbs_ElementType GetType() const;
1098 void SetColorStr( const TCollection_AsciiString& );
1099 void GetColorStr( TCollection_AsciiString& ) const;
1102 typedef std::set< long > TIDs;
1104 Quantity_Color myColor;
1105 SMDSAbs_ElementType myType;
1108 typedef boost::shared_ptr<GroupColor> GroupColorPtr;
1111 Class : ElemGeomType
1112 Description : Predicate to check element geometry type
1114 class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
1117 //virtual Predicate* clone() const { return new ElemGeomType( *this ); }
1118 virtual void SetMesh( const SMDS_Mesh* theMesh );
1119 virtual bool IsSatisfy( long theElementId );
1120 void SetType( SMDSAbs_ElementType theType );
1121 virtual SMDSAbs_ElementType GetType() const;
1122 void SetGeomType( SMDSAbs_GeometryType theType );
1123 SMDSAbs_GeometryType GetGeomType() const;
1126 const SMDS_Mesh* myMesh;
1127 SMDSAbs_ElementType myType;
1128 SMDSAbs_GeometryType myGeomType;
1130 typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
1133 Class : CoplanarFaces
1134 Description : Predicate to check angle between faces
1136 class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
1140 //virtual Predicate* clone() const { return new CoplanarFaces( *this ); }
1141 void SetFace( long theID ) { myFaceID = theID; }
1142 long GetFace() const { return myFaceID; }
1143 void SetTolerance (const double theToler) { myToler = theToler; }
1144 double GetTolerance () const { return myToler; }
1145 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
1147 virtual void SetMesh( const SMDS_Mesh* theMesh );
1148 virtual bool IsSatisfy( long theElementId );
1151 TMeshModifTracer myMeshModifTracer;
1154 TIDsMap myCoplanarIDs;
1156 typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
1159 Class : ConnectedElements
1160 Description : Predicate to get elements of one domain
1162 class SMESHCONTROLS_EXPORT ConnectedElements: public virtual Predicate
1165 ConnectedElements();
1166 //virtual Predicate* clone() const { return new ConnectedElements( *this ); }
1167 void SetNode( int nodeID );
1168 void SetPoint( double x, double y, double z );
1169 int GetNode() const;
1170 std::vector<double> GetPoint() const;
1172 void SetType( SMDSAbs_ElementType theType );
1173 virtual SMDSAbs_ElementType GetType() const;
1175 virtual void SetMesh( const SMDS_Mesh* theMesh );
1176 virtual bool IsSatisfy( long theElementId );
1178 //const std::set<long>& GetDomainIDs() const { return myOkIDs; }
1182 std::vector<double> myXYZ;
1183 SMDSAbs_ElementType myType;
1184 TMeshModifTracer myMeshModifTracer;
1188 std::set<smIdType> myOkIDs; // empty means that there is one domain
1190 typedef boost::shared_ptr<ConnectedElements> ConnectedElementsPtr;
1195 class SMESHCONTROLS_EXPORT Filter {
1199 virtual void SetPredicate(PredicatePtr thePred);
1201 typedef std::vector<long> TIdSequence;
1205 GetElementsId( const SMDS_Mesh* theMesh,
1206 TIdSequence& theSequence,
1207 SMDS_ElemIteratorPtr theElements=0);
1211 GetElementsId( const SMDS_Mesh* theMesh,
1212 PredicatePtr thePredicate,
1213 TIdSequence& theSequence,
1214 SMDS_ElemIteratorPtr theElements=0 );
1217 PredicatePtr myPredicate;