79 template <
typename T1>
94 template <
typename T1>
111 template <
typename T1>
130 template <
typename T1>
134 uhbd->Generate_Skin(skin_size, 5);
155 template <
typename T1>
177 template <
typename T1>
201 template <
typename T1>
207 if (x < 0 or y < 0 or z < 0 )
210 if (Skin_Grid[x][y][z] ==
false){
211 if (Exterior[x][y][z] ==
false){
212 Exterior[x][y][z] =
true;
233 template <
typename T1>
239 if (Exterior[i][j][layer] ==
true)
244 std::cout << std::endl;
247 else if (dimension == 1){
250 if (Exterior[layer][j][k] ==
true)
255 std::cout << std::endl;
258 else if (dimension == 2){
261 if (Exterior[i][layer][k] ==
true)
266 std::cout << std::endl;
270 std::cout <<
"Check the dimension flag!!" << std::endl;
291 template <
typename T1>
294 Exterior =
new bool ** [
LengthX];
296 Exterior[i] =
new bool * [
LengthY];
298 Exterior[i][j] =
new bool [
LengthZ];
305 Exterior[i][j][k] =
false;
312 if (Skin_Grid[i][j][0] ==
false){
313 if (Exterior[i][j][0] ==
false){
314 Exterior[i][j][0] =
true;
322 if (Skin_Grid[i][j][
LengthZ-1] ==
false){
323 if (Exterior[i][j][
LengthZ-1] ==
false){
324 Exterior[i][j][
LengthZ-1] =
true;
336 if (Skin_Grid[0][j][k] ==
false){
337 if (Exterior[0][j][k] ==
false){
338 Exterior[0][j][k] =
true;
346 if (Skin_Grid[LengthX-1][j][k] ==
false){
347 if (Exterior[LengthX-1][j][k] ==
false){
348 Exterior[LengthX-1][j][k] =
true;
361 if (Skin_Grid[i][0][k] ==
false){
362 if (Exterior[i][0][k] ==
false){
363 Exterior[i][0][k] =
true;
371 if (Skin_Grid[i][LengthY-1][k] ==
false){
372 if (Exterior[i][LengthY-1][k] ==
false){
373 Exterior[i][LengthY-1][k] =
true;
393 template <
typename T1>
396 std::cout <<
"Generating the DT-Grid structure ..." << std::endl;
397 int componentY, componentZ;
398 int prev_componentY, prev_componentZ;
400 prev_componentY = -1;
403 prev_componentZ = -1;
409 if (Skin_Grid[i][j][k] ==
true){
418 if (Skin_Grid[i][j][k-1] ==
false){
422 if (componentZ == 1){
431 if (Skin_Grid[i][j][k] ==
true){
432 Value.push_back(UHBD_Grid[i][j][k]);
437 acc.push_back(((
int)
Value.size())-1);
442 if (Skin_Grid[i][j][k-1] ==
false){
445 acc.push_back(((
int)
Value.size())-1);
446 if (componentZ == 1){
455 if (k == (LengthZ-1)){
456 if (Skin_Grid[i][j][k] ==
true){
460 if (Skin_Grid[i][j][k-1] ==
true){
467 if (Skin_Grid[i][j][k-1] ==
true){
468 if (Skin_Grid[i][j][k] ==
false){
487 if (prev_componentZ == 0){
492 if (componentY == 1){
499 if (j == (LengthY-1)){
504 if (prev_componentZ > 0){
510 if (prev_componentZ > 0){
511 if (componentZ == 0){
516 prev_componentZ = componentZ;
525 if (prev_componentY == 0){
532 if (i == (LengthX-1)){
537 if (prev_componentY > 0){
543 if (prev_componentY > 0){
544 if (componentY == 0){
549 prev_componentY = componentY;
551 std::cout <<
"DT-Grid structure is generated successfully!" << std::endl;
564 template <
typename T1>
568 std::cout <<
"Writing the DT-Grid (ASCII) to the output file ..." << std::endl;
570 fprintf(output_file,
"%72s\n",
uhbd->Title);
571 fprintf(output_file,
"%12.5E%12.5E%7d%7d%7d%7d%7d\n",
uhbd->scale, \
573 fprintf(output_file,
"%7d%7d%7d%12.5E%12.5E%12.5E%12.5E\n",
uhbd->dim.i,
uhbd->dim.j, \
575 fprintf(output_file,
"%12.5E%12.5E%12.5E%12.5E\n",
uhbd->dummy2,
uhbd->dummy3,
uhbd->dummy4,
uhbd->dummy5);
576 fprintf(output_file,
"%12.5E%12.5E%7d%7d\n",
uhbd->dummy6,
uhbd->dummy7,
uhbd->idummy4,
uhbd->idummy5);
591 template <
typename T1>
594 int binary_dt_type = 2;
595 int flag_binary = 160;
597 std::cout <<
"Writing the DT-Grid (Binary) to the output file ..." << std::endl;
598 fwrite(&flag_binary,
sizeof(
int),1,output_file);
599 fwrite(
uhbd->Title,
sizeof(
char), 72, output_file);
600 fwrite(&(
uhbd->scale),
sizeof(
float),1,output_file);
601 fwrite(&(
uhbd->dummy1),
sizeof(
float),1,output_file);
602 fwrite(&binary_dt_type,
sizeof(
int),1,output_file);
603 fwrite(&(
uhbd->idummy1),
sizeof(
int),1,output_file);
604 fwrite(&(
uhbd->idummy2),
sizeof(
int),1,output_file);
605 fwrite(&(
uhbd->one),
sizeof(
int),1,output_file);
606 fwrite(&(
uhbd->idummy3),
sizeof(
int),1,output_file);
607 fwrite(&(
uhbd->dim.i),
sizeof(
int),1,output_file);
608 fwrite(&(
uhbd->dim.j),
sizeof(
int),1,output_file);
609 fwrite(&(
uhbd->dim.k),
sizeof(
int),1,output_file);
610 fwrite(&(
uhbd->spacing),
sizeof(
float),1,output_file);
611 fwrite(&(
uhbd->o.x),
sizeof(
float),1,output_file);
612 fwrite(&(
uhbd->o.y),
sizeof(
float),1,output_file);
613 fwrite(&(
uhbd->o.z),
sizeof(
float),1,output_file);
614 fwrite(&(
uhbd->dummy2),
sizeof(
float),1,output_file);
615 fwrite(&(
uhbd->dummy3),
sizeof(
float),1,output_file);
616 fwrite(&(
uhbd->dummy4),
sizeof(
float),1,output_file);
617 fwrite(&(
uhbd->dummy5),
sizeof(
float),1,output_file);
618 fwrite(&(
uhbd->dummy6),
sizeof(
float),1,output_file);
619 fwrite(&(
uhbd->dummy7),
sizeof(
float),1,output_file);
620 fwrite(&(
uhbd->idummy4),
sizeof(
int),1,output_file);
621 fwrite(&(
uhbd->idummy5),
sizeof(
int),1,output_file);
634 template <
typename T1>
637 char output_file_name [] =
"sphere.grd";
638 char Title [] =
"Sphere ";
640 float scale = 1.0, spacing = 0.1;
641 float dummy1 = 0.0, dummy2 = 0.0, dummy3 = 0.0, dummy4 = 0.0, dummy5 = 0.0, dummy6 = 0.0, dummy7 = 0.0;
642 float o_x = 0.0, o_y = 0.0, o_z = 0.0;
643 int idummy1 = 0, idummy2 = 0, idummy3 = 0, idummy4 = 0, idummy5 = 0;
646 std::cout <<
"Writing the DT-Grid (ASCII) to the output file ..." << std::endl;
647 fprintf(output_file,
"%72s\n", Title);
648 fprintf(output_file,
"%12.5E%12.5E%7d%7d%7d%7d%7d\n", scale, dummy1, 3, idummy1, idummy2, one, idummy3);
649 fprintf(output_file,
"%7d%7d%7d%12.5E%12.5E%12.5E%12.5E\n", dimi, dimj, dimk, spacing, o_x, o_y, o_z);
650 fprintf(output_file,
"%12.5E%12.5E%12.5E%12.5E\n", dummy2, dummy3, dummy4, dummy5);
651 fprintf(output_file,
"%12.5E%12.5E%7d%7d\n", dummy6, dummy7, idummy4, idummy5);
665 template <
typename T1>
668 char Title [] =
"Sphere ";
670 float scale = 1.0, spacing = 0.1;
671 float dummy1 = 0.0, dummy2 = 0.0, dummy3 = 0.0, dummy4 = 0.0, dummy5 = 0.0, dummy6 = 0.0, dummy7 = 0.0;
672 float o_x = 0.0, o_y = 0.0, o_z = 0.0;
673 int idummy1 = 0, idummy2 = 0, idummy3 = 0, idummy4 = 0, idummy5 = 0;
676 int binary_dt_type = 2;
677 int flag_binary = 160;
678 std::cout <<
"Writing the DT-Grid to the output file ..." << std::endl;
679 fwrite(&flag_binary,
sizeof(
int),1,output_file);
680 fwrite(Title,
sizeof(
char), 72, output_file);
681 fwrite(&(scale),
sizeof(
float),1,output_file);
682 fwrite(&(dummy1),
sizeof(
float),1,output_file);
683 fwrite(&binary_dt_type,
sizeof(
int),1,output_file);
684 fwrite(&(idummy1),
sizeof(
int),1,output_file);
685 fwrite(&(idummy2),
sizeof(
int),1,output_file);
686 fwrite(&(one),
sizeof(
int),1,output_file);
687 fwrite(&(idummy3),
sizeof(
int),1,output_file);
688 fwrite(&(dimi),
sizeof(
int),1,output_file);
689 fwrite(&(dimj),
sizeof(
int),1,output_file);
690 fwrite(&(dimk),
sizeof(
int),1,output_file);
691 fwrite(&(spacing),
sizeof(
float),1,output_file);
692 fwrite(&(o_x),
sizeof(
float),1,output_file);
693 fwrite(&(o_y),
sizeof(
float),1,output_file);
694 fwrite(&(o_z),
sizeof(
float),1,output_file);
695 fwrite(&(dummy2),
sizeof(
float),1,output_file);
696 fwrite(&(dummy3),
sizeof(
float),1,output_file);
697 fwrite(&(dummy4),
sizeof(
float),1,output_file);
698 fwrite(&(dummy5),
sizeof(
float),1,output_file);
699 fwrite(&(dummy6),
sizeof(
float),1,output_file);
700 fwrite(&(dummy7),
sizeof(
float),1,output_file);
701 fwrite(&(idummy4),
sizeof(
int),1,output_file);
702 fwrite(&(idummy5),
sizeof(
int),1,output_file);
713 template <
typename T1>
718 fprintf(output_file,
"%10d%10d%10d\n", (
int)
xcoord.size(), (int)
ycoord.size(), (int)
zcoord.size());
719 fprintf(output_file,
"%10d%10d%10d\n", (
int)
acc.size(), (int)
acc2D.size(), (int)
acc3D.size());
720 fprintf(output_file,
"%10d%10d\n", ((
int)
proj1D.size())+2, ((
int)
proj2D.size())+2);
724 typename std::vector<T1>::iterator itf;
725 std::vector<int>::iterator it;
729 for (itf =
Value.begin(); itf !=
Value.end(); itf++){
730 fprintf(output_file,
"\t%E", (
float) *itf);
733 fprintf(output_file,
"\n");
737 fprintf(output_file,
"\n");
745 fprintf(output_file,
"\t%d", *it);
748 fprintf(output_file,
"\n");
754 fprintf(output_file,
"\n");
755 for (it =
acc.begin(); it !=
acc.end(); it++){
756 fprintf(output_file,
"\t%d", *it);
759 fprintf(output_file,
"\n");
765 fprintf(output_file,
"\n");
767 if (fmod(counter,2) == 0)
768 fprintf(output_file,
"\t%d", *it);
770 fprintf(output_file,
"\t%d", (*it)/2);
773 fprintf(output_file,
"\n");
780 fprintf(output_file,
"\t%d", *it);
782 fprintf(output_file,
"\t%d", (*it)/2+1);
789 fprintf(output_file,
"\n");
791 fprintf(output_file,
"\t%d", *it);
794 fprintf(output_file,
"\n");
800 fprintf(output_file,
"\n");
801 for (it =
acc2D.begin(); it !=
acc2D.end(); it++){
802 fprintf(output_file,
"\t%d", (*it)/2);
805 fprintf(output_file,
"\n");
811 fprintf(output_file,
"\n");
813 fprintf(output_file,
"\t%d", (*it)/2);
816 fprintf(output_file,
"\n");
823 fprintf(output_file,
"\t%d", (*it)/2);
825 fprintf(output_file,
"\t%d", (*it)/2+1);
831 fprintf(output_file,
"\n");
833 fprintf(output_file,
"\t%d", *it);
836 fprintf(output_file,
"\n");
842 fprintf(output_file,
"\n");
843 for (it =
acc3D.begin(); it !=
acc3D.end(); it++){
844 fprintf(output_file,
"\t%d", (*it)/2);
847 fprintf(output_file,
"\n");
851 fprintf(output_file,
"\n");
861 template <
typename T1>
868 fwrite(dt_header_buffer,
sizeof(
int), 10, output_file);
871 typename std::vector<T1>::iterator itf;
872 std::vector<int>::iterator it;
880 for (itf =
Value.begin(); itf !=
Value.end(); itf++){
881 itf_val = (float) *itf;
882 fwrite(&itf_val,
sizeof(
float),1, output_file);
892 fwrite(&it_val,
sizeof(
int),1, output_file);
896 for (it =
acc.begin(); it !=
acc.end(); it++){
898 fwrite(&it_val,
sizeof(
int),1, output_file);
904 if (fmod(counter,2) == 0){
906 fwrite(&it_val,
sizeof(
int),1, output_file);
910 fwrite(&it_val,
sizeof(
int),1, output_file);
923 it_val = (int)
Value.size();
924 fwrite(&it_val,
sizeof(
int),1, output_file);
926 it_val = ((int)
zcoord.size() / 2) - 1;
927 fwrite(&it_val,
sizeof(
int),1, output_file);
932 fwrite(&it_val,
sizeof(
int),1, output_file);
936 for (it =
acc2D.begin(); it !=
acc2D.end(); it++){
938 fwrite(&it_val,
sizeof(
int),1, output_file);
944 fwrite(&it_val,
sizeof(
int),1, output_file);
954 it_val = (int)
proj1D.size() / 2;
955 fwrite(&it_val,
sizeof(
int),1, output_file);
957 it_val = ((int)
ycoord.size() / 2) - 1;
958 fwrite(&it_val,
sizeof(
int),1, output_file);
963 fwrite(&it_val,
sizeof(
int),1, output_file);
967 for (it =
acc3D.begin(); it !=
acc3D.end(); it++){
969 fwrite(&it_val,
sizeof(
int),1, output_file);
Definition: UHBDgrd.hpp:24
int write_dtgrdfile_ascii_nouhbd(FILE *)
Write dt-grid file for test cases.
Definition: DTgrd.hpp:635
std::vector< int > zcoord
icoord array (min and max indices of connected components in y direction)
Definition: DTgrd.hpp:47
std::vector< T1 > Value
Definition: DTgrd.hpp:44
int grid_type_flag
Definition: DTgrd.hpp:34
DT_FILE(int)
DT_FILE constructor - 1.
Definition: DTgrd.hpp:80
int Generate_DTGrid(bool ***, T1 ***)
Generate the DT-Grid structure!
Definition: DTgrd.hpp:394
std::vector< int > acc
icoord array (min and max indices of connected components in z direction)
Definition: DTgrd.hpp:48
void exclusion(char *, float, float)
Create a UHBD object for excluded volume type interactions.
Definition: DTgrd.hpp:156
std::vector< int > ycoord
icoord array (min and max indices of connected components in x direction)
Definition: DTgrd.hpp:46
int uhbd_alloc
a uhbd object for the input UHBD file
Definition: DTgrd.hpp:42
int write_dtgrdfile_binary(FILE *)
Write the DT-Grid structure into the DT-Grid file in binary format.
Definition: DTgrd.hpp:592
int write_dtgrdfile_binary_nouhbd(FILE *)
Write dt-grid file for test cases.
Definition: DTgrd.hpp:666
int write_dtgrdfile_ascii(FILE *)
Write the DT-Grid structure into the DT-Grid file in ASCII format.
Definition: DTgrd.hpp:565
Define a 3D UHBD grid and functions to read-write its format files.
std::vector< int > proj2D
projection array to bridge 1D and 2D DT-Grids
Definition: DTgrd.hpp:52
bool *** exterior_grid(bool ***)
Create the exterior grid.
Definition: DTgrd.hpp:292
UHBD< T1 > * uhbd
number of points along z axis (in uhbd grid)
Definition: DTgrd.hpp:41
std::vector< int > xcoord
'value' array of the DT-Grid
Definition: DTgrd.hpp:45
std::vector< int > acc3D
acc pointer array for two dimensional DT-Grid
Definition: DTgrd.hpp:50
int LengthY
number of points along x axis (in uhbd grid)
Definition: DTgrd.hpp:38
int write_dtgrdfilebody_binary(FILE *)
Write the DT-Grid body into the DT-Grid file in Binary format.
Definition: DTgrd.hpp:862
std::vector< int > acc2D
acc pointer array for one dimensional DT-Grid
Definition: DTgrd.hpp:49
int check_neighbours(bool ***, bool ***, int, int, int)
projection array to bridge 2D and 3D DT-Grids
Definition: DTgrd.hpp:202
int LengthZ
number of points along y axis (in uhbd grid)
Definition: DTgrd.hpp:39
void UHBD_upload(char *, char *, float, float)
Create a UHBD object using the uhbd-file input.
Definition: DTgrd.hpp:131
std::vector< int > proj1D
acc pointer array for three dimensional DT-Grid
Definition: DTgrd.hpp:51
int LengthX
input pqr or pdb?
Definition: DTgrd.hpp:37
bool pqr_flag
0 for excluded volume, 1 for data grid
Definition: DTgrd.hpp:35
int write_dtgrdfilebody_ascii(FILE *)
Write the DT-Grid body into the DT-Grid file in ASCII format.
Definition: DTgrd.hpp:714
int print_layer(bool ***, int, int)
Print a 2D slice for an exterior grid.
Definition: DTgrd.hpp:234