Forge 查看器仅显示部分元素/节点
Forge viewer display only part of element / node
我们实现了一个复杂的过滤方法来过滤模型的元素。一切基于国际金融公司。以下是具有 2 个子元素的 IfcFooting 元素的示例:
ID IfcType Description
--------------------------------------------------------
1 IfcFooting Base
2 > IfcBuildingElementPart Insulation
3 > IfcBuildingElementPart Reinforced Concrete
过滤方法可以找到具有特殊子元素的 IfcFooting 元素 "Reinforced Concrete"。 Return 值为 ID 1 和 3。在查看器中,我们使用以下方法仅显示过滤结果:
viewer3d.impl.visibilityManager.hide(rootId, model);
$.each(selection, function (k, v) {
viewer3d.impl.visibilityManager.show(v, model);
});
问题是用 ID 1 调用此方法,查看器将显示 1、2 和 3。是否可以禁用此行为?我们只需要显示子元素3,但是过滤结果中不能忽略ID 1...thx!
这是预期的行为,如果 id 不是叶组件而是拥有 children 的逻辑组件,那么 showing/hiding 这个组件会影响其所有 children 是正常的.
你应该做的是确保你收集的所有id都是叶子组件(检查instanceTree.enumNodeChildren(dbId)没有children)。并仅在叶子上执行逻辑。
在你的情况下,你会过滤掉 dbId 1,因为它有 children 并且只显示 dbId 3。
这是一个例子:
function isLeafComponent (dbId) {
var instanceTree = viewer.model.getData().instanceTree
var childCount = 0
instanceTree.enumNodeChildren(dbId, function(childId) {
++childCount
})
return (childCount < 2) // Handles IFC with "Body" child
}
我们实现了一个复杂的过滤方法来过滤模型的元素。一切基于国际金融公司。以下是具有 2 个子元素的 IfcFooting 元素的示例:
ID IfcType Description
--------------------------------------------------------
1 IfcFooting Base
2 > IfcBuildingElementPart Insulation
3 > IfcBuildingElementPart Reinforced Concrete
过滤方法可以找到具有特殊子元素的 IfcFooting 元素 "Reinforced Concrete"。 Return 值为 ID 1 和 3。在查看器中,我们使用以下方法仅显示过滤结果:
viewer3d.impl.visibilityManager.hide(rootId, model);
$.each(selection, function (k, v) {
viewer3d.impl.visibilityManager.show(v, model);
});
问题是用 ID 1 调用此方法,查看器将显示 1、2 和 3。是否可以禁用此行为?我们只需要显示子元素3,但是过滤结果中不能忽略ID 1...thx!
这是预期的行为,如果 id 不是叶组件而是拥有 children 的逻辑组件,那么 showing/hiding 这个组件会影响其所有 children 是正常的.
你应该做的是确保你收集的所有id都是叶子组件(检查instanceTree.enumNodeChildren(dbId)没有children)。并仅在叶子上执行逻辑。
在你的情况下,你会过滤掉 dbId 1,因为它有 children 并且只显示 dbId 3。
这是一个例子:
function isLeafComponent (dbId) {
var instanceTree = viewer.model.getData().instanceTree
var childCount = 0
instanceTree.enumNodeChildren(dbId, function(childId) {
++childCount
})
return (childCount < 2) // Handles IFC with "Body" child
}