0024624: Lost word in license statement in source files
[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
16#include <BRepAlgoAPI_Check.ixx>
17#include <BOPAlgo_ArgumentAnalyzer.hxx>
18#include <BRepBuilderAPI_Copy.hxx>
19#include <BRepCheck_Analyzer.hxx>
20
21//=======================================================================
22//function : BRepAlgoAPI_Check
23//purpose :
24//=======================================================================
25 BRepAlgoAPI_Check::BRepAlgoAPI_Check()
26: myAnalyzer(NULL)
27{
28}
29
30//=======================================================================
31//function : BRepAlgoAPI_Check
32//purpose :
33//=======================================================================
34 BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS,
35 const Standard_Boolean bTestSE,
36 const Standard_Boolean bTestSI)
37{
38 Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
39 //
40 Perform();
41}
42
43//=======================================================================
44//function : BRepAlgoAPI_Check
45//purpose :
46//=======================================================================
47 BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS1,
48 const TopoDS_Shape& theS2,
49 const BOPAlgo_Operation theOp,
50 const Standard_Boolean bTestSE,
51 const Standard_Boolean bTestSI)
52{
53 Init(theS1, theS2, theOp, bTestSE, bTestSI);
54 //
55 Perform();
56}
57
58//=======================================================================
59//function : ~BRepAlgoAPI_Check
60//purpose :
61//=======================================================================
62 BRepAlgoAPI_Check::~BRepAlgoAPI_Check()
63{
64 if(myAnalyzer){
65 delete myAnalyzer;
66 myAnalyzer=NULL;
67 }
68 myResult.Clear();
69}
70
71//=======================================================================
72//function : SetData
73//purpose :
74//=======================================================================
75 void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
76 const Standard_Boolean bTestSE,
77 const Standard_Boolean bTestSI)
78{
79 Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
80}
81
82//=======================================================================
83//function : SetData
84//purpose :
85//=======================================================================
86 void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS1,
87 const TopoDS_Shape& theS2,
88 const BOPAlgo_Operation theOp,
89 const Standard_Boolean bTestSE,
90 const Standard_Boolean bTestSI)
91{
92 Init(theS1, theS2, theOp, bTestSE, bTestSI);
93}
94
95
96//=======================================================================
97//function : Init
98//purpose :
99//=======================================================================
100 void BRepAlgoAPI_Check::Init(const TopoDS_Shape& theS1,
101 const TopoDS_Shape& theS2,
102 const BOPAlgo_Operation theOp,
103 const Standard_Boolean bTestSE,
104 const Standard_Boolean bTestSI)
105{
106 myResult.Clear();
107 myS1 = theS1.IsNull() ? theS1 : BRepBuilderAPI_Copy(theS1).Shape();
108 myS2 = theS2.IsNull() ? theS2 : BRepBuilderAPI_Copy(theS2).Shape();
109 //
110 myAnalyzer = new BOPAlgo_ArgumentAnalyzer();
111 //
112 myAnalyzer->SetShape1(myS1);
113 myAnalyzer->SetShape2(myS2);
114 myAnalyzer->OperationType()=theOp;
115 myAnalyzer->ArgumentTypeMode() = Standard_True;
116 myAnalyzer->SmallEdgeMode() = bTestSE;
117 myAnalyzer->SelfInterMode() = bTestSI;
118}
119
120//=======================================================================
121//function : Result
122//purpose :
123//=======================================================================
124 const BOPAlgo_ListOfCheckResult& BRepAlgoAPI_Check::Result()
125{
126 return myResult;
127}
128
129//=======================================================================
130//function : IsValid
131//purpose :
132//=======================================================================
133 Standard_Boolean BRepAlgoAPI_Check::IsValid()
134{
135 return myResult.IsEmpty();
136}
137
138//=======================================================================
139//function : Perform
140//purpose :
141//=======================================================================
142 void BRepAlgoAPI_Check::Perform()
143{
144 Standard_Boolean isS1, isS2;
145 //incompatibility of shape types, small edges and self-interference
146 myAnalyzer->Perform();
147 if (myAnalyzer->HasFaulty()) {
148 myResult = myAnalyzer->GetCheckResult();
149 }
150
151 //topological validity
152 isS1 = !myS1.IsNull();
153 isS2 = !myS2.IsNull();
154 if (isS1) {
155 BRepCheck_Analyzer anS1(myS1);
156 isS1 = anS1.IsValid();
157 } else {
158 isS1 = Standard_True;
159 }
160 //
161 if (isS2) {
162 BRepCheck_Analyzer anS2(myS2);
163 isS2 = anS2.IsValid();
164 } else {
165 isS2 = Standard_True;
166 }
167 if (!isS1 || !isS2) {
168 BOPAlgo_CheckResult aRes;
169 aRes.SetCheckStatus(BOPAlgo_NotValid);
170 if (!isS1) {
171 aRes.SetShape1(myS1);
172 }
173 if (!isS1) {
174 aRes.SetShape2(myS2);
175 }
176 myResult.Append(aRes);
177 }
178}
179
180