Commit de89b8ca authored by Philip Trettner's avatar Philip Trettner
Browse files

fixed weird iterators, fixed missing reserve, fixed face::add for arrays

parent 3a4da622
......@@ -11,6 +11,11 @@ inline face_index low_level_api_mutable::alloc_face() const { return m.alloc_fac
inline edge_index low_level_api_mutable::alloc_edge() const { return m.alloc_edge(); }
inline void low_level_api_mutable::alloc_primitives(int vertices, int faces, int halfedges) const { m.alloc_primitives(vertices, faces, halfedges); }
inline void low_level_api_mutable::reserve_vertices(int capacity) const { m.reserve_vertices(capacity); }
inline void low_level_api_mutable::reserve_edges(int capacity) const { m.reserve_edges(capacity); }
inline void low_level_api_mutable::reserve_halfedges(int capacity) const { m.reserve_halfedges(capacity); }
inline void low_level_api_mutable::reserve_faces(int capacity) const { m.reserve_faces(capacity); }
inline void low_level_api_mutable::permute_faces(const std::vector<int> &p) const { m.permute_faces(p); }
inline void low_level_api_mutable::permute_edges(const std::vector<int> &p) const { m.permute_edges(p); }
inline void low_level_api_mutable::permute_vertices(const std::vector<int> &p) const { m.permute_vertices(p); }
......
......@@ -745,7 +745,7 @@ face_handle face_collection<iterator>::add(const vertex_handle (&v_handles)[N])
{
halfedge_index hs[N];
for (auto i = 0; i < N; ++i)
hs[i] = low_level_api(this->mesh).find_halfedge(v_handles[i].idx, v_handles[(i + 1) % N].idx);
hs[i] = low_level_api(this->mesh).add_or_get_halfedge(v_handles[i].idx, v_handles[(i + 1) % N].idx);
return this->mesh->handle_of(low_level_api(this->mesh).add_face(hs, N));
}
......
......@@ -12,7 +12,7 @@ namespace polymesh
// ================= ITERATOR =================
template <typename tag>
struct valid_primitive_iterator
struct valid_primitive_iterator final
{
using handle_t = typename primitive<tag>::handle;
......@@ -32,7 +32,8 @@ struct valid_primitive_iterator
valid_primitive_iterator operator++(int)const
{
auto i = *this;
return ++i;
operator++();
return i;
}
bool operator==(valid_primitive_iterator const& rhs) const
{
......@@ -52,7 +53,7 @@ private:
};
template <typename tag>
struct all_primitive_iterator
struct all_primitive_iterator final
{
using handle_t = typename primitive<tag>::handle;
......@@ -71,7 +72,8 @@ struct all_primitive_iterator
all_primitive_iterator operator++(int)const
{
auto i = *this;
return ++i;
operator++();
return i;
}
bool operator==(all_primitive_iterator const& rhs) const
{
......@@ -93,7 +95,7 @@ private:
// ================= ATTRIBUTES =================
template <class AttributeT>
struct attribute_iterator
struct attribute_iterator final
{
int idx;
AttributeT attr;
......@@ -108,7 +110,8 @@ struct attribute_iterator
attribute_iterator operator++(int)const
{
auto i = *this;
return ++i;
operator++();
return i;
}
bool operator==(attribute_iterator const& rhs) const { return idx == rhs.idx; }
bool operator!=(attribute_iterator const& rhs) const { return idx != rhs.idx; }
......@@ -117,7 +120,7 @@ struct attribute_iterator
// ================= FILTER + MAP =================
template <class IteratorT, class PredT>
struct filtering_iterator
struct filtering_iterator final
{
IteratorT ocurr;
IteratorT oend;
......@@ -136,7 +139,8 @@ struct filtering_iterator
filtering_iterator operator++(int)const
{
auto i = *this;
return ++i;
operator++();
return i;
}
bool operator==(filtering_iterator const& rhs) const { return ocurr == rhs.ocurr; }
bool operator!=(filtering_iterator const& rhs) const { return ocurr != rhs.ocurr; }
......@@ -156,16 +160,17 @@ struct primitive_circulator
primitive_circulator() = default;
primitive_circulator(halfedge_handle handle, bool not_at_begin) : handle(handle), not_at_begin(not_at_begin) {}
primitive_circulator& operator++()
this_t& operator++()
{
static_cast<this_t*>(this)->advance();
not_at_begin = true;
return *this;
return static_cast<this_t&>(*this);
}
primitive_circulator operator++(int)const
this_t operator++(int)
{
auto i = *this;
return ++i;
auto i = static_cast<this_t const&>(*this);
operator++();
return i;
}
bool operator==(primitive_circulator const& rhs) 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