X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_MakeShape.h;h=6ed4f1d859425116d4bee21990fe318df4188ed1;hb=1c3738ae81b02ba62136ac03a53a81a532b95141;hp=4fa0ef0a13522ec6d794db8e62369a56c31ca740;hpb=5b841e9801c659d762d708378df8c4d85565fda0;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h index 4fa0ef0a1..6ed4f1d85 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h @@ -1,43 +1,151 @@ -// File: GeomAlgoAPI_MakeShape.h -// Created: 17 Oct 2014 -// Author: Sergey ZARITCHNY +// Copyright (C) 2014-2017 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 +// + #ifndef GeomAlgoAPI_MakeShape_H_ #define GeomAlgoAPI_MakeShape_H_ -#include -#include #include -//#include -/**\class GeomAlgoAPI_MakeShape - * \ingroup DataModel - * \Interface to the root class of all topological shapes constructions - */ +#include + +#include +#include +#include +#include + +/// \class GeomAlgoAPI_MakeShape +/// \ingroup DataAlgo +/// \brief Interface to the root class of all topological shapes constructions class GeomAlgoAPI_MakeShape : public GeomAPI_Interface { - public: - /// Constructor +public: + /// Builder type enum + enum BuilderType { + Unknown, + OCCT_BRepBuilderAPI_MakeShape, + OCCT_BOPAlgo_Builder + }; + +public: + /// \brief Empty constructor. GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(); - GEOMALGOAPI_EXPORT GeomAlgoAPI_MakeShape(void* theBuilder); + /// \brief Constructor by builder and builder type. + /// \param[in] theBuilder pointer to the builder. + /// \param[in] theBuilderType builder type. + template explicit GeomAlgoAPI_MakeShape(T* theBuilder, + const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape) + : GeomAPI_Interface(theBuilder), + myBuilderType(theBuilderType) + { + initialize(); + } + + /// \brief Initializes internals. + /// \param[in] theBuilder pointer to the builder. + /// \param[in] theBuilderType builder type. + template void initialize(T* theBuilder, + const BuilderType theBuilderType = OCCT_BRepBuilderAPI_MakeShape) + { + setImpl(theBuilder); + myBuilderType = theBuilderType; + initialize(); + } + + /// \return status of builder. + GEOMALGOAPI_EXPORT bool isDone() const; + + /// \return a shape built by the shape construction algorithm. + GEOMALGOAPI_EXPORT virtual const std::shared_ptr shape() const; + + /// \return true if resulting shape is valid. + GEOMALGOAPI_EXPORT bool isValid() const; + + /// \return true if resulting shape has volume. + GEOMALGOAPI_EXPORT bool hasVolume() const; + + /// \return map of sub-shapes of the result. To be used for History keeping. + GEOMALGOAPI_EXPORT std::shared_ptr mapOfSubShapes() const; - /// Returns a shape built by the shape construction algorithm - GEOMALGOAPI_EXPORT const boost::shared_ptr shape() const; + /// \return the list of shapes generated from the shape \a theShape. + /// \param[in] theShape base shape. + /// \param[out] theHistory generated shapes. + GEOMALGOAPI_EXPORT virtual void generated(const std::shared_ptr theShape, + ListOfShape& theHistory); - /// Returns the list of shapes generated from the shape - GEOMALGOAPI_EXPORT virtual void generated( - const boost::shared_ptr theShape, ListOfShape& theHistory); + /// \return the list of shapes modified from the shape \a theShape. + /// \param[in] theShape base shape. + /// \param[out] theHistory modified shapes. Does not cleared! + GEOMALGOAPI_EXPORT virtual void modified(const std::shared_ptr theShape, + ListOfShape& theHistory); - /// Returns the list of shapes modified from the shape - GEOMALGOAPI_EXPORT virtual void modified( - const boost::shared_ptr theShape, ListOfShape& theHistory); + /// \return true if theShape was deleted. + /// \param[in] theShape base shape. + GEOMALGOAPI_EXPORT virtual bool isDeleted(const std::shared_ptr theShape); - /// Returns whether the shape is an edge - GEOMALGOAPI_EXPORT virtual bool isDeleted(const boost::shared_ptr theShape); + /// \return true if the data were correct. + GEOMALGOAPI_EXPORT virtual bool check() { return true; }; - GEOMALGOAPI_EXPORT void init(void* theMkShape); + /// \return the list of created faces. + GEOMALGOAPI_EXPORT std::map< std::string, std::shared_ptr > getCreatedFaces() + {return myCreatedFaces;} - protected: - boost::shared_ptr myShape; + /// \return the error. + GEOMALGOAPI_EXPORT std::string getError() { return myError; } + + /// \brief Prepare the naming of faces. + GEOMALGOAPI_EXPORT virtual void prepareNamingFaces(); + + /// \brief Check the validity of the produced shape. + GEOMALGOAPI_EXPORT bool checkValid(std::string theMessage); + +protected: + /// \brief Sets builder type. + /// \param[in] theBuilderType new builder type. + void setBuilderType(const BuilderType theBuilderType); + + /// \brief Sets status of builder. + /// \param[in] theFlag new status. + void setDone(const bool theFlag); + + /// \brief Sets result shape. + /// \param[in] theShape new shape. + void setShape(const std::shared_ptr theShape); + +protected: + /// Data map to keep correct orientation of sub-shapes. + std::shared_ptr myMap; + /// Error occurred during the execution of an algorithm. + std::string myError; + /// Map of created faces with their name for naming. + std::map< std::string, std::shared_ptr > myCreatedFaces; + +private: + /// \brief Initializes internals. + void initialize(); + +private: + GeomAlgoAPI_MakeShape::BuilderType myBuilderType; ///< Type of make shape builder. + bool myDone; ///< Builder status. + std::shared_ptr myShape; ///< Resulting shape. }; +typedef std::list > ListOfMakeShape; + #endif