CAD爆炸图算法 [英] Exploded view algorithm for CAD

查看:37
本文介绍了CAD爆炸图算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个程序来查看 3D CAD 模型,并希望构建自动分解视图.将要查看的所有组件都是轴对称的.有些可能不是,但大多数是.我想找出一种算法,用于将装配中的零件自动移动到分解图位置.这是我想通过算法实现的示例(当然要减去标签):

我必须使用的唯一值是每个部分的边界框的中心.如果需要更多信息,我可以计算更多信息,但似乎应该足够了.我想到的粗略方法是计算从组件原点到每个零件中心沿轴对称轴的矢量,然后计算到零件中心相对于中心轴的径向矢量.从那里,我需要找出一些能够沿着这两个向量的某种组合缩放每个部分的位置的计算.这就是我不太确定要往哪个方向发展的部分.我所包含的图像显示了我想要的确切功能,但我希望能够通过任何浮点值缩放位置以扩展或收缩分解视图,1.0 是原始组装模型.有什么想法吗?

解决方案

你的问题很广泛,因此我的解释变得冗长.我将提出两种用于轴向和径向处理的爆炸算法变体.

为了用一个例子来说明它们,我将使用以下数字(仅沿轴的边界框,只有五个部分):

P1: [ 0,10] (电池)P2:[10,14](电机)P3:[14,16](齿轮)P4:[16,24](位持有人)P5:[18,26](齿轮箱)

虽然 P1P4 部分完全相互接触,但 P4P5 实际上重叠.

第一个是一种算法,它基本上按比例缩放距离,例如您提出的.如果组件中的零件尺寸大不相同,重叠零件也会受到影响(例如,在您的示例中,沿轴的圆形齿轮的延伸比钻头支架小得多).

设缩放因子为f,则每个边界框的中心被f缩放,但extension不是.部分然后将是

P1: 5 + [-5,5] =>P1':5*f + [-5,5]P2:12 + [-2,2] =>P2':12*f + [-2,2]P3:15 + [-1,1] =>P3':15*f + [-1,1]P4:20 + [-4,4] =>P4':20*f + [-4,4]P5:22 + [-4,4] =>P5':22*f + [-4,4]

P1'P4 部分之间的距离由

给出

P2' - P1' : (12*f-2) - (5*f+5) = 7*(f-1)P3' - P2' : (15*f-1) - (12*f+2) = 3*(f-1)P4' - P3' : (20*f-4) - (15*f+1) = 5*(f-5)

正如预期的那样,f=0 的差异为零,但对于任何分解视图,距离在很大程度上取决于单独零件的尺寸.如果尺寸变化更大,我认为这看起来不会太好.

另外用于重叠部分

P5' - P4' : (22*f-4) - (20*f+4) = 2*f-8

对于合理的 f,它们仍然重叠.

另一种可能性是不定义轴的比例因子,而是定义一个恒定的部分距离d.然后边界框将如下对齐:

P1': [ 0,10]P2': [10,14]+dP3':[14,16]+2*dP4': [16,24]+3*dP5':[18,26]+4*d+6

请注意,在最后一行我们添加了 24-8=6,即重叠以区分两个部分.

虽然此算法以(在我看来)更好的方式处理上述情况,但我们必须特别注意覆盖多个其他部分且不应包含在分组中的部分(例如,在您的情况下为 handle top).

一种可能性是在第一步中将零件分组,然后将算法应用于这些组的边界框.之后,它可以再次应用于每个组中的部分,省略涵盖多个子组的部分.在您的情况下是(注意嵌套分组是可能的):

<预><代码>[([电池,(开关,电路开关),电机],手柄顶部),电机齿轮,三齿,红齿轮,圆齿轮,位持有者,(齿轮箱、弹簧、锁钮)]

你可能看到我介绍了两种不同的组:方括号中的部分/组由算法处理,即在这样的组内的每个部分/子组之间添加一个间距,而圆括号内的组是没有爆炸.

到目前为止,我们还没有处理径向爆炸,因为它很好地与轴处理分离.但同样,这两种方法也可用于径向爆炸.但在我看来,第二种算法会产生更令人愉快的结果.例如.放射治疗组可按如下方式进行:

<代码> [(电池,开关,<许多零件>,齿轮箱),(开关,弹簧),(手柄顶部,锁定旋钮)]

在这种情况下,我们将向第二组中的所有径向中心添加一个附加分量 r,并为第三组中的所有径向中心添加一个附加分量 r.

请注意,简单的缩放算法在没有特殊用户指导的情况下运行(一旦给出缩放因子),而第二个算法使用附加信息(分组).

我希望这个相当长的解释能给你一些如何进一步进行的想法.如果我的解释在某些时候不清楚,或者您还有其他问题,请随时发表评论.

