9 #include <stk_mesh/base/Types.hpp> 10 #include <stk_mesh/base/Part.hpp> 11 #include <stk_util/util/string_case_compare.hpp> 24 PartVector::const_iterator i = parts.begin();
26 while ( i != parts.end() &&
not_equal_case((*i)->name(),name) ) { ++i ; }
28 return i != parts.end() ? *i : NULL ;
34 print( std::ostream & os ,
const char *
const lead ,
const Part & p )
40 std::vector<Part*>::const_iterator i ;
42 if ( lead != NULL ) { os << lead ; }
50 if ( lead != NULL ) { os << lead ; }
51 os <<
" Supersets {" ;
52 for ( i = supersets.begin() ; i != supersets.end() ; ++i ) {
53 const std::string & n = (*i)->name() ; os <<
" " << n ;
55 os <<
" }" << std::endl ;
57 if ( lead != NULL ) { os << lead ; }
58 os <<
" Intersection_Of {" ;
59 for ( i = intersection.begin() ; i != intersection.end() ; ++i ) {
60 const std::string & n = (*i)->name() ; os <<
" " << n ;
62 os <<
" } }" << std::endl ;
64 if ( lead != NULL ) { os << lead ; }
66 for ( i = subsets.begin() ; i != subsets.end() ; ++i ) {
67 const std::string & n = (*i)->name() ; os <<
" " << n ;
69 os <<
" }" << std::endl ;
78 PartVector::iterator ev = v.end();
79 PartVector::iterator iv = v.begin();
81 iv = std::unique( iv , ev );
87 const PartVector::iterator e = v.end();
88 PartVector::iterator i = v.begin();
90 i = std::lower_bound( i , e , part ,
PartLess() );
92 const bool new_member = i == e || *i != & part ;
94 if ( new_member ) { v.insert( i , &part ); }
100 const PartVector::iterator e = v.end();
101 PartVector::iterator i = v.begin();
103 i = std::lower_bound( i , e , part ,
PartLess() );
105 if ( i != e && *i == & part ) { v.erase( i ); }
110 const PartVector::const_iterator e = v.end();
111 PartVector::const_iterator i = v.begin();
113 i = std::lower_bound( i , e , part ,
PartLess() );
115 return i != e && *i == & part ;
120 bool result = ( ! sub.empty() ) && ( sub.size() <= super.size() );
125 const PartVector::const_iterator ev = super.end();
126 PartVector::const_iterator iv = super.begin();
128 const PartVector::const_iterator ep = sub.end();
129 PartVector::const_iterator ip = sub.begin();
131 while ( result && ip != ep ) {
132 Part *
const q = *ip ; ++ip ;
133 iv = std::lower_bound( iv , ev , q , comp );
134 result = iv != ev && *iv == q ;
145 const PartVector::const_iterator ev = v.end();
146 PartVector::const_iterator iv = v.begin();
148 const PartVector::const_iterator ep = p.end();
149 PartVector::const_iterator ip = p.begin();
153 for ( ; ip != ep && iv != ev ; ++ip ) {
154 Part *
const q = *ip ;
155 iv = std::lower_bound( iv , ev , q ,
PartLess() );
156 if ( iv != ev && *iv == q ) { ++count ; }
166 const PartVector::const_iterator ev = v.end();
167 PartVector::const_iterator iv = v.begin();
169 const PartVector::const_iterator ep = p.end();
170 PartVector::const_iterator ip = p.begin();
172 for ( ; ip != ep && iv != ev ; ++ip ) {
173 Part *
const q = *ip ;
174 iv = std::lower_bound( iv , ev , q ,
PartLess() );
175 if ( iv != ev && *iv == q ) { r.push_back( q ); }
190 std::string convert_to_internal_name(
const std::string& part_name)
192 std::ostringstream out;
193 out << INTERNAL_PART_PREFIX << part_name << INTERNAL_PART_POSTFIX;
194 std::string out_str = out.str();
std::ostream & print(std::ostream &os, const char *const lead, const Part &p)
Print a part's information including supersets, subsets, and intersection. Each line starts with the ...
void order(PartVector &v)
Order a collection of parts: invoke sort and then unique.
bool not_equal_case(const char *lhs, const char *rhs)
Case-insensitive inequality compare.
bool contain(const PartVector &super, const PartVector &sub)
Query containment for two properly ordered PartVector.
An application-defined subset of a problem domain.
const PartVector & intersection_of() const
Parts for which this part is defined as the intersection.
bool intersect(const Part &a, const Part &b)
Query if two parts intersect; i.e., if one is a subset of the other or they share a common subset...
const std::string & name() const
Application-defined text name of this part.
unsigned mesh_meta_data_ordinal() const
Internally generated ordinal of this part that is unique within the owning meta data manager...
const PartVector & supersets() const
Parts that are supersets of this part.
Ordering operator for parts.
const PartVector & subsets() const
Parts that are subsets of this part.
std::vector< Part *> PartVector
Collections of parts are frequently maintained as a vector of Part pointers.
Part * find(const PartVector &parts, const std::string &name)
Find a part by name in a collection of parts.
bool insert(PartVector &v, Part &part)
Insert a part into a properly ordered collection of parts. Returns true if this is a new insertion...