]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for Axis dump
authordbv <dbv@opencascade.com>
Thu, 8 Sep 2016 09:42:30 +0000 (12:42 +0300)
committerdbv <dbv@opencascade.com>
Thu, 8 Sep 2016 09:42:48 +0000 (12:42 +0300)
src/BuildPlugin/Test/TestSubShapes.py
src/BuildPlugin/Test/TestWire.py
src/ConstructionAPI/ConstructionAPI_Axis.cpp
src/ConstructionAPI/ConstructionAPI_Axis.h
src/ConstructionPlugin/Test/TestAxisCreation.py

index e943f66b3752733c6d701583fa7aaf583092f8cc..dbe6d695def133e29d108d1fc80c5a00be6e8cc3 100644 (file)
@@ -128,4 +128,22 @@ aSession.finishOperation()
 assert (len(aSubShapesFeature.results()) > 0)
 
 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(-454.545454545455, 50.600343053173, 137.95899463189)
+SketchCircle_2 = Sketch_1.addCircle(-454.545454545455, 50.600343053173, 62.129572131303)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchCircle_1.center(), SketchCircle_2.center())
+SketchPoint_1 = Sketch_1.addPoint(-490.566037735849, 50.600343053173)
+SketchPoint_2 = Sketch_1.addPoint(-423.670668953688, 50.600343053173)
+model.do()
+Face_1 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_1_2f")])
+Face_2 = model.addFace(Part_1_doc, [model.selection("WIRE", "Sketch_1/Wire-SketchCircle_2_2r")])
+SubShapes_1 = model.addSubShapes(Part_1_doc, model.selection("FACE", "Face_1_1"), [model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_1"), model.selection("VERTEX", "Sketch_1/Vertex-SketchPoint_2")])
+SubShapes_1.setBaseShape(model.selection("FACE", "Face_2_1"))
+model.end()
+
 assert(model.checkPythonDump())
index 545c5ffa6e5aea22278c95e90c03f95b9cd0a487..0d3bb161838997128ede3b15399ba8ff75f01ed5 100644 (file)
@@ -64,4 +64,27 @@ aSession.finishOperation()
 assert (len(aWireFeature.results()) > 0)
 
 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"))
+SketchLine_1 = Sketch_1.addLine(-68.61063464837, 232.418524871355, -488.85077186964, 232.418524871355)
+SketchLine_2 = Sketch_1.addLine(-488.85077186964, 232.418524871355, -488.85077186964, -153.516295025729)
+SketchLine_3 = Sketch_1.addLine(-488.85077186964, -153.516295025729, -68.61063464837, -153.516295025729)
+SketchLine_4 = Sketch_1.addLine(-68.61063464837, -153.516295025729, -68.61063464837, 232.418524871355)
+SketchConstraintCoincidence_1 = Sketch_1.setCoincident(SketchLine_4.endPoint(), SketchLine_1.startPoint())
+SketchConstraintCoincidence_2 = Sketch_1.setCoincident(SketchLine_1.endPoint(), SketchLine_2.startPoint())
+SketchConstraintCoincidence_3 = Sketch_1.setCoincident(SketchLine_2.endPoint(), SketchLine_3.startPoint())
+SketchConstraintCoincidence_4 = Sketch_1.setCoincident(SketchLine_3.endPoint(), SketchLine_4.startPoint())
+SketchConstraintHorizontal_1 = Sketch_1.setHorizontal(SketchLine_1.result()[0])
+SketchConstraintVertical_1 = Sketch_1.setVertical(SketchLine_2.result()[0])
+SketchConstraintHorizontal_2 = Sketch_1.setHorizontal(SketchLine_3.result()[0])
+SketchConstraintVertical_2 = Sketch_1.setVertical(SketchLine_4.result()[0])
+model.do()
+Wire_1 = model.addWire(Part_1_doc, [model.selection("EDGE", "Sketch_1/Edge-SketchLine_1")])
+Wire_1.addContour()
+model.end()
+
 assert(model.checkPythonDump())
index 399017fea881a8992e3a3a6590b92ff302405d7c..7f1debcfa76ffe11e9233916acdc41520427e2d8 100644 (file)
@@ -90,6 +90,32 @@ ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Featur
   }
 }
 
