33 #include "vtkObjectFactory.h"
34 #include "vtkXMLDataElement.h"
37 #include <vtksys/SystemTools.hxx>
55 this->SetCode(
nullptr);
62 vtkSetObjectBodyMacro(
RootElement, vtkXMLDataElement, root);
63 this->SetCode(
nullptr);
78 if (vtksys::SystemTools::FileExists(filename))
80 return vtksys::SystemTools::DuplicateString(filename);
84 std::vector<std::string> paths;
85 std::string userpaths;
86 vtksys::SystemTools::GetEnv(
"USER_MATERIALS_DIRS", userpaths);
87 if (userpaths.size() > 0)
89 vtksys::SystemTools::Split(userpaths.c_str(), paths,
';');
92 #ifdef VTK_MATERIALS_DIRS
94 vtksys::SystemTools::Split(VTK_MATERIALS_DIRS, paths,
';');
96 for (
unsigned int i = 0; i < paths.size(); i++)
98 std::string path = paths[i];
103 vtksys::SystemTools::ConvertToUnixSlashes(path);
104 if (path[path.size() - 1] !=
'/')
109 if (vtksys::SystemTools::FileExists(path.c_str()))
111 return vtksys::SystemTools::DuplicateString(path.c_str());
122 const char *scope = this->
RootElement->GetAttribute(
"scope");
125 vtkErrorMacro(
"Shader description missing \"scope\" attribute.");
127 else if (strcmp(scope,
"Vertex") == 0)
131 else if (strcmp(scope,
"Fragment") == 0)
135 else if (strcmp(scope,
"Geometry") == 0)
150 const char *loc = this->
RootElement->GetAttribute(
"style");
157 if (strcmp(loc,
"1") == 0)
163 if (strcmp(loc,
"2") == 0)
169 vtkErrorMacro(<<
"style number not supported. Expect 1 or 2. We force it to be 1.");
175 assert(
"post valid_result" && (result == 1 || result == 2));
200 std::vector<std::string> args;
201 vtksys::SystemTools::Split(this->
RootElement->GetAttribute(
"args"), args,
' ');
204 int size =
static_cast<int>(args.size());
209 this->
Args =
new char *[size + 1];
210 for (i = 0; i < size; i++)
212 this->
Args[i] = vtksys::SystemTools::DuplicateString(args[i].c_str());
214 this->
Args[size] =
nullptr;
215 return const_cast<const char **
>(this->
Args);
229 char **a = this->
Args;
236 this->
Args =
nullptr;
243 this->Superclass::PrintSelf(os, indent);
244 os << indent <<
"Name: " << (this->
GetName() ? this->
GetName() :
"(none)") << endl;
245 os << indent <<
"Scope: ";
266 os << indent <<
"Entry: " << (this->
GetEntry() ? this->
GetEntry() :
"(none)") << endl;
267 os << indent <<
"Args: ";
268 const char **args = this->
GetArgs();
271 os <<
"(none)" << endl;
277 os << indent << *args <<
" ";
283 os << indent <<
"RootElement: ";
287 this->
RootElement->PrintSelf(os, indent.GetNextIndent());
291 os <<
"(none)" << endl;
void SetSourceLibraryElement(vtkXMLDataElement *)
void SetRootElement(vtkXMLDataElement *)
vtkXMLDataElement * RootElement
void PrintSelf(ostream &os, vtkIndent indent) override
vtkStandardNewMacro(vtkXMLShader)
static const std::string filename
static char * LocateFile(const char *filename)
vtkCxxSetObjectMacro(vtkXMLShader, SourceLibraryElement, vtkXMLDataElement)