combine surfaces into one big surface

28 visualizzazioni (ultimi 30 giorni)
Wesley Ooms
Wesley Ooms il 28 Giu 2013
Risposto: Ted Shultz il 3 Giu 2020
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.

Risposta accettata

Matt J
Matt J il 28 Giu 2013
Modificato: Matt J il 28 Giu 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 Commento
Faez Alkadi
Faez Alkadi il 26 Ott 2017
Modificato: Faez Alkadi il 26 Ott 2017
Is there a way to create a fv that is the merging results of all 376 parts and patch them as one surface?

Accedi per commentare.

Più risposte (1)

Ted Shultz
Ted Shultz il 3 Giu 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