Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-02 08:22:10

0001 // Created on: 2012-12-17
0002 // Created by: Eugeny MALTCHIKOV
0003 // Copyright (c) 2012-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 _BRepAlgoAPI_Check_HeaderFile
0017 #define _BRepAlgoAPI_Check_HeaderFile
0018 
0019 #include <Standard.hxx>
0020 #include <Standard_DefineAlloc.hxx>
0021 #include <Standard_Handle.hxx>
0022 
0023 #include <BOPAlgo_ListOfCheckResult.hxx>
0024 #include <BOPAlgo_Operation.hxx>
0025 #include <BOPAlgo_Options.hxx>
0026 #include <TopoDS_Shape.hxx>
0027 #include <Message_ProgressRange.hxx>
0028 
0029 //! The class Check provides a diagnostic tool for checking the validity
0030 //! of the single shape or couple of shapes.
0031 //! The shapes are checked on:
0032 //! - Topological validity;
0033 //! - Small edges;
0034 //! - Self-interference;
0035 //! - Validity for Boolean operation of certain type (for couple of shapes only).
0036 //!
0037 //! The class provides two ways of checking shape(-s)
0038 //! 1. Constructors
0039 //! BRepAlgoAPI_Check aCh(theS);
0040 //! Standard_Boolean isValid = aCh.IsValid();
0041 //! 2. Methods SetData and Perform
0042 //! BRepAlgoAPI_Check aCh;
0043 //! aCh.SetData(theS1, theS2, BOPAlgo_FUSE, Standard_False);
0044 //! aCh.Perform();
0045 //! Standard_Boolean isValid = aCh.IsValid();
0046 //!
0047 class BRepAlgoAPI_Check : public BOPAlgo_Options
0048 {
0049 public:
0050   DEFINE_STANDARD_ALLOC
0051 
0052 public: //! @name Constructors
0053   //! Empty constructor.
0054   Standard_EXPORT BRepAlgoAPI_Check();
0055   Standard_EXPORT virtual ~BRepAlgoAPI_Check();
0056 
0057   //! Constructor for checking single shape.
0058   //!
0059   //! @param[in] theS  - the shape to check;
0060   //! @param[in] bTestSE  - flag which specifies whether to check the shape
0061   //!                       on small edges or not; by default it is set to TRUE;
0062   //! @param[in] bTestSI  - flag which specifies whether to check the shape
0063   //!                       on self-interference or not; by default it is set to TRUE;
0064   //! @param[in] theRange  - parameter to use progress indicator
0065   Standard_EXPORT BRepAlgoAPI_Check(
0066     const TopoDS_Shape&          theS,
0067     const Standard_Boolean       bTestSE  = Standard_True,
0068     const Standard_Boolean       bTestSI  = Standard_True,
0069     const Message_ProgressRange& theRange = Message_ProgressRange());
0070 
0071   //! Constructor for checking the couple of shapes.
0072   //! Additionally to the validity checks of each given shape,
0073   //! the types of the given shapes will be checked on validity
0074   //! for Boolean operation of given type.
0075   //!
0076   //! @param[in] theS1  - the first shape to check;
0077   //! @param[in] theS2  - the second shape to check;
0078   //! @param[in] theOp  - the type of Boolean Operation for which the validity
0079   //!                     of given shapes should be checked.
0080   //! @param[in] bTestSE  - flag which specifies whether to check the shape
0081   //!                       on small edges or not; by default it is set to TRUE;
0082   //! @param[in] bTestSI  - flag which specifies whether to check the shape
0083   //!                       on self-interference or not; by default it is set to TRUE;
0084   //! @param[in] theRange  - parameter to use progress indicator
0085   Standard_EXPORT BRepAlgoAPI_Check(
0086     const TopoDS_Shape&          theS1,
0087     const TopoDS_Shape&          theS2,
0088     const BOPAlgo_Operation      theOp    = BOPAlgo_UNKNOWN,
0089     const Standard_Boolean       bTestSE  = Standard_True,
0090     const Standard_Boolean       bTestSI  = Standard_True,
0091     const Message_ProgressRange& theRange = Message_ProgressRange());
0092 
0093 public: //! @name Initializing the algorithm
0094   //! Initializes the algorithm with single shape.
0095   //!
0096   //! @param[in] theS  - the shape to check;
0097   //! @param[in] bTestSE  - flag which specifies whether to check the shape
0098   //!                       on small edges or not; by default it is set to TRUE;
0099   //! @param[in] bTestSI  - flag which specifies whether to check the shape
0100   //!                       on self-interference or not; by default it is set to TRUE;
0101   void SetData(const TopoDS_Shape&    theS,
0102                const Standard_Boolean bTestSE = Standard_True,
0103                const Standard_Boolean bTestSI = Standard_True)
0104   {
0105     myS1     = theS;
0106     myS2     = TopoDS_Shape();
0107     myTestSE = bTestSE;
0108     myTestSI = bTestSI;
0109     myFaultyShapes.Clear();
0110   }
0111 
0112   //! Initializes the algorithm with couple of shapes.
0113   //! Additionally to the validity checks of each given shape,
0114   //! the types of the given shapes will be checked on validity
0115   //! for Boolean operation of given type.
0116   //!
0117   //! @param[in] theS1  - the first shape to check;
0118   //! @param[in] theS2  - the second shape to check;
0119   //! @param[in] theOp  - the type of Boolean Operation for which the validity
0120   //!                     of given shapes should be checked.
0121   //! @param[in] bTestSE  - flag which specifies whether to check the shape
0122   //!                       on small edges or not; by default it is set to TRUE;
0123   //! @param[in] bTestSI  - flag which specifies whether to check the shape
0124   //!                       on self-interference or not; by default it is set to TRUE;
0125   void SetData(const TopoDS_Shape&     theS1,
0126                const TopoDS_Shape&     theS2,
0127                const BOPAlgo_Operation theOp   = BOPAlgo_UNKNOWN,
0128                const Standard_Boolean  bTestSE = Standard_True,
0129                const Standard_Boolean  bTestSI = Standard_True)
0130   {
0131     myS1        = theS1;
0132     myS2        = theS2;
0133     myOperation = theOp;
0134     myTestSE    = bTestSE;
0135     myTestSI    = bTestSI;
0136     myFaultyShapes.Clear();
0137   }
0138 
0139 public: //! @name Performing the operation
0140   //! Performs the check.
0141   Standard_EXPORT void Perform(const Message_ProgressRange& theRange = Message_ProgressRange());
0142 
0143 public: //! @name Getting the results.
0144   //! Shows whether shape(s) valid or not.
0145   Standard_Boolean IsValid() { return myFaultyShapes.IsEmpty(); }
0146 
0147   //! Returns faulty shapes.
0148   const BOPAlgo_ListOfCheckResult& Result() { return myFaultyShapes; }
0149 
0150 protected: //! @name Fields
0151   // Inputs
0152   TopoDS_Shape myS1;            //!< The first shape
0153   TopoDS_Shape myS2;            //!< The second shape
0154                                 // clang-format off
0155   Standard_Boolean myTestSE;                //!< Flag defining whether to look for small edges in the given shapes or not
0156   Standard_Boolean myTestSI;                //!< Flag defining whether to check the input edges on self-interference or not
0157   BOPAlgo_Operation myOperation;            //!< Type of Boolean operation for which the validity of input shapes should be checked
0158                                 // clang-format on
0159 
0160   // Results
0161   BOPAlgo_ListOfCheckResult myFaultyShapes; //!< Found faulty shapes
0162 };
0163 
0164 #endif // _BRepAlgoAPI_Check_HeaderFile