0024157: Parallelization of assembly part of BO
[occt.git] / src / VrmlData / VrmlData_Group.hxx
CommitLineData
b311480e 1// Created on: 2006-05-29
2// Created by: Alexander GRIGORIEV
3// Copyright (c) 2006-2012 OPEN CASCADE SAS
4//
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.
9//
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.
12//
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.
19
7fd59977 20
21
22#ifndef VrmlData_Group_HeaderFile
23#define VrmlData_Group_HeaderFile
24
25#include <VrmlData_ListOfNode.hxx>
26#include <Bnd_B3f.hxx>
27#include <gp_Trsf.hxx>
28
29class TopoDS_Shape;
30class VrmlData_DataMapOfShapeAppearance;
31
32/**
33 * Implementation of node "Group"
34 */
35
36class VrmlData_Group : public VrmlData_Node
37{
38 public:
39 typedef VrmlData_ListOfNode::Iterator Iterator;
40
41 // ---------- PUBLIC METHODS ----------
42
43 /**
44 * Empty constructor.
45 * @param isTransform
46 * True if the group of type Transform is defined
47 * @param theAlloc
48 * Allocator used for the list of children
49 */
50 VrmlData_Group (const Standard_Boolean isTransform = Standard_False)
51 : myIsTransform (isTransform)
52 {}
53
54 /**
55 * Constructor.
56 * @param theName
57 * Name of the Group node
58 * @param isTransform
59 * True if the group of type Transform is defined
60 * @param theAlloc
61 * Allocator used for the list of children
62 */
63 Standard_EXPORT VrmlData_Group
64 (const VrmlData_Scene& theScene,
65 const char * theName,
66 const Standard_Boolean isTransform = Standard_False);
67
68 /**
69 * Add one node to the Group.
70 */
71 inline Handle(VrmlData_Node)&
72 AddNode (const Handle(VrmlData_Node)& theNode)
73 { return myNodes.Append(theNode); }
74
75 /**
76 * Remove one node from the Group.
77 * @return
78 * True if the node was located and removed, False if none removed.
79 */
80 Standard_EXPORT Standard_Boolean
81 RemoveNode (const Handle(VrmlData_Node)& theNode);
82
83 /**
84 * Create iterator on nodes belonging to the Group.
85 */
86 inline Iterator
87 NodeIterator () const { return Iterator (myNodes); }
88
89 /**
90 * Query the bounding box.
91 */
92 inline const Bnd_B3f&
93 Box () const { return myBox; }
94
95 /**
96 * Set the bounding box.
97 */
98 inline void SetBox (const Bnd_B3f& theBox) { myBox = theBox; }
99
100 /**
101 * Set the transformation. Returns True if the group is Transform type,
102 * otherwise do nothing and return False.
103 */
104 Standard_EXPORT Standard_Boolean
105 SetTransform (const gp_Trsf& theTrsf);
106
107 /**
108 * Query the transform value.
109 * For group without transformation this always returns Identity
110 */
111 inline const gp_Trsf&
112 GetTransform () const { return myTrsf; }
113
114 /**
115 * Query if the node is Transform type.
116 */
117 inline Standard_Boolean
118 IsTransform () const { return myIsTransform; }
119
120 /**
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.
124 */
125 Standard_EXPORT virtual Handle(VrmlData_Node)
126 Clone (const Handle(VrmlData_Node)& theOther) const;
127
128 /**
129 * Fill the Node internal data from the given input stream.
130 */
131 Standard_EXPORT virtual VrmlData_ErrorStatus
132 Read (VrmlData_InBuffer& theBuffer);
133
134 /**
135 * Write the Node to output stream.
136 */
137 Standard_EXPORT virtual VrmlData_ErrorStatus
138 Write (const char * thePrefix) const;
139
140 /**
141 * Find a node by its name, inside this Group
142 * @param theName
143 * Name of the node to search for.
144 * @param theLocation
145 * Location of the found node with respect to this Group.
146 */
147 Standard_EXPORT Handle(VrmlData_Node)
148 FindNode (const char * theName,
149 gp_Trsf& theLocation) const;
150
151 /**
152 * Get the shape representing the group geometry.
153 */
154 Standard_EXPORT void
155 Shape (TopoDS_Shape& theShape,
156 VrmlData_DataMapOfShapeAppearance * pMapApp);
157
158 protected:
159 // ---------- PROTECTED METHODS ----------
160
161 /**
162 * Try to open a file by the given filename, using the search directories
163 * list myVrmlDir of the Scene.
164 */
165 Standard_EXPORT VrmlData_ErrorStatus
166 openFile (Standard_IStream& theStream,
167 const TCollection_AsciiString& theFilename);
168
169 private:
170 // ---------- PRIVATE FIELDS ----------
171
172 Standard_Boolean myIsTransform;
173 VrmlData_ListOfNode myNodes;
174 Bnd_B3f myBox;
175 gp_Trsf myTrsf;
176
177 public:
178// Declaration of CASCADE RTTI
179DEFINE_STANDARD_RTTI (VrmlData_Group)
180};
181
182// Definition of HANDLE object using Standard_DefineHandle.hxx
183DEFINE_STANDARD_HANDLE (VrmlData_Group, VrmlData_Node)
184
185
186#endif