]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1649: Added CPP High API for Plane feature;
authordbv <dbv@opencascade.com>
Wed, 3 Aug 2016 13:10:18 +0000 (16:10 +0300)
committerdbv <dbv@opencascade.com>
Wed, 3 Aug 2016 13:10:18 +0000 (16:10 +0300)
Added test cases for Plane feature.

src/ConstructionAPI/ConstructionAPI_Axis.cpp
src/ConstructionAPI/ConstructionAPI_Plane.cpp
src/ConstructionAPI/ConstructionAPI_Plane.h
src/ConstructionPlugin/CMakeLists.txt
src/ConstructionPlugin/ConstructionPlugin_Plane.cpp
src/ConstructionPlugin/Test/TestPlane.py [new file with mode: 0644]
src/FeaturesPlugin/FeaturesPlugin_Partition.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeTools.h
src/ModelHighAPI/ModelHighAPI.i
src/ModelHighAPI/ModelHighAPI_Macro.h

index ab3cf13b18a36a33fa5910c52299c9c334842b9f..132adba5124a93bf623cbb65a9f05b0913d46054 100644 (file)
@@ -26,9 +26,9 @@ ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Featur
     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) {
+    } else if(aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::VERTEX) {
       setByPlaneAndPoint(theObject1, theObject2);
-    } else if (aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::FACE) {
+    } else if(aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::FACE) {
       setByTwoPlanes(theObject1, theObject2);
     }
   }
index 2ea1b567ddab97e89450a12517b2f13669d1f5c5..fdde03ebb39359a00f0d148482e3a5e057e90fc8 100644 (file)
 
 #include <ModelHighAPI_Tools.h>
 
-ConstructionAPI_Plane::ConstructionAPI_Plane(
-    const std::shared_ptr<ModelAPI_Feature> & theFeature)
+//==================================================================================================
+ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature)
 : ModelHighAPI_Interface(theFeature)
 {
   initialize();
 }
 
-ConstructionAPI_Plane::ConstructionAPI_Plane(
-    const std::shared_ptr<ModelAPI_Feature> & theFeature,
-    const ModelHighAPI_Selection & theFace,
-    const ModelHighAPI_Double & theDistance)
+//==================================================================================================
+ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                             const ModelHighAPI_Selection& theFace,
+                                             const ModelHighAPI_Double& theDistance,
+                                             const bool theIsReverse)
 : ModelHighAPI_Interface(theFeature)
 {
-  if (initialize())
-    setFaceAndDistance(theFace, theDistance);
+  if(initialize()) {
+    setByFaceAndDistance(theFace, theDistance, theIsReverse);
+  }
 }
 
-ConstructionAPI_Plane::ConstructionAPI_Plane(
-    const std::shared_ptr<ModelAPI_Feature> & theFeature,
-    const ModelHighAPI_Double & theA,
-    const ModelHighAPI_Double & theB,
-    const ModelHighAPI_Double & theC,
-    const ModelHighAPI_Double & theD)
+//==================================================================================================
+ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                             const ModelHighAPI_Double& theA,
+                                             const ModelHighAPI_Double& theB,
+                                             const ModelHighAPI_Double& theC,
+                                             const ModelHighAPI_Double& theD)
 : ModelHighAPI_Interface(theFeature)
 {
-  if (initialize())
-    setGeneralEquation(theA, theB, theC, theD);
+  if(initialize()) {
+    setByGeneralEquation(theA, theB, theC, theD);
+  }
 }
 