+//==================================================================================================
+ConstructionAPI_Axis::ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                           const ModelHighAPI_Selection& thePlane1,
+                                           const ModelHighAPI_Selection& thePlane2,
+                                           const ModelHighAPI_Double& theOffset2,
+                                           const bool theReverseOffset2)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setByTwoPlanes(thePlane1, thePlane2, theOffset2, theReverseOffset2);
+  }
+}
+
+//==================================================================================================
+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)
+: ModelHighAPI_Interface(theFeature)
+{
+  if(initialize()) {
+    setByTwoPlanes(thePlane1, theOffset1, theReverseOffset1, thePlane2);
+  }
+}
+
 //==================================================================================================
 ConstructionAPI_Axis::~ConstructionAPI_Axis()
 {
@@ -197,6 +223,40 @@ void ConstructionAPI_Axis::setByTwoPlanes(const ModelHighAPI_Selection& thePlane
   execute();
 }
 
+//==================================================================================================
+void ConstructionAPI_Axis::setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+                                          const ModelHighAPI_Selection& thePlane2,
+                                          const ModelHighAPI_Double& theOffset2,
+                                          const bool theReverseOffset2)
+{
+  fillAttribute(ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES(), creationMethod());
+  fillAttribute(thePlane1, plane1());
+  fillAttribute("", useOffset1());
+  fillAttribute(thePlane2, plane2());
+  fillAttribute(ConstructionPlugin_Axis::USE_OFFSET2(), useOffset2());
+  fillAttribute(theOffset2, offset2());
+  fillAttribute(theReverseOffset2, reverseOffset2());
+
+  execute();
+}
+
+//==================================================================================================
+void ConstructionAPI_Axis::setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+                                          const ModelHighAPI_Double& theOffset1,
+                                          const bool theReverseOffset1,
+                                          const ModelHighAPI_Selection& thePlane2)
+{
+  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("", useOffset2());
+
+  execute();
+}
+
 //==================================================================================================
 void ConstructionAPI_Axis::dump(ModelHighAPI_Dumper& theDumper) const
 {
@@ -233,14 +293,23 @@ void ConstructionAPI_Axis::dump(ModelHighAPI_Dumper& theDumper) const
     theDumper << ", " << anAttrPlane << ", " << anAttrPoint;
   } else if(aCreationMethod == ConstructionPlugin_Axis::CREATION_METHOD_BY_TWO_PLANES()) {
     AttributeSelectionPtr anAttrPlane1 = aBase->selection(ConstructionPlugin_Axis::PLANE1());
-    AttributeDoublePtr anAttrOffset1 = aBase->real(ConstructionPlugin_Axis::OFFSET1());
-    AttributeBooleanPtr anAttrReverseOffset1 = aBase->boolean(ConstructionPlugin_Axis::REVERSE_OFFSET1());
     AttributeSelectionPtr anAttrPlane2 = aBase->selection(ConstructionPlugin_Axis::PLANE2());
-    AttributeDoublePtr anAttrOffset2 = aBase->real(ConstructionPlugin_Axis::OFFSET2());
-    AttributeBooleanPtr anAttrReverseOffset2 = aBase->boolean(ConstructionPlugin_Axis::REVERSE_OFFSET2());
 
-    theDumper << ", " << anAttrPlane1 << ", " << anAttrOffset1 << ", " << anAttrReverseOffset1
-              << ", " << anAttrPlane2 << ", " << anAttrOffset2 << ", " << anAttrReverseOffset2;
+    theDumper << ", " << anAttrPlane1;
+    if(aBase->string(ConstructionPlugin_Axis::USE_OFFSET1())->isInitialized()
+      && !aBase->string(ConstructionPlugin_Axis::USE_OFFSET1())->value().empty()) {
+      AttributeDoublePtr anAttrOffset1 = aBase->real(ConstructionPlugin_Axis::OFFSET1());
+      AttributeBooleanPtr anAttrReverseOffset1 = aBase->boolean(ConstructionPlugin_Axis::REVERSE_OFFSET1());
+      theDumper << ", " << anAttrOffset1 << ", " << anAttrReverseOffset1;
+    }
+
+    theDumper << ", " << anAttrPlane2;
+    if(aBase->string(ConstructionPlugin_Axis::USE_OFFSET2())->isInitialized()
+      && !aBase->string(ConstructionPlugin_Axis::USE_OFFSET2())->value().empty()) {
+      AttributeDoublePtr anAttrOffset2 = aBase->real(ConstructionPlugin_Axis::OFFSET2());
+      AttributeBooleanPtr anAttrReverseOffset2 = aBase->boolean(ConstructionPlugin_Axis::REVERSE_OFFSET2());
+      theDumper << ", " << anAttrOffset2 << ", " << anAttrReverseOffset2;
+    }
   } else if(aCreationMethod == ConstructionPlugin_Axis::CREATION_METHOD_BY_POINT_AND_DIRECTION()) {
     AttributeSelectionPtr anAttrFirstPnt = aBase->selection(ConstructionPlugin_Axis::POINT_FIRST());
     AttributeDoublePtr anAttrX = aBase->real(ConstructionPlugin_Axis::X_DIRECTION());
@@ -309,3 +378,29 @@ AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
   return AxisPtr(new ConstructionAPI_Axis(aFeature, thePlane1, theOffset1, theReverseOffset1,
                                                     thePlane2, theOffset2, theReverseOffset2));
 }
