]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOMImpl/GEOMImpl_CopyDriver.cxx
Salome HOME
ENV: Windows porting.
[modules/geom.git] / src / GEOMImpl / GEOMImpl_CopyDriver.cxx
1
2 #include <Standard_Stream.hxx>
3
4 #include <GEOMImpl_CopyDriver.hxx>
5 #include <GEOMImpl_ICopy.hxx>
6 #include <GEOMImpl_Types.hxx>
7 #include <GEOM_Function.hxx>
8
9 #include <BRep_Tool.hxx>
10 #include <gp_Pnt.hxx>
11 #include <TopoDS.hxx>
12 #include <TopoDS_Shape.hxx>
13 #include <TopoDS_Vertex.hxx>
14 #include <TopAbs.hxx>
15 #include <TNaming_CopyShape.hxx>
16 #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
17
18 //=======================================================================
19 //function : GetID
20 //purpose  :
21 //======================================================================= 
22 const Standard_GUID& GEOMImpl_CopyDriver::GetID()
23 {
24   static Standard_GUID aCopyDriver("FF1BBB53-5D14-4df2-980B-3A668264EA16");
25   return aCopyDriver; 
26 }
27
28
29 //=======================================================================
30 //function : GEOMImpl_CopyDriver
31 //purpose  : 
32 //=======================================================================
33 GEOMImpl_CopyDriver::GEOMImpl_CopyDriver() 
34 {
35 }
36
37 //=======================================================================
38 //function : Execute
39 //purpose  :
40 //======================================================================= 
41 Standard_Integer GEOMImpl_CopyDriver::Execute(TFunction_Logbook& log) const
42 {
43   if (Label().IsNull()) return 0;    
44   Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
45
46   Standard_Integer aType = aFunction->GetType();
47
48   GEOMImpl_ICopy aCI (aFunction);
49   TopoDS_Shape aCopy;
50   
51   if(aType == COPY_WITH_REF) {
52   
53     Handle(GEOM_Function) aRefFunction = aCI.GetOriginal();
54     if (aRefFunction.IsNull()) return 0;
55     TopoDS_Shape anOriginal = aRefFunction->GetValue();
56
57     TColStd_IndexedDataMapOfTransientTransient aMap;
58   
59     TNaming_CopyShape::CopyTool(anOriginal, aMap, aCopy);
60   }
61   else if(aType == COPY_WITHOUT_REF) {
62     aCopy = aFunction->GetValue();
63   }
64   
65   if (aCopy.IsNull()) return 0;
66
67   aFunction->SetValue(aCopy);
68
69   log.SetTouched(Label()); 
70
71   return 1;    
72 }
73
74
75 //=======================================================================
76 //function :  GEOMImpl_CopyDriver_Type_
77 //purpose  :
78 //======================================================================= 
79 Standard_EXPORT Handle_Standard_Type& GEOMImpl_CopyDriver_Type_()
80 {
81
82   static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
83   if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
84   static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
85   if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); 
86   static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
87   if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
88  
89
90   static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
91   static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_CopyDriver",
92                                                          sizeof(GEOMImpl_CopyDriver),
93                                                          1,
94                                                          (Standard_Address)_Ancestors,
95                                                          (Standard_Address)NULL);
96
97   return _aType;
98 }
99
100 //=======================================================================
101 //function : DownCast
102 //purpose  :
103 //======================================================================= 
104 const Handle(GEOMImpl_CopyDriver) Handle(GEOMImpl_CopyDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
105 {
106   Handle(GEOMImpl_CopyDriver) _anOtherObject;
107
108   if (!AnObject.IsNull()) {
109      if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_CopyDriver))) {
110        _anOtherObject = Handle(GEOMImpl_CopyDriver)((Handle(GEOMImpl_CopyDriver)&)AnObject);
111      }
112   }
113
114   return _anOtherObject ;
115 }