Tree @lintian-fixes/main (Download .tar.gz)
- .git_filters
- debian
- doc
- meshfix
- sample
- tools
- .gitattributes
- .gitignore
- .gitmodules
- advancefront.m
- affinemap.m
- AUTHORS.txt
- barydualmesh.m
- base64decode.m
- base64encode.m
- bbxflatsegment.m
- binsurface.m
- bwislands.m
- cgals2m.m
- cgalv2m.m
- ChangeLog.txt
- closestnode.m
- Content.txt
- COPYING.txt
- decodevarname.m
- deislands2d.m
- deislands3d.m
- delendelem.m
- deletemeshfile.m
- DESCRIPTION
- dist2surf.m
- edgeneighbors.m
- elemfacecenter.m
- elemvolume.m
- encodevarname.m
- extractloops.m
- extrudecurve.m
- extrudesurf.m
- faceneighbors.m
- fallbackexeext.m
- fast_match_bracket.m
- fillholes3d.m
- fillsurf.m
- finddisconnsurf.m
- flatsegment.m
- gendocs.sh
- getexeext.m
- getintersecttri.m
- getoptkey.m
- getplanefrom3pt.m
- getvarfrom.m
- gzipdecode.m
- gzipencode.m
- highordertet.m
- i2m.m
- i2m.png
- i2m.prj
- imedge3d.m
- img2mesh.fig
- img2mesh.m
- INDEX
- innersurf.m
- insurface.m
- internalpoint.m
- iso2meshver.m
- isoctavemesh.m
- jdatadecode.m
- jdataencode.m
- jload.m
- jnifticreate.m
- jnii2nii.m
- jsave.m
- jsonopt.m
- latticegrid.m
- layersurf.m
- linextriangle.m
- loadbj.m
- loadjnifti.m
- loadjson.m
- loadmsgpack.m
- loadnifti.m
- loadubjson.m
- lz4decode.m
- lz4encode.m
- lz4hcdecode.m
- lz4hcencode.m
- lzipdecode.m
- lzipencode.m
- lzmadecode.m
- lzmaencode.m
- m2v.m
- maskdist.m
- match_bracket.m
- maxsurf.m
- mcpath.m
- memmapstream.m
- mergemesh.m
- mergestruct.m
- mergesurf.m
- mesh2mask.m
- mesh2vol.m
- meshabox.m
- meshacylinder.m
- meshanellip.m
- meshasphere.m
- meshcentroid.m
- meshcheckrepair.m
- meshconn.m
- meshcylinders.m
- meshedge.m
- mesheuler.m
- meshface.m
- meshgrid5.m
- meshgrid6.m
- meshinterp.m
- meshquality.m
- meshrefine.m
- meshremap.m
- meshreorient.m
- meshresample.m
- meshunitsphere.m
- metchgui.fig
- metchgui.m
- metchgui_one.m
- mwpath.m
- ndgaussian.m
- ndimfilter.m
- neighborelem.m
- nestbracket2dim.m
- nifticreate.m
- nii2jnii.m
- niicodemap.m
- niiformat.m
- nodesurfnorm.m
- nodevolume.m
- orderloopedge.m
- orthdisk.m
- outersurf.m
- plotedges.m
- plotmesh.m
- plotsurf.m
- plottetra.m
- polylineinterp.m
- polylinelen.m
- polylinesimplify.m
- proj2mesh.m
- qmeshcut.m
- raysurf.m
- raytrace.m
- readasc.m
- readgts.m
- readinr.m
- README.md
- README.txt
- readmedit.m
- readmptiff.m
- readnifti.m
- readnirfast.m
- readoff.m
- readsmf.m
- readtetgen.m
- regpt2surf.m
- remeshsurf.m
- removedupelem.m
- removedupnodes.m
- removeisolatednode.m
- removeisolatedsurf.m
- rotatevec3d.m
- rotmat2vec.m
- s2m.m
- s2v.m
- saveabaqus.m
- saveasc.m
- savebinstl.m
- savebj.m
- savebnii.m
- savedxf.m
- savegts.m
- saveinr.m
- savejmesh.m
- savejnifti.m
- savejnii.m
- savejson.m
- savemedit.m
- savemphtxt.m
- savemsgpack.m
- savemsh.m
- savenifti.m
- savenirfast.m
- saveoff.m
- savesmf.m
- savestl.m
- savesurfpoly.m
- savetetgenele.m
- savetetgennode.m
- saveubjson.m
- savevrml.m
- slicesurf.m
- slicesurf3.m
- smoothbinvol.m
- smoothsurf.m
- sms.m
- sortmesh.m
- surf2mesh.m
- surf2vol.m
- surf2volz.m
- surfaceclean.m
- surfacenorm.m
- surfboolean.m
- surfdiffuse.m
- surfedge.m
- surfinterior.m
- surfpart.m
- surfplane.m
- surfreorient.m
- surfseeds.m
- surfvolume.m
- thickenbinvol.m
- thinbinvol.m
- TODO.txt
- uniqedges.m
- uniqfaces.m
- v2m.m
- v2s.m
- varargin2struct.m
- vol2mesh.m
- vol2restrictedtri.m
- vol2surf.m
- volface.m
- volmap2mesh.m
- zlibdecode.m
- zlibencode.m
proj2mesh.m @lintian-fixes/main — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | function [newpt elemid weight]=proj2mesh(v,f,pt,nv,cn,radmax) % [newpt elemid weight]=proj2mesh(v,f,pt,nv,cn) % % project a point cloud on to the surface mesh (surface can only be triangular) % % author: Qianqian Fang <q.fang at neu.edu> % date: 12/12/2008 % % parameters: % v: node coordinate of the surface mesh (nn x 3) % f: element list of the surface mesh (3 columns for % triangular mesh, 4 columns for cubic surface mesh) % pt: points to be projected, 3 columns for x,y and z respectively % nv: nodal norms (vector) calculated from nodesurfnorm.m % with dimensions of (size(v,1),3) % cn: a integer vector with the length of p, denoting the closest % surface nodes (indices of v) for each point in p. this % value can be calculated from dist2surf.m % radmax: if speicified, the search for elements to project will be % limited to those within a bounding box with half-edge-length % of radmax centered at the point to be projected % % if nv and cn are not supplied, proj2mesh will project the point % cloud onto the surface by the direction pointing to the centroid % of the mesh % % outputs: % newpt: the projected points from p % elemid: a vector of length of p, denotes which surface trangle (in elem) % contains the projected point % weight: the barycentric coordinate for each projected points, these are % the weights % % Please find more information at http://iso2mesh.sf.net/cgi-bin/index.cgi?metch % % this function is part of "metch" toobox, see COPYING for license cent=mean(v); enum=length(f); ec=reshape(v(f(:,1:3)',:)', [3 3,enum]); centroid=squeeze(mean(ec,2)); newpt =zeros(size(pt,1),3); elemid=zeros(size(pt,1),1); weight=zeros(size(pt,1),3); [idoldmesh,loc]=ismember(pt,v,'rows'); idnode=find(idoldmesh); if(~isempty(idnode)) [tt,ll]=ismember(loc(idnode),f); [p1,p2]=ind2sub(size(f),ll); % p1 is the index in f newpt(idnode,:)=pt(idnode,:); elemid(idnode)=p1; weight(sub2ind(size(weight),idnode,p2))=1; end radlimit=-1; if(nargin>=5) % if nv and cn are supplied, use nodal norms to project the points direction=nv(cn,:); if(nargin>=6) radlimit=radmax; end elseif(nargin==3) % otherwise, project toward the centroid direction=pt-repmat(cent,size(pt,1),1); end for t=1:size(pt,1) if(idoldmesh(t)~=0) continue; end maxdist=sqrt(sum((pt(t,:)-cent).*(pt(t,:)-cent))); if(radlimit>0) maxdist=radlimit; end idx=find(centroid(1,:)>pt(t,1)-maxdist & ... centroid(1,:)<pt(t,1)+maxdist & ... centroid(2,:)>pt(t,2)-maxdist & ... centroid(2,:)<pt(t,2)+maxdist & ... centroid(3,:)>pt(t,3)-maxdist & ... centroid(3,:)<pt(t,3)+maxdist ); dist=centroid(:,idx); dist(1,:)=dist(1,:)-pt(t,1); dist(2,:)=dist(2,:)-pt(t,2); dist(3,:)=dist(3,:)-pt(t,3); c0=sum(dist.*dist); % sort the distances to accelate the calculation [c1,sorted]=sort(c0); for i=1:length(idx) % project the point along vector direction and calculate the intersection to a plane [inside,p,w]=linextriangle(pt(t,:), pt(t,:)+direction(t,:),v(f(idx(sorted(i)),:),:)); % the intersection is within the current trianglar surface if(inside) newpt(t,:)=p; weight(t,:)=w; elemid(t)=idx(sorted(i)); break; end end end |