-ConstructionAPI_Plane::~ConstructionAPI_Plane()
+//==================================================================================================
+ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                             const ModelHighAPI_Selection& thePoint1,
+                                             const ModelHighAPI_Selection& thePoint2,
+                                             const ModelHighAPI_Selection& thePoint3)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setByThreePoints(thePoint1, thePoint2, thePoint3);
+  }
+}
+
+//==================================================================================================
+ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                             const ModelHighAPI_Selection& theLine,
+                                             const ModelHighAPI_Selection& thePoint,
+                                             const bool theIsPerpendicular)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setByLineAndPoint(theLine, thePoint, theIsPerpendicular);
+  }
+}
+
+//==================================================================================================
+ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                             const ModelHighAPI_Selection& theObject1,
+                                             const ModelHighAPI_Selection& theObject2)
+: ModelHighAPI_Interface(theFeature)
 {
+  if(initialize()) {
+    GeomAPI_Shape::ShapeType aType1 = getShapeType(theObject1);
+    GeomAPI_Shape::ShapeType aType2 = getShapeType(theObject2);
+    if(aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::VERTEX) {
+      setByCoincidentToPoint(theObject1, theObject2);
+    } else if(aType1 == GeomAPI_Shape::FACE && aType2 == GeomAPI_Shape::FACE) {
+      setByTwoParallelPlanes(theObject1, theObject2);
+    }
+  }
+}
 
+//==================================================================================================
+ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                             const ModelHighAPI_Selection& thePlane,
+                                             const ModelHighAPI_Selection& theAxis,
+                                             const ModelHighAPI_Double& theAngle)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setByRotation(thePlane, theAxis, theAngle);
+  }
 }
 
-//--------------------------------------------------------------------------------------
-void ConstructionAPI_Plane::setFaceAndDistance(
-    const ModelHighAPI_Selection & theFace,
-    const ModelHighAPI_Double & theDistance)
+//==================================================================================================
+ConstructionAPI_Plane::~ConstructionAPI_Plane()
 {
-  fillAttribute("PlaneByFaceAndDistance", mycreationMethod);
+}
+
+//==================================================================================================
+void ConstructionAPI_Plane::setByFaceAndDistance(const ModelHighAPI_Selection& theFace,
+                                                 const ModelHighAPI_Double& theDistance,
+                                                 const bool theIsReverse)
+{
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE(), mycreationMethod);
   fillAttribute(theFace, myplane);
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_DISTANCE_FROM_OTHER(), mycreationMethodByOtherPlane);
   fillAttribute(theDistance, mydistance);
+  fillAttribute(theIsReverse, myreverse);
 
   execute();
 }
 
-void ConstructionAPI_Plane::setGeneralEquation(
-    const ModelHighAPI_Double & theA,
-    const ModelHighAPI_Double & theB,
-    const ModelHighAPI_Double & theC,
-    const ModelHighAPI_Double & theD)
+//==================================================================================================
+void ConstructionAPI_Plane::setByGeneralEquation(const ModelHighAPI_Double& theA,
+                                                 const ModelHighAPI_Double& theB,
+                                                 const ModelHighAPI_Double& theC,
+                                                 const ModelHighAPI_Double& theD)
 {
   fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_GENERAL_EQUATION(), mycreationMethod);
   fillAttribute(theA, myA);
@@ -69,23 +127,131 @@ void ConstructionAPI_Plane::setGeneralEquation(
   execute();
 }
 
