0029915: Porting to VC 2017 : Regressions in Modeling Algorithms on VC 2017
[occt.git] / src / BRepBuilderAPI / BRepBuilderAPI_GTransform.cxx
1 // Created on: 1996-12-30
2 // Created by: Stagiaire Mary FABIEN
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <BRep_Builder.hxx>
19 #include <BRepBuilderAPI_GTransform.hxx>
20 #include <BRepBuilderAPI_NurbsConvert.hxx>
21 #include <BRepTools_GTrsfModification.hxx>
22 #include <BRepTools_NurbsConvertModification.hxx>
23 #include <gp.hxx>
24 #include <gp_GTrsf.hxx>
25 #include <Standard_NoSuchObject.hxx>
26 #include <TopoDS.hxx>
27 #include <TopoDS_Shape.hxx>
28 #include <TopTools_ListIteratorOfListOfShape.hxx>
29 #include <TopTools_ListOfShape.hxx>
30
31 //=======================================================================
32 //function : BRepBuilderAPI_GTransform
33 //purpose  : 
34 //=======================================================================
35 BRepBuilderAPI_GTransform::BRepBuilderAPI_GTransform (const gp_GTrsf& T) :
36   myGTrsf(T)
37 {
38   myModification = new BRepTools_GTrsfModification(T);
39 }
40
41
42 //=======================================================================
43 //function : BRepBuilderAPI_GTransform
44 //purpose  : 
45 //=======================================================================
46
47 BRepBuilderAPI_GTransform::BRepBuilderAPI_GTransform (const TopoDS_Shape& S,
48                                         const gp_GTrsf& T,
49                                         const Standard_Boolean Copy) :
50   myGTrsf(T)
51 {
52   myModification = new BRepTools_GTrsfModification(T);
53   Perform(S,Copy);
54 }
55
56
57
58 //=======================================================================
59 //function : Perform
60 //purpose  : 
61 //=======================================================================
62
63 void BRepBuilderAPI_GTransform::Perform(const TopoDS_Shape& S,
64                                  const Standard_Boolean Copy)
65 {
66   BRepBuilderAPI_NurbsConvert nc;
67   nc.Perform(S, Copy);
68   myHist.Add(S,nc);
69   TopoDS_Shape Slocal = nc.Shape();
70   Handle(BRepTools_GTrsfModification) theModif =
71     Handle(BRepTools_GTrsfModification)::DownCast(myModification);
72   theModif->GTrsf() = myGTrsf;
73   DoModif(Slocal,myModification);
74 //  myHist.Filter (Shape());
75 }
76
77
78 //=======================================================================
79 //function : Modified
80 //purpose  : 
81 //=======================================================================
82
83 const TopTools_ListOfShape& BRepBuilderAPI_GTransform::Modified
84   (const TopoDS_Shape& F)
85 {
86   myGenerated.Clear();
87   const TopTools_DataMapOfShapeListOfShape& M = myHist.Modification();
88   if (M.IsBound(F)) { 
89     TopTools_ListOfShape Li;
90     TopTools_ListIteratorOfListOfShape itL(M(F));
91     for (;itL.More();itL.Next())
92       Li.Assign(BRepBuilderAPI_ModifyShape::Modified(itL.Value()));
93   }
94   return myGenerated;
95 }
96
97
98 //=======================================================================
99 //function : ModifiedShape
100 //purpose  : 
101 //=======================================================================
102
103 TopoDS_Shape BRepBuilderAPI_GTransform::ModifiedShape
104   (const TopoDS_Shape& S) const
105 {
106   const TopTools_DataMapOfShapeListOfShape &aMapModif = myHist.Modification();
107   TopoDS_Shape                              aShape    = S;
108
109   if (aMapModif.IsBound(S)) {
110     const TopTools_ListOfShape &aListModShape = aMapModif(S);
111     Standard_Integer            aNbShapes     = aListModShape.Extent();
112
113     if (aNbShapes > 0)
114       aShape = aListModShape.First();
115   }
116
117   return BRepBuilderAPI_ModifyShape::ModifiedShape(aShape);
118 }
119