From: Clarisse Genrault Date: Thu, 16 Mar 2017 15:27:33 +0000 (+0100) Subject: Added "Sphere" primitive. X-Git-Tag: V_2.9.0~54 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f97ab8f4020ddb1843ca64ed420f31d27c6da97d;p=modules%2Fshaper.git Added "Sphere" primitive. --- diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 2b5d6a2c6..f3390147c 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -43,6 +43,7 @@ SET(PROJECT_HEADERS GeomAlgoAPI_Exception.h GeomAlgoAPI_Box.h GeomAlgoAPI_Cylinder.h + GeomAlgoAPI_Sphere.h GeomAlgoAPI_XAOExport.h GeomAlgoAPI_XAOImport.h GeomAlgoAPI_Copy.h @@ -88,6 +89,7 @@ SET(PROJECT_SOURCES GeomAlgoAPI_Exception.cpp GeomAlgoAPI_Box.cpp GeomAlgoAPI_Cylinder.cpp + GeomAlgoAPI_Sphere.cpp GeomAlgoAPI_XAOExport.cpp GeomAlgoAPI_XAOImport.cpp GeomAlgoAPI_Copy.cpp diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp index 9765c6456..55050b96a 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp @@ -7,12 +7,13 @@ #include "GeomAlgoAPI_ShapeAPI.h" #include -#include #include #include +#include #include #include #include +#include #include #include @@ -192,6 +193,53 @@ namespace GeomAlgoAPI_ShapeAPI return aCylinderAlgo.shape(); } + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeSphere( + std::shared_ptr theCenterPoint, double theRadius) throw (GeomAlgoAPI_Exception) + { + GeomAlgoAPI_Sphere aSphereAlgo(theCenterPoint, theRadius); + + if (!aSphereAlgo.check()) { + throw GeomAlgoAPI_Exception(aSphereAlgo.getError()); + } + + aSphereAlgo.build(); + + if(!aSphereAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aSphereAlgo.getError()); + } + + if (!aSphereAlgo.checkValid("Sphere builder")) { + throw GeomAlgoAPI_Exception(aSphereAlgo.getError()); + } + return aSphereAlgo.shape(); + } + + //=============================================================================================== + std::shared_ptr GeomAlgoAPI_ShapeAPI::makeSphere(double theRadius) + throw (GeomAlgoAPI_Exception) + { + std::shared_ptr aCenterPoint = + std::shared_ptr(new GeomAPI_Pnt(0.,0.,0.)); + + GeomAlgoAPI_Sphere aSphereAlgo(aCenterPoint, theRadius); + + if (!aSphereAlgo.check()) { + throw GeomAlgoAPI_Exception(aSphereAlgo.getError()); + } + + aSphereAlgo.build(); + + if(!aSphereAlgo.isDone()) { + throw GeomAlgoAPI_Exception(aSphereAlgo.getError()); + } + + if (!aSphereAlgo.checkValid("Sphere builder")) { + throw GeomAlgoAPI_Exception(aSphereAlgo.getError()); + } + return aSphereAlgo.shape(); + } + //=============================================================================================== std::shared_ptr GeomAlgoAPI_ShapeAPI::makeTranslation( std::shared_ptr theSourceShape, diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h index 3f137c4fe..1743e6d66 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h @@ -71,6 +71,17 @@ public: static std::shared_ptr makeCylinder(double theRadius, double theHeight, double theAngle) throw (GeomAlgoAPI_Exception); + /// Creates a sphere using a center and a radius. + /// \param theCenterPoint The center of the sphere + /// \param theRadius The radius of the sphere + static std::shared_ptr makeSphere(std::shared_ptr theCenterPoint, + double theRadius) throw (GeomAlgoAPI_Exception); + + /// Creates a sphere using the origin and a radius. + /// \param theRadius The radius of the cylinder + static std::shared_ptr makeSphere(double theRadius) + throw (GeomAlgoAPI_Exception); + /// Performs a translation from an axis and a distance. /// \param theSourceShape Shape to be moved /// \param theAxis Movement axis diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp new file mode 100644 index 000000000..b2642c94c --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp @@ -0,0 +1,68 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: GeomAlgoAPI_Sphere.h +// Created: 16 Mar 2017 +// Author: Clarisse Genrault (CEA) + +#include + +#include + +//================================================================================================= +GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere() +{ +} + +//================================================================================================= +GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere(std::shared_ptr theCenterPoint, + const double theRadius) +{ + myCenterPoint = theCenterPoint; + myRadius = theRadius; +} + +//================================================================================================= +bool GeomAlgoAPI_Sphere::check() +{ + if (!myCenterPoint) { + myError = "Sphere builder :: center is not valid."; + return false; + } + if (myRadius < Precision::Confusion()) { + myError = "Sphere builder :: radius is negative or null."; + return false; + } + return true; +} + +//================================================================================================= +void GeomAlgoAPI_Sphere::build() +{ + myCreatedFaces.clear(); + + const gp_Pnt& aCenterPoint = myCenterPoint->impl(); + + // Construct the sphere + BRepPrimAPI_MakeSphere *aSphereMaker = new BRepPrimAPI_MakeSphere(aCenterPoint, myRadius); + + aSphereMaker->Build(); + + if (!aSphereMaker->IsDone()) { + return; + } + + TopoDS_Shape aResult = aSphereMaker->Shape(); + std::shared_ptr aShape(new GeomAPI_Shape()); + aShape->setImpl(new TopoDS_Shape(aResult)); + setShape(aShape); + + // Test on the shapes + if (!aShape.get() || aShape->isNull()) { + myError = "Sphere builder :: resulting shape is null."; + return; + } + + setImpl(aSphereMaker); + + setDone(true); +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.h b/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.h new file mode 100644 index 000000000..f317a26ee --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.h @@ -0,0 +1,40 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: GeomAlgoAPI_Sphere.h +// Created: 16 Mar 2017 +// Author: Clarisse Genrault (CEA) + +#ifndef GEOMALGOAPI_SPHERE_H_ +#define GEOMALGOAPI_SPHERE_H_ + +#include + +#include + +/**\class GeomAlgoAPI_Sphere + * \ingroup DataAlgo + * \brief Allows to create Sphere Primitives + */ +class GeomAlgoAPI_Sphere : public GeomAlgoAPI_MakeShape +{ + public: + GEOMALGOAPI_EXPORT GeomAlgoAPI_Sphere(); + + /// Creates a sphere. + /// \param theCenterPoint The center point of the sphere + /// \param theRadius The radius of the sphere + GEOMALGOAPI_EXPORT GeomAlgoAPI_Sphere(std::shared_ptr theCenterPoint, + const double theRadius); + + /// Checks if data for the sphere construction is OK. + GEOMALGOAPI_EXPORT bool check(); + + /// Builds the sphere. + GEOMALGOAPI_EXPORT void build(); + + private: + std::shared_ptr myCenterPoint; /// Center of the sphere. + double myRadius; +}; + +#endif // GEOMALGOAPI_SPHERE_H_ diff --git a/src/PrimitivesAPI/CMakeLists.txt b/src/PrimitivesAPI/CMakeLists.txt index abd9c9f1f..cbe3c9aad 100644 --- a/src/PrimitivesAPI/CMakeLists.txt +++ b/src/PrimitivesAPI/CMakeLists.txt @@ -6,11 +6,13 @@ SET(PROJECT_HEADERS PrimitivesAPI.h PrimitivesAPI_Box.h PrimitivesAPI_Cylinder.h + PrimitivesAPI_Sphere.h ) SET(PROJECT_SOURCES PrimitivesAPI_Box.cpp PrimitivesAPI_Cylinder.cpp + PrimitivesAPI_Sphere.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/PrimitivesAPI/PrimitivesAPI.i b/src/PrimitivesAPI/PrimitivesAPI.i index 3bea92c00..d708a40cd 100644 --- a/src/PrimitivesAPI/PrimitivesAPI.i +++ b/src/PrimitivesAPI/PrimitivesAPI.i @@ -21,7 +21,9 @@ // shared pointers %shared_ptr(PrimitivesAPI_Box) %shared_ptr(PrimitivesAPI_Cylinder) +%shared_ptr(PrimitivesAPI_Sphere) // all supported interfaces %include "PrimitivesAPI_Box.h" %include "PrimitivesAPI_Cylinder.h" +%include "PrimitivesAPI_Sphere.h" diff --git a/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp new file mode 100644 index 000000000..eaba588f7 --- /dev/null +++ b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp @@ -0,0 +1,83 @@ +// Copyright (C) 2014-201x CEA/DEN, EDF R&D --> + +// File: PrimitivesAPI_Sphere.h +// Created: 16 Mar 2017 +// Author: Clarisse Genrault + +#include "PrimitivesAPI_Sphere.h" + +#include +#include +#include + +//================================================================================================== +PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr& theFeature) +: ModelHighAPI_Interface(theFeature) +{ + initialize(); +} + +//================================================================================================== +PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr& theFeature, + const ModelHighAPI_Selection& theCenterPoint, + const ModelHighAPI_Double& theRadius) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) { + fillAttribute(theCenterPoint, centerPoint()); + setRadius(theRadius); + } +} + +//================================================================================================== +PrimitivesAPI_Sphere::~PrimitivesAPI_Sphere() +{ +} + +//================================================================================================== +void PrimitivesAPI_Sphere::setCenterPoint(const ModelHighAPI_Selection& theCenterPoint) +{ + fillAttribute(theCenterPoint, centerPoint()); + execute(); +} + +//================================================================================================== +void PrimitivesAPI_Sphere::setRadius(const ModelHighAPI_Double& theRadius) +{ + fillAttribute(theRadius, radius()); + execute(); +} + +//================================================================================================== +void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const +{ + FeaturePtr aBase = feature(); + const std::string& aDocName = theDumper.name(aBase->document()); + + theDumper << aBase << " = model.addSphere(" << aDocName; + + AttributeSelectionPtr anAttrCenterPoint = + aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID()); + AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID()); + theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius; + + theDumper << ")" << std::endl; +} + +//================================================================================================== +SpherePtr addSphere(const std::shared_ptr& thePart, + const ModelHighAPI_Selection& theCenterPoint, + const ModelHighAPI_Double& theRadius) +{ + std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID()); + return SpherePtr(new PrimitivesAPI_Sphere(aFeature, theCenterPoint, theRadius)); +} + +//================================================================================================== +SpherePtr addSphere(const std::shared_ptr& thePart, + const ModelHighAPI_Double& theRadius) +{ + ModelHighAPI_Selection aCenterPoint("VERTEX", "PartSet/Origin"); + std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID()); + return SpherePtr(new PrimitivesAPI_Sphere(aFeature, aCenterPoint, theRadius)); +} diff --git a/src/PrimitivesAPI/PrimitivesAPI_Sphere.h b/src/PrimitivesAPI/PrimitivesAPI_Sphere.h new file mode 100644 index 000000000..0374469cf --- /dev/null +++ b/src/PrimitivesAPI/PrimitivesAPI_Sphere.h @@ -0,0 +1,75 @@ +// Copyright (C) 2014-201x CEA/DEN, EDF R&D --> + +// File: PrimitivesAPI_Sphere.h +// Created: 16 Mar 2017 +// Author: Clarisse Genrault + +#ifndef PRIMITIVESAPI_SPHERE_H_ +#define PRIMITIVESAPI_SPHERE_H_ + +#include "PrimitivesAPI.h" + +#include + +#include +#include + +class ModelHighAPI_Double; +class ModelHighAPI_Selection; + +/// \class PrimitivesAPI_Sphere +/// \ingroup CPPHighAPI +/// \brief Interface for primitive Sphere feature. +class PrimitivesAPI_Sphere: public ModelHighAPI_Interface +{ +public: + /// Constructor without values. + PRIMITIVESAPI_EXPORT + explicit PrimitivesAPI_Sphere(const std::shared_ptr& theFeature); + + /// Constructor with values. + PRIMITIVESAPI_EXPORT + explicit PrimitivesAPI_Sphere(const std::shared_ptr& theFeature, + const ModelHighAPI_Selection& theCenterPoint, + const ModelHighAPI_Double& theRadius); + + /// Destructor. + PRIMITIVESAPI_EXPORT + virtual ~PrimitivesAPI_Sphere(); + + INTERFACE_2(PrimitivesPlugin_Sphere::ID(), + centerPoint, PrimitivesPlugin_Sphere::CENTER_POINT_ID(), + ModelAPI_AttributeSelection, /** Center point */, + radius, PrimitivesPlugin_Sphere::RADIUS_ID(), + ModelAPI_AttributeDouble, /** Radius */) + + /// Set center point + PRIMITIVESAPI_EXPORT + void setCenterPoint(const ModelHighAPI_Selection& theCenterPoint); + + /// Set radius + PRIMITIVESAPI_EXPORT + void setRadius(const ModelHighAPI_Double& theRadius); + + /// Dump wrapped feature + PRIMITIVESAPI_EXPORT + virtual void dump(ModelHighAPI_Dumper& theDumper) const; +}; + +/// Pointer on primitive Sphere object +typedef std::shared_ptr SpherePtr; + +/// \ingroup CPPHighAPI +/// \brief Create primitive Sphere feature. +PRIMITIVESAPI_EXPORT +SpherePtr addSphere(const std::shared_ptr& thePart, + const ModelHighAPI_Selection& theCenterPoint, + const ModelHighAPI_Double& theRadius); + +/// \ingroup CPPHighAPI +/// \brief Create primitive Sphere feature. +PRIMITIVESAPI_EXPORT +SpherePtr addSphere(const std::shared_ptr& thePart, + const ModelHighAPI_Double& theRadius); + +#endif // PRIMITIVESAPI_SPHERE_H_ diff --git a/src/PrimitivesAPI/PrimitivesAPI_swig.h b/src/PrimitivesAPI/PrimitivesAPI_swig.h index 98fc5bf03..04b3e3716 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_swig.h +++ b/src/PrimitivesAPI/PrimitivesAPI_swig.h @@ -12,5 +12,6 @@ #include "PrimitivesAPI.h" #include "PrimitivesAPI_Box.h" #include "PrimitivesAPI_Cylinder.h" + #include "PrimitivesAPI_Sphere.h" #endif // PRIMITIVESAPI_SWIG_H_ diff --git a/src/PrimitivesPlugin/CMakeLists.txt b/src/PrimitivesPlugin/CMakeLists.txt index e8aa0147a..8df0d67db 100644 --- a/src/PrimitivesPlugin/CMakeLists.txt +++ b/src/PrimitivesPlugin/CMakeLists.txt @@ -9,18 +9,21 @@ SET(PROJECT_HEADERS PrimitivesPlugin_Plugin.h PrimitivesPlugin_Box.h PrimitivesPlugin_Cylinder.h + PrimitivesPlugin_Sphere.h ) SET(PROJECT_SOURCES PrimitivesPlugin_Plugin.cpp PrimitivesPlugin_Box.cpp PrimitivesPlugin_Cylinder.cpp + PrimitivesPlugin_Sphere.cpp ) SET(XML_RESOURCES plugin-Primitives.xml box_widget.xml cylinder_widget.xml + sphere_widget.xml ) INCLUDE_DIRECTORIES( diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Plugin.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Plugin.cpp index b3ef9cbf3..36c77fa8a 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Plugin.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Plugin.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include #include @@ -29,6 +31,8 @@ FeaturePtr PrimitivesPlugin_Plugin::createFeature(std::string theFeatureID) return FeaturePtr(new PrimitivesPlugin_Box); } else if (theFeatureID == PrimitivesPlugin_Cylinder::ID()) { return FeaturePtr(new PrimitivesPlugin_Cylinder); + } else if (theFeatureID == PrimitivesPlugin_Sphere::ID()) { + return FeaturePtr(new PrimitivesPlugin_Sphere); } // feature of such kind is not found return FeaturePtr(); diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp new file mode 100644 index 000000000..9e63047df --- /dev/null +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp @@ -0,0 +1,112 @@ +// Copyright (C) 2014-201x CEA/DEN, EDF R&D + +// File: PrimitivesPlugin_Sphere.h +// Created: 15 Mar 2017 +// Author: Clarisse Genrault (CEA) + +#include + +#include + +#include +#include +#include +#include +#include + +//================================================================================================= +PrimitivesPlugin_Sphere::PrimitivesPlugin_Sphere() +{ +} + +//================================================================================================= +void PrimitivesPlugin_Sphere::initAttributes() +{ + data()->addAttribute(PrimitivesPlugin_Sphere::CENTER_POINT_ID(), + ModelAPI_AttributeSelection::typeId()); + + data()->addAttribute(PrimitivesPlugin_Sphere::RADIUS_ID(), + ModelAPI_AttributeDouble::typeId()); + + // Initialize the center point of the sphere at the origin if the center point is not filled. + AttributeSelectionPtr aCenterPoint = + data()->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID()); + if (!aCenterPoint->isInitialized()) { + ObjectPtr aPointObj = ModelAPI_Session::get()->moduleDocument() + ->objectByName(ModelAPI_ResultConstruction::group(), "Origin"); + if (aPointObj.get()) { + ResultPtr aPointRes = std::dynamic_pointer_cast(aPointObj); + aCenterPoint->setValue(aPointRes, std::shared_ptr()); + } + } +} + +//================================================================================================= +void PrimitivesPlugin_Sphere::execute() +{ + // Getting point. + std::shared_ptr aCenterPoint; + std::shared_ptr aPointRef = + selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID()); + if (aPointRef.get() != NULL) { + GeomShapePtr aShape1 = aPointRef->value(); + if (!aShape1.get()) { + aShape1 = aPointRef->context()->shape(); + } + if (aShape1) { + aCenterPoint = GeomAlgoAPI_PointBuilder::point(aShape1); + } + } + + // Getting radius + double aRadius = real(PrimitivesPlugin_Sphere::RADIUS_ID())->value(); + + std::shared_ptr aSphereAlgo = + std::shared_ptr(new GeomAlgoAPI_Sphere(aCenterPoint, aRadius)); + + // These checks should be made to the GUI for the feature but + // the corresponding validator does not exist yet. + if (!aSphereAlgo->check()) { + setError(aSphereAlgo->getError()); + return; + } + + // Build the sphere + aSphereAlgo->build(); + + // Check if the creation of the cylinder + if(!aSphereAlgo->isDone()) { + setError(aSphereAlgo->getError()); + return; + } + if(!aSphereAlgo->checkValid("Sphere builder")) { + setError(aSphereAlgo->getError()); + return; + } + + int aResultIndex = 0; + ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex); + loadNamingDS(aSphereAlgo, aResultBox); + setResult(aResultBox, aResultIndex); +} + +//================================================================================================= +void PrimitivesPlugin_Sphere::loadNamingDS(std::shared_ptr theSphereAlgo, + std::shared_ptr theResultSphere) +{ + // Load the result + theResultSphere->store(theSphereAlgo->shape()); + + // Prepare the naming + theSphereAlgo->prepareNamingFaces(); + + // Insert to faces + int num = 1; + std::map< std::string, std::shared_ptr > listOfFaces = + theSphereAlgo->getCreatedFaces(); + for (std::map< std::string, std::shared_ptr >::iterator + it=listOfFaces.begin(); it!=listOfFaces.end(); ++it) { + std::shared_ptr aFace = (*it).second; + theResultSphere->generated(aFace, (*it).first, num++); + } +} diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.h b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.h new file mode 100644 index 000000000..08693f3a5 --- /dev/null +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.h @@ -0,0 +1,67 @@ +// Copyright (C) 2014-201x CEA/DEN, EDF R&D + +// File: PrimitivesPlugin_Sphere.h +// Created: 15 Mar 2017 +// Author: Clarisse Genrault (CEA) + +#ifndef PRIMITIVESPLUGIN_SPHERE_H_ +#define PRIMITIVESPLUGIN_SPHERE_H_ + +#include +#include +#include + +/**\class PrimitivesPlugin_Sphere + * \ingroup Plugins + * \brief Feature for creation of a sphere. + * + * Creates a sphere from a radius and a center point defaulting to the origin + */ +class PrimitivesPlugin_Sphere : public ModelAPI_Feature +{ + public: + /// Sphere kind + inline static const std::string& ID() + { + static const std::string MY_SPHERE_ID("Sphere"); + return MY_SPHERE_ID; + } + + /// Attribute name of the base point + inline static const std::string& CENTER_POINT_ID() + { + static const std::string MY_CENTER_POINT_ID("center_point"); + return MY_CENTER_POINT_ID; + } + + /// Attribute name of the radius + inline static const std::string& RADIUS_ID() + { + static const std::string MY_RADIUS_ID("radius"); + return MY_RADIUS_ID; + } + + /// Returns the kind of a feature + PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = PrimitivesPlugin_Sphere::ID(); + return MY_KIND; + } + + /// Creates a new part document if needed + PRIMITIVESPLUGIN_EXPORT virtual void execute(); + + /// Request for initialization of data model of the feature: adding all attributes + PRIMITIVESPLUGIN_EXPORT virtual void initAttributes(); + + /// Use plugin manager for features creation + PrimitivesPlugin_Sphere(); + + private: + /// Load Naming data structure of the feature to the document + void loadNamingDS(std::shared_ptr theSphereAlgo, + std::shared_ptr theResultSphere); + +}; + +#endif // PRIMITIVESPLUGIN_SPHERE_H_ diff --git a/src/PrimitivesPlugin/icons/sphere.png b/src/PrimitivesPlugin/icons/sphere.png new file mode 100644 index 000000000..000d658ab Binary files /dev/null and b/src/PrimitivesPlugin/icons/sphere.png differ diff --git a/src/PrimitivesPlugin/plugin-Primitives.xml b/src/PrimitivesPlugin/plugin-Primitives.xml index 13e22414a..9880e628b 100644 --- a/src/PrimitivesPlugin/plugin-Primitives.xml +++ b/src/PrimitivesPlugin/plugin-Primitives.xml @@ -13,5 +13,10 @@ + + + + + diff --git a/src/PrimitivesPlugin/sphere_widget.xml b/src/PrimitivesPlugin/sphere_widget.xml new file mode 100644 index 000000000..664f41abe --- /dev/null +++ b/src/PrimitivesPlugin/sphere_widget.xml @@ -0,0 +1,17 @@ + + + + + + + + \ No newline at end of file diff --git a/src/PythonAPI/model/primitives/__init__.py b/src/PythonAPI/model/primitives/__init__.py index 49d9adb32..6f0b8e061 100644 --- a/src/PythonAPI/model/primitives/__init__.py +++ b/src/PythonAPI/model/primitives/__init__.py @@ -1,4 +1,4 @@ """Package for Primitives plugin for the Parametric Geometry API of the Modeler. """ -from PrimitivesAPI import addBox, addCylinder +from PrimitivesAPI import addBox, addCylinder, addSphere