Changeset 1d9b7aa for src


Ignore:
Timestamp:
Aug 19, 2009, 2:31:29 PM (15 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

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r99c484 r1d9b7aa  
    624624
    625625  // First step: RemovePointFromTesselatedSurface
    626   PointRunner = TesselStruct->PointsOnBoundary.begin();
    627   PointAdvance = PointRunner; // we need an advanced point, as the PointRunner might get removed
    628   while (PointRunner != TesselStruct->PointsOnBoundary.end()) {
    629     PointAdvance++;
    630     point = PointRunner->second;
    631     *out << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
    632     Concavity = true;
    633     for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
     626  do {
     627    Concavity = false;
     628    PointRunner = TesselStruct->PointsOnBoundary.begin();
     629    PointAdvance = PointRunner; // we need an advanced point, as the PointRunner might get removed
     630    while (PointRunner != TesselStruct->PointsOnBoundary.end()) {
     631      PointAdvance++;
     632      point = PointRunner->second;
     633      *out << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
     634      for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
     635        line = LineRunner->second;
     636        *out << Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
     637      }
     638      if (!line->CheckConvexityCriterion(out)) {
     639        *out << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl;
     640        // remove the point
     641        Concavity = true;
     642        TesselStruct->RemovePointFromTesselatedSurface(out, point);
     643      }
     644      PointRunner = PointAdvance;
     645    }
     646
     647    //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     648    //StoreTrianglesinFile(out, mol, filename, "-second");
     649
     650    // second step: PickFarthestofTwoBaselines
     651    LineRunner = TesselStruct->LinesOnBoundary.begin();
     652    LineAdvance = LineRunner;  // we need an advanced line, as the LineRunner might get removed
     653    while (LineRunner != TesselStruct->LinesOnBoundary.end()) {
     654      LineAdvance++;
    634655      line = LineRunner->second;
    635       *out << Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
    636       Concavity = Concavity && (!line->CheckConvexityCriterion(out));
    637     }
    638     if (Concavity) {
    639       *out << Verbose(1) << "... point " << *point << " cannot be on convex envelope." << endl;
    640       // remove the point
    641       TesselStruct->RemovePointFromTesselatedSurface(out, point);
    642     }
    643     PointRunner = PointAdvance;
    644   }
    645 
    646   //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
    647   StoreTrianglesinFile(out, mol, filename, "-second");
    648 
    649   // second step: PickFarthestofTwoBaselines
    650   LineRunner = TesselStruct->LinesOnBoundary.begin();
    651   LineAdvance = LineRunner;  // we need an advanced line, as the LineRunner might get removed
    652   while (LineRunner != TesselStruct->LinesOnBoundary.end()) {
    653     LineAdvance++;
    654     line = LineRunner->second;
    655     *out << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl;
    656     // take highest of both lines
    657     if (TesselStruct->IsConvexRectangle(out, line) == NULL)
    658       TesselStruct->PickFarthestofTwoBaselines(out, line);
    659     LineRunner = LineAdvance;
    660   }
    661 
    662   //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     656      *out << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl;
     657      // take highest of both lines
     658      if (TesselStruct->IsConvexRectangle(out, line) == NULL) {
     659        TesselStruct->PickFarthestofTwoBaselines(out, line);
     660        Concavity = true;
     661      }
     662      LineRunner = LineAdvance;
     663    }
     664  } while (Concavity);
     665  CalculateConcavityPerBoundaryPoint(out, TesselStruct);
    663666  StoreTrianglesinFile(out, mol, filename, "-third");
    664667
     
    670673    line = LineRunner->second;
    671674    *out << Verbose(1) << "INFO: Current line is " << *line << "." << endl;
    672     if (LineAdvance != TesselStruct->LinesOnBoundary.end())
    673       *out << Verbose(1) << "INFO: Next line will be " << *(LineAdvance->second) << "." << endl;
     675    //if (LineAdvance != TesselStruct->LinesOnBoundary.end())
     676      //*out << Verbose(1) << "INFO: Next line will be " << *(LineAdvance->second) << "." << endl;
    674677    if (!line->CheckConvexityCriterion(out)) {
    675678      *out << Verbose(1) << "... line " << *line << " is concave, flipping it." << endl;
     
    684687
    685688  CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     689  StoreTrianglesinFile(out, mol, filename, "-fourth");
    686690
    687691  // end
  • 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.