Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/AnalysisAction/PrincipalAxisSystemAction.cpp

    r6e5084 r0430e3  
    1010#include "Actions/AnalysisAction/PrincipalAxisSystemAction.hpp"
    1111#include "Actions/ActionRegistry.hpp"
    12 #include "Helpers/Log.hpp"
    13 #include "Helpers/Verbose.hpp"
    14 #include "LinearAlgebra/Matrix.hpp"
    15 #include "LinearAlgebra/Vector.hpp"
    16 #include "element.hpp"
    1712#include "molecule.hpp"
     13#include "log.hpp"
     14#include "verbose.hpp"
    1815
    1916#include <iostream>
     
    2421#include "UIElements/UIFactory.hpp"
    2522#include "UIElements/Dialog.hpp"
    26 #include "Actions/ValueStorage.hpp"
     23#include "UIElements/ValueStorage.hpp"
    2724
    2825const char AnalysisPrincipalAxisSystemAction::NAME[] = "principal-axis-system";
     
    3936};
    4037
    41 Dialog* AnalysisPrincipalAxisSystemAction::fillDialog(Dialog *dialog) {
    42   ASSERT(dialog,"No Dialog given when filling action dialog");
     38Dialog* AnalysisPrincipalAxisSystemAction::createDialog() {
     39  Dialog *dialog = UIFactory::getInstance().makeDialog();
    4340
    4441  dialog->queryEmpty(NAME, ValueStorage::getInstance().getDescription(NAME));
     
    4946Action::state_ptr AnalysisPrincipalAxisSystemAction::performCall() {
    5047  molecule *mol = NULL;
    51   Matrix InertiaTensor;
    5248
    5349  ValueStorage::getInstance().queryCurrentValue(NAME, mol);
     
    5551  for (World::MoleculeSelectionIterator iter = World::getInstance().beginMoleculeSelection(); iter != World::getInstance().endMoleculeSelection(); ++iter) {
    5652    molecule *mol = iter->second;
    57     Vector *CenterOfGravity = mol->DetermineCenterOfGravity();
    58 
    59     // reset inertia tensor
    60     InertiaTensor.zero();
    61 
    62     // sum up inertia tensor
    63     for (molecule::const_iterator iter = mol->begin(); iter != mol->end(); ++iter) {
    64       Vector x = (*iter)->x;
    65       x -= *CenterOfGravity;
    66       InertiaTensor.at(0,0) += (*iter)->type->mass*(x[1]*x[1] + x[2]*x[2]);
    67       InertiaTensor.at(0,1) += (*iter)->type->mass*(-x[0]*x[1]);
    68       InertiaTensor.at(0,2) += (*iter)->type->mass*(-x[0]*x[2]);
    69       InertiaTensor.at(1,0) += (*iter)->type->mass*(-x[1]*x[0]);
    70       InertiaTensor.at(1,1) += (*iter)->type->mass*(x[0]*x[0] + x[2]*x[2]);
    71       InertiaTensor.at(1,2) += (*iter)->type->mass*(-x[1]*x[2]);
    72       InertiaTensor.at(2,0) += (*iter)->type->mass*(-x[2]*x[0]);
    73       InertiaTensor.at(2,1) += (*iter)->type->mass*(-x[2]*x[1]);
    74       InertiaTensor.at(2,2) += (*iter)->type->mass*(x[0]*x[0] + x[1]*x[1]);
    75     }
    76     // print InertiaTensor for debugging
    77     DoLog(0) && (Log() << Verbose(0) << "The inertia tensor is:" << InertiaTensor << endl);
     53    mol->PrincipalAxisSystem(false);
    7854  }
    7955  return Action::success;
Note: See TracChangeset for help on using the changeset viewer.