0024023: Revamp the OCCT Handle -- ambiguity
[occt.git] / src / BRepBuilderAPI / BRepBuilderAPI_Transform.cxx
CommitLineData
b311480e 1// Created on: 1994-12-09
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
17#include <BRepBuilderAPI_Transform.ixx>
18
19#include <BRepTools_TrsfModification.hxx>
20#include <gp.hxx>
21
22
23//=======================================================================
24//function : BRepBuilderAPI_Transform
25//purpose :
26//=======================================================================
27
28BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const gp_Trsf& T) :
29 myTrsf(T)
30{
31 myModification = new BRepTools_TrsfModification(T);
32}
33
34
35//=======================================================================
36//function : BRepBuilderAPI_Transform
37//purpose :
38//=======================================================================
39
40BRepBuilderAPI_Transform::BRepBuilderAPI_Transform (const TopoDS_Shape& S,
41 const gp_Trsf& T,
42 const Standard_Boolean Copy) :
43 myTrsf(T)
44{
45 myModification = new BRepTools_TrsfModification(T);
46 Perform(S,Copy);
47}
48
49
50
51//=======================================================================
52//function : Perform
53//purpose :
54//=======================================================================
55
56void BRepBuilderAPI_Transform::Perform(const TopoDS_Shape& S,
57 const Standard_Boolean Copy)
58{
59// myUseModif = Copy || myTrsf.IsNegative(); bug gp_Trsf.
60 myUseModif = Copy ||
61 myTrsf.ScaleFactor()*myTrsf.HVectorialPart().Determinant() < 0. ||
62 Abs(Abs(myTrsf.ScaleFactor()) - 1) > gp::Resolution();
63 if (myUseModif) {
64 Handle(BRepTools_TrsfModification) theModif =
65 Handle(BRepTools_TrsfModification)::DownCast(myModification);
66 theModif->Trsf() = myTrsf;
67 DoModif(S,myModification);
68 }
69 else {
70 myLocation = myTrsf;
71 myShape = S.Moved(myLocation);
72 Done();
73 }
74
75}
76
77//=======================================================================
78//function : ModifiedShape
79//purpose :
80//=======================================================================
81
346cf025 82TopoDS_Shape BRepBuilderAPI_Transform::ModifiedShape
7fd59977 83 (const TopoDS_Shape& S) const
84{
85 if (myUseModif) {
86 return myModifier.ModifiedShape(S);
87 }
346cf025 88 return S.Moved (myLocation);
7fd59977 89}
90
91
92//=======================================================================
93//function : Modified
94//purpose :
95//=======================================================================
96
97const TopTools_ListOfShape& BRepBuilderAPI_Transform::Modified
98 (const TopoDS_Shape& F)
99{
100 if (!myUseModif) {
101 myGenerated.Clear();
102 myGenerated.Append(F.Moved(myLocation));
103 return myGenerated;
104 }
105 return BRepBuilderAPI_ModifyShape::Modified(F);
106}
107