0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepAlgoAPI / BRepAlgoAPI_Check.cxx
CommitLineData
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
4e57c75e 17#include <BOPAlgo_ArgumentAnalyzer.hxx>
42cf5bc1 18#include <BRepAlgoAPI_Check.hxx>
4e57c75e 19#include <BRepCheck_Analyzer.hxx>
42cf5bc1 20#include <TopoDS_Shape.hxx>
4e57c75e 21
22//=======================================================================
23//function : BRepAlgoAPI_Check
24//purpose :
25//=======================================================================
b1d15f53 26BRepAlgoAPI_Check::BRepAlgoAPI_Check()
27:
28 BRepAlgoAPI_Algo(),
29 myAnalyzer(NULL),
30 myFuzzyValue(0.)
4e57c75e 31{
32}
33
34//=======================================================================
35//function : BRepAlgoAPI_Check
36//purpose :
37//=======================================================================
b1d15f53 38BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS,
39 const Standard_Boolean bTestSE,
40 const Standard_Boolean bTestSI)
41: BRepAlgoAPI_Algo(),
42 myFuzzyValue(0.)
4e57c75e 43{
44 Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
45 //
46 Perform();
47}
48
49//=======================================================================
50//function : BRepAlgoAPI_Check
51//purpose :
52//=======================================================================
b1d15f53 53BRepAlgoAPI_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)
58: BRepAlgoAPI_Algo(),
59 myFuzzyValue(0.)
4e57c75e 60{
61 Init(theS1, theS2, theOp, bTestSE, bTestSI);
62 //
63 Perform();
64}
65
66//=======================================================================
67//function : ~BRepAlgoAPI_Check
68//purpose :
69//=======================================================================
b1d15f53 70BRepAlgoAPI_Check::~BRepAlgoAPI_Check()
4e57c75e 71{
72 if(myAnalyzer){
73 delete myAnalyzer;
74 myAnalyzer=NULL;
75 }
76 myResult.Clear();
77}
78
b1d15f53 79//=======================================================================
80//function : SetFuzzyValue
81//purpose :
82//=======================================================================
83void BRepAlgoAPI_Check::SetFuzzyValue(const Standard_Real theFuzz)
84{
92e24f9d 85 myFuzzyValue = (theFuzz < 0.) ? 0. : theFuzz;
b1d15f53 86}
87//=======================================================================
88//function : FuzzyValue
89//purpose :
90//=======================================================================
91Standard_Real BRepAlgoAPI_Check::FuzzyValue() const
92{
93 return myFuzzyValue;
94}
95
4e57c75e 96//=======================================================================
97//function : SetData
98//purpose :
99//=======================================================================
b1d15f53 100void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
101 const Standard_Boolean bTestSE,
102 const Standard_Boolean bTestSI)
4e57c75e 103{
104 Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
105}
106
107//=======================================================================
108//function : SetData
109//purpose :
110//=======================================================================
b1d15f53 111void 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)
4e57c75e 116{
117 Init(theS1, theS2, theOp, bTestSE, bTestSI);
118}
4e57c75e 119//=======================================================================
120//function : Init
121//purpose :
122//=======================================================================
b1d15f53 123void 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)
4e57c75e 128{
129 myResult.Clear();
a967f104 130 myS1 = theS1;
131 myS2 = theS2;
4e57c75e 132 //
133 myAnalyzer = new BOPAlgo_ArgumentAnalyzer();
134 //
135 myAnalyzer->SetShape1(myS1);
136 myAnalyzer->SetShape2(myS2);
a967f104 137 myAnalyzer->OperationType() = theOp;
4e57c75e 138 myAnalyzer->ArgumentTypeMode() = Standard_True;
139 myAnalyzer->SmallEdgeMode() = bTestSE;
140 myAnalyzer->SelfInterMode() = bTestSI;
b1d15f53 141 //
142 myAnalyzer->SetRunParallel(myRunParallel);
143 myAnalyzer->SetProgressIndicator(myProgressIndicator);
144 myAnalyzer->SetFuzzyValue(myFuzzyValue);
4e57c75e 145}
146
147//=======================================================================
148//function : Result
149//purpose :
150//=======================================================================
b1d15f53 151const BOPAlgo_ListOfCheckResult& BRepAlgoAPI_Check::Result()
4e57c75e 152{
153 return myResult;
154}
155
156//=======================================================================
157//function : IsValid
158//purpose :
159//=======================================================================
b1d15f53 160Standard_Boolean BRepAlgoAPI_Check::IsValid()
4e57c75e 161{
162 return myResult.IsEmpty();
163}
164
165//=======================================================================
166//function : Perform
167//purpose :
168//=======================================================================
b1d15f53 169void BRepAlgoAPI_Check::Perform()
4e57c75e 170{
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();
176 }
177
178 //topological validity
179 isS1 = !myS1.IsNull();
180 isS2 = !myS2.IsNull();
181 if (isS1) {
182 BRepCheck_Analyzer anS1(myS1);
183 isS1 = anS1.IsValid();
184 } else {
185 isS1 = Standard_True;
186 }
187 //
188 if (isS2) {
189 BRepCheck_Analyzer anS2(myS2);
190 isS2 = anS2.IsValid();
191 } else {
192 isS2 = Standard_True;
193 }
194 if (!isS1 || !isS2) {
195 BOPAlgo_CheckResult aRes;
196 aRes.SetCheckStatus(BOPAlgo_NotValid);
197 if (!isS1) {
198 aRes.SetShape1(myS1);
199 }
200 if (!isS1) {
201 aRes.SetShape2(myS2);
202 }
203 myResult.Append(aRes);
204 }
205}