+
+//==================================================================================================
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Selection& thePlane1,
+                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,
+                                                    thePlane2, theOffset2, theReverseOffset2));
+}
+
+//==================================================================================================
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Selection& thePlane1,
+                const ModelHighAPI_Double& theOffset1,
+                const bool theReverseOffset1,
+                const ModelHighAPI_Selection& thePlane2)
+{
+  // 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));
+}
index fc6bbbc1936fbf96ee7a32b685bfc290039c05b4..e9bdb6bfc944125b54adda045da8c2ad0379b2ee 100644 (file)
@@ -66,6 +66,22 @@ public:
                        const ModelHighAPI_Double& theOffset2,
                        const bool theReverseOffset2);
 
+  /// Constructor with values
+  CONSTRUCTIONAPI_EXPORT
+  ConstructionAPI_Axis(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                       const ModelHighAPI_Selection& thePlane1,
+                       const ModelHighAPI_Selection& thePlane2,
+                       const ModelHighAPI_Double& theOffset2,
+                       const bool theReverseOffset2);
+
+  /// 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);
+
   /// Destructor
   CONSTRUCTIONAPI_EXPORT
   virtual ~ConstructionAPI_Axis();
@@ -138,6 +154,20 @@ public:
                       const ModelHighAPI_Double& theOffset2,
                       const bool theReverseOffset2);
 
+  /// Set by two planes
+  CONSTRUCTIONAPI_EXPORT
+  void setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+                      const ModelHighAPI_Selection& thePlane2,
+                      const ModelHighAPI_Double& theOffset2,
+                      const bool theReverseOffset2);
+
+  /// Set by two planes
+  CONSTRUCTIONAPI_EXPORT
+  void setByTwoPlanes(const ModelHighAPI_Selection& thePlane1,
+                      const ModelHighAPI_Double& theOffset1,
+                      const bool theReverseOffset1,
+                      const ModelHighAPI_Selection& thePlane2);
+
   /// Dump wrapped feature
   CONSTRUCTIONAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
@@ -187,4 +217,22 @@ AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
                 const ModelHighAPI_Double& theOffset2,
                 const bool theReverseOffset2);
 
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
+CONSTRUCTIONAPI_EXPORT
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Selection& thePlane1,
+                const ModelHighAPI_Selection& thePlane2,
+                const ModelHighAPI_Double& theOffset2,
+                const bool theReverseOffset2);
+
+/// \ingroup CPPHighAPI
+/// \brief Create Axis feature
+CONSTRUCTIONAPI_EXPORT
+AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document>& thePart,
+                const ModelHighAPI_Selection& thePlane1,
+                const ModelHighAPI_Double& theOffset1,
+                const bool theReverseOffset1,
+                const ModelHighAPI_Selection& thePlane2);
+
 #endif /* SRC_CONSTRUCTIONAPI_CONSTRUCTIONAPI_AXIS_H_ */
index 77be60ef1dfd48437eaa6c99291f36eb806c3af3..2c0dabfb65c2020abaa63e20e917e834840be4e8 100644 (file)
@@ -189,5 +189,5 @@ anAxis = model.addAxis(aPart, aPlane1.result()[0], 50, False, aPlane2.result()[0
 aSession.finishOperation()
 assert (len(anAxis.result()) > 0)
 
-#import model
-#assert(model.checkPythonDump())
+import model
+assert(model.checkPythonDump())