Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-09 09:17:25

0001 // Created on: 2006-05-29
0002 // Created by: Alexander GRIGORIEV
0003 // Copyright (c) 2006-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef VrmlData_Group_HeaderFile
0017 #define VrmlData_Group_HeaderFile
0018 
0019 #include <VrmlData_ListOfNode.hxx>
0020 #include <VrmlData_DataMapOfShapeAppearance.hxx>
0021 #include <Bnd_B3f.hxx>
0022 #include <gp_Trsf.hxx>
0023 
0024 class TopoDS_Shape;
0025 
0026 /**
0027  * Implementation of node "Group"
0028  */
0029 
0030 class VrmlData_Group : public VrmlData_Node
0031 {
0032 public:
0033   typedef VrmlData_ListOfNode::Iterator Iterator;
0034 
0035   // ---------- PUBLIC METHODS ----------
0036 
0037   /**
0038    * Empty constructor.
0039    * @param isTransform
0040    *   True if the group of type Transform is defined
0041    * @param theAlloc
0042    *   Allocator used for the list of children
0043    */
0044   VrmlData_Group(const Standard_Boolean isTransform = Standard_False)
0045       : myIsTransform(isTransform)
0046   {
0047   }
0048 
0049   /**
0050    * Constructor.
0051    * @param theName
0052    *   Name of the Group node
0053    * @param isTransform
0054    *   True if the group of type Transform is defined
0055    * @param theAlloc
0056    *   Allocator used for the list of children
0057    */
0058   Standard_EXPORT VrmlData_Group(const VrmlData_Scene&  theScene,
0059                                  const char*            theName,
0060                                  const Standard_Boolean isTransform = Standard_False);
0061 
0062   /**
0063    *  Add one node to the Group.
0064    */
0065   inline Handle(VrmlData_Node)& AddNode(const Handle(VrmlData_Node)& theNode)
0066   {
0067     return myNodes.Append(theNode);
0068   }
0069 
0070   /**
0071    * Remove one node from the Group.
0072    * @return
0073    *   True if the node was located and removed, False if none removed.
0074    */
0075   Standard_EXPORT Standard_Boolean RemoveNode(const Handle(VrmlData_Node)& theNode);
0076 
0077   /**
0078    * Create iterator on nodes belonging to the Group.
0079    */
0080   inline Iterator NodeIterator() const { return Iterator(myNodes); }
0081 
0082   /**
0083    * Query the bounding box.
0084    */
0085   inline const Bnd_B3f& Box() const { return myBox; }
0086 
0087   /**
0088    * Set the bounding box.
0089    */
0090   inline void SetBox(const Bnd_B3f& theBox) { myBox = theBox; }
0091 
0092   /**
0093    * Set the transformation. Returns True if the group is Transform type,
0094    * otherwise do nothing and return False.
0095    */
0096   Standard_EXPORT Standard_Boolean SetTransform(const gp_Trsf& theTrsf);
0097 
0098   /**
0099    * Query the transform value.
0100    * For group without transformation this always returns Identity
0101    */
0102   inline const gp_Trsf& GetTransform() const { return myTrsf; }
0103 
0104   /**
0105    * Query if the node is Transform type.
0106    */
0107   inline Standard_Boolean IsTransform() const { return myIsTransform; }
0108 
0109   /**
0110    * Create a copy of this node.
0111    * If the parameter is null, a new copied node is created. Otherwise new node
0112    * is not created, but rather the given one is modified.
0113    */
0114   Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
0115     Standard_OVERRIDE;
0116 
0117   /**
0118    * Fill the Node internal data from the given input stream.
0119    */
0120   Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
0121 
0122   /**
0123    * Write the Node to output stream.
0124    */
0125   Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
0126 
0127   /**
0128    * Find a node by its name, inside this Group
0129    * @param theName
0130    *   Name of the node to search for.
0131    * @param theLocation
0132    *   Location of the found node with respect to this Group.
0133    */
0134   Standard_EXPORT Handle(VrmlData_Node) FindNode(const char* theName, gp_Trsf& theLocation) const;
0135 
0136   /**
0137    * Get the shape representing the group geometry.
0138    */
0139   Standard_EXPORT void Shape(TopoDS_Shape& theShape, VrmlData_DataMapOfShapeAppearance* pMapApp);
0140 
0141 protected:
0142   // ---------- PROTECTED METHODS ----------
0143 
0144   /**
0145    * Try to open a file by the given filename, using the search directories
0146    * list myVrmlDir of the Scene.
0147    */
0148   Standard_EXPORT VrmlData_ErrorStatus openFile(Standard_IStream&              theStream,
0149                                                 const TCollection_AsciiString& theFilename);
0150 
0151 private:
0152   // ---------- PRIVATE FIELDS ----------
0153 
0154   Standard_Boolean    myIsTransform;
0155   VrmlData_ListOfNode myNodes;
0156   Bnd_B3f             myBox;
0157   gp_Trsf             myTrsf;
0158 
0159 public:
0160   // Declaration of CASCADE RTTI
0161   DEFINE_STANDARD_RTTIEXT(VrmlData_Group, VrmlData_Node)
0162 };
0163 
0164 // Definition of HANDLE object using Standard_DefineHandle.hxx
0165 DEFINE_STANDARD_HANDLE(VrmlData_Group, VrmlData_Node)
0166 
0167 #endif