Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:05:32

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    * Constructor.
0050    * @param theName
0051    *   Name of the Group node
0052    * @param isTransform
0053    *   True if the group of type Transform is defined
0054    * @param theAlloc
0055    *   Allocator used for the list of children
0056    */
0057   Standard_EXPORT VrmlData_Group
0058                         (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)&
0066                 AddNode         (const Handle(VrmlData_Node)& theNode)
0067   { return myNodes.Append(theNode); }
0068 
0069   /**
0070    * Remove one node from the Group.
0071    * @return
0072    *   True if the node was located and removed, False if none removed.
0073    */
0074   Standard_EXPORT Standard_Boolean
0075                 RemoveNode      (const Handle(VrmlData_Node)& theNode);
0076 
0077   /**
0078    * Create iterator on nodes belonging to the Group.
0079    */
0080   inline Iterator
0081                 NodeIterator    () const { return Iterator (myNodes); }    
0082 
0083   /**
0084    * Query the bounding box.
0085    */
0086   inline const Bnd_B3f&
0087                 Box             () const { return myBox; }
0088 
0089   /**
0090    * Set the bounding box.
0091    */
0092   inline void   SetBox          (const Bnd_B3f& theBox) { myBox = theBox; }
0093 
0094   /**
0095    * Set the transformation. Returns True if the group is Transform type,
0096    * otherwise do nothing and return False.
0097    */
0098   Standard_EXPORT Standard_Boolean
0099                 SetTransform    (const gp_Trsf& theTrsf);
0100 
0101   /**
0102    * Query the transform value.
0103    * For group without transformation this always returns Identity
0104    */ 
0105   inline const gp_Trsf&
0106                 GetTransform     () const { return myTrsf; }
0107 
0108   /**
0109    * Query if the node is Transform type.
0110    */
0111   inline Standard_Boolean
0112                 IsTransform     () const { return myIsTransform; }
0113 
0114   /**
0115    * Create a copy of this node.
0116    * If the parameter is null, a new copied node is created. Otherwise new node
0117    * is not created, but rather the given one is modified.
0118    */
0119   Standard_EXPORT virtual Handle(VrmlData_Node)
0120                 Clone           (const Handle(VrmlData_Node)& theOther) const Standard_OVERRIDE;
0121 
0122   /**
0123    * Fill the Node internal data from the given input stream.
0124    */
0125   Standard_EXPORT virtual VrmlData_ErrorStatus
0126                 Read            (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
0127 
0128   /**
0129    * Write the Node to output stream.
0130    */
0131   Standard_EXPORT virtual VrmlData_ErrorStatus
0132                 Write           (const char * thePrefix) const Standard_OVERRIDE;
0133 
0134   /**
0135    * Find a node by its name, inside this Group
0136    * @param theName
0137    *   Name of the node to search for.
0138    * @param theLocation
0139    *   Location of the found node with respect to this Group.
0140    */
0141   Standard_EXPORT Handle(VrmlData_Node)
0142                                 FindNode (const char * theName,
0143                                           gp_Trsf&     theLocation) const;
0144 
0145   /**
0146    * Get the shape representing the group geometry.
0147    */
0148   Standard_EXPORT void
0149                 Shape           (TopoDS_Shape&                     theShape,
0150                                  VrmlData_DataMapOfShapeAppearance * pMapApp);
0151 
0152  protected:
0153   // ---------- PROTECTED METHODS ----------
0154 
0155   /**
0156    * Try to open a file by the given filename, using the search directories
0157    * list myVrmlDir of the Scene.
0158    */
0159   Standard_EXPORT VrmlData_ErrorStatus
0160                 openFile        (Standard_IStream&              theStream,
0161                                  const TCollection_AsciiString& theFilename);
0162 
0163  private:
0164   // ---------- PRIVATE FIELDS ----------
0165 
0166   Standard_Boolean      myIsTransform;
0167   VrmlData_ListOfNode   myNodes;
0168   Bnd_B3f               myBox;
0169   gp_Trsf               myTrsf;
0170 
0171  public:
0172 // Declaration of CASCADE RTTI
0173 DEFINE_STANDARD_RTTIEXT(VrmlData_Group,VrmlData_Node)
0174 };
0175 
0176 // Definition of HANDLE object using Standard_DefineHandle.hxx
0177 DEFINE_STANDARD_HANDLE (VrmlData_Group, VrmlData_Node)
0178 
0179 
0180 #endif