std::vector<Handler<BitmapGlyph> > FreeType::lookupBitmap(Font& font, float size, std::vector<unsigned int> const& ucs4, float& ascent, float& descent, float& height) { Font::RawFaceSession rfs(font); FT_Face face = rfs.face(); FT_Face face__; FTC_ScalerRec scaler; { scaler.face_id = face; scaler.width = 0; scaler.height = FLOAT_TO_26_6( size ); scaler.pixel = 0; scaler.x_res=72; //XXX scaler.y_res=72; //XXX } FTC_Manager_LookupFace(this->cache_, face, &face__); { FT_Size size; FTC_Manager_LookupSize(this->cache_, &scaler, &size); ascent = FLOAT_FROM_26_6(size->metrics.ascender); descent = FLOAT_FROM_26_6(size->metrics.descender); height = FLOAT_FROM_26_6(size->metrics.height); } std::vector<Handler<BitmapGlyph> > ret; ret.reserve(ucs4.size()); for(unsigned int const& u : ucs4) { unsigned int const gindex = FTC_CMapCache_Lookup(this->cmap_, face, font.unicodeCharmapIndex(), u); FT_Glyph glyph; { FT_Glyph glyph_orig; FTC_ImageCache_LookupScaler(this->image_, &scaler, 0, gindex, &glyph_orig, nullptr); FT_Glyph_Copy(glyph_orig, &glyph); } if(glyph->format != FT_GLYPH_FORMAT_BITMAP ) { FT_Vector_ vec; vec.x = 0; vec.y = 0; FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, &vec, 1); } ret.push_back( Handler<BitmapGlyph>(new BitmapGlyph(reinterpret_cast<FT_BitmapGlyph>(glyph))) ); } return ret; }
void rfs(int start, int idx, std::set<int> *adjList, std::list<int> &stack, std::set<int> &seen, std::list<int> &cluster) { seen.insert(idx); for(std::set<int>::iterator it = adjList[idx].begin(); it != adjList[idx].end(); it++) { int nidx = *it; if(seen.find(nidx)!=seen.end()) continue; rfs(start, nidx, adjList, stack, seen, cluster); } std::list<int>::iterator pos = find(stack.begin(), stack.end(), idx); assert(pos != stack.end()); stack.erase(pos); cluster.push_back(idx); }
uint32 TypeMapperBase::insertFunction(FncSerT _fs, FncDesT _fd, uint8 _pos, const char *_name){ //Locker<Mutex> lock(d.mtx); if(!_pos){ while(d.crtpos < d.fncvec.size() && d.fncvec[d.crtpos].pfs != NULL){ ++d.crtpos; } if(d.crtpos == d.fncvec.size()){ d.fncvec.push_back(Data::FunctionStub()); } _pos = d.crtpos; ++d.crtpos; }else{ if(_pos >= d.fncvec.size()){ d.fncvec.resize(_pos + 1); } if(d.fncvec[_pos].pfs){ THROW_EXCEPTION_EX("Overlapping identifiers", _pos); return _pos; } } CRCValue<uint8> crcval(_pos); if(!crcval.ok()){ THROW_EXCEPTION_EX("Invalid CRCValue", _pos); } Data::FunctionStub &rfs(d.fncvec[_pos]); rfs.pfs = _fs; rfs.pfd = _fd; rfs.name = _name; rfs.id = (uint8)crcval; if(d.fncmap.find(_name) == d.fncmap.end()){ d.fncmap[rfs.name] = _pos; } return _pos; }
unsigned int FreeType::lookupGlyphIndex(Font& font, unsigned int ucs4) { Font::RawFaceSession rfs(font); FT_Face face = rfs.face(); return FTC_CMapCache_Lookup(this->cmap_, face, font.unicodeCharmapIndex(), ucs4); }
template<typename PointNT, typename PointOutT> void pcl::SHOTEstimationOMP<pcl::PointXYZRGBA, PointNT, PointOutT>::computeFeature (PointCloudOut &output) { if (threads_ < 0) threads_ = 1; descLength_ = (b_describe_shape_) ? nr_grid_sector_ * (nr_shape_bins_ + 1) : 0; descLength_ += (b_describe_color_) ? nr_grid_sector_ * (nr_color_bins_ + 1) : 0; sqradius_ = search_radius_ * search_radius_; radius3_4_ = (search_radius_ * 3) / 4; radius1_4_ = search_radius_ / 4; radius1_2_ = search_radius_ / 2; if (output.points[0].descriptor.size () != (size_t)descLength_) for (size_t idx = 0; idx < indices_->size (); ++idx) output.points[idx].descriptor.resize (descLength_); int data_size = indices_->size (); Eigen::VectorXf *shot = new Eigen::VectorXf[threads_]; std::vector<std::vector<Eigen::Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > > rfs (threads_); for (size_t i = 0; i < rfs.size (); ++i) rfs[i].resize (3); for (int i = 0; i < threads_; i++) shot[i].setZero (descLength_); // Iterating over the entire index vector #pragma omp parallel for num_threads(threads_) for (int idx = 0; idx < data_size; ++idx) { // Allocate enough space to hold the results // \note This resize is irrelevant for a radiusSearch (). std::vector<int> nn_indices (k_); std::vector<float> nn_dists (k_); this->searchForNeighbors ((*indices_)[idx], search_parameter_, nn_indices, nn_dists); // Estimate the SHOT at each patch #ifdef _OPENMP int tid = omp_get_thread_num (); #else int tid = 0; #endif computePointSHOT ((*indices_)[idx], nn_indices, nn_dists, shot[tid], rfs[tid]); // Copy into the resultant cloud for (int d = 0; d < shot[tid].size (); ++d) output.points[idx].descriptor[d] = shot[tid][d]; for (int d = 0; d < 9; ++d) output.points[idx].rf[d] = rfs[tid][d / 3][d % 3]; } delete[] shot; }
TInt RMmCustomAPI::GetParameterValue(TInt aLineNumber,TInt aIndex ) { if ( KErrNone != iFileError) return -1; RFile fread; TInt lError = fread.Open(iFs,KMyFile,EFileRead); RFileReadStream rfs(fread); TChar delmeter(10); TInt ret = -9999; TInt err; if ( KErrNone == lError ) { for(TInt i = 0; i < aLineNumber; i++ ) { TRAP(err,rfs.ReadL(iLineBuffer,delmeter)); if(err != KErrNone) { rfs.Close(); fread.Close(); return -1; } iLineBuffer.Copy(iLineBuffer.Left(iLineBuffer.Length() - 2 )); } } TBuf8<64> restBuffer; TInt pos = KErrNotFound; TChar c(44); // 44 means ',' if(aIndex != -1 ) { for(TInt i = 0; i < aIndex; i++ ) { pos = iLineBuffer.Locate(c); if(pos == KErrNotFound) break; restBuffer.Copy(iLineBuffer.Left(pos )); iLineBuffer.Copy(iLineBuffer.Mid( pos + 1)); } if(pos != KErrNotFound) iLineBuffer.Copy(restBuffer); } if(ret == -9999) { pos = iLineBuffer.Locate(c); if(pos != KErrNotFound) { restBuffer.Copy(iLineBuffer.Left(pos )); iLineBuffer.Copy(restBuffer); } TLex8 input(iLineBuffer); input.Val(ret); } rfs.Close(); fread.Close(); return ret; #if 0 RFs fs; RFile fread; TInt lError = fs.Connect(); if ( KErrNone != lError ) return -1; lError = fread.Open(fs,KMyFile,EFileRead); RFileReadStream rfs(fread); TBuf8<8> buf; TChar delmeter(10); TInt ret = -999; TInt err; if ( KErrNone == lError ) { for(TInt i = 0; i < aIndex; i++ ) { TRAP(err,rfs.ReadL(buf,delmeter)); if(err != KErrNone) { rfs.Close(); fread.Close(); fs.Close(); return -1; } buf.Copy(buf.Left(buf.Length() - 2 )); } } if(ret == -999) { TLex8 input(buf); input.Val(ret); } rfs.Close(); fread.Close(); fs.Close(); return ret; #endif }
std::list<std::list<depGraph*> > kosaraju(std::list<depGraph*> &nodes, int level) { //printf("SCC: called at level = %d\n", level); /* i'm lazy */ std::map<depGraph*, int> nodeMap; std::map<int, depGraph*> revNodeMap; std::set<int> *adjFwdMatrix; std::set<int> *adjRevMatrix; std::list<int> theStack; std::set<int> seenNodes; std::list<int> cluster; std::list<std::list<depGraph*> > sccs; adjFwdMatrix = new std::set<int>[nodes.size()]; adjRevMatrix = new std::set<int>[nodes.size()]; int deepestFwd = -1, deepestRev = -1; for(std::list<depGraph*>::iterator it = nodes.begin(); it != nodes.end(); it++) { depGraph *g = *it; int p = (int)nodeMap.size(); nodeMap[g] = p; revNodeMap[p] = g; } assert(nodeMap.size() == nodes.size()); for(std::list<depGraph*>::iterator it0 = nodes.begin(); it0 != nodes.end(); it0++) { depGraph *v = *it0; int i = nodeMap[v]; for(int l = level; l < MAX_DEPTH; l++) { for(std::list<depEdge>::iterator it1 = v->NodeEdges[l].begin(); it1 != v->NodeEdges[l].end(); it1++) { depGraph *u = (*it1).node; int j = nodeMap[u]; if(i==j) continue; //printf("FWD: adding edge from node %d to %d\n", i, j); adjFwdMatrix[i].insert(j); if(l > deepestFwd) deepestFwd = l; } } } // printf("getting ready to REV\n"); /* reverse all edges */ for(std::list<depGraph*>::iterator it0 = nodes.begin(); it0 != nodes.end(); it0++) { depGraph *v = *it0; int i = nodeMap[v]; for(int l = level; l < MAX_DEPTH; l++) { for(std::list<depEdge>::iterator it1 = v->NodeEdges[l].begin(); it1 != v->NodeEdges[l].end(); it1++) { depGraph *u = (*it1).node; int j = nodeMap[u]; if(i==j) continue; /* fwd: edge from i -> j */ /* rev: edge from j to i */ //printf("REV: adding edge from node %d to %d\n", i, j); adjRevMatrix[j].insert(i); if(l > deepestRev) deepestRev = l; } } } //printf("DEEPEST REV = %d, DEEPEST FWD = %d\n", //deepestFwd, deepestRev); //exit(-1); int c=0; int size = nodeMap.size(); while((int)theStack.size() < size) { dfs(c, adjFwdMatrix, theStack, seenNodes, size); c++; } seenNodes.clear(); /* for(std::list<int>::iterator it = theStack.begin(); it != theStack.end(); it++) { depGraph *g = revNodeMap[*it]; printf("%d: %s\n",*it, g->name.c_str()); } */ assert((int)theStack.size() == size); std::list<depGraph*> scc; while(theStack.size() != 0) { scc.clear(); cluster.clear(); c = theStack.back(); rfs(c, c, adjRevMatrix, theStack, seenNodes, cluster); for(std::list<int>::iterator it = cluster.begin(); it != cluster.end(); it++) { depGraph *g = revNodeMap[*it]; scc.push_back(g); } sccs.push_back(scc); } delete [] adjFwdMatrix; delete [] adjRevMatrix; return sccs; }
// // Opens client-side sub-session for a registered script. The script session is modelled as a // client side sub-session with a peer server side sub-session. // TInt RSecMgrSubSession::Open(const RSessionBase& aSession, CScript& aScriptInfo, TPolicyID aPolicyID, const TDesC& aHashValue) { TIpcArgs args(aScriptInfo.ScriptID (), aPolicyID); TInt errCode(KErrNone); errCode = iFs.Connect(); if(errCode == KErrNone) { if ( KAnonymousScript==aScriptInfo.ScriptID ()) errCode = CreateSubSession (aSession, EGetTrustedUnRegScriptSession, args); else errCode = CreateSubSession (aSession, EGetScriptSession, args); if ( errCode==KErrNone) { // Retrieve the RFs and RFile handles from the server TPckgBuf<TInt> fh; // sub-session (RFile) handle TIpcArgs args(&fh); RFile file; CleanupClosePushL(file); if ( KErrNone==errCode) { iFs.ShareProtected (); TFileName tempDirPath; TFileName tempPath; iFs.PrivatePath (tempDirPath); BaflUtils::EnsurePathExistsL (iFs, tempDirPath); errCode = file.Temp (iFs, tempDirPath, tempPath, EFileWrite); if ( KErrNone==errCode) { file.TransferToServer (args, EMsgArgOne, EMsgArgTwo); errCode = SendReceive (EGetScriptFile, args); if ( KErrNone==errCode) { RFileReadStream rfs(file); CleanupClosePushL(rfs); aScriptInfo.InternalizeL (rfs); TBufC<KMaxPath> hashValue(aScriptInfo.Hash()); if(0 != hashValue.Compare(KNullDesC)) { if(!aScriptInfo.HashMatch(aHashValue)) { //hash check failed errCode = KErrNotFound; } } CleanupStack::PopAndDestroy(&rfs); } } iFs.Delete (tempPath); } CleanupStack::PopAndDestroy(&file); } } return errCode; }