Changes in / [23e09b:6d4a76]
- Location:
- src
- Files:
-
- 3 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/boundary.cpp
r23e09b r6d4a76 2 2 #include "boundary.hpp" 3 3 4 #define DEBUG 0 4 #define DEBUG 1 5 #define DoTecplotOutput 0 6 #define DoRaster3DOutput 1 7 #define TecplotSuffix ".dat" 8 #define Raster3DSuffix ".r3d" 5 9 6 10 // ======================================== Points on Boundary ================================= … … 564 568 } 565 569 ; 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 */ 577 void 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 }; 566 624 567 625 /* … … 1923 1981 /** This function finds a triangle to a line, adjacent to an existing one. 1924 1982 * @param out output stream for debugging 1925 * @param tecplot output stream for writing found triangles in TecPlot format1926 1983 * @param mol molecule structure with all atoms and bonds 1927 1984 * @param Line current baseline to search from … … 1930 1987 * @param N number of found triangles 1931 1988 */ 1932 void Tesselation::Find_next_suitable_triangle(ofstream *out, ofstream *tecplot,1989 void Tesselation::Find_next_suitable_triangle(ofstream *out, 1933 1990 molecule* mol, BoundaryLineSet &Line, BoundaryTriangleSet &T, 1934 const double& RADIUS, int N )1991 const double& RADIUS, int N, const char *tempbasename) 1935 1992 { 1936 1993 cout << Verbose(1) << "Looking for next suitable triangle \n"; … … 1939 1996 Vector Chord; 1940 1997 ofstream *tempstream = NULL; 1941 char filename[255]; 1998 char NumberName[255]; 1999 double tmp; 2000 //atom* Walker; 1942 2001 atom* OldThirdPoint; 1943 2002 … … 2008 2067 cout << "Letzter Winkel bei " << TrianglesOnBoundaryCount << " Winkel ist " << Storage[2] << endl; 2009 2068 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++; 2019 2095 } 2020 2096 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 2029 2098 2030 2099 cout << " Optimal candidate is " << *Opt_Candidate << endl; … … 2229 2298 ; 2230 2299 2231 void Find_non_convex_border(ofstream *out, ofstream *tecplot, molecule* mol)2300 void Find_non_convex_border(ofstream *out, const char *filename, molecule* mol) 2232 2301 { 2233 2302 int N = 0; … … 2237 2306 const double RADIUS = 6.; 2238 2307 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 2239 2310 Tess->Find_starting_triangle(mol, RADIUS); 2240 2311 … … 2245 2316 { 2246 2317 cout << Verbose(1) << "Begin of Tesselation ... " << endl; 2247 Tess->Find_next_suitable_triangle(out, tecplot,mol,2318 Tess->Find_next_suitable_triangle(out, mol, 2248 2319 *(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; 2250 2322 cout << Verbose(1) << "End of Tesselation ... " << endl; 2251 2323 } … … 2259 2331 baseline++; 2260 2332 } 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 86 86 void AddTriangleToLines(); 87 87 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); 89 89 90 90 PointMap PointsOnBoundary; … … 111 111 void PrepareClustersinWater(ofstream *out, config *configuration, molecule *mol, double ClusterVolume, double celldensity); 112 112 void 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);113 void Find_non_convex_border(ofstream *out, const char *filename, molecule* mol); 114 114 115 115 -
src/builder.cpp
r23e09b r6d4a76 1025 1025 else { 1026 1026 cout << Verbose(0) << "Evaluating npn-convex envelope."; 1027 ofstream *output = new ofstream(argv[argptr], ios::trunc);1028 1027 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); 1032 1029 argptr+=1; 1033 1030 } … … 1037 1034 if ((argptr >= argc) || (argv[argptr][0] == '-')) { 1038 1035 ExitFlag = 255; 1039 cerr << "Not enough or invalid arguments given for storing temp ature: -T <temperature file>" << endl;1036 cerr << "Not enough or invalid arguments given for storing temperature: -T <temperature file>" << endl; 1040 1037 } else { 1041 1038 cout << Verbose(1) << "Storing temperatures in " << argv[argptr] << "." << endl;
Note:
See TracChangeset
for help on using the changeset viewer.