Salome HOME
Useful commits from master and V8_5_0
[modules/shaper.git] / src / FeaturesPlugin / Test / TestPipe.py
index 811ee33a46ccdd9998afaec6a833d00a0bae33af..f805375d5fbb98c6f7f407f199d466943f90f5f4 100644 (file)
@@ -1,3 +1,23 @@
+## Copyright (C) 2014-2017  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>
+##
+
 # Initialization of the test
 from ModelAPI import *
 from GeomDataAPI import *
@@ -27,8 +47,8 @@ norm.setValue(0, 0, 1)
 
 # Create circle
 aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle")
-anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("CircleCenter"))
-aCircleRadius = aSketchCircleFeature.real("CircleRadius")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("circle_center"))
+aCircleRadius = aSketchCircleFeature.real("circle_radius")
 anCircleCentr.setValue(0, 0)
 aCircleRadius.setValue(10)
 aSession.finishOperation()
@@ -65,10 +85,9 @@ aSketchLineEndPoint.setValue(0, 200)
 
 # Create arc
 aSketchArcFeature = aSketchFeature.addFeature("SketchArc")
-aSketchArcFeature.string("ArcType").setValue("CenterStartEnd")
-aSketchArcCenterPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("ArcCenter"))
-aSketchArcStartPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("ArcStartPoint"))
-aSketchArcEndPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("ArcEndPoint"))
+aSketchArcCenterPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("center_point"))
+aSketchArcStartPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("start_point"))
+aSketchArcEndPoint = geomDataAPI_Point2D(aSketchArcFeature.attribute("end_point"))
 aSketchArcCenterPoint.setValue(100, 200)
 aSketchArcStartPoint.setValue(200, 200)
 aSketchArcEndPoint.setValue(0, 200)
@@ -101,65 +120,86 @@ aSession.finishOperation()
 # Test results
 assert (len(aPipeFeature.results()) > 0)
 # aSession.undo()
-#
-# # Create pipe with bi-normal
-# aSession.startOperation()
-# aPipeFeature = aPart.addFeature("Pipe")
-# aBaseObjectsList = aPipeFeature.selectionList("base_objects")
-# aBaseObjectsList.append(aFaceResult1, None)
-# aPathObjectSelection = aPipeFeature.selection("path_object")
-# aPathObjectSelection.setValue(aWireResult, None)
-# aPipeFeature.string("creation_method").setValue("binormal")
-# aBinormalObjectSelection = aPipeFeature.selection("binormal")
-# aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
-# aBinormalObjectSelection.setValue(aSketchResult, aShapeExplorer.current())
-# aSession.finishOperation()
-#
-# # Test results
-# assert (len(aPipeFeature.results()) > 0)
+
+# Recover original face
+aSession.startOperation()
+aRecover = aPart.addFeature("Recover")
+aBaseObject = aRecover.reference("base_feature")
+aBaseObject.setValue(aPipeFeature)
+aRecoveredObjects = aRecover.reflist("recovered")
+aRecoveredObjects.append(aFaceResult1)
+aSession.finishOperation()
+
+# Create pipe with bi-normal
+aSession.startOperation()
+aPipeFeature = aPart.addFeature("Pipe")
+aBaseObjectsList = aPipeFeature.selectionList("base_objects")
+aBaseObjectsList.append(aRecover.firstResult(), None)
+aPathObjectSelection = aPipeFeature.selection("path_object")
+aPathObjectSelection.setValue(aWireResult, None)
+aPipeFeature.string("creation_method").setValue("binormal")
+aBinormalObjectSelection = aPipeFeature.selection("binormal")
+aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
+aBinormalObjectSelection.setValue(aSketchResult, aShapeExplorer.current())
+aSession.finishOperation()
+
+# Test results
+assert (len(aPipeFeature.results()) > 0)
 # aSession.undo()
