combine surfaces into one big surface

25 vues (au cours des 30 derniers jours)
Wesley Ooms
Wesley Ooms le 28 Juin 2013
Hi,
I have a lot of surfaces and patches in a single plot; surf(this) surf(that). 376 in total. (I also have a struct with 376 handles to all surfaces/patches). Each patch on its own is pretty small, but every call to patch seems to be a call to the graphics renderer. To speed up the display updating, i would like to combine all surfaces, or patches, into one big surface. Is there an easy way to do this? All surfaces have the same color and all surfaces are stationary relative to each other. I was thinking about something like get all the handles and combine them into one handle somehow with al the vertexdata/facedata combined.

Réponse acceptée

Matt J
Matt J le 28 Juin 2013
Modifié(e) : Matt J le 28 Juin 2013
but every call to patch seems to be a call to the graphics renderer.
You could try generating handles to the surf/patch objects without rendering them, by calling
h(i) = patch(...,'Visible','off');
and similarly for surf. Once you've generated a vector of handles this way, and you're ready to display, you can make the entire plot visible by doing
set(h,'Visible','on')
  1 commentaire
Faez Alkadi
Faez Alkadi le 26 Oct 2017
Modifié(e) : Faez Alkadi le 26 Oct 2017
Is there a way to create a fv that is the merging results of all 376 parts and patch them as one surface?

Connectez-vous pour commenter.

Plus de réponses (1)

Ted Shultz
Ted Shultz le 3 Juin 2020
How I do this is I convert all the patch objects to polyshape objects, and then union the poly shape objects together. you can then convert the master polyshape back into a patch, or you can just display the polyshape. sample code for two shapes is shown below. If the patch objects are more complex shapes (multiple shapes per patch), then you sometimes need to do some additional tricks, but this is a start of what the code could look like.
p1=polyshape(h1.XData, h1.YData);
p2=polyshape(h2.XData, h2.YData);
polyout = union(p1,p2);
hOut = patch(polyout.Vertices(:,1),polyout.Vertices(:,2),'k','facecolor','none');
hOut.FaceColor = h1.FaceColor;
hOut.FaceAlpha = h1.FaceAlpha;
hOut.EdgeColor = h1.EdgeColor;
hOut.LineStyle = h1.LineStyle;
hOut.LineWidth = h1.LineWidth;
delete(h1)
delete(h2)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by