void qHPR::onNewSelection(const ccHObject::Container& selectedEntities) { if (m_action) { //a single point cloud must be selected m_action->setEnabled(selectedEntities.size() == 1 && selectedEntities.front()->isA(CC_TYPES::POINT_CLOUD)); } }
void BaseFilter::getAllEntitiesThatHaveMetaData(QString key, ccHObject::Container &entities) { entities.clear(); //better be sure ccHObject::Container tempContainer; getAllEntitiesOfType(CC_TYPES::HIERARCHY_OBJECT, tempContainer); for (ccHObject::Container::const_iterator it = tempContainer.begin(); it != tempContainer.end(); ++it ) { if ((*it)->hasMetaData(key)) entities.push_back(*it); } }
int ccDBRoot::getSelectedEntities(ccHObject::Container& selEntities, CC_CLASS_ENUM filter/*=CC_OBJECT*/, dbTreeSelectionInfo* info/*=NULL*/) { QItemSelectionModel* qism = m_dbTreeWidget->selectionModel(); QModelIndexList selectedIndexes = qism->selectedIndexes(); int i,selCount = selectedIndexes.size(); for (i=0;i<selCount; ++i) { ccHObject* anObject = static_cast<ccHObject*>(selectedIndexes[i].internalPointer()); if (anObject && anObject->isKindOf(filter)) selEntities.push_back(anObject); } if (info) { info->reset(); info->selCount=selCount; for (i=0;i<selCount;++i) { ccHObject* obj = selEntities[i]; info->sfCount += int(obj->hasScalarFields()); info->colorCount += int(obj->hasColors()); info->normalsCount += int(obj->hasNormals()); if (obj->isKindOf(CC_POINT_CLOUD)) { ccGenericPointCloud* cloud = ccHObjectCaster::ToGenericPointCloud(obj); info->cloudCount++; info->octreeCount += int(cloud->getOctree()!=NULL); } if (obj->isKindOf(CC_MESH)) info->meshCount++; if (obj->isKindOf(CC_SENSOR)) { info->sensorCount++; if (obj->isKindOf(CC_GBL_SENSOR)) info->gblSensorCount++; } if (obj->isKindOf(CC_POINT_KDTREE)) info->kdTreeCount++; } } return int(selEntities.size()); }
void qFacets::onNewSelection(const ccHObject::Container& selectedEntities) { if (m_doFuseKdTreeCells) m_doFuseKdTreeCells->setEnabled(selectedEntities.size()==1 && selectedEntities.back()->isA(CC_TYPES::POINT_CLOUD)); if (m_fastMarchingExtraction) m_fastMarchingExtraction->setEnabled(selectedEntities.size()==1 && selectedEntities.back()->isA(CC_TYPES::POINT_CLOUD)); if (m_doExportFacets) m_doExportFacets->setEnabled(selectedEntities.size() != 0); if (m_doExportFacetsInfo) m_doExportFacetsInfo->setEnabled(selectedEntities.size() != 0); if (m_doClassifyFacetsByAngle) m_doClassifyFacetsByAngle->setEnabled(selectedEntities.size()==1 && selectedEntities.back()->isA(CC_TYPES::HIERARCHY_OBJECT)); if (m_doShowStereogram) m_doShowStereogram->setEnabled(selectedEntities.size()==1 && (selectedEntities.back()->isA(CC_TYPES::HIERARCHY_OBJECT) || selectedEntities.back()->isA(CC_TYPES::POINT_CLOUD))); }
void qSRA::onNewSelection(const ccHObject::Container& selectedEntities) { if (m_doLoadProfile) { //always active } bool cloudAndPolylineSelected = ( selectedEntities.size() == 2 && ( (selectedEntities[0]->isA(CC_TYPES::POLY_LINE) && selectedEntities[1]->isA(CC_TYPES::POINT_CLOUD)) || (selectedEntities[1]->isA(CC_TYPES::POLY_LINE) && selectedEntities[0]->isA(CC_TYPES::POINT_CLOUD))) ); if (m_doCompareCloudToProfile) { m_doCompareCloudToProfile->setEnabled(cloudAndPolylineSelected); } if (m_doProjectCloudDists) { m_doProjectCloudDists->setEnabled( /*(selectedEntities.size() == 1 && selectedEntities[0]->isA(CC_TYPES::POINT_CLOUD)) || (selectedEntities.size() == 2 && ( (selectedEntities[0]->isA(CC_TYPES::POLY_LINE) && selectedEntities[1]->isA(CC_TYPES::POINT_CLOUD)) || (selectedEntities[1]->isA(CC_TYPES::POLY_LINE) && selectedEntities[0]->isA(CC_TYPES::POINT_CLOUD))))*/ cloudAndPolylineSelected ); } //backup selected entities m_selectedEntities = selectedEntities; }
void qSRA::onNewSelection(const ccHObject::Container& selectedEntities) { if (m_doLoadProfile) { //always active } bool validSelection = false; if (selectedEntities.size() == 2) { //we expect a cloud... int cloudIndex = selectedEntities[0]->isA(CC_TYPES::POINT_CLOUD) ? 0 : selectedEntities[1]->isA(CC_TYPES::POINT_CLOUD) ? 1 : -1; if (cloudIndex != -1) { //... and either a polyline or a cone/cylinder validSelection = (selectedEntities[1-cloudIndex]->isA(CC_TYPES::POLY_LINE) || selectedEntities[1-cloudIndex]->isKindOf(CC_TYPES::CONE)); } } if (m_doCompareCloudToProfile) { m_doCompareCloudToProfile->setEnabled(validSelection); } if (m_doProjectCloudDists) { m_doProjectCloudDists->setEnabled(validSelection); } }
void qCork::onNewSelection(const ccHObject::Container& selectedEntities) { if (m_action) { //we need two and only two meshes! m_action->setEnabled( selectedEntities.size() == 2 && selectedEntities[0]->isKindOf(CC_TYPES::MESH) && selectedEntities[1]->isKindOf(CC_TYPES::MESH)); } }
ccMatchScalesDlg::ccMatchScalesDlg( const ccHObject::Container& entities, int defaultSelectedIndex/*=0*/, QWidget* parent/*=0*/) : QDialog(parent, Qt::Tool) , Ui::MatchScalesDialog() { setupUi(this); for (size_t i=0; i<entities.size(); ++i) { //add one line per entity in the combo-box listWidget->insertItem(static_cast<int>(i), new QListWidgetItem(QString("%1 (ID=%2)").arg(entities[i]->getName()).arg(entities[i]->getUniqueID()))); } //default selection if (defaultSelectedIndex >= 0 && static_cast<size_t>(defaultSelectedIndex) < entities.size()) listWidget->setItemSelected(listWidget->item(defaultSelectedIndex),true); rmsDifferenceLineEdit->setValidator(new QDoubleValidator(rmsDifferenceLineEdit)); }
void BaseFilter::getSelectedEntitiesThatAre(CC_CLASS_ENUM kind, ccHObject::Container & entities) { ccHObject::Container selected = m_selected; for (size_t i = 0 ; i < selected.size(); ++i) { ccHObject * this_obj = selected[i]; if (this_obj->isA(kind)) { entities.push_back(this_obj); } } }
void BaseFilter::getSelectedEntitiesThatAreCCPointCloud(ccHObject::Container & entities) { ccHObject::Container selected = m_selected; for (size_t i = 0 ; i < selected.size(); ++i) { ccHObject * this_obj = selected[i]; if (this_obj->isA(CC_TYPES::POINT_CLOUD)) { entities.push_back(this_obj); } } }
ccHObject::Container vombat::filterObjectsByKind(const ccHObject::Container& in, const CC_CLASS_ENUM ThisType) { if (in.empty()) return in; ccHObject::Container out; for (ccHObject* obj : in) { if (obj->isKindOf(ThisType)) { out.push_back(obj); } } return out; }
ccEntityPickerDlg::ccEntityPickerDlg( const ccHObject::Container& entities, int selectedIndex/*=0*/, QWidget* parent/*=0*/, QString labelStr/*=QString()*/) : QDialog(parent) , Ui::PickEntityDlg() { setupUi(this); setWindowFlags(Qt::Tool/*Qt::Dialog | Qt::WindowStaysOnTopHint*/); for (size_t i=0; i<entities.size(); ++i) { //add one line per entity in the combo-box comboBox->addItem(QString("%1 (ID=%2)").arg(entities[i]->getName()).arg(entities[i]->getUniqueID())); } if (!labelStr.isNull()) label->setText(labelStr); }
bool qPoissonReconPlugin::onNewSelection(const ccHObject::Container& selectedEntities) { return (selectedEntities.size()==1 && selectedEntities[0]->isA(CC_POINT_CLOUD)); }
void qRansacSD::onNewSelection(const ccHObject::Container& selectedEntities) { if (m_action) m_action->setEnabled(selectedEntities.size()==1 && selectedEntities[0]->isA(CC_POINT_CLOUD)); }
void qPCV::onNewSelection(const ccHObject::Container& selectedEntities) { if (m_action) m_action->setEnabled(selectedEntities.size()==1); }
void qGMMRegPlugin::onNewSelection(const ccHObject::Container& selectedEntities) { if (m_action) m_action->setEnabled(selectedEntities.size() == 2); }
int qPCVPlugin::doAction(ccHObject::Container& selectedEntities, unsigned& uiModificationFlags, ccProgressDialog* progressCb/*=NULL*/, QWidget* parent/*=NULL*/) { unsigned selNum = selectedEntities.size(); if (selNum!=1) return -1; ccHObject* ent = selectedEntities[0]; ccGenericPointCloud* cloud = NULL; ccGenericMesh* mesh = NULL; if (ent->isKindOf(CC_POINT_CLOUD)) { cloud = static_cast<ccGenericPointCloud*>(ent); } else if (ent->isKindOf(CC_MESH)) { mesh = static_cast<ccGenericMesh*>(ent); cloud = mesh->getAssociatedCloud(); } else { return -2; } if (!cloud->isA(CC_POINT_CLOUD)) //TODO return-3; ccPointCloud* pc = static_cast<ccPointCloud*>(cloud); ccPcvDlg dlg(parent); //for meshes only if (!mesh) dlg.closedMeshCheckBox->setEnabled(false); //for using clouds normals as rays std::vector<ccGenericPointCloud*> cloudsWithNormals; if (m_app && m_app->dbRoot()) { ccHObject* root = m_app->dbRoot(); if (root) { ccHObject::Container clouds; root->filterChildren(clouds,true,CC_POINT_CLOUD); for (unsigned i=0;i<clouds.size();++i) { //we keep only clouds with normals ccGenericPointCloud* cloud = static_cast<ccGenericPointCloud*>(clouds[i]); if (cloud && cloud->hasNormals()) { cloudsWithNormals.push_back(cloud); QString cloudTitle = QString("%1 - %2 points").arg(cloud->getName()).arg(cloud->size()); if (cloud->getParent() && cloud->getParent()->isKindOf(CC_MESH)) cloudTitle.append(QString(" (%1)").arg(cloud->getParent()->getName())); dlg.cloudsComboBox->addItem(cloudTitle); } } } } if (cloudsWithNormals.empty()) dlg.useCloudRadioButton->setEnabled(false); if (!dlg.exec()) return 0; //on récupère le champ PCV s'il existe déjà, et on le créé sinon int sfIdx = pc->getScalarFieldIndexByName(CC_PCV_FIELD_LABEL_NAME); if (sfIdx<0) sfIdx=pc->addScalarField(CC_PCV_FIELD_LABEL_NAME,true); if (sfIdx<0) return -4; pc->setCurrentScalarField(sfIdx); unsigned raysNumber = dlg.raysSpinBox->value(); unsigned res = dlg.resSpinBox->value(); bool meshIsClosed = (mesh ? dlg.closedMeshCheckBox->checkState()==Qt::Checked : false); bool mode360 = !dlg.mode180CheckBox->isChecked(); //PCV type ShadeVis bool success = false; if (!cloudsWithNormals.empty() && dlg.useCloudRadioButton->isChecked()) { //Version with cloud normals as light rays assert(dlg.cloudsComboBox->currentIndex() < (int)cloudsWithNormals.size()); ccGenericPointCloud* pc = cloudsWithNormals[dlg.cloudsComboBox->currentIndex()]; std::vector<CCVector3> rays; unsigned count = pc->size(); rays.resize(count); for (unsigned i=0;i<count;++i) rays[i]=CCVector3(pc->getPointNormal(i)); success = PCV::Launch(rays,cloud,mesh,meshIsClosed,res,res,progressCb); } else { //Version with rays sampled on a sphere success = (PCV::Launch(raysNumber,cloud,mesh,meshIsClosed,mode360,res,res,progressCb)>0); } if (!success) { pc->deleteScalarField(sfIdx); return -255; } else { pc->getCurrentInScalarField()->computeMinAndMax(); pc->setCurrentDisplayedScalarField(sfIdx); ccScalarField* sf = static_cast<ccScalarField*>(pc->getScalarField(sfIdx)); if (sf) sf->setColorRamp(GREY); ent->showSF(true); ent->showNormals(false); ent->prepareDisplayForRefresh_recursive(); } //currently selected entities parameters may have changed! uiModificationFlags |= CC_PLUGIN_REFRESH_ENTITY_BROWSER; //currently selected entities appearance may have changed! uiModificationFlags |= CC_PLUGIN_REFRESH_GL_WINDOWS; return 1; }
bool qPCVPlugin::onNewSelection(const ccHObject::Container& selectedEntities) { return (selectedEntities.size()==1); }
void GetSupportedShapes(ccHObject* baseEntity, ccHObject::Container& shapes, ESRI_SHAPE_TYPE& shapeType) { shapeType = SHP_NULL_SHAPE; if (!baseEntity) { assert(false); shapes.clear(); return; } switch (baseEntity->getClassID()) { case CC_TYPES::POINT_CLOUD: { unsigned count = ccHObjectCaster::ToGenericPointCloud(baseEntity)->size(); if (count != 0) { shapeType = SHP_MULTI_POINT_Z; shapes.push_back(baseEntity); } } break; //DGM: TODO //case CC_MESH: //case CC_SUB_MESH: // { // unsigned count = ccHObjectCaster::ToGenericMesh(baseEntity)->size(); // if (count != 0) // { // shapeType = SHP_MULTI_PATCH; // shapes.push_back(baseEntity); // } // } // break; case CC_TYPES::POLY_LINE: { ccPolyline* poly = static_cast<ccPolyline*>(baseEntity); shapeType = poly->is2DMode() ? SHP_POLYLINE : SHP_POLYLINE_Z; shapes.push_back(baseEntity); break; } case CC_TYPES::HIERARCHY_OBJECT: //we only allow groups with children of the same type! if (baseEntity->getChildrenNumber()) { ccHObject* child = baseEntity->getChild(0); assert(child); if (!child) return; //first we check that all entities have the same type { for (unsigned i=1; i<baseEntity->getChildrenNumber(); ++i) { if (baseEntity->getChild(i) && baseEntity->getChild(i)->getClassID() != child->getClassID()) { //mixed shapes are not allowed in shape files (yet?) return; } } } //call the same method on the first child so as to get its type GetSupportedShapes(child,shapes,shapeType/*,closedPolylinesAsPolygons*/); if (shapeType == SHP_NULL_SHAPE) return; //then add the remaining children { for (unsigned i=1; i<baseEntity->getChildrenNumber(); ++i) { ESRI_SHAPE_TYPE otherShapeType = SHP_NULL_SHAPE; ccHObject* child = baseEntity->getChild(i); if (child) GetSupportedShapes(child,shapes,otherShapeType); if (otherShapeType != shapeType) { if (child) ccLog::Warning(QString("[SHP] Entity %1 has not the same type (%1) as the others in the selection (%2)! Can't mix types...") .arg(child->getName()) .arg(ToString(otherShapeType)) .arg(ToString(shapeType))); //mixed shapes are not allowed in shape files (yet?) shapes.clear(); return; } } } } break; default: //nothing to do break; } }
int qPoissonReconPlugin::doAction(ccHObject::Container& selectedEntities, unsigned& uiModificationFlags, ccProgressDialog* progressCb/*=NULL*/, QWidget* parent/*=NULL*/) { //we need one point cloud unsigned selNum = selectedEntities.size(); if (selNum!=1) return -1; //a real point cloud ccHObject* ent = selectedEntities[0]; if (!ent->isA(CC_POINT_CLOUD)) return -1; //with normals! ccPointCloud* pc = static_cast<ccPointCloud*>(ent); if (!pc->hasNormals()) return -2; bool ok; #if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0)) int depth = QInputDialog::getInt(0, "Poisson reconstruction","Octree depth:", 8, 1, 24, 1, &ok); #else int depth = QInputDialog::getInteger(0, "Poisson reconstruction","Octree depth:", 8, 1, 24, 1, &ok); #endif if (!ok) return 1; //TODO: faster, lighter unsigned i,count = pc->size(); float* points = new float[count*3]; if (!points) return -3; float* normals = new float[count*3]; if (!normals) { delete[] points; return -3; } float* _points = points; float* _normals = normals; for (i=0;i<count;++i) { const CCVector3* P = pc->getPoint(i); *_points++ = (float)P->x; *_points++ = (float)P->y; *_points++ = (float)P->z; const PointCoordinateType* N = pc->getPointNormal(i); *_normals++ = (float)N[0]; *_normals++ = (float)N[1]; *_normals++ = (float)N[2]; } /*** RECONSTRUCTION PROCESS ***/ CoredVectorMeshData mesh; PoissonReconLib::PoissonReconResultInfo info; bool result = false; if (progressCb) { progressCb->setCancelButton(0); progressCb->setRange(0,0); progressCb->setInfo("Operation in progress"); progressCb->setMethodTitle("Poisson Reconstruction"); progressCb->start(); //QApplication::processEvents(); //run in a separate thread s_points = points; s_normals = normals; s_count = count; s_depth = depth; s_mesh = &mesh; s_info = &info; QFuture<void> future = QtConcurrent::run(doReconstruct); unsigned progress = 0; while (!future.isFinished()) { #if defined(_WIN32) || defined(WIN32) ::Sleep(500); #else sleep(500); #endif progressCb->update(++progress); //Qtconcurrent::run can't be canceled! /*if (progressCb->isCancelRequested()) { future.cancel(); future.waitForFinished(); s_result = false; break; } //*/ } result = s_result; progressCb->stop(); QApplication::processEvents(); } else { result = PoissonReconLib::reconstruct(count, points, normals, mesh, depth, &info); } delete[] points; points=0; delete[] normals; normals=0; if (!result || mesh.polygonCount() < 1) return -4; unsigned nic = (unsigned)mesh.inCorePoints.size(); unsigned noc = (unsigned)mesh.outOfCorePointCount(); unsigned nr_vertices = nic+noc; unsigned nr_faces = (unsigned)mesh.polygonCount(); ccPointCloud* newPC = new ccPointCloud("vertices"); newPC->reserve(nr_vertices); //we enlarge bounding box a little bit (2%) PointCoordinateType bbMin[3],bbMax[3]; pc->getBoundingBox(bbMin,bbMax); CCVector3 boxHalfDiag = (CCVector3(bbMax)-CCVector3(bbMin))*0.51f; CCVector3 boxCenter = (CCVector3(bbMax)+CCVector3(bbMin))*0.5f; CCVector3 filterMin = boxCenter-boxHalfDiag; CCVector3 filterMax = boxCenter+boxHalfDiag; Point3D<float> p; CCVector3 p2; for (i=0; i<nic; i++) { p = mesh.inCorePoints[i]; p2.x = p.coords[0]*info.scale+info.center[0]; p2.y = p.coords[1]*info.scale+info.center[1]; p2.z = p.coords[2]*info.scale+info.center[2]; newPC->addPoint(p2); } for (i=0; i<noc; i++) { mesh.nextOutOfCorePoint(p); p2.x = p.coords[0]*info.scale+info.center[0]; p2.y = p.coords[1]*info.scale+info.center[1]; p2.z = p.coords[2]*info.scale+info.center[2]; newPC->addPoint(p2); } ccMesh* newMesh = new ccMesh(newPC); newMesh->setName(QString("Mesh[%1] (level %2)").arg(pc->getName()).arg(depth)); newMesh->reserve(nr_faces); newMesh->addChild(newPC); std::vector<CoredVertexIndex> vertices; for (i=0; i < nr_faces; i++) { mesh.nextPolygon(vertices); if (vertices.size()!=3) { //Can't handle anything else than triangles yet! assert(false); } else { for (std::vector<CoredVertexIndex>::iterator it = vertices.begin(); it != vertices.end(); ++it) if (!it->inCore) it->idx += nic; newMesh->addTriangle(vertices[0].idx, vertices[1].idx, vertices[2].idx); } } newPC->setVisible(false); newMesh->setVisible(true); newMesh->computeNormals(); //output mesh selectedEntities.push_back(newMesh); //currently selected entities parameters may have changed! uiModificationFlags |= CC_PLUGIN_REFRESH_ENTITY_BROWSER; //currently selected entities appearance may have changed! uiModificationFlags |= CC_PLUGIN_REFRESH_GL_WINDOWS; return 1; }
void qPoissonRecon::onNewSelection(const ccHObject::Container& selectedEntities) { if (m_action) m_action->setEnabled(selectedEntities.size()==1 && selectedEntities[0]->isA(CC_TYPES::POINT_CLOUD)); }
void qAnimation::onNewSelection(const ccHObject::Container& selectedEntities) { if (m_action) m_action->setEnabled(!selectedEntities.empty()); }