Import: modernize C++11

* use nullptr
This commit is contained in:
wmayer
2022-03-23 19:11:33 +01:00
parent 1b9f30fe76
commit 84f5b40789
9 changed files with 45 additions and 45 deletions

View File

@@ -44,7 +44,7 @@ PyMOD_INIT_FUNC(Import)
}
catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
PyMOD_Return(0);
PyMOD_Return(nullptr);
}
// add mesh elements

View File

@@ -133,12 +133,12 @@ private:
Py::Object importer(const Py::Tuple& args, const Py::Dict &kwds)
{
char* Name;
char* DocName=0;
char* DocName=nullptr;
PyObject *importHidden = Py_None;
PyObject *merge = Py_None;
PyObject *useLinkGroup = Py_None;
int mode = -1;
static char* kwd_list[] = {"name", "docName","importHidden","merge","useLinkGroup","mode",0};
static char* kwd_list[] = {"name", "docName","importHidden","merge","useLinkGroup","mode",nullptr};
if(!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "et|sOOOi",
kwd_list,"utf-8",&Name,&DocName,&importHidden,&merge,&useLinkGroup,&mode))
throw Py::Exception();
@@ -151,7 +151,7 @@ private:
//Base::Console().Log("Insert in Part with %s",Name);
Base::FileInfo file(Utf8Name.c_str());
App::Document *pcDoc = 0;
App::Document *pcDoc = nullptr;
if (DocName) {
pcDoc = App::GetApplication().getDocument(DocName);
}
@@ -289,7 +289,7 @@ private:
PyObject *exportHidden = Py_None;
PyObject *legacy = Py_None;
PyObject *keepPlacement = Py_None;
static char* kwd_list[] = {"obj", "name", "exportHidden", "legacy", "keepPlacement",0};
static char* kwd_list[] = {"obj", "name", "exportHidden", "legacy", "keepPlacement",nullptr};
if(!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "Oet|OOO",
kwd_list,&object,"utf-8",&Name,&exportHidden,&legacy,&keepPlacement))
throw Py::Exception();
@@ -407,7 +407,7 @@ private:
Py::Object readDXF(const Py::Tuple& args)
{
char* Name;
const char* DocName=0;
const char* DocName=nullptr;
const char* optionSource = nullptr;
std::string defaultOptions = "User parameter:BaseApp/Preferences/Mod/Draft";
bool IgnoreErrors=true;

View File

@@ -270,7 +270,7 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc,
if (!localValue.empty()) {
if (aShapeTool->IsAssembly(label)) {
App::Part *pcPart = NULL;
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);
@@ -310,7 +310,7 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc,
TopExp_Explorer xp;
int ctSolids = 0, ctShells = 0, ctVertices = 0, ctEdges = 0;
std::vector<App::DocumentObject *> localValue;
App::Part *pcPart = NULL;
App::Part *pcPart = nullptr;
if (mergeShape) {

View File

@@ -121,7 +121,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 = 0)
Handle(XCAFDoc_ColorTool) aColorTool, const char *msg = nullptr)
{
if(label.IsNull() || !FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG))
return;
@@ -171,7 +171,7 @@ static void dumpLabels(TDF_Label label, Handle(XCAFDoc_ShapeTool) aShapeTool,
/////////////////////////////////////////////////////////////////////
ImportOCAF2::ImportOCAF2(Handle(TDocStd_Document) h, App::Document* d, const std::string& name)
: pDoc(h), pDocument(d), default_name(name), sequencer(0)
: pDoc(h), pDocument(d), default_name(name), sequencer(nullptr)
{
aShapeTool = XCAFDoc_DocumentTool::ShapeTool (pDoc->Main());
aColorTool = XCAFDoc_DocumentTool::ColorTool(pDoc->Main());
@@ -303,7 +303,7 @@ App::DocumentObject *ImportOCAF2::expandShape(
App::Document *doc, TDF_Label label, const TopoDS_Shape &shape)
{
if(shape.IsNull() || !TopExp_Explorer(shape,TopAbs_VERTEX).More())
return 0;
return nullptr;
// When saved as compound, STEP file does not support instance sharing,
// meaning that even if the source compound may contain child shapes of
@@ -338,7 +338,7 @@ App::DocumentObject *ImportOCAF2::expandShape(
}
}
if(objs.empty())
return 0;
return nullptr;
auto compound = static_cast<Part::Compound2*>(doc->addObject("Part::Compound2","Compound"));
compound->Links.setValues(objs);
// compound->Visibility.setValue(false);
@@ -346,7 +346,7 @@ App::DocumentObject *ImportOCAF2::expandShape(
return compound;
}
Info info;
info.obj = 0;
info.obj = nullptr;
createObject(doc,label,shape,info,false);
return info.obj;
}
@@ -557,7 +557,7 @@ App::DocumentObject* ImportOCAF2::loadShapes()
ImportLegacy legacy(*this);
legacy.setMerge(merge);
legacy.loadShapes();
return 0;
return nullptr;
}
if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG))
@@ -567,7 +567,7 @@ App::DocumentObject* ImportOCAF2::loadShapes()
aShapeTool->GetShapes(labels);
Base::SequencerLauncher seq("Importing...",labels.Length());
FC_MSG("free shape count " << labels.Length());
sequencer = showProgress?&seq:0;
sequencer = showProgress?&seq:nullptr;
labels.Clear();
myShapes.clear();
@@ -595,7 +595,7 @@ App::DocumentObject* ImportOCAF2::loadShapes()
vis.push_back(aColorTool->IsVisible(label));
}
}
App::DocumentObject *ret = 0;
App::DocumentObject *ret = nullptr;
if(objs.size()==1) {
ret = objs.front();
}else {
@@ -624,7 +624,7 @@ App::DocumentObject* ImportOCAF2::loadShapes()
ret = feature;
ret->recomputeFeature(true);
}
sequencer = 0;
sequencer = nullptr;
return ret;
}
@@ -690,7 +690,7 @@ App::DocumentObject *ImportOCAF2::loadShape(App::Document *doc,
TDF_Label label, const TopoDS_Shape &shape, bool baseOnly, bool newDoc)
{
if(shape.IsNull())
return 0;
return nullptr;
auto baseShape = shape.Located(TopLoc_Location());
auto it = myShapes.find(baseShape);
@@ -705,7 +705,7 @@ App::DocumentObject *ImportOCAF2::loadShape(App::Document *doc,
else
res = createAssembly(doc,baseLabel,baseShape,info,newDoc);
if(!res)
return 0;
return nullptr;
setObjectName(info,baseLabel);
it = myShapes.emplace(baseShape,info).first;
}
@@ -1122,22 +1122,22 @@ void ExportOCAF2::exportObjects(std::vector<App::DocumentObject*> &objs, const c
myNames.clear();
mySetups.clear();
if(objs.size()==1)
exportObject(objs.front(),0,TDF_Label());
exportObject(objs.front(),nullptr,TDF_Label());
else {
auto label = aShapeTool->NewShape();
App::Document *doc = 0;
App::Document *doc = nullptr;
bool sameDoc = true;
for(auto obj : objs) {
if(doc)
sameDoc = sameDoc && doc==obj->getDocument();
else
doc = obj->getDocument();
exportObject(obj,0,label);
exportObject(obj,nullptr,label);
}
if(!name && doc && sameDoc)
name = doc->getName();
setName(label,0,name);
setName(label,nullptr,name);
}
if(FC_LOG_INSTANCE.isEnabled(FC_LOGLEVEL_LOG))
@@ -1153,7 +1153,7 @@ 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,0,&obj,false,!sub);
auto shape = Part::Feature::getTopoShape(parentObj,sub,false,nullptr,&obj,false,!sub);
if(!obj || shape.isNull()) {
if (obj)
FC_WARN(obj->getFullName() << " has null shape");
@@ -1214,7 +1214,7 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
setupObject(label,name?parentObj:obj,shape,prefix,name);
return label;
}
auto next = linked->getLinkedObject(false,0,false,depth++);
auto next = linked->getLinkedObject(false,nullptr,false,depth++);
if(!next || linked==next)
break;
linked = next;
@@ -1258,7 +1258,7 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
label = aShapeTool->AddShape(shape.getShape(),Standard_False, Standard_False);
auto o = name?parentObj:obj;
if(o!=linked)
setupObject(label,linked,shape,prefix,0,true);
setupObject(label,linked,shape,prefix,nullptr,true);
setupObject(label,o,shape,prefix,name,true);
}
@@ -1278,9 +1278,9 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
// check for link array
auto linkArray = obj->getLinkedObject(true)->getExtensionByType<App::LinkBaseExtension>(true);
if(linkArray && (linkArray->getShowElementValue() || !linkArray->getElementCountValue()))
linkArray = 0;
linkArray = nullptr;
for(auto &subobj : subs) {
App::DocumentObject *parentGrp = 0;
App::DocumentObject *parentGrp = nullptr;
std::string childName;
auto sobj = obj->resolve(subobj.c_str(),&parentGrp,&childName);
if(!sobj) {
@@ -1303,7 +1303,7 @@ TDF_Label ExportOCAF2::exportObject(App::DocumentObject* parentObj,
if(!vis && !exportHidden)
continue;
TDF_Label childLabel = exportObject(obj,subobj.c_str(),label,linkArray?childName.c_str():0);
TDF_Label childLabel = exportObject(obj,subobj.c_str(),label,linkArray?childName.c_str():nullptr);
if(childLabel.IsNull())
continue;

View File

@@ -95,8 +95,8 @@ public:
private:
struct Info {
std::string baseName;
App::DocumentObject *obj = 0;
App::PropertyPlacement *propPlacement = 0;
App::DocumentObject *obj = nullptr;
App::PropertyPlacement *propPlacement = nullptr;
App::Color faceColor;
App::Color edgeColor;
bool hasFaceColor = false;
@@ -176,15 +176,15 @@ public:
void setExportHiddenObject(bool enable) {exportHidden=enable;}
void setKeepPlacement(bool enable) {keepPlacement=enable;}
void exportObjects(std::vector<App::DocumentObject*> &objs, const char *name=0);
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=0);
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=0, bool force=false);
void setName(TDF_Label label, App::DocumentObject *obj, const char *name=0);
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:

View File

@@ -38,7 +38,7 @@ int StepShapePy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyObject* StepShapePy::read(PyObject * /*args*/)
{
PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
return 0;
return nullptr;
}
@@ -47,7 +47,7 @@ PyObject* StepShapePy::read(PyObject * /*args*/)
PyObject *StepShapePy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
return nullptr;
}
int StepShapePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)

