1 // File: VrmlData_Group.hxx
2 // Created: 29.05.06 08:56:28
3 // Author: Alexander GRIGORIEV
4 // Copyright: Open Cascade 2006
7 #ifndef VrmlData_Group_HeaderFile
8 #define VrmlData_Group_HeaderFile
10 #include <VrmlData_ListOfNode.hxx>
11 #include <Bnd_B3f.hxx>
12 #include <gp_Trsf.hxx>
15 class VrmlData_DataMapOfShapeAppearance;
18 * Implementation of node "Group"
21 class VrmlData_Group : public VrmlData_Node
24 typedef VrmlData_ListOfNode::Iterator Iterator;
26 // ---------- PUBLIC METHODS ----------
31 * True if the group of type Transform is defined
33 * Allocator used for the list of children
35 VrmlData_Group (const Standard_Boolean isTransform = Standard_False)
36 : myIsTransform (isTransform)
42 * Name of the Group node
44 * True if the group of type Transform is defined
46 * Allocator used for the list of children
48 Standard_EXPORT VrmlData_Group
49 (const VrmlData_Scene& theScene,
51 const Standard_Boolean isTransform = Standard_False);
54 * Add one node to the Group.
56 inline Handle(VrmlData_Node)&
57 AddNode (const Handle(VrmlData_Node)& theNode)
58 { return myNodes.Append(theNode); }
61 * Remove one node from the Group.
63 * True if the node was located and removed, False if none removed.
65 Standard_EXPORT Standard_Boolean
66 RemoveNode (const Handle(VrmlData_Node)& theNode);
69 * Create iterator on nodes belonging to the Group.
72 NodeIterator () const { return Iterator (myNodes); }
75 * Query the bounding box.
78 Box () const { return myBox; }
81 * Set the bounding box.
83 inline void SetBox (const Bnd_B3f& theBox) { myBox = theBox; }
86 * Set the transformation. Returns True if the group is Transform type,
87 * otherwise do nothing and return False.
89 Standard_EXPORT Standard_Boolean
90 SetTransform (const gp_Trsf& theTrsf);
93 * Query the transform value.
94 * For group without transformation this always returns Identity
97 GetTransform () const { return myTrsf; }
100 * Query if the node is Transform type.
102 inline Standard_Boolean
103 IsTransform () const { return myIsTransform; }
106 * Create a copy of this node.
107 * If the parameter is null, a new copied node is created. Otherwise new node
108 * is not created, but rather the given one is modified.
110 Standard_EXPORT virtual Handle(VrmlData_Node)
111 Clone (const Handle(VrmlData_Node)& theOther) const;
114 * Fill the Node internal data from the given input stream.
116 Standard_EXPORT virtual VrmlData_ErrorStatus
117 Read (VrmlData_InBuffer& theBuffer);
120 * Write the Node to output stream.
122 Standard_EXPORT virtual VrmlData_ErrorStatus
123 Write (const char * thePrefix) const;
126 * Find a node by its name, inside this Group
128 * Name of the node to search for.
130 * Location of the found node with respect to this Group.
132 Standard_EXPORT Handle(VrmlData_Node)
133 FindNode (const char * theName,
134 gp_Trsf& theLocation) const;
137 * Get the shape representing the group geometry.
140 Shape (TopoDS_Shape& theShape,
141 VrmlData_DataMapOfShapeAppearance * pMapApp);
144 // ---------- PROTECTED METHODS ----------
147 * Try to open a file by the given filename, using the search directories
148 * list myVrmlDir of the Scene.
150 Standard_EXPORT VrmlData_ErrorStatus
151 openFile (Standard_IStream& theStream,
152 const TCollection_AsciiString& theFilename);
155 // ---------- PRIVATE FIELDS ----------
157 Standard_Boolean myIsTransform;
158 VrmlData_ListOfNode myNodes;
163 // Declaration of CASCADE RTTI
164 DEFINE_STANDARD_RTTI (VrmlData_Group)
167 // Definition of HANDLE object using Standard_DefineHandle.hxx
168 DEFINE_STANDARD_HANDLE (VrmlData_Group, VrmlData_Node)