topology.hh

Go to the documentation of this file.
1 
7 #ifndef topology_hh
8 #define topology_hh
9 
10 #include <memory>
11 #include <map>
12 #include "basics/typedefs.hh"
13 #include "basics/Zm.hh"
14 #include "basics/debug.hh"
16 #include "connector.hh"
17 #include "quadsubdiv.hh"
18 #include "strategyChange.hh"
19 
20 #define VertexConstr_D 0
21 
22 namespace concepts {
23 
24  // ***************************************************************** match **
25 
30  int match(const Connector1& edg0, const Connector1& edg1, int idx[]);
31 
32 
33  // **************************************************************** Vertex **
34 
40  class Vertex : public Connector0 {
41  public:
45  }
46 
47  virtual ~Vertex();
48 
49  virtual Vertex* child(uint i, bool mode = 0) { return this; }
50  virtual const Vertex* child(uint) const { return this; }
51 
55  inline Vertex* clone() const;
56  protected:
57  virtual std::ostream& info(std::ostream& os) const;
58  private:
61  };
62 
63  Vertex* Vertex::clone() const {
64  return new Vertex(attrib(), key());
65  }
66 
67  // ****************************************************************** Edge **
68 
73  class Edge : public Connector1 {
74 
75  public:
82  Edge(Vertex& vtx0, Vertex& vtx1, const Attribute attrib = Attribute());
84  Edge(Edge& edg0, Edge& edg1);
85  virtual ~Edge();
86 
100  virtual Edge* child(uint i, bool mode = 0);
101  virtual const Edge* child(uint i) const;
102 
103  Vertex* vertex(uint i) const { return i < 2 ? vtx_[i] : 0; }
104 
108  inline Edge* clone(Vertex& vtx0, Vertex& vtx1) const;
109  protected:
111  Edge(Vertex& vtx0, Vertex& vtx1, const Attribute attrib, const Key& key);
112 
113  virtual std::ostream& info(std::ostream& os) const;
116 
121 
124 
129  bool regular_;
130  };
131 
132  Edge* Edge::clone(Vertex& vtx0, Vertex& vtx1) const {
133  return new Edge(vtx0, vtx1, attrib(), key());
134  }
135 
136  // ********************************************************** InfiniteEdge **
137 
143  class InfiniteEdge : public Connector1 {
144 
145  public:
152  virtual ~InfiniteEdge();
153 
165  virtual Connector1* child(uint i, bool mode = 0);
166  virtual const Connector1* child(uint i) const;
167 
168  Vertex* vertex(uint i = 0) const { return i < 1 ? vtx_ : 0; }
169  protected:
170  virtual std::ostream& info(std::ostream& os) const;
173 
178 
181  };
182 
183  // ************************************************************** Triangle **
184 
193  class Triangle : public Connector2 {
194  public:
206  Triangle(Edge& edg0, Edge& edg1, Edge& edg2,
207  const Attribute attrib = Attribute());
208  virtual ~Triangle();
209 
221  virtual Triangle* child(uint i, bool mode = 0);
222  virtual const Triangle* child(uint i) const;
223 
224  Edge* edge(uint i) const { return i < 3 ? edg_[i] : 0; }
225  Vertex* vertex(uint i) const { return i<3 ? edg_[i]->vertex(rho_[i]) : 0; }
226 
230  Z2 rho(int i) const { return rho_[i]; }
231 
235  inline Triangle* clone(Edge& edg0, Edge& edg1, Edge& edg2) const;
236  protected:
237  virtual std::ostream& info(std::ostream& os) const;
238  private:
240  Triangle(Edge& edg0, Edge& edg1, Edge& edg2,
241  const Attribute attrib, const Key& key, const Z2 rho[]);
242 
245 
250 
252  Edge* edg_[3];
253 
255  Z2 rho_[3];
256  };
257 
258  Triangle* Triangle::clone(Edge& edg0, Edge& edg1, Edge& edg2) const {
259  return new Triangle(edg0, edg1, edg2, attrib(), key(), rho_);
260  }
261 
262  // ****************************************************************** Quad **
263 
272  class Quad : public Connector2 {
273  friend class QuadSubdiv4;
274  friend class QuadSubdiv2H;
275  friend class QuadSubdiv2V;
276  public:
290  Quad(Edge& edg0, Edge& edg1, Edge& edg2, Edge& edg3,
291  const Attribute attrib = Attribute());
297  Quad(const Quad& quad, uint i);
299  virtual ~Quad();
300 
313  virtual Quad* child(uint i, bool mode = 0);
314  virtual const Quad* child(uint i) const;
315 
316  Edge* edge(uint i) const { return i < 4 ? edg_[i] : 0; }
317  Vertex* vertex(uint i) const { return i<4 ? edg_[i]->vertex(rho_[i]) : 0; }
318 
319  int numVertices() const {
320  return 4;
321  }
322 
323  int numEdges() const {
324  return 4;
325  }
326 
334  Z2 rho(int i) const { return rho_[i]; }
335 
336  bool regular() const { return regular_; }
337 
341  inline Quad* clone(Edge& edg0, Edge& edg1, Edge& edg2, Edge& edg3) const;
342 
354  void setStrategy(const QuadSubdivision* strategy = 0)
355  throw(StrategyChange);
356 
362  const QuadSubdivision* getStrategy() const { return subdivStrategy_; }
363  protected:
364  virtual std::ostream& info(std::ostream& os) const;
365 
367  Quad(Edge& edg0, Edge& edg1, Edge& edg2, Edge& edg3,
368  const Attribute attrib, const Key& key, const Z2 rho[]);
369 
372 
374  bool regular_;
375 
377  Edge* edg_[4];
378 
380  Z2 rho_[4];
381 
383  static std::map<Key, Z2> rhoTriv_;
384 
387 
389  inline Scan<Quad>* children_() const {
390  return new concepts::PListScan<Quad>(*chld_);
391  }
392 
394  void edgeAssertion_() const;
395  };
396 
397  Quad* Quad::clone(Edge& edg0, Edge& edg1, Edge& edg2, Edge& edg3) const {
398  return new Quad(edg0, edg1, edg2, edg3, attrib(), key(), rho_);
399  }
400 
401 
402  // ********************************************************** InfiniteQuad **
403 
423  class InfiniteQuad : public Connector2 {
424  friend class InfQuadSubdiv2V;
425  public:
438  const Attribute attrib = Attribute());
440  virtual ~InfiniteQuad();
441 
454  virtual Connector2* child(uint i, bool mode = 0);
455  virtual const Connector2* child(uint i) const;
456 
457  Connector1* edge(uint i) const;
458  Vertex* vertex(uint i) const { return i<2 ? infEdg_[i]->vertex() : 0; }
459 
460  int numVertices() const {
461  return 2;
462  }
463 
464  int numEdges() const {
465  return 3;
466  }
467 
473  Z2 rho() const { return rho_; }
474 
478  inline InfiniteQuad* clone(InfiniteEdge& edg0, Edge& edg1,
479  InfiniteEdge& edg2) const;
480 
492  void setStrategy(const InfQuadSubdivision* strategy = 0)
493  throw(StrategyChange);
494 
500  const InfQuadSubdivision* getStrategy() const { return subdivStrategy_; }
501  protected:
502  virtual std::ostream& info(std::ostream& os) const;
503 
506  const Attribute attrib, const Key& key, const Z2 rho);
507 
510 
513 
516 
519 
522 
524  inline Scan<Connector2>* children_() const {
526  }
527 
529  void edgeAssertion_() const;
530 };
531 
533  InfiniteEdge& edg2) const {
534  return new InfiniteQuad(edg0, edg1, edg2, attrib(), key(), rho_);
535  }
536 
537 } // namespace concepts
538 
539 #endif
virtual const Quad * child(uint i) const
Triangle(Edge &edg0, Edge &edg1, Edge &edg2, const Attribute attrib=Attribute())
Constructor.
Scan< Connector2 > * children_() const
Scanner over the children.
Definition: topology.hh:524
virtual const Connector2 * child(uint i) const
Quad(Edge &edg0, Edge &edg1, Edge &edg2, Edge &edg3, const Attribute attrib, const Key &key, const Z2 rho[])
Constructor used by clone()
const InfQuadSubdivision * subdivStrategy_
Subdivision strategy for the quadrilateral.
Definition: topology.hh:521
Z2 rho_
Orientation flags for the finite edge.
Definition: topology.hh:518
Edge * edg_
Finite edge.
Definition: topology.hh:512
InfiniteQuad(InfiniteEdge &edg0, Edge &edg1, InfiniteEdge &edg2, const Attribute attrib, const Key &key, const Z2 rho)
Constructor used by clone()
virtual Connector2 * child(uint i, bool mode=0)
Returns a child.
Edge(Edge &edg0, Edge &edg1)
Construct a "parent" edge of the edges edg0 and edg1.
void edgeAssertion_() const
Assert, that the vertices of the four edges match properly.
virtual Connector1 * child(uint i, bool mode=0)
Returns a child.
const Attribute & attrib() const
Returns the attribute of the connector.
Definition: connector.hh:108
Edge * edg_[3]
Array of the edges.
Definition: topology.hh:252
virtual Quad * child(uint i, bool mode=0)
Returns a child.
Z2 rho_[3]
Array of the orientation flags for the edges.
Definition: topology.hh:255
Edge * chld_
Pointer to the first child.
Definition: topology.hh:120
A infinite quadrilateral in the topology, which possess one Edge and two InfiniteEdges since one edge...
Definition: topology.hh:423
Subdivision strategy for infinite quadrilaterals which generates two children which are infinite quad...
Definition: quadsubdiv.hh:182
A quadrilateral in the topology.
Definition: topology.hh:272
virtual const Triangle * child(uint i) const
Interface for topological subdivision strategies for quadrilaterals.
Definition: quadsubdiv.hh:37
Edge(Vertex &vtx0, Vertex &vtx1, const Attribute attrib, const Key &key)
Constructor used by clone()
Joiner class with multiple successors, i.e.
int numEdges() const
Definition: topology.hh:323
Edge * lnk_
Pointer to a sibling.
Definition: topology.hh:115
virtual ~Quad()
Destructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
int numEdges() const
Definition: topology.hh:464
InfiniteQuad * clone(InfiniteEdge &edg0, Edge &edg1, InfiniteEdge &edg2) const
Returns the pointer of a new Quad with the same attribute, the same key and the same rho but NO child...
Definition: topology.hh:532
Quad(const Quad &quad, uint i)
Creating of intermediate cells through coalescing of two of the four childs (only for subdivision in ...
Exception indicating that changing the subdivision strategy is not allowed (but was tried anyway).
Edge * edge(uint i) const
Returns a 1D component: edge.
Definition: topology.hh:224
InfiniteEdge(Vertex &vtx, const Attribute attrib=Attribute())
Constructor.
virtual const Connector1 * child(uint i) const
Scan< Quad > * children_() const
Scanner over the children.
Definition: topology.hh:389
Subdivision strategy for quadrilaterals which generates two children.
Definition: quadsubdiv.hh:117
#define DEBUGL(doit, msg)
Vertex * vertex(uint i) const
Returns a 0D component: vertex A 2D element consists of 1D and 0D elements, the vertices can be queri...
Definition: topology.hh:458
const QuadSubdivision * getStrategy() const
Returns the subdivision strategy of this quad.
Definition: topology.hh:362
Edge * edge(uint i) const
Returns a 1D component: edge.
Definition: topology.hh:316
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
bool regular_
Regular Cell, deleting of children possible.
Definition: topology.hh:374
Z2 rho_[4]
Array of the orientation flags for the edges.
Definition: topology.hh:380
Z2 rho(int i) const
Returns the orientation of an edge.
Definition: topology.hh:334
const Key & key() const
Returns the key of the connector.
Definition: connector.hh:105
const InfQuadSubdivision * getStrategy() const
Returns the subdivision strategy of this quad.
Definition: topology.hh:500
bool regular() const
Definition: topology.hh:336
A vertex in the topology.
Definition: topology.hh:40
An infinite edge in the topology, which possess only one vertex as the other lies in the infinite.
Definition: topology.hh:143
Edge * clone(Vertex &vtx0, Vertex &vtx1) const
Returns the pointer of a new Edge with the same attribute, the same key but NO children and sibling.
Definition: topology.hh:132
A 2D element of the topology.
Definition: connector.hh:226
int numVertices() const
Definition: topology.hh:319
virtual const Vertex * child(uint) const
Definition: topology.hh:50
virtual Vertex * child(uint i, bool mode=0)
Returns the ith child of the connector.
Definition: topology.hh:49
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Vertex * vertex(uint i=0) const
Returns a 0D component: vertex A 1D element consists of 0D elements, the vertices can be queried here...
Definition: topology.hh:168
An abstract class for scanning a mesh (a set of cells) or a space (a set of elements).
concepts::Joiner< Connector2 *, 1 > * chld_
List of Pointers to the children.
Definition: topology.hh:509
static std::map< Key, Z2 > rhoTriv_
orientation of trivial edges (with idential vertices)
Definition: topology.hh:383
Triangle(Edge &edg0, Edge &edg1, Edge &edg2, const Attribute attrib, const Key &key, const Z2 rho[])
Constructor used by clone()
Vertex * vtx_[2]
Array of the vertices.
Definition: topology.hh:123
Vertex * clone() const
Returns the pointer of a new vertex with the same attribute, the same key but NO children.
Definition: topology.hh:63
Subdivision strategy for quadrilaterals which generates two children.
Definition: quadsubdiv.hh:95
Edge * lnk_
Pointer to a sibling.
Definition: topology.hh:172
bool regular_
Boolean, if its a regular edge.
Definition: topology.hh:129
A scanner for 2D connectors on the processor intersection (cap)
Definition: mesh_p.hh:45
InfiniteQuad(InfiniteEdge &edg0, Edge &edg1, InfiniteEdge &edg2, const Attribute attrib=Attribute())
Constructor.
Connector1 * edge(uint i) const
Returns a 1D component: edge.
Triangle * lnk_
Pointer to a sibling.
Definition: topology.hh:244
void edgeAssertion_() const
Assert, that the vertices of the four edges match properly.
Interface for topological subdivision strategies for infinite quadrilaterals.
Definition: quadsubdiv.hh:147
Triangle * clone(Edge &edg0, Edge &edg1, Edge &edg2) const
Returns the pointer of a new Triangle with the same attribute, the same key and the same rho but NO c...
Definition: topology.hh:258
Triangle * chld_
Pointer to the first child.
Definition: topology.hh:249
Vertex * vtx_
Array of the vertices.
Definition: topology.hh:180
A 1D element of the topology.
Definition: connector.hh:182
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual Triangle * child(uint i, bool mode=0)
Returns a child.
virtual Edge * child(uint i, bool mode=0)
Returns a child.
Z2 rho() const
Returns the orientation of the finite edge.
Definition: topology.hh:473
Edge(Vertex &vtx0, Vertex &vtx1, const Attribute attrib=Attribute())
Constructor.
Edge * edg_[4]
Array of the edges.
Definition: topology.hh:377
Vertex(const Attribute attrib, const Key &key)
Constructor used by clone()
Definition: topology.hh:60
Subdivision strategy for quadrilaterals which generates four children.
Definition: quadsubdiv.hh:73
Key class.
Definition: connector.hh:53
Binary group (algebraic): only the values 0 and 1 are represented.
Definition: Zm.hh:16
Vertex * vertex(uint i) const
Returns a 0D component: vertex A 2D element consists of 1D and 0D elements, the vertices can be queri...
Definition: topology.hh:225
Quad * clone(Edge &edg0, Edge &edg1, Edge &edg2, Edge &edg3) const
Returns the pointer of a new Quad with the same attribute, the same key and the same rho but NO child...
Definition: topology.hh:397
An edge in the topology.
Definition: topology.hh:73
Vertex(const Attribute attrib=Attribute())
Default constructor.
Definition: topology.hh:43
Quad(Edge &edg0, Edge &edg1, Edge &edg2, Edge &edg3, const Attribute attrib=Attribute())
Constructor.
void setStrategy(const InfQuadSubdivision *strategy=0)
Sets the subdivision strategy of this quad.
A triangle in the topology.
Definition: topology.hh:193
int match(const Connector1 &edg0, const Connector1 &edg1, int idx[])
Checks, if two edges has a common vertex.
#define VertexConstr_D
Definition: topology.hh:20
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Vertex * vertex(uint i) const
Returns a 0D component: vertex A 1D element consists of 0D elements, the vertices can be queried here...
Definition: topology.hh:103
virtual ~Edge()
virtual ~Vertex()
Z2 rho(int i) const
Returns the orientation of an edge.
Definition: topology.hh:230
InfiniteEdge * chld_
Pointer to the first child.
Definition: topology.hh:177
Attributes for elements of the topology.
Definition: connector.hh:22
int numVertices() const
Definition: topology.hh:460
concepts::Joiner< Quad *, 1 > * chld_
List of Pointers to the children.
Definition: topology.hh:371
const QuadSubdivision * subdivStrategy_
Subdivision strategy for the quadrilateral.
Definition: topology.hh:386
A 0D element of the topology.
Definition: connector.hh:147
virtual const Edge * child(uint i) const
InfiniteEdge * infEdg_[2]
Finite edge.
Definition: topology.hh:515
void setStrategy(const QuadSubdivision *strategy=0)
Sets the subdivision strategy of this quad.
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Vertex * vertex(uint i) const
Returns a 0D component: vertex A 2D element consists of 1D and 0D elements, the vertices can be queri...
Definition: topology.hh:317
Scanner for a list of pointers.
virtual ~InfiniteQuad()
Destructor.
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich