Surface repairing utility contest

1. Test Dataset Script
2. Test Dataset Download
3. Sample Surface

1. Test Dataset Script

We use the following command with iso2mesh 1.0.1 to generate all testing datasets:

 [node,face]=randomsurface(hex2dec('623F9A9E'),100);

The output node and face are 100x1 cell array with each one being a random surface including 5 components.

Although it is not required, if you want to replicate the original data, you can download the following source code and version 1.0.1 release of iso2mesh (we ran the above command on a 64bit Ubuntu 10.04 Linux with MATLAB 7.4 or Octave 3.2.4).

function [node,face]=randomsurface(randseed,count)

rngstate = rand ('state');
rand('state',randseed);

node=cell(count,1);
face=cell(count,1);
[nosph,fcsph]=meshunitsphere(0.1);
[nobox,elbox,fcbox]=meshabox([0 0 0],[1 1 1],0.0005,0.1);
[nosph,fcsph]=removeisolatednode(nosph,fcsph);
[nobox,fcbox]=removeisolatednode(nobox,fcbox);
for i=1:count
    sphcount=floor(rand(1)*5)+1;
    sph=rand(sphcount,4)*100;
    sph(:,4)=sph(:,4)*0.2+10;
    box=rand(5-sphcount,6);
    node{i}=[];face{i}=[];
    for j=1:sphcount
        newnode=(rotationmatrix(rand(1,3),rand(1,3))*(sph(j,4)*nosph)')'+repmat(sph(j,1:3),size(nosph,1),1);
        if(j==1) 
            node{i}=newnode;
            face{i}=[fcsph ones(size(fcsph,1),1)];
        else
            [node{i},face{i}]=mergemesh(node{i},face{i},newnode,[fcsph j*ones(size(fcsph,1),1)]);
        end
    end
    for j=sphcount+1:5
        newnode=(rotationmatrix(rand(1,3),rand(1,3))*(diag(box(j-sphcount,1:3)*50+30)*nobox'))'+repmat(box(j-sphcount,4:6)*100,size(nobox,1),1);
        [node{i},face{i}]=mergemesh(node{i},face{i},newnode,[fcbox j*ones(size(fcbox,1),1)]);
    end
end

rand ('state',rngstate);

function R=rotationmatrix(u,v)
uvangle=acos(dot(u,v));
k=cross(u,v);
kx=[0 -k(1,3) k(1,2);k(1,3) 0 -k(1,1);-k(1,2) k(1,1) 0];
R=eye(3,3)+(kx.*sin(uvangle))+((1-cos(uvangle))*kx^2);

2. Test Dataset Download

The MATLAB .mat formatted data file can be downloaded from this URL (12MB).

To use the .mat file, you need to use either MATLAB or GNU Octave (a free matlab clone) and run

 load surface_repair.mat

at the directory containing the downloaded .mat file. The two variables loaded into the workspace, node and face are both 100x1 cell arrays, representing 100 random surfaces. To access each surface, you can use node{i} and face{i} where i is an integer between 1 and 100. For example, you can plot the results using

 plotmesh(node{i},face{i})

the array node{i} has 3 columns representing the x/y/z coordinates at each node (a row per node); the array face{i} has 4 integers per row, the first 3 integers denote the indices of the nodes forming a surface triangle (a row per triangle); the last integer is a grouping index, depicting the surface components.

3. Sample Surface

The figure below shows a sample surface (i=8) in the test dataset. The intersecting elements are quite obvious.

upload:surface_sample.png

Powered by Habitat