Version: 6.3.1

src/Controls/SMESH_ControlsDef.hxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #ifndef _SMESH_CONTROLSDEF_HXX_
00024 #define _SMESH_CONTROLSDEF_HXX_
00025 
00026 #include <set>
00027 #include <map>
00028 #include <vector>
00029 
00030 #include <boost/shared_ptr.hpp>
00031 
00032 #include <gp_XYZ.hxx>
00033 #include <GeomAPI_ProjectPointOnSurf.hxx>
00034 #include <GeomAPI_ProjectPointOnCurve.hxx>
00035 #include <TColStd_SequenceOfInteger.hxx>
00036 #include <TColStd_MapOfInteger.hxx>
00037 #include <TCollection_AsciiString.hxx>
00038 #include <TopAbs.hxx>
00039 #include <TopoDS_Face.hxx>
00040 #include <TopTools_MapOfShape.hxx>
00041 #include <BRepClass3d_SolidClassifier.hxx>
00042 #include <Quantity_Color.hxx>
00043 
00044 #include "SMDSAbs_ElementType.hxx"
00045 #include "SMDS_MeshNode.hxx"
00046 
00047 #include "SMESH_Controls.hxx"
00048 
00049 #ifdef WNT
00050  #if defined SMESHCONTROLS_EXPORTS || defined SMESHControls_EXPORTS
00051   #define SMESHCONTROLS_EXPORT __declspec( dllexport )
00052  #else
00053   #define SMESHCONTROLS_EXPORT __declspec( dllimport )
00054  #endif
00055 #else
00056  #define SMESHCONTROLS_EXPORT
00057 #endif
00058 
00059 class SMDS_MeshElement;
00060 class SMDS_MeshFace;
00061 class SMDS_MeshNode;
00062 class SMDS_Mesh;
00063 
00064 class SMESHDS_Mesh;
00065 class SMESHDS_SubMesh;
00066 
00067 class gp_Pnt;
00068 
00069 namespace SMESH{
00070   namespace Controls{
00071 
00072     class SMESHCONTROLS_EXPORT TSequenceOfXYZ
00073     {
00074       typedef std::vector<gp_XYZ>::size_type size_type;
00075 
00076     public:
00077       TSequenceOfXYZ();
00078 
00079       TSequenceOfXYZ(size_type n);
00080 
00081       TSequenceOfXYZ(size_type n, const gp_XYZ& t);
00082 
00083       TSequenceOfXYZ(const TSequenceOfXYZ& theSequenceOfXYZ);
00084 
00085       template <class InputIterator>
00086       TSequenceOfXYZ(InputIterator theBegin, InputIterator theEnd);
00087 
00088       ~TSequenceOfXYZ();
00089 
00090       TSequenceOfXYZ& operator=(const TSequenceOfXYZ& theSequenceOfXYZ);
00091 
00092       gp_XYZ& operator()(size_type n);
00093 
00094       const gp_XYZ& operator()(size_type n) const;
00095 
00096       void clear();
00097 
00098       void reserve(size_type n);
00099 
00100       void push_back(const gp_XYZ& v);
00101 
00102       size_type size() const;
00103 
00104     private:
00105       std::vector<gp_XYZ> myArray;
00106     };
00107 
00108     /*
00109       Class       : Functor
00110       Description : Root of all Functors
00111     */
00112     class SMESHCONTROLS_EXPORT Functor
00113     {
00114     public:
00115       ~Functor(){}
00116       virtual void SetMesh( const SMDS_Mesh* theMesh ) = 0;
00117       virtual SMDSAbs_ElementType GetType() const = 0;
00118     };
00119 
00120     /*
00121       Class       : NumericalFunctor
00122       Description : Root of all Functors returning numeric value
00123     */
00124     class SMESHCONTROLS_EXPORT NumericalFunctor: public virtual Functor{
00125     public:
00126       NumericalFunctor();
00127       virtual void SetMesh( const SMDS_Mesh* theMesh );
00128       virtual double GetValue( long theElementId );
00129       virtual double GetValue(const TSequenceOfXYZ& thePoints) { return -1.0;};
00130       void GetHistogram(int                     nbIntervals,
00131                         std::vector<int>&       nbEvents,
00132                         std::vector<double>&    funValues,
00133                         const std::vector<int>& elements,
00134                         const double*           minmax=0);
00135       virtual SMDSAbs_ElementType GetType() const = 0;
00136       virtual double GetBadRate( double Value, int nbNodes ) const = 0;
00137       long  GetPrecision() const;
00138       void  SetPrecision( const long thePrecision );
00139       double Round( const double & value );
00140       
00141       bool GetPoints(const int theId,
00142                      TSequenceOfXYZ& theRes) const;
00143       static bool GetPoints(const SMDS_MeshElement* theElem,
00144                             TSequenceOfXYZ& theRes);
00145     protected:
00146       const SMDS_Mesh*        myMesh;
00147       const SMDS_MeshElement* myCurrElement;
00148       long                    myPrecision;
00149       double                  myPrecisionValue;
00150     };
00151 
00152 
00153     /*
00154       Class       : Volume
00155       Description : Functor calculating volume of 3D mesh element
00156     */
00157     class SMESHCONTROLS_EXPORT Volume: public virtual NumericalFunctor{
00158     public:
00159       virtual double GetValue( long theElementId );
00160       //virtual double GetValue( const TSequenceOfXYZ& thePoints );
00161       virtual double GetBadRate( double Value, int nbNodes ) const;
00162       virtual SMDSAbs_ElementType GetType() const;
00163     };
00164   
00165   
00166     /*
00167       Class       : MaxElementLength2D
00168       Description : Functor calculating maximum length of 2D element
00169     */
00170     class SMESHCONTROLS_EXPORT MaxElementLength2D: public virtual NumericalFunctor{
00171     public:
00172       virtual double GetValue( long theElementId );
00173       virtual double GetBadRate( double Value, int nbNodes ) const;
00174       virtual SMDSAbs_ElementType GetType() const;
00175     };
00176   
00177   
00178     /*
00179       Class       : MaxElementLength3D
00180       Description : Functor calculating maximum length of 3D element
00181     */
00182     class SMESHCONTROLS_EXPORT MaxElementLength3D: public virtual NumericalFunctor{
00183     public:
00184       virtual double GetValue( long theElementId );
00185       virtual double GetBadRate( double Value, int nbNodes ) const;
00186       virtual SMDSAbs_ElementType GetType() const;
00187     };
00188   
00189   
00190     /*
00191       Class       : SMESH_MinimumAngle
00192       Description : Functor for calculation of minimum angle
00193     */
00194     class SMESHCONTROLS_EXPORT MinimumAngle: public virtual NumericalFunctor{
00195     public:
00196       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00197       virtual double GetBadRate( double Value, int nbNodes ) const;
00198       virtual SMDSAbs_ElementType GetType() const;
00199     };
00200   
00201   
00202     /*
00203       Class       : AspectRatio
00204       Description : Functor for calculating aspect ratio
00205     */
00206     class SMESHCONTROLS_EXPORT AspectRatio: public virtual NumericalFunctor{
00207     public:
00208       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00209       virtual double GetBadRate( double Value, int nbNodes ) const;
00210       virtual SMDSAbs_ElementType GetType() const;
00211     };
00212   
00213   
00214     /*
00215       Class       : AspectRatio3D
00216       Description : Functor for calculating aspect ratio of 3D elems.
00217     */
00218     class SMESHCONTROLS_EXPORT AspectRatio3D: public virtual NumericalFunctor{
00219     public:
00220       virtual double GetValue( long theElementId );
00221       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00222       virtual double GetBadRate( double Value, int nbNodes ) const;
00223       virtual SMDSAbs_ElementType GetType() const;
00224     };
00225   
00226   
00227     /*
00228       Class       : Warping
00229       Description : Functor for calculating warping
00230     */
00231     class SMESHCONTROLS_EXPORT Warping: public virtual NumericalFunctor{
00232     public:
00233       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00234       virtual double GetBadRate( double Value, int nbNodes ) const;
00235       virtual SMDSAbs_ElementType GetType() const;
00236       
00237     private:
00238       double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const;
00239     };
00240   
00241   
00242     /*
00243       Class       : Taper
00244       Description : Functor for calculating taper
00245     */
00246     class SMESHCONTROLS_EXPORT Taper: public virtual NumericalFunctor{
00247     public:
00248       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00249       virtual double GetBadRate( double Value, int nbNodes ) const;
00250       virtual SMDSAbs_ElementType GetType() const;
00251     };
00252 
00253 
00254     /*
00255       Class       : Skew
00256       Description : Functor for calculating skew in degrees
00257     */
00258     class SMESHCONTROLS_EXPORT Skew: public virtual NumericalFunctor{
00259     public:
00260       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00261       virtual double GetBadRate( double Value, int nbNodes ) const;
00262       virtual SMDSAbs_ElementType GetType() const;
00263     };
00264 
00265 
00266     /*
00267       Class       : Area
00268       Description : Functor for calculating area
00269     */
00270     class SMESHCONTROLS_EXPORT Area: public virtual NumericalFunctor{
00271     public:
00272       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00273       virtual double GetBadRate( double Value, int nbNodes ) const;
00274       virtual SMDSAbs_ElementType GetType() const;
00275     };
00276   
00277   
00278     /*
00279       Class       : Length
00280       Description : Functor for calculating length of edge
00281     */
00282     class SMESHCONTROLS_EXPORT Length: public virtual NumericalFunctor{
00283     public:
00284       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00285       virtual double GetBadRate( double Value, int nbNodes ) const;
00286       virtual SMDSAbs_ElementType GetType() const;
00287     };
00288 
00289     /*
00290       Class       : Length2D
00291       Description : Functor for calculating length of edge
00292     */
00293     class SMESHCONTROLS_EXPORT Length2D: public virtual NumericalFunctor{
00294     public:
00295       virtual double GetValue( long theElementId );
00296       virtual double GetBadRate( double Value, int nbNodes ) const;
00297       virtual SMDSAbs_ElementType GetType() const;
00298       struct Value{
00299         double myLength;
00300         long myPntId[2];
00301         Value(double theLength, long thePntId1, long thePntId2);
00302         bool operator<(const Value& x) const;
00303       };
00304       typedef std::set<Value> TValues;
00305       void GetValues(TValues& theValues);
00306     };
00307     typedef boost::shared_ptr<Length2D> Length2DPtr;
00308 
00309     /*
00310       Class       : MultiConnection
00311       Description : Functor for calculating number of faces conneted to the edge
00312     */
00313     class SMESHCONTROLS_EXPORT MultiConnection: public virtual NumericalFunctor{
00314     public:
00315       virtual double GetValue( long theElementId );
00316       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00317       virtual double GetBadRate( double Value, int nbNodes ) const;
00318       virtual SMDSAbs_ElementType GetType() const;
00319     };
00320     
00321     /*
00322       Class       : MultiConnection2D
00323       Description : Functor for calculating number of faces conneted to the edge
00324     */
00325     class SMESHCONTROLS_EXPORT MultiConnection2D: public virtual NumericalFunctor{
00326     public:
00327       virtual double GetValue( long theElementId );
00328       virtual double GetValue( const TSequenceOfXYZ& thePoints );
00329       virtual double GetBadRate( double Value, int nbNodes ) const;
00330       virtual SMDSAbs_ElementType GetType() const;
00331       struct Value{
00332         long myPntId[2];
00333         Value(long thePntId1, long thePntId2);
00334         bool operator<(const Value& x) const;
00335       };
00336       typedef std::map<Value,int> MValues;
00337 
00338       void GetValues(MValues& theValues);
00339     };
00340     typedef boost::shared_ptr<MultiConnection2D> MultiConnection2DPtr;
00341     /*
00342       PREDICATES
00343     */
00344     /*
00345       Class       : Predicate
00346       Description : Base class for all predicates
00347     */
00348     class SMESHCONTROLS_EXPORT Predicate: public virtual Functor{
00349     public:
00350       virtual bool IsSatisfy( long theElementId ) = 0;
00351       virtual SMDSAbs_ElementType GetType() const = 0;
00352     };
00353   
00354   
00355     /*
00356       Class       : FreeBorders
00357       Description : Predicate for free borders
00358     */
00359     class SMESHCONTROLS_EXPORT FreeBorders: public virtual Predicate{
00360     public:
00361       FreeBorders();
00362       virtual void SetMesh( const SMDS_Mesh* theMesh );
00363       virtual bool IsSatisfy( long theElementId );
00364       virtual SMDSAbs_ElementType GetType() const;
00365 
00366     protected:
00367       const SMDS_Mesh* myMesh;
00368     };
00369    
00370 
00371     /*
00372       Class       : BadOrientedVolume
00373       Description : Predicate bad oriented volumes
00374     */
00375     class SMESHCONTROLS_EXPORT BadOrientedVolume: public virtual Predicate{
00376     public:
00377       BadOrientedVolume();
00378       virtual void SetMesh( const SMDS_Mesh* theMesh );
00379       virtual bool IsSatisfy( long theElementId );
00380       virtual SMDSAbs_ElementType GetType() const;
00381 
00382     protected:
00383       const SMDS_Mesh* myMesh;
00384     };
00385 
00386     /*
00387       BareBorderVolume
00388     */
00389     class SMESHCONTROLS_EXPORT BareBorderVolume: public Predicate
00390     {
00391     public:
00392       BareBorderVolume():myMesh(0) {}
00393       virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
00394       virtual SMDSAbs_ElementType GetType() const      { return SMDSAbs_Volume; }
00395       virtual bool IsSatisfy( long theElementId );
00396     protected:
00397       const SMDS_Mesh* myMesh;
00398     };
00399     typedef boost::shared_ptr<BareBorderVolume> BareBorderVolumePtr;
00400 
00401     /*
00402       BareBorderFace
00403     */
00404     class SMESHCONTROLS_EXPORT BareBorderFace: public Predicate
00405     {
00406     public:
00407       BareBorderFace():myMesh(0) {}
00408       virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
00409       virtual SMDSAbs_ElementType GetType() const      { return SMDSAbs_Face; }
00410       virtual bool IsSatisfy( long theElementId );
00411     protected:
00412       const SMDS_Mesh* myMesh;
00413       std::vector< const SMDS_MeshNode* > myLinkNodes;
00414     };
00415     typedef boost::shared_ptr<BareBorderFace> BareBorderFacePtr;
00416 
00417     /*
00418       OverConstrainedVolume
00419     */
00420     class SMESHCONTROLS_EXPORT OverConstrainedVolume: public Predicate
00421     {
00422     public:
00423       OverConstrainedVolume():myMesh(0) {}
00424       virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
00425       virtual SMDSAbs_ElementType GetType() const      { return SMDSAbs_Volume; }
00426       virtual bool IsSatisfy( long theElementId );
00427     protected:
00428       const SMDS_Mesh* myMesh;
00429     };
00430     typedef boost::shared_ptr<OverConstrainedVolume> OverConstrainedVolumePtr;
00431 
00432     /*
00433       OverConstrainedFace
00434     */
00435     class SMESHCONTROLS_EXPORT OverConstrainedFace: public Predicate
00436     {
00437     public:
00438       OverConstrainedFace():myMesh(0) {}
00439       virtual void SetMesh( const SMDS_Mesh* theMesh ) { myMesh = theMesh; }
00440       virtual SMDSAbs_ElementType GetType() const      { return SMDSAbs_Face; }
00441       virtual bool IsSatisfy( long theElementId );
00442     protected:
00443       const SMDS_Mesh* myMesh;
00444       std::vector< const SMDS_MeshNode* > myLinkNodes;
00445     };
00446     typedef boost::shared_ptr<OverConstrainedFace> OverConstrainedFacePtr;
00447 
00448     /*
00449       Class       : FreeEdges
00450       Description : Predicate for free Edges
00451     */
00452     class SMESHCONTROLS_EXPORT FreeEdges: public virtual Predicate{
00453     public:
00454       FreeEdges();
00455       virtual void SetMesh( const SMDS_Mesh* theMesh );
00456       virtual bool IsSatisfy( long theElementId );
00457       virtual SMDSAbs_ElementType GetType() const;
00458       static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId  );
00459       typedef long TElemId;
00460       struct Border{
00461         TElemId myElemId;
00462         TElemId myPntId[2];
00463         Border(long theElemId, long thePntId1, long thePntId2);
00464         bool operator<(const Border& x) const;
00465       };
00466       typedef std::set<Border> TBorders;
00467       void GetBoreders(TBorders& theBorders);
00468 
00469     protected:
00470       const SMDS_Mesh* myMesh;
00471     };
00472     typedef boost::shared_ptr<FreeEdges> FreeEdgesPtr;
00473     
00474     
00475     /*
00476       Class       : FreeNodes
00477       Description : Predicate for free nodes
00478     */
00479     class SMESHCONTROLS_EXPORT FreeNodes: public virtual Predicate{
00480     public:
00481       FreeNodes();
00482       virtual void SetMesh( const SMDS_Mesh* theMesh );
00483       virtual bool IsSatisfy( long theNodeId );
00484       virtual SMDSAbs_ElementType GetType() const;
00485 
00486     protected:
00487       const SMDS_Mesh* myMesh;
00488     };
00489     
00490 
00491     /*
00492       Class       : RangeOfIds
00493       Description : Predicate for Range of Ids.
00494                     Range may be specified with two ways.
00495                     1. Using AddToRange method
00496                     2. With SetRangeStr method. Parameter of this method is a string
00497                        like as "1,2,3,50-60,63,67,70-"
00498     */
00499     class SMESHCONTROLS_EXPORT RangeOfIds: public virtual Predicate
00500     {
00501     public:
00502                                     RangeOfIds();
00503       virtual void                  SetMesh( const SMDS_Mesh* theMesh );
00504       virtual bool                  IsSatisfy( long theNodeId );
00505       virtual SMDSAbs_ElementType   GetType() const;
00506       virtual void                  SetType( SMDSAbs_ElementType theType );
00507 
00508       bool                          AddToRange( long theEntityId );
00509       void                          GetRangeStr( TCollection_AsciiString& );
00510       bool                          SetRangeStr( const TCollection_AsciiString& );
00511 
00512     protected:
00513       const SMDS_Mesh*              myMesh;
00514 
00515       TColStd_SequenceOfInteger     myMin;
00516       TColStd_SequenceOfInteger     myMax;
00517       TColStd_MapOfInteger          myIds;
00518 
00519       SMDSAbs_ElementType           myType;
00520     };
00521     
00522     typedef boost::shared_ptr<RangeOfIds> RangeOfIdsPtr;
00523    
00524     
00525     /*
00526       Class       : Comparator
00527       Description : Base class for comparators
00528     */
00529     class SMESHCONTROLS_EXPORT Comparator: public virtual Predicate{
00530     public:
00531       Comparator();
00532       virtual ~Comparator();
00533       virtual void SetMesh( const SMDS_Mesh* theMesh );
00534       virtual void SetMargin(double theValue);
00535       virtual void SetNumFunctor(NumericalFunctorPtr theFunct);
00536       virtual bool IsSatisfy( long theElementId ) = 0;
00537       virtual SMDSAbs_ElementType GetType() const;
00538       double  GetMargin();
00539   
00540     protected:
00541       double myMargin;
00542       NumericalFunctorPtr myFunctor;
00543     };
00544     typedef boost::shared_ptr<Comparator> ComparatorPtr;
00545   
00546   
00547     /*
00548       Class       : LessThan
00549       Description : Comparator "<"
00550     */
00551     class SMESHCONTROLS_EXPORT LessThan: public virtual Comparator{
00552     public:
00553       virtual bool IsSatisfy( long theElementId );
00554     };
00555   
00556   
00557     /*
00558       Class       : MoreThan
00559       Description : Comparator ">"
00560     */
00561     class SMESHCONTROLS_EXPORT MoreThan: public virtual Comparator{
00562     public:
00563       virtual bool IsSatisfy( long theElementId );
00564     };
00565   
00566   
00567     /*
00568       Class       : EqualTo
00569       Description : Comparator "="
00570     */
00571     class SMESHCONTROLS_EXPORT EqualTo: public virtual Comparator{
00572     public:
00573       EqualTo();
00574       virtual bool IsSatisfy( long theElementId );
00575       virtual void SetTolerance( double theTol );
00576       virtual double GetTolerance();
00577   
00578     private:
00579       double myToler;
00580     };
00581     typedef boost::shared_ptr<EqualTo> EqualToPtr;
00582   
00583     
00584     /*
00585       Class       : LogicalNOT
00586       Description : Logical NOT predicate
00587     */
00588     class SMESHCONTROLS_EXPORT LogicalNOT: public virtual Predicate{
00589     public:
00590       LogicalNOT();
00591       virtual ~LogicalNOT();
00592       virtual bool IsSatisfy( long theElementId );
00593       virtual void SetMesh( const SMDS_Mesh* theMesh );
00594       virtual void SetPredicate(PredicatePtr thePred);
00595       virtual SMDSAbs_ElementType GetType() const;
00596   
00597     private:
00598       PredicatePtr myPredicate;
00599     };
00600     typedef boost::shared_ptr<LogicalNOT> LogicalNOTPtr;
00601     
00602   
00603     /*
00604       Class       : LogicalBinary
00605       Description : Base class for binary logical predicate
00606     */
00607     class SMESHCONTROLS_EXPORT LogicalBinary: public virtual Predicate{
00608     public:
00609       LogicalBinary();
00610       virtual ~LogicalBinary();
00611       virtual void SetMesh( const SMDS_Mesh* theMesh );
00612       virtual void SetPredicate1(PredicatePtr thePred);
00613       virtual void SetPredicate2(PredicatePtr thePred);
00614       virtual SMDSAbs_ElementType GetType() const;
00615   
00616     protected:
00617       PredicatePtr myPredicate1;
00618       PredicatePtr myPredicate2;
00619     };
00620     typedef boost::shared_ptr<LogicalBinary> LogicalBinaryPtr;
00621   
00622   
00623     /*
00624       Class       : LogicalAND
00625       Description : Logical AND
00626     */
00627     class SMESHCONTROLS_EXPORT LogicalAND: public virtual LogicalBinary{
00628     public:
00629       virtual bool IsSatisfy( long theElementId );
00630     };
00631   
00632   
00633     /*
00634       Class       : LogicalOR
00635       Description : Logical OR
00636     */
00637     class SMESHCONTROLS_EXPORT LogicalOR: public virtual LogicalBinary{
00638     public:
00639       virtual bool IsSatisfy( long theElementId );
00640     };
00641   
00642   
00643     /*
00644       Class       : ManifoldPart
00645       Description : Predicate for manifold part of mesh
00646     */
00647     class SMESHCONTROLS_EXPORT ManifoldPart: public virtual Predicate{
00648     public:
00649 
00650       /* internal class for algorithm uses */
00651       class Link
00652       {
00653       public:
00654         Link( SMDS_MeshNode* theNode1,
00655               SMDS_MeshNode* theNode2 );
00656         ~Link();
00657         
00658         bool IsEqual( const ManifoldPart::Link& theLink ) const;
00659         bool operator<(const ManifoldPart::Link& x) const;
00660         
00661         SMDS_MeshNode* myNode1;
00662         SMDS_MeshNode* myNode2;
00663       };
00664 
00665       bool IsEqual( const ManifoldPart::Link& theLink1,
00666                     const ManifoldPart::Link& theLink2 );
00667       
00668       typedef std::set<ManifoldPart::Link>                TMapOfLink;
00669       typedef std::vector<SMDS_MeshFace*>                 TVectorOfFacePtr;
00670       typedef std::vector<ManifoldPart::Link>             TVectorOfLink;
00671       typedef std::map<SMDS_MeshFace*,int>                TDataMapFacePtrInt;
00672       typedef std::map<ManifoldPart::Link,SMDS_MeshFace*> TDataMapOfLinkFacePtr;
00673       
00674       ManifoldPart();
00675       ~ManifoldPart();
00676       virtual void SetMesh( const SMDS_Mesh* theMesh );
00677       // inoke when all parameters already set
00678       virtual bool IsSatisfy( long theElementId );
00679       virtual      SMDSAbs_ElementType GetType() const;
00680 
00681       void    SetAngleTolerance( const double theAngToler );
00682       double  GetAngleTolerance() const;
00683       void    SetIsOnlyManifold( const bool theIsOnly );
00684       void    SetStartElem( const long  theStartElemId );
00685 
00686     private:
00687       bool    process();
00688       bool    findConnected( const TDataMapFacePtrInt& theAllFacePtrInt,
00689                              SMDS_MeshFace*            theStartFace,
00690                              TMapOfLink&               theNonManifold,
00691                              TColStd_MapOfInteger&     theResFaces );
00692       bool    isInPlane( const SMDS_MeshFace* theFace1,
00693                           const SMDS_MeshFace* theFace2 );
00694       void    expandBoundary( TMapOfLink&            theMapOfBoundary,
00695                               TVectorOfLink&         theSeqOfBoundary,
00696                               TDataMapOfLinkFacePtr& theDMapLinkFacePtr,
00697                               TMapOfLink&            theNonManifold,
00698                               SMDS_MeshFace*         theNextFace ) const;
00699 
00700      void     getFacesByLink( const Link& theLink,
00701                               TVectorOfFacePtr& theFaces ) const;
00702 
00703     private:
00704       const SMDS_Mesh*      myMesh;
00705       TColStd_MapOfInteger  myMapIds;
00706       TColStd_MapOfInteger  myMapBadGeomIds;
00707       TVectorOfFacePtr      myAllFacePtr;
00708       TDataMapFacePtrInt    myAllFacePtrIntDMap;
00709       double                myAngToler;
00710       bool                  myIsOnlyManifold;
00711       long                  myStartElemId;
00712 
00713     };
00714     typedef boost::shared_ptr<ManifoldPart> ManifoldPartPtr;
00715 
00716 
00717     /*
00718       Class       : ElementsOnSurface
00719       Description : Predicate elements that lying on indicated surface
00720                     (plane or cylinder)
00721     */
00722     class SMESHCONTROLS_EXPORT ElementsOnSurface : public virtual Predicate {
00723     public:
00724       ElementsOnSurface();
00725       ~ElementsOnSurface();
00726       virtual void SetMesh( const SMDS_Mesh* theMesh );
00727       virtual bool IsSatisfy( long theElementId );
00728       virtual      SMDSAbs_ElementType GetType() const;
00729 
00730       void    SetTolerance( const double theToler );
00731       double  GetTolerance() const;
00732       void    SetSurface( const TopoDS_Shape& theShape,
00733                           const SMDSAbs_ElementType theType );
00734       void    SetUseBoundaries( bool theUse );
00735       bool    GetUseBoundaries() const { return myUseBoundaries; }
00736 
00737     private:
00738       void    process();
00739       void    process( const SMDS_MeshElement* theElem  );
00740       bool    isOnSurface( const SMDS_MeshNode* theNode );
00741 
00742     private:
00743       const SMDS_Mesh*      myMesh;
00744       TColStd_MapOfInteger  myIds;
00745       SMDSAbs_ElementType   myType;
00746       //Handle(Geom_Surface)  mySurf;
00747       TopoDS_Face           mySurf;
00748       double                myToler;
00749       bool                  myUseBoundaries;
00750       GeomAPI_ProjectPointOnSurf myProjector;
00751     };
00752 
00753     typedef boost::shared_ptr<ElementsOnSurface> ElementsOnSurfacePtr;
00754 
00755 
00756     /*
00757       Class       : ElementsOnShape
00758       Description : Predicate elements that lying on indicated shape
00759                     (1D, 2D or 3D)
00760     */
00761     class SMESHCONTROLS_EXPORT ElementsOnShape : public virtual Predicate
00762     {
00763     public:
00764       ElementsOnShape();
00765       ~ElementsOnShape();
00766 
00767       virtual void SetMesh (const SMDS_Mesh* theMesh);
00768       virtual bool IsSatisfy (long theElementId);
00769       virtual SMDSAbs_ElementType GetType() const;
00770 
00771       void    SetTolerance (const double theToler);
00772       double  GetTolerance() const;
00773       void    SetAllNodes (bool theAllNodes);
00774       bool    GetAllNodes() const { return myAllNodesFlag; }
00775       void    SetShape (const TopoDS_Shape& theShape,
00776                         const SMDSAbs_ElementType theType);
00777 
00778     private:
00779       void    addShape (const TopoDS_Shape& theShape);
00780       void    process();
00781       void    process (const SMDS_MeshElement* theElem);
00782 
00783     private:
00784       const SMDS_Mesh*      myMesh;
00785       TColStd_MapOfInteger  myIds;
00786       SMDSAbs_ElementType   myType;
00787       TopoDS_Shape          myShape;
00788       double                myToler;
00789       bool                  myAllNodesFlag;
00790 
00791       TopTools_MapOfShape         myShapesMap;
00792       TopAbs_ShapeEnum            myCurShapeType; // type of current sub-shape
00793       BRepClass3d_SolidClassifier myCurSC;        // current SOLID
00794       GeomAPI_ProjectPointOnSurf  myCurProjFace;  // current FACE
00795       TopoDS_Face                 myCurFace;      // current FACE
00796       GeomAPI_ProjectPointOnCurve myCurProjEdge;  // current EDGE
00797       gp_Pnt                      myCurPnt;       // current VERTEX
00798     };
00799 
00800     typedef boost::shared_ptr<ElementsOnShape> ElementsOnShapePtr;
00801 
00802 
00803     /*
00804       Class       : FreeFaces
00805       Description : Predicate for free faces
00806     */
00807     class SMESHCONTROLS_EXPORT FreeFaces: public virtual Predicate{
00808     public:
00809       FreeFaces();
00810       virtual void SetMesh( const SMDS_Mesh* theMesh );
00811       virtual bool IsSatisfy( long theElementId );
00812       virtual SMDSAbs_ElementType GetType() const;
00813 
00814     private:
00815       const SMDS_Mesh* myMesh;
00816     };
00817 
00818     /*
00819       Class       : LinearOrQuadratic
00820       Description : Predicate for free faces
00821     */
00822     class SMESHCONTROLS_EXPORT LinearOrQuadratic: public virtual Predicate{
00823     public:
00824       LinearOrQuadratic();
00825       virtual void        SetMesh( const SMDS_Mesh* theMesh );
00826       virtual bool        IsSatisfy( long theElementId );
00827       void                SetType( SMDSAbs_ElementType theType );
00828       virtual SMDSAbs_ElementType GetType() const;
00829 
00830     private:
00831       const SMDS_Mesh*    myMesh;
00832       SMDSAbs_ElementType myType;
00833     };
00834     typedef boost::shared_ptr<LinearOrQuadratic> LinearOrQuadraticPtr;
00835 
00836     /*
00837       Class       : GroupColor
00838       Description : Functor for check color of group to whic mesh element belongs to
00839     */
00840     class SMESHCONTROLS_EXPORT GroupColor: public virtual Predicate{
00841     public:
00842       GroupColor();
00843       virtual void        SetMesh( const SMDS_Mesh* theMesh );
00844       virtual bool        IsSatisfy( long theElementId );
00845       void                SetType( SMDSAbs_ElementType theType );
00846       virtual             SMDSAbs_ElementType GetType() const;
00847       void                SetColorStr( const TCollection_AsciiString& );
00848       void                GetColorStr( TCollection_AsciiString& ) const;
00849       
00850     private:
00851       typedef std::set< long > TIDs;
00852 
00853       Quantity_Color      myColor;
00854       SMDSAbs_ElementType myType;
00855       TIDs                myIDs;
00856     };
00857     typedef boost::shared_ptr<GroupColor> GroupColorPtr;
00858 
00859     /*
00860       Class       : ElemGeomType
00861       Description : Predicate to check element geometry type
00862     */
00863     class SMESHCONTROLS_EXPORT ElemGeomType: public virtual Predicate{
00864     public:
00865       ElemGeomType();
00866       virtual void         SetMesh( const SMDS_Mesh* theMesh );
00867       virtual bool         IsSatisfy( long theElementId );
00868       void                 SetType( SMDSAbs_ElementType theType );
00869       virtual              SMDSAbs_ElementType GetType() const;
00870       void                 SetGeomType( SMDSAbs_GeometryType theType );
00871       virtual SMDSAbs_GeometryType GetGeomType() const;
00872 
00873     private:
00874       const SMDS_Mesh*     myMesh;
00875       SMDSAbs_ElementType  myType;
00876       SMDSAbs_GeometryType myGeomType;
00877     };
00878     typedef boost::shared_ptr<ElemGeomType> ElemGeomTypePtr;
00879 
00880     /*
00881       Class       : CoplanarFaces
00882       Description : Predicate to check angle between faces
00883     */
00884     class SMESHCONTROLS_EXPORT CoplanarFaces: public virtual Predicate
00885     {
00886     public:
00887       CoplanarFaces();
00888       void                 SetFace( long theID )                   { myFaceID = theID; }
00889       long                 GetFace() const                         { return myFaceID; }
00890       void                 SetTolerance (const double theToler)    { myToler = theToler; }
00891       double               GetTolerance () const                   { return myToler; }
00892       virtual void         SetMesh( const SMDS_Mesh* theMesh )     { myMesh = theMesh; }
00893       virtual              SMDSAbs_ElementType GetType() const     { return SMDSAbs_Face; }
00894 
00895       virtual bool         IsSatisfy( long theElementId );
00896 
00897     private:
00898       const SMDS_Mesh*     myMesh;
00899       long                 myFaceID;
00900       double               myToler;
00901       std::set< long >     myCoplanarIDs;
00902     };
00903     typedef boost::shared_ptr<CoplanarFaces> CoplanarFacesPtr;
00904 
00905     /*
00906       FILTER
00907     */
00908     class SMESHCONTROLS_EXPORT Filter{
00909     public:
00910       Filter();
00911       virtual ~Filter();
00912       virtual void SetPredicate(PredicatePtr thePred);
00913 
00914       typedef std::vector<long> TIdSequence;
00915 
00916       virtual
00917       void
00918       GetElementsId( const SMDS_Mesh* theMesh,
00919                      TIdSequence& theSequence );
00920 
00921       static
00922       void
00923       GetElementsId( const SMDS_Mesh* theMesh,
00924                      PredicatePtr thePredicate,
00925                      TIdSequence& theSequence );
00926       
00927     protected:
00928       PredicatePtr myPredicate;
00929     };
00930   };
00931 };
00932 
00933 
00934 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS