combine surfaces into one big surface

27 次查看(过去 30 天)
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.

采纳的回答

Matt J
Matt J 2013-6-28
编辑:Matt J 2013-6-28
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 个评论
Faez Alkadi
Faez Alkadi 2017-10-26
编辑:Faez Alkadi 2017-10-26
Is there a way to create a fv that is the merging results of all 376 parts and patch them as one surface?

请先登录,再进行评论。

更多回答(1 个)

Ted Shultz
Ted Shultz 2020-6-3
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)

类别

Help CenterFile Exchange 中查找有关 Polygons 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by