}
return mySelectionFeature->selectionList("selection");
}
+
+FeaturePtr Model_Document::lastFeature()
+{
+ if (myObjs)
+ return myObjs->lastFeature();
+ return FeaturePtr();
+}
/// Returns true if document is opened and valid
MODEL_EXPORT virtual bool isOpened();
+ /// Returns the last feature in the document (even not visible or disabled)
+ /// \returns null if there is no features
+ FeaturePtr lastFeature();
+
protected:
//! Returns (creates if needed) the general label
TDF_Label generalLabel() const;
/// makes the last feature in the document as the current
static void makeCurrentLast(std::shared_ptr<ModelAPI_Document> theDoc) {
if (theDoc.get()) {
- FeaturePtr aLastFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(theDoc->object(
- ModelAPI_Feature::group(), theDoc->size(ModelAPI_Feature::group()) - 1));
- theDoc->setCurrentFeature(aLastFeature, false);
+ FeaturePtr aLast = std::dynamic_pointer_cast<Model_Document>(theDoc)->lastFeature();
+ theDoc->setCurrentFeature(aLast, false);
}
}
{
std::shared_ptr<GeomDataAPI_Dir> aNorm = std::dynamic_pointer_cast<GeomDataAPI_Dir>(theNormal);
std::shared_ptr<GeomDataAPI_Dir> aDirX = std::dynamic_pointer_cast<GeomDataAPI_Dir>(theDirX);
- if (!aDirX || (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance))
+ if (!aDirX || (fabs(aDirX->x()) + fabs(aDirX->y()) + fabs(aDirX->z()) < tolerance) ||
+ !aNorm->isInitialized())
return false;
// calculate Y direction
std::shared_ptr<GeomAPI_Dir> aDirY(new GeomAPI_Dir(aNorm->dir()->cross(aDirX->dir())));