for (; anIt != aLast && !anAttribute; anIt++) {
std::shared_ptr<GeomDataAPI_Point2D> aCurPoint =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(*anIt);
+ if (!aCurPoint->isInitialized())
+ continue;
std::shared_ptr<GeomAPI_Pnt> aPnt = convertTo3D(aCurPoint->x(), aCurPoint->y(), theSketch);
if (aPnt && (aPnt->distance(aValue) < Precision::Confusion())) {
for i in range (0, 3):
aLine = self.__sketch.addFeature("SketchLine")
aLinesList.append(aLine)
+ self.updateLines()
aNbLines = aLinesList.size()
# Create constraints to keep the rectangle
for i in range (0, aNbLines):
myEndUpdate = true;
std::shared_ptr<GeomDataAPI_Point2D> aPoint2 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aData->attribute(SketchPlugin_Arc::START_ID()));
- aPoint2->move(theDeltaX, theDeltaY);
+ if (aPoint2->isInitialized())
+ aPoint2->move(theDeltaX, theDeltaY);
std::shared_ptr<GeomDataAPI_Point2D> aPoint3 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aData->attribute(SketchPlugin_Arc::END_ID()));
- aPoint3->move(theDeltaX, theDeltaY);
+ if (aPoint3->isInitialized())
+ aPoint3->move(theDeltaX, theDeltaY);
myStartUpdate = false;
myEndUpdate = false;
std::shared_ptr<GeomDataAPI_Point2D> aPoint1 = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aData->attribute(SketchPlugin_Arc::CENTER_ID()));
- aPoint1->move(theDeltaX, theDeltaY);
+ if (aPoint1->isInitialized())
+ aPoint1->move(theDeltaX, theDeltaY);
std::shared_ptr<GeomDataAPI_Point2D> aPassedPoint =
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(PASSED_POINT_ID()));
- aPassedPoint->move(theDeltaX, theDeltaY);
+ if (aPassedPoint->isInitialized())
+ aPassedPoint->move(theDeltaX, theDeltaY);
aData->blockSendAttributeUpdated(false);
}
std::shared_ptr<GeomDataAPI_Point2D> aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
aData->attribute(CENTER_ID()));
- aPoint->move(theDeltaX, theDeltaY);
+ if (aPoint->isInitialized())
+ aPoint->move(theDeltaX, theDeltaY);
aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(FIRST_POINT_ID()));
- aPoint->move(theDeltaX, theDeltaY);
+ if (aPoint->isInitialized())
+ aPoint->move(theDeltaX, theDeltaY);
aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(SECOND_POINT_ID()));
- aPoint->move(theDeltaX, theDeltaY);
+ if (aPoint->isInitialized())
+ aPoint->move(theDeltaX, theDeltaY);
aPoint = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(THIRD_POINT_ID()));
- aPoint->move(theDeltaX, theDeltaY);
+ if (aPoint->isInitialized())
+ aPoint->move(theDeltaX, theDeltaY);
}
bool SketchPlugin_Circle::isFixed() {
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(attribute(THIRD_POINT_ID()));
double aRadius = aRadiusAttr->value();
- if (fabs(aFirstPnt->pnt()->distance(aCenterAttr->pnt()) - aRadius) > tolerance ||
+ bool isInitialized = aFirstPnt->isInitialized() &&
+ aSecondPnt->isInitialized() && aThirdPnt->isInitialized();
+
+ if (!isInitialized ||
+ fabs(aFirstPnt->pnt()->distance(aCenterAttr->pnt()) - aRadius) > tolerance ||
fabs(aSecondPnt->pnt()->distance(aCenterAttr->pnt()) - aRadius) > tolerance ||
fabs(aThirdPnt->pnt()->distance(aCenterAttr->pnt()) - aRadius) > tolerance) {
aFirstPnt->setValue(aCenterAttr->x() + aRadius, aCenterAttr->y());
return;
}
- myStorage->update(*anIter/*, myGroupID*/);
- EntityWrapperPtr anEntity = myStorage->entity(*anIter);
+ myStorage->update(aRefAttr/*, myGroupID*/);
+ EntityWrapperPtr anEntity = myStorage->entity(aRefAttr);
if (!anEntity) {
// Force creation of an entity
- myStorage->update(*anIter, GID_UNKNOWN, true);
- anEntity = myStorage->entity(*anIter);
+ myStorage->update(aRefAttr, GID_UNKNOWN, true);
+ anEntity = myStorage->entity(aRefAttr);
}
myAttributes.push_back(anEntity);
std::list<AttributePtr> anAttrs = pointAttributes(theFeature);
std::list<AttributePtr>::const_iterator anIt = anAttrs.begin();
for (; anIt != anAttrs.end(); ++anIt) {
+ if (!(*anIt)->isInitialized())
+ return false;
isUpdated = update(*anIt, theGroup, theForce) || isUpdated;
aSubs.push_back(entity(*anIt));
}
bool SketchSolver_Storage::update(AttributePtr theAttribute, const GroupID& theGroup, bool theForce)
{
+ if (!theAttribute->isInitialized())
+ return false;
+
AttributePtr anAttribute = theAttribute;
AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(anAttribute);
if (aRefAttr) {
if (aRefAttr->isObject()) {
FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->object());
return update(aFeature, theGroup, theForce);
- } else
+ } else {
anAttribute = aRefAttr->attr();
+ if (!anAttribute->isInitialized())
+ return false;
+ }
}
EntityWrapperPtr aRelated = entity(anAttribute);