/** * Set the vertices of the point cloud * @param vertices */ void Polygon::setVertices(const vector<Vertex>& vtcs) { if (vtcs.size() == 0) { throw string("Point cloud is empty"); } // set the vertices pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>); min[0] = min[1] = min[2] = FLT_MAX; max[0] = max[1] = max[2] = -FLT_MAX; for_each(vtcs.begin(), vtcs.end(), [&](const Vertex& vtx) { const double* pos = vtx.position3d(); for (int i = 0; i < 3; i++) { if (min[i] > pos[i]) { min[i] = pos[i]; } if (max[i] < pos[i]) { max[i] = pos[i]; } } pcl::PointXYZRGB pt; pt.x = pos[0]; pt.y = pos[1]; pt.z = pos[2]; const uchar* col = vtx.color3b(); pt.rgba = static_cast<uint32_t>(col[0]) << 16 | static_cast<uint32_t>(col[1]) << 8 | static_cast<uint32_t>(col[2]); cloud->push_back(pt); }); float sub[] = { max[0]-min[0], max[1]-min[1], max[2]-min[2] }; scl = (sub[0] > sub[1] ? sub[0] : (sub[1] > sub[2] ? sub[1] : sub[2])); // estimate normal vectors pcl::NormalEstimation<pcl::PointXYZRGB, pcl::Normal> ne; pcl::PointCloud<pcl::Normal>::Ptr normals(new pcl::PointCloud<pcl::Normal>); pcl::search::KdTree<pcl::PointXYZRGB>::Ptr cTree(new pcl::search::KdTree<pcl::PointXYZRGB>); cTree->setInputCloud(cloud); ne.setInputCloud(cloud); ne.setSearchMethod(cTree); ne.setKSearch(20); ne.compute(*normals); // concatenate the vertices and normal vectors cloudWithNormals.reset(new pcl::PointCloud<pcl::PointXYZRGBNormal>); pcl::concatenateFields(*cloud, *normals, *cloudWithNormals); // triangulate triangulate(); if (triangles->polygons.size() == 0) { throw string("Surface is empty"); } }
INT32 _qgmOptiNLJoin::_validate() { PD_TRACE_ENTRY( SDB__QGMOPTINLJOIN__VALIDATE ) ; SDB_ASSERT( 2 == _children.size(), "impossible" ) ; INT32 rc = SDB_OK ; _qgmOptiTreeNode *left = _children.at( 0 ) ; _qgmOptiTreeNode *right = _children.at( 1 ) ; if ( left->_alias == right->_alias ) { PD_LOG_MSG( PDERROR, "same alias:%s", left->_alias.toString().c_str() ) ; rc = SDB_INVALIDARG ; goto error ; } if ( NULL != _condition ) { qgmOpStream lstream, rstream ; vector<qgmDbAttr*> conditionFields ; vector<qgmDbAttr*>::iterator citr ; _qgmConditionNodeHelper cTree( _condition ) ; rc = cTree.getAllAttr( conditionFields ) ; if ( SDB_OK != rc ) { goto error ; } rc = left->outputStream( lstream ) ; if ( SDB_OK != rc ) { goto error ; } rc = right->outputStream( rstream ) ; if ( SDB_OK != rc ) { goto error ; } for ( citr = conditionFields.begin() ; citr != conditionFields.end() ; citr++ ) { if ( lstream.find( *(*citr) ) ) { continue ; } else if ( !rstream.find( *(*citr) ) ) { rc = SDB_INVALIDARG ; PD_LOG_MSG( PDERROR, "condition field[%s] not found in sub output.", (*citr)->toString().c_str() ) ; goto error ; } else { continue ; } } } done: PD_TRACE_EXITRC( SDB__QGMOPTINLJOIN__VALIDATE, rc ) ; return rc ; error: goto done ; }