Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-29 09:18:12

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_CheckResult.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 //! bool isValid = aCh.IsValid();
0041 //! 2. Methods SetData and Perform
0042 //! BRepAlgoAPI_Check aCh;
0043 //! aCh.SetData(theS1, theS2, BOPAlgo_FUSE, false);
0044 //! aCh.Perform();
0045 //! bool 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 ~BRepAlgoAPI_Check() override;
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 bool                   bTestSE  = true,
0068     const bool                   bTestSI  = 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 bool                   bTestSE  = true,
0090     const bool                   bTestSI  = 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, const bool bTestSE = true, const bool bTestSI = true)
0102   {
0103     myS1     = theS;
0104     myS2     = TopoDS_Shape();
0105     myTestSE = bTestSE;
0106     myTestSI = bTestSI;
0107     myFaultyShapes.Clear();
0108   }
0109 
0110   //! Initializes the algorithm with couple of shapes.
0111   //! Additionally to the validity checks of each given shape,
0112   //! the types of the given shapes will be checked on validity
0113   //! for Boolean operation of given type.
0114   //!
0115   //! @param[in] theS1  - the first shape to check;
0116   //! @param[in] theS2  - the second shape to check;
0117   //! @param[in] theOp  - the type of Boolean Operation for which the validity
0118   //!                     of given shapes should be checked.
0119   //! @param[in] bTestSE  - flag which specifies whether to check the shape
0120   //!                       on small edges or not; by default it is set to TRUE;
0121   //! @param[in] bTestSI  - flag which specifies whether to check the shape
0122   //!                       on self-interference or not; by default it is set to TRUE;
0123   void SetData(const TopoDS_Shape&     theS1,
0124                const TopoDS_Shape&     theS2,
0125                const BOPAlgo_Operation theOp   = BOPAlgo_UNKNOWN,
0126                const bool              bTestSE = true,
0127                const bool              bTestSI = true)
0128   {
0129     myS1        = theS1;
0130     myS2        = theS2;
0131     myOperation = theOp;
0132     myTestSE    = bTestSE;
0133     myTestSI    = bTestSI;
0134     myFaultyShapes.Clear();
0135   }
0136 
0137 public: //! @name Performing the operation
0138   //! Performs the check.
0139   Standard_EXPORT void Perform(const Message_ProgressRange& theRange = Message_ProgressRange());
0140 
0141 public: //! @name Getting the results.
0142   //! Shows whether shape(s) valid or not.
0143   bool IsValid() { return myFaultyShapes.IsEmpty(); }
0144 
0145   //! Returns faulty shapes.
0146   const NCollection_List<BOPAlgo_CheckResult>& Result() { return myFaultyShapes; }
0147 
0148 protected: //! @name Fields
0149   // Inputs
0150   TopoDS_Shape myS1;            //!< The first shape
0151   TopoDS_Shape myS2;            //!< The second shape
0152                                 // clang-format off
0153   bool myTestSE;                //!< Flag defining whether to look for small edges in the given shapes or not
0154   bool myTestSI;                //!< Flag defining whether to check the input edges on self-interference or not
0155   BOPAlgo_Operation myOperation;            //!< Type of Boolean operation for which the validity of input shapes should be checked
0156                                 // clang-format on
0157 
0158   // Results
0159   NCollection_List<BOPAlgo_CheckResult> myFaultyShapes; //!< Found faulty shapes
0160 };
0161 
0162 #endif // _BRepAlgoAPI_Check_HeaderFile