1 // Created on: 2012-12-17
2 // Created by: Eugeny MALTCHIKOV
3 // Copyright (c) 2012-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
17 #include <BOPAlgo_ArgumentAnalyzer.hxx>
18 #include <BRepAlgoAPI_Check.hxx>
19 #include <BRepCheck_Analyzer.hxx>
20 #include <TopoDS_Shape.hxx>
22 //=======================================================================
23 //function : BRepAlgoAPI_Check
25 //=======================================================================
26 BRepAlgoAPI_Check::BRepAlgoAPI_Check()
34 //=======================================================================
35 //function : BRepAlgoAPI_Check
37 //=======================================================================
38 BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS,
39 const Standard_Boolean bTestSE,
40 const Standard_Boolean bTestSI)
44 Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
49 //=======================================================================
50 //function : BRepAlgoAPI_Check
52 //=======================================================================
53 BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS1,
54 const TopoDS_Shape& theS2,
55 const BOPAlgo_Operation theOp,
56 const Standard_Boolean bTestSE,
57 const Standard_Boolean bTestSI)
61 Init(theS1, theS2, theOp, bTestSE, bTestSI);
66 //=======================================================================
67 //function : ~BRepAlgoAPI_Check
69 //=======================================================================
70 BRepAlgoAPI_Check::~BRepAlgoAPI_Check()
79 //=======================================================================
80 //function : SetFuzzyValue
82 //=======================================================================
83 void BRepAlgoAPI_Check::SetFuzzyValue(const Standard_Real theFuzz)
85 myFuzzyValue = (theFuzz < 0.) ? 0. : theFuzz;
87 //=======================================================================
88 //function : FuzzyValue
90 //=======================================================================
91 Standard_Real BRepAlgoAPI_Check::FuzzyValue() const
96 //=======================================================================
99 //=======================================================================
100 void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
101 const Standard_Boolean bTestSE,
102 const Standard_Boolean bTestSI)
104 Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
107 //=======================================================================
110 //=======================================================================
111 void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS1,
112 const TopoDS_Shape& theS2,
113 const BOPAlgo_Operation theOp,
114 const Standard_Boolean bTestSE,
115 const Standard_Boolean bTestSI)
117 Init(theS1, theS2, theOp, bTestSE, bTestSI);
119 //=======================================================================
122 //=======================================================================
123 void BRepAlgoAPI_Check::Init(const TopoDS_Shape& theS1,
124 const TopoDS_Shape& theS2,
125 const BOPAlgo_Operation theOp,
126 const Standard_Boolean bTestSE,
127 const Standard_Boolean bTestSI)
133 myAnalyzer = new BOPAlgo_ArgumentAnalyzer();
135 myAnalyzer->SetShape1(myS1);
136 myAnalyzer->SetShape2(myS2);
137 myAnalyzer->OperationType() = theOp;
138 myAnalyzer->ArgumentTypeMode() = Standard_True;
139 myAnalyzer->SmallEdgeMode() = bTestSE;
140 myAnalyzer->SelfInterMode() = bTestSI;
142 myAnalyzer->SetRunParallel(myRunParallel);
143 myAnalyzer->SetProgressIndicator(myProgressIndicator);
144 myAnalyzer->SetFuzzyValue(myFuzzyValue);
147 //=======================================================================
150 //=======================================================================
151 const BOPAlgo_ListOfCheckResult& BRepAlgoAPI_Check::Result()
156 //=======================================================================
159 //=======================================================================
160 Standard_Boolean BRepAlgoAPI_Check::IsValid()
162 return myResult.IsEmpty();
165 //=======================================================================
168 //=======================================================================
169 void BRepAlgoAPI_Check::Perform()
171 Standard_Boolean isS1, isS2;
172 //incompatibility of shape types, small edges and self-interference
173 myAnalyzer->Perform();
174 if (myAnalyzer->HasFaulty()) {
175 myResult = myAnalyzer->GetCheckResult();
178 //topological validity
179 isS1 = !myS1.IsNull();
180 isS2 = !myS2.IsNull();
182 BRepCheck_Analyzer anS1(myS1);
183 isS1 = anS1.IsValid();
185 isS1 = Standard_True;
189 BRepCheck_Analyzer anS2(myS2);
190 isS2 = anS2.IsValid();
192 isS2 = Standard_True;
194 if (!isS1 || !isS2) {
195 BOPAlgo_CheckResult aRes;
196 aRes.SetCheckStatus(BOPAlgo_NotValid);
198 aRes.SetShape1(myS1);
201 aRes.SetShape2(myS2);
203 myResult.Append(aRes);