java.lang.Object
de.grogra.pf.io.FilterBase
de.grogra.imp3d.io.SceneGraphExport
- All Implemented Interfaces:
SceneTree.Visitor
,Filter
,FilterSource
,RegistryContext
,Map
- Direct Known Subclasses:
DXFExport
,GLTFExport
,MTGExport
,OBJExport
,PLYExport
,POVExport
,RootlessXMLExporter
,STLExport
,TEXExport
,WebGLExport
,X3DExport
,XEGExportScene
This base class is used to export the 3D scene graph of a
View3D
to another representation (usually, this
is a file representation for which this class provides a set of
useful methods). The export is done via the creation of an
intermediate SceneTree
in the method
createSceneTree(View3D)
.- Author:
- Ole Kniemeyer
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
This interface is used to export a leaf of theSceneTree
to the destination.static interface
This interface is used to export an object (as an attribute of a node of the scene tree) to the destination.Nested classes/interfaces inherited from interface de.grogra.pf.io.FilterSource
FilterSource.MetaDataKey<V>
-
Field Summary
Modifier and TypeFieldDescriptionprotected ObjectList
The list of files which have been created by this export.Fields inherited from class de.grogra.pf.io.FilterBase
item, source
Fields inherited from interface de.grogra.pf.io.FilterSource
AUTO_PROGRESS, DESTINATION_FILE, DESTINATION_URL
Fields inherited from interface de.grogra.util.Map
DEFAULT_VALUE, EMPTY_MAP
-
Constructor Summary
ConstructorDescriptionSceneGraphExport
(FilterItem item, FilterSource source) Delegates toFilterBase(FilterItem, FilterSource)
. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
beginGroup
(SceneTree.InnerNode group) This method is invoked at the beginning of every inner nodegroup
which has more than one child.protected abstract SceneTree
createSceneTree
(View3D scene) The implementation of this method creates the scene tree which is to be exported by this export.protected abstract void
endGroup
(SceneTree.InnerNode group) This method is invoked at the end of every inner nodegroup
which has more than one child.protected void
export
(SceneTree.Leaf node, SceneTree.InnerNode transform) This method is invoked for every leaf of the scene tree in order to export this leaf.boolean
This method is invoked for some attribute value in order to export the value.This method returns the base directory withingetFileSystem()
to use for the export.getExportFor
(Object object, boolean asNode) This method is used to obtain an instance ofNodeExport
capable of exporting the object of aSceneTree.Leaf
.getExportForObject
(Object object) This method is used to obtain an instance ofObjectExport
capable of exporting theobject
(which is some attribute value).This method creates a file ingetDirectory()
.getFiles()
Returns the list of files which have been created during export.This method returns the file system to use for the export.Returns the graph state which is used for export.getOutputStream
(Object file) getPath
(FileObjectItem file) Returns the path of a file of this export's file system (getFileSystem()
) as a string.getView()
Returns the view which defines the scene to export.protected Object
Determines the directory to use.protected FileSystem
Determines the file system to use.void
visit
(SceneTree.Leaf leaf) Informs the visitor that a leaf is visited.void
Informs the visitor that an inner node has been entered.void
Informs the visitor that an inner node has been left.protected void
write()
Exports the scene of the view.Methods inherited from class de.grogra.pf.io.FilterBase
get, getFilter, getFlavor, getImpl, getMetaData, getRegistry, getSource, getSystemId, initProgressMonitor, setFlavor, setMetaData, setMetaData, setProgress, setSystemId, toString, toURL
-
Field Details
-
files
The list of files which have been created by this export.
-
-
Constructor Details
-
SceneGraphExport
Delegates toFilterBase(FilterItem, FilterSource)
. The source is expected to be anObjectSource
representing an instance ofView3D
.- Parameters:
item
- the definingFilterItem
source
- the data source
-
-
Method Details
-
getFileSystem
This method returns the file system to use for the export. On first invocation, the file system is obtained frominitFileSystem()
.- Returns:
- file system to use for export
- Throws:
IOException
-
getDirectory
This method returns the base directory withingetFileSystem()
to use for the export. On first invocation, the directory is obtained frominitDirectory()
.- Returns:
- directory to use for export
- Throws:
IOException
-
initFileSystem
Determines the file system to use. This method is invoked once bygetFileSystem()
.- Returns:
- file system to use
- Throws:
IOException
-
initDirectory
Determines the directory to use. This method is invoked once bygetDirectory()
.- Returns:
- directory to use
- Throws:
IOException
-
getFile
This method creates a file ingetDirectory()
. The file name is based obname
: E.g., ifname
istest.png
, the actual name could be something liketest123.png
. It is ensured that no file will be returned twice during a single export.- Parameters:
name
- name for file- Returns:
- file
- Throws:
IOException
-
getPath
Returns the path of a file of this export's file system (getFileSystem()
) as a string.- Parameters:
file
- file of this export's file system- Returns:
- path of
file
- Throws:
IOException
-
getOutputStream
- Throws:
IOException
-
getPath
- Throws:
IOException
-
createSceneTree
The implementation of this method creates the scene tree which is to be exported by this export.- Parameters:
scene
- the view which defines the scene to export- Returns:
- scene tree for the view
-
getView
Returns the view which defines the scene to export. This requires that the source of this export is anObjectSource
representing an instance ofView3D
.- Returns:
- view
- Throws:
IOException
-
getGraphState
Returns the graph state which is used for export. This is the graph state of the view's workbench.- Returns:
- graph state for export
-
getFiles
Returns the list of files which have been created during export.- Returns:
- created files
-
visitEnter
Description copied from interface:SceneTree.Visitor
Informs the visitor that an inner node has been entered.- Specified by:
visitEnter
in interfaceSceneTree.Visitor
- Parameters:
node
- the node being entered
-
visitLeave
Description copied from interface:SceneTree.Visitor
Informs the visitor that an inner node has been left.- Specified by:
visitLeave
in interfaceSceneTree.Visitor
- Parameters:
node
- the node being left
-
visit
Description copied from interface:SceneTree.Visitor
Informs the visitor that a leaf is visited.- Specified by:
visit
in interfaceSceneTree.Visitor
- Parameters:
leaf
- the leaf being visited
-
write
Exports the scene of the view. This method at first creates the scene tree usingcreateSceneTree(View3D)
, then it lets this export instance visit the created scene tree. During visit, the methodsbeginGroup(de.grogra.imp3d.objects.SceneTree.InnerNode)
,endGroup(de.grogra.imp3d.objects.SceneTree.InnerNode)
andexport(SceneTree.Leaf, SceneTree.InnerNode)
are invoked; these have to be implemented to perform the actual export to the destination.- Throws:
IOException
-
beginGroup
This method is invoked at the beginning of every inner nodegroup
which has more than one child. Its children will be processed until the corresponding methodendGroup(de.grogra.imp3d.objects.SceneTree.InnerNode)
is invoked. The export should write the hierarchy and transformation information of thegroup
.- Parameters:
group
- the group- Throws:
IOException
-
endGroup
This method is invoked at the end of every inner nodegroup
which has more than one child. Its children have been processed completely.- Parameters:
group
- the group- Throws:
IOException
- See Also:
-
getExportFor
This method is used to obtain an instance ofNodeExport
capable of exporting the object of aSceneTree.Leaf
. If no such export is defined,null
is returned.This implementation looks for an export defined in the registry: As name, the name of the class of
object
is chosen, the export is searched as a child ofFilterBase.item
.- Parameters:
object
- object of the original scene graphasNode
- is object a node or an edge?- Returns:
- suitable export for the object or
null
-
getExportForObject
This method is used to obtain an instance ofObjectExport
capable of exporting theobject
(which is some attribute value). If no such export is defined,null
is returned.This implementation looks for an export defined in the registry: As name, the name of the class of
object
is chosen, the export is searched as a child ofFilterBase.item
.- Parameters:
object
- object to export- Returns:
- suitable export for the object or
null
-
export
This method is invoked for every leaf of the scene tree in order to export this leaf. Iftransform
is non-null
, this means thatnode
is the only child oftransform
and the transformation oftransform
has to be exported together with thenode
.This implementation obtains a
SceneGraphExport.NodeExport
viagetExportFor(Object, boolean)
and, if successful, uses this to export the leaf.- Parameters:
node
- a leaf of the scene treetransform
- transformation of node- Throws:
IOException
- See Also:
-
export
This method is invoked for some attribute value in order to export the value.This implementation obtains an
SceneGraphExport.ObjectExport
viagetExportForObject(Object)
and, if successful, uses this to export the value.- Parameters:
object
- object to export- Throws:
IOException
-