1 // Created on: 2006-05-29
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2006-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef VrmlData_Group_HeaderFile
17 #define VrmlData_Group_HeaderFile
19 #include <VrmlData_ListOfNode.hxx>
20 #include <VrmlData_DataMapOfShapeAppearance.hxx>
21 #include <Bnd_B3f.hxx>
22 #include <gp_Trsf.hxx>
27 * Implementation of node "Group"
30 class VrmlData_Group : public VrmlData_Node
33 typedef VrmlData_ListOfNode::Iterator Iterator;
35 // ---------- PUBLIC METHODS ----------
40 * True if the group of type Transform is defined
42 * Allocator used for the list of children
44 VrmlData_Group (const Standard_Boolean isTransform = Standard_False)
45 : myIsTransform (isTransform)
51 * Name of the Group node
53 * True if the group of type Transform is defined
55 * Allocator used for the list of children
57 Standard_EXPORT VrmlData_Group
58 (const VrmlData_Scene& theScene,
60 const Standard_Boolean isTransform = Standard_False);
63 * Add one node to the Group.
65 inline Handle(VrmlData_Node)&
66 AddNode (const Handle(VrmlData_Node)& theNode)
67 { return myNodes.Append(theNode); }
70 * Remove one node from the Group.
72 * True if the node was located and removed, False if none removed.
74 Standard_EXPORT Standard_Boolean
75 RemoveNode (const Handle(VrmlData_Node)& theNode);
78 * Create iterator on nodes belonging to the Group.
81 NodeIterator () const { return Iterator (myNodes); }
84 * Query the bounding box.
87 Box () const { return myBox; }
90 * Set the bounding box.
92 inline void SetBox (const Bnd_B3f& theBox) { myBox = theBox; }
95 * Set the transformation. Returns True if the group is Transform type,
96 * otherwise do nothing and return False.
98 Standard_EXPORT Standard_Boolean
99 SetTransform (const gp_Trsf& theTrsf);
102 * Query the transform value.
103 * For group without transformation this always returns Identity
105 inline const gp_Trsf&
106 GetTransform () const { return myTrsf; }
109 * Query if the node is Transform type.
111 inline Standard_Boolean
112 IsTransform () const { return myIsTransform; }
115 * Create a copy of this node.
116 * If the parameter is null, a new copied node is created. Otherwise new node
117 * is not created, but rather the given one is modified.
119 Standard_EXPORT virtual Handle(VrmlData_Node)
120 Clone (const Handle(VrmlData_Node)& theOther) const Standard_OVERRIDE;
123 * Fill the Node internal data from the given input stream.
125 Standard_EXPORT virtual VrmlData_ErrorStatus
126 Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
129 * Write the Node to output stream.
131 Standard_EXPORT virtual VrmlData_ErrorStatus
132 Write (const char * thePrefix) const Standard_OVERRIDE;
135 * Find a node by its name, inside this Group
137 * Name of the node to search for.
139 * Location of the found node with respect to this Group.
141 Standard_EXPORT Handle(VrmlData_Node)
142 FindNode (const char * theName,
143 gp_Trsf& theLocation) const;
146 * Get the shape representing the group geometry.
149 Shape (TopoDS_Shape& theShape,
150 VrmlData_DataMapOfShapeAppearance * pMapApp);
153 // ---------- PROTECTED METHODS ----------
156 * Try to open a file by the given filename, using the search directories
157 * list myVrmlDir of the Scene.
159 Standard_EXPORT VrmlData_ErrorStatus
160 openFile (Standard_IStream& theStream,
161 const TCollection_AsciiString& theFilename);
164 // ---------- PRIVATE FIELDS ----------
166 Standard_Boolean myIsTransform;
167 VrmlData_ListOfNode myNodes;
172 // Declaration of CASCADE RTTI
173 DEFINE_STANDARD_RTTIEXT(VrmlData_Group,VrmlData_Node)
176 // Definition of HANDLE object using Standard_DefineHandle.hxx
177 DEFINE_STANDARD_HANDLE (VrmlData_Group, VrmlData_Node)