Fem: modernize type checking
This commit is contained in:
@@ -462,19 +462,19 @@ const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub& direct
|
||||
return Base::Vector3d(0, 0, 0);
|
||||
}
|
||||
|
||||
if (obj->getTypeId().isDerivedFrom(App::Line::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom<App::Line>()) {
|
||||
Base::Vector3d vec(1.0, 0.0, 0.0);
|
||||
static_cast<App::Line*>(obj)->Placement.getValue().multVec(vec, vec);
|
||||
return vec;
|
||||
}
|
||||
|
||||
if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom<App::Plane>()) {
|
||||
Base::Vector3d vec(0.0, 0.0, 1.0);
|
||||
static_cast<App::Plane*>(obj)->Placement.getValue().multVec(vec, vec);
|
||||
return vec;
|
||||
}
|
||||
|
||||
if (!obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
|
||||
if (!obj->isDerivedFrom<Part::Feature>()) {
|
||||
std::stringstream str;
|
||||
str << "Type is not a line, plane or Part object";
|
||||
throw Base::TypeError(str.str());
|
||||
|
||||
@@ -71,7 +71,7 @@ PyObject* FemPostPipelinePy::load(PyObject* args)
|
||||
}
|
||||
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(py)->getDocumentObjectPtr();
|
||||
if (!obj->getTypeId().isDerivedFrom(FemResultObject::getClassTypeId())) {
|
||||
if (!obj->isDerivedFrom<FemResultObject>()) {
|
||||
PyErr_SetString(PyExc_TypeError, "object is not a result object");
|
||||
return nullptr;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ PyObject* FemPostPipelinePy::holdsPostObject(PyObject* args)
|
||||
}
|
||||
|
||||
App::DocumentObject* obj = static_cast<App::DocumentObjectPy*>(py)->getDocumentObjectPtr();
|
||||
if (!obj->getTypeId().isDerivedFrom(FemPostObject::getClassTypeId())) {
|
||||
if (!obj->isDerivedFrom<FemPostObject>()) {
|
||||
PyErr_SetString(PyExc_TypeError, "object is not a post-processing object");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ App::DocumentObject* getObjectByType(const Base::Type type)
|
||||
if (obj->getTypeId() == type) {
|
||||
return obj;
|
||||
}
|
||||
if (obj->getTypeId() == FemAnalysis::getClassTypeId()) {
|
||||
if (obj->is<FemAnalysis>()) {
|
||||
std::vector<App::DocumentObject*> fem = (static_cast<FemAnalysis*>(obj))->Group.getValues();
|
||||
for (const auto& it : fem) {
|
||||
if (it->getTypeId().isDerivedFrom(type)) {
|
||||
@@ -624,7 +624,7 @@ App::DocumentObject* createObjectByType(const Base::Type type)
|
||||
}
|
||||
App::DocumentObject* obj = pcDoc->getActiveObject();
|
||||
|
||||
if (obj->getTypeId() == FemAnalysis::getClassTypeId()) {
|
||||
if (obj->is<FemAnalysis>()) {
|
||||
App::DocumentObject* newobj = pcDoc->addObject(type.getName());
|
||||
static_cast<FemAnalysis*>(obj)->addObject(newobj);
|
||||
return newobj;
|
||||
|
||||
@@ -87,7 +87,7 @@ private:
|
||||
&& object) {
|
||||
App::DocumentObject* obj =
|
||||
static_cast<App::DocumentObjectPy*>(object)->getDocumentObjectPtr();
|
||||
if (!obj || !obj->getTypeId().isDerivedFrom(Fem::FemAnalysis::getClassTypeId())) {
|
||||
if (!obj || !obj->isDerivedFrom<Fem::FemAnalysis>()) {
|
||||
throw Py::Exception(Base::PyExc_FC_GeneralError,
|
||||
"Active Analysis object have to be of type Fem::FemAnalysis!");
|
||||
}
|
||||
|
||||
@@ -1091,7 +1091,7 @@ void CmdFemDefineNodesSet::activated(int)
|
||||
if (it == docObj.begin()) {
|
||||
Gui::Document* doc = getActiveGuiDocument();
|
||||
Gui::MDIView* view = doc->getActiveView();
|
||||
if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
|
||||
if (view->isDerivedFrom<Gui::View3DInventor>()) {
|
||||
Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer();
|
||||
viewer->setEditing(true);
|
||||
viewer->startSelection(Gui::View3DInventorViewer::Clip);
|
||||
|
||||
@@ -91,7 +91,7 @@ void TaskCreateNodeSet::Poly()
|
||||
{
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
Gui::MDIView* view = doc->getActiveView();
|
||||
if (view->getTypeId().isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
|
||||
if (view->isDerivedFrom<Gui::View3DInventor>()) {
|
||||
Gui::View3DInventorViewer* viewer = ((Gui::View3DInventor*)view)->getViewer();
|
||||
viewer->setEditing(true);
|
||||
viewer->startSelection(Gui::View3DInventorViewer::Clip);
|
||||
|
||||
@@ -226,7 +226,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(
|
||||
if (pcAnalysis) {
|
||||
std::vector<App::DocumentObject*> fem = pcAnalysis->Group.getValues();
|
||||
for (auto it : fem) {
|
||||
if (it->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) {
|
||||
if (it->isDerivedFrom<Fem::FemMeshObject>()) {
|
||||
pcMesh = static_cast<Fem::FemMeshObject*>(it);
|
||||
}
|
||||
}
|
||||
@@ -238,7 +238,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(
|
||||
}
|
||||
if (pcMesh) {
|
||||
App::Property* prop = pcMesh->getPropertyByName("Shape"); // PropertyLink
|
||||
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) {
|
||||
if (prop && prop->isDerivedFrom<App::PropertyLink>()) {
|
||||
App::PropertyLink* pcLink = static_cast<App::PropertyLink*>(prop);
|
||||
Part::Feature* pcPart = dynamic_cast<Part::Feature*>(pcLink->getValue());
|
||||
if (pcPart) { // deduct dimension from part_obj.Shape.ShapeType
|
||||
@@ -267,7 +267,7 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(
|
||||
if (pcAnalysis) {
|
||||
std::vector<App::DocumentObject*> fem = pcAnalysis->Group.getValues();
|
||||
for (auto it : fem) {
|
||||
if (it->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId())) {
|
||||
if (it->isDerivedFrom<Fem::FemSolverObject>()) {
|
||||
pcSolver = static_cast<Fem::FemSolverObject*>(it);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1332,8 +1332,7 @@ void TaskPostClip::collectImplicitFunctions()
|
||||
if (!pipelines.empty()) {
|
||||
Fem::FemPostPipeline* pipeline = pipelines.front();
|
||||
if (pipeline->Functions.getValue()
|
||||
&& pipeline->Functions.getValue()->getTypeId()
|
||||
== Fem::FemPostFunctionProvider::getClassTypeId()) {
|
||||
&& pipeline->Functions.getValue()->is<Fem::FemPostFunctionProvider>()) {
|
||||
|
||||
ui->FunctionBox->clear();
|
||||
QStringList items;
|
||||
@@ -1383,8 +1382,7 @@ void TaskPostClip::onFunctionBoxCurrentIndexChanged(int idx)
|
||||
if (!pipelines.empty()) {
|
||||
Fem::FemPostPipeline* pipeline = pipelines.front();
|
||||
if (pipeline->Functions.getValue()
|
||||
&& pipeline->Functions.getValue()->getTypeId()
|
||||
== Fem::FemPostFunctionProvider::getClassTypeId()) {
|
||||
&& pipeline->Functions.getValue()->is<Fem::FemPostFunctionProvider>()) {
|
||||
|
||||
const std::vector<App::DocumentObject*>& funcs =
|
||||
static_cast<Fem::FemPostFunctionProvider*>(pipeline->Functions.getValue())
|
||||
@@ -1617,8 +1615,7 @@ void TaskPostCut::collectImplicitFunctions()
|
||||
if (!pipelines.empty()) {
|
||||
Fem::FemPostPipeline* pipeline = pipelines.front();
|
||||
if (pipeline->Functions.getValue()
|
||||
&& pipeline->Functions.getValue()->getTypeId()
|
||||
== Fem::FemPostFunctionProvider::getClassTypeId()) {
|
||||
&& pipeline->Functions.getValue()->is<Fem::FemPostFunctionProvider>()) {
|
||||
|
||||
ui->FunctionBox->clear();
|
||||
QStringList items;
|
||||
@@ -1668,8 +1665,7 @@ void TaskPostCut::onFunctionBoxCurrentIndexChanged(int idx)
|
||||
if (!pipelines.empty()) {
|
||||
Fem::FemPostPipeline* pipeline = pipelines.front();
|
||||
if (pipeline->Functions.getValue()
|
||||
&& pipeline->Functions.getValue()->getTypeId()
|
||||
== Fem::FemPostFunctionProvider::getClassTypeId()) {
|
||||
&& pipeline->Functions.getValue()->is<Fem::FemPostFunctionProvider>()) {
|
||||
|
||||
const std::vector<App::DocumentObject*>& funcs =
|
||||
static_cast<Fem::FemPostFunctionProvider*>(pipeline->Functions.getValue())
|
||||
|
||||
@@ -223,32 +223,32 @@ bool ViewProviderFemAnalysis::canDragObject(App::DocumentObject* obj) const
|
||||
if (!obj) {
|
||||
return false;
|
||||
}
|
||||
if (obj->getTypeId().isDerivedFrom(Fem::FemMeshObject::getClassTypeId())) {
|
||||
if (obj->isDerivedFrom<Fem::FemMeshObject>()) {
|
||||
return true;
|
||||
}
|
||||
else if (obj->getTypeId().isDerivedFrom(Fem::FemSolverObject::getClassTypeId())) {
|
||||
else if (obj->isDerivedFrom<Fem::FemSolverObject>()) {
|
||||
return true;
|
||||
}
|
||||
else if (obj->getTypeId().isDerivedFrom(Fem::FemResultObject::getClassTypeId())) {
|
||||
else if (obj->isDerivedFrom<Fem::FemResultObject>()) {
|
||||
return true;
|
||||
}
|
||||
else if (obj->getTypeId().isDerivedFrom(Fem::Constraint::getClassTypeId())) {
|
||||
else if (obj->isDerivedFrom<Fem::Constraint>()) {
|
||||
return true;
|
||||
}
|
||||
else if (obj->getTypeId().isDerivedFrom(Fem::FemSetObject::getClassTypeId())) {
|
||||
else if (obj->isDerivedFrom<Fem::FemSetObject>()) {
|
||||
return true;
|
||||
}
|
||||
else if (obj->getTypeId().isDerivedFrom(Base::Type::fromName("Fem::FeaturePython"))) {
|
||||
return true;
|
||||
}
|
||||
else if (obj->getTypeId().isDerivedFrom(App::MaterialObject::getClassTypeId())) {
|
||||
else if (obj->isDerivedFrom<App::MaterialObject>()) {
|
||||
return true;
|
||||
}
|
||||
else if (obj->getTypeId().isDerivedFrom(App::TextDocument::getClassTypeId())) {
|
||||
else if (obj->isDerivedFrom<App::TextDocument>()) {
|
||||
return true;
|
||||
}
|
||||
#ifdef FC_USE_VTK
|
||||
else if (obj->getTypeId().isDerivedFrom(Fem::FemPostObject::getClassTypeId())) {
|
||||
else if (obj->isDerivedFrom<Fem::FemPostObject>()) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -930,7 +930,7 @@ void ViewProviderFemPostObject::hide()
|
||||
App::DocumentObject* firstVisiblePostObject = nullptr;
|
||||
// step through the objects
|
||||
for (auto it : ObjectsList) {
|
||||
if (it->getTypeId().isDerivedFrom(Fem::FemPostObject::getClassTypeId())) {
|
||||
if (it->isDerivedFrom<Fem::FemPostObject>()) {
|
||||
if (!firstVisiblePostObject && it->Visibility.getValue()
|
||||
&& !it->isDerivedFrom(Fem::FemPostDataAtPointFilter::getClassTypeId())) {
|
||||
firstVisiblePostObject = it;
|
||||
|
||||
Reference in New Issue
Block a user