+
## @package Plugins
# ExportFeature class definition
# Copyright (C) 2014-20xx CEA/DEN, EDF R&D
import ModelAPI
import GeomAPI
import GeomAlgoAPI
+import ShapeUtilities
import salome
from salome.geom import geomBuilder
## Exports all bodies
def exportBodies(self):
- global ShapeIndex
- kResultBodyType = "Bodies"
- aPartSize = self.Part.size(kResultBodyType)
- if aPartSize == 0:
- EventsAPI.Events_InfoMessage("ExportFeature","No results in the active document").send()
- return
-
- anObjList = [self.Part.object(kResultBodyType, idx) for idx in xrange(aPartSize)]
- aShapesList = GeomAlgoAPI.ShapeList()
- aName = ""
- for idx, anObject in enumerate(anObjList):
- aResult = ModelAPI.modelAPI_Result(anObject)
- aBodyResult = ModelAPI.modelAPI_ResultBody(aResult)
- if not aBodyResult:
- continue
- aShape = aBodyResult.shape()
- if aShape is not None and not aShape.isNull():
- aShapesList.append(aShape)
- if len(aShapesList) == 1:
- aName = aBodyResult.data().name()
-
- # issue 1045: create compound if there are more than one shape
- if len(aShapesList) > 1:
- self.shape = GeomAlgoAPI.GeomAlgoAPI_CompoundBuilder.compound(aShapesList)
- aName = "ShaperResults"
- elif len(aShapesList) == 1:
- self.shape = aShapesList[0]
-
- # so, only one shape is always in the result
+ self.shape = ShapeUtilities.makeShape(self.Part)
+
+ aName = self.shape.name
+
+ # only one shape is always in the result
aDump = self.shape.getShapeStream()
+
+ # guess the name of the dumped part objet
+ partName = "Part_%i"%self.Part.id()
+
+ # add the information that the stream comes from Shaper to make specific dump in GEOM
+ firstLine = "FromShaperExportToGeom;" + partName
+ aDump = firstLine + aDump
+
# Load shape to SALOME Geom
aBrep = self.geompy.RestoreShape(aDump)
--- /dev/null
+import EventsAPI
+import ModelAPI
+import GeomAlgoAPI
+
+## Make the shape from the part
+# Utility function used in Shaper's ExportToGeom and Geom's RestoreShape
+def makeShape(aPart):
+ kResultBodyType = "Bodies"
+ aPartSize = aPart.size(kResultBodyType)
+ if aPartSize == 0:
+ EventsAPI.Events_InfoMessage("ExportFeature","No results in the active document").send()
+ return
+
+ anObjList = [aPart.object(kResultBodyType, idx) for idx in xrange(aPartSize)]
+ aShapesList = GeomAlgoAPI.ShapeList()
+ aName = ""
+ for idx, anObject in enumerate(anObjList):
+ aResult = ModelAPI.modelAPI_Result(anObject)
+ aBodyResult = ModelAPI.modelAPI_ResultBody(aResult)
+ if not aBodyResult:
+ continue
+ aShape = aBodyResult.shape()
+ if aShape is not None and not aShape.isNull():
+ aShapesList.append(aShape)
+ if len(aShapesList) == 1:
+ aName = aBodyResult.data().name()
+
+ # issue 1045: create compound if there are more than one shape
+ if len(aShapesList) > 1:
+ aShape = GeomAlgoAPI.GeomAlgoAPI_CompoundBuilder.compound(aShapesList)
+ aName = "ShaperResults"
+ elif len(aShapesList) == 1:
+ aShape = aShapesList[0]
+
+ aShape.name = aName
+
+ return aShape
\ No newline at end of file