1 // Copyright (C) 2010-2011 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "vtkMedLink.h"
22 #include "vtkObjectFactory.h"
24 #include "vtkMedUtilities.h"
29 // vtkCxxRevisionMacro(vtkMedLink, "$Revision$")
30 vtkStandardNewMacro(vtkMedLink)
32 vtkMedLink::vtkMedLink()
34 this->MedIterator = -1;
35 this->MeshName = NULL;
39 vtkMedLink::~vtkMedLink()
41 this->SetMeshName(NULL);
45 const char* vtkMedLink::GetFullLink(const char* originalFileName)
48 static const char sep = '\\';
50 static const char sep = '/';
53 if(this->Link == NULL)
58 // First test if the Link is a full path, then return it.
59 if(this->Link != NULL && this->Link[0] == sep)
64 string name = string(originalFileName);
65 size_t pos = name.find_last_of(sep);
66 if(pos == string::npos)
71 string clean_link = this->Link;
72 string to_remove = string(".") + sep;
73 int to_remove_size = to_remove.size();
74 while(clean_link.substr(0, to_remove_size) == to_remove)
75 clean_link = clean_link.substr(to_remove_size, string::npos);
77 string path = name.substr(0, pos+1);
78 this->FullLinkPath = path + clean_link;
79 return this->FullLinkPath.c_str();
82 void vtkMedLink::SetMountedIterator(med_class what, med_int mit)
84 this->MountedIterator[what] = mit;
87 med_int vtkMedLink::GetMountedIterator(med_class what)
89 if(this->MountedIterator.find(what) == this->MountedIterator.end())
92 return this->MountedIterator[what];
95 void vtkMedLink::PrintSelf(ostream& os, vtkIndent indent)
97 this->Superclass::PrintSelf(os, indent);
98 PRINT_IVAR(os, indent, MedIterator);