Changeset a8bcea6 for src/boundary.cpp


Ignore:
Timestamp:
Dec 4, 2008, 3:15:00 PM (17 years ago)
Author:
Christian Neuen <neuen@…>
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, Candidate_v1.7.0, 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:
f714979
Parents:
f683fe
Message:

several changes, now output is created, quality unknown

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    rf683fe ra8bcea6  
    456456
    457457
     458/*
     459 * This function creates the tecplot file, displaying the tesselation of the hull.
     460 * \param *out output stream for debugging
     461 * \param *tecplot output stream for tecplot data
     462 */
     463void write_tecplot_file(ofstream *out, ofstream *tecplot, class Tesselation *TesselStruct, class molecule *mol)
     464{
     465  // 8. Store triangles in tecplot file
     466  if (tecplot != NULL) {
     467    *tecplot << "TITLE = \"3D CONVEX SHELL\"" << endl;
     468    *tecplot << "VARIABLES = \"X\" \"Y\" \"Z\"" << endl;
     469    *tecplot << "ZONE T=\"TRIANGLES\", N=" <<  TesselStruct->PointsOnBoundaryCount << ", E=" <<  TesselStruct->TrianglesOnBoundaryCount << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl;
     470    int *LookupList = new int[mol->AtomCount];
     471    for (int i=0;i<mol->AtomCount;i++)
     472      LookupList[i] = -1;
     473
     474    // print atom coordinates
     475    *out << Verbose(2) << "The following triangles were created:";
     476    int Counter = 1;
     477    atom *Walker = NULL;
     478    for (PointMap::iterator target =  TesselStruct->PointsOnBoundary.begin(); target !=  TesselStruct->PointsOnBoundary.end(); target++) {
     479      Walker = target->second->node;
     480      LookupList[Walker->nr] = Counter++;
     481      *tecplot << Walker->x.x[0] << " " << Walker->x.x[1] << " " << Walker->x.x[2] << " " << endl;
     482    }
     483    *tecplot << endl;
     484      // print connectivity
     485    for (TriangleMap::iterator runner =  TesselStruct->TrianglesOnBoundary.begin(); runner !=  TesselStruct->TrianglesOnBoundary.end(); runner++) {
     486      *out << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name;
     487      *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl;
     488    }
     489    delete[](LookupList);
     490    *out << endl;
     491  }
     492}
     493
    458494/** Determines the volume of a cluster.
    459495 * Determines first the convex envelope, then tesselates it and calculates its volume.
     
    478514  double a,b,c;
    479515
    480   Find_non_convex_border(*TesselStruct, mol);
     516  Find_non_convex_border(out, tecplot, *TesselStruct, mol);
    481517  /*
    482518  // 1. calculate center of gravity
     
    560596
    561597
    562 
    563   // 8. Store triangles in tecplot file
    564   if (tecplot != NULL) {
    565     *tecplot << "TITLE = \"3D CONVEX SHELL\"" << endl;
    566     *tecplot << "VARIABLES = \"X\" \"Y\" \"Z\"" << endl;
    567     *tecplot << "ZONE T=\"TRIANGLES\", N=" <<  TesselStruct->PointsOnBoundaryCount << ", E=" <<  TesselStruct->TrianglesOnBoundaryCount << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl;
    568     int *LookupList = new int[mol->AtomCount];
    569     for (int i=0;i<mol->AtomCount;i++)
    570       LookupList[i] = -1;
    571 
    572     // print atom coordinates
    573     *out << Verbose(2) << "The following triangles were created:";
    574     int Counter = 1;
    575     atom *Walker = NULL;
    576     for (PointMap::iterator target =  TesselStruct->PointsOnBoundary.begin(); target !=  TesselStruct->PointsOnBoundary.end(); target++) {
    577       Walker = target->second->node;
    578       LookupList[Walker->nr] = Counter++;
    579       *tecplot << Walker->x.x[0] << " " << Walker->x.x[1] << " " << Walker->x.x[2] << " " << endl;
    580     }
    581     *tecplot << endl;
    582       // print connectivity
    583     for (TriangleMap::iterator runner =  TesselStruct->TrianglesOnBoundary.begin(); runner !=  TesselStruct->TrianglesOnBoundary.end(); runner++) {
    584       *out << " " << runner->second->endpoints[0]->node->Name << "<->" << runner->second->endpoints[1]->node->Name << "<->" << runner->second->endpoints[2]->node->Name;
    585       *tecplot << LookupList[runner->second->endpoints[0]->node->nr] << " " << LookupList[runner->second->endpoints[1]->node->nr] << " " << LookupList[runner->second->endpoints[2]->node->nr] << endl;
    586     }
    587     delete[](LookupList);
    588     *out << endl;
    589   }
     598  write_tecplot_file(out, tecplot, TesselStruct, mol);
     599
    590600
    591601  // free reference lists
     
    699709Tesselation::~Tesselation()
    700710{
     711        cout << Verbose(1) << "Free'ing TesselStruct ... " << endl;
    701712  for (TriangleMap::iterator runner = TrianglesOnBoundary.begin(); runner != TrianglesOnBoundary.end(); runner++) {
    702713    delete(runner->second);
     
    10281039 *  with all neighbours of the candidate.
    10291040 */
    1030 void Find_next_suitable_point(atom* a, atom* b, atom* Candidate, int n, Vector *Chord, Vector *d1, Vector *d2, double *Storage, const double RADIUS, molecule* mol)
     1041void Find_next_suitable_point(atom* a, atom* b, atom* Candidate, int n, Vector *Chord, Vector *d1, Vector *d2, atom*& Opt_Candidate, double *Storage, const double RADIUS, molecule* mol, bool problem)
    10311042{
    10321043  /* d2 is normal vector on the triangle
     
    10451056  AngleCheck.ProjectOntoPlane(Chord);
    10461057
    1047   if (Chord->Norm()/(2*sin(dif_a.Angle(&dif_b)))<RADIUS) //Using Formula for relation of chord length with inner angle to find of Ball will touch atom
     1058  if (problem)
    10481059  {
    1049 
    1050     if (dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1))>Storage[1]) //This will give absolute preference to those in "right-hand" quadrants
     1060          cout << "Atom number" << Candidate->nr << endl;
     1061          Candidate->x.Output((ofstream *)&cout);
     1062          cout << "number of bonds " << mol->NumberOfBondsPerAtom[Candidate->nr] << endl;
     1063  }
     1064
     1065  if (a != Candidate and b != Candidate)
     1066  {
     1067
     1068          if (Chord->Norm()/(2*sin(dif_a.Angle(&dif_b)))<RADIUS) //Using Formula for relation of chord length with inner angle to find of Ball will touch atom
     1069          {
     1070                  if (dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1))>Storage[0]) //This will give absolute preference to those in "right-hand" quadrants
     1071                  {
     1072                          Opt_Candidate = Candidate;
     1073                          Storage[0]=dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1));
     1074                          Storage[1]=AngleCheck.Angle(d2);
     1075                  }
     1076                  else
     1077                  {
     1078                          if ((dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1)) == Storage[0] && Storage[0]>0 &&  Storage[1]< AngleCheck.Angle(d2)) or \
     1079                                          (dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1)) == Storage[0] && Storage[0]<0 &&  Storage[1]> AngleCheck.Angle(d2)))
     1080                                  //Depending on quadrant we prefer higher or lower atom with respect to Triangle normal first.
     1081                          {
     1082                                  Opt_Candidate = Candidate;
     1083                                  Storage[0]=dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1));
     1084                                  Storage[1]=AngleCheck.Angle(d2);
     1085                          }
     1086                          else
     1087                          {
     1088                                  if (problem)
     1089                                          cout << "Loses to better candidate" << endl;
     1090                          }
     1091                  }
     1092          }
     1093          else
     1094          {
     1095                  if (problem)
     1096                          cout << "erfuellt Dreiecksbedingung fuer sehne nicht" <<endl;
     1097          }
     1098  }
     1099  else
     1100  {
     1101          if (problem)
     1102                          cout << "identisch mit Ursprungslinie" << endl;
     1103  }
     1104
     1105  if (n<5) // Five is the recursion level threshold.
     1106  {
     1107          for(int i=0; i<mol->NumberOfBondsPerAtom[Candidate->nr];i++) // go through all bond
    10511108      {
    1052         Storage[0]=(double)Candidate->nr;
    1053         Storage[1]=dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1));
    1054         Storage[2]=AngleCheck.Angle(d2);
     1109                  Walker = mol->ListOfBondsPerAtom[Candidate->nr][i]->GetOtherAtom(Candidate);
     1110
     1111                  Find_next_suitable_point(a, b, Walker, n+1, Chord, d1, d2, Opt_Candidate, Storage, RADIUS, mol, problem);  //call function again
    10551112      }
    1056     else
    1057       {
    1058         if ((dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1)) == Storage[1] && Storage[1]>0 &&  Storage[2]< AngleCheck.Angle(d2)) or \
    1059             (dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1)) == Storage[1] && Storage[1]<0 &&  Storage[2]> AngleCheck.Angle(d2)))
    1060           //Depending on quadrant we prefer higher or lower atom with respect to Triangle normal first.
    1061           {
    1062             Storage[0]=(double)Candidate->nr;
    1063             Storage[1]=dif_a.ScalarProduct(d1)/fabs(dif_a.ScalarProduct(d1));
    1064             Storage[2]=AngleCheck.Angle(d2);
    1065           }
    1066       }
    1067   }
    1068 
    1069   if (n<5) // Five is the recursion level threshold.
    1070     {
    1071       for(int i=0; i<mol->NumberOfBondsPerAtom[Candidate->nr];i++) // go through all bond
    1072         {
    1073                 Walker= mol->start; // go through all atoms
    1074 
    1075           while (Walker->nr != (mol->ListOfBondsPerAtom[Candidate->nr][i]->leftatom->nr ==Candidate->nr ? mol->ListOfBondsPerAtom[Candidate->nr][i]->rightatom->nr : mol->ListOfBondsPerAtom[Candidate->nr][i]->leftatom->nr))
    1076             { // until atom found which belongs to bond
    1077               Walker = Walker->next;
    1078             }
    1079 
    1080 
    1081           Find_next_suitable_point(a, b, Walker, n+1, Chord, d1, d2, Storage, RADIUS, mol);  //call function again
    1082         }
    1083     }
     1113  }
    10841114};
    10851115
     
    10871117 * this function fins a triangle to a line, adjacent to an existing one.
    10881118 */
    1089 void Tesselation::Find_next_suitable_triangle(molecule* mol, BoundaryLineSet Line, BoundaryTriangleSet T, const double& RADIUS)
    1090 {
    1091         printf("Looking for next suitable triangle \n");
     1119void Tesselation::Find_next_suitable_triangle(ofstream *out, ofstream *tecplot, molecule* mol, BoundaryLineSet &Line, BoundaryTriangleSet &T, const double& RADIUS)
     1120{
     1121        cout << Verbose(1) << "Looking for next suitable triangle \n";
    10921122  Vector direction1;
    10931123  Vector helper;
     
    10951125  atom* Walker;
    10961126
    1097   double *Storage;
    1098   Storage = new double[3];
    1099   Storage[0]=-1.;   // Id must be positive, we see should nothing be done
    1100   Storage[1]=-1.;   // This direction is either +1 or -1 one, so any result will take precedence over initial values
    1101   Storage[2]=-10.;  // This is also lower then any value produced by an eligible atom, which are all positive
    1102 
    1103 
     1127  double Storage[2];
     1128  Storage[0]=-2.;    // This direction is either +1 or -1 one, so any result will take precedence over initial values
     1129  Storage[1]=9999999.;  // This is also lower then any value produced by an eligible atom, which are all positive
     1130  atom* Opt_Candidate = NULL;
     1131
     1132
     1133  cout << Verbose(1) << "Constructing helpful vectors ... " << endl;
    11041134  helper.CopyVector(&(Line.endpoints[0]->node->x));
    11051135  for (int i =0; i<3; i++)
     
    11151145  direction1.CopyVector(&Line.endpoints[0]->node->x);
    11161146  direction1.SubtractVector(&Line.endpoints[1]->node->x);
    1117   direction1.VectorProduct(T.NormalVector);
     1147  direction1.VectorProduct(&(T.NormalVector));
    11181148
    11191149  if (direction1.ScalarProduct(&helper)>0)
     
    11251155  Chord.SubtractVector(&(Line.endpoints[1]->node->x));
    11261156
    1127 printf("Looking for third point candidates for triangle \n");
    1128   Find_next_suitable_point(Line.endpoints[0]->node, Line.endpoints[1]->node, Line.endpoints[0]->node, 0, &Chord, &direction1, T.NormalVector, Storage, RADIUS, mol);
    1129 
     1157  cout << Verbose(1) << "Looking for third point candidates for triangle ... " << endl;
     1158  Find_next_suitable_point(Line.endpoints[0]->node, Line.endpoints[1]->node, Line.endpoints[0]->node, 0, &Chord, &direction1, &(T.NormalVector), Opt_Candidate, Storage, RADIUS, mol,0);
     1159
     1160  if (Opt_Candidate==NULL)
     1161  {
     1162          cout << Verbose(1) << "No new Atom found, triangle construction will crash" << endl;
     1163          write_tecplot_file(out, tecplot, this, mol);
     1164          tecplot->flush();
     1165          Find_next_suitable_point(Line.endpoints[0]->node, Line.endpoints[1]->node, Line.endpoints[0]->node, 0, &Chord, &direction1, &(T.NormalVector), Opt_Candidate, Storage, RADIUS, mol, 1);
     1166
     1167  }
    11301168  // Konstruiere nun neues Dreieck am Ende der Liste der Dreiecke
    1131   // Next Triangle is Line, atom with number in Storage[0]
    1132 
    1133   Walker= mol->start;
    1134   while (Walker->nr != (int)Storage[0])
    1135     {
    1136       Walker = Walker->next;
    1137     }
    1138 
    1139   AddPoint(Walker);
    1140 
    1141   BPS[0] = new class BoundaryPointSet(Walker);
     1169
     1170  cout << Verbose(1) << "Adding exactly one Walker for reasons completely unknown to me ... " << endl;
     1171  cout << " Optimal candidate is " << *Opt_Candidate << endl;
     1172  AddPoint(Opt_Candidate);
     1173  cout << " Optimal candidate is " << *Opt_Candidate << endl;
     1174
     1175  BPS[0] = new class BoundaryPointSet(Opt_Candidate);
     1176  cout << " Optimal candidate is " << *Opt_Candidate << endl;
    11421177  BPS[1] = new class BoundaryPointSet(Line.endpoints[0]->node);
     1178  cout << " Optimal candidate is " << *Opt_Candidate << endl;
    11431179  BLS[0] = new class BoundaryLineSet(BPS , LinesOnBoundaryCount);
    1144   BPS[0] = new class BoundaryPointSet(Walker);
     1180  cout << " Optimal candidate is " << *Opt_Candidate << endl;
     1181  BPS[0] = new class BoundaryPointSet(Opt_Candidate);
     1182  cout << " Optimal candidate is " << *Opt_Candidate << endl;
    11451183  BPS[1] = new class BoundaryPointSet(Line.endpoints[1]->node);
    11461184  BLS[1] = new class BoundaryLineSet(BPS , LinesOnBoundaryCount);
     
    11511189  TrianglesOnBoundaryCount++;
    11521190
     1191  cout << Verbose(1) << "Checking for already present lines ... " << endl;
    11531192  for(int i=0;i<NDIM;i++) // sind Linien bereits vorhanden ???
    11541193    {
     
    11601199        }
    11611200    }
    1162   BTS->GetNormalVector(*BTS->NormalVector);
    1163 
    1164   if( (BTS->NormalVector->ScalarProduct(T.NormalVector)<0 && Storage[1]>0) || \
    1165       (BTS->NormalVector->ScalarProduct(T.NormalVector)>0 && Storage[1]<0))
     1201  cout << Verbose(1) << "Constructing normal vector for this triangle ... " << endl;
     1202
     1203  BTS->GetNormalVector(BTS->NormalVector);
     1204
     1205  if ((BTS->NormalVector.ScalarProduct(&(T.NormalVector))<0 && Storage[0]>0) ||
     1206                  ((BTS->NormalVector.ScalarProduct(&(T.NormalVector))>0 && Storage[0]<0)) )
    11661207    {
    1167       BTS->NormalVector->Scale(-1);
    1168     }
    1169 
    1170 };
    1171 
    1172 
    1173 void Find_second_point_for_Tesselation(atom* a, atom* Candidate, int n, Vector Oben, double Storage[3], molecule* mol)
    1174 {
    1175         printf("Looking for second point of starting triangle \n");
    1176   int i;
    1177   Vector *AngleCheck;
    1178   atom* Walker;
    1179 
    1180   AngleCheck->CopyVector(&(Candidate->x));
    1181   AngleCheck->SubtractVector(&(a->x));
    1182   if (AngleCheck->Angle(&Oben) < Storage[1])
     1208      BTS->NormalVector.Scale(-1);
     1209    };
     1210
     1211};
     1212
     1213
     1214void Find_second_point_for_Tesselation(atom* a, atom* Candidate, int n, Vector Oben, atom*& Opt_Candidate, double Storage[2], molecule* mol, double RADIUS)
     1215{
     1216        cout << Verbose(1) << "Looking for second point of starting triangle, recursive level "<< n <<endl;;
     1217        int i;
     1218        Vector AngleCheck;
     1219        atom* Walker;
     1220
     1221        AngleCheck.CopyVector(&(Candidate->x));
     1222        AngleCheck.SubtractVector(&(a->x));
     1223        if (AngleCheck.Norm() < RADIUS and AngleCheck.Angle(&Oben) < Storage[0])
    11831224    {
    1184           //printf("Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
    1185       Storage[0]=(double)(Candidate->nr);
    1186       Storage[1]=AngleCheck->Angle(&Oben);
    1187       //printf("Changing something in Storage: %lf %lf. \n", Storage[0], Storage[1]);
     1225          //cout << Verbose(1) << "Old values of Storage: %lf %lf \n", Storage[0], Storage[1]);
     1226      Opt_Candidate=Candidate;
     1227      Storage[0]=AngleCheck.Angle(&Oben);
     1228      //cout << Verbose(1) << "Changing something in Storage: %lf %lf. \n", Storage[0], Storage[1]);
    11881229    };
    1189   printf("%d \n", n);
    1190   if (n<5)
     1230        if (n<5)
    11911231    {
    11921232      for (i = 0; i< mol->NumberOfBondsPerAtom[Candidate->nr]; i++)
    1193         {
    1194           Walker = mol->start;
    1195           while (Candidate->nr != (mol->ListOfBondsPerAtom[Candidate->nr][i]->leftatom->nr ==Candidate->nr ? mol->ListOfBondsPerAtom[Candidate->nr][i]->leftatom->nr : mol->ListOfBondsPerAtom[Candidate->nr][i]->rightatom->nr))
    1196             {
    1197               Walker = Walker->next;
    1198             };
    1199 
    1200           Find_second_point_for_Tesselation(a, Walker, n+1, Oben, Storage, mol);
    1201             };
     1233      {
     1234          Walker = mol->ListOfBondsPerAtom[Candidate->nr][i]->GetOtherAtom(Candidate);
     1235          Find_second_point_for_Tesselation(a, Walker, n+1, Oben, Opt_Candidate, Storage, mol, RADIUS);
     1236      };
    12021237    };
    12031238
     
    12081243void Tesselation::Find_starting_triangle(molecule* mol, const double RADIUS)
    12091244{
    1210         printf("Looking for starting triangle \n");
     1245        cout << Verbose(1) << "Looking for starting triangle \n";
    12111246  int i=0;
    12121247  atom* Walker;
     
    12271262      max_coordinate[i] =-1;
    12281263    }
    1229 printf("Molecule mol is there and has %d Atoms \n", mol->AtomCount);
     1264cout << Verbose(1) << "Molecule mol is there and has " << mol->AtomCount << " Atoms \n";
    12301265  Walker = mol->start;
    12311266  while (Walker->next != mol->end)
     
    12421277    }
    12431278
    1244 printf("Found starting atom \n");
     1279cout << Verbose(1) << "Found starting atom \n";
    12451280  //Koennen dies fuer alle Richtungen, legen hier erstmal Richtung auf k=0
    12461281  const int k=2;
     
    12531288      Walker = Walker->next;
    12541289    }
    1255 printf("%d \n", Walker->nr);
    1256   double Storage[3];
    1257   Storage[0]=-1.;   // Id must be positive, we see should nothing be done
    1258   Storage[1]=999999.;   // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant.
    1259   Storage[2]=999999.;  // This will be an angle looking for the third point.
    1260 printf("%d \n", mol->NumberOfBondsPerAtom[Walker->nr]);
     1290cout << Verbose(1) << "Number of start atom: " << Walker->nr << endl;
     1291  double Storage[2];
     1292  atom* Opt_Candidate = NULL;
     1293  Storage[0]=999999.;   // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant.
     1294  Storage[1]=999999.;  // This will be an angle looking for the third point.
     1295cout << Verbose(1) << "Number of Bonds: " << mol->NumberOfBondsPerAtom[Walker->nr] << endl;
    12611296
    12621297  for (i=1; i< (mol->NumberOfBondsPerAtom[Walker->nr]); i++)
    12631298    {
    1264       Walker2 = mol->start;
    1265       Walker2 = Walker2->next;
    1266       while (Walker2->nr != (mol->ListOfBondsPerAtom[Walker->nr][i]->leftatom->nr == Walker->nr ? mol->ListOfBondsPerAtom[Walker->nr][i]->rightatom->nr : mol->ListOfBondsPerAtom[Walker->nr][i]->leftatom->nr) )
    1267         {
    1268           Walker2 = Walker2->next;
    1269         }
    1270 
    1271       Find_second_point_for_Tesselation(Walker, Walker2, 0, Oben, Storage, mol);
    1272     }
    1273 
    1274   Walker2 = mol->start;
    1275 
    1276   while (Walker2->nr != int(Storage[0]))
    1277     {
    1278       Walker2 = Walker2->next;
    1279     }
    1280 
     1299          Walker2 = mol->ListOfBondsPerAtom[Walker->nr][i]->GetOtherAtom(Walker);
     1300      Find_second_point_for_Tesselation(Walker, Walker2, 0, Oben, Opt_Candidate, Storage, mol, RADIUS);
     1301    }
     1302
     1303  Walker2 = Opt_Candidate;
     1304  Opt_Candidate=NULL;
    12811305  helper.CopyVector(&(Walker->x));
    12821306  helper.SubtractVector(&(Walker2->x));
    12831307  Oben.ProjectOntoPlane(&helper);
    12841308  helper.VectorProduct(&Oben);
    1285   Storage[0]=-1.;   // Id must be positive, we see should nothing be done
    1286   Storage[1]=-2.;   // This will contain the angle, which will be always positive (when looking for second point), when looking for third point this will be the quadrant.
    1287   Storage[2]= -10.;  // This will be an angle looking for the third point.
     1309  Storage[0]=-2.;       // This will indicate the quadrant.
     1310  Storage[1]= 9999999.; // This will be an angle looking for the third point.
    12881311
    12891312  Chord.CopyVector(&(Walker->x)); // bring into calling function
    12901313  Chord.SubtractVector(&(Walker2->x));
    12911314
    1292 printf("Looking for third point candidates \n");
    1293        Find_next_suitable_point(Walker, Walker2, (mol->ListOfBondsPerAtom[Walker->nr][0]->leftatom->nr == Walker->nr ? mol->ListOfBondsPerAtom[Walker->nr][0]->rightatom : mol->ListOfBondsPerAtom[Walker->nr][0]->leftatom), 0, &Chord, &helper, &Oben, Storage, RADIUS, mol);
    1294   Walker3 = mol->start;
    1295   while (Walker3->nr != int(Storage[0]))
    1296     {
    1297       Walker3 = Walker3->next;
    1298     }
    1299 
    1300   //Starting Triangle is Walker, Walker2, index Storage[0]
     1315  cout << Verbose(1) << "Looking for third point candidates \n";
     1316  Find_next_suitable_point(Walker, Walker2, mol->ListOfBondsPerAtom[Walker->nr][0]->GetOtherAtom(Walker), 0, &Chord, &helper, &Oben, Opt_Candidate, Storage, RADIUS, mol, 0);
     1317
     1318
     1319  //Starting Triangle is Walker, Walker2, Opt_Candidate
    13011320
    13021321  AddPoint(Walker);
    13031322  AddPoint(Walker2);
    1304   AddPoint(Walker3);
     1323  AddPoint(Opt_Candidate);
     1324
     1325  cout << Verbose(1) << "The found starting triangle consists of " << *Walker << ", " << *Walker2 << " and " << *Opt_Candidate << "." << endl;
    13051326
    13061327  BPS[0] = new class BoundaryPointSet(Walker);
     
    13081329  BLS[0] = new class BoundaryLineSet(BPS , LinesOnBoundaryCount);
    13091330  BPS[0] = new class BoundaryPointSet(Walker);
    1310   BPS[1] = new class BoundaryPointSet(Walker3);
     1331  BPS[1] = new class BoundaryPointSet(Opt_Candidate);
    13111332  BLS[1] = new class BoundaryLineSet(BPS , LinesOnBoundaryCount);
    13121333  BPS[0] = new class BoundaryPointSet(Walker);
     
    13141335  BLS[2] = new class BoundaryLineSet(BPS , LinesOnBoundaryCount);
    13151336
    1316   BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
     1337  Tesselation::BTS = new class BoundaryTriangleSet(BLS, TrianglesOnBoundaryCount);
    13171338  TrianglesOnBoundary.insert( TrianglePair(TrianglesOnBoundaryCount, BTS) );
    13181339  TrianglesOnBoundaryCount++;
     
    13241345    };
    13251346
    1326        BTS->GetNormalVector(*BTS->NormalVector);
    1327 
    1328        if( BTS->NormalVector->ScalarProduct(&Oben)<0)
     1347       BTS->GetNormalVector(BTS->NormalVector);
     1348
     1349       if( BTS->NormalVector.ScalarProduct(&Oben)<0)
    13291350         {
    1330            BTS->NormalVector->Scale(-1);
     1351           BTS->NormalVector.Scale(-1);
    13311352         }
    13321353};
    13331354
    13341355
    1335 void Find_non_convex_border(Tesselation Tess, molecule* mol)
    1336 {
    1337         printf("Entering finding of non convex hull. \n");
     1356void Find_non_convex_border(ofstream *out, ofstream *tecplot, Tesselation Tess, molecule* mol)
     1357{
     1358        cout << Verbose(1) << "Entering finding of non convex hull. " << endl;
     1359        cout << flush;
    13381360  const double RADIUS =6;
     1361  LineMap::iterator baseline;
    13391362  Tess.Find_starting_triangle(mol, RADIUS);
    13401363
    1341   for (LineMap::iterator baseline = Tess.LinesOnBoundary.begin(); baseline != Tess.LinesOnBoundary.end(); baseline++)
     1364  baseline = Tess.LinesOnBoundary.begin();
     1365  while (baseline != Tess.LinesOnBoundary.end()) {
    13421366    if (baseline->second->TrianglesCount == 1)
    13431367      {
    1344                 Tess.Find_next_suitable_triangle(mol, *(baseline->second), *(baseline->second->triangles.begin()->second), RADIUS); //the line is there, so there is a triangle, but only one.
     1368        cout << Verbose(1) << "Begin of Tesselation ... " << endl;
     1369                Tess.Find_next_suitable_triangle(out, tecplot, mol, *(baseline->second), *(baseline->second->triangles.begin()->second), RADIUS); //the line is there, so there is a triangle, but only one.
     1370        cout << Verbose(1) << "End of Tesselation ... " << endl;
    13451371      }
    13461372    else
    13471373      {
    1348         printf("There is a line with %d triangles adjacent", baseline->second->TrianglesCount);
     1374        cout << Verbose(1) << "There is a line with " << baseline->second->TrianglesCount << " triangles adjacent";
    13491375      }
    1350 };
     1376  baseline++;
     1377  }
     1378
     1379};
Note: See TracChangeset for help on using the changeset viewer.