]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fixed shell feature. Added test case for Shell feature.
authordbv <dbv@opencascade.com>
Tue, 10 May 2016 11:56:09 +0000 (14:56 +0300)
committerdbv <dbv@opencascade.com>
Tue, 10 May 2016 11:56:09 +0000 (14:56 +0300)
src/BuildPlugin/Test/TestFace.py
src/BuildPlugin/Test/TestShell.py [new file with mode: 0644]
src/BuildPlugin/Test/TestWire.py
src/GeomAlgoAPI/GeomAlgoAPI_Sewing.cpp

index 9cf158a05d67d8f47bd5f60bf1714fd4fa98a76a..bd85a3a61717f53ba645f13d8ab314f3d3bc658f 100644 (file)
@@ -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 (file)
index 0000000..cd06246
--- /dev/null
@@ -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)
index f5d2098e3f574c36ec93ceef6be2abd4b20dd9af..de75b080c9e0724e31c28b25e4941cfd235eb281 100644 (file)
@@ -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"))
index 4539b086399653dab79acee6262cf0ab7c27aea3..5d8039cbfc3ca9dbc19ce7a4de5d00115cd1b024 100644 (file)
@@ -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<GeomAPI_Shape> aShape(new GeomAPI_Shape());