facetteTraceTypes.hh

Go to the documentation of this file.
1 
11 #ifndef facetteTracetypes_hh
12 #define facetteTracetypes_hh
13 
14 #define FacetteTraceDeconstr_D 0
15 
16 
17 #include <map>
18 #include "geometry/semantics.hh"
19 #include "geometry/connectorSet.hh"
20 #include "geometry/normalVector.hh"
21 #include "toolbox/hashMap.hh"
22 
23 namespace concepts {
24 
33  template<class NormalVectorRule>
35  public:
37 
38  //by default look outward first and use first trace only
39  FacetteTraceType(): type_(FIRST), normalVectorRule_(NormalVectorRule().clone()) {}
40 
42  type_(fttype.type_), normalVectorRule_(fttype.normalVectorRule_->clone()){}
43 
44 
45  FacetteTraceType(const enum traceTypes type,const NormalVectorRule& normalVectorRule= NormalVectorRule()):
46  type_(type), normalVectorRule_(normalVectorRule.clone()){}
47 
48  virtual ~FacetteTraceType(){
49  DEBUGL(FacetteTraceDeconstr_D, "Delete done.")
50  }
51 
53  if (&fttype != this) {
54  type_ = fttype.type_;
55  normalVectorRule_.reset(fttype.normalVectorRule_->clone());
56  }
57  return *this;
58  }
59 
61  std::string typeStr() const{
62  switch(type_) {
63  case FIRST : return "FIRST"; break;
64  case MEAN : return "MEAN"; break;
65  case JUMP : return "JUMP"; break;
66  case PLUS : return "PLUS"; break;
67  case MINUS : return "MINUS"; break;
68  default: return "UNDEFINED";
69  }
70  }
71 
72  enum traceTypes type() const { return type_; }
73 
74  const NormalVectorRule& rule() const{return *normalVectorRule_;}
75 
76  protected:
77  virtual std::ostream& info(std::ostream& os) const{
78  return os << concepts::typeOf(*this)<<" ("<< typeStr() <<", "<< *normalVectorRule_<<")";
79  }
80  private :
81  //trace Type
82  enum traceTypes type_;
83  //normalvectorrule
84  std::unique_ptr< NormalVectorRule> normalVectorRule_;
85  };
86 
87 
101  template<class NormalVectorRule>
102  class FacetteTraceTypes : public Semantics<FacetteTraceType<NormalVectorRule> > {
103  public:
104 
108 
113  DEBUGL(FacetteTraceDeconstr_D, "Delete done.")
114  }
115 
124  typename std::map<uint,FacetteTraceType<NormalVectorRule> >::const_iterator i = facetteTraceTypes_.find(attrib.attrib());
125  DEBUGL(FacetteTraceDeconstr_D, "i = " << i->second)
126  assert( i != facetteTraceTypes_.end());
127  return i->second;
128  }
129 
130 
140  void add(const Attribute& attrib, const FacetteTraceType<NormalVectorRule>& fttObject){
141  facetteTraceTypes_[attrib.attrib()]= fttObject;
142  }
143 
144  void add(const Set<Attribute>& attrib, const FacetteTraceType<NormalVectorRule>& fttObject){
145  Set<Attribute>::const_iterator iter = attrib.begin();
146  for( ; iter != attrib.end(); iter++){
147  facetteTraceTypes_[iter->attrib()]= fttObject;
148  }
149  }
150 
154  Set<uint> domain() const {
156  typename std::map<uint, FacetteTraceType<NormalVectorRule> >::const_iterator iter = facetteTraceTypes_.begin();
157  for( ; iter!= facetteTraceTypes_.end();iter++){
158  domain.insert(iter->first);
159  }
160  return domain;
161  }
162 
163  protected:
164  virtual std::ostream& info(std::ostream& os) const{
165  os<< concepts::typeOf(*this)<<"["<<std::endl;
166  typename std::map<uint,FacetteTraceType<NormalVectorRule> >::const_iterator iter = facetteTraceTypes_.begin();
167  for( ; iter!= facetteTraceTypes_.end();iter++){
168  os << "Attribute("<<iter->first<<") --> "<<(facetteTraceTypes_[iter->first])<<std::endl;
169  }
170  return os<<"]";
171  }
172  private:
176  mutable std::map<uint, FacetteTraceType<NormalVectorRule> > facetteTraceTypes_;
177  };
178 
179 
180 
181 } // namespace concepts
182 
183 #endif // facetteTracetypes_hh
const NormalVectorRule & rule() const
void add(const Attribute &attrib, const FacetteTraceType< NormalVectorRule > &fttObject)
Adds an edge-traceType with this attribute to the list of facette Tracetypes.
void add(const Set< Attribute > &attrib, const FacetteTraceType< NormalVectorRule > &fttObject)
uint attrib() const
Returns the attribute.
Definition: connector.hh:38
std::string typeStr() const
Return the type of the edgeTraceType as output string.
Set with operations, output operator, and method of the particular element types.
Definition: traces.hh:18
Class FacetteTraceType holding the information about the TraceType, i.e.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
#define DEBUGL(doit, msg)
enum traceTypes type() const
#define FacetteTraceDeconstr_D
FacetteTraceType(const FacetteTraceType &fttype)
virtual FacetteTraceType< NormalVectorRule > operator()(Attribute attrib) const
Application operator.
std::unique_ptr< NormalVectorRule > normalVectorRule_
std::map< uint, FacetteTraceType< NormalVectorRule > > facetteTraceTypes_
Map from Attribute to a EdgeTraceType.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
An abstract function class to query attributes.
Definition: semantics.hh:22
FacetteTraceType(const enum traceTypes type, const NormalVectorRule &normalVectorRule=NormalVectorRule())
FacetteTraceType< NormalVectorRule > & operator=(const FacetteTraceType &fttype)
virtual ~FacetteTraceTypes()
Destructor.
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
FacetteTraceTypes()
Default constructor.
Class providing an output operator.
Set< uint > domain() const
Method returning the domain of the Map.
Attributes for elements of the topology.
Definition: connector.hh:22
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich