From: azv Date: Thu, 20 Dec 2018 04:08:50 +0000 (+0300) Subject: [Code coverage GeomAlgoAPI]: Refactoring of Pipe algorithm X-Git-Tag: End2018~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e2823a1620aa63a7df7f6c952b9ae241766abf7a;p=modules%2Fshaper.git [Code coverage GeomAlgoAPI]: Refactoring of Pipe algorithm --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp index 210a8c4b0..4ce80d3ff 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp @@ -77,26 +77,15 @@ GeomAlgoAPI_Pipe::GeomAlgoAPI_Pipe(const ListOfShape& theBaseShapes, void GeomAlgoAPI_Pipe::build(const GeomShapePtr theBaseShape, const GeomShapePtr thePathShape) { - // Getting base shape. - if(!theBaseShape.get()) { - return; - } - TopoDS_Shape aBaseShape = theBaseShape->impl(); - if(aBaseShape.IsNull()) { - return; - } - TopAbs_ShapeEnum aBaseShapeType = aBaseShape.ShapeType(); - if(aBaseShapeType != TopAbs_VERTEX && aBaseShapeType != TopAbs_EDGE && - aBaseShapeType != TopAbs_WIRE && aBaseShapeType != TopAbs_FACE && - aBaseShapeType != TopAbs_SHELL && aBaseShapeType != TopAbs_COMPOUND) { - return; - } - - // Getting path. + // Getting base shape and path. + TopoDS_Shape aBaseShape; + TopAbs_ShapeEnum aBaseShapeType; TopoDS_Wire aPathWire; - if(!getPath(aPathWire, thePathShape)) { + if (!getBase(aBaseShape, aBaseShapeType, theBaseShape) || + !getPath(aPathWire, thePathShape)) { return; } + aPathWire.Move(getPathToBaseTranslation(aBaseShape, aPathWire)); // Making pipe. @@ -131,25 +120,19 @@ void GeomAlgoAPI_Pipe::build(const GeomShapePtr theBaseShape, const GeomShapePtr thePathShape, const GeomShapePtr theBiNormal) { - // Getting base shape. + // Getting base shape and path. TopoDS_Shape aBaseShape; TopAbs_ShapeEnum aBaseShapeType; - if(!getBase(aBaseShape, aBaseShapeType, theBaseShape)) { - return; - } - - // Getting path. TopoDS_Wire aPathWire; - if(!getPath(aPathWire, thePathShape)) { + if (!getBase(aBaseShape, aBaseShapeType, theBaseShape) || + !getPath(aPathWire, thePathShape) || + !theBiNormal.get()) { return; } aPathWire.Move(getPathToBaseTranslation(theBaseShape->impl(), aPathWire)); // Getting Bi-Normal. - if(!theBiNormal.get()) { - return; - } TopoDS_Shape aBiNormalShape = theBiNormal->impl(); if(aBiNormalShape.IsNull() || aBiNormalShape.ShapeType() != TopAbs_EDGE) { return; @@ -177,10 +160,8 @@ void GeomAlgoAPI_Pipe::build(const GeomShapePtr theBaseShape, this->initialize(aPipeBuilder); // Checking result. - if(aBaseShapeType == TopAbs_FACE) { - if(aPipeBuilder->MakeSolid() == Standard_False) { - return; - } + if(aBaseShapeType == TopAbs_FACE && !aPipeBuilder->MakeSolid()) { + return; } TopoDS_Shape aResult = aPipeBuilder->Shape(); if(aResult.IsNull()) { @@ -209,15 +190,12 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes, return; } - // Getting path. + // Getting base shape and path. TopoDS_Shape aBaseShape; TopAbs_ShapeEnum aBaseShapeType; - if (!getBase(aBaseShape, aBaseShapeType, theBaseShapes.front())) { - return; - } - TopoDS_Wire aPathWire; - if(!getPath(aPathWire, thePathShape)) { + if (!getBase(aBaseShape, aBaseShapeType, theBaseShapes.front()) || + !getPath(aPathWire, thePathShape)) { return; } @@ -312,10 +290,8 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes, this->initialize(aPipeBuilder); // Checking result. - if(anIsSolidNeeded) { - if(aPipeBuilder->MakeSolid() == Standard_False) { - return; - } + if(anIsSolidNeeded && !aPipeBuilder->MakeSolid()) { + return; } TopoDS_Shape aResult = aPipeBuilder->Shape();