-//--------------------------------------------------------------------------------------
-PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
-                  const ModelHighAPI_Selection & theFace,
-                  const ModelHighAPI_Double & theDistance)
+//==================================================================================================
+void ConstructionAPI_Plane::setByThreePoints(const ModelHighAPI_Selection& thePoint1,
+                                             const ModelHighAPI_Selection& thePoint2,
+                                             const ModelHighAPI_Selection& thePoint3)
+{
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_THREE_POINTS(), mycreationMethod);
+  fillAttribute(thePoint1, mypoint1);
+  fillAttribute(thePoint2, mypoint2);
+  fillAttribute(thePoint3, mypoint3);
+
+  execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Plane::setByLineAndPoint(const ModelHighAPI_Selection& theLine,
+                                              const ModelHighAPI_Selection& thePoint,
+                                              const bool theIsPerpendicular)
+{
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_LINE_AND_POINT(), mycreationMethod);
+  fillAttribute(theLine, myline);
+  fillAttribute(thePoint, mypoint);
+  fillAttribute(theIsPerpendicular, myperpendicular);
+
+  execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Plane::setByTwoParallelPlanes(const ModelHighAPI_Selection& thePlane1,
+                                                   const ModelHighAPI_Selection& thePlane2)
+{
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_TWO_PARALLEL_PLANES(), mycreationMethod);
+  fillAttribute(thePlane1, myplane1);
+  fillAttribute(thePlane2, myplane2);
+
+  execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Plane::setByCoincidentToPoint(const ModelHighAPI_Selection& thePlane,
+                                                   const ModelHighAPI_Selection& thePoint)
+{
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE(), mycreationMethod);
+  fillAttribute(thePlane, myplane);
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_COINCIDENT_TO_POINT(), mycreationMethodByOtherPlane);
+  fillAttribute(thePoint, mycoincidentPoint);
+
+  execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Plane::setByRotation(const ModelHighAPI_Selection& thePlane,
+                                          const ModelHighAPI_Selection& theAxis,
+                                          const ModelHighAPI_Double& theAngle)
+{
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE(), mycreationMethod);
+  fillAttribute(thePlane, myplane);
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_ROTATION(), mycreationMethodByOtherPlane);
+  fillAttribute(theAxis, myaxis);
+  fillAttribute(theAngle, myangle);
+
+  execute();
+}
+
+//==================================================================================================
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& theFace,
+                  const ModelHighAPI_Double& theDistance,
+                  const bool theIsReverse)
 {
   // TODO(spo): check that thePart is not empty
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
-  return PlanePtr(new ConstructionAPI_Plane(aFeature, theFace, theDistance));
+  return PlanePtr(new ConstructionAPI_Plane(aFeature, theFace, theDistance, theIsReverse));
 }
 
-PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
-                  const ModelHighAPI_Double & theA,
-                  const ModelHighAPI_Double & theB,
-                  const ModelHighAPI_Double & theC,
-                  const ModelHighAPI_Double & theD)
+//==================================================================================================
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Double& theA,
+                  const ModelHighAPI_Double& theB,
+                  const ModelHighAPI_Double& theC,
+                  const ModelHighAPI_Double& theD)
 {
   // TODO(spo): check that thePart is not empty
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
   return PlanePtr(new ConstructionAPI_Plane(aFeature, theA, theB, theC, theD));
 }
+
+//==================================================================================================
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& thePoint1,
+                  const ModelHighAPI_Selection& thePoint2,
+                  const ModelHighAPI_Selection& thePoint3)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
+  return PlanePtr(new ConstructionAPI_Plane(aFeature, thePoint1, thePoint2, thePoint3));
+}
+
+//==================================================================================================
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& theLine,
+                  const ModelHighAPI_Selection& thePoint,
+                  const bool theIsPerpendicular)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
+  return PlanePtr(new ConstructionAPI_Plane(aFeature, theLine, thePoint, theIsPerpendicular));
+}
+
+//==================================================================================================
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& theObject1,
+                  const ModelHighAPI_Selection& theObject2)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
+  return PlanePtr(new ConstructionAPI_Plane(aFeature, theObject1, theObject2));
+}
+
+//==================================================================================================
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& thePlane,
+                  const ModelHighAPI_Selection& theAxis,
+                  const ModelHighAPI_Double& theAngle)
+{
+  // TODO(spo): check that thePart is not empty
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
+  return PlanePtr(new ConstructionAPI_Plane(aFeature, thePlane, theAxis, theAngle));
+}
index 7713d19cde41bffe197151aabc79f1f10669ca81..2aaac52290ab71e0b6697cb4e421219d50537bcc 100644 (file)
 #ifndef SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_PLANE_H_
 #define SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_PLANE_H_
 
-//--------------------------------------------------------------------------------------
 #include "ConstructionAPI.h"
 
 #include <ConstructionPlugin_Plane.h>
 
 #include <ModelHighAPI_Interface.h>
 #include <ModelHighAPI_Macro.h>
