Exemplo n.º 1
0
void eventor::write_footprint(std::ofstream& fh)
{
	// write the footprint out - write values out that are not mv
	for (int j=0; j<footprint_height; j++)
		for (int i=0; i<footprint_width; i++)
		{
			int idx = j*footprint_width+i;
			if (wind_footprint[idx] > w_mv)
			{
				// get the true latitude / longitude from the rotated grid
				FP_TYPE tru_lon, tru_lat;
				tru_lon = mslp_field[0]->get_rotated_grid()->get_global_longitude_value(i,j);
				tru_lat = mslp_field[0]->get_rotated_grid()->get_global_latitude_value(i,j);
				// get the grid box corner points
				std::list<FP_TYPE> gb_corners = mslp_field[0]->get_rotated_grid()->get_global_grid_box_values(i,j);
				// write the data
				fh.precision(2);
				fh << std::fixed;
				fh << tru_lon << "," << tru_lat << ",";
				for (std::list<FP_TYPE>::iterator it_gbc = gb_corners.begin(); 
					 it_gbc != gb_corners.end(); it_gbc++)
					fh << *it_gbc << ",";		// order is lon0,lat0, lon1,lat1, lon2,lat2, lon3,lat3
				fh.precision(0);
				fh << mslp_footprint[idx] << ",";
				fh.precision(2);
				fh << wind_footprint[idx] << "," << std::endl;
			}
		}
}
Exemplo n.º 2
0
    static void
    write(std::ofstream &file, 
          const CrsMatrixType A,
          const std::string comment = "%% Tacho::MatrixMarket::Export",
          const int uplo = 0) {
      typedef typename CrsMatrixType::value_type   value_type;
      typedef typename CrsMatrixType::ordinal_type ordinal_type;
      typedef typename CrsMatrixType::size_type    size_type;

      std::streamsize prec = file.precision();
      file.precision(8);
      file << std::scientific;
      
      file << "%%MatrixMarket matrix coordinate "
           << (Util::isComplex<value_type>() ? "complex " : "real ")
           << ((uplo == Uplo::Upper || uplo == Uplo::Lower) ? "symmetric " : "general ")
           << std::endl;
      
      file << comment << std::endl;
      
      // cnt nnz
      size_type nnz = 0;
      for (ordinal_type i=0;i<A.NumRows();++i) {
        const size_type jbegin = A.RowPtrBegin(i), jend = A.RowPtrEnd(i);
        for (size_type j=jbegin;j<jend;++j) {
          const auto aj = A.Col(j);
          if (uplo == Uplo::Upper && i <= aj) ++nnz;
          if (uplo == Uplo::Lower && i >= aj) ++nnz;
          if (!uplo) ++nnz;
        }
      }
      file << A.NumRows() << " " << A.NumCols() << " " << nnz << std::endl;
      
      const int w = 10;
      for (ordinal_type i=0;i<A.NumRows();++i) {
        const size_type jbegin = A.RowPtrBegin(i), jend = A.RowPtrEnd(i);
        for (size_type j=jbegin;j<jend;++j) {
          const auto aj = A.Col(j);
          bool flag = false;
          if (uplo == Uplo::Upper && i <= aj) flag = true;
          if (uplo == Uplo::Lower && i >= aj) flag = true;
          if (!uplo) flag = true;
          if (flag) {
            value_type val = A.Value(j);
            file << std::setw(w) << ( i+1) << "  "
                 << std::setw(w) << (aj+1) << "  "
                 << std::setw(w) <<    val << std::endl;
          }
        }
      }
      
      file.unsetf(std::ios::scientific);
      file.precision(prec);
    }
