FreeMat

- Main Page
- Related Pages

vtkObjectFactory

Section: Visualization Toolkit Common Classes

# Usage

vtkObjectFactory is used to create vtk objects. The base class vtkObjectFactory contains a static method CreateInstance which is used to create vtk objects from the list of registered vtkObjectFactory sub-classes. The first time CreateInstance is called, all dll's or shared libraries in the environment variable VTK_AUTOLOAD_PATH are loaded into the current process. The C functions vtkLoad, vtkGetFactoryCompilerUsed, and vtkGetFactoryVersion are called on each dll. To implement these functions in a shared library or dll, use the macro: VTK_FACTORY_INTERFACE_IMPLEMENT. VTK_AUTOLOAD_PATH is an environment variable containing a colon separated (semi-colon on win32) list of paths.

The vtkObjectFactory can be use to override the creation of any object in VTK with a sub-class of that object. The factories can be registered either at run time with the VTK_AUTOLOAD_PATH, or at compile time with the vtkObjectFactory::RegisterFactory method.

To create an instance of class vtkObjectFactory, simply invoke its constructor as follows

      obj = vtkObjectFactory

# Methods

The class vtkObjectFactory has several methods that can be used. They are listed below. Note that the documentation is translated automatically from the VTK sources, and may not be completely intelligible. When in doubt, consult the VTK website. In the methods listed below, `obj` is an instance of the vtkObjectFactory class.

- `string = obj.GetClassName ()`
- `int = obj.IsA (string name)`
- `vtkObjectFactory = obj.NewInstance ()`
- `vtkObjectFactory = obj.SafeDownCast (vtkObject o)`
- `string = obj.GetVTKSourceVersion ()` - All sub-classes of vtkObjectFactory should must return the version of VTK they were built with. This should be implemented with the macro VTK_SOURCE_VERSION and NOT a call to vtkVersion::GetVTKSourceVersion. As the version needs to be compiled into the file as a string constant. This is critical to determine possible incompatible dynamic factory loads.
- `string = obj.GetDescription ()` - Return a descriptive string describing the factory.
- `int = obj.GetNumberOfOverrides ()` - Return number of overrides this factory can create.
- `string = obj.GetClassOverrideName (int index)` - Return the name of a class override at the given index.
- `string = obj.GetClassOverrideWithName (int index)` - Return the name of the class that will override the class at the given index
- `int = obj.GetEnableFlag (int index)` - Return the enable flag for the class at the given index.
- `string = obj.GetOverrideDescription (int index)` - Return the description for a the class override at the given index.
- `obj.SetEnableFlag (int flag, string className, string subclassName)` - Set and Get the Enable flag for the specific override of className. if subclassName is null, then it is ignored.
- `int = obj.GetEnableFlag (string className, string subclassName)` - Set and Get the Enable flag for the specific override of className. if subclassName is null, then it is ignored.
- `int = obj.HasOverride (string className)` - Return 1 if this factory overrides the given class name, 0 otherwise.
- `int = obj.HasOverride (string className, string subclassName)` - Return 1 if this factory overrides the given class name, 0 otherwise.
- `obj.Disable (string className)` - Set all enable flags for the given class to 0. This will mean that the factory will stop producing class with the given name.
- `string = obj.GetLibraryPath ()` - This returns the path to a dynamically loaded factory.