Changeset c15ca2 for src/unittests


Ignore:
Timestamp:
Dec 29, 2009, 2:48:49 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:
97498a
Parents:
71b20e
Message:

Changes to FindClosest...ToVector() and use of ..Map,..Set,..List defines in tesselation.cpp.

Location:
src/unittests
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • src/unittests/Makefile.am

    r71b20e rc15ca2  
    44AM_CXXFLAGS = $(CPPUNIT_CFLAGS)
    55
    6 TESTS = ActOnAllUnitTest AnalysisBondsUnitTests AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest BondGraphUnitTest InfoUnitTest ListOfBondsUnitTest LogUnitTest MemoryUsageObserverUnitTest MemoryAllocatorUnitTest StackClassUnitTest VectorUnitTest
     6TESTS = ActOnAllUnitTest AnalysisBondsUnitTests AnalysisCorrelationToPointUnitTest AnalysisCorrelationToSurfaceUnitTest AnalysisPairCorrelationUnitTest BondGraphUnitTest InfoUnitTest ListOfBondsUnitTest LogUnitTest MemoryUsageObserverUnitTest MemoryAllocatorUnitTest StackClassUnitTest TesselationUnitTest TesselationInOutsideUnitTest VectorUnitTest
    77check_PROGRAMS = $(TESTS)
    88noinst_PROGRAMS = $(TESTS)
     
    4444StackClassUnitTest_LDADD = ../libmolecuilder.a
    4545
     46TesselationUnitTest_SOURCES = tesselationunittest.cpp tesselationunittest.hpp
     47TesselationUnitTest_LDADD = ../libmolecuilder.a
     48
     49TesselationInOutsideUnitTest_SOURCES = tesselation_insideoutsideunittest.cpp tesselation_insideoutsideunittest.hpp
     50TesselationInOutsideUnitTest_LDADD = ../libmolecuilder.a
     51
    4652VectorUnitTest_SOURCES = vectorunittest.cpp vectorunittest.hpp
    4753VectorUnitTest_LDADD = ../libmolecuilder.a
  • src/unittests/tesselationunittest.cpp

    r71b20e rc15ca2  
    3030  class TesselPoint *Walker;
    3131  Walker = new TesselPoint;
    32   Walker->node = new Vector(1., 0., 0.);
    33   Walker->Name = new char[3];
     32  Walker->node = new Vector(1., 0., -1.);
     33  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    3434  strcpy(Walker->Name, "1");
    3535  Walker->nr = 1;
    3636  Corners.push_back(Walker);
    3737  Walker = new TesselPoint;
    38   Walker->node = new Vector(-1., 1., 0.);
    39   Walker->Name = new char[3];
     38  Walker->node = new Vector(-1., 1., -1.);
     39  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    4040  strcpy(Walker->Name, "2");
    4141  Walker->nr = 2;
    4242  Corners.push_back(Walker);
    4343  Walker = new TesselPoint;
    44   Walker->node = new Vector(-1., -1., 0.);
    45   Walker->Name = new char[3];
     44  Walker->node = new Vector(-1., -1., -1.);
     45  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    4646  strcpy(Walker->Name, "3");
    4747  Walker->nr = 3;
     
    4949  Walker = new TesselPoint;
    5050  Walker->node = new Vector(-1., 0., 1.);
    51   Walker->Name = new char[3];
     51  Walker->Name = Malloc<char>(3, "TesselationTest::setUp");
    5252  strcpy(Walker->Name, "4");
    5353  Walker->nr = 4;
     
    5959  // create tesselation
    6060  TesselStruct = new Tesselation;
    61   TesselStruct->PointsOnBoundary.clear();
    62   TesselStruct->LinesOnBoundary.clear();
    63   TesselStruct->TrianglesOnBoundary.clear();
     61  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->PointsOnBoundary.empty() );
     62  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->LinesOnBoundary.empty() );
     63  CPPUNIT_ASSERT_EQUAL( true, TesselStruct->TrianglesOnBoundary.empty() );
    6464  TesselStruct->FindStartingTriangle(SPHERERADIUS, LinkedList);
    65   bool flag = false;
    6665
    67   LineMap::iterator baseline = TesselStruct->LinesOnBoundary.begin();
    68   while (baseline != TesselStruct->LinesOnBoundary.end()) {
    69     if (baseline->second->triangles.size() == 1) {
    70       flag = TesselStruct->FindNextSuitableTriangle(*(baseline->second), *(((baseline->second->triangles.begin()))->second), SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
     66  CandidateForTesselation *baseline = NULL;
     67  BoundaryTriangleSet *T = NULL;
     68  bool OneLoopWithoutSuccessFlag = true;
     69  bool TesselationFailFlag = false;
     70  while ((!TesselStruct->OpenLines.empty()) && (OneLoopWithoutSuccessFlag)) {
     71    // 2a. fill all new OpenLines
     72    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     73      baseline = Runner->second;
     74      if (baseline->pointlist.empty()) {
     75        T = (((baseline->BaseLine->triangles.begin()))->second);
     76        TesselationFailFlag = TesselStruct->FindNextSuitableTriangle(*baseline, *T, SPHERERADIUS, LinkedList); //the line is there, so there is a triangle, but only one.
     77      }
    7178    }
    72     baseline++;
    73     if ((baseline == TesselStruct->LinesOnBoundary.end()) && (flag)) {
    74       baseline = TesselStruct->LinesOnBoundary.begin();   // restart if we reach end due to newly inserted lines
    75       flag = false;
     79
     80    // 2b. search for smallest ShortestAngle among all candidates
     81    double ShortestAngle = 4.*M_PI;
     82    for (CandidateMap::iterator Runner = TesselStruct->OpenLines.begin(); Runner != TesselStruct->OpenLines.end(); Runner++) {
     83      if (Runner->second->ShortestAngle < ShortestAngle) {
     84        baseline = Runner->second;
     85        ShortestAngle = baseline->ShortestAngle;
     86      }
     87    }
     88    if ((ShortestAngle == 4.*M_PI) || (baseline->pointlist.empty()))
     89      OneLoopWithoutSuccessFlag = false;
     90    else {
     91      TesselStruct->AddCandidateTriangle(*baseline);
    7692    }
    7793  }
     
    84100  delete(TesselStruct);
    85101  for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++) {
    86     delete[]((*Runner)->Name);
    87102    delete((*Runner)->node);
    88103    delete(*Runner);
    89104  }
    90105  Corners.clear();
    91 };
    92 
    93 /** UnitTest for Tesselation::IsInnerPoint()
    94  */
    95 void TesselationTest::IsInnerPointTest()
    96 {
    97   // true inside points
    98   CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.,0.), LinkedList) );
    99   CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.5,0.,0.), LinkedList) );
    100   CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.5,0.), LinkedList) );
    101   CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint(Vector(0.,0.,0.5), LinkedList) );
    102 
    103   // corners
    104   for (LinkedNodes::iterator Runner = Corners.begin(); Runner != Corners.end(); Runner++)
    105     CPPUNIT_ASSERT_EQUAL( true, TesselStruct->IsInnerPoint((*Runner), LinkedList) );
    106 
    107   // true outside points
    108   CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(0.,5.,0.), LinkedList) );
    109   CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(0.,0.,5.), LinkedList) );
    110   CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(1.,1.,1.), LinkedList) );
    111 
    112   // tricky point, there are three equally close triangles
    113   CPPUNIT_ASSERT_EQUAL( false, TesselStruct->IsInnerPoint(Vector(5.,0.,0.), LinkedList) );
    114 
     106  MemoryUsageObserver::purgeInstance();
     107  logger::purgeInstance();
     108  errorLogger::purgeInstance();
    115109};
    116110
  • src/unittests/tesselationunittest.hpp

    r71b20e rc15ca2  
    2121{
    2222    CPPUNIT_TEST_SUITE( TesselationTest) ;
    23     CPPUNIT_TEST ( IsInnerPointTest );
    2423    CPPUNIT_TEST ( GetAllTrianglesTest );
    2524    CPPUNIT_TEST ( ContainmentTest );
     
    2928      void setUp();
    3029      void tearDown();
    31       void IsInnerPointTest();
    3230      void GetAllTrianglesTest();
    3331      void ContainmentTest();
Note: See TracChangeset for help on using the changeset viewer.