From: dbv Date: Tue, 10 May 2016 11:56:09 +0000 (+0300) Subject: Fixed shell feature. Added test case for Shell feature. X-Git-Tag: V_2.3.1~96 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=29488ade3e44cefc2ce81f00c0c8d14886dcf949;p=modules%2Fshaper.git Fixed shell feature. Added test case for Shell feature. --- diff --git a/src/BuildPlugin/Test/TestFace.py b/src/BuildPlugin/Test/TestFace.py index 9cf158a05..bd85a3a61 100644 --- a/src/BuildPlugin/Test/TestFace.py +++ b/src/BuildPlugin/Test/TestFace.py @@ -26,7 +26,6 @@ aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) aNorm.setValue(0, 0, 1) # Create lines -aNumOfLines = 10 aSketchLineFeature = aSketchFeature.addFeature("SketchLine") aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint")) aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint")) diff --git a/src/BuildPlugin/Test/TestShell.py b/src/BuildPlugin/Test/TestShell.py new file mode 100644 index 000000000..cd06246f1 --- /dev/null +++ b/src/BuildPlugin/Test/TestShell.py @@ -0,0 +1,79 @@ +# Initialization of the test +from ModelAPI import * +from GeomDataAPI import * +from GeomAlgoAPI import * +from GeomAPI import * + +def createFace(thePart, theNormX, theNormY, theNormZ): + # Create a sketch + aSession.startOperation() + aSketchFeature = featureToCompositeFeature(thePart.addFeature("Sketch")) + anOrigin = geomDataAPI_Point(aSketchFeature.attribute("Origin")) + anOrigin.setValue(0, 0, 0) + aDirX = geomDataAPI_Dir(aSketchFeature.attribute("DirX")) + aDirX.setValue(1, 0, 0) + aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) + aNorm.setValue(theNormX, theNormY, theNormZ) + + # Create lines + aSketchLineFeature = aSketchFeature.addFeature("SketchLine") + aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint")) + aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint")) + aSketchLineStartPoint.setValue(0, 0) + aSketchLineEndPoint.setValue(0, 50) + aSketchLineFeature = aSketchFeature.addFeature("SketchLine") + aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint")) + aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint")) + aSketchLineStartPoint.setValue(0, 50) + aSketchLineEndPoint.setValue(50, 50) + aSketchLineFeature = aSketchFeature.addFeature("SketchLine") + aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint")) + aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint")) + aSketchLineStartPoint.setValue(50, 50) + aSketchLineEndPoint.setValue(50, 0) + aSketchLineFeature = aSketchFeature.addFeature("SketchLine") + aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint")) + aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint")) + aSketchLineStartPoint.setValue(50, 0) + aSketchLineEndPoint.setValue(0, 0) + aSession.finishOperation() + aSketchResult = aSketchFeature.firstResult() + aSketchShape = aSketchResult.shape() + + # Create face + aSession.startOperation() + aFaceFeature = thePart.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() + return aFaceFeature.firstResult() + +# Get document +aSession = ModelAPI_Session.get() +aDocument = aSession.moduleDocument() + +# Create a part +aSession.startOperation() +aPartFeature = aDocument.addFeature("Part") +aSession.finishOperation() +aPartResult = modelAPI_ResultPart(aPartFeature.firstResult()) +aPart = aPartResult.partDoc() + +# Create faces +aFaceResults = [] +aFaceResults.append(createFace(aPart, 0, 0, 1)) +aFaceResults.append(createFace(aPart, 0, 1, 0)) + +# Create shell +aSession.startOperation() +aShellFeature = aPart.addFeature("Shell") +aBaseObjectsList = aShellFeature.selectionList("base_objects") +for aFaceResult in aFaceResults: + aBaseObjectsList.append(aFaceResult, None) +aSession.finishOperation() + +# Test results +assert (len(aShellFeature.results()) > 0) diff --git a/src/BuildPlugin/Test/TestWire.py b/src/BuildPlugin/Test/TestWire.py index f5d2098e3..de75b080c 100644 --- a/src/BuildPlugin/Test/TestWire.py +++ b/src/BuildPlugin/Test/TestWire.py @@ -26,7 +26,6 @@ aNorm = geomDataAPI_Dir(aSketchFeature.attribute("Norm")) aNorm.setValue(0, 0, 1) # Create lines -aNumOfLines = 10 aSketchLineFeature = aSketchFeature.addFeature("SketchLine") aSketchLineStartPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("StartPoint")) aSketchLineEndPoint = geomDataAPI_Point2D(aSketchLineFeature.attribute("EndPoint")) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp index 4539b0863..5d8039cbf 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp @@ -38,22 +38,26 @@ void GeomAlgoAPI_Sewing::build(const ListOfShape& theShapes) TopoDS_Shape aResult = aSewingBuilder->SewedShape(); BRep_Builder aBuilder; - TopoDS_Compound aResultCompound; - aBuilder.MakeCompound(aResultCompound); - for(TopoDS_Iterator anIt(aResult); anIt.More(); anIt.Next()) { - const TopoDS_Shape aSubShape = anIt.Value(); - if(aSubShape.ShapeType() == TopAbs_SHELL) { - aBuilder.Add(aResultCompound, aSubShape); - } else if (aSubShape.ShapeType() == TopAbs_FACE) { - TopoDS_Shell aShell; - aBuilder.MakeShell(aShell); - aBuilder.Add(aShell, aSubShape); - aBuilder.Add(aResultCompound, aShell); + if(aResult.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Compound aResultCompound; + aBuilder.MakeCompound(aResultCompound); + for(TopoDS_Iterator anIt(aResult); anIt.More(); anIt.Next()) { + const TopoDS_Shape aSubShape = anIt.Value(); + if(aSubShape.ShapeType() == TopAbs_SHELL) { + aBuilder.Add(aResultCompound, aSubShape); + } else if (aSubShape.ShapeType() == TopAbs_FACE) { + TopoDS_Shell aShell; + aBuilder.MakeShell(aShell); + aBuilder.Add(aShell, aSubShape); + aBuilder.Add(aResultCompound, aShell); + } } - } - TopoDS_Iterator anIt(aResultCompound); - if(anIt.More()) { aResult = aResultCompound; + } else if(aResult.ShapeType() == TopAbs_FACE) { + TopoDS_Shell aShell; + aBuilder.MakeShell(aShell); + aBuilder.Add(aShell, aResult); + aResult = aShell; } std::shared_ptr aShape(new GeomAPI_Shape());