- if (!theFeature->data()->isValid())
- return false;
-
- // SketchPlugin features
- std::shared_ptr<SketchPlugin_Feature> aFeature = std::dynamic_pointer_cast<
- SketchPlugin_Feature>(theFeature);
- if (!aFeature)
- return false;
-
- // Verify the feature by its kind
- const std::string& aFeatureKind = aFeature->getKind();
- DataPtr aData = aFeature->data();
- // Line
- if (aFeatureKind == SketchPlugin_Line::ID()) {
- AttributePtr aStart = aData->attribute(SketchPlugin_Line::START_ID());
- AttributePtr aEnd = aData->attribute(SketchPlugin_Line::END_ID());
- if (!aStart->isInitialized() || !aEnd->isInitialized())
- return false;
- if (!createEntity(aStart, theEntities, theParameters) ||
- !createEntity(aEnd, theEntities, theParameters))
- return false;
- Slvs_hEntity aLineID = theEntities.back().h + 1;
- theEntities.push_back(Slvs_MakeLineSegment(aLineID, SLVS_G_UNKNOWN, SLVS_E_UNKNOWN,
- aLineID-2, aLineID-1));
- }
- // Circle
- else if (aFeatureKind == SketchPlugin_Circle::ID()) {
- AttributePtr aCenter = aData->attribute(SketchPlugin_Circle::CENTER_ID());
- AttributePtr aRadius = aData->attribute(SketchPlugin_Circle::RADIUS_ID());
- if (!aCenter->isInitialized() || !aRadius->isInitialized())
- return false;
- if (!createEntity(aCenter, theEntities, theParameters) ||
- !createEntity(aRadius, theEntities, theParameters))
- return false;
- Slvs_hEntity aCircID = theEntities.back().h;
- theEntities.push_back(Slvs_MakeCircle(aCircID, SLVS_G_UNKNOWN, SLVS_E_UNKNOWN, aCircID-2,
- SLVS_E_UNKNOWN, aCircID-1));
- }
- // Arc
- else if (aFeatureKind == SketchPlugin_Arc::ID()) {
- AttributePtr aCenter = aData->attribute(SketchPlugin_Arc::CENTER_ID());
- AttributePtr aStart = aData->attribute(SketchPlugin_Arc::START_ID());
- AttributePtr aEnd = aData->attribute(SketchPlugin_Arc::END_ID());
- if (!aCenter->isInitialized() || !aStart->isInitialized() || !aEnd->isInitialized())
- return false;
- if (!createEntity(aCenter, theEntities, theParameters) ||
- !createEntity(aStart, theEntities, theParameters) ||
- !createEntity(aEnd, theEntities, theParameters))
- return false;
- Slvs_hEntity anArcID = theEntities.back().h;
- theEntities.push_back(Slvs_MakeArcOfCircle(anArcID, SLVS_G_UNKNOWN, SLVS_E_UNKNOWN,
- SLVS_E_UNKNOWN, anArcID-3, anArcID-2, anArcID-1));
- }
- // 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 = aData->attribute(SketchPlugin_Point::COORD_ID());
- if (!aPoint->isInitialized() ||
- !createEntity(aPoint, theEntities, theParameters))
- return false;
- // Both the sketch point and its attribute (coordinates) link to the same SolveSpace point identifier.
- // No need to add another entity.
- }
- return true;
+ if (theEntity->type() != ENTITY_POINT)
+ return std::shared_ptr<GeomAPI_Pnt2d>();
+ if (theEntity->subEntities().size() == 1) // SketchPlugin_Point wrapper
+ return point(theEntity->subEntities().front());
+
+ double aXY[2];
+ std::list<ParameterWrapperPtr> aParams = theEntity->parameters();
+ std::list<ParameterWrapperPtr>::const_iterator anIt = aParams.begin();
+ for (int i = 0; i < 2 && anIt != aParams.end(); ++i, ++anIt)
+ aXY[i] = (*anIt)->value();
+ if (anIt != aParams.end())
+ return std::shared_ptr<GeomAPI_Pnt2d>();
+
+ return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aXY[0], aXY[1]));