std::shared_ptr<GeomAPI_Shape> 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) {
bool aHasPlane = aNDir && !(aNDir->x() == 0 && aNDir->y() == 0 && aNDir->z() == 0);
if (aHasPlane) {
std::shared_ptr<GeomAPI_Dir> aNormal = aNDir->dir();
- std::shared_ptr<GeomAPI_Pnt> aStartPoint(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
+ std::shared_ptr<GeomAPI_Pnt>
+ aStartPoint(aSketch->to3D(aStartAttr->x(), aStartAttr->y()));
std::shared_ptr<GeomAPI_Pnt> aEndPoint = aStartPoint;
if (aTypeAttr && aTypeAttr->isInitialized() &&
aTypeAttr->value() == ARC_TYPE_THREE_POINTS()) {
aEndAttr->pnt()->distance(aStartAttr->pnt()) > tolerance) {
aEndPoint = aSketch->to3D(aEndAttr->x(), aEndAttr->y());
std::shared_ptr<GeomDataAPI_Point2D> aPassedAttr =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(PASSED_POINT_ID()));
- if (!aPassedAttr->isInitialized()) { // calculate the appropriate center for the presentation
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ 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<GeomAPI_Circ2d> aCircleForArc(new GeomAPI_Circ2d(
aCenterAttr->pnt(), aStartAttr->pnt()));
- std::shared_ptr<GeomAPI_Pnt2d> aProjection = aCircleForArc->project(aEndAttr->pnt());
+ std::shared_ptr<GeomAPI_Pnt2d> aProjection =
+ aCircleForArc->project(aEndAttr->pnt());
if (!aProjection.get() || aEndAttr->pnt()->distance(aProjection) > tolerance) {
std::shared_ptr<GeomAPI_XY> aDir =
aEndAttr->pnt()->xy()->decreased(aStartAttr->pnt()->xy())->multiplied(0.5);
}
}
// make a visible point
- std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::vertex(aCenter);
+ std::shared_ptr<GeomAPI_Shape> aCenterPointShape =
+ GeomAlgoAPI_PointBuilder::vertex(aCenter);
aShapes.push_back(aCenterPointShape);
}
if (!aShapes.empty()) {
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;
}
std::dynamic_pointer_cast<ModelAPI_AttributeString>(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<ModelAPI_AttributeRefAttr>(
data()->attribute(TANGENT_POINT_ID()));
std::shared_ptr<GeomAPI_Pnt2d> 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<GeomAPI_Lin2d> anOrthoLine(new GeomAPI_Lin2d(aTangPnt2d, anOrthoDir));
std::shared_ptr<GeomAPI_Lin2d> aMiddleLine(new GeomAPI_Lin2d(aMidPnt, aMidDir));
std::shared_ptr<GeomAPI_Pnt2d> aCenter = anOrthoLine->intersect(aMiddleLine);
}
}
// 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<GeomDataAPI_Point2D> aPassedAttr =
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<GeomDataAPI_Point2D> aPassedAttr =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(data()->attribute(PASSED_POINT_ID()));
double aPassedParam;
}
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<GeomAPI_Pnt2d> aStart = aStartAttr->pnt();
double aRadius = aRadiusAttr->value();
data()->blockSendAttributeUpdated(true);
- std::shared_ptr<GeomAPI_Dir2d> aStartDir(new GeomAPI_Dir2d(aStart->xy()->decreased(aCenter->xy())));
- std::shared_ptr<GeomAPI_XY> aNewStart = aStartDir->xy()->multiplied(aRadius)->added(aCenter->xy());
+ std::shared_ptr<GeomAPI_Dir2d>
+ aStartDir(new GeomAPI_Dir2d(aStart->xy()->decreased(aCenter->xy())));
+ std::shared_ptr<GeomAPI_XY>
+ aNewStart = aStartDir->xy()->multiplied(aRadius)->added(aCenter->xy());
aStartAttr->setValue(aNewStart->x(), aNewStart->y());
- std::shared_ptr<GeomAPI_Dir2d> anEndDir(new GeomAPI_Dir2d(anEnd->xy()->decreased(aCenter->xy())));
- std::shared_ptr<GeomAPI_XY> aNewEnd = anEndDir->xy()->multiplied(aRadius)->added(aCenter->xy());
+ std::shared_ptr<GeomAPI_Dir2d>
+ anEndDir(new GeomAPI_Dir2d(anEnd->xy()->decreased(aCenter->xy())));
+ std::shared_ptr<GeomAPI_XY>
+ aNewEnd = anEndDir->xy()->multiplied(aRadius)->added(aCenter->xy());
anEndAttr->setValue(aNewEnd->x(), aNewEnd->y());
data()->blockSendAttributeUpdated(false);
return;
void SketchPlugin_Arc::setReversed(bool isReversed)
{
- std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(attribute(INVERSED_ID()))->setValue(isReversed);
+ std::dynamic_pointer_cast<ModelAPI_AttributeBoolean>(
+ attribute(INVERSED_ID()))->setValue(isReversed);
myParamBefore = 0.0;
}
if (aCircleShape && aRadius != 0) {
std::list<std::shared_ptr<GeomAPI_Shape> > aShapes;
// make a visible point
- std::shared_ptr<GeomAPI_Shape> aCenterPointShape = GeomAlgoAPI_PointBuilder::vertex(aCenter);
+ std::shared_ptr<GeomAPI_Shape> aCenterPointShape =
+ GeomAlgoAPI_PointBuilder::vertex(aCenter);
aShapes.push_back(aCenterPointShape);
aShapes.push_back(aCircleShape);
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,
{
std::shared_ptr<ModelAPI_Data> aData = data();
- std::shared_ptr<ModelAPI_AttributeRefAttr> anAttrA = aData->refattr(SketchPlugin_Constraint::ENTITY_A());
- std::shared_ptr<ModelAPI_AttributeRefAttr> anAttrB = aData->refattr(SketchPlugin_Constraint::ENTITY_B());
+ std::shared_ptr<ModelAPI_AttributeRefAttr> anAttrA =
+ aData->refattr(SketchPlugin_Constraint::ENTITY_A());
+ std::shared_ptr<ModelAPI_AttributeRefAttr> anAttrB =
+ aData->refattr(SketchPlugin_Constraint::ENTITY_B());
if (!anAttrA->isInitialized() || !anAttrB->isInitialized())
return;
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<GeomDataAPI_Point2D> aFlyOutAttr = std::dynamic_pointer_cast<
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);
// Recalculate flyout point in local coordinates
// coordinates are calculated according to the center of shapes intersection
std::shared_ptr<GeomDataAPI_Point2D> aFlyoutAttr =
- std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ attribute(SketchPlugin_Constraint::FLYOUT_VALUE_PNT()));
std::shared_ptr<ModelAPI_Data> aData = data();
std::shared_ptr<GeomAPI_Ax3> 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<GeomAPI_Pnt2d> anInter = intersect(aLineA, aLineB);
bool isReversed1 = boolean(ANGLE_REVERSED_FIRST_LINE_ID())->value();
std::shared_ptr<GeomAPI_Lin2d> aLine2(new GeomAPI_Lin2d(aStartB->pnt(), aEndB->pnt()));
bool isReversed2 = boolean(ANGLE_REVERSED_SECOND_LINE_ID())->value();
- anAng = std::shared_ptr<GeomAPI_Angle2d>(new GeomAPI_Angle2d(aLine1, isReversed1, aLine2, isReversed2));
+ anAng = std::shared_ptr<GeomAPI_Angle2d>(
+ new GeomAPI_Angle2d(aLine1, isReversed1, aLine2, isReversed2));
}
double anAngle = anAng->angleDegree();
std::shared_ptr<ModelAPI_AttributeDouble> aValueAttr = std::dynamic_pointer_cast<
{
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;
}
if (!sketch())
return thePrevious;
- AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this, sketch()->coordinatePlane(),
+ AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
+ sketch()->coordinatePlane(),
thePrevious);
return anAIS;
}
{
std::shared_ptr<ModelAPI_AttributeDouble> 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);
} 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<GeomDataAPI_Point2D> aFlyoutAttr =
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()
aPointsIter != myNewPoints.end();
++aPointsIter) {
AttributePtr aPointAttr = *aPointsIter;
- std::shared_ptr<GeomDataAPI_Point2D> aFilletPoint2d = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aPointAttr);
+ std::shared_ptr<GeomDataAPI_Point2D> aFilletPoint2d =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aPointAttr);
if(!aFilletPoint2d.get()) {
setError("Error: One of the selected points is empty.");
return;
// Obtain base lines for fillet.
bool anIsNeedNewObjects = true;
FilletFeatures aFilletFeatures;
- std::map<AttributePtr, FilletFeatures>::iterator aPrevPointsIter = myPointFeaturesMap.find(aPointAttr);
+ std::map<AttributePtr, FilletFeatures>::iterator aPrevPointsIter =
+ myPointFeaturesMap.find(aPointAttr);
if(aPrevPointsIter != myPointFeaturesMap.end()) {
anIsNeedNewObjects = false;
aFilletFeatures = aPrevPointsIter->second;
// Obtain constraint coincidence for the fillet point.
FeaturePtr aConstraintCoincidence;
const std::set<AttributePtr>& aRefsList = aFilletPoint2d->owner()->data()->refsToMe();
- for(std::set<AttributePtr>::const_iterator anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) {
+ for(std::set<AttributePtr>::const_iterator
+ anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) {
std::shared_ptr<ModelAPI_Attribute> anAttr = (*anIt);
FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->owner());
if(aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
aBaseEdgeA = *aLinesIt++;
aBaseEdgeB = *aLinesIt;
- std::pair<FeaturePtr, bool> aBasePairA = std::make_pair(aBaseEdgeA, aBaseEdgeA->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value());
- std::pair<FeaturePtr, bool> aBasePairB = std::make_pair(aBaseEdgeB, aBaseEdgeB->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value());
+ std::pair<FeaturePtr, bool> aBasePairA =
+ std::make_pair(aBaseEdgeA,
+ aBaseEdgeA->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value());
+ std::pair<FeaturePtr, bool> aBasePairB =
+ std::make_pair(aBaseEdgeB,
+ aBaseEdgeB->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value());
aFilletFeatures.baseEdgesState.push_back(aBasePairA);
aFilletFeatures.baseEdgesState.push_back(aBasePairB);
}
static const int aNbFeatures = 2;
FeaturePtr aBaseFeatures[aNbFeatures] = {aBaseEdgeA, aBaseEdgeB};
FeaturePtr aResultFeatures[aNbFeatures] = {aResultEdgeA, aResultEdgeB};
- std::shared_ptr<GeomAPI_Dir2d> aTangentDir[aNbFeatures]; // tangent directions of the features in coincident point
+ // tangent directions of the features in coincident point
+ std::shared_ptr<GeomAPI_Dir2d> aTangentDir[aNbFeatures];
bool isStart[aNbFeatures]; // indicates which point the features share
- std::shared_ptr<GeomAPI_Pnt2d> 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<GeomAPI_Pnt2d> aStartEndPnt[aNbFeatures * 2];
std::string aFeatAttributes[aNbFeatures * 2]; // attributes of features
for (int i = 0; i < aNbFeatures; i++) {
std::string aStartAttr, aEndAttr;
if (!isStart[i])
aDir = aDir->multiplied(-1.0);
} else if (aResultFeatures[i]->getKind() == SketchPlugin_Arc::ID()) {
- std::shared_ptr<GeomAPI_Pnt2d> aCenterPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ std::shared_ptr<GeomAPI_Pnt2d> aCenterPoint =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
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());
double y = aDir->y();
aDir->setX(-y);
aDir->setY(x);
- if (isStart[i] == std::dynamic_pointer_cast<SketchPlugin_Arc>(aBaseFeatures[i])->isReversed())
+ if (isStart[i] ==
+ std::dynamic_pointer_cast<SketchPlugin_Arc>(aBaseFeatures[i])->isReversed())
aDir = aDir->multiplied(-1.0);
}
aTangentDir[i] = std::shared_ptr<GeomAPI_Dir2d>(new GeomAPI_Dir2d(aDir));
// 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<GeomAPI_XY> 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<GeomDataAPI_Point2D>(
- 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<GeomDataAPI_Point2D>(
- 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<GeomDataAPI_Point2D>(
aTangentPntA = aTangentPntB;
aTangentPntB = aTmp;
}
- std::shared_ptr<GeomDataAPI_Point2D> aStartPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ std::shared_ptr<GeomDataAPI_Point2D> aStartPoint =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aResultArc->attribute(SketchPlugin_Arc::START_ID()));
std::shared_ptr<GeomDataAPI_Point2D> aEndPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aResultArc->attribute(SketchPlugin_Arc::END_ID()));
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);
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);
aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
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);
myNewPoints.clear();
// Get list of points for fillets and current radius.
- AttributeRefAttrListPtr aRefListOfFilletPoints = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(
+ AttributeRefAttrListPtr aRefListOfFilletPoints =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(
data()->attribute(SketchPlugin_Constraint::ENTITY_A()));
AttributeDoublePtr aRadiusAttribute = real(VALUE());
int aListSize = aRefListOfFilletPoints->size();
// Iterate over points to get base lines an calculate radius for fillets.
double aMinimumRadius = 0;
- std::list<std::pair<ObjectPtr, AttributePtr>> aSelectedPointsList = aRefListOfFilletPoints->list();
+ std::list<std::pair<ObjectPtr, AttributePtr>>
+ aSelectedPointsList = aRefListOfFilletPoints->list();
std::list<std::pair<ObjectPtr, AttributePtr>>::iterator anIter = aSelectedPointsList.begin();
std::set<AttributePtr> aPointsToSkeep;
for(int anIndex = 0; anIndex < aListSize; anIndex++, anIter++) {
// Obtain constraint coincidence for the fillet point.
FeaturePtr aConstraintCoincidence;
const std::set<AttributePtr>& aRefsList = aFilletPointAttr->owner()->data()->refsToMe();
- for(std::set<AttributePtr>::const_iterator anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) {
+ for(std::set<AttributePtr>::const_iterator
+ anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) {
std::shared_ptr<ModelAPI_Attribute> anAttr = (*anIt);
FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(anAttr->owner());
if(aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
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<GeomAPI_Pnt2d> aFilletPnt2d = aFilletPoint2D->pnt();
std::set<FeaturePtr> aNewSetOfCoincides;
- for(std::set<FeaturePtr>::iterator anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) {
+ for(std::set<FeaturePtr>::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());
// If we still have more than two coincides remove auxilary entities from set of coincides.
if(aCoincides.size() > 2) {
aNewSetOfCoincides.clear();
- for(std::set<FeaturePtr>::iterator anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) {
+ for(std::set<FeaturePtr>::iterator
+ anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) {
if(!(*anIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) {
aNewSetOfCoincides.insert(*anIt);
}
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;
}
}
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;
}
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<GeomAPI_XY> aPoint1(new GeomAPI_XY(x1, y1));
theCenters.push_back(aPoint1);
// get and filter possible centers
std::list< std::shared_ptr<GeomAPI_XY> > 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<GeomAPI_XY> >::iterator anIt = aSuspectCenters.begin();
for (; anIt != aSuspectCenters.end(); anIt++) {
// get possible centers and filter them
std::list< std::shared_ptr<GeomAPI_XY> > 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());
// get and filter possible centers
std::list< std::shared_ptr<GeomAPI_XY> > 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<GeomAPI_XY> aLineTgPoint, anArcTgPoint;
std::list< std::shared_ptr<GeomAPI_XY> >::iterator anIt = aSuspectCenters.begin();
aPntEnd = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
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<GeomAPI_Pnt2d> aPntTemp;
std::shared_ptr<GeomAPI_Pnt2d> aPntStart = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
{
std::set<FeaturePtr> aCoincides;
- std::shared_ptr<GeomAPI_Pnt2d> aFilletPnt = SketchPlugin_Tools::getCoincidencePoint(theConstraintCoincidence);
+ std::shared_ptr<GeomAPI_Pnt2d> aFilletPnt =
+ SketchPlugin_Tools::getCoincidencePoint(theConstraintCoincidence);
SketchPlugin_Tools::findCoincidences(theConstraintCoincidence,
SketchPlugin_ConstraintCoincidence::ENTITY_A(),
// If we still have more than two coincides remove auxilary entities from set of coincides.
if(aCoincides.size() > 2) {
aNewSetOfCoincides.clear();
- for(std::set<FeaturePtr>::iterator anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) {
+ for(std::set<FeaturePtr>::iterator
+ anIt = aCoincides.begin(); anIt != aCoincides.end(); ++anIt) {
if(!(*anIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) {
aNewSetOfCoincides.insert(*anIt);
}
/** \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()
public:
/// \struct Struct to store base edges with states, result edges and constraints.
struct FilletFeatures {
- std::list<std::pair<FeaturePtr, bool>> baseEdgesState; ///< list of objects the fillet is based and its states
- std::list<FeaturePtr> resultEdges; ///< list of result edges
- std::list<FeaturePtr> resultConstraints; ///< list of constraints provided by the fillet
+ /// list of objects the fillet is based and its states
+ std::list<std::pair<FeaturePtr, bool>> baseEdgesState;
+ std::list<FeaturePtr> resultEdges; ///< list of result edges
+ std::list<FeaturePtr> resultConstraints; ///< list of constraints provided by the fillet
};
/// Fillet constraint kind
private:
std::set<AttributePtr> myNewPoints; ///< set of new points
- std::map<AttributePtr, FilletFeatures> myPointFeaturesMap; ///< map of point and features for fillet
+
+ /// map of point and features for fillet
+ std::map<AttributePtr, FilletFeatures> 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
// 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());
}
if (!sketch())
return thePrevious;
- AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this, sketch()->coordinatePlane(),
- thePrevious);
+ AISObjectPtr anAIS = SketcherPrs_Factory::lengthDimensionConstraint(this,
+ sketch()->coordinatePlane(), thePrevious);
return anAIS;
}
{
std::shared_ptr<ModelAPI_AttributeDouble> 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);
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()
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);
static Events_ID aRedispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
std::list<ObjectPtr> aTargetList = aRefListOfMirrored->list();
- for(std::list<ObjectPtr>::const_iterator aTargetIt = aTargetList.cbegin(); aTargetIt != aTargetList.cend(); aTargetIt++) {
+ for(std::list<ObjectPtr>::const_iterator aTargetIt =
+ aTargetList.cbegin(); aTargetIt != aTargetList.cend(); aTargetIt++) {
if((*aTargetIt).get()) {
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(*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);
{
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()
if (!sketch())
return thePrevious;
- AISObjectPtr anAIS = SketcherPrs_Factory::perpendicularConstraint(this, sketch()->coordinatePlane(),
- thePrevious);
+ AISObjectPtr anAIS = SketcherPrs_Factory::perpendicularConstraint(this,
+ sketch()->coordinatePlane(), thePrevious);
return anAIS;
}
// 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<GeomDataAPI_Point2D> aFlyoutAttr = std::dynamic_pointer_cast<
GeomDataAPI_Point2D>(data()->attribute(theAttributeId));
// Prepare a circle
if (aCyrcFeature->getKind() == SketchPlugin_Circle::ID()) { // circle
- std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ std::shared_ptr<GeomDataAPI_Point2D> aCenterAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aCyrcFeature->data()->attribute(SketchPlugin_Circle::CENTER_ID()));
double aShift = aRadius * 1.1;
std::shared_ptr<GeomAPI_Pnt2d> aPnt = aCenterAttr->pnt();
if (theID == SketchPlugin_Constraint::ENTITY_A()) {
std::shared_ptr<ModelAPI_AttributeDouble> 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<ModelAPI_Feature> aCyrcFeature;
double aRadius = circleRadius(aCyrcFeature);
if (aRadius > 0) { // set as value the radius of updated reference to another circle
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.");
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<FeaturePtr, IdToPointPair>::const_iterator anIt = aCoincidenceToFeature.begin(),
aLast = aCoincidenceToFeature.end();
for (int i = 1; anIt != aLast; anIt++, i++) {
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::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<AttributePtr, std::list<AttributePtr> >::const_iterator aRefIt = aBaseRefAttributes.begin(),
- aRefLast = aBaseRefAttributes.end();
- std::cout << std::endl << "References to attributes of base feature [" << aBaseRefAttributes.size() << "]" << std::endl;
+ std::map<AttributePtr, std::list<AttributePtr> >::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<AttributePtr> aRefAttributes = aRefIt->second;
FeaturePtr aRFeature = ModelAPI_Feature::feature(aRAttr->owner());
aRefsInfo.append("(" + aRFeature->name() + ") ");
}
- std::shared_ptr<GeomDataAPI_Point2D> aPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aBaseAttr);
- std::cout << aPointAttr->id().c_str() << ": " << "[" << aRefAttributes.size() << "] " << aRefsInfo << std::endl;
+ std::shared_ptr<GeomDataAPI_Point2D> aPointAttr =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(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<AttributePtr>::const_iterator aRefAttrIt = aRefsToFeature.begin(),
aRefAttrLast = aRefsToFeature.end();
std::string aRefsInfo;
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
}
std::cout << "Modifed attributes (constraints to attributes are moved here):" << std::endl;
- std::set<std::pair<AttributePtr, AttributePtr> >::const_iterator aPIt = aModifiedAttributes.begin(),
- aPLast = aModifiedAttributes.end();
+ std::set<std::pair<AttributePtr, AttributePtr> >::const_iterator
+ aPIt = aModifiedAttributes.begin(), aPLast = aModifiedAttributes.end();
std::string aResInfo;
for (; aPIt != aPLast; aPIt++) {
if (!aResInfo.empty())
aPoints.push_back(aStartPoint);
std::shared_ptr<GeomAPI_Pnt2d> aSecondPnt2d = aSecondPointAttrOfSplit->pnt();
- std::shared_ptr<GeomAPI_Pnt> aSecondPoint = sketch()->to3D(aSecondPnt2d->x(), aSecondPnt2d->y());
+ std::shared_ptr<GeomAPI_Pnt> aSecondPoint =
+ sketch()->to3D(aSecondPnt2d->x(), aSecondPnt2d->y());
aPoints.push_back(aSecondPoint);
std::set<std::shared_ptr<GeomAPI_Shape> > aSplitShapes;
GeomAlgoAPI_ShapeTools::splitShape(aBaseShape, aPoints, aSplitShapes);
- std::shared_ptr<GeomAPI_Shape> aShape = GeomAlgoAPI_ShapeTools::findShape(aPoints, aSplitShapes);
+ std::shared_ptr<GeomAPI_Shape> aShape =
+ GeomAlgoAPI_ShapeTools::findShape(aPoints, aSplitShapes);
AISObjectPtr anAIS = thePrevious;
if (aShape) {
}
std::shared_ptr<GeomDataAPI_Point2D> SketchPlugin_ConstraintSplit::getPointOfRefAttr(
- const AttributePtr& theAttribute)
+ const AttributePtr& theAttribute)
{
AttributePoint2DPtr aPointAttribute;
if (theAttribute->attributeType() == ModelAPI_AttributeRefAttr::typeId()) {
- AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+ AttributeRefAttrPtr aRefAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
if (aRefAttr.get() && aRefAttr->isInitialized()) {
AttributePtr anAttribute = aRefAttr->attr();
if (anAttribute.get() && anAttribute->attributeType() == GeomDataAPI_Point2D::typeId())
}
if (!aStartAttributeName.empty() && !anEndAttributeName.empty()) {
theStartPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aBaseFeature->attribute(aStartAttributeName));
+ aBaseFeature->attribute(aStartAttributeName));
theEndPointAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
- aBaseFeature->attribute(anEndAttributeName));
+ aBaseFeature->attribute(anEndAttributeName));
}
}
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));
? 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()) {
}
void SketchPlugin_ConstraintSplit::getRefAttributes(const FeaturePtr& theFeature,
- std::map<AttributePtr, std::list<AttributePtr> >& theRefs,
- std::list<AttributePtr>& theRefsToFeature)
+ std::map<AttributePtr, std::list<AttributePtr> >& theRefs,
+ std::list<AttributePtr>& theRefsToFeature)
{
theRefs.clear();
- std::list<AttributePtr> aPointAttributes = theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
+ std::list<AttributePtr> aPointAttributes =
+ theFeature->data()->attributes(GeomDataAPI_Point2D::typeId());
std::set<AttributePtr> aPointAttributesSet;
- std::list<AttributePtr>::const_iterator aPIt = aPointAttributes.begin(), aPLast = aPointAttributes.end();
+ std::list<AttributePtr>::const_iterator aPIt =
+ aPointAttributes.begin(), aPLast = aPointAttributes.end();
for (; aPIt != aPLast; aPIt++)
aPointAttributesSet.insert(*aPIt);
AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(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 {
aFeaturePointAttribute = aFCAttribute;
}
if (aFeaturePointAttribute.get()) {
- FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aFeaturePointAttribute->owner());
+ FeaturePtr aFeature =
+ std::dynamic_pointer_cast<ModelAPI_Feature>(aFeaturePointAttribute->owner());
aTangentFeature->refattr(anAttributeId)->setObject(getFeatureResult(aFeature));
}
#ifdef DEBUG_SPLIT
}
}
-void SketchPlugin_ConstraintSplit::updateRefFeatureConstraints(const ResultPtr& theFeatureBaseResult,
- const std::list<AttributePtr>& theRefsToFeature)
+void SketchPlugin_ConstraintSplit::updateRefFeatureConstraints(
+ const ResultPtr& theFeatureBaseResult,
+ const std::list<AttributePtr>& theRefsToFeature)
{
std::list<AttributePtr>::const_iterator anIt = theRefsToFeature.begin(),
aLast = theRefsToFeature.end();
}
void SketchPlugin_ConstraintSplit::updateRefAttConstraints(
- const std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
- const std::set<std::pair<AttributePtr, AttributePtr> >& theModifiedAttributes)
+ const std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
+ const std::set<std::pair<AttributePtr, AttributePtr> >& theModifiedAttributes)
{
#ifdef DEBUG_SPLIT
std::cout << "SketchPlugin_ConstraintSplit::updateRefAttConstraints" << std::endl;
#endif
- std::set<std::pair<AttributePtr, AttributePtr> >::const_iterator anIt = theModifiedAttributes.begin(),
- aLast = theModifiedAttributes.end();
+ std::set<std::pair<AttributePtr, AttributePtr> >::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<AttributePtr> aRefAttributes = theBaseRefAttributes.at(anAttribute);
std::list<AttributePtr>::const_iterator aRefIt = aRefAttributes.begin(),
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()) {
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
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()),
thePoints.insert(std::dynamic_pointer_cast<GeomDataAPI_Point2D>
(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()),
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()) {
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
// 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
// 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()),
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<SketchPlugin_Arc>(theSplitFeature)->isReversed();
theCreatedFeatures.insert(theSplitFeature);
/// base feature is a left part of the circle
- theBaseFeatureModified = createArcFeature(aBaseFeature, aFirstPointAttrOfSplit, aSecondPointAttrOfSplit);
- std::dynamic_pointer_cast<SketchPlugin_Arc>(theBaseFeatureModified)->setReversed(!aSplitReversed);
+ theBaseFeatureModified = createArcFeature(aBaseFeature,
+ aFirstPointAttrOfSplit, aSecondPointAttrOfSplit);
+ std::dynamic_pointer_cast<SketchPlugin_Arc>(
+ 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);
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);
return aConstraint;
}
-FeaturePtr SketchPlugin_ConstraintSplit::createConstraintForObjects(const std::string& theConstraintId,
+FeaturePtr SketchPlugin_ConstraintSplit::createConstraintForObjects(
+ const std::string& theConstraintId,
const ObjectPtr& theFirstObject,
const ObjectPtr& theSecondObject)
{
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<AttributePtr> anAttrs = theFeature->data()->attributes(
- ModelAPI_AttributeRefAttr::typeId());
+ ModelAPI_AttributeRefAttr::typeId());
std::list<AttributePtr>::const_iterator anIt = anAttrs.begin(), aLast = anAttrs.end();
std::string anAttributesInfo;
for(; anIt != aLast; anIt++) {
std::string aType = anAttr->attributeType();
if (aType == ModelAPI_AttributeRefAttr::typeId()) {
std::shared_ptr<ModelAPI_AttributeRefAttr> aRefAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttr);
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttr);
if (aRefAttr.get()) {
if (aRefAttr->isObject()) {
FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToPoint*/);
/// Obtains references to feature point attributes and to feature,
- /// e.g. for feature line: 1st container is <1st line point, list<entity_a in distance, entity_b in parallel> >
- /// <2nd line point, list<> >
+ /// e.g. for feature line: 1st container is
+ /// <1st line point, list<entity_a in distance, entity_b in parallel> >
+ /// <2nd line point, list<> >
/// for feature circle 2nd container is <entity_a in Radius, entity_b in equal, ...>
/// \param theFeature an investigated feature
/// \param theRefs a container of list of referenced attributes
/// \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<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature,
- const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences,
- const std::set<ResultPtr>& theFeatureResults);
+ const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theCoincidenceToFeature,
+ const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences,
+ const std::set<ResultPtr>& 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
/// \param theModifiedAttributes container of attributes placed instead of base attributes
/// at the same place
void updateRefAttConstraints(
- const std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
- const std::set<std::pair<AttributePtr, AttributePtr> >& theModifiedAttributes);
+ const std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
+ const std::set<std::pair<AttributePtr, AttributePtr> >& theModifiedAttributes);
/// Make the base object is splitted by the point attributes
/// \param theSplitFeature a result split feature
/// \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<ModelAPI_Feature>& theSplitFeature,
std::shared_ptr<ModelAPI_Feature>& theBeforeFeature,
std::shared_ptr<ModelAPI_Feature>& theAfterFeature,
bool SketchPlugin_ExternalValidator::isExternalAttribute(const AttributePtr& theAttribute) const
{
bool isExternal = false;
- AttributeRefAttrPtr anAttribute = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+ AttributeRefAttrPtr anAttribute =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
if (anAttribute.get() != NULL) {
FeaturePtr anArgumentFeature = ModelAPI_Feature::feature(anAttribute->object());
if (anArgumentFeature.get() != NULL) {
std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
- std::dynamic_pointer_cast<SketchPlugin_Feature>(anArgumentFeature);
+ std::dynamic_pointer_cast<SketchPlugin_Feature>(anArgumentFeature);
if (aSketchFeature.get() != NULL) {
isExternal = aSketchFeature->isExternal();
}
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
std::shared_ptr<GeomAPI_Edge> anEdge;
if(aLineAttr && aLineAttr->value() && aLineAttr->value()->isEdge()) {
anEdge = std::shared_ptr<GeomAPI_Edge>(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<GeomAPI_Edge>(new GeomAPI_Edge(aLineAttr->context()->shape()));
}
if(!anEdge.get())
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()
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 =
//// 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));
//// }
//// }
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);
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);
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()
if (!aStart || !aEnd)
return;
- std::shared_ptr<GeomAPI_XY> aShiftVec(new GeomAPI_XY(aEnd->x() - aStart->x(), aEnd->y() - aStart->y()));
+ std::shared_ptr<GeomAPI_XY>
+ 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);
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 =
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);
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);
// 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",
std::shared_ptr<ModelAPI_Data> aData = aSketchFeature->data();
if (aData) {
std::shared_ptr<GeomDataAPI_Dir> aNormal =
- std::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+ std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ 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() &&
std::shared_ptr<GeomAPI_Edge> anEdge;
if (aExtFeature && aExtFeature->value() && aExtFeature->value()->isEdge()) {
anEdge = std::shared_ptr<GeomAPI_Edge>(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<GeomAPI_Edge>(new GeomAPI_Edge(aExtFeature->context()->shape()));
}
if (!anEdge.get())
aProjection = sketch()->addFeature(SketchPlugin_Circle::ID());
// update attributes of projection
- std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aProjection->attribute(SketchPlugin_Circle::CENTER_ID()));
aCenterPnt->setValue(aCenterInSketch);
aProjection->real(SketchPlugin_Circle::RADIUS_ID())->setValue(aRadius);
aProjection = sketch()->addFeature(SketchPlugin_Arc::ID());
// update attributes of projection
- std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ std::shared_ptr<GeomDataAPI_Point2D> aCenterPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aProjection->attribute(SketchPlugin_Arc::CENTER_ID()));
- std::shared_ptr<GeomDataAPI_Point2D> aStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ std::shared_ptr<GeomDataAPI_Point2D> aStartPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aProjection->attribute(SketchPlugin_Arc::START_ID()));
- std::shared_ptr<GeomDataAPI_Point2D> aEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ std::shared_ptr<GeomDataAPI_Point2D> aEndPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aProjection->attribute(SketchPlugin_Arc::END_ID()));
aStartPnt->setValue(aFirstInSketch);
aEndPnt->setValue(aLastInSketch);
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());
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 {
aCoords = aCoords->multiplied(-aD * aCoords->distance(aZero));
std::shared_ptr<GeomAPI_Pnt> 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<GeomAPI_Dir> aTempDir(
isX ? new GeomAPI_Dir(0, 1, 0) : new GeomAPI_Dir(1, 0, 0));
* \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
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());
}
/**\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
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;
std::shared_ptr<GeomAPI_Pnt2d> getCoincidencePoint(const FeaturePtr theStartCoin)
{
std::shared_ptr<GeomAPI_Pnt2d> 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;
ObjectPtr anObject = aRefAttr->object();
const ModelAPI_AttributeValidator* aShapeValidator =
- dynamic_cast<const ModelAPI_AttributeValidator*>(aFactory->validator("GeomValidators_ShapeType"));
+ dynamic_cast<const ModelAPI_AttributeValidator*>(
+ aFactory->validator("GeomValidators_ShapeType"));
std::list<std::string> anArguments;
anArguments.push_back("circle");
Events_InfoMessage aCircleError;
SessionPtr aMgr = ModelAPI_Session::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
- FeaturePtr anAttributeFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
- AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+ FeaturePtr anAttributeFeature =
+ std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ AttributeRefAttrPtr aRefAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
bool isObject = aRefAttr->isObject();
ObjectPtr anObject = aRefAttr->object();
return false;
}
- AttributeRefAttrPtr aRefAttrB = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
+ AttributeRefAttrPtr aRefAttrB =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
// first attribute is a point, it may coincide with any object
if (!aRefAttrA->isObject())
return true;
}
-bool SketchPlugin_SolverErrorValidator::isValid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
- const std::list<std::string>& theArguments,
- Events_InfoMessage& theError) const
+bool SketchPlugin_SolverErrorValidator::isValid(
+ const std::shared_ptr<ModelAPI_Feature>& theFeature,
+ const std::list<std::string>& theArguments,
+ Events_InfoMessage& theError) const
{
AttributeStringPtr aAttributeString = theFeature->string(SketchPlugin_Sketch::SOLVER_ERROR());
return true;
}
-bool SketchPlugin_SolverErrorValidator::isNotObligatory(std::string theFeature, std::string theAttribute)
+bool SketchPlugin_SolverErrorValidator::isNotObligatory(std::string theFeature,
+ std::string theAttribute)
{
return true;
}
-static bool hasSameTangentFeature(const std::set<AttributePtr>& theRefsList, const FeaturePtr theFeature)
+static bool hasSameTangentFeature(const std::set<AttributePtr>& theRefsList,
+ const FeaturePtr theFeature)
{
- for(std::set<AttributePtr>::const_iterator anIt = theRefsList.cbegin(); anIt != theRefsList.cend(); ++anIt) {
+ for(std::set<AttributePtr>::const_iterator
+ anIt = theRefsList.cbegin(); anIt != theRefsList.cend(); ++anIt) {
std::shared_ptr<ModelAPI_Attribute> aAttr = (*anIt);
FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
if (aFeature->getKind() == SketchPlugin_ConstraintTangent::ID()) {
const std::list<std::string>& theArguments,
Events_InfoMessage& theError) const
{
- std::shared_ptr<SketchPlugin_ConstraintFillet> aFilletFeature = std::dynamic_pointer_cast<SketchPlugin_ConstraintFillet>(theAttribute->owner());
- AttributeRefAttrListPtr aPointsRefList = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
+ std::shared_ptr<SketchPlugin_ConstraintFillet> aFilletFeature =
+ std::dynamic_pointer_cast<SketchPlugin_ConstraintFillet>(theAttribute->owner());
+ AttributeRefAttrListPtr aPointsRefList =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefAttrList>(theAttribute);
if(aPointsRefList->size() == 0) {
theError = "Error: List of points is empty.";
return false;
}
- std::map<AttributePtr, SketchPlugin_ConstraintFillet::FilletFeatures> aPointsFeaturesMap = aFilletFeature->pointsFeaturesMap();
+ std::map<AttributePtr, SketchPlugin_ConstraintFillet::FilletFeatures> aPointsFeaturesMap =
+ aFilletFeature->pointsFeaturesMap();
std::set<AttributePtr> aSetOfPointsOnResultEdges;
- for(std::map<AttributePtr, SketchPlugin_ConstraintFillet::FilletFeatures>::iterator aPointsIter = aPointsFeaturesMap.begin();
+ for(std::map<AttributePtr, SketchPlugin_ConstraintFillet::FilletFeatures>::iterator
+ aPointsIter = aPointsFeaturesMap.begin();
aPointsIter != aPointsFeaturesMap.end();
++aPointsIter) {
const SketchPlugin_ConstraintFillet::FilletFeatures& aFeatures = aPointsIter->second;
}
std::list<std::pair<ObjectPtr, AttributePtr>> aPointsList = aPointsRefList->list();
- for(std::list<std::pair<ObjectPtr, AttributePtr>>::const_iterator aPointsIt = aPointsList.cbegin(); aPointsIt != aPointsList.cend(); aPointsIt++) {
+ for(std::list<std::pair<ObjectPtr, AttributePtr>>::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<GeomAPI_Pnt2d> aSelectedPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aPointAttribute)->pnt();
+ std::shared_ptr<GeomAPI_Pnt2d> aSelectedPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aPointAttribute)->pnt();
// If we alredy have some result then:
// - if it is the same point all ok, just skip it
// Obtain constraint coincidence for the fillet point.
const std::set<AttributePtr>& aRefsList = aPointAttribute->owner()->data()->refsToMe();
FeaturePtr aConstraintCoincidence;
- for(std::set<AttributePtr>::const_iterator anIt = aRefsList.cbegin(); anIt != aRefsList.cend(); ++anIt) {
+ for(std::set<AttributePtr>::const_iterator anIt = aRefsList.cbegin();
+ anIt != aRefsList.cend(); ++anIt) {
std::shared_ptr<ModelAPI_Attribute> aAttr = (*anIt);
FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
// Remove points from set of coincides.
std::set<FeaturePtr> aNewSetOfCoincides;
- for(std::set<FeaturePtr>::iterator anIt = aCoinsides.begin(); anIt != aCoinsides.end(); ++anIt) {
+ for(std::set<FeaturePtr>::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<GeomAPI_Pnt2d> anArcCenterPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anArcCenter)->pnt();
+ std::shared_ptr<GeomAPI_Pnt2d> anArcCenterPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anArcCenter)->pnt();
double aDistSelectedArcCenter = aSelectedPnt->distance(anArcCenterPnt);
if(aDistSelectedArcCenter < tolerance) {
continue;
// If we still have more than two coincides remove auxilary entities from set of coincides.
if(aCoinsides.size() > 2) {
aNewSetOfCoincides.clear();
- for(std::set<FeaturePtr>::iterator anIt = aCoinsides.begin(); anIt != aCoinsides.end(); ++anIt) {
+ for(std::set<FeaturePtr>::iterator anIt = aCoinsides.begin();
+ anIt != aCoinsides.end(); ++anIt) {
if(!(*anIt)->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID())->value()) {
aNewSetOfCoincides.insert(*anIt);
}
}
std::list<ResultPtr> aFirstResults = aFirstFeature->results();
- for(std::list<ResultPtr>::iterator aResIt = aFirstResults.begin(); aResIt != aFirstResults.end(); ++aResIt) {
+ for(std::list<ResultPtr>::iterator aResIt = aFirstResults.begin();
+ aResIt != aFirstResults.end(); ++aResIt) {
ResultPtr aRes = *aResIt;
const std::set<AttributePtr>& aResRefsList = aRes->data()->refsToMe();
if(hasSameTangentFeature(aResRefsList, aSecondFeature)) {
}
// 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<GeomAPI_Pnt2d> aFirstStartPnt, aFirstEndPnt, aSecondStartPnt, aSecondEndPnt;
- aFirstStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFirstFeature->attribute(aStartAttr))->pnt();
- aFirstEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFirstFeature->attribute(anEndAttr))->pnt();
- aSecondStartPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aSecondFeature->attribute(aStartAttr))->pnt();
- aSecondEndPnt = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aSecondFeature->attribute(anEndAttr))->pnt();
- double aCheck1 = fabs((aFirstEndPnt->x() - aFirstStartPnt->x()) * (aSecondStartPnt->y() - aFirstStartPnt->y()) -
+ aFirstStartPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aFirstFeature->attribute(aStartAttr))->pnt();
+ aFirstEndPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aFirstFeature->attribute(anEndAttr))->pnt();
+ aSecondStartPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aSecondFeature->attribute(aStartAttr))->pnt();
+ aSecondEndPnt =
+ std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ 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;
SessionPtr aMgr = ModelAPI_Session::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
- FeaturePtr anAttributeFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
+ FeaturePtr anAttributeFeature =
+ std::dynamic_pointer_cast<ModelAPI_Feature>(theAttribute->owner());
AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(theAttribute);
AttributeRefAttrPtr anOtherAttr = anAttributeFeature->data()->refattr(aParamA);
return false;
}
AttributeSelectionPtr aLineAttr =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+ std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
std::shared_ptr<GeomAPI_Edge> anEdge;
if(aLineAttr && aLineAttr->value() && aLineAttr->value()->isEdge()) {
anEdge = std::shared_ptr<GeomAPI_Edge>(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<GeomAPI_Edge>(new GeomAPI_Edge(aLineAttr->context()->shape()));
}
// coincidences to the feature
std::set<std::shared_ptr<GeomDataAPI_Point2D> > 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<SketchPlugin_Feature> aSFeature =
std::shared_ptr<GeomAPI_Dir> aDirY(new GeomAPI_Dir(aNorm->dir()->cross(aX->dir())));
std::list<std::shared_ptr<GeomAPI_Pnt> > aPoints;
- std::map<std::shared_ptr<GeomDataAPI_Point2D>, std::shared_ptr<GeomAPI_Pnt> > aPointToAttributes;
+ std::map<std::shared_ptr<GeomDataAPI_Point2D>, std::shared_ptr<GeomAPI_Pnt> >
+ aPointToAttributes;
ModelGeomAlgo_Point2D::getPointsInsideShape(anAttrShape, aRefAttributes, aC->pnt(),
aX->dir(), aDirY, aPoints, aPointToAttributes);