forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvtkXMLMaterialParser.h
122 lines (104 loc) · 4.57 KB
/
vtkXMLMaterialParser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*=========================================================================
Program: Visualization Toolkit
Module: vtkXMLMaterialParser.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*
* Copyright 2004 Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the
* U.S. Government. Redistribution and use in source and binary forms, with
* or without modification, are permitted provided that this Notice and any
* statement of authorship are reproduced on all copies.
*/
// .NAME vtkXMLMaterialParser - Parses VTK Material file
//
// .SECTION Description
// vtkXMLMaterialParser parses a VTK Material file and provides that file's
// description of a number of vertex and fragment shaders along with data
// values specified for data members of vtkProperty. This material is to be
// applied to an actor through it's vtkProperty and augments VTK's concept
// of a vtkProperty to include explicitly include vertex and fragment shaders
// and parameter settings for those shaders. This effectively makes reflectance
// models and other shaders a material property. If no shaders are specified
// VTK should default to standard rendering.
//
// .SECTION Design
// vtkXMLMaterialParser provides access to 3 distinct types of first-level
// vtkXMLDataElements that describe a VTK material. These elements are as
// follows:
//
// vtkProperty - describe values for vtkProperty data members
//
// vtkVertexShader - a vertex shader and enough information to
// install it into the hardware rendering pipeline including values for
// specific shader parameters and structures.
//
// vtkFragmentShader - a fragment shader and enough information to
// install it into the hardware rendering pipeline including values for
// specific shader parameters and structures.
//
// The design of the material file closely follows that of vtk's xml
// descriptions of it's data sets. This allows use of the very handy
// vtkXMLDataElement which provides easy access to an xml element's
// attribute values. Inlined data is currently not handled.
//
// Ideally this class would be a Facade to a DOM parser, but VTK only
// provides access to expat, a SAX parser. Other vtk classes that parse
// xml files are tuned to read vtkDataSets and don't provide the functionality
// to handle generic xml data. As such they are of little use here.
//
// This class may be extended for better data handling or may become a
// Facade to a DOM parser should on become part of the VTK code base.
// .SECTION Thanks
// Shader support in VTK includes key contributions by Gary Templet at
// Sandia National Labs.
#ifndef __vtkXMLMaterialParser_h
#define __vtkXMLMaterialParser_h
#include "vtkXMLParser.h"
class vtkXMLMaterial;
class vtkXMLMaterialParserInternals;
class VTK_IO_EXPORT vtkXMLMaterialParser : public vtkXMLParser
{
public:
static vtkXMLMaterialParser *New();
vtkTypeMacro(vtkXMLMaterialParser,vtkXMLParser);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set/Get the vtkXMLMaterial representation of the parsed material.
vtkGetObjectMacro(Material, vtkXMLMaterial);
void SetMaterial(vtkXMLMaterial*);
// Description:
// Overridden to initialize the internal structures before
// the parsing begins.
virtual int Parse();
virtual int Parse(const char* inputString);
virtual int Parse(const char* inputString, unsigned int length);
// Description:
// Overridden to clean up internal structures before the chunk-parsing
// begins.
virtual int InitializeParser();
protected:
vtkXMLMaterialParser();
~vtkXMLMaterialParser();
// Description:
// Event for handling the start of an element
virtual void StartElement(const char* name, const char** atts);
// Description:
// Event for handling the end of an element
virtual void EndElement(const char*);
// Description:
// Handle character data, not yet implemented
virtual void CharacterDataHandler( const char* data, int length );
vtkXMLMaterial* Material;
vtkXMLMaterialParserInternals* Internals;
private:
vtkXMLMaterialParser(const vtkXMLMaterialParser&); // Not implemented
void operator=(const vtkXMLMaterialParser&); // Not implemented
};
#endif