62 int x, y, z, dx = d->getSizeX(), dy = d->getSizeY(), dz = d->getSizeZ();
64 Point3df boxmax( -10000.0f, -10000.0f, -10000.0f );
65 Point3df boxmin( 10000.0f, 10000.0f, 10000.0f );
68 for ( z=0; z<dz; z++ )
69 for ( y=0; y<dy; y++ )
70 for ( x=0; x<dx; x++ )
71 if ( d->at( x, y, z ) )
73 pt =
Point3df(
float( x ),
float( y ),
float( z ) );
74 pt[ 0 ] *= dsize[ 0 ];
75 pt[ 1 ] *= dsize[ 1 ];
76 pt[ 2 ] *= dsize[ 2 ];
79 if ( npt[ 0 ] < boxmin[ 0 ] ) boxmin[ 0 ] = npt[ 0 ];
80 if ( npt[ 1 ] < boxmin[ 1 ] ) boxmin[ 1 ] = npt[ 1 ];
81 if ( npt[ 2 ] < boxmin[ 2 ] ) boxmin[ 2 ] = npt[ 2 ];
82 if ( npt[ 0 ] > boxmax[ 0 ] ) boxmax[ 0 ] = npt[ 0 ];
83 if ( npt[ 1 ] > boxmax[ 1 ] ) boxmax[ 1 ] = npt[ 1 ];
84 if ( npt[ 2 ] > boxmax[ 2 ] ) boxmax[ 2 ] = npt[ 2 ];
87 if ( fabs( boxmin[ 0 ] ) > fabs( boxmax[ 0 ] ) )
88 _scale[ 0 ] = 1.0f / fabs( boxmin[ 0 ] );
89 else _scale[ 0 ] = 1.0f / fabs( boxmax[ 0 ] );
91 std::cout <<
"Box Min : " << boxmin <<
"\tBox Max :" << boxmax << std::endl ;
92 _scale[ 1 ] = 1.0f / fabs( boxmax[ 1 ] );
95 _scale[ 2 ] = 1.0f / fabs( boxmin[ 2 ] );