X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSALOMEDSImpl%2FSALOMEDSImpl_AttributeReal.cxx;h=1bbbe771534e759da366136ed18c4bf749829c57;hb=45f53064bcaeac84e620fbacb663878f85a1614c;hp=45ddd227a8f5017a0934b17fb55b4e359bcaffbc;hpb=1bd1d38e86c39b13e265f8ff534fc1463c25fef3;p=modules%2Fyacs.git diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.cxx index 45ddd227a..1bbbe7715 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeReal.cxx @@ -1,28 +1,48 @@ +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + // File : SALOMEDSImpl_AttributeReal.cxx // Author : Sergey RUIN // Module : SALOME - +// #include "SALOMEDSImpl_AttributeReal.hxx" -using namespace std; +#include -IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeReal, SALOMEDSImpl_GenericAttribute ) -IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeReal, SALOMEDSImpl_GenericAttribute ) //======================================================================= //function : GetID //purpose : //======================================================================= -const Standard_GUID& SALOMEDSImpl_AttributeReal::GetID () +const std::string& SALOMEDSImpl_AttributeReal::GetID () { - static Standard_GUID realID ("1D1992F0-56F4-46b4-8065-CDEA68061CAB"); + static std::string realID ("1D1992F0-56F4-46b4-8065-CDEA68061CAB"); return realID; } -Handle(SALOMEDSImpl_AttributeReal) SALOMEDSImpl_AttributeReal::Set (const TDF_Label& L, const Standard_Real Val) +SALOMEDSImpl_AttributeReal* SALOMEDSImpl_AttributeReal::Set (const DF_Label& L, const double& Val) { - Handle(SALOMEDSImpl_AttributeReal) A; - if (!L.FindAttribute(SALOMEDSImpl_AttributeReal::GetID(), A)) { + SALOMEDSImpl_AttributeReal* A = NULL; + if (!(A=(SALOMEDSImpl_AttributeReal*)L.FindAttribute(SALOMEDSImpl_AttributeReal::GetID()))) { A = new SALOMEDSImpl_AttributeReal(); L.AddAttribute(A); } @@ -35,7 +55,7 @@ Handle(SALOMEDSImpl_AttributeReal) SALOMEDSImpl_AttributeReal::Set (const TDF_La //function : SetValue //purpose : //======================================================================= -void SALOMEDSImpl_AttributeReal::SetValue(const Standard_Real v) +void SALOMEDSImpl_AttributeReal::SetValue(const double& v) { CheckLocked(); @@ -51,7 +71,7 @@ void SALOMEDSImpl_AttributeReal::SetValue(const Standard_Real v) //function : ID //purpose : //======================================================================= -const Standard_GUID& SALOMEDSImpl_AttributeReal::ID () const +const std::string& SALOMEDSImpl_AttributeReal::ID () const { return GetID(); } @@ -60,7 +80,7 @@ const Standard_GUID& SALOMEDSImpl_AttributeReal::ID () const //function : NewEmpty //purpose : //======================================================================= -Handle(TDF_Attribute) SALOMEDSImpl_AttributeReal::NewEmpty () const +DF_Attribute* SALOMEDSImpl_AttributeReal::NewEmpty () const { return new SALOMEDSImpl_AttributeReal(); } @@ -69,17 +89,36 @@ Handle(TDF_Attribute) SALOMEDSImpl_AttributeReal::NewEmpty () const //function : Restore //purpose : //======================================================================= -void SALOMEDSImpl_AttributeReal::Restore(const Handle(TDF_Attribute)& with) +void SALOMEDSImpl_AttributeReal::Restore(DF_Attribute* with) { - myValue = Handle(SALOMEDSImpl_AttributeReal)::DownCast (with)->Value (); + myValue = dynamic_cast(with)->Value (); } //======================================================================= //function : Paste //purpose : //======================================================================= -void SALOMEDSImpl_AttributeReal::Paste (const Handle(TDF_Attribute)& into, - const Handle(TDF_RelocationTable)& RT) const +void SALOMEDSImpl_AttributeReal::Paste (DF_Attribute* into) +{ + dynamic_cast(into)->SetValue(myValue); +} + +//======================================================================= +//function : Save +//purpose : +//======================================================================= +std::string SALOMEDSImpl_AttributeReal::Save() +{ + char buffer[255]; + sprintf(buffer, "%.64e", myValue); + return std::string(buffer); +} + +//======================================================================= +//function : Load +//purpose : +//======================================================================= +void SALOMEDSImpl_AttributeReal::Load(const std::string& theValue) { - Handle(SALOMEDSImpl_AttributeReal)::DownCast (into)->SetValue(myValue); + myValue = atof(theValue.c_str()); }