Import: [skip ci] fix warning about trailing whitespaces, fix parsing errors
This commit is contained in:
@@ -687,9 +687,9 @@ static PyObject * importAssembly(PyObject *self, PyObject *args)
|
||||
|
||||
|
||||
App::Document *pcDoc = 0;
|
||||
|
||||
pcDoc = App::GetApplication().getActiveDocument();
|
||||
|
||||
|
||||
pcDoc = App::GetApplication().getActiveDocument();
|
||||
|
||||
if (!pcDoc)
|
||||
pcDoc = App::GetApplication().newDocument("ImportedAssembly");
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <XCAFDoc_ColorTool.hxx>
|
||||
#include <XCAFDoc_ShapeTool.hxx>
|
||||
|
||||
#include <App/Material.h>
|
||||
#include <Mod/Import/ImportGlobal.h>
|
||||
|
||||
|
||||
@@ -42,6 +43,7 @@ class TopLoc_Location;
|
||||
namespace App {
|
||||
class Document;
|
||||
class DocumentObject;
|
||||
class Part;
|
||||
}
|
||||
namespace Part {
|
||||
class Feature;
|
||||
|
||||
@@ -38,20 +38,19 @@ using namespace Import;
|
||||
|
||||
void FeatureImportIges::InitLabel(const TDF_Label &rcLabel)
|
||||
{
|
||||
addProperty("String","FileName");
|
||||
|
||||
addProperty("String","FileName");
|
||||
}
|
||||
|
||||
/*
|
||||
bool FeaturePartImportStep::MustExecute(void)
|
||||
{
|
||||
Base::Console().Log("PartBoxFeature::MustExecute()\n");
|
||||
return false;
|
||||
Base::Console().Log("PartBoxFeature::MustExecute()\n");
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
Standard_Integer FeatureImportIges::Execute(void)
|
||||
{
|
||||
Base::Console().Log("FeaturePartImportIges::Execute()\n");
|
||||
Base::Console().Log("FeaturePartImportIges::Execute()\n");
|
||||
|
||||
/* cout << GetFloatProperty("x") << endl;
|
||||
cout << GetFloatProperty("y") << endl;
|
||||
@@ -68,13 +67,13 @@ Standard_Integer FeatureImportIges::Execute(void)
|
||||
std::string FileName = getPropertyString("FileName");
|
||||
|
||||
int i=_open(FileName.c_str(),O_RDONLY);
|
||||
if( i != -1)
|
||||
{
|
||||
_close(i);
|
||||
}else{
|
||||
if( i != -1)
|
||||
{
|
||||
_close(i);
|
||||
}else{
|
||||
Base::Console().Log("FeaturePartImportIges::Execute() not able to open %s!\n",FileName.c_str());
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// just do show the wait cursor when the Gui is up
|
||||
Base::Sequencer().start("Load IGES", 1);
|
||||
@@ -83,17 +82,17 @@ Standard_Integer FeatureImportIges::Execute(void)
|
||||
// read iges-file
|
||||
if (aReader.ReadFile((const Standard_CString)FileName.c_str()) != IFSelect_RetDone)
|
||||
throw Base::FileException("IGES read failed (load file)");
|
||||
|
||||
|
||||
// check iges-file (memory)
|
||||
//if (!aReader.Check(Standard_True))
|
||||
// Base::Console().Warning( "IGES model contains errors! try loading anyway....\n" );
|
||||
|
||||
|
||||
// make brep
|
||||
aReader.TransferRoots();
|
||||
// one shape, who contain's all subshapes
|
||||
aShape = aReader.OneShape();
|
||||
|
||||
setShape(aShape);
|
||||
setShape(aShape);
|
||||
Base::Sequencer().stop();
|
||||
}
|
||||
catch(...){
|
||||
@@ -108,7 +107,7 @@ Standard_Integer FeatureImportIges::Execute(void)
|
||||
/*
|
||||
void FeatureImportIges::Validate(void)
|
||||
{
|
||||
Base::Console().Log("FeaturePartImportStep::Validate()\n");
|
||||
Base::Console().Log("FeaturePartImportStep::Validate()\n");
|
||||
|
||||
// We validate the object label ( Label() ), all the arguments and the results of the object:
|
||||
log.SetValid(Label(), Standard_True);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
|
||||
class TDF_Label;
|
||||
|
||||
namespace Import
|
||||
{
|
||||
@@ -33,16 +34,16 @@ class FeatureImportIges :public Part::Feature
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void InitLabel(const TDF_Label &rcLabel);
|
||||
virtual void InitLabel(const TDF_Label &rcLabel);
|
||||
|
||||
// virtual bool MustExecute(void);
|
||||
// virtual bool MustExecute(void);
|
||||
|
||||
virtual Standard_Integer Execute(void);
|
||||
virtual Standard_Integer Execute(void);
|
||||
|
||||
// virtual void Validate(void);
|
||||
// virtual void Validate(void);
|
||||
|
||||
/// Returns the Name/Type of the feature
|
||||
virtual const char *Type(void){return "PartImportIges";};
|
||||
virtual const char *Type(void){return "PartImportIges";}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -38,20 +38,20 @@ using namespace Import;
|
||||
|
||||
void FeatureImportStep::InitLabel(const TDF_Label &rcLabel)
|
||||
{
|
||||
addProperty("String","FileName");
|
||||
addProperty("String","FileName");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
bool FeaturePartImportStep::MustExecute(void)
|
||||
{
|
||||
Base::Console().Log("PartBoxFeature::MustExecute()\n");
|
||||
return false;
|
||||
Base::Console().Log("PartBoxFeature::MustExecute()\n");
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
Standard_Integer FeatureImportStep::Execute(void)
|
||||
{
|
||||
Base::Console().Log("FeaturePartImportStep::Execute()\n");
|
||||
Base::Console().Log("FeaturePartImportStep::Execute()\n");
|
||||
|
||||
/* cout << GetFloatProperty("x") << endl;
|
||||
cout << GetFloatProperty("y") << endl;
|
||||
@@ -71,13 +71,13 @@ Standard_Integer FeatureImportStep::Execute(void)
|
||||
return 1;
|
||||
|
||||
int i=_open(FileName.c_str(),O_RDONLY);
|
||||
if( i != -1)
|
||||
{
|
||||
_close(i);
|
||||
}else{
|
||||
if( i != -1)
|
||||
{
|
||||
_close(i);
|
||||
}else{
|
||||
setError("File not readable");
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// just do show the wait cursor when the Gui is up
|
||||
Base::Sequencer().start("Load IGES", 1);
|
||||
@@ -112,7 +112,7 @@ Standard_Integer FeatureImportStep::Execute(void)
|
||||
}
|
||||
}
|
||||
|
||||
setShape(aShape);
|
||||
setShape(aShape);
|
||||
Base::Sequencer().stop();
|
||||
}
|
||||
catch(...){
|
||||
@@ -127,8 +127,8 @@ Standard_Integer FeatureImportStep::Execute(void)
|
||||
/*
|
||||
void FeatureImportStep::Validate(void)
|
||||
{
|
||||
Base::Console().Log("FeaturePartImportStep::Validate()\n");
|
||||
|
||||
Base::Console().Log("FeaturePartImportStep::Validate()\n");
|
||||
|
||||
// We validate the object label ( Label() ), all the arguments and the results of the object:
|
||||
log.SetValid(Label(), Standard_True);
|
||||
|
||||
|
||||
@@ -33,14 +33,14 @@ namespace Import
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void InitLabel(const TDF_Label &rcLabel);
|
||||
virtual void InitLabel(const TDF_Label &rcLabel);
|
||||
|
||||
virtual Standard_Integer Execute(void);
|
||||
virtual Standard_Integer Execute(void);
|
||||
|
||||
// virtual void Validate(void);
|
||||
// virtual void Validate(void);
|
||||
|
||||
/// Returns the Name/Type of the feature
|
||||
virtual const char *Type(void){return "PartImportStep";};
|
||||
virtual const char *Type(void){return "PartImportStep";}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ static std::string labelName(TDF_Label label) {
|
||||
}
|
||||
|
||||
static void printLabel(TDF_Label label, Handle(XCAFDoc_ShapeTool) aShapeTool,
|
||||
Handle(XCAFDoc_ColorTool) aColorTool, const char *msg = nullptr)
|
||||
Handle(XCAFDoc_ColorTool) aColorTool, const char *msg = nullptr)
|
||||
{
|
||||
if(label.IsNull() || !FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG))
|
||||
return;
|
||||
@@ -150,7 +150,7 @@ static void printLabel(TDF_Label label, Handle(XCAFDoc_ShapeTool) aShapeTool,
|
||||
Base::Console().NotifyLog(ss.str().c_str());
|
||||
}
|
||||
|
||||
static void dumpLabels(TDF_Label label, Handle(XCAFDoc_ShapeTool) aShapeTool,
|
||||
static void dumpLabels(TDF_Label label, Handle(XCAFDoc_ShapeTool) aShapeTool,
|
||||
Handle(XCAFDoc_ColorTool) aColorTool, int depth=0)
|
||||
{
|
||||
std::string indent(depth*2,' ');
|
||||
@@ -305,7 +305,7 @@ bool ImportOCAF2::getColor(const TopoDS_Shape &shape, Info &info, bool check, bo
|
||||
// color. And this will look weird in FC. So for shape with face
|
||||
// we'll ignore the curve color, if it is the same as the face color.
|
||||
if((c!=info.faceColor || !TopExp_Explorer(shape,TopAbs_FACE).More()) &&
|
||||
(!check || info.edgeColor!=c))
|
||||
(!check || info.edgeColor!=c))
|
||||
{
|
||||
info.edgeColor = c;
|
||||
info.hasEdgeColor = true;
|
||||
@@ -322,7 +322,7 @@ bool ImportOCAF2::getColor(const TopoDS_Shape &shape, Info &info, bool check, bo
|
||||
}
|
||||
|
||||
App::DocumentObject *ImportOCAF2::expandShape(
|
||||
App::Document *doc, TDF_Label label, const TopoDS_Shape &shape)
|
||||
App::Document *doc, TDF_Label label, const TopoDS_Shape &shape)
|
||||
{
|
||||
if(shape.IsNull() || !TopExp_Explorer(shape,TopAbs_VERTEX).More())
|
||||
return nullptr;
|
||||
@@ -373,7 +373,7 @@ App::DocumentObject *ImportOCAF2::expandShape(
|
||||
return info.obj;
|
||||
}
|
||||
|
||||
bool ImportOCAF2::createObject(App::Document *doc, TDF_Label label,
|
||||
bool ImportOCAF2::createObject(App::Document *doc, TDF_Label label,
|
||||
const TopoDS_Shape &shape, Info &info, bool newDoc)
|
||||
{
|
||||
if(shape.IsNull() || !TopExp_Explorer(shape,TopAbs_VERTEX).More()) {
|
||||
@@ -463,7 +463,7 @@ bool ImportOCAF2::createObject(App::Document *doc, TDF_Label label,
|
||||
doc = getDocument(doc,label);
|
||||
|
||||
if(options.expandCompound &&
|
||||
(tshape.countSubShapes(TopAbs_SOLID)>1 ||
|
||||
(tshape.countSubShapes(TopAbs_SOLID)>1 ||
|
||||
(!tshape.countSubShapes(TopAbs_SOLID) && tshape.countSubShapes(TopAbs_SHELL)>1)))
|
||||
{
|
||||
feature = dynamic_cast<Part::Feature*>(expandShape(doc,label,shape));
|
||||
@@ -501,7 +501,7 @@ App::Document *ImportOCAF2::getDocument(App::Document *doc, TDF_Label label) {
|
||||
for(int i=0;i<1000;++i) {
|
||||
ss.str("");
|
||||
ss << path << '/' << fi.fileNamePure() << "_parts";
|
||||
if(i>0)
|
||||
if(i>0)
|
||||
ss << '_' << std::setfill('0') << std::setw(3) << i;
|
||||
Base::FileInfo fi2(ss.str());
|
||||
if(fi2.exists()) {
|
||||
@@ -518,7 +518,7 @@ App::Document *ImportOCAF2::getDocument(App::Document *doc, TDF_Label label) {
|
||||
for(int i=0;i<1000;++i) {
|
||||
ss.str("");
|
||||
ss << path << '/' << newDoc->getName() << ".fcstd";
|
||||
if(i>0)
|
||||
if(i>0)
|
||||
ss << '_' << std::setfill('0') << std::setw(3) << i;
|
||||
Base::FileInfo fi(ss.str());
|
||||
if(!fi.exists()) {
|
||||
@@ -532,10 +532,10 @@ App::Document *ImportOCAF2::getDocument(App::Document *doc, TDF_Label label) {
|
||||
return doc;
|
||||
}
|
||||
|
||||
bool ImportOCAF2::createGroup(App::Document *doc, Info &info, const TopoDS_Shape &shape,
|
||||
std::vector<App::DocumentObject*> &children,
|
||||
bool ImportOCAF2::createGroup(App::Document *doc, Info &info, const TopoDS_Shape &shape,
|
||||
std::vector<App::DocumentObject*> &children,
|
||||
const boost::dynamic_bitset<> &visibilities,
|
||||
bool canReduce)
|
||||
bool canReduce)
|
||||
{
|
||||
assert(children.size() == visibilities.size());
|
||||
if(children.empty())
|
||||
@@ -611,7 +611,7 @@ App::DocumentObject* ImportOCAF2::loadShapes()
|
||||
auto label = labels.Value(i);
|
||||
if(!options.importHidden && !aColorTool->IsVisible(label))
|
||||
continue;
|
||||
auto obj = loadShape(pDocument, label,
|
||||
auto obj = loadShape(pDocument, label,
|
||||
aShapeTool->GetShape(label), false, count>1);
|
||||
if(obj) {
|
||||
objs.push_back(obj);
|
||||
@@ -651,7 +651,7 @@ App::DocumentObject* ImportOCAF2::loadShapes()
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ImportOCAF2::getSHUOColors(TDF_Label label,
|
||||
void ImportOCAF2::getSHUOColors(TDF_Label label,
|
||||
std::map<std::string,App::Color> &colors, bool appendFirst)
|
||||
{
|
||||
TDF_AttributeSequence seq;
|
||||
@@ -703,14 +703,14 @@ void ImportOCAF2::getSHUOColors(TDF_Label label,
|
||||
if(aColorTool->GetColor(slabel, XCAFDoc_ColorSurf, aColor) ||
|
||||
aColorTool->GetColor(slabel, XCAFDoc_ColorGen, aColor))
|
||||
{
|
||||
colors.emplace(subname,convertColor(aColor));
|
||||
colors.emplace(subname, convertColor(aColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
App::DocumentObject *ImportOCAF2::loadShape(App::Document *doc,
|
||||
TDF_Label label, const TopoDS_Shape &shape, bool baseOnly, bool newDoc)
|
||||
App::DocumentObject *ImportOCAF2::loadShape(App::Document *doc,
|
||||
TDF_Label label, const TopoDS_Shape &shape, bool baseOnly, bool newDoc)
|
||||
{
|
||||
if(shape.IsNull())
|
||||
return nullptr;
|
||||
@@ -725,7 +725,7 @@ App::DocumentObject *ImportOCAF2::loadShape(App::Document *doc,
|
||||
bool res;
|
||||
if(baseLabel.IsNull() || !aShapeTool->IsAssembly(baseLabel))
|
||||
res = createObject(doc,baseLabel,baseShape,info,newDoc);
|
||||
else
|
||||
else
|
||||
res = createAssembly(doc,baseLabel,baseShape,info,newDoc);
|
||||
if(!res)
|
||||
return nullptr;
|
||||
@@ -788,7 +788,7 @@ struct ChildInfo {
|
||||
TopoDS_Shape shape;
|
||||
};
|
||||
|
||||
bool ImportOCAF2::createAssembly(App::Document *_doc,
|
||||
bool ImportOCAF2::createAssembly(App::Document *_doc,
|
||||
TDF_Label label, const TopoDS_Shape &shape, Info &info, bool newDoc)
|
||||
{
|
||||
(void)label;
|
||||
@@ -821,7 +821,7 @@ bool ImportOCAF2::createAssembly(App::Document *_doc,
|
||||
children.push_back(obj);
|
||||
getSHUOColors(childLabel,shuoColors,true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
auto &childInfo = childrenMap[obj];
|
||||
if (childInfo.plas.empty()) {
|
||||
@@ -835,7 +835,7 @@ bool ImportOCAF2::createAssembly(App::Document *_doc,
|
||||
childInfo.plas.emplace_back(Part::TopoShape::convert(childShape.Location().Transformation()));
|
||||
Quantity_ColorRGBA aColor;
|
||||
if (aColorTool->GetColor(childShape, XCAFDoc_ColorSurf, aColor)) {
|
||||
childInfo.colors[childInfo.plas.size()-1] = convertColor(aColor);
|
||||
childInfo.colors[childInfo.plas.size()-1] = convertColor(aColor);
|
||||
}
|
||||
}
|
||||
assert(visibilities.size() == children.size());
|
||||
@@ -1026,7 +1026,7 @@ TDF_Label ExportOCAF2::findComponent(const char *subname, TDF_Label label, TDF_L
|
||||
return TDF_Label();
|
||||
}
|
||||
|
||||
void ExportOCAF2::setupObject(TDF_Label label, App::DocumentObject *obj,
|
||||
void ExportOCAF2::setupObject(TDF_Label label, App::DocumentObject *obj,
|
||||
const Part::TopoShape &shape, const std::string &prefix, const char *name, bool force)
|
||||
{
|
||||
setName(label,obj,name);
|
||||
@@ -1116,7 +1116,7 @@ void ExportOCAF2::setupObject(TDF_Label label, App::DocumentObject *obj,
|
||||
// capability of overriding context-depdendent element color,
|
||||
// only whole shape color. Newer version of the same document
|
||||
// (https://www.cax-if.org/documents/rec_prac_styling_org_v15.pdf)
|
||||
// does support this, in section 5.1.
|
||||
// does support this, in section 5.1.
|
||||
//
|
||||
// The above observation is confirmed by further inspection of
|
||||
// OCCT code, XCAFDoc_ShapeTool.cxx and STEPCAFControl_Writer.cxx.
|
||||
@@ -1189,8 +1189,8 @@ void ExportOCAF2::exportObjects(std::vector<App::DocumentObject*> &objs, const c
|
||||
#endif
|
||||
}
|
||||
|
||||
TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
|
||||
const char *sub, TDF_Label parent, const char *name)
|
||||
TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
|
||||
const char *sub, TDF_Label parent, const char *name)
|
||||
{
|
||||
App::DocumentObject *obj;
|
||||
auto shape = Part::Feature::getTopoShape(parentObj,sub,false,nullptr,&obj,false,!sub);
|
||||
@@ -1242,7 +1242,7 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
|
||||
// have to flaten all multi-level link without scales. In other
|
||||
// word, all link will all be forced to refer to the same
|
||||
// non-located shape
|
||||
|
||||
|
||||
// retrieve OCAF computed shape, in case the current object returns
|
||||
// a new shape every time Part::Feature::getTopoShape() is called.
|
||||
auto baseShape = aShapeTool->GetShape(it->second);
|
||||
@@ -1364,7 +1364,7 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
|
||||
Quantity_ColorRGBA col;
|
||||
if(!aColorTool->GetInstanceColor(childShape,XCAFDoc_ColorGen,col) &&
|
||||
!aColorTool->GetInstanceColor(childShape,XCAFDoc_ColorSurf,col) &&
|
||||
!aColorTool->GetInstanceColor(childShape,XCAFDoc_ColorCurv,col))
|
||||
!aColorTool->GetInstanceColor(childShape,XCAFDoc_ColorCurv,col))
|
||||
{
|
||||
auto &c = options.defaultColor;
|
||||
aColorTool->SetColor(childLabel, convertColor(c), XCAFDoc_ColorGen);
|
||||
@@ -1407,7 +1407,7 @@ bool ExportOCAF2::canFallback(std::vector<App::DocumentObject*> objs) {
|
||||
continue;
|
||||
if(obj->getExtensionByType<App::LinkBaseExtension>(true))
|
||||
return false;
|
||||
for(auto &sub : obj->getSubObjects())
|
||||
for(auto &sub : obj->getSubObjects())
|
||||
objs.push_back(obj->getSubObject(sub.c_str()));
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -137,15 +137,15 @@ private:
|
||||
int free = true;
|
||||
};
|
||||
|
||||
App::DocumentObject *loadShape(App::Document *doc, 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,
|
||||
bool createAssembly(App::Document *doc, TDF_Label label,
|
||||
const TopoDS_Shape &shape, Info &info, bool newDoc);
|
||||
bool createObject(App::Document *doc, TDF_Label label,
|
||||
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,
|
||||
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);
|
||||
@@ -164,7 +164,7 @@ private:
|
||||
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 {
|
||||
myParent.applyFaceColors(part, colors);
|
||||
@@ -220,8 +220,8 @@ public:
|
||||
|
||||
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,
|
||||
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);
|
||||
|
||||
@@ -53,8 +53,8 @@ using namespace Import;
|
||||
|
||||
|
||||
ImportOCAFAssembly::ImportOCAFAssembly(Handle(TDocStd_Document) h, App::Document* d, const std::string& name, App::DocumentObject *target)
|
||||
: pDoc(h),
|
||||
doc(d),
|
||||
: pDoc(h),
|
||||
doc(d),
|
||||
default_name(name),
|
||||
targetObj(target)
|
||||
{
|
||||
|
||||
@@ -36,7 +36,7 @@ std::string StepShapePy::representation(void) const
|
||||
|
||||
PyObject *StepShapePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of StepShapePy and the Twin object
|
||||
// create a new instance of StepShapePy and the Twin object
|
||||
return new StepShapePy(new StepShape);
|
||||
}
|
||||
|
||||
@@ -53,17 +53,12 @@ int StepShapePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
PyObject* StepShapePy::read(PyObject * /*args*/)
|
||||
{
|
||||
PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
PyObject *StepShapePy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
return nullptr;
|
||||
@@ -71,7 +66,5 @@ PyObject *StepShapePy::getCustomAttributes(const char* /*attr*/) const
|
||||
|
||||
int StepShapePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -326,7 +326,7 @@ void ImpExpDxfRead::OnReadInsert(const double* point, const double* scale, const
|
||||
TopoDS_Compound comp;
|
||||
builder.MakeCompound(comp);
|
||||
std::vector<Part::TopoShape*> v = i->second;
|
||||
for(std::vector<Part::TopoShape*>::const_iterator j = v.begin(); j != v.end(); ++j) {
|
||||
for(std::vector<Part::TopoShape*>::const_iterator j = v.begin(); j != v.end(); ++j) {
|
||||
const TopoDS_Shape& sh = (*j)->getShape();
|
||||
if (!sh.IsNull())
|
||||
builder.Add(comp, sh);
|
||||
@@ -341,7 +341,7 @@ void ImpExpDxfRead::OnReadInsert(const double* point, const double* scale, const
|
||||
AddObject(pcomp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -425,7 +425,7 @@ void ImpExpDxfRead::AddGraphics() const
|
||||
k = "LAYER_0";
|
||||
std::vector<Part::TopoShape*> v = i->second;
|
||||
if(k.substr(0, 6) != "BLOCKS") {
|
||||
for(std::vector<Part::TopoShape*>::const_iterator j = v.begin(); j != v.end(); ++j) {
|
||||
for(std::vector<Part::TopoShape*>::const_iterator j = v.begin(); j != v.end(); ++j) {
|
||||
const TopoDS_Shape& sh = (*j)->getShape();
|
||||
if (!sh.IsNull())
|
||||
builder.Add(comp, sh);
|
||||
@@ -433,7 +433,7 @@ void ImpExpDxfRead::AddGraphics() const
|
||||
if (!comp.IsNull()) {
|
||||
Part::Feature *pcFeature = static_cast<Part::Feature *>(document->addObject("Part::Feature", k.c_str()));
|
||||
pcFeature->Shape.setValue(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -458,7 +458,7 @@ point3D gPntTopoint3D(gp_Pnt& p)
|
||||
return result;
|
||||
}
|
||||
|
||||
ImpExpDxfWrite::ImpExpDxfWrite(std::string filepath) :
|
||||
ImpExpDxfWrite::ImpExpDxfWrite(std::string filepath) :
|
||||
CDxfWrite(filepath.c_str())
|
||||
{
|
||||
setOptionSource("User parameter:BaseApp/Preferences/Mod/Import");
|
||||
@@ -580,11 +580,11 @@ void ImpExpDxfWrite::exportShape(const TopoDS_Shape input)
|
||||
gp_Pnt p = BRep_Tool::Pnt(v);
|
||||
duplicates.push_back(p);
|
||||
}
|
||||
|
||||
|
||||
std::sort(duplicates.begin(),duplicates.end(),ImpExpDxfWrite::gp_PntCompare);
|
||||
auto newEnd = std::unique(duplicates.begin(),duplicates.end(),ImpExpDxfWrite::gp_PntEqual);
|
||||
std::vector<gp_Pnt> uniquePts(duplicates.begin(),newEnd);
|
||||
for (auto& p: uniquePts) {
|
||||
for (auto& p : uniquePts) {
|
||||
double point[3] = {0,0,0};
|
||||
gPntToTuple(point, p);
|
||||
writePoint(point);
|
||||
@@ -592,7 +592,7 @@ void ImpExpDxfWrite::exportShape(const TopoDS_Shape input)
|
||||
}
|
||||
}
|
||||
|
||||
bool ImpExpDxfWrite::gp_PntEqual(gp_Pnt p1, gp_Pnt p2)
|
||||
bool ImpExpDxfWrite::gp_PntEqual(gp_Pnt p1, gp_Pnt p2)
|
||||
{
|
||||
bool result = false;
|
||||
if (p1.IsEqual(p2,Precision::Confusion())) {
|
||||
@@ -602,12 +602,12 @@ bool ImpExpDxfWrite::gp_PntEqual(gp_Pnt p1, gp_Pnt p2)
|
||||
}
|
||||
|
||||
//is p1 "less than" p2?
|
||||
bool ImpExpDxfWrite::gp_PntCompare(gp_Pnt p1, gp_Pnt p2)
|
||||
bool ImpExpDxfWrite::gp_PntCompare(gp_Pnt p1, gp_Pnt p2)
|
||||
{
|
||||
bool result = false;
|
||||
if (!(p1.IsEqual(p2,Precision::Confusion()))) { //ie v1 != v2
|
||||
if (!(fabs(p1.X() - p2.X()) < Precision::Confusion())) { // x1 != x2
|
||||
result = p1.X() < p2.X();
|
||||
result = p1.X() < p2.X();
|
||||
} else if (!(fabs(p1.Y() - p2.Y()) < Precision::Confusion())) { // y1 != y2
|
||||
result = p1.Y() < p2.Y();
|
||||
} else {
|
||||
@@ -643,7 +643,7 @@ void ImpExpDxfWrite::exportEllipse(BRepAdaptor_Curve& c)
|
||||
gp_Dir xaxis = ellp.XAxis().Direction(); //direction of major axis
|
||||
//rotation appears to be the clockwise(?) angle between major & +Y??
|
||||
double rotation = xaxis.AngleWithRef(gp_Dir(0, 1, 0), gp_Dir(0, 0, 1));
|
||||
|
||||
|
||||
//2*M_PI = 6.28319 is invalid(doesn't display in LibreCAD), but 2PI = 6.28318 is valid!
|
||||
//writeEllipse(center, major, minor, rotation, 0.0, 2 * M_PI, true );
|
||||
writeEllipse(center, major, minor, rotation, 0.0, 6.28318, true );
|
||||
@@ -764,7 +764,7 @@ void ImpExpDxfWrite::exportBSpline(BRepAdaptor_Curve& c)
|
||||
spline->D0(spline->LastParameter(),p);
|
||||
sd.endtan = gPntTopoint3D(p);
|
||||
|
||||
//next bit is from DrawingExport.cpp (Dan Falk?).
|
||||
//next bit is from DrawingExport.cpp (Dan Falk?).
|
||||
Standard_Integer m = 0;
|
||||
if (spline->IsPeriodic()) {
|
||||
m = spline->NbPoles() + 2*spline->Degree() - spline->Multiplicity(1) + 2;
|
||||
@@ -785,8 +785,8 @@ void ImpExpDxfWrite::exportBSpline(BRepAdaptor_Curve& c)
|
||||
for (int i = poles.Lower(); i <= poles.Upper(); i++) {
|
||||
sd.control.push_back(gPntTopoint3D(poles(i)));
|
||||
}
|
||||
//OCC doesn't have separate lists for control points and fit points.
|
||||
|
||||
//OCC doesn't have separate lists for control points and fit points.
|
||||
|
||||
writeSpline(sd);
|
||||
}
|
||||
|
||||
@@ -873,8 +873,8 @@ void ImpExpDxfWrite::exportText(const char* text, Base::Vector3d position1, Base
|
||||
writeText(text, location1, location2, size, just);
|
||||
}
|
||||
|
||||
void ImpExpDxfWrite::exportLinearDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
|
||||
Base::Vector3d extLine1Start, Base::Vector3d extLine2Start,
|
||||
void ImpExpDxfWrite::exportLinearDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
|
||||
Base::Vector3d extLine1Start, Base::Vector3d extLine2Start,
|
||||
char* dimText, int type)
|
||||
{
|
||||
double text[3] = {0,0,0};
|
||||
@@ -896,8 +896,8 @@ void ImpExpDxfWrite::exportLinearDim(Base::Vector3d textLocn, Base::Vector3d lin
|
||||
writeLinearDim(text, line, ext1,ext2,dimText, type);
|
||||
}
|
||||
|
||||
void ImpExpDxfWrite::exportAngularDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
|
||||
Base::Vector3d extLine1End, Base::Vector3d extLine2End,
|
||||
void ImpExpDxfWrite::exportAngularDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
|
||||
Base::Vector3d extLine1End, Base::Vector3d extLine2End,
|
||||
Base::Vector3d apexPoint,
|
||||
char* dimText)
|
||||
{
|
||||
@@ -924,7 +924,7 @@ void ImpExpDxfWrite::exportAngularDim(Base::Vector3d textLocn, Base::Vector3d li
|
||||
writeAngularDim(text, line, apex, ext1, apex, ext2, dimText);
|
||||
}
|
||||
|
||||
void ImpExpDxfWrite::exportRadialDim(Base::Vector3d centerPoint, Base::Vector3d textLocn,
|
||||
void ImpExpDxfWrite::exportRadialDim(Base::Vector3d centerPoint, Base::Vector3d textLocn,
|
||||
Base::Vector3d arcPoint,
|
||||
char* dimText)
|
||||
{
|
||||
@@ -944,7 +944,7 @@ void ImpExpDxfWrite::exportRadialDim(Base::Vector3d centerPoint, Base::Vector3d
|
||||
|
||||
}
|
||||
|
||||
void ImpExpDxfWrite::exportDiametricDim(Base::Vector3d textLocn,
|
||||
void ImpExpDxfWrite::exportDiametricDim(Base::Vector3d textLocn,
|
||||
Base::Vector3d arcPoint1, Base::Vector3d arcPoint2,
|
||||
char* dimText)
|
||||
{
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Import
|
||||
{
|
||||
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;
|
||||
@@ -51,7 +51,7 @@ namespace Import
|
||||
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
|
||||
@@ -62,7 +62,7 @@ namespace Import
|
||||
|
||||
private:
|
||||
gp_Pnt makePoint(const double* p);
|
||||
|
||||
|
||||
protected:
|
||||
App::Document *document;
|
||||
bool optionGroupLayers;
|
||||
@@ -75,26 +75,26 @@ namespace Import
|
||||
class ImportExport ImpExpDxfWrite : public CDxfWrite
|
||||
{
|
||||
public:
|
||||
ImpExpDxfWrite(std::string filepath);
|
||||
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,
|
||||
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,
|
||||
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,
|
||||
void exportRadialDim(Base::Vector3d centerPoint, Base::Vector3d textLocn,
|
||||
Base::Vector3d arcPoint,
|
||||
char* dimText);
|
||||
void exportDiametricDim(Base::Vector3d textLocn,
|
||||
void exportDiametricDim(Base::Vector3d textLocn,
|
||||
Base::Vector3d arcPoint1, Base::Vector3d arcPoint2,
|
||||
char* dimText);
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ void CDxfWrite::endRun(void)
|
||||
{
|
||||
makeLayerTable();
|
||||
makeBlockRecordTableBody();
|
||||
|
||||
|
||||
writeClassesSection();
|
||||
writeTablesSection();
|
||||
writeBlocksSection();
|
||||
@@ -130,7 +130,7 @@ void CDxfWrite::writeClassesSection(void)
|
||||
if (m_version < 14) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//static classes section content
|
||||
std::stringstream ss;
|
||||
ss << "classes" << m_version << ".rub";
|
||||
@@ -209,7 +209,7 @@ void CDxfWrite::makeLayerTable(void)
|
||||
(*m_ssLayer) << " 6" << endl;
|
||||
(*m_ssLayer) << "CONTINUOUS" << endl;
|
||||
|
||||
for (auto& l: m_layerList) {
|
||||
for (auto& l : m_layerList) {
|
||||
(*m_ssLayer) << " 0" << endl;
|
||||
(*m_ssLayer) << "LAYER" << endl;
|
||||
(*m_ssLayer) << " 5" << endl;
|
||||
@@ -257,7 +257,7 @@ void CDxfWrite::makeBlockRecordTableHead(void)
|
||||
(*m_ssBlkRecord) << "AcDbSymbolTable" << endl;
|
||||
(*m_ssBlkRecord) << " 70" << endl;
|
||||
(*m_ssBlkRecord) << (m_blockList.size() + 5) << endl;
|
||||
|
||||
|
||||
m_saveModelSpaceHandle = getBlkRecordHandle();
|
||||
(*m_ssBlkRecord) << " 0" << endl;
|
||||
(*m_ssBlkRecord) << "BLOCK_RECORD" << endl;
|
||||
@@ -290,7 +290,7 @@ void CDxfWrite::makeBlockRecordTableHead(void)
|
||||
// (*m_ssBlkRecord) << " 1" << endl;
|
||||
// (*m_ssBlkRecord) << " " << endl;
|
||||
}
|
||||
|
||||
|
||||
//***************************
|
||||
//makeBlockRecordTableBody
|
||||
//added by Wandererfan 2018 (wandererfan@gmail.com) for FreeCAD project
|
||||
@@ -299,9 +299,9 @@ void CDxfWrite::makeBlockRecordTableBody(void)
|
||||
if (m_version < 14) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int iBlkRecord = 0;
|
||||
for (auto& b: m_blockList) {
|
||||
for (auto& b : m_blockList) {
|
||||
(*m_ssBlkRecord) << " 0" << endl;
|
||||
(*m_ssBlkRecord) << "BLOCK_RECORD" << endl;
|
||||
(*m_ssBlkRecord) << " 5" << endl;
|
||||
@@ -352,7 +352,7 @@ void CDxfWrite::makeBlockSectionHead(void)
|
||||
(*m_ssBlock) << " 0" << endl;
|
||||
(*m_ssBlock) << " 10" << endl;
|
||||
(*m_ssBlock) << 0.0 << endl;
|
||||
(*m_ssBlock) << " 20" << endl;
|
||||
(*m_ssBlock) << " 20" << endl;
|
||||
(*m_ssBlock) << 0.0 << endl;
|
||||
(*m_ssBlock) << " 30" << endl;
|
||||
(*m_ssBlock) << 0.0 << endl;
|
||||
@@ -402,7 +402,7 @@ void CDxfWrite::makeBlockSectionHead(void)
|
||||
(*m_ssBlock) << " 0" << endl;
|
||||
(*m_ssBlock) << " 10" << endl;
|
||||
(*m_ssBlock) << 0.0 << endl;
|
||||
(*m_ssBlock) << " 20" << endl;
|
||||
(*m_ssBlock) << " 20" << endl;
|
||||
(*m_ssBlock) << 0.0 << endl;
|
||||
(*m_ssBlock) << " 30" << endl;
|
||||
(*m_ssBlock) << 0.0 << endl;
|
||||
@@ -500,7 +500,7 @@ std::string CDxfWrite::getBlkRecordHandle(void)
|
||||
// return ss.str();
|
||||
}
|
||||
|
||||
void CDxfWrite::addBlockName(std::string b, std::string h)
|
||||
void CDxfWrite::addBlockName(std::string b, std::string h)
|
||||
{
|
||||
m_blockList.push_back(b);
|
||||
m_blkRecordList.push_back(h);
|
||||
@@ -584,21 +584,21 @@ void CDxfWrite::writeLWPolyLine(const LWPolyDataOut &pd)
|
||||
// (*m_ssEntity) << pd.Elev << endl; // Elevation
|
||||
// (*m_ssEntity) << " 39" << endl;
|
||||
// (*m_ssEntity) << pd.Thick << endl; // Thickness
|
||||
for (auto& p: pd.Verts) {
|
||||
for (auto& p : pd.Verts) {
|
||||
(*m_ssEntity) << " 10" << endl; // Vertices
|
||||
(*m_ssEntity) << p.x << endl;
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
(*m_ssEntity) << p.y << endl;
|
||||
}
|
||||
for (auto& s: pd.StartWidth) {
|
||||
}
|
||||
for (auto& s : pd.StartWidth) {
|
||||
(*m_ssEntity) << " 40" << endl;
|
||||
(*m_ssEntity) << s << endl; // Start Width
|
||||
}
|
||||
for (auto& e: pd.EndWidth) {
|
||||
for (auto& e : pd.EndWidth) {
|
||||
(*m_ssEntity) << " 41" << endl;
|
||||
(*m_ssEntity) << e << endl; // End Width
|
||||
}
|
||||
for (auto& b: pd.Bulge) { // Bulge
|
||||
for (auto& b : pd.Bulge) { // Bulge
|
||||
(*m_ssEntity) << " 42" << endl;
|
||||
(*m_ssEntity) << b << endl;
|
||||
}
|
||||
@@ -641,7 +641,7 @@ void CDxfWrite::writePolyline(const LWPolyDataOut &pd)
|
||||
(*m_ssEntity) << "0.0" << endl;
|
||||
(*m_ssEntity) << " 70" << endl;
|
||||
(*m_ssEntity) << "0" << endl;
|
||||
for (auto& p: pd.Verts) {
|
||||
for (auto& p : pd.Verts) {
|
||||
(*m_ssEntity) << " 0" << endl;
|
||||
(*m_ssEntity) << "VERTEX" << endl;
|
||||
(*m_ssEntity) << " 5" << endl;
|
||||
@@ -654,7 +654,7 @@ void CDxfWrite::writePolyline(const LWPolyDataOut &pd)
|
||||
(*m_ssEntity) << p.y << endl;
|
||||
(*m_ssEntity) << " 30" << endl;
|
||||
(*m_ssEntity) << "0.0" << endl;
|
||||
}
|
||||
}
|
||||
(*m_ssEntity) << " 0" << endl;
|
||||
(*m_ssEntity) << "SEQEND" << endl;
|
||||
(*m_ssEntity) << " 5" << endl;
|
||||
@@ -769,7 +769,7 @@ void CDxfWrite::writeCircle(const double* c, double radius)
|
||||
(*m_ssEntity) << radius << endl; // Radius
|
||||
}
|
||||
|
||||
void CDxfWrite::writeEllipse(const double* c, double major_radius, double minor_radius,
|
||||
void CDxfWrite::writeEllipse(const double* c, double major_radius, double minor_radius,
|
||||
double rotation, double start_angle, double end_angle,
|
||||
bool endIsCW)
|
||||
{
|
||||
@@ -857,13 +857,13 @@ void CDxfWrite::writeSpline(const SplineDataOut &sd)
|
||||
|
||||
(*m_ssEntity) << " 70" << endl;
|
||||
(*m_ssEntity) << sd.flag << endl; //flags
|
||||
(*m_ssEntity) << " 71" << endl;
|
||||
(*m_ssEntity) << " 71" << endl;
|
||||
(*m_ssEntity) << sd.degree << endl;
|
||||
(*m_ssEntity) << " 72" << endl;
|
||||
(*m_ssEntity) << sd.knots << endl;
|
||||
(*m_ssEntity) << " 73" << endl;
|
||||
(*m_ssEntity) << sd.control_points << endl;
|
||||
(*m_ssEntity) << " 74" << endl;
|
||||
(*m_ssEntity) << " 74" << endl;
|
||||
(*m_ssEntity) << 0 << endl;
|
||||
|
||||
// (*m_ssEntity) << " 12" << endl;
|
||||
@@ -879,17 +879,17 @@ void CDxfWrite::writeSpline(const SplineDataOut &sd)
|
||||
// (*m_ssEntity) << " 33" << endl;
|
||||
// (*m_ssEntity) << sd.endtan.z << endl;
|
||||
|
||||
for (auto& k: sd.knot) {
|
||||
(*m_ssEntity) << " 40" << endl;
|
||||
(*m_ssEntity) << k << endl;
|
||||
for (auto& k : sd.knot) {
|
||||
(*m_ssEntity) << " 40" << endl;
|
||||
(*m_ssEntity) << k << endl;
|
||||
}
|
||||
|
||||
for (auto& w : sd.weight) {
|
||||
(*m_ssEntity) << " 41" << endl;
|
||||
(*m_ssEntity) << w << endl;
|
||||
(*m_ssEntity) << " 41" << endl;
|
||||
(*m_ssEntity) << w << endl;
|
||||
}
|
||||
|
||||
for (auto& c: sd.control) {
|
||||
for (auto& c : sd.control) {
|
||||
(*m_ssEntity) << " 10" << endl;
|
||||
(*m_ssEntity) << c.x << endl; // X in WCS coordinates
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
@@ -897,7 +897,7 @@ void CDxfWrite::writeSpline(const SplineDataOut &sd)
|
||||
(*m_ssEntity) << " 30" << endl;
|
||||
(*m_ssEntity) << c.z << endl; // Z in WCS coordinates
|
||||
}
|
||||
for (auto& f: sd.fit) {
|
||||
for (auto& f : sd.fit) {
|
||||
(*m_ssEntity) << " 11" << endl;
|
||||
(*m_ssEntity) << f.x << endl; // X in WCS coordinates
|
||||
(*m_ssEntity) << " 21" << endl;
|
||||
@@ -930,7 +930,7 @@ void CDxfWrite::writeVertex(double x, double y, double z)
|
||||
}
|
||||
(*m_ssEntity) << " 10" << endl;
|
||||
(*m_ssEntity) << x << endl;
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
(*m_ssEntity) << y << endl;
|
||||
(*m_ssEntity) << " 30" << endl;
|
||||
(*m_ssEntity) << z << endl;
|
||||
@@ -942,9 +942,9 @@ void CDxfWrite::writeText(const char* text, const double* location1, const doubl
|
||||
const double height, const int horizJust)
|
||||
{
|
||||
putText(text, toVector3d(location1), toVector3d(location2),
|
||||
height, horizJust,
|
||||
height, horizJust,
|
||||
m_ssEntity, getEntityHandle(), m_saveModelSpaceHandle);
|
||||
}
|
||||
}
|
||||
|
||||
//***************************
|
||||
//putText
|
||||
@@ -976,7 +976,7 @@ void CDxfWrite::putText(const char* text, const Base::Vector3d location1, const
|
||||
// (*outStream) << 0 << endl; //thickness
|
||||
(*outStream) << " 10" << endl; //first alignment point
|
||||
(*outStream) << location1.x << endl;
|
||||
(*outStream) << " 20" << endl;
|
||||
(*outStream) << " 20" << endl;
|
||||
(*outStream) << location1.y << endl;
|
||||
(*outStream) << " 30" << endl;
|
||||
(*outStream) << location1.z << endl;
|
||||
@@ -1001,7 +1001,7 @@ void CDxfWrite::putText(const char* text, const Base::Vector3d location1, const
|
||||
//// (*outStream) << "0" << endl;
|
||||
(*outStream) << " 11" << endl; //second alignment point
|
||||
(*outStream) << location2.x << endl;
|
||||
(*outStream) << " 21" << endl;
|
||||
(*outStream) << " 21" << endl;
|
||||
(*outStream) << location2.y << endl;
|
||||
(*outStream) << " 31" << endl;
|
||||
(*outStream) << location2.z << endl;
|
||||
@@ -1015,7 +1015,7 @@ void CDxfWrite::putText(const char* text, const Base::Vector3d location1, const
|
||||
(*outStream) << "100" << endl;
|
||||
(*outStream) << "AcDbText" << endl;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CDxfWrite::putArrow(Base::Vector3d arrowPos, Base::Vector3d barb1Pos, Base::Vector3d barb2Pos,
|
||||
@@ -1096,13 +1096,13 @@ void CDxfWrite::writeLinearDim(const double* textMidPoint, const double* lineDef
|
||||
(*m_ssEntity) << "*" << getLayerName() << endl; // blockName
|
||||
(*m_ssEntity) << " 10" << endl; //dimension line definition point
|
||||
(*m_ssEntity) << lineDefPoint[0] << endl;
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
(*m_ssEntity) << lineDefPoint[1] << endl;
|
||||
(*m_ssEntity) << " 30" << endl;
|
||||
(*m_ssEntity) << lineDefPoint[2] << endl;
|
||||
(*m_ssEntity) << " 11" << endl; //text mid point
|
||||
(*m_ssEntity) << textMidPoint[0] << endl;
|
||||
(*m_ssEntity) << " 21" << endl;
|
||||
(*m_ssEntity) << " 21" << endl;
|
||||
(*m_ssEntity) << textMidPoint[1] << endl;
|
||||
(*m_ssEntity) << " 31" << endl;
|
||||
(*m_ssEntity) << textMidPoint[2] << endl;
|
||||
@@ -1128,13 +1128,13 @@ void CDxfWrite::writeLinearDim(const double* textMidPoint, const double* lineDef
|
||||
}
|
||||
(*m_ssEntity) << " 13" << endl;
|
||||
(*m_ssEntity) << extLine1[0] << endl;
|
||||
(*m_ssEntity) << " 23" << endl;
|
||||
(*m_ssEntity) << " 23" << endl;
|
||||
(*m_ssEntity) << extLine1[1] << endl;
|
||||
(*m_ssEntity) << " 33" << endl;
|
||||
(*m_ssEntity) << extLine1[2] << endl;
|
||||
(*m_ssEntity) << " 14" << endl;
|
||||
(*m_ssEntity) << extLine2[0] << endl;
|
||||
(*m_ssEntity) << " 24" << endl;
|
||||
(*m_ssEntity) << " 24" << endl;
|
||||
(*m_ssEntity) << extLine2[1] << endl;
|
||||
(*m_ssEntity) << " 34" << endl;
|
||||
(*m_ssEntity) << extLine2[2] << endl;
|
||||
@@ -1186,14 +1186,14 @@ void CDxfWrite::writeAngularDim(const double* textMidPoint, const double* lineDe
|
||||
|
||||
(*m_ssEntity) << " 10" << endl;
|
||||
(*m_ssEntity) << endExt2[0] << endl;
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
(*m_ssEntity) << endExt2[1] << endl;
|
||||
(*m_ssEntity) << " 30" << endl;
|
||||
(*m_ssEntity) << endExt2[2] << endl;
|
||||
|
||||
(*m_ssEntity) << " 11" << endl;
|
||||
(*m_ssEntity) << textMidPoint[0] << endl;
|
||||
(*m_ssEntity) << " 21" << endl;
|
||||
(*m_ssEntity) << " 21" << endl;
|
||||
(*m_ssEntity) << textMidPoint[1] << endl;
|
||||
(*m_ssEntity) << " 31" << endl;
|
||||
(*m_ssEntity) << textMidPoint[2] << endl;
|
||||
@@ -1204,7 +1204,7 @@ void CDxfWrite::writeAngularDim(const double* textMidPoint, const double* lineDe
|
||||
// (*m_ssEntity) << " 71" << endl; // not R12? not required?
|
||||
// (*m_ssEntity) << 5 << endl; // attachPoint 5 = middle
|
||||
(*m_ssEntity) << " 1" << endl;
|
||||
(*m_ssEntity) << dimText << endl;
|
||||
(*m_ssEntity) << dimText << endl;
|
||||
(*m_ssEntity) << " 3" << endl;
|
||||
(*m_ssEntity) << "STANDARD" << endl; //style
|
||||
//angular dims
|
||||
@@ -1214,28 +1214,28 @@ void CDxfWrite::writeAngularDim(const double* textMidPoint, const double* lineDe
|
||||
}
|
||||
(*m_ssEntity) << " 13" << endl;
|
||||
(*m_ssEntity) << startExt1[0] << endl;
|
||||
(*m_ssEntity) << " 23" << endl;
|
||||
(*m_ssEntity) << " 23" << endl;
|
||||
(*m_ssEntity) << startExt1[1] << endl;
|
||||
(*m_ssEntity) << " 33" << endl;
|
||||
(*m_ssEntity) << startExt1[2] << endl;
|
||||
|
||||
(*m_ssEntity) << " 14" << endl;
|
||||
(*m_ssEntity) << endExt1[0] << endl;
|
||||
(*m_ssEntity) << " 24" << endl;
|
||||
(*m_ssEntity) << " 24" << endl;
|
||||
(*m_ssEntity) << endExt1[1] << endl;
|
||||
(*m_ssEntity) << " 34" << endl;
|
||||
(*m_ssEntity) << endExt1[2] << endl;
|
||||
|
||||
(*m_ssEntity) << " 15" << endl;
|
||||
(*m_ssEntity) << startExt2[0] << endl;
|
||||
(*m_ssEntity) << " 25" << endl;
|
||||
(*m_ssEntity) << " 25" << endl;
|
||||
(*m_ssEntity) << startExt2[1] << endl;
|
||||
(*m_ssEntity) << " 35" << endl;
|
||||
(*m_ssEntity) << startExt2[2] << endl;
|
||||
|
||||
(*m_ssEntity) << " 16" << endl;
|
||||
(*m_ssEntity) << lineDefPoint[0] << endl;
|
||||
(*m_ssEntity) << " 26" << endl;
|
||||
(*m_ssEntity) << " 26" << endl;
|
||||
(*m_ssEntity) << lineDefPoint[1] << endl;
|
||||
(*m_ssEntity) << " 36" << endl;
|
||||
(*m_ssEntity) << lineDefPoint[2] << endl;
|
||||
@@ -1250,7 +1250,7 @@ void CDxfWrite::writeAngularDim(const double* textMidPoint, const double* lineDe
|
||||
//***************************
|
||||
//writeRadialDim
|
||||
//added by Wandererfan 2018 (wandererfan@gmail.com) for FreeCAD project
|
||||
void CDxfWrite::writeRadialDim(const double* centerPoint, const double* textMidPoint,
|
||||
void CDxfWrite::writeRadialDim(const double* centerPoint, const double* textMidPoint,
|
||||
const double* arcPoint,
|
||||
const char* dimText)
|
||||
{
|
||||
@@ -1274,13 +1274,13 @@ void CDxfWrite::writeRadialDim(const double* centerPoint, const double* textMidP
|
||||
(*m_ssEntity) << "*" << getLayerName() << endl; // blockName
|
||||
(*m_ssEntity) << " 10" << endl; // arc center point
|
||||
(*m_ssEntity) << centerPoint[0] << endl;
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
(*m_ssEntity) << centerPoint[1] << endl;
|
||||
(*m_ssEntity) << " 30" << endl;
|
||||
(*m_ssEntity) << centerPoint[2] << endl;
|
||||
(*m_ssEntity) << " 11" << endl; //text mid point
|
||||
(*m_ssEntity) << textMidPoint[0] << endl;
|
||||
(*m_ssEntity) << " 21" << endl;
|
||||
(*m_ssEntity) << " 21" << endl;
|
||||
(*m_ssEntity) << textMidPoint[1] << endl;
|
||||
(*m_ssEntity) << " 31" << endl;
|
||||
(*m_ssEntity) << textMidPoint[2] << endl;
|
||||
@@ -1289,7 +1289,7 @@ void CDxfWrite::writeRadialDim(const double* centerPoint, const double* textMidP
|
||||
// (*m_ssEntity) << " 71" << endl; // not R12
|
||||
// (*m_ssEntity) << 1 << endl; // attachPoint 5 = middle center
|
||||
(*m_ssEntity) << " 1" << endl;
|
||||
(*m_ssEntity) << dimText << endl;
|
||||
(*m_ssEntity) << dimText << endl;
|
||||
(*m_ssEntity) << " 3" << endl;
|
||||
(*m_ssEntity) << "STANDARD" << endl; //style
|
||||
//radial dims
|
||||
@@ -1299,7 +1299,7 @@ void CDxfWrite::writeRadialDim(const double* centerPoint, const double* textMidP
|
||||
}
|
||||
(*m_ssEntity) << " 15" << endl;
|
||||
(*m_ssEntity) << arcPoint[0] << endl;
|
||||
(*m_ssEntity) << " 25" << endl;
|
||||
(*m_ssEntity) << " 25" << endl;
|
||||
(*m_ssEntity) << arcPoint[1] << endl;
|
||||
(*m_ssEntity) << " 35" << endl;
|
||||
(*m_ssEntity) << arcPoint[2] << endl;
|
||||
@@ -1314,7 +1314,7 @@ void CDxfWrite::writeRadialDim(const double* centerPoint, const double* textMidP
|
||||
//***************************
|
||||
//writeDiametricDim
|
||||
//added by Wandererfan 2018 (wandererfan@gmail.com) for FreeCAD project
|
||||
void CDxfWrite::writeDiametricDim(const double* textMidPoint,
|
||||
void CDxfWrite::writeDiametricDim(const double* textMidPoint,
|
||||
const double* arcPoint1, const double* arcPoint2,
|
||||
const char* dimText)
|
||||
{
|
||||
@@ -1338,13 +1338,13 @@ void CDxfWrite::writeDiametricDim(const double* textMidPoint,
|
||||
(*m_ssEntity) << "*" << getLayerName() << endl; // blockName
|
||||
(*m_ssEntity) << " 10" << endl;
|
||||
(*m_ssEntity) << arcPoint1[0] << endl;
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
(*m_ssEntity) << " 20" << endl;
|
||||
(*m_ssEntity) << arcPoint1[1] << endl;
|
||||
(*m_ssEntity) << " 30" << endl;
|
||||
(*m_ssEntity) << arcPoint1[2] << endl;
|
||||
(*m_ssEntity) << " 11" << endl; //text mid point
|
||||
(*m_ssEntity) << textMidPoint[0] << endl;
|
||||
(*m_ssEntity) << " 21" << endl;
|
||||
(*m_ssEntity) << " 21" << endl;
|
||||
(*m_ssEntity) << textMidPoint[1] << endl;
|
||||
(*m_ssEntity) << " 31" << endl;
|
||||
(*m_ssEntity) << textMidPoint[2] << endl;
|
||||
@@ -1353,7 +1353,7 @@ void CDxfWrite::writeDiametricDim(const double* textMidPoint,
|
||||
// (*m_ssEntity) << " 71" << endl; // not R12
|
||||
// (*m_ssEntity) << 5 << endl; // attachPoint 5 = middle center
|
||||
(*m_ssEntity) << " 1" << endl;
|
||||
(*m_ssEntity) << dimText << endl;
|
||||
(*m_ssEntity) << dimText << endl;
|
||||
(*m_ssEntity) << " 3" << endl;
|
||||
(*m_ssEntity) << "STANDARD" << endl; //style
|
||||
//diametric dims
|
||||
@@ -1363,7 +1363,7 @@ void CDxfWrite::writeDiametricDim(const double* textMidPoint,
|
||||
}
|
||||
(*m_ssEntity) << " 15" << endl;
|
||||
(*m_ssEntity) << arcPoint2[0] << endl;
|
||||
(*m_ssEntity) << " 25" << endl;
|
||||
(*m_ssEntity) << " 25" << endl;
|
||||
(*m_ssEntity) << arcPoint2[1] << endl;
|
||||
(*m_ssEntity) << " 35" << endl;
|
||||
(*m_ssEntity) << arcPoint2[2] << endl;
|
||||
@@ -1410,7 +1410,7 @@ void CDxfWrite::writeDimBlockPreamble(void)
|
||||
(*m_ssBlock) << " 1" << endl;
|
||||
(*m_ssBlock) << " 10" << endl;
|
||||
(*m_ssBlock) << 0.0 << endl;
|
||||
(*m_ssBlock) << " 20" << endl;
|
||||
(*m_ssBlock) << " 20" << endl;
|
||||
(*m_ssBlock) << 0.0 << endl;
|
||||
(*m_ssBlock) << " 30" << endl;
|
||||
(*m_ssBlock) << 0.0 << endl;
|
||||
@@ -1464,7 +1464,7 @@ void CDxfWrite::writeLinearDimBlock(const double* textMidPoint, const double* di
|
||||
angle = angle * 180.0 / M_PI;
|
||||
if (type == ALIGNED) {
|
||||
//NOP
|
||||
} else if (type == HORIZONTAL) {
|
||||
} else if (type == HORIZONTAL) {
|
||||
double x = e1Start[0];
|
||||
double y = dimLine[1];
|
||||
e1E = Base::Vector3d(x, y, 0.0);
|
||||
@@ -1473,7 +1473,7 @@ void CDxfWrite::writeLinearDimBlock(const double* textMidPoint, const double* di
|
||||
perp = Base::Vector3d(0, -1, 0); //down
|
||||
para = Base::Vector3d(1, 0, 0); //right
|
||||
if (dimLine[1] > e1Start[1]) {
|
||||
perp = Base::Vector3d(0, 1, 0); //up
|
||||
perp = Base::Vector3d(0, 1, 0); //up
|
||||
}
|
||||
if (e1Start[0] > e2Start[0]) {
|
||||
para = Base::Vector3d(-1, 0, 0); //left
|
||||
@@ -1559,7 +1559,7 @@ void CDxfWrite::writeAngularDimBlock(const double* textMidPoint, const double* l
|
||||
Base::Vector3d endOff(cos(endAngle - offset),sin(endAngle - offset),0.0);
|
||||
startAngle = startAngle * 180.0 / M_PI;
|
||||
endAngle = endAngle * 180.0 / M_PI;
|
||||
|
||||
|
||||
Base::Vector3d linePt(lineDefPoint[0],lineDefPoint[1],lineDefPoint[2]);
|
||||
double radius = (e2S - linePt).Length();
|
||||
|
||||
@@ -1610,9 +1610,9 @@ void CDxfWrite::writeAngularDimBlock(const double* textMidPoint, const double* l
|
||||
Base::Vector3d endTan = e1S + (startOff * radius);
|
||||
Base::Vector3d startTan = e2S + (endOff * radius);
|
||||
Base::Vector3d tanP1 = (arrow1Start - startTan).Normalize();
|
||||
Base::Vector3d perp1(-tanP1.y,tanP1.x,tanP1.z);
|
||||
Base::Vector3d perp1(-tanP1.y,tanP1.x,tanP1.z);
|
||||
Base::Vector3d tanP2 = (arrow2Start - endTan).Normalize();
|
||||
Base::Vector3d perp2(-tanP2.y,tanP2.x,tanP2.z);
|
||||
Base::Vector3d perp2(-tanP2.y,tanP2.x,tanP2.z);
|
||||
double arrowLen = 5.0; //magic number
|
||||
double arrowWidth = arrowLen/6.0/2.0; //magic number calc!
|
||||
|
||||
@@ -1632,7 +1632,7 @@ void CDxfWrite::writeAngularDimBlock(const double* textMidPoint, const double* l
|
||||
//***************************
|
||||
//writeRadialDimBlock
|
||||
//added by Wandererfan 2018 (wandererfan@gmail.com) for FreeCAD project
|
||||
void CDxfWrite::writeRadialDimBlock(const double* centerPoint, const double* textMidPoint,
|
||||
void CDxfWrite::writeRadialDimBlock(const double* centerPoint, const double* textMidPoint,
|
||||
const double* arcPoint, const char* dimText)
|
||||
{
|
||||
putLine(toVector3d(centerPoint), toVector3d(arcPoint),
|
||||
@@ -1660,7 +1660,7 @@ void CDxfWrite::writeRadialDimBlock(const double* centerPoint, const double* tex
|
||||
//***************************
|
||||
//writeDiametricDimBlock
|
||||
//added by Wandererfan 2018 (wandererfan@gmail.com) for FreeCAD project
|
||||
void CDxfWrite::writeDiametricDimBlock(const double* textMidPoint,
|
||||
void CDxfWrite::writeDiametricDimBlock(const double* textMidPoint,
|
||||
const double* arcPoint1, const double* arcPoint2,
|
||||
const char* dimText)
|
||||
{
|
||||
@@ -1724,7 +1724,7 @@ void CDxfWrite::writeEntitiesSection(void)
|
||||
|
||||
//write entities content
|
||||
(*m_ofs) << (*m_ssEntity).str();
|
||||
|
||||
|
||||
|
||||
(*m_ofs) << " 0" << endl;
|
||||
(*m_ofs) << "ENDSEC" << endl;
|
||||
@@ -2001,7 +2001,7 @@ bool CDxfRead::ReadArc()
|
||||
double c[3] = {0,0,0}; // centre
|
||||
double z_extrusion_dir = 1.0;
|
||||
bool hidden = false;
|
||||
|
||||
|
||||
while(!((*m_ifs).eof()))
|
||||
{
|
||||
get_line();
|
||||
@@ -2078,9 +2078,9 @@ bool CDxfRead::ReadArc()
|
||||
get_line();
|
||||
break;
|
||||
case 230:
|
||||
//Z extrusion direction for arc
|
||||
//Z extrusion direction for arc
|
||||
get_line();
|
||||
ss.str(m_str); ss >> z_extrusion_dir; if(ss.fail()) return false;
|
||||
ss.str(m_str); ss >> z_extrusion_dir; if(ss.fail()) return false;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -2661,7 +2661,7 @@ bool CDxfRead::ReadLwPolyLine()
|
||||
ss.str(m_str); ss >> y; y = mm(y); if(ss.fail()) return false;
|
||||
y_found = true;
|
||||
break;
|
||||
case 38:
|
||||
case 38:
|
||||
// elevation
|
||||
get_line();
|
||||
ss.str(m_str); ss >> z; z = mm(z); if(ss.fail()) return false;
|
||||
@@ -2874,7 +2874,7 @@ void CDxfRead::OnReadArc(double start_angle, double end_angle, double radius, co
|
||||
temp[0] =-c[0];
|
||||
temp[1] =c[1];
|
||||
temp[2] =c[2];
|
||||
|
||||
|
||||
e[0] = -(c[0] + radius * cos(start_angle * M_PI/180));
|
||||
e[1] = (c[1] + radius * sin(start_angle * M_PI/180));
|
||||
e[2] = c[2];
|
||||
@@ -2929,12 +2929,12 @@ bool CDxfRead::ReadInsert()
|
||||
std::istringstream ss;
|
||||
ss.imbue(std::locale("C"));
|
||||
switch(n){
|
||||
case 0:
|
||||
case 0:
|
||||
// next item found
|
||||
DerefACI();
|
||||
OnReadInsert(c, s, name, rot * M_PI/180);
|
||||
return(true);
|
||||
case 8:
|
||||
case 8:
|
||||
// Layer name follows
|
||||
get_line();
|
||||
strcpy(m_layer_name, m_str);
|
||||
@@ -3021,12 +3021,12 @@ bool CDxfRead::ReadDimension()
|
||||
std::istringstream ss;
|
||||
ss.imbue(std::locale("C"));
|
||||
switch(n){
|
||||
case 0:
|
||||
case 0:
|
||||
// next item found
|
||||
DerefACI();
|
||||
OnReadDimension(s, e, p, rot * M_PI/180);
|
||||
return(true);
|
||||
case 8:
|
||||
case 8:
|
||||
// Layer name follows
|
||||
get_line();
|
||||
strcpy(m_layer_name, m_str);
|
||||
@@ -3285,7 +3285,7 @@ void CDxfRead::DoRead(const bool ignore_errors /* = false */ )
|
||||
}
|
||||
continue;
|
||||
} // End if - then
|
||||
|
||||
|
||||
else if(!strcmp(m_str, "0"))
|
||||
{
|
||||
get_line();
|
||||
@@ -3311,9 +3311,9 @@ void CDxfRead::DoRead(const bool ignore_errors /* = false */ )
|
||||
printf("CDxfRead::DoRead() Failed to read layer\n");
|
||||
//return; Some objects or tables can have "LAYER" as name...
|
||||
}
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
else if (!strcmp( m_str, "BLOCK" )) {
|
||||
if(!ReadBlockInfo())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user