combine surfaces into one big surface

24 visualizaciones (últimos 30 días)
Wesley Ooms
Wesley Ooms el 28 de Jun. de 2013
Respondida: Ted Shultz el 3 de Jun. de 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.

Respuesta aceptada

Matt J
Matt J el 28 de Jun. de 2013
Editada: Matt J el 28 de Jun. de 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 comentario
Faez Alkadi
Faez Alkadi el 26 de Oct. de 2017
Editada: Faez Alkadi el 26 de Oct. de 2017
Is there a way to create a fv that is the merging results of all 376 parts and patch them as one surface?

Iniciar sesión para comentar.

Más respuestas (1)

Ted Shultz
Ted Shultz el 3 de Jun. de 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