0023024: Update headers of OCCT files
[occt.git] / src / BOP / BOP_EmptyBuilder.cxx
CommitLineData
b311480e 1// Created on: 2002-02-01
2// Created by: Peter KURNEV
3// Copyright (c) 2002-2012 OPEN CASCADE SAS
4//
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.
9//
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.
12//
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.
19
7fd59977 20
21#include <BOP_EmptyBuilder.ixx>
22
23#include <Standard_Failure.hxx>
24#include <Standard_ErrorHandler.hxx>
25
26#include <TopoDS_Compound.hxx>
27
28#include <BRep_Builder.hxx>
29
30#include <BOPTColStd_Dump.hxx>
31#include <BOPTools_DSFiller.hxx>
32#include <BOPTools_Tools3D.hxx>
33
34
35
36
37//=======================================================================
38// function: BOP_EmptyBuilder::BOP_EmptyBuilder
39// purpose:
40//=======================================================================
b311480e 41BOP_EmptyBuilder::BOP_EmptyBuilder()
7fd59977 42{
43}
44//=======================================================================
45// function: Destroy
46// purpose:
47//=======================================================================
48 void BOP_EmptyBuilder::Destroy()
49{
50}
51//=======================================================================
52// function: Do
53// purpose:
54//=======================================================================
55 void BOP_EmptyBuilder::Do()
56{
57 myErrorStatus=0;
58 myIsDone=Standard_False;
59 //
60 // Filling the DS
61 BOPTools_DSFiller aDSFiller;
62 aDSFiller.SetShapes (myShape1, myShape2);
63 //
64 aDSFiller.Perform ();
65 //
66 DoWithFiller(aDSFiller);
67}
68
69//=======================================================================
70// function: DoWithFiller
71// purpose:
72//=======================================================================
73 void BOP_EmptyBuilder::DoWithFiller(const BOPTools_DSFiller& aDSFiller)
74{
75 myErrorStatus=0;
76 myIsDone=Standard_False;
77 //
78 myResultMap.Clear();
79 myModifiedMap.Clear();
80 //
81 myDSFiller=(BOPTools_DSFiller*) &aDSFiller;
82 //
83 //
84 try {
85 OCC_CATCH_SIGNALS
86 Standard_Boolean bIsNewFiller;
87 bIsNewFiller=aDSFiller.IsNewFiller();
88
89 if (bIsNewFiller) {
90 aDSFiller.SetNewFiller(!bIsNewFiller);
91 }
92 //
93 BuildResult();
94 //
95 //
96 //FillModified();
97 myIsDone=Standard_True;
98 }
99
100 catch ( Standard_Failure ) {
101 myErrorStatus = 1;
102 BOPTColStd_Dump::PrintMessage("Can not build result\n");
103 }
104 //
105}
106
107//=======================================================================
108// function: BuildResult
109// purpose:
110//=======================================================================
111 void BOP_EmptyBuilder::BuildResult()
112{
113 Standard_Boolean bIsEmptyShape1, bIsEmptyShape2;
114 BRep_Builder aBB;
115 TopoDS_Compound aCompound;
116
117 aBB.MakeCompound(aCompound);
118 //
119 bIsEmptyShape1=BOPTools_Tools3D::IsEmptyShape(myShape1);
120 bIsEmptyShape2=BOPTools_Tools3D::IsEmptyShape(myShape2);
121 //
122 if (!bIsEmptyShape1 && bIsEmptyShape2) {
123 if (myOperation==BOP_FUSE || myOperation==BOP_CUT) {
124 aBB.Add(aCompound, myShape1);
125 }
126 }
127 //
128 else if (bIsEmptyShape1 && !bIsEmptyShape2) {
129 if (myOperation==BOP_FUSE || myOperation==BOP_CUT21) {
130 aBB.Add(aCompound, myShape2);
131 }
132 }
133 //
134 myResult=aCompound;
135}
136