X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FFeaturesPlugin%2FTest%2FTestSerialBoolean.py;h=f0d788fea2c6ec973a22bf05edfa98b4ce8d734f;hb=2af30ac5d930cbdb4cba162742ded39f4c17e254;hp=9b248edcc789397da16b601d3b62dae1b05321fa;hpb=d34842c50d5f335cca443c78910c16c54139c7d0;p=modules%2Fshaper.git diff --git a/src/FeaturesPlugin/Test/TestSerialBoolean.py b/src/FeaturesPlugin/Test/TestSerialBoolean.py index 9b248edcc..f0d788fea 100644 --- a/src/FeaturesPlugin/Test/TestSerialBoolean.py +++ b/src/FeaturesPlugin/Test/TestSerialBoolean.py @@ -1,13 +1,32 @@ +# Copyright (C) 2014-2019 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 +# + """ TestExtrusion.py Unit test of FeaturesPlugin_Boolean class: many Boolean operations performance - + class FeaturesPlugin_Extrusion : public ModelAPI_Feature static const std::string MY_EXTRUSION_ID("Extrusion"); static const std::string MY_FACE_ID("base"); static const std::string MY_SIZE_ID("size"); static const std::string MY_REVERSE_ID("reverse"); - + data()->addAttribute(FeaturesPlugin_Extrusion::FACE_ID(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(FeaturesPlugin_Extrusion::SIZE_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(FeaturesPlugin_Extrusion::REVERSE_ID(), ModelAPI_AttributeBoolean::typeId()); @@ -47,8 +66,8 @@ radius = 95. / N / 2. aSession.startOperation() aSketchFeatures = [] -for i in xrange(0, N): - for j in xrange(0, N): +for i in range(0, N): + for j in range(0, N): # Create circle aSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch")) origin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) @@ -58,8 +77,8 @@ for i in xrange(0, N): norm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) norm.setValue(0, 0, 1) aSketchCircle = aSketchFeature.addFeature("SketchCircle") - anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("CircleCenter")) - aCircleRadius = aSketchCircle.real("CircleRadius") + anCircleCentr = geomDataAPI_Point2D(aSketchCircle.attribute("circle_center")) + aCircleRadius = aSketchCircle.real("circle_radius") anCircleCentr.setValue(0.5 + step * (0.5 + i), 0.5 + step * (0.5 + j)) aCircleRadius.setValue(radius) aSketchFeatures.append(aSketchFeature) @@ -75,31 +94,18 @@ aSession.finishOperation() aSession.startOperation() anExtrusions = [] -for i in xrange(0, N * N): - aSketchResult = aSketchFeatures[i].firstResult() - aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() - origin = geomDataAPI_Point(aSketchFeatures[i].attribute("Origin")).pnt() - dirX = geomDataAPI_Dir(aSketchFeatures[i].attribute("DirX")).dir() - norm = geomDataAPI_Dir(aSketchFeatures[i].attribute("Norm")).dir() - aSketchFaces = ShapeList() - GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aSketchEdges, aSketchFaces) - +for i in range(0, N * N): + aSketchResult = modelAPI_ResultConstruction(aSketchFeatures[i].firstResult()) anExtrusionFt = aPart.addFeature("Extrusion") assert (anExtrusionFt.getKind() == "Extrusion") anExtrusionFt.selectionList("base").append( - aSketchResult, aSketchFaces[0]) + aSketchResult, aSketchResult.face(0)) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("from_size").setValue(0) anExtrusionFt.real("to_size").setValue(10) anExtrusionFt.real("to_offset").setValue(0) #TODO: remove - anExtrusionFt.real("from_offset").setValue(0) #TODO: remove - # v1.0.2 from master - # anExtrusionFt.selection("extrusion_face").setValue( - # aSketchResult, aSketchFaces[0]) - # anExtrusionFt.real("extrusion_size").setValue(10) - # anExtrusionFt.boolean("extrusion_reverse").setValue(False) + anExtrusionFt.real("from_offset").setValue(0) #TODO: remove anExtrusions.append(anExtrusionFt) aSession.finishOperation() @@ -142,28 +148,16 @@ aSession.startOperation() #========================================================================= # Build a big box extrusion #========================================================================= -aSketchResult = aQuadrangleSketchFeature.firstResult() -aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape() -origin = geomDataAPI_Point(aQuadrangleSketchFeature.attribute("Origin")).pnt() -dirX = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("DirX")).dir() -norm = geomDataAPI_Dir(aQuadrangleSketchFeature.attribute("Norm")).dir() -aSketchFaces = ShapeList() -GeomAlgoAPI_SketchBuilder.createFaces( - origin, dirX, norm, aSketchEdges, aSketchFaces) +aSketchResult = modelAPI_ResultConstruction(aQuadrangleSketchFeature.firstResult()) # Create extrusion on them aBox = aPart.addFeature("Extrusion") aBox.selectionList("base").append( - aSketchResult, aSketchFaces[0]) + aSketchResult, aSketchResult.face(0)) aBox.string("CreationMethod").setValue("BySizes") aBox.real("from_size").setValue(0) aBox.real("to_size").setValue(10) aBox.real("to_offset").setValue(0) #TODO: remove aBox.real("from_offset").setValue(0) #TODO: remove -# v 1.0.2 from master -# aBox.selection("extrusion_face").setValue( -# aSketchResult, aSketchFaces[0]) -# aBox.real("extrusion_size").setValue(10) -# aBox.boolean("extrusion_reverse").setValue(False) aSession.finishOperation() @@ -175,13 +169,11 @@ aSession.finishOperation() aCurrentResult = modelAPI_ResultBody(aBox.firstResult()) aSession.startOperation() aFactory = ModelAPI_Session.get().validators() -for i in xrange(0, N * N): +for i in range(0, N * N): anExtrusionResult = modelAPI_ResultBody(anExtrusions[i].firstResult()) - aBooleanFt = aPart.addFeature("Boolean") + aBooleanFt = aPart.addFeature("Cut") aBooleanFt.selectionList("main_objects").append(aCurrentResult, aCurrentResult.shape()) aBooleanFt.selectionList("tool_objects").append(anExtrusionResult, anExtrusionResult.shape()) - kBooleanTypeCut = 0 - aBooleanFt.integer("bool_type").setValue(kBooleanTypeCut) aBooleanFt.execute() assert (aFactory.validate(aBooleanFt)) assert (len(aBooleanFt.results()) > 0) @@ -193,5 +185,5 @@ aSession.finishOperation() # End of test #========================================================================= -import model +from salome.shaper import model assert(model.checkPythonDump())