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.
16 #include <BRepAlgoAPI_Check.ixx>
17 #include <BOPAlgo_ArgumentAnalyzer.hxx>
18 #include <BRepCheck_Analyzer.hxx>
20 //=======================================================================
21 //function : BRepAlgoAPI_Check
23 //=======================================================================
24 BRepAlgoAPI_Check::BRepAlgoAPI_Check()
32 //=======================================================================
33 //function : BRepAlgoAPI_Check
35 //=======================================================================
36 BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS,
37 const Standard_Boolean bTestSE,
38 const Standard_Boolean bTestSI)
42 Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
47 //=======================================================================
48 //function : BRepAlgoAPI_Check
50 //=======================================================================
51 BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS1,
52 const TopoDS_Shape& theS2,
53 const BOPAlgo_Operation theOp,
54 const Standard_Boolean bTestSE,
55 const Standard_Boolean bTestSI)
59 Init(theS1, theS2, theOp, bTestSE, bTestSI);
64 //=======================================================================
65 //function : ~BRepAlgoAPI_Check
67 //=======================================================================
68 BRepAlgoAPI_Check::~BRepAlgoAPI_Check()
77 //=======================================================================
78 //function : SetFuzzyValue
80 //=======================================================================
81 void BRepAlgoAPI_Check::SetFuzzyValue(const Standard_Real theFuzz)
83 myFuzzyValue = (theFuzz < 0.) ? 0. : theFuzz;
85 //=======================================================================
86 //function : FuzzyValue
88 //=======================================================================
89 Standard_Real BRepAlgoAPI_Check::FuzzyValue() const
94 //=======================================================================
97 //=======================================================================
98 void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
99 const Standard_Boolean bTestSE,
100 const Standard_Boolean bTestSI)
102 Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
105 //=======================================================================
108 //=======================================================================
109 void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS1,
110 const TopoDS_Shape& theS2,
111 const BOPAlgo_Operation theOp,
112 const Standard_Boolean bTestSE,
113 const Standard_Boolean bTestSI)
115 Init(theS1, theS2, theOp, bTestSE, bTestSI);
117 //=======================================================================
120 //=======================================================================
121 void BRepAlgoAPI_Check::Init(const TopoDS_Shape& theS1,
122 const TopoDS_Shape& theS2,
123 const BOPAlgo_Operation theOp,
124 const Standard_Boolean bTestSE,
125 const Standard_Boolean bTestSI)
131 myAnalyzer = new BOPAlgo_ArgumentAnalyzer();
133 myAnalyzer->SetShape1(myS1);
134 myAnalyzer->SetShape2(myS2);
135 myAnalyzer->OperationType() = theOp;
136 myAnalyzer->ArgumentTypeMode() = Standard_True;
137 myAnalyzer->SmallEdgeMode() = bTestSE;
138 myAnalyzer->SelfInterMode() = bTestSI;
140 myAnalyzer->SetRunParallel(myRunParallel);
141 myAnalyzer->SetProgressIndicator(myProgressIndicator);
142 myAnalyzer->SetFuzzyValue(myFuzzyValue);
145 //=======================================================================
148 //=======================================================================
149 const BOPAlgo_ListOfCheckResult& BRepAlgoAPI_Check::Result()
154 //=======================================================================
157 //=======================================================================
158 Standard_Boolean BRepAlgoAPI_Check::IsValid()
160 return myResult.IsEmpty();
163 //=======================================================================
166 //=======================================================================
167 void BRepAlgoAPI_Check::Perform()
169 Standard_Boolean isS1, isS2;
170 //incompatibility of shape types, small edges and self-interference
171 myAnalyzer->Perform();
172 if (myAnalyzer->HasFaulty()) {
173 myResult = myAnalyzer->GetCheckResult();
176 //topological validity
177 isS1 = !myS1.IsNull();
178 isS2 = !myS2.IsNull();
180 BRepCheck_Analyzer anS1(myS1);
181 isS1 = anS1.IsValid();
183 isS1 = Standard_True;
187 BRepCheck_Analyzer anS2(myS2);
188 isS2 = anS2.IsValid();
190 isS2 = Standard_True;
192 if (!isS1 || !isS2) {
193 BOPAlgo_CheckResult aRes;
194 aRes.SetCheckStatus(BOPAlgo_NotValid);
196 aRes.SetShape1(myS1);
199 aRes.SetShape2(myS2);
201 myResult.Append(aRes);