-//--------------------------------------------------------------------------------------
+
 class ModelHighAPI_Double;
 class ModelHighAPI_Selection;
-//--------------------------------------------------------------------------------------
-/**\class ConstructionAPI_Plane
- * \ingroup CPPHighAPI
- * \brief Interface for Plane feature
- */
-class ConstructionAPI_Plane : public ModelHighAPI_Interface
+
+/// \class ConstructionAPI_Plane
+/// \ingroup CPPHighAPI
+/// \brief Interface for Plane feature
+class ConstructionAPI_Plane: public ModelHighAPI_Interface
 {
 public:
   /// Constructor without values
   CONSTRUCTIONAPI_EXPORT
-  explicit ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+  explicit ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature);
+
+  /// Constructor with values
+  CONSTRUCTIONAPI_EXPORT
+  ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                        const ModelHighAPI_Selection& theFace,
+                        const ModelHighAPI_Double& theDistance,
+                        const bool theIsReverse);
+
   /// Constructor with values
   CONSTRUCTIONAPI_EXPORT
-  ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature> & theFeature,
-                        const ModelHighAPI_Selection & theFace,
-                        const ModelHighAPI_Double & theDistance);
+  ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                        const ModelHighAPI_Double& theA,
+                        const ModelHighAPI_Double& theB,
+                        const ModelHighAPI_Double& theC,
+                        const ModelHighAPI_Double& theD);
+
+  /// Constructor with values
+  CONSTRUCTIONAPI_EXPORT
+  ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                        const ModelHighAPI_Selection& thePoint1,
+                        const ModelHighAPI_Selection& thePoint2,
+                        const ModelHighAPI_Selection& thePoint3);
+
   /// Constructor with values
   CONSTRUCTIONAPI_EXPORT
-  ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature> & theFeature,
-                        const ModelHighAPI_Double & theA,
-                        const ModelHighAPI_Double & theB,
-                        const ModelHighAPI_Double & theC,
-                        const ModelHighAPI_Double & theD);
+  ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                        const ModelHighAPI_Selection& theLine,
+                        const ModelHighAPI_Selection& thePoint,
+                        const bool theIsPerpendicular);
+
+  /// Constructor with values
+  CONSTRUCTIONAPI_EXPORT
+  ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                        const ModelHighAPI_Selection& theObject1,
+                        const ModelHighAPI_Selection& theObject2);
+
+  /// Constructor with values
+  CONSTRUCTIONAPI_EXPORT
+  ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                        const ModelHighAPI_Selection& thePlane,
+                        const ModelHighAPI_Selection& theAxis,
+                        const ModelHighAPI_Double& theAngle);
+
   /// Destructor
   CONSTRUCTIONAPI_EXPORT
   virtual ~ConstructionAPI_Plane();
 
