FP_LIB_TABLE* PROJECT::PcbFootprintLibs() { // This is a lazy loading function, it loads the project specific table when // that table is asked for, not before. FP_LIB_TABLE* tbl = (FP_LIB_TABLE*) GetElem( ELEM_FPTBL ); // its gotta be NULL or a FP_LIB_TABLE, or a bug. wxASSERT( !tbl || dynamic_cast<FP_LIB_TABLE*>( tbl ) ); if( !tbl ) { // Stack the project specific FP_LIB_TABLE overlay on top of the global table. // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may // stack this way, all using the same global fallback table. tbl = new FP_LIB_TABLE( &GFootprintTable ); SetElem( ELEM_FPTBL, tbl ); wxString projectFpLibTableFileName = FootprintLibTblName(); try { tbl->Load( projectFpLibTableFileName ); } catch( const IO_ERROR& ioe ) { DisplayError( NULL, ioe.errorText ); } } return tbl; }
void PROJECT::ElemsClear() { // careful here, this should work, but the virtual destructor may not // be in the same link image as PROJECT. for( unsigned i = 0; i < DIM( m_elems ); ++i ) { SetElem( ELEM_T( i ), NULL ); } }
SEARCH_STACK* PROJECT::SchSearchS() { SEARCH_STACK* ss = (SEARCH_STACK*) GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ); wxASSERT( !ss || dynamic_cast<SEARCH_STACK*>( GetElem( PROJECT::ELEM_SCH_SEARCH_STACK ) ) ); if( !ss ) { ss = new SEARCH_STACK(); // Make PROJECT the new SEARCH_STACK owner. SetElem( PROJECT::ELEM_SCH_SEARCH_STACK, ss ); // to the empty SEARCH_STACK for SchSearchS(), add project dir as first ss->AddPaths( m_project_name.GetPath() ); // next add the paths found in *.pro, variable "LibDir" wxString libDir; try { PART_LIBS::LibNamesAndPaths( this, false, &libDir ); } catch( const IO_ERROR& DBG( ioe ) ) { DBG(printf( "%s: %s\n", __func__, TO_UTF8( ioe.What() ) );) } if( !!libDir ) { wxArrayString paths; SEARCH_STACK::Split( &paths, libDir ); for( unsigned i =0; i<paths.GetCount(); ++i ) { wxString path = AbsolutePath( paths[i] ); ss->AddPaths( path ); // at the end } } // append all paths from aSList add_search_paths( ss, Kiface().KifaceSearch(), -1 ); // addLibrarySearchPaths( SEARCH_STACK* aSP, wxConfigBase* aCfg ) // This is undocumented, but somebody wanted to store !schematic! // library search paths in the .kicad_common file? add_search_paths( ss, Pgm().CommonSettings(), -1 ); }
int main() { LNode* list = 0; InitLkList(list); InsertList(list,1, 30.0); InsertList(list, 1, 40.0); InsertList(list, 1, 50.0); InsertList(list, 1, 60.0); OutList(list); DeleteList(list,2); OutList(list); SetElem(list, 2, 78.56); OutList(list); return 0; }
/* * @description:求解迷宫路径 */ Status MazePath(MazeType maze,SqStack *S,PosType start,PosType end) { PosType curpos; int curstep; SElemType elem; InitStack(S); curpos = start; curstep = 1; do { if(Pass(&maze,curpos)) { FootPrint(&maze,curpos); elem = SetElem(curpos,curstep,1); Push(S,elem); if(curpos.x == end.x && curpos.y == end.y ) return TRUE; curpos = NextPos(curpos,1); curstep++; } else { if(!StackEmpty(*S)) { Pop(S,&elem); //这种情况是:东南西已经 while(elem.di == 4 && !StackEmpty(*S)) { MarkPrint(&maze,elem.seat); //此路不通,做标记 Pop(S,&elem); } if(elem.di < 4) { //按东南西北的方向调整探测 elem.di++; Push(S,elem); curpos = NextPos(elem.seat,elem.di); } } } }while(!StackEmpty(*S)); return FALSE; }
FP_LIB_TABLE* PROJECT::PcbFootprintLibs( KIWAY& aKiway ) { // This is a lazy loading function, it loads the project specific table when // that table is asked for, not before. FP_LIB_TABLE* tbl = (FP_LIB_TABLE*) GetElem( ELEM_FPTBL ); // its gotta be NULL or a FP_LIB_TABLE, or a bug. wxASSERT( !tbl || dynamic_cast<FP_LIB_TABLE*>( tbl ) ); if( !tbl ) { // Build a new project specific FP_LIB_TABLE with the global table as a fallback. // ~FP_LIB_TABLE() will not touch the fallback table, so multiple projects may // stack this way, all using the same global fallback table. KIFACE* kiface = aKiway.KiFACE( KIWAY::FACE_PCB ); if( kiface ) tbl = (FP_LIB_TABLE*) kiface->IfaceOrAddress( KIFACE_NEW_FOOTPRINT_TABLE ); wxASSERT( tbl ); SetElem( ELEM_FPTBL, tbl ); wxString projectFpLibTableFileName = FootprintLibTblName(); try { tbl->Load( projectFpLibTableFileName ); } catch( const IO_ERROR& ioe ) { DisplayErrorMessage( NULL, _( "Error loading project footprint library table" ), ioe.What() ); } } return tbl; }
void Insert(T slope, T intercept) { auto p = data.insert(SetElem(slope, intercept)); if (!p.second) return; auto it = p.first; if (it != data.begin()) prev(it)->next = &(*it); if (next(it) != data.end()) it->next = &(*next(it)); if (is_bad(it)) erase(it); else { while (it != data.begin()) { auto prv = prev(it); if (is_bad(prv)) { erase(prv); } else break; } while (next(it) != data.end()) { auto nxt = next(it); if (is_bad(nxt)) { erase(nxt); } else break; } } }
void PfDataReadFile (PF_CALC_CB* pfcb, const char* fileName, ePfDataStructType datatructType) { FILE* fp; fp=fopen(fileName,"rb"); if(fp==NULL) return; switch(datatructType) { case ePfDataStructTypeLBCTest: { #if 0 char sf[20]; int i,j,nbr; PF_CALC_DATA_TYPE data; /*读PQ、PV、BL节点数*/ fscanf(fp,"%s",sf); if(strcmp(sf,"NODE_NBR")==0) { fscanf(fp,"%d %d %d",&(pfcb->pqNodeNbr),&(pfcb->pvNodeNbr),&(pfcb->blNodeNbr)); } nbr=pfcb->blNodeNbr+pfcb->pqNodeNbr+pfcb->pvNodeNbr; /*读最大迭代次数和迭代精度*/ fscanf(fp,"%s",sf); if(strcmp(sf,"ITER_CTRL")==0) { fscanf(fp,"%d %lf",&(pfcb->maxIterTimes),&(pfcb->precision)); } /*读电导矩阵*/ fscanf(fp,"%s",sf); if(strcmp(sf,"G")==0) { for(i=0;i<nbr;i++) for(j=0;j<nbr;j++) { fscanf(fp,"%lf",&data); if(abs(data)>pfcb->precision) SetElem(pfcb->Gij,data,i,j); } } /*读电纳矩阵*/ fscanf(fp,"%s",sf); if(strcmp(sf,"B")==0) { for(i=0;i<nbr;i++) for(j=0;j<nbr;j++) { fscanf(fp,"%lf",&data); if(abs(data)>pfcb->precision) SetElem(pfcb->Bij,data,i,j); } } /*读有功给定*/ fscanf(fp,"%s",sf); if(strcmp(sf,"P_SET")==0) { for(i=0;i<nbr;i++) { fscanf(fp,"%lf",&(pfcb->PiSET[i])); } } /*读无功给定*/ fscanf(fp,"%s",sf); if(strcmp(sf,"Q_SET")==0) { for(i=0;i<nbr;i++) { fscanf(fp,"%lf",&(pfcb->QiSET[i])); } } /*读电压给定*/ fscanf(fp,"%s",sf); if(strcmp(sf,"U2_SET")==0) { for(i=0;i<pfcb->pvNodeNbr;i++) { fscanf(fp,"%lf",&(pfcb->U2iSET[i])); } } /*读迭代初始值:电压实部*/ fscanf(fp,"%s",sf); if(strcmp(sf,"e_INIT")==0) { for(i=0;i<nbr;i++) { fscanf(fp,"%lf",&(pfcb->ei[i])); } } /*读迭代初始值:电压实部*/ fscanf(fp,"%s",sf); if(strcmp(sf,"f_INIT")==0) { for(i=0;i<nbr;i++) { fscanf(fp,"%lf",&(pfcb->fi[i])); } } /*读最大迭代次数和迭代精度*/ fscanf(fp,"%s",sf); if(strcmp(sf,"DATA_CHECK")==0) { fscanf(fp,"%d",&(pfcb->dataCheckFlag)); } #endif break; } case ePfDataStructTypeIEEE: { PF_CALC_CB* pfcb=(PF_CALC_CB*) malloc(sizeof(PF_CALC_CB)); int pqNodeNbr=0, pvNodeNbr=0, blNodeNbr =0; pfcb->pvNodeNbr=pvNodeNbr; pfcb->blNodeNbr=blNodeNbr; pfcb->pqNodeNbr=pqNodeNbr; int pqvNbr =pqNodeNbr+pvNodeNbr; int nbr =pqvNbr+blNodeNbr; int pqvNbrTimes2=pqvNbr*2; pfcb->curIterTime=0; pfcb->dataCheckFlag=0; pfcb->maxIterTimes=maxIterTimes; pfcb->precision=precision; /*allocate all the fields which needs dynamic memory of *pfcb.*/ /* set the .deltaEF[], .deltaPQPU2[], .HNJLRS[][] fields to zero. if don't clear these field before use them, problems will occur.*/ for (int i=0;i<pqvNbrTimes2;i++) { pfcb->deltaEF[i]=0; pfcb->deltaPQPU2[i]=0; for (int j=0;j<pqvNbrTimes2;j++) { pfcb->HNJLRS[i][j]=0; } } /*set the .Bij[][], .Gij[][] fields to zero.*/ /*for (int i=0;i<nbr;i++) { for (int j=0;j<nbr;j++) { SetElem(pfcb->Bij,0,i,j); SetElem(pfcb->Gij,0,i,j); } }*/ /*set the .blNodeTabl[], pqNodeTable[], pvNodeTable[] fields to zero.*/ PF_CALC_NODE_BL blNode; blNode.e=0;blNode.f=0;blNode.index=0;blNode.Pg=0;blNode.Pl=0;blNode.Qg=0;blNode.Ql=0; for (int i=0;i<blNodeNbr;i++) { pfcb->blNodeTable[i]=blNode; } for (int i=0;i<pvNodeNbr;i++) { pfcb->pvNodeTable[i]=pvNode; } /*After read the data file, update the .id.offset field.*/ for(pf_uint32 i=0;i<blNodeNbr) { for(pf_uint32 j=0;j<pqNodeNbr;j++) { if(pfcb->pqNodeTable[j].id.index>pfcb->blNodeTable[i].index) pfcb->pqNodeTable[j].id.offset++; } for(pf_uint32 j=0;j<pvNodeNbr;j++) { if(pfcb->pvNodeTable[j].id.index>pfcb->blNodeTable[i].index) pfcb->pvNodeTable[j].id.offset++; } } PF_CALC_DATA_TYPE r,x,bb,gij,bij,k0; pf_uint32 nodeNbr,branchNbr; pf_uint32 tmp,branchNo=0,nodeNoi=0,nodeNoj=0; PF_CALC_DATA_TYPE baseCapacity; PF_CALC_DATA_TYPE central; pf_uint32 targetFunctionClassCode; PF_CALC_DATA_TYPE ble,blf; pf_uint32 blNodeNo; /*Get the header of IEEE standard file.*/ fscanf(fp,"%d %d %lf %lf %d %lf",&nodeNbr,&branchNbr,&baseCapacity,&pfcb->maxIterTimes,¢ral); /*allocate the memory for pfcb->Gij and Bij.*/ pfcb->Bij =CreateEmptySMatrix(nodeNbr,nodeNbr); pfcb->Gij =CreateEmptySMatrix(nodeNbr,nodeNbr); /*QU: Does an IEEE standard system only include one BL Node?*/ blNodeNbr=1; pfcb->blNodeTable=(PF_CALC_NODE_BL*)malloc(sizeof(PF_CALC_NODE_BL)*(blNodeNbr)); fscanf(fp,"%lf %d",&pfcb->precision,&targetFunctionClassCode); fscanf(fp,"%d %lf",&pfcb->blNodeTable[0].index,&ble); /*The Index of balance Node, 0*/ pfcb->blNodeTable[0].index-=1; /*平衡节点电压数据*/ pfcb->blNodeTable[0].e=ble; /*Done.*/ /*Get the parameters of Lines and Update pfcb->Gij and Bij.*/ fscanf(fp,"%d",&tmp); /*线路参数*/ fscanf(fp,"%d",&branchNo); while(branchNo!=0) { fscanf(fp,"%d %d %lf %lf %lf",&nodeNoi,&nodeNoj,&r,&x,&bb); gij=r/(r*r+x*x); bij=-x/(r*r+x*x); PF_CALC_DATA_TYPE t; #if 0 pfcb->Gij[nodeNoj-1][nodeNoi-1]=-gij; pfcb->Gij[nodeNoi-1][nodeNoj-1]=-gij; pfcb->Bij[nodeNoj-1][nodeNoi-1]=-bij; pfcb->Bij[nodeNoi-1][nodeNoj-1]=-bij; pfcb->Gij[nodeNoi-1][nodeNoi-1]=pfcb->Gij[nodeNoi-1][nodeNoi-1]+gij; pfcb->Bij[nodeNoi-1][nodeNoi-1]=pfcb->Bij[nodeNoi-1][nodeNoi-1]+bij+bb; //因为线路电纳只包含在自电纳中,所以bb加在b[i][i]和b[j][j]里面 pfcb->Gij[nodeNoj-1][nodeNoj-1]=pfcb->Gij[nodeNoj-1][nodeNoj-1]+gij; pfcb->Bij[nodeNoj-1][nodeNoj-1]=pfcb->Bij[nodeNoj-1][nodeNoj-1]+bij+bb; #endif SetElem(pfcb->Gij,-gij,nodeNoj-1,nodeNoi-1); SetElem(pfcb->Gij,-gij,nodeNoi-1,nodeNoj-1); SetElem(pfcb->Bij,-bij,nodeNoj-1,nodeNoi-1); SetElem(pfcb->Bij,-bij,nodeNoi-1,nodeNoj-1); GetElem(pfcb->Gij,nodeNoi-1,nodeNoi-1,&t); SetElem(pfcb->Gij,nodeNoi-1,nodeNoi-1,t+gij); GetElem(pfcb->Gij,nodeNoi-1,nodeNoi-1,&t); SetElem(pfcb->Bij,nodeNoi-1,nodeNoi-1,t+bij+bb); //因为线路电纳只包含在自电纳中,所以bb加在b[i][i]和b[j][j]里面 GetElem(pfcb->Gij,nodeNoj-1,nodeNoj-1,&t); SetElem(pfcb->Gij,nodeNoj-1,nodeNoj-1,t+gij); GetElem(pfcb->Gij,nodeNoj-1,nodeNoj-1,&t); SetElem(pfcb->Bij,nodeNoj-1,nodeNoj-1,t+bij+bb); fscanf(fp,"%d",&branchNo); } /*Done.*/ /*Get the parameters of Grounding Lines and Update pfcb->Gij and Bij.*/ fscanf(fp,"%d",&tmp); /*接地支路参数*/ fscanf(fp,"%d",&branchNo); while(branchNo!=0) { fscanf(fp,",%d %lf %lf",&nodeNoi,&r,&x); PF_CALC_DATA_TYPE t; GetElem(pfcb->Gij,nodeNoi-1,nodeNoi-1,&t); SetElem(pfcb->Gij,nodeNoi-1,nodeNoi-1,t+r); GetElem(pfcb->Bij,nodeNoi-1,nodeNoi-1,&t); SetElem(pfcb->Bij,nodeNoi-1,nodeNoi-1,t+x); fscanf(fp,"%d",&branchNo); } /*Done.*/ /*Get the parameters of Transformer and Grounding Lines and Update pfcb->Gij and Bij.*/ fscanf(fp,"%d",&tmp); /*变压器参数*/ fscanf(fp,"%d",&branchNo); while(branchNo!=0) { PF_CALC_DATA_TYPE t; fscanf(fp,"%d %d %lf %lf %lf",&nodeNoi,&nodeNoj,&r,&x,&k0); gij=r/(r*r+x*x); bij=-x/(r*r+x*x); //归算到j点 SetElem(pfcb->Gij,nodeNoi-1,nodeNoj-1,-gij/k0); SetElem(pfcb->Gij,nodeNoj-1,nodeNoi-1,gij/k0); SetElem(pfcb->Bij,nodeNoi-1,nodeNoj-1,-bij/k0); SetElem(pfcb->Bij,nodeNoj-1,nodeNoi-1,-bij/k0); GetElem(pfcb->Gij,nodeNoi-1,nodeNoi-1,&t); SetElem(pfcb->Gij,nodeNoi-1,nodeNoi-1,t+gij/k0/k0); GetElem(pfcb->Gij,nodeNoi-1,nodeNoi-1,&t); SetElem(pfcb->Gij,nodeNoi-1,nodeNoi-1,t+bij/k0/k0); GetElem(pfcb->Bij,nodeNoj-1,nodeNoj-1,&t); SetElem(pfcb->Bij,nodeNoj-1,nodeNoj-1,t+gij); GetElem(pfcb->Bij,nodeNoj-1,nodeNoj-1,&t); SetElem(pfcb->Bij,nodeNoj-1,nodeNoj-1,t+bij); fscanf(fp,"%d",&branchNo); } /*Done.*/ /*Here we get the Running parameters, or to say PQ Node Parameters from IEEE standard file.*/ PF_CALC_DATA_TYPE Pg,Qg,Pl,Ql; fscanf(fp,"%d",&tmp); /*Running parameters. from these we know PQNode Number.*/ PF_CALC_NODE_PQ pqNode; pqNode.e=0;pqNode.f=0;pqNode.id.index=0;pqNode.id.offset=0;pqNode.P=0;pqNode.Q=0; fscanf(fp,"%d",&nodeNoi); pf_uint32 i_run=0; while(branchNo!=0) { pqNodeNbr++; pfcb->pqNodeTable[i_run]=(PF_CALC_NODE_PQ)(malloc(sizeof(PF_CALC_NODE_PQ))); pfcb->pqNodeTable[i_run]=pqNode; fscanf(fp,"%lf %lf %lf %lf",&Pg,&Qg,&Pl,&Ql); pfcb->pqNodeTable[i_run].P=Pg-Pl; pfcb->pqNodeTable[i_run].Q=Qg-Ql; pfcb->pqNodeTable[i_run].id.index=nodeNoi-1; fscanf(fp,"%d",&nodeNoi); i_run++; } /*Done.*/ /*Get the PV Node parameters.*/ PF_CALC_DATA_TYPE pvQmin,pvQmax; fscanf(fp,"%d",&tmp); PF_CALC_NODE_PV pvNode; pvNode.e=0;pvNode.f=0;pvNode.id.index=0;pvNode.id.offset=0;pvNode.P=0;pvNode.Qg=0;pvNode.Ql=0;pvNode.U2=0; fscanf(fp,"%d",&nodeNoi); pf_uint32 i_run=0; while(branchNo!=0) { pqNodeNbr++; pfcb->pqNodeTable[i_run]=(PF_CALC_NODE_PQ)(malloc(sizeof(PF_CALC_NODE_PQ))); pfcb->pqNodeTable[i_run]=pqNode; fscanf(fp,"%lf %lf %lf %lf",&Pg,&Qg,&Pl,&Ql); pfcb->pqNodeTable[i_run].P=Pg-Pl; pfcb->pqNodeTable[i_run].Q=Qg-Ql; pfcb->pqNodeTable[i_run].id.index=nodeNoi-1; fscanf(fp,"%d",&nodeNoi); i_run++; } /*Done.*/ pfcb->deltaEF=(PF_CALC_DATA_TYPE*)malloc(sizeof(PF_CALC_DATA_TYPE)*(pqvNbrTimes2)); pfcb->deltaPQPU2=(PF_CALC_DATA_TYPE*)malloc(sizeof(PF_CALC_DATA_TYPE)*(pqvNbrTimes2)); for(int i=0;i<pqvNbrTimes2;i++) { pfcb->HNJLRS[i]=(PF_CALC_DATA_TYPE*)malloc(sizeof(PF_CALC_DATA_TYPE)*(pqvNbrTimes2)); } pfcb->pvNodeTable=(PF_CALC_NODE_PV*)malloc(sizeof(PF_CALC_NODE_PV)*(pvNodeNbr)); break; } default:{break;} } fclose(fp); }
void SSEVector3::SetZ( float value ) { SetElem( 2, value ); }
void SSEVector3::SetY( float value ) { SetElem( 1, value ); }
void SSEVector3::SetX( float value ) { SetElem(0, value ); }