Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Created on: 1990-12-13
0002 // Created by: Remi Lequette
0003 // Copyright (c) 1990-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _TopoDS_TShape_HeaderFile
0018 #define _TopoDS_TShape_HeaderFile
0019 
0020 #include <TopAbs.hxx>
0021 #include <TopAbs_ShapeEnum.hxx>
0022 #include <TopoDS_ListOfShape.hxx>
0023 
0024 
0025 // resolve name collisions with X11 headers
0026 #ifdef Convex
0027   #undef Convex
0028 #endif
0029 
0030 //! A TShape  is a topological  structure describing a
0031 //! set of points in a 2D or 3D space.
0032 //!
0033 //! A topological shape is a structure made from other
0034 //! shapes.  This is a deferred class  used to support
0035 //! topological objects.
0036 //!
0037 //! TShapes are   defined   by  their  optional domain
0038 //! (geometry)  and  their  components  (other TShapes
0039 //! with  Locations and Orientations).  The components
0040 //! are stored in a List of Shapes.
0041 //!
0042 //! A   TShape contains  the   following boolean flags :
0043 //!
0044 //! - Free       : Free or Frozen.
0045 //! - Modified   : Has been modified.
0046 //! - Checked    : Has been checked.
0047 //! - Orientable : Can be oriented.
0048 //! - Closed     : Is closed (note that only Wires and Shells may be closed).
0049 //! - Infinite   : Is infinite.
0050 //! - Convex     : Is convex.
0051 //!
0052 //! Users have no direct access to the classes derived
0053 //! from TShape.  They  handle them with   the classes
0054 //! derived from Shape.
0055 class TopoDS_TShape : public Standard_Transient
0056 {
0057 
0058 public:
0059 
0060   //! Returns the free flag.
0061   Standard_Boolean Free() const { return ((myFlags & TopoDS_TShape_Flags_Free) != 0); }
0062 
0063   //! Sets the free flag.
0064   void Free (Standard_Boolean theIsFree) { setFlag (TopoDS_TShape_Flags_Free, theIsFree); }
0065 
0066   //! Returns the locked flag.
0067   Standard_Boolean Locked() const { return ((myFlags & TopoDS_TShape_Flags_Locked) != 0); }
0068 
0069   //! Sets the locked flag.
0070   void Locked (Standard_Boolean theIsLocked) { setFlag (TopoDS_TShape_Flags_Locked, theIsLocked); }
0071 
0072   //! Returns the modification flag.
0073   Standard_Boolean Modified() const { return ((myFlags & TopoDS_TShape_Flags_Modified) != 0); }
0074 
0075   //! Sets the modification flag.
0076   void Modified (Standard_Boolean theIsModified)
0077   {
0078     setFlag (TopoDS_TShape_Flags_Modified, theIsModified);
0079     if (theIsModified)
0080     {
0081       setFlag (TopoDS_TShape_Flags_Checked, false); // when a TShape is modified it is also unchecked
0082     }
0083   }
0084 
0085   //! Returns the checked flag.
0086   Standard_Boolean Checked() const { return ((myFlags & TopoDS_TShape_Flags_Checked) != 0); }
0087 
0088   //! Sets the checked flag.
0089   void Checked (Standard_Boolean theIsChecked) { setFlag (TopoDS_TShape_Flags_Checked, theIsChecked); }
0090 
0091   //! Returns the orientability flag.
0092   Standard_Boolean Orientable() const { return ((myFlags & TopoDS_TShape_Flags_Orientable) != 0); }
0093 
0094   //! Sets the orientability flag.
0095   void Orientable (Standard_Boolean theIsOrientable) { setFlag (TopoDS_TShape_Flags_Orientable, theIsOrientable); }
0096 
0097   //! Returns the closedness flag.
0098   Standard_Boolean Closed() const { return ((myFlags & TopoDS_TShape_Flags_Closed) != 0); }
0099 
0100   //! Sets the closedness flag.
0101   void Closed (Standard_Boolean theIsClosed) { setFlag (TopoDS_TShape_Flags_Closed, theIsClosed); }
0102 
0103   //! Returns the infinity flag.
0104   Standard_Boolean Infinite() const { return ((myFlags & TopoDS_TShape_Flags_Infinite) != 0); }
0105 
0106   //! Sets the infinity flag.
0107   void Infinite (Standard_Boolean theIsInfinite) { setFlag (TopoDS_TShape_Flags_Infinite, theIsInfinite); }
0108 
0109   //! Returns the convexness flag.
0110   Standard_Boolean Convex() const { return ((myFlags & TopoDS_TShape_Flags_Convex) != 0); }
0111 
0112   //! Sets the convexness flag.
0113   void Convex (Standard_Boolean theIsConvex) { setFlag (TopoDS_TShape_Flags_Convex, theIsConvex); }
0114 
0115   //! Returns the type as a term of the ShapeEnum enum :
0116   //! VERTEX, EDGE, WIRE, FACE, ....
0117   Standard_EXPORT virtual TopAbs_ShapeEnum ShapeType() const = 0;
0118   
0119   //! Returns a copy  of the  TShape  with no sub-shapes.
0120   Standard_EXPORT virtual Handle(TopoDS_TShape) EmptyCopy() const = 0;
0121 
0122   //! Returns the number of direct sub-shapes (children).
0123   //! @sa TopoDS_Iterator for accessing sub-shapes
0124   Standard_Integer NbChildren() const { return myShapes.Size(); }
0125 
0126   //! Dumps the content of me into the stream
0127   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0128 
0129 friend class TopoDS_Iterator;
0130 friend class TopoDS_Builder;
0131 
0132 
0133   DEFINE_STANDARD_RTTIEXT(TopoDS_TShape,Standard_Transient)
0134 
0135 protected:
0136 
0137   //! Constructs an empty TShape.
0138   //! Free       : True
0139   //! Modified   : True
0140   //! Checked    : False
0141   //! Orientable : True
0142   //! Closed     : False
0143   //! Infinite   : False
0144   //! Convex     : False
0145   TopoDS_TShape()
0146   : myFlags (TopoDS_TShape_Flags_Free
0147            | TopoDS_TShape_Flags_Modified
0148            | TopoDS_TShape_Flags_Orientable) {}
0149 
0150 private:
0151 
0152   // Defined mask values
0153   enum TopoDS_TShape_Flags
0154   {
0155     TopoDS_TShape_Flags_Free       = 0x001,
0156     TopoDS_TShape_Flags_Modified   = 0x002,
0157     TopoDS_TShape_Flags_Checked    = 0x004,
0158     TopoDS_TShape_Flags_Orientable = 0x008,
0159     TopoDS_TShape_Flags_Closed     = 0x010,
0160     TopoDS_TShape_Flags_Infinite   = 0x020,
0161     TopoDS_TShape_Flags_Convex     = 0x040,
0162     TopoDS_TShape_Flags_Locked     = 0x080
0163   };
0164 
0165   //! Set bit flag.
0166   void setFlag (TopoDS_TShape_Flags theFlag,
0167                 Standard_Boolean    theIsOn)
0168   {
0169     if (theIsOn) myFlags |=  (Standard_Integer )theFlag;
0170     else         myFlags &= ~(Standard_Integer )theFlag;
0171   }
0172 
0173 private:
0174 
0175   TopoDS_ListOfShape myShapes;
0176   Standard_Integer   myFlags;
0177 };
0178 
0179 DEFINE_STANDARD_HANDLE(TopoDS_TShape, Standard_Transient)
0180 
0181 #endif // _TopoDS_TShape_HeaderFile