-  INTERFACE_7(ConstructionPlugin_Plane::ID(),
-              creationMethod, ConstructionPlugin_Plane::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */,
-              A, ConstructionPlugin_Plane::A(), ModelAPI_AttributeDouble, /** Parameter A for general equation */,
-              B, ConstructionPlugin_Plane::B(), ModelAPI_AttributeDouble, /** Parameter B for general equation */,
-              C, ConstructionPlugin_Plane::C(), ModelAPI_AttributeDouble, /** Parameter C for general equation */,
-              D, ConstructionPlugin_Plane::D(), ModelAPI_AttributeDouble, /** Parameter D for general equation */,
-              plane, ConstructionPlugin_Plane::PLANE(), ModelAPI_AttributeSelection, /** Plane face */,
-              distance, ConstructionPlugin_Plane::DISTANCE(), ModelAPI_AttributeDouble, /** Distance */
- )
+  INTERFACE_20(ConstructionPlugin_Plane::ID(),
+               creationMethod, ConstructionPlugin_Plane::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */,
+               A, ConstructionPlugin_Plane::A(), ModelAPI_AttributeDouble, /** Parameter A for general equation */,
+               B, ConstructionPlugin_Plane::B(), ModelAPI_AttributeDouble, /** Parameter B for general equation */,
+               C, ConstructionPlugin_Plane::C(), ModelAPI_AttributeDouble, /** Parameter C for general equation */,
+               D, ConstructionPlugin_Plane::D(), ModelAPI_AttributeDouble, /** Parameter D for general equation */,
+               point1, ConstructionPlugin_Plane::POINT1(), ModelAPI_AttributeSelection, /** Point 1 for plane */,
+               point2, ConstructionPlugin_Plane::POINT2(), ModelAPI_AttributeSelection, /** Point 2 for plane */,
+               point3, ConstructionPlugin_Plane::POINT3(), ModelAPI_AttributeSelection, /** Point 3 for plane */,
+               line, ConstructionPlugin_Plane::LINE(), ModelAPI_AttributeSelection, /** Line for plane */,
+               point, ConstructionPlugin_Plane::POINT(), ModelAPI_AttributeSelection, /** Point for plane */,
+               perpendicular, ConstructionPlugin_Plane::PERPENDICULAR(), ModelAPI_AttributeBoolean, /** Perpendicular flag */,
+               creationMethodByOtherPlane, ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE_OPTION(), ModelAPI_AttributeString, /** Creation method  by other plane*/,
+               plane, ConstructionPlugin_Plane::PLANE(), ModelAPI_AttributeSelection, /** Plane face */,
+               distance, ConstructionPlugin_Plane::DISTANCE(), ModelAPI_AttributeDouble, /** Distance */,
+               reverse, ConstructionPlugin_Plane::REVERSE(), ModelAPI_AttributeBoolean, /** Reverse flag */,
+               coincidentPoint, ConstructionPlugin_Plane::COINCIDENT_POINT(), ModelAPI_AttributeSelection, /** Coincident point */,
+               axis, ConstructionPlugin_Plane::AXIS(), ModelAPI_AttributeSelection, /** Axis for rotation */,
+               angle, ConstructionPlugin_Plane::ANGLE(), ModelAPI_AttributeDouble, /** Rotation angle */,
+               plane1, ConstructionPlugin_Plane::PLANE1(), ModelAPI_AttributeSelection, /** Plane 1 */,
+               plane2, ConstructionPlugin_Plane::PLANE2(), ModelAPI_AttributeSelection, /** Plane 2 */)
 
   /// Set face and distance
   CONSTRUCTIONAPI_EXPORT
-  void setFaceAndDistance(const ModelHighAPI_Selection& theFace,
-                          const ModelHighAPI_Double& theDistance);
+  void setByFaceAndDistance(const ModelHighAPI_Selection& theFace,
+                            const ModelHighAPI_Double& theDistance,
+                            const bool theIsReverse);
 
   /// Set GeneralEquation parameters of the feature
   CONSTRUCTIONAPI_EXPORT
-  void setGeneralEquation(const ModelHighAPI_Double & theA,
-                          const ModelHighAPI_Double & theB,
-                          const ModelHighAPI_Double & theC,
-                          const ModelHighAPI_Double & theD);
+  void setByGeneralEquation(const ModelHighAPI_Double& theA,
+                            const ModelHighAPI_Double& theB,
+                            const ModelHighAPI_Double& theC,
+                            const ModelHighAPI_Double& theD);
+
+  /// Set by three points.
+  CONSTRUCTIONAPI_EXPORT
+  void setByThreePoints(const ModelHighAPI_Selection& thePoint1,
+                        const ModelHighAPI_Selection& thePoint2,
+                        const ModelHighAPI_Selection& thePoint3);
+
+  /// Set by line and point.
+  CONSTRUCTIONAPI_EXPORT
+  void setByLineAndPoint(const ModelHighAPI_Selection& theLine,
+                         const ModelHighAPI_Selection& thePoint,
+                         const bool theIsPerpendicular);
+
+  /// Set by two parallel planes.
+  CONSTRUCTIONAPI_EXPORT
+  void setByTwoParallelPlanes(const ModelHighAPI_Selection& thePlane1,
+                              const ModelHighAPI_Selection& thePlane2);
+
+  /// Set by coincident to point.
+  CONSTRUCTIONAPI_EXPORT
+  void setByCoincidentToPoint(const ModelHighAPI_Selection& thePlane,
+                              const ModelHighAPI_Selection& thePoint);
+
+  /// Set by rotation.
+  CONSTRUCTIONAPI_EXPORT
+  void setByRotation(const ModelHighAPI_Selection& thePlane,
+                     const ModelHighAPI_Selection& theAxis,
+                     const ModelHighAPI_Double& theAngle);
+
 };
 
