Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:03

0001 // Created by: Peter KURNEV
0002 // Copyright (c) 2010-2014 OPEN CASCADE SAS
0003 // Copyright (c) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
0004 // Copyright (c) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT,
0005 //                         EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
0006 //
0007 // This file is part of Open CASCADE Technology software library.
0008 //
0009 // This library is free software; you can redistribute it and/or modify it under
0010 // the terms of the GNU Lesser General Public License version 2.1 as published
0011 // by the Free Software Foundation, with special exception defined in the file
0012 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0013 // distribution for complete text of the license and disclaimer of any warranty.
0014 //
0015 // Alternatively, this file may be used under the terms of Open CASCADE
0016 // commercial license or contractual agreement.
0017 
0018 #ifndef _BOPAlgo_BuilderShape_HeaderFile
0019 #define _BOPAlgo_BuilderShape_HeaderFile
0020 
0021 #include <Standard.hxx>
0022 #include <Standard_DefineAlloc.hxx>
0023 #include <Standard_Handle.hxx>
0024 
0025 #include <BOPAlgo_Algo.hxx>
0026 #include <BRepTools_History.hxx>
0027 
0028 #include <NCollection_BaseAllocator.hxx>
0029 #include <TopoDS_Shape.hxx>
0030 #include <TopTools_ListOfShape.hxx>
0031 #include <TopTools_MapOfShape.hxx>
0032 class TopoDS_Shape;
0033 
0034 //! Root class for algorithms that has shape as result.
0035 //!
0036 //! The class provides the History mechanism, which allows
0037 //! tracking the modification of the input shapes during
0038 //! the operation. It uses the *BRepTools_History* tool
0039 //! as a storer for history objects.
0040 class BOPAlgo_BuilderShape : public BOPAlgo_Algo
0041 {
0042 public:
0043 
0044   DEFINE_STANDARD_ALLOC
0045 
0046 public: //! @name Getting the result
0047 
0048   //! Returns the result of algorithm
0049   const TopoDS_Shape& Shape() const { return myShape; }
0050 
0051 
0052 public: //! @name History methods
0053 
0054   //! Returns the list of shapes Modified from the shape theS.
0055   const TopTools_ListOfShape& Modified(const TopoDS_Shape& theS)
0056   {
0057     if (myFillHistory && myHistory)
0058       return myHistory->Modified(theS);
0059     myHistShapes.Clear();
0060     return myHistShapes;
0061   }
0062 
0063   //! Returns the list of shapes Generated from the shape theS.
0064   const TopTools_ListOfShape& Generated(const TopoDS_Shape& theS)
0065   {
0066     if (myFillHistory && myHistory)
0067       return myHistory->Generated(theS);
0068     myHistShapes.Clear();
0069     return myHistShapes;
0070   }
0071 
0072   //! Returns true if the shape theS has been deleted.
0073   //! In this case the shape will have no Modified elements,
0074   //! but can have Generated elements.
0075   Standard_Boolean IsDeleted(const TopoDS_Shape& theS)
0076   {
0077     return (myFillHistory && myHistory ? myHistory->IsRemoved(theS) : Standard_False);
0078   }
0079 
0080   //! Returns true if any of the input shapes has been modified during operation.
0081   Standard_Boolean HasModified() const
0082   {
0083     return (myFillHistory && myHistory ? myHistory->HasModified() : Standard_False);
0084   }
0085 
0086   //! Returns true if any of the input shapes has generated shapes during operation.
0087   Standard_Boolean HasGenerated() const
0088   {
0089     return (myFillHistory && myHistory ? myHistory->HasGenerated() : Standard_False);
0090   }
0091 
0092   //! Returns true if any of the input shapes has been deleted during operation.
0093   Standard_Boolean HasDeleted() const
0094   {
0095     return (myFillHistory && myHistory ? myHistory->HasRemoved() : Standard_False);
0096   }
0097 
0098   //! History Tool
0099   Handle(BRepTools_History) History()
0100   {
0101     if (myFillHistory)
0102     {
0103       if (myHistory.IsNull())
0104        // It seems the algorithm has exited with error before filling
0105        // the history. Initialize the History tool to return the empty
0106        // History instead of NULL.
0107        myHistory = new BRepTools_History();
0108 
0109       return myHistory;
0110     }
0111 
0112     // If the History has not been requested to be filled, return the NULL
0113     // explicitly as the History may be partially filled for the algorithm's
0114     // internal needs.
0115     return NULL;
0116   }
0117 
0118 public: //! @name Enabling/Disabling the history collection.
0119 
0120   //! Allows disabling the history collection
0121   void SetToFillHistory(const Standard_Boolean theHistFlag) { myFillHistory = theHistFlag; }
0122 
0123   //! Returns flag of history availability
0124   Standard_Boolean HasHistory() const { return myFillHistory; }
0125 
0126 protected: //! @name Constructors
0127 
0128   //! Empty constructor
0129   BOPAlgo_BuilderShape()
0130   :
0131     BOPAlgo_Algo(),
0132     myFillHistory(Standard_True)
0133   {}
0134 
0135   //! Constructor with allocator
0136   BOPAlgo_BuilderShape(const Handle(NCollection_BaseAllocator)& theAllocator)
0137   :
0138     BOPAlgo_Algo(theAllocator),
0139     myFillHistory(Standard_True)
0140   {}
0141 
0142 
0143 protected: //! @name Clearing
0144 
0145   //! Clears the content of the algorithm.
0146   virtual void Clear() Standard_OVERRIDE
0147   {
0148     BOPAlgo_Algo::Clear();
0149     myHistory.Nullify();
0150     myMapShape.Clear();
0151   }
0152 
0153 protected: //! @name Fields
0154 
0155   TopoDS_Shape myShape; //!< Result of the operation
0156 
0157   TopTools_ListOfShape myHistShapes;   //!< Storer for the history shapes
0158   TopTools_MapOfShape myMapShape;      //!< cached map of all arguments shapes
0159 
0160   Standard_Boolean myFillHistory;      //!< Controls the history filling
0161   Handle(BRepTools_History) myHistory; //!< History tool
0162 
0163 };
0164 
0165 #endif // _BOPAlgo_BuilderShape_HeaderFile