Use static member variable to avoid creation and allow binding to const&

parent c2acc628
Pipeline #2100 passed with stage
in 23 minutes 11 seconds
......@@ -219,7 +219,11 @@ public:
virtual std::vector<GFace *> faces() const { return std::vector<GFace *>(); }
// edges that bound this entity or that this entity bounds.
virtual std::vector<GEdge *> edges() const { return std::vector<GEdge *>(); }
virtual std::vector<GEdge *> const &edges() const
{
static std::vector<GEdge *> i;
return i;
}
// vertices that bound this entity.
virtual std::vector<GVertex *> vertices() const
......
......@@ -106,7 +106,7 @@ public:
// edges that bound the face
int delEdge(GEdge *edge);
virtual std::vector<GEdge *> edges() const { return l_edges; }
virtual std::vector<GEdge *> const &edges() const { return l_edges; }
void set(const std::vector<GEdge *> &f) { l_edges = f; }
void setOrientations(const std::vector<int> &f) { l_dirs = f; }
void setEdge(GEdge *const f, int const orientation)
......
......@@ -385,16 +385,17 @@ void GRegion::writeGEO(FILE *fp)
}
}
std::vector<GEdge*> GRegion::edges() const
std::vector<GEdge*> const &GRegion::edges() const
{
// TODO C++11 clean this up
std::vector<GEdge*> e;
static std::vector<GEdge*> e;
e.clear();
std::vector<GFace*>::const_iterator it = l_faces.begin();
while(it != l_faces.end()){
std::vector<GEdge*> e2 = (*it)->edges();
std::vector<GEdge*> const &e2 = (*it)->edges();
std::vector<GEdge*>::const_iterator it2 = e2.begin();
while (it2 != e2.end()){
GEdge *edge = *it2;
GEdge *const edge = *it2;
if(std::find(e.begin(), e.end(), edge) == e.end())
e.push_back(edge);
++it2;
......
......@@ -83,7 +83,7 @@ public:
virtual std::vector<GFace *> embeddedFaces() const { return embedded_faces; }
// edges that bound the region
virtual std::vector<GEdge *> edges() const;
virtual std::vector<GEdge *> const &edges() const;
// vertices that bound the region
virtual std::vector<GVertex *> vertices() const;
......
......@@ -50,7 +50,7 @@ public:
virtual std::list<GRegion *> regions() const;
// get the edges that this vertex bounds
virtual std::vector<GEdge *> edges() const { return l_edges; }
virtual std::vector<GEdge *> const &edges() const { return l_edges; }
// faces that bound this entity or that this entity bounds.
virtual std::vector<GFace *> faces() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment