Back to index

salome-geom  6.5.0
GEOMImpl_CopyDriver.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 #include <Standard_Stream.hxx>
00024 
00025 #include <GEOMImpl_CopyDriver.hxx>
00026 #include <GEOMImpl_ICopy.hxx>
00027 #include <GEOMImpl_Types.hxx>
00028 #include <GEOM_Function.hxx>
00029 
00030 #include <BRep_Tool.hxx>
00031 #include <gp_Pnt.hxx>
00032 #include <TopoDS.hxx>
00033 #include <TopoDS_Shape.hxx>
00034 #include <TopoDS_Vertex.hxx>
00035 #include <TopAbs.hxx>
00036 #include <TNaming_CopyShape.hxx>
00037 #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
00038 
00039 //=======================================================================
00040 //function : GetID
00041 //purpose  :
00042 //======================================================================= 
00043 const Standard_GUID& GEOMImpl_CopyDriver::GetID()
00044 {
00045   static Standard_GUID aCopyDriver("FF1BBB53-5D14-4df2-980B-3A668264EA16");
00046   return aCopyDriver; 
00047 }
00048 
00049 
00050 //=======================================================================
00051 //function : GEOMImpl_CopyDriver
00052 //purpose  : 
00053 //=======================================================================
00054 GEOMImpl_CopyDriver::GEOMImpl_CopyDriver() 
00055 {
00056 }
00057 
00058 //=======================================================================
00059 //function : Execute
00060 //purpose  :
00061 //======================================================================= 
00062 Standard_Integer GEOMImpl_CopyDriver::Execute(TFunction_Logbook& log) const
00063 {
00064   if (Label().IsNull()) return 0;    
00065   Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
00066 
00067   Standard_Integer aType = aFunction->GetType();
00068 
00069   GEOMImpl_ICopy aCI (aFunction);
00070   TopoDS_Shape aCopy;
00071   
00072   if(aType == COPY_WITH_REF) {
00073   
00074     Handle(GEOM_Function) aRefFunction = aCI.GetOriginal();
00075     if (aRefFunction.IsNull()) return 0;
00076     TopoDS_Shape anOriginal = aRefFunction->GetValue();
00077 
00078     TColStd_IndexedDataMapOfTransientTransient aMap;
00079   
00080     TNaming_CopyShape::CopyTool(anOriginal, aMap, aCopy);
00081   }
00082   else if(aType == COPY_WITHOUT_REF) {
00083     aCopy = aFunction->GetValue();
00084   }
00085   
00086   if (aCopy.IsNull()) return 0;
00087 
00088   aFunction->SetValue(aCopy);
00089 
00090   log.SetTouched(Label()); 
00091 
00092   return 1;    
00093 }
00094 
00095 
00096 //=======================================================================
00097 //function :  GEOMImpl_CopyDriver_Type_
00098 //purpose  :
00099 //======================================================================= 
00100 Standard_EXPORT Handle_Standard_Type& GEOMImpl_CopyDriver_Type_()
00101 {
00102 
00103   static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
00104   if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
00105   static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
00106   if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared); 
00107   static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
00108   if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
00109  
00110 
00111   static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
00112   static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_CopyDriver",
00113                                                          sizeof(GEOMImpl_CopyDriver),
00114                                                          1,
00115                                                          (Standard_Address)_Ancestors,
00116                                                          (Standard_Address)NULL);
00117 
00118   return _aType;
00119 }
00120 
00121 //=======================================================================
00122 //function : DownCast
00123 //purpose  :
00124 //======================================================================= 
00125 const Handle(GEOMImpl_CopyDriver) Handle(GEOMImpl_CopyDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
00126 {
00127   Handle(GEOMImpl_CopyDriver) _anOtherObject;
00128 
00129   if (!AnObject.IsNull()) {
00130      if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_CopyDriver))) {
00131        _anOtherObject = Handle(GEOMImpl_CopyDriver)((Handle(GEOMImpl_CopyDriver)&)AnObject);
00132      }
00133   }
00134 
00135   return _anOtherObject ;
00136 }