Import: Apply clang format
This commit is contained in:
@@ -30,8 +30,9 @@
|
||||
#include "StepShapePy.h"
|
||||
|
||||
|
||||
namespace Import {
|
||||
extern PyObject* initModule();
|
||||
namespace Import
|
||||
{
|
||||
extern PyObject* initModule();
|
||||
}
|
||||
|
||||
PyMOD_INIT_FUNC(Import)
|
||||
@@ -41,13 +42,13 @@ PyMOD_INIT_FUNC(Import)
|
||||
try {
|
||||
Base::Interpreter().loadModule("Part");
|
||||
}
|
||||
catch(const Base::Exception& e) {
|
||||
catch (const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
PyMOD_Return(nullptr);
|
||||
}
|
||||
|
||||
// add mesh elements
|
||||
Base::Interpreter().addType(&Import::StepShapePy ::Type, importModule, "StepShape");
|
||||
Base::Interpreter().addType(&Import::StepShapePy ::Type, importModule, "StepShape");
|
||||
|
||||
|
||||
Base::Console().Log("Loading Import module... done\n");
|
||||
|
||||
@@ -22,121 +22,137 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#if defined(__MINGW32__)
|
||||
# define WNT // avoid conflict with GUID
|
||||
#define WNT// avoid conflict with GUID
|
||||
#endif
|
||||
#ifndef _PreComp_
|
||||
# include <climits>
|
||||
# if defined(__clang__)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wextra-semi"
|
||||
# endif
|
||||
# include <APIHeaderSection_MakeHeader.hxx>
|
||||
# include <IGESCAFControl_Reader.hxx>
|
||||
# include <IGESCAFControl_Writer.hxx>
|
||||
# include <IGESControl_Controller.hxx>
|
||||
# include <IGESData_GlobalSection.hxx>
|
||||
# include <IGESData_IGESModel.hxx>
|
||||
# include <IGESToBRep_Actor.hxx>
|
||||
# include <Interface_Static.hxx>
|
||||
# include <OSD_Exception.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
# include <STEPCAFControl_Reader.hxx>
|
||||
# include <STEPCAFControl_Writer.hxx>
|
||||
# include <TColStd_IndexedDataMapOfStringString.hxx>
|
||||
# include <TDocStd_Document.hxx>
|
||||
# include <Transfer_TransientProcess.hxx>
|
||||
# include <XCAFApp_Application.hxx>
|
||||
# include <XCAFDoc_DocumentTool.hxx>
|
||||
# include <XSControl_TransferReader.hxx>
|
||||
# include <XSControl_WorkSession.hxx>
|
||||
# if OCC_VERSION_HEX >= 0x070500
|
||||
# include <Message_ProgressRange.hxx>
|
||||
# include <RWGltf_CafWriter.hxx>
|
||||
# endif
|
||||
# if defined(__clang__)
|
||||
# pragma clang diagnostic pop
|
||||
# endif
|
||||
#include <climits>
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wextra-semi"
|
||||
#endif
|
||||
#include <APIHeaderSection_MakeHeader.hxx>
|
||||
#include <IGESCAFControl_Reader.hxx>
|
||||
#include <IGESCAFControl_Writer.hxx>
|
||||
#include <IGESControl_Controller.hxx>
|
||||
#include <IGESData_GlobalSection.hxx>
|
||||
#include <IGESData_IGESModel.hxx>
|
||||
#include <IGESToBRep_Actor.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <OSD_Exception.hxx>
|
||||
#include <STEPCAFControl_Reader.hxx>
|
||||
#include <STEPCAFControl_Writer.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <TColStd_IndexedDataMapOfStringString.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <Transfer_TransientProcess.hxx>
|
||||
#include <XCAFApp_Application.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XSControl_TransferReader.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
#if OCC_VERSION_HEX >= 0x070500
|
||||
#include <Message_ProgressRange.hxx>
|
||||
#include <RWGltf_CafWriter.hxx>
|
||||
#endif
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "dxf/ImpExpDxf.h"
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObjectPy.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/PyWrapParseTupleAndKeywords.h>
|
||||
#include "dxf/ImpExpDxf.h"
|
||||
#include <Mod/Part/App/encodeFilename.h>
|
||||
#include <Mod/Part/App/ImportIges.h>
|
||||
#include <Mod/Part/App/ImportStep.h>
|
||||
#include <Mod/Part/App/Interface.h>
|
||||
#include <Mod/Part/App/OCAF/ImportExportSettings.h>
|
||||
#include <Mod/Part/App/PartFeaturePy.h>
|
||||
#include <Mod/Part/App/ProgressIndicator.h>
|
||||
#include <Mod/Part/App/TopoShapePy.h>
|
||||
#include <Mod/Part/App/PartFeaturePy.h>
|
||||
#include <Mod/Part/App/OCAF/ImportExportSettings.h>
|
||||
#include <Mod/Part/App/encodeFilename.h>
|
||||
|
||||
#include "ImportOCAF2.h"
|
||||
|
||||
|
||||
namespace Import {
|
||||
namespace Import
|
||||
{
|
||||
|
||||
class ImportOCAFExt : public Import::ImportOCAF2
|
||||
class ImportOCAFExt: public Import::ImportOCAF2
|
||||
{
|
||||
public:
|
||||
ImportOCAFExt(Handle(TDocStd_Document) hStdDoc, App::Document* doc, const std::string& name)
|
||||
: ImportOCAF2(hStdDoc, doc, name)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
std::map<Part::Feature*, std::vector<App::Color> > partColors;
|
||||
std::map<Part::Feature*, std::vector<App::Color>> partColors;
|
||||
|
||||
private:
|
||||
void applyFaceColors(Part::Feature* part, const std::vector<App::Color>& colors) override {
|
||||
void applyFaceColors(Part::Feature* part, const std::vector<App::Color>& colors) override
|
||||
{
|
||||
partColors[part] = colors;
|
||||
}
|
||||
};
|
||||
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
class Module: public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("Import")
|
||||
Module()
|
||||
: Py::ExtensionModule<Module>("Import")
|
||||
{
|
||||
add_keyword_method("open",&Module::importer,
|
||||
"open(string) -- Open the file and create a new document."
|
||||
);
|
||||
add_keyword_method("insert",&Module::importer,
|
||||
"insert(string,string) -- Insert the file into the given document."
|
||||
);
|
||||
add_keyword_method("export",&Module::exporter,
|
||||
"export(list,string) -- Export a list of objects into a single file."
|
||||
);
|
||||
add_varargs_method("readDXF",&Module::readDXF,
|
||||
"readDXF(filename,[document,ignore_errors,option_source]): Imports a DXF file into the given document. ignore_errors is True by default."
|
||||
);
|
||||
add_varargs_method("writeDXFShape",&Module::writeDXFShape,
|
||||
"writeDXFShape([shape],filename [version,usePolyline,optionSource]): Exports Shape(s) to a DXF file."
|
||||
);
|
||||
add_varargs_method("writeDXFObject",&Module::writeDXFObject,
|
||||
"writeDXFObject([objects],filename [,version,usePolyline,optionSource]): Exports DocumentObject(s) to a DXF file."
|
||||
);
|
||||
initialize("This module is the Import module."); // register with Python
|
||||
add_keyword_method("open",
|
||||
&Module::importer,
|
||||
"open(string) -- Open the file and create a new document.");
|
||||
add_keyword_method("insert",
|
||||
&Module::importer,
|
||||
"insert(string,string) -- Insert the file into the given document.");
|
||||
add_keyword_method("export",
|
||||
&Module::exporter,
|
||||
"export(list,string) -- Export a list of objects into a single file.");
|
||||
add_varargs_method("readDXF",
|
||||
&Module::readDXF,
|
||||
"readDXF(filename,[document,ignore_errors,option_source]): Imports a "
|
||||
"DXF file into the given document. ignore_errors is True by default.");
|
||||
add_varargs_method("writeDXFShape",
|
||||
&Module::writeDXFShape,
|
||||
"writeDXFShape([shape],filename [version,usePolyline,optionSource]): "
|
||||
"Exports Shape(s) to a DXF file.");
|
||||
add_varargs_method(
|
||||
"writeDXFObject",
|
||||
&Module::writeDXFObject,
|
||||
"writeDXFObject([objects],filename [,version,usePolyline,optionSource]): Exports "
|
||||
"DocumentObject(s) to a DXF file.");
|
||||
initialize("This module is the Import module.");// register with Python
|
||||
}
|
||||
|
||||
~Module() override = default;
|
||||
|
||||
private:
|
||||
Py::Object importer(const Py::Tuple& args, const Py::Dict &kwds)
|
||||
Py::Object importer(const Py::Tuple& args, const Py::Dict& kwds)
|
||||
{
|
||||
char* Name;
|
||||
char* DocName=nullptr;
|
||||
PyObject *importHidden = Py_None;
|
||||
PyObject *merge = Py_None;
|
||||
PyObject *useLinkGroup = Py_None;
|
||||
char* DocName = nullptr;
|
||||
PyObject* importHidden = Py_None;
|
||||
PyObject* merge = Py_None;
|
||||
PyObject* useLinkGroup = Py_None;
|
||||
int mode = -1;
|
||||
static const std::array<const char *, 7> kwd_list {"name", "docName", "importHidden", "merge",
|
||||
"useLinkGroup", "mode", nullptr};
|
||||
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "et|sO!O!O!i",
|
||||
kwd_list, "utf-8", &Name, &DocName, &PyBool_Type, &importHidden,
|
||||
&PyBool_Type, &merge,
|
||||
&PyBool_Type, &useLinkGroup, &mode)) {
|
||||
static const std::array<const char*, 7>
|
||||
kwd_list {"name", "docName", "importHidden", "merge", "useLinkGroup", "mode", nullptr};
|
||||
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
|
||||
kwds.ptr(),
|
||||
"et|sO!O!O!i",
|
||||
kwd_list,
|
||||
"utf-8",
|
||||
&Name,
|
||||
&DocName,
|
||||
&PyBool_Type,
|
||||
&importHidden,
|
||||
&PyBool_Type,
|
||||
&merge,
|
||||
&PyBool_Type,
|
||||
&useLinkGroup,
|
||||
&mode)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
@@ -147,7 +163,7 @@ private:
|
||||
try {
|
||||
Base::FileInfo file(Utf8Name.c_str());
|
||||
|
||||
App::Document *pcDoc = nullptr;
|
||||
App::Document* pcDoc = nullptr;
|
||||
if (DocName) {
|
||||
pcDoc = App::GetApplication().getDocument(DocName);
|
||||
}
|
||||
@@ -165,7 +181,8 @@ private:
|
||||
aReader.SetColorMode(true);
|
||||
aReader.SetNameMode(true);
|
||||
aReader.SetLayerMode(true);
|
||||
if (aReader.ReadFile((Standard_CString)(name8bit.c_str())) != IFSelect_RetDone) {
|
||||
if (aReader.ReadFile((Standard_CString)(name8bit.c_str()))
|
||||
!= IFSelect_RetDone) {
|
||||
throw Py::Exception(PyExc_IOError, "cannot read STEP file");
|
||||
}
|
||||
|
||||
@@ -184,24 +201,29 @@ private:
|
||||
Base::Console().Error("%s\n", e.GetMessageString());
|
||||
Base::Console().Message("Try to load STEP file without colors...\n");
|
||||
|
||||
Part::ImportStepParts(pcDoc,Utf8Name.c_str());
|
||||
Part::ImportStepParts(pcDoc, Utf8Name.c_str());
|
||||
pcDoc->recompute();
|
||||
}
|
||||
}
|
||||
else if (file.hasExtension({"igs", "iges"})) {
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("IGES");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/Part")
|
||||
->GetGroup("IGES");
|
||||
|
||||
try {
|
||||
IGESControl_Controller::Init();
|
||||
IGESCAFControl_Reader aReader;
|
||||
// http://www.opencascade.org/org/forum/thread_20603/?forum=3
|
||||
aReader.SetReadVisible(hGrp->GetBool("SkipBlankEntities", true)
|
||||
? Standard_True : Standard_False);
|
||||
aReader.SetReadVisible(
|
||||
hGrp->GetBool("SkipBlankEntities", true) ? Standard_True : Standard_False);
|
||||
aReader.SetColorMode(true);
|
||||
aReader.SetNameMode(true);
|
||||
aReader.SetLayerMode(true);
|
||||
if (aReader.ReadFile((Standard_CString)(name8bit.c_str())) != IFSelect_RetDone) {
|
||||
if (aReader.ReadFile((Standard_CString)(name8bit.c_str()))
|
||||
!= IFSelect_RetDone) {
|
||||
throw Py::Exception(PyExc_IOError, "cannot read IGES file");
|
||||
}
|
||||
|
||||
@@ -217,13 +239,13 @@ private:
|
||||
#endif
|
||||
// http://opencascade.blogspot.de/2009/03/unnoticeable-memory-leaks-part-2.html
|
||||
Handle(IGESToBRep_Actor)::DownCast(aReader.WS()->TransferReader()->Actor())
|
||||
->SetModel(new IGESData_IGESModel);
|
||||
->SetModel(new IGESData_IGESModel);
|
||||
}
|
||||
catch (OSD_Exception& e) {
|
||||
Base::Console().Error("%s\n", e.GetMessageString());
|
||||
Base::Console().Message("Try to load IGES file without colors...\n");
|
||||
|
||||
Part::ImportIgesParts(pcDoc,Utf8Name.c_str());
|
||||
Part::ImportIgesParts(pcDoc, Utf8Name.c_str());
|
||||
pcDoc->recompute();
|
||||
}
|
||||
}
|
||||
@@ -233,21 +255,25 @@ private:
|
||||
|
||||
ImportOCAFExt ocaf(hDoc, pcDoc, file.fileNamePure());
|
||||
ocaf.setImportOptions(ImportOCAFExt::customImportOptions());
|
||||
if (merge != Py_None)
|
||||
if (merge != Py_None) {
|
||||
ocaf.setMerge(Base::asBoolean(merge));
|
||||
if (importHidden != Py_None)
|
||||
}
|
||||
if (importHidden != Py_None) {
|
||||
ocaf.setImportHiddenObject(Base::asBoolean(importHidden));
|
||||
if (useLinkGroup != Py_None)
|
||||
}
|
||||
if (useLinkGroup != Py_None) {
|
||||
ocaf.setUseLinkGroup(Base::asBoolean(useLinkGroup));
|
||||
if (mode >= 0)
|
||||
}
|
||||
if (mode >= 0) {
|
||||
ocaf.setMode(mode);
|
||||
}
|
||||
ocaf.loadShapes();
|
||||
|
||||
hApp->Close(hDoc);
|
||||
|
||||
if (!ocaf.partColors.empty()) {
|
||||
Py::List list;
|
||||
for (auto &it : ocaf.partColors) {
|
||||
for (auto& it : ocaf.partColors) {
|
||||
Py::Tuple tuple(2);
|
||||
tuple.setItem(0, Py::asObject(it.first->getPyObject()));
|
||||
|
||||
@@ -271,19 +297,32 @@ private:
|
||||
|
||||
return Py::None();
|
||||
}
|
||||
Py::Object exporter(const Py::Tuple& args, const Py::Dict &kwds)
|
||||
Py::Object exporter(const Py::Tuple& args, const Py::Dict& kwds)
|
||||
{
|
||||
PyObject* object;
|
||||
char* Name;
|
||||
PyObject *exportHidden = Py_None;
|
||||
PyObject *legacy = Py_None;
|
||||
PyObject *keepPlacement = Py_None;
|
||||
static const std::array<const char *, 6> kwd_list{"obj", "name", "exportHidden", "legacy", "keepPlacement",
|
||||
PyObject* exportHidden = Py_None;
|
||||
PyObject* legacy = Py_None;
|
||||
PyObject* keepPlacement = Py_None;
|
||||
static const std::array<const char*, 6> kwd_list {"obj",
|
||||
"name",
|
||||
"exportHidden",
|
||||
"legacy",
|
||||
"keepPlacement",
|
||||
nullptr};
|
||||
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "Oet|O!O!O!",
|
||||
kwd_list, &object, "utf-8", &Name, &PyBool_Type, &exportHidden,
|
||||
&PyBool_Type, &legacy,
|
||||
&PyBool_Type, &keepPlacement)) {
|
||||
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
|
||||
kwds.ptr(),
|
||||
"Oet|O!O!O!",
|
||||
kwd_list,
|
||||
&object,
|
||||
"utf-8",
|
||||
&Name,
|
||||
&PyBool_Type,
|
||||
&exportHidden,
|
||||
&PyBool_Type,
|
||||
&legacy,
|
||||
&PyBool_Type,
|
||||
&keepPlacement)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
@@ -300,8 +339,10 @@ private:
|
||||
std::vector<App::DocumentObject*> objs;
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
PyObject* item = (*it).ptr();
|
||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type)))
|
||||
objs.push_back(static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr());
|
||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
||||
objs.push_back(
|
||||
static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr());
|
||||
}
|
||||
}
|
||||
|
||||
if (legacy == Py_None) {
|
||||
@@ -313,10 +354,12 @@ private:
|
||||
if (!Base::asBoolean(legacy) || !ocaf.canFallback(objs)) {
|
||||
ocaf.setExportOptions(ExportOCAF2::customExportOptions());
|
||||
|
||||
if (exportHidden != Py_None)
|
||||
if (exportHidden != Py_None) {
|
||||
ocaf.setExportHiddenObject(Base::asBoolean(exportHidden));
|
||||
if (keepPlacement != Py_None)
|
||||
}
|
||||
if (keepPlacement != Py_None) {
|
||||
ocaf.setKeepPlacement(Base::asBoolean(keepPlacement));
|
||||
}
|
||||
|
||||
ocaf.exportObjects(objs);
|
||||
}
|
||||
@@ -324,17 +367,19 @@ private:
|
||||
bool keepExplicitPlacement = Standard_True;
|
||||
ExportOCAF ocaf(hDoc, keepExplicitPlacement);
|
||||
// That stuff is exporting a list of selected objects into FreeCAD Tree
|
||||
std::vector <TDF_Label> hierarchical_label;
|
||||
std::vector <TopLoc_Location> hierarchical_loc;
|
||||
std::vector <App::DocumentObject*> hierarchical_part;
|
||||
for(auto obj : objs)
|
||||
ocaf.exportObject(obj,hierarchical_label, hierarchical_loc,hierarchical_part);
|
||||
std::vector<TDF_Label> hierarchical_label;
|
||||
std::vector<TopLoc_Location> hierarchical_loc;
|
||||
std::vector<App::DocumentObject*> hierarchical_part;
|
||||
for (auto obj : objs) {
|
||||
ocaf.exportObject(obj, hierarchical_label, hierarchical_loc, hierarchical_part);
|
||||
}
|
||||
|
||||
// Free Shapes must have absolute placement and not explicit
|
||||
std::vector <TDF_Label> FreeLabels;
|
||||
std::vector <int> part_id;
|
||||
ocaf.getFreeLabels(hierarchical_label,FreeLabels, part_id);
|
||||
// Update is not performed automatically anymore: https://tracker.dev.opencascade.org/view.php?id=28055
|
||||
std::vector<TDF_Label> FreeLabels;
|
||||
std::vector<int> part_id;
|
||||
ocaf.getFreeLabels(hierarchical_label, FreeLabels, part_id);
|
||||
// Update is not performed automatically anymore:
|
||||
// https://tracker.dev.opencascade.org/view.php?id=28055
|
||||
XCAFDoc_DocumentTool::ShapeTool(hDoc->Main())->UpdateAssemblies();
|
||||
}
|
||||
|
||||
@@ -345,17 +390,27 @@ private:
|
||||
writer.Transfer(hDoc, STEPControl_AsIs);
|
||||
|
||||
APIHeaderSection_MakeHeader makeHeader(writer.ChangeWriter().Model());
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("STEP");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/Part")
|
||||
->GetGroup("STEP");
|
||||
|
||||
// Don't set name because STEP doesn't support UTF-8
|
||||
// https://forum.freecad.org/viewtopic.php?f=8&t=52967
|
||||
makeHeader.SetAuthorValue (1, new TCollection_HAsciiString(hGrp->GetASCII("Author", "Author").c_str()));
|
||||
makeHeader.SetOrganizationValue (1, new TCollection_HAsciiString(hGrp->GetASCII("Company").c_str()));
|
||||
makeHeader.SetOriginatingSystem(new TCollection_HAsciiString(App::Application::getExecutableName().c_str()));
|
||||
makeHeader.SetAuthorValue(
|
||||
1,
|
||||
new TCollection_HAsciiString(hGrp->GetASCII("Author", "Author").c_str()));
|
||||
makeHeader.SetOrganizationValue(
|
||||
1,
|
||||
new TCollection_HAsciiString(hGrp->GetASCII("Company").c_str()));
|
||||
makeHeader.SetOriginatingSystem(
|
||||
new TCollection_HAsciiString(App::Application::getExecutableName().c_str()));
|
||||
makeHeader.SetDescriptionValue(1, new TCollection_HAsciiString("FreeCAD Model"));
|
||||
IFSelect_ReturnStatus ret = writer.Write(name8bit.c_str());
|
||||
if (ret == IFSelect_RetError || ret == IFSelect_RetFail || ret == IFSelect_RetStop) {
|
||||
if (ret == IFSelect_RetError || ret == IFSelect_RetFail
|
||||
|| ret == IFSelect_RetStop) {
|
||||
PyErr_Format(PyExc_IOError, "Cannot open file '%s'", Utf8Name.c_str());
|
||||
throw Py::Exception();
|
||||
}
|
||||
@@ -364,9 +419,12 @@ private:
|
||||
IGESControl_Controller::Init();
|
||||
IGESCAFControl_Writer writer;
|
||||
IGESData_GlobalSection header = writer.Model()->GlobalSection();
|
||||
header.SetAuthorName(new TCollection_HAsciiString(Part::Interface::writeIgesHeaderAuthor()));
|
||||
header.SetCompanyName(new TCollection_HAsciiString(Part::Interface::writeIgesHeaderCompany()));
|
||||
header.SetSendName(new TCollection_HAsciiString(Part::Interface::writeIgesHeaderProduct()));
|
||||
header.SetAuthorName(
|
||||
new TCollection_HAsciiString(Part::Interface::writeIgesHeaderAuthor()));
|
||||
header.SetCompanyName(
|
||||
new TCollection_HAsciiString(Part::Interface::writeIgesHeaderCompany()));
|
||||
header.SetSendName(
|
||||
new TCollection_HAsciiString(Part::Interface::writeIgesHeaderProduct()));
|
||||
writer.Model()->SetGlobalSection(header);
|
||||
writer.Transfer(hDoc);
|
||||
Standard_Boolean ret = writer.Write(name8bit.c_str());
|
||||
@@ -378,15 +436,16 @@ private:
|
||||
else if (file.hasExtension({"glb", "gltf"})) {
|
||||
#if OCC_VERSION_HEX >= 0x070500
|
||||
TColStd_IndexedDataMapOfStringString aMetadata;
|
||||
RWGltf_CafWriter aWriter (name8bit.c_str(), file.hasExtension("glb"));
|
||||
aWriter.SetTransformationFormat (RWGltf_WriterTrsfFormat_Compact);
|
||||
RWGltf_CafWriter aWriter(name8bit.c_str(), file.hasExtension("glb"));
|
||||
aWriter.SetTransformationFormat(RWGltf_WriterTrsfFormat_Compact);
|
||||
// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#coordinate-system-and-units
|
||||
aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (0.001);
|
||||
aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem (RWMesh_CoordinateSystem_Zup);
|
||||
aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit(0.001);
|
||||
aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem(
|
||||
RWMesh_CoordinateSystem_Zup);
|
||||
#if OCC_VERSION_HEX >= 0x070700
|
||||
aWriter.SetParallel(true);
|
||||
#endif
|
||||
Standard_Boolean ret = aWriter.Perform (hDoc, aMetadata, Message_ProgressRange());
|
||||
Standard_Boolean ret = aWriter.Perform(hDoc, aMetadata, Message_ProgressRange());
|
||||
if (!ret) {
|
||||
PyErr_Format(PyExc_IOError, "Cannot save to file '%s'", Utf8Name.c_str());
|
||||
throw Py::Exception();
|
||||
@@ -412,34 +471,46 @@ private:
|
||||
Py::Object readDXF(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
const char* DocName=nullptr;
|
||||
const char* DocName = nullptr;
|
||||
const char* optionSource = nullptr;
|
||||
std::string defaultOptions = "User parameter:BaseApp/Preferences/Mod/Draft";
|
||||
bool IgnoreErrors=true;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et|sbs","utf-8",&Name,&DocName,&IgnoreErrors,&optionSource))
|
||||
bool IgnoreErrors = true;
|
||||
if (!PyArg_ParseTuple(args.ptr(),
|
||||
"et|sbs",
|
||||
"utf-8",
|
||||
&Name,
|
||||
&DocName,
|
||||
&IgnoreErrors,
|
||||
&optionSource)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
Base::FileInfo file(EncodedName.c_str());
|
||||
if (!file.exists())
|
||||
if (!file.exists()) {
|
||||
throw Py::RuntimeError("File doesn't exist");
|
||||
}
|
||||
|
||||
if (optionSource)
|
||||
if (optionSource) {
|
||||
defaultOptions = optionSource;
|
||||
}
|
||||
|
||||
App::Document *pcDoc;
|
||||
if (DocName)
|
||||
App::Document* pcDoc;
|
||||
if (DocName) {
|
||||
pcDoc = App::GetApplication().getDocument(DocName);
|
||||
else
|
||||
}
|
||||
else {
|
||||
pcDoc = App::GetApplication().getActiveDocument();
|
||||
if (!pcDoc)
|
||||
}
|
||||
if (!pcDoc) {
|
||||
pcDoc = App::GetApplication().newDocument(DocName);
|
||||
}
|
||||
|
||||
try {
|
||||
// read the DXF file
|
||||
ImpExpDxfRead dxf_file(EncodedName,pcDoc);
|
||||
ImpExpDxfRead dxf_file(EncodedName, pcDoc);
|
||||
dxf_file.setOptionSource(defaultOptions);
|
||||
dxf_file.setOptions();
|
||||
dxf_file.DoRead(IgnoreErrors);
|
||||
@@ -456,35 +527,36 @@ private:
|
||||
|
||||
Py::Object writeDXFShape(const Py::Tuple& args)
|
||||
{
|
||||
PyObject *shapeObj;
|
||||
PyObject* shapeObj;
|
||||
char* fname;
|
||||
std::string filePath;
|
||||
std::string layerName;
|
||||
const char* optionSource = nullptr;
|
||||
std::string defaultOptions = "User parameter:BaseApp/Preferences/Mod/Import";
|
||||
int versionParm = -1;
|
||||
bool versionOverride = false;
|
||||
bool polyOverride = false;
|
||||
PyObject *usePolyline = Py_False;
|
||||
int versionParm = -1;
|
||||
bool versionOverride = false;
|
||||
bool polyOverride = false;
|
||||
PyObject* usePolyline = Py_False;
|
||||
|
||||
//handle list of shapes
|
||||
if (PyArg_ParseTuple(args.ptr(), "O!et|iOs", &(PyList_Type) ,
|
||||
&shapeObj,
|
||||
"utf-8",
|
||||
&fname,
|
||||
&versionParm,
|
||||
&usePolyline,
|
||||
&optionSource)) {
|
||||
// handle list of shapes
|
||||
if (PyArg_ParseTuple(args.ptr(),
|
||||
"O!et|iOs",
|
||||
&(PyList_Type),
|
||||
&shapeObj,
|
||||
"utf-8",
|
||||
&fname,
|
||||
&versionParm,
|
||||
&usePolyline,
|
||||
&optionSource)) {
|
||||
filePath = std::string(fname);
|
||||
layerName = "none";
|
||||
PyMem_Free(fname);
|
||||
|
||||
if ((versionParm == 12) ||
|
||||
(versionParm == 14)) {
|
||||
versionOverride = true;
|
||||
if ((versionParm == 12) || (versionParm == 14)) {
|
||||
versionOverride = true;
|
||||
}
|
||||
if (usePolyline == Py_True) {
|
||||
polyOverride = true;
|
||||
polyOverride = true;
|
||||
}
|
||||
if (optionSource) {
|
||||
defaultOptions = optionSource;
|
||||
@@ -503,7 +575,8 @@ private:
|
||||
Py::Sequence list(shapeObj);
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapePy::Type))) {
|
||||
Part::TopoShape* ts = static_cast<Part::TopoShapePy*>((*it).ptr())->getTopoShapePtr();
|
||||
Part::TopoShape* ts =
|
||||
static_cast<Part::TopoShapePy*>((*it).ptr())->getTopoShapePtr();
|
||||
TopoDS_Shape shape = ts->getShape();
|
||||
writer.exportShape(shape);
|
||||
}
|
||||
@@ -517,23 +590,24 @@ private:
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args.ptr(), "O!et|iOs", &(Part::TopoShapePy::Type) ,
|
||||
&shapeObj,
|
||||
"utf-8",
|
||||
&fname,
|
||||
&versionParm,
|
||||
&usePolyline,
|
||||
&optionSource)) {
|
||||
if (PyArg_ParseTuple(args.ptr(),
|
||||
"O!et|iOs",
|
||||
&(Part::TopoShapePy::Type),
|
||||
&shapeObj,
|
||||
"utf-8",
|
||||
&fname,
|
||||
&versionParm,
|
||||
&usePolyline,
|
||||
&optionSource)) {
|
||||
filePath = std::string(fname);
|
||||
layerName = "none";
|
||||
PyMem_Free(fname);
|
||||
|
||||
if ((versionParm == 12) ||
|
||||
(versionParm == 14)) {
|
||||
versionOverride = true;
|
||||
if ((versionParm == 12) || (versionParm == 14)) {
|
||||
versionOverride = true;
|
||||
}
|
||||
if (usePolyline == Py_True) {
|
||||
polyOverride = true;
|
||||
polyOverride = true;
|
||||
}
|
||||
if (optionSource) {
|
||||
defaultOptions = optionSource;
|
||||
@@ -565,34 +639,35 @@ private:
|
||||
|
||||
Py::Object writeDXFObject(const Py::Tuple& args)
|
||||
{
|
||||
PyObject *docObj;
|
||||
PyObject* docObj;
|
||||
char* fname;
|
||||
std::string filePath;
|
||||
std::string layerName;
|
||||
const char* optionSource = nullptr;
|
||||
std::string defaultOptions = "User parameter:BaseApp/Preferences/Mod/Import";
|
||||
int versionParm = -1;
|
||||
bool versionOverride = false;
|
||||
bool polyOverride = false;
|
||||
PyObject *usePolyline = Py_False;
|
||||
int versionParm = -1;
|
||||
bool versionOverride = false;
|
||||
bool polyOverride = false;
|
||||
PyObject* usePolyline = Py_False;
|
||||
|
||||
if (PyArg_ParseTuple(args.ptr(), "O!et|iOs", &(PyList_Type) ,
|
||||
&docObj,
|
||||
"utf-8",
|
||||
&fname,
|
||||
&versionParm,
|
||||
&usePolyline,
|
||||
&optionSource)) {
|
||||
if (PyArg_ParseTuple(args.ptr(),
|
||||
"O!et|iOs",
|
||||
&(PyList_Type),
|
||||
&docObj,
|
||||
"utf-8",
|
||||
&fname,
|
||||
&versionParm,
|
||||
&usePolyline,
|
||||
&optionSource)) {
|
||||
filePath = std::string(fname);
|
||||
layerName = "none";
|
||||
PyMem_Free(fname);
|
||||
|
||||
if ((versionParm == 12) ||
|
||||
(versionParm == 14)) {
|
||||
versionOverride = true;
|
||||
if ((versionParm == 12) || (versionParm == 14)) {
|
||||
versionOverride = true;
|
||||
}
|
||||
if (usePolyline == Py_True) {
|
||||
polyOverride = true;
|
||||
polyOverride = true;
|
||||
}
|
||||
|
||||
if (optionSource) {
|
||||
@@ -613,7 +688,8 @@ private:
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
if (PyObject_TypeCheck((*it).ptr(), &(Part::PartFeaturePy::Type))) {
|
||||
PyObject* item = (*it).ptr();
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
App::DocumentObject* obj =
|
||||
static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr();
|
||||
Part::Feature* part = static_cast<Part::Feature*>(obj);
|
||||
layerName = part->getNameInDocument();
|
||||
writer.setLayerName(layerName);
|
||||
@@ -630,29 +706,30 @@ private:
|
||||
}
|
||||
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args.ptr(), "O!et|iOs", &(App::DocumentObjectPy::Type) ,
|
||||
&docObj,
|
||||
"utf-8",
|
||||
&fname,
|
||||
&versionParm,
|
||||
&usePolyline,
|
||||
&optionSource)) {
|
||||
if (PyArg_ParseTuple(args.ptr(),
|
||||
"O!et|iOs",
|
||||
&(App::DocumentObjectPy::Type),
|
||||
&docObj,
|
||||
"utf-8",
|
||||
&fname,
|
||||
&versionParm,
|
||||
&usePolyline,
|
||||
&optionSource)) {
|
||||
filePath = std::string(fname);
|
||||
layerName = "none";
|
||||
PyMem_Free(fname);
|
||||
|
||||
if ((versionParm == 12) ||
|
||||
(versionParm == 14)) {
|
||||
versionOverride = true;
|
||||
if ((versionParm == 12) || (versionParm == 14)) {
|
||||
versionOverride = true;
|
||||
}
|
||||
if (usePolyline == Py_True) {
|
||||
polyOverride = true;
|
||||
polyOverride = true;
|
||||
}
|
||||
|
||||
if (optionSource) {
|
||||
defaultOptions = optionSource;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
ImpExpDxfWrite writer(filePath);
|
||||
writer.setOptionSource(defaultOptions);
|
||||
@@ -663,7 +740,8 @@ private:
|
||||
writer.setPolyOverride(polyOverride);
|
||||
writer.setLayerName(layerName);
|
||||
writer.init();
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(docObj)->getDocumentObjectPtr();
|
||||
App::DocumentObject* obj =
|
||||
static_cast<App::DocumentObjectPy*>(docObj)->getDocumentObjectPtr();
|
||||
Part::Feature* part = static_cast<Part::Feature*>(obj);
|
||||
layerName = part->getNameInDocument();
|
||||
writer.setLayerName(layerName);
|
||||
@@ -687,4 +765,4 @@ PyObject* initModule()
|
||||
return Base::Interpreter().addModule(new Module);
|
||||
}
|
||||
|
||||
} // namespace Import
|
||||
}// namespace Import
|
||||
|
||||
@@ -22,25 +22,25 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#if defined(__MINGW32__)
|
||||
# define WNT // avoid conflict with GUID
|
||||
#define WNT// avoid conflict with GUID
|
||||
#endif
|
||||
#ifndef _PreComp_
|
||||
# include <climits>
|
||||
# include <gp_Ax1.hxx>
|
||||
# include <gp_Dir.hxx>
|
||||
# include <gp_Pln.hxx> // for Precision::Confusion()
|
||||
# include <gp_Trsf.hxx>
|
||||
# include <Quantity_ColorRGBA.hxx>
|
||||
# include <Standard_Failure.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
# include <TDataStd_Name.hxx>
|
||||
# include <TDF_Label.hxx>
|
||||
# include <TDF_LabelSequence.hxx>
|
||||
# include <TDocStd_Document.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
# include <XCAFDoc_DocumentTool.hxx>
|
||||
# include <XCAFDoc_Location.hxx>
|
||||
#include <Quantity_ColorRGBA.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_LabelSequence.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_Location.hxx>
|
||||
#include <climits>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pln.hxx>// for Precision::Confusion()
|
||||
#include <gp_Trsf.hxx>
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
@@ -54,12 +54,12 @@
|
||||
|
||||
#if OCC_VERSION_HEX >= 0x070500
|
||||
// See https://dev.opencascade.org/content/occt-3d-viewer-becomes-srgb-aware
|
||||
# define OCC_COLOR_SPACE Quantity_TOC_sRGB
|
||||
#define OCC_COLOR_SPACE Quantity_TOC_sRGB
|
||||
#else
|
||||
# define OCC_COLOR_SPACE Quantity_TOC_RGB
|
||||
#define OCC_COLOR_SPACE Quantity_TOC_RGB
|
||||
#endif
|
||||
|
||||
static inline Quantity_ColorRGBA convertColor(const App::Color &c)
|
||||
static inline Quantity_ColorRGBA convertColor(const App::Color& c)
|
||||
{
|
||||
return Quantity_ColorRGBA(Quantity_Color(c.r, c.g, c.b, OCC_COLOR_SPACE), 1.0 - c.a);
|
||||
}
|
||||
@@ -118,8 +118,9 @@ std::vector<App::DocumentObject*> ExportOCAF::filterPart(App::Part* part) const
|
||||
}
|
||||
}
|
||||
|
||||
if (accept)
|
||||
if (accept) {
|
||||
keepObjects.push_back(it);
|
||||
}
|
||||
}
|
||||
|
||||
entries.swap(keepObjects);
|
||||
@@ -129,11 +130,11 @@ std::vector<App::DocumentObject*> ExportOCAF::filterPart(App::Part* part) const
|
||||
}
|
||||
|
||||
int ExportOCAF::exportObject(App::DocumentObject* obj,
|
||||
std::vector <TDF_Label>& hierarchical_label,
|
||||
std::vector <TopLoc_Location>& hierarchical_loc,
|
||||
std::vector <App::DocumentObject*>& hierarchical_part)
|
||||
std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TopLoc_Location>& hierarchical_loc,
|
||||
std::vector<App::DocumentObject*>& hierarchical_part)
|
||||
{
|
||||
std::vector <int> local_label;
|
||||
std::vector<int> local_label;
|
||||
int root_id;
|
||||
int return_label = -1;
|
||||
|
||||
@@ -148,15 +149,16 @@ int ExportOCAF::exportObject(App::DocumentObject* obj,
|
||||
}
|
||||
|
||||
for (it = entries.begin(); it != entries.end(); ++it) {
|
||||
int new_label=0;
|
||||
new_label = exportObject((*it), hierarchical_label, hierarchical_loc, hierarchical_part);
|
||||
int new_label = 0;
|
||||
new_label =
|
||||
exportObject((*it), hierarchical_label, hierarchical_loc, hierarchical_part);
|
||||
local_label.push_back(new_label);
|
||||
}
|
||||
|
||||
createNode(part,root_id, hierarchical_label, hierarchical_loc, hierarchical_part);
|
||||
createNode(part, root_id, hierarchical_label, hierarchical_loc, hierarchical_part);
|
||||
std::vector<int>::iterator label_it;
|
||||
for (label_it = local_label.begin(); label_it != local_label.end(); ++label_it) {
|
||||
pushNode(root_id,(*label_it), hierarchical_label,hierarchical_loc);
|
||||
pushNode(root_id, (*label_it), hierarchical_label, hierarchical_loc);
|
||||
}
|
||||
|
||||
return_label = root_id;
|
||||
@@ -167,17 +169,20 @@ int ExportOCAF::exportObject(App::DocumentObject* obj,
|
||||
std::vector<App::Color> colors;
|
||||
findColors(part, colors);
|
||||
|
||||
return_label = saveShape(part, colors, hierarchical_label, hierarchical_loc, hierarchical_part);
|
||||
return_label =
|
||||
saveShape(part, colors, hierarchical_label, hierarchical_loc, hierarchical_part);
|
||||
}
|
||||
|
||||
return return_label;
|
||||
}
|
||||
|
||||
// This function creates an Assembly node in an XCAF document with its relative placement information
|
||||
void ExportOCAF::createNode(App::Part* part, int& root_id,
|
||||
std::vector <TDF_Label>& hierarchical_label,
|
||||
std::vector <TopLoc_Location>& hierarchical_loc,
|
||||
std::vector <App::DocumentObject*>& hierarchical_part)
|
||||
// This function creates an Assembly node in an XCAF document with its relative placement
|
||||
// information
|
||||
void ExportOCAF::createNode(App::Part* part,
|
||||
int& root_id,
|
||||
std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TopLoc_Location>& hierarchical_loc,
|
||||
std::vector<App::DocumentObject*>& hierarchical_part)
|
||||
{
|
||||
TDF_Label shapeLabel = aShapeTool->NewShape();
|
||||
Handle(TDataStd_Name) N;
|
||||
@@ -192,24 +197,26 @@ void ExportOCAF::createNode(App::Part* part, int& root_id,
|
||||
|
||||
gp_Trsf trf;
|
||||
trf.SetRotation(gp_Ax1(gp_Pnt(), gp_Dir(axis.x, axis.y, axis.z)), angle);
|
||||
trf.SetTranslationPart(gp_Vec(pl.getPosition().x,pl.getPosition().y,pl.getPosition().z));
|
||||
trf.SetTranslationPart(gp_Vec(pl.getPosition().x, pl.getPosition().y, pl.getPosition().z));
|
||||
TopLoc_Location MyLoc = TopLoc_Location(trf);
|
||||
XCAFDoc_Location::Set(shapeLabel,TopLoc_Location(trf));
|
||||
XCAFDoc_Location::Set(shapeLabel, TopLoc_Location(trf));
|
||||
|
||||
hierarchical_label.push_back(shapeLabel);
|
||||
hierarchical_loc.push_back(MyLoc);
|
||||
hierarchical_part.push_back(part);
|
||||
root_id=hierarchical_label.size();
|
||||
root_id = hierarchical_label.size();
|
||||
}
|
||||
|
||||
int ExportOCAF::saveShape(Part::Feature* part, const std::vector<App::Color>& colors,
|
||||
std::vector <TDF_Label>& hierarchical_label,
|
||||
std::vector <TopLoc_Location>& hierarchical_loc,
|
||||
std::vector <App::DocumentObject*>& hierarchical_part)
|
||||
int ExportOCAF::saveShape(Part::Feature* part,
|
||||
const std::vector<App::Color>& colors,
|
||||
std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TopLoc_Location>& hierarchical_loc,
|
||||
std::vector<App::DocumentObject*>& hierarchical_part)
|
||||
{
|
||||
const TopoDS_Shape& shape = part->Shape.getValue();
|
||||
if (shape.IsNull())
|
||||
if (shape.IsNull()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
TopoDS_Shape baseShape;
|
||||
TopLoc_Location aLoc;
|
||||
@@ -221,8 +228,8 @@ int ExportOCAF::saveShape(Part::Feature* part, const std::vector<App::Color>& co
|
||||
double angle;
|
||||
rot.getValue(axis, angle);
|
||||
gp_Trsf trf;
|
||||
trf.SetRotation(gp_Ax1(gp_Pnt(0.,0.,0.), gp_Dir(axis.x, axis.y, axis.z)), angle);
|
||||
trf.SetTranslationPart(gp_Vec(pl.getPosition().x,pl.getPosition().y,pl.getPosition().z));
|
||||
trf.SetRotation(gp_Ax1(gp_Pnt(0., 0., 0.), gp_Dir(axis.x, axis.y, axis.z)), angle);
|
||||
trf.SetTranslationPart(gp_Vec(pl.getPosition().x, pl.getPosition().y, pl.getPosition().z));
|
||||
TopLoc_Location MyLoc = TopLoc_Location(trf);
|
||||
|
||||
if (keepExplicitPlacement) {
|
||||
@@ -241,19 +248,19 @@ int ExportOCAF::saveShape(Part::Feature* part, const std::vector<App::Color>& co
|
||||
TDataStd_Name::Set(shapeLabel, TCollection_ExtendedString(part->Label.getValue(), true));
|
||||
|
||||
|
||||
/*
|
||||
if (keepExplicitPlacement) {
|
||||
aShapeTool->AddComponent(aShapeTool->BaseLabel(), shapeLabel, aLoc);
|
||||
XCAFDoc_Location::Set(shapeLabel,MyLoc);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
if (keepExplicitPlacement) {
|
||||
aShapeTool->AddComponent(aShapeTool->BaseLabel(), shapeLabel, aLoc);
|
||||
XCAFDoc_Location::Set(shapeLabel,MyLoc);
|
||||
}
|
||||
*/
|
||||
|
||||
// Add color information
|
||||
Quantity_ColorRGBA col;
|
||||
|
||||
std::set<int> face_index;
|
||||
TopTools_IndexedMapOfShape faces;
|
||||
TopExp_Explorer xp(baseShape,TopAbs_FACE);
|
||||
TopExp_Explorer xp(baseShape, TopAbs_FACE);
|
||||
while (xp.More()) {
|
||||
face_index.insert(faces.Add(xp.Current()));
|
||||
xp.Next();
|
||||
@@ -261,7 +268,7 @@ int ExportOCAF::saveShape(Part::Feature* part, const std::vector<App::Color>& co
|
||||
|
||||
// define color per face?
|
||||
if (colors.size() == face_index.size()) {
|
||||
xp.Init(baseShape,TopAbs_FACE);
|
||||
xp.Init(baseShape, TopAbs_FACE);
|
||||
while (xp.More()) {
|
||||
int index = faces.FindIndex(xp.Current());
|
||||
if (face_index.find(index) != face_index.end()) {
|
||||
@@ -281,7 +288,7 @@ int ExportOCAF::saveShape(Part::Feature* part, const std::vector<App::Color>& co
|
||||
}
|
||||
|
||||
if (!faceLabel.IsNull()) {
|
||||
const App::Color& color = colors[index-1];
|
||||
const App::Color& color = colors[index - 1];
|
||||
col = convertColor(color);
|
||||
aColorTool->SetColor(faceLabel, col, XCAFDoc_ColorSurf);
|
||||
}
|
||||
@@ -299,16 +306,16 @@ int ExportOCAF::saveShape(Part::Feature* part, const std::vector<App::Color>& co
|
||||
hierarchical_loc.push_back(MyLoc);
|
||||
hierarchical_part.push_back(part);
|
||||
|
||||
return(hierarchical_label.size());
|
||||
return (hierarchical_label.size());
|
||||
}
|
||||
|
||||
// This function is scanning the OCAF doc for Free Shapes and returns the label attached to it
|
||||
// If this Free Shapes are regular Part::Feature, we must use absolute coordinate instead of
|
||||
// allocating a placement into the hierarchy as it is not attached to a hierarchical node
|
||||
|
||||
void ExportOCAF::getFreeLabels(std::vector <TDF_Label>& hierarchical_label,
|
||||
std::vector <TDF_Label>& labels,
|
||||
std::vector <int>& label_part_id)
|
||||
void ExportOCAF::getFreeLabels(std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TDF_Label>& labels,
|
||||
std::vector<int>& label_part_id)
|
||||
{
|
||||
TDF_LabelSequence FreeLabels;
|
||||
aShapeTool->GetFreeShapes(FreeLabels);
|
||||
@@ -324,36 +331,38 @@ void ExportOCAF::getFreeLabels(std::vector <TDF_Label>& hierarchical_label,
|
||||
}
|
||||
}
|
||||
|
||||
void ExportOCAF::getPartColors(std::vector <App::DocumentObject*> hierarchical_part,
|
||||
std::vector <TDF_Label> FreeLabels,
|
||||
std::vector <int> part_id,
|
||||
std::vector < std::vector<App::Color> >& Colors) const
|
||||
void ExportOCAF::getPartColors(std::vector<App::DocumentObject*> hierarchical_part,
|
||||
std::vector<TDF_Label> FreeLabels,
|
||||
std::vector<int> part_id,
|
||||
std::vector<std::vector<App::Color>>& Colors) const
|
||||
{
|
||||
// I am seeking for the colors of each parts
|
||||
std::size_t n = FreeLabels.size();
|
||||
for (std::size_t i = 0; i < n; i++) {
|
||||
std::vector<App::Color> colors;
|
||||
Part::Feature * part = static_cast<Part::Feature *>(hierarchical_part.at(part_id.at(i)));
|
||||
Part::Feature* part = static_cast<Part::Feature*>(hierarchical_part.at(part_id.at(i)));
|
||||
findColors(part, colors);
|
||||
Colors.push_back(colors);
|
||||
}
|
||||
}
|
||||
|
||||
void ExportOCAF::reallocateFreeShape(std::vector <App::DocumentObject*> hierarchical_part,
|
||||
std::vector <TDF_Label> FreeLabels,
|
||||
std::vector <int> part_id,
|
||||
std::vector< std::vector<App::Color> >& Colors)
|
||||
void ExportOCAF::reallocateFreeShape(std::vector<App::DocumentObject*> hierarchical_part,
|
||||
std::vector<TDF_Label> FreeLabels,
|
||||
std::vector<int> part_id,
|
||||
std::vector<std::vector<App::Color>>& Colors)
|
||||
{
|
||||
std::size_t n = FreeLabels.size();
|
||||
for (std::size_t i = 0; i < n; i++) {
|
||||
TDF_Label label = FreeLabels.at(i);
|
||||
// hierarchical part does contain only part currently and not node I should add node
|
||||
if (hierarchical_part.at(part_id.at(i))->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
Part::Feature * part = static_cast<Part::Feature *>(hierarchical_part.at(part_id.at(i)));
|
||||
if (hierarchical_part.at(part_id.at(i))
|
||||
->getTypeId()
|
||||
.isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
Part::Feature* part = static_cast<Part::Feature*>(hierarchical_part.at(part_id.at(i)));
|
||||
aShapeTool->SetShape(label, part->Shape.getValue());
|
||||
// Add color information
|
||||
std::vector<App::Color> colors;
|
||||
colors=Colors.at(i);
|
||||
colors = Colors.at(i);
|
||||
TopoDS_Shape baseShape = part->Shape.getValue();
|
||||
|
||||
// Add color information
|
||||
@@ -361,7 +370,7 @@ void ExportOCAF::reallocateFreeShape(std::vector <App::DocumentObject*> hierarch
|
||||
|
||||
std::set<int> face_index;
|
||||
TopTools_IndexedMapOfShape faces;
|
||||
TopExp_Explorer xp(baseShape,TopAbs_FACE);
|
||||
TopExp_Explorer xp(baseShape, TopAbs_FACE);
|
||||
while (xp.More()) {
|
||||
face_index.insert(faces.Add(xp.Current()));
|
||||
xp.Next();
|
||||
@@ -369,7 +378,7 @@ void ExportOCAF::reallocateFreeShape(std::vector <App::DocumentObject*> hierarch
|
||||
|
||||
// define color per face?
|
||||
if (colors.size() == face_index.size()) {
|
||||
xp.Init(baseShape,TopAbs_FACE);
|
||||
xp.Init(baseShape, TopAbs_FACE);
|
||||
while (xp.More()) {
|
||||
int index = faces.FindIndex(xp.Current());
|
||||
if (face_index.find(index) != face_index.end()) {
|
||||
@@ -389,7 +398,7 @@ void ExportOCAF::reallocateFreeShape(std::vector <App::DocumentObject*> hierarch
|
||||
}
|
||||
|
||||
if (!faceLabel.IsNull()) {
|
||||
const App::Color& color = colors[index-1];
|
||||
const App::Color& color = colors[index - 1];
|
||||
col = convertColor(color);
|
||||
aColorTool->SetColor(faceLabel, col, XCAFDoc_ColorSurf);
|
||||
}
|
||||
@@ -408,26 +417,31 @@ void ExportOCAF::reallocateFreeShape(std::vector <App::DocumentObject*> hierarch
|
||||
}
|
||||
|
||||
// This function is moving a "standard" node into an Assembly node within an XCAF doc
|
||||
void ExportOCAF::pushNode(int root_id, int node_id, std::vector <TDF_Label>& hierarchical_label,std::vector <TopLoc_Location>& hierarchical_loc)
|
||||
void ExportOCAF::pushNode(int root_id,
|
||||
int node_id,
|
||||
std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TopLoc_Location>& hierarchical_loc)
|
||||
{
|
||||
TDF_Label root;
|
||||
TDF_Label node;
|
||||
root = hierarchical_label.at(root_id-1);
|
||||
node = hierarchical_label.at(node_id-1);
|
||||
root = hierarchical_label.at(root_id - 1);
|
||||
node = hierarchical_label.at(node_id - 1);
|
||||
|
||||
XCAFDoc_DocumentTool::ShapeTool(root)->AddComponent(root, node, hierarchical_loc.at(node_id-1));
|
||||
XCAFDoc_DocumentTool::ShapeTool(root)->AddComponent(root,
|
||||
node,
|
||||
hierarchical_loc.at(node_id - 1));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
ExportOCAFCmd::ExportOCAFCmd(Handle(TDocStd_Document) h, bool explicitPlacement)
|
||||
: ExportOCAF(h, explicitPlacement)
|
||||
{
|
||||
}
|
||||
: ExportOCAF(h, explicitPlacement)
|
||||
{}
|
||||
|
||||
void ExportOCAFCmd::findColors(Part::Feature* part, std::vector<App::Color>& colors) const
|
||||
{
|
||||
std::map<Part::Feature*, std::vector<App::Color> >::const_iterator it = partColors.find(part);
|
||||
if (it != partColors.end())
|
||||
std::map<Part::Feature*, std::vector<App::Color>>::const_iterator it = partColors.find(part);
|
||||
if (it != partColors.end()) {
|
||||
colors = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,16 +40,19 @@
|
||||
class TDF_Label;
|
||||
class TopLoc_Location;
|
||||
|
||||
namespace App {
|
||||
namespace App
|
||||
{
|
||||
class Document;
|
||||
class DocumentObject;
|
||||
class Part;
|
||||
}
|
||||
namespace Part {
|
||||
}// namespace App
|
||||
namespace Part
|
||||
{
|
||||
class Feature;
|
||||
}
|
||||
|
||||
namespace Import {
|
||||
namespace Import
|
||||
{
|
||||
|
||||
class ImportExport ExportOCAF
|
||||
{
|
||||
@@ -57,33 +60,38 @@ public:
|
||||
ExportOCAF(Handle(TDocStd_Document) h, bool explicitPlacement);
|
||||
virtual ~ExportOCAF();
|
||||
int exportObject(App::DocumentObject* obj,
|
||||
std::vector <TDF_Label>& hierarchical_label,
|
||||
std::vector <TopLoc_Location>& hierarchical_loc,
|
||||
std::vector <App::DocumentObject*>& hierarchical_part);
|
||||
int saveShape(Part::Feature* part, const std::vector<App::Color>&,
|
||||
std::vector <TDF_Label>& hierarchical_label,
|
||||
std::vector <TopLoc_Location>& hierarchical_loc,
|
||||
std::vector <App::DocumentObject*>& hierarchical_part);
|
||||
void getPartColors(std::vector <App::DocumentObject*> hierarchical_part,
|
||||
std::vector <TDF_Label> FreeLabels,
|
||||
std::vector <int> part_id,
|
||||
std::vector < std::vector<App::Color> >& Colors) const;
|
||||
void reallocateFreeShape(std::vector <App::DocumentObject*> hierarchical_part,
|
||||
std::vector <TDF_Label> FreeLabels,
|
||||
std::vector <int> part_id,
|
||||
std::vector< std::vector<App::Color> >& Colors);
|
||||
void getFreeLabels(std::vector <TDF_Label>& hierarchical_label,
|
||||
std::vector <TDF_Label>& labels,
|
||||
std::vector <int>& label_part_id);
|
||||
void createNode(App::Part* part, int& root_it,
|
||||
std::vector <TDF_Label>& hierarchical_label,
|
||||
std::vector <TopLoc_Location>& hierarchical_loc,
|
||||
std::vector <App::DocumentObject*>& hierarchical_part);
|
||||
void pushNode(int root, int node, std::vector <TDF_Label>& hierarchical_label,
|
||||
std::vector <TopLoc_Location>& hierarchical_loc);
|
||||
std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TopLoc_Location>& hierarchical_loc,
|
||||
std::vector<App::DocumentObject*>& hierarchical_part);
|
||||
int saveShape(Part::Feature* part,
|
||||
const std::vector<App::Color>&,
|
||||
std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TopLoc_Location>& hierarchical_loc,
|
||||
std::vector<App::DocumentObject*>& hierarchical_part);
|
||||
void getPartColors(std::vector<App::DocumentObject*> hierarchical_part,
|
||||
std::vector<TDF_Label> FreeLabels,
|
||||
std::vector<int> part_id,
|
||||
std::vector<std::vector<App::Color>>& Colors) const;
|
||||
void reallocateFreeShape(std::vector<App::DocumentObject*> hierarchical_part,
|
||||
std::vector<TDF_Label> FreeLabels,
|
||||
std::vector<int> part_id,
|
||||
std::vector<std::vector<App::Color>>& Colors);
|
||||
void getFreeLabels(std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TDF_Label>& labels,
|
||||
std::vector<int>& label_part_id);
|
||||
void createNode(App::Part* part,
|
||||
int& root_it,
|
||||
std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TopLoc_Location>& hierarchical_loc,
|
||||
std::vector<App::DocumentObject*>& hierarchical_part);
|
||||
void pushNode(int root,
|
||||
int node,
|
||||
std::vector<TDF_Label>& hierarchical_label,
|
||||
std::vector<TopLoc_Location>& hierarchical_loc);
|
||||
|
||||
private:
|
||||
virtual void findColors(Part::Feature*, std::vector<App::Color>&) const {}
|
||||
virtual void findColors(Part::Feature*, std::vector<App::Color>&) const
|
||||
{}
|
||||
std::vector<App::DocumentObject*> filterPart(App::Part* part) const;
|
||||
|
||||
private:
|
||||
@@ -92,14 +100,15 @@ private:
|
||||
Handle(XCAFDoc_ColorTool) aColorTool;
|
||||
TDF_Label rootLabel;
|
||||
bool keepExplicitPlacement;
|
||||
bool filterBaseFeature{true};
|
||||
bool filterBaseFeature {true};
|
||||
};
|
||||
|
||||
class ImportExport ExportOCAFCmd : public ExportOCAF
|
||||
class ImportExport ExportOCAFCmd: public ExportOCAF
|
||||
{
|
||||
public:
|
||||
ExportOCAFCmd(Handle(TDocStd_Document) h, bool explicitPlacement);
|
||||
void setPartColorsMap(const std::map<Part::Feature*, std::vector<App::Color> >& colors) {
|
||||
void setPartColorsMap(const std::map<Part::Feature*, std::vector<App::Color>>& colors)
|
||||
{
|
||||
partColors = colors;
|
||||
}
|
||||
|
||||
@@ -107,10 +116,10 @@ private:
|
||||
void findColors(Part::Feature*, std::vector<App::Color>&) const override;
|
||||
|
||||
private:
|
||||
std::map<Part::Feature*, std::vector<App::Color> > partColors;
|
||||
std::map<Part::Feature*, std::vector<App::Color>> partColors;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
}// namespace Import
|
||||
|
||||
#endif //IMPORT_EXPORTOCAF_H
|
||||
#endif// IMPORT_EXPORTOCAF_H
|
||||
|
||||
@@ -22,29 +22,29 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#if defined(__MINGW32__)
|
||||
# define WNT // avoid conflict with GUID
|
||||
#define WNT// avoid conflict with GUID
|
||||
#endif
|
||||
#ifndef _PreComp_
|
||||
# include <climits>
|
||||
# include <gp_Pln.hxx> // for Precision::Confusion()
|
||||
# include <gp_Trsf.hxx>
|
||||
# include <Bnd_Box.hxx>
|
||||
# include <BRepBndLib.hxx>
|
||||
# include <BRep_Builder.hxx>
|
||||
# include <BRepExtrema_DistShapeShape.hxx>
|
||||
# include <Quantity_ColorRGBA.hxx>
|
||||
# include <Standard_Failure.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
# include <TDataStd_Name.hxx>
|
||||
# include <TDF_ChildIterator.hxx>
|
||||
# include <TDF_Label.hxx>
|
||||
# include <TDF_LabelSequence.hxx>
|
||||
# include <TDocStd_Document.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <TopoDS_Iterator.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
# include <XCAFDoc_DocumentTool.hxx>
|
||||
# include <XCAFDoc_Location.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepExtrema_DistShapeShape.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <Bnd_Box.hxx>
|
||||
#include <Quantity_ColorRGBA.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_LabelSequence.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_Location.hxx>
|
||||
#include <climits>
|
||||
#include <gp_Pln.hxx>// for Precision::Confusion()
|
||||
#include <gp_Trsf.hxx>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -57,21 +57,21 @@
|
||||
|
||||
|
||||
#ifdef HAVE_TBB
|
||||
# include <tbb/blocked_range.h>
|
||||
# include <tbb/parallel_for.h>
|
||||
# include <tbb/task_group.h>
|
||||
#include <tbb/blocked_range.h>
|
||||
#include <tbb/parallel_for.h>
|
||||
#include <tbb/task_group.h>
|
||||
#endif
|
||||
|
||||
using namespace Import;
|
||||
|
||||
#if OCC_VERSION_HEX >= 0x070500
|
||||
// See https://dev.opencascade.org/content/occt-3d-viewer-becomes-srgb-aware
|
||||
# define OCC_COLOR_SPACE Quantity_TOC_sRGB
|
||||
#define OCC_COLOR_SPACE Quantity_TOC_sRGB
|
||||
#else
|
||||
# define OCC_COLOR_SPACE Quantity_TOC_RGB
|
||||
#define OCC_COLOR_SPACE Quantity_TOC_RGB
|
||||
#endif
|
||||
|
||||
static inline App::Color convertColor(const Quantity_ColorRGBA &c)
|
||||
static inline App::Color convertColor(const Quantity_ColorRGBA& c)
|
||||
{
|
||||
Standard_Real r, g, b;
|
||||
c.GetRGB().Values(r, g, b, OCC_COLOR_SPACE);
|
||||
@@ -84,9 +84,11 @@ static inline App::Color convertColor(const Quantity_ColorRGBA &c)
|
||||
#define OCAF_KEEP_PLACEMENT
|
||||
|
||||
ImportOCAF::ImportOCAF(Handle(TDocStd_Document) h, App::Document* d, const std::string& name)
|
||||
: pDoc(h), doc(d), default_name(name)
|
||||
: pDoc(h)
|
||||
, doc(d)
|
||||
, default_name(name)
|
||||
{
|
||||
aShapeTool = XCAFDoc_DocumentTool::ShapeTool (pDoc->Main());
|
||||
aShapeTool = XCAFDoc_DocumentTool::ShapeTool(pDoc->Main());
|
||||
aColorTool = XCAFDoc_DocumentTool::ColorTool(pDoc->Main());
|
||||
}
|
||||
|
||||
@@ -129,11 +131,14 @@ void ImportOCAF::loadShapes()
|
||||
|
||||
void ImportOCAF::setMerge(bool merge)
|
||||
{
|
||||
this->merge=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,
|
||||
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)
|
||||
{
|
||||
int hash = 0;
|
||||
@@ -143,59 +148,61 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
#endif
|
||||
TopoDS_Shape aShape;
|
||||
|
||||
std::vector<App::DocumentObject *> localValue;
|
||||
std::vector<App::DocumentObject*> localValue;
|
||||
|
||||
if (aShapeTool->GetShape(label,aShape)) {
|
||||
if (aShapeTool->GetShape(label, aShape)) {
|
||||
hash = aShape.HashCode(HashUpper);
|
||||
}
|
||||
|
||||
Handle(TDataStd_Name) name;
|
||||
std::string part_name = defaultname;
|
||||
if (label.FindAttribute(TDataStd_Name::GetID(),name)) {
|
||||
if (label.FindAttribute(TDataStd_Name::GetID(), name)) {
|
||||
TCollection_ExtendedString extstr = name->Get();
|
||||
char* str = new char[extstr.LengthOfCString()+1];
|
||||
char* str = new char[extstr.LengthOfCString() + 1];
|
||||
extstr.ToUTF8CString(str);
|
||||
part_name = str;
|
||||
delete [] str;
|
||||
delete[] str;
|
||||
if (part_name.empty()) {
|
||||
part_name = defaultname;
|
||||
}
|
||||
else {
|
||||
bool ws=true;
|
||||
bool ws = true;
|
||||
for (char it : part_name) {
|
||||
if (it != ' ') {
|
||||
ws = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ws)
|
||||
if (ws) {
|
||||
part_name = defaultname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TopLoc_Location part_loc = loc;
|
||||
Handle(XCAFDoc_Location) hLoc;
|
||||
if (label.FindAttribute(XCAFDoc_Location::GetID(), hLoc)) {
|
||||
if (isRef)
|
||||
if (isRef) {
|
||||
part_loc = part_loc * hLoc->Get();
|
||||
else
|
||||
}
|
||||
else {
|
||||
part_loc = hLoc->Get();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FC_DEBUG
|
||||
Base::Console().Log("H:%d, N:%s, T:%d, A:%d, S:%d, C:%d, SS:%d, F:%d, R:%d, C:%d, SS:%d\n",
|
||||
hash,
|
||||
part_name.c_str(),
|
||||
aShapeTool->IsTopLevel(label),
|
||||
aShapeTool->IsAssembly(label),
|
||||
aShapeTool->IsShape(label),
|
||||
aShapeTool->IsCompound(label),
|
||||
aShapeTool->IsSimpleShape(label),
|
||||
aShapeTool->IsFree(label),
|
||||
aShapeTool->IsReference(label),
|
||||
aShapeTool->IsComponent(label),
|
||||
aShapeTool->IsSubShape(label)
|
||||
);
|
||||
hash,
|
||||
part_name.c_str(),
|
||||
aShapeTool->IsTopLevel(label),
|
||||
aShapeTool->IsAssembly(label),
|
||||
aShapeTool->IsShape(label),
|
||||
aShapeTool->IsCompound(label),
|
||||
aShapeTool->IsSimpleShape(label),
|
||||
aShapeTool->IsFree(label),
|
||||
aShapeTool->IsReference(label),
|
||||
aShapeTool->IsComponent(label),
|
||||
aShapeTool->IsSubShape(label));
|
||||
#endif
|
||||
|
||||
#if defined(OCAF_KEEP_PLACEMENT)
|
||||
@@ -215,44 +222,50 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
|
||||
if (isRef || myRefShapes.find(hash) == myRefShapes.end()) {
|
||||
TopoDS_Shape aShape;
|
||||
if (isRef && aShapeTool->GetShape(label, aShape))
|
||||
if (isRef && aShapeTool->GetShape(label, aShape)) {
|
||||
myRefShapes.insert(aShape.HashCode(HashUpper));
|
||||
}
|
||||
|
||||
if (aShapeTool->IsSimpleShape(label) && (isRef || aShapeTool->IsFree(label))) {
|
||||
if (!asm_name.empty())
|
||||
if (!asm_name.empty()) {
|
||||
part_name = asm_name;
|
||||
}
|
||||
|
||||
// TODO: The merge parameter (last one from createShape) should become an Importer/Exporter
|
||||
// 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)
|
||||
// TODO: The merge parameter (last one from createShape) should become an
|
||||
// Importer/Exporter 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, this->merge);
|
||||
else
|
||||
}
|
||||
else {
|
||||
createShape(label, part_loc, part_name, localValue, this->merge);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (aShapeTool->IsSimpleShape(label)) {
|
||||
// We are not creating a list of Part::Feature in that case but just
|
||||
// a single Part::Feature which has as a Shape a Compound of the Subshapes contained
|
||||
// within the global shape
|
||||
// This is standard behavior of many STEP reader and avoid to register a crazy amount of
|
||||
// Shape within the Tree as STEP file do mostly contain large assemblies
|
||||
// This is standard behavior of many STEP reader and avoid to register a crazy
|
||||
// amount of Shape within the Tree as STEP file do mostly contain large assemblies
|
||||
return;
|
||||
}
|
||||
|
||||
// This is probably an Assembly let's try to create a Compound with the name
|
||||
for (TDF_ChildIterator it(label); it.More(); it.Next()) {
|
||||
if (isRef)
|
||||
if (isRef) {
|
||||
loadShapes(it.Value(), part_loc, part_name, asm_name, false, localValue);
|
||||
else
|
||||
}
|
||||
else {
|
||||
loadShapes(it.Value(), part_loc, part_name, asm_name, isRef, localValue);
|
||||
}
|
||||
}
|
||||
|
||||
if (!localValue.empty()) {
|
||||
if (aShapeTool->IsAssembly(label)) {
|
||||
App::Part *pcPart = nullptr;
|
||||
pcPart = static_cast<App::Part*>(doc->addObject("App::Part",asm_name.c_str()));
|
||||
App::Part* pcPart = nullptr;
|
||||
pcPart = static_cast<App::Part*>(doc->addObject("App::Part", asm_name.c_str()));
|
||||
pcPart->Label.setValue(asm_name);
|
||||
pcPart->addObjects(localValue);
|
||||
|
||||
@@ -268,8 +281,11 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
}
|
||||
}
|
||||
|
||||
void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc, const std::string& name,
|
||||
std::vector<App::DocumentObject*>& lValue, bool mergeShape)
|
||||
void ImportOCAF::createShape(const TDF_Label& label,
|
||||
const TopLoc_Location& loc,
|
||||
const std::string& name,
|
||||
std::vector<App::DocumentObject*>& lValue,
|
||||
bool mergeShape)
|
||||
{
|
||||
const TopoDS_Shape& aShape = aShapeTool->GetShape(label);
|
||||
#ifdef HAVE_TBB
|
||||
@@ -280,8 +296,8 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND) {
|
||||
TopExp_Explorer xp;
|
||||
int ctSolids = 0, ctShells = 0, ctVertices = 0, ctEdges = 0;
|
||||
std::vector<App::DocumentObject *> localValue;
|
||||
App::Part *pcPart = nullptr;
|
||||
std::vector<App::DocumentObject*> localValue;
|
||||
App::Part* pcPart = nullptr;
|
||||
|
||||
if (mergeShape) {
|
||||
|
||||
@@ -294,26 +310,26 @@ 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;
|
||||
App::Color color(0.8f,0.8f,0.8f);
|
||||
if (aColorTool->GetColor(xp.Current(), XCAFDoc_ColorGen, aColor) ||
|
||||
aColorTool->GetColor(xp.Current(), XCAFDoc_ColorSurf, aColor) ||
|
||||
aColorTool->GetColor(xp.Current(), XCAFDoc_ColorCurv, aColor)) {
|
||||
color.r = (float)aColor.Red();
|
||||
color.g = (float)aColor.Green();
|
||||
color.b = (float)aColor.Blue();
|
||||
colors.push_back(color);
|
||||
}
|
||||
}
|
||||
/*
|
||||
std::vector<App::Color> colors;
|
||||
for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++) {
|
||||
Quantity_Color aColor;
|
||||
App::Color color(0.8f,0.8f,0.8f);
|
||||
if (aColorTool->GetColor(xp.Current(), XCAFDoc_ColorGen, aColor) ||
|
||||
aColorTool->GetColor(xp.Current(), XCAFDoc_ColorSurf, aColor) ||
|
||||
aColorTool->GetColor(xp.Current(), XCAFDoc_ColorCurv, aColor)) {
|
||||
color.r = (float)aColor.Red();
|
||||
color.g = (float)aColor.Green();
|
||||
color.b = (float)aColor.Blue();
|
||||
colors.push_back(color);
|
||||
}
|
||||
}
|
||||
|
||||
if (colors.size() > 1) {
|
||||
createShape(label, loc, name, lValue, false);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
if (colors.size() > 1) {
|
||||
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()) {
|
||||
@@ -344,7 +360,7 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
|
||||
// Ok we got a Compound which is computed
|
||||
// Just need to add it to a Part::Feature and push it to lValue
|
||||
if (!comp.IsNull() && (ctSolids||ctShells||ctEdges||ctVertices)) {
|
||||
if (!comp.IsNull() && (ctSolids || ctShells || ctEdges || ctVertices)) {
|
||||
Part::Feature* part = static_cast<Part::Feature*>(doc->addObject("Part::Feature"));
|
||||
// Let's allocate the relative placement of the Compound from the STEP file
|
||||
tryPlacementFromLoc(part, loc);
|
||||
@@ -371,7 +387,7 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
}
|
||||
|
||||
if (!localValue.empty() && !mergeShape) {
|
||||
pcPart = static_cast<App::Part*>(doc->addObject("App::Part",name.c_str()));
|
||||
pcPart = static_cast<App::Part*>(doc->addObject("App::Part", name.c_str()));
|
||||
pcPart->Label.setValue(name);
|
||||
|
||||
// localValue contain the objects that must added to the local Part
|
||||
@@ -379,39 +395,44 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc,
|
||||
pcPart->addObjects(localValue);
|
||||
|
||||
// Let's compute relative placement of the Part
|
||||
/*
|
||||
gp_Trsf trf;
|
||||
Base::Matrix4D mtrx;
|
||||
if ( loc.IsIdentity() )
|
||||
trf = loc.Transformation();
|
||||
else
|
||||
trf = TopLoc_Location(loc.FirstDatum()).Transformation();
|
||||
Part::TopoShape::convertToMatrix(trf, mtrx);
|
||||
Base::Placement pl;
|
||||
pl.fromMatrix(mtrx);
|
||||
pcPart->Placement.setValue(pl);
|
||||
*/
|
||||
/*
|
||||
gp_Trsf trf;
|
||||
Base::Matrix4D mtrx;
|
||||
if ( loc.IsIdentity() )
|
||||
trf = loc.Transformation();
|
||||
else
|
||||
trf = TopLoc_Location(loc.FirstDatum()).Transformation();
|
||||
Part::TopoShape::convertToMatrix(trf, mtrx);
|
||||
Base::Placement pl;
|
||||
pl.fromMatrix(mtrx);
|
||||
pcPart->Placement.setValue(pl);
|
||||
*/
|
||||
lValue.push_back(pcPart);
|
||||
}
|
||||
|
||||
if (ctSolids > 0 || ctShells > 0)
|
||||
if (ctSolids > 0 || ctShells > 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (!aShape.IsNull()) {
|
||||
createShape(aShape, loc, name, lValue);
|
||||
}
|
||||
}
|
||||
|
||||
void ImportOCAF::createShape(const TopoDS_Shape& aShape, const TopLoc_Location& loc, const std::string& name,
|
||||
void ImportOCAF::createShape(const TopoDS_Shape& aShape,
|
||||
const TopLoc_Location& loc,
|
||||
const std::string& name,
|
||||
std::vector<App::DocumentObject*>& lvalue)
|
||||
{
|
||||
Part::Feature* part = static_cast<Part::Feature*>(doc->addObject("Part::Feature"));
|
||||
|
||||
if (!loc.IsIdentity())
|
||||
if (!loc.IsIdentity()) {
|
||||
// part->Shape.setValue(aShape.Moved(TopLoc_Location(loc.FirstDatum())));
|
||||
part->Shape.setValue(aShape.Moved(loc));
|
||||
else
|
||||
}
|
||||
else {
|
||||
part->Shape.setValue(aShape);
|
||||
}
|
||||
|
||||
part->Label.setValue(name);
|
||||
lvalue.push_back(part);
|
||||
@@ -422,10 +443,10 @@ void ImportOCAF::createShape(const TopoDS_Shape& aShape, const TopLoc_Location&
|
||||
void ImportOCAF::loadColors(Part::Feature* part, const TopoDS_Shape& aShape)
|
||||
{
|
||||
Quantity_ColorRGBA aColor;
|
||||
App::Color color(0.8f,0.8f,0.8f);
|
||||
if (aColorTool->GetColor(aShape, XCAFDoc_ColorGen, aColor) ||
|
||||
aColorTool->GetColor(aShape, XCAFDoc_ColorSurf, aColor) ||
|
||||
aColorTool->GetColor(aShape, XCAFDoc_ColorCurv, aColor)) {
|
||||
App::Color color(0.8f, 0.8f, 0.8f);
|
||||
if (aColorTool->GetColor(aShape, XCAFDoc_ColorGen, aColor)
|
||||
|| aColorTool->GetColor(aShape, XCAFDoc_ColorSurf, aColor)
|
||||
|| aColorTool->GetColor(aShape, XCAFDoc_ColorCurv, aColor)) {
|
||||
color = convertColor(aColor);
|
||||
std::vector<App::Color> colors;
|
||||
colors.push_back(color);
|
||||
@@ -433,7 +454,7 @@ void ImportOCAF::loadColors(Part::Feature* part, const TopoDS_Shape& aShape)
|
||||
}
|
||||
|
||||
TopTools_IndexedMapOfShape faces;
|
||||
TopExp_Explorer xp(aShape,TopAbs_FACE);
|
||||
TopExp_Explorer xp(aShape, TopAbs_FACE);
|
||||
while (xp.More()) {
|
||||
faces.Add(xp.Current());
|
||||
xp.Next();
|
||||
@@ -442,14 +463,14 @@ void ImportOCAF::loadColors(Part::Feature* part, const TopoDS_Shape& aShape)
|
||||
bool found_face_color = false;
|
||||
std::vector<App::Color> faceColors;
|
||||
faceColors.resize(faces.Extent(), color);
|
||||
xp.Init(aShape,TopAbs_FACE);
|
||||
xp.Init(aShape, TopAbs_FACE);
|
||||
while (xp.More()) {
|
||||
if (aColorTool->GetColor(xp.Current(), XCAFDoc_ColorGen, aColor) ||
|
||||
aColorTool->GetColor(xp.Current(), XCAFDoc_ColorSurf, aColor) ||
|
||||
aColorTool->GetColor(xp.Current(), XCAFDoc_ColorCurv, aColor)) {
|
||||
if (aColorTool->GetColor(xp.Current(), XCAFDoc_ColorGen, aColor)
|
||||
|| aColorTool->GetColor(xp.Current(), XCAFDoc_ColorSurf, aColor)
|
||||
|| aColorTool->GetColor(xp.Current(), XCAFDoc_ColorCurv, aColor)) {
|
||||
int index = faces.FindIndex(xp.Current());
|
||||
color = convertColor(aColor);
|
||||
faceColors[index-1] = color;
|
||||
faceColors[index - 1] = color;
|
||||
found_face_color = true;
|
||||
}
|
||||
xp.Next();
|
||||
@@ -464,8 +485,7 @@ void ImportOCAF::loadColors(Part::Feature* part, const TopoDS_Shape& aShape)
|
||||
|
||||
ImportOCAFCmd::ImportOCAFCmd(Handle(TDocStd_Document) h, App::Document* d, const std::string& name)
|
||||
: ImportOCAF(h, d, name)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void ImportOCAFCmd::applyColors(Part::Feature* part, const std::vector<App::Color>& colors)
|
||||
{
|
||||
@@ -475,9 +495,11 @@ void ImportOCAFCmd::applyColors(Part::Feature* part, const std::vector<App::Colo
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
ImportXCAF::ImportXCAF(Handle(TDocStd_Document) h, App::Document* d, const std::string& name)
|
||||
: hdoc(h), doc(d), default_name(name)
|
||||
: hdoc(h)
|
||||
, doc(d)
|
||||
, default_name(name)
|
||||
{
|
||||
aShapeTool = XCAFDoc_DocumentTool::ShapeTool (hdoc->Main());
|
||||
aShapeTool = XCAFDoc_DocumentTool::ShapeTool(hdoc->Main());
|
||||
hColors = XCAFDoc_DocumentTool::ColorTool(hdoc->Main());
|
||||
}
|
||||
|
||||
@@ -487,11 +509,11 @@ void ImportXCAF::loadShapes()
|
||||
{
|
||||
// collect sequence of labels to display
|
||||
TDF_LabelSequence shapeLabels, colorLabels;
|
||||
aShapeTool->GetFreeShapes (shapeLabels);
|
||||
aShapeTool->GetFreeShapes(shapeLabels);
|
||||
hColors->GetColors(colorLabels);
|
||||
|
||||
// set presentations and show
|
||||
for (Standard_Integer i=1; i <= shapeLabels.Length(); i++ ) {
|
||||
for (Standard_Integer i = 1; i <= shapeLabels.Length(); i++) {
|
||||
// get the shapes and attributes
|
||||
const TDF_Label& label = shapeLabels.Value(i);
|
||||
loadShapes(label);
|
||||
@@ -530,8 +552,8 @@ void ImportXCAF::createShape(const TopoDS_Shape& shape, bool perface, bool setna
|
||||
std::map<Standard_Integer, Quantity_ColorRGBA>::const_iterator jt;
|
||||
jt = myColorMap.find(shape.HashCode(INT_MAX));
|
||||
|
||||
App::Color partColor(0.8f,0.8f,0.8f);
|
||||
#if 0//TODO
|
||||
App::Color partColor(0.8f, 0.8f, 0.8f);
|
||||
#if 0// TODO
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(part);
|
||||
if (vp && vp->isDerivedFrom(PartGui::ViewProviderPart::getClassTypeId())) {
|
||||
if (jt != myColorMap.end()) {
|
||||
@@ -558,7 +580,7 @@ void ImportXCAF::createShape(const TopoDS_Shape& shape, bool perface, bool setna
|
||||
// check for colors per face
|
||||
if (perface && !myColorMap.empty()) {
|
||||
TopTools_IndexedMapOfShape faces;
|
||||
TopExp_Explorer xp(shape,TopAbs_FACE);
|
||||
TopExp_Explorer xp(shape, TopAbs_FACE);
|
||||
while (xp.More()) {
|
||||
faces.Add(xp.Current());
|
||||
xp.Next();
|
||||
@@ -567,19 +589,19 @@ void ImportXCAF::createShape(const TopoDS_Shape& shape, bool perface, bool setna
|
||||
bool found_face_color = false;
|
||||
std::vector<App::Color> faceColors;
|
||||
faceColors.resize(faces.Extent(), partColor);
|
||||
xp.Init(shape,TopAbs_FACE);
|
||||
xp.Init(shape, TopAbs_FACE);
|
||||
while (xp.More()) {
|
||||
jt = myColorMap.find(xp.Current().HashCode(INT_MAX));
|
||||
if (jt != myColorMap.end()) {
|
||||
int index = faces.FindIndex(xp.Current());
|
||||
faceColors[index-1] = convertColor(jt->second);
|
||||
faceColors[index - 1] = convertColor(jt->second);
|
||||
found_face_color = true;
|
||||
}
|
||||
xp.Next();
|
||||
}
|
||||
|
||||
if (found_face_color) {
|
||||
#if 0//TODO
|
||||
#if 0// TODO
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(part);
|
||||
if (vp && vp->isDerivedFrom(PartGui::ViewProviderPartExt::getClassTypeId())) {
|
||||
static_cast<PartGui::ViewProviderPartExt*>(vp)->DiffuseColor.setValues(faceColors);
|
||||
@@ -592,53 +614,60 @@ void ImportXCAF::createShape(const TopoDS_Shape& shape, bool perface, bool setna
|
||||
void ImportXCAF::loadShapes(const TDF_Label& label)
|
||||
{
|
||||
TopoDS_Shape aShape;
|
||||
if (aShapeTool->GetShape(label,aShape)) {
|
||||
//if (aShapeTool->IsReference(label)) {
|
||||
// TDF_Label reflabel;
|
||||
// if (aShapeTool->GetReferredShape(label, reflabel)) {
|
||||
// loadShapes(reflabel);
|
||||
// }
|
||||
//}
|
||||
if (aShapeTool->GetShape(label, aShape)) {
|
||||
// if (aShapeTool->IsReference(label)) {
|
||||
// TDF_Label reflabel;
|
||||
// if (aShapeTool->GetReferredShape(label, reflabel)) {
|
||||
// loadShapes(reflabel);
|
||||
// }
|
||||
// }
|
||||
if (aShapeTool->IsTopLevel(label)) {
|
||||
int ctSolids = 0, ctShells = 0, ctComps = 0;
|
||||
// add the shapes
|
||||
TopExp_Explorer xp;
|
||||
for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++)
|
||||
for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++) {
|
||||
this->mySolids[xp.Current().HashCode(INT_MAX)] = (xp.Current());
|
||||
for (xp.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); xp.More(); xp.Next(), ctShells++)
|
||||
}
|
||||
for (xp.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); xp.More(); xp.Next(), ctShells++) {
|
||||
this->myShells[xp.Current().HashCode(INT_MAX)] = (xp.Current());
|
||||
}
|
||||
// if no solids and no shells were found then go for compounds
|
||||
if (ctSolids == 0 && ctShells == 0) {
|
||||
for (xp.Init(aShape, TopAbs_COMPOUND); xp.More(); xp.Next(), ctComps++)
|
||||
for (xp.Init(aShape, TopAbs_COMPOUND); xp.More(); xp.Next(), ctComps++) {
|
||||
this->myCompds[xp.Current().HashCode(INT_MAX)] = (xp.Current());
|
||||
}
|
||||
}
|
||||
if (ctComps == 0) {
|
||||
for (xp.Init(aShape, TopAbs_FACE, TopAbs_SHELL); xp.More(); xp.Next())
|
||||
for (xp.Init(aShape, TopAbs_FACE, TopAbs_SHELL); xp.More(); xp.Next()) {
|
||||
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
|
||||
for (xp.Init(aShape, TopAbs_WIRE, TopAbs_FACE); xp.More(); xp.Next())
|
||||
}
|
||||
for (xp.Init(aShape, TopAbs_WIRE, TopAbs_FACE); xp.More(); xp.Next()) {
|
||||
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
|
||||
for (xp.Init(aShape, TopAbs_EDGE, TopAbs_WIRE); xp.More(); xp.Next())
|
||||
}
|
||||
for (xp.Init(aShape, TopAbs_EDGE, TopAbs_WIRE); xp.More(); xp.Next()) {
|
||||
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
|
||||
for (xp.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); xp.More(); xp.Next())
|
||||
}
|
||||
for (xp.Init(aShape, TopAbs_VERTEX, TopAbs_EDGE); xp.More(); xp.Next()) {
|
||||
this->myShapes[xp.Current().HashCode(INT_MAX)] = (xp.Current());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getting color
|
||||
Quantity_ColorRGBA col;
|
||||
if (hColors->GetColor(label, XCAFDoc_ColorGen, col) ||
|
||||
hColors->GetColor(label, XCAFDoc_ColorSurf, col) ||
|
||||
hColors->GetColor(label, XCAFDoc_ColorCurv, col)) {
|
||||
if (hColors->GetColor(label, XCAFDoc_ColorGen, col)
|
||||
|| hColors->GetColor(label, XCAFDoc_ColorSurf, col)
|
||||
|| hColors->GetColor(label, XCAFDoc_ColorCurv, col)) {
|
||||
// add defined color
|
||||
myColorMap[aShape.HashCode(INT_MAX)] = col;
|
||||
}
|
||||
else {
|
||||
// http://www.opencascade.org/org/forum/thread_17107/
|
||||
TopoDS_Iterator it;
|
||||
for (it.Initialize(aShape);it.More(); it.Next()) {
|
||||
if (hColors->GetColor(it.Value(), XCAFDoc_ColorGen, col) ||
|
||||
hColors->GetColor(it.Value(), XCAFDoc_ColorSurf, col) ||
|
||||
hColors->GetColor(it.Value(), XCAFDoc_ColorCurv, col)) {
|
||||
for (it.Initialize(aShape); it.More(); it.Next()) {
|
||||
if (hColors->GetColor(it.Value(), XCAFDoc_ColorGen, col)
|
||||
|| hColors->GetColor(it.Value(), XCAFDoc_ColorSurf, col)
|
||||
|| hColors->GetColor(it.Value(), XCAFDoc_ColorCurv, col)) {
|
||||
// add defined color
|
||||
myColorMap[it.Value().HashCode(INT_MAX)] = col;
|
||||
}
|
||||
@@ -647,14 +676,15 @@ void ImportXCAF::loadShapes(const TDF_Label& label)
|
||||
|
||||
// getting names
|
||||
Handle(TDataStd_Name) name;
|
||||
if (label.FindAttribute(TDataStd_Name::GetID(),name)) {
|
||||
if (label.FindAttribute(TDataStd_Name::GetID(), name)) {
|
||||
TCollection_ExtendedString extstr = name->Get();
|
||||
char* str = new char[extstr.LengthOfCString()+1];
|
||||
char* str = new char[extstr.LengthOfCString() + 1];
|
||||
extstr.ToUTF8CString(str);
|
||||
std::string labelName(str);
|
||||
if (!labelName.empty())
|
||||
if (!labelName.empty()) {
|
||||
myNameMap[aShape.HashCode(INT_MAX)] = labelName;
|
||||
delete [] str;
|
||||
}
|
||||
delete[] str;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
@@ -43,15 +43,18 @@
|
||||
class TDF_Label;
|
||||
class TopLoc_Location;
|
||||
|
||||
namespace App {
|
||||
namespace App
|
||||
{
|
||||
class Document;
|
||||
class DocumentObject;
|
||||
}
|
||||
namespace Part {
|
||||
}// namespace App
|
||||
namespace Part
|
||||
{
|
||||
class Feature;
|
||||
}
|
||||
|
||||
namespace Import {
|
||||
namespace Import
|
||||
{
|
||||
|
||||
class ImportExport ImportOCAF
|
||||
{
|
||||
@@ -62,11 +65,24 @@ public:
|
||||
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*> &);
|
||||
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*>&);
|
||||
void loadColors(Part::Feature* part, const TopoDS_Shape& aShape);
|
||||
virtual void applyColors(Part::Feature*, const std::vector<App::Color>&){}
|
||||
virtual void applyColors(Part::Feature*, const std::vector<App::Color>&)
|
||||
{}
|
||||
static void tryPlacementFromLoc(App::GeoFeature*, const TopLoc_Location&);
|
||||
static void tryPlacementFromMatrix(App::GeoFeature*, const Base::Matrix4D&);
|
||||
|
||||
@@ -75,17 +91,18 @@ private:
|
||||
App::Document* doc;
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool;
|
||||
Handle(XCAFDoc_ColorTool) aColorTool;
|
||||
bool merge{true};
|
||||
bool merge {true};
|
||||
std::string default_name;
|
||||
std::set<int> myRefShapes;
|
||||
static const int HashUpper = INT_MAX;
|
||||
};
|
||||
|
||||
class ImportExport ImportOCAFCmd : public ImportOCAF
|
||||
class ImportExport ImportOCAFCmd: public ImportOCAF
|
||||
{
|
||||
public:
|
||||
ImportOCAFCmd(Handle(TDocStd_Document) h, App::Document* d, const std::string& name);
|
||||
std::map<Part::Feature*, std::vector<App::Color> > getPartColorsMap() const {
|
||||
std::map<Part::Feature*, std::vector<App::Color>> getPartColorsMap() const
|
||||
{
|
||||
return partColors;
|
||||
}
|
||||
|
||||
@@ -93,7 +110,7 @@ private:
|
||||
void applyColors(Part::Feature* part, const std::vector<App::Color>& colors) override;
|
||||
|
||||
private:
|
||||
std::map<Part::Feature*, std::vector<App::Color> > partColors;
|
||||
std::map<Part::Feature*, std::vector<App::Color>> partColors;
|
||||
};
|
||||
|
||||
class ImportXCAF
|
||||
@@ -104,9 +121,10 @@ public:
|
||||
void loadShapes();
|
||||
|
||||
private:
|
||||
void createShape(const TopoDS_Shape& shape, bool perface=false, bool setname=false) const;
|
||||
void createShape(const TopoDS_Shape& shape, bool perface = false, bool setname = false) const;
|
||||
void loadShapes(const TDF_Label& label);
|
||||
virtual void applyColors(Part::Feature*, const std::vector<App::Color>&){}
|
||||
virtual void applyColors(Part::Feature*, const std::vector<App::Color>&)
|
||||
{}
|
||||
|
||||
private:
|
||||
Handle(TDocStd_Document) hdoc;
|
||||
@@ -122,6 +140,6 @@ private:
|
||||
std::map<Standard_Integer, std::string> myNameMap;
|
||||
};
|
||||
|
||||
}
|
||||
}// namespace Import
|
||||
|
||||
#endif //IMPORT_IMPORTOCAF_H
|
||||
#endif// IMPORT_IMPORTOCAF_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -39,32 +39,39 @@
|
||||
#include <Base/Sequencer.h>
|
||||
#include <Mod/Part/App/TopoShape.h>
|
||||
|
||||
#include "ImportOCAF.h"
|
||||
#include "ExportOCAF.h"
|
||||
#include "ImportOCAF.h"
|
||||
|
||||
|
||||
class TDF_Label;
|
||||
class TopLoc_Location;
|
||||
|
||||
namespace App {
|
||||
namespace App
|
||||
{
|
||||
class Document;
|
||||
class DocumentObject;
|
||||
}
|
||||
namespace Part {
|
||||
}// namespace App
|
||||
namespace Part
|
||||
{
|
||||
class Feature;
|
||||
}
|
||||
|
||||
namespace Import {
|
||||
namespace Import
|
||||
{
|
||||
|
||||
struct ShapeHasher {
|
||||
std::size_t operator()(const TopoDS_Shape &s) const {
|
||||
struct ShapeHasher
|
||||
{
|
||||
std::size_t operator()(const TopoDS_Shape& s) const
|
||||
{
|
||||
return s.HashCode(INT_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
struct LabelHasher {
|
||||
std::size_t operator()(const TDF_Label &l) const {
|
||||
return TDF_LabelMapHasher::HashCode(l,INT_MAX);
|
||||
struct LabelHasher
|
||||
{
|
||||
std::size_t operator()(const TDF_Label& l) const
|
||||
{
|
||||
return TDF_LabelMapHasher::HashCode(l, INT_MAX);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -92,27 +99,34 @@ public:
|
||||
|
||||
static ImportOCAFOptions customImportOptions();
|
||||
void setImportOptions(ImportOCAFOptions opts);
|
||||
void setMerge(bool enable) {
|
||||
void setMerge(bool enable)
|
||||
{
|
||||
options.merge = enable;
|
||||
}
|
||||
void setUseLinkGroup(bool enable);
|
||||
void setBaseName(bool enable) {
|
||||
void setBaseName(bool enable)
|
||||
{
|
||||
options.useBaseName = enable;
|
||||
}
|
||||
void setImportHiddenObject(bool enable) {
|
||||
void setImportHiddenObject(bool enable)
|
||||
{
|
||||
options.importHidden = enable;
|
||||
}
|
||||
void setReduceObjects(bool enable) {
|
||||
void setReduceObjects(bool enable)
|
||||
{
|
||||
options.reduceObjects = enable;
|
||||
}
|
||||
void setShowProgress(bool enable) {
|
||||
void setShowProgress(bool enable)
|
||||
{
|
||||
options.showProgress = enable;
|
||||
}
|
||||
void setExpandCompound(bool enable) {
|
||||
void setExpandCompound(bool enable)
|
||||
{
|
||||
options.expandCompound = enable;
|
||||
}
|
||||
|
||||
enum ImportMode {
|
||||
enum ImportMode
|
||||
{
|
||||
SingleDoc = 0,
|
||||
GroupPerDoc = 1,
|
||||
GroupPerDir = 2,
|
||||
@@ -121,15 +135,17 @@ public:
|
||||
ModeMax,
|
||||
};
|
||||
void setMode(int m);
|
||||
int getMode() const {
|
||||
int getMode() const
|
||||
{
|
||||
return options.mode;
|
||||
}
|
||||
|
||||
private:
|
||||
struct Info {
|
||||
struct Info
|
||||
{
|
||||
std::string baseName;
|
||||
App::DocumentObject *obj = nullptr;
|
||||
App::PropertyPlacement *propPlacement = nullptr;
|
||||
App::DocumentObject* obj = nullptr;
|
||||
App::PropertyPlacement* propPlacement = nullptr;
|
||||
App::Color faceColor;
|
||||
App::Color edgeColor;
|
||||
bool hasFaceColor = false;
|
||||
@@ -137,40 +153,62 @@ private:
|
||||
int free = true;
|
||||
};
|
||||
|
||||
App::DocumentObject *loadShape(App::Document *doc, TDF_Label label,
|
||||
const TopoDS_Shape &shape, bool baseOnly=false, bool newDoc=true);
|
||||
App::Document *getDocument(App::Document *doc, TDF_Label label);
|
||||
bool createAssembly(App::Document *doc, TDF_Label label,
|
||||
const TopoDS_Shape &shape, Info &info, bool newDoc);
|
||||
bool createObject(App::Document *doc, TDF_Label label,
|
||||
const TopoDS_Shape &shape, Info &info, bool newDoc);
|
||||
bool createGroup(App::Document *doc, Info &info,
|
||||
const TopoDS_Shape &shape, std::vector<App::DocumentObject*> &children,
|
||||
const boost::dynamic_bitset<> &visibilities, bool canReduce=false);
|
||||
bool getColor(const TopoDS_Shape &shape, Info &info, bool check=false, bool noDefault=false);
|
||||
void getSHUOColors(TDF_Label label, std::map<std::string,App::Color> &colors, bool appendFirst);
|
||||
void setObjectName(Info &info, TDF_Label label);
|
||||
App::DocumentObject* loadShape(App::Document* doc,
|
||||
TDF_Label label,
|
||||
const TopoDS_Shape& shape,
|
||||
bool baseOnly = false,
|
||||
bool newDoc = true);
|
||||
App::Document* getDocument(App::Document* doc, TDF_Label label);
|
||||
bool createAssembly(App::Document* doc,
|
||||
TDF_Label label,
|
||||
const TopoDS_Shape& shape,
|
||||
Info& info,
|
||||
bool newDoc);
|
||||
bool createObject(App::Document* doc,
|
||||
TDF_Label label,
|
||||
const TopoDS_Shape& shape,
|
||||
Info& info,
|
||||
bool newDoc);
|
||||
bool createGroup(App::Document* doc,
|
||||
Info& info,
|
||||
const TopoDS_Shape& shape,
|
||||
std::vector<App::DocumentObject*>& children,
|
||||
const boost::dynamic_bitset<>& visibilities,
|
||||
bool canReduce = false);
|
||||
bool
|
||||
getColor(const TopoDS_Shape& shape, Info& info, bool check = false, bool noDefault = false);
|
||||
void
|
||||
getSHUOColors(TDF_Label label, std::map<std::string, App::Color>& colors, bool appendFirst);
|
||||
void setObjectName(Info& info, TDF_Label label);
|
||||
std::string getLabelName(TDF_Label label);
|
||||
App::DocumentObject *expandShape(App::Document *doc, TDF_Label label, const TopoDS_Shape &shape);
|
||||
App::DocumentObject*
|
||||
expandShape(App::Document* doc, TDF_Label label, const TopoDS_Shape& shape);
|
||||
|
||||
virtual void applyEdgeColors(Part::Feature*, const std::vector<App::Color>&) {}
|
||||
virtual void applyFaceColors(Part::Feature*, const std::vector<App::Color>&) {}
|
||||
virtual void applyElementColors(App::DocumentObject*, const std::map<std::string,App::Color>&) {}
|
||||
virtual void applyLinkColor(App::DocumentObject *, int /*index*/, App::Color){}
|
||||
virtual void applyEdgeColors(Part::Feature*, const std::vector<App::Color>&)
|
||||
{}
|
||||
virtual void applyFaceColors(Part::Feature*, const std::vector<App::Color>&)
|
||||
{}
|
||||
virtual void applyElementColors(App::DocumentObject*, const std::map<std::string, App::Color>&)
|
||||
{}
|
||||
virtual void applyLinkColor(App::DocumentObject*, int /*index*/, App::Color)
|
||||
{}
|
||||
|
||||
private:
|
||||
class ImportLegacy : public ImportOCAF {
|
||||
class ImportLegacy: public ImportOCAF
|
||||
{
|
||||
public:
|
||||
explicit ImportLegacy(ImportOCAF2 &parent)
|
||||
:ImportOCAF(parent.pDoc, parent.pDocument, parent.default_name),myParent(parent)
|
||||
explicit ImportLegacy(ImportOCAF2& parent)
|
||||
: ImportOCAF(parent.pDoc, parent.pDocument, parent.default_name)
|
||||
, myParent(parent)
|
||||
{}
|
||||
|
||||
private:
|
||||
void applyColors(Part::Feature* part, const std::vector<App::Color>& colors) override {
|
||||
void applyColors(Part::Feature* part, const std::vector<App::Color>& colors) override
|
||||
{
|
||||
myParent.applyFaceColors(part, colors);
|
||||
}
|
||||
|
||||
ImportOCAF2 &myParent;
|
||||
ImportOCAF2& myParent;
|
||||
};
|
||||
friend class ImportLegacy;
|
||||
|
||||
@@ -187,7 +225,7 @@ private:
|
||||
std::unordered_map<TDF_Label, std::string, LabelHasher> myNames;
|
||||
std::unordered_map<App::DocumentObject*, App::PropertyPlacement*> myCollapsedObjects;
|
||||
|
||||
Base::SequencerLauncher *sequencer{nullptr};
|
||||
Base::SequencerLauncher* sequencer {nullptr};
|
||||
};
|
||||
|
||||
struct ImportExport ExportOCAFOptions
|
||||
@@ -201,41 +239,51 @@ struct ImportExport ExportOCAFOptions
|
||||
class ImportExport ExportOCAF2
|
||||
{
|
||||
public:
|
||||
using GetShapeColorsFunc = std::function<std::map<std::string,App::Color>(
|
||||
App::DocumentObject*, const char*)>;
|
||||
explicit ExportOCAF2(Handle(TDocStd_Document) h, GetShapeColorsFunc func=GetShapeColorsFunc());
|
||||
using GetShapeColorsFunc =
|
||||
std::function<std::map<std::string, App::Color>(App::DocumentObject*, const char*)>;
|
||||
explicit ExportOCAF2(Handle(TDocStd_Document) h,
|
||||
GetShapeColorsFunc func = GetShapeColorsFunc());
|
||||
|
||||
static ExportOCAFOptions customExportOptions();
|
||||
void setExportOptions(ExportOCAFOptions opts) {
|
||||
void setExportOptions(ExportOCAFOptions opts)
|
||||
{
|
||||
options = opts;
|
||||
}
|
||||
void setExportHiddenObject(bool enable) {
|
||||
void setExportHiddenObject(bool enable)
|
||||
{
|
||||
options.exportHidden = enable;
|
||||
}
|
||||
void setKeepPlacement(bool enable) {
|
||||
void setKeepPlacement(bool enable)
|
||||
{
|
||||
options.keepPlacement = enable;
|
||||
}
|
||||
void exportObjects(std::vector<App::DocumentObject*> &objs, const char *name=nullptr);
|
||||
void exportObjects(std::vector<App::DocumentObject*>& objs, const char* name = nullptr);
|
||||
bool canFallback(std::vector<App::DocumentObject*> objs);
|
||||
|
||||
private:
|
||||
TDF_Label exportObject(App::DocumentObject *obj, const char *sub, TDF_Label parent, const char *name=nullptr);
|
||||
void setupObject(TDF_Label label, App::DocumentObject *obj,
|
||||
const Part::TopoShape &shape, const std::string &prefix,
|
||||
const char *name=nullptr, bool force=false);
|
||||
void setName(TDF_Label label, App::DocumentObject *obj, const char *name=nullptr);
|
||||
TDF_Label findComponent(const char *subname, TDF_Label label, TDF_LabelSequence &labels);
|
||||
TDF_Label exportObject(App::DocumentObject* obj,
|
||||
const char* sub,
|
||||
TDF_Label parent,
|
||||
const char* name = nullptr);
|
||||
void setupObject(TDF_Label label,
|
||||
App::DocumentObject* obj,
|
||||
const Part::TopoShape& shape,
|
||||
const std::string& prefix,
|
||||
const char* name = nullptr,
|
||||
bool force = false);
|
||||
void setName(TDF_Label label, App::DocumentObject* obj, const char* name = nullptr);
|
||||
TDF_Label findComponent(const char* subname, TDF_Label label, TDF_LabelSequence& labels);
|
||||
|
||||
private:
|
||||
Handle(TDocStd_Document) pDoc;
|
||||
Handle(XCAFDoc_ShapeTool) aShapeTool;
|
||||
Handle(XCAFDoc_ColorTool) aColorTool;
|
||||
|
||||
std::unordered_map<App::DocumentObject *, TDF_Label> myObjects;
|
||||
std::unordered_map<App::DocumentObject*, TDF_Label> myObjects;
|
||||
|
||||
std::unordered_map<TDF_Label, std::vector<std::string>, LabelHasher> myNames;
|
||||
|
||||
std::set<std::pair<App::DocumentObject*,std::string> > mySetups;
|
||||
std::set<std::pair<App::DocumentObject*, std::string>> mySetups;
|
||||
|
||||
std::vector<App::DocumentObject*> groupLinks;
|
||||
|
||||
@@ -244,6 +292,6 @@ private:
|
||||
ExportOCAFOptions options;
|
||||
};
|
||||
|
||||
}
|
||||
}// namespace Import
|
||||
|
||||
#endif //IMPORT_IMPORTOCAF2_H
|
||||
#endif// IMPORT_IMPORTOCAF2_H
|
||||
|
||||
@@ -22,23 +22,23 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#if defined(__MINGW32__)
|
||||
# define WNT // avoid conflict with GUID
|
||||
#define WNT// avoid conflict with GUID
|
||||
#endif
|
||||
#ifndef _PreComp_
|
||||
# include <climits>
|
||||
# include <sstream>
|
||||
# include <Quantity_Color.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
# include <TDataStd_Name.hxx>
|
||||
# include <TDF_ChildIterator.hxx>
|
||||
# include <TDF_Label.hxx>
|
||||
# include <TDocStd_Document.hxx>
|
||||
# include <TopExp_Explorer.hxx>
|
||||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
# include <XCAFDoc_ColorTool.hxx>
|
||||
# include <XCAFDoc_DocumentTool.hxx>
|
||||
# include <XCAFDoc_Location.hxx>
|
||||
# include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <Quantity_Color.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <XCAFDoc_ColorTool.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_Location.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <climits>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include <App/Application.h>
|
||||
@@ -52,31 +52,33 @@
|
||||
using namespace Import;
|
||||
|
||||
|
||||
ImportOCAFAssembly::ImportOCAFAssembly(Handle(TDocStd_Document) h, App::Document* d, const std::string& name, App::DocumentObject *target)
|
||||
: pDoc(h),
|
||||
doc(d),
|
||||
default_name(name),
|
||||
targetObj(target)
|
||||
ImportOCAFAssembly::ImportOCAFAssembly(Handle(TDocStd_Document) h,
|
||||
App::Document* d,
|
||||
const std::string& name,
|
||||
App::DocumentObject* target)
|
||||
: pDoc(h)
|
||||
, doc(d)
|
||||
, default_name(name)
|
||||
, targetObj(target)
|
||||
{
|
||||
aShapeTool = XCAFDoc_DocumentTool::ShapeTool (pDoc->Main());
|
||||
aShapeTool = XCAFDoc_DocumentTool::ShapeTool(pDoc->Main());
|
||||
aColorTool = XCAFDoc_DocumentTool::ColorTool(pDoc->Main());
|
||||
}
|
||||
|
||||
ImportOCAFAssembly::~ImportOCAFAssembly()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
void ImportOCAFAssembly::loadShapes()
|
||||
{
|
||||
myRefShapes.clear();
|
||||
loadShapes(pDoc->Main(), TopLoc_Location(), default_name, "", false,0);
|
||||
loadShapes(pDoc->Main(), TopLoc_Location(), default_name, "", false, 0);
|
||||
}
|
||||
|
||||
|
||||
void ImportOCAFAssembly::loadAssembly()
|
||||
{
|
||||
myRefShapes.clear();
|
||||
loadShapes(pDoc->Main(), TopLoc_Location(), default_name, "", false,0);
|
||||
loadShapes(pDoc->Main(), TopLoc_Location(), default_name, "", false, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,88 +86,97 @@ std::string ImportOCAFAssembly::getName(const TDF_Label& label)
|
||||
{
|
||||
Handle(TDataStd_Name) name;
|
||||
std::string part_name;
|
||||
if (label.FindAttribute(TDataStd_Name::GetID(),name)) {
|
||||
if (label.FindAttribute(TDataStd_Name::GetID(), name)) {
|
||||
TCollection_ExtendedString extstr = name->Get();
|
||||
char* str = new char[extstr.LengthOfCString()+1];
|
||||
char* str = new char[extstr.LengthOfCString() + 1];
|
||||
extstr.ToUTF8CString(str);
|
||||
part_name = str;
|
||||
delete [] str;
|
||||
delete[] str;
|
||||
return part_name;
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ImportOCAFAssembly::loadShapes(const TDF_Label& label, const TopLoc_Location& loc, const std::string& defaultname, const std::string& assembly, bool isRef, int dep)
|
||||
void ImportOCAFAssembly::loadShapes(const TDF_Label& label,
|
||||
const TopLoc_Location& loc,
|
||||
const std::string& defaultname,
|
||||
const std::string& assembly,
|
||||
bool isRef,
|
||||
int dep)
|
||||
{
|
||||
int hash = 0;
|
||||
TopoDS_Shape aShape;
|
||||
if (aShapeTool->GetShape(label,aShape)) {
|
||||
if (aShapeTool->GetShape(label, aShape)) {
|
||||
hash = aShape.HashCode(HashUpper);
|
||||
}
|
||||
|
||||
Handle(TDataStd_Name) name;
|
||||
std::string part_name = defaultname;
|
||||
if (label.FindAttribute(TDataStd_Name::GetID(),name)) {
|
||||
if (label.FindAttribute(TDataStd_Name::GetID(), name)) {
|
||||
TCollection_ExtendedString extstr = name->Get();
|
||||
char* str = new char[extstr.LengthOfCString()+1];
|
||||
char* str = new char[extstr.LengthOfCString() + 1];
|
||||
extstr.ToUTF8CString(str);
|
||||
part_name = str;
|
||||
delete [] str;
|
||||
delete[] str;
|
||||
if (part_name.empty()) {
|
||||
part_name = defaultname;
|
||||
}
|
||||
else {
|
||||
bool ws=true;
|
||||
bool ws = true;
|
||||
for (std::string::iterator it = part_name.begin(); it != part_name.end(); ++it) {
|
||||
if (*it != ' ') {
|
||||
ws = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ws)
|
||||
if (ws) {
|
||||
part_name = defaultname;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TopLoc_Location part_loc = loc;
|
||||
Handle(XCAFDoc_Location) hLoc;
|
||||
if (label.FindAttribute(XCAFDoc_Location::GetID(), hLoc)) {
|
||||
if (isRef)
|
||||
if (isRef) {
|
||||
part_loc = part_loc * hLoc->Get();
|
||||
else
|
||||
}
|
||||
else {
|
||||
part_loc = hLoc->Get();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FC_DEBUG
|
||||
const char *s;
|
||||
if( !hLoc.IsNull() )
|
||||
s = hLoc->Get().IsIdentity()?"0":"1";
|
||||
else
|
||||
const char* s;
|
||||
if (!hLoc.IsNull()) {
|
||||
s = hLoc->Get().IsIdentity() ? "0" : "1";
|
||||
}
|
||||
else {
|
||||
s = "0";
|
||||
}
|
||||
|
||||
std::stringstream str;
|
||||
|
||||
Base::Console().Log("H:%-9d \tN:%-30s \tTop:%d, Asm:%d, Shape:%d, Compound:%d, Simple:%d, Free:%d, Ref:%d, Component:%d, SubShape:%d\tTrf:%s-- Dep:%d \n",
|
||||
hash,
|
||||
part_name.c_str(),
|
||||
aShapeTool->IsTopLevel(label),
|
||||
aShapeTool->IsAssembly(label),
|
||||
aShapeTool->IsShape(label),
|
||||
aShapeTool->IsCompound(label),
|
||||
aShapeTool->IsSimpleShape(label),
|
||||
aShapeTool->IsFree(label),
|
||||
aShapeTool->IsReference(label),
|
||||
aShapeTool->IsComponent(label),
|
||||
aShapeTool->IsSubShape(label),
|
||||
s,
|
||||
dep
|
||||
);
|
||||
Base::Console().Log("H:%-9d \tN:%-30s \tTop:%d, Asm:%d, Shape:%d, Compound:%d, Simple:%d, "
|
||||
"Free:%d, Ref:%d, Component:%d, SubShape:%d\tTrf:%s-- Dep:%d \n",
|
||||
hash,
|
||||
part_name.c_str(),
|
||||
aShapeTool->IsTopLevel(label),
|
||||
aShapeTool->IsAssembly(label),
|
||||
aShapeTool->IsShape(label),
|
||||
aShapeTool->IsCompound(label),
|
||||
aShapeTool->IsSimpleShape(label),
|
||||
aShapeTool->IsFree(label),
|
||||
aShapeTool->IsReference(label),
|
||||
aShapeTool->IsComponent(label),
|
||||
aShapeTool->IsSubShape(label),
|
||||
s,
|
||||
dep);
|
||||
|
||||
label.Dump(str);
|
||||
Base::Console().Message(str.str().c_str() );
|
||||
Base::Console().Message(str.str().c_str());
|
||||
#endif
|
||||
|
||||
std::string asm_name = assembly;
|
||||
@@ -175,65 +186,74 @@ void ImportOCAFAssembly::loadShapes(const TDF_Label& label, const TopLoc_Locatio
|
||||
|
||||
TDF_Label ref;
|
||||
if (aShapeTool->IsReference(label) && aShapeTool->GetReferredShape(label, ref)) {
|
||||
loadShapes(ref, part_loc, part_name, asm_name, true,dep + 1);
|
||||
loadShapes(ref, part_loc, part_name, asm_name, true, dep + 1);
|
||||
}
|
||||
|
||||
if (isRef || myRefShapes.find(hash) == myRefShapes.end()) {
|
||||
TopoDS_Shape aShape;
|
||||
if (isRef && aShapeTool->GetShape(label, aShape))
|
||||
if (isRef && aShapeTool->GetShape(label, aShape)) {
|
||||
myRefShapes.insert(aShape.HashCode(HashUpper));
|
||||
}
|
||||
|
||||
if (aShapeTool->IsSimpleShape(label) && (isRef || aShapeTool->IsFree(label))) {
|
||||
if (!asm_name.empty())
|
||||
if (!asm_name.empty()) {
|
||||
part_name = asm_name;
|
||||
if (isRef)
|
||||
}
|
||||
if (isRef) {
|
||||
createShape(label, loc, part_name);
|
||||
else
|
||||
}
|
||||
else {
|
||||
createShape(label, part_loc, part_name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (TDF_ChildIterator it(label); it.More(); it.Next()) {
|
||||
loadShapes(it.Value(), part_loc, part_name, asm_name, isRef, dep+1);
|
||||
loadShapes(it.Value(), part_loc, part_name, asm_name, isRef, dep + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ImportOCAFAssembly::createShape(const TDF_Label& label, const TopLoc_Location& loc, const std::string& name)
|
||||
void ImportOCAFAssembly::createShape(const TDF_Label& label,
|
||||
const TopLoc_Location& loc,
|
||||
const std::string& name)
|
||||
{
|
||||
Base::Console().Log("-create Shape\n");
|
||||
Base::Console().Log("-create Shape\n");
|
||||
const TopoDS_Shape& aShape = aShapeTool->GetShape(label);
|
||||
if (!aShape.IsNull() && aShape.ShapeType() == TopAbs_COMPOUND) {
|
||||
TopExp_Explorer xp;
|
||||
int ctSolids = 0, ctShells = 0;
|
||||
for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++)
|
||||
{
|
||||
for (xp.Init(aShape, TopAbs_SOLID); xp.More(); xp.Next(), ctSolids++) {
|
||||
createShape(xp.Current(), loc, name);
|
||||
}
|
||||
for (xp.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); xp.More(); xp.Next(), ctShells++)
|
||||
{
|
||||
for (xp.Init(aShape, TopAbs_SHELL, TopAbs_SOLID); xp.More(); xp.Next(), ctShells++) {
|
||||
createShape(xp.Current(), loc, name);
|
||||
}
|
||||
if (ctSolids > 0 || ctShells > 0)
|
||||
if (ctSolids > 0 || ctShells > 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
createShape(aShape, loc, name);
|
||||
}
|
||||
|
||||
void ImportOCAFAssembly::createShape(const TopoDS_Shape& aShape, const TopLoc_Location& loc, const std::string& name)
|
||||
void ImportOCAFAssembly::createShape(const TopoDS_Shape& aShape,
|
||||
const TopLoc_Location& loc,
|
||||
const std::string& name)
|
||||
{
|
||||
Part::Feature* part = static_cast<Part::Feature*>(doc->addObject("Part::Feature"));
|
||||
if (!loc.IsIdentity())
|
||||
if (!loc.IsIdentity()) {
|
||||
part->Shape.setValue(aShape.Moved(loc));
|
||||
else
|
||||
}
|
||||
else {
|
||||
part->Shape.setValue(aShape);
|
||||
}
|
||||
part->Label.setValue(name);
|
||||
|
||||
Quantity_Color aColor;
|
||||
App::Color color(0.8f,0.8f,0.8f);
|
||||
if (aColorTool->GetColor(aShape, XCAFDoc_ColorGen, aColor) ||
|
||||
aColorTool->GetColor(aShape, XCAFDoc_ColorSurf, aColor) ||
|
||||
aColorTool->GetColor(aShape, XCAFDoc_ColorCurv, aColor)) {
|
||||
App::Color color(0.8f, 0.8f, 0.8f);
|
||||
if (aColorTool->GetColor(aShape, XCAFDoc_ColorGen, aColor)
|
||||
|| aColorTool->GetColor(aShape, XCAFDoc_ColorSurf, aColor)
|
||||
|| aColorTool->GetColor(aShape, XCAFDoc_ColorCurv, aColor)) {
|
||||
color.r = (float)aColor.Red();
|
||||
color.g = (float)aColor.Green();
|
||||
color.b = (float)aColor.Blue();
|
||||
@@ -243,7 +263,7 @@ void ImportOCAFAssembly::createShape(const TopoDS_Shape& aShape, const TopLoc_Lo
|
||||
}
|
||||
|
||||
TopTools_IndexedMapOfShape faces;
|
||||
TopExp_Explorer xp(aShape,TopAbs_FACE);
|
||||
TopExp_Explorer xp(aShape, TopAbs_FACE);
|
||||
while (xp.More()) {
|
||||
faces.Add(xp.Current());
|
||||
xp.Next();
|
||||
@@ -251,16 +271,16 @@ void ImportOCAFAssembly::createShape(const TopoDS_Shape& aShape, const TopLoc_Lo
|
||||
bool found_face_color = false;
|
||||
std::vector<App::Color> faceColors;
|
||||
faceColors.resize(faces.Extent(), color);
|
||||
xp.Init(aShape,TopAbs_FACE);
|
||||
xp.Init(aShape, TopAbs_FACE);
|
||||
while (xp.More()) {
|
||||
if (aColorTool->GetColor(xp.Current(), XCAFDoc_ColorGen, aColor) ||
|
||||
aColorTool->GetColor(xp.Current(), XCAFDoc_ColorSurf, aColor) ||
|
||||
aColorTool->GetColor(xp.Current(), XCAFDoc_ColorCurv, aColor)) {
|
||||
if (aColorTool->GetColor(xp.Current(), XCAFDoc_ColorGen, aColor)
|
||||
|| aColorTool->GetColor(xp.Current(), XCAFDoc_ColorSurf, aColor)
|
||||
|| aColorTool->GetColor(xp.Current(), XCAFDoc_ColorCurv, aColor)) {
|
||||
int index = faces.FindIndex(xp.Current());
|
||||
color.r = (float)aColor.Red();
|
||||
color.g = (float)aColor.Green();
|
||||
color.b = (float)aColor.Blue();
|
||||
faceColors[index-1] = color;
|
||||
faceColors[index - 1] = color;
|
||||
found_face_color = true;
|
||||
}
|
||||
xp.Next();
|
||||
@@ -270,5 +290,3 @@ void ImportOCAFAssembly::createShape(const TopoDS_Shape& aShape, const TopLoc_Lo
|
||||
applyColors(part, faceColors);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -38,34 +38,46 @@
|
||||
class TDF_Label;
|
||||
class TopLoc_Location;
|
||||
|
||||
namespace App {
|
||||
namespace App
|
||||
{
|
||||
class Document;
|
||||
class DocumentObject;
|
||||
}
|
||||
namespace Part {
|
||||
}// namespace App
|
||||
namespace Part
|
||||
{
|
||||
class Feature;
|
||||
}
|
||||
|
||||
namespace Import {
|
||||
namespace Import
|
||||
{
|
||||
|
||||
class ImportExport ImportOCAFAssembly
|
||||
{
|
||||
public:
|
||||
ImportOCAFAssembly(Handle(TDocStd_Document) h, App::Document* d, const std::string& name, App::DocumentObject *target);
|
||||
ImportOCAFAssembly(Handle(TDocStd_Document) h,
|
||||
App::Document* d,
|
||||
const std::string& name,
|
||||
App::DocumentObject* target);
|
||||
virtual ~ImportOCAFAssembly();
|
||||
void loadShapes();
|
||||
void loadAssembly();
|
||||
|
||||
protected:
|
||||
std::string getName(const TDF_Label& label);
|
||||
App::DocumentObject *targetObj;
|
||||
App::DocumentObject* targetObj;
|
||||
|
||||
|
||||
private:
|
||||
void loadShapes(const TDF_Label& label, const TopLoc_Location&, const std::string& partname, const std::string& assembly, bool isRef, int dep);
|
||||
void loadShapes(const TDF_Label& label,
|
||||
const TopLoc_Location&,
|
||||
const std::string& partname,
|
||||
const std::string& assembly,
|
||||
bool isRef,
|
||||
int dep);
|
||||
void createShape(const TDF_Label& label, const TopLoc_Location&, const std::string&);
|
||||
void createShape(const TopoDS_Shape& label, const TopLoc_Location&, const std::string&);
|
||||
virtual void applyColors(Part::Feature*, const std::vector<App::Color>&){}
|
||||
virtual void applyColors(Part::Feature*, const std::vector<App::Color>&)
|
||||
{}
|
||||
|
||||
private:
|
||||
Handle(TDocStd_Document) pDoc;
|
||||
@@ -78,6 +90,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
} // namespace Import {
|
||||
}// namespace Import
|
||||
|
||||
#endif //IMPORT_ImportOCAFAssembly_H
|
||||
#endif// IMPORT_ImportOCAFAssembly_H
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
# PlmXmlParser
|
||||
#***************************************************************************
|
||||
#* Copyright (c) 2015 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
#* *
|
||||
#* This file is part of the FreeCAD CAx development system. *
|
||||
#* *
|
||||
#* This program is free software; you can redistribute it and/or modify *
|
||||
#* it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
#* as published by the Free Software Foundation; either version 2 of *
|
||||
#* the License, or (at your option) any later version. *
|
||||
#* for detail see the LICENCE text file. *
|
||||
#* *
|
||||
#* FreeCAD is distributed in the hope that it will be useful, *
|
||||
#* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
#* GNU Lesser General Public License for more details. *
|
||||
#* *
|
||||
#* You should have received a copy of the GNU Library General Public *
|
||||
#* License along with FreeCAD; if not, write to the Free Software *
|
||||
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
#* USA *
|
||||
#* *
|
||||
#***************************************************************************/
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2015 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
# * This program is free software; you can redistribute it and/or modify *
|
||||
# * it under the terms of the GNU Lesser General Public License (LGPL) *
|
||||
# * as published by the Free Software Foundation; either version 2 of *
|
||||
# * the License, or (at your option) any later version. *
|
||||
# * for detail see the LICENCE text file. *
|
||||
# * *
|
||||
# * FreeCAD is distributed in the hope that it will be useful, *
|
||||
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
# * GNU Lesser General Public License for more details. *
|
||||
# * *
|
||||
# * You should have received a copy of the GNU Library General Public *
|
||||
# * License along with FreeCAD; if not, write to the Free Software *
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
@@ -29,131 +29,149 @@ FreeCAD_On = False
|
||||
FreeCAD_Doc = None
|
||||
FreeCAD_ObjList = []
|
||||
|
||||
|
||||
def ParseUserData(element):
|
||||
res = {}
|
||||
for i in element.findall('{http://www.plmxml.org/Schemas/PLMXMLSchema}UserData'):
|
||||
for value in i.findall('{http://www.plmxml.org/Schemas/PLMXMLSchema}UserValue'):
|
||||
res[value.attrib['title']] = value.attrib['value']
|
||||
for i in element.findall("{http://www.plmxml.org/Schemas/PLMXMLSchema}UserData"):
|
||||
for value in i.findall("{http://www.plmxml.org/Schemas/PLMXMLSchema}UserValue"):
|
||||
res[value.attrib["title"]] = value.attrib["value"]
|
||||
return res
|
||||
|
||||
|
||||
def addPart(partElement):
|
||||
global FreeCAD_On,FreeCAD_Doc,FreeCAD_ObjList
|
||||
global FreeCAD_On, FreeCAD_Doc, FreeCAD_ObjList
|
||||
print("=== Part ======================================================")
|
||||
name = partElement.attrib['name']
|
||||
id = partElement.attrib['id']
|
||||
name = partElement.attrib["name"]
|
||||
id = partElement.attrib["id"]
|
||||
userData = ParseUserData(partElement)
|
||||
|
||||
bound = partElement.find('{http://www.plmxml.org/Schemas/PLMXMLSchema}Bound')
|
||||
print(bound.attrib['values'])
|
||||
bound = partElement.find("{http://www.plmxml.org/Schemas/PLMXMLSchema}Bound")
|
||||
print(bound.attrib["values"])
|
||||
|
||||
representation = partElement.find('{http://www.plmxml.org/Schemas/PLMXMLSchema}Representation')
|
||||
format = representation.attrib['format']
|
||||
location = representation.attrib['location']
|
||||
representation = partElement.find("{http://www.plmxml.org/Schemas/PLMXMLSchema}Representation")
|
||||
format = representation.attrib["format"]
|
||||
location = representation.attrib["location"]
|
||||
|
||||
print(id, name, userData, format, location)
|
||||
if FreeCAD_On:
|
||||
import FreeCAD,Assembly
|
||||
import FreeCAD, Assembly
|
||||
|
||||
print("Create Reference")
|
||||
partObject =FreeCAD_Doc.addObject("App::Part",id)
|
||||
partObject = FreeCAD_Doc.addObject("App::Part", id)
|
||||
FreeCAD_ObjList.append(partObject)
|
||||
partObject.Label = name
|
||||
partObject.Meta = userData
|
||||
|
||||
|
||||
def addAssembly(asmElement):
|
||||
global FreeCAD_On,FreeCAD_Doc,FreeCAD_ObjList
|
||||
global FreeCAD_On, FreeCAD_Doc, FreeCAD_ObjList
|
||||
print("=== Assembly ======================================================")
|
||||
userData = ParseUserData(asmElement)
|
||||
name = asmElement.attrib['name']
|
||||
id = asmElement.attrib['id']
|
||||
instanceRefs = asmElement.attrib['instanceRefs']
|
||||
userData['instanceRefs'] = instanceRefs
|
||||
name = asmElement.attrib["name"]
|
||||
id = asmElement.attrib["id"]
|
||||
instanceRefs = asmElement.attrib["instanceRefs"]
|
||||
userData["instanceRefs"] = instanceRefs
|
||||
|
||||
print(id, name, instanceRefs, userData)
|
||||
if FreeCAD_On:
|
||||
import FreeCAD,Assembly
|
||||
import FreeCAD, Assembly
|
||||
|
||||
print("Create Reference")
|
||||
admObject =FreeCAD_Doc.addObject("Assembly::Product",id)
|
||||
admObject = FreeCAD_Doc.addObject("Assembly::Product", id)
|
||||
FreeCAD_ObjList.append(admObject)
|
||||
admObject.Label = name
|
||||
admObject.Meta = userData
|
||||
|
||||
|
||||
def addReference(refElement):
|
||||
global FreeCAD_On,FreeCAD_Doc,FreeCAD_ObjList
|
||||
global FreeCAD_On, FreeCAD_Doc, FreeCAD_ObjList
|
||||
print("=== Reference ======================================================")
|
||||
userData = ParseUserData(refElement)
|
||||
partRef = refElement.attrib['partRef'][1:]
|
||||
userData['partRef'] = partRef
|
||||
id = refElement.attrib['id']
|
||||
name = refElement.attrib['name']
|
||||
transform = refElement.find('{http://www.plmxml.org/Schemas/PLMXMLSchema}Transform')
|
||||
mtrx = [float(i) for i in transform.text.split(' ')]
|
||||
partRef = refElement.attrib["partRef"][1:]
|
||||
userData["partRef"] = partRef
|
||||
id = refElement.attrib["id"]
|
||||
name = refElement.attrib["name"]
|
||||
transform = refElement.find("{http://www.plmxml.org/Schemas/PLMXMLSchema}Transform")
|
||||
mtrx = [float(i) for i in transform.text.split(" ")]
|
||||
print(mtrx)
|
||||
print(id,name,partRef)
|
||||
print(id, name, partRef)
|
||||
|
||||
if FreeCAD_On:
|
||||
import FreeCAD,Assembly
|
||||
import FreeCAD, Assembly
|
||||
|
||||
print("Create Reference")
|
||||
refObject =FreeCAD_Doc.addObject("Assembly::ProductRef",id)
|
||||
refObject = FreeCAD_Doc.addObject("Assembly::ProductRef", id)
|
||||
FreeCAD_ObjList.append(refObject)
|
||||
refObject.Label = name
|
||||
refObject.Meta = userData
|
||||
|
||||
|
||||
def resolveRefs():
|
||||
global FreeCAD_On,FreeCAD_Doc,FreeCAD_ObjList
|
||||
global FreeCAD_On, FreeCAD_Doc, FreeCAD_ObjList
|
||||
print("=== Resolve References ======================================================")
|
||||
if FreeCAD_On:
|
||||
for i in FreeCAD_ObjList:
|
||||
if i.TypeId == 'Assembly::Product':
|
||||
if i.TypeId == "Assembly::Product":
|
||||
objectList = []
|
||||
for l in i.Meta['instanceRefs'].split(' '):
|
||||
for l in i.Meta["instanceRefs"].split(" "):
|
||||
objectList.append(FreeCAD_Doc.getObject(l))
|
||||
i.Items = objectList
|
||||
if i.TypeId == 'Assembly::ProductRef':
|
||||
i.Item = FreeCAD_Doc.getObject(i.Meta['partRef'])
|
||||
if i.TypeId == "Assembly::ProductRef":
|
||||
i.Item = FreeCAD_Doc.getObject(i.Meta["partRef"])
|
||||
|
||||
|
||||
def open(fileName):
|
||||
"""called when freecad opens an PlmXml file"""
|
||||
global FreeCAD_On,FreeCAD_Doc
|
||||
import FreeCAD,os
|
||||
global FreeCAD_On, FreeCAD_Doc
|
||||
import FreeCAD, os
|
||||
|
||||
docname = os.path.splitext(os.path.basename(fileName))[0]
|
||||
doc = FreeCAD.newDocument(docname)
|
||||
message='Started with opening of "'+fileName+'" file\n'
|
||||
message = 'Started with opening of "' + fileName + '" file\n'
|
||||
FreeCAD.Console.PrintMessage(message)
|
||||
FreeCAD_Doc = doc
|
||||
FreeCAD_On = True
|
||||
parse(fileName)
|
||||
resolveRefs()
|
||||
|
||||
def insert(filename,docname):
|
||||
|
||||
def insert(filename, docname):
|
||||
"""called when freecad imports an PlmXml file"""
|
||||
global FreeCAD_On,FreeCAD_Doc
|
||||
global FreeCAD_On, FreeCAD_Doc
|
||||
import FreeCAD
|
||||
|
||||
FreeCAD.setActiveDocument(docname)
|
||||
doc=FreeCAD.getDocument(docname)
|
||||
FreeCAD.Console.PrintMessage('Started import of "'+filename+'" file')
|
||||
doc = FreeCAD.getDocument(docname)
|
||||
FreeCAD.Console.PrintMessage('Started import of "' + filename + '" file')
|
||||
FreeCAD_Doc = doc
|
||||
FreeCAD_On = True
|
||||
parse(fileName)
|
||||
resolveRefs()
|
||||
|
||||
|
||||
def main():
|
||||
parse('../../../../data/tests/Jt/Engine/2_Cylinder_Engine3.plmxml')
|
||||
parse("../../../../data/tests/Jt/Engine/2_Cylinder_Engine3.plmxml")
|
||||
|
||||
|
||||
def parse(fileName):
|
||||
|
||||
tree = ET.parse(fileName)
|
||||
root = tree.getroot()
|
||||
ProductDef = root.find('{http://www.plmxml.org/Schemas/PLMXMLSchema}ProductDef')
|
||||
ProductDef = root.find("{http://www.plmxml.org/Schemas/PLMXMLSchema}ProductDef")
|
||||
|
||||
res = ParseUserData(ProductDef.find('{http://www.plmxml.org/Schemas/PLMXMLSchema}UserData'))
|
||||
res = ParseUserData(ProductDef.find("{http://www.plmxml.org/Schemas/PLMXMLSchema}UserData"))
|
||||
|
||||
InstanceGraph = ProductDef.find('{http://www.plmxml.org/Schemas/PLMXMLSchema}InstanceGraph')
|
||||
InstanceGraph = ProductDef.find("{http://www.plmxml.org/Schemas/PLMXMLSchema}InstanceGraph")
|
||||
|
||||
# get all the special elements we can read
|
||||
Instances = InstanceGraph.findall('{http://www.plmxml.org/Schemas/PLMXMLSchema}Instance')
|
||||
Parts = InstanceGraph.findall('{http://www.plmxml.org/Schemas/PLMXMLSchema}Part')
|
||||
ProductInstances = InstanceGraph.findall('{http://www.plmxml.org/Schemas/PLMXMLSchema}ProductInstance')
|
||||
ProductRevisionViews = InstanceGraph.findall('{http://www.plmxml.org/Schemas/PLMXMLSchema}ProductRevisionView')
|
||||
Instances = InstanceGraph.findall("{http://www.plmxml.org/Schemas/PLMXMLSchema}Instance")
|
||||
Parts = InstanceGraph.findall("{http://www.plmxml.org/Schemas/PLMXMLSchema}Part")
|
||||
ProductInstances = InstanceGraph.findall(
|
||||
"{http://www.plmxml.org/Schemas/PLMXMLSchema}ProductInstance"
|
||||
)
|
||||
ProductRevisionViews = InstanceGraph.findall(
|
||||
"{http://www.plmxml.org/Schemas/PLMXMLSchema}ProductRevisionView"
|
||||
)
|
||||
|
||||
instanceTypesSet = set()
|
||||
for child in InstanceGraph:
|
||||
@@ -163,28 +181,31 @@ def parse(fileName):
|
||||
print(i)
|
||||
print("")
|
||||
|
||||
print(len(Instances),'\t{http://www.plmxml.org/Schemas/PLMXMLSchema}Instance')
|
||||
print(len(Parts),'\t{http://www.plmxml.org/Schemas/PLMXMLSchema}Part')
|
||||
print(len(ProductInstances),'\t{http://www.plmxml.org/Schemas/PLMXMLSchema}ProductInstance')
|
||||
print(len(ProductRevisionViews),'\t{http://www.plmxml.org/Schemas/PLMXMLSchema}ProductRevisionView')
|
||||
print(len(Instances), "\t{http://www.plmxml.org/Schemas/PLMXMLSchema}Instance")
|
||||
print(len(Parts), "\t{http://www.plmxml.org/Schemas/PLMXMLSchema}Part")
|
||||
print(len(ProductInstances), "\t{http://www.plmxml.org/Schemas/PLMXMLSchema}ProductInstance")
|
||||
print(
|
||||
len(ProductRevisionViews),
|
||||
"\t{http://www.plmxml.org/Schemas/PLMXMLSchema}ProductRevisionView",
|
||||
)
|
||||
|
||||
# handle all instances
|
||||
for child in Instances:
|
||||
addReference(child)
|
||||
|
||||
#handle the parts and assemblies
|
||||
# handle the parts and assemblies
|
||||
for child in Parts:
|
||||
if 'type' in child.attrib:
|
||||
if child.attrib['type'] == 'solid' :
|
||||
if "type" in child.attrib:
|
||||
if child.attrib["type"] == "solid":
|
||||
addPart(child)
|
||||
continue
|
||||
if child.attrib['type'] == 'assembly' :
|
||||
if child.attrib["type"] == "assembly":
|
||||
addAssembly(child)
|
||||
continue
|
||||
print("Unknown Part type:",child)
|
||||
print("Unknown Part type:", child)
|
||||
else:
|
||||
print("not Type in Part", child)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -22,4 +22,3 @@
|
||||
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
|
||||
@@ -29,30 +29,30 @@
|
||||
|
||||
/// point at which warnings of overly long specifiers disabled (needet for VC6)
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning( disable : 4251 )
|
||||
# pragma warning( disable : 4275 )
|
||||
# pragma warning( disable : 4503 )
|
||||
# pragma warning( disable : 4786 ) // specifier longer then 255 chars
|
||||
#pragma warning(disable : 4251)
|
||||
#pragma warning(disable : 4275)
|
||||
#pragma warning(disable : 4503)
|
||||
#pragma warning(disable : 4786)// specifier longer then 255 chars
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _PreComp_
|
||||
|
||||
// standard
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <io.h>
|
||||
#include <cstdio>
|
||||
#include <fcntl.h>
|
||||
#include <vector>
|
||||
#include <io.h>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
// OpenCasCade =====================================================================================
|
||||
// Base
|
||||
#include <Mod/Part/App/OpenCascadeAll.h>
|
||||
|
||||
#endif //_PreComp_
|
||||
#endif//_PreComp_
|
||||
|
||||
#endif
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
#include <Base/Exception.h>
|
||||
@@ -31,8 +31,8 @@
|
||||
#include <Interface_Static.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Message_PrinterOStream.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <STEPControl_Reader.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <StepData_StepModel.hxx>
|
||||
|
||||
#include "StepShape.h"
|
||||
@@ -63,8 +63,8 @@ int StepShape::read(const char* fileName)
|
||||
|
||||
Handle(TColStd_HSequenceOfTransient) list = aReader.GiveList();
|
||||
|
||||
//Use method StepData_StepModel::NextNumberForLabel to find its rank with the following:
|
||||
//Standard_CString label = "#...";
|
||||
// Use method StepData_StepModel::NextNumberForLabel to find its rank with the following:
|
||||
// Standard_CString label = "#...";
|
||||
Handle(StepData_StepModel) model = aReader.StepModel();
|
||||
|
||||
|
||||
@@ -77,15 +77,15 @@ int StepShape::read(const char* fileName)
|
||||
model->DumpHeader(std::cout);
|
||||
#endif
|
||||
|
||||
for (int nent=1;nent<=model->NbEntities();nent++) {
|
||||
Handle(Standard_Transient) entity=model->Entity(nent);
|
||||
std::cout << "label entity " << nent << ":" ;
|
||||
for (int nent = 1; nent <= model->NbEntities(); nent++) {
|
||||
Handle(Standard_Transient) entity = model->Entity(nent);
|
||||
std::cout << "label entity " << nent << ":";
|
||||
#if OCC_VERSION_HEX < 0x070401
|
||||
model->PrintLabel(entity, msg);
|
||||
model->PrintLabel(entity, msg);
|
||||
#else
|
||||
model->PrintLabel(entity, std::cout);
|
||||
model->PrintLabel(entity, std::cout);
|
||||
#endif
|
||||
std::cout << ";"<< entity->DynamicType()->Name() << std::endl;
|
||||
std::cout << ";" << entity->DynamicType()->Name() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -41,10 +41,9 @@ public:
|
||||
~StepShape();
|
||||
|
||||
int read(const char* fileName);
|
||||
|
||||
};
|
||||
|
||||
} // namespace Import
|
||||
}// namespace Import
|
||||
|
||||
|
||||
#endif // IMPORT_STEPSHAPE_H
|
||||
#endif// IMPORT_STEPSHAPE_H
|
||||
|
||||
@@ -27,4 +27,4 @@ Read a STEP file into memory and make it accessible
|
||||
</Methode>
|
||||
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
</GenerateModel>
|
||||
|
||||
@@ -22,9 +22,11 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
// clang-format off
|
||||
// inclusion of the generated files (generated out of StepShapePy.xml)
|
||||
#include "StepShapePy.h"
|
||||
#include "StepShapePy.cpp"
|
||||
// clang-format on
|
||||
|
||||
using namespace Import;
|
||||
|
||||
@@ -34,7 +36,7 @@ std::string StepShapePy::representation() const
|
||||
return {"<StepShape object>"};
|
||||
}
|
||||
|
||||
PyObject *StepShapePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
PyObject* StepShapePy::PyMake(struct _typeobject*, PyObject*, PyObject*)// Python wrapper
|
||||
{
|
||||
// create a new instance of StepShapePy and the Twin object
|
||||
return new StepShapePy(new StepShape);
|
||||
@@ -53,13 +55,13 @@ int StepShapePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyObject* StepShapePy::read(PyObject * /*args*/)
|
||||
PyObject* StepShapePy::read(PyObject* /*args*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PyObject *StepShapePy::getCustomAttributes(const char* /*attr*/) const
|
||||
PyObject* StepShapePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -35,90 +35,126 @@ class BRepAdaptor_Curve;
|
||||
|
||||
namespace Import
|
||||
{
|
||||
class ImportExport ImpExpDxfRead : public CDxfRead
|
||||
class ImportExport ImpExpDxfRead: public CDxfRead
|
||||
{
|
||||
public:
|
||||
ImpExpDxfRead(std::string filepath, App::Document* pcDoc);
|
||||
|
||||
// CDxfRead's virtual functions
|
||||
void OnReadLine(const double* s, const double* e, bool hidden) override;
|
||||
void OnReadPoint(const double* s) override;
|
||||
void OnReadText(const double* point, const double height, const char* text) override;
|
||||
void
|
||||
OnReadArc(const double* s, const double* e, const double* c, bool dir, bool hidden) override;
|
||||
void OnReadCircle(const double* s, const double* c, bool dir, bool hidden) override;
|
||||
void OnReadEllipse(const double* c,
|
||||
double major_radius,
|
||||
double minor_radius,
|
||||
double rotation,
|
||||
double start_angle,
|
||||
double end_angle,
|
||||
bool dir) override;
|
||||
void OnReadSpline(struct SplineData& sd) override;
|
||||
void OnReadInsert(const double* point,
|
||||
const double* scale,
|
||||
const char* name,
|
||||
double rotation) override;
|
||||
void OnReadDimension(const double* s,
|
||||
const double* e,
|
||||
const double* point,
|
||||
double rotation) override;
|
||||
void AddGraphics() const override;
|
||||
|
||||
// FreeCAD-specific functions
|
||||
void AddObject(Part::TopoShape* shape);// Called by OnRead functions to add Part objects
|
||||
std::string Deformat(const char* text);// Removes DXF formatting from texts
|
||||
|
||||
std::string getOptionSource()
|
||||
{
|
||||
public:
|
||||
ImpExpDxfRead(std::string filepath, App::Document *pcDoc);
|
||||
|
||||
// CDxfRead's virtual functions
|
||||
void OnReadLine(const double* s, const double* e, bool hidden) override;
|
||||
void OnReadPoint(const double* s) override;
|
||||
void OnReadText(const double* point, const double height, const char* text) override;
|
||||
void OnReadArc(const double* s, const double* e, const double* c, bool dir, bool hidden) override;
|
||||
void OnReadCircle(const double* s, const double* c, bool dir, bool hidden) override;
|
||||
void OnReadEllipse(const double* c, double major_radius, double minor_radius, double rotation, double start_angle, double end_angle, bool dir) override;
|
||||
void OnReadSpline(struct SplineData& sd) override;
|
||||
void OnReadInsert(const double* point, const double* scale, const char* name, double rotation) override;
|
||||
void OnReadDimension(const double* s, const double* e, const double* point, double rotation) override;
|
||||
void AddGraphics() const override;
|
||||
|
||||
// FreeCAD-specific functions
|
||||
void AddObject(Part::TopoShape *shape); //Called by OnRead functions to add Part objects
|
||||
std::string Deformat(const char* text); // Removes DXF formatting from texts
|
||||
|
||||
std::string getOptionSource() { return m_optionSource; }
|
||||
void setOptionSource(std::string s) { m_optionSource = s; }
|
||||
void setOptions();
|
||||
|
||||
private:
|
||||
gp_Pnt makePoint(const double* p);
|
||||
|
||||
protected:
|
||||
App::Document *document;
|
||||
bool optionGroupLayers;
|
||||
bool optionImportAnnotations;
|
||||
double optionScaling;
|
||||
std::map <std::string, std::vector <Part::TopoShape*> > layers;
|
||||
std::string m_optionSource;
|
||||
};
|
||||
|
||||
class ImportExport ImpExpDxfWrite : public CDxfWrite
|
||||
return m_optionSource;
|
||||
}
|
||||
void setOptionSource(std::string s)
|
||||
{
|
||||
public:
|
||||
explicit ImpExpDxfWrite(std::string filepath);
|
||||
~ImpExpDxfWrite();
|
||||
m_optionSource = s;
|
||||
}
|
||||
void setOptions();
|
||||
|
||||
void exportShape(const TopoDS_Shape input);
|
||||
std::string getOptionSource() { return m_optionSource; }
|
||||
void setOptionSource(std::string s) { m_optionSource = s; }
|
||||
void setOptions();
|
||||
private:
|
||||
gp_Pnt makePoint(const double* p);
|
||||
|
||||
void exportText(const char* text, Base::Vector3d position1, Base::Vector3d position2, double size, int just);
|
||||
void exportLinearDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
|
||||
Base::Vector3d extLine1Start, Base::Vector3d extLine2Start,
|
||||
char* dimText, int type);
|
||||
void exportAngularDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
|
||||
Base::Vector3d extLine1Start, Base::Vector3d extLine2Start,
|
||||
Base::Vector3d apexPoint,
|
||||
char* dimText);
|
||||
void exportRadialDim(Base::Vector3d centerPoint, Base::Vector3d textLocn,
|
||||
Base::Vector3d arcPoint,
|
||||
char* dimText);
|
||||
void exportDiametricDim(Base::Vector3d textLocn,
|
||||
Base::Vector3d arcPoint1, Base::Vector3d arcPoint2,
|
||||
char* dimText);
|
||||
protected:
|
||||
App::Document* document;
|
||||
bool optionGroupLayers;
|
||||
bool optionImportAnnotations;
|
||||
double optionScaling;
|
||||
std::map<std::string, std::vector<Part::TopoShape*>> layers;
|
||||
std::string m_optionSource;
|
||||
};
|
||||
|
||||
class ImportExport ImpExpDxfWrite: public CDxfWrite
|
||||
{
|
||||
public:
|
||||
explicit ImpExpDxfWrite(std::string filepath);
|
||||
~ImpExpDxfWrite();
|
||||
|
||||
void exportShape(const TopoDS_Shape input);
|
||||
std::string getOptionSource()
|
||||
{
|
||||
return m_optionSource;
|
||||
}
|
||||
void setOptionSource(std::string s)
|
||||
{
|
||||
m_optionSource = s;
|
||||
}
|
||||
void setOptions();
|
||||
|
||||
void exportText(const char* text,
|
||||
Base::Vector3d position1,
|
||||
Base::Vector3d position2,
|
||||
double size,
|
||||
int just);
|
||||
void exportLinearDim(Base::Vector3d textLocn,
|
||||
Base::Vector3d lineLocn,
|
||||
Base::Vector3d extLine1Start,
|
||||
Base::Vector3d extLine2Start,
|
||||
char* dimText,
|
||||
int type);
|
||||
void exportAngularDim(Base::Vector3d textLocn,
|
||||
Base::Vector3d lineLocn,
|
||||
Base::Vector3d extLine1Start,
|
||||
Base::Vector3d extLine2Start,
|
||||
Base::Vector3d apexPoint,
|
||||
char* dimText);
|
||||
void exportRadialDim(Base::Vector3d centerPoint,
|
||||
Base::Vector3d textLocn,
|
||||
Base::Vector3d arcPoint,
|
||||
char* dimText);
|
||||
void exportDiametricDim(Base::Vector3d textLocn,
|
||||
Base::Vector3d arcPoint1,
|
||||
Base::Vector3d arcPoint2,
|
||||
char* dimText);
|
||||
|
||||
|
||||
static bool gp_PntEqual(gp_Pnt p1, gp_Pnt p2);
|
||||
static bool gp_PntCompare(gp_Pnt p1, gp_Pnt p2);
|
||||
static bool gp_PntEqual(gp_Pnt p1, gp_Pnt p2);
|
||||
static bool gp_PntCompare(gp_Pnt p1, gp_Pnt p2);
|
||||
|
||||
protected:
|
||||
void exportCircle(BRepAdaptor_Curve& c);
|
||||
void exportEllipse(BRepAdaptor_Curve& c);
|
||||
void exportArc(BRepAdaptor_Curve& c);
|
||||
void exportEllipseArc(BRepAdaptor_Curve& c);
|
||||
void exportBSpline(BRepAdaptor_Curve& c);
|
||||
void exportBCurve(BRepAdaptor_Curve& c);
|
||||
void exportLine(BRepAdaptor_Curve& c);
|
||||
void exportLWPoly(BRepAdaptor_Curve& c); //LWPolyline not supported in R12?
|
||||
void exportPolyline(BRepAdaptor_Curve& c);
|
||||
protected:
|
||||
void exportCircle(BRepAdaptor_Curve& c);
|
||||
void exportEllipse(BRepAdaptor_Curve& c);
|
||||
void exportArc(BRepAdaptor_Curve& c);
|
||||
void exportEllipseArc(BRepAdaptor_Curve& c);
|
||||
void exportBSpline(BRepAdaptor_Curve& c);
|
||||
void exportBCurve(BRepAdaptor_Curve& c);
|
||||
void exportLine(BRepAdaptor_Curve& c);
|
||||
void exportLWPoly(BRepAdaptor_Curve& c);// LWPolyline not supported in R12?
|
||||
void exportPolyline(BRepAdaptor_Curve& c);
|
||||
|
||||
// std::string m_optionSource;
|
||||
double optionMaxLength;
|
||||
bool optionPolyLine;
|
||||
bool optionExpPoints;
|
||||
};
|
||||
// std::string m_optionSource;
|
||||
double optionMaxLength;
|
||||
bool optionPolyLine;
|
||||
bool optionExpPoints;
|
||||
};
|
||||
|
||||
}
|
||||
}// namespace Import
|
||||
|
||||
#endif // IMPEXPDXF_H
|
||||
#endif// IMPEXPDXF_H
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,12 +21,11 @@
|
||||
#include <Mod/Import/ImportGlobal.h>
|
||||
|
||||
|
||||
|
||||
typedef int ColorIndex_t; // DXF color index
|
||||
typedef int ColorIndex_t;// DXF color index
|
||||
|
||||
typedef enum
|
||||
{
|
||||
eUnspecified = 0, // Unspecified (No units)
|
||||
eUnspecified = 0,// Unspecified (No units)
|
||||
eInches,
|
||||
eFeet,
|
||||
eMiles,
|
||||
@@ -50,7 +49,7 @@ typedef enum
|
||||
} eDxfUnits_t;
|
||||
|
||||
|
||||
//spline data for reading
|
||||
// spline data for reading
|
||||
struct SplineData
|
||||
{
|
||||
double norm[3];
|
||||
@@ -76,8 +75,8 @@ struct SplineData
|
||||
};
|
||||
|
||||
//***************************
|
||||
//data structures for writing
|
||||
//added by Wandererfan 2018 (wandererfan@gmail.com) for FreeCAD project
|
||||
// data structures for writing
|
||||
// added by Wandererfan 2018 (wandererfan@gmail.com) for FreeCAD project
|
||||
struct point3D
|
||||
{
|
||||
double x;
|
||||
@@ -104,7 +103,7 @@ struct SplineDataOut
|
||||
struct LWPolyDataOut
|
||||
{
|
||||
double nVert;
|
||||
int Flag;
|
||||
int Flag;
|
||||
double Width;
|
||||
double Elev;
|
||||
double Thick;
|
||||
@@ -132,7 +131,8 @@ typedef enum
|
||||
} eDXFVersion_t;
|
||||
//********************
|
||||
|
||||
class CDxfWrite{
|
||||
class CDxfWrite
|
||||
{
|
||||
private:
|
||||
std::ofstream* m_ofs;
|
||||
bool m_fail;
|
||||
@@ -142,20 +142,32 @@ private:
|
||||
std::ostringstream* m_ssLayer;
|
||||
|
||||
protected:
|
||||
void putLine(const Base::Vector3d s, const Base::Vector3d e,
|
||||
std::ostringstream* outStream, const std::string handle,
|
||||
void putLine(const Base::Vector3d s,
|
||||
const Base::Vector3d e,
|
||||
std::ostringstream* outStream,
|
||||
const std::string handle,
|
||||
const std::string ownerHandle);
|
||||
void putText(const char* text, const Base::Vector3d location1, const Base::Vector3d location2,
|
||||
const double height, const int horizJust,
|
||||
std::ostringstream* outStream, const std::string handle,
|
||||
void putText(const char* text,
|
||||
const Base::Vector3d location1,
|
||||
const Base::Vector3d location2,
|
||||
const double height,
|
||||
const int horizJust,
|
||||
std::ostringstream* outStream,
|
||||
const std::string handle,
|
||||
const std::string ownerHandle);
|
||||
void putArrow(Base::Vector3d arrowPos, Base::Vector3d barb1Pos, Base::Vector3d barb2Pos,
|
||||
std::ostringstream* outStream, const std::string handle,
|
||||
void putArrow(Base::Vector3d arrowPos,
|
||||
Base::Vector3d barb1Pos,
|
||||
Base::Vector3d barb2Pos,
|
||||
std::ostringstream* outStream,
|
||||
const std::string handle,
|
||||
const std::string ownerHandle);
|
||||
|
||||
//! copy boiler plate file
|
||||
std::string getPlateFile(std::string fileSpec);
|
||||
void setDataDir(std::string s) { m_dataDir = s; }
|
||||
void setDataDir(std::string s)
|
||||
{
|
||||
m_dataDir = s;
|
||||
}
|
||||
std::string getHandle();
|
||||
std::string getEntityHandle();
|
||||
std::string getLayerHandle();
|
||||
@@ -170,7 +182,7 @@ protected:
|
||||
int m_blockHandle;
|
||||
int m_blkRecordHandle;
|
||||
bool m_polyOverride;
|
||||
|
||||
|
||||
std::string m_saveModelSpaceHandle;
|
||||
std::string m_savePaperSpaceHandle;
|
||||
std::string m_saveBlockRecordTableHandle;
|
||||
@@ -185,56 +197,93 @@ protected:
|
||||
public:
|
||||
ImportExport CDxfWrite(const char* filepath);
|
||||
ImportExport ~CDxfWrite();
|
||||
|
||||
|
||||
ImportExport void init();
|
||||
ImportExport void endRun();
|
||||
|
||||
ImportExport bool Failed(){return m_fail;}
|
||||
// void setOptions(void);
|
||||
// bool isVersionValid(int vers);
|
||||
ImportExport std::string getLayerName() { return m_layerName; }
|
||||
ImportExport bool Failed()
|
||||
{
|
||||
return m_fail;
|
||||
}
|
||||
// void setOptions(void);
|
||||
// bool isVersionValid(int vers);
|
||||
ImportExport std::string getLayerName()
|
||||
{
|
||||
return m_layerName;
|
||||
}
|
||||
ImportExport void setLayerName(std::string s);
|
||||
ImportExport void setVersion(int v) { m_version = v;}
|
||||
ImportExport void setPolyOverride(bool b) { m_polyOverride = b; }
|
||||
ImportExport void setVersion(int v)
|
||||
{
|
||||
m_version = v;
|
||||
}
|
||||
ImportExport void setPolyOverride(bool b)
|
||||
{
|
||||
m_polyOverride = b;
|
||||
}
|
||||
ImportExport void addBlockName(std::string s, std::string blkRecordHandle);
|
||||
|
||||
ImportExport void writeLine(const double* s, const double* e);
|
||||
ImportExport void writePoint(const double*);
|
||||
ImportExport void writeArc(const double* s, const double* e, const double* c, bool dir);
|
||||
ImportExport void writeEllipse(const double* c, double major_radius, double minor_radius,
|
||||
double rotation, double start_angle, double end_angle, bool endIsCW);
|
||||
ImportExport void writeCircle(const double* c, double radius );
|
||||
ImportExport void writeSpline(const SplineDataOut &sd);
|
||||
ImportExport void writeLWPolyLine(const LWPolyDataOut &pd);
|
||||
ImportExport void writePolyline(const LWPolyDataOut &pd);
|
||||
ImportExport void writeEllipse(const double* c,
|
||||
double major_radius,
|
||||
double minor_radius,
|
||||
double rotation,
|
||||
double start_angle,
|
||||
double end_angle,
|
||||
bool endIsCW);
|
||||
ImportExport void writeCircle(const double* c, double radius);
|
||||
ImportExport void writeSpline(const SplineDataOut& sd);
|
||||
ImportExport void writeLWPolyLine(const LWPolyDataOut& pd);
|
||||
ImportExport void writePolyline(const LWPolyDataOut& pd);
|
||||
ImportExport void writeVertex(double x, double y, double z);
|
||||
ImportExport void writeText(const char* text, const double* location1, const double* location2,
|
||||
const double height, const int horizJust);
|
||||
ImportExport void writeLinearDim(const double* textMidPoint, const double* lineDefPoint,
|
||||
const double* extLine1, const double* extLine2,
|
||||
const char* dimText, int type);
|
||||
ImportExport void writeLinearDimBlock(const double* textMidPoint, const double* lineDefPoint,
|
||||
const double* extLine1, const double* extLine2,
|
||||
const char* dimText, int type);
|
||||
ImportExport void writeAngularDim(const double* textMidPoint, const double* lineDefPoint,
|
||||
const double* startExt1, const double* endExt1,
|
||||
const double* startExt2, const double* endExt2,
|
||||
const char* dimText);
|
||||
ImportExport void writeAngularDimBlock(const double* textMidPoint, const double* lineDefPoint,
|
||||
const double* startExt1, const double* endExt1,
|
||||
const double* startExt2, const double* endExt2,
|
||||
const char* dimText);
|
||||
ImportExport void writeRadialDim(const double* centerPoint, const double* textMidPoint,
|
||||
const double* arcPoint,
|
||||
const char* dimText);
|
||||
ImportExport void writeRadialDimBlock(const double* centerPoint, const double* textMidPoint,
|
||||
const double* arcPoint, const char* dimText);
|
||||
ImportExport void writeText(const char* text,
|
||||
const double* location1,
|
||||
const double* location2,
|
||||
const double height,
|
||||
const int horizJust);
|
||||
ImportExport void writeLinearDim(const double* textMidPoint,
|
||||
const double* lineDefPoint,
|
||||
const double* extLine1,
|
||||
const double* extLine2,
|
||||
const char* dimText,
|
||||
int type);
|
||||
ImportExport void writeLinearDimBlock(const double* textMidPoint,
|
||||
const double* lineDefPoint,
|
||||
const double* extLine1,
|
||||
const double* extLine2,
|
||||
const char* dimText,
|
||||
int type);
|
||||
ImportExport void writeAngularDim(const double* textMidPoint,
|
||||
const double* lineDefPoint,
|
||||
const double* startExt1,
|
||||
const double* endExt1,
|
||||
const double* startExt2,
|
||||
const double* endExt2,
|
||||
const char* dimText);
|
||||
ImportExport void writeAngularDimBlock(const double* textMidPoint,
|
||||
const double* lineDefPoint,
|
||||
const double* startExt1,
|
||||
const double* endExt1,
|
||||
const double* startExt2,
|
||||
const double* endExt2,
|
||||
const char* dimText);
|
||||
ImportExport void writeRadialDim(const double* centerPoint,
|
||||
const double* textMidPoint,
|
||||
const double* arcPoint,
|
||||
const char* dimText);
|
||||
ImportExport void writeRadialDimBlock(const double* centerPoint,
|
||||
const double* textMidPoint,
|
||||
const double* arcPoint,
|
||||
const char* dimText);
|
||||
ImportExport void writeDiametricDim(const double* textMidPoint,
|
||||
const double* arcPoint1, const double* arcPoint2,
|
||||
const char* dimText);
|
||||
const double* arcPoint1,
|
||||
const double* arcPoint2,
|
||||
const char* dimText);
|
||||
ImportExport void writeDiametricDimBlock(const double* textMidPoint,
|
||||
const double* arcPoint1, const double* arcPoint2,
|
||||
const char* dimText);
|
||||
const double* arcPoint1,
|
||||
const double* arcPoint2,
|
||||
const char* dimText);
|
||||
|
||||
ImportExport void writeDimBlockPreamble();
|
||||
ImportExport void writeBlockTrailer();
|
||||
@@ -253,7 +302,8 @@ public:
|
||||
};
|
||||
|
||||
// derive a class from this and implement it's virtual functions
|
||||
class CDxfRead{
|
||||
class CDxfRead
|
||||
{
|
||||
private:
|
||||
std::ifstream* m_ifs;
|
||||
|
||||
@@ -268,7 +318,8 @@ private:
|
||||
bool m_ignore_errors;
|
||||
|
||||
|
||||
std::map<std::string,ColorIndex_t> m_layer_ColorIndex_map; // Mapping from layer name -> layer color index
|
||||
std::map<std::string, ColorIndex_t>
|
||||
m_layer_ColorIndex_map;// Mapping from layer name -> layer color index
|
||||
const ColorIndex_t ColorBylayer = 256;
|
||||
const ColorIndex_t ColorByBlock = 0;
|
||||
|
||||
@@ -283,10 +334,19 @@ private:
|
||||
bool ReadSpline();
|
||||
bool ReadLwPolyLine();
|
||||
bool ReadPolyLine();
|
||||
bool ReadVertex(double *pVertex, bool *bulge_found, double *bulge);
|
||||
void OnReadArc(double start_angle, double end_angle, double radius, const double* c, double z_extrusion_dir, bool hidden);
|
||||
bool ReadVertex(double* pVertex, bool* bulge_found, double* bulge);
|
||||
void OnReadArc(double start_angle,
|
||||
double end_angle,
|
||||
double radius,
|
||||
const double* c,
|
||||
double z_extrusion_dir,
|
||||
bool hidden);
|
||||
void OnReadCircle(const double* c, double radius, bool hidden);
|
||||
void OnReadEllipse(const double* c, const double* m, double ratio, double start_angle, double end_angle);
|
||||
void OnReadEllipse(const double* c,
|
||||
const double* m,
|
||||
double ratio,
|
||||
double start_angle,
|
||||
double end_angle);
|
||||
bool ReadInsert();
|
||||
bool ReadDimension();
|
||||
bool ReadBlockInfo();
|
||||
@@ -295,7 +355,7 @@ private:
|
||||
bool ResolveEncoding();
|
||||
|
||||
void get_line();
|
||||
void put_line(const char *value);
|
||||
void put_line(const char* value);
|
||||
void ResolveColorIndex();
|
||||
|
||||
protected:
|
||||
@@ -304,35 +364,70 @@ protected:
|
||||
const char* (CDxfRead::*stringToUTF8)(const char*) const;
|
||||
|
||||
private:
|
||||
const std::string* m_CodePage; // Code Page name from $DWGCODEPAGE or null if none/not read yet
|
||||
// The following was going to be python's canonical name for the encoding, but this is (a) not easily found and (b) does not speed up finding the encoding object.
|
||||
const std::string* m_CodePage;// Code Page name from $DWGCODEPAGE or null if none/not read yet
|
||||
// The following was going to be python's canonical name for the encoding, but this is (a) not
|
||||
// easily found and (b) does not speed up finding the encoding object.
|
||||
const std::string* m_encoding;// A name for the encoding implied by m_version and m_CodePage
|
||||
const char* UTF8ToUTF8(const char* encoded) const;
|
||||
const char* GeneralToUTF8(const char* encoded) const;
|
||||
|
||||
public:
|
||||
ImportExport CDxfRead(const char* filepath); // this opens the file
|
||||
ImportExport virtual ~CDxfRead(); // this closes the file
|
||||
ImportExport CDxfRead(const char* filepath);// this opens the file
|
||||
ImportExport virtual ~CDxfRead(); // this closes the file
|
||||
|
||||
ImportExport bool Failed(){return m_fail;}
|
||||
ImportExport void DoRead(const bool ignore_errors = false); // this reads the file and calls the following functions
|
||||
ImportExport bool Failed()
|
||||
{
|
||||
return m_fail;
|
||||
}
|
||||
ImportExport void DoRead(
|
||||
const bool ignore_errors = false);// this reads the file and calls the following functions
|
||||
|
||||
ImportExport double mm( double value ) const;
|
||||
ImportExport double mm(double value) const;
|
||||
|
||||
ImportExport bool IgnoreErrors() const { return(m_ignore_errors); }
|
||||
ImportExport bool IgnoreErrors() const
|
||||
{
|
||||
return (m_ignore_errors);
|
||||
}
|
||||
|
||||
ImportExport virtual void OnReadLine(const double* /*s*/, const double* /*e*/, bool /*hidden*/){}
|
||||
ImportExport virtual void OnReadPoint(const double* /*s*/){}
|
||||
ImportExport virtual void OnReadText(const double* /*point*/, const double /*height*/, const char* /*text*/){}
|
||||
ImportExport virtual void OnReadArc(const double* /*s*/, const double* /*e*/, const double* /*c*/, bool /*dir*/, bool /*hidden*/){}
|
||||
ImportExport virtual void OnReadCircle(const double* /*s*/, const double* /*c*/, bool /*dir*/, bool /*hidden*/){}
|
||||
ImportExport virtual void OnReadEllipse(const double* /*c*/, double /*major_radius*/, double /*minor_radius*/, double /*rotation*/, double /*start_angle*/, double /*end_angle*/, bool /*dir*/){}
|
||||
ImportExport virtual void OnReadSpline(struct SplineData& /*sd*/){}
|
||||
ImportExport virtual void OnReadInsert(const double* /*point*/, const double* /*scale*/, const char* /*name*/, double /*rotation*/){}
|
||||
ImportExport virtual void OnReadDimension(const double* /*s*/, const double* /*e*/, const double* /*point*/, double /*rotation*/){}
|
||||
ImportExport virtual void AddGraphics() const { }
|
||||
ImportExport virtual void OnReadLine(const double* /*s*/, const double* /*e*/, bool /*hidden*/)
|
||||
{}
|
||||
ImportExport virtual void OnReadPoint(const double* /*s*/)
|
||||
{}
|
||||
ImportExport virtual void
|
||||
OnReadText(const double* /*point*/, const double /*height*/, const char* /*text*/)
|
||||
{}
|
||||
ImportExport virtual void OnReadArc(const double* /*s*/,
|
||||
const double* /*e*/,
|
||||
const double* /*c*/,
|
||||
bool /*dir*/,
|
||||
bool /*hidden*/)
|
||||
{}
|
||||
ImportExport virtual void
|
||||
OnReadCircle(const double* /*s*/, const double* /*c*/, bool /*dir*/, bool /*hidden*/)
|
||||
{}
|
||||
ImportExport virtual void OnReadEllipse(const double* /*c*/,
|
||||
double /*major_radius*/,
|
||||
double /*minor_radius*/,
|
||||
double /*rotation*/,
|
||||
double /*start_angle*/,
|
||||
double /*end_angle*/,
|
||||
bool /*dir*/)
|
||||
{}
|
||||
ImportExport virtual void OnReadSpline(struct SplineData& /*sd*/)
|
||||
{}
|
||||
ImportExport virtual void OnReadInsert(const double* /*point*/,
|
||||
const double* /*scale*/,
|
||||
const char* /*name*/,
|
||||
double /*rotation*/)
|
||||
{}
|
||||
ImportExport virtual void OnReadDimension(const double* /*s*/,
|
||||
const double* /*e*/,
|
||||
const double* /*point*/,
|
||||
double /*rotation*/)
|
||||
{}
|
||||
ImportExport virtual void AddGraphics() const
|
||||
{}
|
||||
|
||||
ImportExport std::string LayerName() const;
|
||||
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -10,12 +10,12 @@
|
||||
* for detail see the LICENCE text file. *
|
||||
* *
|
||||
* FreeCAD is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with FreeCAD; if not, write to the Free Software *
|
||||
* License along with FreeCAD; if not, write to the Free Software *
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
* USA *
|
||||
* *
|
||||
@@ -35,7 +35,8 @@
|
||||
void CreateImportCommands();
|
||||
|
||||
|
||||
namespace ImportGui {
|
||||
namespace ImportGui
|
||||
{
|
||||
extern PyObject* initModule();
|
||||
}
|
||||
|
||||
@@ -49,7 +50,7 @@ PyMOD_INIT_FUNC(ImportGui)
|
||||
try {
|
||||
Base::Interpreter().loadModule("PartGui");
|
||||
}
|
||||
catch(const Base::Exception& e) {
|
||||
catch (const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
PyMOD_Return(nullptr);
|
||||
}
|
||||
|
||||
@@ -22,77 +22,77 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#if defined(__MINGW32__)
|
||||
# define WNT // avoid conflict with GUID
|
||||
#define WNT// avoid conflict with GUID
|
||||
#endif
|
||||
#ifndef _PreComp_
|
||||
# include <climits>
|
||||
# include <iostream>
|
||||
#include <climits>
|
||||
#include <iostream>
|
||||
|
||||
# include <QApplication>
|
||||
# include <QDialog>
|
||||
# include <QDialogButtonBox>
|
||||
# include <QHBoxLayout>
|
||||
# include <QPointer>
|
||||
# include <QString>
|
||||
# include <QStyle>
|
||||
# include <QTreeWidget>
|
||||
# include <QTreeWidgetItem>
|
||||
# include <QTextStream>
|
||||
# include <QVBoxLayout>
|
||||
#include <QApplication>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
#include <QStyle>
|
||||
#include <QTextStream>
|
||||
#include <QTreeWidget>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#if defined(__clang__)
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Wextra-semi"
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wextra-semi"
|
||||
#endif
|
||||
|
||||
# include <APIHeaderSection_MakeHeader.hxx>
|
||||
# include <IGESCAFControl_Reader.hxx>
|
||||
# include <IGESCAFControl_Writer.hxx>
|
||||
# include <IGESControl_Controller.hxx>
|
||||
# include <IGESData_GlobalSection.hxx>
|
||||
# include <IGESData_IGESModel.hxx>
|
||||
# include <IGESToBRep_Actor.hxx>
|
||||
# include <Interface_Static.hxx>
|
||||
# include <OSD_Exception.hxx>
|
||||
# include <Standard_Version.hxx>
|
||||
# include <STEPCAFControl_Reader.hxx>
|
||||
# include <STEPCAFControl_Writer.hxx>
|
||||
# include <TColStd_IndexedDataMapOfStringString.hxx>
|
||||
# include <TDataStd.hxx>
|
||||
# include <TDataStd_Integer.hxx>
|
||||
# include <TDataStd_Name.hxx>
|
||||
# include <TDataStd_TreeNode.hxx>
|
||||
# include <TDataXtd_Shape.hxx>
|
||||
# include <TDF_AttributeIterator.hxx>
|
||||
# include <TDF_ChildIterator.hxx>
|
||||
# include <TDF_ChildIDIterator.hxx>
|
||||
# include <TDF_IDList.hxx>
|
||||
# include <TDF_Label.hxx>
|
||||
# include <TDF_ListIteratorOfIDList.hxx>
|
||||
# include <TDF_TagSource.hxx>
|
||||
# include <TDocStd_Document.hxx>
|
||||
# include <TDocStd_Owner.hxx>
|
||||
# include <TNaming_NamedShape.hxx>
|
||||
# include <TNaming_UsedShapes.hxx>
|
||||
# include <Transfer_TransientProcess.hxx>
|
||||
# include <XCAFApp_Application.hxx>
|
||||
# include <XCAFDoc_Color.hxx>
|
||||
# include <XCAFDoc_ColorTool.hxx>
|
||||
# include <XCAFDoc_DocumentTool.hxx>
|
||||
# include <XCAFDoc_LayerTool.hxx>
|
||||
# include <XCAFDoc_Location.hxx>
|
||||
# include <XCAFDoc_ShapeMapTool.hxx>
|
||||
# include <XCAFDoc_ShapeTool.hxx>
|
||||
# include <XSControl_TransferReader.hxx>
|
||||
# include <XSControl_WorkSession.hxx>
|
||||
#include <APIHeaderSection_MakeHeader.hxx>
|
||||
#include <IGESCAFControl_Reader.hxx>
|
||||
#include <IGESCAFControl_Writer.hxx>
|
||||
#include <IGESControl_Controller.hxx>
|
||||
#include <IGESData_GlobalSection.hxx>
|
||||
#include <IGESData_IGESModel.hxx>
|
||||
#include <IGESToBRep_Actor.hxx>
|
||||
#include <Interface_Static.hxx>
|
||||
#include <OSD_Exception.hxx>
|
||||
#include <STEPCAFControl_Reader.hxx>
|
||||
#include <STEPCAFControl_Writer.hxx>
|
||||
#include <Standard_Version.hxx>
|
||||
#include <TColStd_IndexedDataMapOfStringString.hxx>
|
||||
#include <TDF_AttributeIterator.hxx>
|
||||
#include <TDF_ChildIDIterator.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDF_IDList.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_ListIteratorOfIDList.hxx>
|
||||
#include <TDF_TagSource.hxx>
|
||||
#include <TDataStd.hxx>
|
||||
#include <TDataStd_Integer.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <TDataXtd_Shape.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
#include <TDocStd_Owner.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <TNaming_UsedShapes.hxx>
|
||||
#include <Transfer_TransientProcess.hxx>
|
||||
#include <XCAFApp_Application.hxx>
|
||||
#include <XCAFDoc_Color.hxx>
|
||||
#include <XCAFDoc_ColorTool.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_LayerTool.hxx>
|
||||
#include <XCAFDoc_Location.hxx>
|
||||
#include <XCAFDoc_ShapeMapTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
#include <XSControl_TransferReader.hxx>
|
||||
#include <XSControl_WorkSession.hxx>
|
||||
|
||||
# if OCC_VERSION_HEX >= 0x070500
|
||||
# include <Message_ProgressRange.hxx>
|
||||
# include <RWGltf_CafWriter.hxx>
|
||||
# endif
|
||||
# if defined(__clang__)
|
||||
# pragma clang diagnostic pop
|
||||
# endif
|
||||
#if OCC_VERSION_HEX >= 0x070500
|
||||
#include <Message_ProgressRange.hxx>
|
||||
#include <RWGltf_CafWriter.hxx>
|
||||
#endif
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
@@ -105,19 +105,20 @@
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/ViewProviderLink.h>
|
||||
#include <Mod/Import/App/ImportOCAF2.h>
|
||||
#include <Mod/Part/Gui/ViewProvider.h>
|
||||
#include <Mod/Part/App/OCAF/ImportExportSettings.h>
|
||||
#include <Mod/Part/App/encodeFilename.h>
|
||||
#include <Mod/Part/App/ImportIges.h>
|
||||
#include <Mod/Part/App/ImportStep.h>
|
||||
#include <Mod/Part/App/Interface.h>
|
||||
#include <Mod/Part/App/OCAF/ImportExportSettings.h>
|
||||
#include <Mod/Part/App/ProgressIndicator.h>
|
||||
#include <Mod/Part/App/encodeFilename.h>
|
||||
#include <Mod/Part/Gui/DlgExportStep.h>
|
||||
#include <Mod/Part/Gui/ViewProvider.h>
|
||||
|
||||
|
||||
FC_LOG_LEVEL_INIT("Import", true, true)
|
||||
|
||||
namespace ImportGui {
|
||||
namespace ImportGui
|
||||
{
|
||||
class OCAFBrowser
|
||||
{
|
||||
public:
|
||||
@@ -146,10 +147,10 @@ private:
|
||||
void load(const TDF_Label& label, QTreeWidgetItem* item, const QString&);
|
||||
std::string toString(const TCollection_ExtendedString& extstr) const
|
||||
{
|
||||
char* str = new char[extstr.LengthOfCString()+1];
|
||||
char* str = new char[extstr.LengthOfCString() + 1];
|
||||
extstr.ToUTF8CString(str);
|
||||
std::string text(str);
|
||||
delete [] str;
|
||||
delete[] str;
|
||||
return text;
|
||||
}
|
||||
|
||||
@@ -176,15 +177,16 @@ void OCAFBrowser::load(const TDF_Label& label, QTreeWidgetItem* item, const QStr
|
||||
label.Dump(std::cout);
|
||||
|
||||
Handle(TDataStd_Name) name;
|
||||
if (label.FindAttribute(TDataStd_Name::GetID(),name)) {
|
||||
QString text = QString::fromLatin1("%1 %2").arg(s, QString::fromUtf8(toString(name->Get()).c_str()));
|
||||
if (label.FindAttribute(TDataStd_Name::GetID(), name)) {
|
||||
QString text =
|
||||
QString::fromLatin1("%1 %2").arg(s, QString::fromUtf8(toString(name->Get()).c_str()));
|
||||
item->setText(0, text);
|
||||
}
|
||||
|
||||
|
||||
TDF_IDList localList;
|
||||
TDF_AttributeIterator itr (label);
|
||||
for ( ; itr.More(); itr.Next()) {
|
||||
TDF_AttributeIterator itr(label);
|
||||
for (; itr.More(); itr.Next()) {
|
||||
localList.Append(itr.Value()->ID());
|
||||
}
|
||||
|
||||
@@ -221,33 +223,33 @@ void OCAFBrowser::load(const TDF_Label& label, QTreeWidgetItem* item, const QStr
|
||||
str << attr->DynamicType()->Name() << " = ";
|
||||
if (!shape.IsNull()) {
|
||||
switch (shape.ShapeType()) {
|
||||
case TopAbs_COMPOUND:
|
||||
str << "COMPOUND PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_COMPSOLID:
|
||||
str << "COMPSOLID PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_SOLID:
|
||||
str << "SOLID PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_SHELL:
|
||||
str << "SHELL PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_FACE:
|
||||
str << "FACE PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_WIRE:
|
||||
str << "WIRE PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_EDGE:
|
||||
str << "EDGE PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_VERTEX:
|
||||
str << "VERTEX PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_SHAPE:
|
||||
str << "SHAPE PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_COMPOUND:
|
||||
str << "COMPOUND PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_COMPSOLID:
|
||||
str << "COMPSOLID PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_SOLID:
|
||||
str << "SOLID PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_SHELL:
|
||||
str << "SHELL PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_FACE:
|
||||
str << "FACE PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_WIRE:
|
||||
str << "WIRE PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_EDGE:
|
||||
str << "EDGE PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_VERTEX:
|
||||
str << "VERTEX PRIMITIVE";
|
||||
break;
|
||||
case TopAbs_SHAPE:
|
||||
str << "SHAPE PRIMITIVE";
|
||||
break;
|
||||
}
|
||||
}
|
||||
child->setText(0, text);
|
||||
@@ -259,8 +261,8 @@ void OCAFBrowser::load(const TDF_Label& label, QTreeWidgetItem* item, const QStr
|
||||
}
|
||||
|
||||
|
||||
int i=1;
|
||||
for (TDF_ChildIterator it(label); it.More(); it.Next(),i++) {
|
||||
int i = 1;
|
||||
for (TDF_ChildIterator it(label); it.More(); it.Next(), i++) {
|
||||
QString text = QString::fromLatin1("%1:%2").arg(s).arg(i);
|
||||
QTreeWidgetItem* child = new QTreeWidgetItem();
|
||||
child->setText(0, text);
|
||||
@@ -270,24 +272,26 @@ void OCAFBrowser::load(const TDF_Label& label, QTreeWidgetItem* item, const QStr
|
||||
}
|
||||
}
|
||||
|
||||
class ImportOCAFExt : public Import::ImportOCAF2
|
||||
class ImportOCAFExt: public Import::ImportOCAF2
|
||||
{
|
||||
public:
|
||||
ImportOCAFExt(Handle(TDocStd_Document) h, App::Document* d, const std::string& name)
|
||||
: ImportOCAF2(h, d, name)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
private:
|
||||
void applyFaceColors(Part::Feature* part, const std::vector<App::Color>& colors) override {
|
||||
auto vp = dynamic_cast<PartGui::ViewProviderPartExt*>(Gui::Application::Instance->getViewProvider(part));
|
||||
if (!vp)
|
||||
void applyFaceColors(Part::Feature* part, const std::vector<App::Color>& colors) override
|
||||
{
|
||||
auto vp = dynamic_cast<PartGui::ViewProviderPartExt*>(
|
||||
Gui::Application::Instance->getViewProvider(part));
|
||||
if (!vp) {
|
||||
return;
|
||||
if(colors.empty()) {
|
||||
}
|
||||
if (colors.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(colors.size() == 1) {
|
||||
if (colors.size() == 1) {
|
||||
vp->ShapeColor.setValue(colors.front());
|
||||
vp->Transparency.setValue(100 * colors.front().a);
|
||||
}
|
||||
@@ -295,99 +299,120 @@ private:
|
||||
vp->DiffuseColor.setValues(colors);
|
||||
}
|
||||
}
|
||||
void applyEdgeColors(Part::Feature* part, const std::vector<App::Color>& colors) override {
|
||||
auto vp = dynamic_cast<PartGui::ViewProviderPartExt*>(Gui::Application::Instance->getViewProvider(part));
|
||||
if (!vp)
|
||||
void applyEdgeColors(Part::Feature* part, const std::vector<App::Color>& colors) override
|
||||
{
|
||||
auto vp = dynamic_cast<PartGui::ViewProviderPartExt*>(
|
||||
Gui::Application::Instance->getViewProvider(part));
|
||||
if (!vp) {
|
||||
return;
|
||||
if(colors.size() == 1)
|
||||
}
|
||||
if (colors.size() == 1) {
|
||||
vp->LineColor.setValue(colors.front());
|
||||
else
|
||||
}
|
||||
else {
|
||||
vp->LineColorArray.setValues(colors);
|
||||
}
|
||||
}
|
||||
void applyLinkColor(App::DocumentObject *obj, int index, App::Color color) override {
|
||||
auto vp = dynamic_cast<Gui::ViewProviderLink*>(Gui::Application::Instance->getViewProvider(obj));
|
||||
if(!vp)
|
||||
void applyLinkColor(App::DocumentObject* obj, int index, App::Color color) override
|
||||
{
|
||||
auto vp =
|
||||
dynamic_cast<Gui::ViewProviderLink*>(Gui::Application::Instance->getViewProvider(obj));
|
||||
if (!vp) {
|
||||
return;
|
||||
if(index<0) {
|
||||
}
|
||||
if (index < 0) {
|
||||
vp->OverrideMaterial.setValue(true);
|
||||
vp->ShapeMaterial.setDiffuseColor(color);
|
||||
return;
|
||||
}
|
||||
if(vp->OverrideMaterialList.getSize()<=index)
|
||||
vp->OverrideMaterialList.setSize(index+1);
|
||||
vp->OverrideMaterialList.set1Value(index,true);
|
||||
if (vp->OverrideMaterialList.getSize() <= index) {
|
||||
vp->OverrideMaterialList.setSize(index + 1);
|
||||
}
|
||||
vp->OverrideMaterialList.set1Value(index, true);
|
||||
App::Material mat(App::Material::DEFAULT);
|
||||
if(vp->MaterialList.getSize()<=index)
|
||||
vp->MaterialList.setSize(index+1,mat);
|
||||
if (vp->MaterialList.getSize() <= index) {
|
||||
vp->MaterialList.setSize(index + 1, mat);
|
||||
}
|
||||
mat.diffuseColor = color;
|
||||
vp->MaterialList.set1Value(index,mat);
|
||||
vp->MaterialList.set1Value(index, mat);
|
||||
}
|
||||
void applyElementColors(App::DocumentObject *obj,
|
||||
const std::map<std::string,App::Color> &colors) override
|
||||
void applyElementColors(App::DocumentObject* obj,
|
||||
const std::map<std::string, App::Color>& colors) override
|
||||
{
|
||||
auto vp = Gui::Application::Instance->getViewProvider(obj);
|
||||
if(!vp)
|
||||
if (!vp) {
|
||||
return;
|
||||
}
|
||||
(void)colors;
|
||||
}
|
||||
};
|
||||
|
||||
class ExportOCAFGui : public Import::ExportOCAF
|
||||
class ExportOCAFGui: public Import::ExportOCAF
|
||||
{
|
||||
public:
|
||||
ExportOCAFGui(Handle(TDocStd_Document) h, bool explicitPlacement)
|
||||
: ExportOCAF(h, explicitPlacement)
|
||||
{
|
||||
}
|
||||
{}
|
||||
void findColors(Part::Feature* part, std::vector<App::Color>& colors) const override
|
||||
{
|
||||
Gui::ViewProvider* vp = Gui::Application::Instance->getViewProvider(part);
|
||||
if (vp && vp->isDerivedFrom(PartGui::ViewProviderPartExt::getClassTypeId())) {
|
||||
colors = static_cast<PartGui::ViewProviderPartExt*>(vp)->DiffuseColor.getValues();
|
||||
if (colors.empty())
|
||||
colors.push_back(static_cast<PartGui::ViewProviderPart*>(vp)->ShapeColor.getValue());
|
||||
if (colors.empty()) {
|
||||
colors.push_back(
|
||||
static_cast<PartGui::ViewProviderPart*>(vp)->ShapeColor.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
class Module: public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("ImportGui")
|
||||
Module()
|
||||
: Py::ExtensionModule<Module>("ImportGui")
|
||||
{
|
||||
add_keyword_method("open",&Module::insert,
|
||||
"open(string) -- Open the file and create a new document."
|
||||
);
|
||||
add_keyword_method("insert",&Module::insert,
|
||||
"insert(string,string) -- Insert the file into the given document."
|
||||
);
|
||||
add_varargs_method("exportOptions",&Module::exportOptions,
|
||||
"exportOptions(string) -- Return the export options of a file type."
|
||||
);
|
||||
add_keyword_method("export",&Module::exporter,
|
||||
"export(list,string) -- Export a list of objects into a single file."
|
||||
);
|
||||
add_varargs_method("ocaf",&Module::ocaf,
|
||||
"ocaf(string) -- Browse the ocaf structure."
|
||||
);
|
||||
initialize("This module is the ImportGui module."); // register with Python
|
||||
add_keyword_method("open",
|
||||
&Module::insert,
|
||||
"open(string) -- Open the file and create a new document.");
|
||||
add_keyword_method("insert",
|
||||
&Module::insert,
|
||||
"insert(string,string) -- Insert the file into the given document.");
|
||||
add_varargs_method("exportOptions",
|
||||
&Module::exportOptions,
|
||||
"exportOptions(string) -- Return the export options of a file type.");
|
||||
add_keyword_method("export",
|
||||
&Module::exporter,
|
||||
"export(list,string) -- Export a list of objects into a single file.");
|
||||
add_varargs_method("ocaf", &Module::ocaf, "ocaf(string) -- Browse the ocaf structure.");
|
||||
initialize("This module is the ImportGui module.");// register with Python
|
||||
}
|
||||
|
||||
private:
|
||||
Py::Object insert(const Py::Tuple& args, const Py::Dict &kwds)
|
||||
Py::Object insert(const Py::Tuple& args, const Py::Dict& kwds)
|
||||
{
|
||||
char* Name;
|
||||
char* DocName=nullptr;
|
||||
PyObject *importHidden = Py_None;
|
||||
PyObject *merge = Py_None;
|
||||
PyObject *useLinkGroup = Py_None;
|
||||
char* DocName = nullptr;
|
||||
PyObject* importHidden = Py_None;
|
||||
PyObject* merge = Py_None;
|
||||
PyObject* useLinkGroup = Py_None;
|
||||
int mode = -1;
|
||||
static const std::array<const char *, 7> kwd_list{"name", "docName", "importHidden", "merge", "useLinkGroup",
|
||||
"mode", nullptr};
|
||||
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "et|sO!O!O!i",
|
||||
kwd_list, "utf-8", &Name, &DocName, &PyBool_Type, &importHidden,
|
||||
&PyBool_Type, &merge,
|
||||
&PyBool_Type, &useLinkGroup, &mode)) {
|
||||
static const std::array<const char*, 7>
|
||||
kwd_list {"name", "docName", "importHidden", "merge", "useLinkGroup", "mode", nullptr};
|
||||
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
|
||||
kwds.ptr(),
|
||||
"et|sO!O!O!i",
|
||||
kwd_list,
|
||||
"utf-8",
|
||||
&Name,
|
||||
&DocName,
|
||||
&PyBool_Type,
|
||||
&importHidden,
|
||||
&PyBool_Type,
|
||||
&merge,
|
||||
&PyBool_Type,
|
||||
&useLinkGroup,
|
||||
&mode)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
@@ -398,7 +423,7 @@ private:
|
||||
try {
|
||||
Base::FileInfo file(Utf8Name.c_str());
|
||||
|
||||
App::Document *pcDoc = nullptr;
|
||||
App::Document* pcDoc = nullptr;
|
||||
if (DocName) {
|
||||
pcDoc = App::GetApplication().getDocument(DocName);
|
||||
}
|
||||
@@ -412,16 +437,18 @@ private:
|
||||
ImportOCAFExt ocaf(hDoc, pcDoc, file.fileNamePure());
|
||||
ocaf.setImportOptions(ImportOCAFExt::customImportOptions());
|
||||
FC_TIME_INIT(t);
|
||||
FC_DURATION_DECL_INIT2(d1,d2);
|
||||
FC_DURATION_DECL_INIT2(d1, d2);
|
||||
|
||||
if (file.hasExtension({"stp", "step"})) {
|
||||
|
||||
if(mode<0)
|
||||
if (mode < 0) {
|
||||
mode = ocaf.getMode();
|
||||
if(mode && !pcDoc->isSaved()) {
|
||||
}
|
||||
if (mode && !pcDoc->isSaved()) {
|
||||
auto gdoc = Gui::Application::Instance->getDocument(pcDoc);
|
||||
if(!gdoc->save())
|
||||
if (!gdoc->save()) {
|
||||
return Py::Object();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -449,20 +476,24 @@ private:
|
||||
Base::Console().Error("%s\n", e.GetMessageString());
|
||||
Base::Console().Message("Try to load STEP file without colors...\n");
|
||||
|
||||
Part::ImportStepParts(pcDoc,Utf8Name.c_str());
|
||||
Part::ImportStepParts(pcDoc, Utf8Name.c_str());
|
||||
pcDoc->recompute();
|
||||
}
|
||||
}
|
||||
else if (file.hasExtension({"igs", "iges"})) {
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("IGES");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/Part")
|
||||
->GetGroup("IGES");
|
||||
|
||||
try {
|
||||
IGESControl_Controller::Init();
|
||||
IGESCAFControl_Reader aReader;
|
||||
// http://www.opencascade.org/org/forum/thread_20603/?forum=3
|
||||
aReader.SetReadVisible(hGrp->GetBool("SkipBlankEntities", true)
|
||||
? Standard_True : Standard_False);
|
||||
aReader.SetReadVisible(
|
||||
hGrp->GetBool("SkipBlankEntities", true) ? Standard_True : Standard_False);
|
||||
aReader.SetColorMode(true);
|
||||
aReader.SetNameMode(true);
|
||||
aReader.SetLayerMode(true);
|
||||
@@ -482,13 +513,13 @@ private:
|
||||
#endif
|
||||
// http://opencascade.blogspot.de/2009/03/unnoticeable-memory-leaks-part-2.html
|
||||
Handle(IGESToBRep_Actor)::DownCast(aReader.WS()->TransferReader()->Actor())
|
||||
->SetModel(new IGESData_IGESModel);
|
||||
->SetModel(new IGESData_IGESModel);
|
||||
}
|
||||
catch (OSD_Exception& e) {
|
||||
Base::Console().Error("%s\n", e.GetMessageString());
|
||||
Base::Console().Message("Try to load IGES file without colors...\n");
|
||||
|
||||
Part::ImportIgesParts(pcDoc,Utf8Name.c_str());
|
||||
Part::ImportIgesParts(pcDoc, Utf8Name.c_str());
|
||||
pcDoc->recompute();
|
||||
}
|
||||
}
|
||||
@@ -496,25 +527,28 @@ private:
|
||||
throw Py::Exception(PyExc_IOError, "no supported file format");
|
||||
}
|
||||
|
||||
FC_DURATION_PLUS(d1,t);
|
||||
if (merge != Py_None)
|
||||
FC_DURATION_PLUS(d1, t);
|
||||
if (merge != Py_None) {
|
||||
ocaf.setMerge(Base::asBoolean(merge));
|
||||
if (importHidden != Py_None)
|
||||
}
|
||||
if (importHidden != Py_None) {
|
||||
ocaf.setImportHiddenObject(Base::asBoolean(importHidden));
|
||||
if (useLinkGroup != Py_None)
|
||||
}
|
||||
if (useLinkGroup != Py_None) {
|
||||
ocaf.setUseLinkGroup(Base::asBoolean(useLinkGroup));
|
||||
}
|
||||
ocaf.setMode(mode);
|
||||
auto ret = ocaf.loadShapes();
|
||||
hApp->Close(hDoc);
|
||||
FC_DURATION_PLUS(d2,t);
|
||||
FC_DURATION_LOG(d1,"file read");
|
||||
FC_DURATION_LOG(d2,"import");
|
||||
FC_DURATION_LOG((d1+d2),"total");
|
||||
FC_DURATION_PLUS(d2, t);
|
||||
FC_DURATION_LOG(d1, "file read");
|
||||
FC_DURATION_LOG(d2, "import");
|
||||
FC_DURATION_LOG((d1 + d2), "total");
|
||||
|
||||
if(ret) {
|
||||
if (ret) {
|
||||
App::GetApplication().setActiveDocument(pcDoc);
|
||||
auto gdoc = Gui::Application::Instance->getDocument(pcDoc);
|
||||
if(gdoc) {
|
||||
if (gdoc) {
|
||||
gdoc->setActiveView();
|
||||
Gui::Application::Instance->commandManager().runCommandByName("Std_ViewFitAll");
|
||||
}
|
||||
@@ -532,18 +566,22 @@ private:
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
static std::map<std::string, App::Color> getShapeColors(App::DocumentObject *obj, const char *subname) {
|
||||
static std::map<std::string, App::Color> getShapeColors(App::DocumentObject* obj,
|
||||
const char* subname)
|
||||
{
|
||||
auto vp = Gui::Application::Instance->getViewProvider(obj);
|
||||
if(vp)
|
||||
if (vp) {
|
||||
return vp->getElementColors(subname);
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Py::Object exportOptions(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et", "utf-8", &Name))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et", "utf-8", &Name)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
std::string Utf8Name = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
@@ -565,23 +603,31 @@ private:
|
||||
return options;
|
||||
}
|
||||
|
||||
Py::Object exporter(const Py::Tuple& args, const Py::Dict &kwds)
|
||||
Py::Object exporter(const Py::Tuple& args, const Py::Dict& kwds)
|
||||
{
|
||||
PyObject* object;
|
||||
char* Name;
|
||||
PyObject *pyoptions = nullptr;
|
||||
PyObject *pyexportHidden = Py_None;
|
||||
PyObject *pylegacy = Py_None;
|
||||
PyObject *pykeepPlacement = Py_None;
|
||||
static const std::array<const char *, 7> kwd_list{"obj", "name", "options", "exportHidden", "legacy",
|
||||
"keepPlacement", nullptr};
|
||||
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "Oet|O!O!O!O!",
|
||||
kwd_list, &object,
|
||||
"utf-8", &Name,
|
||||
&PyDict_Type, &pyoptions,
|
||||
&PyBool_Type, &pyexportHidden,
|
||||
&PyBool_Type, &pylegacy,
|
||||
&PyBool_Type, &pykeepPlacement)) {
|
||||
PyObject* pyoptions = nullptr;
|
||||
PyObject* pyexportHidden = Py_None;
|
||||
PyObject* pylegacy = Py_None;
|
||||
PyObject* pykeepPlacement = Py_None;
|
||||
static const std::array<const char*, 7>
|
||||
kwd_list {"obj", "name", "options", "exportHidden", "legacy", "keepPlacement", nullptr};
|
||||
if (!Base::Wrapped_ParseTupleAndKeywords(args.ptr(),
|
||||
kwds.ptr(),
|
||||
"Oet|O!O!O!O!",
|
||||
kwd_list,
|
||||
&object,
|
||||
"utf-8",
|
||||
&Name,
|
||||
&PyDict_Type,
|
||||
&pyoptions,
|
||||
&PyBool_Type,
|
||||
&pyexportHidden,
|
||||
&PyBool_Type,
|
||||
&pylegacy,
|
||||
&PyBool_Type,
|
||||
&pykeepPlacement)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
@@ -593,9 +639,12 @@ private:
|
||||
Part::OCAF::ImportExportSettings settings;
|
||||
|
||||
// still support old way
|
||||
bool legacyExport = (pylegacy == Py_None ? settings.getExportLegacy() : Base::asBoolean(pylegacy));
|
||||
bool exportHidden = (pyexportHidden == Py_None ? settings.getExportHiddenObject() : Base::asBoolean(pyexportHidden));
|
||||
bool keepPlacement = (pykeepPlacement == Py_None ? settings.getExportKeepPlacement() : Base::asBoolean(pykeepPlacement));
|
||||
bool legacyExport =
|
||||
(pylegacy == Py_None ? settings.getExportLegacy() : Base::asBoolean(pylegacy));
|
||||
bool exportHidden = (pyexportHidden == Py_None ? settings.getExportHiddenObject()
|
||||
: Base::asBoolean(pyexportHidden));
|
||||
bool keepPlacement = (pykeepPlacement == Py_None ? settings.getExportKeepPlacement()
|
||||
: Base::asBoolean(pykeepPlacement));
|
||||
|
||||
// new way
|
||||
if (pyoptions) {
|
||||
@@ -617,11 +666,13 @@ private:
|
||||
Handle(TDocStd_Document) hDoc;
|
||||
hApp->NewDocument(TCollection_ExtendedString("MDTV-CAF"), hDoc);
|
||||
|
||||
std::vector<App::DocumentObject *> objs;
|
||||
std::vector<App::DocumentObject*> objs;
|
||||
for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) {
|
||||
PyObject* item = (*it).ptr();
|
||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type)))
|
||||
objs.push_back(static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr());
|
||||
if (PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
||||
objs.push_back(
|
||||
static_cast<App::DocumentObjectPy*>(item)->getDocumentObjectPtr());
|
||||
}
|
||||
}
|
||||
|
||||
Import::ExportOCAF2 ocaf(hDoc, &getShapeColors);
|
||||
@@ -636,32 +687,36 @@ private:
|
||||
bool keepExplicitPlacement = Standard_True;
|
||||
ExportOCAFGui ocaf(hDoc, keepExplicitPlacement);
|
||||
// That stuff is exporting a list of selected objects into FreeCAD Tree
|
||||
std::vector <TDF_Label> hierarchical_label;
|
||||
std::vector <TopLoc_Location> hierarchical_loc;
|
||||
std::vector <App::DocumentObject*> hierarchical_part;
|
||||
for(auto obj : objs)
|
||||
ocaf.exportObject(obj,hierarchical_label, hierarchical_loc,hierarchical_part);
|
||||
std::vector<TDF_Label> hierarchical_label;
|
||||
std::vector<TopLoc_Location> hierarchical_loc;
|
||||
std::vector<App::DocumentObject*> hierarchical_part;
|
||||
for (auto obj : objs) {
|
||||
ocaf.exportObject(obj, hierarchical_label, hierarchical_loc, hierarchical_part);
|
||||
}
|
||||
|
||||
// Free Shapes must have absolute placement and not explicit
|
||||
std::vector <TDF_Label> FreeLabels;
|
||||
std::vector <int> part_id;
|
||||
ocaf.getFreeLabels(hierarchical_label,FreeLabels, part_id);
|
||||
// Got issue with the colors as they are coming from the View Provider they can't be determined into
|
||||
// the App Code.
|
||||
std::vector< std::vector<App::Color> > Colors;
|
||||
ocaf.getPartColors(hierarchical_part,FreeLabels,part_id,Colors);
|
||||
ocaf.reallocateFreeShape(hierarchical_part,FreeLabels,part_id,Colors);
|
||||
std::vector<TDF_Label> FreeLabels;
|
||||
std::vector<int> part_id;
|
||||
ocaf.getFreeLabels(hierarchical_label, FreeLabels, part_id);
|
||||
// Got issue with the colors as they are coming from the View Provider they can't be
|
||||
// determined into the App Code.
|
||||
std::vector<std::vector<App::Color>> Colors;
|
||||
ocaf.getPartColors(hierarchical_part, FreeLabels, part_id, Colors);
|
||||
ocaf.reallocateFreeShape(hierarchical_part, FreeLabels, part_id, Colors);
|
||||
|
||||
XCAFDoc_DocumentTool::ShapeTool(hDoc->Main())->UpdateAssemblies();
|
||||
}
|
||||
|
||||
Base::FileInfo file(Utf8Name.c_str());
|
||||
if (file.hasExtension({"stp", "step"})) {
|
||||
ParameterGrp::handle hGrp_stp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part/STEP");
|
||||
std::string scheme = hGrp_stp->GetASCII("Scheme", Part::Interface::writeStepScheme());
|
||||
ParameterGrp::handle hGrp_stp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Part/STEP");
|
||||
std::string scheme =
|
||||
hGrp_stp->GetASCII("Scheme", Part::Interface::writeStepScheme());
|
||||
std::list<std::string> supported = Part::supportedSTEPSchemes();
|
||||
if (std::find(supported.begin(), supported.end(), scheme) != supported.end())
|
||||
if (std::find(supported.begin(), supported.end(), scheme) != supported.end()) {
|
||||
Part::Interface::writeStepScheme(scheme.c_str());
|
||||
}
|
||||
|
||||
STEPCAFControl_Writer writer;
|
||||
Part::Interface::writeStepAssembly(Part::Interface::Assembly::On);
|
||||
@@ -670,17 +725,27 @@ private:
|
||||
// edit STEP header
|
||||
APIHeaderSection_MakeHeader makeHeader(writer.ChangeWriter().Model());
|
||||
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("STEP");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/Part")
|
||||
->GetGroup("STEP");
|
||||
|
||||
// Don't set name because STEP doesn't support UTF-8
|
||||
// https://forum.freecad.org/viewtopic.php?f=8&t=52967
|
||||
makeHeader.SetAuthorValue (1, new TCollection_HAsciiString(hGrp->GetASCII("Author", "Author").c_str()));
|
||||
makeHeader.SetOrganizationValue (1, new TCollection_HAsciiString(hGrp->GetASCII("Company").c_str()));
|
||||
makeHeader.SetOriginatingSystem(new TCollection_HAsciiString(App::Application::getExecutableName().c_str()));
|
||||
makeHeader.SetAuthorValue(
|
||||
1,
|
||||
new TCollection_HAsciiString(hGrp->GetASCII("Author", "Author").c_str()));
|
||||
makeHeader.SetOrganizationValue(
|
||||
1,
|
||||
new TCollection_HAsciiString(hGrp->GetASCII("Company").c_str()));
|
||||
makeHeader.SetOriginatingSystem(
|
||||
new TCollection_HAsciiString(App::Application::getExecutableName().c_str()));
|
||||
makeHeader.SetDescriptionValue(1, new TCollection_HAsciiString("FreeCAD Model"));
|
||||
IFSelect_ReturnStatus ret = writer.Write(name8bit.c_str());
|
||||
if (ret == IFSelect_RetError || ret == IFSelect_RetFail || ret == IFSelect_RetStop) {
|
||||
if (ret == IFSelect_RetError || ret == IFSelect_RetFail
|
||||
|| ret == IFSelect_RetStop) {
|
||||
PyErr_Format(PyExc_IOError, "Cannot open file '%s'", Utf8Name.c_str());
|
||||
throw Py::Exception();
|
||||
}
|
||||
@@ -689,9 +754,12 @@ private:
|
||||
IGESControl_Controller::Init();
|
||||
IGESCAFControl_Writer writer;
|
||||
IGESData_GlobalSection header = writer.Model()->GlobalSection();
|
||||
header.SetAuthorName(new TCollection_HAsciiString(Part::Interface::writeIgesHeaderAuthor()));
|
||||
header.SetCompanyName(new TCollection_HAsciiString(Part::Interface::writeIgesHeaderCompany()));
|
||||
header.SetSendName(new TCollection_HAsciiString(Part::Interface::writeIgesHeaderProduct()));
|
||||
header.SetAuthorName(
|
||||
new TCollection_HAsciiString(Part::Interface::writeIgesHeaderAuthor()));
|
||||
header.SetCompanyName(
|
||||
new TCollection_HAsciiString(Part::Interface::writeIgesHeaderCompany()));
|
||||
header.SetSendName(
|
||||
new TCollection_HAsciiString(Part::Interface::writeIgesHeaderProduct()));
|
||||
writer.Model()->SetGlobalSection(header);
|
||||
writer.Transfer(hDoc);
|
||||
Standard_Boolean ret = writer.Write((const char*)name8bit.c_str());
|
||||
@@ -703,15 +771,16 @@ private:
|
||||
else if (file.hasExtension({"glb", "gltf"})) {
|
||||
#if OCC_VERSION_HEX >= 0x070500
|
||||
TColStd_IndexedDataMapOfStringString aMetadata;
|
||||
RWGltf_CafWriter aWriter (name8bit.c_str(), file.hasExtension("glb"));
|
||||
aWriter.SetTransformationFormat (RWGltf_WriterTrsfFormat_Compact);
|
||||
RWGltf_CafWriter aWriter(name8bit.c_str(), file.hasExtension("glb"));
|
||||
aWriter.SetTransformationFormat(RWGltf_WriterTrsfFormat_Compact);
|
||||
// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#coordinate-system-and-units
|
||||
aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (0.001);
|
||||
aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem (RWMesh_CoordinateSystem_Zup);
|
||||
aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit(0.001);
|
||||
aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem(
|
||||
RWMesh_CoordinateSystem_Zup);
|
||||
#if OCC_VERSION_HEX >= 0x070700
|
||||
aWriter.SetParallel(true);
|
||||
#endif
|
||||
Standard_Boolean ret = aWriter.Perform (hDoc, aMetadata, Message_ProgressRange());
|
||||
Standard_Boolean ret = aWriter.Perform(hDoc, aMetadata, Message_ProgressRange());
|
||||
if (!ret) {
|
||||
PyErr_Format(PyExc_IOError, "Cannot save to file '%s'", Utf8Name.c_str());
|
||||
throw Py::Exception();
|
||||
@@ -736,8 +805,9 @@ private:
|
||||
Py::Object ocaf(const Py::Tuple& args)
|
||||
{
|
||||
const char* Name;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "s",&Name))
|
||||
if (!PyArg_ParseTuple(args.ptr(), "s", &Name)) {
|
||||
throw Py::Exception();
|
||||
}
|
||||
|
||||
try {
|
||||
Base::FileInfo file(Name);
|
||||
@@ -751,7 +821,7 @@ private:
|
||||
aReader.SetColorMode(true);
|
||||
aReader.SetNameMode(true);
|
||||
aReader.SetLayerMode(true);
|
||||
aReader.SetSHUOMode(true);
|
||||
aReader.SetSHUOMode(true);
|
||||
if (aReader.ReadFile((Standard_CString)Name) != IFSelect_RetDone) {
|
||||
throw Py::Exception(PyExc_IOError, "cannot read STEP file");
|
||||
}
|
||||
@@ -768,13 +838,17 @@ private:
|
||||
#endif
|
||||
}
|
||||
else if (file.hasExtension({"igs", "iges"})) {
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
|
||||
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/Part")->GetGroup("IGES");
|
||||
Base::Reference<ParameterGrp> hGrp = App::GetApplication()
|
||||
.GetUserParameter()
|
||||
.GetGroup("BaseApp")
|
||||
->GetGroup("Preferences")
|
||||
->GetGroup("Mod/Part")
|
||||
->GetGroup("IGES");
|
||||
IGESControl_Controller::Init();
|
||||
IGESCAFControl_Reader aReader;
|
||||
// http://www.opencascade.org/org/forum/thread_20603/?forum=3
|
||||
aReader.SetReadVisible(hGrp->GetBool("SkipBlankEntities", true)
|
||||
? Standard_True : Standard_False);
|
||||
aReader.SetReadVisible(hGrp->GetBool("SkipBlankEntities", true) ? Standard_True
|
||||
: Standard_False);
|
||||
aReader.SetColorMode(true);
|
||||
aReader.SetNameMode(true);
|
||||
aReader.SetLayerMode(true);
|
||||
@@ -794,7 +868,7 @@ private:
|
||||
#endif
|
||||
// http://opencascade.blogspot.de/2009/03/unnoticeable-memory-leaks-part-2.html
|
||||
Handle(IGESToBRep_Actor)::DownCast(aReader.WS()->TransferReader()->Actor())
|
||||
->SetModel(new IGESData_IGESModel);
|
||||
->SetModel(new IGESData_IGESModel);
|
||||
}
|
||||
else {
|
||||
throw Py::Exception(PyExc_IOError, "no supported file format");
|
||||
@@ -806,14 +880,14 @@ private:
|
||||
QTreeWidget* tree = new QTreeWidget();
|
||||
tree->setHeaderLabel(QString::fromLatin1("OCAF Browser"));
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
layout->addWidget(tree);
|
||||
dlg->setLayout(layout);
|
||||
|
||||
QDialogButtonBox* btn = new QDialogButtonBox(dlg);
|
||||
btn->setStandardButtons(QDialogButtonBox::Close);
|
||||
QObject::connect(btn, &QDialogButtonBox::rejected, dlg, &QDialog::reject);
|
||||
QHBoxLayout *boxlayout = new QHBoxLayout;
|
||||
QHBoxLayout* boxlayout = new QHBoxLayout;
|
||||
boxlayout->addWidget(btn);
|
||||
layout->addLayout(boxlayout);
|
||||
}
|
||||
@@ -843,4 +917,4 @@ PyObject* initModule()
|
||||
return Base::Interpreter().addModule(new Module);
|
||||
}
|
||||
|
||||
} // namespace ImportGui
|
||||
}// namespace ImportGui
|
||||
|
||||
@@ -38,29 +38,32 @@ using Gui::FileDialog;
|
||||
DEF_STD_CMD_A(FCCmdImportReadBREP)
|
||||
|
||||
FCCmdImportReadBREP::FCCmdImportReadBREP()
|
||||
: Command("Import_ReadBREP")
|
||||
: Command("Import_ReadBREP")
|
||||
{
|
||||
sAppModule = "Import";
|
||||
sGroup = "Import";
|
||||
sMenuText = "Read BREP";
|
||||
sToolTipText = "Read a BREP file";
|
||||
sWhatsThis = "Import_ReadBREP";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Std_Tool1";
|
||||
sAppModule = "Import";
|
||||
sGroup = "Import";
|
||||
sMenuText = "Read BREP";
|
||||
sToolTipText = "Read a BREP file";
|
||||
sWhatsThis = "Import_ReadBREP";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Std_Tool1";
|
||||
}
|
||||
|
||||
void FCCmdImportReadBREP::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Read BREP"));
|
||||
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), QLatin1String("BREP (*.brep *.rle)"));
|
||||
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(),
|
||||
QString(),
|
||||
QString(),
|
||||
QLatin1String("BREP (*.brep *.rle)"));
|
||||
if (fn.isEmpty()) {
|
||||
abortCommand();
|
||||
return;
|
||||
}
|
||||
|
||||
fn = Base::Tools::escapeEncodeFilename(fn);
|
||||
doCommand(Doc,"TopoShape = Import.ReadBREP(\"%s\")",(const char*)fn.toUtf8());
|
||||
doCommand(Doc, "TopoShape = Import.ReadBREP(\"%s\")", (const char*)fn.toUtf8());
|
||||
commitCommand();
|
||||
}
|
||||
|
||||
@@ -75,27 +78,30 @@ bool FCCmdImportReadBREP::isActive()
|
||||
DEF_STD_CMD_A(ImportStep)
|
||||
|
||||
ImportStep::ImportStep()
|
||||
: Command("Part_ImportStep")
|
||||
: Command("Part_ImportStep")
|
||||
{
|
||||
sAppModule = "Part";
|
||||
sGroup = "Part";
|
||||
sMenuText = "Import STEP";
|
||||
sToolTipText = "Create or change a Import STEP feature";
|
||||
sWhatsThis = "Part_ImportStep";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Save";
|
||||
sAppModule = "Part";
|
||||
sGroup = "Part";
|
||||
sMenuText = "Import STEP";
|
||||
sToolTipText = "Create or change a Import STEP feature";
|
||||
sWhatsThis = "Part_ImportStep";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Save";
|
||||
}
|
||||
|
||||
|
||||
void ImportStep::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), QLatin1String("STEP (*.stp *.step)"));
|
||||
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(),
|
||||
QString(),
|
||||
QString(),
|
||||
QLatin1String("STEP (*.stp *.step)"));
|
||||
if (!fn.isEmpty()) {
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "Part ImportSTEP Create"));
|
||||
doCommand(Doc,"f = App.document().addObject(\"ImportStep\",\"ImportStep\")");
|
||||
doCommand(Doc, "f = App.document().addObject(\"ImportStep\",\"ImportStep\")");
|
||||
fn = Base::Tools::escapeEncodeFilename(fn);
|
||||
doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toUtf8());
|
||||
doCommand(Doc, "f.FileName = \"%s\"", (const char*)fn.toUtf8());
|
||||
commitCommand();
|
||||
updateActive();
|
||||
}
|
||||
@@ -103,10 +109,12 @@ void ImportStep::activated(int iMsg)
|
||||
|
||||
bool ImportStep::isActive()
|
||||
{
|
||||
if (getActiveGuiDocument())
|
||||
if (getActiveGuiDocument()) {
|
||||
return true;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,26 +124,29 @@ bool ImportStep::isActive()
|
||||
DEF_STD_CMD_A(ImportIges)
|
||||
|
||||
ImportIges::ImportIges()
|
||||
: Command("Import_Iges")
|
||||
: Command("Import_Iges")
|
||||
{
|
||||
sAppModule = "Import";
|
||||
sGroup = "Part";
|
||||
sMenuText = "Import IGES";
|
||||
sToolTipText = "Create or change a Import IGES feature";
|
||||
sWhatsThis = "Import_Iges";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Save";
|
||||
sAppModule = "Import";
|
||||
sGroup = "Part";
|
||||
sMenuText = "Import IGES";
|
||||
sToolTipText = "Create or change a Import IGES feature";
|
||||
sWhatsThis = "Import_Iges";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "Save";
|
||||
}
|
||||
|
||||
void ImportIges::activated(int iMsg)
|
||||
{
|
||||
Q_UNUSED(iMsg);
|
||||
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), QLatin1String("IGES (*.igs *.iges)"));
|
||||
QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(),
|
||||
QString(),
|
||||
QString(),
|
||||
QLatin1String("IGES (*.igs *.iges)"));
|
||||
if (!fn.isEmpty()) {
|
||||
openCommand(QT_TRANSLATE_NOOP("Command", "ImportIGES Create"));
|
||||
doCommand(Doc,"f = App.document().addObject(\"ImportIges\",\"ImportIges\")");
|
||||
doCommand(Doc, "f = App.document().addObject(\"ImportIges\",\"ImportIges\")");
|
||||
fn = Base::Tools::escapeEncodeFilename(fn);
|
||||
doCommand(Doc,"f.FileName = \"%s\"",(const char*)fn.toUtf8());
|
||||
doCommand(Doc, "f.FileName = \"%s\"", (const char*)fn.toUtf8());
|
||||
commitCommand();
|
||||
updateActive();
|
||||
}
|
||||
@@ -143,15 +154,17 @@ void ImportIges::activated(int iMsg)
|
||||
|
||||
bool ImportIges::isActive()
|
||||
{
|
||||
if (getActiveGuiDocument())
|
||||
if (getActiveGuiDocument()) {
|
||||
return true;
|
||||
else
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CreateImportCommands()
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
rcCmdMgr.addCommand(new FCCmdImportReadBREP());
|
||||
}
|
||||
|
||||
@@ -29,61 +29,58 @@
|
||||
|
||||
// point at which warnings of overly long specifiers disabled (needed for VC6)
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(disable : 4005)
|
||||
# pragma warning(disable : 4251)
|
||||
# pragma warning(disable : 4503)
|
||||
# pragma warning(disable : 4786) // specifier longer then 255 chars
|
||||
#pragma warning(disable : 4005)
|
||||
#pragma warning(disable : 4251)
|
||||
#pragma warning(disable : 4503)
|
||||
#pragma warning(disable : 4786)// specifier longer then 255 chars
|
||||
#endif
|
||||
|
||||
#ifdef _PreComp_
|
||||
|
||||
// standard
|
||||
#include <list>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
|
||||
// STL
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#ifndef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
// OpenCasCade Base
|
||||
#include <Mod/Part/App/OpenCascadeAll.h>
|
||||
|
||||
// OpenCascade View
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <BRepPrimAPI_MakeSphere.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <Geom_Axis2Placement.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_TagSource.hxx>
|
||||
#include <TDataStd_Real.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_TagSource.hxx>
|
||||
#include <Geom_SphericalSurface.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <TDataStd_Real.hxx>
|
||||
#include <TDataStd_Integer.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_TagSource.hxx>
|
||||
#include <TDataStd_ChildNodeIterator.hxx>
|
||||
#include <TDataStd_Integer.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDataStd_Real.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <TNaming_Builder.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <TNaming_Tool.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Sphere.hxx>
|
||||
#include <gp_Trsf.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopLoc_Location.hxx>
|
||||
#include <TNaming_Tool.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepPrimAPI_MakeSphere.hxx>
|
||||
#include <Geom_SphericalSurface.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TNaming_Builder.hxx>
|
||||
|
||||
#ifndef FC_OS_WIN32
|
||||
#include <Graphic3d_GraphicDevice.hxx>
|
||||
@@ -93,10 +90,10 @@
|
||||
|
||||
// Qt Toolkit
|
||||
#ifndef __QtAll__
|
||||
# include <Gui/QtAll.h>
|
||||
#include <Gui/QtAll.h>
|
||||
#endif
|
||||
|
||||
|
||||
#endif //_PreComp_
|
||||
#endif//_PreComp_
|
||||
|
||||
#endif // __PRECOMPILED_GUI__
|
||||
#endif// __PRECOMPILED_GUI__
|
||||
|
||||
@@ -46,4 +46,3 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
|
||||
Gui::ToolBarItem* root = new Gui::ToolBarItem;
|
||||
return root;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,12 +26,13 @@
|
||||
|
||||
#include <Gui/Workbench.h>
|
||||
|
||||
namespace ImportGui {
|
||||
namespace ImportGui
|
||||
{
|
||||
|
||||
/**
|
||||
* @author Werner Mayer
|
||||
*/
|
||||
class Workbench : public Gui::StdWorkbench
|
||||
class Workbench: public Gui::StdWorkbench
|
||||
{
|
||||
TYPESYSTEM_HEADER_WITH_OVERRIDE();
|
||||
|
||||
@@ -44,7 +45,7 @@ protected:
|
||||
Gui::ToolBarItem* setupCommandBars() const override;
|
||||
};
|
||||
|
||||
} // namespace ImportGui
|
||||
}// namespace ImportGui
|
||||
|
||||
|
||||
#endif // IMPORT_WORKBENCH_H
|
||||
#endif// IMPORT_WORKBENCH_H
|
||||
|
||||
Reference in New Issue
Block a user