/** * Update the detected objects. That is, discovering new objects or * discarding old objects or detecting moved objects. This should * be called periodically (i.e. in Effect::animate()) or every time * before using the detector. */ void AreaDetector::update() { AreaObjects newObjects; AreaObjects oldObjects = objects; objects.clear(); memset(workMatrix, false, count * sizeof(bool)); // Discover all objects. for (unsigned int x = 0; x < width; ++x) { for (unsigned int y = 0; y < height; ++y) { unsigned int currentIndex = x + y * width; if (! workMatrix[currentIndex]) { // This cell was not checked yet if (env->getMatrix()[currentIndex]) { // The current cell is being "touched", we found an object newObjects.push_back(identifyObject(x, y)); } } } } // Check for objects that have already existed before (i.e. moving objects). for (unsigned int i = 0; i < newObjects.size(); ++i) { unsigned int j = 0; bool found = false; AreaObjects::iterator iter = oldObjects.begin(); while (!found && j < oldObjects.size()) { unsigned int maxX = newObjects[i].x > oldObjects[j].x ? newObjects[i].x : oldObjects[j].x; unsigned int minX = newObjects[i].x < oldObjects[j].x ? newObjects[i].x : oldObjects[j].x; unsigned int maxY = newObjects[i].y > oldObjects[j].y ? newObjects[i].y : oldObjects[j].y; unsigned int minY = newObjects[i].y < oldObjects[j].y ? newObjects[i].y : oldObjects[j].y; // Check if the object is within the range specified by threshold. float dist = sqrt( ((maxX - minX)^2) + ((maxY - minY)^2) ); if(dist < threshold) { found = true; } else { ++j; ++iter; } } if (found) { // The object exists already within the range specified by threshold. newObjects[i].id = oldObjects[j].id; oldObjects.erase(iter); } else { // The object seems to be new, therefore a new identifier is generated. newObjects[i].id = ++lastId; } objects.push_back(newObjects[i]); } }
int MainUI::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QMainWindow::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: updatePointView((*reinterpret_cast< hash_map<int,Entity*>*(*)>(_a[1]))); break; case 1: updateNodeInfo((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break; case 2: newProject(); break; case 3: quit(); break; case 4: showAllObjects(); break; case 5: saveCurrentScreen(); break; case 6: itemView(); break; case 7: editorView(); break; case 8: filterPtsByOBAFilter(); break; case 9: classifyObjs(); break; case 10: resetEntitysType(); break; case 11: extractBuildingManual(); break; case 12: exportBuilding(); break; case 13: autoRun(); break; case 14: datasetInfo(); break; case 15: importDTM(); break; case 16: importPoint(); break; case 17: importRectangle(); break; case 18: importTIN(); break; case 19: text2las(); break; case 20: las2text(); break; case 21: about(); break; case 22: showMousePos((*reinterpret_cast< const int(*)>(_a[1])),(*reinterpret_cast< const int(*)>(_a[2]))); break; case 23: identifyObject((*reinterpret_cast< const int(*)>(_a[1])),(*reinterpret_cast< const int(*)>(_a[2]))); break; case 24: cancelBuilding((*reinterpret_cast< const int(*)>(_a[1]))); break; case 25: useEntityParam((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const int(*)>(_a[2]))); break; default: ; } _id -= 26; } return _id; }