0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / BRepBuilderAPI / BRepBuilderAPI_ModifyShape.cxx
CommitLineData
b311480e 1// Created on: 1994-12-02
2// Created by: Jacques GOUSSARD
3// Copyright (c) 1994-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <BRepBuilderAPI_ModifyShape.hxx>
19#include <BRepTools_Modification.hxx>
20#include <Standard_NoSuchObject.hxx>
7fd59977 21#include <Standard_NullObject.hxx>
42cf5bc1 22#include <TopoDS_Shape.hxx>
7fd59977 23
24//=======================================================================
25//function : BRepBuilderAPI_ModifyShape
26//purpose :
27//=======================================================================
7fd59977 28BRepBuilderAPI_ModifyShape::BRepBuilderAPI_ModifyShape () {}
29
30
31//=======================================================================
32//function : BRepBuilderAPI_ModifyShape
33//purpose :
34//=======================================================================
35
36BRepBuilderAPI_ModifyShape::BRepBuilderAPI_ModifyShape (const TopoDS_Shape& S):
37 myModifier(S), myInitialShape(S)
38{}
39
40
41//=======================================================================
42//function : BRepBuilderAPI_ModifyShape
43//purpose :
44//=======================================================================
45
46BRepBuilderAPI_ModifyShape::BRepBuilderAPI_ModifyShape
47 (const Handle(BRepTools_Modification)& M)
48{
49 myModification = M;
50}
51
52
53//=======================================================================
54//function : BRepBuilderAPI_ModifyShape
55//purpose :
56//=======================================================================
57
58BRepBuilderAPI_ModifyShape::BRepBuilderAPI_ModifyShape
59 (const TopoDS_Shape& S,
60 const Handle(BRepTools_Modification)& M): myModifier(S),myInitialShape(S)
61{
62 myModification = M;
63 DoModif();
64}
65
66
67//=======================================================================
68//function : DoModif
69//purpose :
70//=======================================================================
71
72void BRepBuilderAPI_ModifyShape::DoModif ()
73{
74 if (myInitialShape.IsNull() || myModification.IsNull()) {
75 Standard_NullObject::Raise();
76 }
77 myModifier.Perform(myModification);
78 if (myModifier.IsDone()) {
79 Done();
80 myShape = myModifier.ModifiedShape(myInitialShape);
81 }
82 else {
83 NotDone();
84 }
85}
86
87
88//=======================================================================
89//function : DoModif
90//purpose :
91//=======================================================================
92
93void BRepBuilderAPI_ModifyShape::DoModif (const TopoDS_Shape& S)
94{
95 if (!S.IsEqual(myInitialShape) || !IsDone()) {
96 myInitialShape = S;
97 myModifier.Init(S);
98 DoModif();
99 }
100}
101
102
103//=======================================================================
104//function : DoModif
105//purpose :
106//=======================================================================
107
108void BRepBuilderAPI_ModifyShape::DoModif (const Handle(BRepTools_Modification)& M)
109{
110 myModification = M;
111 DoModif();
112}
113
114
115//=======================================================================
116//function : DoModif
117//purpose :
118//=======================================================================
119
120void BRepBuilderAPI_ModifyShape::DoModif (const TopoDS_Shape& S,
121 const Handle(BRepTools_Modification)& M)
122{
123 myInitialShape = S;
124 myModifier.Init(S);
125 myModification = M;
126 DoModif();
127}
128
129
130//=======================================================================
131//function : ModifiedShape
132//purpose :
133//=======================================================================
134
346cf025 135TopoDS_Shape BRepBuilderAPI_ModifyShape::ModifiedShape
7fd59977 136 (const TopoDS_Shape& S) const
137{
138 return myModifier.ModifiedShape(S);
139}
140
141//=======================================================================
142//function : Modified
143//purpose :
144//=======================================================================
145
146const TopTools_ListOfShape& BRepBuilderAPI_ModifyShape::Modified
147 (const TopoDS_Shape& F)
148{
149 myGenerated.Clear();
150 myGenerated.Append(myModifier.ModifiedShape(F));
151 return myGenerated;
152}