-//! Pointer on Plane object
+/// Pointer on Plane object
 typedef std::shared_ptr<ConstructionAPI_Plane> PlanePtr;
 
-/**\ingroup CPPHighAPI
- * \brief Create Plane feature
- */
+/// \ingroup CPPHighAPI
+/// \brief Create Plane feature
 CONSTRUCTIONAPI_EXPORT
-PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
-                  const ModelHighAPI_Selection & theFace,
-                  const ModelHighAPI_Double & theDistance);
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& theFace,
+                  const ModelHighAPI_Double& theDistance,
+                  const bool theIsReverse);
 
-/**\ingroup CPPHighAPI
- * \brief Create Plane feature
- */
+/// \ingroup CPPHighAPI
+/// \brief Create Plane feature
 CONSTRUCTIONAPI_EXPORT
-PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document> & thePart,
-                  const ModelHighAPI_Double & theA,
-                  const ModelHighAPI_Double & theB,
-                  const ModelHighAPI_Double & theC,
-                  const ModelHighAPI_Double & theD);
-
-//--------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Double& theA,
+                  const ModelHighAPI_Double& theB,
+                  const ModelHighAPI_Double& theC,
+                  const ModelHighAPI_Double& theD);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Plane feature
+CONSTRUCTIONAPI_EXPORT
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& thePoint1,
+                  const ModelHighAPI_Selection& thePoint2,
+                  const ModelHighAPI_Selection& thePoint3);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Plane feature
+CONSTRUCTIONAPI_EXPORT
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& theLine,
+                  const ModelHighAPI_Selection& thePoint,
+                  const bool theIsPerpendicular);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Plane feature
+CONSTRUCTIONAPI_EXPORT
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& theObject1,
+                  const ModelHighAPI_Selection& theObject2);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Plane feature
+CONSTRUCTIONAPI_EXPORT
+PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
+                  const ModelHighAPI_Selection& thePlane,
+                  const ModelHighAPI_Selection& theAxis,
+                  const ModelHighAPI_Double& theAngle);
+
 #endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_PLANE_H_ */
index c0fb687198d7a27e8d92921ce4b3ac4ad09368c4..00263fbf70190cffeba5d3997700e723ed504173 100644 (file)
@@ -60,4 +60,5 @@ INCLUDE_DIRECTORIES(
 ADD_UNIT_TESTS(TestAxisCreation.py
                UnitTestAxis.py
                TestPointName.py
-               TestPoint.py)
+               TestPoint.py
+               TestPlane.py)
index c95d450ad06d98e3856d29ad7e71d9d5f9e44d3c..2acacfb9e0e0b63a6b575cff06c928687d4a8867 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <GeomAPI_Ax1.h>
 #include <GeomAPI_Edge.h>
+#include <GeomAPI_Face.h>
 #include <GeomAPI_Lin.h>
 #include <GeomAPI_Pln.h>
 #include <GeomAPI_Pnt.h>
