% Function for detecting an object within an given area % % result = get_3D_edge(geometry,[ x, y, z]) % % geometry = geometry % xyz = coordinates % density % % result = edge(s) in the given coordinates function result = face(geometry,x,y,z,tol,density) % getting geometry dimension [gd] = geominfo(geometry,'out',{'gd'}); % getting geometrie infos : number of objects (for every space dimension) and parameter range [no,rng] = geominfo(geometry,'out',{'no' 'rng'},'od',0:gd); % plot geometrie for control purposes figure, geomplot(geometry,'facelabels','on'); % x = number of points between pointelements % if tol does not exist, set tol to eps if exist('tol','var') ~= 1 tol = eps; end % if density does not existiert, set it to 2 if exist('density','var') ~= 1 density = [2 2]; end % creating a matrix for the elements greater x coordinate_matrix_x_g = zeros(1,no(3)); % creating a matrix for the elements smaller x coordinate_matrix_x_s = zeros(1,no(3)); % creating a matrix for the elements greater y coordinate_matrix_y_g = zeros(1,no(3)); % creating a matrix for the elements smaller y coordinate_matrix_y_s = zeros(1,no(3)); % creating a matrix for the elements greater z coordinate_matrix_z_g = zeros(1,no(3)); % creating a matrix for the elements smaller z coordinate_matrix_z_s = zeros(1,no(3)); adj = geominfo(geometry,'out','adj','odp',[1;2]) for k=1:no(3) k %% debug B = find(adj{1}(:,k)); for i=1:length(B) S(i,:,1) = linspace(rng{2}(1,B(i)),rng{2}(2,B(i)),density); end [xyz]=geominfo(geometry,'out',{'xx'},'par',{{B S}}); %% Calculating the X-Coordinates % getting elements with x-coordinate > x groesse=prod(size(xyz{1}(:,:,1))); if length(find(xyz{1}(:,:,1) + tol >= x(1))) >= groesse coordinate_matrix_x_g(k)=1; end if length(find(xyz{1}(:,:,1) <= x(2) + tol)) >= groesse coordinate_matrix_x_s(k)=1; end %% Calculating the Y-Coordinates % getting elements with y-coordinate > y groesse=prod(size(xyz{1}(:,:,2))); if length(find(xyz{1}(:,:,2) + tol >= y(1))) >= groesse coordinate_matrix_y_g(k)=1; end if length(find(xyz{1}(:,:,2) <= y(2) + tol)) >= groesse coordinate_matrix_y_s(k)=1; end %% Z - Coordinate if length(no) == 4 % getting elements with z-coordinate > z if length(find(xyz{1}(:,:,3) + tol >= z(1))) >= groesse coordinate_matrix_z_g(k)=1; end if length(find(xyz{1}(:,:,3) <= z(2) + tol)) >= groesse coordinate_matrix_z_s(k)=1; end end clear('B'); clear('S'); end % Merge the x-coordinate_s and x-coordinate_g matrix coordinate_matrix_x = coordinate_matrix_x_g & coordinate_matrix_x_s; % Merge the y-coordinate_s and y-coordinate_g matrix coordinate_matrix_y = coordinate_matrix_y_g & coordinate_matrix_y_s; % Merge the z-coordinate_s and z-coordinate_g matrix if length(no) == 4 coordinate_matrix_z = coordinate_matrix_z_g & coordinate_matrix_z_s; end %% Calculating the Object which fullfills all the conditions x y z % Addition of both matrices to get the element which is the searchobject if length(no) == 4 result{1} = find(coordinate_matrix_x & coordinate_matrix_y & coordinate_matrix_z == 1); else result{1} = find(coordinate_matrix_x & coordinate_matrix_y == 1); end