简体   繁体   English

根据区域所包含的3D区域将曲面指定给区域

[英]Assigning surfaces to zones based on the 3D regions they enclose

Given a set of surfaces in three-dimensional space, I am attempting to assign each surface to a zone referring to the smallest 3D region the set encloses, or no zone if this is not applicable. 给定三维空间中的一组曲面,我试图将每个曲面分配到一个区域,指向该组所包含的最小3D区域,如果不适用,则不分区。 I also want to determine if a surface is an interface between two zones. 我还想确定表面是否是两个区域之间的接口。 So, for example, if we had 11 surfaces representing two cubes stacked on top of each other, the surfaces in the top cube would be in the same zone and the surfaces in the bottom would be in a different zone (with the interface surface being in both zones). 因此,例如,如果我们有11个表示两个立方体堆叠在一起的表面,则顶部立方体中的表面将位于相同的区域中,而底部的表面将位于不同的区域中(界面表面为在两个区域)。

As an example, I want to take in a set of surfaces such as this and turn it in to this . 作为一个例子,我想在一组表面如 ,并把它在给 Each color here represents a zone, with gray being no zone associated (as in the flap at the bottom). 这里的每种颜色代表一个区域,灰色没有区域关联(如在底部的翻盖中)。

I have done some searching around trying to find if someone has already come up with an algorithm to do this, but I have not found anything (most seem to identify regions rather than link surfaces to the region they enclose). 我已经做了一些搜索,试图找出是否有人已经提出了一个算法来做到这一点,但我没有找到任何东西(大多数似乎识别区域而不是链接表面到他们所包围的区域)。 As such I am trying to come up with my own algorithm and am wondering if there are any other alternatives or if my method would work. 因此,我试图提出我自己的算法,并想知道是否有任何其他选择或我的方法是否有效。

I am assuming all surfaces are connected. 我假设所有表面都已连接。

My idea is the following: 我的想法如下:

  1. Select a random surface whose sides each touch exactly one other surface, and add this to zone 1. 选择一个随机曲面,其边的每一个都与另一个曲面完全相同,然后将其添加到区域1。
  2. Add each connected surface to zone 1 provided each of its sides touch exactly one other surface. 将每个连接的表面添加到区域1,前提是其每个侧面都与另一个表面完全接触。
  3. For those connected surfaces that touch more than one surface on at least one of its sides, add it to the "maybe" list. 对于那些在其至少一侧接触多个表面的连接表面,将其添加到“可能”列表中。
  4. For each new surface in zone 1, repeat steps 2-3. 对于区域1中的每个新曲面,重复步骤2-3。
  5. Once a surface has been added to the "maybe" list twice, add it to zone 1 and remove from the "maybe" list. 将表面添加到“可能”列表两次后,将其添加到区域1并从“可能”列表中删除。 Mark this surface as a zone interface. 将此曲面标记为区域界面。
  6. Add the zone interface to zone 2. 将区域接口添加到区域2。
  7. Select one random surface from the "maybe" list and assign it to zone 2 and clear the "maybe" list. 从“可能”列表中选择一个随机曲面并将其指定给区域2并清除“可能”列表。
  8. Repeat steps 2-7 (updating the zone number of course) until there are no surfaces that are unassigned. 重复步骤2-7(更新当前的区域编号),直到没有未分配的曲面。

This seems to work for simple scenarios (eg, two cubes stacked on top of one another), but I am not sure if there are any tricky conditions I need to watch out for, or if it falls apart once there are more than two zones that share a side. 这似乎适用于简单的场景(例如,两个立方体堆叠在一起),但我不确定是否有任何棘手的条件我需要注意,或者如果有两个以上的区域它会崩溃分享一方。

Any improvement on my rough algorithm/alternate ideas for implementation would be appreciated. 对我的粗略算法/实施的替代想法的任何改进将不胜感激。 Thanks! 谢谢!

EDIT: Here are some more details in response to some comments. 编辑:以下是一些回复一些评论的细节。 A zone by my definition is simply a group of surfaces that completely bound a 3D region with no gaps. 根据我的定义,区域只是一组完全绑定3D区域而没有间隙的表面。 So if I had two cubes, A and B, that do not touch, I would have two zones: one consisting of all the surfaces of cube A and the other of all the surfaces for cube B. If I had a cube that was missing one side, there would be no zone associated with those surfaces. 因此,如果我有两个不接触的立方体A和B,我将有两个区域:一个由立方体A的所有表面组成,另一个由立方体B的所有表面组成。如果我有一个缺少的立方体一方面,没有与这些表面相关的区域。

