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