Skip to content

Commit

Permalink
Fem: remove some superfluous const_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jun 24, 2022
1 parent 8573d9f commit 1aa897d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 36 deletions.
4 changes: 2 additions & 2 deletions src/Mod/Fem/App/FemMesh.cpp
Expand Up @@ -2489,7 +2489,7 @@ Base::BoundBox3d FemMesh::getBoundBox(void) const
{
Base::BoundBox3d box;

SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(getSMesh())->GetMeshDS();
const SMESHDS_Mesh* data = getSMesh()->GetMeshDS();

SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator();
for (;aNodeIter->more();) {
Expand Down Expand Up @@ -2533,7 +2533,7 @@ struct Fem::FemMesh::FemMeshInfo FemMesh::getInfo(void) const{

struct FemMeshInfo rtrn;

SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(getSMesh())->GetMeshDS();
const SMESHDS_Mesh* data = getSMesh()->GetMeshDS();
const SMDS_MeshInfo& info = data->GetMeshInfo();
rtrn.numFaces = data->NbFaces();
rtrn.numNode = info.NbNodes();
Expand Down
15 changes: 0 additions & 15 deletions src/Mod/Fem/App/FemMeshShapeObject.cpp
Expand Up @@ -230,21 +230,6 @@ App::DocumentObjectExecReturn *FemMeshShapeObject::execute(void)
myNetGenMesher.Compute();
#endif



//SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(newMesh.getSMesh())->GetMeshDS();
//const SMDS_MeshInfo& info = data->GetMeshInfo();
//int numNode = info.NbNodes();
//int numTria = info.NbTriangles();
//int numQuad = info.NbQuadrangles();
//int numPoly = info.NbPolygons();
//int numVolu = info.NbVolumes();
//int numTetr = info.NbTetras();
//int numHexa = info.NbHexas();
//int numPyrd = info.NbPyramids();
//int numPris = info.NbPrisms();
//int numHedr = info.NbPolyhedrons();

// set the value to the object
FemMesh.setValue(newMesh);

Expand Down
10 changes: 5 additions & 5 deletions src/Mod/Fem/App/FemVTKTools.cpp
Expand Up @@ -126,7 +126,7 @@ void FemVTKTools::importVTKMesh(vtkSmartPointer<vtkDataSet> dataset, FemMesh* me
vtkSmartPointer<vtkIdList> idlist= vtkSmartPointer<vtkIdList>::New();

//Now fill the SMESH datastructure
SMESH_Mesh* smesh = const_cast<SMESH_Mesh*>(mesh->getSMesh());
SMESH_Mesh* smesh = mesh->getSMesh();
SMESHDS_Mesh* meshds = smesh->GetMeshDS();
meshds->ClearMesh();

Expand Down Expand Up @@ -446,8 +446,8 @@ void FemVTKTools::exportVTKMesh(const FemMesh* mesh, vtkSmartPointer<vtkUnstruct
{

Base::Console().Log("Start: VTK mesh builder ======================\n");
SMESH_Mesh* smesh = const_cast<SMESH_Mesh*>(mesh->getSMesh());
SMESHDS_Mesh* meshDS = smesh->GetMeshDS();
const SMESH_Mesh* smesh = mesh->getSMesh();
const SMESHDS_Mesh* meshDS = smesh->GetMeshDS();

// nodes
Base::Console().Log(" Start: VTK mesh builder nodes.\n");
Expand Down Expand Up @@ -831,8 +831,8 @@ void FemVTKTools::exportFreeCADResult(const App::DocumentObject* result, vtkSmar
Base::Console().Error("Result object does not correctly link to mesh");
return;
}
SMESH_Mesh* smesh = const_cast<SMESH_Mesh*>(static_cast<FemMeshObject*>(meshObj)->FemMesh.getValue().getSMesh());
SMESHDS_Mesh* meshDS = smesh->GetMeshDS();
const SMESH_Mesh* smesh = static_cast<FemMeshObject*>(meshObj)->FemMesh.getValue().getSMesh();
const SMESHDS_Mesh* meshDS = smesh->GetMeshDS();

// all result object meshes are in mm therefore for e.g. length outputs like
// displacement we must divide by 1000
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/Command.cpp
Expand Up @@ -975,7 +975,7 @@ void DefineNodesCallback(void* ud, SoEventCallback* n)
if (docObj.size() != 1)
return;

const SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(static_cast<Fem::FemMeshObject*>(docObj[0])->FemMesh.getValue().getSMesh())->GetMeshDS();
const SMESHDS_Mesh* data = static_cast<Fem::FemMeshObject*>(docObj[0])->FemMesh.getValue().getSMesh()->GetMeshDS();

SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator();
Base::Vector3f pt2d;
Expand Down
16 changes: 8 additions & 8 deletions src/Mod/Fem/Gui/PropertyFemMeshItem.cpp
Expand Up @@ -94,7 +94,7 @@ QVariant PropertyFemMeshItem::value(const App::Property*) const
const std::vector<App::Property*>& props = getPropertyData();
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
const SMESH_Mesh* mesh = prop->getValue().getSMesh();
ctN += mesh->NbNodes();
ctE += mesh->NbEdges();
ctF += mesh->NbFaces();
Expand Down Expand Up @@ -154,7 +154,7 @@ int PropertyFemMeshItem::countNodes() const
const std::vector<App::Property*>& props = getPropertyData();
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
const SMESH_Mesh* mesh = prop->getValue().getSMesh();
ctN += mesh->NbNodes();
}

Expand All @@ -167,7 +167,7 @@ int PropertyFemMeshItem::countEdges() const
const std::vector<App::Property*>& props = getPropertyData();
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
const SMESH_Mesh* mesh = prop->getValue().getSMesh();
ctE += mesh->NbEdges();
}

Expand All @@ -180,7 +180,7 @@ int PropertyFemMeshItem::countFaces() const
const std::vector<App::Property*>& props = getPropertyData();
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
const SMESH_Mesh* mesh = prop->getValue().getSMesh();
ctF += mesh->NbFaces();
}

Expand All @@ -193,7 +193,7 @@ int PropertyFemMeshItem::countPolygons() const
const std::vector<App::Property*>& props = getPropertyData();
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
const SMESH_Mesh* mesh = prop->getValue().getSMesh();
ctP += mesh->NbPolygons();
}

Expand All @@ -206,7 +206,7 @@ int PropertyFemMeshItem::countVolumes() const
const std::vector<App::Property*>& props = getPropertyData();
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
const SMESH_Mesh* mesh = prop->getValue().getSMesh();
ctV += mesh->NbVolumes();
}

Expand All @@ -219,7 +219,7 @@ int PropertyFemMeshItem::countPolyhedrons() const
const std::vector<App::Property*>& props = getPropertyData();
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
const SMESH_Mesh* mesh = prop->getValue().getSMesh();
ctH += mesh->NbPolyhedrons();
}

