X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomData%2FGeomData_Dir.cpp;h=07ed1e0d6fdaaf36dc042a152d5715dc97133703;hb=814a346c0ef4b2625779c5ef96be5ff87980acbb;hp=d36e8a8f5c84685b7b3d6fbc879ee6aa03ca2fa2;hpb=38afbd899a8645c83e17f2c24a17a2b7414911b4;p=modules%2Fshaper.git diff --git a/src/GeomData/GeomData_Dir.cpp b/src/GeomData/GeomData_Dir.cpp index d36e8a8f5..07ed1e0d6 100644 --- a/src/GeomData/GeomData_Dir.cpp +++ b/src/GeomData/GeomData_Dir.cpp @@ -1,17 +1,29 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: GeomData_Dir.cxx -// Created: 2 Apr 2014 -// Author: Mikhail PONIKAROV +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// 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 +// #include "GeomData_Dir.h" -#include "GeomAPI_Dir.h" +#include +#include #include #include #include -using namespace std; - void GeomData_Dir::setValue(const double theX, const double theY, const double theZ) { if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY @@ -49,11 +61,34 @@ std::shared_ptr GeomData_Dir::dir() new GeomAPI_Dir(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2))); } +std::shared_ptr GeomData_Dir::xyz() +{ + return std::shared_ptr( + new GeomAPI_XYZ(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2))); +} + GeomData_Dir::GeomData_Dir(TDF_Label& theLabel) { - myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True; + myLab = theLabel; + reinit(); +} + +void GeomData_Dir::reinit() +{ + myIsInitialized = myLab.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True; if (!myIsInitialized) { // create attribute: not initialized by value yet, just zero - myCoords = TDataStd_RealArray::Set(theLabel, 0, 2); + myCoords = TDataStd_RealArray::Set(myLab, 0, 2); + myIsInitialized = true; } } + +bool GeomData_Dir::isInitialized() +{ + // Check once again the direction is initialized. + // Use case (bos #18905): draw a sketch, click "Change sketch plane", then abort it. + // myIsInitialized value is dropped to false, thus recheck. + if (!myIsInitialized) + myIsInitialized = myLab.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True; + return ModelAPI_Attribute::isInitialized(); +}