Move Step reader to New Part Design workflow
This commit is contained in:
committed by
wmayer
parent
68d7f38970
commit
5f1879ee21
@@ -68,6 +68,7 @@
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObjectPy.h>
|
||||
#include <App/Part.h>
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/FeatureCompound.h>
|
||||
#include "ImportOCAF.h"
|
||||
@@ -107,6 +108,7 @@ void ImportOCAF::loadShapes()
|
||||
std::vector<App::DocumentObject*> lValue;
|
||||
myRefShapes.clear();
|
||||
loadShapes(pDoc->Main(), TopLoc_Location(), default_name, "", false, lValue);
|
||||
lValue.clear();
|
||||
}
|
||||
|
||||
void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
@@ -205,20 +207,23 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
}
|
||||
else {
|
||||
// This is probably an Assembly let's try to create a Compound with the name
|
||||
Part::Compound *pcCompound = NULL;
|
||||
App::Part *pcPart = NULL;
|
||||
if (aShapeTool->IsAssembly(label)) {
|
||||
pcCompound = static_cast<Part::Compound*>(doc->addObject
|
||||
("Part::Compound",asm_name.c_str()));
|
||||
pcPart = static_cast<App::Part*>(doc->addObject
|
||||
("App::Part",asm_name.c_str()));
|
||||
}
|
||||
|
||||
for (TDF_ChildIterator it(label); it.More(); it.Next()) {
|
||||
loadShapes(it.Value(), part_loc, part_name, asm_name, isRef, localValue);
|
||||
}
|
||||
|
||||
if (pcCompound) {
|
||||
pcCompound->Links.setValues(localValue);
|
||||
lValue.push_back(pcCompound);
|
||||
Node_Shapes.push_back(pcCompound->getNameInDocument());
|
||||
if (pcPart) {
|
||||
for (std::size_t i=0; i<localValue.size(); i++) {
|
||||
pcPart->addObject((localValue[i]));
|
||||
}
|
||||
|
||||
if (!localValue.empty())
|
||||
lValue.push_back(pcPart);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,8 +243,7 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
int ctSolids = 0, ctShells = 0;
|
||||
std::vector<App::DocumentObject *> localValue;
|
||||
|
||||
Part::Compound *pcCompound = static_cast<Part::Compound*>(doc->addObject
|
||||
("Part::Compound",name.c_str() ));
|
||||
App::Part *pcPart = NULL;
|
||||
for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++) {
|
||||
createShape(xp.Current(), loc, name, localValue);
|
||||
}
|
||||
@@ -247,9 +251,18 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
createShape(xp.Current(), loc, name, localValue);
|
||||
}
|
||||
|
||||
pcCompound->Links.setValues(localValue);
|
||||
lValue.push_back(pcCompound);
|
||||
Node_Shapes.push_back(pcCompound->getNameInDocument());
|
||||
if (!localValue.empty()) {
|
||||
pcPart = static_cast<App::Part*>(doc->addObject("App::Part",name.c_str()));
|
||||
|
||||
// localValue contain the object that I must add to the local Part
|
||||
// I must add the PartOrigin and the Part itself
|
||||
for (std::size_t i=0; i<localValue.size(); i++) {
|
||||
pcPart->addObject(localValue[i]);
|
||||
}
|
||||
|
||||
lValue.push_back(pcPart);
|
||||
}
|
||||
|
||||
if (ctSolids > 0 || ctShells > 0)
|
||||
return;
|
||||
}
|
||||
@@ -261,12 +274,15 @@ void ImportOCAF::createShape(const TopoDS_Shape& aShape, const TopLoc_Location&
|
||||
std::vector<App::DocumentObject*>& lvalue)
|
||||
{
|
||||
Part::Feature* part = static_cast<Part::Feature*>(doc->addObject("Part::Feature"));
|
||||
|
||||
// I probably have to create a Part copy
|
||||
// as to properly set it up into my new step tree
|
||||
if (!loc.IsIdentity())
|
||||
part->Shape.setValue(aShape.Moved(loc));
|
||||
else
|
||||
part->Shape.setValue(aShape);
|
||||
|
||||
part->Label.setValue(name);
|
||||
Leaf_Shapes.push_back(part->getNameInDocument());
|
||||
lvalue.push_back(part);
|
||||
|
||||
Quantity_Color aColor;
|
||||
|
||||
@@ -57,12 +57,6 @@ public:
|
||||
ImportOCAF(Handle_TDocStd_Document h, App::Document* d, const std::string& name);
|
||||
virtual ~ImportOCAF();
|
||||
void loadShapes();
|
||||
std::vector<const char *> return_leaf() const {
|
||||
return Leaf_Shapes;
|
||||
}
|
||||
std::vector<const char *> return_node() const {
|
||||
return Node_Shapes;
|
||||
}
|
||||
|
||||
private:
|
||||
void loadShapes(const TDF_Label& label, const TopLoc_Location&, const std::string& partname, const std::string& assembly, bool isRef, std::vector<App::DocumentObject*> &);
|
||||
@@ -78,10 +72,6 @@ private:
|
||||
std::string default_name;
|
||||
std::set<int> myRefShapes;
|
||||
static const int HashUpper = INT_MAX;
|
||||
// These variables are used to transfer Shape names to the UI backend and decide
|
||||
// to activate / deactivate the right members for performance improvements
|
||||
std::vector<const char *> Leaf_Shapes;
|
||||
std::vector<const char *> Node_Shapes;
|
||||
};
|
||||
|
||||
class ImportExport ExportOCAF
|
||||
|
||||
@@ -407,16 +407,6 @@ private:
|
||||
|
||||
ImportOCAFExt ocaf(hDoc, pcDoc, file.fileNamePure());
|
||||
ocaf.loadShapes();
|
||||
|
||||
// Shape are loaded we must now sort the one we want to display and the one we do want to hide
|
||||
Gui::Document *guiDoc = Gui::Application::Instance->activeDocument();
|
||||
std::vector<const char *>keep_leaf= ocaf.return_leaf();
|
||||
for (std::vector<const char *>::iterator it = keep_leaf.begin() ; it != keep_leaf.end(); ++it)
|
||||
guiDoc->setShow((*it));
|
||||
std::vector<const char *>hide_node= ocaf.return_node();
|
||||
for (std::vector<const char *>::iterator it = hide_node.begin() ; it != hide_node.end(); ++it)
|
||||
guiDoc->setHide((*it));
|
||||
|
||||
pcDoc->recompute();
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
|
||||
Reference in New Issue
Block a user