void dumpinfo() { FILE *out; int i; struct transform *t; char buffer[400], buffer2[400]; out = fopen("gdrawbuildchars.c","w"); fprintf(out,"#include \"gdrawP.h\"\n\n" ); for ( i=0; names[i].name!=NULL; ++i ) fprintf( out, "#define\t%s\t0x%07x\n", names[i].name, names[i].mask ); fprintf(out,"\n#define\tANY\t0x%07x\n\n", ANY ); for ( i=0; i<95; ++i ) if ( info[i]!=NULL ) { fprintf(out, "static struct gchr_transform trans_%s[] = {\n", charnames[i] ); for ( t=info[i]; t!=NULL; t=t->next ) fprintf(out, " { %s, %s, 0x%07x }%s\n", Mask(buffer,t->oldstate), Mask(buffer2,t->newstate), t->resch, t->next==NULL?"":"," ); fprintf(out,"};\n\n"); } fprintf(out,"struct gchr_lookup _gdraw_chrlookup[95] = {\n" ); for ( i=0; i<95; ++i ) { if ( info[i]==NULL ) fprintf(out, " { 0 },\t\t\t/* %c */\n", i+' ' ); else fprintf(out, " { %d, trans_%s },\t/* %c */\n", queuelen(info[i]), charnames[i], i+' ' ); } fprintf(out,"};\n\n" ); fprintf(out, "struct gchr_accents _gdraw_accents[] = {\n" ); fprintf(out, " { 0x0301, 0x%07x },\n", ACUTE ); fprintf(out, " { 0x0300, 0x%07x },\n", GRAVE ); fprintf(out, " { 0x0308, 0x%07x },\n", DIAERESIS ); fprintf(out, " { 0x0302, 0x%07x },\n", CIRCUMFLEX ); fprintf(out, " { 0x0303, 0x%07x },\n", TILDE ); fprintf(out, " { 0x030a, 0x%07x },\n", RING ); fprintf(out, " { 0x0338, 0x%07x },\n", SLASH ); fprintf(out, " { 0x0306, 0x%07x },\n", BREVE ); fprintf(out, " { 0x030c, 0x%07x },\n", CARON ); fprintf(out, " { 0x0307, 0x%07x },\n", DOTABOVE ); fprintf(out, " { 0x0323, 0x%07x },\n", DOTBELOW ); fprintf(out, " { 0x0327, 0x%07x },\n", CEDILLA ); fprintf(out, " { 0x0328, 0x%07x },\n", OGONEK ); fprintf(out, " { 0x0304, 0x%07x },\n", MACRON ); fprintf(out, " { 0x030d, 0x%07x },\n", DBLGRAVE|GREEK ); fprintf(out, " { 0x030b, 0x%07x },\n", DBLGRAVE ); fprintf(out, " { 0x030b, 0x%07x },\n", DBLACUTE ); fprintf(out, " { 0x030b, 0x%07x },\n", INVBREVE ); fprintf(out, " { 0x030b, 0x%07x },\n", DIAERESISBELOW ); fprintf(out, " { 0x030b, 0x%07x },\n", CIRCUMFLEXBELOW ); fprintf(out, " { 0x030b, 0x%07x },\n", TILDEBELOW ); fprintf(out, " { 0x030b, 0x%07x },\n", RINGBELOW ); fprintf(out, " { 0x030b, 0x%07x },\n", LINEBELOW ); fprintf(out, " { 0x030b, 0x%07x },\n", HOOKABOVE ); fprintf(out, " { 0x030b, 0x%07x },\n", HORN ); fprintf(out, " { 0 },\n" ); fprintf(out, "};\n\n" ); fprintf(out, "uint32 _gdraw_chrs_any=ANY, _gdraw_chrs_ctlmask=GREEK, _gdraw_chrs_metamask=0;\n" ); fclose(out); }
void init() { /* copy singleton simulationBox data to simbox simBox holds global and* * local SimulationSize and where the local SimArea is in the greater * * scheme using Offsets from global LEFT, TOP, FRONT */ PMACC_AUTO(simBox, Environment<DIM2>::get().SubGrid().getSimulationBox()); /* Recall that in types.hpp the following is defined: * * typedef MappingDescription<DIM2, math::CT::Int<16,16> > MappingDesc; * * where math::CT::Int<16,16> is arbitrarily(!) chosen SuperCellSize and DIM2 * * is the dimension of the grid. * * Expression of 2nd argument translates to DataSpace<DIM3>(16,16,0). * * This is the guard size (here set to be one Supercell wide in all * * directions). Meaning we have 16*16*(2*grid.x+2*grid.y+4) more * * cells in GridLayout than in SimulationBox. */ GridLayout<DIM2> layout( simBox.getLocalSize(), MappingDesc::SuperCellSize::toRT()); /* getDataSpace will return DataSpace( grid.x +16+16, grid.y +16+16) * * init stores the arguments internally in a MappingDesc private * * variable which stores the layout regarding Core, Border and guard * * in units of SuperCells to be used by the kernel to identify itself.*/ evo.init(MappingDesc(layout.getDataSpace(), 1, 1)); buff1 = new Buffer(layout, false); buff2 = new Buffer(layout, false); Space gardingCells(1, 1); for (uint32_t i = 1; i < traits::NumberOfExchanges<DIM2>::value; ++i) { /* to check which number corresponds to which direction, you can * * use the following member of class Mask like done in the two * * lines below: * * DataSpace<DIM2>relVec = Mask::getRelativeDirections<DIM2>(i); * * std::cout << "Direction:" << i << " => Vec: (" << relVec[0] * * << "," << relVec[1] << ")\n"; * * The result is: 1:right(1,0), 2:left(-1,0), 3:up(0,1), * * 4:up right(1,1), 5:(-1,1), 6:(0,-1), 7:(1,-1), 8:(-1,-1) */ /* types.hpp: enum CommunicationTags{ BUFF1 = 0u, BUFF2 = 1u }; */ buff1->addExchange(GUARD, Mask(i), gardingCells, BUFF1); buff2->addExchange(GUARD, Mask(i), gardingCells, BUFF2); } /* Both next lines are defined in GatherSlice.hpp: * * -gather saves the MessageHeader object * * -Then do an Allgather for the gloabalRanks from GC, sort out * * -inactive processes (second/boolean ,argument in gather.init) and* * save new MPI_COMMUNICATOR created from these into private var. * * -return if rank == 0 */ MessageHeader header(gridSize, layout, simBox.getGlobalOffset()); isMaster = gather.init(header, true); /* Calls kernel to initialize random generator. Game of Life is then * * initialized using uniform random numbers. With 10% (second arg) * * white points. World will be written to buffer in first argument */ evo.initEvolution(buff1->getDeviceBuffer().getDataBox(), 0.1); }
CmWSHandleRFC6455Test() { m_mask_key[0] = 0x37; m_mask_key[1] = 0xfa; m_mask_key[2] = 0x21; m_mask_key[3] = 0x3d; m_pMaskData1 = Mask(SZ_DATA_TEST1, SZ_DATA_TEST1_LEN); m_pMaskData2 = Mask(SZ_DATA_TEST2, SZ_DATA_TEST2_LEN); m_pMaskData3 = Mask(SZ_DATA_TEST3, SZ_DATA_TEST3_LEN); }
Bool fakeScreenInitialize(KdScreenInfo * screen, FakeScrPriv * scrpriv) { if (!screen->width || !screen->height) { screen->width = 1024; screen->height = 768; screen->rate = 72; } if (screen->width <= 0) screen->width = 1; if (screen->height <= 0) screen->height = 1; if (!screen->fb.depth) screen->fb.depth = 16; if (screen->fb.depth <= 8) { screen->fb.visuals = ((1 << StaticGray) | (1 << GrayScale) | (1 << StaticColor) | (1 << PseudoColor) | (1 << TrueColor) | (1 << DirectColor)); } else { screen->fb.visuals = (1 << TrueColor); #define Mask(o,l) (((1 << l) - 1) << o) if (screen->fb.depth <= 15) { screen->fb.depth = 15; screen->fb.bitsPerPixel = 16; screen->fb.redMask = Mask (10, 5); screen->fb.greenMask = Mask (5, 5); screen->fb.blueMask = Mask (0, 5); } else if (screen->fb.depth <= 16) { screen->fb.depth = 16; screen->fb.bitsPerPixel = 16; screen->fb.redMask = Mask (11, 5); screen->fb.greenMask = Mask (5, 6); screen->fb.blueMask = Mask (0, 5); } else { screen->fb.depth = 24; screen->fb.bitsPerPixel = 32; screen->fb.redMask = Mask (16, 8); screen->fb.greenMask = Mask (8, 8); screen->fb.blueMask = Mask (0, 8); } } scrpriv->randr = screen->randr; return fakeMapFramebuffer(screen); }
MatrixXd lidarBoostEngine::check_unreliable_samples(MatrixXd map, double thresh) { MatrixXd Mask( beta*n, beta*m ); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { if(map(i, j) > thresh) Mask(beta*i, beta*j) = 1; } } return Mask; }
int read_sequences(Auto_Unzip & input, int num_seq, Mask sequences[], Fasta::FASTQ_encoding format_type, bool gui_output) { if (&input == NULL) return 0; Fasta read; read.set_FASTQ_type(format_type); int n_seq = 0; { mutex::scoped_lock lock(read_mutex); istream & in = input.filtered(); while (not input.eof() and n_seq < num_seq) { in >> read; if (read.length() > MAX_READ_LENGTH) { cerr << "Read " << read.get_id() << " too long. Max allowed read size is " << MAX_READ_LENGTH << endl; exit(5); } //Reset and take a ref Mask & r = sequences[n_seq] = Mask(); r.set_id(read.get_id()); r.set_sequence(read.get_sequence()); r.set_quality(read.get_quality()); n_seq++; } output_progress(input, gui_output); } return n_seq; }
void OutConnValidator::OnOutput() { m_ts.Update(); assert(m_buf.Size() > 0); int wn = m_stream_sock.Send(m_buf.Data(),m_buf.Size()); if(wn > 0) { m_buf.Erase(wn); if(m_buf.Size() == 0) { Mask(NetSpace::INPUT_MASK|NetSpace::TIMER_MASK); } }else if(wn == -1 && NetGetLastError() == EWOULDBLOCK) { //等待下一次可写 }else { //失败 DEBUG_PRINT0("OutConnValidator::OnOutput() failed\n"); MsgSpace::PostMessageEx(m_task_id, new NetConnectPeerFailed(m_peer_entry)); GetSelector()->RemoveHandler(this); } }
void WinEDA_ModuleEditFrame::Export_Module(MODULE* ptmod, bool createlib) /************************************************************************/ /* Genere 1 fichier type Empreinte a partir de la description du module sur PCB */ { wxString FullFileName, Mask( wxT("*") ); char Line[1025]; FILE * dest; wxString msg, path; if ( ptmod == NULL ) return; ptmod->m_LibRef = ptmod->m_Reference->m_Text; FullFileName = ptmod->m_LibRef; FullFileName += createlib ? LibExtBuffer : EXT_CMP; Mask += createlib ? LibExtBuffer : EXT_CMP; if ( createlib ) path = g_RealLibDirBuffer; FullFileName = EDA_FileSelector( createlib ? _("Create lib") : _("Export Module:"), path, /* Chemin par defaut */ FullFileName, /* nom fichier par defaut */ createlib ? LibExtBuffer : EXT_CMP, /* extension par defaut */ Mask, /* Masque d'affichage */ this, wxSAVE, TRUE ); if ( FullFileName.IsEmpty() ) return; if ( createlib && wxFileExists(FullFileName) ) { msg.Printf( _("File %s exists, OK to replace ?"), FullFileName.GetData()); if( ! IsOK(this, msg) ) return; } /* Generation du fichier Empreinte */ if ( (dest = wxFopen(FullFileName, wxT("wt")) ) == NULL ) { msg.Printf( _("Unable to create <%s>"),FullFileName.GetData()) ; DisplayError(this, msg) ; return ; } fprintf(dest,"%s %s\n", ENTETE_LIBRAIRIE, DateAndTime(Line)); fputs("$INDEX\n",dest); fprintf(dest,"%s\n", CONV_TO_UTF8(ptmod->m_LibRef) ); fputs("$EndINDEX\n",dest); m_Pcb->m_Modules->WriteDescr(dest); fputs("$EndLIBRARY\n",dest); fclose(dest) ; msg.Printf( _("Module exported in file <%s>"),FullFileName.GetData()) ; DisplayInfo(this, msg) ; }
void ini_matrix(imageptr *iptr, int nx, int ny) { int ix,iy; printf ("iptr @ %d (sizeof = %d)\n",*iptr,sizeof(image)); if (*iptr==0) { *iptr = (imageptr ) allocate((sizeof(image))); printf ("allocated image 'iptr' @ %d\n",*iptr); Frame(*iptr) = (real *) allocate (nx*ny*sizeof(real)); printf ("Allocated frame @ %d\n",Frame(*iptr)); } else { printf ("Image already allocated @ %d\n",*iptr); printf ("with Frame @ %d\n",Frame(*iptr)); } Nx(*iptr) = nx; Ny(*iptr) = ny; Nz(*iptr) = 1; Xmin(*iptr) = 1.0; Ymin(*iptr) = 2.0; Zmin(*iptr) = 3.0; Dx(*iptr) = 0.1; Dy(*iptr) = 0.1; Dz(*iptr) = 0.1; Namex(*iptr) = NULL; /* no axis names */ Namey(*iptr) = NULL; Namez(*iptr) = NULL; Unit(*iptr) = NULL; /* no units */ Mask(*iptr) = NULL; set_iarray(*iptr); for (ix=0; ix<nx; ix++) for (iy=0; iy<ny; iy++) MapValue(*iptr,ix,iy) = (ix*ny+iy)*0.1; }
STDMETHODIMP CPDObjectSymbolInstance::Render2(/*[in]*/ DWORD dwBitmap, DWORD dwGraphics, double scaleX, double scaleY) { Gdiplus::Graphics& graphics = *(Gdiplus::Graphics*)dwGraphics; // Gdiplus::Graphics* pGraphics = (Gdiplus::Graphics*)dwGraphics; Gdiplus::Bitmap* pBitmap = (Gdiplus::Bitmap*)dwBitmap; // Gdiplus::Graphics graphics(pBitmap); graphics.SetSmoothingMode(Gdiplus::SmoothingModeHighQuality/*pGraphics->GetSmoothingMode()*/); // graphics.ScaleTransform(scaleX, scaleY/*, Gdiplus::MatrixOrderAppend*/); // graphics.TranslateTransform(-m_filterRect.X, -m_filterRect.Y); if (m_symbol) { CComPtr<IPDObject> symbolObject; m_symbol->get_symbolObject(&symbolObject); CPDObject* pObject = (CPDObject*)static_cast<CPDObjectImpl<IPDObject>*>(symbolObject.p); // Gdiplus::Matrix oldmat; // pGraphics->GetTransform(&oldmat); // pGraphics->ScaleTransform(scaleX, scaleY, Gdiplus::MatrixOrderAppend); graphics.TranslateTransform(m_x, m_y); pObject->Render(NULL, &graphics, scaleX, scaleY); Mask(pBitmap, m_filterRect, scaleX, scaleY, Gdiplus::SmoothingModeHighQuality); // pGraphics->SetTransform(&oldmat); } return S_OK; }
void Serializer::check(SerializedScene& output, SceneGraph const& scene_graph, std::string const& render_mask, bool draw_bounding_boxes, bool draw_rays, bool enable_frustum_culling) { data_ = &output; std::size_t geometry_count = data_->geometrynodes_.size(); std::size_t volume_count = data_->volumenodes_.size(); std::size_t point_light_count = data_->point_lights_.size(); std::size_t spot_light_count = data_->spot_lights_.size(); std::size_t sun_light_count = data_->sun_lights_.size(); std::size_t ray_count = data_->rays_.size(); std::size_t textured_quad_count = data_->textured_quads_.size(); data_->geometrynodes_.clear(); data_->volumenodes_.clear(); data_->point_lights_.clear(); data_->spot_lights_.clear(); data_->sun_lights_.clear(); data_->textured_quads_.clear(); data_->bounding_boxes_.clear(); data_->rays_.clear(); draw_bounding_boxes_ = draw_bounding_boxes; draw_rays_ = draw_rays; if (draw_bounding_boxes_) { data_->materials_.insert("gua_bounding_box"); data_->bounding_boxes_.reserve(geometry_count + point_light_count + spot_light_count + ray_count); } if (draw_rays_) { data_->materials_.insert("gua_bounding_box"); data_->rays_.reserve(ray_count); } data_->materials_.insert("gua_textured_quad"); // assuming the number of nodes stays quite constant through time, // reserving the old size might save some time data_->volumenodes_.reserve(volume_count); data_->point_lights_.reserve(point_light_count); data_->spot_lights_.reserve(spot_light_count); data_->sun_lights_.reserve(sun_light_count); data_->textured_quads_.reserve(textured_quad_count); enable_frustum_culling_ = enable_frustum_culling; current_render_mask_ = Mask(render_mask); current_frustum_ = output.frustum; current_center_of_interest_ = output.center_of_interest; scene_graph.accept(*this); }
/** * Construct a masked value from given base value. The generated * mask ignores all bit from the specified position to LSB. * * @param base Base value to use for the mask * @param pos Bit position from where to start ignoring (position of LSB is 0) * @return the masked value */ static Mask createMask(uint16_t base, int pos) { uint16_t m = 0xffff; if (pos >= 0) { m = m << (pos+1); } return Mask(base & m, m); }
MaskSequence::MaskSequence(uint size_x, uint size_y, uint size_t, bool default_value) { _frames.reserve(size_t); for (uint i = 0; i < size_t; i++) { _frames.push_back(Mask(size_x, size_y, default_value)); } }
MaskSequence::MaskSequence(uint size_x, uint size_y, uint size_t) { _frames.reserve(size_t); for (uint i = 0; i < size_t; i++) { _frames.push_back(Mask(size_x, size_y)); } }
MaskSequence::MaskSequence(Shape size) : _size(size.size_x, size.size_y, size.size_t) { _frames.reserve(size.size_t); for (uint i = 0; i < size.size_t; i++) { _frames.push_back(Mask(size)); } }
/*virtual*/ void Value::CopyFrom(const Value& source) { // TODO: Check if this is a derived type and throw an exception in that case Data()->CopyFrom(*source.Data()); if ((Mask() == nullptr) && (source.Mask() != nullptr)) InvalidArgument("Value::CopyFrom: Invalid source object; Cannot copy a Value with a mask into 'this' Value that does not have a mask."); if (source.Mask() != nullptr) Mask()->CopyFrom(*source.Mask()); else { if (Mask() != nullptr) { // Clear the mask Mask()->Clear(); } } }
void opencv::get_mask_image(const Mat& src, Mat& dst, vector<vector<Point>>& contours, int ID, int method, int thickness) { if (src.empty()) return; const size_t widthStep = src.step; const size_t height = src.rows; uchar *sdata = src.data; if (0 == method) { Mat Mask(src.rows,src.cols, src.type(), Scalar(0,0,0)); uchar *ddata = Mask.data; drawContours(Mask, contours, ID/*获得的轮廓序号*/, Scalar(255, 255, 255), thickness); for (int h = 0; h < height; h++) { for (int w = 0; w < widthStep; w++) { ddata[w] &= sdata[w]; } sdata += widthStep; ddata += widthStep; } dst = Mask.clone(); } else { Mat Mask(src.rows, src.cols, src.type(), Scalar(255, 255, 255)); uchar *ddata = Mask.data; drawContours(Mask, contours, ID/*获得的轮廓序号*/, Scalar(0, 0, 0), thickness); for (int h = 0; h < height; h++) { for (int w = 0; w < widthStep; w++) { ddata[w] |= sdata[w]; } sdata += widthStep; ddata += widthStep; } dst = Mask.clone(); } }
int main () { // Test variable declarations of A++ objects Index_Pointer_Array_MAX_ARRAY_DIMENSION_Type Internal_Index_List_1; intArray Mask ( Internal_Index_List_1 ); #if 1 intArray X(10); Index I = Index( *(Internal_Index_List_1[0]) ); // Use the variable to make sure we have the name unparsed correctly // Mask(I) = 0; Mask(I) = X(I); #else // Use the variable to make sure we have the name unparsed correctly Mask = 0; #endif return 0; }
int DirToArray(const CKBehaviorContext& behcontext) { CKBehavior* beh = behcontext.Behavior; CKContext* ctx = behcontext.Context; XString filename((CKSTRING) beh->GetInputParameterReadDataPtr(0)); XString Mask((CKSTRING) beh->GetInputParameterReadDataPtr(1)); int rec; beh->GetInputParameterValue(2,&rec); if( beh->IsInputActive(0) ){ beh->ActivateInput(0,FALSE); flist.erase(flist.begin(),flist.end()); CKDirectoryParser MyParser(filename.Str(),Mask.Str(),rec); char* str = NULL; while(str = MyParser.GetNextFile()) flist.push_back(XString(str)); counter = 0; beh->ActivateInput(1,TRUE); } if( beh->IsInputActive(1) ){ beh->ActivateInput(1,FALSE); if ( counter < flist.size() ){ XString entry = flist.at(counter); CKParameterOut * pout = beh->GetOutputParameter(0); pout->SetStringValue(entry.Str() ); counter++; beh->SetOutputParameterValue(1,&counter); beh->ActivateOutput(1); }else{ beh->SetOutputParameterValue(1,&counter); counter = 0 ; beh->ActivateOutput(0); } } return 0; }
void ElPoly::IsoLine(int NSample,double *IsoLevel,int NIso,int How){ int NPairF = 1;//NFile[1]-NFile[0]; double OldPos[3] = {pNanoPos(0,0),pNanoPos(0,1),pNanoPos(0,2)}; double DensEl = SQR(NSample)/(pVol()*NPairF); double Dens = 13.3; //IsoLevel *= NPairF; for(int ff=NFile[0];ff<NFile[1];ff+=NPairF){ double *Plot = (double *)calloc(SQR(NSample),sizeof(double)); double Min = 0.; double Max = 0.; double Pos[3]; for(int f=ff;f<ff+NPairF&&f<NFile[1];f++){ Processing(f); if(OpenRisk(cFile[f],BF_PART))return; for(int b=0;b<pNBlock();b++){ for(int p=Block[b].InitIdx;p<Block[b].EndIdx;p++){ if(pType(p) != 0)continue; for(int d=0;d<3;d++){ Pos[d] = pPos(p,d) - (pNanoPos(0,d)-.5*pEdge(d)); Pos[d] -= floor(Pos[d]*pInvEdge(d))*pEdge(d); } int sx = (int)(Pos[CLat1]*pInvEdge(CLat1)*NSample); int sy = (int)(Pos[CLat2]*pInvEdge(CLat2)*NSample); int sTot = sx*NSample+sy; if(How==0)//particle file Plot[sTot] += DensEl; else Plot[sTot] += pPos(p,CNorm); if(Max < Plot[sTot]) Max = Plot[sTot]; if(Min > Plot[sTot]) Min = Plot[sTot]; } } printf("Min %lf Max %lf DensEl %lf\n",Min,Max,DensEl); } Matrice Mask(5,5); Mask.FillGaussian(.5,3.); Mask.Print(); int NDim = 2; int IfMinImConv = 1; Mask.ConvoluteMatrix(Plot,NSample,NDim,IfMinImConv); Mask.ConvoluteMatrix(Plot,NSample,NDim,IfMinImConv); char FString[60]; sprintf(FString,"IsoSurf%05d.dat",ff); FILE *F2Write = fopen(FString,"w"); fprintf(F2Write,"#l(%lf %lf %lf) v[%d] d[part]\n",pEdge(0),pEdge(1),pEdge(2),NSample); HeaderNano(F2Write); IsoLine(F2Write,Plot,NSample,IsoLevel,NIso); free(Plot); fclose(F2Write); } }
//This sets a collisionMask as the collision object collisionObject::collisionObject(string fileName, Vec3f startingOffset, float startingSpeed, float xScale, float zScale, Vec3f AutoScale) { theMask = Mask(fileName, startingOffset, xScale, zScale, AutoScale); dirVec = Vec3f(); speed = startingSpeed; //mask collision objects are always located at 0,0. Instead, we apply an offset to them. position = Vec3f(0.0f,0.0f,0.0f); collisionType = 3; updatePos = false; }
InConnValidator::InConnValidator(ResourceManager &res_manager,NetSpace::NetHandle net_hdl) : m_stream_sock(net_hdl) , m_res_manager(res_manager) , m_task_id(0) { assert(m_stream_sock.IsValid()); NetSpace::InetAddress addr; m_stream_sock.GetRemoteAddr(addr); m_peer_entry.addr = addr.IP(); m_peer_entry.port = addr.Port(); Mask(NetSpace::INPUT_MASK|NetSpace::TIMER_MASK); }
TEST_F(CmWSHandleRFC6455Test, Decode127TestMask) { char* pBuf = new char[565633]; memset(pBuf, 'f', 565633); pBuf[565632] = '\0'; UINT8 uFirstByte = 0x81; UINT8 uSecondByte = 0xff; DWORD dwSize = 565632; char* pMask = Mask(pBuf, dwSize); CCmMessageBlock aHead(14); CCmMessageBlock aData(dwSize); aData.Write(pBuf, dwSize); CCmMessageBlock aDataMask(dwSize); aDataMask.Write(pMask, dwSize); unsigned long long uDataLen = aDataMask.GetChainedLength(); CCmByteStreamNetwork networkStream(aHead); networkStream << uFirstByte; networkStream << uSecondByte; networkStream << uDataLen; networkStream << m_mask_key[0]; networkStream << m_mask_key[1]; networkStream << m_mask_key[2]; networkStream << m_mask_key[3]; aHead.Append(&aDataMask); CCmMessageBlock* aDataOut = NULL; m_RFC6455.SetDataType(E_WS_DTYPE_TEXT); EXPECT_EQ(CM_OK, m_RFC6455.Decode(aHead, aDataOut)); EXPECT_TRUE(IsMessageEqual(aData, *aDataOut)); delete [] pMask; pMask = NULL; delete [] pBuf; pBuf = NULL; ASSERT_TRUE(NULL != aDataOut); aDataOut->DestroyChained(); }
static int filtro_gestos_make_up(lua_State *L) { dato_t *in = (filtro_gestos_in_imagen_t *)lua_touserdata(L, 1); color_t *salida = (color_t *)malloc(sizeof(color_t) *in->m_ancho*in->m_alto*in->m_bytes); int i,j; for(i=0;i<in->m_alto;i++) { for(j=0;j<in->m_ancho;j++){ salida[(i*in->m_ancho*in->m_bytes)+(j*in->m_bytes)]= salida[(i*in->m_ancho*in->m_bytes)+(j*in->m_bytes)+1]= salida[(i*in->m_ancho*in->m_bytes)+(j*in->m_bytes)+2]=Mask(in,i,j); } } free(in->m_imagen); in->m_imagen=salida; return 0; }
status_t FFont::Flatten(void *buffer, ssize_t size) const { if( size < sizeof(flat_font_data) ) return B_BAD_VALUE; // Easy reference to the buffer. flat_font_data* fdat = (flat_font_data*)buffer; memset(fdat,0,sizeof(*fdat)); // Stash away name of family and style. GetFamilyAndStyle(&fdat->family,&fdat->style); // This is used as a temporary when byte-swapping floats. // Note that we are assuming a float is 4 bytes. union { uint32 aslong; float asfloat; } swap; // Byte-swap size, shear, and rotation into the flattened // structure. This is written for clarity more than speed, // since the additional overhead will be entirely subsumed // by everything else going on. swap.asfloat = Size(); swap.aslong = htonl(swap.aslong); fdat->size = swap.asfloat; swap.asfloat = Shear(); swap.aslong = htonl(swap.aslong); fdat->shear = swap.asfloat; swap.asfloat = Rotation(); swap.aslong = htonl(swap.aslong); fdat->rotation = swap.asfloat; // Byte-swap the remaining data into the flattened structure. fdat->flags = htonl(Flags()); fdat->face = htons(Face()); fdat->spacing = Spacing(); fdat->encoding = Encoding(); fdat->mask = htonl(Mask()); return B_NO_ERROR; }
/* * CREATE_CUBE: create a blank cube Nx by Ny by Nz in size */ int create_cube (imageptr *iptr, int nx, int ny, int nz) { *iptr = (imageptr ) allocate(sizeof(image)); dprintf (DLEV,"CREATE_CUBE: Allocated image @ cube %d size=%d * %d * %d", *iptr,nx,ny,nz); if (*iptr == NULL) return 0; /* no memory available */ Frame(*iptr) = (real *) allocate(nx*ny*nz*sizeof(real)); dprintf (DLEV,"Frame allocated @ %d ",Frame(*iptr)); Nx(*iptr) = nx; /* cube dimension */ Ny(*iptr) = ny; Nz(*iptr) = nz; Xmin(*iptr) = 0.0; /* start lower left corner at 0.0 */ Ymin(*iptr) = 0.0; Zmin(*iptr) = 0.0; Xref(*iptr) = 0.0; Yref(*iptr) = 0.0; Zref(*iptr) = 0.0; Dx(*iptr) = 1.0; /* unity pixels */ Dy(*iptr) = 1.0; Dz(*iptr) = 1.0; MapMin(*iptr) = 0.0; MapMax(*iptr) = 0.0; BeamType(*iptr) = 0; Beamx(*iptr) = 0.0; /* name beams */ Beamy(*iptr) = 0.0; Beamz(*iptr) = 0.0; Namex(*iptr) = NULL; /* no axis names yet */ Namey(*iptr) = NULL; Namez(*iptr) = NULL; Unit(*iptr) = NULL; /* no units */ Time(*iptr) = 0.0; Storage(*iptr) = matdef[idef]; Axis(*iptr) = 0; Mask(*iptr) = NULL; set_iarray(*iptr); return 1; /* succes return code */ }
// Action_Vector::DoAction() Action::RetType Action_Vector::DoAction(int frameNum, Frame* currentFrame, Frame** frameAddress) { switch ( mode_ ) { case MASK : Mask(*currentFrame); break; case CENTER : Vec_->AddVxyz( currentFrame->VCenterOfMass(mask_) ); break; case DIPOLE : Dipole(*currentFrame); break; case PRINCIPAL_X : case PRINCIPAL_Y : case PRINCIPAL_Z : Principal(*currentFrame); break; case CORRPLANE : CorrPlane(*currentFrame); break; case BOX : Vec_->AddVxyz( currentFrame->BoxCrd().Lengths() ); break; case BOX_X : case BOX_Y : case BOX_Z : case BOX_CTR : UnitCell( currentFrame->BoxCrd() ); break; case MINIMAGE : MinImage( *currentFrame ); break; default : return Action::ERR; // NO_OP } // END switch over vectorMode if (Magnitude_ != 0) { float mag = (float)(sqrt(Vec_->Back().Magnitude2())); Magnitude_->Add(frameNum, &mag); } return Action::OK; }
OutConnValidator::OutConnValidator(NetSpace::NetHandle net_hdl,const PeerEntry &peer_entry, const TaskID &task_id, const Sha1Hash &info_hash, const PeerID &peer_id) : m_stream_sock(net_hdl) , m_task_id(task_id) , m_infohash(info_hash) , m_peer_id(peer_id) , m_peer_entry(peer_entry) { assert(m_stream_sock.IsValid()); assert(m_task_id != INVALID_TASK_ID); /*NetSpace::InetAddress addr; m_stream_sock.GetRemoteAddr(addr); m_peer_entry = PeerEntry(addr.IP(), addr.Port());*/ Mask(NetSpace::OUTPUT_MASK|NetSpace::TIMER_MASK); m_buf.Insert(&build_hand_shake(m_infohash, m_peer_id)[0], 68); assert(m_buf.Size() == 68); }
void InConnValidator::OnInput() { m_ts.Update(); t_byte buf[68]; int read_len = 68 - m_buf.Size(); assert(read_len <= 68); int rn = m_stream_sock.Recv(buf, read_len); if(rn > 0) { m_buf.Insert(buf, rn); assert(m_buf.Size() <= 68); if(m_buf.Size() == 68) { if(!check_connection_handshake()) { //DEBUG_PRINT0("check_connection_handshake failed\n"); GetSelector()->RemoveHandler(this); return; }else { assert(m_buf.Size() == 68); Mask(NetSpace::OUTPUT_MASK|NetSpace::TIMER_MASK); } } }else if(rn == -1 && NetGetLastError() == EWOULDBLOCK) { //等待下次; }else { DEBUG_PRINT0("accepted peer connection abort\n"); GetSelector()->RemoveHandler(this); } }
int create_image (imageptr *iptr, int nx, int ny) { *iptr = (imageptr ) allocate(sizeof(image)); dprintf (DLEV,"create_image:Allocated image @ %d size=%d * %d",*iptr,nx,ny); Frame(*iptr) = (real *) allocate(nx*ny*sizeof(real)); dprintf (DLEV,"Frame allocated @ %d ",Frame(*iptr)); Axis(*iptr) = 0; /* old style axis with no reference pixel */ Nx(*iptr) = nx; /* old style ONE map, no cube */ Ny(*iptr) = ny; Nz(*iptr) = 1; Xmin(*iptr) = 0.0; /* start lower left corner at 0.0 */ Ymin(*iptr) = 0.0; Zmin(*iptr) = 0.0; Dx(*iptr) = 1.0; /* unity pixels */ Dy(*iptr) = 1.0; Dz(*iptr) = 1.0; Xref(*iptr) = 0.0; Yref(*iptr) = 0.0; Zref(*iptr) = 0.0; MapMin(*iptr) = 0.0; MapMax(*iptr) = 0.0; BeamType(*iptr) = 0; Beamx(*iptr) = 0.0; /* name beams */ Beamy(*iptr) = 0.0; Beamz(*iptr) = 0.0; Namex(*iptr) = NULL; /* no axis names */ Namey(*iptr) = NULL; Namez(*iptr) = NULL; Unit(*iptr) = NULL; /* no units */ Time(*iptr) = 0.0; Storage(*iptr) = matdef[idef]; Axis(*iptr) = 0; Mask(*iptr) = NULL; set_iarray((*iptr)); return 1; /* succes return code */ }