Exemplo n.º 3
0
bool GravStep::savetofile(std::ofstream& ofs, const unsigned int stepid) {
	
	if (!ofs) {
		debugout("savetofile() - No File found!", 99);
		return false;
	}
	debugout("savetofile() - Objectlist", objects, 15);
	
	ofs << "#" << stepid << ";" << numObjects << DELIMLINE;
	ofs.precision(DATAPRECISION);
	
	//Add Data of each object to datafile
	std::vector<GravObject*>::iterator i;
	for (i = objects.begin(); i != objects.end(); ++i) {
		if (*i) {
	    	//[Objekt ID];[Masse];[Radius];[Geschw.Vektor x];[Geschw.Vektor y];[Geschw.Vektor z];
	    	//[Beschl.Vektor x];[Beschl.Vektor y];[Beschl.Vektor z];[Position x];[Position y];[Position z]
			//debugout("Model - AddStep() - Adding data to file No"+i);
			ofs << (*i)->id << DELIMDATA;
			ofs << (*i)->mass << DELIMDATA;
			ofs << (*i)->radius << DELIMDATA;
			ofs << (*i)->vel.x << DELIMDATA;
			ofs << (*i)->vel.y << DELIMDATA;
			ofs << (*i)->vel.z << DELIMDATA;
			ofs << (*i)->pos.x << DELIMDATA;
			ofs << (*i)->pos.y << DELIMDATA;
			ofs << (*i)->pos.z << DELIMLINE;
		}
	}
	debugout("savetofile() - Step successfully saved!", 40);
	return true;
}
Exemplo n.º 4
0
int main(int argc, char** argv)
{
	urbi::UClient* client = new urbi::UClient(argv[1], 54000);
	std::cout << "start"<<std::flush;
	client->setCallback (urbi::callback(onJointSensor),"legRF1");
	client->setCallback (urbi::callback(onJointSensor),"legRF2");
	client->setCallback (urbi::callback(onJointSensor),"legRF3");
	client->setCallback (urbi::callback(onJointSensor),"legRH1");
	client->setCallback (urbi::callback(onJointSensor),"legRH2");
	client->setCallback (urbi::callback(onJointSensor),"legRH3");
	client->setCallback (urbi::callback(onJointSensor),"legLF1");
	client->setCallback (urbi::callback(onJointSensor),"legLF2");
	client->setCallback (urbi::callback(onJointSensor),"legLF3");
	client->setCallback (urbi::callback(onJointSensor),"legLH1");
	client->setCallback (urbi::callback(onJointSensor),"legLH2");
	client->setCallback (urbi::callback(onJointSensor),"legLH3");
	client->setCallback (urbi::callback(onJointSensor),"mouth");
	client->setCallback (urbi::callback(onJointSensor),"headNeck");
	client->setCallback (urbi::callback(onJointSensor),"headPan");
	client->setCallback (urbi::callback(onJointSensor),"headTilt");
	client->setCallback (urbi::callback(onJointSensor),"tailTilt");
	client->setCallback (urbi::callback(onJointSensor),"tailPan");


	client->send("loop legRF1 << legRF1.val, loop legRF2 << legRF2.val, loop legRF3 << legRF3.val, loop legRH1 << legRH1.val, loop legRH2 << legRH2.val, loop legRH3 << legRH3.val, loop legLF1 << legLF1.val, loop legLF2 << legLF2.val, loop legLF3 << legLF3.val, loop legLH1 << legLH1.val, loop legLH2 << legLH2.val, loop legLH3 << legLH3.val, loop neck << neck.val, loop headTilt << headTilt.val, loop headPan << headPan.val, loop tailPan << tailPan.val, loop tailTilt << tailTilt.val, loop mouth << mouth.val,");
	std::cout << "send"<<std::flush;
	myfile.open ("Data1.txt");
	myfile.precision(15);
	urbi::execute();
	myfile.close();

	std::cout << "finish"<<std::flush;

	return(0);
}
Exemplo n.º 5
0
        void pluginLoad()
        {
            if (notifyFrequency > 0)
            {
                // number of cells on the current CPU for each direction
                const DataSpace<simDim> nrOfGpuCells = Environment<simDim>::get().SubGrid().getLocalDomain().size;

                // create as much storage as cells in the direction we are interested in:
                // on gpu und host
                sliceDataField = new GridBuffer<float3_X, DIM1 >
                        (DataSpace<DIM1 > (nrOfGpuCells.y()));

                Environment<>::get().PluginConnector().setNotificationPeriod(this, notifyFrequency);

                const int rank = Environment<simDim>::get().GridController().getGlobalRank();

                // open output file
                std::stringstream oFileName;
                oFileName << "lineSliceFields_" << rank << ".txt";

                outfile.open(oFileName.str().c_str(), std::ofstream::out | std::ostream::trunc);
                outfile.precision(8);
                outfile.setf(std::ios::scientific);
            }
        }
 TimeLoggingSolver(Solver *_solver, std::string path, const InstructionInfoProvider* _iip) 
 : solver(_solver),
   os(path.c_str(), std::ios::trunc),
   queryCount(0),
   iip(_iip) {
     os.precision(2);
 }