Expand All @@ -232,7 +232,7 @@ int PropertyFemMeshItem::countGroups() const
const std::vector<App::Property*>& props = getPropertyData();
for (std::vector<App::Property*>::const_iterator pt = props.begin(); pt != props.end(); ++pt) {
Fem::PropertyFemMesh* prop = static_cast<Fem::PropertyFemMesh*>(*pt);
SMESH_Mesh* mesh = const_cast<SMESH_Mesh*>(prop->getValue().getSMesh());
const SMESH_Mesh* mesh = prop->getValue().getSMesh();
ctG += mesh->NbGroup();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Fem/Gui/TaskCreateNodeSet.cpp
Expand Up @@ -162,7 +162,7 @@ void TaskCreateNodeSet::DefineNodesCallback(void* ud, SoEventCallback* n)

void TaskCreateNodeSet::DefineNodes(const Base::Polygon2d& polygon, const Gui::ViewVolumeProjection& proj, bool inner)
{
const SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(pcObject->FemMesh.getValue<Fem::FemMeshObject*>()->FemMesh.getValue().getSMesh())->GetMeshDS();
const SMESHDS_Mesh* data = pcObject->FemMesh.getValue<Fem::FemMeshObject*>()->FemMesh.getValue().getSMesh()->GetMeshDS();

SMDS_NodeIteratorPtr aNodeIter = data->nodesIterator();
Base::Vector3f pt2d;
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Fem/Gui/ViewProviderFemMesh.cpp
Expand Up @@ -468,7 +468,7 @@ std::set<long> ViewProviderFemMesh::getHighlightNodes() const
void ViewProviderFemMesh::setHighlightNodes(const std::set<long>& HighlightedNodes)
{
if (!HighlightedNodes.empty()) {
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>((static_cast<Fem::FemMeshObject*>(this->pcObject)->FemMesh).getValue().getSMesh())->GetMeshDS();
const SMESHDS_Mesh* data = static_cast<Fem::FemMeshObject*>(this->pcObject)->FemMesh.getValue().getSMesh()->GetMeshDS();

pcAnoCoords->point.setNum(HighlightedNodes.size());
SbVec3f* verts = pcAnoCoords->point.startEditing();
Expand Down Expand Up @@ -722,7 +722,7 @@ void ViewProviderFEMMeshBuilder::createMesh(const App::Property* prop,

const Fem::PropertyFemMesh* mesh = static_cast<const Fem::PropertyFemMesh*>(prop);

SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(mesh->getValue().getSMesh())->GetMeshDS();
const SMESHDS_Mesh* data = mesh->getValue().getSMesh()->GetMeshDS();

int numFaces = data->NbFaces();
int numNodes = data->NbNodes();
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Fem/Gui/ViewProviderFemMeshPyImp.cpp
Expand Up @@ -257,8 +257,8 @@ Py::List ViewProviderFemMeshPy::getHighlightedNodes(void) const
void ViewProviderFemMeshPy::setHighlightedNodes(Py::List arg)
{
ViewProviderFemMesh* vp = this->getViewProviderFemMeshPtr();
SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>((static_cast<Fem::FemMeshObject*>
(vp->getObject())->FemMesh).getValue().getSMesh())->GetMeshDS();
const SMESHDS_Mesh* data = static_cast<Fem::FemMeshObject*>
(vp->getObject())->FemMesh.getValue().getSMesh()->GetMeshDS();

std::set<long> res;
for (Py::List::iterator it = arg.begin(); it != arg.end(); ++it) {
Expand Down

0 comments on commit 1aa897d

Please sign in to comment.