Changes in / [23e09b:6d4a76]


Ignore:
Location:
src
Files:
3 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r23e09b r6d4a76  
    22#include "boundary.hpp"
    33
    4 #define DEBUG 0
     4#define DEBUG 1
     5#define DoTecplotOutput 0
     6#define DoRaster3DOutput 1
     7#define TecplotSuffix ".dat"
     8#define Raster3DSuffix ".r3d"
    59
    610// ======================================== Points on Boundary =================================
     
    564568}
    565569;
     570
     571/** Creates the objects in a raster3d file (renderable with a header.r3d)
     572 * \param *out output stream for debugging
     573 * \param *tecplot output stream for tecplot data
     574 * \param *Tess Tesselation structure with constructed triangles
     575 * \param *mol molecule structure with atom positions
     576 */
     577void write_raster3d_file(ofstream *out, ofstream *rasterfile, class Tesselation *Tess, class molecule *mol)
     578{
     579  atom *Walker = mol->start;
     580  bond *Binder = mol->first;
     581  int i;
     582  Vector *center = mol->DetermineCenterOfAll(out);
     583  if (rasterfile != NULL) {
     584    //cout << Verbose(1) << "Writing Raster3D file ... ";
     585    *rasterfile << "# Raster3D object description, created by MoleCuilder" << endl;
     586    *rasterfile << "@header.r3d" << endl;
     587    *rasterfile << "# All atoms as spheres" << endl;
     588    while (Walker->next != mol->end) {
     589      Walker = Walker->next;
     590      *rasterfile << "2" << endl << "  "; // 2 is sphere type
     591      for (i=0;i<NDIM;i++)
     592        *rasterfile << Walker->x.x[i]+center->x[i] << " ";
     593      *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
     594    }
     595
     596    *rasterfile << "# All bonds as vertices" << endl;
     597    while (Binder->next != mol->last) {
     598      Binder = Binder->next;
     599      *rasterfile << "3" << endl << "  "; // 2 is round-ended cylinder type
     600      for (i=0;i<NDIM;i++)
     601        *rasterfile << Binder->leftatom->x.x[i]+center->x[i] << " ";
     602      *rasterfile << "\t0.03\t";
     603      for (i=0;i<NDIM;i++)
     604        *rasterfile << Binder->rightatom->x.x[i]+center->x[i] << " ";
     605      *rasterfile << "\t0.03\t0. 0. 1." << endl; // radius 0.05 and blue as colour
     606    }
     607
     608    *rasterfile << "# All tesselation triangles" << endl;
     609    for (TriangleMap::iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) {
     610      *rasterfile << "1" << endl << "  "; // 1 is triangle type
     611      for (i=0;i<3;i++) { // print each node
     612        for (int j=0;j<NDIM;j++)  // and for each node all NDIM coordinates
     613          *rasterfile << TriangleRunner->second->endpoints[i]->node->x.x[j]+center->x[j] << " ";
     614        *rasterfile << "\t";
     615      }
     616      *rasterfile << "1. 0. 0." << endl;  // red as colour
     617      *rasterfile << "18" << endl << "  0.5 0.5 0.5" << endl; // 18 is transparency type for previous object
     618    }
     619  } else {
     620    cerr << "ERROR: Given rasterfile is " << rasterfile << "." << endl;
     621  }
     622  delete(center);
     623};
    566624
    567625/*
     
    19231981/** This function finds a triangle to a line, adjacent to an existing one.
    19241982 * @param out   output stream for debugging
    1925  * @param tecplot output stream for writing found triangles in TecPlot format
    19261983 * @param mol molecule structure with all atoms and bonds
    19271984 * @param Line current baseline to search from
     
    19301987 * @param N number of found triangles
    19311988 */
    1932 void Tesselation::Find_next_suitable_triangle(ofstream *out, ofstream *tecplot,
     1989void Tesselation::Find_next_suitable_triangle(ofstream *out,
    19331990    molecule* mol, BoundaryLineSet &Line, BoundaryTriangleSet &T,
    1934     const double& RADIUS, int N)
     1991    const double& RADIUS, int N, const char *tempbasename)
    19351992{
    19361993  cout << Verbose(1) << "Looking for next suitable triangle \n";
     
    19391996  Vector Chord;
    19401997  ofstream *tempstream = NULL;
    1941   char filename[255];
     1998  char NumberName[255];
     1999  double tmp;
     2000  //atom* Walker;
    19422001  atom* OldThirdPoint;
    19432002
     
    20082067      cout << "Letzter Winkel bei " << TrianglesOnBoundaryCount << " Winkel ist " << Storage[2] << endl;
    20092068
    2010 
    2011   if ((TrianglesOnBoundaryCount % 1) == 0)
    2012     {
    2013     sprintf(filename, "testEnvelope-%d.dat", TriangleFilesWritten);
    2014     tempstream = new ofstream(filename, ios::trunc);
    2015     write_tecplot_file(out, tempstream, this, mol, TriangleFilesWritten++);
    2016     tempstream->close();
    2017     tempstream->flush();
    2018     delete(tempstream);
     2069  if ((TrianglesOnBoundaryCount % 10) == 0) {
     2070    sprintf(NumberName, "-%d", TriangleFilesWritten);
     2071    if (DoTecplotOutput) {
     2072      string NameofTempFile(tempbasename);
     2073      NameofTempFile.append(NumberName);
     2074      NameofTempFile.append(TecplotSuffix);
     2075      cout << Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
     2076      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
     2077      write_tecplot_file(out, tempstream, this, mol, TriangleFilesWritten);
     2078      tempstream->close();
     2079      tempstream->flush();
     2080      delete(tempstream);
     2081    }
     2082    if (DoRaster3DOutput) {
     2083      string NameofTempFile(tempbasename);
     2084      NameofTempFile.append(NumberName);
     2085      NameofTempFile.append(Raster3DSuffix);
     2086      cout << Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
     2087      tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
     2088      write_raster3d_file(out, tempstream, this, mol);
     2089      tempstream->close();
     2090      tempstream->flush();
     2091      delete(tempstream);
     2092    }
     2093    if (DoTecplotOutput || DoRaster3DOutput)
     2094      TriangleFilesWritten++;
    20192095  }
    20202096
    2021   if (TrianglesOnBoundaryCount >189 and TrianglesOnBoundaryCount < 200 )
    2022     {
    2023       cout << Verbose(1)
    2024           << "No new Atom found, triangle construction will crash" << endl;
    2025       write_tecplot_file(out, tecplot, this, mol, TriangleFilesWritten);
    2026       cout << "This is currently added candidate" << Opt_Candidate << endl;
    2027     }
    2028   // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke
     2097      // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke
    20292098
    20302099  cout << " Optimal candidate is " << *Opt_Candidate << endl;
     
    22292298;
    22302299
    2231 void Find_non_convex_border(ofstream *out, ofstream *tecplot, molecule* mol)
     2300void Find_non_convex_border(ofstream *out, const char *filename, molecule* mol)
    22322301{
    22332302  int N = 0;
     
    22372306  const double RADIUS = 6.;
    22382307  LineMap::iterator baseline;
     2308  cout << Verbose(0) << "Begin of Find_non_convex_border\n";
     2309  bool flag = false;  // marks whether we went once through all baselines without finding any without two triangles
    22392310  Tess->Find_starting_triangle(mol, RADIUS);
    22402311
     
    22452316        {
    22462317          cout << Verbose(1) << "Begin of Tesselation ... " << endl;
    2247           Tess->Find_next_suitable_triangle(out, tecplot, mol,
     2318          Tess->Find_next_suitable_triangle(out, mol,
    22482319              *(baseline->second),
    2249               *(((baseline->second->triangles.begin()))->second), RADIUS, N); //the line is there, so there is a triangle, but only one.
     2320              *(((baseline->second->triangles.begin()))->second), RADIUS, N, filename); //the line is there, so there is a triangle, but only one.
     2321          flag = true;
    22502322          cout << Verbose(1) << "End of Tesselation ... " << endl;
    22512323        }
     
    22592331      baseline++;
    22602332    }
    2261   write_tecplot_file(out, tecplot, Tess, mol, -1);
    2262 
    2263 }
    2264 ;
     2333  cout << Verbose(1) << "Writing final tecplot file\n";
     2334  if (DoTecplotOutput) {
     2335    string Name(filename);
     2336    Name.append(TecplotSuffix);
     2337    ofstream tecplot(Name.c_str(), ios::trunc);
     2338    write_tecplot_file(out, &tecplot, Tess, mol, -1);
     2339    tecplot.close();
     2340  }
     2341  if (DoRaster3DOutput) {
     2342    string Name(filename);
     2343    Name.append(Raster3DSuffix);
     2344    ofstream raster(Name.c_str(), ios::trunc);
     2345    write_raster3d_file(out, &raster, Tess, mol);
     2346    raster.close();
     2347  }
     2348}
     2349;
  • src/boundary.hpp

    r23e09b r6d4a76  
    8686    void AddTriangleToLines();
    8787    void Find_starting_triangle(molecule* mol, const double RADIUS);
    88     void Find_next_suitable_triangle(ofstream *out, ofstream *tecplot, molecule* mol, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, int N);
     88    void Find_next_suitable_triangle(ofstream *out, molecule* mol, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS, int N, const char *tempbasename);
    8989
    9090    PointMap PointsOnBoundary;
     
    111111void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double ClusterVolume, double celldensity);
    112112void Find_next_suitable_point(atom a, atom b, atom Candidate, int n, Vector *d1, Vector *d2, atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule *mol, bool problem);
    113 void Find_non_convex_border(ofstream *out, ofstream *tecplot, molecule* mol);
     113void Find_non_convex_border(ofstream *out, const char *filename, molecule* mol);
    114114
    115115
  • src/builder.cpp

    r23e09b r6d4a76  
    10251025                else {
    10261026                        cout << Verbose(0) << "Evaluating npn-convex envelope.";
    1027                         ofstream *output = new ofstream(argv[argptr], ios::trunc);
    10281027                        cout << Verbose(1) << "Storing tecplot data in " << argv[argptr] << "." << endl;
    1029                         Find_non_convex_border((ofstream *)&cout, output, mol);
    1030                         output->close();
    1031                         delete(output);
     1028                        Find_non_convex_border((ofstream *)&cout, argv[argptr], mol);
    10321029                        argptr+=1;
    10331030                        }
     
    10371034              if ((argptr >= argc) || (argv[argptr][0] == '-')) {
    10381035                ExitFlag = 255;
    1039                 cerr << "Not enough or invalid arguments given for storing tempature: -T <temperature file>" << endl;
     1036                cerr << "Not enough or invalid arguments given for storing temperature: -T <temperature file>" << endl;
    10401037              } else {
    10411038                cout << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl;
Note: See TracChangeset for help on using the changeset viewer.