From: cg246364 Date: Fri, 2 Jul 2021 09:55:38 +0000 (+0200) Subject: Add a new method to create a part of sphere with radii and angles. X-Git-Tag: OPERA_v0.5-s990~1^2^2~5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5d3e20edc9f6f2a1fcef0fe2580afb91d380428f;p=modules%2Fshaper.git Add a new method to create a part of sphere with radii and angles. --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp index 21da9cb04..4ba9fd2ad 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp @@ -189,12 +189,12 @@ void GeomAlgoAPI_Box::buildWithPoints() //================================================================================================= void GeomAlgoAPI_Box::buildWithPointAndDims() { - // Construct points from cordinates and dimensions to use the method with two points + // Construct points from cordinates and dimensions to use the method with two points myFirstPoint = std::shared_ptr(new GeomAPI_Pnt(myOx - myDx, myOy - myDy, myOz - myDz)); mySecondPoint = std::shared_ptr(new GeomAPI_Pnt(myOx + myDx, myOy + myDy, myOz + myDz)); - + buildWithPoints(); } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Box.h b/src/GeomAlgoAPI/GeomAlgoAPI_Box.h index 44cdd1c69..888361bdd 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Box.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Box.h @@ -50,7 +50,7 @@ class GeomAlgoAPI_Box : public GeomAlgoAPI_MakeShape /// \param theSecondPoint The other extremity of the diagonal GEOMALGOAPI_EXPORT GeomAlgoAPI_Box(std::shared_ptr theFirstPoint, std::shared_ptr theSecondPoint); - + /// Creates a box using coordinates of a point (the center of gravity) andthe dimensions. /// \param theOx The X coordinate of the point /// \param theOy The Y coordinate of the point diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp index f2b8db42c..73ca13050 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.cpp @@ -17,32 +17,61 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: GeomAlgoAPI_Sphere.h +// File: GeomAlgoAPI_Sphere.cpp // Created: 16 Mar 2017 // Author: Clarisse Genrault (CEA) #include +#include + +#include +#include +#include + +#include #include //================================================================================================= GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere(std::shared_ptr theCenterPoint, const double theRadius) { + isSectionSphere = false; myCenterPoint = theCenterPoint; myRadius = theRadius; } +//================================================================================================= +GeomAlgoAPI_Sphere::GeomAlgoAPI_Sphere(const double theRMin, const double theRMax, + const double thePhiMin, const double thePhiMax, + const double theThetaMin, const double theThetaMax) +{ + isSectionSphere = true; + myRMin = theRMin; + myRMax = theRMax; + myPhiMin = thePhiMin; + myPhiMax = thePhiMax; + myThetaMin = theThetaMin; + myThetaMax = theThetaMax; +} + //================================================================================================= 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; + if (isSectionSphere) { + if ((myRMin-myRMax) > Precision::Confusion()) { + myError = "Sphere builder :: RMin is larger than RMax."; + return false; + } + } else { + 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; } @@ -51,7 +80,17 @@ bool GeomAlgoAPI_Sphere::check() void GeomAlgoAPI_Sphere::build() { myCreatedFaces.clear(); + + if (isSectionSphere) { + buildSectionSphere(); + } else { + buildSphere(); + } +} +//================================================================================================= +void GeomAlgoAPI_Sphere::buildSphere() +{ const gp_Pnt& aCenterPoint = myCenterPoint->impl(); // Construct the sphere @@ -78,3 +117,114 @@ void GeomAlgoAPI_Sphere::build() setDone(true); } + +//================================================================================================= +void GeomAlgoAPI_Sphere::buildSectionSphere() +{ + myCreatedFaces.clear(); + + const double aStartPhiRad = myPhiMin * M_PI / 180.; + BRepBuilderAPI_MakeWire aWireBuilder; + + gp_Pnt anOrigin(0., 0., 0.); + gp_Dir aNormal(-sin(aStartPhiRad), cos(aStartPhiRad), 0.); + + //The section is defined by 4 points and up to 4 wires. In the rmin = 0 case, two of the points will actually be the origin + double aX = myRMax*sin(myThetaMin * M_PI/180.); + double aZ = myRMax*cos(myThetaMin * M_PI/180.); + gp_Pnt aTopOuterStart(aX*cos(aStartPhiRad), aX*sin(aStartPhiRad), aZ); + + aX = myRMax*sin((myThetaMin+myThetaMax) * M_PI/180.); + aZ = myRMax*cos((myThetaMin+myThetaMax) * M_PI/180.); + gp_Pnt aBaseOuterEnd(aX*cos(aStartPhiRad), aX*sin(aStartPhiRad), aZ); + + aX = myRMin*sin(myThetaMin * M_PI/180.); + aZ = myRMin*cos(myThetaMin * M_PI/180.); + gp_Pnt aTopInnerStart(aX*cos(aStartPhiRad), aX*sin(aStartPhiRad), aZ); + + aX = myRMin*sin((myThetaMin+myThetaMax) * M_PI/180.); + aZ = myRMin*cos((myThetaMin+myThetaMax) * M_PI/180.); + gp_Pnt aBaseInnerEnd(aX*cos(aStartPhiRad), aX*sin(aStartPhiRad), aZ); + + // There will always be the rmax arc since rmax can't be zero + gp_Circ anOuterCircle(gp_Ax2(anOrigin, aNormal), myRMax); + BRepBuilderAPI_MakeEdge anArcOuterBuilder; + if (aTopOuterStart.IsEqual(aBaseOuterEnd, Precision::Confusion())) + anArcOuterBuilder = BRepBuilderAPI_MakeEdge(anOuterCircle); + else + anArcOuterBuilder = BRepBuilderAPI_MakeEdge(anOuterCircle, aTopOuterStart, aBaseOuterEnd); + anArcOuterBuilder.Build(); + + //Two cases : either we need four edges (one being an arc with curvature radius rmin) or we need three (if rmin=0). + // In the later case the top and bottom edges intersect at the origin + // Add the edges to the wire in consecutive order (very important for the face to make sense topologically) + if(myRMin >= Precision::Confusion()){ + gp_Circ anInnerCircle(gp_Ax2(anOrigin, aNormal), myRMin); + BRepBuilderAPI_MakeEdge anArcInnerBuilder; + if (aTopInnerStart.IsEqual(aBaseInnerEnd, Precision::Confusion())) + anArcInnerBuilder = BRepBuilderAPI_MakeEdge(anInnerCircle); + else + anArcInnerBuilder = BRepBuilderAPI_MakeEdge(anInnerCircle, aTopInnerStart, aBaseInnerEnd); + anArcInnerBuilder.Build(); + + BRepBuilderAPI_MakeEdge anEdgeStartBuilder(aTopInnerStart, aTopOuterStart); + anEdgeStartBuilder.Build(); + BRepBuilderAPI_MakeEdge anEdgeEndBuilder(aBaseInnerEnd, aBaseOuterEnd); + anEdgeEndBuilder.Build(); + + aWireBuilder.Add(anEdgeStartBuilder.Edge()); + aWireBuilder.Add(anArcOuterBuilder.Edge()); + aWireBuilder.Add(anEdgeEndBuilder.Edge()); + aWireBuilder.Add(anArcInnerBuilder.Edge()); + } else { + BRepBuilderAPI_MakeEdge anEdgeStartBuilder(anOrigin, aTopOuterStart); + anEdgeStartBuilder.Build(); + BRepBuilderAPI_MakeEdge anEdgeEndBuilder(anOrigin, aBaseOuterEnd); + anEdgeEndBuilder.Build(); + + aWireBuilder.Add(anArcOuterBuilder.Edge()); + aWireBuilder.Add(anEdgeStartBuilder.Edge()); + aWireBuilder.Add(anEdgeEndBuilder.Edge()); + } + + // Make a face from the wire + aWireBuilder.Build(); + BRepBuilderAPI_MakeFace aFaceBuilder(aWireBuilder.Wire()); + aFaceBuilder.Build(); + + if (!aFaceBuilder.IsDone()){ + myError = "Sphere builder :: section is not valid"; + return; + } + + // Mathematical tool objects needed by the revolution builder + gp_Dir aZDir(0., 0., 1.); + gp_Ax1 aZAxis(anOrigin, aZDir); + + // Build the solid using the section face we've created and a revolution builder + BRepPrimAPI_MakeRevol* aRevolBuilder = new BRepPrimAPI_MakeRevol(aFaceBuilder.Face(), aZAxis, myPhiMax * M_PI / 180., Standard_True); + if(!aRevolBuilder) { + return; + myError = "Sphere builder :: section revolution did not succeed"; + } + if(!aRevolBuilder->IsDone()) { + myError = "Sphere builder :: section revolution did not succeed"; + return; + } + + // Get the shape, verify it, build a GeomAPI_Shape. + std::shared_ptr aResultShape = std::shared_ptr(new GeomAPI_Shape()) ; + aResultShape->setImpl(new TopoDS_Shape(aRevolBuilder->Shape())); + setShape(aResultShape); + + // Test on the shapes + if (!(aResultShape).get() || aResultShape->isNull()) { + myError = "Sphere builder :: resulting shape is null."; + return; + } + + setImpl(aRevolBuilder); + setBuilderType(OCCT_BRepBuilderAPI_MakeShape); + + setDone(true); +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.h b/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.h index 8fb449948..0966b5aef 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Sphere.h @@ -40,6 +40,16 @@ class GeomAlgoAPI_Sphere : public GeomAlgoAPI_MakeShape /// \param theRadius The radius of the sphere GEOMALGOAPI_EXPORT GeomAlgoAPI_Sphere(std::shared_ptr theCenterPoint, const double theRadius); + /// Creates a sphere. + /// \param theRMin The inner radius of the sphere + /// \param theRMax The outer radius of the sphere + /// \param thePhiMin The lower phi limit + /// \param thePhiMax The higher phi limit + /// \param theThetaMin The lower theta limit + /// \param theThetaMax The higher theta limit + GEOMALGOAPI_EXPORT GeomAlgoAPI_Sphere(const double theRMin, const double theRMax, + const double thePhiMin, const double thePhiMax, + const double theThetaMin, const double theThetaMax); /// Checks if data for the sphere construction is OK. GEOMALGOAPI_EXPORT bool check(); @@ -47,9 +57,19 @@ class GeomAlgoAPI_Sphere : public GeomAlgoAPI_MakeShape /// Builds the sphere. GEOMALGOAPI_EXPORT void build(); + /// Builds the sphere. + GEOMALGOAPI_EXPORT void buildSphere(); + + /// Builds the section of sphere. + GEOMALGOAPI_EXPORT void buildSectionSphere(); + private: - std::shared_ptr myCenterPoint; /// Center of the sphere. - double myRadius; + bool isSectionSphere; // Boolean to define if the second mode is used. + std::shared_ptr myCenterPoint; /// Center of the sphere for the first mode. + double myRadius; /// Radius of the sphere for the first mode. + double myRMin, myRMax; /// Inner and outer radius for the second mode. + double myPhiMin, myPhiMax; /// Lower and higher phi limit for the second mode. + double myThetaMin, myThetaMax; /// Lower and higher theta limit for the second mode. }; #endif // GEOMALGOAPI_SPHERE_H_ diff --git a/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp index 4b3b594ad..20e9cbd1c 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp +++ b/src/PrimitivesAPI/PrimitivesAPI_Sphere.cpp @@ -41,11 +41,34 @@ PrimitivesAPI_Sphere::PrimitivesAPI_Sphere(const std::shared_ptr& theFeature, + const ModelHighAPI_Double& theRMin, + const ModelHighAPI_Double& theRMax, + const ModelHighAPI_Double& thePhiMin, + const ModelHighAPI_Double& thePhiMax, + const ModelHighAPI_Double& theThetaMin, + const ModelHighAPI_Double& theThetaMax) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) { + fillAttribute(PrimitivesPlugin_Sphere::CREATION_METHOD_BY_DIMENSIONS(), creationMethod()); + fillAttribute(theRMin, rmin()); + fillAttribute(theRMax, rmax()); + fillAttribute(thePhiMin, phimin()); + fillAttribute(thePhiMax, phimax()); + fillAttribute(theThetaMin, thetamin()); + fillAttribute(theThetaMax, thetamax()); + execute(); + } +} + //================================================================================================== PrimitivesAPI_Sphere::~PrimitivesAPI_Sphere() { @@ -65,6 +88,33 @@ void PrimitivesAPI_Sphere::setRadius(const ModelHighAPI_Double& theRadius) execute(); } +//================================================================================================== +void PrimitivesAPI_Sphere::setRadius(const ModelHighAPI_Double& theRMin, + const ModelHighAPI_Double& theRMax) +{ + fillAttribute(theRMin, rmin()); + fillAttribute(theRMax, rmax()); + execute(); +} + +//================================================================================================== +void PrimitivesAPI_Sphere::setPhi(const ModelHighAPI_Double& thePhiMin, + const ModelHighAPI_Double& thePhiMax) +{ + fillAttribute(thePhiMin, phimin()); + fillAttribute(thePhiMax, phimax()); + execute(); +} + +//================================================================================================== +void PrimitivesAPI_Sphere::setTheta(const ModelHighAPI_Double& theThetaMin, + const ModelHighAPI_Double& theThetaMax) +{ + fillAttribute(theThetaMin, thetamin()); + fillAttribute(theThetaMax, thetamax()); + execute(); +} + //================================================================================================== void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const { @@ -73,10 +123,24 @@ void PrimitivesAPI_Sphere::dump(ModelHighAPI_Dumper& theDumper) const 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; + std::string aCreationMethod = aBase->string(PrimitivesPlugin_Sphere::CREATION_METHOD())->value(); + + if(aCreationMethod == PrimitivesPlugin_Sphere::CREATION_METHOD_BY_PT_RADIUS()) { + AttributeSelectionPtr anAttrCenterPoint = + aBase->selection(PrimitivesPlugin_Sphere::CENTER_POINT_ID()); + AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Sphere::RADIUS_ID()); + theDumper << ", " << anAttrCenterPoint << ", " << anAttrRadius; + } else if(aCreationMethod == PrimitivesPlugin_Sphere::CREATION_METHOD_BY_DIMENSIONS()) { + AttributeDoublePtr anAttrRMin = aBase->real(PrimitivesPlugin_Sphere::RMIN_ID()); + AttributeDoublePtr anAttrRMax = aBase->real(PrimitivesPlugin_Sphere::RMAX_ID()); + AttributeDoublePtr anAttrPhiMin = aBase->real(PrimitivesPlugin_Sphere::PHIMIN_ID()); + AttributeDoublePtr anAttrPhiMax = aBase->real(PrimitivesPlugin_Sphere::PHIMAX_ID()); + AttributeDoublePtr anAttrThetaMin = aBase->real(PrimitivesPlugin_Sphere::THETAMIN_ID()); + AttributeDoublePtr anAttrThetaMax = aBase->real(PrimitivesPlugin_Sphere::THETAMAX_ID()); + theDumper << ", " << anAttrRMin << ", " << anAttrRMax; + theDumper << ", " << anAttrPhiMin << ", " << anAttrPhiMax; + theDumper << ", " << anAttrThetaMin << ", " << anAttrThetaMax; + } theDumper << ")" << std::endl; } @@ -98,3 +162,17 @@ SpherePtr addSphere(const std::shared_ptr& thePart, std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID()); return SpherePtr(new PrimitivesAPI_Sphere(aFeature, aCenterPoint, theRadius)); } + +//================================================================================================== +SpherePtr addSphere(const std::shared_ptr& thePart, + const ModelHighAPI_Double& theRMin, + const ModelHighAPI_Double& theRMax, + const ModelHighAPI_Double& thePhiMin, + const ModelHighAPI_Double& thePhiMax, + const ModelHighAPI_Double& theThetaMin, + const ModelHighAPI_Double& theThetaMax) +{ + std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Sphere::ID()); + return SpherePtr(new PrimitivesAPI_Sphere(aFeature, theRMin, theRMax, thePhiMin, thePhiMax, + theThetaMin, theThetaMax)); +} diff --git a/src/PrimitivesAPI/PrimitivesAPI_Sphere.h b/src/PrimitivesAPI/PrimitivesAPI_Sphere.h index 68e0ca5df..3c4691a46 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_Sphere.h +++ b/src/PrimitivesAPI/PrimitivesAPI_Sphere.h @@ -50,15 +50,39 @@ public: const ModelHighAPI_Selection& theCenterPoint, const ModelHighAPI_Double& theRadius); + /// Constructor with values. + PRIMITIVESAPI_EXPORT + explicit PrimitivesAPI_Sphere(const std::shared_ptr& theFeature, + const ModelHighAPI_Double& theRMin, + const ModelHighAPI_Double& theRMax, + const ModelHighAPI_Double& thePhiMin, + const ModelHighAPI_Double& thePhiMax, + const ModelHighAPI_Double& theThetaMin, + const ModelHighAPI_Double& theThetaMax); + /// Destructor. PRIMITIVESAPI_EXPORT virtual ~PrimitivesAPI_Sphere(); - INTERFACE_2(PrimitivesPlugin_Sphere::ID(), + INTERFACE_9(PrimitivesPlugin_Sphere::ID(), + creationMethod, PrimitivesPlugin_Sphere::CREATION_METHOD(), + ModelAPI_AttributeString, /** Creation method */, centerPoint, PrimitivesPlugin_Sphere::CENTER_POINT_ID(), ModelAPI_AttributeSelection, /** Center point */, radius, PrimitivesPlugin_Sphere::RADIUS_ID(), - ModelAPI_AttributeDouble, /** Radius */) + ModelAPI_AttributeDouble, /** Radius */, + rmin, PrimitivesPlugin_Sphere::RMIN_ID(), + ModelAPI_AttributeDouble, /** The minimum radius*/, + rmax, PrimitivesPlugin_Sphere::RMAX_ID(), + ModelAPI_AttributeDouble, /** The maximum radius*/, + phimin, PrimitivesPlugin_Sphere::PHIMIN_ID(), + ModelAPI_AttributeDouble, /** The minimum phi*/, + phimax, PrimitivesPlugin_Sphere::PHIMAX_ID(), + ModelAPI_AttributeDouble, /** The maximum phi*/, + thetamin, PrimitivesPlugin_Sphere::THETAMIN_ID(), + ModelAPI_AttributeDouble, /** The minimum theta*/, + thetamax,PrimitivesPlugin_Sphere::THETAMAX_ID(), + ModelAPI_AttributeDouble, /** The maximum theta*/) /// Set center point PRIMITIVESAPI_EXPORT @@ -68,6 +92,18 @@ public: PRIMITIVESAPI_EXPORT void setRadius(const ModelHighAPI_Double& theRadius); + /// Set minimum and maximum radius + PRIMITIVESAPI_EXPORT + void setRadius(const ModelHighAPI_Double& theRMin, const ModelHighAPI_Double& theRMax); + + /// Set minimum and maximum phi + PRIMITIVESAPI_EXPORT + void setPhi(const ModelHighAPI_Double& thePhiMin, const ModelHighAPI_Double& thePhiMax); + + /// Set minimum and maximum theta + PRIMITIVESAPI_EXPORT + void setTheta(const ModelHighAPI_Double& theThetaMin, const ModelHighAPI_Double& theThetaMax); + /// Dump wrapped feature PRIMITIVESAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const; @@ -89,4 +125,15 @@ PRIMITIVESAPI_EXPORT SpherePtr addSphere(const std::shared_ptr& thePart, const ModelHighAPI_Double& theRadius); +/// \ingroup CPPHighAPI +/// \brief Create primitive Sphere feature. +PRIMITIVESAPI_EXPORT +SpherePtr addSphere(const std::shared_ptr& thePart, + const ModelHighAPI_Double& theRMin, + const ModelHighAPI_Double& theRMax, + const ModelHighAPI_Double& thePhiMin, + const ModelHighAPI_Double& thePhiMax, + const ModelHighAPI_Double& theThetaMin, + const ModelHighAPI_Double& theThetaMax); + #endif // PRIMITIVESAPI_SPHERE_H_ diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp index c9606b717..feea6763d 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp @@ -71,7 +71,7 @@ void PrimitivesPlugin_Box::execute() if (aMethodType == CREATION_METHOD_BY_TWO_POINTS()) createBoxByTwoPoints(); - + if (aMethodType == CREATION_METHOD_BY_ONE_POINT_AND_DIMS()) createBoxByOnePointAndDims(); } @@ -168,7 +168,7 @@ void PrimitivesPlugin_Box::createBoxByOnePointAndDims() double aDx = real(PrimitivesPlugin_Box::HALF_DX_ID())->value(); double aDy = real(PrimitivesPlugin_Box::HALF_DY_ID())->value(); double aDz = real(PrimitivesPlugin_Box::HALF_DZ_ID())->value(); - + // Getting point coordinates double x = real(PrimitivesPlugin_Box::OX_ID())->value(); double y = real(PrimitivesPlugin_Box::OY_ID())->value(); @@ -176,7 +176,7 @@ void PrimitivesPlugin_Box::createBoxByOnePointAndDims() std::shared_ptr aBoxAlgo; aBoxAlgo = std::shared_ptr(new GeomAlgoAPI_Box(x,y,z,aDx,aDy,aDz)); - + // These checks should be made to the GUI for the feature but // the corresponding validator does not exist yet. if (!aBoxAlgo->check()) { diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Box.h b/src/PrimitivesPlugin/PrimitivesPlugin_Box.h index 0f3bc7f0f..6d2b64095 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Box.h +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Box.h @@ -31,7 +31,7 @@ class ModelAPI_ResultBody; * \ingroup Plugins * \brief Feature for creation of a box primitive using various methods. * - * Box creates a cuboid - Parallelepiped with 6 rectangular faces. It can be built via two + * Box creates a cuboid - Parallelepiped with 6 rectangular faces. It can be built via three * methods : using two points that define a diagonal, a point that define a center and 3 lengths * that define the half-lengths on X, Y and Z-axes, or using 3 lengths that define the * rectangular dimensions. @@ -108,7 +108,7 @@ class PrimitivesPlugin_Box : public ModelAPI_Feature static const std::string MY_DZ_ID("dz"); return MY_DZ_ID; } - + /// Attribute name of the first coordinate of the center inline static const std::string& OX_ID() { @@ -129,7 +129,7 @@ class PrimitivesPlugin_Box : public ModelAPI_Feature static const std::string MY_OZ_ID("oz"); return MY_OZ_ID; } - + /// Attribute name of the half-length on X axis inline static const std::string& HALF_DX_ID() { @@ -178,7 +178,7 @@ class PrimitivesPlugin_Box : public ModelAPI_Feature ///Perform the creation of the box using three cordinates void createBoxByDimensions(); - ///Perform the creation of the box using a center and three half-lenths + ///Perform the creation of the box using a center and three half-lenths void createBoxByOnePointAndDims(); }; diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp index 00ca224b0..26ed6511d 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.cpp @@ -17,7 +17,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// File: PrimitivesPlugin_Sphere.h +// File: PrimitivesPlugin_Sphere.cpp // Created: 15 Mar 2017 // Author: Clarisse Genrault (CEA) @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -43,6 +44,9 @@ PrimitivesPlugin_Sphere::PrimitivesPlugin_Sphere() //================================================================================================= void PrimitivesPlugin_Sphere::initAttributes() { + data()->addAttribute(PrimitivesPlugin_Sphere::CREATION_METHOD(), ModelAPI_AttributeString::typeId()); + + // data for the first mode : by a point and a radius data()->addAttribute(PrimitivesPlugin_Sphere::CENTER_POINT_ID(), ModelAPI_AttributeSelection::typeId()); @@ -60,10 +64,32 @@ void PrimitivesPlugin_Sphere::initAttributes() aCenterPoint->setValue(aPointRes, std::shared_ptr()); } } + + // data for the second mode : by dimensions + data()->addAttribute(PrimitivesPlugin_Sphere::RMIN_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Sphere::RMAX_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Sphere::PHIMIN_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Sphere::PHIMAX_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Sphere::THETAMIN_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Sphere::THETAMAX_ID(), ModelAPI_AttributeDouble::typeId()); } //================================================================================================= void PrimitivesPlugin_Sphere::execute() +{ + AttributeStringPtr aMethodTypeAttr = string(PrimitivesPlugin_Sphere::CREATION_METHOD()); + std::string aMethodType = aMethodTypeAttr->value(); + + if (aMethodType == CREATION_METHOD_BY_PT_RADIUS()) + createSphereByPtRadius(); + + if (aMethodType == CREATION_METHOD_BY_DIMENSIONS()) + createShereByDimensions(); +} + + +//================================================================================================= +void PrimitivesPlugin_Sphere::createSphereByPtRadius() { // Getting point. std::shared_ptr aCenterPoint; @@ -95,7 +121,7 @@ void PrimitivesPlugin_Sphere::execute() // Build the sphere aSphereAlgo->build(); - // Check if the creation of the cylinder + // Check if the creation of the sphere is OK if(!aSphereAlgo->isDone()) { setError(aSphereAlgo->getError()); return; @@ -111,6 +137,48 @@ void PrimitivesPlugin_Sphere::execute() setResult(aResultBox, aResultIndex); } +//================================================================================================= +void PrimitivesPlugin_Sphere::createShereByDimensions() +{ + // Getting rmin, rmax, phimin, phimax, thetamin et thetamax + double aRMin = real(PrimitivesPlugin_Sphere::RMIN_ID())->value(); + double aRMax = real(PrimitivesPlugin_Sphere::RMAX_ID())->value(); + double aPhiMin = real(PrimitivesPlugin_Sphere::PHIMIN_ID())->value(); + double aPhiMax = real(PrimitivesPlugin_Sphere::PHIMAX_ID())->value(); + double aThetaMin = real(PrimitivesPlugin_Sphere::THETAMIN_ID())->value(); + double aThetaMax = real(PrimitivesPlugin_Sphere::THETAMAX_ID())->value(); + + std::shared_ptr aSphereAlgo = std::shared_ptr( + new GeomAlgoAPI_Sphere(aRMin, aRMax, aPhiMin, aPhiMax, aThetaMin, aThetaMax)); + + // 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 sphere is OK + if(!aSphereAlgo->isDone()) { + // The error is not displayed in a popup window. It must be in the message console. + setError(aSphereAlgo->getError()); + return; + } + if(!aSphereAlgo->checkValid("Sphere Builder")) { + // The error is not displayed in a popup window. It must be in the message console. + 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) diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.h b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.h index 2f00e989e..348c1287c 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.h +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Sphere.h @@ -30,9 +30,10 @@ /**\class PrimitivesPlugin_Sphere * \ingroup Plugins - * \brief Feature for creation of a sphere. + * \brief Feature for creation of a sphere primitive using various methods. * - * Creates a sphere from a radius and a center point defaulting to the origin + * It can be built via two methods : using a radius and a center point defaulting to the origin, + * or radii (inner and outer) and angle limits (theta and phi). */ class PrimitivesPlugin_Sphere : public ModelAPI_Feature { @@ -44,6 +45,27 @@ class PrimitivesPlugin_Sphere : public ModelAPI_Feature return MY_SPHERE_ID; } + /// Attribute name for creation method + inline static const std::string& CREATION_METHOD() + { + static const std::string MY_CREATION_METHOD_ID("CreationMethod"); + return MY_CREATION_METHOD_ID; + } + + /// Attribute name for creation method + inline static const std::string& CREATION_METHOD_BY_PT_RADIUS() + { + static const std::string MY_CREATION_METHOD_ID("SphereByPointRadius"); + return MY_CREATION_METHOD_ID; + } + + /// Attribute name for creation method + inline static const std::string& CREATION_METHOD_BY_DIMENSIONS() + { + static const std::string MY_CREATION_METHOD_ID("SphereByDimensions"); + return MY_CREATION_METHOD_ID; + } + /// Attribute name of the base point inline static const std::string& CENTER_POINT_ID() { @@ -57,6 +79,48 @@ class PrimitivesPlugin_Sphere : public ModelAPI_Feature static const std::string MY_RADIUS_ID("radius"); return MY_RADIUS_ID; } + + /// attribute name of the inner radius + inline static const std::string& RMIN_ID() + { + static const std::string MY_RMIN_ID("rmin"); + return MY_RMIN_ID; + } + + /// attribute name of the outer radius + inline static const std::string& RMAX_ID() + { + static const std::string MY_RMAX_ID("rmax"); + return MY_RMAX_ID; + } + + /// attribute name of the lower phi limit + inline static const std::string& PHIMIN_ID() + { + static const std::string MY_PHIMIN_ID("phimin"); + return MY_PHIMIN_ID; + } + + /// attribute name of the higher phi limit + inline static const std::string& PHIMAX_ID() + { + static const std::string MY_PHIMAX_ID("phimax"); + return MY_PHIMAX_ID; + } + + /// attribute name of the lower theta limit + inline static const std::string& THETAMIN_ID() + { + static const std::string MY_THETAMIN_ID("thetamin"); + return MY_THETAMIN_ID; + } + + /// attribute name of the higher theta limit + inline static const std::string& THETAMAX_ID() + { + static const std::string MY_THETAMAX_ID("thetamax"); + return MY_THETAMAX_ID; + } /// Returns the kind of a feature PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind() @@ -78,6 +142,12 @@ class PrimitivesPlugin_Sphere : public ModelAPI_Feature /// Load Naming data structure of the feature to the document void loadNamingDS(std::shared_ptr theSphereAlgo, std::shared_ptr theResultSphere); + + /// Perform the creation of the sphere using a point and a radius + void createSphereByPtRadius(); + + /// Perform the creation of the sphere using radii (inner and outer) and angle limits (theta and phi) + void createShereByDimensions(); }; diff --git a/src/PrimitivesPlugin/doc/TUI_sphereFeature.rst b/src/PrimitivesPlugin/doc/TUI_sphereFeature.rst index f4012bcce..31aee5680 100644 --- a/src/PrimitivesPlugin/doc/TUI_sphereFeature.rst +++ b/src/PrimitivesPlugin/doc/TUI_sphereFeature.rst @@ -1,12 +1,11 @@ .. _tui_create_sphere: -Create / Sphere -=============== +Create sphere +============= -.. literalinclude:: examples/sphere.py +.. literalinclude:: examples/sphere1.py :linenos: :language: python -:download:`Download this script ` - +:download:`Download this script ` diff --git a/src/PrimitivesPlugin/doc/TUI_spherePart.rst b/src/PrimitivesPlugin/doc/TUI_spherePart.rst new file mode 100644 index 000000000..c38cbe40f --- /dev/null +++ b/src/PrimitivesPlugin/doc/TUI_spherePart.rst @@ -0,0 +1,11 @@ + + .. _tui_create_part_sphere: + +Create part ofsphere +==================== + +.. literalinclude:: examples/sphere2.py + :linenos: + :language: python + +:download:`Download this script ` diff --git a/src/PrimitivesPlugin/doc/boxFeature.rst b/src/PrimitivesPlugin/doc/boxFeature.rst index 1171514af..e91466c20 100644 --- a/src/PrimitivesPlugin/doc/boxFeature.rst +++ b/src/PrimitivesPlugin/doc/boxFeature.rst @@ -1,16 +1,14 @@ -.. _box_feature: +.. |Box_button.icon| image:: images/Box_button.png Box === -.. |box.icon| image:: images/box.png - Box feature creates a box solid. To create a Box in the active part: #. select in the Main Menu *Primitives - > Box* item or -#. click |box.icon| **Box** button in the toolbar: +#. click |Box_button.icon| **Box** button in the toolbar: There are 3 algorithms for creation of a Box: diff --git a/src/PrimitivesPlugin/doc/examples/sphere.py b/src/PrimitivesPlugin/doc/examples/sphere.py deleted file mode 100644 index 05320ce31..000000000 --- a/src/PrimitivesPlugin/doc/examples/sphere.py +++ /dev/null @@ -1,9 +0,0 @@ -from salome.shaper import model - -model.begin() -partSet = model.moduleDocument() -Part_1 = model.addPart(partSet) -Part_1_doc = Part_1.document() -Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10) -model.do() -model.end() diff --git a/src/PrimitivesPlugin/doc/examples/sphere1.py b/src/PrimitivesPlugin/doc/examples/sphere1.py new file mode 100644 index 000000000..05320ce31 --- /dev/null +++ b/src/PrimitivesPlugin/doc/examples/sphere1.py @@ -0,0 +1,9 @@ +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sphere_1 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin"), 10) +model.do() +model.end() diff --git a/src/PrimitivesPlugin/doc/examples/sphere2.py b/src/PrimitivesPlugin/doc/examples/sphere2.py new file mode 100644 index 000000000..81f469ea2 --- /dev/null +++ b/src/PrimitivesPlugin/doc/examples/sphere2.py @@ -0,0 +1,9 @@ +from salome.shaper import model + +model.begin() +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Sphere_1 = model.addSphere(Part_1_doc,5,10,180,245,0,90) +model.do() +model.end() diff --git a/src/PrimitivesPlugin/doc/images/Sphere1.png b/src/PrimitivesPlugin/doc/images/Sphere1.png new file mode 100644 index 000000000..87214a713 Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Sphere1.png differ diff --git a/src/PrimitivesPlugin/doc/images/Sphere2.png b/src/PrimitivesPlugin/doc/images/Sphere2.png new file mode 100644 index 000000000..b2ad67a62 Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Sphere2.png differ diff --git a/src/PrimitivesPlugin/doc/images/Sphere_button.png b/src/PrimitivesPlugin/doc/images/Sphere_button.png index fb13d34b0..000d658ab 100644 Binary files a/src/PrimitivesPlugin/doc/images/Sphere_button.png and b/src/PrimitivesPlugin/doc/images/Sphere_button.png differ diff --git a/src/PrimitivesPlugin/doc/images/Sphere_full.png b/src/PrimitivesPlugin/doc/images/Sphere_full.png new file mode 100644 index 000000000..4b5351b9d Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Sphere_full.png differ diff --git a/src/PrimitivesPlugin/doc/images/Sphere_part.png b/src/PrimitivesPlugin/doc/images/Sphere_part.png new file mode 100644 index 000000000..15007d69d Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Sphere_part.png differ diff --git a/src/PrimitivesPlugin/doc/images/box.png b/src/PrimitivesPlugin/doc/images/box.png deleted file mode 100644 index 2b0757b05..000000000 Binary files a/src/PrimitivesPlugin/doc/images/box.png and /dev/null differ diff --git a/src/PrimitivesPlugin/doc/images/sphere_32x32.png b/src/PrimitivesPlugin/doc/images/sphere_32x32.png new file mode 100644 index 000000000..484c384e8 Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/sphere_32x32.png differ diff --git a/src/PrimitivesPlugin/doc/images/sphere_part_32x32.png b/src/PrimitivesPlugin/doc/images/sphere_part_32x32.png new file mode 100644 index 000000000..ce9c5856b Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/sphere_part_32x32.png differ diff --git a/src/PrimitivesPlugin/doc/sphereFeature.rst b/src/PrimitivesPlugin/doc/sphereFeature.rst index 71688a999..ade524999 100644 --- a/src/PrimitivesPlugin/doc/sphereFeature.rst +++ b/src/PrimitivesPlugin/doc/sphereFeature.rst @@ -3,29 +3,46 @@ Sphere ====== -Sphere feature creates a sphere solid. +Sphere feature creates a sphere solid or a part of a sphere solid. To create a Sphere in the active part: #. select in the Main Menu *Primitives - > Sphere* item or #. click |Sphere_button.icon| **Sphere** button in the toolbar -The following property panel appears. +There are 2 algorithms for creation of a Sphere -.. figure:: images/Sphere.png +.. figure:: images/sphere_32x32.png + :align: left + :height: 24px + +**By a center and a radius** + +.. figure:: images/sphere_part_32x32.png + :align: left + :height: 24px + +**By radii (inner and outer) and angle limits (theta and phi)** + +-------------------------------------------------------------------------------- + +By a center and a radius +------------------------ + +Sphere is created by a center (origin by default) and a radius. + +.. figure:: images/Sphere_full.png :align: center - Sphere property panel - Input fields: - **Point** defines the center of the sphere selected in 3D OCC viewer or object browser; - **Radius** defines the radius. - + **TUI Command**: .. py:function:: model.addSphere(Part_doc, Point, Radius) - + :param part: The current part object. :param object: Vertex. :param real: Radius. @@ -34,11 +51,52 @@ Input fields: Result """""" -An example is shown below. +A solid sphere based on the origin and a radius. -.. figure:: images/Sphere_res.png +.. figure:: images/Sphere1.png :align: center - - Sphere created -**See Also** a sample TUI Script of :ref:`tui_create_sphere` operation. +**See Also** a sample TUI Script of a :ref:`tui_create_sphere` operation. + +By radii (inner and outer) and angle limits (theta and phi) +----------------------------------------------------------- + +Part of sphere is created by radii (inner and outer) and angle limits (phi and theta). + +.. figure:: images/Sphere_part.png + :align: center + +Input fields: + +- **RMin** defines the inner radius; +- **RMax** defines the outer radius; +- **PhiMin** defines the lower phi limit; +- **PhiMax** defines the higher phi limit; +- **ThetaMin** defines the lower theta limit; +- **ThetaMax** defines the higher theta limit. + +**TUI Command**: + +.. py:function:: model.addSphere(Part_doc, RMin, RMax, PhiMin, PhiMax, ThetaMin, ThetaMax) + + :param part: The current part object. + :param real: Inner radius. + :param real: Outer radius. + :param real: Lower phi. + :param real: Hiher phi. + :param real: Lower theta. + :param real: Hiher theta. + :return: Result object. + +Result +"""""" + +A solid sphere based on the origin with radii (inner and outer) and angles (phi and theta). + +.. figure:: images/Sphere2.png + :align: center + +**See Also** a sample TUI Script of a :ref:`tui_create_part_sphere` operation. + + + diff --git a/src/PrimitivesPlugin/icons/sphere_32x32.png b/src/PrimitivesPlugin/icons/sphere_32x32.png new file mode 100644 index 000000000..484c384e8 Binary files /dev/null and b/src/PrimitivesPlugin/icons/sphere_32x32.png differ diff --git a/src/PrimitivesPlugin/icons/sphere_part_32x32.png b/src/PrimitivesPlugin/icons/sphere_part_32x32.png new file mode 100644 index 000000000..ce9c5856b Binary files /dev/null and b/src/PrimitivesPlugin/icons/sphere_part_32x32.png differ diff --git a/src/PrimitivesPlugin/sphere_widget.xml b/src/PrimitivesPlugin/sphere_widget.xml index d2f29ce1e..389d8c5bc 100644 --- a/src/PrimitivesPlugin/sphere_widget.xml +++ b/src/PrimitivesPlugin/sphere_widget.xml @@ -1,15 +1,65 @@ - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + diff --git a/test.API/SHAPER/Primitives/TestAPI_Box.py b/test.API/SHAPER/Primitives/TestAPI_Box.py index f4711ed19..856192817 100644 --- a/test.API/SHAPER/Primitives/TestAPI_Box.py +++ b/test.API/SHAPER/Primitives/TestAPI_Box.py @@ -62,32 +62,32 @@ Box_8 = shaperpy.makeBox(pnt1,pnt2) try : Box_9 = shaperpy.makeBox(pnt1,pnt1) except myExcept as ec: - assert(ec.what() == "Box builder with points :: the distance between the two points is null.") + assert(ec.what() == "Box builder with two points :: the distance between the two points is null.") try : pnt3 = pnt(0.,50.,50.) Box_10 = shaperpy.makeBox(pnt1,pnt3) except myExcept as ec: - assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") + assert(ec.what() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.") try : pnt4 = pnt(50.,0.,50.) Box_11 = shaperpy.makeBox(pnt1,pnt4) except myExcept as ec: - assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") + assert(ec.what() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.") try : pnt5 = pnt(50.,50.,0.) Box_12 = shaperpy.makeBox(pnt1,pnt5) except myExcept as ec: - assert(ec.what() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") + assert(ec.what() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.") try : Box_13 = shaperpy.makeBox(None, pnt2) except myExcept as ec: - assert(ec.what() == "Box builder with points :: the first point is not valid.") + assert(ec.what() == "Box builder with two points :: the first point is not valid.") try : Box_14 = shaperpy.makeBox(pnt2, None) except myExcept as ec: - assert(ec.what() == "Box builder with points :: the second point is not valid.") \ No newline at end of file + assert(ec.what() == "Box builder with two points :: the second point is not valid.") diff --git a/test.API/SHAPER/Primitives/TestBox.py b/test.API/SHAPER/Primitives/TestBox.py index 7d228addc..c3c58a2fe 100644 --- a/test.API/SHAPER/Primitives/TestBox.py +++ b/test.API/SHAPER/Primitives/TestBox.py @@ -84,6 +84,7 @@ Box_15 = model.addBox(Part_1_doc, model.selection("VERTEX", "Sketch_1/SketchLine Box_16 = model.addBox(Part_1_doc, model.selection("VERTEX", "[Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_3][Extrusion_1_1/Generated_Face&Sketch_1/SketchLine_4][Extrusion_1_1/To_Face]"), model.selection("VERTEX", "[Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_6][Extrusion_2_1/Generated_Face&Sketch_2/SketchLine_7][Extrusion_2_1/To_Face]")) Box_17 = model.addBox(Part_1_doc, model.selection("VERTEX", "Vertex_1_1"), model.selection("VERTEX", "Vertex_2_1")) Box_18 = model.addBox(Part_1_doc, "dx", "dy", "dz") +Box_19 = model.addBox(Part_1_doc, 0, 0, 0, 20, 20 ,20) model.do() model.end() @@ -126,6 +127,12 @@ model.testNbSubShapes(Box_18, GeomAPI_Shape.SOLID, [1]) model.testNbSubShapes(Box_18, GeomAPI_Shape.FACE, [6]) model.testHaveNamingFaces(Box_18, model, Part_1_doc) +model.testNbResults(Box_19, 1) +model.testNbSubResults(Box_19, [0]) +model.testNbSubShapes(Box_19, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Box_19, GeomAPI_Shape.FACE, [6]) +model.testHaveNamingFaces(Box_19, model, Part_1_doc) + model.testNbResults(Box_2, 0) assert(Box_2.feature().error() == "Box builder with dimensions :: Dx is null or negative.") @@ -145,16 +152,16 @@ model.testNbResults(Box_7, 0) assert(Box_7.feature().error() == "Box builder with dimensions :: Dz is null or negative.") model.testNbResults(Box_9, 0) -assert(Box_9.feature().error() == "Box builder with points :: the distance between the two points is null.") +assert(Box_9.feature().error() == "Box builder with two points :: the distance between the two points is null.") model.testNbResults(Box_10, 0) -assert(Box_10.feature().error() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") +assert(Box_10.feature().error() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.") model.testNbResults(Box_11, 0) -assert(Box_11.feature().error() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") +assert(Box_11.feature().error() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.") model.testNbResults(Box_12, 0) -assert(Box_12.feature().error() == "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes.") +assert(Box_12.feature().error() == "Box builder with two points :: the points belong both to one of the OXY, OYZ or OZX planes.") model.testNbResults(Box_13, 0) assert(Box_13.feature().error() == "Attribute \"FirstPoint\" is not initialized.") diff --git a/test.API/SHAPER/Primitives/TestSphere.py b/test.API/SHAPER/Primitives/TestSphere.py index 33782eadb..36a820856 100644 --- a/test.API/SHAPER/Primitives/TestSphere.py +++ b/test.API/SHAPER/Primitives/TestSphere.py @@ -41,6 +41,9 @@ Sphere_6 = model.addSphere(Part_1_doc, model.selection("VERTEX", "PartSet/Origin Sphere_7 = model.addSphere(Part_1_doc, 10) Sphere_7.setCenterPoint(Point_1) +Sphere_8 = model.addSphere(Part_1_doc,10,40,0,180,0,180) +Sphere_9 = model.addSphere(Part_1_doc,40,10,0,180,0,180) + model.do() model.end() @@ -71,6 +74,12 @@ model.testNbSubShapes(Sphere_7, GeomAPI_Shape.SOLID, [1]) model.testNbSubShapes(Sphere_7, GeomAPI_Shape.FACE, [1]) model.testHaveNamingFaces(Sphere_7, model, Part_1_doc) +model.testNbResults(Sphere_8, 1) +model.testNbSubResults(Sphere_8, [0]) +model.testNbSubShapes(Sphere_8, GeomAPI_Shape.SOLID, [1]) +model.testNbSubShapes(Sphere_8, GeomAPI_Shape.FACE, [4]) +model.testHaveNamingFaces(Sphere_8, model, Part_1_doc) + model.testNbResults(Sphere_2, 0) assert(Sphere_2.feature().error() == "Sphere builder :: radius is negative or null.") @@ -79,3 +88,6 @@ assert(Sphere_3.feature().error() == "Sphere builder :: radius is negative or nu model.testNbResults(Sphere_5, 0) assert(Sphere_5.feature().error() == "Attribute \"center_point\" is not initialized.") + +model.testNbResults(Sphere_9, 0) +assert(Sphere_9.feature().error() == "Sphere builder :: RMin is larger than RMax.")