--- /dev/null
+// 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 <GeomAlgoAPI_Box.h>
+#include <GeomAlgoAPI_BoxPoints.h>
+
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Edge.h>
+#include <GeomAlgoAPI_EdgeBuilder.h>
+
+#include <iostream>
+
+namespace GeomAlgoAPI_DirectAPI
+{
+ //=========================================================================================================
+ std::shared_ptr<GeomAPI_Shape> 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<GeomAPI_Shape> GeomAlgoAPI_DirectAPI::makeBox(std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
+ std::shared_ptr<GeomAPI_Pnt> 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();
+ }
+}
--- /dev/null
+// 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 <GeomAPI_Shape.h>
+#include <GeomAPI_Pnt.h>
+#include <GeomAPI_Edge.h>
+
+#include <GeomAlgoAPI_Exception.h>
+
+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<GeomAPI_Shape> 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<GeomAPI_Shape> makeBox(std::shared_ptr<GeomAPI_Pnt> theFirstPoint,
+ std::shared_ptr<GeomAPI_Pnt> theSecondPoint) throw (GeomAlgoAPI_Exception);
+};
+}
+#endif
--- /dev/null
+// Copyright (C) 2014-2016 CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_Exception.cpp
+// Created: 14 April 2016
+// Author: Clarisse Genrault (CEA)
+
+#include <GeomAlgoAPI_Exception.h>
+
+//=================================================================================================
+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
--- /dev/null
+#ifndef GeomAlgoAPI_Exception_H_
+#define GeomAlgoAPI_Exception_H_
+
+#include <GeomAlgoAPI.h>
+
+#include <iostream>
+
+/**\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