INSTALL(FILES ${TEXT_RESOURCES} DESTINATION ${SHAPER_INSTALL_XML_RESOURCES})
ADD_UNIT_TESTS(TestExtrusion.py
+ TestExtrusionOfCompound.py
TestExtrusionCut.py
TestExtrusionCut_BySize.py
TestExtrusionCut_ByPlanesAndOffsets.py
TestExtrusion_ZeroOffsetError.py
TestRevolution.py
TestRevolution_ByAngle.py
+ TestRevolutionOfPoint.py
+ TestRevolutionOfEdge.py
TestRevolutionCut.py
TestRevolutionCut_ByAngle.py
TestRevolutionCut_ByPlanesAndOffsets.py
#include <ModelAPI_Validator.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
-#include <GeomAlgoAPI_Prism.h>
#include <GeomAlgoAPI_Revolution.h>
#include <GeomAlgoAPI_ShapeTools.h>
#include <GeomAlgoAPI_SketchBuilder.h>
--- /dev/null
+## Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOY"))
+SketchCircle_1 = Sketch_1.addCircle(15, -20, 8)
+SketchCircle_2 = Sketch_1.addCircle(35, -5, 15)
+model.do()
+Compound_1 = model.addCompound(Part_1_doc, [model.selection("FACE", "Sketch_1/Face-SketchCircle_1_2r"), model.selection("FACE", "Sketch_1/Face-SketchCircle_2_2f")])
+Extrusion_1 = model.addExtrusion(Part_1_doc, [model.selection("COMPOUND", "Compound_1_1")], model.selection(), model.selection(), 0, model.selection("FACE", "PartSet/XOY"), 10)
+model.do()
+model.end()
+
+from GeomAPI import GeomAPI_Shape
+
+model.testNbResults(Extrusion_1, 1)
+model.testNbSubResults(Extrusion_1, [2])
+model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.SOLID, [2])
+model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.FACE, [6])
+model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.EDGE, [12])
+model.testNbSubShapes(Extrusion_1, GeomAPI_Shape.VERTEX, [24])
+model.testResultsVolumes(Extrusion_1, [9079.2027688745])
+
+assert(model.checkPythonDump())
\ No newline at end of file
--- /dev/null
+## Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+from GeomAPI import GeomAPI_Shape
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Point_2 = model.addPoint(Part_1_doc, 10, 0, 0)
+Point_3 = model.addPoint(Part_1_doc, 20, 0, 10)
+Polyline_1 = model.addPolyline3D(Part_1_doc, [model.selection("VERTEX", "Point_1"), model.selection("VERTEX", "Point_2")], False)
+
+Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("EDGE", "Polyline_1_1/Generated_Edge&Point_1/Point_1")], model.selection("EDGE", "PartSet/OZ"), model.selection(), 0, model.selection("FACE", "PartSet/XOZ"), 0)
+
+model.testNbResults(Revolution_1, 1)
+model.testNbSubResults(Revolution_1, [0])
+model.testNbSubShapes(Revolution_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Revolution_1, GeomAPI_Shape.FACE, [1])
+model.testNbSubShapes(Revolution_1, GeomAPI_Shape.EDGE, [4])
+model.testNbSubShapes(Revolution_1, GeomAPI_Shape.VERTEX, [8])
+model.testResultsVolumes(Revolution_1, [666.43244])
+
+Revolution_1.setPlanesAndOffsets(model.selection("FACE", "PartSet/YOZ"), 0, model.selection("FACE", "PartSet/XOZ"), 0)
+
+model.testNbResults(Revolution_1, 1)
+model.testNbSubResults(Revolution_1, [0])
+model.testNbSubShapes(Revolution_1, GeomAPI_Shape.SOLID, [0])
+model.testNbSubShapes(Revolution_1, GeomAPI_Shape.FACE, [1])
+model.testNbSubShapes(Revolution_1, GeomAPI_Shape.EDGE, [4])
+model.testNbSubShapes(Revolution_1, GeomAPI_Shape.VERTEX, [8])
+model.testResultsVolumes(Revolution_1, [333.21622])
+
+model.end()
+
+assert(model.checkPythonDump())
--- /dev/null
+## Copyright (C) 2018-20xx CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+from GeomAPI import *
+
+import math
+
+def checkMiddlePoint(shape, x, y, z, tolerance = 1.e-7):
+ assert(shape is not None)
+ assert(shape.isEdge())
+ middlePoint = shape.middlePoint()
+ assert(math.fabs(middlePoint.x() - x) < tolerance), "{} != {}".format(middlePoint.x(), x)
+ assert(math.fabs(middlePoint.y() - y) < tolerance), "{} != {}".format(middlePoint.y(), y)
+ assert(math.fabs(middlePoint.z() - z) < tolerance), "{} != {}".format(middlePoint.z(), z)
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Point_2 = model.addPoint(Part_1_doc, 10, 0, 0)
+Vertex_1 = model.addVertex(Part_1_doc, [model.selection("VERTEX", "Point_1")])
+
+Revolution_1 = model.addRevolution(Part_1_doc, [model.selection("VERTEX", "Vertex_1_1")], model.selection("EDGE", "PartSet/OZ"), model.selection(), 0, model.selection("FACE", "PartSet/XOZ"), 0)
+Shape = Revolution_1.results()[0].resultSubShapePair()[0].shape()
+checkMiddlePoint(Shape, 0, -10, 0)
+
+Revolution_1.setPlanesAndOffsets(model.selection("FACE", "PartSet/YOZ"), 0, model.selection("FACE", "PartSet/XOZ"), 0)
+Shape = Revolution_1.results()[0].resultSubShapePair()[0].shape()
+checkMiddlePoint(Shape, 7.071067811865474, -7.071067811865474, 0)
+
+model.end()
+
+assert(model.checkPythonDump())
const TopoDS_Face& theFromFace);
-//==================================================================================================
-GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
- const double theToSize,
- const double theFromSize)
-{
- build(theBaseShape, std::shared_ptr<GeomAPI_Dir>(), GeomShapePtr(),
- theToSize, GeomShapePtr(), theFromSize);
-}
-
-//==================================================================================================
-GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
- const std::shared_ptr<GeomAPI_Dir> theDirection,
- const double theToSize,
- const double theFromSize)
-{
- build(theBaseShape, theDirection, GeomShapePtr(), theToSize, GeomShapePtr(), theFromSize);
-}
-
-//==================================================================================================
-GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
- const GeomShapePtr theToShape,
- const double theToSize,
- const GeomShapePtr theFromShape,
- const double theFromSize)
-{
- build(theBaseShape, std::shared_ptr<GeomAPI_Dir>(), theToShape,
- theToSize, theFromShape, theFromSize);
-}
-
//==================================================================================================
GeomAlgoAPI_Prism::GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
const std::shared_ptr<GeomAPI_Dir> theDirection,
class GeomAlgoAPI_Prism : public GeomAlgoAPI_MakeSweep
{
public:
- /// \brief Creates extrusion for the given shape along the normal for this shape.
- /// \param[in] theBaseShape planar face or wire to be extruded.
- /// \param[in] theToSize offset for "to" plane.
- /// \param[in] theFromSize offset for "from" plane.
- GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
- const double theToSize,
- const double theFromSize);
-
- /// \brief Creates extrusion for the given shape along the normal for this shape.
- /// \param[in] theBaseShape vertex, edge, wire, face or shell.
- /// \param[in] theDirection direction of extrusion.
- /// Can be empty if theBaseShape is planar wire or face.
- /// \param[in] theToSize offset for "to" plane.
- /// \param[in] theFromSize offset for "from" plane.
- GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
- const std::shared_ptr<GeomAPI_Dir> theDirection,
- const double theToSize,
- const double theFromSize);
-
- /// \brief Creates extrusion for the given shape along the normal for this shape.
- /// \param[in] theBaseShape planar face or wire to be extruded.
- /// \param[in] theToShape top bounding shape. Can be empty.
- /// In this case offset will be applied to the basis.
- /// \param[in] theToSize offset for "to" plane.
- /// \param[in] theFromShape bottom bounding shape. Can be empty.
- /// In this case offset will be applied to the basis.
- /// \param[in] theFromSize offset for "from" plane.
- GEOMALGOAPI_EXPORT GeomAlgoAPI_Prism(const GeomShapePtr theBaseShape,
- const GeomShapePtr theToShape,
- const double theToSize,
- const GeomShapePtr theFromShape,
- const double theFromSize);
-
/// \brief Creates extrusion for the given shape along the normal for this shape.
/// \param[in] theBaseShape planar face or wire to be extruded.
/// \param[in] theDirection direction of extrusion.
const TopoDS_Shape& theModifiedBaseShape,
const bool theIsFromFaceSet);
-//==================================================================================================
-GeomAlgoAPI_Revolution::GeomAlgoAPI_Revolution(const GeomShapePtr theBaseShape,
- const std::shared_ptr<GeomAPI_Ax1> theAxis,
- const double theToAngle,
- const double theFromAngle)
-{
- build(theBaseShape, theAxis, GeomShapePtr(), theToAngle, GeomShapePtr(), theFromAngle);
-}
-
//==================================================================================================
GeomAlgoAPI_Revolution::GeomAlgoAPI_Revolution(const GeomShapePtr theBaseShape,
const std::shared_ptr<GeomAPI_Ax1> theAxis,
class GeomAlgoAPI_Revolution : public GeomAlgoAPI_MakeSweep
{
public:
- /// \brief Creates revolution for the given shape.
- /// \param[in] theBaseShape face for revolution.
- /// \param[in] theAxis axis for revolution.
- /// \param[in] theToAngle to angle.
- /// \param[in] theFromAngle from angle.
- GEOMALGOAPI_EXPORT GeomAlgoAPI_Revolution(const GeomShapePtr theBaseShape,
- const std::shared_ptr<GeomAPI_Ax1> theAxis,
- const double theToAngle,
- const double theFromAngle);
-
/// \brief Creates revolution for the given shape.
/// \param[in] theBaseShape face for revolution.
/// \param[in] theAxis axis for revolution.
return aResultPoints;
}
-//==================================================================================================
-std::shared_ptr<GeomAPI_Shape>
- GeomAlgoAPI_ShapeTools::faceToInfinitePlane(const std::shared_ptr<GeomAPI_Shape> theFace)
-{
- if (!theFace.get())
- return std::shared_ptr<GeomAPI_Shape>();
-
- TopoDS_Face aPlaneFace = TopoDS::Face(theFace->impl<TopoDS_Shape>());
- if (aPlaneFace.IsNull())
- return std::shared_ptr<GeomAPI_Shape>();
-
- Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(BRep_Tool::Surface(aPlaneFace));
- if (aPlane.IsNull())
- return std::shared_ptr<GeomAPI_Shape>();
-
- // make an infinity face on the plane
- TopoDS_Shape anInfiniteFace = BRepBuilderAPI_MakeFace(aPlane->Pln()).Shape();
-
- std::shared_ptr<GeomAPI_Shape> aResult(new GeomAPI_Shape);
- aResult->setImpl(new TopoDS_Shape(anInfiniteFace));
- return aResult;
-}
-
//==================================================================================================
std::shared_ptr<GeomAPI_Face> GeomAlgoAPI_ShapeTools::fitPlaneToBox(
const std::shared_ptr<GeomAPI_Shape> thePlane,
}
//==================================================================================================
+#ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS
std::shared_ptr<GeomAPI_Dir> GeomAlgoAPI_ShapeTools::buildDirFromAxisAndShape(
const std::shared_ptr<GeomAPI_Shape> theBaseShape,
const std::shared_ptr<GeomAPI_Ax1> theAxis)
aCentreOfMassPoint.Z()-aPoint.Z()));
return aDir;
}
+#endif
//==================================================================================================
static TopoDS_Wire fixParametricGaps(const TopoDS_Wire& theWire)
std::list<std::shared_ptr<GeomAPI_Pnt> > getBoundingBox(const ListOfShape& theShapes,
const double theEnlarge = 0.0);
- /// \return infinite plane received from theFace plane.
- GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape>
- faceToInfinitePlane(const std::shared_ptr<GeomAPI_Shape> theFace);
-
/// \brief Enlarges or reduces plane to fit bounding box.
/// \return plane that fits to bounding box.
/// \param[in] thePlane base plane.
const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints,
const std::set<std::shared_ptr<GeomAPI_Shape> >& theShapes);
+#ifdef FEATURE_MULTIROTATION_TWO_DIRECTIONS
/// \brief Returns a dir from a shape and an axis.
/// \param[in] theBaseShape shape whose center of mass serves as the starting point of the dir.
/// \param[in] theAxis axis that serves as a direction for the dir
GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Dir> buildDirFromAxisAndShape(
const std::shared_ptr<GeomAPI_Shape> theBaseShape,
const std::shared_ptr<GeomAPI_Ax1> theAxis);
+#endif
/// \brief Reapproximate a wire to build a single edge
GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Edge> wireToEdge(