本文介绍了如何在伪造查看器中使用 svf 文件计算面积和体积的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要计算 3D 文件的体积和表面面积.由于forge api 可以将各种3D 文件转换成svf 格式,所以如果我可以从svf 格式文件中计算面积和体积,那么我的程序就可以处理forge api 支持的所有格式的3D 文件.但是forge viewer没有计算面积和体积的api.因为forge viewer是基于THREE.js的,所以我想能不能用THREE.js的api来计算体积和面积.我阅读了forge viewer的api,但是没有api可以从forge view中获取THREE.js的几何.

I need to calculate volume and area of surfaces of 3D file. Since forge api can convert all kinds of 3D file to svf format, so If I can calculate area and volume from svf format file , then my program can handle all format 3D file that forge api support. But forge viewer doesn't have the api to calculate area and volume. Because forge viewer is based on THREE.js, so I guess if I can use THREE.js's api to calculate volume and area. I read the api of forge viewer, but there is no api to get geometry of THREE.js from forge view.

var 可视化 =Autodesk.Viewing.Document.getSubItemsWithProperties(doc.getRootItem(),{'type':'geometry'}, true);

我尝试了这个,它不是 THREE.js 的几何图形,而是伪造查看器的几何图形.不能用来计算.

I try this one, It's not geometry of THREE.js , but forge viewer's. It can't be used to calculate.

推荐答案

对于这个坏消息,我深表歉意,据我所知,Forge Viewer 中没有可用于计算面积或体积的 API,但您自己做了一些解决方法.

Apologizing for the bad news, there is no API available for calculating area or volume in the Forge Viewer as I know, but you make some workaround by yourself.

要将 Forge 片段转换为 THREE.Mesh,您可以查看此处,此处 和此处.面积计算可以参考Autodesk.Viewing.Extensions.Measure.Snapper.prototype.snapping3DAutodesk.Viewing.Extensions.Measure.MeasureTool.prototype中Forge Viewer的一些代码.getFaceArea.

For converting Forge fragment into THREE.Mesh, you can check here, here and here. For area calculation, you can refer some codes of the Forge Viewer in the Autodesk.Viewing.Extensions.Measure.Snapper.prototype.snapping3D and Autodesk.Viewing.Extensions.Measure.MeasureTool.prototype.getFaceArea.

希望对您有所帮助.

这篇关于如何在伪造查看器中使用 svf 文件计算面积和体积的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 17:59