From bb5bba6e567f9cae87f9fbaf584d2d0502ec372e Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 2 Nov 2016 19:02:42 +0300 Subject: [PATCH] Issue #1834: Fix length of lines --- src/SketchPlugin/SketchPlugin_Arc.cpp | 57 ++++-- src/SketchPlugin/SketchPlugin_Circle.cpp | 3 +- .../SketchPlugin_ConstraintAngle.cpp | 38 ++-- .../SketchPlugin_ConstraintCoincidence.cpp | 4 +- .../SketchPlugin_ConstraintDistance.cpp | 9 +- .../SketchPlugin_ConstraintFillet.cpp | 114 +++++++---- .../SketchPlugin_ConstraintFillet.h | 17 +- .../SketchPlugin_ConstraintLength.cpp | 13 +- .../SketchPlugin_ConstraintMirror.cpp | 18 +- .../SketchPlugin_ConstraintParallel.cpp | 1 - .../SketchPlugin_ConstraintPerpendicular.cpp | 4 +- .../SketchPlugin_ConstraintRadius.cpp | 9 +- .../SketchPlugin_ConstraintSplit.cpp | 192 +++++++++++------- .../SketchPlugin_ConstraintSplit.h | 18 +- .../SketchPlugin_ExternalValidator.cpp | 5 +- .../SketchPlugin_ExternalValidator.h | 3 +- .../SketchPlugin_IntersectionPoint.cpp | 3 +- .../SketchPlugin_MultiRotation.cpp | 17 +- .../SketchPlugin_MultiTranslation.cpp | 18 +- src/SketchPlugin/SketchPlugin_Plugin.cpp | 15 +- src/SketchPlugin/SketchPlugin_Projection.cpp | 15 +- src/SketchPlugin/SketchPlugin_Sketch.cpp | 9 +- src/SketchPlugin/SketchPlugin_Sketch.h | 2 +- .../SketchPlugin_SketchEntity.cpp | 6 +- src/SketchPlugin/SketchPlugin_SketchEntity.h | 6 +- src/SketchPlugin/SketchPlugin_Tools.cpp | 2 +- src/SketchPlugin/SketchPlugin_Validators.cpp | 103 ++++++---- 27 files changed, 453 insertions(+), 248 deletions(-) diff --git a/src/SketchPlugin/SketchPlugin_Arc.cpp b/src/SketchPlugin/SketchPlugin_Arc.cpp index 4de512510..ef74d2d04 100644 --- a/src/SketchPlugin/SketchPlugin_Arc.cpp +++ b/src/SketchPlugin/SketchPlugin_Arc.cpp @@ -150,9 +150,11 @@ void SketchPlugin_Arc::execute() std::shared_ptr aCircleShape; if(!isInversed->value()) { - aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStartPoint, aEndPoint, aNormal); + aCircleShape = + GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStartPoint, aEndPoint, aNormal); } else { - aCircleShape = GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aEndPoint, aStartPoint, aNormal); + aCircleShape = + GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aEndPoint, aStartPoint, aNormal); } if (aCircleShape) { @@ -193,7 +195,8 @@ AISObjectPtr SketchPlugin_Arc::getAISObject(AISObjectPtr thePrevious) bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0); if (aHasPlane) { std::shared_ptr aNormal = aNDir->dir(); - std::shared_ptr aStartPoint(aSketch->to3D(aStartAttr->x(), aStartAttr->y())); + std::shared_ptr + aStartPoint(aSketch->to3D(aStartAttr->x(), aStartAttr->y())); std::shared_ptr aEndPoint = aStartPoint; if (aTypeAttr && aTypeAttr->isInitialized() && aTypeAttr->value() == ARC_TYPE_THREE_POINTS()) { @@ -201,12 +204,15 @@ AISObjectPtr SketchPlugin_Arc::getAISObject(AISObjectPtr thePrevious) aEndAttr->pnt()->distance(aStartAttr->pnt()) > tolerance) { aEndPoint = aSketch->to3D(aEndAttr->x(), aEndAttr->y()); std::shared_ptr aPassedAttr = - std::dynamic_pointer_cast(data()->attribute(PASSED_POINT_ID())); - if (!aPassedAttr->isInitialized()) { // calculate the appropriate center for the presentation + std::dynamic_pointer_cast( + data()->attribute(PASSED_POINT_ID())); + if (!aPassedAttr->isInitialized()) { + // calculate the appropriate center for the presentation // check that center is bad for the current start and end and must be recomputed std::shared_ptr aCircleForArc(new GeomAPI_Circ2d( aCenterAttr->pnt(), aStartAttr->pnt())); - std::shared_ptr aProjection = aCircleForArc->project(aEndAttr->pnt()); + std::shared_ptr aProjection = + aCircleForArc->project(aEndAttr->pnt()); if (!aProjection.get() || aEndAttr->pnt()->distance(aProjection) > tolerance) { std::shared_ptr aDir = aEndAttr->pnt()->xy()->decreased(aStartAttr->pnt()->xy())->multiplied(0.5); @@ -235,7 +241,8 @@ AISObjectPtr SketchPlugin_Arc::getAISObject(AISObjectPtr thePrevious) } } // make a visible point - std::shared_ptr aCenterPointShape = GeomAlgoAPI_PointBuilder::vertex(aCenter); + std::shared_ptr aCenterPointShape = + GeomAlgoAPI_PointBuilder::vertex(aCenter); aShapes.push_back(aCenterPointShape); } if (!aShapes.empty()) { @@ -312,9 +319,11 @@ bool SketchPlugin_Arc::isFeatureValid() bool isValid = false; if (anArcType == ARC_TYPE_THREE_POINTS()) - isValid = aStartAttr->isInitialized() && anEndAttr->isInitialized() && aPassedAttr->isInitialized(); + isValid = aStartAttr->isInitialized() && + anEndAttr->isInitialized() && aPassedAttr->isInitialized(); else - isValid = aCenterAttr->isInitialized() && aStartAttr->isInitialized() && anEndAttr->isInitialized(); + isValid = aCenterAttr->isInitialized() && + aStartAttr->isInitialized() && anEndAttr->isInitialized(); return isValid; } @@ -366,7 +375,8 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) std::dynamic_pointer_cast(attribute(ARC_TYPE())); // this is before others since here end attribute may be changed, but with the special behavior - if (aTypeAttr->value() == ARC_TYPE_TANGENT() && (theID == TANGENT_POINT_ID() || theID == END_ID())) { + if (aTypeAttr->value() == ARC_TYPE_TANGENT() && + (theID == TANGENT_POINT_ID() || theID == END_ID())) { SketchPlugin_Sketch* aSketch = sketch(); AttributeRefAttrPtr aTangPtAttr = std::dynamic_pointer_cast( data()->attribute(TANGENT_POINT_ID())); @@ -402,7 +412,8 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) std::shared_ptr aMidPnt( new GeomAPI_Pnt2d(aEndPntCoord->added(aTangPnt2d->xy())->multiplied(0.5))); - // compute center of arc by calculating intersection of orthogonal line and middle perpendicular + // compute center of arc by calculating intersection of + // orthogonal line and middle perpendicular std::shared_ptr anOrthoLine(new GeomAPI_Lin2d(aTangPnt2d, anOrthoDir)); std::shared_ptr aMiddleLine(new GeomAPI_Lin2d(aMidPnt, aMidDir)); std::shared_ptr aCenter = anOrthoLine->intersect(aMiddleLine); @@ -441,7 +452,8 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) } } // update all other attributes due to the base attributes values - if (aTypeAttr->value() == ARC_TYPE_THREE_POINTS()) { // update passed point due to start, end and center + if (aTypeAttr->value() == ARC_TYPE_THREE_POINTS()) { + // update passed point due to start, end and center if (aCenter->distance(aStart) > tolerance && aCenter->distance(anEnd) > tolerance) { // project passed point t othe circle std::shared_ptr aPassedAttr = @@ -484,7 +496,8 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) aCircle->parameter(anEnd, paramTolerance, aEndParam); adjustPeriod(aStartParam); adjustPeriod(aEndParam); - if (aTypeAttr->value() == ARC_TYPE_THREE_POINTS()) { // use the passed point for the angle calculation + // use the passed point for the angle calculation + if (aTypeAttr->value() == ARC_TYPE_THREE_POINTS()) { std::shared_ptr aPassedAttr = std::dynamic_pointer_cast(data()->attribute(PASSED_POINT_ID())); double aPassedParam; @@ -545,7 +558,8 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) } if (theID == RADIUS_ID()) { - if (!aStartAttr->isInitialized() || !anEndAttr->isInitialized() || !aCenterAttr->isInitialized()) + if (!aStartAttr->isInitialized() || !anEndAttr->isInitialized() || + !aCenterAttr->isInitialized()) return; // move center and passed point std::shared_ptr aStart = aStartAttr->pnt(); @@ -558,11 +572,15 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) double aRadius = aRadiusAttr->value(); data()->blockSendAttributeUpdated(true); - std::shared_ptr aStartDir(new GeomAPI_Dir2d(aStart->xy()->decreased(aCenter->xy()))); - std::shared_ptr aNewStart = aStartDir->xy()->multiplied(aRadius)->added(aCenter->xy()); + std::shared_ptr + aStartDir(new GeomAPI_Dir2d(aStart->xy()->decreased(aCenter->xy()))); + std::shared_ptr + aNewStart = aStartDir->xy()->multiplied(aRadius)->added(aCenter->xy()); aStartAttr->setValue(aNewStart->x(), aNewStart->y()); - std::shared_ptr anEndDir(new GeomAPI_Dir2d(anEnd->xy()->decreased(aCenter->xy()))); - std::shared_ptr aNewEnd = anEndDir->xy()->multiplied(aRadius)->added(aCenter->xy()); + std::shared_ptr + anEndDir(new GeomAPI_Dir2d(anEnd->xy()->decreased(aCenter->xy()))); + std::shared_ptr + aNewEnd = anEndDir->xy()->multiplied(aRadius)->added(aCenter->xy()); anEndAttr->setValue(aNewEnd->x(), aNewEnd->y()); data()->blockSendAttributeUpdated(false); return; @@ -590,7 +608,8 @@ void SketchPlugin_Arc::attributeChanged(const std::string& theID) void SketchPlugin_Arc::setReversed(bool isReversed) { - std::dynamic_pointer_cast(attribute(INVERSED_ID()))->setValue(isReversed); + std::dynamic_pointer_cast( + attribute(INVERSED_ID()))->setValue(isReversed); myParamBefore = 0.0; } diff --git a/src/SketchPlugin/SketchPlugin_Circle.cpp b/src/SketchPlugin/SketchPlugin_Circle.cpp index cc8a992bc..3df29fe2d 100644 --- a/src/SketchPlugin/SketchPlugin_Circle.cpp +++ b/src/SketchPlugin/SketchPlugin_Circle.cpp @@ -123,7 +123,8 @@ AISObjectPtr SketchPlugin_Circle::getAISObject(AISObjectPtr thePrevious) if (aCircleShape && aRadius != 0) { std::list > aShapes; // make a visible point - std::shared_ptr aCenterPointShape = GeomAlgoAPI_PointBuilder::vertex(aCenter); + std::shared_ptr aCenterPointShape = + GeomAlgoAPI_PointBuilder::vertex(aCenter); aShapes.push_back(aCenterPointShape); aShapes.push_back(aCircleShape); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp b/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp index 65ac80b15..432b28eb4 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintAngle.cpp @@ -42,11 +42,15 @@ void SketchPlugin_ConstraintAngle::initAttributes() data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId()); data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId()); - data()->addAttribute(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID(), ModelAPI_AttributeDouble::typeId()); - data()->addAttribute(SketchPlugin_ConstraintAngle::TYPE_ID(), ModelAPI_AttributeInteger::typeId()); - - data()->addAttribute(SketchPlugin_ConstraintAngle::ANGLE_REVERSED_FIRST_LINE_ID(), ModelAPI_AttributeBoolean::typeId()); - data()->addAttribute(SketchPlugin_ConstraintAngle::ANGLE_REVERSED_SECOND_LINE_ID(), ModelAPI_AttributeBoolean::typeId()); + data()->addAttribute(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID(), + ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(SketchPlugin_ConstraintAngle::TYPE_ID(), + ModelAPI_AttributeInteger::typeId()); + + data()->addAttribute(SketchPlugin_ConstraintAngle::ANGLE_REVERSED_FIRST_LINE_ID(), + ModelAPI_AttributeBoolean::typeId()); + data()->addAttribute(SketchPlugin_ConstraintAngle::ANGLE_REVERSED_SECOND_LINE_ID(), + ModelAPI_AttributeBoolean::typeId()); } void SketchPlugin_ConstraintAngle::colorConfigInfo(std::string& theSection, std::string& theName, @@ -61,8 +65,10 @@ void SketchPlugin_ConstraintAngle::execute() { std::shared_ptr aData = data(); - std::shared_ptr anAttrA = aData->refattr(SketchPlugin_Constraint::ENTITY_A()); - std::shared_ptr anAttrB = aData->refattr(SketchPlugin_Constraint::ENTITY_B()); + std::shared_ptr anAttrA = + aData->refattr(SketchPlugin_Constraint::ENTITY_A()); + std::shared_ptr anAttrB = + aData->refattr(SketchPlugin_Constraint::ENTITY_B()); if (!anAttrA->isInitialized() || !anAttrB->isInitialized()) return; @@ -74,7 +80,8 @@ void SketchPlugin_ConstraintAngle::execute() anAttrValue->setValue(anAngle); updateConstraintValueByAngleValue(); } - // the value should to be computed here, not in the getAISObject in order to change the model value + // the value should to be computed here, not in the + // getAISObject in order to change the model value // inside the object transaction. This is important for creating a constraint by preselection. // The display of the presentation in this case happens after the transaction commit std::shared_ptr aFlyOutAttr = std::dynamic_pointer_cast< @@ -109,7 +116,8 @@ void SketchPlugin_ConstraintAngle::attributeChanged(const std::string& theID) AttributeDoublePtr aConstrValueAttr = real(SketchPlugin_Constraint::VALUE()); // only if one of attributes is not initialized, try to compute the current value if (!aValueAttr->isInitialized() || !aConstrValueAttr->isInitialized()) { - if (aValueAttr->isInitialized() && !aConstrValueAttr->isInitialized()) // initialize base value of constraint + if (aValueAttr->isInitialized() && !aConstrValueAttr->isInitialized()) + // initialize base value of constraint updateConstraintValueByAngleValue(); double anAngle = calculateAngle(); aValueAttr->setValue(anAngle); @@ -119,12 +127,15 @@ void SketchPlugin_ConstraintAngle::attributeChanged(const std::string& theID) // Recalculate flyout point in local coordinates // coordinates are calculated according to the center of shapes intersection std::shared_ptr aFlyoutAttr = - std::dynamic_pointer_cast(attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); + std::dynamic_pointer_cast( + attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT())); std::shared_ptr aData = data(); std::shared_ptr aPlane = SketchPlugin_Sketch::plane(sketch()); - FeaturePtr aLineA = SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A()); - FeaturePtr aLineB = SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B()); + FeaturePtr aLineA = + SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_A()); + FeaturePtr aLineB = + SketcherPrs_Tools::getFeatureLine(aData, SketchPlugin_Constraint::ENTITY_B()); // Intersection of lines std::shared_ptr anInter = intersect(aLineA, aLineB); @@ -174,7 +185,8 @@ double SketchPlugin_ConstraintAngle::calculateAngle() bool isReversed1 = boolean(ANGLE_REVERSED_FIRST_LINE_ID())->value(); std::shared_ptr aLine2(new GeomAPI_Lin2d(aStartB->pnt(), aEndB->pnt())); bool isReversed2 = boolean(ANGLE_REVERSED_SECOND_LINE_ID())->value(); - anAng = std::shared_ptr(new GeomAPI_Angle2d(aLine1, isReversed1, aLine2, isReversed2)); + anAng = std::shared_ptr( + new GeomAPI_Angle2d(aLine1, isReversed1, aLine2, isReversed2)); } double anAngle = anAng->angleDegree(); std::shared_ptr aValueAttr = std::dynamic_pointer_cast< diff --git a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp index 5f79a167e..8d2ab687e 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintCoincidence.cpp @@ -89,10 +89,10 @@ AttributePoint2DPtr SketchPlugin_ConstraintCoincidence::getPoint(const FeaturePt { AttributePoint2DPtr aPoint = ModelGeomAlgo_Point2D::getPointOfRefAttr(theFeature.get(), SketchPlugin_Constraint::ENTITY_A(), - SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID()); + SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID()); if (!aPoint.get()) aPoint = ModelGeomAlgo_Point2D::getPointOfRefAttr(theFeature.get(), SketchPlugin_Constraint::ENTITY_B(), - SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID()); + SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID()); return aPoint; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp index 35104dc38..02931bcc2 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintDistance.cpp @@ -71,7 +71,8 @@ AISObjectPtr SketchPlugin_ConstraintDistance::getAISObject(AISObjectPtr thePrevi if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this, sketch()->coordinatePlane(), + AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this, + sketch()->coordinatePlane(), thePrevious); return anAIS; } @@ -170,7 +171,8 @@ void SketchPlugin_ConstraintDistance::attributeChanged(const std::string& theID) { std::shared_ptr aValueAttr = std::dynamic_pointer_cast< ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); - if (!aValueAttr->isInitialized()) { // only if it is not initialized, try to compute the current value + if (!aValueAttr->isInitialized()) { + // only if it is not initialized, try to compute the current value double aDistance = calculateCurrentDistance(); if (aDistance > 0) { // set as value the length of updated references aValueAttr->setValue(aDistance); @@ -179,7 +181,8 @@ void SketchPlugin_ConstraintDistance::attributeChanged(const std::string& theID) } else if (theID == SketchPlugin_Constraint::FLYOUT_VALUE_PNT() && !myFlyoutUpdate) { myFlyoutUpdate = true; // Recalculate flyout point in local coordinates of the distance constraint: - // the X coordinate is a length of projection of the flyout point on the line binding two distanced points + // the X coordinate is a length of projection of the flyout point on the + // line binding two distanced points // or a line of projection of the distanced point onto the distanced segment // the Y coordinate is a distance from the flyout point to the line std::shared_ptr aFlyoutAttr = diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp index 0481c4a14..c2ad12f99 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp @@ -69,7 +69,8 @@ SketchPlugin_ConstraintFillet::SketchPlugin_ConstraintFillet() void SketchPlugin_ConstraintFillet::initAttributes() { data()->addAttribute(SketchPlugin_Constraint::VALUE(), ModelAPI_AttributeDouble::typeId()); - data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttrList::typeId()); + data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), + ModelAPI_AttributeRefAttrList::typeId()); } void SketchPlugin_ConstraintFillet::execute() @@ -98,7 +99,8 @@ void SketchPlugin_ConstraintFillet::execute() aPointsIter != myNewPoints.end(); ++aPointsIter) { AttributePtr aPointAttr = *aPointsIter; - std::shared_ptr aFilletPoint2d = std::dynamic_pointer_cast(aPointAttr); + std::shared_ptr aFilletPoint2d = + std::dynamic_pointer_cast(aPointAttr); if(!aFilletPoint2d.get()) { setError("Error: One of the selected points is empty."); return; @@ -108,7 +110,8 @@ void SketchPlugin_ConstraintFillet::execute() // Obtain base lines for fillet. bool anIsNeedNewObjects = true; FilletFeatures aFilletFeatures; - std::map::iterator aPrevPointsIter = myPointFeaturesMap.find(aPointAttr); + std::map::iterator aPrevPointsIter = + myPointFeaturesMap.find(aPointAttr); if(aPrevPointsIter != myPointFeaturesMap.end()) { anIsNeedNewObjects = false; aFilletFeatures = aPrevPointsIter->second; @@ -121,7 +124,8 @@ void SketchPlugin_ConstraintFillet::execute() // Obtain constraint coincidence for the fillet point. FeaturePtr aConstraintCoincidence; const std::set& aRefsList = aFilletPoint2d->owner()->data()->refsToMe(); - for(std::set::const_iterator anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) { + for(std::set::const_iterator + anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) { std::shared_ptr anAttr = (*anIt); FeaturePtr aConstrFeature = std::dynamic_pointer_cast(anAttr->owner()); if(aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { @@ -162,8 +166,12 @@ void SketchPlugin_ConstraintFillet::execute() aBaseEdgeA = *aLinesIt++; aBaseEdgeB = *aLinesIt; - std::pair aBasePairA = std::make_pair(aBaseEdgeA, aBaseEdgeA->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()); - std::pair aBasePairB = std::make_pair(aBaseEdgeB, aBaseEdgeB->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()); + std::pair aBasePairA = + std::make_pair(aBaseEdgeA, + aBaseEdgeA->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()); + std::pair aBasePairB = + std::make_pair(aBaseEdgeB, + aBaseEdgeB->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()); aFilletFeatures.baseEdgesState.push_back(aBasePairA); aFilletFeatures.baseEdgesState.push_back(aBasePairB); } @@ -198,9 +206,11 @@ void SketchPlugin_ConstraintFillet::execute() static const int aNbFeatures = 2; FeaturePtr aBaseFeatures[aNbFeatures] = {aBaseEdgeA, aBaseEdgeB}; FeaturePtr aResultFeatures[aNbFeatures] = {aResultEdgeA, aResultEdgeB}; - std::shared_ptr aTangentDir[aNbFeatures]; // tangent directions of the features in coincident point + // tangent directions of the features in coincident point + std::shared_ptr aTangentDir[aNbFeatures]; bool isStart[aNbFeatures]; // indicates which point the features share - std::shared_ptr aStartEndPnt[aNbFeatures * 2]; // first pair of points relate to first feature, second pair - to second + // first pair of points relate to first feature, second pair - to second + std::shared_ptr aStartEndPnt[aNbFeatures * 2]; std::string aFeatAttributes[aNbFeatures * 2]; // attributes of features for (int i = 0; i < aNbFeatures; i++) { std::string aStartAttr, aEndAttr; @@ -236,7 +246,8 @@ void SketchPlugin_ConstraintFillet::execute() if (!isStart[i]) aDir = aDir->multiplied(-1.0); } else if (aResultFeatures[i]->getKind() == SketchPlugin_Arc::ID()) { - std::shared_ptr aCenterPoint = std::dynamic_pointer_cast( + std::shared_ptr aCenterPoint = + std::dynamic_pointer_cast( aResultFeatures[i]->attribute(SketchPlugin_Arc::CENTER_ID()))->pnt(); aDir = isStart[i] ? aStartEndPnt[2*i]->xy() : aStartEndPnt[2*i+1]->xy(); aDir = aDir->decreased(aCenterPoint->xy()); @@ -245,7 +256,8 @@ void SketchPlugin_ConstraintFillet::execute() double y = aDir->y(); aDir->setX(-y); aDir->setY(x); - if (isStart[i] == std::dynamic_pointer_cast(aBaseFeatures[i])->isReversed()) + if (isStart[i] == + std::dynamic_pointer_cast(aBaseFeatures[i])->isReversed()) aDir = aDir->multiplied(-1.0); } aTangentDir[i] = std::shared_ptr(new GeomAPI_Dir2d(aDir)); @@ -254,24 +266,29 @@ void SketchPlugin_ConstraintFillet::execute() // By default, the start point of fillet arc is connected to FeatureA, // and the end point - to FeatureB. But when the angle between TangentDirA and // TangentDirB greater 180 degree, the sequaence of features need to be reversed. - double cosBA = aTangentDir[0]->cross(aTangentDir[1]); // cos(B-A), where A and B - angles between corresponding tanget direction and the X axis + double cosBA = aTangentDir[0]->cross(aTangentDir[1]); // cos(B-A), + // where A and B - angles between corresponding tanget direction and the X axis bool isReversed = cosBA > 0.0; // Calculate fillet arc parameters std::shared_ptr aCenter, aTangentPntA, aTangentPntB; - calculateFilletCenter(aBaseEdgeA, aBaseEdgeB, aFilletRadius, isStart, aCenter, aTangentPntA, aTangentPntB); + calculateFilletCenter(aBaseEdgeA, aBaseEdgeB, aFilletRadius, + isStart, aCenter, aTangentPntA, aTangentPntB); if(!aCenter.get() || !aTangentPntA.get() || !aTangentPntB.get()) { setError("Can not create fillet with the specified parameters."); return; } // update features std::dynamic_pointer_cast( - aResultEdgeA->attribute(aFeatAttributes[isStart[0] ? 0 : 1]))->setValue(aTangentPntA->x(), aTangentPntA->y()); + aResultEdgeA->attribute(aFeatAttributes[isStart[0] ? 0 : 1]))-> + setValue(aTangentPntA->x(), aTangentPntA->y()); aResultEdgeA->execute(); std::dynamic_pointer_cast( - aResultEdgeB->attribute(aFeatAttributes[2 + (isStart[1] ? 0 : 1)]))->setValue(aTangentPntB->x(), aTangentPntB->y()); + aResultEdgeB->attribute(aFeatAttributes[2 + (isStart[1] ? 0 : 1)]))-> + setValue(aTangentPntB->x(), aTangentPntB->y()); aResultEdgeB->execute(); - // update fillet arc: make the arc correct for sure, so, it is not needed to process the "attribute updated" + // update fillet arc: make the arc correct for sure, so, it is not needed to + // process the "attribute updated" // by arc; moreover, it may cause cyclicity in hte mechanism of updater aResultArc->data()->blockSendAttributeUpdated(true); std::dynamic_pointer_cast( @@ -281,7 +298,8 @@ void SketchPlugin_ConstraintFillet::execute() aTangentPntA = aTangentPntB; aTangentPntB = aTmp; } - std::shared_ptr aStartPoint = std::dynamic_pointer_cast( + std::shared_ptr aStartPoint = + std::dynamic_pointer_cast( aResultArc->attribute(SketchPlugin_Arc::START_ID())); std::shared_ptr aEndPoint = std::dynamic_pointer_cast( aResultArc->attribute(SketchPlugin_Arc::END_ID())); @@ -308,7 +326,8 @@ void SketchPlugin_ConstraintFillet::execute() int aFeatInd = isReversed ? 1 : 0; int anAttrInd = (isReversed ? 2 : 0) + (isStart[isReversed ? 1 : 0] ? 0 : 1); aRefAttr->setAttr(aResultFeatures[aFeatInd]->attribute(aFeatAttributes[anAttrInd])); - recalculateAttributes(aResultArc, SketchPlugin_Arc::START_ID(), aResultFeatures[aFeatInd], aFeatAttributes[anAttrInd]); + recalculateAttributes(aResultArc, SketchPlugin_Arc::START_ID(), + aResultFeatures[aFeatInd], aFeatAttributes[anAttrInd]); aConstraint->execute(); aFilletFeatures.resultConstraints.push_back(aConstraint); ModelAPI_EventCreator::get()->sendUpdated(aConstraint, anUpdateEvent); @@ -322,7 +341,8 @@ void SketchPlugin_ConstraintFillet::execute() aFeatInd = isReversed ? 0 : 1; anAttrInd = (isReversed ? 0 : 2) + (isStart[isReversed ? 0 : 1] ? 0 : 1); aRefAttr->setAttr(aResultFeatures[aFeatInd]->attribute(aFeatAttributes[anAttrInd])); - recalculateAttributes(aResultArc, SketchPlugin_Arc::END_ID(), aResultFeatures[aFeatInd], aFeatAttributes[anAttrInd]); + recalculateAttributes(aResultArc, SketchPlugin_Arc::END_ID(), + aResultFeatures[aFeatInd], aFeatAttributes[anAttrInd]); aConstraint->execute(); aFilletFeatures.resultConstraints.push_back(aConstraint); ModelAPI_EventCreator::get()->sendUpdated(aConstraint, anUpdateEvent); @@ -348,7 +368,8 @@ void SketchPlugin_ConstraintFillet::execute() aRefAttr = std::dynamic_pointer_cast( aConstraint->attribute(SketchPlugin_Constraint::ENTITY_B())); bool isArc = aResultFeatures[i]->getKind() == SketchPlugin_Arc::ID(); - aRefAttr->setObject(isArc ? aResultFeatures[i]->lastResult() : aResultFeatures[i]->firstResult()); + aRefAttr->setObject(isArc ? aResultFeatures[i]->lastResult() : + aResultFeatures[i]->firstResult()); aConstraint->execute(); aFilletFeatures.resultConstraints.push_back(aConstraint); ModelAPI_EventCreator::get()->sendUpdated(aConstraint, anUpdateEvent); @@ -446,7 +467,8 @@ void SketchPlugin_ConstraintFillet::attributeChanged(const std::string& theID) myNewPoints.clear(); // Get list of points for fillets and current radius. - AttributeRefAttrListPtr aRefListOfFilletPoints = std::dynamic_pointer_cast( + AttributeRefAttrListPtr aRefListOfFilletPoints = + std::dynamic_pointer_cast( data()->attribute(SketchPlugin_Constraint::ENTITY_A())); AttributeDoublePtr aRadiusAttribute = real(VALUE()); int aListSize = aRefListOfFilletPoints->size(); @@ -460,7 +482,8 @@ void SketchPlugin_ConstraintFillet::attributeChanged(const std::string& theID) // Iterate over points to get base lines an calculate radius for fillets. double aMinimumRadius = 0; - std::list> aSelectedPointsList = aRefListOfFilletPoints->list(); + std::list> + aSelectedPointsList = aRefListOfFilletPoints->list(); std::list>::iterator anIter = aSelectedPointsList.begin(); std::set aPointsToSkeep; for(int anIndex = 0; anIndex < aListSize; anIndex++, anIter++) { @@ -484,7 +507,8 @@ void SketchPlugin_ConstraintFillet::attributeChanged(const std::string& theID) // Obtain constraint coincidence for the fillet point. FeaturePtr aConstraintCoincidence; const std::set& aRefsList = aFilletPointAttr->owner()->data()->refsToMe(); - for(std::set::const_iterator anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) { + for(std::set::const_iterator + anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) { std::shared_ptr anAttr = (*anIt); FeaturePtr aConstrFeature = std::dynamic_pointer_cast(anAttr->owner()); if(aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { @@ -526,10 +550,12 @@ void SketchPlugin_ConstraintFillet::attributeChanged(const std::string& theID) SketchPlugin_ConstraintCoincidence::ENTITY_B(), aCoincides); - // Remove points from set of coincides. Also get all attributes which is equal to this point to exclude it. + // Remove points from set of coincides. + // Also get all attributes which is equal to this point to exclude it. std::shared_ptr aFilletPnt2d = aFilletPoint2D->pnt(); std::set aNewSetOfCoincides; - for(std::set::iterator anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) { + for(std::set::iterator + anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) { std::string aFeatureKind = (*anIt)->getKind(); if(aFeatureKind == SketchPlugin_Point::ID()) { AttributePtr anAttr = (*anIt)->attribute(SketchPlugin_Point::COORD_ID()); @@ -580,7 +606,8 @@ void SketchPlugin_ConstraintFillet::attributeChanged(const std::string& theID) // If we still have more than two coincides remove auxilary entities from set of coincides. if(aCoincides.size() > 2) { aNewSetOfCoincides.clear(); - for(std::set::iterator anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) { + for(std::set::iterator + anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) { if(!(*anIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) { aNewSetOfCoincides.insert(*anIt); } @@ -616,7 +643,8 @@ void SketchPlugin_ConstraintFillet::attributeChanged(const std::string& theID) double aDistanceA = getProjectionDistance(anOldFeatureB, aPntA); double aDistanceB = getProjectionDistance(anOldFeatureA, aPntB); double aRadius = aDistanceA < aDistanceB ? aDistanceA / 2.0 : aDistanceB / 2.0; - aMinimumRadius = aMinimumRadius == 0 ? aRadius : aRadius < aMinimumRadius ? aRadius : aMinimumRadius; + aMinimumRadius = aMinimumRadius == 0 ? aRadius : + aRadius < aMinimumRadius ? aRadius : aMinimumRadius; } } @@ -662,7 +690,8 @@ void SketchPlugin_ConstraintFillet::clearResults() for(aFeatureIt = aFilletFeatures.baseEdgesState.cbegin(); aFeatureIt != aFilletFeatures.baseEdgesState.cend(); ++aFeatureIt) { - aFeatureIt->first->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->setValue(aFeatureIt->second); + aFeatureIt->first->boolean( + SketchPlugin_SketchEntity::AUXILIARY_ID())->setValue(aFeatureIt->second); } ++aPointsIter; } @@ -788,11 +817,15 @@ void possibleFilletCenterArcArc( double aMedDist = (aRadA * aRadA - aRadB * aRadB + aCenterDist2) / (2.0 * aCenterDist); double aHeight = sqrt(aRadA * aRadA - aMedDist * aMedDist); - double x1 = theCenterA->x() + (aMedDist * aCenterDir->x() + aCenterDir->y() * aHeight) / aCenterDist; - double y1 = theCenterA->y() + (aMedDist * aCenterDir->y() - aCenterDir->x() * aHeight) / aCenterDist; + double x1 = theCenterA->x() + + (aMedDist * aCenterDir->x() + aCenterDir->y() * aHeight) / aCenterDist; + double y1 = theCenterA->y() + + (aMedDist * aCenterDir->y() - aCenterDir->x() * aHeight) / aCenterDist; - double x2 = theCenterA->x() + (aMedDist * aCenterDir->x() - aCenterDir->y() * aHeight) / aCenterDist; - double y2 = theCenterA->y() + (aMedDist * aCenterDir->y() + aCenterDir->x() * aHeight) / aCenterDist; + double x2 = theCenterA->x() + + (aMedDist * aCenterDir->x() - aCenterDir->y() * aHeight) / aCenterDist; + double y2 = theCenterA->y() + + (aMedDist * aCenterDir->y() + aCenterDir->x() * aHeight) / aCenterDist; std::shared_ptr aPoint1(new GeomAPI_XY(x1, y1)); theCenters.push_back(aPoint1); @@ -847,7 +880,8 @@ void calculateFilletCenter(FeaturePtr theFeatureA, FeaturePtr theFeatureB, // get and filter possible centers std::list< std::shared_ptr > aSuspectCenters; - possibleFilletCenterLineLine(aStart[0], aDir[0], aStart[1], aDir[1], theRadius, aSuspectCenters); + possibleFilletCenterLineLine(aStart[0], aDir[0], aStart[1], aDir[1], + theRadius, aSuspectCenters); double aDot = 0.0; std::list< std::shared_ptr >::iterator anIt = aSuspectCenters.begin(); for (; anIt != aSuspectCenters.end(); anIt++) { @@ -882,7 +916,8 @@ void calculateFilletCenter(FeaturePtr theFeatureA, FeaturePtr theFeatureB, // get possible centers and filter them std::list< std::shared_ptr > aSuspectCenters; - possibleFilletCenterLineArc(aStart[aLineInd], aDirLine, aCenter[1-aLineInd], anArcRadius, theRadius, aSuspectCenters); + possibleFilletCenterLineArc(aStart[aLineInd], aDirLine, aCenter[1-aLineInd], + anArcRadius, theRadius, aSuspectCenters); double aDot = 0.0; // the line is forward into the arc double innerArc = aCenter[1-aLineInd]->decreased(aStart[aLineInd])->dot(aDirLine->xy()); @@ -938,7 +973,8 @@ void calculateFilletCenter(FeaturePtr theFeatureA, FeaturePtr theFeatureB, // get and filter possible centers std::list< std::shared_ptr > aSuspectCenters; - possibleFilletCenterArcArc(aCenter[0], anArcRadius[0], aCenter[1], anArcRadius[1], theRadius, aSuspectCenters); + possibleFilletCenterArcArc(aCenter[0], anArcRadius[0], aCenter[1], + anArcRadius[1], theRadius, aSuspectCenters); double aDot = 0.0; std::shared_ptr aLineTgPoint, anArcTgPoint; std::list< std::shared_ptr >::iterator anIt = aSuspectCenters.begin(); @@ -979,7 +1015,9 @@ void getPointOnEdge(const FeaturePtr theFeature, aPntEnd = std::dynamic_pointer_cast( theFeature->attribute(SketchPlugin_Line::START_ID()))->pnt(); } - thePoint.reset( new GeomAPI_Pnt2d(aPntStart->xy()->added( aPntEnd->xy()->decreased( aPntStart->xy() )->multiplied(1.0 / 3.0) ) ) ); + thePoint.reset( + new GeomAPI_Pnt2d(aPntStart->xy()->added( + aPntEnd->xy()->decreased( aPntStart->xy() )->multiplied(1.0 / 3.0) ) ) ); } else { std::shared_ptr aPntTemp; std::shared_ptr aPntStart = std::dynamic_pointer_cast( @@ -1038,7 +1076,8 @@ std::set getCoincides(const FeaturePtr& theConstraintCoincidence) { std::set aCoincides; - std::shared_ptr aFilletPnt = SketchPlugin_Tools::getCoincidencePoint(theConstraintCoincidence); + std::shared_ptr aFilletPnt = + SketchPlugin_Tools::getCoincidencePoint(theConstraintCoincidence); SketchPlugin_Tools::findCoincidences(theConstraintCoincidence, SketchPlugin_ConstraintCoincidence::ENTITY_A(), @@ -1067,7 +1106,8 @@ std::set getCoincides(const FeaturePtr& theConstraintCoincidence) // If we still have more than two coincides remove auxilary entities from set of coincides. if(aCoincides.size() > 2) { aNewSetOfCoincides.clear(); - for(std::set::iterator anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) { + for(std::set::iterator + anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) { if(!(*anIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) { aNewSetOfCoincides.insert(*anIt); } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.h b/src/SketchPlugin/SketchPlugin_ConstraintFillet.h index 0f665a32f..d965eaff5 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.h @@ -13,10 +13,12 @@ /** \class SketchPlugin_ConstraintFillet * \ingroup Plugins - * \brief Feature for creation of a new constraint filleting two objects which have coincident point + * \brief Feature for creation of a new constraint filleting two objects which have + * coincident point * * This constraint has three attributes: - * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() for the filleting objects; + * SketchPlugin_Constraint::ENTITY_A() and SketchPlugin_Constraint::ENTITY_B() + * for the filleting objects; * SketchPlugin_Constraint::VALUE() contains radius of filleting circular arc * * Also the constraint has attribute SketchPlugin_Constraint::ENTITY_C() @@ -27,9 +29,10 @@ class SketchPlugin_ConstraintFillet : public SketchPlugin_ConstraintBase public: /// \struct Struct to store base edges with states, result edges and constraints. struct FilletFeatures { - std::list> baseEdgesState; ///< list of objects the fillet is based and its states - std::list resultEdges; ///< list of result edges - std::list resultConstraints; ///< list of constraints provided by the fillet + /// list of objects the fillet is based and its states + std::list> baseEdgesState; + std::list resultEdges; ///< list of result edges + std::list resultConstraints; ///< list of constraints provided by the fillet }; /// Fillet constraint kind @@ -76,7 +79,9 @@ private: private: std::set myNewPoints; ///< set of new points - std::map myPointFeaturesMap; ///< map of point and features for fillet + + /// map of point and features for fillet + std::map myPointFeaturesMap; bool myListOfPointsChangedInCode; ///< flag to track that list of points changed in code bool myRadiusChangedByUser; ///< flag to track that radius changed by user bool myRadiusChangedInCode; ///< flag to track that radius changed in code diff --git a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp index 9a87f7f26..6b291b643 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintLength.cpp @@ -68,10 +68,12 @@ void SketchPlugin_ConstraintLength::execute() // aValueAttr->setValue(aLenght); //} - // the value should to be computed here, not in the getAISObject in order to change the model value + // the value should to be computed here, not in the getAISObject + // in order to change the model value // inside the object transaction. This is important for creating a constraint by preselection. // The display of the presentation in this case happens after the transaction commit - AttributePtr aFlyOutAttribute = data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); + AttributePtr aFlyOutAttribute = + data()->attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); if (!aFlyOutAttribute->isInitialized()) { compute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()); } @@ -145,8 +147,8 @@ AISObjectPtr SketchPlugin_ConstraintLength::getAISObject(AISObjectPtr thePreviou if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this, sketch()->coordinatePlane(), - thePrevious); + AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this, + sketch()->coordinatePlane(), thePrevious); return anAIS; } @@ -186,7 +188,8 @@ void SketchPlugin_ConstraintLength::attributeChanged(const std::string& theID) { { std::shared_ptr aValueAttr = std::dynamic_pointer_cast< ModelAPI_AttributeDouble>(attribute(SketchPlugin_Constraint::VALUE())); - if (!aValueAttr->isInitialized()) { // only if it is not initialized, try to compute the current value + if (!aValueAttr->isInitialized()) { + // only if it is not initialized, try to compute the current value double aLength; if (computeLenghtValue(aLength)) aValueAttr->setValue(aLength); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp index 42ed4d5b4..797d293e3 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintMirror.cpp @@ -31,9 +31,12 @@ void SketchPlugin_ConstraintMirror::initAttributes() data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_C(), ModelAPI_AttributeRefList::typeId()); - data()->addAttribute(SketchPlugin_ConstraintMirror::MIRROR_LIST_ID(), ModelAPI_AttributeRefList::typeId()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_C()); + data()->addAttribute(SketchPlugin_ConstraintMirror::MIRROR_LIST_ID(), + ModelAPI_AttributeRefList::typeId()); + ModelAPI_Session::get()->validators()-> + registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B()); + ModelAPI_Session::get()->validators()-> + registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_C()); } void SketchPlugin_ConstraintMirror::execute() @@ -133,7 +136,8 @@ void SketchPlugin_ConstraintMirror::execute() if (aMirrorIter != aMirroredList.end()) break; // the lists are inconsistent // There is no mirrored object yet, create it - FeaturePtr aNewFeature = SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeatureIn, sketch(), true); + FeaturePtr aNewFeature = + SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeatureIn, sketch(), true); aNewFeature->execute(); ModelAPI_EventCreator::get()->sendUpdated(aNewFeature, aRedisplayEvent); @@ -207,13 +211,15 @@ void SketchPlugin_ConstraintMirror::erase() static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); std::list aTargetList = aRefListOfMirrored->list(); - for(std::list::const_iterator aTargetIt = aTargetList.cbegin(); aTargetIt != aTargetList.cend(); aTargetIt++) { + for(std::list::const_iterator aTargetIt = + aTargetList.cbegin(); aTargetIt != aTargetList.cend(); aTargetIt++) { if((*aTargetIt).get()) { ResultPtr aRes = std::dynamic_pointer_cast(*aTargetIt); if(aRes.get()) { FeaturePtr aFeature = aRes->document()->feature(aRes); if(aFeature.get()) { - AttributeBooleanPtr aBooleanAttr = aFeature->boolean(SketchPlugin_SketchEntity::COPY_ID()); + AttributeBooleanPtr aBooleanAttr = + aFeature->boolean(SketchPlugin_SketchEntity::COPY_ID()); if(aBooleanAttr.get()) { if (ModelAPI_Session::get()->isOperation()) // if this is not undo or redo aBooleanAttr->setValue(false); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp index 7a6f71af5..7d34a8412 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintParallel.cpp @@ -31,7 +31,6 @@ void SketchPlugin_ConstraintParallel::initAttributes() { data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefAttr::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefAttr::typeId()); - //data()->addAttribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT(), GeomDataAPI_Point2D::typeId()); } void SketchPlugin_ConstraintParallel::execute() diff --git a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp index c7e327fa1..30817fdc9 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintPerpendicular.cpp @@ -41,8 +41,8 @@ AISObjectPtr SketchPlugin_ConstraintPerpendicular::getAISObject(AISObjectPtr the if (!sketch()) return thePrevious; - AISObjectPtr anAIS = SketcherPrs_Factory::perpendicularConstraint(this, sketch()->coordinatePlane(), - thePrevious); + AISObjectPtr anAIS = SketcherPrs_Factory::perpendicularConstraint(this, + sketch()->coordinatePlane(), thePrevious); return anAIS; } diff --git a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp index f4bf1708f..339fe9af3 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintRadius.cpp @@ -75,7 +75,8 @@ void SketchPlugin_ConstraintRadius::execute() // aValueAttr->setValue(aRadius); //} - // the value should to be computed here, not in the getAISObject in order to change the model value + // the value should to be computed here, + // not in the getAISObject in order to change the model value // inside the object transaction. This is important for creating a constraint by preselection. // The display of the presentation in this case happens after the transaction commit std::shared_ptr aFlyoutAttr = std::dynamic_pointer_cast< @@ -100,7 +101,8 @@ bool SketchPlugin_ConstraintRadius::compute(const std::string& theAttributeId) GeomDataAPI_Point2D>(data()->attribute(theAttributeId)); // Prepare a circle if (aCyrcFeature->getKind() == SketchPlugin_Circle::ID()) { // circle - std::shared_ptr aCenterAttr = std::dynamic_pointer_cast( + std::shared_ptr aCenterAttr = + std::dynamic_pointer_cast( aCyrcFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID())); double aShift = aRadius * 1.1; std::shared_ptr aPnt = aCenterAttr->pnt(); @@ -174,7 +176,8 @@ void SketchPlugin_ConstraintRadius::attributeChanged(const std::string& theID) { if (theID == SketchPlugin_Constraint::ENTITY_A()) { std::shared_ptr aValueAttr = std::dynamic_pointer_cast< ModelAPI_AttributeDouble>(data()->attribute(SketchPlugin_Constraint::VALUE())); - if (!aValueAttr->isInitialized()) { // only if it is not initialized, try to compute the current value + if (!aValueAttr->isInitialized()) { + // only if it is not initialized, try to compute the current value std::shared_ptr aCyrcFeature; double aRadius = circleRadius(aCyrcFeature); if (aRadius > 0) { // set as value the radius of updated reference to another circle diff --git a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp index 6a0cb2efd..156dc33fa 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp @@ -72,8 +72,10 @@ void SketchPlugin_ConstraintSplit::execute() setError("Error: Base object is not initialized."); return; } - AttributePoint2DPtr aFirstPointAttrOfSplit = getPointOfRefAttr(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); - AttributePoint2DPtr aSecondPointAttrOfSplit = getPointOfRefAttr(aData->attribute(SketchPlugin_Constraint::ENTITY_B())); + AttributePoint2DPtr aFirstPointAttrOfSplit = + getPointOfRefAttr(aData->attribute(SketchPlugin_Constraint::ENTITY_A())); + AttributePoint2DPtr aSecondPointAttrOfSplit = + getPointOfRefAttr(aData->attribute(SketchPlugin_Constraint::ENTITY_B())); if (!aFirstPointAttrOfSplit.get() || !aFirstPointAttrOfSplit->isInitialized() || !aSecondPointAttrOfSplit.get() || !aSecondPointAttrOfSplit->isInitialized()) { setError("Error: Sub-shape is not initialized."); @@ -118,7 +120,8 @@ void SketchPlugin_ConstraintSplit::execute() std::cout << std::endl; if (!aCoincidenceToFeature.empty()) { - std::cout << "Coincidences to base feature[" << aCoincidenceToFeature.size() << "]: " << std::endl; + std::cout << "Coincidences to base feature[" << + aCoincidenceToFeature.size() << "]: " << std::endl; std::map::const_iterator anIt = aCoincidenceToFeature.begin(), aLast = aCoincidenceToFeature.end(); for (int i = 1; anIt != aLast; anIt++, i++) { @@ -128,7 +131,8 @@ void SketchPlugin_ConstraintSplit::execute() std::cout << i << "-" << getFeatureInfo(aFeature) << std::endl; std::cout << " -Attribute to correct:" << anAttributeId << std::endl; - std::cout << " -Point attribute:" << ModelGeomAlgo_Point2D::getPointAttributeInfo(aPointAttr) << std::endl; + std::cout << " -Point attribute:" << + ModelGeomAlgo_Point2D::getPointAttributeInfo(aPointAttr) << std::endl; } } @@ -144,13 +148,15 @@ void SketchPlugin_ConstraintSplit::execute() std::cout << i << "-" << getFeatureInfo(aFeature) << std::endl; std::cout << " -Attribute to correct:" << anAttributeId << std::endl; - std::cout << " -Point attribute:" << ModelGeomAlgo_Point2D::getPointAttributeInfo(aPointAttr) << std::endl; + std::cout << " -Point attribute:" << + ModelGeomAlgo_Point2D::getPointAttributeInfo(aPointAttr) << std::endl; } } - std::map >::const_iterator aRefIt = aBaseRefAttributes.begin(), - aRefLast = aBaseRefAttributes.end(); - std::cout << std::endl << "References to attributes of base feature [" << aBaseRefAttributes.size() << "]" << std::endl; + std::map >::const_iterator + aRefIt = aBaseRefAttributes.begin(), aRefLast = aBaseRefAttributes.end(); + std::cout << std::endl << "References to attributes of base feature [" << + aBaseRefAttributes.size() << "]" << std::endl; for (; aRefIt != aRefLast; aRefIt++) { AttributePtr aBaseAttr = aRefIt->first; std::list aRefAttributes = aRefIt->second; @@ -165,11 +171,14 @@ void SketchPlugin_ConstraintSplit::execute() FeaturePtr aRFeature = ModelAPI_Feature::feature(aRAttr->owner()); aRefsInfo.append("(" + aRFeature->name() + ") "); } - std::shared_ptr aPointAttr = std::dynamic_pointer_cast(aBaseAttr); - std::cout << aPointAttr->id().c_str() << ": " << "[" << aRefAttributes.size() << "] " << aRefsInfo << std::endl; + std::shared_ptr aPointAttr = + std::dynamic_pointer_cast(aBaseAttr); + std::cout << aPointAttr->id().c_str() << + ": " << "[" << aRefAttributes.size() << "] " << aRefsInfo << std::endl; } std::cout << std::endl; - std::cout << std::endl << "References to base feature [" << aRefsToFeature.size() << "]" << std::endl; + std::cout << std::endl << "References to base feature [" << + aRefsToFeature.size() << "]" << std::endl; std::list::const_iterator aRefAttrIt = aRefsToFeature.begin(), aRefAttrLast = aRefsToFeature.end(); std::string aRefsInfo; @@ -202,13 +211,14 @@ void SketchPlugin_ConstraintSplit::execute() aModifiedAttributes); if (aFeatureKind == SketchPlugin_Circle::ID()) { FeaturePtr aCircleFeature = aBaseFeature; - splitCircle(aSplitFeature, aBaseFeature, anAfterFeature, aFurtherCoincidences, aCreatedFeatures, - aModifiedAttributes); + splitCircle(aSplitFeature, aBaseFeature, anAfterFeature, aFurtherCoincidences, + aCreatedFeatures, aModifiedAttributes); updateRefFeatureConstraints(getFeatureResult(aBaseFeature), aRefsToFeature); aFeaturesToDelete.insert(aCircleFeature); - aBaseObjectAttr->setObject(ResultPtr()); // as circle is removed, temporary fill this attribute*/ + // as circle is removed, temporary fill this attribute*/ + aBaseObjectAttr->setObject(ResultPtr()); } #ifdef DEBUG_SPLIT @@ -237,8 +247,8 @@ void SketchPlugin_ConstraintSplit::execute() } std::cout << "Modifed attributes (constraints to attributes are moved here):" << std::endl; - std::set >::const_iterator aPIt = aModifiedAttributes.begin(), - aPLast = aModifiedAttributes.end(); + std::set >::const_iterator + aPIt = aModifiedAttributes.begin(), aPLast = aModifiedAttributes.end(); std::string aResInfo; for (; aPIt != aPLast; aPIt++) { if (!aResInfo.empty()) @@ -339,13 +349,15 @@ AISObjectPtr SketchPlugin_ConstraintSplit::getAISObject(AISObjectPtr thePrevious aPoints.push_back(aStartPoint); std::shared_ptr aSecondPnt2d = aSecondPointAttrOfSplit->pnt(); - std::shared_ptr aSecondPoint = sketch()->to3D(aSecondPnt2d->x(), aSecondPnt2d->y()); + std::shared_ptr aSecondPoint = + sketch()->to3D(aSecondPnt2d->x(), aSecondPnt2d->y()); aPoints.push_back(aSecondPoint); std::set > aSplitShapes; GeomAlgoAPI_ShapeTools::splitShape(aBaseShape, aPoints, aSplitShapes); - std::shared_ptr aShape = GeomAlgoAPI_ShapeTools::findShape(aPoints, aSplitShapes); + std::shared_ptr aShape = + GeomAlgoAPI_ShapeTools::findShape(aPoints, aSplitShapes); AISObjectPtr anAIS = thePrevious; if (aShape) { @@ -364,12 +376,13 @@ AISObjectPtr SketchPlugin_ConstraintSplit::getAISObject(AISObjectPtr thePrevious } std::shared_ptr SketchPlugin_ConstraintSplit::getPointOfRefAttr( - const AttributePtr& theAttribute) + const AttributePtr& theAttribute) { AttributePoint2DPtr aPointAttribute; if (theAttribute->attributeType() == ModelAPI_AttributeRefAttr::typeId()) { - AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(theAttribute); + AttributeRefAttrPtr aRefAttr = + std::dynamic_pointer_cast(theAttribute); if (aRefAttr.get() && aRefAttr->isInitialized()) { AttributePtr anAttribute = aRefAttr->attr(); if (anAttribute.get() && anAttribute->attributeType() == GeomDataAPI_Point2D::typeId()) @@ -400,9 +413,9 @@ void SketchPlugin_ConstraintSplit::getFeaturePoints(AttributePoint2DPtr& theStar } if (!aStartAttributeName.empty() && !anEndAttributeName.empty()) { theStartPointAttr = std::dynamic_pointer_cast( - aBaseFeature->attribute(aStartAttributeName)); + aBaseFeature->attribute(aStartAttributeName)); theEndPointAttr = std::dynamic_pointer_cast( - aBaseFeature->attribute(anEndAttributeName)); + aBaseFeature->attribute(anEndAttributeName)); } } @@ -436,16 +449,18 @@ void SketchPlugin_ConstraintSplit::getConstraints(std::set& theFeatu theFeaturesToUpdate.insert(aRefFeature); else if (aRefFeatureKind == SketchPlugin_ConstraintTangent::ID()) { if (aBaseFeature->getKind() == SketchPlugin_Circle::ID()) /// TEMPORARY limitaion - theFeaturesToDelete.insert(aRefFeature); /// until tangency between arc and line is implemented + /// until tangency between arc and line is implemented + theFeaturesToDelete.insert(aRefFeature); else { std::string anAttributeToBeModified; AttributePoint2DPtr aTangentPoint; ObjectPtr aResult1 = aRefFeature->refattr(SketchPlugin_Constraint::ENTITY_A())->object(); ObjectPtr aResult2 = aRefFeature->refattr(SketchPlugin_Constraint::ENTITY_B())->object(); if (aResult1.get() && aResult2.get()) { - FeaturePtr aCoincidenceFeature = SketchPlugin_ConstraintCoincidence::findCoincidenceFeature - (ModelAPI_Feature::feature(aResult1), - ModelAPI_Feature::feature(aResult2)); + FeaturePtr aCoincidenceFeature = + SketchPlugin_ConstraintCoincidence::findCoincidenceFeature + (ModelAPI_Feature::feature(aResult1), + ModelAPI_Feature::feature(aResult2)); // get the point not lying on the splitting feature for (int i = 0; i < CONSTRAINT_ATTR_SIZE; ++i) { AttributeRefAttrPtr aRefAttr = aCoincidenceFeature->refattr(ATTRIBUTE(i)); @@ -467,8 +482,8 @@ void SketchPlugin_ConstraintSplit::getConstraints(std::set& theFeatu ? SketchPlugin_Constraint::ENTITY_A() : SketchPlugin_Constraint::ENTITY_B(); theTangentFeatures[aRefFeature] = std::make_pair(anAttributeToBeModified, aTangentPoint); } - else - theFeaturesToDelete.insert(aRefFeature); /// there is not coincident point between tangent constraint + else /// there is not coincident point between tangent constraint + theFeaturesToDelete.insert(aRefFeature); } } else if (aRefFeatureKind == SketchPlugin_ConstraintCoincidence::ID()) { @@ -529,15 +544,17 @@ void SketchPlugin_ConstraintSplit::getConstraints(std::set& theFeatu } void SketchPlugin_ConstraintSplit::getRefAttributes(const FeaturePtr& theFeature, - std::map >& theRefs, - std::list& theRefsToFeature) + std::map >& theRefs, + std::list& theRefsToFeature) { theRefs.clear(); - std::list aPointAttributes = theFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); + std::list aPointAttributes = + theFeature->data()->attributes(GeomDataAPI_Point2D::typeId()); std::set aPointAttributesSet; - std::list::const_iterator aPIt = aPointAttributes.begin(), aPLast = aPointAttributes.end(); + std::list::const_iterator aPIt = + aPointAttributes.begin(), aPLast = aPointAttributes.end(); for (; aPIt != aPLast; aPIt++) aPointAttributesSet.insert(*aPIt); @@ -554,7 +571,8 @@ void SketchPlugin_ConstraintSplit::getRefAttributes(const FeaturePtr& theFeature AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(anAttr); if (!aRefAttr->isObject()) { /// find attributes referenced to feature point attributes AttributePtr anAttrInRef = aRefAttr->attr(); - if (anAttrInRef.get() && aPointAttributesSet.find(anAttrInRef) != aPointAttributesSet.end()) { + if (anAttrInRef.get() && + aPointAttributesSet.find(anAttrInRef) != aPointAttributesSet.end()) { if (theRefs.find(anAttrInRef) != theRefs.end()) theRefs[anAttrInRef].push_back(aRefAttr); else { @@ -653,7 +671,8 @@ void SketchPlugin_ConstraintSplit::updateTangentConstraintsToFeature( aFeaturePointAttribute = aFCAttribute; } if (aFeaturePointAttribute.get()) { - FeaturePtr aFeature = std::dynamic_pointer_cast(aFeaturePointAttribute->owner()); + FeaturePtr aFeature = + std::dynamic_pointer_cast(aFeaturePointAttribute->owner()); aTangentFeature->refattr(anAttributeId)->setObject(getFeatureResult(aFeature)); } #ifdef DEBUG_SPLIT @@ -662,8 +681,9 @@ void SketchPlugin_ConstraintSplit::updateTangentConstraintsToFeature( } } -void SketchPlugin_ConstraintSplit::updateRefFeatureConstraints(const ResultPtr& theFeatureBaseResult, - const std::list& theRefsToFeature) +void SketchPlugin_ConstraintSplit::updateRefFeatureConstraints( + const ResultPtr& theFeatureBaseResult, + const std::list& theRefsToFeature) { std::list::const_iterator anIt = theRefsToFeature.begin(), aLast = theRefsToFeature.end(); @@ -675,19 +695,20 @@ void SketchPlugin_ConstraintSplit::updateRefFeatureConstraints(const ResultPtr& } void SketchPlugin_ConstraintSplit::updateRefAttConstraints( - const std::map >& theBaseRefAttributes, - const std::set >& theModifiedAttributes) + const std::map >& theBaseRefAttributes, + const std::set >& theModifiedAttributes) { #ifdef DEBUG_SPLIT std::cout << "SketchPlugin_ConstraintSplit::updateRefAttConstraints" << std::endl; #endif - std::set >::const_iterator anIt = theModifiedAttributes.begin(), - aLast = theModifiedAttributes.end(); + std::set >::const_iterator + anIt = theModifiedAttributes.begin(), aLast = theModifiedAttributes.end(); for (; anIt != aLast; anIt++) { AttributePtr anAttribute = anIt->first; - if (theBaseRefAttributes.find(anAttribute) == theBaseRefAttributes.end()) /// not found in references + /// not found in references + if (theBaseRefAttributes.find(anAttribute) == theBaseRefAttributes.end()) continue; std::list aRefAttributes = theBaseRefAttributes.at(anAttribute); std::list::const_iterator aRefIt = aRefAttributes.begin(), @@ -729,8 +750,10 @@ void SketchPlugin_ConstraintSplit::splitLine(FeaturePtr& theSplitFeature, if (aFeatureKind != SketchPlugin_Line::ID()) return; - AttributePoint2DPtr aFirstPointAttrOfSplit = getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); - AttributePoint2DPtr aSecondPointAttrOfSplit = getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_B())); + AttributePoint2DPtr aFirstPointAttrOfSplit = + getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); + AttributePoint2DPtr aSecondPointAttrOfSplit = + getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_B())); AttributePoint2DPtr aStartPointAttrOfBase, anEndPointAttrOfBase; getFeaturePoints(aStartPointAttrOfBase, anEndPointAttrOfBase); if (!aStartPointAttrOfBase.get() && !anEndPointAttrOfBase.get()) { @@ -738,24 +761,30 @@ void SketchPlugin_ConstraintSplit::splitLine(FeaturePtr& theSplitFeature, return; } - arrangePointsOnLine(aStartPointAttrOfBase, anEndPointAttrOfBase, aFirstPointAttrOfSplit, aSecondPointAttrOfSplit); + arrangePointsOnLine(aStartPointAttrOfBase, anEndPointAttrOfBase, + aFirstPointAttrOfSplit, aSecondPointAttrOfSplit); #ifdef DEBUG_SPLIT std::cout << "Arranged points (to build split between 1st and 2nd points:" << std::endl; - std::cout << "Start point: " << ModelGeomAlgo_Point2D::getPointAttributeInfo(aStartPointAttrOfBase) << std::endl; - std::cout << "1st point: " << ModelGeomAlgo_Point2D::getPointAttributeInfo(aFirstPointAttrOfSplit) << std::endl; - std::cout << "2nd point: " << ModelGeomAlgo_Point2D::getPointAttributeInfo(aSecondPointAttrOfSplit) << std::endl; - std::cout << "End point: " << ModelGeomAlgo_Point2D::getPointAttributeInfo(anEndPointAttrOfBase) << std::endl; + std::cout << "Start point: " << + ModelGeomAlgo_Point2D::getPointAttributeInfo(aStartPointAttrOfBase) << std::endl; + std::cout << "1st point: " << + ModelGeomAlgo_Point2D::getPointAttributeInfo(aFirstPointAttrOfSplit) << std::endl; + std::cout << "2nd point: " << + ModelGeomAlgo_Point2D::getPointAttributeInfo(aSecondPointAttrOfSplit) << std::endl; + std::cout << "End point: " << + ModelGeomAlgo_Point2D::getPointAttributeInfo(anEndPointAttrOfBase) << std::endl; #endif /// create a split feature - theSplitFeature = createLineFeature(aBaseFeature, aFirstPointAttrOfSplit, aSecondPointAttrOfSplit); + theSplitFeature = + createLineFeature(aBaseFeature, aFirstPointAttrOfSplit, aSecondPointAttrOfSplit); theCreatedFeatures.insert(theSplitFeature); // before split feature if (aStartPointAttrOfBase->pnt()->isEqual(aFirstPointAttrOfSplit->pnt())) { theModifiedAttributes.insert(std::make_pair(aStartPointAttrOfBase, - theSplitFeature->attribute(SketchPlugin_Line::START_ID()))); + theSplitFeature->attribute(SketchPlugin_Line::START_ID()))); } else { theBaseFeatureModified = aBaseFeature; ///< use base feature to store all constraints here @@ -774,7 +803,7 @@ void SketchPlugin_ConstraintSplit::splitLine(FeaturePtr& theSplitFeature, aFeature = createLineFeature(aBaseFeature, aSecondPointAttrOfSplit, anEndPointAttrOfBase); theCreatedFeatures.insert(aFeature); theModifiedAttributes.insert(std::make_pair(anEndPointAttrOfBase, - aFeature->attribute(SketchPlugin_Line::END_ID()))); + aFeature->attribute(SketchPlugin_Line::END_ID()))); } aConstraintFeature = createConstraint(SketchPlugin_ConstraintCoincidence::ID(), theSplitFeature->attribute(SketchPlugin_Line::END_ID()), @@ -795,14 +824,15 @@ void SketchPlugin_ConstraintSplit::splitLine(FeaturePtr& theSplitFeature, thePoints.insert(std::dynamic_pointer_cast (theSplitFeature->attribute(SketchPlugin_Line::END_ID()))); theModifiedAttributes.insert(std::make_pair(anEndPointAttrOfBase, - theSplitFeature->attribute(SketchPlugin_Line::END_ID()))); + theSplitFeature->attribute(SketchPlugin_Line::END_ID()))); } // base split, that is defined before split feature should be changed at end // (after the after feature creation). Otherwise modified value will be used in after feature // before split feature if (!aStartPointAttrOfBase->pnt()->isEqual(aFirstPointAttrOfSplit->pnt())) { /// move end arc point to start of split - fillAttribute(theBaseFeatureModified->attribute(SketchPlugin_Line::END_ID()), aFirstPointAttrOfSplit); + fillAttribute(theBaseFeatureModified->attribute(SketchPlugin_Line::END_ID()), + aFirstPointAttrOfSplit); theBaseFeatureModified->execute(); // to update result aConstraintFeature = createConstraint(SketchPlugin_ConstraintCoincidence::ID(), theBaseFeatureModified->attribute(SketchPlugin_Line::END_ID()), @@ -853,8 +883,10 @@ void SketchPlugin_ConstraintSplit::splitArc(FeaturePtr& theSplitFeature, if (aFeatureKind != SketchPlugin_Arc::ID()) return; - AttributePoint2DPtr aFirstPointAttrOfSplit = getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); - AttributePoint2DPtr aSecondPointAttrOfSplit = getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_B())); + AttributePoint2DPtr aFirstPointAttrOfSplit = + getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); + AttributePoint2DPtr aSecondPointAttrOfSplit = + getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_B())); AttributePoint2DPtr aStartPointAttrOfBase, anEndPointAttrOfBase; getFeaturePoints(aStartPointAttrOfBase, anEndPointAttrOfBase); if (!aStartPointAttrOfBase.get() && !anEndPointAttrOfBase.get()) { @@ -870,10 +902,14 @@ void SketchPlugin_ConstraintSplit::splitArc(FeaturePtr& theSplitFeature, aFirstPointAttrOfSplit, aSecondPointAttrOfSplit); #ifdef DEBUG_SPLIT std::cout << "Arranged points (to build split between 1st and 2nd points:" << std::endl; - std::cout << "Start point: " << ModelGeomAlgo_Point2D::getPointAttributeInfo(aStartPointAttrOfBase) << std::endl; - std::cout << "1st point: " << ModelGeomAlgo_Point2D::getPointAttributeInfo(aFirstPointAttrOfSplit) << std::endl; - std::cout << "2nd point: " << ModelGeomAlgo_Point2D::getPointAttributeInfo(aSecondPointAttrOfSplit) << std::endl; - std::cout << "End point: " << ModelGeomAlgo_Point2D::getPointAttributeInfo(anEndPointAttrOfBase) << std::endl; + std::cout << "Start point: " << + ModelGeomAlgo_Point2D::getPointAttributeInfo(aStartPointAttrOfBase) << std::endl; + std::cout << "1st point: " << + ModelGeomAlgo_Point2D::getPointAttributeInfo(aFirstPointAttrOfSplit) << std::endl; + std::cout << "2nd point: " << + ModelGeomAlgo_Point2D::getPointAttributeInfo(aSecondPointAttrOfSplit) << std::endl; + std::cout << "End point: " << + ModelGeomAlgo_Point2D::getPointAttributeInfo(anEndPointAttrOfBase) << std::endl; #endif /// split feature @@ -883,7 +919,7 @@ void SketchPlugin_ConstraintSplit::splitArc(FeaturePtr& theSplitFeature, // before split feature if (aStartPointAttrOfBase->pnt()->isEqual(aFirstPointAttrOfSplit->pnt())) { theModifiedAttributes.insert(std::make_pair(aStartPointAttrOfBase, - theSplitFeature->attribute(SketchPlugin_Arc::START_ID()))); + theSplitFeature->attribute(SketchPlugin_Arc::START_ID()))); } else { theBaseFeatureModified = aBaseFeature; ///< use base feature to store all constraints here @@ -930,7 +966,8 @@ void SketchPlugin_ConstraintSplit::splitArc(FeaturePtr& theSplitFeature, // before split feature if (!aStartPointAttrOfBase->pnt()->isEqual(aFirstPointAttrOfSplit->pnt())) { /// move end arc point to start of split - fillAttribute(theBaseFeatureModified->attribute(SketchPlugin_Arc::END_ID()), aFirstPointAttrOfSplit); + fillAttribute(theBaseFeatureModified->attribute(SketchPlugin_Arc::END_ID()), + aFirstPointAttrOfSplit); theBaseFeatureModified->execute(); // to update result aConstraintFeature = createConstraint(SketchPlugin_ConstraintCoincidence::ID(), theBaseFeatureModified->attribute(SketchPlugin_Arc::END_ID()), @@ -989,21 +1026,27 @@ void SketchPlugin_ConstraintSplit::splitCircle(FeaturePtr& theSplitFeature, if (aFeatureKind != SketchPlugin_Circle::ID()) return; - AttributePoint2DPtr aFirstPointAttrOfSplit = getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); - AttributePoint2DPtr aSecondPointAttrOfSplit = getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_B())); + AttributePoint2DPtr aFirstPointAttrOfSplit = + getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_A())); + AttributePoint2DPtr aSecondPointAttrOfSplit = + getPointOfRefAttr(data()->attribute(SketchPlugin_Constraint::ENTITY_B())); /// split feature - theSplitFeature = createArcFeature(aBaseFeature, aFirstPointAttrOfSplit, aSecondPointAttrOfSplit); + theSplitFeature = + createArcFeature(aBaseFeature, aFirstPointAttrOfSplit, aSecondPointAttrOfSplit); bool aSplitReversed = std::dynamic_pointer_cast(theSplitFeature)->isReversed(); theCreatedFeatures.insert(theSplitFeature); /// base feature is a left part of the circle - theBaseFeatureModified = createArcFeature(aBaseFeature, aFirstPointAttrOfSplit, aSecondPointAttrOfSplit); - std::dynamic_pointer_cast(theBaseFeatureModified)->setReversed(!aSplitReversed); + theBaseFeatureModified = createArcFeature(aBaseFeature, + aFirstPointAttrOfSplit, aSecondPointAttrOfSplit); + std::dynamic_pointer_cast( + theBaseFeatureModified)->setReversed(!aSplitReversed); theBaseFeatureModified->execute(); - theModifiedAttributes.insert(std::make_pair(aBaseFeature->attribute(SketchPlugin_Circle::CENTER_ID()), - theBaseFeatureModified->attribute(SketchPlugin_Arc::CENTER_ID()))); + theModifiedAttributes.insert( + std::make_pair(aBaseFeature->attribute(SketchPlugin_Circle::CENTER_ID()), + theBaseFeatureModified->attribute(SketchPlugin_Arc::CENTER_ID()))); theCreatedFeatures.insert(theBaseFeatureModified); @@ -1129,7 +1172,8 @@ FeaturePtr SketchPlugin_ConstraintSplit::createArcFeature(const FeaturePtr& theB return aFeature; aFeature = aSketch->addFeature(SketchPlugin_Arc::ID()); - // update fillet arc: make the arc correct for sure, so, it is not needed to process the "attribute updated" + // update fillet arc: make the arc correct for sure, so, it is not needed to process + // the "attribute updated" // by arc; moreover, it may cause cyclicity in hte mechanism of updater aFeature->data()->blockSendAttributeUpdated(true); @@ -1168,7 +1212,8 @@ FeaturePtr SketchPlugin_ConstraintSplit::createConstraint(const std::string& the return aConstraint; } -FeaturePtr SketchPlugin_ConstraintSplit::createConstraintForObjects(const std::string& theConstraintId, +FeaturePtr SketchPlugin_ConstraintSplit::createConstraintForObjects( + const std::string& theConstraintId, const ObjectPtr& theFirstObject, const ObjectPtr& theSecondObject) { @@ -1258,14 +1303,15 @@ std::string SketchPlugin_ConstraintSplit::getFeatureInfo( if (isUseAttributesInfo) { std::string aPointsInfo = ModelGeomAlgo_Point2D::getPontAttributesInfo(theFeature, getEdgeAttributes(theFeature)); - if (!aPointsInfo.empty()) { /// processing of feature with point 2d attributes, like line, arc, circle + /// processing of feature with point 2d attributes, like line, arc, circle + if (!aPointsInfo.empty()) { anInfo += ": "; anInfo += "\n"; anInfo += aPointsInfo; } else { /// process constraint coincidence, find points in ref attr attributes std::list anAttrs = theFeature->data()->attributes( - ModelAPI_AttributeRefAttr::typeId()); + ModelAPI_AttributeRefAttr::typeId()); std::list::const_iterator anIt = anAttrs.begin(), aLast = anAttrs.end(); std::string anAttributesInfo; for(; anIt != aLast; anIt++) { @@ -1278,7 +1324,7 @@ std::string SketchPlugin_ConstraintSplit::getFeatureInfo( std::string aType = anAttr->attributeType(); if (aType == ModelAPI_AttributeRefAttr::typeId()) { std::shared_ptr aRefAttr = - std::dynamic_pointer_cast(anAttr); + std::dynamic_pointer_cast(anAttr); if (aRefAttr.get()) { if (aRefAttr->isObject()) { FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object()); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintSplit.h b/src/SketchPlugin/SketchPlugin_ConstraintSplit.h index 78df54272..1af0db8f7 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintSplit.h +++ b/src/SketchPlugin/SketchPlugin_ConstraintSplit.h @@ -115,8 +115,9 @@ private: std::map, IdToPointPair>& theCoincidenceToPoint*/); /// Obtains references to feature point attributes and to feature, - /// e.g. for feature line: 1st container is <1st line point, list > - /// <2nd line point, list<> > + /// e.g. for feature line: 1st container is + /// <1st line point, list > + /// <2nd line point, list<> > /// for feature circle 2nd container is /// \param theFeature an investigated feature /// \param theRefs a container of list of referenced attributes @@ -129,9 +130,9 @@ private: /// \param theFurtherCoincidences a list of points where coincidences will be build /// \paramv theFeatureResults created results after split where constaint might be connected void updateCoincidenceConstraintsToFeature( - const std::map, IdToPointPair>& theCoincidenceToFeature, - const std::set >& theFurtherCoincidences, - const std::set& theFeatureResults); + const std::map, IdToPointPair>& theCoincidenceToFeature, + const std::set >& theFurtherCoincidences, + const std::set& theFeatureResults); /// Move tangency constraint to the nearest split feature that has a coincidence to the tangent /// \param theTangentFeatures tangencies to feature to be connected to nearest feature @@ -152,8 +153,8 @@ private: /// \param theModifiedAttributes container of attributes placed instead of base attributes /// at the same place void updateRefAttConstraints( - const std::map >& theBaseRefAttributes, - const std::set >& theModifiedAttributes); + const std::map >& theBaseRefAttributes, + const std::set >& theModifiedAttributes); /// Make the base object is splitted by the point attributes /// \param theSplitFeature a result split feature @@ -161,7 +162,8 @@ private: /// \param theAfterFeature a feature between last point of split feature and the end point /// \param thePoints a list of points where coincidences will be build /// \param theCreatedFeatures a container of created features - /// \param theModifiedAttributes a container of attribute on base feature to attribute on new feature + /// \param theModifiedAttributes a container of attribute on base + /// feature to attribute on new feature void splitLine(std::shared_ptr& theSplitFeature, std::shared_ptr& theBeforeFeature, std::shared_ptr& theAfterFeature, diff --git a/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp b/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp index 9c9fc3345..a9d232da6 100644 --- a/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp +++ b/src/SketchPlugin/SketchPlugin_ExternalValidator.cpp @@ -40,13 +40,14 @@ bool SketchPlugin_ExternalValidator::isValid(const AttributePtr& theAttribute, bool SketchPlugin_ExternalValidator::isExternalAttribute(const AttributePtr& theAttribute) const { bool isExternal = false; - AttributeRefAttrPtr anAttribute = std::dynamic_pointer_cast(theAttribute); + AttributeRefAttrPtr anAttribute = + std::dynamic_pointer_cast(theAttribute); if (anAttribute.get() != NULL) { FeaturePtr anArgumentFeature = ModelAPI_Feature::feature(anAttribute->object()); if (anArgumentFeature.get() != NULL) { std::shared_ptr aSketchFeature = - std::dynamic_pointer_cast(anArgumentFeature); + std::dynamic_pointer_cast(anArgumentFeature); if (aSketchFeature.get() != NULL) { isExternal = aSketchFeature->isExternal(); } diff --git a/src/SketchPlugin/SketchPlugin_ExternalValidator.h b/src/SketchPlugin/SketchPlugin_ExternalValidator.h index 303e62650..4d4eaf073 100644 --- a/src/SketchPlugin/SketchPlugin_ExternalValidator.h +++ b/src/SketchPlugin/SketchPlugin_ExternalValidator.h @@ -19,7 +19,8 @@ class SketchPlugin_ExternalValidator : public ModelAPI_AttributeValidator { public: - /// returns true if the feature of attribute do not contain external features in the given attribute and + /// returns true if the feature of attribute do not contain external features + /// in the given attribute and /// among attributes listed in the arguments /// \param theAttribute an attribute to check /// \param theArguments a filter parameters diff --git a/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp b/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp index 3f7c94a89..d32b9a4c6 100644 --- a/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp +++ b/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp @@ -58,7 +58,8 @@ void SketchPlugin_IntersectionPoint::computePoint() std::shared_ptr anEdge; if(aLineAttr && aLineAttr->value() && aLineAttr->value()->isEdge()) { anEdge = std::shared_ptr(new GeomAPI_Edge(aLineAttr->value())); - } else if(aLineAttr->context() && aLineAttr->context()->shape() && aLineAttr->context()->shape()->isEdge()) { + } else if(aLineAttr->context() && aLineAttr->context()->shape() && + aLineAttr->context()->shape()->isEdge()) { anEdge = std::shared_ptr(new GeomAPI_Edge(aLineAttr->context()->shape())); } if(!anEdge.get()) diff --git a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp index 6ae033dec..f208204bb 100755 --- a/src/SketchPlugin/SketchPlugin_MultiRotation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiRotation.cpp @@ -45,8 +45,10 @@ void SketchPlugin_MultiRotation::initAttributes() data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefList::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId()); data()->addAttribute(ROTATION_LIST_ID(), ModelAPI_AttributeRefList::typeId()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_A()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B()); + ModelAPI_Session::get()->validators()-> + registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_A()); + ModelAPI_Session::get()->validators()-> + registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B()); } void SketchPlugin_MultiRotation::execute() @@ -112,7 +114,8 @@ void SketchPlugin_MultiRotation::execute() if (!(*aUsedIter)) { aRefListOfShapes->remove(*anInitIter); aRefListOfRotated->remove(*aTargetIter++); - for (int i = 0; i < aCurrentNbCopies && aTargetIter != aTargetList.end(); i++, aTargetIter++) { + for (int i = 0; i < aCurrentNbCopies && aTargetIter != aTargetList.end(); + i++, aTargetIter++) { aRefListOfRotated->remove(*aTargetIter); // remove the corresponding feature from the sketch ResultConstructionPtr aRC = @@ -195,7 +198,7 @@ void SketchPlugin_MultiRotation::execute() //// while (aTargetIter != aTargetList.end()) { //// ObjectPtr anInitialObject = *aTargetIter++; //// for (int i = 0; i < aNbCopies && aTargetIter != aTargetList.end(); i++, aTargetIter++) -//// rotateFeature(anInitialObject, *aTargetIter, aCenter->x(), aCenter->y(), anAngle * (i + 1)); +//// rotateFeature(anInitialObject, *aTargetIter, aCenter->x(), aCenter->y(), anAngle * (i + 1)); //// } //// } @@ -237,7 +240,8 @@ void SketchPlugin_MultiRotation::erase() if(aRes.get()) { FeaturePtr aFeature = aRes->document()->feature(aRes); if(aFeature.get()) { - AttributeBooleanPtr aBooleanAttr = aFeature->boolean(SketchPlugin_SketchEntity::COPY_ID()); + AttributeBooleanPtr aBooleanAttr = + aFeature->boolean(SketchPlugin_SketchEntity::COPY_ID()); if(aBooleanAttr.get()) { if (ModelAPI_Session::get()->isOperation()) // if this is not undo or redo aBooleanAttr->setValue(false); @@ -260,7 +264,8 @@ ObjectPtr SketchPlugin_MultiRotation::copyFeature(ObjectPtr theObject) if (!aFeature || !aResult) return ObjectPtr(); - FeaturePtr aNewFeature = SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeature, sketch(), true); + FeaturePtr aNewFeature = + SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeature, sketch(), true); aNewFeature->execute(); static Events_ID aRedisplayEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); diff --git a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp index 34e26377b..b08545435 100755 --- a/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp +++ b/src/SketchPlugin/SketchPlugin_MultiTranslation.cpp @@ -39,8 +39,10 @@ void SketchPlugin_MultiTranslation::initAttributes() data()->addAttribute(SketchPlugin_Constraint::ENTITY_A(), ModelAPI_AttributeRefList::typeId()); data()->addAttribute(SketchPlugin_Constraint::ENTITY_B(), ModelAPI_AttributeRefList::typeId()); data()->addAttribute(TRANSLATION_LIST_ID(), ModelAPI_AttributeRefList::typeId()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_A()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B()); + ModelAPI_Session::get()->validators()-> + registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_A()); + ModelAPI_Session::get()->validators()-> + registerNotObligatory(getKind(), SketchPlugin_Constraint::ENTITY_B()); } void SketchPlugin_MultiTranslation::execute() @@ -69,7 +71,8 @@ void SketchPlugin_MultiTranslation::execute() if (!aStart || !aEnd) return; - std::shared_ptr aShiftVec(new GeomAPI_XY(aEnd->x() - aStart->x(), aEnd->y() - aStart->y())); + std::shared_ptr + aShiftVec(new GeomAPI_XY(aEnd->x() - aStart->x(), aEnd->y() - aStart->y())); // Wait all objects being created, then send update events static Events_ID anUpdateEvent = Events_Loop::eventByName(EVENT_OBJECT_UPDATED); @@ -110,7 +113,8 @@ void SketchPlugin_MultiTranslation::execute() if (!(*aUsedIter)) { aRefListOfShapes->remove(*anInitIter); aRefListOfTranslated->remove(*aTargetIter++); - for (int i = 0; i < aCurrentNbCopies && aTargetIter != aTargetList.end(); i++, aTargetIter++) { + for (int i = 0; i < aCurrentNbCopies && aTargetIter != aTargetList.end(); + i++, aTargetIter++) { aRefListOfTranslated->remove(*aTargetIter); // remove the corresponding feature from the sketch ResultConstructionPtr aRC = @@ -222,7 +226,8 @@ void SketchPlugin_MultiTranslation::erase() if(aRes.get()) { FeaturePtr aFeature = aRes->document()->feature(aRes); if(aFeature.get()) { - AttributeBooleanPtr aBooleanAttr = aFeature->boolean(SketchPlugin_SketchEntity::COPY_ID()); + AttributeBooleanPtr aBooleanAttr = + aFeature->boolean(SketchPlugin_SketchEntity::COPY_ID()); if(aBooleanAttr.get()) { if (ModelAPI_Session::get()->isOperation()) // if this is not undo or redo aBooleanAttr->setValue(false); @@ -245,7 +250,8 @@ ObjectPtr SketchPlugin_MultiTranslation::copyFeature(ObjectPtr theObject) if (!aFeature || !aResult) return ObjectPtr(); - FeaturePtr aNewFeature = SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeature, sketch(), true); + FeaturePtr aNewFeature = + SketchPlugin_Sketch::addUniqueNamedCopiedFeature(aFeature, sketch(), true); aNewFeature->execute(); static Events_ID aRedisplayEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY); diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index ebead598f..f446375fa 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -91,16 +91,20 @@ SketchPlugin_Plugin::SketchPlugin_Plugin() // register this plugin ModelAPI_Session::get()->registerPlugin(this); - Config_PropManager::registerProp("Visualization", "sketch_entity_color", "Sketch entity color", + Config_PropManager::registerProp("Visualization", "sketch_entity_color", + "Sketch entity color", Config_Prop::Color, SKETCH_ENTITY_COLOR); - Config_PropManager::registerProp("Visualization", "sketch_external_color", "Sketch external entity color", + Config_PropManager::registerProp("Visualization", "sketch_external_color", + "Sketch external entity color", Config_Prop::Color, SKETCH_EXTERNAL_COLOR); - Config_PropManager::registerProp("Visualization", "sketch_auxiliary_color", "Sketch auxiliary entity color", + Config_PropManager::registerProp("Visualization", "sketch_auxiliary_color", + "Sketch auxiliary entity color", Config_Prop::Color, SKETCH_AUXILIARY_COLOR); - Config_PropManager::registerProp("Visualization", "sketch_dimension_color", "Sketch dimension color", + Config_PropManager::registerProp("Visualization", "sketch_dimension_color", + "Sketch dimension color", Config_Prop::Color, SKETCH_DIMENSION_COLOR); Config_PropManager::registerProp("Visualization", "sketch_overconstraint_color", @@ -202,7 +206,8 @@ std::shared_ptr SketchPlugin_Plugin std::shared_ptr aData = aSketchFeature->data(); if (aData) { std::shared_ptr aNormal = - std::dynamic_pointer_cast(aData->attribute(SketchPlugin_Sketch::NORM_ID())); + std::dynamic_pointer_cast( + aData->attribute(SketchPlugin_Sketch::NORM_ID())); // it is important to check whether the normal attribute is initialized // because it is possible that normal values are filled when the plane is checked on validity aHasSketchPlane = aNormal && aNormal->isInitialized() && diff --git a/src/SketchPlugin/SketchPlugin_Projection.cpp b/src/SketchPlugin/SketchPlugin_Projection.cpp index ac8b56797..795cfe4fb 100644 --- a/src/SketchPlugin/SketchPlugin_Projection.cpp +++ b/src/SketchPlugin/SketchPlugin_Projection.cpp @@ -94,7 +94,8 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) std::shared_ptr anEdge; if (aExtFeature && aExtFeature->value() && aExtFeature->value()->isEdge()) { anEdge = std::shared_ptr(new GeomAPI_Edge(aExtFeature->value())); - } else if (aExtFeature->context() && aExtFeature->context()->shape() && aExtFeature->context()->shape()->isEdge()) { + } else if (aExtFeature->context() && aExtFeature->context()->shape() && + aExtFeature->context()->shape()->isEdge()) { anEdge = std::shared_ptr(new GeomAPI_Edge(aExtFeature->context()->shape())); } if (!anEdge.get()) @@ -161,7 +162,8 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) aProjection = sketch()->addFeature(SketchPlugin_Circle::ID()); // update attributes of projection - std::shared_ptr aCenterPnt = std::dynamic_pointer_cast( + std::shared_ptr aCenterPnt = + std::dynamic_pointer_cast( aProjection->attribute(SketchPlugin_Circle::CENTER_ID())); aCenterPnt->setValue(aCenterInSketch); aProjection->real(SketchPlugin_Circle::RADIUS_ID())->setValue(aRadius); @@ -180,11 +182,14 @@ void SketchPlugin_Projection::computeProjection(const std::string& theID) aProjection = sketch()->addFeature(SketchPlugin_Arc::ID()); // update attributes of projection - std::shared_ptr aCenterPnt = std::dynamic_pointer_cast( + std::shared_ptr aCenterPnt = + std::dynamic_pointer_cast( aProjection->attribute(SketchPlugin_Arc::CENTER_ID())); - std::shared_ptr aStartPnt = std::dynamic_pointer_cast( + std::shared_ptr aStartPnt = + std::dynamic_pointer_cast( aProjection->attribute(SketchPlugin_Arc::START_ID())); - std::shared_ptr aEndPnt = std::dynamic_pointer_cast( + std::shared_ptr aEndPnt = + std::dynamic_pointer_cast( aProjection->attribute(SketchPlugin_Arc::END_ID())); aStartPnt->setValue(aFirstInSketch); aEndPnt->setValue(aLastInSketch); diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 3ce9adaa5..83f974248 100755 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -52,7 +52,8 @@ void SketchPlugin_Sketch::initAttributes() data()->addAttribute(SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir::typeId()); data()->addAttribute(SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList::typeId()); // the selected face, base for the sketcher plane, not obligatory - data()->addAttribute(SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(SketchPlugin_SketchEntity::EXTERNAL_ID(), + ModelAPI_AttributeSelection::typeId()); ModelAPI_Session::get()->validators()->registerNotObligatory( getKind(), SketchPlugin_SketchEntity::EXTERNAL_ID()); data()->addAttribute(SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString::typeId()); @@ -148,7 +149,8 @@ void SketchPlugin_Sketch::removeFeature(std::shared_ptr theFea if (!data()->isValid()) // sketch is already removed (case on undo of sketch), sync is not needed return; AttributeRefListPtr aList = reflist(SketchPlugin_Sketch::FEATURES_ID()); - // if the object is last, remove it from the list (needed to skip empty transaction on edit of sketch feature) + // if the object is last, remove it from the list + // (needed to skip empty transaction on edit of sketch feature) if (aList->object(aList->size(true) - 1, true) == theFeature) { aList->remove(theFeature); } else { @@ -229,7 +231,8 @@ void SketchPlugin_Sketch::attributeChanged(const std::string& theID) { aCoords = aCoords->multiplied(-aD * aCoords->distance(aZero)); std::shared_ptr anOrigPnt(new GeomAPI_Pnt(aCoords)); // X axis is preferable to be dirX on the sketch - static const double tol = 0.1; // here can not be very small value to avoid very close to X normal axis (issue 595) + // here can not be very small value to avoid very close to X normal axis (issue 595) + static const double tol = 0.1; bool isX = fabs(anA) - 1.0 < tol && fabs(aB) < tol && fabs(aC) < tol; std::shared_ptr aTempDir( isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0)); diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h index a67069fe8..1c4e9b5d2 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.h +++ b/src/SketchPlugin/SketchPlugin_Sketch.h @@ -28,7 +28,7 @@ * \ingroup Plugins * \brief Feature for creation of the new part in PartSet. */ -class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICustomPrs//, public GeomAPI_IPresentable +class SketchPlugin_Sketch : public ModelAPI_CompositeFeature, public GeomAPI_ICustomPrs { public: /// Sketch feature kind diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.cpp b/src/SketchPlugin/SketchPlugin_SketchEntity.cpp index 6b5beb942..1a37de2cf 100644 --- a/src/SketchPlugin/SketchPlugin_SketchEntity.cpp +++ b/src/SketchPlugin/SketchPlugin_SketchEntity.cpp @@ -16,7 +16,9 @@ void SketchPlugin_SketchEntity::initAttributes() initDerivedClassAttributes(); - AttributePtr anAttr = data()->addAttribute(SketchPlugin_SketchEntity::COPY_ID(), ModelAPI_AttributeBoolean::typeId()); + AttributePtr anAttr = data()->addAttribute(SketchPlugin_SketchEntity::COPY_ID(), + ModelAPI_AttributeBoolean::typeId()); anAttr->setIsArgument(false); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), SketchPlugin_SketchEntity::COPY_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), + SketchPlugin_SketchEntity::COPY_ID()); } diff --git a/src/SketchPlugin/SketchPlugin_SketchEntity.h b/src/SketchPlugin/SketchPlugin_SketchEntity.h index a29b09695..6888eef83 100644 --- a/src/SketchPlugin/SketchPlugin_SketchEntity.h +++ b/src/SketchPlugin/SketchPlugin_SketchEntity.h @@ -27,7 +27,8 @@ /**\class SketchPlugin_SketchEntity * \ingroup Plugins - * \brief Sketch Entity for creation of the new feature in PartSet. This is an abstract class to give + * \brief Sketch Entity for creation of the new feature in PartSet. + * This is an abstract class to give * an interface to create the entity features such as line, circle, arc and point. */ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_ICustomPrs @@ -121,7 +122,8 @@ class SketchPlugin_SketchEntity : public SketchPlugin_Feature, public GeomAPI_IC bool isCustomized = theDefaultPrs.get() != NULL && theDefaultPrs->customisePresentation(theResult, thePrs, theDefaultPrs); int aShapeType = thePrs->getShapeType(); - // a compound is processed like the edge because the arc feature uses the compound for presentable AIS + // a compound is processed like the edge because the + // arc feature uses the compound for presentable AIS if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/ && aShapeType != 0/*compound*/) return false; diff --git a/src/SketchPlugin/SketchPlugin_Tools.cpp b/src/SketchPlugin/SketchPlugin_Tools.cpp index 82c5a3f93..9b332fc96 100644 --- a/src/SketchPlugin/SketchPlugin_Tools.cpp +++ b/src/SketchPlugin/SketchPlugin_Tools.cpp @@ -64,7 +64,7 @@ void clearExpressions(FeaturePtr theFeature) std::shared_ptr getCoincidencePoint(const FeaturePtr theStartCoin) { std::shared_ptr aPnt = SketcherPrs_Tools::getPoint(theStartCoin.get(), - SketchPlugin_Constraint::ENTITY_A()); + SketchPlugin_Constraint::ENTITY_A()); if (aPnt.get() == NULL) aPnt = SketcherPrs_Tools::getPoint(theStartCoin.get(), SketchPlugin_Constraint::ENTITY_B()); return aPnt; diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 729424d96..dc46d01c4 100755 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -73,7 +73,8 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const AttributePtr& theAttribut ObjectPtr anObject = aRefAttr->object(); const ModelAPI_AttributeValidator* aShapeValidator = - dynamic_cast(aFactory->validator("GeomValidators_ShapeType")); + dynamic_cast( + aFactory->validator("GeomValidators_ShapeType")); std::list anArguments; anArguments.push_back("circle"); Events_InfoMessage aCircleError; @@ -173,8 +174,10 @@ bool SketchPlugin_TangentAttrValidator::isValid(const AttributePtr& theAttribute SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - FeaturePtr anAttributeFeature = std::dynamic_pointer_cast(theAttribute->owner()); - AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(theAttribute); + FeaturePtr anAttributeFeature = + std::dynamic_pointer_cast(theAttribute->owner()); + AttributeRefAttrPtr aRefAttr = + std::dynamic_pointer_cast(theAttribute); bool isObject = aRefAttr->isObject(); ObjectPtr anObject = aRefAttr->object(); @@ -390,7 +393,8 @@ bool SketchPlugin_CoincidenceAttrValidator::isValid(const AttributePtr& theAttri return false; } - AttributeRefAttrPtr aRefAttrB = std::dynamic_pointer_cast(theAttribute); + AttributeRefAttrPtr aRefAttrB = + std::dynamic_pointer_cast(theAttribute); // first attribute is a point, it may coincide with any object if (!aRefAttrA->isObject()) @@ -473,9 +477,10 @@ bool SketchPlugin_CopyValidator::isValid(const AttributePtr& theAttribute, return true; } -bool SketchPlugin_SolverErrorValidator::isValid(const std::shared_ptr& theFeature, - const std::list& theArguments, - Events_InfoMessage& theError) const +bool SketchPlugin_SolverErrorValidator::isValid( + const std::shared_ptr& theFeature, + const std::list& theArguments, + Events_InfoMessage& theError) const { AttributeStringPtr aAttributeString = theFeature->string(SketchPlugin_Sketch::SOLVER_ERROR()); @@ -487,14 +492,17 @@ bool SketchPlugin_SolverErrorValidator::isValid(const std::shared_ptr& theRefsList, const FeaturePtr theFeature) +static bool hasSameTangentFeature(const std::set& theRefsList, + const FeaturePtr theFeature) { - for(std::set::const_iterator anIt = theRefsList.cbegin(); anIt != theRefsList.cend(); ++anIt) { + for(std::set::const_iterator + anIt = theRefsList.cbegin(); anIt != theRefsList.cend(); ++anIt) { std::shared_ptr aAttr = (*anIt); FeaturePtr aFeature = std::dynamic_pointer_cast(aAttr->owner()); if (aFeature->getKind() == SketchPlugin_ConstraintTangent::ID()) { @@ -535,16 +543,20 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut const std::list& theArguments, Events_InfoMessage& theError) const { - std::shared_ptr aFilletFeature = std::dynamic_pointer_cast(theAttribute->owner()); - AttributeRefAttrListPtr aPointsRefList = std::dynamic_pointer_cast(theAttribute); + std::shared_ptr aFilletFeature = + std::dynamic_pointer_cast(theAttribute->owner()); + AttributeRefAttrListPtr aPointsRefList = + std::dynamic_pointer_cast(theAttribute); if(aPointsRefList->size() == 0) { theError = "Error: List of points is empty."; return false; } - std::map aPointsFeaturesMap = aFilletFeature->pointsFeaturesMap(); + std::map aPointsFeaturesMap = + aFilletFeature->pointsFeaturesMap(); std::set aSetOfPointsOnResultEdges; - for(std::map::iterator aPointsIter = aPointsFeaturesMap.begin(); + for(std::map::iterator + aPointsIter = aPointsFeaturesMap.begin(); aPointsIter != aPointsFeaturesMap.end(); ++aPointsIter) { const SketchPlugin_ConstraintFillet::FilletFeatures& aFeatures = aPointsIter->second; @@ -564,12 +576,14 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut } std::list> aPointsList = aPointsRefList->list(); - for(std::list>::const_iterator aPointsIt = aPointsList.cbegin(); aPointsIt != aPointsList.cend(); aPointsIt++) { + for(std::list>::const_iterator + aPointsIt = aPointsList.cbegin(); aPointsIt != aPointsList.cend(); aPointsIt++) { ObjectPtr anObject = (*aPointsIt).first; AttributePtr aPointAttribute = (*aPointsIt).second; if (!aPointAttribute.get()) return false; - std::shared_ptr aSelectedPnt = std::dynamic_pointer_cast(aPointAttribute)->pnt(); + std::shared_ptr aSelectedPnt = + std::dynamic_pointer_cast(aPointAttribute)->pnt(); // If we alredy have some result then: // - if it is the same point all ok, just skip it @@ -588,7 +602,8 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut // Obtain constraint coincidence for the fillet point. const std::set& aRefsList = aPointAttribute->owner()->data()->refsToMe(); FeaturePtr aConstraintCoincidence; - for(std::set::const_iterator anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) { + for(std::set::const_iterator anIt = aRefsList.cbegin(); + anIt != aRefsList.cend(); ++anIt) { std::shared_ptr aAttr = (*anIt); FeaturePtr aConstrFeature = std::dynamic_pointer_cast(aAttr->owner()); if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) { @@ -629,14 +644,16 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut // Remove points from set of coincides. std::set aNewSetOfCoincides; - for(std::set::iterator anIt = aCoinsides.begin(); anIt != aCoinsides.end(); ++anIt) { + for(std::set::iterator anIt = aCoinsides.begin(); + anIt != aCoinsides.end(); ++anIt) { if((*anIt)->getKind() != SketchPlugin_Line::ID() && (*anIt)->getKind() != SketchPlugin_Arc::ID()) { continue; } if((*anIt)->getKind() == SketchPlugin_Arc::ID()) { AttributePtr anArcCenter = (*anIt)->attribute(SketchPlugin_Arc::CENTER_ID()); - std::shared_ptr anArcCenterPnt = std::dynamic_pointer_cast(anArcCenter)->pnt(); + std::shared_ptr anArcCenterPnt = + std::dynamic_pointer_cast(anArcCenter)->pnt(); double aDistSelectedArcCenter = aSelectedPnt->distance(anArcCenterPnt); if(aDistSelectedArcCenter < tolerance) { continue; @@ -649,7 +666,8 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut // If we still have more than two coincides remove auxilary entities from set of coincides. if(aCoinsides.size() > 2) { aNewSetOfCoincides.clear(); - for(std::set::iterator anIt = aCoinsides.begin(); anIt != aCoinsides.end(); ++anIt) { + for(std::set::iterator anIt = aCoinsides.begin(); + anIt != aCoinsides.end(); ++anIt) { if(!(*anIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) { aNewSetOfCoincides.insert(*anIt); } @@ -673,7 +691,8 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut } std::list aFirstResults = aFirstFeature->results(); - for(std::list::iterator aResIt = aFirstResults.begin(); aResIt != aFirstResults.end(); ++aResIt) { + for(std::list::iterator aResIt = aFirstResults.begin(); + aResIt != aFirstResults.end(); ++aResIt) { ResultPtr aRes = *aResIt; const std::set& aResRefsList = aRes->data()->refsToMe(); if(hasSameTangentFeature(aResRefsList, aSecondFeature)) { @@ -683,17 +702,29 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut } // Check that lines not collinear - if(aFirstFeature->getKind() == SketchPlugin_Line::ID() && aSecondFeature->getKind() == SketchPlugin_Line::ID()) { + if(aFirstFeature->getKind() == SketchPlugin_Line::ID() && + aSecondFeature->getKind() == SketchPlugin_Line::ID()) { std::string aStartAttr = SketchPlugin_Line::START_ID(); std::string anEndAttr = SketchPlugin_Line::END_ID(); std::shared_ptr aFirstStartPnt, aFirstEndPnt, aSecondStartPnt, aSecondEndPnt; - aFirstStartPnt = std::dynamic_pointer_cast(aFirstFeature->attribute(aStartAttr))->pnt(); - aFirstEndPnt = std::dynamic_pointer_cast(aFirstFeature->attribute(anEndAttr))->pnt(); - aSecondStartPnt = std::dynamic_pointer_cast(aSecondFeature->attribute(aStartAttr))->pnt(); - aSecondEndPnt = std::dynamic_pointer_cast(aSecondFeature->attribute(anEndAttr))->pnt(); - double aCheck1 = fabs((aFirstEndPnt->x() - aFirstStartPnt->x()) * (aSecondStartPnt->y() - aFirstStartPnt->y()) - + aFirstStartPnt = + std::dynamic_pointer_cast( + aFirstFeature->attribute(aStartAttr))->pnt(); + aFirstEndPnt = + std::dynamic_pointer_cast(aFirstFeature->attribute(anEndAttr))->pnt(); + aSecondStartPnt = + std::dynamic_pointer_cast( + aSecondFeature->attribute(aStartAttr))->pnt(); + aSecondEndPnt = + std::dynamic_pointer_cast( + aSecondFeature->attribute(anEndAttr))->pnt(); + double aCheck1 = + fabs((aFirstEndPnt->x() - aFirstStartPnt->x()) * + (aSecondStartPnt->y() - aFirstStartPnt->y()) - (aSecondStartPnt->x() - aFirstStartPnt->x()) * (aFirstEndPnt->y() - aFirstStartPnt->y())); - double aCheck2 = fabs((aFirstEndPnt->x() - aFirstStartPnt->x()) * (aSecondEndPnt->y() - aFirstStartPnt->y()) - + double aCheck2 = + fabs((aFirstEndPnt->x() - aFirstStartPnt->x()) * + (aSecondEndPnt->y() - aFirstStartPnt->y()) - (aSecondEndPnt->x() - aFirstStartPnt->x()) * (aFirstEndPnt->y() - aFirstStartPnt->y())); if(aCheck1 < 1.e-7 && aCheck2 < 1.e-7) { return false; @@ -719,7 +750,8 @@ bool SketchPlugin_MiddlePointAttrValidator::isValid(const AttributePtr& theAttri SessionPtr aMgr = ModelAPI_Session::get(); ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); - FeaturePtr anAttributeFeature = std::dynamic_pointer_cast(theAttribute->owner()); + FeaturePtr anAttributeFeature = + std::dynamic_pointer_cast(theAttribute->owner()); AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(theAttribute); AttributeRefAttrPtr anOtherAttr = anAttributeFeature->data()->refattr(aParamA); @@ -820,11 +852,12 @@ bool SketchPlugin_IntersectionValidator::isValid(const AttributePtr& theAttribut return false; } AttributeSelectionPtr aLineAttr = - std::dynamic_pointer_cast(theAttribute); + std::dynamic_pointer_cast(theAttribute); std::shared_ptr anEdge; if(aLineAttr && aLineAttr->value() && aLineAttr->value()->isEdge()) { anEdge = std::shared_ptr(new GeomAPI_Edge(aLineAttr->value())); - } else if(aLineAttr->context() && aLineAttr->context()->shape() && aLineAttr->context()->shape()->isEdge()) { + } else if(aLineAttr->context() && + aLineAttr->context()->shape() && aLineAttr->context()->shape()->isEdge()) { anEdge = std::shared_ptr(new GeomAPI_Edge(aLineAttr->context()->shape())); } @@ -889,8 +922,9 @@ bool SketchPlugin_SplitValidator::isValid(const AttributePtr& theAttribute, // coincidences to the feature std::set > aRefAttributes; - ModelGeomAlgo_Point2D::getPointsOfReference(anAttrFeature, SketchPlugin_ConstraintCoincidence::ID(), - aRefAttributes, SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID()); + ModelGeomAlgo_Point2D::getPointsOfReference(anAttrFeature, + SketchPlugin_ConstraintCoincidence::ID(), + aRefAttributes, SketchPlugin_Point::ID(), SketchPlugin_Point::COORD_ID()); GeomShapePtr anAttrShape = *anEdgeShapes.begin(); std::shared_ptr aSFeature = @@ -907,7 +941,8 @@ bool SketchPlugin_SplitValidator::isValid(const AttributePtr& theAttribute, std::shared_ptr aDirY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir()))); std::list > aPoints; - std::map, std::shared_ptr > aPointToAttributes; + std::map, std::shared_ptr > + aPointToAttributes; ModelGeomAlgo_Point2D::getPointsInsideShape(anAttrShape, aRefAttributes, aC->pnt(), aX->dir(), aDirY, aPoints, aPointToAttributes); -- 2.30.2