void ThermoPhase::reportCSV(std::ofstream& csvFile) const
{
    int tabS = 15;
    int tabM = 30;
    csvFile.precision(8);
    vector_fp X(nSpecies());
    getMoleFractions(&X[0]);
    std::vector<std::string> pNames;
    std::vector<vector_fp> data;
    getCsvReportData(pNames, data);

    csvFile << setw(tabS) << "Species,";
    for (size_t i = 0; i < pNames.size(); i++) {
        csvFile << setw(tabM) << pNames[i] << ",";
    }
    csvFile << endl;
    for (size_t k = 0; k < nSpecies(); k++) {
        csvFile << setw(tabS) << speciesName(k) + ",";
        if (X[k] > SmallNumber) {
            for (size_t i = 0; i < pNames.size(); i++) {
                csvFile << setw(tabM) << data[i][k] << ",";
            }
            csvFile << endl;
        } else {
            for (size_t i = 0; i < pNames.size(); i++) {
                csvFile << setw(tabM) << 0 << ",";
            }
            csvFile << endl;
        }
    }
}
Exemplo n.º 8
0
void Matrix::Show() const
{
	std::streamsize pr = cout.precision(5);
	cout << std::left;
	cout << "MATRIX " << n << 'x' << n << ": " << endl;
	for (size_t i = 0; i < n; i++)
	{
		for (size_t j = 0; j < n; j++)
		{
			cout << std::setw(10);
			cout << A[i][j];
			cout << ' ';
		}			
		cout << endl;
	}
	cout << endl;
	cout.precision(pr);
}
Exemplo n.º 9
0
void LasWell::WriteLasLine(std::ofstream     & file,
                           const std::string & mnemonic,
                           const std::string & units,
                           double              data,
                           const std::string & description)
{
  file.precision(3);
  file.setf(std::ios_base::fixed);

  file << mnemonic << " ." << units << " " << data << " : " << description << "\n";
}
Exemplo n.º 10
0
void WriteOutput(const Points& centroids, std::ofstream& output) {
  output.precision(15);
  for (size_t centroid_id = 0; centroid_id != centroids.size();
      ++centroid_id) {
    output << " centroid_id:" << centroid_id;
    for (const double component : centroids[centroid_id]) {
      output << '\t' << component;
    }
    output << std::endl;
  }
}
Exemplo n.º 11
0
  /*!Add a field*/
 void addvector(const string& nameoffield, Fem2D::Mesh* mesh, const KN<double>&val, const KN<double>&val2)
  {
   _ofdata.flags(std::ios_base::scientific);
   _ofdata.precision(15);

   _ofdata << "<DataArray type=\"Float32\" Name=\"";
   _ofdata << nameoffield<<"\" NumberOfComponents=\"3\" format=\"ascii\">";
   _ofdata << std::endl;
   for(int i=0;i<val.size();++i) _ofdata<<checkprecision(val[i])<< " " << checkprecision(val2[i]) << " " << 0.0 << std::endl;
   _ofdata << "</DataArray>" << std::endl;
   _ofdata.flush();
  }
Exemplo n.º 12
0
void write_cams(std::ofstream &file, CameraArray& cam_list)
{
	file.precision(10);
	file.setf(std::ios_base::scientific);

	size_t n_cams = cam_list.size();
	for (size_t i = 0; i < n_cams; ++i) {
		Camera &cam = *(std::dynamic_pointer_cast<Camera>(cam_list[i]));
		file << cam.focal[0] << " " << cam.disto_coeffs[0] << " " << cam.disto_coeffs[1] << std::endl;
		file << cam.rotation.toRotationMatrix() << std::endl;
		file << cam.translation.transpose() << std::endl;
	}
}
Exemplo n.º 13
0
void write_points(std::ofstream &file, std::vector<Point> &point_list)
{
	size_t n_points = point_list.size();
	for (size_t i = 0; i < n_points; ++i) {
		Point &pt = point_list[i];

		file.precision(10);
		file.setf(std::ios_base::scientific);

		file << pt.position.transpose() << std::endl;
		file << pt.color.transpose() << std::endl;

		write_visibility_list(file, pt);
	}
}
Exemplo n.º 14
0
 void write_vertices(std::ofstream& fout,
         const VectorF& vertices, const size_t dim) {
     if (dim != 2 && dim != 3) {
         throw IOError("Unsupported mesh dimension: " + std::to_string(dim));
     }
     fout.precision(16);
     size_t num_vertices = vertices.size() / dim;
     for (size_t i=0; i<num_vertices; i++) {
         const auto& v = vertices.segment(i*dim, dim);
         fout << "v";
         for (size_t j=0; j<dim; j++) {
             fout << " " << v[j];
         }
         fout << std::endl;
     }
 }
