|
Sierra Toolkit Version of the Day
|
00001 /*------------------------------------------------------------------------*/ 00002 /* Copyright 2010 Sandia Corporation. */ 00003 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */ 00004 /* license for use of this work by or on behalf of the U.S. Government. */ 00005 /* Export of this program may require a license from the */ 00006 /* United States Government. */ 00007 /*------------------------------------------------------------------------*/ 00008 00009 00010 #ifndef stk_mesh_Selector_hpp 00011 #define stk_mesh_Selector_hpp 00012 00013 #include <iosfwd> 00014 #include <stk_mesh/base/Types.hpp> 00015 00016 namespace stk { 00017 namespace mesh { 00018 00037 class Selector { 00038 public: 00040 ~Selector(); 00041 00043 Selector(); 00044 00046 Selector( const Selector & selector); 00047 00049 Selector & operator = ( const Selector & B ); 00050 00052 Selector( const Part & part); 00053 00055 Selector & operator &= ( const Selector & selector); 00056 00058 Selector & operator |= ( const Selector & selector); 00059 00063 Selector & complement(); 00064 00066 Selector operator ! () const 00067 { Selector S( *this ); return S.complement(); } 00068 00072 bool operator()( const Bucket & candidate ) const ; 00073 00077 bool operator()( const Entity & candidate ) const ; 00078 00080 friend std::ostream & operator << ( std::ostream & out, const Selector & selector); 00081 00082 private: 00083 00085 struct OpType { 00086 unsigned m_part_id ; 00087 unsigned short m_unary ; 00088 unsigned short m_count ; 00089 00090 OpType() : m_part_id(0), m_unary(0), m_count(0) {} 00091 OpType( unsigned part_id , unsigned unary , unsigned count ) 00092 : m_part_id( part_id ), m_unary( unary ), m_count( count ) {} 00093 OpType( const OpType & opType ); 00094 OpType & operator = ( const OpType & opType ); 00095 }; 00096 00098 friend class std::vector<OpType> ; 00099 00101 const MetaData * m_mesh_meta_data ; 00102 00104 std::vector< OpType > m_op ; 00105 00107 void verify_compatible( const Selector & B ) const; 00108 00110 void verify_compatible( const Bucket & B ) const; 00111 00113 bool apply( 00114 unsigned part_id , 00115 const Bucket & candidate 00116 ) const; 00117 00119 bool apply( 00120 std::vector<OpType>::const_iterator start, 00121 std::vector<OpType>::const_iterator finish, 00122 const Bucket & candidate 00123 ) const; 00124 00126 void compoundAll(); 00127 00129 std::string printExpression( 00130 const std::vector<OpType>::const_iterator start, 00131 const std::vector<OpType>::const_iterator finish 00132 ) const; 00133 00134 }; 00135 00139 Selector operator & ( const Part & A , const Part & B ); 00140 00144 Selector operator & ( const Part & A , const Selector & B ); 00145 00149 Selector operator & ( const Selector & A, const Part & B ); 00150 00154 Selector operator & ( const Selector & A, const Selector & B ); 00155 00159 Selector operator | ( const Part & A , const Part & B ); 00160 00164 Selector operator | ( const Part & A , const Selector & B ); 00165 00169 Selector operator | ( const Selector & A, const Part & B ); 00170 00174 Selector operator | ( const Selector & A , const Selector & B ); 00175 00179 Selector operator ! ( const Part & A ); 00180 00181 00185 Selector selectUnion( const PartVector& union_part_vector ); 00186 00190 Selector selectIntersection( const PartVector& intersection_part_vector ); 00191 00194 } // namespace mesh 00195 } // namespace stk 00196 00197 #endif // stk_mesh_Selector_hpp 00198