예제 #1
0
int NormalEstimation::compute()
{
    //pointer to selected cloud
    ccPointCloud* cloud = getSelectedEntityAsCCPointCloud();
     if (!cloud)
         return -1;

     //if we have normals delete them!
     if (cloud->hasNormals())
         cloud->unallocateNorms();

        if (cloud->hasNormals())
            cloud->unallocateNorms();

    //get xyz in sensor_msgs format
    cc2smReader converter;
    converter.setInputCloud(cloud);
    sensor_msgs::PointCloud2 sm_cloud = converter.getXYZ();


    //get as pcl point cloud
    pcl::PointCloud<pcl::PointXYZ>::Ptr pcl_cloud  (new pcl::PointCloud<pcl::PointXYZ>);

    pcl::fromROSMsg(sm_cloud, *pcl_cloud);

    //create storage for normals
    pcl::PointCloud<pcl::PointNormal>::Ptr normals (new pcl::PointCloud<pcl::PointNormal>);

    //now compute
    int result = compute_normals<pcl::PointXYZ, pcl::PointNormal>(pcl_cloud, m_useKnn ? m_knn_radius: m_radius, m_useKnn, normals);

    sensor_msgs::PointCloud2::Ptr sm_normals (new sensor_msgs::PointCloud2);
    pcl::toROSMsg(*normals, *sm_normals);

	sm2ccConverter converter2(sm_normals);
    converter2.addNormals(cloud);
    converter2.addScalarField(cloud, "curvature", m_overwrite_curvature);

    emit entityHasChanged(cloud);

    return 1;
}
예제 #2
0
int FlipModel::compute()
{

    std::vector<ccHObject*> to_flip = vombat::theInstance()->getAllObjectsSelectedBySPCDti(&spc::StratigraphicModelSingleAttitude::Type);

    for (ccHObject* o : to_flip) {
        ccSPCElementShell* shell = dynamic_cast<ccSPCElementShell*>(o);

        spc::StratigraphicModelSingleAttitude::Ptr model = shell->getSPCElement<spc::StratigraphicModelSingleAttitude>();

        model->setNormal(-model->getNormal());

        ccSingleAttitudeModel* ccmodel = dynamic_cast<ccSingleAttitudeModel*>(o);

        ccmodel->updateInternals();
        entityHasChanged(ccmodel);
    }

    return 1;
}