From: cg246364 Date: Wed, 16 Jun 2021 13:14:48 +0000 (+0200) Subject: Add a new method to create a box with a center and three half-lengths X-Git-Tag: OPERA_v0.5-s990~1^2^2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8b70f46fd6ac8b7cc1823d911c37788b8bca5e65;p=modules%2Fshaper.git Add a new method to create a box with a center and three half-lengths --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp index 1dcc9fa97..21da9cb04 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Box.cpp @@ -34,6 +34,7 @@ GeomAlgoAPI_Box::GeomAlgoAPI_Box(const double theDx, const double theDy, const d myDy = theDy; myDz = theDz; myMethodType = MethodType::BOX_DIM; + headError = "Box builder with dimensions"; } //================================================================================================= @@ -43,33 +44,48 @@ GeomAlgoAPI_Box::GeomAlgoAPI_Box(std::shared_ptr theFirstPoint, myFirstPoint = theFirstPoint; mySecondPoint = theSecondPoint; myMethodType = MethodType::BOX_POINTS; + headError = "Box builder with two points"; +} + +//================================================================================================= +GeomAlgoAPI_Box::GeomAlgoAPI_Box(const double theOx, const double theOy, const double theOz, + const double theDx, const double theDy, const double theDz) +{ + myOx = theOx; + myOy = theOy; + myOz = theOz; + myDx = theDx; + myDy = theDy; + myDz = theDz; + myMethodType = MethodType::BOX_POINT_DIMS; + headError = "Box builder with coordinates and dimensions"; } //================================================================================================= bool GeomAlgoAPI_Box::check() { - if (myMethodType == MethodType::BOX_DIM) { + if (myMethodType == MethodType::BOX_DIM || myMethodType == MethodType::BOX_POINT_DIMS) { if (myDx < Precision::Confusion()) { - myError = "Box builder with dimensions :: Dx is null or negative."; + myError = headError + " :: Dx is null or negative."; return false; } else if (myDy < Precision::Confusion()) { - myError = "Box builder with dimensions :: Dy is null or negative."; + myError = headError + " :: Dy is null or negative."; return false; } else if (myDz < Precision::Confusion()) { - myError = "Box builder with dimensions :: Dz is null or negative."; + myError = headError + " :: Dz is null or negative."; return false; } } else if (myMethodType == MethodType::BOX_POINTS) { if (!myFirstPoint.get()) { - myError = "Box builder with points :: the first point is not valid."; + myError = headError + " :: the first point is not valid."; return false; } if (!mySecondPoint.get()) { - myError = "Box builder with points :: the second point is not valid."; + myError = headError + " :: the second point is not valid."; return false; } if (myFirstPoint->distance(mySecondPoint) < Precision::Confusion()) { - myError = "Box builder with points :: the distance between the two points is null."; + myError = headError + " :: the distance between the two points is null."; return false; } double aDiffX = myFirstPoint->x() - mySecondPoint->x(); @@ -79,7 +95,7 @@ bool GeomAlgoAPI_Box::check() fabs(aDiffY) < Precision::Confusion() || fabs(aDiffZ) < Precision::Confusion()) { myError = - "Box builder with points :: the points belong both to one of the OXY, OYZ or OZX planes."; + headError + " :: the points belong both to one of the OXY, OYZ or OZX planes."; return false; } } else { @@ -96,6 +112,8 @@ void GeomAlgoAPI_Box::build() buildWithDimensions(); } else if (myMethodType == MethodType::BOX_POINTS) { buildWithPoints(); + } else if (myMethodType == MethodType::BOX_POINT_DIMS) { + buildWithPointAndDims(); } else { myError = "Box builder :: Method not implemented."; return; @@ -113,7 +131,7 @@ void GeomAlgoAPI_Box::buildWithDimensions() // Test the algorithm if (!aBoxMaker->IsDone()) { - myError = "Box builder with dimensions :: algorithm failed."; + myError = headError + " :: algorithm failed."; return; } @@ -124,7 +142,7 @@ void GeomAlgoAPI_Box::buildWithDimensions() // Test on the shapes if (!aShape.get() || aShape->isNull()) { - myError = "Box builder with dimensions :: resulting shape is null."; + myError = headError + " :: resulting shape is null."; return; } @@ -147,7 +165,7 @@ void GeomAlgoAPI_Box::buildWithPoints() // Test the algorithm if(!aBoxMaker->IsDone()) { - myError = "Box builder with two points :: algorithm failed."; + myError = headError + " :: algorithm failed."; return; } @@ -159,7 +177,7 @@ void GeomAlgoAPI_Box::buildWithPoints() // Tests on the shape if (!aShape.get() || aShape->isNull()) { - myError = "Box builder with two points :: resulting shape is null."; + myError = headError + " :: resulting shape is null."; return; } @@ -168,6 +186,18 @@ void GeomAlgoAPI_Box::buildWithPoints() setDone(true); } +//================================================================================================= +void GeomAlgoAPI_Box::buildWithPointAndDims() +{ + // 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(); +} + //================================================================================================= void GeomAlgoAPI_Box::prepareNamingFaces() { diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Box.h b/src/GeomAlgoAPI/GeomAlgoAPI_Box.h index c6f1269f1..44cdd1c69 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Box.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Box.h @@ -34,6 +34,7 @@ class GeomAlgoAPI_Box : public GeomAlgoAPI_MakeShape enum MethodType { BOX_DIM, ///< Box with dimensions BOX_POINTS, ///< Box with points + BOX_POINT_DIMS, /// 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 + /// \param theOz The Z coordinate of the point + /// \param theDx The dimension on X + /// \param theDy The dimension on Y + /// \param theDz The dimension on Z + GEOMALGOAPI_EXPORT GeomAlgoAPI_Box(const double theOx, const double theOy, const double theOz, + const double theDx, const double theDy, const double theDz); /// Checks if data for the box construction is OK. GEOMALGOAPI_EXPORT bool check(); @@ -64,13 +75,19 @@ class GeomAlgoAPI_Box : public GeomAlgoAPI_MakeShape void buildWithDimensions(); /// Builds the box with two points void buildWithPoints(); + /// Buils the box with coordinates of a point and dimensions + void buildWithPointAndDims(); + double myOx; /// X coordinate of the center to create a box. + double myOy; /// Y coordinate of the center to create a box. + double myOz; /// Z coordinate of the center to create a box. double myDx; /// Dimension on X to create a box. double myDy; /// Dimension on Y to create a box. double myDz; /// Dimension Z to create a box. std::shared_ptr myFirstPoint; /// First point to create a box. std::shared_ptr mySecondPoint; /// Second point to create a box. MethodType myMethodType; /// Type of method used. + std::string headError; /// Head of the error message according to the method }; diff --git a/src/PrimitivesAPI/PrimitivesAPI_Box.cpp b/src/PrimitivesAPI/PrimitivesAPI_Box.cpp index 04b73f6ee..67fbe3396 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_Box.cpp +++ b/src/PrimitivesAPI/PrimitivesAPI_Box.cpp @@ -50,6 +50,29 @@ PrimitivesAPI_Box::PrimitivesAPI_Box(const std::shared_ptr& th setPoints(theFirstPoint, theSecondPoint); } +//================================================================================================== +PrimitivesAPI_Box::PrimitivesAPI_Box(const std::shared_ptr& theFeature, + const ModelHighAPI_Double& theOx, + const ModelHighAPI_Double& theOy, + const ModelHighAPI_Double& theOz, + const ModelHighAPI_Double& theHalfX, + const ModelHighAPI_Double& theHalfY, + const ModelHighAPI_Double& theHalfZ) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) + { + fillAttribute(PrimitivesPlugin_Box::CREATION_METHOD_BY_ONE_POINT_AND_DIMS(), creationMethod()); + fillAttribute(theOx, ox()); + fillAttribute(theOy, oy()); + fillAttribute(theOz, oz()); + fillAttribute(theHalfX, halfdx()); + fillAttribute(theHalfY, halfdy()); + fillAttribute(theHalfZ, halfdz()); + execute(); + } +} + //================================================================================================== PrimitivesAPI_Box::~PrimitivesAPI_Box() { @@ -80,6 +103,30 @@ void PrimitivesAPI_Box::setPoints(const ModelHighAPI_Selection& theFirstPoint, execute(); } +//================================================================================================== +void PrimitivesAPI_Box::setOrigin(const ModelHighAPI_Double& theOx, + const ModelHighAPI_Double& theOy, + const ModelHighAPI_Double& theOz) +{ + fillAttribute(theOx, ox()); + fillAttribute(theOy, oy()); + fillAttribute(theOz, oz()); + + execute(); +} + +//================================================================================================== +void PrimitivesAPI_Box::setHalfLengths(const ModelHighAPI_Double& theHalfLengthX, + const ModelHighAPI_Double& theHalfLengthY, + const ModelHighAPI_Double& theHalfLengthZ) +{ + fillAttribute(theHalfLengthX, halfdx()); + fillAttribute(theHalfLengthY, halfdy()); + fillAttribute(theHalfLengthZ, halfdz()); + + execute(); +} + //================================================================================================== void PrimitivesAPI_Box::dump(ModelHighAPI_Dumper& theDumper) const { @@ -101,6 +148,16 @@ void PrimitivesAPI_Box::dump(ModelHighAPI_Dumper& theDumper) const AttributeSelectionPtr anAttrSecondPnt = aBase->selection(PrimitivesPlugin_Box::POINT_SECOND_ID()); theDumper << ", " << anAttrFirstPnt << ", " << anAttrSecondPnt; + } else if (aCreationMethod == PrimitivesPlugin_Box::CREATION_METHOD_BY_ONE_POINT_AND_DIMS()) { + AttributeDoublePtr anAttrOx = aBase->real(PrimitivesPlugin_Box::OX_ID()); + AttributeDoublePtr anAttrOy = aBase->real(PrimitivesPlugin_Box::OY_ID()); + AttributeDoublePtr anAttrOz = aBase->real(PrimitivesPlugin_Box::OZ_ID()); + AttributeDoublePtr anAttrHalfLengthX = aBase->real(PrimitivesPlugin_Box::HALF_DX_ID()); + AttributeDoublePtr anAttrHalfLengthY = aBase->real(PrimitivesPlugin_Box::HALF_DY_ID()); + AttributeDoublePtr anAttrHalfLengthZ = aBase->real(PrimitivesPlugin_Box::HALF_DZ_ID()); + theDumper << ", " << anAttrOx << ", " << anAttrOy << ", " << anAttrOz; + theDumper << ", " << anAttrHalfLengthX << ", " << anAttrHalfLengthY; + theDumper << ", " << anAttrHalfLengthZ; } theDumper << ")" << std::endl; @@ -123,4 +180,18 @@ BoxPtr addBox(const std::shared_ptr& thePart, { std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Box::ID()); return BoxPtr(new PrimitivesAPI_Box(aFeature, theFirstPoint, theSecondPoint)); -} \ No newline at end of file +} + +//================================================================================================== +BoxPtr addBox(const std::shared_ptr& thePart, + const ModelHighAPI_Double& theOx, + const ModelHighAPI_Double& theOy, + const ModelHighAPI_Double& theOz, + const ModelHighAPI_Double& theHalfLengthX, + const ModelHighAPI_Double& theHalfLengthY, + const ModelHighAPI_Double& theHalfLengthZ) +{ + std::shared_ptr aFeature = thePart->addFeature(PrimitivesAPI_Box::ID()); + return BoxPtr(new PrimitivesAPI_Box(aFeature, theOx, theOy, theOz, theHalfLengthX, + theHalfLengthY, theHalfLengthZ)); +} diff --git a/src/PrimitivesAPI/PrimitivesAPI_Box.h b/src/PrimitivesAPI/PrimitivesAPI_Box.h index 2fda32494..33b412bea 100644 --- a/src/PrimitivesAPI/PrimitivesAPI_Box.h +++ b/src/PrimitivesAPI/PrimitivesAPI_Box.h @@ -53,11 +53,21 @@ public: const ModelHighAPI_Selection& theFirstPoint, const ModelHighAPI_Selection& theSecondPoint); + /// Constructor with values. + PRIMITIVESAPI_EXPORT + explicit PrimitivesAPI_Box(const std::shared_ptr& theFeature, + const ModelHighAPI_Double& theOx, + const ModelHighAPI_Double& theOy, + const ModelHighAPI_Double& theOz, + const ModelHighAPI_Double& theHalfX, + const ModelHighAPI_Double& theHalfY, + const ModelHighAPI_Double& theHalfZ); + /// Destructor. PRIMITIVESAPI_EXPORT virtual ~PrimitivesAPI_Box(); - INTERFACE_6(PrimitivesPlugin_Box::ID(), + INTERFACE_12(PrimitivesPlugin_Box::ID(), creationMethod, PrimitivesPlugin_Box::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */, dx, PrimitivesPlugin_Box::DX_ID(), @@ -69,7 +79,19 @@ public: firstPoint, PrimitivesPlugin_Box::POINT_FIRST_ID(), ModelAPI_AttributeSelection, /** First point */, secondPoint, PrimitivesPlugin_Box::POINT_SECOND_ID(), - ModelAPI_AttributeSelection, /** Second point */) + ModelAPI_AttributeSelection, /** Second point */, + ox, PrimitivesPlugin_Box::OX_ID(), + ModelAPI_AttributeDouble, /** X coordinate for origin*/, + oy, PrimitivesPlugin_Box::OY_ID(), + ModelAPI_AttributeDouble, /** Y coordinate for origin*/, + oz, PrimitivesPlugin_Box::OZ_ID(), + ModelAPI_AttributeDouble, /** Z coordinate for origin*/, + halfdx, PrimitivesPlugin_Box::HALF_DX_ID(), + ModelAPI_AttributeDouble, /** Half length in X*/, + halfdy, PrimitivesPlugin_Box::HALF_DY_ID(), + ModelAPI_AttributeDouble, /** Half length in Y*/, + halfdz, PrimitivesPlugin_Box::HALF_DZ_ID(), + ModelAPI_AttributeDouble, /** Half length in Z*/) /// Set dimensions PRIMITIVESAPI_EXPORT @@ -82,6 +104,18 @@ public: void setPoints(const ModelHighAPI_Selection& theFirstPoint, const ModelHighAPI_Selection& theSecondPoint); + /// Set origin point + PRIMITIVESAPI_EXPORT + void setOrigin(const ModelHighAPI_Double& theOx, + const ModelHighAPI_Double& theOy, + const ModelHighAPI_Double& theOz); + + /// Set half lengths + PRIMITIVESAPI_EXPORT + void setHalfLengths(const ModelHighAPI_Double& theHalfLengthX, + const ModelHighAPI_Double& theHalfLengthY, + const ModelHighAPI_Double& theHalfLengthZ); + /// Dump wrapped feature PRIMITIVESAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const; @@ -105,4 +139,15 @@ BoxPtr addBox(const std::shared_ptr& thePart, const ModelHighAPI_Selection& theFirstPoint, const ModelHighAPI_Selection& theSecondPoint); -#endif // PRIMITIVESAPI_BOX_H_ \ No newline at end of file +/// \ingroup CPPHighAPI +/// \brief Create primitive Box feature. +PRIMITIVESAPI_EXPORT +BoxPtr addBox(const std::shared_ptr& thePart, + const ModelHighAPI_Double& theOx, + const ModelHighAPI_Double& theOy, + const ModelHighAPI_Double& theOz, + const ModelHighAPI_Double& theHalfLengthX, + const ModelHighAPI_Double& theHalfLengthY, + const ModelHighAPI_Double& theHalfLengthZ); + +#endif // PRIMITIVESAPI_BOX_H_ diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp index 30caf171d..c9606b717 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp @@ -40,14 +40,24 @@ void PrimitivesPlugin_Box::initAttributes() { data()->addAttribute(PrimitivesPlugin_Box::CREATION_METHOD(), ModelAPI_AttributeString::typeId()); + // Data for the first mode data()->addAttribute(PrimitivesPlugin_Box::DX_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(PrimitivesPlugin_Box::DY_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(PrimitivesPlugin_Box::DZ_ID(), ModelAPI_AttributeDouble::typeId()); + // Data for the second mode data()->addAttribute(PrimitivesPlugin_Box::POINT_FIRST_ID(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(PrimitivesPlugin_Box::POINT_SECOND_ID(), ModelAPI_AttributeSelection::typeId()); + + // Data for the third mode + data()->addAttribute(PrimitivesPlugin_Box::OX_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Box::OY_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Box::OZ_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Box::HALF_DX_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Box::HALF_DY_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(PrimitivesPlugin_Box::HALF_DZ_ID(), ModelAPI_AttributeDouble::typeId()); } //================================================================================================= @@ -61,6 +71,9 @@ void PrimitivesPlugin_Box::execute() if (aMethodType == CREATION_METHOD_BY_TWO_POINTS()) createBoxByTwoPoints(); + + if (aMethodType == CREATION_METHOD_BY_ONE_POINT_AND_DIMS()) + createBoxByOnePointAndDims(); } //================================================================================================= @@ -148,6 +161,50 @@ void PrimitivesPlugin_Box::createBoxByTwoPoints() setResult(aResultBox, aResultIndex); } +//================================================================================================= +void PrimitivesPlugin_Box::createBoxByOnePointAndDims() +{ + // Getting dx, dy and dz + 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(); + double z = real(PrimitivesPlugin_Box::OZ_ID())->value(); + + 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()) { + setError(aBoxAlgo->getError()); + return; + } + + // Build the box + aBoxAlgo->build(); + + // Check if the creation of the box + if(!aBoxAlgo->isDone()) { + // The error is not displayed in a popup window. It must be in the message console. + setError(aBoxAlgo->getError()); + return; + } + if(!aBoxAlgo->checkValid("Box builder with one point and dimensions")) { + // The error is not displayed in a popup window. It must be in the message console. + setError(aBoxAlgo->getError()); + return; + } + + int aResultIndex = 0; + ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex); + loadNamingDS(aBoxAlgo, aResultBox); + setResult(aResultBox, aResultIndex); +} + //================================================================================================= void PrimitivesPlugin_Box::loadNamingDS(std::shared_ptr theBoxAlgo, std::shared_ptr theResultBox) diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Box.h b/src/PrimitivesPlugin/PrimitivesPlugin_Box.h index 252cf52f3..0f3bc7f0f 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Box.h +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Box.h @@ -32,7 +32,8 @@ class ModelAPI_ResultBody; * \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 - * methods : using two points that define a diagonal, or using 3 lengths that define the + * 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. */ class PrimitivesPlugin_Box : public ModelAPI_Feature @@ -66,6 +67,13 @@ class PrimitivesPlugin_Box : public ModelAPI_Feature return MY_CREATION_METHOD_ID; } + /// Attribute name for creation method + inline static const std::string& CREATION_METHOD_BY_ONE_POINT_AND_DIMS() + { + static const std::string MY_CREATION_METHOD_ID("BoxByOnePointAndDims"); + return MY_CREATION_METHOD_ID; + } + /// Attribute name of first point inline static const std::string& POINT_FIRST_ID() { @@ -100,6 +108,48 @@ 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() + { + static const std::string MY_OX_ID("ox"); + return MY_OX_ID; + } + + /// Attribute name of the second coordinate of the center + inline static const std::string& OY_ID() + { + static const std::string MY_OY_ID("oy"); + return MY_OY_ID; + } + + /// Attribute name of the third coordinate of the center + inline static const std::string& OZ_ID() + { + 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() + { + static const std::string MY_HALF_DX_ID("half_dx"); + return MY_HALF_DX_ID; + } + + /// Attribute name of the half-length on Y axis + inline static const std::string& HALF_DY_ID() + { + static const std::string MY_HALF_DY_ID("half_dy"); + return MY_HALF_DY_ID; + } + + /// Attribute name of the half-length on Z axis + inline static const std::string& HALF_DZ_ID() + { + static const std::string MY_HALF_DZ_ID("half_dz"); + return MY_HALF_DZ_ID; + } /// Returns the kind of a feature PRIMITIVESPLUGIN_EXPORT virtual const std::string& getKind() @@ -128,6 +178,9 @@ 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 + void createBoxByOnePointAndDims(); + }; diff --git a/src/PrimitivesPlugin/box_widget.xml b/src/PrimitivesPlugin/box_widget.xml index f968b5154..bcd5ba91a 100644 --- a/src/PrimitivesPlugin/box_widget.xml +++ b/src/PrimitivesPlugin/box_widget.xml @@ -40,5 +40,56 @@ shape_types="vertex"> + + + + + + + + + + + + + + + + + + + + + diff --git a/src/PrimitivesPlugin/doc/TUI_boxByPtDims.rst b/src/PrimitivesPlugin/doc/TUI_boxByPtDims.rst new file mode 100644 index 000000000..2b5aa3142 --- /dev/null +++ b/src/PrimitivesPlugin/doc/TUI_boxByPtDims.rst @@ -0,0 +1,12 @@ + + .. _tui_create_boxptdim: + +Create Box coordinates of a point and dimensions +================================================ + +.. literalinclude:: examples/box3.py + :linenos: + :language: python + +:download:`Download this script ` + diff --git a/src/PrimitivesPlugin/doc/boxFeature.rst b/src/PrimitivesPlugin/doc/boxFeature.rst index 759fc9eb8..1171514af 100644 --- a/src/PrimitivesPlugin/doc/boxFeature.rst +++ b/src/PrimitivesPlugin/doc/boxFeature.rst @@ -12,7 +12,7 @@ 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: -There are 2 algorithms for creation of a Box: +There are 3 algorithms for creation of a Box: .. figure:: images/box_dxyz_32x32.png :align: left @@ -26,6 +26,12 @@ There are 2 algorithms for creation of a Box: **By two points** +.. figure:: images/box_pt_dxyz_32x32.png + :align: left + :height: 24px + +**By coordinates of a point and dimensions** + -------------------------------------------------------------------------------- By dimensions @@ -81,8 +87,6 @@ Input fields: :param object: Second vertex of diagonal. :return: Result object. -**Arguments**: Part + 2 selected points (opposite vertices of the box) - Result """""" @@ -94,3 +98,41 @@ A solid box based on two points and with edges parallel to the coordinate axes. Created boxes **See Also** a sample TUI Script of :ref:`tui_create_boxpnt` operation. + +By coordinates of a point and dimensions +---------------------------------------- + +Box is created by dimensions along X, Y, Z axis starting from the point of coordinates (x,y,z). + +.. figure:: images/Box_ptAndDims.png + :align: center + +Input fields: + +- **OX**, **OY**, **OZ** define coordinates of the center of box. +- **DX**, **DY**, **DZ** define dimensions (hafl length) of the box along the corresponding coordinate axes. + +**TUI Command**: + +.. py:function:: model.addBox(Part_doc, OX, OY, OZ, DX, DY, DZ) + + :param part: The current part object. + :param real: X coordinate of the center point + :param real: Y coordinate of the center point + :param real: Z coordinate of the center point + :param real: Half size along X. + :param real: Half size along Y. + :param real: Half size along Z. + :return: Result object. + +Result +"""""" + +A solid box whose point coordinates are the center and the dimensions are half lengths on one side and the other on the axes relative to the center. + +.. figure:: images/Box3.png + :align: center + + Created boxes + +**See Also** a sample TUI Script of :ref:`tui_create_boxptdim` operation. diff --git a/src/PrimitivesPlugin/doc/examples/box3.py b/src/PrimitivesPlugin/doc/examples/box3.py new file mode 100644 index 000000000..493143920 --- /dev/null +++ b/src/PrimitivesPlugin/doc/examples/box3.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() +Box_1 = model.addBox(Part_1_doc, 0, 0, 0, 20, 20, 20) +model.do() +model.end() diff --git a/src/PrimitivesPlugin/doc/images/Box3.png b/src/PrimitivesPlugin/doc/images/Box3.png new file mode 100644 index 000000000..a1b5e5fce Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Box3.png differ diff --git a/src/PrimitivesPlugin/doc/images/Box_ptAndDims.png b/src/PrimitivesPlugin/doc/images/Box_ptAndDims.png new file mode 100644 index 000000000..3fedaf7df Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Box_ptAndDims.png differ diff --git a/src/PrimitivesPlugin/doc/images/box_pt_dxyz_32x32.png b/src/PrimitivesPlugin/doc/images/box_pt_dxyz_32x32.png new file mode 100644 index 000000000..db199ea7b Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/box_pt_dxyz_32x32.png differ diff --git a/src/PrimitivesPlugin/icons/box_pt_dxyz_32x32.png b/src/PrimitivesPlugin/icons/box_pt_dxyz_32x32.png new file mode 100644 index 000000000..db199ea7b Binary files /dev/null and b/src/PrimitivesPlugin/icons/box_pt_dxyz_32x32.png differ