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