From: Clarisse Genrault Date: Tue, 21 Jun 2016 13:18:45 +0000 (+0200) Subject: Adding the high level direct API. X-Git-Tag: V_2.5.0~234 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=59c6b4b05cf0793b1a2f96e9004544f933f9010d;p=modules%2Fshaper.git Adding the high level direct API. --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_DirectAPI.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_DirectAPI.cpp new file mode 100644 index 000000000..f621478fd --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_DirectAPI.cpp @@ -0,0 +1,60 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +// File: GeomAlgoAPI_DirectAPI.cpp +// Created: 17 Mar 2016 +// Author: Clarisse Genrault (CEA) + +#include "GeomAlgoAPI_DirectAPI.h" +#include +#include + +#include +#include +#include + +#include + +namespace GeomAlgoAPI_DirectAPI +{ + //========================================================================================================= + std::shared_ptr GeomAlgoAPI_DirectAPI::makeBox(const double theDx, const double theDy, + const double theDz) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_Box aBoxAlgo(theDx,theDy,theDz); + + if (!aBoxAlgo.check()) { + throw GeomAlgoAPI_Exception(aBoxAlgo.getError()); + } + + aBoxAlgo.build(); + + if(!aBoxAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aBoxAlgo.getError()); + } + if (!aBoxAlgo.checkValid("Box builder with dimensions")) { + throw GeomAlgoAPI_Exception(aBoxAlgo.getError()); + } + return aBoxAlgo.shape(); + } + + //========================================================================================================= + std::shared_ptr GeomAlgoAPI_DirectAPI::makeBox(std::shared_ptr theFirstPoint, + std::shared_ptr theSecondPoint) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_BoxPoints aBoxAlgo(theFirstPoint, theSecondPoint); + + if (!aBoxAlgo.check()) { + throw GeomAlgoAPI_Exception(aBoxAlgo.getError()); + } + + aBoxAlgo.build(); + + if(!aBoxAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aBoxAlgo.getError()); + } + if (!aBoxAlgo.checkValid("Box builder with two points")) { + throw GeomAlgoAPI_Exception(aBoxAlgo.getError()); + } + return aBoxAlgo.shape(); + } +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_DirectAPI.h b/src/GeomAlgoAPI/GeomAlgoAPI_DirectAPI.h new file mode 100644 index 000000000..26a7e82fd --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_DirectAPI.h @@ -0,0 +1,40 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +// File: GeomAlgoAPI_DirectAPI.h +// Created: 17 Mar 2016 +// Author: Clarisse Genrault (CEA) + +#ifndef GEOMALGOAPI_DIRECTAPI_H +#define GEOMALGOAPI_DIRECTAPI_H + +#include +#include +#include + +#include + +namespace GeomAlgoAPI_DirectAPI +{ +/**\class GeomAlgoAPI_DirectAPI + * \ingroup DataAlgo + * \brief Allows to access the direct API + */ +class GeomAlgoAPI_DirectAPI +{ +public: + /// Creates a box using the dimensions. + /// \param theDx The dimension on X + /// \param theDy The dimension on Y + /// \param theDz The dimension on Z + /// \return a shape + static std::shared_ptr makeBox(const double theDx, const double theDy, const double theDz) throw (GeomAlgoAPI_Exception); + + /// Creates a box using the two points that defined a diagonal. + /// \param theFirstPoint One extermity of the diagonal + /// \param theSecondPoint The other extremity of the diagonal + /// \return a shape + static std::shared_ptr makeBox(std::shared_ptr theFirstPoint, + std::shared_ptr theSecondPoint) throw (GeomAlgoAPI_Exception); +}; +} +#endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Exception.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Exception.cpp new file mode 100755 index 000000000..53338dae7 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Exception.cpp @@ -0,0 +1,24 @@ +// Copyright (C) 2014-2016 CEA/DEN, EDF R&D + +// File: GeomAlgoAPI_Exception.cpp +// Created: 14 April 2016 +// Author: Clarisse Genrault (CEA) + +#include + +//================================================================================================= +GeomAlgoAPI_Exception::GeomAlgoAPI_Exception(std::string theMessageError) +: myMessageError(theMessageError) +{ +} + +//================================================================================================= +GeomAlgoAPI_Exception::~GeomAlgoAPI_Exception() throw() +{ +} + +//================================================================================================= +const char* GeomAlgoAPI_Exception::what() const throw() +{ + return myMessageError.c_str(); +} \ No newline at end of file diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Exception.h b/src/GeomAlgoAPI/GeomAlgoAPI_Exception.h new file mode 100644 index 000000000..8bdeaa3f3 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Exception.h @@ -0,0 +1,28 @@ +#ifndef GeomAlgoAPI_Exception_H_ +#define GeomAlgoAPI_Exception_H_ + +#include + +#include + +/**\class GeomAlgoAPI_Exception + * \ingroup DataAlgo + * \brief Manage exceptions + */ +class GeomAlgoAPI_Exception : public std::exception +{ + public: + /// Create an exception + /// \param theMessageError Error message to be displayed + GEOMALGOAPI_EXPORT GeomAlgoAPI_Exception(std::string theMessageError); + /// Destroyer + GEOMALGOAPI_EXPORT ~GeomAlgoAPI_Exception() throw(); + /// Allows to collet the error + GEOMALGOAPI_EXPORT const char* what() const throw(); + +private: + std::string myMessageError; /// Error message to be displayed. +}; + + +#endif \ No newline at end of file