133 | | //! Rectangular support each vector of XYZ specifies (begining-end) interval for each dimension. Same number of points, \c dimsize, in each dimension. |
134 | | void set_support ( const Array<vec> &XYZ, const int dimsize ) { |
135 | | set_support ( XYZ, dimsize*ones_i ( XYZ.length() ) ); |
136 | | } |
137 | | //! Rectangular support each vector of XYZ specifies (begining-end) interval for each dimension. \c gridsize specifies number of points is each dimension. |
138 | | void set_support ( const Array<vec> &XYZ, const ivec &gridsize ) { |
139 | | int dim = XYZ.length(); //check with internal dim!! |
140 | | Npoints = prod ( gridsize ); |
| 134 | //! Set support points from rectangular grid |
| 135 | void set_support ( rectangular_support &Sup) { |
| 136 | Npoints = Sup.points(); |
145 | | ivec ind = zeros_i ( dim ); //indeces of dimensions in for cycle; |
146 | | vec smpi ( dim ); // ith sample |
147 | | vec steps = zeros ( dim ); // ith sample |
148 | | // first corner |
149 | | for ( int j = 0; j < dim; j++ ) { |
150 | | smpi ( j ) = XYZ ( j ) ( 0 ); /* beginning of the interval*/ |
151 | | it_assert ( gridsize ( j ) != 0.0, "Zeros in gridsize!" ); |
152 | | steps ( j ) = ( XYZ ( j ) ( 1 ) - smpi ( j ) ) / gridsize ( j ); |
153 | | } |
154 | | // fill samples |
155 | | for ( int i = 0; i < Npoints; i++ ) { |
156 | | // copy |
157 | | samples ( i ) = smpi; |
158 | | // go through all dimensions |
159 | | for ( int j = 0; j < dim; j++ ) { |
160 | | if ( ind ( j ) == gridsize ( j ) - 1 ) { //j-th index is full |
161 | | ind ( j ) = 0; //shift back |
162 | | smpi ( j ) = XYZ ( j ) ( 0 ); |
163 | | |
164 | | if ( i < Npoints - 1 ) { |
165 | | ind ( j + 1 ) ++; //increase the next dimension; |
166 | | smpi ( j + 1 ) += steps ( j + 1 ); |
167 | | break; |
168 | | } |
169 | | |
170 | | } else { |
171 | | ind ( j ) ++; |
172 | | smpi ( j ) += steps ( j ); |
173 | | break; |
174 | | } |
175 | | } |
| 141 | samples(0)=Sup.first_vec(); |
| 142 | for (int j=1; j < Npoints; j++ ) { |
| 143 | samples ( j ) = Sup.next_vec(); |