Changeset a83171


Ignore:
Timestamp:
Mar 3, 2010, 2:53:07 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
328418d, 3d575e
Parents:
bd506d
git-author:
Frederik Heber <heber@…> (03/03/10 14:46:13)
git-committer:
Frederik Heber <heber@…> (03/03/10 14:53:07)
Message:

Default molecule name can be set via command line, BUGFIX: molecule::DepthFirstSearchAnalysis() seg'faulted on no atoms.

Allow '-I' on empty configs:

new case 'X' for setting default molecule name:

Location:
molecuilder/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/World.cpp

    rbd506d ra83171  
    66 */
    77
     8#include <string>
     9
    810#include "World.hpp"
    911
    1012double *World::cell_size = 0;
     13char *World::DefaultName = 0;
    1114
    1215/** Constructor of World.
     
    1619{
    1720  cell_size = new double[6];
     21  DefaultName = new char[6];
     22  strncpy(DefaultName, "none", 4);
    1823};
    1924
     
    2429{
    2530  delete[](cell_size);
     31  delete[](DefaultName);
    2632};
    2733
  • molecuilder/src/World.hpp

    rbd506d ra83171  
    3232
    3333  static double *cell_size;
     34  static char *DefaultName;
    3435
    3536private:
  • molecuilder/src/builder.cpp

    rbd506d ra83171  
    14801480            Log() << Verbose(0) << "\t-v\t\tsets verbosity (more is more)." << endl;
    14811481            Log() << Verbose(0) << "\t-V\t\tGives version information." << endl;
     1482            Log() << Verbose(0) << "\t-X\t\tset default name of a molecule." << endl;
    14821483            Log() << Verbose(0) << "Note: config files must not begin with '-' !" << endl;
    14831484            return (1);
     
    15181519            Log() << Verbose(0) << "I won't parse trajectories." << endl;
    15191520            configuration.FastParsing = true;
     1521            break;
     1522          case 'X':
     1523            {
     1524              char **name = &(World::get()->DefaultName);
     1525              delete[](*name);
     1526              const int length = strlen(argv[argptr]);
     1527              *name = new char[length+2];
     1528              strncpy(*name, argv[argptr], length);
     1529              Log() << Verbose(0) << "Default name of new molecules set to " << *name << "." << endl;
     1530            }
    15201531            break;
    15211532          default:   // no match? Step on
     
    17091720                  }
    17101721              }
    1711               if (mol == NULL) {
     1722              if ((mol == NULL) && (!molecules->ListOfMolecules.empty())) {
    17121723                mol = *(molecules->ListOfMolecules.begin());
    1713                 mol->ActiveFlag = true;
     1724                if (mol != NULL)
     1725                  mol->ActiveFlag = true;
    17141726              }
    17151727              break;
  • molecuilder/src/molecule.cpp

    rbd506d ra83171  
    4646  for(int i=MAX_ELEMENTS;i--;)
    4747    ElementsInMolecule[i] = 0;
    48   strcpy(name,"none");
     48  strcpy(name,World::get()->DefaultName);
    4949};
    5050
  • molecuilder/src/molecule_graph.cpp

    rbd506d ra83171  
    495495  bond *Binder = NULL;
    496496
     497  if (AtomCount == 0)
     498    return SubGraphs;
    497499  Log() << Verbose(0) << "Begin of DepthFirstSearchAnalysis" << endl;
    498500  DepthFirstSearchAnalysis_Init(DFS, this);
  • molecuilder/src/moleculelist.cpp

    rbd506d ra83171  
    786786
    787787  // 1. dissect the molecule into connected subgraphs
    788   configuration->BG->ConstructBondGraph(mol);
     788  if (configuration->BG->ConstructBondGraph(mol)) {
     789    delete (mol);
     790    eLog() << Verbose(1) << "There are no bonds." << endl;
     791    return;
     792  }
    789793
    790794  // 2. scan for connected subgraphs
     
    793797  Subgraphs = mol->DepthFirstSearchAnalysis(BackEdgeStack);
    794798  delete(BackEdgeStack);
     799  if ((Subgraphs == NULL) || (Subgraphs->next == NULL)) {
     800    delete (mol);
     801    eLog() << Verbose(1) << "There are no atoms." << endl;
     802    return;
     803  }
    795804
    796805  // 3. dissect (the following construct is needed to have the atoms not in the order of the DFS, but in
Note: See TracChangeset for help on using the changeset viewer.