diff --git a/src/ConstructionPlugin/Test/TestPlane.py b/src/ConstructionPlugin/Test/TestPlane.py
new file mode 100644 (file)
index 0000000..0661b4d
--- /dev/null
@@ -0,0 +1,84 @@
+"""
+Test case for Construction Plane feature. Written on High API.
+"""
+from ModelAPI import *
+from GeomAPI import *
+
+import model
+
+# Get session
+aSession = ModelAPI_Session.get()
+
+# Create a part
+aDocument = aSession.activeDocument()
+aSession.startOperation()
+model.addPart(aDocument)
+aDocument = aSession.activeDocument()
+aSession.finishOperation()
+
+# Test a plane by general equation
+aSession.startOperation()
+aPlane = model.addPlane(aDocument, 1, 1, 1, 0)
+aSession.finishOperation()
+assert (len(aPlane.result()) > 0)
+
+# Create a point 1
+aSession.startOperation()
+aPoint1 = model.addPoint(aDocument, 0, 0, 0)
+aSession.finishOperation()
+
+# Create a point 2
+aSession.startOperation()
+aPoint2 = model.addPoint(aDocument, 100, 0, 0)
+aSession.finishOperation()
+
+# Create a point 3
+aSession.startOperation()
+aPoint3 = model.addPoint(aDocument, 50, 50, 50)
+aSession.finishOperation()
+
+# Test a plane by three points
+aSession.startOperation()
+aPlane = model.addPlane(aDocument, aPoint1.result()[0], aPoint2.result()[0], aPoint3.result()[0])
+aSession.finishOperation()
+assert (len(aPlane.result()) > 0)
+
+# Create an axis
+aSession.startOperation()
+anAxis = model.addAxis(aDocument, 0, 0, 100)
+aSession.finishOperation()
+
+# Test a plane by line and point
+aSession.startOperation()
+aPlane = model.addPlane(aDocument, anAxis.result()[0], aPoint3.result()[0], True)
+aSession.finishOperation()
+assert (len(aPlane.result()) > 0)
+
+# Test a plane by distance from other
+aSession.startOperation()
+aPlane = model.addPlane(aDocument, aPlane.result()[0], 50, False)
+aSession.finishOperation()
+assert (len(aPlane.result()) > 0)
+
+# Test a plane by coincidence to point
+aSession.startOperation()
+aCoincidentPlane = model.addPlane(aDocument, aPlane.result()[0], aPoint2.result()[0])
+aSession.finishOperation()
+assert (len(aCoincidentPlane.result()) > 0)
+
+# Create an axis
+aSession.startOperation()
+anAxis = model.addAxis(aDocument, 100, 0, 0)
+aSession.finishOperation()
+
+# Test a plane by rotation
+aSession.startOperation()
+aRotatedPlane = model.addPlane(aDocument, aCoincidentPlane.result()[0], anAxis.result()[0], 45)
+aSession.finishOperation()
+assert (len(aRotatedPlane.result()) > 0)
+
+# Test plane by two parallel planes
+aSession.startOperation()
+aPlane = model.addPlane(aDocument, aCoincidentPlane.result()[0], aPlane.result()[0])
+aSession.finishOperation()
+assert (len(aPlane.result()) > 0)
index df2ba89ead43bbf7fd90b249c4df4acb721f4c12..1fed0c7d840ab7c244f1c5274256e554e142eb15 100755 (executable)
@@ -23,6 +23,7 @@
 #include <GeomAlgoAPI_MakeShapeList.h>
 #include <GeomAlgoAPI_ShapeTools.h>
 
+#include <GeomAPI_Face.h>
 #include <GeomAPI_ShapeIterator.h>
 
 #include <sstream>
index 247e6126e7a4eb58a28fd89cac9d150ac7a25545..7c0f462e086a033cd980920130a521a79856ba09 100644 (file)
@@ -419,33 +419,33 @@ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::faceToInfinitePlane(const
 }
 
 //==================================================================================================
