Commit 6124a32b authored by js9's avatar js9

merge from 1.12: pick up fix to Dirname and to POV writing with different dirs


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@7360 18c085ea-50e0-402c-830e-de6fd14e8384
parent db702a33
......@@ -66,6 +66,7 @@
#include <ColorControlPointList.h>
#include <ColorControlPoint.h>
#include <AtomicProperties.h>
#include <StringHelpers.h>
#include <avtCommonDataFunctions.h>
......@@ -1138,6 +1139,10 @@ TakeOffPolyLine(int *seg_list,int start_pt,std::vector< std::vector<int> > &ls)
// which means "unknown", and hydrogen now starts at 1. This
// also means we don't have to correct for 1-origin atomic numbers.
//
// Jeremy Meredith, Wed May 20 13:48:34 EDT 2009
// Write atomicproperties and colortables .inc files to same directory
// as the pov files.
//
// ****************************************************************************
void
......@@ -1146,13 +1151,18 @@ avtDatasetFileWriter::WritePOVRayFamily(const char *filename)
avtDataTree_p dt = GetInputDataTree();
//
// Re-construct the basename.
// Re-construct the base file name without the extension.
//
char *basename = new char[strlen(filename)+1];
int badExt = strlen(extensions[(int) POVRAY]);
strncpy(basename, filename, strlen(filename)-badExt);
basename[strlen(filename)-badExt] = '\0';
//
// Get the dir name in case user's not saving in current directory
//
string dirname(StringHelpers::Dirname(basename));
//
// It's easiest and safest to collect data and spatial extents
// manually, especially for spatial since POVRay and VisIt are
......@@ -1187,7 +1197,8 @@ avtDatasetFileWriter::WritePOVRayFamily(const char *filename)
//
// And make a .inc file with the current visit colortables
//
ofstream ctfile("colortables.inc");
string ct_fname = dirname + VISIT_SLASH_CHAR + "colortables.inc";
ofstream ctfile(ct_fname.c_str());
const ColorTableAttributes *colortables =
avtColorTables::Instance()->GetColorTables();
int num = colortables->GetNumColorTables();
......@@ -1218,7 +1229,8 @@ avtDatasetFileWriter::WritePOVRayFamily(const char *filename)
//
// And make a .inc file with the current atomic properties
//
ofstream atomfile("atomicproperties.inc");
string atom_fname = dirname + VISIT_SLASH_CHAR + "atomicproperties.inc";
ofstream atomfile(atom_fname.c_str());
atomfile << "#declare atomic_radius = array["<<MAX_ELEMENT_NUMBER+1<<"]\n";
atomfile << "{" << endl;
for (int i=0; i<=MAX_ELEMENT_NUMBER; i++)
......
......@@ -508,11 +508,16 @@ StringHelpers::ExtractRESubstr(const char *strToSearch, const char *re)
// Programmer: Mark C. Miller
// Creation: Unknown
//
// Modifications:
// Jeremy Meredith, Wed May 20 13:46:39 EDT 2009
// Should default to "0" for start, and only use "-1" for
// the "all-slash-string" case.
//
// ****************************************************************************
static const char *
basename(const char *path, int& start)
{
start = -1;
start = 0;
if (path == 0)
{
......@@ -546,6 +551,7 @@ basename(const char *path, int& start)
// deal with string consisting of all VISIT_SLASH_CHAR chars
if (j == -1)
{
start = -1;
strcpy(StaticStringBuf, VISIT_SLASH_STRING);
return StaticStringBuf;
}
......@@ -581,28 +587,18 @@ StringHelpers::Basename(const char *path)
// Programmer: Mark C. Miller
// Creation: Unknown
//
// Modifications:
// Jeremy Meredith, Wed May 20 13:46:39 EDT 2009
// Special cases were unnecessary; they fall out of the start position
// returned from the above implementation of basename naturally. Fixed
// a couple of the special cases as well.
//
// ****************************************************************************
const char *
StringHelpers::Dirname(const char *path)
{
int start;
// deal with special cases first
if ((path == 0) || // null path
(path[0] == '\0') || // ""
((path[0] == '.') && (path[1] == '\0')) || // "."
((path[0] == '.') && (path[1] == '.') && // ".."
(path[2] == '\0')))
{
strcpy(StaticStringBuf, ".");
return StaticStringBuf;
}
else if ((path[0] == VISIT_SLASH_CHAR) && (path[1] == '\0'))
{
strcpy(StaticStringBuf, VISIT_SLASH_STRING);
return StaticStringBuf;
}
// ok, figure out the basename
basename(path, start);
......@@ -611,6 +607,11 @@ StringHelpers::Dirname(const char *path)
strcpy(StaticStringBuf, VISIT_SLASH_STRING);
return StaticStringBuf;
}
else if (start == 0)
{
strcpy(StaticStringBuf, ".");
return StaticStringBuf;
}
else
{
int i;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment