1
1
#include " mvManager.h"
2
+
3
+ #include " mvAxes.h"
4
+ #include " mvBoundingBox.h"
5
+ #include " mvClipBox.h"
6
+ #include " mvColorBar.h"
7
+ #include " mvColorTable.h"
2
8
#include " mvCustomAppendPolyData.h"
3
- #include " mvModelList.h"
4
- #include " mvGUISettings.h"
5
- #include " mvPathlines.h"
6
- #include " mvGridLines.h"
9
+ #include " mvDisplayText.h"
7
10
#include " mvGridLayer.h"
11
+ #include " mvGridLines.h"
8
12
#include " mvGridShell.h"
13
+ #include " mvGUISettings.h"
9
14
#include " mvHashTable.h"
10
- #include " mvBoundingBox.h"
11
- #include " mvAxes.h"
15
+ #include " mvLogColorTable.h"
12
16
#include " mvModelFeatures.h"
13
- #include " mvColorBar.h"
14
- #include " mvDisplayText.h"
17
+ #include " mvModelList.h"
15
18
#include " mvOverlay.h"
16
- #include " mvColorTable.h"
17
- #include " mvLogColorTable.h"
18
- #include " mvClipBox.h"
19
+ #include " mvPathlines.h"
20
+ #include " mvSaveCurrentDirectory.h"
19
21
#include " mvUtil.h"
20
22
21
23
#include " vtkActor.h"
24
+ #include " vtkAlgorithmOutput.h"
22
25
#include " vtkBandedPolyDataContourFilter.h"
26
+ #include " vtkCellArray.h"
27
+ #include " vtkCellData.h"
23
28
#include " vtkClipPolyData.h"
24
29
#include " vtkContourFilter.h"
25
30
#include " vtkCubeSource.h"
26
31
#include " vtkCutter.h"
27
32
#include " vtkDataSetMapper.h"
28
- #include " vtkExtractGrid.h"
29
- #include " vtkExtractCells.h"
30
33
#include " vtkDoubleArray.h"
34
+ #include " vtkExtractCells.h"
35
+ #include " vtkExtractGeometry.h"
36
+ #include " vtkExtractGrid.h"
31
37
#include " vtkGeometryFilter.h"
32
38
#include " vtkGlyph3D.h"
33
39
#include " vtkHedgeHog.h"
34
- #include " vtkLookupTable.h"
40
+ #include " vtkHexagonalPrism.h"
41
+ #include " vtkHexahedron.h"
35
42
#include " vtkLogLookupTable.h"
43
+ #include " vtkLookupTable.h"
44
+ #include " vtkMaskPoints.h"
45
+ #include " vtkPentagonalPrism.h"
36
46
#include " vtkPlane.h"
47
+ #include " vtkPointData.h"
37
48
#include " vtkPolyData.h"
38
49
#include " vtkPolyDataMapper.h"
39
50
#include " vtkPropCollection.h"
51
+ #include " vtkProperty.h"
52
+ #include " vtkProperty2D.h"
40
53
#include " vtkStructuredGrid.h"
54
+ #include " vtkTextProperty.h"
41
55
#include " vtkThreshold.h"
42
56
#include " vtkThresholdPoints.h"
43
- #include " vtkMaskPoints.h"
44
- #include " vtkExtractGeometry.h"
45
- #include " vtkPointData.h"
46
- #include " vtkProperty.h"
47
- #include " vtkProperty2D.h"
48
57
#include " vtkUnstructuredGrid.h"
49
- #include " vtkCellData.h"
50
- #include " vtkTextProperty.h"
51
- #include " vtkAlgorithmOutput.h"
52
58
#include " vtkWedge.h"
53
- #include " vtkHexahedron.h"
54
- #include " vtkPentagonalPrism.h"
55
- #include " vtkHexagonalPrism.h"
56
- #include " vtkCellArray.h"
57
-
58
- #include " vtkConeSource.h"
59
59
60
60
#include < direct.h>
61
61
@@ -4848,7 +4848,7 @@ char *mvManager::Serialize(const char *fileName, mvGUISettings *gui) const
4848
4848
cr = strchr (code, ' \n ' );
4849
4849
*(cr) = ' \0 ' ;
4850
4850
// Get relative paths for all file codes
4851
- std::string relative = GetRelativePath (fileName, code);
4851
+ std::string relative = mvSaveCurrentDirectory:: GetRelativePath (fileName, code);
4852
4852
out << " File code " << (i + 1 ) << " = " << relative.c_str () << endl;
4853
4853
code = cr + 1 ;
4854
4854
}
@@ -5101,7 +5101,9 @@ char *mvManager::Serialize(const char *fileName, mvGUISettings *gui) const
5101
5101
// Overlay
5102
5102
if (m_Overlay->HasData ())
5103
5103
{
5104
- out << " Overlay file = " << m_Overlay->GetFileName () << endl;
5104
+ std::string dir = mvSaveCurrentDirectory::GetDirName (fileName);
5105
+ std::string relative = mvSaveCurrentDirectory::GetRelativePath (dir.c_str (), m_Overlay->GetFileName ());
5106
+ out << " Overlay file = " << relative << endl;
5105
5107
}
5106
5108
out << " Overlay data type = " << m_Overlay->GetType () << endl;
5107
5109
double x, y;
@@ -5141,8 +5143,9 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, std::strin
5141
5143
return ;
5142
5144
}
5143
5145
5146
+ #if defined(_DEBUG)
5144
5147
// Set the working directory to the directory that contains
5145
- // the document (.mv ) file. We assume that model data files
5148
+ // the document (.mvmf6 ) file. We assume that model data files
5146
5149
// are also in this directory.
5147
5150
strcpy (buffer, fileName);
5148
5151
char *p = strrchr (buffer, ' \\ ' );
@@ -5151,7 +5154,11 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, std::strin
5151
5154
p++;
5152
5155
}
5153
5156
*p = ' \0 ' ;
5154
- _chdir (buffer);
5157
+ // /_chdir(buffer);
5158
+ char curdir[1024 ];
5159
+ ::GetCurrentDirectory (1023 , curdir);
5160
+ ASSERT (strcmp (curdir, buffer) == 0 );
5161
+ #endif
5155
5162
5156
5163
// Create a hash table and read the data file into the hash table
5157
5164
mvHashTable *hashTable = new mvHashTable;
@@ -5198,7 +5205,7 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, std::strin
5198
5205
}
5199
5206
5200
5207
// Get absolute paths for all file codes
5201
- std::string dirname = GetDirName (fileName);
5208
+ std::string dirname = mvSaveCurrentDirectory:: GetDirName (fileName);
5202
5209
char szDest[MAX_PATH];
5203
5210
char fullpath[MAX_PATH];
5204
5211
char * dataFileList = new char [ncode * 1024 ];
@@ -5237,6 +5244,13 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, std::strin
5237
5244
strcat (dataFileList, " \n " );
5238
5245
}
5239
5246
5247
+ std::shared_ptr<mvSaveCurrentDirectory> spCurDir;
5248
+ if (ncode == 1 )
5249
+ {
5250
+ // save current directory and cd to dataFileList
5251
+ spCurDir.reset (new mvSaveCurrentDirectory (dataFileList));
5252
+ }
5253
+
5240
5254
// Load the data and set up the visualization pipeline
5241
5255
5242
5256
char *err = LoadData (modelName, dataFileList);
@@ -6014,7 +6028,7 @@ void mvManager::Deserialize(const char *fileName, mvGUISettings *gui, std::strin
6014
6028
char *errMsg = 0 ;
6015
6029
if (hashTable->GetHashTableValue (" Overlay file" , filename))
6016
6030
{
6017
- SetOverlayFileName (filename);
6031
+ SetOverlayFileName (mvSaveCurrentDirectory::GetFullPath ( filename, dirname. c_str ()). c_str () );
6018
6032
if (!UpdateOverlay (errMsg))
6019
6033
{
6020
6034
strcat (m_WarningMessage, " Unable to load overlay file. Overlay will not be displayed." );
@@ -6087,7 +6101,7 @@ void mvManager::ClearOverlayData()
6087
6101
m_Overlay->ClearData ();
6088
6102
}
6089
6103
6090
- void mvManager::SetOverlayFileName (char *filename)
6104
+ void mvManager::SetOverlayFileName (const char *filename)
6091
6105
{
6092
6106
m_Overlay->SetFileName (filename);
6093
6107
}
@@ -6351,33 +6365,3 @@ int mvManager::GetGridDisplayMode()
6351
6365
{
6352
6366
return m_GridDisplayMode;
6353
6367
}
6354
-
6355
- std::string mvManager::GetRelativePath (const char *pszFrom, const char *pszTo)
6356
- {
6357
- TCHAR szOut[MAX_PATH] = " " ;
6358
- if (strlen (pszTo) && PathIsSameRoot (pszFrom, pszTo))
6359
- {
6360
- std::string cpTo (pszTo);
6361
- std::replace (cpTo.begin (), cpTo.end (), ' /' , ' \\ ' );
6362
- VERIFY (PathCanonicalize (szOut, cpTo.c_str ()));
6363
- cpTo = szOut;
6364
- VERIFY (PathRelativePathTo (szOut, pszFrom, FILE_ATTRIBUTE_NORMAL, cpTo.c_str (), FILE_ATTRIBUTE_NORMAL));
6365
- return std::string (szOut);
6366
- }
6367
- return std::string (pszTo);
6368
- }
6369
-
6370
- std::string mvManager::GetDirName (const char *fullPath)
6371
- {
6372
- char szPath[MAX_PATH];
6373
- char szOut[MAX_PATH];
6374
- char szDrive[_MAX_DRIVE];
6375
- char szDir[_MAX_DIR];
6376
- char szDest[MAX_PATH];
6377
-
6378
- ASSERT (!PathIsRelative (fullPath));
6379
- VERIFY (_tsplitpath_s (fullPath, szDrive, _MAX_DRIVE, szDir, _MAX_DIR, NULL , 0 , NULL , 0 ) == 0 );
6380
- VERIFY (_tmakepath_s (szPath, _MAX_DIR, szDrive, szDir, NULL , NULL ) == 0 );
6381
-
6382
- return std::string (szPath);
6383
- }
0 commit comments