找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 24|回复: 0

C++ 从 AcDbSolid 中检索可能位于块中的顶点

[复制链接]

0

主题

0

回帖

26

积分

管理员

积分
26
发表于 2024-10-6 17:21:50 | 显示全部楼层 |阅读模式
  1. void CRmWindow::solid_meshing(AcDbEntity* entity, const AcGeMatrix3d& trans)
  2. {
  3. #if 0
  4.         AcDbSolid* pSolid = AcDbSolid::cast(entity);
  5.         double thickness = pSolid->thickness();
  6.         AcGePoint3d vertices[4];
  7.         int numVertices = 4;
  8.         AcGeVector3d normal = pSolid->normal();
  9.         double elevation = pSolid->elevation();
  10.         for (int i = 0; i < 4; ++i)
  11.                 pSolid->getPointAt(i, vertices[i]);
  12.         if (vertices[2].isEqualTo(vertices[3]))
  13.                 numVertices = 3;
  14.         for (int i = 0; i < numVertices; ++i)
  15.                 vertices[i].z += elevation;
  16.        
  17.         std::vector<AcGePoint3d> allVertices;
  18.         for (int i = 0; i < numVertices; ++i) {
  19.                 vertices[i].transformBy(trans);
  20.                 allVertices.push_back(vertices[i]);
  21.         }
  22.         for (int i = 0; i < numVertices; ++i) {
  23.                 AcGePoint3d extrudedVertex = vertices[i] + normal * thickness;
  24.                 extrudedVertex.transformBy(trans);
  25.                 allVertices.push_back(extrudedVertex);
  26.         }
  27.         std::ofstream file(path_from_mfc + L'\\' + mesh_file_str, std::ios::app);
  28.         if (!file.is_open()) {
  29.                 acutPrintf(L"Failed to open file for writing.\n");
  30.                 return;
  31.         }
  32.         std::size_t numTotalVertices = allVertices.size();
  33.         file << global_obj_mesh_counter << '\n' << numTotalVertices << "    " << 1 << '\n'; // Number of vertices and one solid
  34.         for (const auto& vertex : allVertices) {
  35.                 file << formatDouble(vertex.x) << '\n'
  36.                         << formatDouble(vertex.y) << '\n'
  37.                         << formatDouble(vertex.z) << '\n';
  38.         }
  39.         file.close();
  40. #endif
  41. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|膜结构网

GMT+8, 2024-12-27 05:53 , Processed in 0.133660 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表