I'm making a program to view 3D CAD models and would like to build in automated exploded views. All the assemblies that will be viewed are axi-symmetric. Some may not be, but the majority are. I'd like to figure out an algorithm for automatically moving parts in an assembly into an exploded view position. Here is an example of what I want to achieve through an algorithm (minus the labels of course):

The only value I have to work with is the center of the bounding box of each part. If more information than that is needed, I can calculate more information, but it seems like it should be sufficient. The rough approach I have in mind is to calculate a vector from the origin of the assembly to the center of each part along the axi-symmetric axis, then calculate a radial vector to the center of the part with respect to the center axis. From there, I'd need to figure out some calculation that would be able to scale the position of each part along some combination of those two vectors. That's the part where I'm not quite sure what direction to go with this. The image I've included shows the exact functionality I'd like, but I want to be able to scale the position by any float value to expand or contract the exploded view, with 1.0 being the original assembled model. Any ideas?

解决方案

Your question is quite broad and thus my explanation became somehow lengthy. I'll propose two variants of an explosion algorithm for both axial and radial treatment.

To illustrate them with an example I'll use the following numbers (bounding boxes along the axis only, only five parts):

P1: [ 0,10] (battery)
P2: [10,14] (motor)
P3: [14,16] (cog)
P4: [16,24] (bit holder)
P5: [18,26] (gear casing)

While parts P1 to P4 exactly touch each other, P4 and P5 actually overlap.

The first one is an algorithm which basically scales the distances by a factor, such as you proposed. It will suffer if size of pieces is much different in an assembly but also for overlapping parts (e.g. in your example along the axis the extension of circle cog is much smaller than bit holder).

Let the scaling factor be f, then the center of each bounding box is scaled by f, but extension is not. Parts then would be

P1:  5 + [-5,5]   => P1':  5*f + [-5,5]
P2: 12 + [-2,2]   => P2': 12*f + [-2,2]
P3: 15 + [-1,1]   => P3': 15*f + [-1,1]
P4: 20 + [-4,4]   => P4': 20*f + [-4,4]
P5: 22 + [-4,4]   => P5': 22*f + [-4,4]

The distance between the parts P1' to P4 is then given by

P2' - P1' : (12*f-2) - (5*f+5) = 7*(f-1)
P3' - P2' : (15*f-1) - (12*f+2) = 3*(f-1)
P4' - P3' : (20*f-4) - (15*f+1) = 5*(f-5)

As expected the difference is zero for f=0 but for any exploded view the distance strongly depends on the sizes of the separate parts. I don't think that this will look too good if variation of sizes is bigger.

Additionally for overlapping parts

P5' - P4' : (22*f-4) - (20*f+4) = 2*f-8

they still overlap for reasonable f.

Another possibility would be to define not a scaling factor for the axis but a constant part-distance d. Then bounding boxes would be aligned like the following:

P1': [ 0,10]
P2': [10,14]+d
P3': [14,16]+2*d
P4': [16,24]+3*d
P5': [18,26]+4*d+6

Note that in the last line we added 24-8=6, i.e. the overlap in order to differentiate the two parts.

While this algorithm handles the above mentioned cases in a (in my opinion) better way we have to add special care to parts which cover multiple other parts and should not be included in the grouping (e.g. handle top in your case).

One possibility would be to group the parts into groups in a first step and then apply the algorithm to the bounding box of these groups. Afterwards it can be applied to parts in each group again, omitting the parts which cover more than one subgroup. In your case it would be (note nested grouping is possible):

[
    ([battery,(switch,circuit switch),motor],handle top),
    motor cog, 
    tri-cog,
    red-cog,
    circle-cog,
    bit-holder,
    (gear casing,spring,lock knob)
]

You might see that I have introduced two different kind of groups: parts/groups in square braces are handled by the algorithm, i.e. a spacing is added between each part/subgroup inside such a group, while the groups inside round braces are not exploded.

Up to now we did not handled the radial explosion because it nicely decouples from the axis treatment. But again the same both approaches can be used for radial explosion also. But again in my opinion the second algorithm yields more pleasant results. E.g. the groups can be done as follows for radial treatment:

 [
     (battery,switch,<many parts>,gear casing),
     (switch,spring),
     (handle top, lock knob)
 ]

In this case we would add an additional component r to all radial centers in the second group and 2*r to all in the third group.

Note that the simple scaling algorithm runs without special user guidance (once the scaling factor is given) while the second one uses additional information (the grouping).

I hope this rather long explanation gives you some ideas how to proceed further. If my explanations are unclear at some point or if you have further questions please feel free to comment.

这篇关于CAD爆炸图算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