1 // Created on: 2006-05-29
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2006-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
22 #ifndef VrmlData_Group_HeaderFile
23 #define VrmlData_Group_HeaderFile
25 #include <VrmlData_ListOfNode.hxx>
26 #include <Bnd_B3f.hxx>
27 #include <gp_Trsf.hxx>
30 class VrmlData_DataMapOfShapeAppearance;
33 * Implementation of node "Group"
36 class VrmlData_Group : public VrmlData_Node
39 typedef VrmlData_ListOfNode::Iterator Iterator;
41 // ---------- PUBLIC METHODS ----------
46 * True if the group of type Transform is defined
48 * Allocator used for the list of children
50 VrmlData_Group (const Standard_Boolean isTransform = Standard_False)
51 : myIsTransform (isTransform)
57 * Name of the Group node
59 * True if the group of type Transform is defined
61 * Allocator used for the list of children
63 Standard_EXPORT VrmlData_Group
64 (const VrmlData_Scene& theScene,
66 const Standard_Boolean isTransform = Standard_False);
69 * Add one node to the Group.
71 inline Handle(VrmlData_Node)&
72 AddNode (const Handle(VrmlData_Node)& theNode)
73 { return myNodes.Append(theNode); }
76 * Remove one node from the Group.
78 * True if the node was located and removed, False if none removed.
80 Standard_EXPORT Standard_Boolean
81 RemoveNode (const Handle(VrmlData_Node)& theNode);
84 * Create iterator on nodes belonging to the Group.
87 NodeIterator () const { return Iterator (myNodes); }
90 * Query the bounding box.
93 Box () const { return myBox; }
96 * Set the bounding box.
98 inline void SetBox (const Bnd_B3f& theBox) { myBox = theBox; }
101 * Set the transformation. Returns True if the group is Transform type,
102 * otherwise do nothing and return False.
104 Standard_EXPORT Standard_Boolean
105 SetTransform (const gp_Trsf& theTrsf);
108 * Query the transform value.
109 * For group without transformation this always returns Identity
111 inline const gp_Trsf&
112 GetTransform () const { return myTrsf; }
115 * Query if the node is Transform type.
117 inline Standard_Boolean
118 IsTransform () const { return myIsTransform; }
121 * Create a copy of this node.
122 * If the parameter is null, a new copied node is created. Otherwise new node
123 * is not created, but rather the given one is modified.
125 Standard_EXPORT virtual Handle(VrmlData_Node)
126 Clone (const Handle(VrmlData_Node)& theOther) const;
129 * Fill the Node internal data from the given input stream.
131 Standard_EXPORT virtual VrmlData_ErrorStatus
132 Read (VrmlData_InBuffer& theBuffer);
135 * Write the Node to output stream.
137 Standard_EXPORT virtual VrmlData_ErrorStatus
138 Write (const char * thePrefix) const;
141 * Find a node by its name, inside this Group
143 * Name of the node to search for.
145 * Location of the found node with respect to this Group.
147 Standard_EXPORT Handle(VrmlData_Node)
148 FindNode (const char * theName,
149 gp_Trsf& theLocation) const;
152 * Get the shape representing the group geometry.
155 Shape (TopoDS_Shape& theShape,
156 VrmlData_DataMapOfShapeAppearance * pMapApp);
159 // ---------- PROTECTED METHODS ----------
162 * Try to open a file by the given filename, using the search directories
163 * list myVrmlDir of the Scene.
165 Standard_EXPORT VrmlData_ErrorStatus
166 openFile (Standard_IStream& theStream,
167 const TCollection_AsciiString& theFilename);
170 // ---------- PRIVATE FIELDS ----------
172 Standard_Boolean myIsTransform;
173 VrmlData_ListOfNode myNodes;
178 // Declaration of CASCADE RTTI
179 DEFINE_STANDARD_RTTI (VrmlData_Group)
182 // Definition of HANDLE object using Standard_DefineHandle.hxx
183 DEFINE_STANDARD_HANDLE (VrmlData_Group, VrmlData_Node)