25 #include <basic/Tracer.hh>
27 #include <utility/vector1.hh>
33 static basic::Tracer
TR(
"protocols.BumpGrid" );
38 bb_extended_(
Vector(0.0) ),
67 Vector local_center = center -
bb_.lower();
68 Vector low_corner = local_center - radius;
70 assert( low_corner.x() >= 0.0 && low_corner.y() >= 0.0 && low_corner.z() >= 0.0 );
72 Bin3D halfgrid_of_lowcorner;
73 halfgrid_of_lowcorner[ 1 ] =
static_cast< Size > ( low_corner.x() / ( 2 *
bin_width_ ) );
74 halfgrid_of_lowcorner[ 2 ] =
static_cast< Size > ( low_corner.y() / ( 2 *
bin_width_ ) );
75 halfgrid_of_lowcorner[ 3 ] =
static_cast< Size > ( low_corner.z() / ( 2 *
bin_width_ ) );
78 aligned_low_corner.x() +=
bin_width_2x_ * halfgrid_of_lowcorner[ 1 ];
79 aligned_low_corner.y() +=
bin_width_2x_ * halfgrid_of_lowcorner[ 2 ];
80 aligned_low_corner.z() +=
bin_width_2x_ * halfgrid_of_lowcorner[ 3 ];
82 Vector upper_corner = local_center + radius;
95 Vector local_center = bb.lower() -
bb_.lower();
97 utility::fixedsizearray1< int, 3 > floored_lower;
98 floored_lower[ 1 ] =
static_cast< Size > ( local_center.x() /
bin_width_ );
99 floored_lower[ 2 ] =
static_cast< Size > ( local_center.y() /
bin_width_ );
100 floored_lower[ 3 ] =
static_cast< Size > ( local_center.z() /
bin_width_ );
117 using namespace core;
119 Real const rad2 = radius * radius;
125 if ( rad_minus_cendis < 0 ) {
130 Real rad_minus_cendis2 = rad_minus_cendis * rad_minus_cendis;
132 Real const rad_plus_cendis2 = rad_plus_cendis * rad_plus_cendis;
137 SSize xlo( static_cast< SSize > ((relpos.x() - radius) /
bin_width_ ));
138 SSize xhi( static_cast< SSize > ((relpos.x() + radius) /
bin_width_ ) + 1);
139 SSize ylo( static_cast< SSize > ((relpos.y() - radius) /
bin_width_ ));
140 SSize yhi( static_cast< SSize > ((relpos.y() + radius) /
bin_width_ ) + 1);
141 SSize zlo( static_cast< SSize > ((relpos.z() - radius) /
bin_width_ ));
142 SSize zhi( static_cast< SSize > ((relpos.z() + radius) /
bin_width_ ) + 1);
144 Size uxlo = xlo < 0 ? 0 : xlo;
146 Size uylo = ylo < 0 ? 0 : ylo;
148 Size uzlo = zlo < 0 ? 0 : zlo;
151 for (
Size ii = uxlo; ii < uxhi; ++ii ) {
153 for (
Size jj = uylo; jj < uyhi; ++jj ) {
155 for (
Size kk = uzlo; kk < uzhi; ++kk ) {
159 Real sphere_cent_to_voxel_cent2 = bin_center_point.distance_squared( center );
160 if ( sphere_cent_to_voxel_cent2 > rad_plus_cendis2 )
continue;
162 bool all_contained(
true );
163 if ( sphere_cent_to_voxel_cent2 > rad_minus_cendis2 ) {
164 utility::fixedsizearray1< Vector, 8 > grid_corners =
corners( bin );
165 for (
Size ll = 1; ll <= 8; ++ll ) {
166 Real d2 = center.distance_squared( grid_corners[ ll ] );
167 if ( d2 > rad2 ) { all_contained =
false;
break; }
170 if ( all_contained ) {
208 using namespace core;
210 Real const rad2 = radius * radius;
213 Real rad_minus_cendis2 = rad_minus_cendis * rad_minus_cendis;
215 Real const rad_plus_cendis2 = rad_plus_cendis * rad_plus_cendis;
219 SSize xlo( static_cast< SSize > ((relpos.x() - radius) /
bin_width_ ));
220 SSize xhi( static_cast< SSize > ((relpos.x() + radius) /
bin_width_ ) + 1);
221 SSize ylo( static_cast< SSize > ((relpos.y() - radius) /
bin_width_ ));
222 SSize yhi( static_cast< SSize > ((relpos.y() + radius) /
bin_width_ ) + 1);
223 SSize zlo( static_cast< SSize > ((relpos.z() - radius) /
bin_width_ ));
224 SSize zhi( static_cast< SSize > ((relpos.z() + radius) /
bin_width_ ) + 1);
226 Size uxlo = xlo < 0 ? 0 : xlo;
228 Size uylo = ylo < 0 ? 0 : ylo;
230 Size uzlo = zlo < 0 ? 0 : zlo;
233 for (
Size ii = uxlo; ii < uxhi; ++ii ) {
235 for (
Size jj = uylo; jj < uyhi; ++jj ) {
237 for (
Size kk = uzlo; kk < uzhi; ++kk ) {
241 Real sphere_cent_to_voxel_cent2 = bin_center_point.distance_squared( center );
247 if ( sphere_cent_to_voxel_cent2 > rad_plus_cendis2 )
continue;
250 bool any_contained( sphere_cent_to_voxel_cent2 < rad2 );
252 if ( !any_contained && sphere_cent_to_voxel_cent2 > rad_minus_cendis2 ) {
254 utility::fixedsizearray1< Vector, 8 > grid_corners =
corners( bin );
255 for (
Size ll = 1; ll <= 8; ++ll ) {
256 Real d2 = center.distance_squared( grid_corners[ ll ] );
257 if ( d2 < rad2 ) { any_contained =
true;
break; }
259 if ( ! any_contained ) {
262 bool x_in_range = ( center.x() >= grid_corners[ 1 ].x() && center.x() <= grid_corners[ 8 ].x() );
263 bool y_in_range = ( center.y() >= grid_corners[ 1 ].y() && center.y() <= grid_corners[ 8 ].y() );
264 bool z_in_range = ( center.z() >= grid_corners[ 1 ].z() && center.z() <= grid_corners[ 8 ].z() );
265 Size n_in_range = (
Size) x_in_range + (
Size ) y_in_range + (
Size ) z_in_range;
267 if ( n_in_range == 2 ) {
270 Size dim_out_of_range( 1 );
271 if ( ! x_in_range ) {
272 dim_out_of_range = 1;
273 }
else if ( ! y_in_range ) {
274 dim_out_of_range = 2;
276 assert( ! z_in_range );
277 dim_out_of_range = 3;
281 if ( center( dim_out_of_range ) < grid_corners[ 1 ]( dim_out_of_range )) {
282 dim_edge = grid_corners[ 1 ]( dim_out_of_range );
284 dim_edge = grid_corners[ 8 ]( dim_out_of_range );
286 Real d = center( dim_out_of_range ) - dim_edge;
288 any_contained =
true;
294 if ( any_contained ) {
313 for (
Size jj = 0; jj < dimsizes_[ 2 ]; ++jj ) {
315 for (
Size kk = 0; kk < dimsizes_[ 3 ]; ++kk ) {
318 bool all_corners_contained(
true );
319 for (
Size ll = 1; ll <= 8; ++ll ) {
320 bool contained_anywhere(
false );
321 for (
Size mm = 1; mm <= spheres.size(); ++mm ) {
322 Real d2 = spheres[ mm ].first.distance_squared( grid_corners[ ll ] );
323 if ( d2 <= spheres[ mm ].second ) { contained_anywhere =
true;
break; }
325 if ( ! contained_anywhere ) {
326 all_corners_contained =
false;
330 if ( all_corners_contained ) {
346 Vector clipped_lower( bb.lower() ), clipped_upper( bb.upper() );
347 for (
Size ii = 1; ii <= 3; ++ii )
if ( clipped_lower( ii ) <
bb_.lower()( ii ) ) clipped_lower( ii ) =
bb_.lower()( ii );
348 for (
Size ii = 1; ii <= 3; ++ii ) if ( clipped_upper( ii ) >
bb_.upper()( ii ) ) clipped_upper( ii ) =
bb_.upper()( ii );
354 for (
Size ii = bin_lo[ 1 ]; ii <= bin_hi[ 1 ]; ++ii ) {
356 for (
Size jj = bin_lo[ 2 ]; jj <= bin_hi[ 2 ]; ++jj ) {
358 for (
Size kk = bin_lo[ 3 ]; kk <= bin_hi[ 3 ]; ++kk ) {
388 Real const xlo( lower_corner.x() ), xhi( lower_corner.x() +
bin_width_ );
389 Real const ylo( lower_corner.y() ), yhi( lower_corner.y() +
bin_width_ );
390 Real const zlo( lower_corner.z() ), zhi( lower_corner.z() +
bin_width_ );
392 corns[ 1 ] =
Vector( xlo, ylo, zlo );
393 corns[ 2 ] =
Vector( xlo, ylo, zhi );
394 corns[ 3 ] =
Vector( xlo, yhi, zlo );
395 corns[ 4 ] =
Vector( xlo, yhi, zhi );
396 corns[ 5 ] =
Vector( xhi, ylo, zlo );
397 corns[ 6 ] =
Vector( xhi, ylo, zhi );
398 corns[ 7 ] =
Vector( xhi, yhi, zlo );
399 corns[ 8 ] =
Vector( xhi, yhi, zhi );
442 return grid_[ imp.first ] & imp.second;
447 for (
Size ii = 1; ii <= 3; ++ii ) {
448 if ( bin[ ii ] >=
dimsizes_[ ii ] )
return false;
453 return grid_[ imp.first ] & imp.second;
463 halfbin[ 1 ] = bin[ 1 ] / 2;
Size xmod2 = bin[ 1 ] % 2;
464 halfbin[ 2 ] = bin[ 2 ] / 2;
Size ymod2 = bin[ 2 ] % 2;
465 halfbin[ 3 ] = bin[ 3 ] / 2;
Size zmod2 = bin[ 3 ] % 2;
468 unsigned char & voxel_bits(
grid_[ index ] );
476 voxel_bits |= voxbit;
509 std::max(
bb_.lower().x(), other.
bb_.lower().x() ),
510 std::max(
bb_.lower().y(), other.
bb_.lower().y() ),
511 std::max(
bb_.lower().z(), other.
bb_.lower().z() ) );
514 std::min(
bb_.upper().x(), other.
bb_.upper().x() ),
515 std::min(
bb_.upper().y(), other.
bb_.upper().y() ),
516 std::min(
bb_.upper().z(), other.
bb_.upper().z() ) );
519 if ( overlap_low.x() >= overlap_high.x() ||
520 overlap_low.y() >= overlap_high.y() ||
521 overlap_low.z() >= overlap_high.z() )
return;
525 assert( std::abs( (overlap_low.x() -
bb_.lower().x()) -
bin_width_ * static_cast< int > ((overlap_low.x() -
bb_.lower().x()) /
bin_width_ )) < 1e-6 );
526 assert( std::abs( (overlap_low.y() -
bb_.lower().y()) -
bin_width_ * static_cast< int > ((overlap_low.y() -
bb_.lower().y()) /
bin_width_ )) < 1e-6 );
527 assert( std::abs( (overlap_low.z() -
bb_.lower().z()) -
bin_width_ * static_cast< int > ((overlap_low.z() -
bb_.lower().z()) /
bin_width_ )) < 1e-6 );
529 assert( std::abs( (overlap_low.x() - other.
bb_.lower().x()) -
bin_width_ * static_cast< int > ((overlap_low.x() - other.
bb_.lower().x()) /
bin_width_ )) < 1e-6 );
530 assert( std::abs( (overlap_low.y() - other.
bb_.lower().y()) -
bin_width_ * static_cast< int > ((overlap_low.y() - other.
bb_.lower().y()) /
bin_width_ )) < 1e-6 );
531 assert( std::abs( (overlap_low.z() - other.
bb_.lower().z()) -
bin_width_ * static_cast< int > ((overlap_low.z() - other.
bb_.lower().z()) /
bin_width_ )) < 1e-6 );
536 n_overlap[ 1 ] =
static_cast< Size > (( overlap_high.x() - overlap_low.x() + perturb ) /
bin_width_ );
537 n_overlap[ 2 ] =
static_cast< Size > (( overlap_high.y() - overlap_low.y() + perturb ) /
bin_width_ );
538 n_overlap[ 3 ] =
static_cast< Size > (( overlap_high.z() - overlap_low.z() + perturb ) /
bin_width_ );
541 my_grid_start[ 1 ] =
static_cast< Size > (( overlap_low.x() -
bb_.lower().x() + perturb ) /
bin_width_ );
542 my_grid_start[ 2 ] =
static_cast< Size > (( overlap_low.y() -
bb_.lower().y() + perturb ) /
bin_width_ );
543 my_grid_start[ 3 ] =
static_cast< Size > (( overlap_low.z() -
bb_.lower().z() + perturb ) /
bin_width_ );
545 Bin3D other_grid_start;
546 other_grid_start[ 1 ] =
static_cast< Size > (( overlap_low.x() - other.
bb_.lower().x() + perturb ) /
bin_width_ );
547 other_grid_start[ 2 ] =
static_cast< Size > (( overlap_low.y() - other.
bb_.lower().y() + perturb ) /
bin_width_ );
548 other_grid_start[ 3 ] =
static_cast< Size > (( overlap_low.z() - other.
bb_.lower().z() + perturb ) /
bin_width_ );
553 for (
Size ii = 0; ii < n_overlap[ 1 ]; ++ii ) {
554 my_pos[ 1 ] = my_grid_start[ 1 ] + ii;
555 other_pos[ 1 ] = other_grid_start[ 1 ] + ii;
556 for (
Size jj = 0; jj < n_overlap[ 2 ]; ++jj ) {
557 my_pos[ 2 ] = my_grid_start[ 2 ] + jj;
558 other_pos[ 2 ] = other_grid_start[ 2 ] + jj;
559 for (
Size kk = 0; kk < n_overlap[ 3 ]; ++kk ) {
560 my_pos[ 3 ] = my_grid_start[ 3 ] + kk;
561 other_pos[ 3 ] = other_grid_start[ 3 ] + kk;
565 if (
grid_[ my_indmask.first ] & my_indmask.second )
continue;
566 if ( other.
grid_[ other_indmask.first ] & other_indmask.second ) {
567 grid_[ my_indmask.first ] |= my_indmask.second;
581 std::max(
bb_.lower().x(), other.
bb_.lower().x() ),
582 std::max(
bb_.lower().y(), other.
bb_.lower().y() ),
583 std::max(
bb_.lower().z(), other.
bb_.lower().z() ) );
586 std::min(
bb_.upper().x(), other.
bb_.upper().x() ),
587 std::min(
bb_.upper().y(), other.
bb_.upper().y() ),
588 std::min(
bb_.upper().z(), other.
bb_.upper().z() ) );
591 if ( overlap_low.x() >= overlap_high.x() ||
592 overlap_low.y() >= overlap_high.y() ||
593 overlap_low.z() >= overlap_high.z() )
return;
597 assert( std::abs( (overlap_low.x() -
bb_.lower().x()) -
bin_width_ * static_cast< int > ((overlap_low.x() -
bb_.lower().x()) /
bin_width_ )) < 1e-6 );
598 assert( std::abs( (overlap_low.y() -
bb_.lower().y()) -
bin_width_ * static_cast< int > ((overlap_low.y() -
bb_.lower().y()) /
bin_width_ )) < 1e-6 );
599 assert( std::abs( (overlap_low.z() -
bb_.lower().z()) -
bin_width_ * static_cast< int > ((overlap_low.z() -
bb_.lower().z()) /
bin_width_ )) < 1e-6 );
601 assert( std::abs( (overlap_low.x() - other.
bb_.lower().x()) -
bin_width_ * static_cast< int > ((overlap_low.x() - other.
bb_.lower().x()) /
bin_width_ )) < 1e-6 );
602 assert( std::abs( (overlap_low.y() - other.
bb_.lower().y()) -
bin_width_ * static_cast< int > ((overlap_low.y() - other.
bb_.lower().y()) /
bin_width_ )) < 1e-6 );
603 assert( std::abs( (overlap_low.z() - other.
bb_.lower().z()) -
bin_width_ * static_cast< int > ((overlap_low.z() - other.
bb_.lower().z()) /
bin_width_ )) < 1e-6 );
608 n_overlap[ 1 ] =
static_cast< Size > (( overlap_high.x() - overlap_low.x() + perturb ) /
bin_width_ );
609 n_overlap[ 2 ] =
static_cast< Size > (( overlap_high.y() - overlap_low.y() + perturb ) /
bin_width_ );
610 n_overlap[ 3 ] =
static_cast< Size > (( overlap_high.z() - overlap_low.z() + perturb ) /
bin_width_ );
613 my_grid_start[ 1 ] =
static_cast< Size > (( overlap_low.x() -
bb_.lower().x() + perturb ) /
bin_width_ );
614 my_grid_start[ 2 ] =
static_cast< Size > (( overlap_low.y() -
bb_.lower().y() + perturb ) /
bin_width_ );
615 my_grid_start[ 3 ] =
static_cast< Size > (( overlap_low.z() -
bb_.lower().z() + perturb ) /
bin_width_ );
617 Bin3D other_grid_start;
618 other_grid_start[ 1 ] =
static_cast< Size > (( overlap_low.x() - other.
bb_.lower().x() + perturb ) /
bin_width_ );
619 other_grid_start[ 2 ] =
static_cast< Size > (( overlap_low.y() - other.
bb_.lower().y() + perturb ) /
bin_width_ );
620 other_grid_start[ 3 ] =
static_cast< Size > (( overlap_low.z() - other.
bb_.lower().z() + perturb ) /
bin_width_ );
625 for (
Size ii = 0; ii < n_overlap[ 1 ]; ++ii ) {
626 my_pos[ 1 ] = my_grid_start[ 1 ] + ii;
627 other_pos[ 1 ] = other_grid_start[ 1 ] + ii;
628 for (
Size jj = 0; jj < n_overlap[ 2 ]; ++jj ) {
629 my_pos[ 2 ] = my_grid_start[ 2 ] + jj;
630 other_pos[ 2 ] = other_grid_start[ 2 ] + jj;
631 for (
Size kk = 0; kk < n_overlap[ 3 ]; ++kk ) {
632 my_pos[ 3 ] = my_grid_start[ 3 ] + kk;
633 other_pos[ 3 ] = other_grid_start[ 3 ] + kk;
637 if ( !
grid_[ my_indmask.first ] & my_indmask.second )
continue;
638 if ( other.
grid_[ other_indmask.first ] & other_indmask.second )
continue;
639 grid_[ my_indmask.first ] &= ~my_indmask.second;
654 std::max(
bb_.lower().x(), other.
bb_.lower().x() ),
655 std::max(
bb_.lower().y(), other.
bb_.lower().y() ),
656 std::max(
bb_.lower().z(), other.
bb_.lower().z() ) );
659 std::min(
bb_.upper().x(), other.
bb_.upper().x() ),
660 std::min(
bb_.upper().y(), other.
bb_.upper().y() ),
661 std::min(
bb_.upper().z(), other.
bb_.upper().z() ) );
664 if ( overlap_low.x() >= overlap_high.x() ||
665 overlap_low.y() >= overlap_high.y() ||
666 overlap_low.z() >= overlap_high.z() )
return;
670 assert( std::abs( (overlap_low.x() -
bb_.lower().x()) -
bin_width_ * static_cast< int > ((overlap_low.x() -
bb_.lower().x()) /
bin_width_ )) < 1e-6 );
671 assert( std::abs( (overlap_low.y() -
bb_.lower().y()) -
bin_width_ * static_cast< int > ((overlap_low.y() -
bb_.lower().y()) /
bin_width_ )) < 1e-6 );
672 assert( std::abs( (overlap_low.z() -
bb_.lower().z()) -
bin_width_ * static_cast< int > ((overlap_low.z() -
bb_.lower().z()) /
bin_width_ )) < 1e-6 );
674 assert( std::abs( (overlap_low.x() - other.
bb_.lower().x()) -
bin_width_ * static_cast< int > ((overlap_low.x() - other.
bb_.lower().x()) /
bin_width_ )) < 1e-6 );
675 assert( std::abs( (overlap_low.y() - other.
bb_.lower().y()) -
bin_width_ * static_cast< int > ((overlap_low.y() - other.
bb_.lower().y()) /
bin_width_ )) < 1e-6 );
676 assert( std::abs( (overlap_low.z() - other.
bb_.lower().z()) -
bin_width_ * static_cast< int > ((overlap_low.z() - other.
bb_.lower().z()) /
bin_width_ )) < 1e-6 );
681 n_overlap[ 1 ] =
static_cast< Size > (( overlap_high.x() - overlap_low.x() + perturb ) /
bin_width_ );
682 n_overlap[ 2 ] =
static_cast< Size > (( overlap_high.y() - overlap_low.y() + perturb ) /
bin_width_ );
683 n_overlap[ 3 ] =
static_cast< Size > (( overlap_high.z() - overlap_low.z() + perturb ) /
bin_width_ );
686 my_grid_start[ 1 ] =
static_cast< Size > (( overlap_low.x() -
bb_.lower().x() + perturb ) /
bin_width_ );
687 my_grid_start[ 2 ] =
static_cast< Size > (( overlap_low.y() -
bb_.lower().y() + perturb ) /
bin_width_ );
688 my_grid_start[ 3 ] =
static_cast< Size > (( overlap_low.z() -
bb_.lower().z() + perturb ) /
bin_width_ );
690 Bin3D other_grid_start;
691 other_grid_start[ 1 ] =
static_cast< Size > (( overlap_low.x() - other.
bb_.lower().x() + perturb ) /
bin_width_ );
692 other_grid_start[ 2 ] =
static_cast< Size > (( overlap_low.y() - other.
bb_.lower().y() + perturb ) /
bin_width_ );
693 other_grid_start[ 3 ] =
static_cast< Size > (( overlap_low.z() - other.
bb_.lower().z() + perturb ) /
bin_width_ );
698 for (
Size ii = 0; ii < n_overlap[ 1 ]; ++ii ) {
699 my_pos[ 1 ] = my_grid_start[ 1 ] + ii;
700 other_pos[ 1 ] = other_grid_start[ 1 ] + ii;
701 for (
Size jj = 0; jj < n_overlap[ 2 ]; ++jj ) {
702 my_pos[ 2 ] = my_grid_start[ 2 ] + jj;
703 other_pos[ 2 ] = other_grid_start[ 2 ] + jj;
704 for (
Size kk = 0; kk < n_overlap[ 3 ]; ++kk ) {
705 my_pos[ 3 ] = my_grid_start[ 3 ] + kk;
706 other_pos[ 3 ] = other_grid_start[ 3 ] + kk;
710 if ( !
grid_[ my_indmask.first ] & my_indmask.second )
continue;
712 if ( ! other.
grid_[ other_indmask.first ] & other_indmask.second )
continue;
714 grid_[ my_indmask.first ] &= ~my_indmask.second;
725 for (
Size ii = 0; ii <
grid_.size(); ++ii ) {
740 Size ymod2 = local.y() - halfbin[ 2 ] * bin_width_2x_ >=
bin_width_ ? 1 : 0;
741 Size zmod2 = local.z() - halfbin[ 3 ] * bin_width_2x_ >=
bin_width_ ? 1 : 0;
752 return std::make_pair( index, mask );
759 halfbin[ 1 ] = bin[ 1 ] / 2;
760 halfbin[ 2 ] = bin[ 2 ] / 2;
761 halfbin[ 3 ] = bin[ 3 ] / 2;
762 Size xmod2 = bin[ 1 ] % 2;
763 Size ymod2 = bin[ 2 ] % 2;
764 Size zmod2 = bin[ 3 ] % 2;
775 return std::make_pair( index, mask );
781 assert(
bb_.contains( point ) );
798 nbins[ 1 ] =
static_cast< Size > ( (local_upper_corner.x() + perturb ) /
bin_width_ );
799 nbins[ 2 ] =
static_cast< Size > ( (local_upper_corner.y() + perturb ) /
bin_width_ );
800 nbins[ 3 ] =
static_cast< Size > ( (local_upper_corner.z() + perturb ) /
bin_width_ );
802 if ( nbins[ 1 ] *
bin_width_ < local_upper_corner.x() ) ++nbins[ 1 ];
803 if ( nbins[ 2 ] *
bin_width_ < local_upper_corner.y() ) ++nbins[ 2 ];
804 if ( nbins[ 3 ] *
bin_width_ < local_upper_corner.z() ) ++nbins[ 3 ];
806 for (
Size ii = 1; ii <= 3; ++ii ) {
833 dimprods_[ 1 ] = dimprods_[ 2 ] *
dimsizes_[ 2 ];
838 grid_.resize( nchar );
839 std::fill(
grid_.begin(),
grid_.end(), (
unsigned char) 0 );
859 assert( xmod2 == 0 || xmod2 == 1 );
860 assert( ymod2 == 0 || ymod2 == 1 );
861 assert( zmod2 == 0 || zmod2 == 1 );
863 Size offset = 4 * xmod2 + 2 * ymod2 + zmod2;
865 case 0 :
return 0x01;
866 case 1 :
return 0x02;
867 case 2 :
return 0x04;
868 case 3 :
return 0x08;
869 case 4 :
return 0x10;
870 case 5 :
return 0x20;
871 case 6 :
return 0x40;
872 case 7 :
return 0x80;
874 utility_exit_with_message(
"ERROR: Bad input to Bool3DGrid mask from offsets" );
881 assert( xmod2 == 0 || xmod2 == 1 );
882 assert( ymod2 == 0 || ymod2 == 1 );
883 assert( zmod2 == 0 || zmod2 == 1 );
885 Size offset = 4 * xmod2 + 2 * ymod2 + zmod2;
887 case 0 :
return 0xFE;
888 case 1 :
return 0xFD;
889 case 2 :
return 0xFB;
890 case 3 :
return 0xF7;
891 case 4 :
return 0xEF;
892 case 5 :
return 0xDF;
893 case 6 :
return 0xBF;
894 case 7 :
return 0x7F;
896 utility_exit_with_message(
"ERROR: Bad input to Bool3DGrid negmask from offsets" );
929 general_permit_overlap_( 0.0 )
939 { 0, 0, 0, 0, 0, 0, 0, 0 },
940 { 0, 0, 0, 0.5, 0.5, 0, 0, 0 },
941 { 0, 0, 0, 0, 0, 0, 0, 0 },
942 { 0, 0.5, 0, 0.3, 0.3, 0, 0, 0 },
943 { 0, 0.5, 0, 0.3, 0.3, 0, 0, 0 },
944 { 0, 0, 0, 0, 0, 0, 0, 0 },
945 { 0, 0, 0, 0, 0, 0, 0, 0 },
946 { 0, 0, 0, 0, 0, 0, 0, 0 }};
959 pair_permit_overlap_( rhs.pair_permit_overlap_ ),
960 general_permit_overlap_( rhs.general_permit_overlap_ )
989 lower.x() =
static_cast< Real > (
static_cast< int > ( lower.x() ));
990 lower.y() =
static_cast< Real > (
static_cast< int > ( lower.y() ));
991 lower.z() =
static_cast< Real > (
static_cast< int > ( lower.z() ));
995 grids_[ ii ]->set_bin_width( 0.25 );
996 grids_[ ii ]->set_bounding_box( iibb );
1026 bgop->set_bounding_box( bb );
1033 if (
grids_[ ii ]->actual_bb().intersects( other.
grids_[ ii ]->actual_bb() ) ) {
1041 if (
grids_[ ii ]->actual_bb().intersects( other.
grids_[ ii ]->actual_bb() ) ) {
1061 if ( radius_type ==
ZERO )
return;
1064 grids_[ ii ]->or_by_sphere_conservative( center,
1072 if (
grids_[ ii ]->actual_bb().intersects( other.
grids_[ ii ]->actual_bb() ) ) {
1086 if ( radius_type ==
ZERO )
return false;
1088 return grids_[ radius_type ]->occupied( p );
1115 using namespace core;
1116 using namespace core::chemical;
1120 for (
Size ii = 1; ii <= atset->n_atomtypes(); ++ii ) {
1122 AtomType const & iiat( (*atset)[ ii ] );
1123 if ( iiat.
element() ==
"H" ) {
1124 if ( iiat.
name() ==
"Hapo" ) ii_probe_radius =
H_ALA;
1125 else ii_probe_radius =
H_ARO;
1126 }
else if ( iiat.
element() ==
"N" ) {
1127 ii_probe_radius =
NIT;
1128 }
else if ( iiat.
element() ==
"O" ) {
1129 ii_probe_radius =
OXY;
1130 }
else if ( iiat.
element() ==
"C" ) {
1131 if ( iiat.
name() ==
"CNH2" || iiat.
name() ==
"COO" || iiat.
name() ==
"CObb" ) ii_probe_radius =
C_CAR;
1132 else ii_probe_radius =
C_ALA;
1134 ii_probe_radius =
SULPH;
1136 ii_probe_radius =
ZERO;
1143 if ( rad <= radius_shrunk ) {
1150 attype_2_radtype[ ii ] = ii_probe_radius;
1151 TR <<
"Atom type " << iiat.
name() <<
" with ProbeRadius " << ii_probe_radius
1154 return attype_2_radtype;
1161 return attype_2_probe_radius[ atomtype ];
1168 using namespace core;
1176 bool found_an_atom(
false );
1181 found_an_atom =
true;
1185 if ( ! found_an_atom ) {
1191 Vector bbl( first_xyz - at1rad ), bbu( first_xyz + at1rad );
1195 bbl.min( pose.
residue( ii ).
xyz( jj ) - jjrad );
1196 bbu.max( pose.
residue( ii ).
xyz( jj ) + jjrad );
1201 numeric::geometry::BoundingBox< Vector > bb( bbl, bbu );
1202 bgop->set_bounding_box( bb );
1212 using namespace core;
1216 if ( residue.
natoms() < 1 ) {
1219 first_xyz = residue.
xyz( 1 );
1224 core::Vector bbl( first_xyz - at1rad ), bbu( first_xyz + at1rad );
1229 bbl.min( residue.
xyz( ii ) - iirad );
1230 bbu.max( residue.
xyz( ii ) + iirad );
1233 numeric::geometry::BoundingBox< Vector > bb( bbl, bbu );
1242 using namespace core;
1246 if ( residue.
natoms() < 1 ) {
1249 first_xyz = residue.
xyz( 1 );
1254 core::Vector bbl( first_xyz - at1rad ), bbu( first_xyz + at1rad );
1257 for (
Size ii = 2; ii <= residue.
natoms(); ++ii ) {
1259 bbl.min( residue.
xyz( ii ) - iirad );
1260 bbu.max( residue.
xyz( ii ) + iirad );
1263 numeric::geometry::BoundingBox< Vector > bb( bbl, bbu );
1275 using namespace core;
1276 for (
Size ii = 1; ii <= residue.
natoms(); ++ii ) {
1287 using namespace core;
1300 using namespace core;
1308 unselectable_( true ),
1309 line_color_(
"red" ),
1311 shrink_factor_( 0.75 ),
1312 skip_completely_buried_positions_( true ),
1313 write_empty_voxels_( false ),
1314 empty_voxel_color_(
"gray" ),
1315 write_facets_( false ),
1316 facet_master_(
"grid facets" ),
1317 facet_color_(
"pinktint" ),
1318 transparent_facets_( false ),
1340 std::ostream & ostr,
1357 Size const A( 1 ),
B( 5 ),
C( 7 ),
D( 3 ),
E( 2 ), F( 6 ),
G( 8 ), H( 4 );
1359 ostr <<
"@group {" << group_name <<
"} dominant\n";
1360 ostr <<
"@vectorlist {} color= " <<
line_color_ <<
" width= 1\n";
1365 ostr.precision( 3 );
1367 for (
Size ii = 0; ii < ndims[ 1 ]; ++ii ) {
1369 for (
Size jj = 0; jj < ndims[ 2 ]; ++jj ) {
1371 for (
Size kk = 0; kk < ndims[ 3 ]; ++kk ) {
1374 if ( ! grid.
occupied( bin ) )
continue;
1378 if ( bin[ 1 ] == 0 || bin[ 2 ] == 0 || bin[ 3 ] == 0 ) skip =
false;
1379 if ( bin[ 1 ] + 1 >= ndims[ 1 ] || bin[ 2 ] + 1 >= ndims[ 2 ] || bin[ 3 ] + 1 >= ndims[ 3 ] ) skip =
false;
1383 for (
Size ll = 0; ll <= 2; ++ll ) {
1384 neighb[ 1 ] = bin[ 1 ] - 1 + ll;
1385 for (
Size mm = 0; mm <= 2; ++mm ) {
1386 neighb[ 2 ] = bin[ 2 ] - 1 + mm;
1387 for (
Size nn = 0; nn <= 2; ++nn ) {
1388 neighb[ 3 ] = bin[ 3 ] - 1 + nn;
1389 if ( ll == 1 && mm == 1 && nn == 1 )
continue;
1395 if ( ! skip )
break;
1397 if ( ! skip )
break;
1401 if ( skip )
continue;
1404 for (
Size ll = 1; ll <= 8; ++ll ) c[ ll ] += corner_offsets[ ll ];
1406 ostr <<
"{\"}P" << (
unselectable_ ?
" U ":
" " ) << c[
A].x() <<
" " << c[
A].y() <<
" " << c[
A].z() <<
"\n";
1407 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
B].x() <<
" " << c[
B].y() <<
" " << c[
B].z() <<
"\n";
1408 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
C].x() <<
" " << c[
C].y() <<
" " << c[
C].z() <<
"\n";
1409 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
D].x() <<
" " << c[
D].y() <<
" " << c[
D].z() <<
"\n";
1410 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
A].x() <<
" " << c[
A].y() <<
" " << c[
A].z() <<
"\n";
1411 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
E].x() <<
" " << c[
E].y() <<
" " << c[
E].z() <<
"\n";
1412 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[F].x() <<
" " << c[F].y() <<
" " << c[F].z() <<
"\n";
1413 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
G].x() <<
" " << c[
G].y() <<
" " << c[
G].z() <<
"\n";
1414 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[H].x() <<
" " << c[H].y() <<
" " << c[H].z() <<
"\n";
1415 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
E].x() <<
" " << c[
E].y() <<
" " << c[
E].z() <<
"\n";
1416 ostr <<
"{\"}P" << (
unselectable_ ?
" U ":
" " ) << c[
B].x() <<
" " << c[
B].y() <<
" " << c[
B].z() <<
"\n";
1417 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[F].x() <<
" " << c[F].y() <<
" " << c[F].z() <<
"\n";
1418 ostr <<
"{\"}P" << (
unselectable_ ?
" U ":
" " ) << c[
C].x() <<
" " << c[
C].y() <<
" " << c[
C].z() <<
"\n";
1419 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
G].x() <<
" " << c[
G].y() <<
" " << c[
G].z() <<
"\n";
1420 ostr <<
"{\"}P" << (
unselectable_ ?
" U ":
" " ) << c[
D].x() <<
" " << c[
D].y() <<
" " << c[
D].z() <<
"\n";
1421 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[H].x() <<
" " << c[H].y() <<
" " << c[H].z() <<
"\n";
1428 ostr <<
"@vectorlist {} color= " <<
empty_voxel_color_ <<
" master= {empty voxels} width= 1\n";
1429 for (
Size ii = 0; ii < ndims[ 1 ]; ++ii ) {
1431 for (
Size jj = 0; jj < ndims[ 2 ]; ++jj ) {
1433 for (
Size kk = 0; kk < ndims[ 3 ]; ++kk ) {
1435 if ( grid.
occupied( bin ) )
continue;
1438 for (
Size ll = 1; ll <= 8; ++ll ) c[ ll ] += corner_offsets[ ll ];
1440 ostr <<
"{\"}P" << (
unselectable_ ?
" U ":
" " ) << c[
A].x() <<
" " << c[
A].y() <<
" " << c[
A].z() <<
"\n";
1441 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
B].x() <<
" " << c[
B].y() <<
" " << c[
B].z() <<
"\n";
1442 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
C].x() <<
" " << c[
C].y() <<
" " << c[
C].z() <<
"\n";
1443 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
D].x() <<
" " << c[
D].y() <<
" " << c[
D].z() <<
"\n";
1444 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
A].x() <<
" " << c[
A].y() <<
" " << c[
A].z() <<
"\n";
1445 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
E].x() <<
" " << c[
E].y() <<
" " << c[
E].z() <<
"\n";
1446 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[F].x() <<
" " << c[F].y() <<
" " << c[F].z() <<
"\n";
1447 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
G].x() <<
" " << c[
G].y() <<
" " << c[
G].z() <<
"\n";
1448 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[H].x() <<
" " << c[H].y() <<
" " << c[H].z() <<
"\n";
1449 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
E].x() <<
" " << c[
E].y() <<
" " << c[
E].z() <<
"\n";
1450 ostr <<
"{\"}P" << (
unselectable_ ?
" U ":
" " ) << c[
B].x() <<
" " << c[
B].y() <<
" " << c[
B].z() <<
"\n";
1451 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[F].x() <<
" " << c[F].y() <<
" " << c[F].z() <<
"\n";
1452 ostr <<
"{\"}P" << (
unselectable_ ?
" U ":
" " ) << c[
C].x() <<
" " << c[
C].y() <<
" " << c[
C].z() <<
"\n";
1453 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
G].x() <<
" " << c[
G].y() <<
" " << c[
G].z() <<
"\n";
1454 ostr <<
"{\"}P" << (
unselectable_ ?
" U ":
" " ) << c[
D].x() <<
" " << c[
D].y() <<
" " << c[
D].z() <<
"\n";
1455 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[H].x() <<
" " << c[H].y() <<
" " << c[H].z() <<
"\n";
1464 for (
Size ii = 0; ii < ndims[ 1 ]; ++ii ) {
1466 for (
Size jj = 0; jj < ndims[ 2 ]; ++jj ) {
1468 for (
Size kk = 0; kk < ndims[ 3 ]; ++kk ) {
1470 if ( ! grid.
occupied( bin ) )
continue;
1473 for (
Size ll = 1; ll <= 8; ++ll ) c[ ll ] += corner_offsets[ ll ];
1478 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[H].x() <<
" " << c[H].y() <<
" " << c[H].z() <<
"\n";
1479 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
D].x() <<
" " << c[
D].y() <<
" " << c[
D].z() <<
"\n";
1480 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
E].x() <<
" " << c[
E].y() <<
" " << c[
E].z() <<
"\n";
1481 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
A].x() <<
" " << c[
A].y() <<
" " << c[
A].z() <<
"\n";
1482 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[F].x() <<
" " << c[F].y() <<
" " << c[F].z() <<
"\n";
1483 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
B].x() <<
" " << c[
B].y() <<
" " << c[
B].z() <<
"\n";
1484 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
G].x() <<
" " << c[
G].y() <<
" " << c[
G].z() <<
"\n";
1485 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
C].x() <<
" " << c[
C].y() <<
" " << c[
C].z() <<
"\n";
1486 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[H].x() <<
" " << c[H].y() <<
" " << c[H].z() <<
"\n";
1487 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
D].x() <<
" " << c[
D].y() <<
" " << c[
D].z() <<
"\n";
1489 ostr <<
"@ribonlist {} color= " <<
facet_color_ <<
" master= {" << facet_master_ <<
"} ";
1493 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
E].x() <<
" " << c[
E].y() <<
" " << c[
E].z() <<
"\n";
1494 ostr <<
"{\"} " << (
unselectable_ ?
" U ":
" " ) << c[H].x() <<
" " << c[H].y() <<
" " << c[H].z() <<
"\n";
1495 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[F].x() <<
" " << c[F].y() <<
" " << c[F].z() <<
"\n";
1496 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
G].x() <<
" " << c[
G].y() <<
" " << c[
G].z() <<
"\n";
1498 ostr <<
"@ribonlist {} color= " <<
facet_color_ <<
" master= {" << facet_master_ <<
"} ";
1502 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
A].x() <<
" " << c[
A].y() <<
" " << c[
A].z() <<
"\n";
1503 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
B].x() <<
" " << c[
B].y() <<
" " << c[
B].z() <<
"\n";
1504 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
D].x() <<
" " << c[
D].y() <<
" " << c[
D].z() <<
"\n";
1505 ostr <<
"{\"}" << (
unselectable_ ?
" U ":
" " ) << c[
C].x() <<
" " << c[
C].y() <<
" " << c[
C].z() <<
"\n";