Ignore:
Timestamp:
Aug 19, 2009, 2:31:29 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:
34e0592
Parents:
99c484
Message:

Smaller fixes, but convex tesselation not working yet

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tesselation.cpp

    r99c484 r1d9b7aa  
    1616  LinesCount = 0;
    1717  Nr = -1;
     18  value = 0.;
    1819};
    1920
     
    2627  LinesCount = 0;
    2728  Nr = Walker->nr;
     29  value = 0.;
    2830};
    2931
     
    148150void BoundaryLineSet::AddTriangle(class BoundaryTriangleSet *triangle)
    149151{
    150   cout << Verbose(6) << "Add " << triangle->Nr << " to line " << *this << "."
    151       << endl;
     152  cout << Verbose(6) << "Add " << triangle->Nr << " to line " << *this << "." << endl;
    152153  triangles.insert(TrianglePair(triangle->Nr, triangle));
    153154};
     
    177178  if (triangles.size() != 2) {
    178179    *out << Verbose(1) << "ERROR: Baseline " << *this << " is connect to less than two triangles, Tesselation incomplete!" << endl;
    179     return false;
     180    return true;
    180181  }
    181182  // check normal vectors
    182183  // have a normal vector on the base line pointing outwards
    183   *out << Verbose(3) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl;
     184  //*out << Verbose(3) << "INFO: " << *this << " has vectors at " << *(endpoints[0]->node->node) << " and at " << *(endpoints[1]->node->node) << "." << endl;
    184185  BaseLineCenter.CopyVector(endpoints[0]->node->node);
    185186  BaseLineCenter.AddVector(endpoints[1]->node->node);
     
    187188  BaseLine.CopyVector(endpoints[0]->node->node);
    188189  BaseLine.SubtractVector(endpoints[1]->node->node);
    189   *out << Verbose(3) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl;
     190  //*out << Verbose(3) << "INFO: Baseline is " << BaseLine << " and its center is at " << BaseLineCenter << "." << endl;
    190191
    191192  BaseLineNormal.Zero();
     
    195196  class BoundaryPointSet *node = NULL;
    196197  for(TriangleMap::iterator runner = triangles.begin(); runner != triangles.end(); runner++) {
    197     *out << Verbose(3) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;
     198    //*out << Verbose(3) << "INFO: NormalVector of " << *(runner->second) << " is " << runner->second->NormalVector << "." << endl;
    198199    NormalCheck.AddVector(&runner->second->NormalVector);
    199200    NormalCheck.Scale(sign);
     
    202203    node = runner->second->GetThirdEndpoint(this);
    203204    if (node != NULL) {
    204       *out << Verbose(3) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;
     205      //*out << Verbose(3) << "INFO: Third node for triangle " << *(runner->second) << " is " << *node << " at " << *(node->node->node) << "." << endl;
    205206      helper[i].CopyVector(node->node->node);
    206207      helper[i].SubtractVector(&BaseLineCenter);
    207208      helper[i].MakeNormalVector(&BaseLine);  // we want to compare the triangle's heights' angles!
    208       *out << Verbose(4) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;
     209      //*out << Verbose(4) << "INFO: Height vector with respect to baseline is " << helper[i] << "." << endl;
    209210      i++;
    210211    } else {
    211       *out << Verbose(2) << "WARNING: I cannot find third node in triangle, something's wrong." << endl;
     212      //*out << Verbose(2) << "WARNING: I cannot find third node in triangle, something's wrong." << endl;
    212213      return true;
    213214    }
    214215  }
    215   *out << Verbose(3) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;
     216  //*out << Verbose(3) << "INFO: BaselineNormal is " << BaseLineNormal << "." << endl;
    216217  if (NormalCheck.NormSquared() < MYEPSILON) {
    217     *out << Verbose(3) << "Normalvectors of both triangles are the same: convex." << endl;
     218    *out << Verbose(2) << "ACCEPT: Normalvectors of both triangles are the same: convex." << endl;
    218219    return true;
    219220  }
    220221  double angle = getAngle(helper[0], helper[1], BaseLineNormal);
    221   if ((angle - M_PI) > -MYEPSILON)
     222  if ((angle - M_PI) > -MYEPSILON) {
     223    *out << Verbose(2) << "ACCEPT: Angle is greater than pi: convex." << endl;
    222224    return true;
    223   else
     225  } else {
     226    *out << Verbose(2) << "REJECT: Angle is less than pi: concave." << endl;
    224227    return false;
     228  }
    225229}
    226230
     
    17671771
    17681772  // delete the temporary other base line
    1769   delete(ClosestPoint);
    17701773  delete(OtherBase);
    17711774
     
    17801783    distance[i] = BaseLine.ScalarProduct(&DistanceToIntersection[i]);
    17811784  }
    1782   if ((distance[0] * distance[1]) > MYEPSILON)  { // have same sign?
    1783     *out << Verbose(3) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1]  << ". " << *Base << " is concave." << endl;
     1785  delete(ClosestPoint);
     1786  if ((distance[0] * distance[1]) > 0)  { // have same sign?
     1787    *out << Verbose(3) << "REJECT: Both SKPs have same sign: " << distance[0] << " and " << distance[1]  << ". " << *Base << "' rectangle is concave." << endl;
    17841788    if (distance[0] < distance[1]) {
    17851789      Spot = Base->endpoints[0];
     
    19031907  Vector NewOffset;
    19041908  NewOffset.CopyVector(OtherBase->endpoints[0]->node->node);
     1909  NewOffset.SubtractVector(Base->endpoints[0]->node->node);
    19051910  NewOffset.ProjectOntoPlane(&Normal);
    19061911  NewOffset.AddVector(Base->endpoints[0]->node->node);
     1912  Vector NewDirection;
     1913  NewDirection.CopyVector(&NewOffset);
     1914  NewDirection.AddVector(&OtherBaseline);
    19071915
    19081916  // calculate the intersection between this projected baseline and Base
    19091917  Vector *Intersection = new Vector;
    1910   Intersection->GetIntersectionOfTwoLinesOnPlane(out, Base->endpoints[0]->node->node, Base->endpoints[1]->node->node, &NewOffset, &OtherBaseline, &Normal);
     1918  Intersection->GetIntersectionOfTwoLinesOnPlane(out, Base->endpoints[0]->node->node, Base->endpoints[1]->node->node, &NewOffset, &NewDirection, &Normal);
    19111919  Normal.CopyVector(Intersection);
    19121920  Normal.SubtractVector(Base->endpoints[0]->node->node);
     
    26222630  int i;
    26232631
     2632  if (point == NULL) {
     2633    *out << Verbose(1) << "ERROR: Cannot remove the point " << point << ", it's NULL!" << endl;
     2634    return 0.;
     2635  } else
     2636    *out << Verbose(2) << "Removing point " << *point << " from tesselated boundary ..." << endl;
     2637
    26242638  // copy old location for the volume
    26252639  OldPoint.CopyVector(point->node->node);
     
    26362650    count+=LineRunner->second->triangles.size();
    26372651  numbers = new int[count];
     2652  class BoundaryTriangleSet **Candidates = new BoundaryTriangleSet*[count];
    26382653  i=0;
    26392654  for (LineMap::iterator LineRunner = point->lines.begin(); (point != NULL) && (LineRunner != point->lines.end()); LineRunner++) {
     
    26412656    for (TriangleMap::iterator TriangleRunner = line->triangles.begin(); TriangleRunner != line->triangles.end(); TriangleRunner++) {
    26422657      triangle = TriangleRunner->second;
    2643       *out << Verbose(2) << "Erasing triangle " << *triangle << "." << endl;
     2658      Candidates[i] = triangle;
    26442659      numbers[i++] = triangle->Nr;
    2645       RemoveTesselationTriangle(triangle);
    2646       triangle = NULL;
    2647     }
    2648   }
     2660    }
     2661  }
     2662  for (int j=0;j<i;j++) {
     2663    RemoveTesselationTriangle(Candidates[j]);
     2664  }
     2665  delete[](Candidates);
    26492666  *out << Verbose(1) << i << " triangles were removed." << endl;
    26502667
Note: See TracChangeset for help on using the changeset viewer.