Changeset 57066a for src/boundary.cpp


Ignore:
Timestamp:
Sep 28, 2009, 8:00:33 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Branches:
Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
Children:
e4a379
Parents:
91e7e4a
git-author:
Frederik Heber <heber@…> (09/28/09 18:47:54)
git-committer:
Frederik Heber <heber@…> (09/28/09 20:00:33)
Message:

Various fixes and attempt to get convex hull working.

Moved tesselation writing to tesselation.cpp

  • WriteVrmlFile(), WriteRaster3dFile(), WriteTecplotFile() moved to tesselation.cpp
  • these also don't use molecule anymore, but the PointCloud structure (hence, bonds are no more visible)
  • new function TesselStruct::Output() which performs the writing
  • new function InsertSphereInRaster3D(), which places a sphere at the position of the last triangle
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r91e7e4a r57066a  
    112112;
    113113
    114 /** Creates the objects in a VRML file.
    115  * \param *out output stream for debugging
    116  * \param *vrmlfile output stream for tecplot data
    117  * \param *Tess Tesselation structure with constructed triangles
    118  * \param *mol molecule structure with atom positions
    119  */
    120 void WriteVrmlFile(ofstream *out, ofstream *vrmlfile, class Tesselation *Tess, class molecule *mol)
    121 {
    122   atom *Walker = mol->start;
    123   bond *Binder = mol->first;
    124   int i;
    125   Vector *center = mol->DetermineCenterOfAll(out);
    126   if (vrmlfile != NULL) {
    127     //cout << Verbose(1) << "Writing Raster3D file ... ";
    128     *vrmlfile << "#VRML V2.0 utf8" << endl;
    129     *vrmlfile << "#Created by molecuilder" << endl;
    130     *vrmlfile << "#All atoms as spheres" << endl;
    131     while (Walker->next != mol->end) {
    132       Walker = Walker->next;
    133       *vrmlfile << "Sphere {" << endl << "  "; // 2 is sphere type
    134       for (i=0;i<NDIM;i++)
    135         *vrmlfile << Walker->x.x[i]-center->x[i] << " ";
    136       *vrmlfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
    137     }
    138 
    139     *vrmlfile << "# All bonds as vertices" << endl;
    140     while (Binder->next != mol->last) {
    141       Binder = Binder->next;
    142       *vrmlfile << "3" << endl << "  "; // 2 is round-ended cylinder type
    143       for (i=0;i<NDIM;i++)
    144         *vrmlfile << Binder->leftatom->x.x[i]-center->x[i] << " ";
    145       *vrmlfile << "\t0.03\t";
    146       for (i=0;i<NDIM;i++)
    147         *vrmlfile << Binder->rightatom->x.x[i]-center->x[i] << " ";
    148       *vrmlfile << "\t0.03\t0. 0. 1." << endl; // radius 0.05 and blue as colour
    149     }
    150 
    151     *vrmlfile << "# All tesselation triangles" << endl;
    152     for (TriangleMap::iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) {
    153       *vrmlfile << "1" << endl << "  "; // 1 is triangle type
    154       for (i=0;i<3;i++) { // print each node
    155         for (int j=0;j<NDIM;j++)  // and for each node all NDIM coordinates
    156           *vrmlfile << TriangleRunner->second->endpoints[i]->node->node->x[j]-center->x[j] << " ";
    157         *vrmlfile << "\t";
    158       }
    159       *vrmlfile << "1. 0. 0." << endl;  // red as colour
    160       *vrmlfile << "18" << endl << "  0.5 0.5 0.5" << endl; // 18 is transparency type for previous object
    161     }
    162   } else {
    163     cerr << "ERROR: Given vrmlfile is " << vrmlfile << "." << endl;
    164   }
    165   delete(center);
    166 };
    167 
    168 /** Creates the objects in a raster3d file (renderable with a header.r3d).
    169  * \param *out output stream for debugging
    170  * \param *rasterfile output stream for tecplot data
    171  * \param *Tess Tesselation structure with constructed triangles
    172  * \param *mol molecule structure with atom positions
    173  */
    174 void WriteRaster3dFile(ofstream *out, ofstream *rasterfile, class Tesselation *Tess, class molecule *mol)
    175 {
    176   atom *Walker = mol->start;
    177   bond *Binder = mol->first;
    178   int i;
    179   Vector *center = mol->DetermineCenterOfAll(out);
    180   if (rasterfile != NULL) {
    181     //cout << Verbose(1) << "Writing Raster3D file ... ";
    182     *rasterfile << "# Raster3D object description, created by MoleCuilder" << endl;
    183     *rasterfile << "@header.r3d" << endl;
    184     *rasterfile << "# All atoms as spheres" << endl;
    185     while (Walker->next != mol->end) {
    186       Walker = Walker->next;
    187       *rasterfile << "2" << endl << "  ";  // 2 is sphere type
    188       for (i=0;i<NDIM;i++)
    189         *rasterfile << Walker->x.x[i]-center->x[i] << " ";
    190       *rasterfile << "\t0.1\t1. 1. 1." << endl; // radius 0.05 and white as colour
    191     }
    192 
    193     *rasterfile << "# All bonds as vertices" << endl;
    194     while (Binder->next != mol->last) {
    195       Binder = Binder->next;
    196       *rasterfile << "3" << endl << "  ";  // 2 is round-ended cylinder type
    197       for (i=0;i<NDIM;i++)
    198         *rasterfile << Binder->leftatom->x.x[i]-center->x[i] << " ";
    199       *rasterfile << "\t0.03\t";
    200       for (i=0;i<NDIM;i++)
    201         *rasterfile << Binder->rightatom->x.x[i]-center->x[i] << " ";
    202       *rasterfile << "\t0.03\t0. 0. 1." << endl; // radius 0.05 and blue as colour
    203     }
    204 
    205     *rasterfile << "# All tesselation triangles" << endl;
    206     *rasterfile << "8\n  25. -1.   1. 1. 1.   0.0    0 0 0 2\n  SOLID     1.0 0.0 0.0\n  BACKFACE  0.3 0.3 1.0   0 0\n";
    207     for (TriangleMap::iterator TriangleRunner = Tess->TrianglesOnBoundary.begin(); TriangleRunner != Tess->TrianglesOnBoundary.end(); TriangleRunner++) {
    208       *rasterfile << "1" << endl << "  ";  // 1 is triangle type
    209       for (i=0;i<3;i++) {  // print each node
    210         for (int j=0;j<NDIM;j++)  // and for each node all NDIM coordinates
    211           *rasterfile << TriangleRunner->second->endpoints[i]->node->node->x[j]-center->x[j] << " ";
    212         *rasterfile << "\t";
    213       }
    214       *rasterfile << "1. 0. 0." << endl;  // red as colour
    215       //*rasterfile << "18" << endl << "  0.5 0.5 0.5" << endl;  // 18 is transparency type for previous object
    216     }
    217     *rasterfile << "9\n#  terminating special property\n";
    218   } else {
    219     cerr << "ERROR: Given rasterfile is " << rasterfile << "." << endl;
    220   }
    221   delete(center);
    222 };
    223 
    224 /** This function creates the tecplot file, displaying the tesselation of the hull.
    225  * \param *out output stream for debugging
    226  * \param *tecplot output stream for tecplot data
    227  * \param N arbitrary number to differentiate various zones in the tecplot format
    228  */
    229 void WriteTecplotFile(ofstream *out, ofstream *tecplot, class Tesselation *TesselStruct, class molecule *mol, int N)
    230 {
    231   if ((tecplot != NULL) && (TesselStruct != NULL)) {
    232     // write header
    233     *tecplot << "TITLE = \"3D CONVEX SHELL\"" << endl;
    234     *tecplot << "VARIABLES = \"X\" \"Y\" \"Z\" \"U\"" << endl;
    235     *tecplot << "ZONE T=\"TRIANGLES" << N << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl;
    236     int *LookupList = new int[mol->AtomCount];
    237     for (int i = 0; i < mol->AtomCount; i++)
    238       LookupList[i] = -1;
    239 
    240     // print atom coordinates
    241     *out << Verbose(2) << "The following triangles were created:";
    242     int Counter = 1;
    243     TesselPoint *Walker = NULL;
    244     for (PointMap::iterator target = TesselStruct->PointsOnBoundary.begin(); target != TesselStruct->PointsOnBoundary.end(); target++) {
    245       Walker = target->second->node;
    246       LookupList[Walker->nr] = Counter++;
    247       *tecplot << Walker->node->x[0] << " " << Walker->node->x[1] << " " << Walker->node->x[2] << " " << target->second->value << endl;
    248     }
    249     *tecplot << endl;
    250     // print connectivity
    251     for (TriangleMap::iterator runner = TesselStruct->TrianglesOnBoundary.begin(); runner != TesselStruct->TrianglesOnBoundary.end(); runner++) {
    252       *out << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name;
    253       *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl;
    254     }
    255     delete[] (LookupList);
    256     *out << endl;
    257   }
    258 }
    259 
    260114
    261115/** Determines the boundary points of a cluster.
     
    536390
    537391        // flip the line
    538         if (!mol->TesselStruct->PickFarthestofTwoBaselines(out, line))
     392        if (mol->TesselStruct->PickFarthestofTwoBaselines(out, line) == 0.)
    539393          *out << Verbose(1) << "ERROR: Correction of concave baselines failed!" << endl;
    540         else
     394        else {
     395          mol->TesselStruct->FlipBaseline(out, line);
    541396          *out << Verbose(1) << "INFO: Correction of concave baselines worked." << endl;
     397        }
    542398      }
    543399    }
     
    644500  class BoundaryLineSet *line = NULL;
    645501  bool Concavity;
     502  char dummy[MAXSTRINGSIZE];
    646503  PointMap::iterator PointRunner, PointAdvance;
    647504  LineMap::iterator LineRunner, LineAdvance;
     
    656513  }
    657514
    658   //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
    659   StoreTrianglesinFile(out, mol, filename, "-first");
    660 
    661515  // First step: RemovePointFromTesselatedSurface
     516  int run = 0;
     517  double tmp;
    662518  do {
    663519    Concavity = false;
     520    sprintf(dummy, "-first-%d", run);
     521    //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     522    StoreTrianglesinFile(out, mol, filename, dummy);
     523
    664524    PointRunner = TesselStruct->PointsOnBoundary.begin();
    665525    PointAdvance = PointRunner; // we need an advanced point, as the PointRunner might get removed
     
    671531        line = LineRunner->second;
    672532        *out << Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
    673       }
    674       if (!line->CheckConvexityCriterion(out)) {
    675         *out << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl;
    676         // remove the point
    677         Concavity = true;
    678         TesselStruct->RemovePointFromTesselatedSurface(out, point);
     533        if (!line->CheckConvexityCriterion(out)) {
     534          // remove the point if needed
     535          *out << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl;
     536          volume += TesselStruct->RemovePointFromTesselatedSurface(out, point);
     537          sprintf(dummy, "-first-%d", ++run);
     538          StoreTrianglesinFile(out, mol, filename, dummy);
     539          Concavity = true;
     540          break;
     541        }
    679542      }
    680543      PointRunner = PointAdvance;
    681544    }
    682545
     546    sprintf(dummy, "-second-%d", run);
    683547    //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
    684     //StoreTrianglesinFile(out, mol, filename, "-second");
     548    StoreTrianglesinFile(out, mol, filename, dummy);
    685549
    686550    // second step: PickFarthestofTwoBaselines
     
    693557      // take highest of both lines
    694558      if (TesselStruct->IsConvexRectangle(out, line) == NULL) {
    695         TesselStruct->PickFarthestofTwoBaselines(out, line);
    696         Concavity = true;
     559        tmp = TesselStruct->PickFarthestofTwoBaselines(out, line);
     560        volume += tmp;
     561        if (tmp != 0) {
     562          mol->TesselStruct->FlipBaseline(out, line);
     563          Concavity = true;
     564        }
    697565      }
    698566      LineRunner = LineAdvance;
    699567    }
     568    run++;
    700569  } while (Concavity);
    701   CalculateConcavityPerBoundaryPoint(out, TesselStruct);
    702   StoreTrianglesinFile(out, mol, filename, "-third");
     570  //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     571  //StoreTrianglesinFile(out, mol, filename, "-third");
    703572
    704573  // third step: IsConvexRectangle
     
    717586      point = TesselStruct->IsConvexRectangle(out, line);
    718587      if (point != NULL)
    719         TesselStruct->RemovePointFromTesselatedSurface(out, point);
     588        volume += TesselStruct->RemovePointFromTesselatedSurface(out, point);
    720589    }
    721590    LineRunner = LineAdvance;
     
    723592
    724593  CalculateConcavityPerBoundaryPoint(out, TesselStruct);
    725   StoreTrianglesinFile(out, mol, filename, "-fourth");
     594  StoreTrianglesinFile(out, mol, filename, "");
    726595
    727596  // end
     597  *out << Verbose(1) << "Volume is " << volume << "." << endl;
    728598  *out << Verbose(0) << "End of ConvexizeNonconvexEnvelope" << endl;
    729599  return volume;
     
    993863    if ((*ListRunner)->TesselStruct == NULL) {
    994864      *out << Verbose(1) << "Pre-creating tesselation for molecule " << *ListRunner << "." << endl;
    995       FindNonConvexBorder((ofstream *)&cout, (*ListRunner), LCList[i], NULL, 5.);
     865      FindNonConvexBorder((ofstream *)&cout, (*ListRunner), LCList[i], 5., NULL);
    996866    }
    997867    i++;
     
    1115985 * \param *Tess Tesselation filled with points, lines and triangles on boundary on return
    1116986 * \param *LCList atoms in LinkedCell list
     987 * \param RADIUS radius of the virtual sphere
    1117988 * \param *filename filename prefix for output of vertex data
    1118  * \para RADIUS radius of the virtual sphere
    1119  */
    1120 void FindNonConvexBorder(ofstream *out, molecule* mol, class LinkedCell *LCList, const char *filename, const double RADIUS)
     989 */
     990void FindNonConvexBorder(ofstream *out, molecule* mol, class LinkedCell *LCList, const double RADIUS, const char *filename = NULL)
    1121991{
    1122992  int N = 0;
    1123993  bool freeLC = false;
    1124   ofstream *tempstream = NULL;
    1125   char NumberName[255];
    1126   int TriangleFilesWritten = 0;
    1127994
    1128995  *out << Verbose(1) << "Entering search for non convex hull. " << endl;
     
    11411008  bool failflag = false;
    11421009
     1010  // initialise Linked Cell
    11431011  if (LCList == NULL) {
    11441012    LCList = new LinkedCell(mol, 2.*RADIUS);
     
    11461014  }
    11471015
     1016  // 1. get starting triangle
    11481017  mol->TesselStruct->FindStartingTriangle(out, RADIUS, LCList);
    11491018
     1019  // 2. expand from there
    11501020  baseline = mol->TesselStruct->LinesOnBoundary.begin();
    1151   // the outward most line is dangerous, as we may end up with wrapping up the starting triangle, hence
    1152   // terminating the algorithm too early.
    1153   if (baseline != mol->TesselStruct->LinesOnBoundary.end()) // skip first line as it its the outwardmost!
    1154         baseline++;
     1021  baseline++; // skip first line
    11551022  while ((baseline != mol->TesselStruct->LinesOnBoundary.end()) || (flag)) {
    11561023    if (baseline->second->triangles.size() == 1) {
    1157       failflag = mol->TesselStruct->FindNextSuitableTriangle(out, *(baseline->second), *(((baseline->second->triangles.begin()))->second), RADIUS, N, LCList); //the line is there, so there is a triangle, but only one.
     1024      // 3. find next triangle
     1025      failflag = mol->TesselStruct->FindNextSuitableTriangle(out, *(baseline->second), *(((baseline->second->triangles.begin()))->second), RADIUS, LCList); //the line is there, so there is a triangle, but only one.
    11581026      flag = flag || failflag;
    11591027      if (!failflag)
    11601028        cerr << "WARNING: FindNextSuitableTriangle failed." << endl;
     1029
    11611030      // write temporary envelope
    1162       if ((DoSingleStepOutput && (mol->TesselStruct->TrianglesOnBoundaryCount % SingleStepWidth == 0))) { // if we have a new triangle and want to output each new triangle configuration
    1163         TriangleMap::iterator runner = mol->TesselStruct->TrianglesOnBoundary.end();
    1164         runner--;
    1165         class BoundaryTriangleSet *triangle = runner->second;
    1166         if (triangle != NULL) {
    1167           sprintf(NumberName, "-%04d-%s_%s_%s", TriangleFilesWritten, triangle->endpoints[0]->node->Name, triangle->endpoints[1]->node->Name, triangle->endpoints[2]->node->Name);
    1168           if (DoTecplotOutput) {
    1169             string NameofTempFile(filename);
    1170             NameofTempFile.append(NumberName);
    1171             for(size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))
    1172             NameofTempFile.erase(npos, 1);
    1173             NameofTempFile.append(TecplotSuffix);
    1174             *out << Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
    1175             tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
    1176             WriteTecplotFile(out, tempstream, mol->TesselStruct, mol, TriangleFilesWritten);
    1177             tempstream->close();
    1178             tempstream->flush();
    1179             delete(tempstream);
    1180           }
    1181 
    1182           if (DoRaster3DOutput) {
    1183             string NameofTempFile(filename);
    1184             NameofTempFile.append(NumberName);
    1185             for(size_t npos = NameofTempFile.find_first_of(' '); npos != string::npos; npos = NameofTempFile.find(' ', npos))
    1186             NameofTempFile.erase(npos, 1);
    1187             NameofTempFile.append(Raster3DSuffix);
    1188             *out << Verbose(1) << "Writing temporary non convex hull to file " << NameofTempFile << ".\n";
    1189             tempstream = new ofstream(NameofTempFile.c_str(), ios::trunc);
    1190             WriteRaster3dFile(out, tempstream, mol->TesselStruct, mol);
    1191     //        // include the current position of the virtual sphere in the temporary raster3d file
    1192     //        // make the circumsphere's center absolute again
    1193     //        helper.CopyVector(BaseRay->endpoints[0]->node->node);
    1194     //        helper.AddVector(BaseRay->endpoints[1]->node->node);
    1195     //        helper.Scale(0.5);
    1196     //        (*it)->OptCenter.AddVector(&helper);
    1197     //        Vector *center = mol->DetermineCenterOfAll(out);
    1198     //        (*it)->OptCenter.SubtractVector(center);
    1199     //        delete(center);
    1200     //        // and add to file plus translucency object
    1201     //        *tempstream << "# current virtual sphere\n";
    1202     //        *tempstream << "8\n  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0\n";
    1203     //        *tempstream << "2\n  " << (*it)->OptCenter.x[0] << " "
    1204     //          << (*it)->OptCenter.x[1] << " " << (*it)->OptCenter.x[2]
    1205     //          << "\t" << RADIUS << "\t1 0 0\n";
    1206     //        *tempstream << "9\n  terminating special property\n";
    1207             tempstream->close();
    1208             tempstream->flush();
    1209             delete(tempstream);
    1210           }
    1211         }
    1212         if (DoTecplotOutput || DoRaster3DOutput)
    1213           TriangleFilesWritten++;
     1031      if (filename != NULL) {
     1032        if ((DoSingleStepOutput && ((mol->TesselStruct->TrianglesOnBoundary.size() % SingleStepWidth == 0) || (mol->TesselStruct->TrianglesOnBoundary.size() > 8520 && mol->TesselStruct->TrianglesOnBoundary.size() <= 8530)))) { // if we have a new triangle and want to output each new triangle configuration
     1033          mol->TesselStruct->Output(out, filename, mol);
     1034        }
    12141035      }
     1036      baseline = mol->TesselStruct->LinesOnBoundary.end();
    12151037    } else {
    12161038      //cout << Verbose(1) << "Line " << *baseline->second << " has " << baseline->second->triangles.size() << " triangles adjacent" << endl;
     
    12201042
    12211043    N++;
    1222     baseline++;
    12231044    if ((baseline == mol->TesselStruct->LinesOnBoundary.end()) && (flag)) {
    12241045      baseline = mol->TesselStruct->LinesOnBoundary.begin();   // restart if we reach end due to newly inserted lines
     1046      baseline++;
    12251047      flag = false;
    12261048    }
    12271049  }
     1050  // look whether all points are inside of the convex envelope, otherwise add them via degenerated triangles
     1051  mol->TesselStruct->InsertStraddlingPoints(out, mol, LCList);
     1052//  mol->GoToFirst();
     1053//  class TesselPoint *Runner = NULL;
     1054//  while (!mol->IsEnd()) {
     1055//    Runner = mol->GetPoint();
     1056//    *out << Verbose(1) << "Checking on " << Runner->Name << " ... " << endl;
     1057//    if (!mol->TesselStruct->IsInnerPoint(out, Runner, LCList)) {
     1058//      *out << Verbose(2) << Runner->Name << " is outside of envelope, adding via degenerated triangles." << endl;
     1059//      mol->TesselStruct->AddBoundaryPointByDegeneratedTriangle(out, Runner, LCList);
     1060//    } else {
     1061//      *out << Verbose(2) << Runner->Name << " is inside of or on envelope." << endl;
     1062//    }
     1063//    mol->GoToNext();
     1064//  }
    12281065
    12291066  // Purges surplus triangles.
    12301067  mol->TesselStruct->RemoveDegeneratedTriangles();
    1231 
    1232   // write final envelope
    1233   if (filename != 0) {
    1234     *out << Verbose(1) << "Writing final tecplot file\n";
    1235     if (DoTecplotOutput) {
    1236       string OutputName(filename);
    1237       OutputName.append(TecplotSuffix);
    1238       ofstream *tecplot = new ofstream(OutputName.c_str());
    1239       WriteTecplotFile(out, tecplot, mol->TesselStruct, mol, -1);
    1240       tecplot->close();
    1241       delete(tecplot);
    1242     }
    1243     if (DoRaster3DOutput) {
    1244       string OutputName(filename);
    1245       OutputName.append(Raster3DSuffix);
    1246       ofstream *raster = new ofstream(OutputName.c_str());
    1247       WriteRaster3dFile(out, raster, mol->TesselStruct, mol);
    1248       raster->close();
    1249       delete(raster);
    1250     }
    1251   } else {
    1252     cerr << "ERROR: Could definitively not find all necessary triangles!" << endl;
    1253   }
    12541068
    12551069  cout << Verbose(2) << "Check: List of Baselines with not two connected triangles:" << endl;
     
    12641078    *out << Verbose(2) << "None." << endl;
    12651079
    1266 //  // Tests the IsInnerAtom() function.
    1267 //  Vector x (0, 0, 0);
    1268 //  *out << Verbose(0) << "Point to check: " << x << endl;
    1269 //  *out << Verbose(0) << "Check: IsInnerPoint() returns " << mol->TesselStruct->IsInnerPoint(out, x, LCList)
    1270 //    << "for vector " << x << "." << endl;
    1271 //  TesselPoint* a = mol->TesselStruct->PointsOnBoundary.begin()->second->node;
    1272 //  *out << Verbose(0) << "Point to check: " << *a << " (on boundary)." << endl;
    1273 //  *out << Verbose(0) << "Check: IsInnerAtom() returns " << mol->TesselStruct->IsInnerPoint(out, a, LCList)
    1274 //    << "for atom " << a << " (on boundary)." << endl;
    1275 //  LinkedNodes *List = NULL;
    1276 //  for (int i=0;i<NDIM;i++) { // each axis
    1277 //    LCList->n[i] = LCList->N[i]-1; // current axis is topmost cell
    1278 //    for (LCList->n[(i+1)%NDIM]=0;LCList->n[(i+1)%NDIM]<LCList->N[(i+1)%NDIM];LCList->n[(i+1)%NDIM]++)
    1279 //      for (LCList->n[(i+2)%NDIM]=0;LCList->n[(i+2)%NDIM]<LCList->N[(i+2)%NDIM];LCList->n[(i+2)%NDIM]++) {
    1280 //        List = LCList->GetCurrentCell();
    1281 //        //cout << Verbose(2) << "Current cell is " << LC->n[0] << ", " << LC->n[1] << ", " << LC->n[2] << " with No. " << LC->index << "." << endl;
    1282 //        if (List != NULL) {
    1283 //          for (LinkedNodes::iterator Runner = List->begin();Runner != List->end();Runner++) {
    1284 //            if (mol->TesselStruct->PointsOnBoundary.find((*Runner)->nr) == mol->TesselStruct->PointsOnBoundary.end()) {
    1285 //              a = *Runner;
    1286 //              i=3;
    1287 //              for (int j=0;j<NDIM;j++)
    1288 //                LCList->n[j] = LCList->N[j];
    1289 //              break;
    1290 //            }
    1291 //          }
    1292 //        }
    1293 //      }
    1294 //  }
    1295 //  *out << Verbose(0) << "Check: IsInnerPoint() returns " << mol->TesselStruct->IsInnerPoint(out, a, LCList)
    1296 //    << "for atom " << a << " (inside)." << endl;
     1080  // write final envelope
     1081  CalculateConcavityPerBoundaryPoint(out, mol->TesselStruct);
     1082  StoreTrianglesinFile(out, mol, filename, "");
    12971083
    12981084  if (freeLC)
     
    13001086  *out << Verbose(0) << "End of FindNonConvexBorder\n";
    13011087};
     1088
    13021089
    13031090/** Finds a hole of sufficient size in \a this molecule to embed \a *srcmol into it.
Note: See TracChangeset for help on using the changeset viewer.