-#
-# # Create pipe with locations
-# # Create a sketch with circle for pipe profile
-# aSession.startOperation()
-# aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
-# origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
-# origin.setValue(0, 0, 200)
-# dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
-# dirx.setValue(1, 0, 0)
-# norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
-# norm.setValue(0, 0, 1)
-#
-# # Create circle
-# aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle")
-# anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("CircleCenter"))
-# aCircleRadius = aSketchCircleFeature.real("CircleRadius")
-# anCircleCentr.setValue(0, 0)
-# aCircleRadius.setValue(20)
-# aSession.finishOperation()
-# aSketchResult = aSketchFeature.firstResult()
-# aSketchShape = aSketchResult.shape()
-#
-# # Create face
-# aSession.startOperation()
-# aFaceFeature = aPart.addFeature("Face")
-# aBaseObjectsList = aFaceFeature.selectionList("base_objects")
-# aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
-# while aShapeExplorer.more():
-#     aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
-#     aShapeExplorer.next()
-# aSession.finishOperation()
-# aFaceResult2 = aFaceFeature.firstResult()
-#
-# aSession.startOperation()
-# aPipeFeature = aPart.addFeature("Pipe")
-# aBaseObjectsList = aPipeFeature.selectionList("base_objects")
-# aBaseObjectsList.append(aFaceResult1, None)
-# aBaseObjectsList.append(aFaceResult2, None)
-# aPathObjectSelection = aPipeFeature.selection("path_object")
-# aPathObjectSelection.setValue(aWireResult, None)
-# aPipeFeature.string("creation_method").setValue("locations")
-# aSession.finishOperation()
-#
-# # Test results
-# assert (len(aPipeFeature.results()) > 0)
+
+# Recover original face
+aSession.startOperation()
+aRecover2 = aPart.addFeature("Recover")
+aBaseObject = aRecover2.reference("base_feature")
+aBaseObject.setValue(aPipeFeature)
+aRecoveredObjects = aRecover2.reflist("recovered")
+aRecoveredObjects.append(aRecover.firstResult())
+aSession.finishOperation()
+
+# Create pipe with locations
+# Create a sketch with circle for pipe profile
+aSession.startOperation()
+aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 200)
+dirx = geomDataAPI_Dir(aSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+
+# Create circle
+aSketchCircleFeature = aSketchFeature.addFeature("SketchCircle")
+anCircleCentr = geomDataAPI_Point2D(aSketchCircleFeature.attribute("circle_center"))
+aCircleRadius = aSketchCircleFeature.real("circle_radius")
+anCircleCentr.setValue(0, 0)
+aCircleRadius.setValue(20)
+aSession.finishOperation()
+aSketchResult = aSketchFeature.firstResult()
+aSketchShape = aSketchResult.shape()
+
+# Create face
+aSession.startOperation()
+aFaceFeature = aPart.addFeature("Face")
+aBaseObjectsList = aFaceFeature.selectionList("base_objects")
+aShapeExplorer = GeomAPI_ShapeExplorer(aSketchShape, GeomAPI_Shape.EDGE)
+while aShapeExplorer.more():
+    aBaseObjectsList.append(aSketchResult, aShapeExplorer.current())
+    aShapeExplorer.next()
+aSession.finishOperation()
+aFaceResult2 = aFaceFeature.firstResult()
+
+aSession.startOperation()
+aPipeFeature = aPart.addFeature("Pipe")
+aBaseObjectsList = aPipeFeature.selectionList("base_objects")
+aBaseObjectsList.append(aRecover2.firstResult(), None)
+aBaseObjectsList.append(aFaceResult2, None)
+aPathObjectSelection = aPipeFeature.selection("path_object")
+aPathObjectSelection.setValue(aWireResult, None)
+aPipeFeature.string("creation_method").setValue("locations")
+aSession.finishOperation()
+
+# Test results
+assert (len(aPipeFeature.results()) > 0)
+
+from salome.shaper import model
+assert(model.checkPythonDump())