{
ConstraintWrapperPtr aResult;
ParameterWrapperPtr anIntermediate;
+
+ std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint1 = GCS_POINT_WRAPPER(thePoint1);
+ if (!aPoint1 && thePoint1->type() == ENTITY_POINT)
+ aPoint1 = GCS_POINT_WRAPPER( GCS_ENTITY_WRAPPER(thePoint1)->subEntities().front() );
+ std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint2 = GCS_POINT_WRAPPER(thePoint2);
+ if (!aPoint2 && thePoint2->type() == ENTITY_POINT)
+ aPoint2 = GCS_POINT_WRAPPER( GCS_ENTITY_WRAPPER(thePoint2)->subEntities().front() );
+
switch (theType) {
case CONSTRAINT_PT_PT_COINCIDENT:
- aResult = createConstraintCoincidence(theConstraint, theGroupID,
- GCS_POINT_WRAPPER(thePoint1), GCS_POINT_WRAPPER(thePoint2));
+ aResult = createConstraintCoincidence(theConstraint, theGroupID, aPoint1, aPoint2);
break;
case CONSTRAINT_PT_ON_LINE:
case CONSTRAINT_PT_ON_CIRCLE:
aResult = createConstraintPointOnEntity(theConstraint, theGroupID, theType,
- GCS_POINT_WRAPPER(thePoint1), GCS_ENTITY_WRAPPER(theEntity1));
+ aPoint1, GCS_ENTITY_WRAPPER(theEntity1));
break;
case CONSTRAINT_PT_PT_DISTANCE:
aResult = createConstraintDistancePointPoint(theConstraint, theGroupID,
GCS_PARAMETER_WRAPPER(createParameter(GID_OUTOFGROUP, theValue)),
- GCS_POINT_WRAPPER(thePoint1), GCS_POINT_WRAPPER(thePoint2));
+ aPoint1, aPoint2);
break;
case CONSTRAINT_PT_LINE_DISTANCE:
aResult = createConstraintDistancePointLine(theConstraint, theGroupID,
GCS_PARAMETER_WRAPPER(createParameter(GID_OUTOFGROUP, theValue)),
- GCS_POINT_WRAPPER(thePoint1), GCS_ENTITY_WRAPPER(theEntity1));
+ aPoint1, GCS_ENTITY_WRAPPER(theEntity1));
break;
case CONSTRAINT_RADIUS:
aResult = createConstraintRadius(theConstraint, theGroupID,
if (theEntity2->group() == theGroupID) // theEntity2 is not fixed
makeMirrorPoints(theEntity1, theEntity2, theMirrorLine);
- std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint1 =
- std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theEntity1);
- std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint2 =
- std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theEntity2);
+ std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint1 = GCS_POINT_WRAPPER(theEntity1);
+ if (!aPoint1 && theEntity1->type() == ENTITY_POINT)
+ aPoint1 = GCS_POINT_WRAPPER( GCS_ENTITY_WRAPPER(theEntity1)->subEntities().front() );
+ std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint2 = GCS_POINT_WRAPPER(theEntity2);
+ if (!aPoint2 && theEntity2->type() == ENTITY_POINT)
+ aPoint2 = GCS_POINT_WRAPPER( GCS_ENTITY_WRAPPER(theEntity2)->subEntities().front() );
std::shared_ptr<PlaneGCSSolver_EntityWrapper> aMirrorLine =
std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theMirrorLine);
return createArc(theFeature, theAttributes, theGroupID);
// Point (it has low probability to be an attribute of constraint, so it is checked at the end)
else if (aFeatureKind == SketchPlugin_Point::ID()) {
- AttributePtr aPoint = theFeature->attribute(SketchPlugin_Point::COORD_ID());
- if (!aPoint->isInitialized())
- return aDummy;
- EntityWrapperPtr aSub = createAttribute(aPoint, theGroupID);
+ EntityWrapperPtr aSub;
+ if (theAttributes.size() == 1)
+ aSub = theAttributes.front();
+ else {
+ AttributePtr aPoint = theFeature->attribute(SketchPlugin_Point::COORD_ID());
+ if (aPoint->isInitialized())
+ aSub = createAttribute(aPoint, theGroupID);
+ }
if (!aSub)
return aDummy;
if (theEntity->type() == ENTITY_POINT) {
std::shared_ptr<PlaneGCSSolver_PointWrapper> aPoint =
std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theEntity);
+ if (!aPoint) {
+ aPoint = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(
+ theEntity->subEntities().front());
+ }
aPoint->setId(++myEntityLastID);
} else if (theEntity->type() == ENTITY_SCALAR) {
std::shared_ptr<PlaneGCSSolver_ScalarWrapper> aScalar =
if (theMaster->type() != ENTITY_POINT || theSlave->type() != ENTITY_POINT)
return;
+ std::shared_ptr<PlaneGCSSolver_PointWrapper> aMaster =
+ std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theMaster);
+ if (!aMaster)
+ aMaster = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(
+ std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theMaster)->subEntities().front());
+ std::shared_ptr<PlaneGCSSolver_PointWrapper> aSlave =
+ std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(theSlave);
+ if (!aSlave)
+ aSlave = std::dynamic_pointer_cast<PlaneGCSSolver_PointWrapper>(
+ std::dynamic_pointer_cast<PlaneGCSSolver_EntityWrapper>(theSlave)->subEntities().front());
+
// Search available coincidence
- CoincidentPointsMap::iterator aMasterFound = myCoincidentPoints.find(theMaster);
- CoincidentPointsMap::iterator aSlaveFound = myCoincidentPoints.find(theSlave);
+ CoincidentPointsMap::iterator aMasterFound = myCoincidentPoints.find(aMaster);
+ CoincidentPointsMap::iterator aSlaveFound = myCoincidentPoints.find(aSlave);
if (aMasterFound == myCoincidentPoints.end() && aSlaveFound == myCoincidentPoints.end()) {
// try to find master and slave points in the lists of slaves of already existent coincidences
CoincidentPointsMap::iterator anIt = myCoincidentPoints.begin();
for (; anIt != myCoincidentPoints.end(); ++anIt) {
- if (anIt->second.find(theMaster) != anIt->second.end())
+ if (anIt->second.find(aMaster) != anIt->second.end())
aMasterFound = anIt;
- else if (anIt->second.find(theSlave) != anIt->second.end())
+ else if (anIt->second.find(aSlave) != anIt->second.end())
aSlaveFound = anIt;
if (aMasterFound != myCoincidentPoints.end() && aSlaveFound != myCoincidentPoints.end())
if (aMasterFound == myCoincidentPoints.end()) {
// create new group
- myCoincidentPoints[theMaster] = std::set<EntityWrapperPtr>();
- aMasterFound = myCoincidentPoints.find(theMaster);
+ myCoincidentPoints[aMaster] = std::set<EntityWrapperPtr>();
+ aMasterFound = myCoincidentPoints.find(aMaster);
} else if (aMasterFound == aSlaveFound)
return; // already coincident
std::set<EntityWrapperPtr>::const_iterator aSlIt = aNewSlaves.begin();
for (; aSlIt != aNewSlaves.end(); ++aSlIt)
- addCoincidentPoints(theMaster, *aSlIt);
+ addCoincidentPoints(aMaster, *aSlIt);
} else {
-//// std::list<ParameterWrapperPtr> aSlaveParams = theSlave->parameters();
-//// theSlave->setParameters(theMaster->parameters());
-////
-//// // Remove slave's parameters
-//// std::list<ParameterWrapperPtr>::iterator aParIt = aSlaveParams.begin();
-//// for (; aParIt != aSlaveParams.end(); ++aParIt)
-//// remove(*aParIt);
+ //std::list<ParameterWrapperPtr> aSlaveParams = aSlave->parameters();
+ //aSlave->setParameters(aMaster->parameters());
+
+ //// Remove slave's parameters
+ //std::list<ParameterWrapperPtr>::iterator aParIt = aSlaveParams.begin();
+ //for (; aParIt != aSlaveParams.end(); ++aParIt)
+ // remove(*aParIt);
- aMasterFound->second.insert(theSlave);
+ aMasterFound->second.insert(aSlave);
}
}
for (; anIt != myAttributeMap.end(); ++anIt) {
// the external feature always should keep the up to date values, so,
// refresh from the solver is never needed
+ bool isExternal = false;
if (anIt->first.get()) {
std::shared_ptr<SketchPlugin_Feature> aSketchFeature =
std::dynamic_pointer_cast<SketchPlugin_Feature>(anIt->first->owner());
if (aSketchFeature.get() && aSketchFeature->isExternal())
- continue;
+ isExternal = true;
}
// update parameter wrappers and obtain values of attributes
bool isUpd[3] = {false};
int i = 0;
for (aParIt = aParams.begin(); i < 3 && aParIt != aParams.end(); ++aParIt, ++i) {
- if (!theFixedOnly || (*aParIt)->group() == GID_OUTOFGROUP || (*aParIt)->isParametric()) {
+ if (!theFixedOnly || isExternal ||
+ (*aParIt)->group() == GID_OUTOFGROUP || (*aParIt)->isParametric()) {
aCoords[i] = (*aParIt)->value();
isUpd[i] = true;
}
std::dynamic_pointer_cast<GeomDataAPI_Point2D>(anIt->first);
if (aPoint2D) {
if ((isUpd[0] && fabs(aPoint2D->x() - aCoords[0]) > tolerance) ||
- (isUpd[1] && fabs(aPoint2D->y() - aCoords[1]) > tolerance)) {
- if (!isUpd[0]) aCoords[0] = aPoint2D->x();
- if (!isUpd[1]) aCoords[1] = aPoint2D->y();
+ (isUpd[1] && fabs(aPoint2D->y() - aCoords[1]) > tolerance) || isExternal) {
+ if (!isUpd[0] || isExternal) aCoords[0] = aPoint2D->x();
+ if (!isUpd[1] || isExternal) aCoords[1] = aPoint2D->y();
aPoint2D->setValue(aCoords[0], aCoords[1]);
// Find points coincident with this one (probably not in GID_OUTOFGROUP)
- std::map<AttributePtr, EntityWrapperPtr>::const_iterator aLocIt =
- theFixedOnly ? myAttributeMap.begin() : anIt;
- for (++aLocIt; aLocIt != myAttributeMap.end(); ++aLocIt)
- if (anIt->second->id() == aLocIt->second->id()) {
- aPoint2D = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(aLocIt->first);
+ CoincidentPointsMap::const_iterator aCoincIt = myCoincidentPoints.begin();
+ for (; aCoincIt != myCoincidentPoints.end(); ++aCoincIt)
+ if (aCoincIt->first == anIt->second ||
+ aCoincIt->second.find(anIt->second) != aCoincIt->second.end())
+ break;
+ if (aCoincIt != myCoincidentPoints.end()) {
+ aPoint2D = std::dynamic_pointer_cast<GeomDataAPI_Point2D>(
+ aCoincIt->first->baseAttribute());
+ if (aPoint2D)
+ aPoint2D->setValue(aCoords[0], aCoords[1]);
+ std::set<EntityWrapperPtr>::const_iterator aSlaveIt = aCoincIt->second.begin();
+ for (; aSlaveIt != aCoincIt->second.end(); ++aSlaveIt) {
+ aPoint2D = std::dynamic_pointer_cast<GeomDataAPI_Point2D>((*aSlaveIt)->baseAttribute());
if (aPoint2D)
aPoint2D->setValue(aCoords[0], aCoords[1]);
}
+ }
}
continue;
}
AttributeDoublePtr aScalar = std::dynamic_pointer_cast<ModelAPI_AttributeDouble>(anIt->first);
- if (aScalar) {
+ if (aScalar && !isExternal) {
if (isUpd[0] && fabs(aScalar->value() - aCoords[0]) > tolerance)
aScalar->setValue(aCoords[0]);
continue;