Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions mcstas-comps/share/union-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -2146,8 +2146,7 @@ void merge_lines_to_draw(struct lines_to_draw *lines_master,struct lines_to_draw
if (lines_master->number_of_lines == 0) {
lines_master->number_of_lines = lines_new->number_of_lines;
if (!lines_master->number_of_lines) {
fprintf(stderr,"Failure allocating list in Union function merge_lines_to_draw 1 - Exit!\n");
exit(EXIT_FAILURE);
return;
}
lines_master->lines = malloc(lines_master->number_of_lines*sizeof(struct line_segment));
if (!lines_master->lines) {
Expand Down Expand Up @@ -2308,23 +2307,27 @@ struct lines_to_draw draw_line_with_highest_priority(Coords position1,Coords pos
int geometry_output;

// Todo: switch to nicer intersect function call
double *double_dummy = malloc(2*sizeof(double));
int int_dummy[2];
double *double_dummy = malloc(max_number_of_solutions*sizeof(double));
int *int_dummy = malloc(max_number_of_solutions*sizeof(int));
// We need a storing pointer for the reallocs, to ensure that on realloc fail
// All is handled correctly
double *tmp;
int *tmpint;

// Find intersections
for (volume_index = 1;volume_index < number_of_volumes; volume_index++) {
if (volume_index != N) {
if (Geometries[volume_index]->eShape==mesh){
tmp = realloc(double_dummy, sizeof(double)*1000);
if ( tmp==NULL ) {
tmpint = realloc(int_dummy, sizeof(double)*1000);
if ( tmp==NULL || tmpint==NULL ) {
free(tmp);
free(tmpint);
printf("\nERROR: Realloc failed on double dummy");
exit(1);
} else {
double_dummy = tmp;
int_dummy = tmpint;
tmp = realloc(temp_intersection, sizeof(double)*1000);
if ( tmp == NULL){
free(tmp);
Expand Down
64 changes: 33 additions & 31 deletions mcstas-comps/union/Union_mesh.comp
Original file line number Diff line number Diff line change
Expand Up @@ -509,48 +509,48 @@ void mcdisplay_mesh_function(struct lines_to_draw *lines_to_draw_output,int inde
// Make sure it does not print a line if it is already printed.... (might take a while?)
for (i = 0 ; i < counter ; i++){
if (print1 == 1 && coord_comp(point1 , list_startpoints[i])){
for (j = 0 ; j < counter ; j++){
if (coord_comp(point2 , list_startpoints[i])){
print1 = 0;
}
}
for (j = 0 ; j < counter ; j++){
if (coord_comp(point2 , list_startpoints[i])){
print1 = 0;
}
}
}
if (print2 == 1 && coord_comp(point2 , list_startpoints[i])){
for (j = 0 ; j < counter ; j++){
if (coord_comp(point1 , list_startpoints[i])){
print1 = 0;
}
}
for (j = 0 ; j < counter ; j++){
if (coord_comp(point1 , list_startpoints[i])){
print1 = 0;
}
}
}
if (print2 == 1 && coord_comp(point2 , list_startpoints[i]) ){
for (j = 0 ; j < counter ; j++){
if (coord_comp(point3 , list_startpoints[i])){
print2 = 0;
}
}
for (j = 0 ; j < counter ; j++){
if (coord_comp(point3 , list_startpoints[i])){
print2 = 0;
}
}
}
if (print3 == 1 && coord_comp(point3 , list_startpoints[i]) ){
for (j = 0 ; j < counter ; j++){
if (coord_comp(point2 , list_startpoints[i])){
print2 = 0;
}
}
for (j = 0 ; j < counter ; j++){
if (coord_comp(point2 , list_startpoints[i])){
print2 = 0;
}
}
}
if (print1 == 1 && coord_comp(point1 , list_startpoints[i]) ){
for (j = 0 ; j < counter ; j++){
if (coord_comp(point1 , list_startpoints[i])){
print3 = 0;
}
}
for (j = 0 ; j < counter ; j++){
if (coord_comp(point1 , list_startpoints[i])){
print3 = 0;
}
}
}
if (print3 == 1 && coord_comp(point3 , list_startpoints[i])){
for (j = 0 ; j < counter ; j++){
if (coord_comp(point1 , list_startpoints[i])){
print3 = 0;
}
}
for (j = 0 ; j < counter ; j++){
if (coord_comp(point1 , list_startpoints[i])){
print3 = 0;
}
}
}

}


Expand Down Expand Up @@ -968,6 +968,8 @@ if(strcmp(dot, ".stl") == 0 || strcmp(dot, ".STL") == 0){
NAME_CURRENT_COMP, filename);
exit(1);
}
printf("\nCOMPONENT %s: Number of faces read: %d\t Number of vertices read: %d\n",
NAME_CURRENT_COMP, n_verts, n_faces);
// Loop over all vertices and multiply their positions with coordinate_scale
for (int i = 0; i<n_verts; i++){
verts[i] = coords_scale(verts[i], coordinate_scale);
Expand Down