From: Clarisse Genrault Date: Thu, 6 Jul 2017 09:50:40 +0000 (+0200) Subject: Fix bug "too long line" and "space". X-Git-Tag: V_2.9.0~35 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=af647cc075309524f791554e7b8777a8c6ddba39;p=modules%2Fshaper.git Fix bug "too long line" and "space". --- diff --git a/src/GDMLPlugin/GDMLPlugin_Ellipsoid.cpp b/src/GDMLPlugin/GDMLPlugin_Ellipsoid.cpp index db962dcfe..1ab4ce05d 100644 --- a/src/GDMLPlugin/GDMLPlugin_Ellipsoid.cpp +++ b/src/GDMLPlugin/GDMLPlugin_Ellipsoid.cpp @@ -46,14 +46,14 @@ void GDMLPlugin_Ellipsoid::initAttributes() void GDMLPlugin_Ellipsoid::execute() { std::shared_ptr anEllipsoidAlgo; - + double aAx = real(AX_ID())->value(); double aBy = real(BY_ID())->value(); double aCz = real(CZ_ID())->value(); - + std::string useZCut1 = string(USE_ZCUT1_ID())->value(); std::string useZCut2 = string(USE_ZCUT2_ID())->value(); - + double aZCut1 = 0.; if (useZCut1.empty()) { aZCut1 = aCz /2.; @@ -66,13 +66,13 @@ void GDMLPlugin_Ellipsoid::execute() } else { aZCut2 = real(ZCUT2_ID())->value(); } - + anEllipsoidAlgo = std::shared_ptr( new GeomAlgoAPI_Ellipsoid(aAx, aBy, aCz, aZCut1, aZCut2)); - + // Check with that the arguments for anEllipsoidAlgo are correct - if (!anEllipsoidAlgo->check()){ - setError(anEllipsoidAlgo->getError(), false); + if (!anEllipsoidAlgo->check()) { + setError(anEllipsoidAlgo->getError(), false); return; } @@ -83,15 +83,15 @@ void GDMLPlugin_Ellipsoid::execute() setError(anEllipsoidAlgo->getError(), false); return; } - + // Check if the created ellipsoid is valid if (!anEllipsoidAlgo->checkValid("Ellipsoid builder")) { setError(anEllipsoidAlgo->getError(), false); return; } - int aResultIndex = 0; - ResultBodyPtr aResultEllipsoid = document()->createBody(data(), aResultIndex); + int aResultIndex = 0; + ResultBodyPtr aResultEllipsoid = document()->createBody(data(), aResultIndex); loadNamingDS(anEllipsoidAlgo, aResultEllipsoid); setResult(aResultEllipsoid, aResultIndex); @@ -103,10 +103,10 @@ void GDMLPlugin_Ellipsoid::loadNamingDS(std::shared_ptr t { // Load the result theResultEllipsoid->store(theEllipsoidAlgo->shape()); - + // Prepare the naming theEllipsoidAlgo->prepareNamingFaces(); - + // Insert to faces int num = 1; std::map< std::string, std::shared_ptr > listOfFaces = diff --git a/src/GDMLPlugin/GDMLPlugin_Plugin.cpp b/src/GDMLPlugin/GDMLPlugin_Plugin.cpp index 9dba4a099..168ae380e 100644 --- a/src/GDMLPlugin/GDMLPlugin_Plugin.cpp +++ b/src/GDMLPlugin/GDMLPlugin_Plugin.cpp @@ -41,7 +41,7 @@ FeaturePtr GDMLPlugin_Plugin::createFeature(std::string theFeatureID) } else if (theFeatureID == GDMLPlugin_Ellipsoid::ID()) { return FeaturePtr(new GDMLPlugin_Ellipsoid); } - + // feature of such kind is not found return FeaturePtr(); } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Ellipsoid.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Ellipsoid.cpp index f23471221..afa430db1 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Ellipsoid.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Ellipsoid.cpp @@ -76,7 +76,7 @@ bool GeomAlgoAPI_Ellipsoid::check() myError = "Ellipsoid builder :: zcut1 and zcut2 are null."; return false; } - + return true; } @@ -84,17 +84,17 @@ bool GeomAlgoAPI_Ellipsoid::check() void GeomAlgoAPI_Ellipsoid::build() { myCreatedFaces.clear(); - + BRepOffsetAPI_Sewing aSewer; gp_Ax2 aRefAx2; gp_Elips anElips; - + gp_Pnt anOrigin(0., 0., 0.); gp_Dir aDirX(1., 0., 0.); gp_Dir aDirY(0., 1., 0.); gp_Dir aDirZ(0., 0., 1.); gp_Ax1 aZAxis(anOrigin, aDirZ); - + // Calculate the parameters needed to make the edges and the faces // gp_Elips needs the second parameter to be greater than the third (major axis) if (myCz < myAx) { @@ -104,20 +104,20 @@ void GeomAlgoAPI_Ellipsoid::build() aRefAx2 = gp_Ax2(anOrigin, aDirY, aDirZ); anElips = gp_Elips(aRefAx2, myCz / 2., myAx / 2.); } - + double aLowPositionFactor = sqrt(1. - (myZCut1 * myZCut1 * 4. / (myCz * myCz))) / 2.; double aHighPositionFactor = sqrt(1. - (myZCut2 * myZCut2 * 4. / (myCz * myCz))) / 2.; - + double aXEndTop = myAx * aHighPositionFactor; double aXEndBottom = myAx * aLowPositionFactor; - + // Build the XZ ellipse gp_Pnt anEndPoint1(aXEndTop, 0., myZCut2); gp_Pnt anEndPoint2(aXEndBottom, 0., -myZCut1); BRepBuilderAPI_MakeEdge anElipsBuilder(anElips, anEndPoint1, anEndPoint2); anElipsBuilder.Build(); TopoDS_Edge anOuterEdge = anElipsBuilder.Edge(); - + // Perform a revolution based on the section to build a simple version of the outer face // (isotropic in XY) BRepPrimAPI_MakeRevol aRevolBuilder(anOuterEdge, aZAxis, 2. * M_PI, Standard_True); @@ -125,7 +125,7 @@ void GeomAlgoAPI_Ellipsoid::build() myError = "Ellipsoid builder :: section revolution did not succeed"; return; } - + gp_GTrsf aGTrsf; gp_Mat rot (1., 0., 0., 0., myBy / myAx, 0., @@ -141,11 +141,11 @@ void GeomAlgoAPI_Ellipsoid::build() TopoDS_Face anOuterFace = TopoDS::Face(aScaleBuilder.Shape()); aSewer.Add(TopoDS::Face(anOuterFace.Reversed())); - + // Build the high and low ellipse if needed gp_Ax2 aLowAx2; gp_Ax2 aHighAx2; - gp_Elips aLowElips; + gp_Elips aLowElips; gp_Elips aHighElips; if (myBy < myAx) { if ((myCz / 2. - myZCut1) > Precision::Confusion()) { @@ -179,7 +179,7 @@ void GeomAlgoAPI_Ellipsoid::build() aSewer.Add(TopoDS::Face(aBottomFace.Reversed())); } if ((myCz / 2. - myZCut2) > Precision::Confusion()) { - TopoDS_Face aTopFace; + TopoDS_Face aTopFace; BRepBuilderAPI_MakeEdge aTopEdgeMk(aHighElips); aTopEdgeMk.Build(); BRepBuilderAPI_MakeWire aTopWireMk; @@ -188,33 +188,35 @@ void GeomAlgoAPI_Ellipsoid::build() aTopFace = aTopFaceMk.Face(); aSewer.Add(TopoDS::Face(aTopFace.Reversed())); } - + TopoDS_Shell aShell; aSewer.Perform(); - if ((myCz / 2. - myZCut2) > Precision::Confusion() || (myCz / 2. - myZCut1) > Precision::Confusion()) { + if ((myCz / 2. - myZCut2) > Precision::Confusion() || + (myCz / 2. - myZCut1) > Precision::Confusion()) { aShell = TopoDS::Shell(aSewer.SewedShape()); } else { TopoDS_Builder aBuilder; aBuilder.MakeShell(aShell); aBuilder.Add(aShell, aSewer.SewedShape()); } - + BRepBuilderAPI_MakeSolid *anEllipsoidMk = new BRepBuilderAPI_MakeSolid(aShell); anEllipsoidMk->Build(); - + // Store and publish the results - std::shared_ptr aResultShape = std::shared_ptr(new GeomAPI_Shape()) ; + std::shared_ptr aResultShape = + std::shared_ptr(new GeomAPI_Shape()); aResultShape->setImpl(new TopoDS_Shape(anEllipsoidMk->Solid())); setShape(aResultShape); - + // Test on the shapes if (!(aResultShape).get() || aResultShape->isNull()) { myError = "Ellipsoid builder :: resulting shape is null."; return; } - + setImpl(anEllipsoidMk); setBuilderType(OCCT_BRepBuilderAPI_MakeShape); - + setDone(true); }