Exemplo n.º 15
0
void write_visibility_list(std::ofstream &file, Point& pt)
{
	file.precision(4);
	file.unsetf(std::ios_base::scientific);
	file.setf(std::ios_base::fixed, std::ios_base::floatfield);

	size_t n_vis = pt.visibility_list.size();
	file << n_vis << " ";

	for (size_t i = 0; i < n_vis; ++i) {
		Visibility &vis = pt.visibility_list[i];

		file << vis.camera_idx << " " << vis.keypoint_idx << " " << vis.position.transpose() << " ";
	}

	file.unsetf(std::ios_base::fixed);
	file.unsetf(std::ios_base::floatfield);
	file << std::endl;
}
Exemplo n.º 16
0
 void addmesh(Fem2D::Mesh* mesh)
  {
   Fem2D::Mesh& Th(*mesh);
   _vecmesh.push_back(mesh);
   _ofdata.flags(std::ios_base::scientific);
   _ofdata.precision(15);

   _ofdata << "<?xml version=\"1.0\"?>" << std::endl;
   _ofdata << "<VTKFile type=\"UnstructuredGrid\" version=\"0.1\" byte_order=\"LittleEndian\">" ;
   _ofdata << std::endl;
   _ofdata << "<UnstructuredGrid>" ; _ofdata << std::endl;
   _ofdata << "<Piece NumberOfPoints=\"" << Th.nv << "\" NumberOfCells=\"" << Th.nt << "\">"; 
   _ofdata << std::endl;
   _ofdata << "<Points>" << std::endl;
   _ofdata << "<DataArray type=\"Float32\" Name=\"Position\" NumberOfComponents=\"3\" format=\"ascii\">"; 
   _ofdata << std::endl;
   for(int k=0;k<Th.nv;++k) _ofdata << Th(k).x<<" "<<Th(k).y<< " " << 0.0 << std::endl;
   _ofdata << "</DataArray>" << std::endl;
   _ofdata << "</Points>" << std::endl;
   _ofdata << "<Cells>" << std::endl;
   _ofdata << "<DataArray type=\"Int32\" Name=\"connectivity\" NumberOfComponents=\"1\" format=\"ascii\">"; 
   _ofdata << std::endl;
   for(int i=0;i<Th.nt;++i)
    for (int j=0; j <3; j++) _ofdata << Th(i,j) << " " ;
   _ofdata << std::endl;
   _ofdata << "</DataArray>" << std::endl;
   _ofdata << "<DataArray type=\"Int32\" Name=\"offsets\" NumberOfComponents=\"1\" format=\"ascii\">"; 
   _ofdata << std::endl;	
   for(int i=0;i<Th.nt;++i)  _ofdata << 3+3*(i) << " ";
   _ofdata << std::endl;
   _ofdata << "</DataArray>" << std::endl;
   _ofdata << "<DataArray type=\"UInt8\" Name=\"types\" NumberOfComponents=\"1\" format=\"ascii\">" ; 
   _ofdata<< std::endl;	
   for(int i=0;i<Th.nt;++i)  _ofdata << 5 << " ";
   _ofdata << std::endl;
   _ofdata << "</DataArray>" << std::endl;
   _ofdata << "</Cells>" << std::endl; 
   _ofdata << "<PointData >" << endl; 
  }