View File

@@ -43,7 +43,7 @@ PyMOD_INIT_FUNC(ImportGui)
{
if (!Gui::Application::Instance) {
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
PyMOD_Return(0);
PyMOD_Return(nullptr);
}
try {
@@ -51,7 +51,7 @@ PyMOD_INIT_FUNC(ImportGui)
}
catch(const Base::Exception& e) {
PyErr_SetString(PyExc_ImportError, e.what());
PyMOD_Return(0);
PyMOD_Return(nullptr);
}
PyObject* mod = ImportGui::initModule();

View File

@@ -396,12 +396,12 @@ private:
Py::Object insert(const Py::Tuple& args, const Py::Dict &kwds)
{
char* Name;
char* DocName=0;
char* DocName=nullptr;
PyObject *importHidden = Py_None;
PyObject *merge = Py_None;
PyObject *useLinkGroup = Py_None;
int mode = -1;
static char* kwd_list[] = {"name","docName","importHidden","merge","useLinkGroup","mode",0};
static char* kwd_list[] = {"name","docName","importHidden","merge","useLinkGroup","mode",nullptr};
if(!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "et|sOOOi",
kwd_list,"utf-8",&Name,&DocName,&importHidden,&merge,&useLinkGroup,&mode))
throw Py::Exception();
@@ -414,7 +414,7 @@ private:
//Base::Console().Log("Insert in Part with %s",Name);
Base::FileInfo file(Utf8Name.c_str());
App::Document *pcDoc = 0;
App::Document *pcDoc = nullptr;
if (DocName) {
pcDoc = App::GetApplication().getDocument(DocName);
}
@@ -564,7 +564,7 @@ private:
PyObject *exportHidden = Py_None;
PyObject *legacy = Py_None;
PyObject *keepPlacement = Py_None;
static char* kwd_list[] = {"obj", "name", "exportHidden", "legacy", "keepPlacement",0};
static char* kwd_list[] = {"obj", "name", "exportHidden", "legacy", "keepPlacement",nullptr};
if(!PyArg_ParseTupleAndKeywords(args.ptr(), kwds.ptr(), "Oet|OOO",
kwd_list,&object,"utf-8",&Name,&exportHidden,&legacy,&keepPlacement))
throw Py::Exception();
@@ -774,7 +774,7 @@ private:
throw Py::Exception(PyExc_IOError, "no supported file format");
}
static QPointer<QDialog> dlg = 0;
static QPointer<QDialog> dlg = nullptr;
if (!dlg) {
dlg = new QDialog(Gui::getMainWindow());
QTreeWidget* tree = new QTreeWidget();

View File

@@ -66,7 +66,7 @@ void FCCmdImportReadBREP::activated(int iMsg)
bool FCCmdImportReadBREP::isActive(void)
{
return getGuiApplication()->activeDocument() != 0;
return getGuiApplication()->activeDocument() != nullptr;
}
//===========================================================================