admin 发表于 2024-10-6 17:21:50

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

void CRmWindow::solid_meshing(AcDbEntity* entity, const AcGeMatrix3d& trans)
{
#if 0
        AcDbSolid* pSolid = AcDbSolid::cast(entity);

        double thickness = pSolid->thickness();

        AcGePoint3d vertices;
        int numVertices = 4;
        AcGeVector3d normal = pSolid->normal();
        double elevation = pSolid->elevation();

        for (int i = 0; i < 4; ++i)
                pSolid->getPointAt(i, vertices);

        if (vertices.isEqualTo(vertices))
                numVertices = 3;

        for (int i = 0; i < numVertices; ++i)
                vertices.z += elevation;
       
        std::vector<AcGePoint3d> allVertices;

        for (int i = 0; i < numVertices; ++i) {
                vertices.transformBy(trans);
                allVertices.push_back(vertices);
        }

        for (int i = 0; i < numVertices; ++i) {
                AcGePoint3d extrudedVertex = vertices + normal * thickness;
                extrudedVertex.transformBy(trans);
                allVertices.push_back(extrudedVertex);
        }

        std::ofstream file(path_from_mfc + L'\\' + mesh_file_str, std::ios::app);
        if (!file.is_open()) {
                acutPrintf(L"Failed to open file for writing.\n");
                return;
        }

        std::size_t numTotalVertices = allVertices.size();
        file << global_obj_mesh_counter << '\n' << numTotalVertices << "    " << 1 << '\n'; // Number of vertices and one solid

        for (const auto& vertex : allVertices) {
                file << formatDouble(vertex.x) << '\n'
                        << formatDouble(vertex.y) << '\n'
                        << formatDouble(vertex.z) << '\n';
        }
        file.close();
#endif
}
页: [1]
查看完整版本: C++ 从 AcDbSolid 中检索可能位于块中的顶点