void NetworkMessage::addPaddingBytes(size_t n) { if (!canAdd(n)) { return; } memset(&buffer[position], 0x33, n); length += n; }
// simply write functions for outgoing message void NetworkMessage::AddByte(const uint8_t& value) { if (!canAdd(1)) { return; } m_MsgBuf[m_ReadPos++] = value; m_MsgSize++; }
void NetworkMessage::addBytes(const char* bytes, size_t size) { if (!canAdd(size) || size > 8192) { return; } memcpy(buffer + info.position, bytes, size); info.position += size; info.length += size; }
void NetworkMessage::AddBytes(const char* bytes, size_t size) { if (!canAdd(size) || size > 8192) { return; } memcpy(m_MsgBuf + m_ReadPos, bytes, size); m_ReadPos += size; m_MsgSize += size; }
void NetworkMessage::AddPaddingBytes(const uint32_t& n) { if (!canAdd(n)) { return; } memset((void*)&m_MsgBuf[m_ReadPos], 0x33, n); m_MsgSize = m_MsgSize + n; }
void NetworkMessage::AddU32(const uint32_t& value) { if (!canAdd(4)) { return; } *(uint32_t*)(m_MsgBuf + m_ReadPos) = swap_uint32(value); m_ReadPos += 4; m_MsgSize += 4; }
void NetworkMessage::AddU16(const uint16_t& value) { if (!canAdd(2)) { return; } *(uint16_t*)(m_MsgBuf + m_ReadPos) = swap_uint16(value); m_ReadPos += 2; m_MsgSize += 2; }
void Measure::addNote( const Note& note ) { if ( canAdd( note ) ) { myNotes.push_back( note ); } else { throw std::runtime_error( "cannot add note to measure" ); } }
void NetworkMessage::AddString(const char* value) { uint32_t stringlen = (uint32_t)strlen(value); if(!canAdd(stringlen+2) || stringlen > 8192) return; AddU16(stringlen); strcpy((char*)(m_MsgBuf + m_ReadPos), value); m_ReadPos += stringlen; m_MsgSize += stringlen; }
void NetworkMessage::addString(const std::string& value) { size_t stringLen = value.length(); if (!canAdd(stringLen + 2) || stringLen > 8192) { return; } add<uint16_t>(stringLen); memcpy(buffer + info.position, value.c_str(), stringLen); info.position += stringLen; info.length += stringLen; }
void NetworkMessage::addString(const char* value) { size_t stringLen = strlen(value); if (!canAdd(stringLen + 2) || stringLen > 8192) { return; } add<uint16_t>(stringLen); memcpy(buffer + position, value, stringLen); position += stringLen; length += stringLen; }
void ListWidget::dragEnterEvent(QDragEnterEvent *event) { QList<QUrl> urls=event->mimeData()->urls(); for(QUrl url : urls) { if(!canAdd(url.toLocalFile())) return; } event->accept(); qDebug("ok"); return; }
void NetworkMessage::AddString(const char* value) { size_t stringlen = strlen(value); if (!canAdd(stringlen + 2) || stringlen > 8192) { return; } AddU16(stringlen); memcpy((char*)m_MsgBuf + m_ReadPos, value, stringlen); m_ReadPos += stringlen; m_MsgSize += stringlen; }
void NetworkMessage::AddString(const std::string& value) { size_t stringlen = value.length(); if (!canAdd(stringlen + 2) || stringlen > 8192) { return; } AddU16(stringlen); memcpy(m_MsgBuf + m_ReadPos, value.c_str(), stringlen); m_ReadPos += stringlen; m_MsgSize += stringlen; }
void CglWnd::addEditBubble( int x /*= 0*/, int y /*= 0*/, int r /*= 100*/ ) { if (!canAdd()) return; for (int i = 0; i < MAX_BUBBLES; i++) { if (m_bubbles[i].eState == ST_REMOVED) { m_bubbles[i].reset(); m_bubbles[i].r = r; m_bubbles[i].setPos(x, y); m_bubbles[i].show(); m_activeBubbles++; checkCanEdit(); return; } } }
//-------------------------------------------------------------- // add indexes for a grid of points void mgIndexBuffer::addGrid( int vertexBase, // starting index int rowSize, // length of row int rows, // total row count int cols, // total col count BOOL outward) // true to face outward { // if no room in buffer, throw exception if (!canAdd(rows*cols*6)) throw new mgErrorMsg("glIndexFull", "", ""); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { int index = vertexBase + i*rowSize+j; addIndex(index); // tl if (outward) { addIndex(index+1); // tr addIndex(index+rowSize); // bl } else { addIndex(index+rowSize); // bl addIndex(index+1); // tr } addIndex(index+rowSize); // bl if (outward) { addIndex(index+1); // tr addIndex(index+rowSize+1); // br } else { addIndex(index+rowSize+1); // br addIndex(index+1); // tr } } } }
void RSSManager::updateAllFeeds() { unsigned int iNewNews = 0; NewsList l_fire_added_array; { CFlyLock(g_csFeed); // [+] IRainman fix. for (auto i = g_feeds.cbegin(); i != g_feeds.cend(); ++i) { if ((*i)->UpdateFeedNewXML()) { const RSSFeed::RSSItemList& list = (*i)->getNewsList(); for (auto j = list.cbegin(); j != list.cend(); ++j) { const RSSItem *l_item = new RSSItem(*j); CFlyFastLock(g_csNews); if (canAdd(l_item)) { g_newsList.push_back(l_item); l_fire_added_array.push_back(l_item); } else { safe_delete(l_item); } } iNewNews += list.size(); } } } for (auto i = l_fire_added_array.begin(); i != l_fire_added_array.end(); ++i) { fly_fire1(RSSListener::Added(), *i); } if (iNewNews) { fly_fire1(RSSListener::NewRSS(), iNewNews); } }
bool Measure::canAdd( const Note& note ) const { return canAdd( note.getDuration() ); }
/** * Adds an element to this collection. If canAdd() returns false * for the given element, or the element already exists in this * collection, then this method does nothing. * * @param element - The element to add. */ virtual void add(const T & element) { if (canAdd(element)) Collection<T>::add(element); }
void MinicolMaterializer::updateMinicolBlock() { minicolBlock->clearBlock(); cerr << "update" << endl; while(cur_block_size < (minicolBlock->getCapacity() * 8)) { // bits-per-byte Block* curblock = NULL; // Get a block from the data source having a fewest number of positions currently loaded // in the block and add it in. //cerr << "nds_pos = " << nds_pos << " and nval_pos = " << nval_pos << endl; if (nds_pos < nval_pos) { if (inputs_exhausted) { break; } curblock = getNextDSBlock(); if (curblock != NULL && canAdd(curblock)) { //cerr << "Read from DS block of size " << curblock->getSize() << endl; dsOutputBuffer[cur_ds_bufidx++] = curblock; nds_pos += curblock->getSize(); cur_block_size += curblock->getSizeInBits(); } else { if (curblock != NULL) { assert(deferredDSBlock == NULL); deferredDSBlock = curblock; } else { inputs_exhausted = true; } break; } } else { if (inputs_exhausted) { break; } curblock = getNextVBlock(); if (curblock != NULL && curblock->getSize() > 0 && canAdd(curblock)) { //cerr << "Read from val block of size " << curblock->getSize() << endl; valOutputBuffer[cur_val_bufidx++] = curblock; nval_pos += curblock->getSize(); cur_block_size += curblock->getSizeInBits(); } else { if (curblock != NULL) { assert(deferredValBlock == NULL); deferredValBlock = curblock; } else { inputs_exhausted = true; } break; } } } // Now we have as much data in the block as we could manage // If one of the columns has more positions than the other, we need to // cut it down to size. if (nval_pos > nds_pos) { cerr << "Need to remove " << (nval_pos - nds_pos) << " positions from last val block" << endl; int wantedpos = valOutputBuffer[cur_val_bufidx-1]->getSize() - (nval_pos - nds_pos); assert(wantedpos >= 0); if (wantedpos > 0) { deferredValBlock = valOutputBuffer[cur_val_bufidx-1]->split(wantedpos); } else { deferredValBlock = valOutputBuffer[--cur_val_bufidx]; } assert(deferredValBlock->getSize() == (nval_pos - nds_pos)); nval_pos -= (nval_pos - nds_pos); cur_block_size -= deferredValBlock->getSizeInBits(); } else if (nds_pos > nval_pos) { cerr << "Need to remove " << (nds_pos - nval_pos) << " positions from last ds block" << endl; int wantedpos = dsOutputBuffer[cur_ds_bufidx-1]->getSize() - (nds_pos - nval_pos); assert(wantedpos >= 0); if (wantedpos > 0) { deferredDSBlock = dsOutputBuffer[cur_ds_bufidx-1]->split(wantedpos); } else { deferredDSBlock = dsOutputBuffer[--cur_ds_bufidx]; } nds_pos -= (nds_pos - nval_pos); cur_block_size -= deferredDSBlock->getSizeInBits(); } else { //cerr << "No removals needed; " << nds_pos << " = " << nval_pos << endl; } // Check that we really did manage to get everything equalized assert(nds_pos == nval_pos && cur_block_size >= 0); // Null-terminate arrays valOutputBuffer[cur_val_bufidx] = NULL; dsOutputBuffer[cur_ds_bufidx] = NULL; // If we actually have data, then update the block with it if (cur_block_size > 0) { minicolBlock->setValBlocks(0, valOutputBuffer); minicolBlock->setValBlocks(1, dsOutputBuffer); // FIXME bogus assumed contiguous int minpos = valOutputBuffer[0]->peekNext()->position; int maxpos = valOutputBuffer[cur_val_bufidx-1]->getEndPosition(); PosBlock** pbarr = new PosBlock*[1]; // FIXME leak pbarr[0] = new PosRLEBlock(new RLETriple(-1, minpos, maxpos-minpos+1)); minicolBlock->setPosBlockArray(new PosBlockArray(pbarr, 1)); minicolBlock->resetCursors(); // Reset for the next call cur_block_size = 0; cur_val_bufidx = 0; cur_ds_bufidx = 0; nds_pos = 0; nval_pos = 0; cerr << "---" << endl; //curPosBlock = NULL; } else { delete minicolBlock; minicolBlock = NULL; } }
int process(const tendrils& i, const tendrils& o) { cv::Mat mask_resized = *mask; cv::Mat rvec, tvec, K; this->K->convertTo(K, CV_32F); R->convertTo(rvec, CV_32F); cv::Rodrigues(rvec.clone(), rvec); T->convertTo(tvec, CV_32F); cam_params->centerX = K.at<float>(0, 2); cam_params->centerY = K.at<float>(1, 2); cam_params->xRes = mask_resized.size().width; cam_params->yRes = mask_resized.size().height; cam_params->focalLength = K.at<float>(0, 0); //get the camera pose Eigen::Vector3f axis(rvec.at<float>(0), rvec.at<float>(1), rvec.at<float>(2)); surfels::Transform3f objPose(Eigen::AngleAxisf(axis.norm(), axis.normalized())); objPose.pretranslate(Eigen::Vector3f(tvec.at<float>(0), tvec.at<float>(1), tvec.at<float>(2))); surfels::Transform3f camPose = objPose.inverse(Eigen::Isometry); //extract the cloud pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>()); cloud->resize(mask_resized.size().width * mask_resized.size().height); cloud->width = mask_resized.size().width; cloud->height = mask_resized.size().height; cvToCloudXYZ(*points3d, *cloud); //compute normals // Estimate normals pcl::IntegralImageNormalEstimation<pcl::PointXYZ, pcl::Normal> ne; pcl::PointCloud<pcl::Normal> result; ne.setNormalEstimationMethod(ne.AVERAGE_DEPTH_CHANGE); ne.setMaxDepthChangeFactor(0.02f); ne.setNormalSmoothingSize(10.0f); ne.setInputCloud(cloud); ne.compute(result); //copy into required structures boost::shared_ptr<boost::multi_array<Eigen::Vector3f, 2> > points(new boost::multi_array<Eigen::Vector3f, 2>()); boost::shared_ptr<boost::multi_array<Eigen::Vector3f, 2> > normals( new boost::multi_array<Eigen::Vector3f, 2>()); boost::shared_ptr<boost::multi_array<bool, 2> > canAdd(new boost::multi_array<bool, 2>()); boost::shared_ptr<boost::multi_array<bool, 2> > validity(new boost::multi_array<bool, 2>()); points->resize(boost::extents[cloud->width][cloud->height]); normals->resize(boost::extents[cloud->width][cloud->height]); canAdd->resize(boost::extents[cloud->width][cloud->height]); validity->resize(boost::extents[cloud->width][cloud->height]); for (unsigned int x = 0; x < cloud->width; x++) { for (unsigned int y = 0; y < cloud->height; y++) { bool mask_value = mask_resized.at<unsigned char>(y, x) > 0; pcl::Normal n = result(x, y); pcl::PointXYZ p = (*cloud)(x, y); (*points)[x][y] = Eigen::Vector3f(p.x, p.y, p.z); (*normals)[x][y] = Eigen::Vector3f(n.normal_x, n.normal_y, n.normal_z).normalized(); (*validity)[x][y] = (*canAdd)[x][y] = mask_value; } } //fill in updatedata surfels::SurfelUpdateData update_data; update_data.currentTime = time++; update_data.camParams = *cam_params; update_data.camTransform = camPose; update_data.image = *image; update_data.pointGrid = points; update_data.normalGrid = normals; update_data.validityGrid = validity; update_data.willingToAdd = canAdd; //perform the update std::vector<bool> can_update(model->surfels.size(), true); std::vector<unsigned int> removed; surfels::updateSurfelModel(*model, update_data, *params, can_update, removed); return ecto::OK; }