1 // Created on: 2002-02-04
2 // Created by: Peter KURNEV
3 // Copyright (c) 2002-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.
22 #include <BOP_WireShell.ixx>
24 #include <Standard_Failure.hxx>
25 #include <Standard_ErrorHandler.hxx>
27 #include <TopAbs_ShapeEnum.hxx>
29 #include <BooleanOperations_ShapesDataStructure.hxx>
31 #include <BOPTColStd_Dump.hxx>
33 #include <BOPTools_DSFiller.hxx>
34 #include <BOPTools_PaveFiller.hxx>
35 #include <BOPTools_WireStateFiller.hxx>
37 #include <BOP_CorrectTolerances.hxx>
39 //=======================================================================
40 // function: BOP_WireShell::BOP_WireShell
42 //=======================================================================
43 BOP_WireShell::BOP_WireShell()
46 //=======================================================================
49 //=======================================================================
50 void BOP_WireShell::Destroy()
53 //=======================================================================
56 //=======================================================================
57 void BOP_WireShell::Do()
60 myIsDone=Standard_False;
63 BOPTools_DSFiller aDSFiller;
64 aDSFiller.SetShapes (myShape1, myShape2);
68 DoWithFiller(aDSFiller);
71 //=======================================================================
72 // function: DoWithFiller
74 //=======================================================================
75 void BOP_WireShell::DoWithFiller(const BOPTools_DSFiller& aDSFiller)
78 myIsDone=Standard_False;
81 myModifiedMap.Clear();
83 myDSFiller=(BOPTools_DSFiller*) &aDSFiller;
88 if(!myDSFiller->IsDone()) {
90 BOPTColStd_Dump::PrintMessage("DSFiller is invalid: Can not build result\n");
94 Standard_Boolean bCheckTypes;
96 bCheckTypes=CheckArgTypes();
102 Standard_Boolean bIsNewFiller;
103 bIsNewFiller=aDSFiller.IsNewFiller();
107 // Preparing the States
108 const BOPTools_PaveFiller& aPaveFiller=myDSFiller->PaveFiller();
109 BOPTools_WireStateFiller aStateFiller(aPaveFiller);
112 aDSFiller.SetNewFiller(!bIsNewFiller);
117 BOP_CorrectTolerances::CorrectTolerances(myResult, 0.01);
120 myIsDone=Standard_True;
122 catch ( Standard_Failure ) {
124 BOPTColStd_Dump::PrintMessage("Can not build result\n");
128 //=======================================================================
129 // function: BuildResult
131 //=======================================================================
132 void BOP_WireShell::BuildResult()
134 AddSplitPartsINOUT();
140 //=======================================================================
141 // function: CheckArgTypes
143 //=======================================================================
144 Standard_Boolean BOP_WireShell::CheckArgTypes(const TopAbs_ShapeEnum theType1,
145 const TopAbs_ShapeEnum theType2,
146 const BOP_Operation theOperation)
148 Standard_Boolean bFlag=Standard_False;
151 if (theType1==TopAbs_WIRE && theType2==TopAbs_SHELL) {
152 if (theOperation==BOP_FUSE || theOperation==BOP_CUT21) {
157 if (theType1==TopAbs_SHELL && theType2==TopAbs_WIRE) {
158 if (theOperation==BOP_FUSE || theOperation==BOP_CUT) {
167 //=======================================================================
168 // function: CheckArgTypes
170 //=======================================================================
171 Standard_Boolean BOP_WireShell::CheckArgTypes() const
173 // Standard_Boolean bFlag=Standard_False;
175 TopAbs_ShapeEnum aT1, aT2;
176 const BooleanOperations_ShapesDataStructure& aDS=myDSFiller->DS();
178 aT1=aDS.Object().ShapeType();
179 aT2=aDS.Tool().ShapeType();
181 // if (aT1==TopAbs_WIRE && aT2==TopAbs_SHELL) {
182 // if (myOperation==BOP_FUSE || myOperation==BOP_CUT21) {
187 // if (aT1==TopAbs_SHELL && aT2==TopAbs_WIRE) {
188 // if (myOperation==BOP_FUSE || myOperation==BOP_CUT) {
194 return CheckArgTypes(aT1, aT2, myOperation);