1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include <Standard_Stream.hxx>
23 #include <GEOMImpl_CopyDriver.hxx>
24 #include <GEOMImpl_ICopy.hxx>
25 #include <GEOMImpl_Types.hxx>
26 #include <GEOM_Function.hxx>
28 #include <BRep_Tool.hxx>
31 #include <TopoDS_Shape.hxx>
32 #include <TopoDS_Vertex.hxx>
34 #include <TNaming_CopyShape.hxx>
35 #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
37 //=======================================================================
40 //=======================================================================
41 const Standard_GUID& GEOMImpl_CopyDriver::GetID()
43 static Standard_GUID aCopyDriver("FF1BBB53-5D14-4df2-980B-3A668264EA16");
48 //=======================================================================
49 //function : GEOMImpl_CopyDriver
51 //=======================================================================
52 GEOMImpl_CopyDriver::GEOMImpl_CopyDriver()
56 //=======================================================================
59 //=======================================================================
60 Standard_Integer GEOMImpl_CopyDriver::Execute(TFunction_Logbook& log) const
62 if (Label().IsNull()) return 0;
63 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
65 Standard_Integer aType = aFunction->GetType();
67 GEOMImpl_ICopy aCI (aFunction);
70 if(aType == COPY_WITH_REF) {
72 Handle(GEOM_Function) aRefFunction = aCI.GetOriginal();
73 if (aRefFunction.IsNull()) return 0;
74 TopoDS_Shape anOriginal = aRefFunction->GetValue();
76 TColStd_IndexedDataMapOfTransientTransient aMap;
78 TNaming_CopyShape::CopyTool(anOriginal, aMap, aCopy);
80 else if(aType == COPY_WITHOUT_REF) {
81 aCopy = aFunction->GetValue();
84 if (aCopy.IsNull()) return 0;
86 aFunction->SetValue(aCopy);
88 log.SetTouched(Label());
94 //=======================================================================
95 //function : GEOMImpl_CopyDriver_Type_
97 //=======================================================================
98 Standard_EXPORT Handle_Standard_Type& GEOMImpl_CopyDriver_Type_()
101 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
102 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
103 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
104 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
105 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
106 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
109 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
110 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_CopyDriver",
111 sizeof(GEOMImpl_CopyDriver),
113 (Standard_Address)_Ancestors,
114 (Standard_Address)NULL);
119 //=======================================================================
120 //function : DownCast
122 //=======================================================================
123 const Handle(GEOMImpl_CopyDriver) Handle(GEOMImpl_CopyDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
125 Handle(GEOMImpl_CopyDriver) _anOtherObject;
127 if (!AnObject.IsNull()) {
128 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_CopyDriver))) {
129 _anOtherObject = Handle(GEOMImpl_CopyDriver)((Handle(GEOMImpl_CopyDriver)&)AnObject);
133 return _anOtherObject ;