Surface: modernize type checking

This commit is contained in:
Florian Foinant-Willig
2023-10-15 21:39:10 +02:00
parent 24934d7843
commit bb3eb31d4e
9 changed files with 13 additions and 13 deletions

View File

@@ -63,7 +63,7 @@ App::DocumentObjectExecReturn* Cut::execute()
Part::TopoShape ts2;
// Get first toposhape
if (shapes[0]->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (shapes[0]->isDerivedFrom<Part::Feature>()) {
ts1 = static_cast<Part::Feature*>(shapes[0])->Shape.getShape(); // Part::TopoShape 1
}
else {
@@ -71,7 +71,7 @@ App::DocumentObjectExecReturn* Cut::execute()
}
// Get second toposhape
if (shapes[1]->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (shapes[1]->isDerivedFrom<Part::Feature>()) {
ts2 = static_cast<Part::Feature*>(shapes[1])->Shape.getShape();
}
else {

View File

@@ -95,7 +95,7 @@ short Extend::mustExecute() const
App::DocumentObjectExecReturn* Extend::execute()
{
App::DocumentObject* part = Face.getValue();
if (!part || !part->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (!part || !part->isDerivedFrom<Part::Feature>()) {
return new App::DocumentObjectExecReturn("No shape linked.");
}
const auto& faces = Face.getSubValues();

View File

@@ -141,7 +141,7 @@ void Filling::addConstraints(BRepFill_Filling& builder,
App::DocumentObject* obj = edge_obj[index];
const std::string& sub = edge_sub[index];
if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (obj && obj->isDerivedFrom<Part::Feature>()) {
// get the sub-edge of the part's shape
const Part::TopoShape& shape = static_cast<Part::Feature*>(obj)->Shape.getShape();
TopoDS_Shape edge = shape.getSubShape(sub.c_str());
@@ -217,7 +217,7 @@ void Filling::addConstraints(BRepFill_Filling& builder,
for (std::size_t index = 0; index < face_obj.size(); index++) {
App::DocumentObject* obj = face_obj[index];
const std::string& sub = face_sub[index];
if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (obj && obj->isDerivedFrom<Part::Feature>()) {
const Part::TopoShape& shape = static_cast<Part::Feature*>(obj)->Shape.getShape();
TopoDS_Shape face = shape.getSubShape(sub.c_str());
if (!face.IsNull() && face.ShapeType() == TopAbs_FACE) {
@@ -241,7 +241,7 @@ void Filling::addConstraints(BRepFill_Filling& builder, const App::PropertyLinkS
for (const auto& it : points) {
App::DocumentObject* obj = it.first;
std::vector<std::string> sub = it.second;
if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (obj && obj->isDerivedFrom<Part::Feature>()) {
const Part::TopoShape& shape = static_cast<Part::Feature*>(obj)->Shape.getShape();
for (const auto& jt : sub) {
TopoDS_Shape subShape = shape.getSubShape(jt.c_str());
@@ -287,7 +287,7 @@ App::DocumentObjectExecReturn* Filling::execute()
// Load the initial surface if set
App::DocumentObject* initFace = InitialFace.getValue();
if (initFace && initFace->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (initFace && initFace->isDerivedFrom<Part::Feature>()) {
const Part::TopoShape& shape = static_cast<Part::Feature*>(initFace)->Shape.getShape();
std::vector<std::string> subNames = InitialFace.getSubValues();
for (const auto& it : subNames) {

View File

@@ -215,7 +215,7 @@ bool GeomFillSurface::getWire(TopoDS_Wire& aWire)
ShapeValidator validator;
for (const auto& set : boundary) {
if (set.first->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (set.first->isDerivedFrom<Part::Feature>()) {
for (const auto& jt : set.second) {
const Part::TopoShape& ts =
static_cast<Part::Feature*>(set.first)->Shape.getShape();

View File

@@ -56,7 +56,7 @@ App::DocumentObjectExecReturn* Sections::execute()
// get the part object
App::DocumentObject* obj = edge_obj[index];
const std::string& sub = edge_sub[index];
if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (obj && obj->isDerivedFrom<Part::Feature>()) {
// get the sub-edge of the part's shape
const Part::TopoShape& shape = static_cast<Part::Feature*>(obj)->Shape.getShape();
TopoDS_Shape edge = shape.getSubShape(sub.c_str());

View File

@@ -81,7 +81,7 @@ App::DocumentObjectExecReturn* Sewing::execute()
for (const auto& it : subset) {
// the subset has the documentobject and the element name which belongs to it,
// in our case for example the cube object and the "Edge1" string
if (it.first->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (it.first->isDerivedFrom<Part::Feature>()) {
// we get the shape of the document object which resemble the whole box
Part::TopoShape ts = static_cast<Part::Feature*>(it.first)->Shape.getShape();

View File

@@ -75,7 +75,7 @@ void CmdSurfaceCut::activated(int iMsg)
bool askUser = false;
for (std::vector<Gui::SelectionObject>::iterator it = Sel.begin(); it != Sel.end(); ++it) {
App::DocumentObject* obj = it->getObject();
if (obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (obj->isDerivedFrom<Part::Feature>()) {
const TopoDS_Shape& shape = static_cast<Part::Feature*>(obj)->Shape.getValue();
if (!PartGui::checkForSolids(shape) && !askUser) {
int ret = QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Non-solids

View File

@@ -584,7 +584,7 @@ void FillingPanel::onListBoundaryItemDoubleClicked(QListWidgetItem* item)
try {
App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray());
App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr;
if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (obj && obj->isDerivedFrom<Part::Feature>()) {
const Part::TopoShape& shape = static_cast<Part::Feature*>(obj)->Shape.getShape();
TopoDS_Shape edge = shape.getSubShape(data[2].toByteArray());

View File

@@ -368,7 +368,7 @@ void FillingEdgePanel::onListUnboundItemDoubleClicked(QListWidgetItem* item)
try {
App::Document* doc = App::GetApplication().getDocument(data[0].toByteArray());
App::DocumentObject* obj = doc ? doc->getObject(data[1].toByteArray()) : nullptr;
if (obj && obj->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
if (obj && obj->isDerivedFrom<Part::Feature>()) {
const Part::TopoShape& shape = static_cast<Part::Feature*>(obj)->Shape.getShape();
TopoDS_Shape edge = shape.getSubShape(data[2].toByteArray());