My end goal is to make an automated process for grouping surfaces in a modeling tool I am creating. 我的最终目标是在我正在创建的建模工具中创建一个自动化流程来对表面进行分组。 The specifics are classified, but essentially I am dealing with models where certain properties are common only between surfaces in the same "zone" as described above. 细节被分类,但基本上我正在处理模型,其中某些属性仅在如上所述的相同“区域”中的表面之间是共同的。 I want to make an automated process that creates these zones so that the user can apply these properties to all surfaces in the zone at once instead of doing it manually. 我想创建一个自动化过程来创建这些区域,以便用户可以立即将这些属性应用于区域中的所有表面,而不是手动执行。

Essentially the problem boils down to finding the smallest 3D regions that are completely enclosed by an arbitrary set of surfaces, and keeping track of which surfaces belong to which regions. 基本上问题归结为找到完全由任意一组表面包围的最小3D区域,并跟踪哪些表面属于哪些区域。 I hope this makes my question more clear. 我希望这使我的问题更清楚。

What you are interested in, then, would be discovering closed surface (volume) mesh topology from a set of input polygons; 那么,您感兴趣的是从一组输入多边形中发现闭合曲面(体积)网格拓扑; in other words - polytopes. 换句话说 - 多面体。 This is common to pretty much every 3d modeling package. 这几乎适用于每个3D建模包。 I would guess that Blender has code that does that. 我猜Blender有代码可以做到这一点。 There are different ways of doing this, commonly however, some version of half-edge graph is used. 有不同的方法,但通常使用某种版本的半边图。 See wiki link here: Doubly Linked half edge graph . 请参阅此处的wiki链接: 双重链接半边图 The idea is to walk your input polies, and build these graphs. 想法是走你的输入政策,并建立这些图。 Once done, you can easily query each graph to see if there are holes (edges missing, etc). 完成后,您可以轻松查询每个图形以查看是否存在孔(边缘缺失等)。

在此输入图像描述

I attached a picture explaining how to use a half-edge structure to get what you want: Say you are given a soup of five rectangles (they make up a cube with out a top. U process your first rectangle say ABCD, this creates your first graph, say G1. Now you process second polygon, say FEHG, none of these vertices you have seen yet, so you create second graph, G2. Now say you process polygon CDGH. You have seen these vertices before, so instead of creating a new graph, you merge(connect) existing graphs that share these nodes. Proceed until you process all polygons. You get graph in picture. 我附上了一张图片,解释了如何使用半边结构来获得你想要的东西:假设给你一个五个长方形的汤(他们组成一个顶部的立方体。你处理你的第一个矩形说ABCD,这会创建你的第一个图形,比如说G1。现在你处理第二个多边形,比如FEHG,你还没有看过这些顶点,所以你创建第二个图形,G2。现在说你处理多边形CDGH。你之前看过这些顶点,所以不是创建一个新图,你合并(连接)共享这些节点的现有图。继续处理所有多边形。你得到图中的图形。

Now, to query the graph to get your information. 现在,查询图表以获取您的信息。 Once you walk the graph, you will see that there are exactly four vertices (nodes) that are missing edges. 走完图形后,您将看到正好有四个缺少边的顶点(节点)。 Those verts correspond to the missing top of the box (the edges are red in the illustration). 这些顶点对应于框的缺失顶部(图中边缘为红色)。 Hence you know that this graph is not a closed manifold. 因此,您知道此图不是封闭的流形。 If you had another box, that did not share nodes with this one, you would have another graph. 如果你有另一个盒子,它没有与这个盒子共享节点,你会有另一个图表。 So each graph, once you done processing your polygons, is a "zone" for you. 因此,处理完多边形后,每个图形都是一个“区域”。

Note, if you have two say intersecting shapes, you can track those too using these graphs, but its much more complicated. 请注意,如果您有两个相交的形状,您也可以使用这些图形来跟踪它们,但它更复杂。 Basically when processing a new polygon, you would not only have to see if any of its verts belong to already processed graphs, but also see if this polygon intersects any of the previously processed polygons, if so, split this polygon and add all this to the intersected graph. 基本上,当处理新的多边形时,您不仅需要查看其任何顶点是否属于已处理的图形,还要查看此多边形是否与先前处理的任何多边形相交,如果是,则拆分此多边形并将所有这些添加到相交图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM