1 // Created on: 2012-12-17
2 // Created by: Eugeny MALTCHIKOV
3 // Copyright (c) 2012-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
20 #include <BRepAlgoAPI_Check.ixx>
21 #include <BOPAlgo_ArgumentAnalyzer.hxx>
22 #include <BRepBuilderAPI_Copy.hxx>
23 #include <BRepCheck_Analyzer.hxx>
25 //=======================================================================
26 //function : BRepAlgoAPI_Check
28 //=======================================================================
29 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)
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)
57 Init(theS1, theS2, theOp, bTestSE, bTestSI);
62 //=======================================================================
63 //function : ~BRepAlgoAPI_Check
65 //=======================================================================
66 BRepAlgoAPI_Check::~BRepAlgoAPI_Check()
75 //=======================================================================
78 //=======================================================================
79 void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS,
80 const Standard_Boolean bTestSE,
81 const Standard_Boolean bTestSI)
83 Init(theS, TopoDS_Shape(), BOPAlgo_UNKNOWN, bTestSE, bTestSI);
86 //=======================================================================
89 //=======================================================================
90 void BRepAlgoAPI_Check::SetData(const TopoDS_Shape& theS1,
91 const TopoDS_Shape& theS2,
92 const BOPAlgo_Operation theOp,
93 const Standard_Boolean bTestSE,
94 const Standard_Boolean bTestSI)
96 Init(theS1, theS2, theOp, bTestSE, bTestSI);
100 //=======================================================================
103 //=======================================================================
104 void BRepAlgoAPI_Check::Init(const TopoDS_Shape& theS1,
105 const TopoDS_Shape& theS2,
106 const BOPAlgo_Operation theOp,
107 const Standard_Boolean bTestSE,
108 const Standard_Boolean bTestSI)
111 myS1 = theS1.IsNull() ? theS1 : BRepBuilderAPI_Copy(theS1).Shape();
112 myS2 = theS2.IsNull() ? theS2 : BRepBuilderAPI_Copy(theS2).Shape();
114 myAnalyzer = new BOPAlgo_ArgumentAnalyzer();
116 myAnalyzer->SetShape1(myS1);
117 myAnalyzer->SetShape2(myS2);
118 myAnalyzer->OperationType()=theOp;
119 myAnalyzer->ArgumentTypeMode() = Standard_True;
120 myAnalyzer->SmallEdgeMode() = bTestSE;
121 myAnalyzer->SelfInterMode() = bTestSI;
124 //=======================================================================
127 //=======================================================================
128 const BOPAlgo_ListOfCheckResult& BRepAlgoAPI_Check::Result()
133 //=======================================================================
136 //=======================================================================
137 Standard_Boolean BRepAlgoAPI_Check::IsValid()
139 return myResult.IsEmpty();
142 //=======================================================================
145 //=======================================================================
146 void BRepAlgoAPI_Check::Perform()
148 Standard_Boolean isS1, isS2;
149 //incompatibility of shape types, small edges and self-interference
150 myAnalyzer->Perform();
151 if (myAnalyzer->HasFaulty()) {
152 myResult = myAnalyzer->GetCheckResult();
155 //topological validity
156 isS1 = !myS1.IsNull();
157 isS2 = !myS2.IsNull();
159 BRepCheck_Analyzer anS1(myS1);
160 isS1 = anS1.IsValid();
162 isS1 = Standard_True;
166 BRepCheck_Analyzer anS2(myS2);
167 isS2 = anS2.IsValid();
169 isS2 = Standard_True;
171 if (!isS1 || !isS2) {
172 BOPAlgo_CheckResult aRes;
173 aRes.SetCheckStatus(BOPAlgo_NotValid);
175 aRes.SetShape1(myS1);
178 aRes.SetShape2(myS2);
180 myResult.Append(aRes);