int main() {
    ios::sync_with_stdio(false);

    int n;
    fin >> n;

    double x[n], y[n];

    int minindex = 0;

    for(int i = 0; i < n; i++) {
        fin >> x[i] >> y[i];

        if(x[minindex] > x[i]) {
            minindex = i;
        }
    }

    //2 ebe

    double res = 0;
    int sure = minindex, trypoint;
    do {
        trypoint = 0;
        for(int i = 1; i < n; i++) {
            if(sure == trypoint or toleft(x[sure], y[sure], x[trypoint], y[trypoint], x[i], y[i])) {
                trypoint = i;
            }
        }

        res += dist(x[sure], y[sure], x[trypoint], y[trypoint]);
        sure = trypoint;
    } while(sure != minindex);

    fout.precision(2);
    fout << fixed << res + dist(x[sure], y[sure], x[minindex], y[minindex]) << endl;
    return 0;
}
Exemplo n.º 18
0
//--------------------------------------------------
void blPDShapeWriter::WriteData(std::ofstream &output)
//--------------------------------------------------
{

	// --------------------------------------------------------
	// PolyData Start Tag
	// --------------------------------------------------------

	WriteStartElementIndent("PolyData",output);
	output << std::endl;


	// --------------------------------------------------------
	// Piece Start Tag
	// --------------------------------------------------------

	unsigned int numberOfPoints = this->m_InputObject->GetNumberOfLandmarks();
	unsigned int numberOfVerts = 0;
	unsigned int numberOfStrips = 0;
	unsigned int numberOfLines = this->m_InputObject->GetNumberOfPolylines();
	unsigned int numberOfPolys = this->m_InputObject->GetNumberOfPolygons();


	std::string pieceTag = "Piece NumberOfPoints=\"";

	char buffer[10];	// auxiliary buffer for temporal storing of strings

	sprintf(buffer, "%u", numberOfPoints);
	pieceTag += buffer;

	pieceTag += "\" NumberOfVerts=\"";

	sprintf(buffer, "%u", numberOfVerts);
	pieceTag += buffer;

	pieceTag += "\" NumberOfLines=\"";
	sprintf(buffer, "%u", numberOfLines);
	pieceTag += buffer;

	pieceTag += "\" NumberOfStrips=\"";
	sprintf(buffer, "%u", numberOfStrips);
	pieceTag += buffer;

	pieceTag += "\" NumberOfPolys=\"";
	sprintf(buffer, "%u", numberOfPolys);
	pieceTag += buffer;
	pieceTag += "\"";


	WriteStartElementIndent(pieceTag, output);
	output << std::endl;


	// --------------------------------------------------------
	// Points Start Tag
	// --------------------------------------------------------

	unsigned int numberDimensions = this->m_InputObject->GetDimension();

	sprintf(buffer,"%u", numberDimensions);

	std::string pointsTag = "Points NumberOfDimensions=\"";
	pointsTag += buffer;
	pointsTag += "\"";

	WriteStartElementIndent(pointsTag, output);
	output << std::endl;


	// --------------------------------------------------------
	// DataArray Start Tag
	// --------------------------------------------------------

	/// If precision is %.20e --> Float64
	//	WriteStartElementIndent("DataArray type=\"Float32\" NumberOfComponents=\"3\" format=\"ascii\"",output);
	WriteStartElementIndent("DataArray type=\"Float64\" NumberOfComponents=\"3\" format=\"ascii\"",output);
	output << std::endl;


	// write the point coordinates...

	unsigned int numberOfDimensions = this->m_InputObject->GetDimension();
	vnl_vector<double> points(numberOfPoints * numberOfDimensions);

	this->m_InputObject->GetPoints(points);


	///// PRECISION
	int prevPrecision = output.precision();

	output.precision(this->doublePrecision);
	///// PRECISION

	unsigned i;
	int x_pos = 0;

	for (i = 0; i < numberOfPoints; i++)
	{
		// indent
		this->WriteIndentation(output);

		output << points[x_pos] << " " << points[x_pos + 1];

		if (numberOfDimensions == 3)
		{
			output << " " << points[x_pos + 2];
		}
		else
		{
			output << " 0";
		}

		output << std::endl;

		x_pos += numberOfDimensions;
	}

	///// restore PRECISION
	output.precision(prevPrecision);
	///// PRECISION

	WriteEndElementIndent("DataArray",output);
	output << std::endl;


	// --------------------------------------------------------
	// Points End Tag
	// --------------------------------------------------------

	WriteEndElementIndent("Points",output);
	output << std::endl;


	// --------------------------------------------------------
	// PointData Start Tag
	// --------------------------------------------------------

	WriteStartElementIndent("PointData",output);
	output << std::endl;


	WriteEndElementIndent("PointData",output);
	output << std::endl;


	// --------------------------------------------------------
	// CellData Start Tag
	// --------------------------------------------------------


	WriteStartElementIndent("CellData",output);
	output << std::endl;

	WriteEndElementIndent("CellData",output);
	output << std::endl;



	// --------------------------------------------------------
	// Verts Start Tag
	// --------------------------------------------------------

	WriteStartElementIndent("Verts",output);
	output << std::endl;

	WriteStartElementIndent(
		"DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"",
		output);
	output << std::endl;

	WriteEndElementIndent("DataArray", output);
	output << std::endl;

	WriteStartElementIndent(
		"DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\"",
		output);
	output << std::endl;

	WriteEndElementIndent("DataArray", output);
	output << std::endl;

	WriteEndElementIndent("Verts",output);
	output << std::endl;


	// --------------------------------------------------------
	// Lines Start Tag
	// --------------------------------------------------------

	WriteStartElementIndent("Lines",output);
	output << std::endl;


	// vectors of connectivity and offset data
	std::vector<unsigned int> connectivityArray, offsetArray;

	// get the polylines from the shape
	blPDShapeInterface::ShapeCellsContainer polylines;
	this->m_InputObject->GetPolylines(polylines);

	// fill the vectors with connectivity and offset data
	this->GetConnectivityAndOffset(polylines, connectivityArray, offsetArray);

	polylines.clear();


	// connectivity
	// -----------------------

	WriteStartElementIndent(
		"DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"",
		output);
	output << std::endl;


	// write the connectivity array
	this->WriteDataArray(connectivityArray, output);


	WriteEndElementIndent("DataArray",output);
	output << std::endl;


	// offsets
	// -----------------------

	WriteStartElementIndent(
		"DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\"",
		output);
	output << std::endl;


	// write the offset array
	this->WriteDataArray(offsetArray, output);


	WriteEndElementIndent("DataArray",output);
	output << std::endl;


	WriteEndElementIndent("Lines",output);
	output << std::endl;


	// --------------------------------------------------------
	// Strips Start Tag
	// --------------------------------------------------------

	WriteStartElementIndent("Strips",output);
	output << std::endl;


	WriteStartElementIndent(
		"DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"",
		output);
	output << std::endl;

	WriteEndElementIndent("DataArray", output);
	output << std::endl;

	WriteStartElementIndent(
		"DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\"",
		output);
	output << std::endl;

	WriteEndElementIndent("DataArray", output);
	output << std::endl;

	WriteEndElementIndent("Strips",output);
	output << std::endl;


	// --------------------------------------------------------
	// Polys Start Tag
	// --------------------------------------------------------

	WriteStartElementIndent("Polys",output);
	output << std::endl;

	// get the polygons
	blPDShapeInterface::ShapeCellsContainer polygons;
	this->m_InputObject->GetPolygons(polygons);

	// fill vectors with connectivity and offset data
	this->GetConnectivityAndOffset(polygons, connectivityArray, offsetArray);

	polygons.clear();


	// connectivity
	// -----------------------

	WriteStartElementIndent(
		"DataArray type=\"Int32\" Name=\"connectivity\" format=\"ascii\"",
		output);
	output << std::endl;


	this->WriteDataArray(connectivityArray, output);


	WriteEndElementIndent("DataArray",output);
	output << std::endl;


	// offsets
	// -----------------------	

	WriteStartElementIndent(
		"DataArray type=\"Int32\" Name=\"offsets\" format=\"ascii\"",
		output);
	output << std::endl;


	this->WriteDataArray(offsetArray, output);


	WriteEndElementIndent("DataArray",output);
	output << std::endl;


	WriteEndElementIndent("Polys",output);
	output << std::endl;


	// --------------------------------------------------------
	// Piece End Tag
	// --------------------------------------------------------

	WriteEndElementIndent("Piece",output);
	output << std::endl;


	WriteEndElementIndent("PolyData",output);
	output << std::endl;

}
Exemplo n.º 19
0
 bool Mesh::SaveVRML2(std::ofstream & fout, const Material & material) const
 {
     if (fout.is_open())
     {
         fout.setf(std::ios::fixed, std::ios::floatfield);
         fout.setf(std::ios::showpoint);
         fout.precision(6);
         size_t nV = m_points.Size();
         size_t nT = m_triangles.Size();
         fout << "#VRML V2.0 utf8" << std::endl;
         fout << "" << std::endl;
         fout << "# Vertices: " << nV << std::endl;
         fout << "# Triangles: " << nT << std::endl;
         fout << "" << std::endl;
         fout << "Group {" << std::endl;
         fout << "    children [" << std::endl;
         fout << "        Shape {" << std::endl;
         fout << "            appearance Appearance {" << std::endl;
         fout << "                material Material {" << std::endl;
         fout << "                    diffuseColor " << material.m_diffuseColor[0] << " "
             << material.m_diffuseColor[1] << " "
             << material.m_diffuseColor[2] << std::endl;
         fout << "                    ambientIntensity " << material.m_ambientIntensity << std::endl;
         fout << "                    specularColor " << material.m_specularColor[0] << " "
             << material.m_specularColor[1] << " "
             << material.m_specularColor[2] << std::endl;
         fout << "                    emissiveColor " << material.m_emissiveColor[0] << " "
             << material.m_emissiveColor[1] << " "
             << material.m_emissiveColor[2] << std::endl;
         fout << "                    shininess " << material.m_shininess << std::endl;
         fout << "                    transparency " << material.m_transparency << std::endl;
         fout << "                }" << std::endl;
         fout << "            }" << std::endl;
         fout << "            geometry IndexedFaceSet {" << std::endl;
         fout << "                ccw TRUE" << std::endl;
         fout << "                solid TRUE" << std::endl;
         fout << "                convex TRUE" << std::endl;
         if (nV > 0)
         {
             fout << "                coord DEF co Coordinate {" << std::endl;
             fout << "                    point [" << std::endl;
             for (size_t v = 0; v < nV; v++)
             {
                 fout << "                        " << m_points[v][0] << " "
                     << m_points[v][1] << " "
                     << m_points[v][2] << "," << std::endl;
             }
             fout << "                    ]" << std::endl;
             fout << "                }" << std::endl;
         }
         if (nT > 0)
         {
             fout << "                coordIndex [ " << std::endl;
             for (size_t f = 0; f < nT; f++)
             {
                 fout << "                        " << m_triangles[f][0] << ", "
                     << m_triangles[f][1] << ", "
                     << m_triangles[f][2] << ", -1," << std::endl;
             }
             fout << "                ]" << std::endl;
         }
         fout << "            }" << std::endl;
         fout << "        }" << std::endl;
         fout << "    ]" << std::endl;
         fout << "}" << std::endl;
         return true;
     }
     return false;
 }
