X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSolveSpaceSolver%2FSolveSpaceSolver_Builder.cpp;h=24f6d229973f2dfc0ee8c866149fde9888a54ee2;hb=b857d9ea753bef79dbbadaeb990b54aae56e488d;hp=3d0e3884294887e34191af9e143da855621768de;hpb=c3aeb6b898054376c1047071ea9fea61abdc9e99;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp index 3d0e38842..24f6d2299 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Builder.cpp @@ -1,8 +1,21 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: SolveSpaceSolver_Builder.cpp -// Created: 25 Mar 2015 -// Author: Artem ZHIDKOV +// Copyright (C) 2014-2020 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include #include @@ -143,7 +156,7 @@ std::list SolveSpaceSolver_Builder::createConstraint( aSlvsEntities[i] = (Slvs_hEntity)anOriginal[i]->id(); // entity is not added into a storage, constraint can not be created if (aSlvsEntities[i] == SLVS_E_UNKNOWN) - return std::list(); + return std::list(); aConstrAttrList.push_back(anOriginal[i]); } @@ -257,10 +270,10 @@ std::list SolveSpaceSolver_Builder::createMirror( aResult.insert(aResult.end(), aMrrList.begin(), aMrrList.end()); } else if (theEntity1->type() == ENTITY_ARC) { - // Do not allow mirrored arc recalculate its position until + // Do not allow mirrored arc recalculate its position until // coordinated of all points recalculated FeaturePtr aMirrArc = theEntity2->baseFeature(); - aMirrArc->data()->blockSendAttributeUpdated(true); + bool aWasBlocked = aMirrArc->data()->blockSendAttributeUpdated(true); std::list aMrrList; std::list::const_iterator anIt1 = theEntity1->subEntities().begin(); @@ -278,12 +291,12 @@ std::list SolveSpaceSolver_Builder::createMirror( anIt1 = aBaseArcPoints.begin(); anIt2 = aMirrorArcPoints.begin(); for (; anIt1 != aBaseArcPoints.end(); ++anIt1, ++anIt2) { - aMrrList = + aMrrList = createMirror(theConstraint, theGroupID, theSketchID, *anIt1, *anIt2, theMirrorLine); aResult.insert(aResult.end(), aMrrList.begin(), aMrrList.end()); } // Restore event sending - aMirrArc->data()->blockSendAttributeUpdated(false); + aMirrArc->data()->blockSendAttributeUpdated(aWasBlocked); } return aResult; } @@ -335,12 +348,12 @@ EntityWrapperPtr SolveSpaceSolver_Builder::createFeature( else if (aFeatureKind == SketchPlugin_Arc::ID()) return createArc(theFeature, theAttributes, theGroupID, theSketchID); // Point (it has low probability to be an attribute of constraint, so it is checked at the end) - else if (aFeatureKind == SketchPlugin_Point::ID() || + else if (aFeatureKind == SketchPlugin_Point::ID() || aFeatureKind == SketchPlugin_IntersectionPoint::ID()) { AttributePtr aPoint = theFeature->attribute(SketchPlugin_Point::COORD_ID()); if (!aPoint->isInitialized()) return aDummy; - EntityWrapperPtr aSub = theAttributes.empty() ? + EntityWrapperPtr aSub = theAttributes.empty() ? createAttribute(aPoint, theGroupID, theSketchID) : theAttributes.front(); if (!aSub) @@ -392,9 +405,9 @@ EntityWrapperPtr SolveSpaceSolver_Builder::createAttribute( std::shared_ptr aPoint2D = std::dynamic_pointer_cast(theAttribute); if (aPoint2D) { - aParameters.push_back(createParameter(theGroupID, aPoint2D->x(), + aParameters.push_back(createParameter(theGroupID, aPoint2D->x(), !aPoint2D->textX().empty())); - aParameters.push_back(createParameter(theGroupID, aPoint2D->y(), + aParameters.push_back(createParameter(theGroupID, aPoint2D->y(), !aPoint2D->textY().empty())); // Create entity (parameters are not filled) anEntity = Slvs_MakePoint2d(SLVS_E_UNKNOWN, (Slvs_hGroup)theGroupID, @@ -404,7 +417,7 @@ EntityWrapperPtr SolveSpaceSolver_Builder::createAttribute( AttributeDoublePtr aScalar = std::dynamic_pointer_cast(theAttribute); if (aScalar) { - aParameters.push_back(createParameter(theGroupID, aScalar->value(), + aParameters.push_back(createParameter(theGroupID, aScalar->value(), !aScalar->text().empty())); // Create entity (parameter is not filled) anEntity = Slvs_MakeDistance(SLVS_E_UNKNOWN, (Slvs_hGroup)theGroupID, @@ -473,7 +486,7 @@ EntityWrapperPtr SolveSpaceSolver_Builder::createNormal( std::shared_ptr aNorm = std::dynamic_pointer_cast(theNormal); std::shared_ptr aDirX = std::dynamic_pointer_cast(theDirX); if (!aDirX || !aNorm || - (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance) || + (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance) || !aNorm->isInitialized()) return EntityWrapperPtr(); // calculate Y direction @@ -528,7 +541,7 @@ EntityWrapperPtr createLine(FeaturePtr theFeature, EntityWrapperPtr aStartEnt, aEndEnt; std::list::const_iterator anIt = theAttributes.begin(); for (; anIt != theAttributes.end(); ++anIt) { - std::shared_ptr aSlvsEntity = + std::shared_ptr aSlvsEntity = std::dynamic_pointer_cast(*anIt); if (aSlvsEntity->isBase(aStart)) aStartEnt = aSlvsEntity; @@ -564,7 +577,7 @@ EntityWrapperPtr createCircle(FeaturePtr theFeature, EntityWrapperPtr aCenterEnt, aRadiusEnt, aNormalEnt; std::list::const_iterator anIt = theAttributes.begin(); for (; anIt != theAttributes.end(); ++anIt) { - std::shared_ptr aSlvsEntity = + std::shared_ptr aSlvsEntity = std::dynamic_pointer_cast(*anIt); if (aSlvsEntity->isBase(aCenter)) aCenterEnt = aSlvsEntity; @@ -604,7 +617,7 @@ EntityWrapperPtr createArc(FeaturePtr theFeature, EntityWrapperPtr aCenterEnt, aStartEnt, aEndEnt, aNormalEnt; std::list::const_iterator anIt = theAttributes.begin(); for (; anIt != theAttributes.end(); ++anIt) { - std::shared_ptr aSlvsEntity = + std::shared_ptr aSlvsEntity = std::dynamic_pointer_cast(*anIt); if (aSlvsEntity->isBase(aCenter)) aCenterEnt = aSlvsEntity; @@ -700,7 +713,7 @@ void adjustAngle(ConstraintWrapperPtr theConstraint) aConstraint->baseConstraint()->boolean( SketchPlugin_ConstraintAngle::ANGLE_REVERSED_SECOND_LINE_ID())->value() }; - std::shared_ptr + std::shared_ptr anAngle(new GeomAPI_Angle2d(aLine[0], isReversed[0], aLine[1], isReversed[1])); std::shared_ptr aCenter = anAngle->center(); @@ -746,10 +759,10 @@ void makeMirrorPoints(EntityWrapperPtr theOriginal, (*aMIt)->setValue(aCoord[i]); // update corresponding attribute - AttributePtr anAttr = + AttributePtr anAttr = std::dynamic_pointer_cast(theMirrored)->baseAttribute(); if (anAttr) { - std::shared_ptr aMirroredPnt = + std::shared_ptr aMirroredPnt = std::dynamic_pointer_cast(anAttr); aMirroredPnt->setValue(aCoord[0], aCoord[1]); }