Skip to content

Commit

Permalink
Proposal to fix issue CGAL#3375
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon-Lopez authored and lrineau committed Oct 10, 2018
1 parent 146fc90 commit 3622f1c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Surface_mesh/include/CGAL/Surface_mesh/Surface_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ class Surface_mesh

bool join(const Surface_mesh& other)
{
size_type nv = num_vertices(), nh = num_halfedges(), nf = num_faces();
const size_type nv = num_vertices(), nh = num_halfedges(), nf = num_faces();
resize(num_vertices()+ other.num_vertices(),
num_edges()+ other.num_edges(),
num_faces()+ other.num_faces());
Expand Down Expand Up @@ -1110,7 +1110,9 @@ class Surface_mesh
Vertex_index vi(nv+other.vertices_freelist_);
Halfedge_index inf((std::numeric_limits<size_type>::max)());
while(vconn_[vi].halfedge_ != inf){
vi = Vertex_index(size_type(vconn_[vi].halfedge_));
Vertex_index corrected_vi = Vertex_index(size_type(vconn_[vi].halfedge_)+nv-nh);
vconn_[vi].halfedge_ = Halfedge_index(corrected_vi);
vi = corrected_vi;
}
vconn_[vi].halfedge_ = Halfedge_index(vertices_freelist_);
}
Expand All @@ -1121,22 +1123,24 @@ class Surface_mesh
Face_index fi(nf+other.faces_freelist_);
Halfedge_index inf((std::numeric_limits<size_type>::max)());
while(fconn_[fi].halfedge_ != inf){
fi = Face_index(size_type(fconn_[fi].halfedge_));
Face_index corrected_fi = Face_index(size_type(fconn_[fi].halfedge_)+nf-nh);
fconn_[fi].halfedge_ = Halfedge_index(corrected_fi);
fi = corrected_fi;
}
fconn_[fi].halfedge_ = Halfedge_index(faces_freelist_);
}
faces_freelist_ = nf + other.faces_freelist_;
}
if(other.edges_freelist_ != inf_value){
if(edges_freelist_ != inf_value){
Halfedge_index hi((nh>>1)+other.edges_freelist_);
Halfedge_index hi(nh+other.edges_freelist_);
Halfedge_index inf((std::numeric_limits<size_type>::max)());
while(hconn_[hi].next_halfedge_ != inf){
hi = hconn_[hi].next_halfedge_;
}
hconn_[hi].next_halfedge_ = Halfedge_index(edges_freelist_);
}
edges_freelist_ = (nh>>1) + other.edges_freelist_;
edges_freelist_ = nh + other.edges_freelist_;
}
garbage_ = garbage_ || other.garbage_;
removed_vertices_ += other.removed_vertices_;
Expand Down

0 comments on commit 3622f1c

Please sign in to comment.