Integration of OCCT 6.5.0 from SVN
[occt.git] / src / QANewModTopOpe / QANewModTopOpe_ReShaper.cxx
CommitLineData
7fd59977 1// File: QANewModTopOpe_ReShaper.cxx
2// Created: Thu Feb 7 12:37:08 2002
3// Author: Igor FEOKTISTOV <ifv@nnov.matra-dtv.fr>
4// Copyright: SAMTECH S.A. 2002
5
6const static char sccsid[] = "@(#) QANewModTopOpe_ReShaper.cxx 4.0-1, 04/28/03@(#)";
7
8// Lastly modified by :
9// +---------------------------------------------------------------------------+
10// ! ifv ! Creation ! 7-02-2002! 3.0-00-2!
11// +---------------------------------------------------------------------------+
12
13
14#include <QANewModTopOpe_ReShaper.ixx>
15#include <TopTools_HSequenceOfShape.hxx>
16#include <TopoDS_Compound.hxx>
17#include <BRepBuilderAPI_Copy.hxx>
18#include <BRep_Builder.hxx>
19#include <TopoDS_Iterator.hxx>
20#include <TopoDS.hxx>
21
22QANewModTopOpe_ReShaper::QANewModTopOpe_ReShaper(const TopoDS_Shape& TheInitialShape):
23 myInitShape(TheInitialShape)
24{
25
26}
27QANewModTopOpe_ReShaper::QANewModTopOpe_ReShaper(const TopoDS_Shape& TheInitialShape,
28 const TopTools_MapOfShape& TheMap):
29 myInitShape(TheInitialShape)
30{
31 myMap.Assign(TheMap);
32}
33
34QANewModTopOpe_ReShaper::QANewModTopOpe_ReShaper(const TopoDS_Shape& TheInitialShape,
35 const Handle(TopTools_HSequenceOfShape)& TheShapeToBeRemoved):
36 myInitShape(TheInitialShape)
37{
38
39 Standard_Integer i, n = TheShapeToBeRemoved->Length();
40 for(i = 1; i <= n; i++) {
41 myMap.Add(TheShapeToBeRemoved->Value(i));
42 }
43
44}
45
46void QANewModTopOpe_ReShaper::Remove(const TopoDS_Shape& TheS)
47{
48 myMap.Add(TheS);
49}
50
51void QANewModTopOpe_ReShaper::Perform()
52{
53
54 BRepBuilderAPI_Copy aCopier;
55
56 if(myMap.IsEmpty()) {
57
58 aCopier.Perform(myInitShape);
59 myResult = aCopier.Shape();
60 return;
61
62 }
63
64 BRep_Builder aBB;
65 myResult.Nullify();
66 aBB.MakeCompound(TopoDS::Compound(myResult));
67 TopoDS_Iterator anIter(myInitShape);
68
69 for(; anIter.More(); anIter.Next()) {
70
71 const TopoDS_Shape& aS = anIter.Value();
72
73 if(myMap.Contains(aS)) continue;
74
75 if(aS.ShapeType() != TopAbs_COMPOUND) {
76 aCopier.Perform(aS);
77 aBB.Add(myResult, aCopier.Shape());
78 }
79 else {
80 Handle(QANewModTopOpe_ReShaper) aR = new QANewModTopOpe_ReShaper(aS, myMap);
81 aR->Perform();
82 const TopoDS_Shape& aSp = aR->GetResult();
83 if(aSp.ShapeType() == TopAbs_COMPOUND) {
84 TopoDS_Iterator anIt(aSp);
85 if(anIt.More()) {
86 aBB.Add(myResult, aSp);
87 }
88 }
89 else {
90 aBB.Add(myResult, aSp);
91 }
92 }
93
94 }
95
96 if(myResult.ShapeType() == TopAbs_COMPOUND) {
97 anIter.Initialize(myResult);
98 if(anIter.More()) {
99 const TopoDS_Shape& aSp = anIter.Value();
100 anIter.Next();
101 if(!anIter.More()) myResult = aSp;
102 }
103 }
104
105}
106
107const TopoDS_Shape& QANewModTopOpe_ReShaper::GetResult() const
108{
109 return myResult;
110}
111
112void QANewModTopOpe_ReShaper::Clear()
113{
114 myMap.Clear();
115 myResult.Nullify();
116}
117
118// @@SDM: begin
119
120// Copyright SAMTECH ..........................................Version 3.0-00
121// Lastly modified by : ifv Date : 7-02-2002
122
123// File history synopsis (creation,modification,correction)
124// +---------------------------------------------------------------------------+
125// ! Developer ! Comments ! Date ! Version !
126// +-----------!-----------------------------------------!----------!----------+
127// ! ifv ! Creation ! 7-02-2002! 3.0-00-2!
128// +---------------------------------------------------------------------------+
129
130// @@SDM: end