Added test cases for Axis.
// History:
// 15/06/16 - Sergey POKHODENKO - Creation of the file
-//--------------------------------------------------------------------------------------
#include "ConstructionAPI_Axis.h"
-//--------------------------------------------------------------------------------------
+
#include <ModelHighAPI_Tools.h>
-//--------------------------------------------------------------------------------------
-ConstructionAPI_Axis::ConstructionAPI_Axis(
- const std::shared_ptr<ModelAPI_Feature> & theFeature)
+
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature)
: ModelHighAPI_Interface(theFeature)
{
initialize();
}
-ConstructionAPI_Axis::ConstructionAPI_Axis(
- const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const ModelHighAPI_Selection & thePoint1,
- const ModelHighAPI_Selection & thePoint2)
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theObject1,
+ const ModelHighAPI_Selection& theObject2)
: ModelHighAPI_Interface(theFeature)
{
- if (initialize())
- setPoints(thePoint1, thePoint2);
+ if(initialize()) {
+ GeomAPI_Shape::ShapeType aType1 = getShapeType(theObject1);
+ GeomAPI_Shape::ShapeType aType2 = getShapeType(theObject2);
+ if(aType1 == GeomAPI_Shape::VERTEX && aType2 == GeomAPI_Shape::VERTEX) {
+ setByPoints(theObject1, theObject2);
+ } else if (aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::VERTEX) {
+ setByPlaneAndPoint(theObject1, theObject2);
+ } else if (aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::FACE) {
+ setByTwoPlanes(theObject1, theObject2);
+ }
+ }
}
-ConstructionAPI_Axis::ConstructionAPI_Axis(
- const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const ModelHighAPI_Selection & theCylindricalFace)
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theObject)
: ModelHighAPI_Interface(theFeature)
{
- if (initialize())
- setCylindricalFace(theCylindricalFace);
+ if(initialize()) {
+ GeomAPI_Shape::ShapeType aType = getShapeType(theObject);
+ if(aType == GeomAPI_Shape::EDGE) {
+ setByLine(theObject);
+ } else if(aType == GeomAPI_Shape::FACE) {
+ setByCylindricalFace(theObject);
+ }
+ }
}
-ConstructionAPI_Axis::ConstructionAPI_Axis(
- const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const ModelHighAPI_Selection & thePoint,
- const ModelHighAPI_Double & theX,
- const ModelHighAPI_Double & theY,
- const ModelHighAPI_Double & theZ)
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& thePoint,
+ const ModelHighAPI_Double& theX,
+ const ModelHighAPI_Double& theY,
+ const ModelHighAPI_Double& theZ)
: ModelHighAPI_Interface(theFeature)
{
- if (initialize())
- setPointAndDirection(thePoint, theX, theY, theZ);
+ if(initialize()) {
+ setByPointAndDirection(thePoint, theX, theY, theZ);
+ }
}
-ConstructionAPI_Axis::ConstructionAPI_Axis(
- const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const ModelHighAPI_Double & theDX,
- const ModelHighAPI_Double & theDY,
- const ModelHighAPI_Double & theDZ)
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theDX,
+ const ModelHighAPI_Double& theDY,
+ const ModelHighAPI_Double& theDZ)
: ModelHighAPI_Interface(theFeature)
{
- if (initialize())
- setDimensions(theDX, theDY, theDZ);
+ if(initialize()) {
+ setByDimensions(theDX, theDY, theDZ);
+ }
}
-ConstructionAPI_Axis::~ConstructionAPI_Axis()
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2)
+: ModelHighAPI_Interface(theFeature)
{
+ if(initialize()) {
+ setByTwoPlanes(thePlane1, theOffset1, theReverseOffset1, thePlane2, theOffset2, theReverseOffset2);
+ }
+}
+//==================================================================================================
+ConstructionAPI_Axis::~ConstructionAPI_Axis()
+{
}
-//--------------------------------------------------------------------------------------
-void ConstructionAPI_Axis::setPoints(
- const ModelHighAPI_Selection & thePoint1,
- const ModelHighAPI_Selection & thePoint2)
+//==================================================================================================
+void ConstructionAPI_Axis::setByPoints(const ModelHighAPI_Selection& thePoint1,
+ const ModelHighAPI_Selection& thePoint2)
{
- fillAttribute("AxisByPointsCase", creationMethod());
+ fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_POINTS(), creationMethod());
fillAttribute(thePoint1, firstPoint());
fillAttribute(thePoint2, secondPoint());
execute();
}
-void ConstructionAPI_Axis::setCylindricalFace(
- const ModelHighAPI_Selection & theCylindricalFace)
+//==================================================================================================
+void ConstructionAPI_Axis::setByCylindricalFace(const ModelHighAPI_Selection& theCylindricalFace)
{
- fillAttribute("AxisByCylindricalFaceCase", creationMethod());
+ fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_CYLINDRICAL_FACE(), creationMethod());
fillAttribute(theCylindricalFace, cylindricalFace());
execute();
}
-void ConstructionAPI_Axis::setPointAndDirection(
- const ModelHighAPI_Selection & thePoint,
- const ModelHighAPI_Double & theX,
- const ModelHighAPI_Double & theY,
- const ModelHighAPI_Double & theZ)
+//==================================================================================================
+void ConstructionAPI_Axis::setByPointAndDirection(const ModelHighAPI_Selection& thePoint,
+ const ModelHighAPI_Double& theX,
+ const ModelHighAPI_Double& theY,
+ const ModelHighAPI_Double& theZ)
{
- fillAttribute("AxisByPointAndDirection", creationMethod());
+ fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_POINT_AND_DIRECTION(), creationMethod());
fillAttribute(thePoint, firstPoint());
fillAttribute(theX, xDirection());
fillAttribute(theY, yDirection());
execute();
}
-void ConstructionAPI_Axis::setDimensions(
- const ModelHighAPI_Double & theDX,
- const ModelHighAPI_Double & theDY,
- const ModelHighAPI_Double & theDZ)
+//==================================================================================================
+void ConstructionAPI_Axis::setByDimensions(const ModelHighAPI_Double& theDX,
+ const ModelHighAPI_Double& theDY,
+ const ModelHighAPI_Double& theDZ)
{
- fillAttribute("AxisByDimensionsCase", creationMethod());
+ fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_DIMENSIONS(), creationMethod());
fillAttribute(theDX, xDimension());
fillAttribute(theDY, yDimension());
fillAttribute(theDZ, zDimension());
execute();
}
-//--------------------------------------------------------------------------------------
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
- const ModelHighAPI_Selection & thePoint1,
- const ModelHighAPI_Selection & thePoint2)
+//==================================================================================================
+void ConstructionAPI_Axis::setByLine(const ModelHighAPI_Selection& theLine)
+{
+ fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_LINE(), creationMethod());
+ fillAttribute(theLine, line());
+
+ execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Axis::setByPlaneAndPoint(const ModelHighAPI_Selection& thePlane,
+ const ModelHighAPI_Selection& thePoint)
+{
+ fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_PLANE_AND_POINT(), creationMethod());
+ fillAttribute(thePlane, plane());
+ fillAttribute(thePoint, point());
+
+ execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Axis::setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Selection& thePlane2)
+{
+ fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES(), creationMethod());
+ fillAttribute(thePlane1, plane1());
+ fillAttribute("", useOffset1());
+ fillAttribute(thePlane2, plane2());
+ fillAttribute("", useOffset2());
+
+ execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Axis::setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2)
+{
+ fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES(), creationMethod());
+ fillAttribute(thePlane1, plane1());
+ fillAttribute(ConstructionPlugin_Axis::USE_OFFSET1(), useOffset1());
+ fillAttribute(theOffset1, offset1());
+ fillAttribute(theReverseOffset1, reverseOffset1());
+ fillAttribute(thePlane2, plane2());
+ fillAttribute(ConstructionPlugin_Axis::USE_OFFSET2(), useOffset2());
+ fillAttribute(theOffset2, offset2());
+ fillAttribute(theReverseOffset2, reverseOffset2());
+
+ execute();
+}
+
+//==================================================================================================
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& thePoint1,
+ const ModelHighAPI_Selection& thePoint2)
{
// TODO(spo): check that thePart is not empty
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint1, thePoint2));
}
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
- const ModelHighAPI_Selection & theCylindricalFace)
+//==================================================================================================
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& theObject)
{
// TODO(spo): check that thePart is not empty
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
- return AxisPtr(new ConstructionAPI_Axis(aFeature, theCylindricalFace));
+ return AxisPtr(new ConstructionAPI_Axis(aFeature, theObject));
}
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
- const ModelHighAPI_Selection & thePoint,
- const ModelHighAPI_Double & theX,
- const ModelHighAPI_Double & theY,
- const ModelHighAPI_Double & theZ)
+//==================================================================================================
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& thePoint,
+ const ModelHighAPI_Double& theX,
+ const ModelHighAPI_Double& theY,
+ const ModelHighAPI_Double& theZ)
{
// TODO(spo): check that thePart is not empty
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint, theX, theY, theZ));
}
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
- const ModelHighAPI_Double & theDX,
- const ModelHighAPI_Double & theDY,
- const ModelHighAPI_Double & theDZ)
+//==================================================================================================
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theDX,
+ const ModelHighAPI_Double& theDY,
+ const ModelHighAPI_Double& theDZ)
{
// TODO(spo): check that thePart is not empty
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
return AxisPtr(new ConstructionAPI_Axis(aFeature, theDX, theDY, theDZ));
}
+
+//==================================================================================================
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2)
+{
+ // TODO(spo): check that thePart is not empty
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
+ return AxisPtr(new ConstructionAPI_Axis(aFeature, thePlane1, theOffset1, theReverseOffset1,
+ thePlane2, theOffset2, theReverseOffset2));
+}
#ifndef SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_
#define SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_
-//--------------------------------------------------------------------------------------
#include "ConstructionAPI.h"
#include <ConstructionPlugin_Axis.h>
#include <ModelHighAPI_Interface.h>
#include <ModelHighAPI_Macro.h>
-//--------------------------------------------------------------------------------------
+
class ModelHighAPI_Double;
class ModelHighAPI_Selection;
-//--------------------------------------------------------------------------------------
-/**\class ConstructionAPI_Axis
- * \ingroup CPPHighAPI
- * \brief Interface for Axis feature
- */
-class ConstructionAPI_Axis : public ModelHighAPI_Interface
+
+/// \class ConstructionAPI_Axis
+/// \ingroup CPPHighAPI
+/// \brief Interface for Axis feature
+class ConstructionAPI_Axis: public ModelHighAPI_Interface
{
public:
/// Constructor without values
CONSTRUCTIONAPI_EXPORT
- explicit ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+ explicit ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
/// Constructor with values
CONSTRUCTIONAPI_EXPORT
- ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const ModelHighAPI_Selection & thePoint1,
- const ModelHighAPI_Selection & thePoint2);
+ ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theObject1,
+ const ModelHighAPI_Selection& theObject2);
+
/// Constructor with values
CONSTRUCTIONAPI_EXPORT
- ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const ModelHighAPI_Selection & theCylindricalFace);
+ ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& theObject);
+
/// Constructor with values
CONSTRUCTIONAPI_EXPORT
- ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const ModelHighAPI_Selection & thePoint,
- const ModelHighAPI_Double & theX,
- const ModelHighAPI_Double & theY,
- const ModelHighAPI_Double & theZ);
+ ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& thePoint,
+ const ModelHighAPI_Double& theX,
+ const ModelHighAPI_Double& theY,
+ const ModelHighAPI_Double& theZ);
+
/// Constructor with values
CONSTRUCTIONAPI_EXPORT
- ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature> & theFeature,
- const ModelHighAPI_Double & theDX,
- const ModelHighAPI_Double & theDY,
- const ModelHighAPI_Double & theDZ);
+ ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Double& theDX,
+ const ModelHighAPI_Double& theDY,
+ const ModelHighAPI_Double& theDZ);
+
+ /// Constructor with values
+ CONSTRUCTIONAPI_EXPORT
+ ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2);
+
/// Destructor
CONSTRUCTIONAPI_EXPORT
virtual ~ConstructionAPI_Axis();
- INTERFACE_10(ConstructionPlugin_Axis::ID(),
- creationMethod, ConstructionPlugin_Axis::METHOD(), ModelAPI_AttributeString, /** Creation method */,
- firstPoint, ConstructionPlugin_Axis::POINT_FIRST(), ModelAPI_AttributeSelection, /** First point */,
- secondPoint, ConstructionPlugin_Axis::POINT_SECOND(), ModelAPI_AttributeSelection, /** Second point */,
- cylindricalFace, ConstructionPlugin_Axis::CYLINDRICAL_FACE(), ModelAPI_AttributeSelection, /** Cylindrical face */,
- xDirection, ConstructionPlugin_Axis::X_DIRECTION(), ModelAPI_AttributeDouble, /** X direction */,
- yDirection, ConstructionPlugin_Axis::Y_DIRECTION(), ModelAPI_AttributeDouble, /** Y direction */,
- zDirection, ConstructionPlugin_Axis::Z_DIRECTION(), ModelAPI_AttributeDouble, /** Z direction */,
- xDimension, ConstructionPlugin_Axis::DX(), ModelAPI_AttributeDouble, /** X dimension */,
- yDimension, ConstructionPlugin_Axis::DY(), ModelAPI_AttributeDouble, /** Y dimension */,
- zDimension, ConstructionPlugin_Axis::DZ(), ModelAPI_AttributeDouble, /** Z dimension */
- )
+ INTERFACE_21(ConstructionPlugin_Axis::ID(),
+ creationMethod, ConstructionPlugin_Axis::METHOD(), ModelAPI_AttributeString, /** Creation method */,
+ firstPoint, ConstructionPlugin_Axis::POINT_FIRST(), ModelAPI_AttributeSelection, /** First point */,
+ secondPoint, ConstructionPlugin_Axis::POINT_SECOND(), ModelAPI_AttributeSelection, /** Second point */,
+ cylindricalFace, ConstructionPlugin_Axis::CYLINDRICAL_FACE(), ModelAPI_AttributeSelection, /** Cylindrical face */,
+ xDirection, ConstructionPlugin_Axis::X_DIRECTION(), ModelAPI_AttributeDouble, /** X direction */,
+ yDirection, ConstructionPlugin_Axis::Y_DIRECTION(), ModelAPI_AttributeDouble, /** Y direction */,
+ zDirection, ConstructionPlugin_Axis::Z_DIRECTION(), ModelAPI_AttributeDouble, /** Z direction */,
+ xDimension, ConstructionPlugin_Axis::DX(), ModelAPI_AttributeDouble, /** X dimension */,
+ yDimension, ConstructionPlugin_Axis::DY(), ModelAPI_AttributeDouble, /** Y dimension */,
+ zDimension, ConstructionPlugin_Axis::DZ(), ModelAPI_AttributeDouble, /** Z dimension */,
+ line, ConstructionPlugin_Axis::LINE(), ModelAPI_AttributeSelection, /** Line */,
+ plane, ConstructionPlugin_Axis::PLANE(), ModelAPI_AttributeSelection, /** Plane */,
+ point, ConstructionPlugin_Axis::POINT(), ModelAPI_AttributeSelection, /** Point */,
+ plane1, ConstructionPlugin_Axis::PLANE1(), ModelAPI_AttributeSelection, /** Plane 1 */,
+ useOffset1, ConstructionPlugin_Axis::USE_OFFSET1(), ModelAPI_AttributeString, /** Use offset 1 */,
+ offset1, ConstructionPlugin_Axis::OFFSET1(), ModelAPI_AttributeDouble, /** Offset 1 */,
+ reverseOffset1, ConstructionPlugin_Axis::REVERSE_OFFSET1(), ModelAPI_AttributeBoolean, /** Reverse offset 1 */,
+ plane2, ConstructionPlugin_Axis::PLANE2(), ModelAPI_AttributeSelection, /** Plane 2 */,
+ useOffset2, ConstructionPlugin_Axis::USE_OFFSET2(), ModelAPI_AttributeString, /** Use offset 2 */,
+ offset2, ConstructionPlugin_Axis::OFFSET2(), ModelAPI_AttributeDouble, /** Offset 2 */,
+ reverseOffset2, ConstructionPlugin_Axis::REVERSE_OFFSET2(), ModelAPI_AttributeBoolean, /** Reverse offset 2 */)
/// Set points
CONSTRUCTIONAPI_EXPORT
- void setPoints(const ModelHighAPI_Selection & thePoint1,
- const ModelHighAPI_Selection & thePoint2);
+ void setByPoints(const ModelHighAPI_Selection& thePoint1,
+ const ModelHighAPI_Selection& thePoint2);
/// Set cylindrical face
CONSTRUCTIONAPI_EXPORT
- void setCylindricalFace(const ModelHighAPI_Selection & theCylindricalFace);
+ void setByCylindricalFace(const ModelHighAPI_Selection& theCylindricalFace);
/// Set direction
CONSTRUCTIONAPI_EXPORT
- void setPointAndDirection(const ModelHighAPI_Selection & thePoint,
- const ModelHighAPI_Double & theX,
- const ModelHighAPI_Double & theY,
- const ModelHighAPI_Double & theZ);
-
+ void setByPointAndDirection(const ModelHighAPI_Selection& thePoint,
+ const ModelHighAPI_Double& theX,
+ const ModelHighAPI_Double& theY,
+ const ModelHighAPI_Double& theZ);
+
/// Set dimensions
CONSTRUCTIONAPI_EXPORT
- void setDimensions(const ModelHighAPI_Double & theDX,
- const ModelHighAPI_Double & theDY,
- const ModelHighAPI_Double & theDZ);
+ void setByDimensions(const ModelHighAPI_Double& theDX,
+ const ModelHighAPI_Double& theDY,
+ const ModelHighAPI_Double& theDZ);
+
+ /// Set by line
+ CONSTRUCTIONAPI_EXPORT
+ void setByLine(const ModelHighAPI_Selection& theCylindricalFace);
+
+ /// Set by plane and point
+ CONSTRUCTIONAPI_EXPORT
+ void setByPlaneAndPoint(const ModelHighAPI_Selection& thePlane,
+ const ModelHighAPI_Selection& thePoint);
+
+ /// Set by two planes
+ CONSTRUCTIONAPI_EXPORT
+ void setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Selection& thePlane2);
+
+ /// Set by two planes
+ CONSTRUCTIONAPI_EXPORT
+ void setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2);
};
-//! Pointer on Axis object
+/// Pointer on Axis object
typedef std::shared_ptr<ConstructionAPI_Axis> AxisPtr;
-/**\ingroup CPPHighAPI
- * \brief Create Axis feature
- */
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
CONSTRUCTIONAPI_EXPORT
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
- const ModelHighAPI_Selection & thePoint1,
- const ModelHighAPI_Selection & thePoint2);
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& theObject1,
+ const ModelHighAPI_Selection& theObject2);
-/**\ingroup CPPHighAPI
- * \brief Create Axis feature
- */
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
CONSTRUCTIONAPI_EXPORT
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
- const ModelHighAPI_Selection & theCylindricalFace);
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& theObject);
-/**\ingroup CPPHighAPI
- * \brief Create Axis feature
- */
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
CONSTRUCTIONAPI_EXPORT
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
- const ModelHighAPI_Selection & thePoint,
- const ModelHighAPI_Double & theX,
- const ModelHighAPI_Double & theY,
- const ModelHighAPI_Double & theZ);
-
-/**\ingroup CPPHighAPI
- * \brief Create Axis feature
- */
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& thePoint,
+ const ModelHighAPI_Double& theX,
+ const ModelHighAPI_Double& theY,
+ const ModelHighAPI_Double& theZ);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
+CONSTRUCTIONAPI_EXPORT
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Double& theDX,
+ const ModelHighAPI_Double& theDY,
+ const ModelHighAPI_Double& theDZ);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
CONSTRUCTIONAPI_EXPORT
-AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
- const ModelHighAPI_Double & theDX,
- const ModelHighAPI_Double & theDY,
- const ModelHighAPI_Double & theDZ);
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+ const ModelHighAPI_Selection& thePlane1,
+ const ModelHighAPI_Double& theOffset1,
+ const bool theReverseOffset1,
+ const ModelHighAPI_Selection& thePlane2,
+ const ModelHighAPI_Double& theOffset2,
+ const bool theReverseOffset2);
-//--------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------
#endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_ */
#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
-#include <algorithm>
-
-/*static GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr);
-static GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection);*/
-
//==================================================================================================
ConstructionAPI_Point::ConstructionAPI_Point(const std::shared_ptr<ModelAPI_Feature>& theFeature)
: ModelHighAPI_Interface(theFeature)
// TODO(spo): check that thePart is not empty
std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
return PointPtr(new ConstructionAPI_Point(aFeature, theObject1, theObject2));
-}
-
-//==================================================================================================
-GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr)
-{
- GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
-
- std::string aShapeTypeStr = theShapeTypeStr;
- std::transform(aShapeTypeStr.begin(), aShapeTypeStr.end(), aShapeTypeStr.begin(), ::tolower);
-
- if(theShapeTypeStr == "compound") {
- aShapeType = GeomAPI_Shape::COMPOUND;
- } else if(theShapeTypeStr == "compsolid") {
- aShapeType = GeomAPI_Shape::COMPSOLID;
- } else if(theShapeTypeStr == "solid") {
- aShapeType = GeomAPI_Shape::SOLID;
- } else if(theShapeTypeStr == "shell") {
- aShapeType = GeomAPI_Shape::SHELL;
- } else if(theShapeTypeStr == "face") {
- aShapeType = GeomAPI_Shape::FACE;
- } else if(theShapeTypeStr == "wire") {
- aShapeType = GeomAPI_Shape::WIRE;
- } else if(theShapeTypeStr == "edge") {
- aShapeType = GeomAPI_Shape::EDGE;
- } else if(theShapeTypeStr == "vertex") {
- aShapeType = GeomAPI_Shape::VERTEX;
- } else if(theShapeTypeStr == "shape") {
- aShapeType = GeomAPI_Shape::SHAPE;
- }
-
- return aShapeType;
-}
-
-//==================================================================================================
-GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection)
-{
- GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
-
- switch(theSelection.variantType()) {
- case ModelHighAPI_Selection::VT_ResultSubShapePair: {
- ResultSubShapePair aPair = theSelection.resultSubShapePair();
- GeomShapePtr aShape = aPair.second;
- if(!aShape.get()) {
- aShape = aPair.first->shape();
- }
- if(!aShape.get()) {
- return aShapeType;
- }
- aShapeType = aShape->shapeType();
- break;
- }
- case ModelHighAPI_Selection::VT_TypeSubShapeNamePair: {
- TypeSubShapeNamePair aPair = theSelection.typeSubShapeNamePair();
- std::string aType = aPair.first;
- aShapeType = shapeTypeByStr(aType);
- break;
- }
- }
-
- return aShapeType;
}*/
{
AttributeStringPtr aMethodTypeAttr = string(ConstructionPlugin_Axis::METHOD());
std::string aMethodType = aMethodTypeAttr->value();
- if (aMethodType == "AxisByPointsCase") {
+ if (aMethodType == CREATION_METHOD_BY_TWO_POINTS()) {
createAxisByTwoPoints();
- } else if (aMethodType == "AxisByCylindricalFaceCase") {
+ } else if (aMethodType == CREATION_METHOD_BY_CYLINDRICAL_FACE()) {
createAxisByCylindricalFace();
- } else if (aMethodType == "AxisByPointAndDirection") {
+ } else if (aMethodType == CREATION_METHOD_BY_POINT_AND_DIRECTION()) {
createAxisByPointAndDirection();
- } else if (aMethodType == "AxisByDimensionsCase") {
+ } else if (aMethodType == CREATION_METHOD_BY_DIMENSIONS()) {
createAxisByDimensions();
} else if(aMethodType == CREATION_METHOD_BY_LINE()) {
createAxisByLine();
return METHOD_ATTR;
}
+ /// Attribute name for creation method.
+ inline static const std::string& CREATION_METHOD_BY_TWO_POINTS()
+ {
+ static const std::string METHOD_ATTR("AxisByPointsCase");
+ return METHOD_ATTR;
+ }
+
+ /// Attribute name for creation method.
+ inline static const std::string& CREATION_METHOD_BY_CYLINDRICAL_FACE()
+ {
+ static const std::string METHOD_ATTR("AxisByCylindricalFaceCase");
+ return METHOD_ATTR;
+ }
+
+ /// Attribute name for creation method.
+ inline static const std::string& CREATION_METHOD_BY_POINT_AND_DIRECTION()
+ {
+ static const std::string METHOD_ATTR("AxisByPointAndDirection");
+ return METHOD_ATTR;
+ }
+
+ /// Attribute name for creation method.
+ inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
+ {
+ static const std::string METHOD_ATTR("AxisByDimensionsCase");
+ return METHOD_ATTR;
+ }
+
/// Attribute name for creation method.
inline static const std::string& CREATION_METHOD_BY_LINE()
{
import math
from ModelAPI import *
+import model
+
aSession = ModelAPI_Session.get()
aDocument = aSession.moduleDocument()
assert (len(anAxisFeature.results()) > 0)
anAxisResult = modelAPI_ResultConstruction(anAxisFeature.firstResult())
assert (anAxisResult is not None)
+
+# Create a sketch with line
+aSession.startOperation()
+anOrigin = GeomAPI_Pnt(0, 0, 0)
+aDirX = GeomAPI_Dir(1, 0, 0)
+aNorm = GeomAPI_Dir(0, 0, 1)
+aSketch = model.addSketch(aPart, GeomAPI_Ax3(anOrigin, aDirX, aNorm))
+aSketchLine = aSketch.addLine(0, 0, 100, 100)
+aSession.finishOperation()
+
+# Test an axis by line
+aSession.startOperation()
+anAxis = model.addAxis(aPart, aSketchLine.result()[0])
+aSession.finishOperation()
+assert (len(anAxis.result()) > 0)
+
+# Create plane
+aSession.startOperation()
+aPlane1 = model.addPlane(aPart, 1, 1, 1, 0)
+aSession.finishOperation()
+
+# Create a sketch with point
+aSession.startOperation()
+anOrigin = GeomAPI_Pnt(0, 0, 0)
+aDirX = GeomAPI_Dir(1, 0, 0)
+aNorm = GeomAPI_Dir(0, 0, 1)
+aSketch = model.addSketch(aPart, GeomAPI_Ax3(anOrigin, aDirX, aNorm))
+aSketchPoint = aSketch.addPoint(50, 50)
+aSession.finishOperation()
+
+# Test an axis by plane and point
+aSession.startOperation()
+anAxis = model.addAxis(aPart, aPlane1.result()[0], aSketchPoint.result()[0])
+aSession.finishOperation()
+assert (len(anAxis.result()) > 0)
+
+# Create plane
+aSession.startOperation()
+aPlane2 = model.addPlane(aPart, 0, 1, 1, 0)
+aSession.finishOperation()
+
+# Test an axis by two planes
+aSession.startOperation()
+anAxis = model.addAxis(aPart, aPlane1.result()[0], aPlane2.result()[0])
+aSession.finishOperation()
+assert (len(anAxis.result()) > 0)
+
+# Test an axis by two planes and offsets
+aSession.startOperation()
+anAxis = model.addAxis(aPart, aPlane1.result()[0], 50, False, aPlane2.result()[0], 100, True)
+aSession.finishOperation()
+assert (len(anAxis.result()) > 0)
<source>
<toolbox id="CreationMethod">
+ <box id="AxisByDimensionsCase" title="By three dimensions" icon="icons/Construction/axis_dxyz_32x32.png">
+ <doublevalue id="DX" label="DX " tooltip="X dimension" default="0"/>
+ <doublevalue id="DY" label="DY " tooltip="Y dimension" default="0"/>
+ <doublevalue id="DZ" label="DZ " tooltip="Z dimension" default="10"/>
+ </box>
<box id="AxisByPointsCase" title="By two points" icon="icons/Construction/by_two_points_32x32.png">
<shape_selector id="FirstPoint"
label="First point"
<validator id="GeomValidators_DifferentShapes"/>
</shape_selector>
</box>
- <box id="AxisByCylindricalFaceCase" title="As axis of cylindrical face" icon="icons/Construction/cylindrical_face_32x32.png">
- <shape_selector id="CylindricalFace"
- label="Main object"
- icon="icons/Construction/circle.png"
- tooltip="Select a cylindrical object"
- shape_types="face">
- <validator id="GeomValidators_Face" parameters="cylinder"/>
- </shape_selector>
- </box>
- <box id="AxisByDimensionsCase" title="By three dimensions" icon="icons/Construction/axis_dxyz_32x32.png">
- <doublevalue id="DX" label="DX " tooltip="X dimension" default="0"/>
- <doublevalue id="DY" label="DY " tooltip="Y dimension" default="0"/>
- <doublevalue id="DZ" label="DZ " tooltip="Z dimension" default="10"/>
- </box>
<box id="by_line" title="By line" icon="icons/Construction/axis_by_line_32x32.png">
<shape_selector id="line"
label="Line"
<validator id="GeomValidators_ShapeType" parameters="line"/>
</shape_selector>
</box>
+ <box id="AxisByCylindricalFaceCase" title="As axis of cylindrical face" icon="icons/Construction/cylindrical_face_32x32.png">
+ <shape_selector id="CylindricalFace"
+ label="Main object"
+ icon="icons/Construction/circle.png"
+ tooltip="Select a cylindrical object"
+ shape_types="face">
+ <validator id="GeomValidators_Face" parameters="cylinder"/>
+ </shape_selector>
+ </box>
<box id="by_plane_and_point" title="By plane and point" icon="icons/Construction/axis_by_plane_and_point_32x32.png">
<shape_selector id="plane"
label="Plane"
aPlane.string("creation_method").setValue("by_other_plane")
aPlane.string("by_other_plane_option").setValue("by_distance_from_other")
aPlane.selection("plane").selectSubShape("face", "Part_1/Extrusion_1_1/Generated_Face_3")
-aPlane.real("distance").setValue(0)
-aPlane.boolean("distance_reverse").setValue(False)
+aPlane.real("distance").setValue(0.001)
+aPlane.boolean("reverse").setValue(False)
aSession.finishOperation()
#=========================================================================
END_INIT() \
public:
+//--------------------------------------------------------------------------------------
+#define INTERFACE_21(KIND, \
+ N_0, AN_0, T_0, C_0, \
+ N_1, AN_1, T_1, C_1, \
+ N_2, AN_2, T_2, C_2, \
+ N_3, AN_3, T_3, C_3, \
+ N_4, AN_4, T_4, C_4, \
+ N_5, AN_5, T_5, C_5, \
+ N_6, AN_6, T_6, C_6, \
+ N_7, AN_7, T_7, C_7, \
+ N_8, AN_8, T_8, C_8, \
+ N_9, AN_9, T_9, C_9, \
+ N_10, AN_10, T_10, C_10, \
+ N_11, AN_11, T_11, C_11, \
+ N_12, AN_12, T_12, C_12, \
+ N_13, AN_13, T_13, C_13, \
+ N_14, AN_14, T_14, C_14, \
+ N_15, AN_15, T_15, C_15, \
+ N_16, AN_16, T_16, C_16, \
+ N_17, AN_17, T_17, C_17, \
+ N_18, AN_18, T_18, C_18, \
+ N_19, AN_19, T_19, C_19, \
+ N_20, AN_20, T_20, C_20) \
+ public: \
+ INTERFACE_COMMON(KIND) \
+ DEFINE_ATTRIBUTE(N_0, T_0, C_0) \
+ DEFINE_ATTRIBUTE(N_1, T_1, C_1) \
+ DEFINE_ATTRIBUTE(N_2, T_2, C_2) \
+ DEFINE_ATTRIBUTE(N_3, T_3, C_3) \
+ DEFINE_ATTRIBUTE(N_4, T_4, C_4) \
+ DEFINE_ATTRIBUTE(N_5, T_5, C_5) \
+ DEFINE_ATTRIBUTE(N_6, T_6, C_6) \
+ DEFINE_ATTRIBUTE(N_7, T_7, C_7) \
+ DEFINE_ATTRIBUTE(N_8, T_8, C_8) \
+ DEFINE_ATTRIBUTE(N_9, T_9, C_9) \
+ DEFINE_ATTRIBUTE(N_10, T_10, C_10) \
+ DEFINE_ATTRIBUTE(N_11, T_11, C_11) \
+ DEFINE_ATTRIBUTE(N_12, T_12, C_12) \
+ DEFINE_ATTRIBUTE(N_13, T_13, C_13) \
+ DEFINE_ATTRIBUTE(N_14, T_14, C_14) \
+ DEFINE_ATTRIBUTE(N_15, T_15, C_15) \
+ DEFINE_ATTRIBUTE(N_16, T_16, C_16) \
+ DEFINE_ATTRIBUTE(N_17, T_17, C_17) \
+ DEFINE_ATTRIBUTE(N_18, T_18, C_18) \
+ DEFINE_ATTRIBUTE(N_19, T_19, C_19) \
+ DEFINE_ATTRIBUTE(N_20, T_20, C_20) \
+ protected: \
+ START_INIT() \
+ SET_ATTRIBUTE(N_0, T_0, AN_0) \
+ SET_ATTRIBUTE(N_1, T_1, AN_1) \
+ SET_ATTRIBUTE(N_2, T_2, AN_2) \
+ SET_ATTRIBUTE(N_3, T_3, AN_3) \
+ SET_ATTRIBUTE(N_4, T_4, AN_4) \
+ SET_ATTRIBUTE(N_5, T_5, AN_5) \
+ SET_ATTRIBUTE(N_6, T_6, AN_6) \
+ SET_ATTRIBUTE(N_7, T_7, AN_7) \
+ SET_ATTRIBUTE(N_8, T_8, AN_8) \
+ SET_ATTRIBUTE(N_9, T_9, AN_9) \
+ SET_ATTRIBUTE(N_10, T_10, AN_10) \
+ SET_ATTRIBUTE(N_11, T_11, AN_11) \
+ SET_ATTRIBUTE(N_12, T_12, AN_12) \
+ SET_ATTRIBUTE(N_13, T_13, AN_13) \
+ SET_ATTRIBUTE(N_14, T_14, AN_14) \
+ SET_ATTRIBUTE(N_15, T_15, AN_15) \
+ SET_ATTRIBUTE(N_16, T_16, AN_16) \
+ SET_ATTRIBUTE(N_17, T_17, AN_17) \
+ SET_ATTRIBUTE(N_18, T_18, AN_18) \
+ SET_ATTRIBUTE(N_19, T_19, AN_19) \
+ SET_ATTRIBUTE(N_20, T_20, AN_20) \
+ END_INIT() \
+ public:
+
//--------------------------------------------------------------------------------------
#endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_MACRO_H_ */
#include "ModelHighAPI_RefAttr.h"
#include "ModelHighAPI_Selection.h"
+#include <algorithm>
+
//--------------------------------------------------------------------------------------
void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d> & theValue,
const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute)
theAttribute->setValue(theValue);
}
+//==================================================================================================
+GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr)
+{
+ GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
+
+ std::string aShapeTypeStr = theShapeTypeStr;
+ std::transform(aShapeTypeStr.begin(), aShapeTypeStr.end(), aShapeTypeStr.begin(), ::tolower);
+
+ if(theShapeTypeStr == "compound") {
+ aShapeType = GeomAPI_Shape::COMPOUND;
+ } else if(theShapeTypeStr == "compsolid") {
+ aShapeType = GeomAPI_Shape::COMPSOLID;
+ } else if(theShapeTypeStr == "solid") {
+ aShapeType = GeomAPI_Shape::SOLID;
+ } else if(theShapeTypeStr == "shell") {
+ aShapeType = GeomAPI_Shape::SHELL;
+ } else if(theShapeTypeStr == "face") {
+ aShapeType = GeomAPI_Shape::FACE;
+ } else if(theShapeTypeStr == "wire") {
+ aShapeType = GeomAPI_Shape::WIRE;
+ } else if(theShapeTypeStr == "edge") {
+ aShapeType = GeomAPI_Shape::EDGE;
+ } else if(theShapeTypeStr == "vertex") {
+ aShapeType = GeomAPI_Shape::VERTEX;
+ } else if(theShapeTypeStr == "shape") {
+ aShapeType = GeomAPI_Shape::SHAPE;
+ }
+
+ return aShapeType;
+}
+
+//==================================================================================================
+GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection)
+{
+ GeomAPI_Shape::ShapeType aShapeType = GeomAPI_Shape::SHAPE;
+
+ switch(theSelection.variantType()) {
+ case ModelHighAPI_Selection::VT_ResultSubShapePair: {
+ ResultSubShapePair aPair = theSelection.resultSubShapePair();
+ GeomShapePtr aShape = aPair.second;
+ if(!aShape.get()) {
+ aShape = aPair.first->shape();
+ }
+ if(!aShape.get()) {
+ return aShapeType;
+ }
+ aShapeType = aShape->shapeType();
+ break;
+ }
+ case ModelHighAPI_Selection::VT_TypeSubShapeNamePair: {
+ TypeSubShapeNamePair aPair = theSelection.typeSubShapeNamePair();
+ std::string aType = aPair.first;
+ aShapeType = shapeTypeByStr(aType);
+ break;
+ }
+ }
+
+ return aShapeType;
+}
+
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
#include "ModelHighAPI.h"
+#include <GeomAPI_Shape.h>
+
#include <list>
#include <memory>
#include <string>
void fillAttribute(const char * theValue,
const std::shared_ptr<ModelAPI_AttributeString> & theAttribute);
+MODELHIGHAPI_EXPORT
+GeomAPI_Shape::ShapeType shapeTypeByStr(const std::string& theShapeTypeStr);
+
+MODELHIGHAPI_EXPORT
+GeomAPI_Shape::ShapeType getShapeType(const ModelHighAPI_Selection& theSelection);
+
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
#endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_TOOLS_H_ */