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()
29 //=======================================================================
30 //function : BRepAlgoAPI_Check
32 //=======================================================================
33 BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS,
34 const Standard_Boolean bTestSE,
35 const Standard_Boolean bTestSI)
37 Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
42 //=======================================================================
43 //function : BRepAlgoAPI_Check
45 //=======================================================================
46 BRepAlgoAPI_Check::BRepAlgoAPI_Check(const TopoDS_Shape& theS1,
47 const TopoDS_Shape& theS2,
48 const BOPAlgo_Operation theOp,
49 const Standard_Boolean bTestSE,
50 const Standard_Boolean bTestSI)
52 Init(theS1, theS2, theOp, bTestSE, bTestSI);
57 //=======================================================================
58 //function : ~BRepAlgoAPI_Check
60 //=======================================================================
61 BRepAlgoAPI_Check::~BRepAlgoAPI_Check()
70 //=======================================================================
73 //=======================================================================
74 void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
75 const Standard_Boolean bTestSE,
76 const Standard_Boolean bTestSI)
78 Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
81 //=======================================================================
84 //=======================================================================
85 void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS1,
86 const TopoDS_Shape& theS2,
87 const BOPAlgo_Operation theOp,
88 const Standard_Boolean bTestSE,
89 const Standard_Boolean bTestSI)
91 Init(theS1, theS2, theOp, bTestSE, bTestSI);
95 //=======================================================================
98 //=======================================================================
99 void BRepAlgoAPI_Check::Init(const TopoDS_Shape& theS1,
100 const TopoDS_Shape& theS2,
101 const BOPAlgo_Operation theOp,
102 const Standard_Boolean bTestSE,
103 const Standard_Boolean bTestSI)
109 myAnalyzer = new BOPAlgo_ArgumentAnalyzer();
111 myAnalyzer->SetShape1(myS1);
112 myAnalyzer->SetShape2(myS2);
113 myAnalyzer->OperationType() = theOp;
114 myAnalyzer->ArgumentTypeMode() = Standard_True;
115 myAnalyzer->SmallEdgeMode() = bTestSE;
116 myAnalyzer->SelfInterMode() = bTestSI;
119 //=======================================================================
122 //=======================================================================
123 const BOPAlgo_ListOfCheckResult& BRepAlgoAPI_Check::Result()
128 //=======================================================================
131 //=======================================================================
132 Standard_Boolean BRepAlgoAPI_Check::IsValid()
134 return myResult.IsEmpty();
137 //=======================================================================
140 //=======================================================================
141 void BRepAlgoAPI_Check::Perform()
143 Standard_Boolean isS1, isS2;
144 //incompatibility of shape types, small edges and self-interference
145 myAnalyzer->Perform();
146 if (myAnalyzer->HasFaulty()) {
147 myResult = myAnalyzer->GetCheckResult();
150 //topological validity
151 isS1 = !myS1.IsNull();
152 isS2 = !myS2.IsNull();
154 BRepCheck_Analyzer anS1(myS1);
155 isS1 = anS1.IsValid();
157 isS1 = Standard_True;
161 BRepCheck_Analyzer anS2(myS2);
162 isS2 = anS2.IsValid();
164 isS2 = Standard_True;
166 if (!isS1 || !isS2) {
167 BOPAlgo_CheckResult aRes;
168 aRes.SetCheckStatus(BOPAlgo_NotValid);
170 aRes.SetShape1(myS1);
173 aRes.SetShape2(myS2);
175 myResult.Append(aRes);