44 #include <OpenMesh/Core/Mesh/ArrayKernel.hh> 49 ArrayKernel::ArrayKernel()
50 : refcount_vstatus_(0), refcount_hstatus_(0),
51 refcount_estatus_(0), refcount_fstatus_(0)
56 ArrayKernel::~ArrayKernel()
73 vertices_ = _other.vertices_;
74 edges_ = _other.edges_;
75 faces_ = _other.faces_;
77 vprops_resize(n_vertices());
78 hprops_resize(n_halfedges());
79 eprops_resize(n_edges());
80 fprops_resize(n_faces());
85 vertex_status_ = _other.vertex_status_;
86 halfedge_status_ = _other.halfedge_status_;
87 edge_status_ = _other.edge_status_;
88 face_status_ = _other.face_status_;
92 refcount_estatus_ = _other.refcount_estatus_ > 0 ? 1 : 0;
93 refcount_vstatus_ = _other.refcount_vstatus_ > 0 ? 1 : 0;
94 refcount_hstatus_ = _other.refcount_hstatus_ > 0 ? 1 : 0;
95 refcount_fstatus_ = _other.refcount_fstatus_ > 0 ? 1 : 0;
110 size_t eh = ( (
char*)&_he - (
char*)&edges_.front() ) /
sizeof(Edge) ;
111 assert((&_he == &edges_[eh].halfedges_[0]) ||
112 (&_he == &edges_[eh].halfedges_[1]));
113 return ((&_he == &edges_[eh].halfedges_[0]) ?
117 EdgeHandle ArrayKernel::handle(
const Edge& _e)
const 119 return EdgeHandle(
int(&_e - &edges_.front() ) );
122 FaceHandle ArrayKernel::handle(
const Face& _f)
const 124 return FaceHandle(
int(&_f - &faces_.front()) );
127 #define SIGNED(x) signed( (x) ) 131 return 0 <= _vh.
idx() && _vh.
idx() < SIGNED(n_vertices());
136 return 0 <= _heh.
idx() && _heh.
idx() < SIGNED(n_edges()*2);
141 return 0 <= _eh.
idx() && _eh.
idx() < SIGNED(n_edges());
146 return 0 <= _fh.
idx() && _fh.
idx() < SIGNED(n_faces());
151 unsigned int ArrayKernel::delete_isolated_vertices()
153 assert(has_vertex_status());
154 unsigned int n_isolated = 0;
155 for (KernelVertexIter v_it = vertices_begin(); v_it != vertices_end(); ++v_it)
157 if (is_isolated(handle(*v_it)))
159 status(handle(*v_it)).set_deleted(
true);
168 std::vector<VertexHandle*> empty_vh;
169 std::vector<HalfedgeHandle*> empty_hh;
170 std::vector<FaceHandle*> empty_fh;
171 garbage_collection( empty_vh,empty_hh,empty_fh,_v, _e, _f);
188 VertexContainer().swap( vertices_ );
191 EdgeContainer().swap( edges_ );
194 FaceContainer().swap( faces_ );
211 void ArrayKernel::resize(
size_t _n_vertices,
size_t _n_edges,
size_t _n_faces )
213 vertices_.resize(_n_vertices);
214 edges_.resize(_n_edges);
215 faces_.resize(_n_faces);
217 vprops_resize(n_vertices());
218 hprops_resize(n_halfedges());
219 eprops_resize(n_edges());
220 fprops_resize(n_faces());
223 void ArrayKernel::reserve(
size_t _n_vertices,
size_t _n_edges,
size_t _n_faces )
225 vertices_.reserve(_n_vertices);
226 edges_.reserve(_n_edges);
227 faces_.reserve(_n_faces);
229 vprops_reserve(_n_vertices);
230 hprops_reserve(_n_edges*2);
231 eprops_reserve(_n_edges);
232 fprops_reserve(_n_faces);
236 void ArrayKernel::init_bit_masks(BitMaskContainer& _bmc)
244 void ArrayKernel::init_bit_masks()
246 init_bit_masks(vertex_bit_masks_);
247 edge_bit_masks_ = vertex_bit_masks_;
248 face_bit_masks_ = vertex_bit_masks_;
249 halfedge_bit_masks_= vertex_bit_masks_;
Handle for a edge entity.
Handle for a face entity.
bool is_valid_handle(VertexHandle _vh) const
checks handle validity - useful for debugging
void clean()
Remove all vertices, edges and faces and deallocates their memory.
void clear()
Does the same as clean() and in addition erases all properties.
Handle for a halfedge entity.
int idx() const
Get the underlying index of this handle.
Handle for a vertex entity.
void assign_connectivity(const ArrayKernel &_other)
void clean_keep_reservation()
Remove all vertices, edges and faces but keep memory allocated.
void garbage_collection(bool _v=true, bool _e=true, bool _f=true)
garbage collection