Ignore:
Timestamp:
Apr 6, 2012, 11:44:51 AM (13 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:
531f27
Parents:
72e4c95
git-author:
Frederik Heber <heber@…> (04/05/12 15:42:12)
git-committer:
Frederik Heber <heber@…> (04/06/12 11:44:51)
Message:

Added regression test Filling/RegularGrid with and without a tesselated surface.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/FillAction/FillRegularGridAction.cpp

    r72e4c95 r80ca29  
    2424#include "Atom/AtomicInfo.hpp"
    2525#include "Atom/CopyAtoms/CopyAtoms_withBonds.hpp"
     26#include "Bond/BondInfo.hpp"
    2627#include "CodePatterns/Log.hpp"
    2728#include "Descriptors/MoleculeOrderDescriptor.hpp"
     
    6768  getParametersfromValueStorage();
    6869
    69   // get the filler molecule and move to origin
     70  // get the filler molecule
     71  std::vector<AtomicInfo> movedatoms;
    7072  const std::vector< molecule *> molecules = World::getInstance().getSelectedMolecules();
    7173  if (molecules.size() != 1) {
     
    7476  }
    7577  molecule *filler = *(molecules.begin());
     78  for(molecule::const_iterator iter = filler->begin(); iter != filler->end(); ++iter)
     79    movedatoms.push_back( AtomicInfo(*(*iter)) );
    7680  LOG(1, "INFO: Chosen molecule has " << filler->size() << " atoms.");
    7781
     
    8286  Tesselation * TesselStruct = NULL;
    8387  if (params.SphereRadius != 0.) {
    84     if ( molecules.size() == 0) {
     88    if ( atoms.size() == 0) {
    8589      ELOG(1, "You have given a sphere radius " << params.SphereRadius
    8690          << " != 0, but have not select any molecules.");
     91      return Action::failure;
    8792    }
    8893    // create adaptor for the selected atoms
     
    99104
    100105  // create predicate, mesh, and filler
    101   std::vector<AtomicInfo> clonedatoms;
     106  FillRegularGridState *UndoState = NULL;
    102107  bool successflag = false;
    103108  {
     
    129134      delete fillerFunction;
    130135
    131       // append each cluster's atoms to clonedatoms
     136      // append each cluster's atoms to clonedatoms (however not selected ones)
     137      std::vector<const atom *> clonedatoms;
     138      std::vector<AtomicInfo> clonedatominfos;
    132139      for (Filler::ClusterVector_t::const_iterator iter = ClonedClusters.begin();
    133140          iter != ClonedClusters.end(); ++iter) {
     
    135142        clonedatoms.reserve(clonedatoms.size()+atoms.size());
    136143        for (AtomIdSet::const_iterator atomiter = atoms.begin(); atomiter != atoms.end(); ++atomiter)
    137           clonedatoms.push_back( AtomicInfo(*(*atomiter)) );
     144          if (!filler->containsAtom(*atomiter)) {
     145            clonedatoms.push_back( *atomiter );
     146            clonedatominfos.push_back( AtomicInfo(*(*atomiter)) );
     147          }
    138148      }
     149      std::vector< BondInfo > clonedbonds;
     150      StoreBondInformationFromAtoms(clonedatoms, clonedbonds);
     151      LOG(2, "DEBUG: There are " << clonedatominfos.size() << " newly created atoms.");
     152
    139153      if (!successflag) {
    140         ELOG(1, "Insertion failed, removing inserted clusters again.");
    141         RemoveAtomsFromAtomicInfo(clonedatoms);
     154        ELOG(1, "Insertion failed, removing inserted clusters, translating original one back");
     155        RemoveAtomsFromAtomicInfo(clonedatominfos);
    142156        clonedatoms.clear();
     157        SetAtomsFromAtomicInfo(movedatoms);
     158      } else {
     159        std::vector<Vector> MovedToVector(filler->size(), zeroVec);
     160        std::transform(filler->begin(), filler->end(), MovedToVector.begin(),
     161            boost::bind(&AtomInfo::getPosition, _1) );
     162        UndoState = new FillRegularGridState(clonedatominfos,clonedbonds,movedatoms,MovedToVector,params);
    143163      }
    144164    }
     
    154174
    155175  if (successflag)
    156     return Action::state_ptr(new FillRegularGridState(clonedatoms,params));
     176    return Action::state_ptr(UndoState);
    157177  else
    158178    return Action::failure;
     
    164184  // remove all created atoms
    165185  RemoveAtomsFromAtomicInfo(state->clonedatoms);
     186  // add the original cluster
     187  SetAtomsFromAtomicInfo(state->movedatoms);
    166188
    167189  return Action::state_ptr(_state);
     
    171193  FillRegularGridState *state = assert_cast<FillRegularGridState*>(_state.get());
    172194
    173   if (AddAtomsFromAtomicInfo(state->clonedatoms))
     195  // place filler cluster again at new spot
     196  ResetAtomPosition(state->movedatoms, state->MovedToVector);
     197
     198  // re-create all clusters
     199  bool statusflag = AddAtomsFromAtomicInfo(state->clonedatoms);
     200
     201  // re-create the bonds
     202  if (statusflag)
     203    AddBondsFromBondInfo(state->clonedbonds);
     204  if (statusflag)
    174205    return Action::state_ptr(_state);
    175206  else
Note: See TracChangeset for help on using the changeset viewer.