Exemplo n.º 20
0
/*
 * Format a summary of the mixture state for output.
 */
void MolalityVPSSTP::reportCSV(std::ofstream& csvFile) const
{


    csvFile.precision(3);
    int tabS = 15;
    int tabM = 30;
    int tabL = 40;
    try {
        if (name() != "") {
            csvFile << "\n"+name()+"\n\n";
        }
        csvFile << setw(tabL) << "temperature (K) =" << setw(tabS) << temperature() << endl;
        csvFile << setw(tabL) << "pressure (Pa) =" << setw(tabS) << pressure() << endl;
        csvFile << setw(tabL) << "density (kg/m^3) =" << setw(tabS) << density() << endl;
        csvFile << setw(tabL) << "mean mol. weight (amu) =" << setw(tabS) << meanMolecularWeight() << endl;
        csvFile << setw(tabL) << "potential (V) =" << setw(tabS) << electricPotential() << endl;
        csvFile << endl;

        csvFile << setw(tabL) << "enthalpy (J/kg) = " << setw(tabS) << enthalpy_mass() << setw(tabL) << "enthalpy (J/kmol) = " << setw(tabS) << enthalpy_mole() << endl;
        csvFile << setw(tabL) << "internal E (J/kg) = " << setw(tabS) << intEnergy_mass() << setw(tabL) << "internal E (J/kmol) = " << setw(tabS) << intEnergy_mole() << endl;
        csvFile << setw(tabL) << "entropy (J/kg) = " << setw(tabS) << entropy_mass() << setw(tabL) << "entropy (J/kmol) = " << setw(tabS) << entropy_mole() << endl;
        csvFile << setw(tabL) << "Gibbs (J/kg) = " << setw(tabS) << gibbs_mass() << setw(tabL) << "Gibbs (J/kmol) = " << setw(tabS) << gibbs_mole() << endl;
        csvFile << setw(tabL) << "heat capacity c_p (J/K/kg) = " << setw(tabS) << cp_mass() << setw(tabL) << "heat capacity c_p (J/K/kmol) = " << setw(tabS) << cp_mole() << endl;
        csvFile << setw(tabL) << "heat capacity c_v (J/K/kg) = " << setw(tabS) << cv_mass() << setw(tabL) << "heat capacity c_v (J/K/kmol) = " << setw(tabS) << cv_mole() << endl;

        csvFile.precision(8);

        vector<std::string> pNames;
        vector<vector_fp> data;
        vector_fp temp(nSpecies());

        getMoleFractions(&temp[0]);
        pNames.push_back("X");
        data.push_back(temp);
        try {
            getMolalities(&temp[0]);
            pNames.push_back("Molal");
            data.push_back(temp);
        } catch (CanteraError& err) {
            err.save();
        }
        try {
            getChemPotentials(&temp[0]);
            pNames.push_back("Chem. Pot. (J/kmol)");
            data.push_back(temp);
        } catch (CanteraError& err) {
            err.save();
        }
        try {
            getStandardChemPotentials(&temp[0]);
            pNames.push_back("Chem. Pot. SS (J/kmol)");
            data.push_back(temp);
        } catch (CanteraError& err) {
            err.save();
        }
        try {
            getMolalityActivityCoefficients(&temp[0]);
            pNames.push_back("Molal Act. Coeff.");
            data.push_back(temp);
        } catch (CanteraError& err) {
            err.save();
        }
        try {
            getActivities(&temp[0]);
            pNames.push_back("Molal Activity");
            data.push_back(temp);
            size_t iHp = speciesIndex("H+");
            if (iHp != npos) {
                double pH = -log(temp[iHp]) / log(10.0);
                csvFile << setw(tabL) << "pH = " << setw(tabS) << pH << endl;
            }
        } catch (CanteraError& err) {
            err.save();
        }
        try {
            getPartialMolarEnthalpies(&temp[0]);
            pNames.push_back("Part. Mol Enthalpy (J/kmol)");
            data.push_back(temp);
        } catch (CanteraError& err) {
            err.save();
        }
        try {
            getPartialMolarEntropies(&temp[0]);
            pNames.push_back("Part. Mol. Entropy (J/K/kmol)");
            data.push_back(temp);
        } catch (CanteraError& err) {
            err.save();
        }
        try {
            getPartialMolarIntEnergies(&temp[0]);
            pNames.push_back("Part. Mol. Energy (J/kmol)");
            data.push_back(temp);
        } catch (CanteraError& err) {
            err.save();
        }
        try {
            getPartialMolarCp(&temp[0]);
            pNames.push_back("Part. Mol. Cp (J/K/kmol");
            data.push_back(temp);
        } catch (CanteraError& err) {
            err.save();
        }
        try {
            getPartialMolarVolumes(&temp[0]);
            pNames.push_back("Part. Mol. Cv (J/K/kmol)");
            data.push_back(temp);
        } catch (CanteraError& err) {
            err.save();
        }

        csvFile << endl << setw(tabS) << "Species,";
        for (size_t i = 0; i < pNames.size(); i++) {
            csvFile << setw(tabM) << pNames[i] << ",";
        }
        csvFile << endl;
        /*
        csvFile.fill('-');
        csvFile << setw(tabS+(tabM+1)*pNames.size()) << "-\n";
        csvFile.fill(' ');
        */
        for (size_t k = 0; k < nSpecies(); k++) {
            csvFile << setw(tabS) << speciesName(k) + ",";
            if (data[0][k] > SmallNumber) {
                for (size_t i = 0; i < pNames.size(); i++) {
                    csvFile << setw(tabM) << data[i][k] << ",";
                }
                csvFile << endl;
            } else {
                for (size_t i = 0; i < pNames.size(); i++) {
                    csvFile << setw(tabM) << 0 << ",";
                }
                csvFile << endl;
            }
        }
    } catch (CanteraError& err) {
        err.save();
    }
}