Changeset cc9225 for molecuilder/src


Ignore:
Timestamp:
Nov 24, 2009, 3:34:49 PM (16 years ago)
Author:
Frederik Heber <heber@…>
Children:
1a3354
Parents:
7d1ad9
Message:

Fixes and naming of final Tecplot output file is now molecule name.

  • FIXES to builder.cpp:
    • case 'p' would not dissect the molecule into connected subgraphs
    • if done so, the BondGraph was not yet initialised
    • if done so, we need to check whether BondGraphFileName has been set
    • BondGraphFileName.empty() could not be used as a check, as was set to "" instead of "\n"
    • if (finally) done so, we have to remove the empty molecule that we parsed in
    • ... and then pick the newly added molecule for mol to point at
    • SaveConfig() did not set the merged molecule name correctly.
    • if empty config is given, the empty molecule now receives the ConfigFileName as name
  • FIXES to config.cpp
    • Load() did not set the name of the molecule
  • changes to tesselationhelper.cpp and tesselation.cpp
  • changes to PointCloud and molecule
    • new virtual function PointCloud::GetName() returns "unknown"
    • new function molecule::GetName() returns pointer to name of molecule
    • IsEmpty() and IsEnd() now return true by default
  • all .dat files in the "Tesselations" tests were changed accordingly (i.e. have now the name in the second line)
  • benzene was added as a new test for an absolutely flat molecule. So far, it fails horribly.
  • 13 of 17 tests run fine

Signed-off-by: Frederik Heber <heber@…>

