Enable the ReadShapeCompoundMode into the C++ code
This commit is contained in:
committed by
Yorik van Havre
parent
91a505ebd8
commit
28fc8ff34f
@@ -127,6 +127,11 @@ void ImportOCAF::loadShapes()
|
||||
lValue.clear();
|
||||
}
|
||||
|
||||
void ImportOCAF::setMerge(bool merge)
|
||||
{
|
||||
this->merge=merge;
|
||||
}
|
||||
|
||||
void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
const std::string& defaultname, const std::string& assembly, bool isRef,
|
||||
std::vector<App::DocumentObject*>& lValue)
|
||||
@@ -221,11 +226,10 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
// option within the FreeCAD preference menu
|
||||
// Currently it is merging STEP Compound Shape into a single Shape Part::Feature which
|
||||
// is an OpenCascade computed Compound
|
||||
|
||||
if (isRef)
|
||||
createShape(label, loc, part_name, lValue, true);
|
||||
createShape(label, loc, part_name, lValue, this->merge);
|
||||
else
|
||||
createShape(label, part_loc, part_name, localValue, true);
|
||||
createShape(label, part_loc, part_name, localValue, this->merge);
|
||||
}
|
||||
else {
|
||||
if (aShapeTool->IsSimpleShape(label)) {
|
||||
@@ -301,6 +305,7 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
TopoDS_Compound comp;
|
||||
builder.MakeCompound(comp);
|
||||
|
||||
/*
|
||||
std::vector<App::Color> colors;
|
||||
for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++) {
|
||||
Quantity_Color aColor;
|
||||
@@ -319,7 +324,7 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
createShape(label, loc, name, lValue, false);
|
||||
return;
|
||||
}
|
||||
|
||||
*/
|
||||
for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++) {
|
||||
const TopoDS_Shape& sh = xp.Current();
|
||||
if (!sh.IsNull()) {
|
||||
|
||||
@@ -58,18 +58,19 @@ public:
|
||||
ImportOCAF(Handle(TDocStd_Document) h, App::Document* d, const std::string& name);
|
||||
virtual ~ImportOCAF();
|
||||
void loadShapes();
|
||||
void setMerge(bool);
|
||||
|
||||
private:
|
||||
void loadShapes(const TDF_Label& label, const TopLoc_Location&, const std::string& partname, const std::string& assembly, bool isRef, std::vector<App::DocumentObject*> &);
|
||||
void createShape(const TDF_Label& label, const TopLoc_Location&, const std::string&, std::vector<App::DocumentObject*> &, bool);
|
||||
void createShape(const TopoDS_Shape& label, const TopLoc_Location&, const std::string&, std::vector<App::DocumentObject*> &);
|
||||
virtual void applyColors(Part::Feature*, const std::vector<App::Color>&){}
|
||||
|
||||
private:
|
||||
Handle(TDocStd_Document) pDoc;
|
||||
App::Document* doc;
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool;
|
||||
Handle(XCAFDoc_ColorTool) aColorTool;
|
||||
bool merge;
|
||||
std::string default_name;
|
||||
std::set<int> myRefShapes;
|
||||
static const int HashUpper = INT_MAX;
|
||||
|
||||
@@ -342,7 +342,14 @@ private:
|
||||
|
||||
Handle(XCAFApp_Application) hApp = XCAFApp_Application::GetApplication();
|
||||
Handle(TDocStd_Document) hDoc;
|
||||
bool optionReadShapeCompoundMode_status;
|
||||
bool optionScheme_214;
|
||||
bool optionScheme_203;
|
||||
hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc);
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Import/hSTEP");
|
||||
optionReadShapeCompoundMode_status = hGrp->GetBool("ReadShapeCompoundMode",false);
|
||||
optionScheme_214 = hGrp->GetBool("Scheme_214",true);
|
||||
optionScheme_203 = hGrp->GetBool("Scheme_203",false);
|
||||
|
||||
if (file.hasExtension("stp") || file.hasExtension("step")) {
|
||||
try {
|
||||
@@ -416,6 +423,8 @@ private:
|
||||
// purge the document before recomputing it to clear it and settle it in the proper
|
||||
// way. This is drastically improving STEP rendering time on complex STEP files.
|
||||
pcDoc->recompute();
|
||||
if (file.hasExtension("stp") || file.hasExtension("step"))
|
||||
ocaf.setMerge(optionReadShapeCompoundMode_status);
|
||||
ocaf.loadShapes();
|
||||
pcDoc->purgeTouched();
|
||||
pcDoc->recompute();
|
||||
|
||||
Reference in New Issue
Block a user