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