33 #if __cplusplus >= 201103L
34 return (
static_cast< proshade_signed
> ( std::round ( x ) ) );
36 return (
static_cast< proshade_signed
> ( round ( x ) ) );
48 #if __cplusplus >= 201103L
49 return (
static_cast< proshade_signed
> ( std::round ( x ) ) );
51 return (
static_cast< proshade_signed
> ( round ( x ) ) );
75 bool firstAtom =
true;
78 if ( pdbFile.models.size() > 0 )
81 for ( proshade_unsign sIt = 0; sIt < static_cast<proshade_unsign> ( pdbFile.models.size() ); sIt++ )
84 if ( firstModel && ( sIt != 0 ) ) {
break; }
87 gemmi::Model model = pdbFile.models.at(sIt);
90 for ( proshade_unsign mIt = 0; mIt < static_cast<proshade_unsign> ( model.chains.size() ); mIt++ )
93 gemmi::Chain chain = model.chains.at(mIt);
96 for ( proshade_unsign rIt = 0; rIt < static_cast<proshade_unsign> ( chain.residues.size() ); rIt++ )
99 gemmi::Residue residue = chain.residues.at(rIt);
102 for ( proshade_unsign aIt = 0; aIt < static_cast<proshade_unsign> ( residue.atoms.size() ); aIt++ )
105 gemmi::Atom atom = residue.atoms.at(aIt);
108 if ( atom.is_hydrogen() ) {
continue; }
113 *xTo =
static_cast<proshade_single
> ( atom.pos.x );
114 *xFrom =
static_cast<proshade_single
> ( atom.pos.x );
115 *yTo =
static_cast<proshade_single
> ( atom.pos.y );
116 *yFrom =
static_cast<proshade_single
> ( atom.pos.y );
117 *zTo =
static_cast<proshade_single
> ( atom.pos.z );
118 *zFrom =
static_cast<proshade_single
> ( atom.pos.z );
123 if (
static_cast<proshade_single
> ( atom.pos.x ) > *xTo ) { *xTo =
static_cast<proshade_single
> ( atom.pos.x ); }
124 if (
static_cast<proshade_single
> ( atom.pos.x ) < *xFrom ) { *xFrom =
static_cast<proshade_single
> ( atom.pos.x ); }
125 if (
static_cast<proshade_single
> ( atom.pos.y ) > *yTo ) { *yTo =
static_cast<proshade_single
> ( atom.pos.y ); }
126 if (
static_cast<proshade_single
> ( atom.pos.y ) < *yFrom ) { *yFrom =
static_cast<proshade_single
> ( atom.pos.y ); }
127 if (
static_cast<proshade_single
> ( atom.pos.z ) > *zTo ) { *zTo =
static_cast<proshade_single
> ( atom.pos.z ); }
128 if (
static_cast<proshade_single
> ( atom.pos.z ) < *zFrom ) { *zFrom =
static_cast<proshade_single
> ( atom.pos.z ); }
137 std::stringstream hlpSS;
138 hlpSS <<
"Found 0 models in input file " << pdbFile.name <<
".\n : This suggests that the input co-ordinate file is\n : corrupted or mis-formatted.";
139 throw ProSHADE_exception (
"Found no model in co-ordinate file.",
"EP00050", __FILE__, __LINE__, __func__, hlpSS.str() );
160 proshade_double totAtoms = 0.0;
166 if ( pdbFile->models.size() > 0 )
169 for ( proshade_unsign sIt = 0; sIt < static_cast<proshade_unsign> ( pdbFile->models.size() ); sIt++ )
172 gemmi::Model model = pdbFile->models.at(sIt);
175 if ( firstModel && ( sIt != 0 ) ) {
break; }
178 for ( proshade_unsign mIt = 0; mIt < static_cast<proshade_unsign> ( model.chains.size() ); mIt++ )
181 gemmi::Chain chain = model.chains.at(mIt);
183 gemmi::ResidueSpan span = chain.whole ( );
186 for ( proshade_unsign rIt = 0; rIt < static_cast<proshade_unsign> ( span.size() ); rIt++ )
189 gemmi::Residue residue = span.at(rIt);
192 for ( proshade_unsign aIt = 0; aIt < static_cast<proshade_unsign> ( residue.atoms.size() ); aIt++ )
195 gemmi::Atom atom = residue.atoms.at(aIt);
198 *xCom += atom.pos.x * atom.element.weight();
199 *yCom += atom.pos.y * atom.element.weight();
200 *zCom += atom.pos.z * atom.element.weight();
201 totAtoms += atom.element.weight();
209 std::stringstream hlpSS;
210 hlpSS <<
"Found 0 models in input file " << pdbFile->name <<
".\n : This suggests that the input co-ordinate file is\n : corrupted or mis-formatted.";
211 throw ProSHADE_exception (
"Found no model in co-ordinate file.",
"EP00050", __FILE__, __LINE__, __func__, hlpSS.str() );
243 void ProSHADE_internal_mapManip::findMAPCOMValues ( proshade_double* map, proshade_double *xCom, proshade_double *yCom, proshade_double *zCom, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_signed xFrom, proshade_signed xTo, proshade_signed yFrom, proshade_signed yTo, proshade_signed zFrom, proshade_signed zTo,
bool removeNegDens )
246 proshade_double totDensity = 0.0;
250 proshade_signed arrPos = 0;
251 proshade_single xSampRate = xAngs /
static_cast< proshade_single
> ( xTo - xFrom + 1 );
252 proshade_single ySampRate = yAngs /
static_cast< proshade_single
> ( yTo - yFrom + 1 );
253 proshade_single zSampRate = zAngs /
static_cast< proshade_single
> ( zTo - zFrom + 1 );
256 for ( proshade_signed xIt = 0; xIt <= ( xTo - xFrom ); xIt++ )
258 for ( proshade_signed yIt = 0; yIt <= ( yTo - yFrom ); yIt++ )
260 for ( proshade_signed zIt = 0; zIt <= ( zTo - zFrom ); zIt++ )
263 arrPos = zIt + ( zTo - zFrom + 1 ) * ( yIt + ( yTo - yFrom + 1 ) * xIt );
266 const FloatingPoint< proshade_double > lhs ( map[arrPos] );
267 if ( !lhs.AlmostEquals ( lhs ) ) { map[arrPos] = 0.0;
continue; }
270 if ( ( map[arrPos] < 0.0 ) && removeNegDens ) {
continue; }
273 totDensity += map[arrPos];
274 *xCom +=
static_cast<proshade_double
> ( xIt * map[arrPos] );
275 *yCom +=
static_cast<proshade_double
> ( yIt * map[arrPos] );
276 *zCom +=
static_cast<proshade_double
> ( zIt * map[arrPos] );
287 *xCom = (
static_cast< proshade_double
> ( xFrom ) + (*xCom) ) *
static_cast< proshade_double
> ( xSampRate );
288 *yCom = (
static_cast< proshade_double
> ( yFrom ) + (*yCom) ) *
static_cast< proshade_double
> ( ySampRate );
289 *zCom = (
static_cast< proshade_double
> ( zFrom ) + (*zCom) ) *
static_cast< proshade_double
> ( zSampRate );
311 proshade_double yCom, proshade_double zCom,
bool firstModel )
314 proshade_double *rotMat =
new proshade_double[9];
319 proshade_double xTmp, yTmp, zTmp;
322 if ( pdbFile->models.size() > 0 )
325 for ( proshade_unsign sIt = 0; sIt < static_cast<proshade_unsign> ( pdbFile->models.size() ); sIt++ )
328 gemmi::Model *model = &pdbFile->models.at(sIt);
331 if ( firstModel && ( sIt != 0 ) ) {
break; }
334 for ( proshade_unsign mIt = 0; mIt < static_cast<proshade_unsign> ( model->chains.size() ); mIt++ )
337 gemmi::Chain *chain = &model->chains.at(mIt);
340 for ( proshade_unsign rIt = 0; rIt < static_cast<proshade_unsign> ( chain->residues.size() ); rIt++ )
343 gemmi::Residue *residue = &chain->residues.at(rIt);
346 for ( proshade_unsign aIt = 0; aIt < static_cast<proshade_unsign> ( residue->atoms.size() ); aIt++ )
349 gemmi::Atom *atom = &residue->atoms.at(aIt);
352 xTmp =
static_cast< proshade_double
> ( atom->pos.x - xCom );
353 yTmp =
static_cast< proshade_double
> ( atom->pos.y - yCom );
354 zTmp =
static_cast< proshade_double
> ( atom->pos.z - zCom );
357 atom->pos.x = ( xTmp * rotMat[0] ) + ( yTmp * rotMat[1] ) + ( zTmp * rotMat[2] );
358 atom->pos.y = ( xTmp * rotMat[3] ) + ( yTmp * rotMat[4] ) + ( zTmp * rotMat[5] );
359 atom->pos.z = ( xTmp * rotMat[6] ) + ( yTmp * rotMat[7] ) + ( zTmp * rotMat[8] );
362 atom->pos.x = atom->pos.x + xCom;
363 atom->pos.y = atom->pos.y + yCom;
364 atom->pos.z = atom->pos.z + zCom;
372 std::stringstream hlpSS;
373 hlpSS <<
"Found 0 models in input file " << pdbFile->name <<
".\n : This suggests that the input co-ordinate file is\n : corrupted or mis-formatted.";
374 throw ProSHADE_exception (
"Found no model in co-ordinate file.",
"EP00050", __FILE__, __LINE__, __func__, hlpSS.str() );
398 if ( pdbFile->models.size() > 0 )
401 for ( proshade_unsign sIt = 0; sIt < static_cast<proshade_unsign> ( pdbFile->models.size() ); sIt++ )
404 if ( firstModel && ( sIt != 0 ) ) {
break; }
407 gemmi::Model *model = &pdbFile->models.at(sIt);
410 for ( proshade_unsign mIt = 0; mIt < static_cast<proshade_unsign> ( model->chains.size() ); mIt++ )
413 gemmi::Chain *chain = &model->chains.at(mIt);
416 for ( proshade_unsign rIt = 0; rIt < static_cast<proshade_unsign> ( chain->residues.size() ); rIt++ )
419 gemmi::Residue *residue = &chain->residues.at(rIt);
422 for ( proshade_unsign aIt = 0; aIt < static_cast<proshade_unsign> ( residue->atoms.size() ); aIt++ )
425 gemmi::Atom *atom = &residue->atoms.at(aIt);
428 atom->pos.x += transX;
429 atom->pos.y += transY;
430 atom->pos.z += transZ;
438 std::stringstream hlpSS;
439 hlpSS <<
"Found 0 models in input file " << pdbFile->name <<
".\n : This suggests that the input co-ordinate file is\n : corrupted or mis-formatted.";
440 throw ProSHADE_exception (
"Found no model in co-ordinate file.",
"EP00050", __FILE__, __LINE__, __func__, hlpSS.str() );
461 if ( pdbFile->models.size() > 0 )
464 for ( proshade_unsign sIt = 0; sIt < static_cast<proshade_unsign> ( pdbFile->models.size() ); sIt++ )
467 if ( firstModel && ( sIt != 0 ) ) {
break; }
470 gemmi::Model *model = &pdbFile->models.at(sIt);
473 for ( proshade_unsign mIt = 0; mIt < static_cast<proshade_unsign> ( model->chains.size() ); mIt++ )
476 gemmi::Chain *chain = &model->chains.at(mIt);
479 for ( proshade_unsign rIt = 0; rIt < static_cast<proshade_unsign> ( chain->residues.size() ); rIt++ )
482 gemmi::Residue *residue = &chain->residues.at(rIt);
485 for ( proshade_unsign aIt = 0; aIt < static_cast<proshade_unsign> ( residue->atoms.size() ); aIt++ )
488 gemmi::Atom *atom = &residue->atoms.at(aIt);
491 atom->b_iso =
static_cast< float > ( newBFactorValue );
499 std::stringstream hlpSS;
500 hlpSS <<
"Found 0 models in input file " << pdbFile->name <<
".\n : This suggests that the input co-ordinate file is\n : corrupted or mis-formatted.";
501 throw ProSHADE_exception (
"Found no model in co-ordinate file.",
"EP00050", __FILE__, __LINE__, __func__, hlpSS.str() );
521 if ( pdbFile->models.size() > 0 )
524 for ( proshade_unsign sIt = 0; sIt < static_cast<proshade_unsign> ( pdbFile->models.size() ); sIt++ )
527 if ( firstModel && ( sIt != 0 ) ) {
break; }
530 gemmi::Model *model = &pdbFile->models.at(sIt);
533 for ( proshade_unsign mIt = 0; mIt < static_cast<proshade_unsign> ( model->chains.size() ); mIt++ )
536 gemmi::Chain *chain = &model->chains.at(mIt);
539 std::vector< proshade_unsign > delVec;
542 for ( proshade_unsign rIt = 0; rIt < static_cast<proshade_unsign> ( chain->residues.size() ); rIt++ )
545 gemmi::Residue *residue = &chain->residues.at(rIt);
548 if ( residue->is_water() )
555 std::sort ( delVec.begin(), delVec.end(), std::greater<int>() );
556 for ( proshade_unsign vecIt = 0; vecIt < static_cast<proshade_unsign> ( delVec.size() ); vecIt++ )
558 chain->residues.erase ( chain->residues.begin() +
static_cast< long int > ( delVec.at(vecIt) ) );
565 std::stringstream hlpSS;
566 hlpSS <<
"Found 0 models in input file " << pdbFile->name <<
".\n : This suggests that the input co-ordinate file is\n : corrupted or mis-formatted.";
567 throw ProSHADE_exception (
"Found no model in co-ordinate file.",
"EP00050", __FILE__, __LINE__, __func__, hlpSS.str() );
590 if ( pdbFile->models.size() > 0 )
593 for ( proshade_unsign sIt = 0; sIt < static_cast<proshade_unsign> ( pdbFile->models.size() ); sIt++ )
596 if ( firstModel && ( sIt != 0 ) ) {
break; }
599 gemmi::Model *model = &pdbFile->models.at(sIt);
602 for ( proshade_unsign mIt = 0; mIt < static_cast<proshade_unsign> ( model->chains.size() ); mIt++ )
605 gemmi::Chain *chain = &model->chains.at(mIt);
608 for ( proshade_unsign rIt = 0; rIt < static_cast<proshade_unsign> ( chain->residues.size() ); rIt++ )
611 gemmi::Residue *residue = &chain->residues.at(rIt);
614 for ( proshade_unsign aIt = 0; aIt < static_cast<proshade_unsign> ( residue->atoms.size() ); aIt++ )
617 gemmi::Atom *atom = &residue->atoms.at(aIt);
620 atom->pos = gemmi::Position ( atom->pos.x +
static_cast< proshade_double
> ( xMov ), atom->pos.y +
static_cast< proshade_double
> ( yMov ), atom->pos.z +
static_cast< proshade_double
> ( zMov ) );
629 std::stringstream hlpSS;
630 hlpSS <<
"Found 0 models in input file " << pdbFile->name <<
".\n : This suggests that the input co-ordinate file is\n : corrupted or mis-formatted.";
631 throw ProSHADE_exception (
"Found no model in co-ordinate file.",
"EP00050", __FILE__, __LINE__, __func__, hlpSS.str() );
658 void ProSHADE_internal_mapManip::generateMapFromPDB ( gemmi::Structure pdbFile, proshade_double*& map, proshade_single requestedResolution, proshade_single xCell, proshade_single yCell, proshade_single zCell, proshade_signed* xTo, proshade_signed* yTo, proshade_signed* zTo,
bool forceP1,
bool firstModel )
661 if ( forceP1 ) { pdbFile.cell = gemmi::UnitCell(); }
662 pdbFile.cell.a =
static_cast< proshade_double
> ( xCell );
663 pdbFile.cell.b =
static_cast< proshade_double
> ( yCell );
664 pdbFile.cell.c =
static_cast< proshade_double
> ( zCell );
665 pdbFile.cell.calculate_properties ( );
668 std::string totElString;
669 for ( proshade_unsign mIt = 0; mIt < static_cast<proshade_unsign> ( pdbFile.models.size() ); mIt++ )
672 if ( firstModel && ( mIt != 0 ) )
674 std::stringstream hlpSS;
675 hlpSS <<
"!!! ProSHADE WARNING !!! Found multiple models (" << pdbFile.models.size() <<
") in input file " << pdbFile.name <<
", while the settings state that only the first PDB file model should be used. If all models should be used, please supply ProSHADE with the \"-x\" option.";
680 std::string hlpStr = pdbFile.models[mIt].present_elements ( ).to_string<char,std::char_traits<char>,std::allocator<char> >();
681 totElString = totElString + hlpStr;
683 std::bitset< static_cast< size_t > ( gemmi::El::END )> present_elems ( totElString );
686 if ( present_elems[
static_cast<int> ( gemmi::El::X )] )
688 throw ProSHADE_exception (
"Found unknown element in input file.",
"EP00051", __FILE__, __LINE__, __func__,
"Gemmi library does not recognise some of the elements in\n : the co-ordinate file. Please check the file for not being\n : corrupted and containing standard elements." );
691 for ( proshade_unsign elIt = 0; elIt < static_cast<proshade_unsign> ( present_elems.size() ); elIt++ )
693 if ( present_elems[elIt] && !gemmi::IT92<double>::has (
static_cast<gemmi::El
> ( elIt ) ) )
695 std::stringstream hlpSS;
696 hlpSS <<
"Missing form factor for element " << element_name (
static_cast<gemmi::El
> ( elIt ) );
697 throw ProSHADE_exception ( hlpSS.str().c_str(),
"EP00052", __FILE__, __LINE__, __func__,
"Gemmi library does not have a form factor value for this\n : reported element. Please report this to the author." );
702 double wavelength = 10.0;
703 double energy = gemmi::hc() / wavelength;
706 gemmi::DensityCalculator<gemmi::IT92<double>,
float> dencalc;
708 dencalc.d_min =
static_cast< double > ( requestedResolution );
709 for (
size_t elIt = 0; elIt < present_elems.size(); elIt++ ) {
if ( present_elems[elIt] ) { dencalc.addends.set (
static_cast< gemmi::El
> ( elIt ),
static_cast< float > ( gemmi::cromer_liberman (
static_cast< int > ( elIt ), energy,
nullptr ) ) ); } }
710 dencalc.set_grid_cell_and_spacegroup ( pdbFile );
713 if ( forceP1 ) { dencalc.grid.spacegroup = &gemmi::get_spacegroup_p1(); }
716 dencalc.grid.data.clear ( );
717 dencalc.grid.set_size_from_spacing ( dencalc.d_min / ( 2.0 * dencalc.rate),
true );
718 for ( proshade_unsign mIt = 0; mIt < static_cast<proshade_unsign> ( pdbFile.models.size() ); mIt++ )
720 if ( firstModel && ( mIt != 0 ) ) {
break; }
721 dencalc.add_model_density_to_grid ( pdbFile.models[mIt] );
722 dencalc.grid.symmetrize ( [](
float a,
float b) {
return a + b; } );
726 const gemmi::Grid<float>& grid = dencalc.grid;
734 map =
new proshade_double [(*xTo) * (*yTo) * (*zTo)];
737 proshade_signed arrPos = 0;
738 for ( proshade_signed uIt = 0; uIt < (*xTo); uIt++ )
740 for ( proshade_signed vIt = 0; vIt < (*yTo); vIt++ )
742 for ( proshade_signed wIt = 0; wIt < (*zTo); wIt++ )
744 arrPos = wIt + (*zTo) * ( vIt + (*yTo) * uIt );
745 map[arrPos] =
static_cast< proshade_double
> ( grid.get_value_q(
static_cast< int > ( uIt ),
static_cast< int > ( vIt ),
static_cast< int > ( wIt ) ) );
777 void ProSHADE_internal_mapManip::moveMapByIndices ( proshade_single* xMov, proshade_single* yMov, proshade_single* zMov, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_signed* xFrom, proshade_signed* xTo, proshade_signed* yFrom, proshade_signed* yTo, proshade_signed* zFrom, proshade_signed* zTo, proshade_signed* xOrigin, proshade_signed* yOrigin, proshade_signed* zOrigin )
780 proshade_single xIndMove = std::floor ( -(*xMov) / ( xAngs / (
static_cast< proshade_single
> ( *xTo ) -
static_cast< proshade_single
> ( *xFrom ) + 1.0f ) ) );
781 proshade_single yIndMove = std::floor ( -(*yMov) / ( yAngs / (
static_cast< proshade_single
> ( *yTo ) -
static_cast< proshade_single
> ( *yFrom ) + 1.0f ) ) );
782 proshade_single zIndMove = std::floor ( -(*zMov) / ( zAngs / (
static_cast< proshade_single
> ( *zTo ) -
static_cast< proshade_single
> ( *zFrom ) + 1.0f ) ) );
785 *xMov = -( *xMov ) - ( xIndMove * ( xAngs / (
static_cast< proshade_single
> ( *xTo ) -
static_cast< proshade_single
> ( *xFrom ) + 1.0f ) ) );
786 *yMov = -( *yMov ) - ( yIndMove * ( yAngs / (
static_cast< proshade_single
> ( *yTo ) -
static_cast< proshade_single
> ( *yFrom ) + 1.0f ) ) );
787 *zMov = -( *zMov ) - ( zIndMove * ( zAngs / (
static_cast< proshade_single
> ( *zTo ) -
static_cast< proshade_single
> ( *zFrom ) + 1.0f ) ) );
790 *xFrom +=
static_cast< proshade_signed
> ( xIndMove );
791 *xTo +=
static_cast< proshade_signed
> ( xIndMove );
792 *yFrom +=
static_cast< proshade_signed
> ( yIndMove );
793 *yTo +=
static_cast< proshade_signed
> ( yIndMove );
794 *zFrom +=
static_cast< proshade_signed
> ( zIndMove );
795 *zTo +=
static_cast< proshade_signed
> ( zIndMove );
825 void ProSHADE_internal_mapManip::moveMapByFourier ( proshade_double*& map, proshade_single xMov, proshade_single yMov, proshade_single zMov, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_signed xDim, proshade_signed yDim, proshade_signed zDim )
828 proshade_unsign arrayPos = 0;
831 fftw_complex *fCoeffs =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( fftw_complex ) *
static_cast< proshade_unsign
> ( xDim * yDim * zDim ) ) );
832 fftw_complex *translatedMap =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( fftw_complex ) *
static_cast< proshade_unsign
> ( xDim * yDim * zDim ) ) );
839 fftw_plan planForwardFourier = fftw_plan_dft_3d (
static_cast< int > ( xDim ),
static_cast< int > ( yDim ),
static_cast< int > ( zDim ), translatedMap, fCoeffs, FFTW_FORWARD, FFTW_ESTIMATE );
840 fftw_plan planBackwardFourier = fftw_plan_dft_3d (
static_cast< int > ( xDim ),
static_cast< int > ( yDim ),
static_cast< int > ( zDim ), fCoeffs, translatedMap, FFTW_BACKWARD, FFTW_ESTIMATE );
843 for ( proshade_unsign uIt = 0; uIt < static_cast< proshade_unsign > ( xDim ); uIt++ )
845 for ( proshade_unsign vIt = 0; vIt < static_cast< proshade_unsign > ( yDim ); vIt++ )
847 for ( proshade_unsign wIt = 0; wIt < static_cast< proshade_unsign > ( zDim ); wIt++ )
849 arrayPos = wIt +
static_cast< proshade_unsign
> ( zDim ) * ( vIt +
static_cast< proshade_unsign
> ( yDim ) * uIt );
851 const FloatingPoint< proshade_double > lhs ( map[arrayPos] ), rhs ( map[arrayPos] );
852 if ( lhs.AlmostEquals ( rhs ) ) { translatedMap[arrayPos][0] = map[arrayPos]; }
853 else { translatedMap[arrayPos][0] = 0.0; }
854 translatedMap[arrayPos][1] = 0.0;
860 fftw_execute ( planForwardFourier );
863 proshade_double *weight =
nullptr;
864 moveMapByFourierInReci ( fCoeffs, weight, xMov, yMov, zMov, xAngs, yAngs, zAngs, xDim, yDim, zDim );
867 fftw_execute ( planBackwardFourier );
870 for ( proshade_unsign uIt = 0; uIt < static_cast< proshade_unsign > ( xDim ); uIt++ )
872 for ( proshade_unsign vIt = 0; vIt < static_cast< proshade_unsign > ( yDim ); vIt++ )
874 for ( proshade_unsign wIt = 0; wIt < static_cast< proshade_unsign > ( zDim ); wIt++ )
876 arrayPos = wIt +
static_cast< proshade_unsign
> ( zDim ) * ( vIt +
static_cast< proshade_unsign
> ( yDim ) * uIt );
877 map[arrayPos] = translatedMap[arrayPos][0];
883 fftw_destroy_plan ( planForwardFourier );
884 fftw_destroy_plan ( planBackwardFourier );
885 fftw_free ( fCoeffs );
886 fftw_free ( translatedMap );
910 void ProSHADE_internal_mapManip::moveMapByFourierInReci ( proshade_complex*& coeffs, proshade_double*& weights, proshade_single xMov, proshade_single yMov, proshade_single zMov, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_signed xDim, proshade_signed yDim, proshade_signed zDim )
913 proshade_unsign arrayPos = 0;
914 proshade_signed h, k, l;
915 proshade_double real = 0.0;
916 proshade_double imag = 0.0;
917 proshade_double trCoeffReal, trCoeffImag;
918 proshade_double normFactor =
static_cast< proshade_double
> ( xDim * yDim * zDim );
919 proshade_double exponent = 0.0;
920 proshade_double hlpArrReal;
921 proshade_double hlpArrImag;
924 proshade_double* wght =
new proshade_double[xDim * yDim * zDim];
926 if ( weights ==
nullptr ) {
for (
size_t iter = 0; iter < static_cast< size_t > ( xDim * yDim * zDim ); iter++ ) { wght[iter] = 1.0; } }
927 else {
for (
size_t iter = 0; iter < static_cast< size_t > ( xDim * yDim * zDim ); iter++ ) { wght[iter] = weights[iter]; } }
930 for ( proshade_unsign uIt = 0; uIt < static_cast<proshade_unsign> ( xDim ); uIt++ )
932 for ( proshade_unsign vIt = 0; vIt < static_cast<proshade_unsign> ( yDim ); vIt++ )
934 for ( proshade_unsign wIt = 0; wIt < static_cast<proshade_unsign> ( zDim ); wIt++ )
937 arrayPos = wIt +
static_cast< proshade_unsign
> ( zDim ) * ( vIt +
static_cast< proshade_unsign
> ( yDim ) * uIt );
938 real = coeffs[arrayPos][0];
939 imag = coeffs[arrayPos][1];
942 if ( uIt >
static_cast< proshade_unsign
> ( (xDim+1) / 2) ) { h =
static_cast < proshade_signed
> ( uIt ) - xDim; }
else { h =
static_cast < proshade_signed
> ( uIt ); }
943 if ( vIt >
static_cast< proshade_unsign
> ( (yDim+1) / 2) ) { k =
static_cast < proshade_signed
> ( vIt ) - yDim; }
else { k =
static_cast < proshade_signed
> ( vIt ); }
944 if ( wIt >
static_cast< proshade_unsign
> ( (zDim+1) / 2) ) { l =
static_cast < proshade_signed
> ( wIt ) - zDim; }
else { l =
static_cast < proshade_signed
> ( wIt ); }
947 exponent = ( ( (
static_cast <proshade_double
> ( h ) /
static_cast <proshade_double
> ( xAngs ) ) *
static_cast< proshade_double
> ( -xMov ) ) +
948 ( (
static_cast <proshade_double
> ( k ) /
static_cast <proshade_double
> ( yAngs ) ) *
static_cast< proshade_double
> ( -yMov ) ) +
949 ( (
static_cast <proshade_double
> ( l ) /
static_cast <proshade_double
> ( zAngs ) ) *
static_cast< proshade_double
> ( -zMov ) ) ) * 2.0 * M_PI;
951 trCoeffReal = cos ( exponent );
952 trCoeffImag = sin ( exponent );
956 coeffs[arrayPos][0] = ( hlpArrReal / normFactor ) * wght[arrayPos];
957 coeffs[arrayPos][1] = ( hlpArrImag / normFactor ) * wght[arrayPos];
986 void ProSHADE_internal_mapManip::blurSharpenMap ( proshade_double*& map, proshade_double*& blurredMap, proshade_unsign xDimS, proshade_unsign yDimS, proshade_unsign zDimS, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_single blurringFactor )
989 proshade_signed xDim =
static_cast< proshade_signed
> ( xDimS );
990 proshade_signed yDim =
static_cast< proshade_signed
> ( yDimS );
991 proshade_signed zDim =
static_cast< proshade_signed
> ( zDimS );
992 proshade_double real, imag, S, mag, phase;
993 proshade_signed h, k, l;
994 proshade_unsign arrayPos = 0;
995 proshade_double normFactor =
static_cast<proshade_double
> ( xDim * yDim * zDim );
998 fftw_complex* mapCoeffs =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( fftw_complex ) *
static_cast< proshade_unsign
> ( xDim * yDim * zDim ) ) );
999 fftw_complex* mapMask =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( fftw_complex ) *
static_cast< proshade_unsign
> ( xDim * yDim * zDim ) ) );
1006 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> (xDim * yDim * zDim); iter++ )
1008 mapMask[iter][0] = map[iter];
1009 mapMask[iter][1] = 0.0;
1013 fftw_plan forward = fftw_plan_dft_3d (
static_cast< int > ( xDim ),
static_cast< int > ( yDim ),
static_cast< int > ( zDim ), mapMask, mapCoeffs, FFTW_FORWARD, FFTW_ESTIMATE );
1014 fftw_plan inverse = fftw_plan_dft_3d (
static_cast< int > ( xDim ),
static_cast< int > ( yDim ),
static_cast< int > ( zDim ), mapCoeffs, mapMask, FFTW_BACKWARD, FFTW_ESTIMATE );
1017 fftw_execute ( forward );
1020 for ( proshade_unsign uIt = 0; uIt < static_cast<proshade_unsign> ( xDim ); uIt++ )
1022 for ( proshade_unsign vIt = 0; vIt < static_cast<proshade_unsign> ( yDim ); vIt++ )
1024 for ( proshade_unsign wIt = 0; wIt < static_cast<proshade_unsign> ( zDim ); wIt++ )
1027 arrayPos = wIt +
static_cast< proshade_unsign
> ( zDim ) * ( vIt +
static_cast< proshade_unsign
> ( yDim ) * uIt );
1028 real = mapCoeffs[arrayPos][0];
1029 imag = mapCoeffs[arrayPos][1];
1032 if ( uIt >
static_cast< proshade_unsign
> ( (xDim+1) / 2) ) { h =
static_cast < proshade_signed
> ( uIt ) - xDim; }
else { h =
static_cast < proshade_signed
> ( uIt ); }
1033 if ( vIt >
static_cast< proshade_unsign
> ( (yDim+1) / 2) ) { k =
static_cast < proshade_signed
> ( vIt ) - yDim; }
else { k =
static_cast < proshade_signed
> ( vIt ); }
1034 if ( wIt >
static_cast< proshade_unsign
> ( (zDim+1) / 2) ) { l =
static_cast < proshade_signed
> ( wIt ) - zDim; }
else { l =
static_cast < proshade_signed
> ( wIt ); }
1037 S = ( pow(
static_cast< proshade_double
> ( h ) /
static_cast< proshade_double
> ( xAngs ), 2.0 ) +
1038 pow(
static_cast< proshade_double
> ( k ) /
static_cast< proshade_double
> ( yAngs ), 2.0 ) +
1039 pow(
static_cast< proshade_double
> ( l ) /
static_cast< proshade_double
> ( zAngs ), 2.0 ) );
1040 mag = std::sqrt ( (real*real) + (imag*imag) ) * std::exp ( - ( (
static_cast< proshade_double
> ( blurringFactor ) * S ) / 4.0 ) );
1041 phase = std::atan2 ( imag, real );
1044 mapCoeffs[arrayPos][0] = ( mag * cos(phase) ) / normFactor;
1045 mapCoeffs[arrayPos][1] = ( mag * sin(phase) ) / normFactor;
1051 fftw_execute ( inverse );
1054 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> (xDim * yDim * zDim); iter++ )
1056 blurredMap[iter] = mapMask[iter][0];
1060 fftw_free ( mapMask );
1061 fftw_free ( mapCoeffs );
1064 fftw_destroy_plan ( forward );
1065 fftw_destroy_plan ( inverse );
1089 std::vector<proshade_double> mapVals ( xDim * yDim * zDim, 0.0 );
1092 for ( proshade_unsign iter = 0; iter < ( xDim * yDim * zDim ); iter++ )
1094 mapVals.at(iter) = blurMap[iter];
1098 proshade_double* medAndIQR =
new proshade_double[2];
1102 proshade_double maskThreshold = medAndIQR[0] + ( medAndIQR[1] *
static_cast<proshade_double
> ( noIQRs ) );
1105 for ( proshade_unsign iter = 0; iter < ( xDim * yDim * zDim ); iter++ )
1107 if ( blurMap[iter] < maskThreshold )
1110 blurMap[iter] = 0.0;
1139 proshade_signed arrayPos = 0;
1150 for ( proshade_signed xIt = 0; xIt < xDim; xIt++ )
1152 for ( proshade_signed yIt = 0; yIt < yDim; yIt++ )
1154 for ( proshade_signed zIt = 0; zIt < zDim; zIt++ )
1157 arrayPos = zIt + zDim * ( yIt + yDim * xIt );
1160 if ( map[arrayPos] > 0.001 )
1162 if ( xIt < ret[0] ) { ret[0] = xIt; }
1163 if ( xIt > ret[1] ) { ret[1] = xIt; }
1164 if ( yIt < ret[2] ) { ret[2] = yIt; }
1165 if ( yIt > ret[3] ) { ret[3] = yIt; }
1166 if ( zIt < ret[4] ) { ret[4] = zIt; }
1167 if ( zIt > ret[5] ) { ret[5] = zIt; }
1201 bounds[0] = bounds[0] - xExtraInds;
1202 bounds[1] = bounds[1] + xExtraInds;
1203 bounds[2] = bounds[2] - yExtraInds;
1204 bounds[3] = bounds[3] + yExtraInds;
1205 bounds[4] = bounds[4] - zExtraInds;
1206 bounds[5] = bounds[5] + zExtraInds;
1232 if ( resolution <= 0.0f )
1234 throw ProSHADE_exception (
"Requested resolution not set for map re-sampling.",
"EM00015", __FILE__, __LINE__, __func__,
"There is no resolution value set, but map re-sampling to\n : this unset resolution value is required. This error\n : occurs when a task with no resolution requirement is\n : requested on a map data and the map resolution change is\n : set to \'on\'. Either supply a resolution value, or do not\n : re-sample the map." );
1238 proshade_signed xDim =
static_cast<proshade_signed
> ( xDimS );
1239 proshade_signed yDim =
static_cast<proshade_signed
> ( yDimS );
1240 proshade_signed zDim =
static_cast<proshade_signed
> ( zDimS );
1241 proshade_single oldXSample = ( xAngs /
static_cast<proshade_single
> ( xDim ) );
1242 proshade_single oldYSample = ( yAngs /
static_cast<proshade_single
> ( yDim ) );
1243 proshade_single oldZSample = ( zAngs /
static_cast<proshade_single
> ( zDim ) );
1244 proshade_single newXSample =
static_cast< proshade_single
> ( resolution / 2.0f );
1245 proshade_single newYSample =
static_cast< proshade_single
> ( resolution / 2.0f );
1246 proshade_single newZSample =
static_cast< proshade_single
> ( resolution / 2.0f );
1249 proshade_signed newXDim =
static_cast<proshade_signed
> ( std::ceil ( xAngs / newXSample ) );
1250 proshade_signed newYDim =
static_cast<proshade_signed
> ( std::ceil ( yAngs / newYSample ) );
1251 proshade_signed newZDim =
static_cast<proshade_signed
> ( std::ceil ( zAngs / newZSample ) );
1254 proshade_double* newMap =
new proshade_double [newXDim * newYDim * newZDim];
1257 proshade_signed xBottom = 0, xTop, yBottom = 0, yTop, zBottom = 0, zTop, oldMapIndex, newMapIndex;
1258 std::vector<proshade_double> c000 = std::vector<proshade_double> ( 4, 0.0 );
1259 std::vector<proshade_double> c001 = std::vector<proshade_double> ( 4, 0.0 );
1260 std::vector<proshade_double> c010 = std::vector<proshade_double> ( 4, 0.0 );
1261 std::vector<proshade_double> c011 = std::vector<proshade_double> ( 4, 0.0 );
1262 std::vector<proshade_double> c100 = std::vector<proshade_double> ( 4, 0.0 );
1263 std::vector<proshade_double> c101 = std::vector<proshade_double> ( 4, 0.0 );
1264 std::vector<proshade_double> c110 = std::vector<proshade_double> ( 4, 0.0 );
1265 std::vector<proshade_double> c111 = std::vector<proshade_double> ( 4, 0.0 );
1266 std::vector<proshade_double> c00 = std::vector<proshade_double> ( 4, 0.0 );
1267 std::vector<proshade_double> c01 = std::vector<proshade_double> ( 4, 0.0 );
1268 std::vector<proshade_double> c10 = std::vector<proshade_double> ( 4, 0.0 );
1269 std::vector<proshade_double> c11 = std::vector<proshade_double> ( 4, 0.0 );
1270 std::vector<proshade_double> c0 = std::vector<proshade_double> ( 4, 0.0 );
1271 std::vector<proshade_double> c1 = std::vector<proshade_double> ( 4, 0.0 );
1272 proshade_double xRelative, yRelative, zRelative;
1274 for ( proshade_signed xIt = 0; xIt < newXDim; xIt++ )
1276 for ( proshade_signed yIt = 0; yIt < newYDim; yIt++ )
1278 for ( proshade_signed zIt = 0; zIt < newZDim; zIt++ )
1281 newMapIndex = zIt + newZDim * ( yIt + newYDim * xIt );
1284 for ( proshade_signed ox = 0; ox < ( static_cast< proshade_signed > ( xDimS ) - 1 ); ox++ ) {
if ( ( (
static_cast< proshade_single
> ( xIt ) * newXSample ) >= (
static_cast< proshade_single
> ( ox ) * oldXSample ) ) && ( (
static_cast< proshade_single
> ( xIt ) * newXSample ) <= ( (
static_cast< proshade_single
> ( ox ) + 1 ) * oldXSample ) ) ) { xBottom = ox;
break; } }
1285 for ( proshade_signed oy = 0; oy < ( static_cast< proshade_signed > ( yDimS ) - 1 ); oy++ ) {
if ( ( (
static_cast< proshade_single
> ( yIt ) * newYSample ) >= (
static_cast< proshade_single
> ( oy ) * oldYSample ) ) && ( (
static_cast< proshade_single
> ( yIt ) * newYSample ) <= ( (
static_cast< proshade_single
> ( oy ) + 1 ) * oldYSample ) ) ) { yBottom = oy;
break; } }
1286 for ( proshade_signed oz = 0; oz < ( static_cast< proshade_signed > ( zDimS ) - 1 ); oz++ ) {
if ( ( (
static_cast< proshade_single
> ( zIt ) * newZSample ) >= (
static_cast< proshade_single
> ( oz ) * oldZSample ) ) && ( (
static_cast< proshade_single
> ( zIt ) * newZSample ) <= ( (
static_cast< proshade_single
> ( oz ) + 1 ) * oldZSample ) ) ) { zBottom = oz;
break; } }
1292 oldMapIndex = zBottom +
static_cast< proshade_signed
> ( zDimS ) * ( yBottom +
static_cast< proshade_signed
> ( yDimS ) * xBottom );
1293 c000.at(0) =
static_cast<proshade_double
> ( xBottom ) *
static_cast<proshade_double
> ( oldXSample );
1294 c000.at(1) =
static_cast<proshade_double
> ( yBottom ) *
static_cast<proshade_double
> ( oldYSample );
1295 c000.at(2) =
static_cast<proshade_double
> ( zBottom ) *
static_cast<proshade_double
> ( oldZSample );
1296 c000.at(3) =
static_cast<proshade_double
> ( map[oldMapIndex] );
1298 oldMapIndex = zTop +
static_cast< proshade_signed
> ( zDimS ) * ( yBottom +
static_cast< proshade_signed
> ( yDimS ) * xBottom );
1299 c001.at(0) =
static_cast<proshade_double
> ( xBottom ) *
static_cast<proshade_double
> ( oldXSample );
1300 c001.at(1) =
static_cast<proshade_double
> ( yBottom ) *
static_cast<proshade_double
> ( oldYSample );
1301 c001.at(2) =
static_cast<proshade_double
> ( zTop ) *
static_cast<proshade_double
> ( oldZSample );
1302 c001.at(3) =
static_cast<proshade_double
> ( map[oldMapIndex] );
1304 oldMapIndex = zBottom +
static_cast< proshade_signed
> ( zDimS ) * ( yTop +
static_cast< proshade_signed
> ( yDimS ) * xBottom );
1305 c010.at(0) =
static_cast<proshade_double
> ( xBottom ) *
static_cast<proshade_double
> ( oldXSample );
1306 c010.at(1) =
static_cast<proshade_double
> ( yTop ) *
static_cast<proshade_double
> ( oldYSample );
1307 c010.at(2) =
static_cast<proshade_double
> ( zBottom ) *
static_cast<proshade_double
> ( oldZSample );
1308 c010.at(3) =
static_cast<proshade_double
> ( map[oldMapIndex] );
1310 oldMapIndex = zTop +
static_cast< proshade_signed
> ( zDimS ) * ( yTop +
static_cast< proshade_signed
> ( yDimS ) * xBottom );
1311 c011.at(0) =
static_cast<proshade_double
> ( xBottom ) *
static_cast<proshade_double
> ( oldXSample );
1312 c011.at(1) =
static_cast<proshade_double
> ( yTop ) *
static_cast<proshade_double
> ( oldYSample );
1313 c011.at(2) =
static_cast<proshade_double
> ( zTop ) *
static_cast<proshade_double
> ( oldZSample );
1314 c011.at(3) =
static_cast<proshade_double
> ( map[oldMapIndex] );
1316 oldMapIndex = zBottom +
static_cast< proshade_signed
> ( zDimS ) * ( yBottom +
static_cast< proshade_signed
> ( yDimS ) * xTop );
1317 c100.at(0) =
static_cast<proshade_double
> ( xTop ) *
static_cast<proshade_double
> ( oldXSample );
1318 c100.at(1) =
static_cast<proshade_double
> ( yBottom ) *
static_cast<proshade_double
> ( oldYSample );
1319 c100.at(2) =
static_cast<proshade_double
> ( zBottom ) *
static_cast<proshade_double
> ( oldZSample );
1320 c100.at(3) =
static_cast<proshade_double
> ( map[oldMapIndex] );
1322 oldMapIndex = zTop +
static_cast< proshade_signed
> ( zDimS ) * ( yBottom +
static_cast< proshade_signed
> ( yDimS ) * xTop );
1323 c101.at(0) =
static_cast<proshade_double
> ( xTop ) *
static_cast<proshade_double
> ( oldXSample );
1324 c101.at(1) =
static_cast<proshade_double
> ( yBottom ) *
static_cast<proshade_double
> ( oldYSample );
1325 c101.at(2) =
static_cast<proshade_double
> ( zTop ) *
static_cast<proshade_double
> ( oldZSample );
1326 c101.at(3) =
static_cast<proshade_double
> ( map[oldMapIndex] );
1328 oldMapIndex = zBottom +
static_cast< proshade_signed
> ( zDimS ) * ( yTop +
static_cast< proshade_signed
> ( yDimS ) * xTop );
1329 c110.at(0) =
static_cast<proshade_double
> ( xTop ) *
static_cast<proshade_double
> ( oldXSample );
1330 c110.at(1) =
static_cast<proshade_double
> ( yTop ) *
static_cast<proshade_double
> ( oldYSample );
1331 c110.at(2) =
static_cast<proshade_double
> ( zBottom ) *
static_cast<proshade_double
> ( oldZSample );
1332 c110.at(3) =
static_cast<proshade_double
> ( map[oldMapIndex] );
1334 oldMapIndex = zTop +
static_cast< proshade_signed
> ( zDimS ) * ( yTop +
static_cast< proshade_signed
> ( yDimS ) * xTop );
1335 c111.at(0) =
static_cast<proshade_double
> ( xTop ) *
static_cast<proshade_double
> ( oldXSample );
1336 c111.at(1) =
static_cast<proshade_double
> ( yTop ) *
static_cast<proshade_double
> ( oldYSample );
1337 c111.at(2) =
static_cast<proshade_double
> ( zTop ) *
static_cast<proshade_double
> ( oldZSample );
1338 c111.at(3) =
static_cast<proshade_double
> ( map[oldMapIndex] );
1341 xRelative = ( (
static_cast<proshade_double
> ( xIt ) *
static_cast<proshade_double
> ( newXSample ) ) - (
static_cast<proshade_double
> ( xBottom ) *
static_cast<proshade_double
> ( oldXSample ) ) ) / ( (
static_cast<proshade_double
> ( xTop ) *
static_cast<proshade_double
> ( oldXSample ) ) - (
static_cast<proshade_double
> ( xBottom ) *
static_cast<proshade_double
> ( oldXSample ) ) );
1344 c00.at(0) = (
static_cast< proshade_double
> ( newXSample ) * xRelative ) + c000.at(0);
1345 c00.at(1) = c000.at(1);
1346 c00.at(2) = c000.at(2);
1347 c00.at(3) = ( c000.at(3) * ( 1.0 - xRelative ) ) + ( c100.at(3) * xRelative );
1350 c01.at(0) = (
static_cast< proshade_double
> ( newXSample ) * xRelative ) + c001.at(0);
1351 c01.at(1) = c001.at(1);
1352 c01.at(2) = c001.at(2);
1353 c01.at(3) = ( c001.at(3) * ( 1.0 - xRelative ) ) + ( c101.at(3) * xRelative );
1356 c10.at(0) = (
static_cast< proshade_double
> ( newXSample ) * xRelative ) + c010.at(0);
1357 c10.at(1) = c010.at(1);
1358 c10.at(2) = c010.at(2);
1359 c10.at(3) = ( c010.at(3) * ( 1.0 - xRelative ) ) + ( c110.at(3) * xRelative );
1362 c11.at(0) = (
static_cast< proshade_double
> ( newXSample ) * xRelative ) + c011.at(0);
1363 c11.at(1) = c011.at(1);
1364 c11.at(2) = c011.at(2);
1365 c11.at(3) = ( c011.at(3) * ( 1.0 - xRelative ) ) + ( c111.at(3) * xRelative );
1368 yRelative = ( (
static_cast<proshade_double
> ( yIt ) *
static_cast<proshade_double
> ( newYSample ) ) - (
static_cast<proshade_double
> ( yBottom ) *
static_cast<proshade_double
> ( oldYSample ) ) ) / ( (
static_cast<proshade_double
> ( yTop ) *
static_cast<proshade_double
> ( oldYSample ) ) - (
static_cast<proshade_double
> ( yBottom ) *
static_cast<proshade_double
> ( oldYSample ) ) );
1371 c0.at(0) = c00.at(0);
1372 c0.at(1) = (
static_cast< proshade_double
> ( newYSample ) * yRelative ) + c00.at(1);
1373 c0.at(2) = c00.at(2);
1374 c0.at(3) = ( c00.at(3) * ( 1.0 - yRelative ) ) + ( c10.at(3) * yRelative );
1377 c1.at(0) = c01.at(0);
1378 c1.at(1) = (
static_cast< proshade_double
> ( newYSample ) * yRelative ) + c01.at(1);
1379 c1.at(2) = c01.at(2);
1380 c1.at(3) = ( c01.at(3) * ( 1.0 - yRelative ) ) + ( c11.at(3) * yRelative );
1383 zRelative = ( (
static_cast<proshade_double
> ( zIt ) *
static_cast< proshade_double
> ( newZSample ) ) - (
static_cast<proshade_double
> ( zBottom ) *
static_cast<proshade_double
> ( oldZSample ) ) ) /
static_cast< proshade_double
> ( (
static_cast<proshade_double
> ( zTop ) *
static_cast<proshade_double
> ( oldZSample ) ) - (
static_cast<proshade_double
> ( zBottom ) *
static_cast<proshade_double
> ( oldZSample ) ) );
1384 newMap[newMapIndex] = ( c0.at(3) * ( 1.0 - zRelative ) ) + ( c1.at(3) * zRelative );
1391 map =
new proshade_double [newXDim * newYDim * newZDim];
1394 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( newXDim * newYDim * newZDim ); iter++ )
1396 map[iter] = newMap[iter];
1403 corrs[0] =
static_cast< proshade_single
> ( newXDim - xDim );
1404 corrs[1] =
static_cast< proshade_single
> ( newYDim - yDim );
1405 corrs[2] =
static_cast< proshade_single
> ( newZDim - zDim );
1406 corrs[3] =
static_cast< proshade_single
> ( newXDim ) *
static_cast< proshade_single
> ( newXSample );
1407 corrs[4] =
static_cast< proshade_single
> ( newYDim ) *
static_cast< proshade_single
> ( newYSample );
1408 corrs[5] =
static_cast< proshade_single
> ( newZDim ) *
static_cast< proshade_single
> ( newZSample );
1442 if ( resolution <= 0.0f )
1444 throw ProSHADE_exception (
"Requested resolution not set for map re-sampling.",
"EM00015", __FILE__, __LINE__, __func__,
"There is no resolution value set, but map re-sampling to\n : this unset resolution value is required. This error\n : occurs when a task with no resolution requirement is\n : requested on a map data and the map resolution change is\n : set to \'on\'. Either supply a resolution value, or do not\n : re-sample the map." );
1452 if ( newXDim % 2 != 0 ) { newXDim += 1; }
1453 if ( newYDim % 2 != 0 ) { newYDim += 1; }
1454 if ( newZDim % 2 != 0 ) { newZDim += 1; }
1456 proshade_signed preXChange, preYChange, preZChange;
1457 preXChange =
static_cast< proshade_signed
> ( std::floor ( (
static_cast<proshade_single
> ( xDimS ) -
static_cast<proshade_single
> ( newXDim ) ) / 2.0f ) );
1458 preYChange =
static_cast< proshade_signed
> ( std::floor ( (
static_cast<proshade_single
> ( yDimS ) -
static_cast<proshade_single
> ( newYDim ) ) / 2.0f ) );
1459 preZChange =
static_cast< proshade_signed
> ( std::floor ( (
static_cast<proshade_single
> ( zDimS ) -
static_cast<proshade_single
> ( newZDim ) ) / 2.0f ) );
1461 proshade_signed postXChange =
static_cast<proshade_signed
> ( xDimS ) - ( preXChange +
static_cast<proshade_signed
> ( newXDim ) );
1462 proshade_signed postYChange =
static_cast<proshade_signed
> ( yDimS ) - ( preYChange +
static_cast<proshade_signed
> ( newYDim ) );
1463 proshade_signed postZChange =
static_cast<proshade_signed
> ( zDimS ) - ( preZChange +
static_cast<proshade_signed
> ( newZDim ) );
1465 proshade_unsign origSizeArr = 0, newSizeArr = 0;
1466 proshade_double normFactor =
static_cast<proshade_double
> ( xDimS * yDimS * zDimS );
1469 fftw_complex *origMap, *fCoeffs, *newFCoeffs, *newMap;
1470 fftw_plan planForwardFourier, planBackwardRescaledFourier;
1472 xDimS, yDimS, zDimS, newXDim, newYDim, newZDim );
1475 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( normFactor ); iter++ ) { origMap[iter][0] = map[iter]; origMap[iter][1] = 0.0; }
1476 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( newXDim * newYDim * newZDim ); iter++ ) { newFCoeffs[iter][0] = 0.0; newFCoeffs[iter][1] = 0.0; }
1479 fftw_execute ( planForwardFourier );
1482 changeFourierOrder ( fCoeffs,
static_cast< proshade_signed
> ( xDimS ),
static_cast< proshade_signed
> ( yDimS ),
static_cast< proshade_signed
> ( zDimS ),
true );
1485 for ( proshade_unsign xIt = 0; xIt < newXDim; xIt++ )
1487 for ( proshade_unsign yIt = 0; yIt < newYDim; yIt++ )
1489 for ( proshade_unsign zIt = 0; zIt < newZDim; zIt++ )
1492 origSizeArr = ( ( zIt +
static_cast< proshade_unsign
> ( preZChange ) ) + zDimS *
1493 ( ( yIt +
static_cast< proshade_unsign
> ( preYChange ) ) + yDimS *
1494 ( xIt +
static_cast< proshade_unsign
> ( preXChange ) ) ) );
1495 newSizeArr = zIt + newZDim * ( yIt + newYDim * xIt );
1498 if ( ( ( -1 <
static_cast< proshade_signed
> ( xIt ) + preXChange ) && ( -1 <
static_cast<proshade_signed
> ( yIt ) + preYChange ) && ( -1 <
static_cast<proshade_signed
> ( zIt ) + preZChange ) ) &&
1499 ( ( xIt < newXDim + static_cast<proshade_unsign> ( postXChange ) ) && ( yIt < newYDim +
static_cast<proshade_unsign
> ( postYChange ) ) && ( zIt < newZDim +
static_cast<proshade_unsign
> ( postZChange ) ) ) )
1502 newFCoeffs[newSizeArr][0] = fCoeffs[origSizeArr][0] / normFactor;
1503 newFCoeffs[newSizeArr][1] = fCoeffs[origSizeArr][1] / normFactor;
1510 changeFourierOrder ( newFCoeffs,
static_cast< proshade_signed
> ( newXDim ),
static_cast< proshade_signed
> ( newYDim ),
static_cast< proshade_signed
> ( newZDim ),
false );
1513 fftw_execute ( planBackwardRescaledFourier );
1517 map =
new proshade_double [newXDim * newYDim * newZDim];
1519 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( newXDim * newYDim * newZDim ); iter++ ) { map[iter] = newMap[iter][0]; }
1525 corrs[0] =
static_cast< proshade_single
> ( newXDim ) -
static_cast< proshade_single
> ( xDimS );
1526 corrs[1] =
static_cast< proshade_single
> ( newYDim ) -
static_cast< proshade_single
> ( yDimS );
1527 corrs[2] =
static_cast< proshade_single
> ( newZDim ) -
static_cast< proshade_single
> ( zDimS );
1528 corrs[3] =
static_cast< proshade_single
> ( newXDim ) *
static_cast< proshade_single
> ( resolution / 2.0f );
1529 corrs[4] =
static_cast< proshade_single
> ( newYDim ) *
static_cast< proshade_single
> ( resolution / 2.0f );
1530 corrs[5] =
static_cast< proshade_single
> ( newZDim ) *
static_cast< proshade_single
> ( resolution / 2.0f );
1555 void ProSHADE_internal_mapManip::allocateResolutionFourierMemory ( fftw_complex*& origMap, fftw_complex*& fCoeffs, fftw_complex*& newFCoeffs, fftw_complex*& newMap, fftw_plan& planForwardFourier, fftw_plan& planBackwardRescaledFourier, proshade_unsign xDimOld, proshade_unsign yDimOld, proshade_unsign zDimOld, proshade_unsign xDimNew, proshade_unsign yDimNew, proshade_unsign zDimNew )
1558 origMap =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( fftw_complex ) * xDimOld * yDimOld * zDimOld ) );
1559 fCoeffs =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( fftw_complex ) * xDimOld * yDimOld * zDimOld ) );
1560 newFCoeffs =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( fftw_complex ) * xDimNew * yDimNew * zDimNew ) );
1561 newMap =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( fftw_complex ) * xDimNew * yDimNew * zDimNew ) );
1570 planForwardFourier = fftw_plan_dft_3d (
static_cast< int > ( xDimOld ),
static_cast< int > ( yDimOld ),
static_cast< int > ( zDimOld ), origMap, fCoeffs, FFTW_FORWARD, FFTW_ESTIMATE );
1571 planBackwardRescaledFourier = fftw_plan_dft_3d (
static_cast< int > ( xDimNew ),
static_cast< int > ( yDimNew ),
static_cast< int > ( zDimNew ), newFCoeffs, newMap, FFTW_BACKWARD, FFTW_ESTIMATE );
1592 fftw_destroy_plan ( planForwardFourier );
1593 fftw_destroy_plan ( planBackwardRescaledFourier );
1596 fftw_free ( origMap );
1597 fftw_free ( fCoeffs );
1598 fftw_free ( newFCoeffs );
1599 fftw_free ( newMap );
1621 proshade_signed h = 0, k = 0, l = 0, origSizeArr = 0, newSizeArr = 0;
1622 proshade_signed xSeq1FreqStart, ySeq1FreqStart, zSeq1FreqStart, xSeq2FreqStart, ySeq2FreqStart, zSeq2FreqStart;
1625 if ( negativeFirst )
1627 if ( ( xDim % 2 ) == 0 ) { xSeq1FreqStart = xDim / 2; xSeq2FreqStart = xDim / 2; }
else { xSeq1FreqStart = (xDim / 2) + 1; xSeq2FreqStart = xDim / 2; }
1628 if ( ( yDim % 2 ) == 0 ) { ySeq1FreqStart = yDim / 2; ySeq2FreqStart = yDim / 2; }
else { ySeq1FreqStart = (yDim / 2) + 1; ySeq2FreqStart = yDim / 2; }
1629 if ( ( zDim % 2 ) == 0 ) { zSeq1FreqStart = zDim / 2; zSeq2FreqStart = zDim / 2; }
else { zSeq1FreqStart = (zDim / 2) + 1; zSeq2FreqStart = zDim / 2; }
1633 if ( ( xDim % 2 ) == 0 ) { xSeq1FreqStart = xDim / 2; xSeq2FreqStart = xDim / 2; }
else { xSeq1FreqStart = (xDim / 2); xSeq2FreqStart = xDim / 2 + 1; }
1634 if ( ( yDim % 2 ) == 0 ) { ySeq1FreqStart = yDim / 2; ySeq2FreqStart = yDim / 2; }
else { ySeq1FreqStart = (yDim / 2); ySeq2FreqStart = yDim / 2 + 1; }
1635 if ( ( zDim % 2 ) == 0 ) { zSeq1FreqStart = zDim / 2; zSeq2FreqStart = zDim / 2; }
else { zSeq1FreqStart = (zDim / 2); zSeq2FreqStart = zDim / 2 + 1; }
1639 fftw_complex *hlpFCoeffs =
reinterpret_cast< fftw_complex*
> ( fftw_malloc (
sizeof ( fftw_complex ) *
static_cast< proshade_unsign
> ( xDim * yDim * zDim ) ) );
1643 for ( proshade_signed xIt = 0; xIt < xDim; xIt++ )
1646 if ( xIt < xSeq1FreqStart ) { h = xIt + xSeq2FreqStart; }
else { h = xIt - xSeq1FreqStart; }
1648 for ( proshade_signed yIt = 0; yIt < yDim; yIt++ )
1651 if ( yIt < ySeq1FreqStart ) { k = yIt + ySeq2FreqStart; }
else { k = yIt - ySeq1FreqStart; }
1653 for ( proshade_signed zIt = 0; zIt < zDim; zIt++ )
1656 if ( zIt < zSeq1FreqStart ) { l = zIt + zSeq2FreqStart; }
else { l = zIt - zSeq1FreqStart; }
1659 newSizeArr = l + zDim * ( k + yDim * h );
1660 origSizeArr = zIt + zDim * ( yIt + yDim * xIt );
1663 hlpFCoeffs[newSizeArr][0] = fCoeffs[origSizeArr][0];
1664 hlpFCoeffs[newSizeArr][1] = fCoeffs[origSizeArr][1];
1670 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( xDim * yDim * zDim ); iter++ ) { fCoeffs[iter][0] = hlpFCoeffs[iter][0]; fCoeffs[iter][1] = hlpFCoeffs[iter][1]; }
1673 fftw_free ( hlpFCoeffs );
1694 proshade_double real, imag, mag, phase;
1695 proshade_unsign arrayPos = 0;
1696 proshade_double normFactor =
static_cast<proshade_double
> ( xDim * yDim * zDim );
1699 for ( proshade_unsign uIt = 0; uIt < xDim; uIt++ )
1701 for ( proshade_unsign vIt = 0; vIt < yDim; vIt++ )
1703 for ( proshade_unsign wIt = 0; wIt < zDim; wIt++ )
1706 arrayPos = wIt + zDim * ( vIt + yDim * uIt );
1707 real = mapCoeffs[arrayPos][0];
1708 imag = mapCoeffs[arrayPos][1];
1711 mag = std::sqrt ( (real*real) + (imag*imag) );;
1715 mapCoeffs[arrayPos][0] = ( mag * cos(phase) ) / normFactor;
1716 mapCoeffs[arrayPos][1] = ( mag * sin(phase) ) / normFactor;
1743 proshade_signed xDim =
static_cast< proshade_signed
> ( xDimS );
1744 proshade_signed yDim =
static_cast< proshade_signed
> ( yDimS );
1745 proshade_signed zDim =
static_cast< proshade_signed
> ( zDimS );
1746 proshade_signed currentPos, neighArrPos, neighXPos, neighYPos, neighZPos;
1747 proshade_double neighSum;
1748 proshade_double neighCount = pow ( ( ( fakeMapKernel * 2 ) + 1 ), 3.0 ) - 1.0;
1751 for ( proshade_signed uIt = 0; uIt < xDim; uIt++ )
1753 for ( proshade_signed vIt = 0; vIt < yDim; vIt++ )
1755 for ( proshade_signed wIt = 0; wIt < zDim; wIt++ )
1758 currentPos = wIt + zDim * ( vIt + yDim * uIt );
1762 for ( proshade_signed xCh = -fakeMapKernel; xCh <= +fakeMapKernel; xCh++ )
1764 for ( proshade_signed yCh = -fakeMapKernel; yCh <= +fakeMapKernel; yCh++ )
1766 for ( proshade_signed zCh = -fakeMapKernel; zCh <= +fakeMapKernel; zCh++ )
1768 if ( ( xCh == 0 ) && ( yCh == 0 ) && ( zCh == 0 ) ) {
continue; }
1771 neighXPos = uIt + xCh;
if ( neighXPos >= xDim ) { neighXPos -= xDim; };
if ( neighXPos < 0 ) { neighXPos += xDim; }
1772 neighYPos = vIt + yCh;
if ( neighYPos >= yDim ) { neighYPos -= yDim; };
if ( neighYPos < 0 ) { neighYPos += yDim; }
1773 neighZPos = wIt + zCh;
if ( neighZPos >= zDim ) { neighZPos -= zDim; };
if ( neighZPos < 0 ) { neighZPos += zDim; }
1774 neighArrPos = neighZPos + zDim * ( neighYPos + yDim * neighXPos );
1777 neighSum += map[neighArrPos];
1783 fakeHalfMap[currentPos] = neighSum / neighCount;
1808 proshade_signed xDim =
static_cast< proshade_signed
> ( xDimS ), yDim =
static_cast< proshade_signed
> ( yDimS ), zDim =
static_cast< proshade_signed
> ( zDimS ), currentPos, neighArrPos, neighXPos, neighYPos, neighZPos, corrIter;
1809 proshade_unsign noCorrVals =
static_cast<proshade_unsign
> ( pow ( ( ( corrMaskKernel * 2 ) + 1 ), 3 ) );
1812 proshade_double *origMap =
new proshade_double [noCorrVals];
1813 proshade_double *fakeHM =
new proshade_double [noCorrVals];
1820 for ( proshade_signed uIt = 0; uIt < xDim; uIt++ )
1822 for ( proshade_signed vIt = 0; vIt < yDim; vIt++ )
1824 for ( proshade_signed wIt = 0; wIt < zDim; wIt++ )
1827 currentPos = wIt + zDim * ( vIt + yDim * uIt );
1831 for ( proshade_signed xCh = -corrMaskKernel; xCh <= +corrMaskKernel; xCh++ )
1833 for ( proshade_signed yCh = -corrMaskKernel; yCh <= +corrMaskKernel; yCh++ )
1835 for ( proshade_signed zCh = -corrMaskKernel; zCh <= +corrMaskKernel; zCh++ )
1838 neighXPos = uIt + xCh;
if ( neighXPos >= xDim ) { neighXPos -= xDim; };
if ( neighXPos < 0 ) { neighXPos += xDim; }
1839 neighYPos = vIt + yCh;
if ( neighYPos >= yDim ) { neighYPos -= yDim; };
if ( neighYPos < 0 ) { neighYPos += yDim; }
1840 neighZPos = wIt + zCh;
if ( neighZPos >= zDim ) { neighZPos -= zDim; };
if ( neighZPos < 0 ) { neighZPos += zDim; }
1841 neighArrPos = neighZPos + zDim * ( neighYPos + yDim * neighXPos );
1844 origMap[corrIter] = map[neighArrPos];
1845 fakeHM[corrIter] = fakeHalfMap[neighArrPos];
1880 std::max ( dist / ( yAngs /
static_cast<proshade_single
> ( yDim ) ),
1881 dist / ( zAngs /
static_cast<proshade_single
> ( zDim ) ) ) ) ) );
1899 void ProSHADE_internal_mapManip::connectMaskBlobs ( proshade_double*& mask, proshade_signed xDim, proshade_signed yDim, proshade_signed zDim, proshade_single xAngs, proshade_single yAngs, proshade_single zAngs, proshade_single maskThres )
1902 proshade_double* hlpMap =
new proshade_double[xDim * yDim * zDim];
1903 proshade_signed addSurroundingPoints =
static_cast< proshade_signed
> ( std::max ( 3L,
static_cast<proshade_signed
> ( std::ceil (
getIndicesFromAngstroms(
static_cast< proshade_unsign
> ( xDim ),
static_cast< proshade_unsign
> ( yDim ),
static_cast< proshade_unsign
> ( zDim ), xAngs, yAngs, zAngs,
static_cast< proshade_single
> ( std::max( xAngs, std::max( yAngs, zAngs ) ) * 0.1f ) ) ) ) ) );
1904 proshade_signed currPos, neighXPos, neighYPos, neighZPos, neighArrPos;
1910 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( xDim * yDim * zDim ); iter++ ) { hlpMap[iter] = mask[iter]; }
1913 for ( proshade_signed it = 0; it < addSurroundingPoints; it++ )
1916 for ( proshade_signed xIt = 0; xIt < xDim; xIt++ )
1918 for ( proshade_signed yIt = 0; yIt < yDim; yIt++ )
1920 for ( proshade_signed zIt = 0; zIt < zDim; zIt++ )
1923 currPos = zIt + zDim * ( yIt + yDim * xIt );
1926 if ( hlpMap[currPos] <
static_cast< proshade_double
> ( maskThres ) ) {
continue; }
1929 for ( proshade_signed xCh = -1; xCh <= +1; xCh++ )
1931 for ( proshade_signed yCh = -1; yCh <= +1; yCh++ )
1933 for ( proshade_signed zCh = -1; zCh <= +1; zCh++ )
1935 if ( ( xCh == 0 ) && ( yCh == 0 ) && ( zCh == 0 ) ) {
continue; }
1938 neighXPos = xIt + xCh;
if ( neighXPos < 0 ) {
continue; }
if ( neighXPos >= xDim ) {
continue; }
1939 neighYPos = yIt + yCh;
if ( neighYPos < 0 ) {
continue; }
if ( neighYPos >= yDim ) {
continue; }
1940 neighZPos = zIt + zCh;
if ( neighZPos < 0 ) {
continue; }
if ( neighZPos >= zDim ) {
continue; }
1941 neighArrPos = neighZPos + zDim * ( neighYPos + yDim * neighXPos );
1944 if ( hlpMap[neighArrPos] <
static_cast< proshade_double
> ( maskThres ) ) { mask[neighArrPos] =
static_cast< proshade_double
> ( maskThres ); }
1953 for ( proshade_unsign iter = 0; iter < static_cast<proshade_unsign> ( xDim * yDim * zDim ); iter++ ) { hlpMap[iter] = mask[iter]; }
1979 while ( bounds[1] >=
static_cast<proshade_signed
> ( xDim ) ) { xDim += 10; }
1980 while ( bounds[3] >=
static_cast<proshade_signed
> ( yDim ) ) { yDim += 10; }
1981 while ( bounds[5] >=
static_cast<proshade_signed
> ( zDim ) ) { zDim += 10; }
1984 proshade_signed addToX =
betterClosePrimeFactors ( bounds[1] - bounds[0] + 1,
static_cast< proshade_signed
> ( xDim ) );
1985 proshade_signed addToY =
betterClosePrimeFactors ( bounds[3] - bounds[2] + 1,
static_cast< proshade_signed
> ( yDim ) );
1986 proshade_signed addToZ =
betterClosePrimeFactors ( bounds[5] - bounds[4] + 1,
static_cast< proshade_signed
> ( zDim ) );
1989 proshade_signed XtoY = std::abs ( addToX - addToY );
1990 proshade_signed XtoZ = std::abs ( addToX - addToZ );
1991 proshade_signed YtoZ = std::abs ( addToY - addToZ );
1993 if ( ( ( XtoY < boundsDiffThres ) && ( XtoZ < boundsDiffThres ) ) ||
1994 ( ( XtoY < boundsDiffThres ) && ( YtoZ < boundsDiffThres ) ) ||
1995 ( ( XtoZ < boundsDiffThres ) && ( YtoZ < boundsDiffThres ) ) )
1998 proshade_signed maxSize = std::max ( addToX, std::max ( addToY, addToZ ) );
2006 if ( XtoY <= boundsDiffThres )
2008 proshade_signed maxSize = std::max ( addToX, addToY );
2012 if ( XtoZ <= boundsDiffThres )
2014 proshade_signed maxSize = std::max ( addToX, addToZ );
2018 if ( YtoZ <= boundsDiffThres )
2020 proshade_signed maxSize = std::max ( addToY, addToZ );
2049 proshade_signed ret = fromRange;
2050 std::vector < proshade_signed > posibles, hlp;
2051 proshade_signed sum;
2054 for ( proshade_signed iter = fromRange; iter < toRange; iter++ )
2058 for ( proshade_unsign i = 0; i < static_cast<proshade_unsign> ( hlp.size() ); i++ ) { sum += hlp.at(i); }
2064 for ( proshade_signed iter = fromRange; iter < toRange; iter++ )
2067 if ( iter %2 != 0 ) {
continue; }
2070 if ( posibles.at(
static_cast< size_t > ( iter - fromRange ) ) < ( posibles.at(
static_cast< size_t > ( ret - fromRange ) ) - ( iter - ret ) ) ) { ret = iter; }
2074 if ( ( ret % 2 != 0 ) && ( ret < ( toRange - 1 ) ) ) { ret += 1; }
2095 if ( newBoundRange > oldBoundRange )
2098 proshade_signed distributeThis = newBoundRange - oldBoundRange;
2100 while ( distributeThis != 0 )
2103 distributeThis -= 1;
2105 if ( distributeThis != 0 )
2108 distributeThis -= 1;
2142 void ProSHADE_internal_mapManip::copyMapByBounds ( proshade_signed xFrom, proshade_signed xTo, proshade_signed yFrom, proshade_signed yTo, proshade_signed zFrom, proshade_signed zTo, proshade_signed origXFrom, proshade_signed origYFrom, proshade_signed origZFrom, proshade_unsign yDimIndices, proshade_unsign zDimIndices, proshade_unsign origXDimIndices, proshade_unsign origYDimIndices, proshade_unsign origZDimIndices, proshade_double*& newMap, proshade_double* origMap )
2145 proshade_signed newMapIndex, oldMapIndex, oldX, oldY, oldZ, newX, newY, newZ;
2148 for ( proshade_signed xIt = xFrom; xIt <= xTo; xIt++ )
2151 newX = ( xIt - xFrom );
2152 oldX = ( newX + ( xFrom - origXFrom ) );
2154 for ( proshade_signed yIt = yFrom; yIt <= yTo; yIt++ )
2157 newY = ( yIt - yFrom );
2158 oldY = ( newY + ( yFrom - origYFrom ) );
2160 for ( proshade_signed zIt = zFrom; zIt <= zTo; zIt++ )
2163 newZ = ( zIt - zFrom );
2164 oldZ = ( newZ + ( zFrom - origZFrom ) );
2167 newMapIndex = newZ +
static_cast< proshade_signed
> ( zDimIndices ) * ( newY +
static_cast< proshade_signed
> ( yDimIndices ) * newX );
2168 oldMapIndex = oldZ +
static_cast< proshade_signed
> ( origZDimIndices ) * ( oldY +
static_cast< proshade_signed
> ( origYDimIndices ) * oldX );
2171 if ( ( ( oldX < 0 ) || ( oldX >=
static_cast< proshade_signed
> ( origXDimIndices ) ) ) ||
2172 ( ( oldY < 0 ) || ( oldY >=
static_cast< proshade_signed
> ( origYDimIndices ) ) ) ||
2173 ( ( oldZ < 0 ) || ( oldZ >=
static_cast< proshade_signed
> ( origZDimIndices ) ) ) )
2176 newMap[newMapIndex] = 0.0;
2181 newMap[newMapIndex] = origMap[oldMapIndex];