示例#1
0
bool GPolyline::pointInrgn(CPoint p)
{
	for (int i = 0; i<pt_num; i++)
	{
		CRect rect(pt_arr[i].x - 5, pt_arr[i].y - 5, pt_arr[i].x + 5, pt_arr[i].y + 5);
		if (rect.PtInRect(p)){
			movemode = i;
			return true;
		}
	}

	if (CRect(point_end.x - 5, point_end.y - 5, point_end.x + 5, point_end.y + 5).PtInRect(p))
	{
		movemode = pt_num;
		return true;
	}

	else if (CRect(getBoundary()).PtInRect(p))
	{
		movemode = -1;
		return true;
	}
	else
		return false;
}
示例#2
0
Boundary
GUIEdge::getCenteringBoundary() const {
    Boundary b = getBoundary();
    // ensure that vehicles and persons on the side are drawn even if the edge
    // is outside the view
    b.grow(10);
    return b;
}
void HTTPRequest::addDefaultHTTPHeaders() {
  addHeader(HTTPHeader("Host", url.getHost()));

  if(method != HTTP_METHOD_POST) {
    return;
  }

  if(!headers.contains("content-type")) {
    if(getFormEncoding() == HTTP_FORM_MULTIPART) {
      addHeader(HTTPHeader("Content-Type", "multipart/form-data; boundary=\"" +getBoundary() +"\""));
    }
    else if(getFormEncoding() == HTTP_FORM_URL_ENCODED) {
      addHeader(HTTPHeader("Content-Type", "application/x-www-form-urlencoded"));
    }
  }
}
bool HTTPRequest::createBody(std::string& result) {
  if(body.size()) {
    result = body;
  }
  else {
    if(content_parameters.size()) {
      if(isPost() && content_parameters.hasFileParameter()) {
        return content_parameters.toBoundaryString(getBoundary(), result);
      }
      else {
        if(content_parameters.size()) {
          content_parameters.percentEncode();
          result = content_parameters.getQueryString();
        }
      }
    }
  }
  return true;
}
示例#5
0
void Group::drawBoundary(CDC* cdc)
{
	CRect rect = getBoundary();// 그릴 사각형을 가져온다.

	CPen m_pen(PS_SOLID, 1, RGB(0, 0, 0));// 그릴 펜의 속성을 지정
	CPen *oldpen = cdc->SelectObject(&m_pen);
	cdc->SelectStockObject(NULL_BRUSH);
	cdc->Rectangle(rect);// 테두리 사각형 그리고

	cdc->SelectStockObject(WHITE_BRUSH);

	CRect box(rect.TopLeft().x - 5, rect.TopLeft().y - 5, rect.TopLeft().x + 5, rect.TopLeft().y + 5);
	cdc->Rectangle(box);// 왼쪽 위 사각형 그리고

	box.SetRect(rect.right - 5, rect.top - 5, rect.right + 5, rect.top + 5);
	cdc->Rectangle(box);// 오른쪽 위 사각형 그리고

	box.SetRect(rect.left - 5, rect.bottom - 5, rect.left + 5, rect.bottom + 5);
	cdc->Rectangle(box);// 왼쪽 아래 사각형 그리고

	box.SetRect(rect.BottomRight().x - 5, rect.BottomRight().y - 5, rect.BottomRight().x + 5, rect.BottomRight().y + 5);
	cdc->Rectangle(box);// 오른쪽 아래 사각형 그리고

	//노드 데이터 변경
	POSITION posNode = NodeData.GetHeadPosition();
	while (posNode)
	{
		Figure* pObj = (Figure*)NodeData.GetNext(posNode);
		pObj->draw(cdc);
	}
	//차일드 데이터 변경(recursion이 일어남)
	POSITION posChild = Child.GetHeadPosition();
	while (posChild)
	{
		Group* pGroup = (Group*)Child.GetNext(posChild);
		pGroup->drawBoundary(cdc);
	}


	cdc->SelectObject(&oldpen);
}
示例#6
0
void MyLine::drawBoundary(CDC* cdc)
{
	CRect rect = getBoundary();// 그릴 사각형을 가져온다.

	CPen m_pen(PS_DOT, 1, RGB(0, 0, 0));// 그릴 펜의 속성을 지정
	CPen *oldpen = cdc->SelectObject(&m_pen);
	cdc->SelectStockObject(NULL_BRUSH);
	cdc->Rectangle(rect);// 테두리 사각형 그리고

	cdc->SelectStockObject(WHITE_BRUSH);

	CRect box(rect.TopLeft().x - 5, rect.TopLeft().y - 5, rect.TopLeft().x + 5, rect.TopLeft().y + 5);
	cdc->Rectangle(box);// 왼쪽 위 사각형 그리고

	box.SetRect(rect.CenterPoint().x - 5, rect.top - 5, rect.CenterPoint().x + 5, rect.top + 5);
	cdc->Rectangle(box);// 위쪽 가운데 사각형 그리고

	box.SetRect(rect.right - 5, rect.top - 5, rect.right + 5, rect.top + 5);
	cdc->Rectangle(box);// 오른쪽 위 사각형 그리고

	box.SetRect(rect.left - 5, rect.CenterPoint().y - 5, rect.left + 5, rect.CenterPoint().y + 5);
	cdc->Rectangle(box);// 왼쪽 가운데 사각형 그리고

	box.SetRect(rect.right - 5, rect.CenterPoint().y - 5, rect.right + 5, rect.CenterPoint().y + 5);
	cdc->Rectangle(box);// 오른쪽 가운데 사각형 그리고

	box.SetRect(rect.left - 5, rect.bottom - 5, rect.left + 5, rect.bottom + 5);
	cdc->Rectangle(box);// 왼쪽 아래 사각형 그리고

	box.SetRect(rect.CenterPoint().x - 5, rect.bottom - 5, rect.CenterPoint().x + 5, rect.bottom + 5);
	cdc->Rectangle(box);// 가운데 아래 사각형 그리고

	box.SetRect(rect.BottomRight().x - 5, rect.BottomRight().y - 5, rect.BottomRight().x + 5, rect.BottomRight().y + 5);
	cdc->Rectangle(box);// 오른쪽 아래 사각형 그리고

	cdc->SelectObject(&oldpen);

}
示例#7
0
文件: ruleAdmin.cpp 项目: bpow/irods
int getEntries( inStruct Sentries ) {
    register int x;
    char *stquery, *tmpq, *tmpStr, *tmpStr1, *tmpPtr;
    char reqMethod[100];
    int msgLength;
    char contentType[100];
    char boundary[MAX_TOKEN];
    int i;


    putenv( "HOME=/" );


    if ( getenv( "CONTENT_TYPE" ) != NULL ) {
        strcpy( contentType, getenv( "CONTENT_TYPE" ) );
    }
    else {
        strcpy( contentType, "" );
    }
    if ( getenv( "REQUEST_METHOD" ) != NULL ) {
        strcpy( reqMethod, getenv( "REQUEST_METHOD" ) );
    }
    else {
        strcpy( reqMethod, "" );
    }
    if ( getenv( "HTTP_COOKIE" ) != NULL ) {
        strcpy( Sentries->cookieStr, getenv( "HTTP_COOKIE" ) );
    }

    else {
        strcpy( Sentries->cookieStr, "" );
    }
    if ( strstr( Sentries->cookieStr, "*" ) != NULL ||
            strstr( Sentries->cookieStr, ".." ) != NULL ||
            strstr( Sentries->cookieStr, "?" ) != NULL ||
            strstr( Sentries->cookieStr, "/" ) != NULL ||
            strstr( Sentries->cookieStr, "\\" ) != NULL ) {

        Sentries->op = -1;
        return 1;


    }


    if ( !strcmp( reqMethod, "POST" ) || !strcmp( reqMethod, "post" ) ) {
        msgLength = atoi( getenv( "CONTENT_LENGTH" ) ) + 10;
        stquery =  malloc( msgLength );
        if ( fread( stquery, 1, msgLength, stdin ) != ( msgLength - 10 ) ) {
            webErrorExit( "short fread", 0 );
        }
        stquery[msgLength] = '\0';
    }
    else {
        stquery =  malloc( QSIZE );
        if ( getenv( "QUERY_STRING" ) != NULL ) {
            strcpy( stquery, getenv( "QUERY_STRING" ) );
        }
        else {
            strcpy( stquery, "" );
        }
    }

    if ( strstr( contentType, "multipart/form-data" ) != NULL ) {

        i = msgLength - 10;
        getBoundary( &stquery, boundary );
        /***     printf("Boundary:**%s**<BR>\n",boundary);fflush(stdout); ***/
        for ( x = 0;  *stquery != '\0'; x++ ) {
            if ( x == MAX_ENTRIES ) {
                webErrorExit( "MaxEntries Exceeded", x );
            }
            Sentries->m = x;
            /***     printf("GettingX:%i....\n",x);fflush(stdout); ***/
            tmpPtr = stquery;
            if ( getmultipartword( &Sentries->entries[x], &stquery, boundary, i ) != 0 ) {
                break;
            }
            i -= stquery - tmpPtr;
            /***     printf("%i:%s=%s<BR>\n",entries[x].size,entries[x].name,entries[x].val);fflush(stdout);***/
        }
        Sentries->m--;
    }
    else {

        /**  the following is to take care of the
         home col. name bad length pb Linux on RedHat7  *******/
        fixstr1 = malloc( 10 );
        free( fixstr1 );
        /******************************************************/

        for ( x = 0;  stquery[0] != '\0'; x++ ) {
            if ( x == MAX_ENTRIES ) {
                webErrorExit( "MaxEntries Exceeded", x );
            }
            Sentries->m = x;
            Sentries->entries[x].val =  malloc( HUGE_STRING );
            getword( Sentries->entries[x].val, stquery, '&' );
            plustospace( Sentries->entries[x].val );
            unescape_url( Sentries->entries[x].val );
            char* wd = ( char * ) makeword( Sentries->entries[x].val, '=' ); // JMC cppcheck - leak
            sprintf( Sentries->entries[x].name, wd );
            free( wd ); // JMC cppcheck - leak
        }
    }

    return 0;

}
示例#8
0
Boundary
GUIEdge::getCenteringBoundary() const {
    Boundary b = getBoundary();
    b.grow(20);
    return b;
}
示例#9
0
Boundary
GUINet::getCenteringBoundary() const {
    return getBoundary();
}
示例#10
0
文件: Skin.cpp 项目: iyer-arvind/gmsh
PView *GMSH_SkinPlugin::execute(PView *v)
{
  int visible = (int)SkinOptions_Number[0].def;
  int fromMesh = (int)SkinOptions_Number[1].def;
  int iView = (int)SkinOptions_Number[2].def;

  // compute boundary of current mesh
  if(fromMesh){
    getBoundaryFromMesh(GModel::current(), visible);
    return v;
  }

  // compute boundary of post-processing data set
  PView *v1 = getView(iView, v);
  if(!v1) return v;
  PViewData *data1 = getPossiblyAdaptiveData(v1);

  if(data1->hasMultipleMeshes()){
    Msg::Error("Skin plugin cannot be applied to multi-mesh views");
    return v;
  }

  Msg::Info("Extracting boundary from View[%d]", v1->getIndex());

  PView *v2 = new PView();
  PViewDataList *data2 = getDataList(v2);

  std::set<ElmData, ElmDataLessThan> skin;
  ElmDataLessThan::tolerance = CTX::instance()->lc * 1.e-12;

  int firstNonEmptyStep = data1->getFirstNonEmptyTimeStep();
  for(int ent = 0; ent < data1->getNumEntities(firstNonEmptyStep); ent++){
    if(visible && data1->skipEntity(firstNonEmptyStep, ent)) continue;
    for(int ele = 0; ele < data1->getNumElements(firstNonEmptyStep, ent); ele++){
      if(data1->skipElement(firstNonEmptyStep, ent, ele, visible)) continue;
      int numComp = data1->getNumComponents(firstNonEmptyStep, ent, ele);
      int type = data1->getType(firstNonEmptyStep, ent, ele);
      const int (*boundary)[6][4];
      int numBoundary = getBoundary(type, &boundary);
      if(!numBoundary) continue;
      for(int i = 0; i < numBoundary; i++){
        ElmData e(numComp);
        for(int j = 0; j < 4; j++){
          int nod = (*boundary)[i][j];
          if(nod < 0) continue;
          double x, y, z;
          data1->getNode(firstNonEmptyStep, ent, ele, nod, x, y, z);
          e.x.push_back(x);
          e.y.push_back(y);
          e.z.push_back(z);
        }
        std::set<ElmData, ElmDataLessThan>::iterator it = skin.find(e);
        if(it == skin.end()){
          for(int step = 0; step < data1->getNumTimeSteps(); step++){
            if(data1->hasTimeStep(step)){
              for(int j = 0; j < 4; j++){
                int nod = (*boundary)[i][j];
                if(nod < 0) continue;
                double v;
                for(int comp = 0; comp < numComp; comp++){
                  data1->getValue(step, ent, ele, nod, comp, v);
                  e.v.push_back(v);
                }
              }
            }
          }
          skin.insert(e);
        }
        else
          skin.erase(it);
      }
    }
  }

  for(std::set<ElmData, ElmDataLessThan>::iterator it = skin.begin();
      it != skin.end(); it++)
    it->addInView(data2);

  for(int i = 0; i < data1->getNumTimeSteps(); i++)
    if(data1->hasTimeStep(i))
      data2->Time.push_back(data1->getTime(i));
  data2->setName(data1->getName() + "_Skin");
  data2->setFileName(data1->getName() + "_Skin.pos");
  data2->finalize();

  return v2;
}
示例#11
0
/*
    Process the content data.
    Returns < 0 on error
            == 0 when more data is needed
            == 1 when data successfully written
 */
