Пример #1
0
void SCH_SHEET_PIN::MirrorX( int aXaxis_position )
{
    int p = m_Pos.y - aXaxis_position;

    m_Pos.y = aXaxis_position - p;

    switch( m_edge )
    {
    case 2:
        SetEdge( 3 );
        break;

    case 3:
        SetEdge( 2 );
        break;
    }
}
Пример #2
0
void SCH_SHEET_PIN::ConstrainOnEdge( wxPoint Pos )
{
    SCH_SHEET* Sheet = (SCH_SHEET*) GetParent();

    if( Sheet == NULL )
        return;

    if( m_edge<2 ) /*horizontal sheetpin*/
    {
        if( Pos.x > ( Sheet->m_pos.x + ( Sheet->m_size.x / 2 ) ) )
        {
            SetEdge( 1 );
        }
        else
        {
            SetEdge( 0 );
        }

        m_Pos.y = Pos.y;

        if( m_Pos.y < Sheet->m_pos.y )
            m_Pos.y = Sheet->m_pos.y;

        if( m_Pos.y > (Sheet->m_pos.y + Sheet->m_size.y) )
            m_Pos.y = Sheet->m_pos.y + Sheet->m_size.y;
    }
    else /* vertical sheetpin*/
    {
        if( Pos.y > ( Sheet->m_pos.y + ( Sheet->m_size.y / 2 ) ) )
        {
            SetEdge( 3 ); //bottom
        }
        else
        {
            SetEdge( 2 ); //top
        }

        m_Pos.x = Pos.x;

        if( m_Pos.x < Sheet->m_pos.x )
            m_Pos.x = Sheet->m_pos.x;

        if( m_Pos.x > (Sheet->m_pos.x + Sheet->m_size.x) )
            m_Pos.x = Sheet->m_pos.x + Sheet->m_size.x;
    }
}
Пример #3
0
SCH_SHEET_PIN::SCH_SHEET_PIN( SCH_SHEET* parent, const wxPoint& pos, const wxString& text ) :
    SCH_HIERLABEL( pos, text, SCH_SHEET_PIN_T )
{
    SetParent( parent );
    wxASSERT( parent );
    m_Layer = LAYER_SHEETLABEL;

    SetTextPos( pos );

    if( parent->IsVerticalOrientation() )
        SetEdge( SHEET_TOP_SIDE );
    else
        SetEdge( SHEET_LEFT_SIDE );

    m_shape = NET_INPUT;
    m_isDangling = true;
    m_number     = 2;
}
Пример #4
0
void SCH_SHEET_PIN::MirrorX( int aXaxis_position )
{
    int p = GetTextPos().y - aXaxis_position;

    SetTextY( aXaxis_position - p );

    switch( m_edge )
    {
    case SHEET_TOP_SIDE:
        SetEdge( SHEET_BOTTOM_SIDE );
        break;

    case SHEET_BOTTOM_SIDE:
        SetEdge( SHEET_TOP_SIDE );
        break;

    default:
        break;
    }
}
Пример #5
0
void SCH_SHEET_PIN::MirrorY( int aYaxis_position )
{
    int p = GetTextPos().x - aYaxis_position;

    SetTextX( aYaxis_position - p );

    switch( m_edge )
    {
    case SHEET_LEFT_SIDE:
        SetEdge( SHEET_RIGHT_SIDE );
        break;

    case SHEET_RIGHT_SIDE:
        SetEdge( SHEET_LEFT_SIDE );
        break;

    default:
        break;
    }
}
Пример #6
0
void SCH_SHEET_PIN::Rotate( wxPoint aPosition )
{
    RotatePoint( &m_Pos, aPosition, 900 );

    switch( m_edge )
    {
    case 0:     //pin on left side
        SetEdge( 3 );
        break;

    case 1:     //pin on right side
        SetEdge( 2 );
        break;

    case 2:      //pin on top side
        SetEdge( 0 );
        break;

    case 3:     //pin on bottom side
        SetEdge( 1 );
        break;
    }
}
Пример #7
0
void SCH_SHEET_PIN::SwapData( SCH_ITEM* aItem )
{
    wxCHECK_RET( aItem->Type() == SCH_SHEET_PIN_T,
                 wxString::Format( wxT( "SCH_SHEET_PIN object cannot swap data with %s object." ),
                                   GetChars( aItem->GetClass() ) ) );

    SCH_SHEET_PIN* pin = ( SCH_SHEET_PIN* ) aItem;
    SCH_TEXT::SwapData( (SCH_TEXT*) pin );
    int tmp = pin->GetNumber();
    pin->SetNumber( GetNumber() );
    SetNumber( tmp );
    SHEET_SIDE stmp = pin->GetEdge();
    pin->SetEdge( GetEdge() );
    SetEdge( stmp );
}
Пример #8
0
int main()
{
    int N, E, i, p, j;
    VertexType n1, n2;


    scanf("%d %d", &N, &E);
    MGraph G = CreateMGraph(N, E);
    while (E--)
    {
        scanf("%d %d %d", &n1, &n2, &p);
        SetEdge(G, n1 - 1, n2 - 1, p);
    }

    Floyd(G);
    int min = INFINITY, index = N;
    int flag = 0;
    for (int i = 0;i < G->numNodes; i++)
    {
        int t = 0;
        for (int j = 0; j < G->numNodes; j++)
        {
            if (i != j && D[i][j] == INFINITY)
            {
                flag = 1;
                break;
            }
            if (i != j && D[i][j] > t)
            {
                t = D[i][j];
            }
        }
        if (t < min)
        {
            min = t;
            index = i;
        }
    }
    if (flag)
        printf("0\n");
    else
        printf("%d %d",index + 1,min);

    return 0;
}
void ReadEdge2Graph(Vertex* AdjacencyList, int NumOfVertexes, int NumOfEdges)
{
    int i;
    for (i = 0; i < NumOfVertexes; ++i)
    {
        AdjacencyList[i] = (Vertex)malloc(sizeof(struct VNode));
        AdjacencyList[i]->ID = i;
        AdjacencyList[i]->WeightOfDistance = AdjacencyList[i]->WeightOfPrice = 0;
        AdjacencyList[i]->Next = NULL;
    }
    for (i = 0; i < NumOfEdges; ++i)
    {
        int VertexID1, VertexID2;
        int WeightOfDistance, WeightOfPrice;
        scanf("%d %d %d %d", &VertexID1, &VertexID2, &WeightOfDistance, &WeightOfPrice);
        SetEdge(AdjacencyList, VertexID1, VertexID2, WeightOfDistance, WeightOfPrice);
    }
}
int main(int argc, char const *argv[])
{
    int i;
    int NumOfVertex, NumOfEdge;
    scanf("%d %d", &NumOfVertex, &NumOfEdge);
    bool *VertexVisited = (bool*)malloc(NumOfVertex * sizeof(bool));
    V *AdjacencyList = (V*)malloc(NumOfVertex * sizeof(struct Vertex));
    for (i = 0; i < NumOfVertex; ++i)
    {
        AdjacencyList[i] = (V)malloc(sizeof(struct Vertex));
        AdjacencyList[i]->ID = i;
        AdjacencyList[i]->Next = NULL;
        VertexVisited[i] = false;
    }
    for (i = 0; i < NumOfEdge; ++i)
    {
        int VertexID1, VertexID2;
        scanf("%d %d", &VertexID1, &VertexID2);
        SetEdge(AdjacencyList, VertexID1, VertexID2);
    }
    for (i = 0; i < NumOfVertex; ++i)
    {
        if (!VertexVisited[i])
        {
            printf("{ ");
            DFS(AdjacencyList[i], AdjacencyList, VertexVisited);
            printf("}\n");
        }
    }
    for (i = 0; i < NumOfVertex; ++i)
    {
        VertexVisited[i] = false;
    }
    for (i = 0; i < NumOfVertex; ++i)
    {
        if (!VertexVisited[i])
        {
            printf("{ ");
            BFS(AdjacencyList[i], AdjacencyList, VertexVisited);
            printf("}\n");
        }
    }
    return 0;
}
Пример #11
0
void Forces::AllocTens(){
  if(VAR_IF_TYPE(SysAlloc,ALL_TENS)) return;
  for(int d=0;d<3;d++){
    Tens.RefPos[d] = pNanoPos(0,d);//.5*pEdge(d);
  }
  Tens.Pre = (double **)calloc(Tens.NComp,sizeof(double));
  Tens.Dens = (double **)calloc(2,sizeof(double));
  //   2d
  if(VAR_IF_TYPE(Tens.CalcMode,CALC_2d)){
    Tens_Ref = &Forces::TensRefPol;
    SetEdge(.5*MIN(pEdge(CLat1),pEdge(CLat2)),3);
    Tens.Edge[0] = pEdge(3);
    Tens.Edge[1] = pEdge(CNorm);
    Tens.Edge[2] = 1.;
    Tens.Wrap[0] = 0;
    Tens.Wrap[1] = 1;
    for(int d=0;d<3;d++){
      Tens.EdgeInv[d] = 1./Tens.Edge[d];
    }
    for(int c=0;c<Tens.NComp;c++){
      Tens.Pre[c] = (double *)calloc(SQR(Tens.NSlab),sizeof(double));
    }
    for(int c=0;c<2;c++){
      Tens.Dens[c] = (double *)calloc(SQR(Tens.NSlab),sizeof(double));
    }
  }
  //  3d
  if(VAR_IF_TYPE(Tens.CalcMode,CALC_3d)){
    Tens_Ref = &Forces::TensRefCart;
    for(int d=0;d<3;d++){
      Tens.Edge[d] = pEdge(d);
      Tens.Wrap[d] = 1;
      Tens.EdgeInv[d] = pInvEdge(d);
    }
    for(int c=0;c<Tens.NComp;c++){
      Tens.Pre[c] = (double *)calloc(CUBE(Tens.NSlab),sizeof(double));
    }
    for(int c=0;c<2;c++){
      Tens.Dens[c] = (double *)calloc(CUBE(Tens.NSlab),sizeof(double));
    }
  }
  VAR_ADD_TYPE(SysAlloc,ALL_TENS);
}
Пример #12
0
int main()
{
    int N, E, i, p, fee;
    VertexType n1, n2, v0, vf;
    int rescue[MAXVEX];

    scanf("%d %d %d %d", &N, &E, &v0, &vf);
    MGraph G = CreateMGraph(N, E);

    for (i = 0; i < N; i++)
        scanf("%d", &rescue[i]);

    while (E--)
    {
        scanf("%d %d %d", &n1, &n2, &p);
        SetEdge(G, n1, n2, p);
    }

    Dijkstra(G, v0, vf, rescue);

    return 0;
}
Пример #13
0
VOID CClientWnd::OnChildOpenClose(BOOL bOpen)
{
	_ExIf(m_bScrabble, OnPlayScrabble());

	if (bOpen)
	{
		m_uChildNum++;
		if (m_uChildNum == 1)
		{
			EnableCommand();
			CMainWnd::EnableCommand(IDM_Play_Synchronize, FALSE);
			CMainWnd::EnableCommand(IDM_Play_Scrabble, FALSE);
		}
		else if (m_uChildNum == 2)
		{
			CMainWnd::EnableCommand(IDM_Play_Synchronize, TRUE);
			CMainWnd::EnableCommand(IDM_Play_Scrabble, TRUE);
		}
	}
	else
	{
		m_uChildNum--;
		if (m_uChildNum <= 1)
		{
			if (m_uChildNum == 0)
			{
				// 保存子窗口最大化状态
				BOOL bMaximized = (HasEdge() == FALSE);
				CIni::SetInt(INI_MaxOnOpen, bMaximized);
				_ExIf(bMaximized, SetEdge());

				EnableCommand(FALSE);
			}
			CMainWnd::EnableCommand(IDM_Play_Synchronize, FALSE);
			CMainWnd::EnableCommand(IDM_Play_Scrabble, FALSE);
		}
	}
}
Пример #14
0
int ElPoly::ProjectionF(int NBin,int Coord){
  if(Coord > 4 || Coord <0) return 1;
  int NType = 5;
  double *Plot = (double *)calloc(NBin*NBin*NType,sizeof(double));
  double InvNBin = 1./(double)NBin;
  double RefPos[3] = {0.,0.,0.};
  for(int d=0;d<3;d++){
    RefPos[d] = Nano->Pos[d]-.5*pEdge(d);
  }
  if(Coord == 3){
    RefPos[0]=pCm(0);RefPos[1]=pCm(1);RefPos[2]=pCm(2);
  }
  SetEdge(.5*MIN(pEdge(CLat1),pEdge(CLat2)),3);
  for(int f=NFile[0];f<NFile[1];f++){
    Processing(f);
    OpenRisk(cFile[f],BF_PART);
    ShiftSys(SHIFT_CM);
    int NPlot = 0;
    //---Projects-against-one-coordinate--
    if(Coord < 3){
      int coord1 = (Coord+1)%3;
      int coord2 = (Coord+2)%3;
      for(int p=0;p<pNPart();p++){
	double x = pPos(p,coord1) - RefPos[coord1];
	x -= floor(x*pInvEdge(coord1))*pEdge(coord1);
	double y = pPos(p,coord2) - RefPos[coord2];
	y -= floor(y*pInvEdge(coord2))*pEdge(coord2);
	int v = (int)(NBin*x*pInvEdge(coord1));
	if( v < 0 || v >= NBin) continue;
	int vv = (int)(NBin*y*pInvEdge(coord2));
	if( vv < 0 || vv >= NBin) continue;
	int t = pType(p);
	if( t < 0 || t > 3) continue;
	if( CHAIN_IF_TYPE(Ch[pChain(p)].Type,CHAIN_ADDED) )
	  Plot[(v*NBin+vv)*NType+3] += 1.;
	Plot[(v*NBin+vv)*NType+t] += 1.;
	if(p<pNPart()-1)
	  if(pType(p+1) == 1 && pType(p) == 0)
	    Plot[(v*NBin+vv)*NType+4] += 1.;	  
      }
    }
    //---Projects-against-the-radial-coordinate--
    else if(Coord == 3){
      SetEdge(.5*MAX((pEdge(CLat1)),(pEdge(CLat2))),3);
      for(int p=0;p<pNPart();p++){
	double x = pPos(p,CLat1) - RefPos[CLat1];
	x -= floor(x*pInvEdge(CLat1))*pEdge(CLat1);
	double y = pPos(p,CLat2) - RefPos[CLat2];
	y -= floor(y*pInvEdge(CLat2))*pEdge(CLat2);
	double z = pPos(p,CNorm) - RefPos[CNorm];
	z -= floor(z*pInvEdge(CNorm))*pEdge(CNorm);
	double r = sqrt(SQR(x)+SQR(y));
	int v = (int)(NBin*r*pInvEdge(3));
	if( v < 0 || v >= NBin) continue;
	int vv = (int)(NBin*pPos(p,CNorm)/pEdge(CNorm));
	if( vv < 0 || vv >= NBin) continue;
	int t = pType(p);
	if( t < 0 || t > 3) continue;
	if( CHAIN_IF_TYPE(Ch[pChain(p)].Type,CHAIN_ADDED) )
	  Plot[(v*NBin+vv)*NType+3] += 1.;
	Plot[(v*NBin+vv)*NType+t] += 1.;
	if(p<pNPart()-1)
	  if(pType(p+1) == 1 && pType(p) == 0)
	    Plot[(v*NBin+vv)*NType+4] += 1.;	  
      }
    }
  }
  printf("\n");
  //-----writes-the-output-file-------------------
  FILE *FileToWrite = NULL;
  FileToWrite = fopen("Projection.xyd","w");
  fprintf(FileToWrite,"#l(%lf %lf %lf) v[%d] d[%s]\n",pEdge(CLat1),pEdge(CLat2),pEdge(CNorm),NBin,ChooseDraw(EL_QUAD1));
  int coord1 = (Coord+1)%3;
  int coord2 = (Coord+2)%3;
  if(Coord == 3){
    coord1 = 3;
    coord2 = CNorm;
  }
  double Max[NType];
  for(int t=0;t<NType;t++){
    Max[t] = Plot[t];
    for(int v=0;v<NBin;v++)
      for(int vv=0;vv<NBin;vv++)
	if(Max[t] < Plot[(v*NBin+vv)*NType+t]) Max[t] = Plot[(v*NBin+vv)*NType+t];
    Max[t] = Max[t] <= 0. ? 1. : Max[t];
  }
  //for(int t=0;t<NType-1;t++){
  for(int t=0;t<1;t++){
    for(int v=0;v<NBin;v++){
      for(int vv=0;vv<NBin;vv++){
	int p = (v*NBin+vv)*NType+t;
	int c = 0;
	if(Plot[p] < .1) continue;
	double x = (v)*InvNBin*pEdge(CLat1);
	double y = (vv)*InvNBin*pEdge(CLat2);
	double dens = Plot[p]/Max[t]*5.+.5*pEdge(CNorm);
	double NanoAdded = 0.;//Plot[p]/Max[t]+Plot[((v*NBin+vv)*NType+3]/Max[3];
	double Phob = t == 0 ? Plot[(v*NBin+vv)*NType+0]/Max[0] : 0.;
	double Phil = t == 1 ? Plot[(v*NBin+vv)*NType+1]/Max[1] : 0.;
	fprintf(FileToWrite,"{t[%d %d %d] x(%lf %lf %lf) v(%lf %lf %lf)}\n",p,c,t,x,y,dens,NanoAdded,Phob,Phil);
      }
    } 
  }
  free(Plot);
  fclose(FileToWrite);
  return 0;
}
Пример #15
0
int ElPoly::RadialShell(int NBin){
  double Volume=0;//Global constant
  double Area=0.;
  double Norm=0.;
  double **Plot;
  double Ypsilon = 0.;
  double InvNFile  = 1./(double)(NFile[1]-NFile[0]);
  Plot = (double **)calloc(NBin,sizeof(double));
  for(int i=0;i<NBin;i++){
    *(Plot+i) = (double *)calloc(NBin,sizeof(double));
  }
  for(int f=NFile[0];f<NFile[1];f++){
    Processing(f);
    if(OpenRisk(cFile[f],BF_PART))return 0;
    SetEdge(MIN((pEdge(CLat1)*.5),(pEdge(CLat2)*.5)),3);
    for(int p=0;p<pNPart();p++){
      double Rad = sqrt(SQR((pPos(p,CLat1)-pCm(CLat1))) 
			+ SQR((pPos(p,CLat2)-pCm(CLat2))) );
      int vr = (int)(NBin*Rad*pInvEdge(3));
      int vz = (int)(NBin*pPos(p,CNorm)*pInvEdge(CNorm));
      //printf("%lf %lf %d %d \n",Rad,pPos(p,CNorm),v,vv);
      if( vr < 0 || vr >= NBin) continue;
      if( vz < 0 || vz >= NBin) continue;
      Plot[vr][vz] += InvNFile;
    }
    Ypsilon += pEdge(2)-pCm(2)-1.;
  }
  printf("\n");
  FILE *FileToWrite = fopen("RadialShell.xye","w");
  //fprintf(FileToWrite,"# l(%.2f %.2f %.2f) v[60] d[chain]\n",Gen->Edge[0],Gen->Edge[1],Gen->Edge[2]);
  fprintf(FileToWrite,"%lf %lf %lf\n",0.,0.,0.);
  fprintf(FileToWrite,"%lf %lf %lf\n",pEdge(0),pEdge(1),1.);
  double Max=0.;
  for(int i=0;i<NBin;i++){
    for(int j=0;j<NBin;j++){
      if(Plot[i][j] > Max) Max = Plot[i][j];
    }
  }
  int th=0;
  for(int vz=0;vz<NBin;vz++){
    //for(int vr=NBin-1;vr>=0;vr--){
    for(int vr=0;vr<NBin;vr++){
      if(Plot[vr][vz] > 0.){
	fprintf(FileToWrite,"%lf %lf %lf\n",(double)vr/NBin*pEdge(3),(double)vz/NBin*pEdge(2),Plot[vr][vz]/Max);
	Norm += Plot[vr][vz];
	th++;
	if(th > 4){
	  th = 0;
	  break;
	}
      }
    }
  }
  fclose(FileToWrite);
  return 0;
  Mat->Ypsilon = Ypsilon*InvNFile;
  double Vol = 1.;//pNPart()/(Gen->rho/(double)pNPCh()*CUB(5.));
  Mat->PreFact = 3./8.*pow((3.*Vol)/DUE_PI,1./3.);
  Mat->Func = &Matematica::ContactAngle;
  int NRadici = 4;
  printf("Volume  %lf Cm %lf Area %lf # to Invert %lf\n",(double)pNPart()/10.,pCm(2),Area,pow(DUE_PI/(2.*pNPart()/10.),.25));
  double *Radici;
  Radici = (double *)malloc(NRadici*sizeof(double));
  int NZeri = Mat->Zeri(0.,DUE_PI/2.,Radici,NRadici);
  for(int i=0;i<NZeri;i++){
    Radici[i] *= 360./DUE_PI;
    printf("Angle %lf\n",Radici[i]);
  }
  if(NZeri == 0){
    printf("The function has no real roots\n");
  }
  free(Plot);
  return 0;
}
Пример #16
0
int Forces::ReadConfDinamica(char *InFile){
  SysType = 0;
  SysShape = 0;
  CalcMode = 0;
  FILE *FileToRead = fopen(InFile,"r");
  if(FileToRead == NULL){
    printf("The conf file %s is missing\n",InFile);
    return 1;
  }
  double buff[12];
  char SysInit[20];
  char *Line = (char *)malloc(256*sizeof(char));
  //fgets(Line,256,FileToRead);
  int NNano = 0;
  for(int k=0;!(fgets(Line,256,FileToRead)==NULL);k++){
    if(strstr(Line, "Rigid") == Line) NNano++;
  }
  SetNNano(NNano);
  NNano = 0;
  rewind(FileToRead);
  for(int k=0;!(fgets(Line,256,FileToRead)==NULL);k++){
    //printf("%s",Line);
    if(1 == sscanf(Line,"NEdge %lf",buff) )
      NEdge = (int)*buff;
    else if(1 == sscanf(Line,"SysShape %s",SysInit) ){
      if(!strcmp(SysInit,"leaves") )
	VAR_ADD_TYPE(SysShape,SYS_LEAVES);
      else if(!strcmp(SysInit,"pore") )
	VAR_ADD_TYPE(SysShape,SYS_PORE);
      else if(!strcmp(SysInit,"1d") )
	VAR_ADD_TYPE(SysShape,SYS_1D);
      else if(!strcmp(SysInit,"2d") )
	VAR_ADD_TYPE(SysShape,SYS_2D);
      else if(!strcmp(SysInit,"3d") )
	VAR_ADD_TYPE(SysShape,SYS_3D);
      else if(!strcmp(SysInit,"rod") )
	VAR_ADD_TYPE(SysShape,SYS_ROD);
      else if(!strcmp(SysInit,"trial") )
	VAR_ADD_TYPE(SysShape,SYS_TRIAL);
      else if(!strcmp(SysInit,"rigid") )
	VAR_ADD_TYPE(SysShape,SYS_RIGID);
      else if(!strcmp(SysInit,"stalk") )
	VAR_ADD_TYPE(SysShape,SYS_STALK);
      else if(!strcmp(SysInit,"md") )
	VAR_ADD_TYPE(SysShape,SYS_MD);
      else if(!strcmp(SysInit,"mc") )
	VAR_ADD_TYPE(SysShape,SYS_MC); 
      else if(!strcmp(SysInit,"electro") ){
	VAR_ADD_TYPE(SysShape,SYS_ELECTRO);
	//VAR_ADD_TYPE(SysShape,SYS_MC); 
      }
      else{
	printf("system type not recognized\n");
	exit(1);
      }
    }
    else if(1 == sscanf(Line,"CalcMode %s",SysInit) ){
      if(!strcmp(SysInit,"NVT") )
	VAR_ADD_TYPE(CalcMode,CALC_NVT);
      else if(!strcmp(SysInit,"NcVT") )
	VAR_ADD_TYPE(CalcMode,CALC_NcVT);
      else if(!strcmp(SysInit,"mcVT") )
	VAR_ADD_TYPE(CalcMode,CALC_mcVT);
      else if(!strcmp(SysInit,"mVT") )
	VAR_ADD_TYPE(CalcMode,CALC_mVT);
      else{
	printf("calculation type not recognized\n");
	exit(1);
      }
    }
    else if(1 == sscanf(Line,"Thermostat %s",SysInit) ){
      if(!strcmp(SysInit,"Langevin") )
	ThermMode = THERM_LANG;
      else if(!strcmp(SysInit,"Andersen") )
	ThermMode = THERM_AND;
      else if(!strcmp(SysInit,"Berendsen") )
	ThermMode = THERM_BERE;
      else if(!strcmp(SysInit,"no") )
	ThermMode = THERM_NO;
      else{
	printf("thermostat not recognized\n");
	exit(1);
      }
    }
    else if(1 == sscanf(Line,"PotentialMode %s",SysInit) ){
      if(!strcmp(SysInit,"Pair") )
	VAR_ADD_TYPE(CalcMode,CALC_PAIR);
      else if(!strcmp(SysInit,"DensFunc") )
	VAR_ADD_TYPE(CalcMode,CALC_DENS);
      else if(!strcmp(SysInit,"DensFuncCh") )
	VAR_ADD_TYPE(CalcMode,CALC_DENS);
    }
    else if(1 == sscanf(Line,"Potential %s",SysInit) ){
      if(!strcmp(SysInit,"LJ") )
	VAR_ADD_TYPE(CalcMode,CALC_LJ);
      else if(!strcmp(SysInit,"LJ39") )
	VAR_ADD_TYPE(CalcMode,CALC_LJ39);
      else if(!strcmp(SysInit,"Harmonic") )
	VAR_ADD_TYPE(CalcMode,CALC_HARM);
      else if(!strcmp(SysInit,"Step") )
	VAR_ADD_TYPE(CalcMode,CALC_STEP);
      else if(!strcmp(SysInit,"Electro") )
	VAR_ADD_TYPE(CalcMode,CALC_ELECTRO);
      else{
	printf("interaction potential not recognized\n");
	exit(1);
      }
    }
    else if(1 == sscanf(Line,"IfInterp %lf",buff) )
      IfInterp = (int)*buff;
    else if(1 == sscanf(Line,"Lap %lf",buff) )
      Kf.Lap = *buff;
    else if(1 == sscanf(Line,"SLap %lf",buff) )
      Kf.SLap = *buff;
    else if(1 == sscanf(Line,"Ext %lf",buff) )
      Kf.Ext = *buff;
    else if(1 == sscanf(Line,"LJ %lf",buff) )
      Kf.LJ = *buff;
    else if(1 == sscanf(Line,"LJMin %lf",buff) )
      Kf.LJMin = *buff;
    else if(1 == sscanf(Line,"kSpr %lf",buff) )
      SetkSpr(*buff);
    else if(1 == sscanf(Line,"SprRest %lf",buff) )
      SetSprRest(*buff);
    else if(1 == sscanf(Line,"kBen %lf",buff) )
      SetkBen(*buff);
    else if(1 == sscanf(Line,"SimLimit %lf",buff) )
      SimLimit = (int)*buff;
    else if(1 == sscanf(Line,"CutOff %lf",buff) )
      Kf.CutOff2 = SQR(*buff);
    else if(1 == sscanf(Line,"Cont %lf",buff) )
      Kf.Cont = *buff;
    else if(1 == sscanf(Line,"NWrite %lf",buff) )
      NWrite = (int)*buff;
    else if(1 == sscanf(Line,"NBin %lf",buff) )
      NBin = (int)*buff;
    else if(1 == sscanf(Line,"NGrid %lf",buff) )
      NGrid = (int)*buff;
    else if(1 == sscanf(Line,"NUpdate %lf",buff) )
      NUpdate = (int)*buff;
    else if(strstr(Line, "Rigid") == Line){
      NanoString(Line,NNano++);
    }
#ifdef __glut_h__
    else if(1 == sscanf(Line,"IfMovie %lf",buff) )
      IfMovie = (int)*buff;
    else if(1 == sscanf(Line,"IfLine %lf",buff) )
      IfLine = (int)*buff;
    else if(1 == sscanf(Line,"NSpline %lf",buff) )
      NSpline = *buff;
    else if(1 == sscanf(Line,"IfSphere %lf",buff) )
      IfSphere = (int)*buff;
#endif
    else if(3 == sscanf(Line,"Edge %lf %lf %lf",buff,buff+1,buff+2) ){
      SetEdge(buff[0],0);
      SetEdge(buff[1],1);
      SetEdge(buff[2],2);
    }
    else if(3 == sscanf(Line,"El %lf %lf %lf",buff,buff+1,buff+2) ){
      Kf.El[0] = *buff;
      Kf.El[1] = *(buff+1);
      Kf.El[2] = *(buff+2);
    }
    else if(3 == sscanf(Line,"Elong %lf %lf %lf",buff,buff+1,buff+2) ){
      Kf.Elong[0] = *buff;
      Kf.Elong[1] = *(buff+1);
      Kf.Elong[2] = *(buff+2);
    }
    else if(6 == sscanf(Line,"Boundary %lf %lf %lf %lf %lf %lf",buff,buff+1,buff+2,buff+3,buff+4,buff+5)){
      BoundCond[0] = (int)buff[0];
      BoundCond[1] = (int)buff[1];
      BoundCond[2] = (int)buff[2];
      BoundCond[3] = (int)buff[3];
      BoundCond[4] = (int)buff[4];
      BoundCond[5] = (int)buff[5];
    }
    else if(3 == sscanf(Line,"Periodic  %lf %lf %lf",buff,buff+1,buff+2)){
      PeriodicImage[0] = (int)*buff;
      PeriodicImage[1] = (int)*(buff+1);
      PeriodicImage[2] = (int)*(buff+2);
    }
    else if(1 == sscanf(Line,"Deltat %lf",buff) )
      Deltat = *buff;
    else if(1 == sscanf(Line,"Temp %lf",buff) )
      SetTemp(buff[0]);
    else if(1 == sscanf(Line,"NChemPotId %lf",buff) )
      NChemPotId = *buff;
    else if(1 == sscanf(Line,"NTrialBias %lf",buff) ){
      NTrialBias =(int) *buff;
    }
    else if(1 == sscanf(Line,"ChemPotEx %lf",buff) )
      ChemPotEx = *buff;
    else if(1 == sscanf(Line,"IfConfBias %lf",buff) ){
      if((int)*buff == 1)
    	VAR_ADD_TYPE(CalcMode,CALC_CONF_BIAS);
    }
    else if(1 == sscanf(Line,"IfBilBias %lf",buff) ){
      if((int)*buff == 1){
    	VAR_ADD_TYPE(CalcMode,CALC_BIL_BIAS);
	StudySys();
      }
    }
    else if(1 == sscanf(Line,"IfSphBias %lf",buff) ){
      if((int)*buff == 1)
    	VAR_ADD_TYPE(CalcMode,CALC_SPH_BIAS);
    }
    else if(1 == sscanf(Line,"Viscosity %lf",buff) )
      Viscosity = *buff;
    else if(1 == sscanf(Line,"TNSlab %lf",buff) )
      Tens.NSlab = (int)*buff;
    else if(1 == sscanf(Line,"TNComp %lf",buff) )
      Tens.NComp = (int)*buff;
    else if(1 == sscanf(Line,"TCalcMode %s",SysInit) ){
      if(!strcmp(SysInit,"2d") ){
	VAR_ADD_TYPE(Tens.CalcMode,CALC_2d);
	Tens.NDim = 2;
      }
      else if(!strcmp(SysInit,"3d") ){
	VAR_ADD_TYPE(Tens.CalcMode,CALC_3d);
	Tens.NDim = 3;
      }
      else{
	printf("Pressure summation not recognized\n");
	exit(1);
      }
    }
  }
  //for(int n=0;n<pNNano();n++) for(int d=0;d<3;d++) Nano[n].Pos[d] *= pEdge(d);
  ChemPotId = log(NChemPotId/pVol());
  printf("Sys] NEdge %d SysShape %d %s Interp %d  \n",NEdge,SysShape,SysInit,IfInterp);
  printf("Forces] Lap %lf SLap %lf Ext %lf LJ %lf Cont %lf El %lf %lf %lf Elong %lf %lf %lf\n",Kf.Lap,Kf.SLap,Kf.Ext,Kf.LJ,Kf.Cont,Kf.El[0],Kf.El[1],Kf.El[2],Kf.Elong[0],Kf.Elong[1],Kf.Elong[2]);
  printf("External] Center %lf %lf %lf Rad %lf Hei %lf\n",Nano->Pos[0],Nano->Pos[1],Nano->Pos[2],Nano->Rad,Nano->Height);
  fclose(FileToRead);
  return 0;
}
Пример #17
0
bool SCH_SHEET_PIN::Load( LINE_READER& aLine, wxString& aErrorMsg )
{
    int     size;
    char    number[256];
    char    name[256];
    char    connectType[256];
    char    sheetSide[256];
    char*   line = aLine.Line();
    char*   cp;

    static const char delims[] = " \t";

    // Read coordinates.
    // D( printf( "line: \"%s\"\n", line );)

    cp = strtok( line, delims );

    strncpy( number, cp, sizeof(number) );
    number[sizeof(number)-1] = 0;

    cp += strlen( number ) + 1;

    cp += ReadDelimitedText( name, cp, sizeof(name) );

    cp = strtok( cp, delims );
    strncpy( connectType, cp, sizeof(connectType) );
    connectType[sizeof(connectType)-1] = 0;

    cp = strtok( NULL, delims );
    strncpy( sheetSide, cp, sizeof(sheetSide) );
    sheetSide[sizeof(sheetSide)-1] = 0;

    cp += strlen( sheetSide ) + 1;

    int r = sscanf( cp, "%d %d %d", &m_Pos.x, &m_Pos.y, &size );
    if( r != 3 )
    {
        aErrorMsg.Printf( wxT( "Eeschema file sheet hierarchical label error at line %d.\n" ),
                          aLine.LineNumber() );

        aErrorMsg << FROM_UTF8( line );
        return false;
    }

    m_Text = FROM_UTF8( name );

    if( size == 0 )
        size = GetDefaultTextSize();

    m_Size.x = m_Size.y = size;

    switch( connectType[0] )
    {
    case 'I':
        m_shape = NET_INPUT;
        break;

    case 'O':
        m_shape = NET_OUTPUT;
        break;

    case 'B':
        m_shape = NET_BIDI;
        break;

    case 'T':
        m_shape = NET_TRISTATE;
        break;

    case 'U':
        m_shape = NET_UNSPECIFIED;
        break;
    }

    switch( sheetSide[0] )
    {
    case 'R' : /* pin on right side */
        SetEdge( 1 );
        break;

    case 'T' : /* pin on top side */
        SetEdge( 2 );
        break;

    case 'B' : /* pin on bottom side */
        SetEdge( 3 );
        break;

    case 'L' : /* pin on left side */
    default  :
        SetEdge( 0 );
        break;
    }

    return true;
}