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