static int processUploadData(HttpQueue *q)
{
    HttpConn        *conn;
    HttpPacket      *packet;
    MprBuf          *content;
    Upload          *up;
    ssize           size, dataLen;
    bool            pureData;
    char            *data, *bp, *key;

    conn = q->conn;
    up = q->queueData;
    content = q->first->content;
    packet = 0;

    size = mprGetBufLength(content);
    if (size < up->boundaryLen) {
        /*  Incomplete boundary. Return and get more data */
        return 0;
    }
    bp = getBoundary(mprGetBufStart(content), size, up->boundary, up->boundaryLen, &pureData);
    if (bp == 0) {
        if (up->clientFilename) {
            /*
                No signature found yet. probably more data to come. Must handle split boundaries.
             */
            data = mprGetBufStart(content);
            dataLen = pureData ? size : (size - (up->boundaryLen - 1));
            if (dataLen > 0) {
                if (writeToFile(q, mprGetBufStart(content), dataLen) < 0) {
                    return MPR_ERR_CANT_WRITE;
                }
            }
            mprAdjustBufStart(content, dataLen);
            return 0;       /* Get more data */
        }
    }
    data = mprGetBufStart(content);
    dataLen = (bp) ? (bp - data) : mprGetBufLength(content);

    if (dataLen > 0) {
        mprAdjustBufStart(content, dataLen);
        /*
            This is the CRLF before the boundary
         */
        if (dataLen >= 2 && data[dataLen - 2] == '\r' && data[dataLen - 1] == '\n') {
            dataLen -= 2;
        }
        if (up->clientFilename) {
            /*
                Write the last bit of file data and add to the list of files and define environment variables
             */
            if (writeToFile(q, data, dataLen) < 0) {
                return MPR_ERR_CANT_WRITE;
            }
            defineFileFields(q, up);

        } else {
            /*
                Normal string form data variables
             */
            data[dataLen] = '\0';
#if KEEP
            httpTrace(conn, "request.upload.variables", "context", "'%s':'%s'", up->name, data);
#endif
            key = mprUriDecode(up->name);
            data = mprUriDecode(data);
            httpSetParam(conn, key, data);

            if (packet == 0) {
                packet = httpCreatePacket(ME_MAX_BUFFER);
            }
            if (httpGetPacketLength(packet) > 0) {
                /*
                    Need to add www-form-urlencoding separators
                 */
                mprPutCharToBuf(packet->content, '&');
            } else {
                conn->rx->mimeType = sclone("application/x-www-form-urlencoded");

            }
            mprPutToBuf(packet->content, "%s=%s", up->name, data);
        }
    }
    if (up->clientFilename) {
        /*
            Now have all the data (we've seen the boundary)
         */
        mprCloseFile(up->file);
        up->file = 0;
        up->clientFilename = 0;
    }
    if (packet) {
        httpPutPacketToNext(q, packet);
    }
    up->contentState = HTTP_UPLOAD_BOUNDARY;
    return 0;
}
示例#12
0
int main(int argc, char *argv[])
{
  register int n, k;

  char    rayFileName[14], inputLine[MAX_LINE_SIZE];
  bool_t  result, exit_on_EOF, to_obs, initialize, crosscoupling,
          analyze_output, equilibria_only;
  int     Nspect, Nread, Nrequired, checkPoint, *wave_index = NULL;
  double  muz, *S, *chi, *J;
  FILE   *fp_out, *fp_ray, *fp_stokes;
  XDR     xdrs;
  ActiveSet *as;

  setOptions(argc, argv);
  getCPU(0, TIME_START, NULL);
  SetFPEtraps();

  /* --- Read input data and initialize --             -------------- */

  readInput();
  spectrum.updateJ = FALSE;

  /* --- Read input data for atmosphere --             -------------- */

  getCPU(1, TIME_START, NULL);
  MULTIatmos(&atmos, &geometry);

  /* --- Read direction cosine for ray --              -------------- */

  if ((fp_ray = fopen(RAY_INPUT_FILE, "r")) == NULL) {
    sprintf(messageStr, "Unable to open inputfile %s", RAY_INPUT_FILE);
    Error(ERROR_LEVEL_2, argv[0], messageStr);
  }
  
  getLine(fp_ray, COMMENT_CHAR, inputLine, exit_on_EOF=TRUE);
  Nread = sscanf(inputLine, "%lf", &muz);
  checkNread(Nread, Nrequired=1, argv[0], checkPoint=1);

  if (muz <= 0.0  ||  muz > 1.0) {
    sprintf(messageStr,
	    "Value of muz = %f does not lie in interval <0.0, 1.0]\n", muz);
    Error(ERROR_LEVEL_2, argv[0], messageStr);
  }

  if (input.StokesMode == FIELD_FREE ||
      input.StokesMode == POLARIZATION_FREE) {
    input.StokesMode = FULL_STOKES;
  }
  /* --- redefine geometry for just this one ray --    -------------- */

  atmos.Nrays = geometry.Nrays = 1;
  geometry.muz[0] = muz;
  geometry.mux[0] = sqrt(1.0 - SQ(geometry.muz[0]));
  geometry.muy[0] = 0.0;
  geometry.wmu[0] = 1.0;
  if (atmos.Stokes) Bproject();

  input.startJ = OLD_J;

  readAtomicModels();
  readMolecularModels();
  SortLambda();

  getBoundary(&geometry);

  /* --- Open file with background opacities --        -------------- */

  if (atmos.moving || input.StokesMode) {
    strcpy(input.background_File, "background.ray");
    Background(analyze_output=FALSE, equilibria_only=FALSE);
  } else {
    Background(analyze_output=FALSE, equilibria_only=TRUE);

    if ((atmos.fd_background =
	 open(input.background_File, O_RDONLY, 0)) == -1) {
      sprintf(messageStr, "Unable to open inputfile %s",
	      input.background_File);
      Error(ERROR_LEVEL_2, argv[0], messageStr);
    }
    readBRS();
  }
  convertScales(&atmos, &geometry);

  getProfiles();
  initSolution();
  initScatter();

  getCPU(1, TIME_POLL, "Total initialize");

  /* --- Solve radiative transfer equations --         -------------- */

  solveSpectrum(FALSE, FALSE);

  /* --- Write emergent spectrum to output file --     -------------- */
 
  sprintf(rayFileName, "spectrum_%4.2f", muz);
  if ((fp_out = fopen(rayFileName, "w" )) == NULL) {
    sprintf(messageStr, "Unable to open output file %s", rayFileName);
    Error(ERROR_LEVEL_2, argv[0], messageStr);
  }
  xdrstdio_create(&xdrs, fp_out, XDR_ENCODE);

  result = xdr_double(&xdrs, &muz);
  result = xdr_vector(&xdrs, (char *) spectrum.I[0], spectrum.Nspect,
		      sizeof(double), (xdrproc_t) xdr_double);

  /* --- Read wavelength indices for which chi and S are to be
         written out for the specified direction --    -------------- */

  Nread = fscanf(fp_ray, "%d", &Nspect);
  checkNread(Nread, 1, argv[0], checkPoint=2);

  if (Nspect > 0) {
    wave_index = (int *) malloc(Nspect * sizeof(int));
    Nread = 0;
    while (fscanf(fp_ray, "%d", &wave_index[Nread]) != EOF) Nread++;
    checkNread(Nread, Nspect, argv[0], checkPoint=3);
    fclose(fp_ray);

    chi = (double *) malloc(atmos.Nspace * sizeof(double));
    if (atmos.Stokes)
      S = (double *) malloc(4 * atmos.Nspace * sizeof(double));
    else
      S = (double *) malloc(atmos.Nspace * sizeof(double));
  }
  result = xdr_int(&xdrs, &Nspect);

  /* --- Go through the list of wavelengths --         -------------- */

  if (Nspect > 0  &&  input.limit_memory)
    J = (double *) malloc(atmos.Nspace * sizeof(double));

  for (n = 0;  n < Nspect;  n++) {
    if (wave_index[n] < 0  ||  wave_index[n] >= spectrum.Nspect) {
      sprintf(messageStr, "Illegal value of wave_index[n]: %4d\n"
	      "Value has to be between 0 and %4d\n", 
	      wave_index[n], spectrum.Nspect);
      Error(ERROR_LEVEL_2, argv[0], messageStr);
      continue;
    }
    sprintf(messageStr, "Processing n = %4d, lambda = %9.3f [nm]\n",
	    wave_index[n], spectrum.lambda[wave_index[n]]);
    Error(MESSAGE, NULL, messageStr);

    as = &spectrum.as[wave_index[n]];
    alloc_as(wave_index[n], crosscoupling=FALSE);
    Opacity(wave_index[n], 0, to_obs=TRUE, initialize=TRUE);
    readBackground(wave_index[n], 0, to_obs=TRUE);

    if (input.limit_memory) {
      readJlambda(wave_index[n], J);
    } else
      J = spectrum.J[wave_index[n]];

    /* --- Add the continuum opacity and emissivity -- -------------- */   

    for (k = 0;  k < atmos.Nspace;  k++) {
      chi[k] = as->chi[k] + as->chi_c[k];
      S[k]   = (as->eta[k] + as->eta_c[k] + as->sca_c[k]*J[k]) / chi[k];
    }
    result = xdr_int(&xdrs, &wave_index[n]);
    result = xdr_vector(&xdrs, (char *) chi, atmos.Nspace,
			sizeof(double), (xdrproc_t) xdr_double);
    result = xdr_vector(&xdrs, (char *) S, atmos.Nspace,
			sizeof(double), (xdrproc_t) xdr_double);

    free_as(wave_index[n], crosscoupling=FALSE);
  }

  /* --- If magnetic fields are present --             -------------- */
  
  if (atmos.Stokes || input.backgr_pol) {
    result = xdr_vector(&xdrs, (char *) spectrum.Stokes_Q[0],
			spectrum.Nspect, sizeof(double),
			(xdrproc_t) xdr_double);
    result = xdr_vector(&xdrs, (char *) spectrum.Stokes_U[0],
			spectrum.Nspect, sizeof(double),
			(xdrproc_t) xdr_double);
    result = xdr_vector(&xdrs, (char *) spectrum.Stokes_V[0],
			spectrum.Nspect, sizeof(double),
			(xdrproc_t) xdr_double);
  }

  if (Nspect > 0  &&  input.limit_memory)
    free(J);

  xdr_destroy(&xdrs);
  fclose(fp_out);
  printTotalCPU();
}
示例#13
0
int main(int argc, char *argv[])
{
  bool_t analyze_output, equilibria_only;
  int    niter, nact;

  Atom *atom;
  Molecule *molecule;

  /* --- Read input data and initialize --             -------------- */

  setOptions(argc, argv);
  getCPU(0, TIME_START, NULL);
  SetFPEtraps();

  readInput();
  spectrum.updateJ = TRUE;
 
  getCPU(1, TIME_START, NULL);
  readAtmos(&atmos, &geometry);
  if (atmos.Stokes) Bproject();
  fillMesh(&geometry);

  readAtomicModels();
  readMolecularModels();
  SortLambda();
  
  getBoundary(&atmos, &geometry);

  Background(analyze_output=TRUE, equilibria_only=FALSE);

  getProfiles();
  initSolution();
  initScatter();

  getCPU(1, TIME_POLL, "Total initialize");
 
  /* --- Solve radiative transfer for active ingredients -- --------- */

  Iterate(input.NmaxIter, input.iterLimit);

  adjustStokesMode(atom);
  niter = 0;
  while (niter < input.NmaxScatter) {  
    if (solveSpectrum(FALSE, FALSE) <= input.iterLimit) break;
    niter++;
  }
  /* --- Write output files --                     ------------------ */
 
  getCPU(1, TIME_START, NULL);

  writeInput();
  writeAtmos(&atmos);
  writeGeometry(&geometry);
  writeSpectrum(&spectrum);
  writeFlux(FLUX_DOT_OUT);

  for (nact = 0;  nact < atmos.Nactiveatom;  nact++) {
    atom = atmos.activeatoms[nact];

    writeAtom(atom);
    writePopulations(atom);
    writeRadRate(atom);
    writeCollisionRate(atom);
    writeDamping(atom);
  } 
  for (nact = 0;  nact < atmos.Nactivemol;  nact++) {
    molecule = atmos.activemols[nact];
    writeMolPops(molecule);
  }

  writeOpacity();

  getCPU(1, TIME_POLL, "Write output");
  printTotalCPU();
}
示例#14
0
int main(int argc, char *argv[])
{
  register int k, l, n, la;

  int     Nspace, result, NmaxIter, Ngdelay, Ngorder, Ngperiod, btype[3],
          inputs[N_INPUTS], nwrite, Nx, Nz;
  double  iterLimit, *lambda, Adamp;

  stats.printCPU = TRUE;
  commandline.quiet = FALSE;
  commandline.logfile = stderr;
  input.Eddington = FALSE;

  getCPU(0, TIME_START, NULL);
  SetFPEtraps();

  fpin  = fopen("2dinput.dat", "r");
  xdrstdio_create(&xdrs, fpin, XDR_DECODE);

  result = xdr_vector(&xdrs, (char *) inputs, N_INPUTS,
		      sizeof(int), (xdrproc_t) xdr_int);

  atmos.angleSet.set = (enum angleset) inputs[0];
  if (atmos.angleSet.set == SET_GL) {
     result = xdr_int(&xdrs, &atmos.angleSet.Ninclination);
     result = xdr_int(&xdrs, &atmos.angleSet.Nazimuth);
  }
  result = xdr_double(&xdrs, &iterLimit);
  result = xdr_double(&xdrs, &Adamp);

  Nx = geometry.Nx = inputs[1];
  Nz = geometry.Nz = inputs[2];
  NmaxIter = inputs[3];
  Ngdelay  = inputs[4];  Ngorder = inputs[5];  Ngperiod = inputs[6];
  Nlambda  = inputs[7];
  Nspace   = atmos.Nspace = geometry.Nx * geometry.Nz;

  result = xdr_vector(&xdrs, (char *) btype, 3,
		      sizeof(int), (xdrproc_t) xdr_int);
  geometry.hboundary = (enum boundary) btype[0];
  for (n = 0;  n < 2;  n++)
    geometry.bvalue[n] = (enum boundval) btype[1+n];

  /* --- Check the validity of boundary conditions and values -- ---- */ 

  switch (geometry.hboundary) {
  case FIXED:     break;
  case PERIODIC:  break;
  default:
    sprintf(messageStr, "Invalid horizontal boundary condition: %d",
	    geometry.hboundary);
    Error(ERROR_LEVEL_2, argv[0], messageStr);
    break;
  }

  switch (geometry.bvalue[TOP]) {
  case IRRADIATED:   break;
  case ZERO:         break;
  case THERMALIZED:  break;
  default:
    sprintf(messageStr, "Invalid boundary value at TOP: %d\n",
	    geometry.bvalue[TOP]);
    Error(ERROR_LEVEL_2, argv[0], messageStr);
    break;
  }
  switch (geometry.bvalue[BOTTOM]) {
  case IRRADIATED:   break;
  case ZERO:         break;
  case THERMALIZED:  break;
  default:
    sprintf(messageStr, "Invalid boundary value at BOTTOM: %d",
	    geometry.bvalue[BOTTOM]);
    Error(ERROR_LEVEL_2, argv[0], messageStr);
    break;
  }

  /* --- Get increments in x, store and check for monotonicity -- --- */

  geometry.dx = (double *) malloc(Nx * sizeof(double));
  result = xdr_vector(&xdrs, (char *) geometry.dx, Nx,
		       sizeof(double), (xdrproc_t) xdr_double);
  for (l = 0;  l < ((geometry.hboundary == PERIODIC) ? Nx : Nx-1);  l++) {
    geometry.dx[l] *= KM_TO_M;
    if (geometry.dx[l] <= 0.0) {
      sprintf(messageStr, "At l = %d:\n x does not increase strictly "
              "monotonically towards the right", l);
      Error(ERROR_LEVEL_2, argv[0], messageStr);
    } 
  }
  geometry.x = (double *) malloc(Nx * sizeof(double));
  geometry.x[0] = 0.0;
  for (l = 0;  l < Nx-1;  l++)
    geometry.x[l+1] = geometry.x[l] + geometry.dx[l];

  /* --- Get vertical grid --                          -------------- */

  geometry.z = (double *) malloc(Nz * sizeof(double));
  result = xdr_vector(&xdrs, (char *) geometry.z, Nz,
		      sizeof(double), (xdrproc_t) xdr_double);
  for (k = 0;  k < Nz;  k++) geometry.z[k] *= KM_TO_M;

  geometry.dz = (double *) malloc(Nz * sizeof(double));
  for (k = 0;  k < Nz-1;  k++) {
    geometry.dz[k] = geometry.z[k] - geometry.z[k+1];
    if (geometry.dz[k] <= 0.0) {
      sprintf(messageStr, "At k = %d:\n z does not decrease strictly "
              "monotonically towards the bottom", k);
      Error(ERROR_LEVEL_2, argv[0], messageStr);
    }
  }
  geometry.dz[Nz-1] = 0.0;


  chi = (double *) malloc(Nspace * sizeof(double));
  S   = (double *) malloc(Nspace * sizeof(double));
  Bp  = (double *) malloc(Nspace * sizeof(double));
  epsilon = (double *) malloc(Nspace * sizeof(double));

  result = xdr_vector(&xdrs, (char *) chi, Nspace,
		       sizeof(double), (xdrproc_t) xdr_double);
  result = xdr_vector(&xdrs, (char *) Bp, Nspace,
		       sizeof(double), (xdrproc_t) xdr_double);
  result = xdr_vector(&xdrs, (char *) epsilon, Nspace,
		       sizeof(double), (xdrproc_t) xdr_double);

  getBoundary(&atmos, &geometry);
  getAngleQuadr(&geometry);
  atmos.Nrays = geometry.Nrays;
  atmos.wmu   = geometry.wmu;
  fillMesh(&geometry);

  lambda = (double *) malloc(Nlambda * sizeof(double));
  phi    = (double *) malloc(Nlambda * sizeof(double));
  wlamb  = (double *) malloc(Nlambda * sizeof(double));

  result = xdr_vector(&xdrs, (char *) lambda, Nlambda,
		      sizeof(double), (xdrproc_t) xdr_double);
  wlamb[0] = (lambda[1] - lambda[0]);
  for (la = 1;  la < Nlambda-1;  la++)
    wlamb[la] = (lambda[la+1] - lambda[la-1]);
  wlamb[Nlambda-1] = (lambda[Nlambda-1] - lambda[Nlambda-2]);

  wphi = 0.0;
  for (la = 0;  la < Nlambda;  la++) {
    phi[la] = Voigt(Adamp, lambda[la], NULL, RYBICKI)/SQRTPI;
    wphi   += wlamb[la]*phi[la];
  }
  wphi = 1.0/wphi;

  xdr_destroy(&xdrs);
  fclose(fpin);

  for (k = 0;  k < Nspace;  k++)  S[k] = Bp[k];
  Ng_S = NgInit(Nspace, Ngdelay, Ngorder, Ngperiod, S);

  Iterate(NmaxIter, iterLimit);

  nwrite = fwrite(S, sizeof(double), Nspace, stdout);
  printTotalCPU();
}
示例#15
0
文件: upload.c 项目: Truhigh/goahead
static int processContentData(Webs *wp)
{
    WebsUpload  *file;
    WebsBuf         *content;
    ssize           size, nbytes;
    char            *data, *bp;

    content = &wp->input;
    file = wp->currentFile;

    size = bufLen(content);
    if (size < wp->boundaryLen) {
        /*  Incomplete boundary. Return and get more data */
        return 0;
    }
    if ((bp = getBoundary(wp, content->servp, size)) == 0) {
        trace(7, "uploadFilter: Got boundary filename %x", wp->clientFilename);
        if (wp->clientFilename) {
            /*  
                No signature found yet. probably more data to come. Must handle split boundaries.
             */
            data = content->servp;
            nbytes = ((int) (content->endp - data)) - (wp->boundaryLen - 1);
            if (nbytes > 0 && writeToFile(wp, content->servp, nbytes) < 0) {
                return -1;
            }
            websConsumeInput(wp, nbytes);
            /* Get more data */
            return 0;
        }
    }
    data = content->servp;
    nbytes = (bp) ? (bp - data) : bufLen(content);

    if (nbytes > 0) {
        websConsumeInput(wp, nbytes);
        /*  
            This is the CRLF before the boundary
         */
        if (nbytes >= 2 && data[nbytes - 2] == '\r' && data[nbytes - 1] == '\n') {
            nbytes -= 2;
        }
        if (wp->clientFilename) {
            /*  
                Write the last bit of file data and add to the list of files and define environment variables
             */
            if (writeToFile(wp, data, nbytes) < 0) {
                return -1;
            }
            hashEnter(wp->files, wp->uploadVar, valueSymbol(file), 0);
            defineUploadVars(wp);

        } else {
            /*  
                Normal string form data variables
             */
            data[nbytes] = '\0'; 
            trace(5, "uploadFilter: form[%s] = %s", wp->uploadVar, data);
            websDecodeUrl(wp->uploadVar, wp->uploadVar, -1);
            websDecodeUrl(data, data, -1);
            websSetVar(wp, wp->uploadVar, data);
        }
    }
    if (wp->clientFilename) {
        /*  
            Now have all the data (we've seen the boundary)
         */
        close(wp->upfd);
        wp->upfd = -1;
        wp->clientFilename = 0;
        wfree(wp->uploadTmp);
        wp->uploadTmp = 0;
    }
    wp->uploadState = UPLOAD_BOUNDARY;
    return 0;
}
示例#16
0
Boundary SUMOSAXAttributes::getInternal(const int attr) const {
    return getBoundary(attr);
}
示例#17
0
Boundary
GNEConnection::getCenteringBoundary() const {
    Boundary b = getBoundary();
    b.grow(20);
    return b;
}