Location:
molecuilder/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/boundary.cpp

    r7d1ad9 rcc9225  
    671671      OutputName.append(TecplotSuffix);
    672672      ofstream *tecplot = new ofstream(OutputName.c_str());
    673       WriteTecplotFile(tecplot, TesselStruct, mol, 0);
     673      WriteTecplotFile(tecplot, TesselStruct, mol, -1);
    674674      tecplot->close();
    675675      delete(tecplot);
  • molecuilder/src/builder.cpp

    r7d1ad9 rcc9225  
    12471247  ofstream output;
    12481248  molecule *mol = new molecule(periode);
     1249  mol->SetNameFromFilename(ConfigFileName);
    12491250
    12501251  if (!strcmp(configuration->configpath, configuration->GetDefaultPath())) {
     
    13851386  int argptr;
    13861387  molecule *mol = NULL;
    1387   string BondGraphFileName("");
     1388  string BondGraphFileName("\n");
    13881389  int verbosity = 0;
    13891390  strncpy(configuration.databasepath, LocalPath, MAXSTRINGSIZE-1);
     
    15391540       mol = new molecule(periode);
    15401541       mol->ActiveFlag = true;
     1542       if (ConfigFileName != NULL)
     1543         mol->SetNameFromFilename(ConfigFileName);
    15411544       molecules->insert(mol);
     1545     }
     1546     if (configuration.BG == NULL) {
     1547       configuration.BG = new BondGraph(configuration.GetIsAngstroem());
     1548       if ((BondGraphFileName.empty()) && (configuration.BG->LoadBondLengthTable(BondGraphFileName))) {
     1549         Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1550       } else {
     1551         eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1552       }
    15421553     }
    15431554
     
    15631574                else {
    15641575                  Log() << Verbose(2) << "File found and parsed." << endl;
     1576                  mol->SetNameFromFilename(argv[argptr]);
     1577                  molecules->ListOfMolecules.remove(mol);
     1578                  molecules->DissectMoleculeIntoConnectedSubgraphs(mol,&configuration);
     1579                  if (molecules->ListOfMolecules.size() != 0) {
     1580                    for (MoleculeList::iterator ListRunner = molecules->ListOfMolecules.begin(); ListRunner != molecules->ListOfMolecules.end(); ListRunner++)
     1581                      if ((*ListRunner)->ActiveFlag) {
     1582                        mol = *ListRunner;
     1583                        break;
     1584                      }
     1585                  }
    15651586                  configPresent = present;
    15661587                }
  • molecuilder/src/config.cpp

    r7d1ad9 rcc9225  
    10561056
    10571057  // 2. parse the bond graph file if given
    1058   BG = new BondGraph(IsAngstroem);
    1059   if (BG->LoadBondLengthTable(BondGraphFileName)) {
    1060     Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
    1061   } else {
    1062     eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1058  if (BG == NULL) {
     1059    BG = new BondGraph(IsAngstroem);
     1060    if (BG->LoadBondLengthTable(BondGraphFileName)) {
     1061      Log() << Verbose(0) << "Bond length table loaded successfully." << endl;
     1062    } else {
     1063      eLog() << Verbose(1) << "Bond length table loading failed." << endl;
     1064    }
    10631065  }
    10641066
    10651067  // 3. parse the molecule in
    10661068  LoadMolecule(mol, FileBuffer, periode, FastParsing);
     1069  mol->SetNameFromFilename(filename);
    10671070  mol->ActiveFlag = true;
    10681071
  • molecuilder/src/molecule.hpp

    r7d1ad9 rcc9225  
    106106
    107107  // re-definition of virtual functions from PointCloud
     108  const char * const GetName() const;
    108109  Vector *GetCenter() const ;
    109110  TesselPoint *GetPoint() const ;
  • molecuilder/src/molecule_pointcloud.cpp

    r7d1ad9 rcc9225  
    1313/************************************* Functions for class molecule *********************************/
    1414
     15/** Returns a name for this point cloud, here the molecule's name.
     16 * \return name of point cloud
     17 */
     18const char * const molecule::GetName() const
     19{
     20  return name;
     21};
    1522
    1623/** Determine center of all atoms.
  • molecuilder/src/moleculelist.cpp

    r7d1ad9 rcc9225  
    760760  // 4a. create array of molecules to fill
    761761  const int MolCount = Subgraphs->next->Count();
     762  char number[MAXSTRINGSIZE];
    762763  molecule **molecules = Malloc<molecule *>(MolCount, "config::Load() - **molecules");
    763764  for (int i=0;i<MolCount;i++) {
    764765    molecules[i] = (molecule*) new molecule(mol->elemente);
    765766    molecules[i]->ActiveFlag = true;
     767    strncpy(molecules[i]->name, mol->name, MAXSTRINGSIZE);
     768    if (MolCount > 1) {
     769      sprintf(number, "-%d", i+1);
     770      strncat(molecules[i]->name, number, MAXSTRINGSIZE - strlen(mol->name) - 1);
     771    }
     772    cout << "MolName is " << molecules[i]->name << endl;
    766773    insert(molecules[i]);
    767774  }
     
    800807    }
    801808  }
    802   // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintained their ListOfBonds, but we have to remove them from first..last list
     809  // 4d. we don't need to redo bonds, as they are connected subgraphs and still maintain their ListOfBonds, but we have to remove them from first..last list
    803810  bond *Binder = mol->first;
    804811  while (mol->first->next != mol->last) {
  • molecuilder/src/tesselation.cpp

    r7d1ad9 rcc9225  
    19571957    BTS = NULL;
    19581958    // check for present edges and whether we reach better candidates from them
    1959     if (HasOtherBaselineBetterCandidate(BaseRay, (*it)->point, ShortestAngle, RADIUS, LC) ) {
     1959    //if (HasOtherBaselineBetterCandidate(BaseRay, (*it)->point, ShortestAngle, RADIUS, LC) ) {
     1960    if (0) {
    19601961      result = false;
    19611962      break;
     
    35843585  }
    35853586  delete(DegeneratedTriangles);
     3587  if (count > 0)
     3588    LastTriangle = NULL;
    35863589
    35873590  Log() << Verbose(1) << "RemoveDegeneratedTriangles() removed " << count << " triangles:" << endl;
  • molecuilder/src/tesselation.hpp

    r7d1ad9 rcc9225  
    170170  virtual ~PointCloud();
    171171
     172  virtual const char * const GetName() const { return "unknown"; };
    172173  virtual Vector *GetCenter() const { return NULL; };
    173174  virtual TesselPoint *GetPoint() const { return NULL; };
     
    177178  virtual void GoToFirst() const {};
    178179  virtual void GoToLast() const {};
    179   virtual bool IsEmpty() const { return false; };
    180   virtual bool IsEnd() const { return false; };
     180  virtual bool IsEmpty() const { return true; };
     181  virtual bool IsEnd() const { return true; };
    181182};
    182183
  • molecuilder/src/tesselationhelpers.cpp

    r7d1ad9 rcc9225  
    756756{
    757757  Vector helper;
    758   // include the current position of the virtual sphere in the temporary raster3d file
    759   Vector *center = cloud->GetCenter();
    760   // make the circumsphere's center absolute again
    761   helper.CopyVector(Tess->LastTriangle->endpoints[0]->node->node);
    762   helper.AddVector(Tess->LastTriangle->endpoints[1]->node->node);
    763   helper.AddVector(Tess->LastTriangle->endpoints[2]->node->node);
    764   helper.Scale(1./3.);
    765   helper.SubtractVector(center);
    766   // and add to file plus translucency object
    767   *rasterfile << "# current virtual sphere\n";
    768   *rasterfile << "8\n  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0\n";
    769   *rasterfile << "2\n  " << helper.x[0] << " " << helper.x[1] << " " << helper.x[2] << "\t" << 5. << "\t1 0 0\n";
    770   *rasterfile << "9\n  terminating special property\n";
    771   delete(center);
     758
     759  if (Tess->LastTriangle != NULL) {
     760    // include the current position of the virtual sphere in the temporary raster3d file
     761    Vector *center = cloud->GetCenter();
     762    // make the circumsphere's center absolute again
     763    helper.CopyVector(Tess->LastTriangle->endpoints[0]->node->node);
     764    helper.AddVector(Tess->LastTriangle->endpoints[1]->node->node);
     765    helper.AddVector(Tess->LastTriangle->endpoints[2]->node->node);
     766    helper.Scale(1./3.);
     767    helper.SubtractVector(center);
     768    // and add to file plus translucency object
     769    *rasterfile << "# current virtual sphere\n";
     770    *rasterfile << "8\n  25.0    0.6     -1.0 -1.0 -1.0     0.2        0 0 0 0\n";
     771    *rasterfile << "2\n  " << helper.x[0] << " " << helper.x[1] << " " << helper.x[2] << "\t" << 5. << "\t1 0 0\n";
     772    *rasterfile << "9\n  terminating special property\n";
     773    delete(center);
     774  }
    772775};
    773776
     
    829832    *tecplot << "TITLE = \"3D CONVEX SHELL\"" << endl;
    830833    *tecplot << "VARIABLES = \"X\" \"Y\" \"Z\" \"U\"" << endl;
    831     *tecplot << "ZONE T=\"" << N << "-";
    832     for (int i=0;i<3;i++)
    833       *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->Name;
     834    *tecplot << "ZONE T=\"";
     835    if (N < 0) {
     836      *tecplot << cloud->GetName();
     837    } else {
     838      *tecplot << N << "-";
     839      for (int i=0;i<3;i++)
     840        *tecplot << (i==0 ? "" : "_") << TesselStruct->LastTriangle->endpoints[i]->node->Name;
     841    }
    834842    *tecplot << "\", N=" << TesselStruct->PointsOnBoundary.size() << ", E=" << TesselStruct->TrianglesOnBoundary.size() << ", DATAPACKING=POINT, ZONETYPE=FETRIANGLE" << endl;
    835843    int i=0;
Note: See TracChangeset for help on using the changeset viewer.