1 // Copyright (C) 2007-2021 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, smIdHasher > TIDsMap;
62 typedef NCollection_Sequence<smIdType> TIDsSeq;
67 class SMESHCONTROLS_EXPORT TSequenceOfXYZ
69 typedef std::vector<gp_XYZ>::size_type size_type;
74 explicit TSequenceOfXYZ(size_type n);
76 TSequenceOfXYZ(size_type n, const gp_XYZ& t);
78 TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ);
80 template <class InputIterator>
81 TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd);
85 TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ);
87 gp_XYZ& operator()(size_type n);
89 const gp_XYZ& operator()(size_type n) const;
93 void reserve(size_type n);
95 void push_back(const gp_XYZ& v);
97 size_type size() const;
100 void setElement(const SMDS_MeshElement* e) { myElem = e; }
102 const SMDS_MeshElement* getElement() const { return myElem; }
104 SMDSAbs_EntityType getElementEntity() const;
107 std::vector<gp_XYZ> myArray;
108 const SMDS_MeshElement* myElem;
112 * \brief Class used to detect mesh modification: IsMeshModified() returns
113 * true if a mesh has changed since last calling IsMeshModified()
115 class SMESHCONTROLS_EXPORT TMeshModifTracer
117 unsigned long myMeshModifTime;
118 const SMDS_Mesh* myMesh;
121 void SetMesh( const SMDS_Mesh* theMesh );
122 const SMDS_Mesh* GetMesh() const { return myMesh; }
123 bool IsMeshModified();
127 Class : NumericalFunctor
128 Description : Root of all Functors returning numeric value
130 class SMESHCONTROLS_EXPORT NumericalFunctor: public virtual Functor{
133 virtual void SetMesh( const SMDS_Mesh* theMesh );
134 virtual double GetValue( long theElementId );
135 virtual double GetValue(const TSequenceOfXYZ& /*thePoints*/) { return -1.0;};
136 void GetHistogram(int nbIntervals,
137 std::vector<int>& nbEvents,
138 std::vector<double>& funValues,
139 const std::vector<::smIdType>& elements,
140 const double* minmax=0,
141 const bool isLogarithmic = false);
142 bool IsApplicable( long theElementId ) const;
143 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
144 virtual SMDSAbs_ElementType GetType() const = 0;
145 virtual double GetBadRate( double Value, int nbNodes ) const = 0;
146 long GetPrecision() const;
147 void SetPrecision( const long thePrecision );
148 double Round( const double & value );
150 bool GetPoints(const ::smIdType theId, TSequenceOfXYZ& theRes) const;
151 static bool GetPoints(const SMDS_MeshElement* theElem, TSequenceOfXYZ& theRes);
153 const SMDS_Mesh* myMesh;
154 const SMDS_MeshElement* myCurrElement;
156 double myPrecisionValue;
162 Description : Functor calculating volume of 3D mesh element
164 class SMESHCONTROLS_EXPORT Volume: public virtual NumericalFunctor{
166 virtual double GetValue( long theElementId );
167 //virtual double GetValue( const TSequenceOfXYZ& thePoints );
168 virtual double GetBadRate( double Value, int nbNodes ) const;
169 virtual SMDSAbs_ElementType GetType() const;
174 Class : MaxElementLength2D
175 Description : Functor calculating maximum length of 2D element
177 class SMESHCONTROLS_EXPORT MaxElementLength2D: public virtual NumericalFunctor{
179 virtual double GetValue( long theElementId );
180 virtual double GetValue( const TSequenceOfXYZ& P );
181 virtual double GetBadRate( double Value, int nbNodes ) const;
182 virtual SMDSAbs_ElementType GetType() const;
187 Class : MaxElementLength3D
188 Description : Functor calculating maximum length of 3D element
190 class SMESHCONTROLS_EXPORT MaxElementLength3D: public virtual NumericalFunctor{
192 virtual double GetValue( long theElementId );
193 virtual double GetBadRate( double Value, int nbNodes ) const;
194 virtual SMDSAbs_ElementType GetType() const;
199 Class : SMESH_MinimumAngle
200 Description : Functor for calculation of minimum angle
202 class SMESHCONTROLS_EXPORT MinimumAngle: public virtual NumericalFunctor{
204 virtual double GetValue( const TSequenceOfXYZ& thePoints );
205 virtual double GetBadRate( double Value, int nbNodes ) const;
206 virtual SMDSAbs_ElementType GetType() const;
212 Description : Functor for calculating aspect ratio
214 class SMESHCONTROLS_EXPORT AspectRatio: public virtual NumericalFunctor{
216 virtual double GetValue( long theElementId );
217 virtual double GetValue( const TSequenceOfXYZ& thePoints );
218 virtual double GetBadRate( double Value, int nbNodes ) const;
219 virtual SMDSAbs_ElementType GetType() const;
220 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
225 Class : AspectRatio3D
226 Description : Functor for calculating aspect ratio of 3D elems.
228 class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
230 virtual double GetValue( long theElementId );
231 virtual double GetValue( const TSequenceOfXYZ& thePoints );
232 virtual double GetBadRate( double Value, int nbNodes ) const;
233 virtual SMDSAbs_ElementType GetType() const;
234 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
240 Description : Functor for calculating warping
242 class SMESHCONTROLS_EXPORT Warping: public virtual NumericalFunctor{
244 virtual double GetValue( const TSequenceOfXYZ& thePoints );
245 virtual double GetBadRate( double Value, int nbNodes ) const;
246 virtual SMDSAbs_ElementType GetType() const;
247 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
250 double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
256 Description : Functor for calculating taper
258 class SMESHCONTROLS_EXPORT Taper: public virtual NumericalFunctor{
260 virtual double GetValue( const TSequenceOfXYZ& thePoints );
261 virtual double GetBadRate( double Value, int nbNodes ) const;
262 virtual SMDSAbs_ElementType GetType() const;
263 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
268 Description : Functor for calculating skew in degrees
270 class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
272 virtual double GetValue( const TSequenceOfXYZ& thePoints );
273 virtual double GetBadRate( double Value, int nbNodes ) const;
274 virtual SMDSAbs_ElementType GetType() const;
275 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
281 Description : Functor for calculating area
283 class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
285 virtual double GetValue( const TSequenceOfXYZ& thePoints );
286 virtual double GetBadRate( double Value, int nbNodes ) const;
287 virtual SMDSAbs_ElementType GetType() const;
293 Description : Functor for calculating length of edge
295 class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
297 virtual double GetValue( const TSequenceOfXYZ& thePoints );
298 virtual double GetBadRate( double Value, int nbNodes ) const;
299 virtual SMDSAbs_ElementType GetType() const;
304 Description : Functor for calculating minimal length of edges of element
306 class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
308 Length2D( SMDSAbs_ElementType type = SMDSAbs_Face );
309 virtual bool IsApplicable( const SMDS_MeshElement* element ) const;
310 virtual double GetValue( const TSequenceOfXYZ& thePoints );
311 virtual double GetBadRate( double Value, int nbNodes ) const;
312 virtual SMDSAbs_ElementType GetType() const;
316 Value(double theLength, long thePntId1, long thePntId2);
317 bool operator<(const Value& x) const;
319 typedef std::set<Value> TValues;
320 void GetValues(TValues& theValues);
323 SMDSAbs_ElementType myType;
325 typedef boost::shared_ptr<Length2D> Length2DPtr;
329 Description : Functor for calculating minimal length of edges of 3D element
331 class SMESHCONTROLS_EXPORT Length3D: public virtual Length2D {
335 typedef boost::shared_ptr<Length3D> Length3DPtr;
339 Description : Functor for calculating distance between a face and geometry
341 class SMESHCONTROLS_EXPORT Deflection2D: public virtual NumericalFunctor{
343 virtual void SetMesh( const SMDS_Mesh* theMesh );
344 virtual double GetValue( const TSequenceOfXYZ& thePoints );
345 virtual double GetBadRate( double Value, int nbNodes ) const;
346 virtual SMDSAbs_ElementType GetType() const;
348 Handle(ShapeAnalysis_Surface) mySurface;
350 boost::shared_ptr<gp_Pln> myPlane;
354 Class : MultiConnection
355 Description : Functor for calculating number of faces connected to the edge
357 class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
359 virtual double GetValue( long theElementId );
360 virtual double GetValue( const TSequenceOfXYZ& thePoints );
361 virtual double GetBadRate( double Value, int nbNodes ) const;
362 virtual SMDSAbs_ElementType GetType() const;
366 Class : MultiConnection2D
367 Description : Functor for calculating number of faces connected to the edge
369 class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
371 virtual double GetValue( long theElementId );
372 virtual double GetValue( const TSequenceOfXYZ& thePoints );
373 virtual double GetBadRate( double Value, int nbNodes ) const;
374 virtual SMDSAbs_ElementType GetType() const;
377 Value(long thePntId1, long thePntId2);
378 bool operator<(const Value& x) const;
380 typedef std::map<Value,int> MValues;
382 void GetValues(MValues& theValues);
384 typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
388 Description : Functor returning diameter of a ball element
390 class SMESHCONTROLS_EXPORT BallDiameter: public virtual NumericalFunctor{
392 virtual double GetValue( long theElementId );
393 virtual double GetBadRate( double Value, int nbNodes ) const;
394 virtual SMDSAbs_ElementType GetType() const;
398 Class : NodeConnectivityNumber
399 Description : Functor returning number of elements connected to a node
401 class SMESHCONTROLS_EXPORT NodeConnectivityNumber: public virtual NumericalFunctor{
403 virtual double GetValue( long theNodeId );
404 virtual double GetBadRate( double Value, int nbNodes ) const;
405 virtual SMDSAbs_ElementType GetType() const;
413 Class : CoincidentNodes
414 Description : Predicate of Coincident Nodes
415 Note : This class is suitable only for visualization of Coincident Nodes
417 class SMESHCONTROLS_EXPORT CoincidentNodes: public Predicate {
420 //virtual Predicate* clone() const { return new CoincidentNodes( *this ); }
421 virtual void SetMesh( const SMDS_Mesh* theMesh );
422 virtual bool IsSatisfy( long theElementId );
423 virtual SMDSAbs_ElementType GetType() const;
425 void SetTolerance (const double theToler);
426 double GetTolerance () const { return myToler; }
430 TIDsMap myCoincidentIDs;
431 TMeshModifTracer myMeshModifTracer;
433 typedef boost::shared_ptr<CoincidentNodes> CoincidentNodesPtr;
436 Class : CoincidentElements
437 Description : Predicate of Coincident Elements
438 Note : This class is suitable only for visualization of Coincident Elements
440 class SMESHCONTROLS_EXPORT CoincidentElements: public Predicate {
442 CoincidentElements();
443 virtual void SetMesh( const SMDS_Mesh* theMesh );
444 virtual bool IsSatisfy( long theElementId );
447 const SMDS_Mesh* myMesh;
449 class SMESHCONTROLS_EXPORT CoincidentElements1D: public CoincidentElements {
451 virtual SMDSAbs_ElementType GetType() const;
452 //virtual Predicate* clone() const { return new CoincidentElements1D( *this ); }
454 class SMESHCONTROLS_EXPORT CoincidentElements2D: public CoincidentElements {
456 virtual SMDSAbs_ElementType GetType() const;
457 //virtual Predicate* clone() const { return new CoincidentElements2D( *this ); }
459 class SMESHCONTROLS_EXPORT CoincidentElements3D: public CoincidentElements {
461 virtual SMDSAbs_ElementType GetType() const;
462 //virtual Predicate* clone() const { return new CoincidentElements3D( *this ); }
467 Description : Predicate for free borders
469 class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
472 //virtual Predicate* clone() const { return new FreeBorders( *this ); }
473 virtual void SetMesh( const SMDS_Mesh* theMesh );
474 virtual bool IsSatisfy( long theElementId );
475 virtual SMDSAbs_ElementType GetType() const;
478 const SMDS_Mesh* myMesh;
483 Class : BadOrientedVolume
484 Description : Predicate bad oriented volumes
486 class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
489 //virtual Predicate* clone() const { return new BadOrientedVolume( *this ); }
490 virtual void SetMesh( const SMDS_Mesh* theMesh );
491 virtual bool IsSatisfy( long theElementId );
492 virtual SMDSAbs_ElementType GetType() const;
495 const SMDS_Mesh* myMesh;
499 Class : ElemEntityType
500 Description : Functor for calculating entity type
502 class SMESHCONTROLS_EXPORT ElemEntityType: public virtual Predicate{
505 //virtual Predicate* clone() const { return new ElemEntityType( *this ); }
506 virtual void SetMesh( const SMDS_Mesh* theMesh );
507 virtual bool IsSatisfy( long theElementId );
508 void SetType( SMDSAbs_ElementType theType );
509 virtual SMDSAbs_ElementType GetType() const;
510 void SetElemEntityType( SMDSAbs_EntityType theEntityType );
511 SMDSAbs_EntityType GetElemEntityType() const;
514 const SMDS_Mesh* myMesh;
515 SMDSAbs_ElementType myType;
516 SMDSAbs_EntityType myEntityType;
518 typedef boost::shared_ptr<ElemEntityType> ElemEntityTypePtr;
524 class SMESHCONTROLS_EXPORT BareBorderVolume: public Predicate
527 BareBorderVolume():myMesh(0) {}
528 virtual Predicate* clone() const { return new BareBorderVolume( *this ); }
529 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
530 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
531 virtual bool IsSatisfy( long theElementId );
533 const SMDS_Mesh* myMesh;
535 typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
540 class SMESHCONTROLS_EXPORT BareBorderFace: public Predicate
543 BareBorderFace():myMesh(0) {}
544 //virtual Predicate* clone() const { return new BareBorderFace( *this ); }
545 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
546 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
547 virtual bool IsSatisfy( long theElementId );
549 const SMDS_Mesh* myMesh;
550 std::vector< const SMDS_MeshNode* > myLinkNodes;
552 typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
555 OverConstrainedVolume
557 class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
560 OverConstrainedVolume():myMesh(0) {}
561 virtual Predicate* clone() const { return new OverConstrainedVolume( *this ); }
562 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
563 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Volume; }
564 virtual bool IsSatisfy( long theElementId );
566 const SMDS_Mesh* myMesh;
568 typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
573 class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
576 OverConstrainedFace():myMesh(0) {}
577 //virtual Predicate* clone() const { return new OverConstrainedFace( *this ); }
578 virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
579 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
580 virtual bool IsSatisfy( long theElementId );
582 const SMDS_Mesh* myMesh;
584 typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
588 Description : Predicate for free Edges
590 class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
593 //virtual Predicate* clone() const { return new FreeEdges( *this ); }
594 virtual void SetMesh( const SMDS_Mesh* theMesh );
595 virtual bool IsSatisfy( long theElementId );
596 virtual SMDSAbs_ElementType GetType() const;
597 static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const ::smIdType theFaceId );
598 typedef long TElemId;
602 Border(long theElemId, long thePntId1, long thePntId2);
603 bool operator<(const Border& x) const;
605 typedef std::set<Border> TBorders;
606 void GetBoreders(TBorders& theBorders);
609 const SMDS_Mesh* myMesh;
611 typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
616 Description : Predicate for free nodes
618 class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
621 //virtual Predicate* clone() const { return new FreeNodes( *this ); }
622 virtual void SetMesh( const SMDS_Mesh* theMesh );
623 virtual bool IsSatisfy( long theNodeId );
624 virtual SMDSAbs_ElementType GetType() const;
627 const SMDS_Mesh* myMesh;
633 Description : Predicate for Range of Ids.
634 Range may be specified with two ways.
635 1. Using AddToRange method
636 2. With SetRangeStr method. Parameter of this method is a string
637 like as "1,2,3,50-60,63,67,70-"
639 class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
643 //virtual Predicate* clone() const { return new RangeOfIds( *this ); }
644 virtual void SetMesh( const SMDS_Mesh* theMesh );
645 virtual bool IsSatisfy( long theNodeId );
646 virtual SMDSAbs_ElementType GetType() const;
647 virtual void SetType( SMDSAbs_ElementType theType );
649 bool AddToRange( long theEntityId );
650 void GetRangeStr( TCollection_AsciiString& );
651 bool SetRangeStr( const TCollection_AsciiString& );
654 const SMDS_Mesh* myMesh;
656 std::vector< ::smIdType > myMin;
657 std::vector< ::smIdType > myMax;
660 SMDSAbs_ElementType myType;
663 typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
668 Description : Base class for comparators
670 class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
673 virtual ~Comparator();
674 virtual void SetMesh( const SMDS_Mesh* theMesh );
675 virtual void SetMargin(double theValue);
676 virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
677 virtual bool IsSatisfy( long theElementId ) = 0;
678 virtual SMDSAbs_ElementType GetType() const;
683 NumericalFunctorPtr myFunctor;
685 typedef boost::shared_ptr<Comparator> ComparatorPtr;
690 Description : Comparator "<"
692 class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
694 virtual bool IsSatisfy( long theElementId );
695 //virtual Predicate* clone() const { return new LessThan( *this ); }
701 Description : Comparator ">"
703 class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
705 virtual bool IsSatisfy( long theElementId );
706 //virtual Predicate* clone() const { return new MoreThan( *this ); }
712 Description : Comparator "="
714 class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
717 //virtual Predicate* clone() const { return new EqualTo( *this ); }
718 virtual bool IsSatisfy( long theElementId );
719 virtual void SetTolerance( double theTol );
720 virtual double GetTolerance();
725 typedef boost::shared_ptr<EqualTo> EqualToPtr;
730 Description : Logical NOT predicate
732 class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
735 //virtual Predicate* clone() const { return new LogicalNOT( *this ); }
736 virtual ~LogicalNOT();
737 virtual bool IsSatisfy( long theElementId );
738 virtual void SetMesh( const SMDS_Mesh* theMesh );
739 virtual void SetPredicate(PredicatePtr thePred);
740 virtual SMDSAbs_ElementType GetType() const;
743 PredicatePtr myPredicate;
745 typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
749 Class : LogicalBinary
750 Description : Base class for binary logical predicate
752 class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
755 virtual ~LogicalBinary();
756 virtual void SetMesh( const SMDS_Mesh* theMesh );
757 virtual void SetPredicate1(PredicatePtr thePred);
758 virtual void SetPredicate2(PredicatePtr thePred);
759 virtual SMDSAbs_ElementType GetType() const;
762 PredicatePtr myPredicate1;
763 PredicatePtr myPredicate2;
765 typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
770 Description : Logical AND
772 class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
774 virtual bool IsSatisfy( long theElementId );
775 //virtual Predicate* clone() const { return new LogicalAND( *this ); }
781 Description : Logical OR
783 class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
785 virtual bool IsSatisfy( long theElementId );
786 //virtual Predicate* clone() const { return new LogicalOR( *this ); }
792 Description : Predicate for manifold part of mesh
794 class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
797 /* internal class for algorithm uses */
801 Link( SMDS_MeshNode* theNode1,
802 SMDS_MeshNode* theNode2 );
805 bool IsEqual( const ManifoldPart::Link& theLink ) const;
806 bool operator<(const ManifoldPart::Link& x) const;
808 SMDS_MeshNode* myNode1;
809 SMDS_MeshNode* myNode2;
812 bool IsEqual( const ManifoldPart::Link& theLink1,
813 const ManifoldPart::Link& theLink2 );
815 typedef std::set<ManifoldPart::Link> TMapOfLink;
816 typedef std::vector<SMDS_MeshFace*> TVectorOfFacePtr;
817 typedef std::vector<ManifoldPart::Link> TVectorOfLink;
818 typedef std::map<SMDS_MeshFace*,int> TDataMapFacePtrInt;
819 typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
823 //virtual Predicate* clone() const { return new ManifoldPart( *this ); }
824 virtual void SetMesh( const SMDS_Mesh* theMesh );
825 // invoke when all parameters already set
826 virtual bool IsSatisfy( long theElementId );
827 virtual SMDSAbs_ElementType GetType() const;
829 void SetAngleTolerance( const double theAngToler );
830 double GetAngleTolerance() const;
831 void SetIsOnlyManifold( const bool theIsOnly );
832 void SetStartElem( const long theStartElemId );
836 bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
837 SMDS_MeshFace* theStartFace,
838 TMapOfLink& theNonManifold,
839 TIDsMap& theResFaces );
840 bool isInPlane( const SMDS_MeshFace* theFace1,
841 const SMDS_MeshFace* theFace2 );
842 void expandBoundary( TMapOfLink& theMapOfBoundary,
843 TVectorOfLink& theSeqOfBoundary,
844 TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
845 TMapOfLink& theNonManifold,
846 SMDS_MeshFace* theNextFace ) const;
848 void getFacesByLink( const Link& theLink,
849 TVectorOfFacePtr& theFaces ) const;
852 const SMDS_Mesh* myMesh;
854 TIDsMap myMapBadGeomIds;
855 TVectorOfFacePtr myAllFacePtr;
856 TDataMapFacePtrInt myAllFacePtrIntDMap;
858 bool myIsOnlyManifold;
862 typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
865 Class : BelongToMeshGroup
866 Description : Verify whether a mesh element is included into a mesh group
868 class SMESHCONTROLS_EXPORT BelongToMeshGroup : public virtual Predicate
872 //virtual Predicate* clone() const { return new BelongToMeshGroup( *this ); }
873 virtual void SetMesh( const SMDS_Mesh* theMesh );
874 virtual bool IsSatisfy( long theElementId );
875 virtual SMDSAbs_ElementType GetType() const;
877 void SetGroup( SMESHDS_GroupBase* g );
878 void SetStoreName( const std::string& sn );
879 const SMESHDS_GroupBase* GetGroup() const { return myGroup; }
882 SMESHDS_GroupBase* myGroup;
883 std::string myStoreName;
885 typedef boost::shared_ptr<BelongToMeshGroup> BelongToMeshGroupPtr;
888 Class : ElementsOnSurface
889 Description : Predicate elements that lying on indicated surface
892 class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
895 ~ElementsOnSurface();
896 //virtual Predicate* clone() const { return new ElementsOnSurface( *this ); }
897 virtual void SetMesh( const SMDS_Mesh* theMesh );
898 virtual bool IsSatisfy( long theElementId );
899 virtual SMDSAbs_ElementType GetType() const;
901 void SetTolerance( const double theToler );
902 double GetTolerance() const;
903 void SetSurface( const TopoDS_Shape& theShape,
904 const SMDSAbs_ElementType theType );
905 void SetUseBoundaries( bool theUse );
906 bool GetUseBoundaries() const { return myUseBoundaries; }
910 void process( const SMDS_MeshElement* theElem );
911 bool isOnSurface( const SMDS_MeshNode* theNode );
914 TMeshModifTracer myMeshModifTracer;
916 SMDSAbs_ElementType myType;
919 bool myUseBoundaries;
920 GeomAPI_ProjectPointOnSurf myProjector;
923 typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
927 Class : ElementsOnShape
928 Description : Predicate elements that lying on indicated shape
931 class SMESHCONTROLS_EXPORT ElementsOnShape : public Predicate
937 virtual Predicate* clone() const;
938 virtual void SetMesh (const SMDS_Mesh* theMesh);
939 virtual bool IsSatisfy (long theElementId);
940 virtual SMDSAbs_ElementType GetType() const;
942 void SetTolerance (const double theToler);
943 double GetTolerance() const;
944 void SetAllNodes (bool theAllNodes);
945 bool GetAllNodes() const { return myAllNodesFlag; }
946 void SetShape (const TopoDS_Shape& theShape,
947 const SMDSAbs_ElementType theType);
948 bool IsSatisfy (const SMDS_MeshElement* elem);
949 bool IsSatisfy (const SMDS_MeshNode* node, TopoDS_Shape* okShape=0);
954 struct OctreeClassifier;
956 void clearClassifiers();
957 bool getNodeIsOut( const SMDS_MeshNode* n, bool& isOut );
958 void setNodeIsOut( const SMDS_MeshNode* n, bool isOut );
960 std::vector< Classifier > myClassifiers;
961 std::vector< Classifier* > myWorkClassifiers;
962 OctreeClassifier* myOctree;
963 SMDSAbs_ElementType myType;
964 TopoDS_Shape myShape;
968 TMeshModifTracer myMeshModifTracer;
969 std::vector<bool> myNodeIsChecked;
970 std::vector<bool> myNodeIsOut;
973 typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
978 Description : Predicate for verifying whether entiy belong to
979 specified geometrical support
981 class SMESHCONTROLS_EXPORT BelongToGeom: public virtual Predicate
985 virtual Predicate* clone() const;
987 virtual void SetMesh( const SMDS_Mesh* theMesh );
988 virtual void SetGeom( const TopoDS_Shape& theShape );
990 virtual bool IsSatisfy( long theElementId );
992 virtual void SetType( SMDSAbs_ElementType theType );
993 virtual SMDSAbs_ElementType GetType() const;
995 TopoDS_Shape GetShape();
996 const SMESHDS_Mesh* GetMeshDS() const;
998 void SetTolerance( double );
999 double GetTolerance();
1002 virtual void init();
1004 TopoDS_Shape myShape;
1005 TColStd_MapOfInteger mySubShapesIDs;
1006 const SMESHDS_Mesh* myMeshDS;
1007 SMDSAbs_ElementType myType;
1009 double myTolerance; // only if myIsSubshape == false
1010 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
1012 typedef boost::shared_ptr<BelongToGeom> BelongToGeomPtr;
1016 Description : Predicate for verifying whether entiy lying or partially lying on
1017 specified geometrical support
1019 class SMESHCONTROLS_EXPORT LyingOnGeom: public virtual Predicate
1023 virtual Predicate* clone() const;
1025 virtual void SetMesh( const SMDS_Mesh* theMesh );
1026 virtual void SetGeom( const TopoDS_Shape& theShape );
1028 virtual bool IsSatisfy( long theElementId );
1030 virtual void SetType( SMDSAbs_ElementType theType );
1031 virtual SMDSAbs_ElementType GetType() const;
1033 TopoDS_Shape GetShape();
1034 const SMESHDS_Mesh* GetMeshDS() const;
1036 void SetTolerance( double );
1037 double GetTolerance();
1040 virtual void init();
1042 TopoDS_Shape myShape;
1043 TColStd_MapOfInteger mySubShapesIDs;
1044 const SMESHDS_Mesh* myMeshDS;
1045 SMDSAbs_ElementType myType;
1047 double myTolerance; // only if myIsSubshape == false
1048 Controls::ElementsOnShapePtr myElementsOnShapePtr; // only if myIsSubshape == false
1050 typedef boost::shared_ptr<LyingOnGeom> LyingOnGeomPtr;
1054 Description : Predicate for free faces
1056 class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
1059 //virtual Predicate* clone() const { return new FreeFaces( *this ); }
1060 virtual void SetMesh( const SMDS_Mesh* theMesh );
1061 virtual bool IsSatisfy( long theElementId );
1062 virtual SMDSAbs_ElementType GetType() const;
1065 const SMDS_Mesh* myMesh;
1069 Class : LinearOrQuadratic
1070 Description : Predicate for free faces
1072 class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
1074 LinearOrQuadratic();
1075 //virtual Predicate* clone() const { return new LinearOrQuadratic( *this ); }
1076 virtual void SetMesh( const SMDS_Mesh* theMesh );
1077 virtual bool IsSatisfy( long theElementId );
1078 void SetType( SMDSAbs_ElementType theType );
1079 virtual SMDSAbs_ElementType GetType() const;
1082 const SMDS_Mesh* myMesh;
1083 SMDSAbs_ElementType myType;
1085 typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
1089 Description : Functor for check color of group to which mesh element belongs to
1091 class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
1094 //virtual Predicate* clone() const { return new GroupColor( *this ); }
1095 virtual void SetMesh( const SMDS_Mesh* theMesh );
1096 virtual bool IsSatisfy( long theElementId );
1097 void SetType( SMDSAbs_ElementType theType );
1098 virtual SMDSAbs_ElementType GetType() const;
1099 void SetColorStr( const TCollection_AsciiString& );
1100 void GetColorStr( TCollection_AsciiString& ) const;
1103 typedef std::set< long > TIDs;
1105 Quantity_Color myColor;
1106 SMDSAbs_ElementType myType;
1109 typedef boost::shared_ptr<GroupColor> GroupColorPtr;
1112 Class : ElemGeomType
1113 Description : Predicate to check element geometry type
1115 class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
1118 //virtual Predicate* clone() const { return new ElemGeomType( *this ); }
1119 virtual void SetMesh( const SMDS_Mesh* theMesh );
1120 virtual bool IsSatisfy( long theElementId );
1121 void SetType( SMDSAbs_ElementType theType );
1122 virtual SMDSAbs_ElementType GetType() const;
1123 void SetGeomType( SMDSAbs_GeometryType theType );
1124 SMDSAbs_GeometryType GetGeomType() const;
1127 const SMDS_Mesh* myMesh;
1128 SMDSAbs_ElementType myType;
1129 SMDSAbs_GeometryType myGeomType;
1131 typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
1134 Class : CoplanarFaces
1135 Description : Predicate to check angle between faces
1137 class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
1141 //virtual Predicate* clone() const { return new CoplanarFaces( *this ); }
1142 void SetFace( long theID ) { myFaceID = theID; }
1143 long GetFace() const { return myFaceID; }
1144 void SetTolerance (const double theToler) { myToler = theToler; }
1145 double GetTolerance () const { return myToler; }
1146 virtual SMDSAbs_ElementType GetType() const { return SMDSAbs_Face; }
1148 virtual void SetMesh( const SMDS_Mesh* theMesh );
1149 virtual bool IsSatisfy( long theElementId );
1152 TMeshModifTracer myMeshModifTracer;
1155 TIDsMap myCoplanarIDs;
1157 typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
1160 Class : ConnectedElements
1161 Description : Predicate to get elements of one domain
1163 class SMESHCONTROLS_EXPORT ConnectedElements: public virtual Predicate
1166 ConnectedElements();
1167 //virtual Predicate* clone() const { return new ConnectedElements( *this ); }
1168 void SetNode( ::smIdType nodeID );
1169 void SetPoint( double x, double y, double z );
1170 ::smIdType GetNode() const;
1171 std::vector<double> GetPoint() const;
1173 void SetType( SMDSAbs_ElementType theType );
1174 virtual SMDSAbs_ElementType GetType() const;
1176 virtual void SetMesh( const SMDS_Mesh* theMesh );
1177 virtual bool IsSatisfy( long theElementId );
1179 //const std::set<long>& GetDomainIDs() const { return myOkIDs; }
1182 ::smIdType myNodeID;
1183 std::vector<double> myXYZ;
1184 SMDSAbs_ElementType myType;
1185 TMeshModifTracer myMeshModifTracer;
1189 std::set<::smIdType> myOkIDs; // empty means that there is one domain
1191 typedef boost::shared_ptr<ConnectedElements> ConnectedElementsPtr;
1196 class SMESHCONTROLS_EXPORT Filter {
1200 virtual void SetPredicate(PredicatePtr thePred);
1202 typedef std::vector<long> TIdSequence;
1206 GetElementsId( const SMDS_Mesh* theMesh,
1207 TIdSequence& theSequence,
1208 SMDS_ElemIteratorPtr theElements=0);
1212 GetElementsId( const SMDS_Mesh* theMesh,
1213 PredicatePtr thePredicate,
1214 TIdSequence& theSequence,
1215 SMDS_ElemIteratorPtr theElements=0 );
1218 PredicatePtr myPredicate;