-std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
-                                                                     const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints)
+std::shared_ptr<GeomAPI_Face> GeomAlgoAPI_ShapeTools::fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
+                                                                    const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints)
 {
-  std::shared_ptr<GeomAPI_Shape> aResultShape;
+  std::shared_ptr<GeomAPI_Face> aResultFace;
 
   if(!thePlane.get()) {
-    return aResultShape;
+    return aResultFace;
   }
 
   const TopoDS_Shape& aShape = thePlane->impl<TopoDS_Shape>();
   if(aShape.ShapeType() != TopAbs_FACE) {
-    return aResultShape;
+    return aResultFace;
   }
 
   TopoDS_Face aFace = TopoDS::Face(aShape);
   Handle(Geom_Surface) aSurf = BRep_Tool::Surface(aFace);
   if(aSurf.IsNull()) {
-    return aResultShape;
+    return aResultFace;
   }
 
   GeomLib_IsPlanarSurface isPlanar(aSurf);
   if(!isPlanar.IsPlanar()) {
-    return aResultShape;
+    return aResultFace;
   }
 
   if(thePoints.size() != 8) {
-    return aResultShape;
+    return aResultFace;
   }
 
   const gp_Pln& aFacePln = isPlanar.Plan();
@@ -465,10 +465,10 @@ std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeTools::fitPlaneToBox(const std::
     if(aPntV < VMin) VMin = aPntV;
     if(aPntV > VMax) VMax = aPntV;
   }
-  aResultShape.reset(new GeomAPI_Shape);
-  aResultShape->setImpl(new TopoDS_Shape(BRepLib_MakeFace(aFacePln, UMin, UMax, VMin, VMax).Face()));
+  aResultFace.reset(new GeomAPI_Face());
+  aResultFace->setImpl(new TopoDS_Face(BRepLib_MakeFace(aFacePln, UMin, UMax, VMin, VMax).Face()));
 
-  return aResultShape;
+  return aResultFace;
 }
 
 //==================================================================================================
index 6a1da0e237e0b928c7c83359714a935b12c6cdab..f69ad5cd56ef1c0c0657c2eeeb63dc4750ac400b 100644 (file)
@@ -62,8 +62,8 @@ public:
   /// \return plane that fits to bounding box.
   /// \param[in] thePlane base plane.
   /// \param[in] thePoints bounding box points (shoud be eight).
-  GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Shape> fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
-                                                                         const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints);
+  GEOMALGOAPI_EXPORT static std::shared_ptr<GeomAPI_Face> fitPlaneToBox(const std::shared_ptr<GeomAPI_Shape> thePlane,
+                                                                        const std::list<std::shared_ptr<GeomAPI_Pnt> >& thePoints);
 
   /// \brief Finds the start and end vertices of theShape. theShape can be of the following type:\n
   /// Vertex: theV1 and theV2 are the same and equal to theShape;\n
index bafdb363cfa653ce03b469cc33412f648aa7ca62..20e33804254982f59c4e428414434ba42ea3f5e3 100644 (file)
@@ -43,7 +43,7 @@
   }
 }
 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Double, const ModelHighAPI_Double & {
-  $1 = (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) ? 1 : 0;
+  $1 = ((PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
 }
 
 %typemap(in) const ModelHighAPI_Integer & (ModelHighAPI_Integer temp) {
@@ -60,7 +60,7 @@
   }
 }
 %typecheck(SWIG_TYPECHECK_POINTER) ModelHighAPI_Integer, const ModelHighAPI_Integer & {
-  $1 = (PyInt_Check($input) || PyString_Check($input)) ? 1 : 0;
+  $1 = ((PyInt_Check($input) || PyString_Check($input)) && !PyBool_Check($input)) ? 1 : 0;
 }
 
 %typemap(in) const ModelHighAPI_RefAttr & (ModelHighAPI_RefAttr temp) {
index 26d4b52ccec1504d228d333a740b510062c9fee4..aed82f368a6ec258be3e296e50bbfc21ea65200e 100644 (file)
     END_INIT() \
   public:
 
+//--------------------------------------------------------------------------------------
+#define INTERFACE_20(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) \
+  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) \
+  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) \
+    END_INIT() \
+  public:
+
 //--------------------------------------------------------------------------------------
 #define INTERFACE_21(KIND, \
                      N_0, AN_0, T_0, C_0, \