1 // Created on: 2012-12-17
2 // Created by: Eugeny MALTCHIKOV
3 // Copyright (c) 2012-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15 
16 #ifndef _BRepAlgoAPI_Check_HeaderFile
17 #define _BRepAlgoAPI_Check_HeaderFile
18 
19 #include <Standard.hxx>
20 #include <Standard_DefineAlloc.hxx>
21 #include <Standard_Handle.hxx>
22 
23 #include <BOPAlgo_ListOfCheckResult.hxx>
24 #include <BOPAlgo_Operation.hxx>
25 #include <BOPAlgo_Options.hxx>
26 #include <Standard_Boolean.hxx>
27 #include <Standard_Real.hxx>
28 #include <TopoDS_Shape.hxx>
29 #include <Message_ProgressRange.hxx>
30 
31 
32 //! The class Check provides a diagnostic tool for checking the validity
33 //! of the single shape or couple of shapes.
34 //! The shapes are checked on:
35 //! - Topological validity;
36 //! - Small edges;
37 //! - Self-interference;
38 //! - Validity for Boolean operation of certain type (for couple of shapes only).
39 //!
40 //! The class provides two ways of checking shape(-s)
41 //! 1. Constructors
42 //! BRepAlgoAPI_Check aCh(theS);
43 //! Standard_Boolean isValid = aCh.IsValid();
44 //! 2. Methods SetData and Perform
45 //! BRepAlgoAPI_Check aCh;
46 //! aCh.SetData(theS1, theS2, BOPAlgo_FUSE, Standard_False);
47 //! aCh.Perform();
48 //! Standard_Boolean isValid = aCh.IsValid();
49 //!
50 class BRepAlgoAPI_Check : public BOPAlgo_Options
51 {
52 public:
53 
54   DEFINE_STANDARD_ALLOC
55 
56 
57 public: //! @name Constructors
58 
59   //! Empty constructor.
60   Standard_EXPORT BRepAlgoAPI_Check();
61   Standard_EXPORT virtual ~BRepAlgoAPI_Check();
62 
63   //! Constructor for checking single shape.
64   //!
65   //! @param theS [in] - the shape to check;
66   //! @param bTestSE [in] - flag which specifies whether to check the shape
67   //!                       on small edges or not; by default it is set to TRUE;
68   //! @param bTestSI [in] - flag which specifies whether to check the shape
69   //!                       on self-interference or not; by default it is set to TRUE;
70   //! @param theRange [in] - parameter to use progress indicator
71   Standard_EXPORT BRepAlgoAPI_Check(const TopoDS_Shape& theS,
72                                     const Standard_Boolean bTestSE = Standard_True,
73                                     const Standard_Boolean bTestSI = Standard_True,
74                                     const Message_ProgressRange& theRange = Message_ProgressRange());
75 
76   //! Constructor for checking the couple of shapes.
77   //! Additionally to the validity checks of each given shape,
78   //! the types of the given shapes will be checked on validity
79   //! for Boolean operation of given type.
80   //!
81   //! @param theS1 [in] - the first shape to check;
82   //! @param theS2 [in] - the second shape to check;
83   //! @param theOp [in] - the type of Boolean Operation for which the validity
84   //!                     of given shapes should be checked.
85   //! @param bTestSE [in] - flag which specifies whether to check the shape
86   //!                       on small edges or not; by default it is set to TRUE;
87   //! @param bTestSI [in] - flag which specifies whether to check the shape
88   //!                       on self-interference or not; by default it is set to TRUE;
89   //! @param theRange [in] - parameter to use progress indicator
90   Standard_EXPORT BRepAlgoAPI_Check(const TopoDS_Shape& theS1,
91                                     const TopoDS_Shape& theS2,
92                                     const BOPAlgo_Operation theOp = BOPAlgo_UNKNOWN,
93                                     const Standard_Boolean bTestSE = Standard_True,
94                                     const Standard_Boolean bTestSI = Standard_True,
95                                     const Message_ProgressRange& theRange = Message_ProgressRange());
96 
97 
98 public: //! @name Initializing the algorithm
99 
100   //! Initializes the algorithm with single shape.
101   //!
102   //! @param theS [in] - the shape to check;
103   //! @param bTestSE [in] - flag which specifies whether to check the shape
104   //!                       on small edges or not; by default it is set to TRUE;
105   //! @param bTestSI [in] - flag which specifies whether to check the shape
106   //!                       on self-interference or not; by default it is set to TRUE;
SetData(const TopoDS_Shape & theS,const Standard_Boolean bTestSE=Standard_True,const Standard_Boolean bTestSI=Standard_True)107   void SetData(const TopoDS_Shape& theS,
108                const Standard_Boolean bTestSE = Standard_True,
109                const Standard_Boolean bTestSI = Standard_True)
110   {
111     myS1 = theS;
112     myS2 = TopoDS_Shape();
113     myTestSE = bTestSE;
114     myTestSI = bTestSI;
115     myFaultyShapes.Clear();
116   }
117 
118   //! Initializes the algorithm with couple of shapes.
119   //! Additionally to the validity checks of each given shape,
120   //! the types of the given shapes will be checked on validity
121   //! for Boolean operation of given type.
122   //!
123   //! @param theS1 [in] - the first shape to check;
124   //! @param theS2 [in] - the second shape to check;
125   //! @param theOp [in] - the type of Boolean Operation for which the validity
126   //!                     of given shapes should be checked.
127   //! @param bTestSE [in] - flag which specifies whether to check the shape
128   //!                       on small edges or not; by default it is set to TRUE;
129   //! @param bTestSI [in] - flag which specifies whether to check the shape
130   //!                       on self-interference or not; by default it is set to TRUE;
SetData(const TopoDS_Shape & theS1,const TopoDS_Shape & theS2,const BOPAlgo_Operation theOp=BOPAlgo_UNKNOWN,const Standard_Boolean bTestSE=Standard_True,const Standard_Boolean bTestSI=Standard_True)131   void SetData(const TopoDS_Shape& theS1,
132                const TopoDS_Shape& theS2,
133                const BOPAlgo_Operation theOp = BOPAlgo_UNKNOWN,
134                const Standard_Boolean bTestSE = Standard_True,
135                const Standard_Boolean bTestSI = Standard_True)
136   {
137     myS1 = theS1;
138     myS2 = theS2;
139     myOperation = theOp;
140     myTestSE = bTestSE;
141     myTestSI = bTestSI;
142     myFaultyShapes.Clear();
143   }
144 
145 
146 public: //! @name Performing the operation
147 
148   //! Performs the check.
149   Standard_EXPORT void Perform(const Message_ProgressRange& theRange = Message_ProgressRange());
150 
151 
152 public: //! @name Getting the results.
153 
154   //! Shows whether shape(s) valid or not.
IsValid()155   Standard_Boolean IsValid()
156   {
157     return myFaultyShapes.IsEmpty();
158   }
159 
160   //! Returns faulty shapes.
Result()161   const BOPAlgo_ListOfCheckResult& Result()
162   {
163     return myFaultyShapes;
164   }
165 
166 
167 protected: //! @name Fields
168 
169   // Inputs
170   TopoDS_Shape myS1;                        //!< The first shape
171   TopoDS_Shape myS2;                        //!< The second shape
172   Standard_Boolean myTestSE;                //!< Flag defining whether to look for small edges in the given shapes or not
173   Standard_Boolean myTestSI;                //!< Flag defining whether to check the input edges on self-interference or not
174   BOPAlgo_Operation myOperation;            //!< Type of Boolean operation for which the validity of input shapes should be checked
175 
176   // Results
177   BOPAlgo_ListOfCheckResult myFaultyShapes; //!< Found faulty shapes
178 
179 };
180 
181 #endif // _BRepAlgoAPI_Check_HeaderFile
182