summaryrefslogtreecommitdiff
path: root/inc/VrmlData_Group.hxx
blob: a3415d81108b6e2f5ebe9a529d2f751f677d1f10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
// File:      VrmlData_Group.hxx
// Created:   29.05.06 08:56:28
// Author:    Alexander GRIGORIEV
// Copyright: Open Cascade 2006


#ifndef VrmlData_Group_HeaderFile
#define VrmlData_Group_HeaderFile

#include <VrmlData_ListOfNode.hxx>
#include <Bnd_B3f.hxx>
#include <gp_Trsf.hxx>

class TopoDS_Shape;
class VrmlData_DataMapOfShapeAppearance;

/**
 * Implementation of node "Group"
 */

class VrmlData_Group : public VrmlData_Node
{
 public:
  typedef VrmlData_ListOfNode::Iterator Iterator;

  // ---------- PUBLIC METHODS ----------

  /**
   * Empty constructor.
   * @param isTransform
   *   True if the group of type Transform is defined
   * @param theAlloc
   *   Allocator used for the list of children
   */
  VrmlData_Group (const Standard_Boolean  isTransform = Standard_False) 
    : myIsTransform     (isTransform)
  {}

  /**
   * Constructor.
   * @param theName
   *   Name of the Group node
   * @param isTransform
   *   True if the group of type Transform is defined
   * @param theAlloc
   *   Allocator used for the list of children
   */
  Standard_EXPORT VrmlData_Group
                        (const VrmlData_Scene&   theScene,
                         const char              * theName,
                         const Standard_Boolean  isTransform = Standard_False);

  /**
   *  Add one node to the Group.
   */
  inline Handle(VrmlData_Node)&
                AddNode         (const Handle(VrmlData_Node)& theNode)
  { return myNodes.Append(theNode); }

  /**
   * Remove one node from the Group.
   * @return
   *   True if the node was located and removed, False if none removed.
   */
  Standard_EXPORT Standard_Boolean
                RemoveNode      (const Handle(VrmlData_Node)& theNode);

  /**
   * Create iterator on nodes belonging to the Group.
   */
  inline Iterator
                NodeIterator    () const { return Iterator (myNodes); }    

  /**
   * Query the bounding box.
   */
  inline const Bnd_B3f&
                Box             () const { return myBox; }

  /**
   * Set the bounding box.
   */
  inline void   SetBox          (const Bnd_B3f& theBox) { myBox = theBox; }

  /**
   * Set the transformation. Returns True if the group is Transform type,
   * otherwise do nothing and return False.
   */
  Standard_EXPORT Standard_Boolean
                SetTransform    (const gp_Trsf& theTrsf);

  /**
   * Query the transform value.
   * For group without transformation this always returns Identity
   */ 
  inline const gp_Trsf&
                GetTransform     () const { return myTrsf; }

  /**
   * Query if the node is Transform type.
   */
  inline Standard_Boolean
                IsTransform     () const { return myIsTransform; }

  /**
   * Create a copy of this node.
   * If the parameter is null, a new copied node is created. Otherwise new node
   * is not created, but rather the given one is modified.
   */
  Standard_EXPORT virtual Handle(VrmlData_Node)
                Clone           (const Handle(VrmlData_Node)& theOther) const;

  /**
   * Fill the Node internal data from the given input stream.
   */
  Standard_EXPORT virtual VrmlData_ErrorStatus
                Read            (VrmlData_InBuffer& theBuffer);

  /**
   * Write the Node to output stream.
   */
  Standard_EXPORT virtual VrmlData_ErrorStatus
                Write           (const char * thePrefix) const;

  /**
   * Find a node by its name, inside this Group
   * @param theName
   *   Name of the node to search for.
   * @param theLocation
   *   Location of the found node with respect to this Group.
   */
  Standard_EXPORT Handle(VrmlData_Node)
                                FindNode (const char * theName,
                                          gp_Trsf&     theLocation) const;

  /**
   * Get the shape representing the group geometry.
   */
  Standard_EXPORT void
                Shape           (TopoDS_Shape&                     theShape,
                                 VrmlData_DataMapOfShapeAppearance * pMapApp);

 protected:
  // ---------- PROTECTED METHODS ----------

  /**
   * Try to open a file by the given filename, using the search directories
   * list myVrmlDir of the Scene.
   */
  Standard_EXPORT VrmlData_ErrorStatus
                openFile        (Standard_IStream&              theStream,
                                 const TCollection_AsciiString& theFilename);

 private:
  // ---------- PRIVATE FIELDS ----------

  Standard_Boolean      myIsTransform;
  VrmlData_ListOfNode   myNodes;
  Bnd_B3f               myBox;
  gp_Trsf               myTrsf;

 public:
// Declaration of CASCADE RTTI
DEFINE_STANDARD_RTTI (VrmlData_Group)
};

// Definition of HANDLE object using Standard_DefineHandle.hxx
DEFINE_STANDARD_HANDLE (VrmlData_Group, VrmlData_Node)


#endif