2 #include "ui_mainwindow.h"
11 #include <QColorDialog>
12 #include <QMessageBox>
34 ui->progressBar->setHidden(
true);
40 ui->glwidget->greenAmbient = 0.58f;
ui->glwidget->blueAmbient = 0.18f;
42 ui->glwidget->redModel = 0.5;
43 ui->glwidget->greenModel = 0.5;
44 ui->glwidget->blueModel = 0.5;
46 ui->glwidget->backroundColor.setAlpha(1.0);
47 ui->glwidget->backroundColor.setRedF(0.2);
48 ui->glwidget->backroundColor.setGreenF(0.2);
49 ui->glwidget->backroundColor.setBlueF(0.2);
51 ui->glwidget->drawer = 1;
53 ui->glwidget->shininess = 50;
54 ui->glwidget->point_size = 1;
63 connect(
ui->actionSolid_Color, SIGNAL(triggered()),
this, SLOT(
modelColor()));
64 connect(
ui->actionAmbient_Color, SIGNAL(triggered()),
this, SLOT(
ambientColor()));
67 connect(
ui->actionHelp_2, SIGNAL(triggered()),
this, SLOT(
showHelp()));
73 connect(
ui->actionColor_ambient_light, SIGNAL(triggered()),
this, SLOT(
ambientColor()));
74 connect(
ui->actionColor_model, SIGNAL(triggered()),
this, SLOT(
modelColor()));
77 connect(
ui->actionHelp, SIGNAL(triggered()),
this, SLOT(
showHelp()));
78 connect(
ui->actionAbout, SIGNAL(triggered()),
this, SLOT(
showAbout()));
90 connect(
ui->drawer_chooser, SIGNAL(currentIndexChanged(QString)),
this, SLOT(
set_drawer()));
91 connect(
ui->dial, SIGNAL(sliderMoved(
int)),
this, SLOT(
setShininess()));
92 connect(
ui->dial_point_size, SIGNAL(sliderMoved(
int)),
this, SLOT(
changePointSize()));
109 char tmp_buffer[100];
110 float x, y, z, vx, vy, vz;
111 int res_x, res_y, res_z;
113 int triangular_facets = 0;
115 ui->glwidget->stl_data[0].clear();
116 ui->glwidget->stl_data[1].clear();
117 ui->glwidget->stl_data[2].clear();
119 ui->glwidget->coordiantes[0].clear();
120 ui->glwidget->coordiantes[1].clear();
121 ui->glwidget->coordiantes[2].clear();
122 ui->glwidget->coordiantes[3].clear();
123 ui->glwidget->coordiantes[4].clear();
124 ui->glwidget->coordiantes[5].clear();
126 ui->glwidget->sampled_data[0].clear();
127 ui->glwidget->sampled_data[1].clear();
128 ui->glwidget->sampled_data[2].clear();
130 ui->glwidget->x_min =
ui->glwidget->x_max =
ui->glwidget->y_min =
ui->glwidget->y_max =
ui->glwidget->z_min =
ui->glwidget->z_max = 0.0;
133 file = QFileDialog::getOpenFileName(
this, tr(
"Open Point-Data File"),
"",tr(
"FILE (*.txt)"));
136 ui->glwidget->coordiantes[0].clear();
137 ui->glwidget->coordiantes[1].clear();
138 ui->glwidget->coordiantes[2].clear();
140 if (
file.length() != 0){
142 fd = fopen(
file.toUtf8().constData(),
"r");
144 ui->progressBar->setHidden(
false);
145 ui->progressBar->setValue(0);
156 fscanf(fd,
"%s", &tmp_buffer);
157 if (strcmp(tmp_buffer,
"\n") != 0) counter++;
161 triangular_facets = counter/6;
169 fscanf(fd,
"%f %f %f %f %f %f\n", &x, &y, &z, &vx, &vy, &vz);
171 ui->glwidget->coordiantes[0].append(x);
172 ui->glwidget->coordiantes[1].append(y);
173 ui->glwidget->coordiantes[2].append(z);
175 ui->glwidget->coordiantes[3].append(vx);
176 ui->glwidget->coordiantes[4].append(vy);
177 ui->glwidget->coordiantes[5].append(vz);
188 ui->progressBar->setValue(100.0/triangular_facets*counter);
192 ui->progressBar->setHidden(
true);
200 for (
int i = 0; i <
ui->glwidget->coordiantes[0].size(); i++){
215 res_x = (int)(300.0);
219 ui->res_x->setValue(res_x);
220 ui->res_y->setValue(res_y);
221 ui->res_z->setValue(res_z);
223 ui->edit_xmin->setValue(x_min_init);
224 ui->edit_ymin->setValue(y_min_init);
225 ui->edit_zmin->setValue(z_min_init);
231 ui->glwidget->updateGL();
243 char tmp_buffer[100];
244 int bin_or_string = 0;
246 float norm_x, norm_y, norm_z;
247 int res_x, res_y, res_z;
249 unsigned short attribute;
250 unsigned int triangular_facets;
252 ui->glwidget->stl_data[0].clear();
253 ui->glwidget->stl_data[1].clear();
254 ui->glwidget->stl_data[2].clear();
256 ui->glwidget->coordiantes[0].clear();
257 ui->glwidget->coordiantes[1].clear();
258 ui->glwidget->coordiantes[2].clear();
259 ui->glwidget->coordiantes[3].clear();
260 ui->glwidget->coordiantes[4].clear();
261 ui->glwidget->coordiantes[5].clear();
263 ui->glwidget->sampled_data[0].clear();
264 ui->glwidget->sampled_data[1].clear();
265 ui->glwidget->sampled_data[2].clear();
267 ui->glwidget->x_min =
ui->glwidget->x_max =
ui->glwidget->y_min =
ui->glwidget->y_max =
ui->glwidget->z_min =
ui->glwidget->z_max = 0.0;
273 file = QFileDialog::getOpenFileName(
this, tr(
"Open STL-File"),
"",tr(
"FILE (*.stl)"));
276 ui->glwidget->stl_data[0].clear();
277 ui->glwidget->stl_data[1].clear();
278 ui->glwidget->stl_data[2].clear();
280 if (
file.length() != 0){
282 ui->progressBar->setHidden(
false);
283 ui->progressBar->setValue(0);
285 fd = fopen(
file.toUtf8().constData(),
"r");
288 fread(&buffer, 6,
sizeof(
char), fd);
293 for (
int i = 0; i < 5; i++) tmp+=buffer[i];
295 if (tmp ==
"solid") bin_or_string = 0;
296 if (tmp !=
"solid") bin_or_string = 1;
302 qDebug() << bin_or_string;
305 if (bin_or_string == 0){
307 fd = fopen(
file.toUtf8().constData(),
"r");
311 fscanf(fd,
"%s", &tmp_buffer);
312 if (strcmp(tmp_buffer,
"normal") == 0) counter++;
313 if (strcmp(tmp_buffer,
"vertex") == 0) counter++;
322 fscanf(fd,
"%s", &tmp_buffer);
324 if (strcmp(tmp_buffer,
"normal") == 0){
326 fscanf(fd,
"%f %f %f", &norm_x, &norm_y, &norm_z);
328 ui->glwidget->stl_data[0].append(norm_x);
329 ui->glwidget->stl_data[1].append(norm_y);
330 ui->glwidget->stl_data[2].append(norm_z);
335 if (strcmp(tmp_buffer,
"vertex") == 0){
337 fscanf(fd,
"%f %f %f", &x, &y, &z);
347 ui->glwidget->stl_data[0].append(x);
348 ui->glwidget->stl_data[1].append(y);
349 ui->glwidget->stl_data[2].append(z);
362 ui->progressBar->setValue(100.0/triangular_facets*counter);
365 ui->progressBar->setHidden(
true);
373 if (bin_or_string == 1){
375 fd = fopen(
file.toUtf8().constData(),
"rb");
380 fread(&triangular_facets, 1,
sizeof(
unsigned int), fd);
382 while(counter < triangular_facets){
384 norm_x = norm_y = norm_z = 0.0;
387 fread(&norm_x, 1,
sizeof(
float), fd);
388 fread(&norm_y, 1,
sizeof(
float), fd);
389 fread(&norm_z, 1,
sizeof(
float), fd);
391 ui->glwidget->stl_data[0].append(norm_x);
392 ui->glwidget->stl_data[1].append(norm_y);
393 ui->glwidget->stl_data[2].append(norm_z);
395 fread(&x, 1,
sizeof(
float), fd);
396 fread(&y, 1,
sizeof(
float), fd);
397 fread(&z, 1,
sizeof(
float), fd);
399 ui->glwidget->stl_data[0].append(x);
400 ui->glwidget->stl_data[1].append(y);
401 ui->glwidget->stl_data[2].append(z);
403 fread(&x, 1,
sizeof(
float), fd);
404 fread(&y, 1,
sizeof(
float), fd);
405 fread(&z, 1,
sizeof(
float), fd);
407 ui->glwidget->stl_data[0].append(x);
408 ui->glwidget->stl_data[1].append(y);
409 ui->glwidget->stl_data[2].append(z);
411 fread(&x, 1,
sizeof(
float), fd);
412 fread(&y, 1,
sizeof(
float), fd);
413 fread(&z, 1,
sizeof(
float), fd);
415 ui->glwidget->stl_data[0].append(x);
416 ui->glwidget->stl_data[1].append(y);
417 ui->glwidget->stl_data[2].append(z);
419 fread(&attribute, 1,
sizeof(
unsigned short), fd);
423 ui->progressBar->setValue(100.0/triangular_facets*counter);
441 ui->progressBar->setHidden(
true);
450 for (
int i = 0; i <
ui->glwidget->stl_data[0].size(); i++){
452 if (i%4==0)
continue;
467 res_x = (int)(300.0);
471 ui->res_x->setValue(res_x);
472 ui->res_y->setValue(res_y);
473 ui->res_z->setValue(res_z);
475 ui->edit_xmin->setValue(x_min_init);
476 ui->edit_ymin->setValue(y_min_init);
477 ui->edit_zmin->setValue(z_min_init);
482 ui->glwidget->init();
483 ui->glwidget->updateGL();
503 ui->glwidget->x_min =
ui->edit_xmin->value();
504 ui->glwidget->y_min =
ui->edit_ymin->value();
505 ui->glwidget->z_min =
ui->edit_zmin->value();
506 ui->glwidget->x_max =
ui->edit_xmax->value();
507 ui->glwidget->y_max =
ui->edit_ymax->value();
508 ui->glwidget->z_max =
ui->edit_zmax->value();
514 ui->glwidget->updateGL();
542 ui->glwidget->updateGL();
554 if ((
ui->glwidget->stl_data[0].size()==0)&&(
ui->glwidget->coordiantes[0].size()==0)){
557 msgBox.setText(
"Please load first some data.");
561 if ((
ui->glwidget->stl_data[0].size()!=0)||(
ui->glwidget->coordiantes[0].size()!=0)){
565 file_save = QFileDialog::getSaveFileName(
this, tr(
"TYCHO boundary-conditions"),
"",tr(
"Tycho Boundary File (*.tyc)"));
566 QFileInfo
file(file_save);
568 if (!file_save.isEmpty()){
570 if(file.suffix().isEmpty()) file_save +=
".tyc";
584 int max_u, max_w, max_uw;
585 int max_ax, max_ay, max_az;
586 int max_bx, max_by, max_bz;
595 ZAX =
ui->res_x->value();
596 ZAY =
ui->res_y->value();
597 ZAZ =
ui->res_z->value();
600 ui->glwidget->x_min =
ui->edit_xmin->value();
601 ui->glwidget->y_min =
ui->edit_ymin->value();
602 ui->glwidget->z_min =
ui->edit_zmin->value();
603 ui->glwidget->x_max =
ui->edit_xmax->value();
604 ui->glwidget->y_max =
ui->edit_ymax->value();
605 ui->glwidget->z_max =
ui->edit_zmax->value();
615 bounding = (
int ***)calloc((
size_t)ZAX,
sizeof(
int **));
616 for (k = 0; k < ZAX; k++) {
617 bounding[k] = (
int **)calloc((
size_t)ZAY,
sizeof(
int *));
619 fprintf(stderr,
"Could not allocate memory.\n");
622 for (j = 0; j < ZAY; j++) {
623 bounding[k][j] = (
int *)calloc((
size_t)ZAZ,
sizeof(int));
625 fprintf(stderr,
"Could not allocate memory.\n");
632 if (
ui->glwidget->coordiantes[0].size() > 0){
634 ui->progressBar->setHidden(
false);
635 ui->progressBar->setValue(0);
639 for (l = 0; l <
ui->glwidget->coordiantes[0].size(); l++)
642 ui->glwidget->coordiantes[0][l] += -(
ui->glwidget->x_min);
643 ui->glwidget->coordiantes[1][l] += -(
ui->glwidget->y_min);
644 ui->glwidget->coordiantes[2][l] += -(
ui->glwidget->z_min);
646 i = (int)(floor(((
ui->glwidget->coordiantes[0][l])/sx)));
647 j = (int)(floor(((
ui->glwidget->coordiantes[1][l])/sy)));
648 k = (int)(floor(((
ui->glwidget->coordiantes[2][l])/sz)));
650 if ((i < 0)||(j < 0)||(k < 0)||(i > ZAX - 1)||(j > ZAY - 1)||(k > ZAZ - 1)) {
652 ui->glwidget->coordiantes[0][l] +=
ui->glwidget->x_min;
653 ui->glwidget->coordiantes[1][l] +=
ui->glwidget->y_min;
654 ui->glwidget->coordiantes[2][l] +=
ui->glwidget->z_min;
661 ui->glwidget->coordiantes[0][l] +=
ui->glwidget->x_min;
662 ui->glwidget->coordiantes[1][l] +=
ui->glwidget->y_min;
663 ui->glwidget->coordiantes[2][l] +=
ui->glwidget->z_min;
667 ui->progressBar->setValue(100.0/
ui->glwidget->coordiantes[0].size()*
counter);
671 ui->progressBar->setHidden(
true);
676 if (
ui->glwidget->stl_data[0].size() > 0){
678 ui->progressBar->setHidden(
false);
679 ui->progressBar->setValue(0);
684 for (l = 0; l <=
ui->glwidget->stl_data[0].size() - 4; l = l + 4)
688 vertex1[0] =
ui->glwidget->stl_data[0].at(l+1)-(
ui->glwidget->x_min);
689 vertex1[1] =
ui->glwidget->stl_data[1].at(l+1)-(
ui->glwidget->y_min);
690 vertex1[2] =
ui->glwidget->stl_data[2].at(l+1)-(
ui->glwidget->z_min);
691 vertex2[0] =
ui->glwidget->stl_data[0].at(l+2)-(
ui->glwidget->x_min);
692 vertex2[1] =
ui->glwidget->stl_data[1].at(l+2)-(
ui->glwidget->y_min);
693 vertex2[2] =
ui->glwidget->stl_data[2].at(l+2)-(
ui->glwidget->z_min);
694 vertex3[0] =
ui->glwidget->stl_data[0].at(l+3)-(
ui->glwidget->x_min);
695 vertex3[1] =
ui->glwidget->stl_data[1].at(l+3)-(
ui->glwidget->y_min);
696 vertex3[2] =
ui->glwidget->stl_data[2].at(l+3)-(
ui->glwidget->z_min);
698 ux = vertex2[0] - vertex1[0];
699 uy = vertex2[1] - vertex1[1];
700 uz = vertex2[2] - vertex1[2];
702 wx = vertex3[0] - vertex1[0];
703 wy = vertex3[1] - vertex1[1];
704 wz = vertex3[2] - vertex1[2];
706 max_ax = ceil(fabs(ux/sx));
707 max_ay = ceil(fabs(uy/sy));
708 max_az = ceil(fabs(uz/sz));
710 max_u = max_ax + max_ay + max_az;
712 max_bx = ceil(fabs(wx/sx));
713 max_by = ceil(fabs(wy/sy));
714 max_bz = ceil(fabs(wz/sz));
716 max_w = max_bx + max_by + max_bz;
717 max_uw = max_u + max_w;
719 for (nu = 0; nu <= max_uw; nu++){
720 for (nw = 0; nw <= max_uw - nu; nw++){
722 px = vertex1[0] + ((1.0 * nu)/max_uw) * ux + ((1.0 * nw)/max_uw) * wx;
723 py = vertex1[1] + ((1.0 * nu)/max_uw) * uy + ((1.0 * nw)/max_uw) * wy;
724 pz = vertex1[2] + ((1.0 * nu)/max_uw) * uz + ((1.0 * nw)/max_uw) * wz;
726 i = (int)(floor((px/sx)));
727 j = (int)(floor((py/sy)));
728 k = (int)(floor((pz/sz)));
730 if ((i < 0)||(j < 0)||(k < 0)||(i > ZAX - 1)||(j > ZAY - 1)||(k > ZAZ - 1))
continue;
736 counter = counter + 4;
738 ui->progressBar->setValue(100.0/
ui->glwidget->stl_data[0].size()*
counter);
741 ui->progressBar->setHidden(
true);
745 fd = fopen(file_save.toUtf8(),
"w");
746 fprintf(fd,
"This is a TYCHO boundary condition file.\n");
747 fprintf(fd,
"X %i\n", ZAX);
748 fprintf(fd,
"Y %i\n", ZAY);
749 fprintf(fd,
"Z %i\n", ZAZ);
750 fseek(fd, 200, SEEK_SET);
752 for (
int i = 0; i < ZAX; i++) {
753 for (
int j = 0; j < ZAY; j++) {
754 for (
int k = 0; k < ZAZ; k++) {
758 fwrite(&tmp, 1,
sizeof (
int), fd);
781 if ((
ui->glwidget->stl_data[0].size()==0)&&(
ui->glwidget->coordiantes[0].size()==0)){
784 msgBox.setText(
"Please load first some data.");
788 if ((
ui->glwidget->stl_data[0].size()!=0)||(
ui->glwidget->coordiantes[0].size()!=0)){
792 file_save = QFileDialog::getSaveFileName(
this, tr(
"TYCHO soundemitter"),
"",tr(
"Tycho Soundemitter File (*.tyc)"));
793 QFileInfo
file(file_save);
795 if (!file_save.isEmpty()){
797 if(file.suffix().isEmpty()) file_save +=
".tyc";
811 int max_u, max_w, max_uw;
812 int max_ax, max_ay, max_az;
813 int max_bx, max_by, max_bz;
822 ZAX =
ui->res_x->value();
823 ZAY =
ui->res_y->value();
824 ZAZ =
ui->res_z->value();
827 ui->glwidget->x_min =
ui->edit_xmin->value();
828 ui->glwidget->y_min =
ui->edit_ymin->value();
829 ui->glwidget->z_min =
ui->edit_zmin->value();
830 ui->glwidget->x_max =
ui->edit_xmax->value();
831 ui->glwidget->y_max =
ui->edit_ymax->value();
832 ui->glwidget->z_max =
ui->edit_zmax->value();
842 bounding = (
int ***)calloc((
size_t)ZAX,
sizeof(
int **));
843 for (k = 0; k < ZAX; k++) {
844 bounding[k] = (
int **)calloc((
size_t)ZAY,
sizeof(
int *));
846 fprintf(stderr,
"Could not allocate memory.\n");
849 for (j = 0; j < ZAY; j++) {
850 bounding[k][j] = (
int *)calloc((
size_t)ZAZ,
sizeof(int));
852 fprintf(stderr,
"Could not allocate memory.\n");
859 if (
ui->glwidget->coordiantes[0].size() > 0){
861 ui->progressBar->setHidden(
false);
862 ui->progressBar->setValue(0);
866 for (l = 0; l <
ui->glwidget->coordiantes[0].size(); l++)
869 ui->glwidget->coordiantes[0][l] += -(
ui->glwidget->x_min);
870 ui->glwidget->coordiantes[1][l] += -(
ui->glwidget->y_min);
871 ui->glwidget->coordiantes[2][l] += -(
ui->glwidget->z_min);
873 i = (int)(floor(((
ui->glwidget->coordiantes[0][l])/sx)));
874 j = (int)(floor(((
ui->glwidget->coordiantes[1][l])/sy)));
875 k = (int)(floor(((
ui->glwidget->coordiantes[2][l])/sz)));
877 if ((i < 0)||(j < 0)||(k < 0)||(i > ZAX - 1)||(j > ZAY - 1)||(k > ZAZ - 1)) {
879 ui->glwidget->coordiantes[0][l] +=
ui->glwidget->x_min;
880 ui->glwidget->coordiantes[1][l] +=
ui->glwidget->y_min;
881 ui->glwidget->coordiantes[2][l] +=
ui->glwidget->z_min;
888 ui->glwidget->coordiantes[0][l] +=
ui->glwidget->x_min;
889 ui->glwidget->coordiantes[1][l] +=
ui->glwidget->y_min;
890 ui->glwidget->coordiantes[2][l] +=
ui->glwidget->z_min;
894 ui->progressBar->setValue(100.0/
ui->glwidget->coordiantes[0].size()*
counter);
898 ui->progressBar->setHidden(
true);
903 if (
ui->glwidget->stl_data[0].size() > 0){
905 ui->progressBar->setHidden(
false);
906 ui->progressBar->setValue(0);
911 for (l = 0; l <=
ui->glwidget->stl_data[0].size() - 4; l = l + 4)
915 vertex1[0] =
ui->glwidget->stl_data[0].at(l+1)-(
ui->glwidget->x_min);
916 vertex1[1] =
ui->glwidget->stl_data[1].at(l+1)-(
ui->glwidget->y_min);
917 vertex1[2] =
ui->glwidget->stl_data[2].at(l+1)-(
ui->glwidget->z_min);
918 vertex2[0] =
ui->glwidget->stl_data[0].at(l+2)-(
ui->glwidget->x_min);
919 vertex2[1] =
ui->glwidget->stl_data[1].at(l+2)-(
ui->glwidget->y_min);
920 vertex2[2] =
ui->glwidget->stl_data[2].at(l+2)-(
ui->glwidget->z_min);
921 vertex3[0] =
ui->glwidget->stl_data[0].at(l+3)-(
ui->glwidget->x_min);
922 vertex3[1] =
ui->glwidget->stl_data[1].at(l+3)-(
ui->glwidget->y_min);
923 vertex3[2] =
ui->glwidget->stl_data[2].at(l+3)-(
ui->glwidget->z_min);
925 ux = vertex2[0] - vertex1[0];
926 uy = vertex2[1] - vertex1[1];
927 uz = vertex2[2] - vertex1[2];
929 wx = vertex3[0] - vertex1[0];
930 wy = vertex3[1] - vertex1[1];
931 wz = vertex3[2] - vertex1[2];
933 max_ax = ceil(fabs(ux/sx));
934 max_ay = ceil(fabs(uy/sy));
935 max_az = ceil(fabs(uz/sz));
937 max_u = max_ax + max_ay + max_az;
939 max_bx = ceil(fabs(wx/sx));
940 max_by = ceil(fabs(wy/sy));
941 max_bz = ceil(fabs(wz/sz));
943 max_w = max_bx + max_by + max_bz;
944 max_uw = max_u + max_w;
946 for (nu = 0; nu <= max_uw; nu++){
947 for (nw = 0; nw <= max_uw - nu; nw++){
949 px = vertex1[0] + ((1.0 * nu)/max_uw) * ux + ((1.0 * nw)/max_uw) * wx;
950 py = vertex1[1] + ((1.0 * nu)/max_uw) * uy + ((1.0 * nw)/max_uw) * wy;
951 pz = vertex1[2] + ((1.0 * nu)/max_uw) * uz + ((1.0 * nw)/max_uw) * wz;
953 i = (int)(floor((px/sx)));
954 j = (int)(floor((py/sy)));
955 k = (int)(floor((pz/sz)));
957 if ((i < 0)||(j < 0)||(k < 0)||(i > ZAX - 1)||(j > ZAY - 1)||(k > ZAZ - 1))
continue;
963 counter = counter + 4;
965 ui->progressBar->setValue(100.0/
ui->glwidget->stl_data[0].size()*
counter);
968 ui->progressBar->setHidden(
true);
972 fd = fopen(file_save.toUtf8(),
"w");
973 fprintf(fd,
"This is a TYCHO boundary condition file.\n");
974 fprintf(fd,
"X %i\n", ZAX);
975 fprintf(fd,
"Y %i\n", ZAY);
976 fprintf(fd,
"Z %i\n", ZAZ);
977 fseek(fd, 200, SEEK_SET);
979 for (
int i = 0; i < ZAX; i++) {
980 for (
int j = 0; j < ZAY; j++) {
981 for (
int k = 0; k < ZAZ; k++) {
985 fwrite(&tmp, 1,
sizeof (
int), fd);
1015 dia_x =
ui->edit_xmax->value()-
ui->edit_xmin->value();
1016 dia_y =
ui->edit_ymax->value()-
ui->edit_ymin->value();
1017 dia_z =
ui->edit_zmax->value()-
ui->edit_zmin->value();
1019 res_x =
ui->res_x->value();
1022 res_y = (int)(res_x * dia_y / dia_x);
1023 ui->res_y->setValue(res_y);
1026 res_z = (int)(res_x * dia_z / dia_x);
1027 ui->res_z->setValue(res_z);
1046 dia_x =
ui->edit_xmax->value()-
ui->edit_xmin->value();
1047 dia_y =
ui->edit_ymax->value()-
ui->edit_ymin->value();
1048 dia_z =
ui->edit_zmax->value()-
ui->edit_zmin->value();
1050 res_y =
ui->res_y->value();
1053 res_x = (int)(res_y * dia_x / dia_y);
1054 ui->res_x->setValue(res_x);
1057 res_z = (int)(res_y * dia_z / dia_y);
1058 ui->res_z->setValue(res_z);
1077 dia_x =
ui->edit_xmax->value()-
ui->edit_xmin->value();
1078 dia_y =
ui->edit_ymax->value()-
ui->edit_ymin->value();
1079 dia_z =
ui->edit_zmax->value()-
ui->edit_zmin->value();
1081 res_z =
ui->res_z->value();
1084 res_x = (int)(res_z * dia_x / dia_z);
1085 ui->res_x->setValue(res_x);
1088 res_y = (int)(res_z * dia_y / dia_z);
1089 ui->res_y->setValue(res_y);
1101 QColor color = QColorDialog::getColor(Qt::black,
this,
"Ambient Colot", QColorDialog::DontUseNativeDialog);
1105 ui->glwidget->redAmbient = (float)color.red()/255.0;
1106 ui->glwidget->greenAmbient = (float)color.green()/255.0;
1107 ui->glwidget->blueAmbient = (float)color.blue()/255.0;
1109 ui->glwidget->init();
1110 ui->glwidget->updateGL();
1121 QColor color = QColorDialog::getColor(Qt::black,
this,
"Model Color", QColorDialog::DontUseNativeDialog);
1125 ui->glwidget->redModel = (float)color.red()/255.0;
1126 ui->glwidget->greenModel = (float)color.green()/255.0;
1127 ui->glwidget->blueModel = (float)color.blue()/255.0;
1129 ui->glwidget->init();
1130 ui->glwidget->updateGL();
1141 QColor color = QColorDialog::getColor(Qt::black,
this,
"Baclground Color", QColorDialog::DontUseNativeDialog);
1145 ui->glwidget->backroundColor = color;
1147 ui->glwidget->init();
1148 ui->glwidget->updateGL();
1177 if (
ui->glwidget->stl_data[0].size()>0){
1180 for (l = 0; l <=
ui->glwidget->stl_data[0].size() - 4; l = l + 4)
1184 vertex1[0] =
ui->glwidget->stl_data[0].at(l+1)-(
ui->glwidget->x_min);
1185 vertex1[1] =
ui->glwidget->stl_data[1].at(l+1)-(
ui->glwidget->y_min);
1186 vertex1[2] =
ui->glwidget->stl_data[2].at(l+1)-(
ui->glwidget->z_min);
1187 vertex2[0] =
ui->glwidget->stl_data[0].at(l+2)-(
ui->glwidget->x_min);
1188 vertex2[1] =
ui->glwidget->stl_data[1].at(l+2)-(
ui->glwidget->y_min);
1189 vertex2[2] =
ui->glwidget->stl_data[2].at(l+2)-(
ui->glwidget->z_min);
1190 vertex3[0] =
ui->glwidget->stl_data[0].at(l+3)-(
ui->glwidget->x_min);
1191 vertex3[1] =
ui->glwidget->stl_data[1].at(l+3)-(
ui->glwidget->y_min);
1192 vertex3[2] =
ui->glwidget->stl_data[2].at(l+3)-(
ui->glwidget->z_min);
1194 ux = vertex2[0] - vertex1[0];
1195 uy = vertex2[1] - vertex1[1];
1196 uz = vertex2[2] - vertex1[2];
1198 wx = vertex3[0] - vertex1[0];
1199 wy = vertex3[1] - vertex1[1];
1200 wz = vertex3[2] - vertex1[2];
1202 xComp = uy*wz - uz*wy;
1203 yComp = uz*wx - ux*wz;
1204 zComp = ux*wy - uy*wx;
1206 ui->glwidget->stl_data[0][l] = xComp;
1207 ui->glwidget->stl_data[1][l] = yComp;
1208 ui->glwidget->stl_data[2][l] = zComp;
1212 ui->glwidget->updateGL();
1228 ui->glwidget->x_min =
ui->edit_xmin->value();
1229 ui->glwidget->y_min =
ui->edit_ymin->value();
1230 ui->glwidget->z_min =
ui->edit_zmin->value();
1231 ui->glwidget->x_max =
ui->edit_xmax->value();
1232 ui->glwidget->y_max =
ui->edit_ymax->value();
1233 ui->glwidget->z_max =
ui->edit_zmax->value();
1235 ui->glwidget->sampled_data[0].clear();
1236 ui->glwidget->sampled_data[1].clear();
1237 ui->glwidget->sampled_data[2].clear();
1239 float spacing_x = (
ui->glwidget->x_max -
ui->glwidget->x_min)/(
float)ZAX;
1240 float spacing_y = (
ui->glwidget->y_max -
ui->glwidget->y_min)/(
float)ZAY;
1241 float spacing_z = (
ui->glwidget->z_max -
ui->glwidget->z_min)/(
float)ZAZ;
1243 ui->progressBar->setHidden(
false);
1245 for (
int l = 0; l < ZAX; l++){
1246 for (
int m = 0; m < ZAY; m++){
1247 for (
int n = 0; n < ZAZ; n++){
1249 if (bounding[l][m][n] != 0){
1251 ui->glwidget->sampled_data[0].append(
ui->glwidget->x_min + l*spacing_x);
1252 ui->glwidget->sampled_data[1].append(
ui->glwidget->y_min + m*spacing_y);
1253 ui->glwidget->sampled_data[2].append(
ui->glwidget->z_min + n*spacing_z);
1258 ui->progressBar->setValue(100.0/ZAX*l);
1261 ui->progressBar->setHidden(
true);
1271 if (
ui->drawer_chooser->currentText().compare(
"Raw Data")==0)
ui->glwidget->drawer = 1;
1272 if (
ui->drawer_chooser->currentText().compare(
"Sampled Data")==0)
ui->glwidget->drawer = 2;
1274 ui->glwidget->updateGL();
1283 ui->glwidget->point_size =
ui->dial_point_size->value();
1284 ui->glwidget->updateGL();
1294 ui->glwidget->shininess = 128 -
ui->dial->value();
1295 ui->glwidget->updateGL();
1305 myhelp->setWindowModality(Qt::ApplicationModal);
1306 myhelp->setWindowFlags(Qt::WindowStaysOnTopHint);
1318 myAbout->setWindowModality(Qt::ApplicationModal);
1319 myAbout->setWindowFlags(Qt::WindowStaysOnTopHint);