Skip to content

Commit

Permalink
Fixed and verified stl_copy. Resolves admesh#48
Browse files Browse the repository at this point in the history
  • Loading branch information
andreondra committed Apr 11, 2022
1 parent 83b1fab commit 1aba97a
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -653,28 +653,27 @@ stl_file *stl_copy(stl_file *dst, const stl_file *src){

if(src->facet_start != NULL){

dst->neighbors_start = (stl_neighbors*)
calloc(dst->stats.number_of_facets, sizeof(stl_neighbors));
if(dst->neighbors_start == NULL) perror("stl_copy");
dst->facet_start = (stl_facet*)calloc(dst->stats.number_of_facets, sizeof(stl_facet));
if(dst->facet_start == NULL) perror("stl_copy");

for(int i = 0; i < dst->stats.number_of_facets; i++){
dst->neighbors_start[i] = src->neighbors_start[i];
dst->facet_start[i] = src->facet_start[i];
}
}

if(src->neighbors_start != NULL){

dst->facet_start = (stl_facet*)calloc(dst->stats.number_of_facets, sizeof(stl_facet));
if(dst->facet_start == NULL) perror("stl_copy");
dst->neighbors_start = (stl_neighbors*) calloc(dst->stats.number_of_facets, sizeof(stl_neighbors));
if(dst->neighbors_start == NULL) perror("stl_copy");

for(int i = 0; i < dst->stats.number_of_facets; i++){
dst->neighbors_start[i] = src->neighbors_start[i];
}
}

if(src->v_indices != NULL){

dst->v_indices = (v_indices_struct*)
calloc(dst->stats.number_of_facets, sizeof(v_indices_struct));
dst->v_indices = (v_indices_struct*) calloc(dst->stats.number_of_facets, sizeof(v_indices_struct));
if(dst->v_indices == NULL) perror("stl_copy");

for(int i = 0; i < dst->stats.number_of_facets; i++)
Expand All @@ -683,8 +682,7 @@ stl_file *stl_copy(stl_file *dst, const stl_file *src){

if(src->v_shared != NULL){

dst->v_shared = (stl_vertex*)
calloc((dst->stats.number_of_facets / 2), sizeof(stl_vertex));
dst->v_shared = (stl_vertex*) calloc((dst->stats.number_of_facets / 2), sizeof(stl_vertex));
if(dst->v_shared == NULL) perror("stl_copy");

for(int i = 0; i < dst->stats.number_of_facets / 2; i++){
Expand Down

0 comments on commit 1aba97a

Please sign in to comment.