【问题标题】:I'm not able to triangulate a regular point cloud我无法对常规点云进行三角测量
【发布时间】:2017-03-02 04:56:16
【问题描述】:

我轻松地细分了两个参数化 3D 表面(都是凸面)。

这是两个镶嵌的参数曲面:

现在,我的意图是将两者合并成一个实体。但我得到了这个:

enter image description here

我正在使用 Qhull 创建 Delaunay 三角剖分,它似乎适用于第一个凸面,但不适用于背面。 :(

这是我当前的代码(部分取自 ZivS)

#include "Qhull.h"

using namespace orgQhull;

void myQhull::Qhull::runQhull3D(const pcl::PCLPointCloud2& pointCloud, const char* args)
{
    std::cout << "runQhull vertices" << std::endl;
    numVertices = 0;
    std::stringstream verticesSS;
    m_externalPoints = new PointCoordinates(3,"");  //3 = dimension
    pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
    pcl::fromPCLPointCloud2(pointCloud, *cloud);
    std::vector<double> allPoints;

    for (unsigned int i = 0; i < cloud->size(); i++) {
        allPoints.push_back(cloud->at(i).x);
        allPoints.push_back(cloud->at(i).y);
        allPoints.push_back(cloud->at(i).z);
        verticesSS << cloud->at(i).x << " " << cloud->at(i).y << " " << cloud->at(i).z << "\n";
        numVertices++;
    }
    vertices += verticesSS.str();


    m_externalPoints->append(allPoints); //convert to vector<double>
    runQhull(*m_externalPoints, args);
}


void myQhull::Qhull::runQhull(const PointCoordinates &points, const char *qhullCommand2)
{
    std::string triangles;
    std::stringstream ss;
    numSimplices = 0;
    int numFaces = 0;

    std::cout << numVertices << std::endl;
    std::cout << "runQhull facets" << std::endl;

    orgQhull::Qhull qHull(points.comment().c_str(), points.dimension(), points.count(), &*points.coordinates(), qhullCommand2);
    QhullFacetList facets = qHull.facetList();
    for (QhullFacetList::iterator it = facets.begin(); it != facets.end(); ++it)
    {
        if (!(*it).isGood()) continue;
        QhullFacet f = *it;
        QhullVertexSet vSet = f.vertices();
        auto coord = f.hyperplane().coordinates();

        numFaces = vSet.size();

        ss << numFaces;
        for (QhullVertexSet::iterator vIt = vSet.begin(); vIt != vSet.end(); ++vIt)
        {
            QhullVertex v = *vIt;
            QhullPoint p = v.point();
            double * coords = p.coordinates();
            ss <<  " " << p.id() << " ";
        }
        ss << "\n";
        numSimplices++;


    }

    simplices +=  ss.str();
    std::cout << numSimplices << std::endl;

}

void myQhull::Qhull::saveOff(std::string file)
{
    std::cout << "Saving qhull.off" << std::endl;
    std::ofstream offFile;
    offFile.open(file);

    offFile << "OFF\n";
    offFile << numVertices << " " << numSimplices << " 0";
    offFile << vertices;
    offFile << simplices;
    offFile.close();

}


void myQhull::Qhull::run(const pcl::PCLPointCloud2& pointCloud)
{
    Qhull qhull;
    qhull.runQhull3D(pointCloud, "Qt");
    qhull.saveOff("qhull.off");

}

另外,我使用了来自 OpenCV 的 greedy_projection,但没有任何成功。它只能执行两个曲面细分而不连接它们。

知道为什么会这样吗?

【问题讨论】:

    标签: python c++ opencv qhull


    【解决方案1】:

    我终于找到了解决方案。 将“d”添加到qhull.runQhull3D(pointCloud, "d Qt") 会为上表面和下表面生成正确的 Delaunay 三角剖分。 因此,由于它们是常规网格,因此我手动创建连接两个曲面的顶点的边。 谢谢。

    【讨论】:

      猜你喜欢
      • 2019-11-03
      • 1970-01-01
      • 1970-01-01
      • 2015-03-08
      • 1970-01-01
      • 2013-03-19
      • 2012-01-26
      • 2022-12-14
      • 2019-11-14
      相关资源
      最近更新 更多