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