Autodesk Forge Viewer:F2D从Dbid获取碎片 [英] Autodesk Forge Viewer : f2d get frag from dbid

查看:125
本文介绍了Autodesk Forge Viewer:F2D从Dbid获取碎片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Revit转换文件的2d查看器中用彩色填充房间。

I am trying to fill in room with color on a revit converted file's 2d viewer.

我有一个定义了房间的Revit文件。 Revit文件还具有定义为第一层,第二层的工作表。当我使用Forge API对其进行转换时

I have a Revit file that has "rooms" defined. The Revit file also has sheets defined "Floor one", "Floor two". When I convert it using the Forge API

我为Revit 3D视图得到一个svf,为第一层和第二层
工作表获得f2d文件。

I get a svf for the Revit 3D view and f2d files for "Floor one" and "Floor Two" sheets.

对于svf,我能够从dbids中获取虚弱的

For the svf I was able to get fragid from dbids other post

现在我正在尝试对f2d文件执行相同的操作。

Now Im trying to do the same for the f2d files.

如果我知道使用

viewer.setThemingColor(dbid, new THREE.Vector4(0, 1, 1,1));

我现在想要做的是能够在2d上获得形状的脆弱性,这样我可以获取其使用的线的起点和终点。我想知道这些顶点,所以我可以构建一个自定义网格并用颜色填充它以填充阴影空间。

What I want to do now is be able to get the fragid of the shape on 2d so that I can get the start and stop vertices of the lines it uses. I want to know these vertices so I can build a custom mesh and fill it in with color for room "hatching".

我的问题是我不知道f2d格式。似乎这是一个网格,并让着色器控制线条的颜色。谁能给我任何指向房间碎片列表的指针?

My problem is that I do not know the f2d format. It seems it is all one mesh and lets the shader control the color of the lines. Can anyone give me any pointers on how to the the fragment list of the room?

这就是我用于3d svf的内容

This is what I used for the 3d svf

function getFragIdFromDbId(viewer, dbid) {
 var returnValue;
 var it = viewer.model.getData().instanceTree;
 it.enumNodeFragments(dbid, function (fragId) {
   //console.log("dbId: " + dbid + " FragId : " + fragId);
   returnValue = fragId;
 }, false);
  return returnValue;
}

在f2d具有查看器的情况下,f2d可以执行哪些操作。 model.getData()。instanceTree = undefined?

What can I use for f2d to do the same when the f2d has viewer.model.getData().instanceTree = undefined?

推荐答案

片段可以具有多个dbid的几何形状,而dbid的几何形状可以是在多个片段中。可以使用 Autodesk.Viewing.Private.VertexBufferReader 进行提取,该功能可帮助2D捕捉程序使用。您可以执行以下操作:

Fragments can have geometry for multiple dbids and the geometry for a dbid can be in multiple fragments. It is possible to extract with Autodesk.Viewing.Private.VertexBufferReader, used by the 2D snapper that helps. You could do something like this:


  1. FragmentList.dbid2fragId [dbid]将返回片段ID或包含几何图形的片段ID数组

  2. 遍历片段并获取每个片段的几何形状。

  3. 使用几何形状创建一个VertexBufferReader。

  4. 使用VertexBufferReader查找dbid的几何。

  1. FragmentList.dbid2fragId[dbid] will return the fragment id or an array of fragment ids that contain geometry for the dbid.
  2. Loop through the fragments and get the geometry for each fragment.
  3. Create a VertexBufferReader using the geometry.
  4. Use the VertexBufferReader to find the geometry for a dbid.

查找几何的最佳方法是使用VertexBufferReader .enumGeomsForObject(dbid,回调)。它使用回调对象来枚举dbid的几何。回调对象需要以下可选功能:

The best way to find the geometry is to use VertexBufferReader.enumGeomsForObject(dbid, callback). It uses a callback object to enumerate geometry for a dbid. The callback object needs these optional functions:


  • onLineSegment(x0,y0,x1,y1,viewport_id)

  • onCircularArc(centerX,centerY,startAngle,endAngle,半径,viewport_id)

  • onEllipticalArccenterX,centerY,startAngle,endAngle,主要,次要,倾斜,viewport_id)

  • onTriangleVertex(x,y,viewport_id)

  • onLineSegment(x0, y0, x1, y1, viewport_id)
  • onCircularArc(centerX, centerY, startAngle, endAngle, radius, viewport_id)
  • onEllipticalArccenterX, centerY, startAngle, endAngle, major, minor, tilt, viewport_id)
  • onTriangleVertex(x, y, viewport_id)

如果您只需要基元而不是它们在哪里,这是可以的在缓冲区中。

This is OK if you just need the primitives and not where they are in the buffer.

您还可以使用 VertexBufferReader 遍历缓冲区中的几何图形以查找dbid。这需要您知道,如果 .useInstancing()为false,则顶点缓冲区中的图元为4个顶点,如果 .useInstancing()为true,则为1个顶点。而且您需要从 .getVertexFlagsAt(vertexIndex)解码基本类型,但是我们没有任何用于解码标志的公共值或方法。

You can also use the VertexBufferReader to loop through the geometry in the buffer looking for the dbid. This requires you to know the a primitive in the vertex buffer is 4 vertices if .useInstancing() is false and 1 vertex if .useInstancing() is true. And you need to decode the primitive type from .getVertexFlagsAt(vertexIndex) but we don’t any public values or methods for decoding the flags.

这篇关于Autodesk Forge Viewer:F2D从Dbid获取碎片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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