Gui: Use getObject<T>() helpers in classes
This commit is generated using regex based find and replace: ``` s/[\w:]+_cast\s*<([^>]+)\*>\s*\(\s*getObject\(\s*\)\)/getObject<$1>/ s/[\w:]+_cast\s*<([^>]+)\*>\s*\(\s*([^)]*)\s*->\s*getObject\(\s*\)\)/$2->getObject<$1>()/ ``` To regenerate if needed.
This commit is contained in:
@@ -230,7 +230,7 @@ void MeshFaceAddition::finishEditing()
|
||||
|
||||
void MeshFaceAddition::addFace()
|
||||
{
|
||||
Mesh::Feature* mf = static_cast<Mesh::Feature*>(faceView->mesh->getObject());
|
||||
Mesh::Feature* mf = faceView->mesh->getObject<Mesh::Feature>();
|
||||
App::Document* doc = mf->getDocument();
|
||||
doc->openTransaction("Add triangle");
|
||||
Mesh::MeshObject* mesh = mf->Mesh.startEditing();
|
||||
@@ -290,7 +290,7 @@ void MeshFaceAddition::showMarker(SoPickedPoint* pp)
|
||||
if (detail) {
|
||||
if (detail->isOfType(SoFaceDetail::getClassTypeId())) {
|
||||
const SoFaceDetail* fd = static_cast<const SoFaceDetail*>(detail);
|
||||
Mesh::Feature* mf = static_cast<Mesh::Feature*>(faceView->mesh->getObject());
|
||||
Mesh::Feature* mf = faceView->mesh->getObject<Mesh::Feature>();
|
||||
const MeshCore::MeshFacetArray& facets =
|
||||
mf->Mesh.getValuePtr()->getKernel().GetFacets();
|
||||
const MeshCore::MeshPointArray& points =
|
||||
@@ -485,7 +485,7 @@ MeshFillHole::~MeshFillHole()
|
||||
|
||||
void MeshFillHole::startEditing(MeshGui::ViewProviderMesh* vp)
|
||||
{
|
||||
this->myMesh = static_cast<Mesh::Feature*>(vp->getObject());
|
||||
this->myMesh = vp->getObject<Mesh::Feature>();
|
||||
|
||||
Gui::View3DInventor* view = static_cast<Gui::View3DInventor*>(parent());
|
||||
Gui::View3DInventorViewer* viewer = view->getViewer();
|
||||
|
||||
@@ -255,7 +255,7 @@ void MeshSelection::fullSelection()
|
||||
// select the complete meshes
|
||||
std::list<ViewProviderMesh*> views = getViewProviders();
|
||||
for (auto view : views) {
|
||||
Mesh::Feature* mf = static_cast<Mesh::Feature*>(view->getObject());
|
||||
Mesh::Feature* mf = view->getObject<Mesh::Feature>();
|
||||
const Mesh::MeshObject* mo = mf->Mesh.getValuePtr();
|
||||
std::vector<Mesh::FacetIndex> faces(mo->countFacets());
|
||||
std::generate(faces.begin(), faces.end(), Base::iotaGen<Mesh::FacetIndex>(0));
|
||||
@@ -277,7 +277,7 @@ bool MeshSelection::deleteSelection()
|
||||
bool selected = false;
|
||||
std::list<ViewProviderMesh*> views = getViewProviders();
|
||||
for (auto view : views) {
|
||||
Mesh::Feature* mf = static_cast<Mesh::Feature*>(view->getObject());
|
||||
Mesh::Feature* mf = view->getObject<Mesh::Feature>();
|
||||
unsigned long ct = MeshCore::MeshAlgorithm(mf->Mesh.getValue().getKernel())
|
||||
.CountFacetFlag(MeshCore::MeshFacet::SELECTED);
|
||||
if (ct > 0) {
|
||||
@@ -302,7 +302,7 @@ bool MeshSelection::deleteSelectionBorder()
|
||||
bool deletion = false;
|
||||
std::list<ViewProviderMesh*> views = getViewProviders();
|
||||
for (auto view : views) {
|
||||
Mesh::Feature* mf = static_cast<Mesh::Feature*>(view->getObject());
|
||||
Mesh::Feature* mf = view->getObject<Mesh::Feature>();
|
||||
|
||||
// mark the selected facet as visited
|
||||
std::vector<Mesh::FacetIndex> selection;
|
||||
@@ -361,7 +361,7 @@ void MeshSelection::selectComponent(int size)
|
||||
{
|
||||
std::list<ViewProviderMesh*> views = getViewProviders();
|
||||
for (auto view : views) {
|
||||
Mesh::Feature* mf = static_cast<Mesh::Feature*>(view->getObject());
|
||||
Mesh::Feature* mf = view->getObject<Mesh::Feature>();
|
||||
const Mesh::MeshObject* mo = mf->Mesh.getValuePtr();
|
||||
|
||||
std::vector<std::vector<Mesh::FacetIndex>> segm;
|
||||
@@ -383,7 +383,7 @@ void MeshSelection::deselectComponent(int size)
|
||||
{
|
||||
std::list<ViewProviderMesh*> views = getViewProviders();
|
||||
for (auto view : views) {
|
||||
Mesh::Feature* mf = static_cast<Mesh::Feature*>(view->getObject());
|
||||
Mesh::Feature* mf = view->getObject<Mesh::Feature>();
|
||||
const Mesh::MeshObject* mo = mf->Mesh.getValuePtr();
|
||||
|
||||
std::vector<std::vector<Mesh::FacetIndex>> segm;
|
||||
@@ -480,8 +480,7 @@ void MeshSelection::selectGLCallback(void* ud, SoEventCallback* n)
|
||||
std::list<ViewProviderMesh*> views = self->getViewProviders();
|
||||
for (auto vp : views) {
|
||||
std::vector<Mesh::FacetIndex> faces;
|
||||
const Mesh::MeshObject& mesh =
|
||||
static_cast<Mesh::Feature*>(vp->getObject())->Mesh.getValue();
|
||||
const Mesh::MeshObject& mesh = vp->getObject<Mesh::Feature>()->Mesh.getValue();
|
||||
const MeshCore::MeshKernel& kernel = mesh.getKernel();
|
||||
|
||||
// simply get all triangles under the polygon
|
||||
@@ -489,7 +488,7 @@ void MeshSelection::selectGLCallback(void* ud, SoEventCallback* n)
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
|
||||
Base::Placement plm = static_cast<Mesh::Feature*>(vp->getObject())->Placement.getValue();
|
||||
Base::Placement plm = vp->getObject<Mesh::Feature>()->Placement.getValue();
|
||||
proj.setTransform(plm.toMatrix());
|
||||
vp->getFacetsFromPolygon(polygon, proj, true, faces);
|
||||
|
||||
|
||||
@@ -771,8 +771,8 @@ void ViewProviderMesh::exportMesh(const char* filename, const char* fmt) const
|
||||
mat.diffuseColor.emplace_back(c[0], c[1], c[2]);
|
||||
}
|
||||
|
||||
Mesh::MeshObject mesh = static_cast<Mesh::Feature*>(getObject())->Mesh.getValue();
|
||||
mesh.setPlacement(static_cast<Mesh::Feature*>(getObject())->globalPlacement());
|
||||
Mesh::MeshObject mesh = getObject<Mesh::Feature>()->Mesh.getValue();
|
||||
mesh.setPlacement(getObject<Mesh::Feature>()->globalPlacement());
|
||||
if (mat.diffuseColor.size() == mesh.countPoints()) {
|
||||
mat.binding = MeshCore::MeshIO::PER_VERTEX;
|
||||
}
|
||||
@@ -976,7 +976,7 @@ public:
|
||||
App::Document* doc = gui->getDocument();
|
||||
|
||||
auto cpy = static_cast<Mesh::Feature*>(doc->addObject("Mesh::Feature"));
|
||||
auto org = static_cast<Mesh::Feature*>(mesh->getObject());
|
||||
auto org = mesh->getObject<Mesh::Feature>();
|
||||
cpy->Label.setValue(org->Label.getValue());
|
||||
cpy->Mesh.setValue(org->Mesh.getValue());
|
||||
|
||||
@@ -1023,9 +1023,8 @@ void ViewProviderMesh::clipMeshCallback(void* ud, SoEventCallback* cb)
|
||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
proj.setTransform(static_cast<Mesh::Feature*>(self->getObject())
|
||||
->Placement.getValue()
|
||||
.toMatrix());
|
||||
proj.setTransform(
|
||||
self->getObject<Mesh::Feature>()->Placement.getValue().toMatrix());
|
||||
if (role == Gui::SelectionRole::Inner) {
|
||||
self->cutMesh(clPoly, proj, true);
|
||||
commitCommand = true;
|
||||
@@ -1093,9 +1092,8 @@ void ViewProviderMesh::trimMeshCallback(void* ud, SoEventCallback* cb)
|
||||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
proj.setTransform(static_cast<Mesh::Feature*>(self->getObject())
|
||||
->Placement.getValue()
|
||||
.toMatrix());
|
||||
proj.setTransform(
|
||||
self->getObject<Mesh::Feature>()->Placement.getValue().toMatrix());
|
||||
if (role == Gui::SelectionRole::Inner) {
|
||||
self->trimMesh(clPoly, proj, true);
|
||||
commitCommand = true;
|
||||
@@ -1181,8 +1179,7 @@ void ViewProviderMesh::partMeshCallback(void* ud, SoEventCallback* cb)
|
||||
auto that = static_cast<ViewProviderMesh*>(view);
|
||||
if (that->getEditingMode() > -1) {
|
||||
that->finishEditing();
|
||||
Base::Placement plm =
|
||||
static_cast<Mesh::Feature*>(that->getObject())->Placement.getValue();
|
||||
Base::Placement plm = that->getObject<Mesh::Feature>()->Placement.getValue();
|
||||
plm.invert();
|
||||
MeshCore::MeshKernel copyToolMesh(toolMesh);
|
||||
copyToolMesh.Transform(plm.toMatrix());
|
||||
@@ -1255,8 +1252,7 @@ void ViewProviderMesh::segmMeshCallback(void* ud, SoEventCallback* cb)
|
||||
auto that = static_cast<ViewProviderMesh*>(view);
|
||||
if (that->getEditingMode() > -1) {
|
||||
that->finishEditing();
|
||||
Base::Placement plm =
|
||||
static_cast<Mesh::Feature*>(that->getObject())->Placement.getValue();
|
||||
Base::Placement plm = that->getObject<Mesh::Feature>()->Placement.getValue();
|
||||
plm.invert();
|
||||
MeshCore::MeshKernel copyToolMesh(toolMesh);
|
||||
copyToolMesh.Transform(plm.toMatrix());
|
||||
|
||||
@@ -315,7 +315,7 @@ void ViewProviderMeshCurvature::updateData(const App::Property* prop)
|
||||
if (auto view = dynamic_cast<ViewProviderMesh*>(pDoc->getViewProvider(object))) {
|
||||
this->pcLinkRoot->addChild(view->getHighlightNode());
|
||||
|
||||
auto mesh = dynamic_cast<Mesh::Feature*>(view->getObject());
|
||||
auto mesh = view->getObject<Mesh::Feature>();
|
||||
Base::Placement plm = mesh->Placement.getValue();
|
||||
ViewProviderMesh::updateTransform(plm, pcTransform);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user