Changeset 0077b5 for src


Ignore:
Timestamp:
Aug 18, 2009, 8:42:39 AM (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:
99c484
Parents:
093645
Message:

Further bugfixes to three-step-procedure in convex envelope, not yet working.

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/boundary.cpp

    r093645 r0077b5  
    620620  }
    621621
     622  //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     623  StoreTrianglesinFile(out, mol, filename, "-first");
     624
    622625  // First step: RemovePointFromTesselatedSurface
    623626  PointRunner = TesselStruct->PointsOnBoundary.begin();
     
    641644  }
    642645
    643 
    644 //  // print all lines
    645 //  LineRunner = TesselStruct->LinesOnBoundary.begin();
    646 //  LineAdvance = LineRunner;  // we need an advanced line, as the LineRunner might get removed
    647 //  *out << Verbose(1) << "Printing all boundary lines for debugging." << endl;
    648 //  while (LineRunner != TesselStruct->LinesOnBoundary.end()) {
    649 //    LineAdvance++;
    650 //    line = LineRunner->second;
    651 //    *out << Verbose(2) << "INFO: Current line is " << *line << "." << endl;
    652 //    if (LineAdvance != TesselStruct->LinesOnBoundary.end())
    653 //      *out << Verbose(2) << "INFO: Next line will be " << *(LineAdvance->second) << "." << endl;
    654 //    LineRunner = LineAdvance;
    655 //  }
    656 //
    657 //  // print all triangles
    658 //  TriangleRunner = TesselStruct->TrianglesOnBoundary.begin();
    659 //  TriangleAdvance = TriangleRunner;  // we need an advanced line, as the LineRunner might get removed
    660 //  *out << Verbose(1) << "Printing all boundary triangles for debugging." << endl;
    661 //  while (TriangleRunner != TesselStruct->TrianglesOnBoundary.end()) {
    662 //    TriangleAdvance++;
    663 //    *out << Verbose(2) << "INFO: Current triangle is " << *(TriangleRunner->second) << "." << endl;
    664 //    if (TriangleAdvance != TesselStruct->TrianglesOnBoundary.end())
    665 //      *out << Verbose(2) << "INFO: Next triangle will be " << *(TriangleAdvance->second) << "." << endl;
    666 //    TriangleRunner = TriangleAdvance;
    667 //  }
     646  //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     647  StoreTrianglesinFile(out, mol, filename, "-second");
    668648
    669649  // second step: PickFarthestofTwoBaselines
     
    674654    line = LineRunner->second;
    675655    *out << Verbose(1) << "INFO: Picking farthest baseline for line is " << *line << "." << endl;
    676     if (LineAdvance != TesselStruct->LinesOnBoundary.end())
    677656    // take highest of both lines
    678     TesselStruct->PickFarthestofTwoBaselines(out, line);
     657    if (TesselStruct->IsConvexRectangle(out, line) == NULL)
     658      TesselStruct->PickFarthestofTwoBaselines(out, line);
    679659    LineRunner = LineAdvance;
    680660  }
    681661
    682   // calculate remaining concavity
    683   for (PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
    684     point = PointRunner->second;
    685     *out << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
    686     point->value = 0;
    687     for (LineMap::iterator LineRunner = point->lines.begin(); LineRunner != point->lines.end(); LineRunner++) {
    688       line = LineRunner->second;
    689       *out << Verbose(2) << "INFO: Current line of point " << *point << " is " << *line << "." << endl;
    690       if (!line->CheckConvexityCriterion(out))
    691         point->value += 1;
    692     }
    693   }
    694 
    695   // 4. Store triangles in tecplot file
    696   if (filename != NULL) {
    697     if (DoTecplotOutput) {
    698       string OutputName(filename);
    699       OutputName.append("_intermed");
    700       OutputName.append(TecplotSuffix);
    701       ofstream *tecplot = new ofstream(OutputName.c_str());
    702       write_tecplot_file(out, tecplot, mol->TesselStruct, mol, 0);
    703       tecplot->close();
    704       delete(tecplot);
    705     }
    706     if (DoRaster3DOutput) {
    707       string OutputName(filename);
    708       OutputName.append("_intermed");
    709       OutputName.append(Raster3DSuffix);
    710       ofstream *rasterplot = new ofstream(OutputName.c_str());
    711       write_raster3d_file(out, rasterplot, mol->TesselStruct, mol);
    712       rasterplot->close();
    713       delete(rasterplot);
    714     }
    715   }
     662  //CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     663  StoreTrianglesinFile(out, mol, filename, "-third");
    716664
    717665  // third step: IsConvexRectangle
     
    735683  }
    736684
     685  CalculateConcavityPerBoundaryPoint(out, TesselStruct);
     686
     687  // end
     688  *out << Verbose(0) << "End of ConvexizeNonconvexEnvelope" << endl;
     689  return volume;
     690};
     691
     692/** Calculates the concavity for each of the BoundaryPointSet's in a Tesselation.
     693 * Sets BoundaryPointSet::value equal to the number of connected lines that are not convex.
     694 * \param *out output stream for debugging
     695 * \param *TesselStruct pointer to Tesselation structure
     696 */
     697void CalculateConcavityPerBoundaryPoint(ofstream *out, class Tesselation *TesselStruct)
     698{
     699  class BoundaryPointSet *point = NULL;
     700  class BoundaryLineSet *line = NULL;
    737701  // calculate remaining concavity
    738   for (PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
     702  for (PointMap::iterator PointRunner = TesselStruct->PointsOnBoundary.begin(); PointRunner != TesselStruct->PointsOnBoundary.end(); PointRunner++) {
    739703    point = PointRunner->second;
    740704    *out << Verbose(1) << "INFO: Current point is " << *point << "." << endl;
     
    747711    }
    748712  }
    749 
     713};
     714
     715/** Stores triangles to file.
     716 * \param *out output stream for debugging
     717 * \param *mol molecule with atoms and bonds
     718 * \param *filename prefix of filename
     719 * \param *extraSuffix intermediate suffix
     720 */
     721void StoreTrianglesinFile(ofstream *out, molecule *mol, const char *filename, const char *extraSuffix)
     722{
    750723  // 4. Store triangles in tecplot file
    751724  if (filename != NULL) {
    752725    if (DoTecplotOutput) {
    753726      string OutputName(filename);
     727      OutputName.append(extraSuffix);
    754728      OutputName.append(TecplotSuffix);
    755729      ofstream *tecplot = new ofstream(OutputName.c_str());
     
    760734    if (DoRaster3DOutput) {
    761735      string OutputName(filename);
     736      OutputName.append(extraSuffix);
    762737      OutputName.append(Raster3DSuffix);
    763738      ofstream *rasterplot = new ofstream(OutputName.c_str());
     
    767742    }
    768743  }
    769 
    770   // end
    771   *out << Verbose(0) << "End of ConvexizeNonconvexEnvelope" << endl;
    772   return volume;
    773744};
    774745
  • src/boundary.hpp

    r093645 r0077b5  
    4242void Find_next_suitable_point(class BoundaryTriangleSet *BaseTriangle, class BoundaryLineSet *BaseLine, atom*& OptCandidate, Vector *OptCandidateCenter, double *ShortestAngle, const double RADIUS, LinkedCell *LC);
    4343Boundaries *GetBoundaryPoints(ofstream *out, molecule *mol);
     44void CalculateConcavityPerBoundaryPoint(ofstream *out, class Tesselation *TesselStruct);
     45void StoreTrianglesinFile(ofstream *out, molecule *mol, const char *filename, const char *extraSuffix);
     46
    4447
    4548#endif /*BOUNDARY_HPP_*/
  • src/tesselation.cpp

    r093645 r0077b5  
    17511751  class BoundaryPointSet *Spot = NULL;
    17521752  class BoundaryLineSet *OtherBase;
    1753   Vector *ClosestPoint[2];
     1753  Vector *ClosestPoint;
    17541754
    17551755  int m=0;
     
    17641764
    17651765  // get the closest point on each line to the other line
    1766   ClosestPoint[0] = GetClosestPointBetweenLine(out, Base, OtherBase);
    1767   ClosestPoint[1] = GetClosestPointBetweenLine(out, OtherBase, Base);
     1766  ClosestPoint = GetClosestPointBetweenLine(out, Base, OtherBase);
    17681767
    17691768  // delete the temporary other base line
     1769  delete(ClosestPoint);
    17701770  delete(OtherBase);
    17711771
    17721772  // get the distance vector from Base line to OtherBase line
    1773   Vector DistanceToIntersection, BaseLine;
     1773  Vector DistanceToIntersection[2], BaseLine;
     1774  double distance[2];
    17741775  BaseLine.CopyVector(Base->endpoints[1]->node->node);
    17751776  BaseLine.SubtractVector(Base->endpoints[0]->node->node);
    1776   DistanceToIntersection.CopyVector(ClosestPoint[0]);
    1777   DistanceToIntersection.SubtractVector(Base->endpoints[0]->node->node);
    1778   Spot = Base->endpoints[1];
    1779   if (BaseLine.ScalarProduct(&DistanceToIntersection) < -MYEPSILON) {
    1780     DistanceToIntersection.CopyVector(ClosestPoint[0]);
    1781     DistanceToIntersection.SubtractVector(Base->endpoints[1]->node->node);
    1782     Spot = Base->endpoints[0];
    1783     if (BaseLine.ScalarProduct(&DistanceToIntersection) < -MYEPSILON) {
    1784       *out << Verbose(3) << "ERROR: Something's very wrong here, both SKPs return negative?!" << endl;
    1785       return NULL;
    1786     }
    1787   }
    1788   if ((BaseLine.NormSquared() - DistanceToIntersection.NormSquared()) < -MYEPSILON) {  // distance is smaller: concave
    1789     *out << Verbose(3) << "INFO: Rectangle of triangles of base line " << *Base << " is concave: Base line squared length " << BaseLine.NormSquared() << " against Distance to intersection squared " << DistanceToIntersection.NormSquared() << "." << endl;
     1777  for (int i=0;i<2;i++) {
     1778    DistanceToIntersection[i].CopyVector(ClosestPoint);
     1779    DistanceToIntersection[i].SubtractVector(Base->endpoints[i]->node->node);
     1780    distance[i] = BaseLine.ScalarProduct(&DistanceToIntersection[i]);
     1781  }
     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;
     1784    if (distance[0] < distance[1]) {
     1785      Spot = Base->endpoints[0];
     1786    } else {
     1787      Spot = Base->endpoints[1];
     1788    }
    17901789    return Spot;
    1791   } else {  // base line is longer: convex
    1792     *out << Verbose(3) << "INFO: Rectangle of triangles of base line " << *Base << " is concave." << endl;
     1790  } else {  // different sign, i.e. we are in between
     1791    *out << Verbose(3) << "ACCEPT: Rectangle of triangles of base line " << *Base << " is convex." << endl;
    17931792    return NULL;
    17941793  }
     
    17961795};
    17971796
     1797void Tesselation::PrintAllBoundaryPoints(ofstream *out)
     1798{
     1799  // print all lines
     1800  *out << Verbose(1) << "Printing all boundary points for debugging:" << endl;
     1801  for (PointMap::iterator PointRunner = PointsOnBoundary.begin();PointRunner != PointsOnBoundary.end(); PointRunner++)
     1802    *out << Verbose(2) << *(PointRunner->second) << endl;
     1803};
     1804
     1805void Tesselation::PrintAllBoundaryLines(ofstream *out)
     1806{
     1807  // print all lines
     1808  *out << Verbose(1) << "Printing all boundary lines for debugging:" << endl;
     1809  for (LineMap::iterator LineRunner = LinesOnBoundary.begin(); LineRunner != LinesOnBoundary.end(); LineRunner++)
     1810    *out << Verbose(2) << *(LineRunner->second) << endl;
     1811};
     1812
     1813void Tesselation::PrintAllBoundaryTriangles(ofstream *out)
     1814{
     1815  // print all triangles
     1816  *out << Verbose(1) << "Printing all boundary triangles for debugging:" << endl;
     1817  for (TriangleMap::iterator TriangleRunner = TrianglesOnBoundary.begin(); TriangleRunner != TrianglesOnBoundary.end(); TriangleRunner++)
     1818    *out << Verbose(2) << *(TriangleRunner->second) << endl;
     1819};
    17981820
    17991821/** For a given boundary line \a *Base and its two triangles, picks the central baseline that is "higher".
     
    18261848  Distance.SubtractVector(ClosestPoint[0]);
    18271849
    1828   // delete the temporary other base line
     1850  // delete the temporary other base line and the closest points
     1851  delete(ClosestPoint[0]);
     1852  delete(ClosestPoint[1]);
    18291853  delete(OtherBase);
    18301854
     
    18431867      BaseLineNormal.AddVector(&(runner->second->NormalVector));
    18441868    }
    1845     BaseLineNormal.Scale(-1./2.); // has to point inside for BoundaryTriangleSet::GetNormalVector()
     1869    BaseLineNormal.Scale(1./2.);
    18461870
    18471871    if (Distance.ScalarProduct(&BaseLineNormal) > MYEPSILON) { // Distance points outwards, hence OtherBase higher than Base -> flip
     
    18661890  // construct the plane of the two baselines (i.e. take both their directional vectors)
    18671891  Vector Normal;
    1868   Vector OtherBaseline;
    1869   Normal.CopyVector(Base->endpoints[1]->node->node);
    1870   Normal.SubtractVector(Base->endpoints[0]->node->node);
     1892  Vector Baseline, OtherBaseline;
     1893  Baseline.CopyVector(Base->endpoints[1]->node->node);
     1894  Baseline.SubtractVector(Base->endpoints[0]->node->node);
    18711895  OtherBaseline.CopyVector(OtherBase->endpoints[1]->node->node);
    18721896  OtherBaseline.SubtractVector(OtherBase->endpoints[0]->node->node);
     1897  Normal.CopyVector(&Baseline);
    18731898  Normal.VectorProduct(&OtherBaseline);
    18741899  Normal.Normalize();
    1875 
    1876   // project one offset point of OtherBase onto this plane
     1900  *out << Verbose(4) << "First direction is " << Baseline << ", second direction is " << OtherBaseline << ", normal of intersection plane is " << Normal << "." << endl;
     1901
     1902  // project one offset point of OtherBase onto this plane (and add plane offset vector)
    18771903  Vector NewOffset;
    18781904  NewOffset.CopyVector(OtherBase->endpoints[0]->node->node);
    18791905  NewOffset.ProjectOntoPlane(&Normal);
    1880   Vector NewDirection;
    1881   NewDirection.CopyVector(OtherBase->endpoints[1]->node->node);
    1882   NewDirection.ProjectOntoPlane(&Normal);
     1906  NewOffset.AddVector(Base->endpoints[0]->node->node);
    18831907
    18841908  // calculate the intersection between this projected baseline and Base
    18851909  Vector *Intersection = new Vector;
    1886   Intersection->GetIntersectionOfTwoLinesOnPlane(out, Base->endpoints[0]->node->node, Base->endpoints[1]->node->node, &NewOffset, &NewDirection, &Normal);
     1910  Intersection->GetIntersectionOfTwoLinesOnPlane(out, Base->endpoints[0]->node->node, Base->endpoints[1]->node->node, &NewOffset, &OtherBaseline, &Normal);
     1911  Normal.CopyVector(Intersection);
     1912  Normal.SubtractVector(Base->endpoints[0]->node->node);
     1913  *out << Verbose(3) << "Found closest point on " << *Base << " at " << *Intersection << ", factor in line is " << fabs(Normal.ScalarProduct(&Baseline)/Baseline.NormSquared()) << "." << endl;
    18871914
    18881915  return Intersection;
     
    29382965double getAngle(const Vector &point, const Vector &reference, const Vector OrthogonalVector)
    29392966{
    2940   if (reference.IsNull())
     2967  if (reference.IsZero())
    29412968    return M_PI;
    29422969
    29432970  // calculate both angles and correct with in-plane vector
    2944   if (point.IsNull())
     2971  if (point.IsZero())
    29452972    return M_PI;
    29462973  double phi = point.Angle(&reference);
  • src/tesselation.hpp

    r093645 r0077b5  
    227227    bool IsInnerPoint(ofstream *out, TesselPoint *Point, LinkedCell* LC);
    228228    bool AddBoundaryPoint(TesselPoint *Walker, int n);
     229
     230    // print for debugging
     231    void PrintAllBoundaryPoints(ofstream *out);
     232    void PrintAllBoundaryLines(ofstream *out);
     233    void PrintAllBoundaryTriangles(ofstream *out);
     234
    229235
    230236    PointMap PointsOnBoundary;
Note: See TracChangeset for help on using the changeset viewer.