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