6aca4d39 |
1 | // Created on: 2012-12-17 |
4e57c75e |
2 | // Created by: Eugeny MALTCHIKOV |
6aca4d39 |
3 | // Copyright (c) 2012-2014 OPEN CASCADE SAS |
4e57c75e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
4e57c75e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
4e57c75e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
4e57c75e |
15 | |
42cf5bc1 |
16 | |
42cf5bc1 |
17 | #include <BRepAlgoAPI_Check.hxx> |
a9810829 |
18 | |
19 | #include <BOPAlgo_ArgumentAnalyzer.hxx> |
4e57c75e |
20 | #include <BRepCheck_Analyzer.hxx> |
21 | |
22 | //======================================================================= |
23 | //function : BRepAlgoAPI_Check |
24 | //purpose : |
25 | //======================================================================= |
b1d15f53 |
26 | BRepAlgoAPI_Check::BRepAlgoAPI_Check() |
a9810829 |
27 | : |
28 | BOPAlgo_Options(), |
29 | myTestSE(Standard_True), |
30 | myTestSI(Standard_True), |
31 | myOperation(BOPAlgo_UNKNOWN) |
4e57c75e |
32 | { |
33 | } |
34 | |
35 | //======================================================================= |
36 | //function : BRepAlgoAPI_Check |
37 | //purpose : |
38 | //======================================================================= |
b1d15f53 |
39 | BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS, |
40 | const Standard_Boolean bTestSE, |
41 | const Standard_Boolean bTestSI) |
a9810829 |
42 | : |
43 | BOPAlgo_Options(), |
44 | myS1(theS), |
45 | myTestSE(bTestSE), |
46 | myTestSI(bTestSI), |
47 | myOperation(BOPAlgo_UNKNOWN) |
4e57c75e |
48 | { |
4e57c75e |
49 | Perform(); |
50 | } |
51 | |
52 | //======================================================================= |
53 | //function : BRepAlgoAPI_Check |
54 | //purpose : |
55 | //======================================================================= |
b1d15f53 |
56 | BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS1, |
57 | const TopoDS_Shape& theS2, |
58 | const BOPAlgo_Operation theOp, |
59 | const Standard_Boolean bTestSE, |
60 | const Standard_Boolean bTestSI) |
a9810829 |
61 | : |
62 | BOPAlgo_Options(), |
63 | myS1(theS1), |
64 | myS2(theS2), |
65 | myTestSE(bTestSE), |
66 | myTestSI(bTestSI), |
67 | myOperation(theOp) |
4e57c75e |
68 | { |
4e57c75e |
69 | Perform(); |
70 | } |
71 | |
72 | //======================================================================= |
73 | //function : ~BRepAlgoAPI_Check |
74 | //purpose : |
75 | //======================================================================= |
b1d15f53 |
76 | BRepAlgoAPI_Check::~BRepAlgoAPI_Check() |
4e57c75e |
77 | { |
4e57c75e |
78 | } |
79 | |
80 | //======================================================================= |
81 | //function : Perform |
82 | //purpose : |
83 | //======================================================================= |
b1d15f53 |
84 | void BRepAlgoAPI_Check::Perform() |
4e57c75e |
85 | { |
a9810829 |
86 | // Check the incompatibility of shapes types, small edges and self-interference |
87 | BOPAlgo_ArgumentAnalyzer anAnalyzer; |
88 | // Set the shapes and options for the check |
89 | anAnalyzer.SetShape1(myS1); |
90 | anAnalyzer.SetShape2(myS2); |
91 | anAnalyzer.OperationType() = myOperation; |
92 | anAnalyzer.ArgumentTypeMode() = Standard_True; |
93 | anAnalyzer.SmallEdgeMode() = myTestSE; |
94 | anAnalyzer.SelfInterMode() = myTestSI; |
95 | // Set options from BOPAlgo_Options |
96 | anAnalyzer.SetRunParallel(myRunParallel); |
97 | anAnalyzer.SetProgressIndicator(myProgressIndicator); |
98 | anAnalyzer.SetFuzzyValue(myFuzzyValue); |
99 | // Perform the check |
100 | anAnalyzer.Perform(); |
101 | // Get the results |
102 | myFaultyShapes = anAnalyzer.GetCheckResult(); |
4e57c75e |
103 | |
a9810829 |
104 | // Check the topological validity of the shapes |
105 | Standard_Boolean isValidS1 = !myS1.IsNull() ? |
106 | BRepCheck_Analyzer(myS1).IsValid() : Standard_True; |
107 | |
108 | Standard_Boolean isValidS2 = !myS2.IsNull() ? |
109 | BRepCheck_Analyzer(myS2).IsValid() : Standard_True; |
110 | |
111 | if (!isValidS1 || !isValidS2) { |
4e57c75e |
112 | BOPAlgo_CheckResult aRes; |
113 | aRes.SetCheckStatus(BOPAlgo_NotValid); |
a9810829 |
114 | if (!isValidS1) { |
4e57c75e |
115 | aRes.SetShape1(myS1); |
116 | } |
a9810829 |
117 | if (!isValidS2) { |
4e57c75e |
118 | aRes.SetShape2(myS2); |
119 | } |
a9810829 |
120 | myFaultyShapes.Append(aRes); |
4e57c75e |
121 | } |
122 | } |