issue 0002698: Exported STEP-File contains surplus PRODUCTS

This commit is contained in:
wmayer
2017-04-30 19:29:54 +02:00
parent 84eb915746
commit 2228a0fd63
4 changed files with 32 additions and 22 deletions
+4 -2
View File
@@ -206,12 +206,14 @@ private:
std::string name8bit = Part::encodeFilename(Utf8Name);
try {
Py::Sequence list(object);
Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Handle(TDocStd_Document) hDoc;
hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc);
Import::ExportOCAF ocaf(hDoc);
Py::Sequence list(object);
bool keepExplicitPlacement = list.size() > 1;
Import::ExportOCAF ocaf(hDoc, keepExplicitPlacement);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
PyObject* item = (*it).ptr();
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
+22 -17
View File
@@ -274,18 +274,20 @@ void ImportOCAF::createShape(const TopoDS_Shape& aShape, const TopLoc_Location&
// ----------------------------------------------------------------------------
ExportOCAF::ExportOCAF(Handle_TDocStd_Document h)
ExportOCAF::ExportOCAF(Handle_TDocStd_Document h, bool explicitPlacement)
: pDoc(h)
, keepExplicitPlacement(explicitPlacement)
{
aShapeTool = XCAFDoc_DocumentTool::ShapeTool(pDoc->Main());
aColorTool = XCAFDoc_DocumentTool::ColorTool(pDoc->Main());
#if defined(OCAF_KEEP_PLACEMENT)
rootLabel = aShapeTool->NewShape();
TDataStd_Name::Set(rootLabel, "ASSEMBLY");
#else
rootLabel = TDF_TagSource::NewChild(pDoc->Main());
#endif
if (keepExplicitPlacement) {
rootLabel = aShapeTool->NewShape();
TDataStd_Name::Set(rootLabel, "ASSEMBLY");
}
else {
rootLabel = TDF_TagSource::NewChild(pDoc->Main());
}
}
void ExportOCAF::saveShape(Part::Feature* part, const std::vector<App::Color>& colors)
@@ -294,13 +296,16 @@ void ExportOCAF::saveShape(Part::Feature* part, const std::vector<App::Color>& c
if (shape.IsNull())
return;
#if defined(OCAF_KEEP_PLACEMENT)
// http://www.opencascade.org/org/forum/thread_18813/?forum=3
TopLoc_Location aLoc = shape.Location();
TopoDS_Shape baseShape = shape.Located(TopLoc_Location());
#else
TopoDS_Shape baseShape = shape;
#endif
TopoDS_Shape baseShape;
TopLoc_Location aLoc;
if (keepExplicitPlacement) {
// http://www.opencascade.org/org/forum/thread_18813/?forum=3
aLoc = shape.Location();
baseShape = shape.Located(TopLoc_Location());
}
else {
baseShape = shape;
}
// Add shape and name
TDF_Label shapeLabel = aShapeTool->NewShape();
@@ -308,9 +313,9 @@ void ExportOCAF::saveShape(Part::Feature* part, const std::vector<App::Color>& c
TDataStd_Name::Set(shapeLabel, TCollection_ExtendedString(part->Label.getValue(), 1));
#if defined(OCAF_KEEP_PLACEMENT)
aShapeTool->AddComponent(rootLabel, shapeLabel, aLoc);
#endif
if (keepExplicitPlacement) {
aShapeTool->AddComponent(rootLabel, shapeLabel, aLoc);
}
// Add color information
Quantity_Color col;
+2 -1
View File
@@ -75,7 +75,7 @@ private:
class ImportExport ExportOCAF
{
public:
ExportOCAF(Handle_TDocStd_Document h);
ExportOCAF(Handle_TDocStd_Document h, bool explicitPlacement);
void saveShape(Part::Feature* part, const std::vector<App::Color>&);
private:
@@ -83,6 +83,7 @@ private:
Handle_XCAFDoc_ShapeTool aShapeTool;
Handle_XCAFDoc_ColorTool aColorTool;
TDF_Label rootLabel;
bool keepExplicitPlacement;
};
+4 -2
View File
@@ -427,12 +427,14 @@ private:
std::string name8bit = Part::encodeFilename(Utf8Name);
try {
Py::Sequence list(object);
Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
Handle(TDocStd_Document) hDoc;
hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc);
Import::ExportOCAF ocaf(hDoc);
Py::Sequence list(object);
bool keepExplicitPlacement = list.size() > 1;
Import::ExportOCAF ocaf(hDoc, keepExplicitPlacement);
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
PyObject* item = (*it).ptr();
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {