Part: PR6497 move return statement to new line

This commit is contained in:
Chris Hennes
2022-03-29 12:37:00 -05:00
parent 3ecd16e0bd
commit 2ecc125497
21 changed files with 150 additions and 75 deletions

View File

@@ -433,7 +433,8 @@ eRefType AttachEngine::getShapeType(const TopoDS_Shape& sh)
case TopAbs_COMPOUND:{
const TopoDS_Compound &cmpd = TopoDS::Compound(sh);
TopoDS_Iterator it (cmpd, Standard_False, Standard_False);//don't mess with placements, to hopefully increase speed
if (! it.More()) return rtAnything;//empty compound
if (! it.More())//empty compound
return rtAnything;
const TopoDS_Shape &sh1 = it.Value();
it.Next();
if (it.More()){

View File

@@ -287,7 +287,8 @@ static TopoShape _getTopoShape(const App::DocumentObject *obj, const char *subna
{
TopoShape shape;
if(!obj) return shape;
if(!obj)
return shape;
PyObject *pyobj = nullptr;
Base::Matrix4D mat;
@@ -526,7 +527,8 @@ TopoShape Feature::getTopoShape(const App::DocumentObject *obj, const char *subn
App::DocumentObject *Feature::getShapeOwner(const App::DocumentObject *obj, const char *subname)
{
if(!obj) return nullptr;
if(!obj)
return nullptr;
auto owner = obj->getSubObject(subname);
if(owner) {
auto linked = owner->getLinkedObject(true);

View File

@@ -117,12 +117,14 @@ App::DocumentObjectExecReturn *RuledSurface::execute(void)
// get the first input shape
TopoDS_Shape S1;
ret = getShape(Curve1, S1);
if (ret) return ret;
if (ret)
return ret;
// get the second input shape
TopoDS_Shape S2;
ret = getShape(Curve2, S2);
if (ret) return ret;
if (ret)
return ret;
// check for expected type
if (S1.IsNull() || S2.IsNull())

View File

@@ -243,7 +243,8 @@ static Standard_Boolean BRepTools_Write(const TopoDS_Shape& Sh, const Standard_
#else
os.open(File, std::ios::out);
#endif
if (!os.rdbuf()->is_open()) return Standard_False;
if (!os.rdbuf()->is_open())
return Standard_False;
Standard_Boolean isGood = (os.good() && !os.eof());
if(!isGood)

View File

@@ -395,7 +395,8 @@ TopoDS_Shape TopoShape::getSubShape(TopAbs_ShapeEnum type, int index, bool silen
unsigned long TopoShape::countSubShapes(const char* Type) const
{
if(!Type) return 0;
if(!Type)
return 0;
if(strcmp(Type,"SubShape")==0)
return countSubShapes(TopAbs_SHAPE);
auto type = shapeType(Type,true);

View File

@@ -3245,7 +3245,8 @@ Py::Float TopoShapePy::getVolume(void) const
PyObject *TopoShapePy::getCustomAttributes(const char* attr) const
{
if (!attr) return nullptr;
if (!attr)
return nullptr;
PY_TRY {
TopoDS_Shape res = getTopoShapePtr()->getSubShape(attr,true);
if(!res.IsNull())

View File

@@ -826,14 +826,22 @@ bool FaceTypedBSpline::isEqual(const TopoDS_Face &faceOne, const TopoDS_Face &fa
if (surfaceOne.IsNull() || surfaceTwo.IsNull())
return false;
if (surfaceOne->IsURational() != surfaceTwo->IsURational()) return false;
if (surfaceOne->IsVRational() != surfaceTwo->IsVRational()) return false;
if (surfaceOne->IsUPeriodic() != surfaceTwo->IsUPeriodic()) return false;
if (surfaceOne->IsVPeriodic() != surfaceTwo->IsVPeriodic()) return false;
if (surfaceOne->IsUClosed() != surfaceTwo->IsUClosed()) return false;
if (surfaceOne->IsVClosed() != surfaceTwo->IsVClosed()) return false;
if (surfaceOne->UDegree() != surfaceTwo->UDegree()) return false;
if (surfaceOne->VDegree() != surfaceTwo->VDegree()) return false;
if (surfaceOne->IsURational() != surfaceTwo->IsURational())
return false;
if (surfaceOne->IsVRational() != surfaceTwo->IsVRational())
return false;
if (surfaceOne->IsUPeriodic() != surfaceTwo->IsUPeriodic())
return false;
if (surfaceOne->IsVPeriodic() != surfaceTwo->IsVPeriodic())
return false;
if (surfaceOne->IsUClosed() != surfaceTwo->IsUClosed())
return false;
if (surfaceOne->IsVClosed() != surfaceTwo->IsVClosed())
return false;
if (surfaceOne->UDegree() != surfaceTwo->UDegree())
return false;
if (surfaceOne->VDegree() != surfaceTwo->VDegree())
return false;
//pole test
int uPoleCountOne(surfaceOne->NbUPoles());

View File

@@ -1004,7 +1004,8 @@ void CmdPartImport::activated(int iMsg)
if (!fn.isEmpty()) {
Gui::WaitCursor wc;
App::Document* pDoc = getDocument();
if (!pDoc) return; // no document
if (!pDoc) // no document
return;
fn = Base::Tools::escapeEncodeFilename(fn);
openCommand(QT_TRANSLATE_NOOP("Command", "Import Part"));
@@ -1065,7 +1066,8 @@ void CmdPartExport::activated(int iMsg)
QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")), &select);
if (!fn.isEmpty()) {
App::Document* pDoc = getDocument();
if (!pDoc) return; // no document
if (!pDoc) // no document
return;
if (select == filter[1] ||
select == filter[3]) {
Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"ImportGui");

View File

@@ -62,7 +62,8 @@ namespace PartGui {
QTreeWidgetItem::setData(column, role, value);
if (role == Qt::CheckStateRole && value.toBool() == true) {
QTreeWidget* tree = this->treeWidget();
if (!tree) return;
if (!tree)
return;
int numChild = tree->topLevelItemCount();
for (int i=0; i<numChild; i++) {
QTreeWidgetItem* item = tree->topLevelItem(i);
@@ -117,7 +118,8 @@ void DlgBooleanOperation::changeEvent(QEvent *e)
void DlgBooleanOperation::slotCreatedObject(const App::DocumentObject& obj)
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) return;
if (!activeDoc)
return;
App::Document* doc = obj.getDocument();
if (activeDoc == doc && obj.getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
observe.push_back(&obj);
@@ -205,9 +207,11 @@ bool DlgBooleanOperation::hasSolids(const App::DocumentObject* obj) const
void DlgBooleanOperation::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) return;
if (!activeDoc)
return;
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
if (!activeGui) return;
if (!activeGui)
return;
std::vector<App::DocumentObject*> objs = activeDoc->getObjectsOfType
(Part::Feature::getClassTypeId());

View File

@@ -346,7 +346,8 @@ void DlgExtrusion::autoSolid()
void DlgExtrusion::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) return;
if (!activeDoc)
return;
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
this->document = activeDoc->getName();
this->label = activeDoc->Label.getValue();

View File

@@ -528,7 +528,8 @@ void DlgFilletEdges::toggleCheckState(const QModelIndex& index)
void DlgFilletEdges::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) return;
if (!activeDoc)
return;
std::vector<App::DocumentObject*> objs = activeDoc->getObjectsOfType
(Part::Feature::getClassTypeId());

View File

@@ -86,15 +86,20 @@ public:
bool allow(App::Document* /*pDoc*/, App::DocumentObject* iPObj, const char* sSubName)
{
Part::Feature* aPart = dynamic_cast<Part::Feature*>(iPObj);
if (!aPart) return false;
if (!sSubName) return false;
if (!aPart)
return false;
if (!sSubName)
return false;
std::string subName(sSubName);
if (subName.empty()) return false;
if (subName.empty())
return false;
auto subShape = aPart->Shape.getShape().getSubShape(sSubName);
if (subShape.IsNull()) return false;
if (subShape.IsNull())
return false;
auto type = subShape.ShapeType();
if (type != TopAbs_EDGE) return false;
if (type != TopAbs_EDGE)
return false;
return true;
}
};
@@ -115,15 +120,20 @@ public:
bool allow(App::Document* /*pDoc*/, App::DocumentObject* iPObj, const char* sSubName)
{
Part::Feature* aPart = dynamic_cast<Part::Feature*>(iPObj);
if (!aPart) return false;
if (!sSubName) return false;
if (!aPart)
return false;
if (!sSubName)
return false;
std::string subName(sSubName);
if (subName.empty()) return false;
if (subName.empty())
return false;
auto subShape = aPart->Shape.getShape().getSubShape(sSubName, true);
if (subShape.IsNull()) return false;
if (subShape.IsNull())
return false;
auto type = subShape.ShapeType();
if (type != TopAbs_FACE) return false;
if (type != TopAbs_FACE)
return false;
return true;
}
};
@@ -333,7 +343,8 @@ void PartGui::DlgProjectionOnSurface::get_camera_direction(void)
auto mainWindow = Gui::getMainWindow();
auto mdiObject = dynamic_cast<Gui::View3DInventor*>(mainWindow->activeWindow());
if (!mdiObject) return;
if (!mdiObject)
return;
auto camerRotation = mdiObject->getViewer()->getCameraOrientation();
SbVec3f lookAt(0, 0, -1);
@@ -349,7 +360,8 @@ void PartGui::DlgProjectionOnSurface::get_camera_direction(void)
void PartGui::DlgProjectionOnSurface::store_current_selected_parts(std::vector<SShapeStore>& iStoreVec, const unsigned int iColor)
{
if (!m_partDocument) return;
if (!m_partDocument)
return;
std::vector<Gui::SelectionObject> selObj = Gui::Selection().getSelectionEx();
if (selObj.size())
{
@@ -402,7 +414,8 @@ void PartGui::DlgProjectionOnSurface::store_current_selected_parts(std::vector<S
bool PartGui::DlgProjectionOnSurface::store_part_in_vector(SShapeStore& iCurrentShape, std::vector<SShapeStore>& iStoreVec)
{
if (iCurrentShape.inputShape.IsNull()) return false;
if (iCurrentShape.inputShape.IsNull())
return false;
auto currentType = iCurrentShape.inputShape.ShapeType();
for ( auto it = iStoreVec.begin(); it != iStoreVec.end(); ++it)
{
@@ -450,7 +463,8 @@ void PartGui::DlgProjectionOnSurface::create_projection_wire(std::vector<SShapeS
{
try
{
if (iCurrentShape.empty()) return;
if (iCurrentShape.empty())
return;
for ( auto &itCurrentShape : iCurrentShape )
{
if (m_projectionSurfaceVec.empty()) continue;;
@@ -513,7 +527,8 @@ void PartGui::DlgProjectionOnSurface::create_projection_wire(std::vector<SShapeS
TopoDS_Shape PartGui::DlgProjectionOnSurface::create_compound(const std::vector<SShapeStore>& iShapeVec)
{
if (iShapeVec.empty()) return TopoDS_Shape();
if (iShapeVec.empty())
return TopoDS_Shape();
TopoDS_Compound aCompound;
TopoDS_Builder aBuilder;
@@ -581,11 +596,13 @@ TopoDS_Shape PartGui::DlgProjectionOnSurface::create_compound(const std::vector<
void PartGui::DlgProjectionOnSurface::show_projected_shapes(const std::vector<SShapeStore>& iShapeStoreVec)
{
if (!m_projectionObject) return;
if (!m_projectionObject)
return;
auto aCompound = create_compound(iShapeStoreVec);
if ( aCompound.IsNull() )
{
if (!m_partDocument) return;
if (!m_partDocument)
return;
m_projectionObject->Shape.setValue(TopoDS_Shape());
return;
}
@@ -625,7 +642,8 @@ void PartGui::DlgProjectionOnSurface::enable_ui_elements(const std::vector<QWidg
void PartGui::DlgProjectionOnSurface::higlight_object(Part::Feature* iCurrentObject, const std::string& iShapeName, bool iHighlight, const unsigned int iColor)
{
if (!iCurrentObject) return;
if (!iCurrentObject)
return;
auto partenShape = iCurrentObject->Shape.getShape().getShape();
auto subShape = iCurrentObject->Shape.getShape().getSubShape(iShapeName.c_str(), true);
@@ -635,8 +653,10 @@ void PartGui::DlgProjectionOnSurface::higlight_object(Part::Feature* iCurrentObj
auto currentShapeType = currentShape.ShapeType();
TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(partenShape, currentShapeType, anIndices);
if (anIndices.IsEmpty()) return;
if (!anIndices.Contains(currentShape)) return;
if (anIndices.IsEmpty())
return;
if (!anIndices.Contains(currentShape))
return;
auto index = anIndices.FindIndex(currentShape);
//set color
@@ -698,7 +718,8 @@ void PartGui::DlgProjectionOnSurface::create_projection_face_from_wire(std::vect
{
try
{
if (iCurrentShape.empty()) return;
if (iCurrentShape.empty())
return;
for ( auto &itCurrentShape : iCurrentShape )
{
@@ -813,7 +834,8 @@ TopoDS_Wire PartGui::DlgProjectionOnSurface::sort_and_heal_wire(const std::vecto
shapeAnalyzer.ConnectEdgesToWires(shapeList, 0.0001, false, aWireHandle);
shapeAnalyzer.ConnectWiresToWires(aWireHandle, 0.0001, false, aWireWireHandle);
if (!aWireWireHandle) return TopoDS_Wire();
if (!aWireWireHandle)
return TopoDS_Wire();
for (auto it = 1; it <= aWireWireHandle->Length(); ++it)
{
auto aShape = TopoDS::Wire(aWireWireHandle->Value(it));
@@ -835,7 +857,8 @@ void PartGui::DlgProjectionOnSurface::create_face_extrude(std::vector<SShapeStor
{
try
{
if (iCurrentShape.empty()) return;
if (iCurrentShape.empty())
return;
for ( auto &itCurrentShape : iCurrentShape )
{
@@ -845,7 +868,8 @@ void PartGui::DlgProjectionOnSurface::create_face_extrude(std::vector<SShapeStor
gp_Vec directionToExtrude(itCurrentShape.aProjectionDir.XYZ());
directionToExtrude.Reverse();
if (height == 0) return;
if (height == 0)
return;
directionToExtrude.Multiply(height);
BRepPrimAPI_MakePrism extrude(itCurrentShape.aProjectedFace, directionToExtrude);
itCurrentShape.aProjectedSolid = extrude.Shape();
@@ -862,11 +886,15 @@ void PartGui::DlgProjectionOnSurface::create_face_extrude(std::vector<SShapeStor
void PartGui::DlgProjectionOnSurface::store_wire_in_vector(const SShapeStore& iCurrentShape, const TopoDS_Shape& iParentShape, std::vector<SShapeStore>& iStoreVec, const unsigned int iColor)
{
if (m_currentSelection != "add_wire") return;
if (iParentShape.IsNull()) return;
if (iCurrentShape.inputShape.IsNull()) return;
if (m_currentSelection != "add_wire")
return;
if (iParentShape.IsNull())
return;
if (iCurrentShape.inputShape.IsNull())
return;
auto currentType = iCurrentShape.inputShape.ShapeType();
if (currentType != TopAbs_EDGE) return;
if (currentType != TopAbs_EDGE)
return;
std::vector<TopoDS_Wire> aWireVec;
for (TopExp_Explorer aExplorer(iParentShape, TopAbs_WIRE); aExplorer.More(); aExplorer.Next())
@@ -888,15 +916,18 @@ void PartGui::DlgProjectionOnSurface::store_wire_in_vector(const SShapeStore& iC
edgeVec.clear();
}
if (edgeVec.empty()) return;
if (edgeVec.empty())
return;
TopTools_IndexedMapOfShape indexMap;
TopExp::MapShapes(iParentShape, TopAbs_EDGE, indexMap);
if (indexMap.IsEmpty()) return;
if (indexMap.IsEmpty())
return;
for ( auto it : edgeVec )
{
if ( it.IsSame(iCurrentShape.inputShape)) continue;
if (!indexMap.Contains(it)) return;
if (!indexMap.Contains(it))
return;
auto index = indexMap.FindIndex(it);
auto newEdgeObject = iCurrentShape;
newEdgeObject.inputShape = it;

View File

@@ -323,7 +323,8 @@ void DlgRevolution::keyPressEvent(QKeyEvent* ke)
void DlgRevolution::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) return;
if (!activeDoc)
return;
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
std::vector<App::DocumentObject*> objs = activeDoc->getObjectsOfType

View File

@@ -89,9 +89,11 @@ void Mirroring::changeEvent(QEvent *e)
void Mirroring::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
if (!activeDoc) return;
if (!activeDoc)
return;
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
if (!activeGui) return;
if (!activeGui)
return;
this->document = QString::fromLatin1(activeDoc->getName());
std::vector<App::DocumentObject*> objs = activeDoc->getObjectsOfType

View File

@@ -459,7 +459,8 @@ void SoBrepFaceSet::GLRender(SoGLRenderAction *action)
void SoBrepFaceSet::renderSimpleArray()
{
int cnt = index_array.size();
if (cnt == 0) return;
if (cnt == 0)
return;
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
@@ -485,7 +486,8 @@ void SoBrepFaceSet::renderColoredArray(SoMaterialBundle *const materials)
{
int num_parts = partIndex.getNum();
int cnt = index_array.size();
if (cnt == 0) return;
if (cnt == 0)
return;
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
@@ -687,19 +689,22 @@ void SoBrepFaceSet::GLRender(SoGLRenderAction *action)
#endif
bool SoBrepFaceSet::overrideMaterialBinding(SoGLRenderAction *action, SelContextPtr ctx, SelContextPtr ctx2) {
if(!ctx && !ctx2) return false;
if(!ctx && !ctx2)
return false;
auto state = action->getState();
auto mb = SoMaterialBindingElement::get(state);
auto element = SoLazyElement::getInstance(state);
const SbColor *diffuse = element->getDiffusePointer();
if(!diffuse) return false;
if(!diffuse)
return false;
int diffuse_size = element->getNumDiffuse();
const float *trans = element->getTransparencyPointer();
int trans_size = element->getNumTransparencies();
if(!trans || !trans_size) return false;
if(!trans || !trans_size)
return false;
float trans0=0.0;
bool hasTransparency = false;
for(int i=0;i<trans_size;++i) {
@@ -979,7 +984,8 @@ void SoBrepFaceSet::generatePrimitives(SoAction * action)
#else
//This is highly experimental!!!
if (this->coordIndex.getNum() < 3) return;
if (this->coordIndex.getNum() < 3)
return;
SoState * state = action->getState();
if (this->vertexProperty.getValue()) {

View File

@@ -81,9 +81,11 @@ void SoFCControlPoints::GLRender(SoGLRenderAction *action)
{
SoState* state = action->getState();
const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state);
if (!coords) return;
if (!coords)
return;
const SbVec3f * points = coords->getArrayPtr3();
if (!points) return;
if (!points)
return;
SoMaterialBundle mb(action);
SoTextureCoordinateBundle tb(action, true, false);
@@ -159,9 +161,11 @@ void SoFCControlPoints::computeBBox(SoAction *action, SbBox3f &box, SbVec3f &cen
{
SoState* state = action->getState();
const SoCoordinateElement * coords = SoCoordinateElement::getInstance(state);
if (!coords) return;
if (!coords)
return;
const SbVec3f * points = coords->getArrayPtr3();
if (!points) return;
if (!points)
return;
float maxX=-FLT_MAX, minX=FLT_MAX,
maxY=-FLT_MAX, minY=FLT_MAX,
maxZ=-FLT_MAX, minZ=FLT_MAX;

View File

@@ -365,7 +365,8 @@ void TaskAttacher::onSelectionChanged(const Gui::SelectionChanges& msg)
std::vector<App::DocumentObject*> refs = pcAttach->Support.getValues();
std::vector<std::string> refnames = pcAttach->Support.getSubValues();
App::DocumentObject* selObj = ViewProvider->getObject()->getDocument()->getObject(msg.pObjectName);
if (!selObj || selObj == ViewProvider->getObject()) return;//prevent self-referencing
if (!selObj || selObj == ViewProvider->getObject())//prevent self-referencing
return;
std::string subname = msg.pSubName;
@@ -563,7 +564,8 @@ void TaskAttacher::onRefName(const QString& text, unsigned idx)
return;
QLineEdit* line = getLine(idx);
if (line == nullptr) return;
if (line == nullptr)
return;
if (text.length() == 0) {
// Reference was removed
@@ -606,7 +608,8 @@ void TaskAttacher::onRefName(const QString& text, unsigned idx)
parts.push_back(QString::fromLatin1(""));
// Check whether this is the name of an App::Plane or Part::Datum feature
App::DocumentObject* obj = ViewProvider->getObject()->getDocument()->getObject(parts[0].toLatin1());
if (obj == nullptr) return;
if (obj == nullptr)
return;
std::string subElement;

View File

@@ -98,7 +98,8 @@ void LoftWidget::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
if (!activeGui) return;
if (!activeGui)
return;
d->document = activeDoc->getName();
std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();

View File

@@ -172,7 +172,8 @@ void ShapeBuilderWidget::on_createButton_clicked()
{
int mode = d->bg.checkedId();
Gui::Document* doc = Gui::Application::Instance->activeDocument();
if (!doc) return;
if (!doc)
return;
try {
if (mode == 0) {

View File

@@ -155,7 +155,8 @@ void SweepWidget::findShapes()
{
App::Document* activeDoc = App::GetApplication().getActiveDocument();
Gui::Document* activeGui = Gui::Application::Instance->getDocument(activeDoc);
if (!activeGui) return;
if (!activeGui)
return;
d->document = activeDoc->getName();
std::vector<Part::Feature*> objs = activeDoc->getObjectsOfType<Part::Feature>();

View File

@@ -246,7 +246,8 @@ void ViewProvider2DObjectGrid::updateData(const App::Property* prop)
if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId()) {
if (GridAutoSize.getValue()) {
Base::BoundBox3d bbox = static_cast<const Part::PropertyPartShape*>(prop)->getBoundingBox();
if (!bbox.IsValid()) return;
if (!bbox.IsValid())
return;
Gui::coinRemoveAllChildren(GridRoot);
Base::Placement place = static_cast<const Part::PropertyPartShape*>(prop)->getComplexData()->getPlacement();
place.invert();