#include <TDF_ChildIterator.hxx>
#include <TopAbs_ShapeEnum.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Edge.hxx>
+#include <BRep_Tool.hxx>
+
using namespace std;
void Model_AttributeSelectionList::append(
const ResultPtr& theContext, const std::shared_ptr<GeomAPI_Shape>& theSubShape)
{
+ // do not use the degenerated edge as a shape, a list is not incremented in this case
+ if (theSubShape.get() && !theSubShape->isNull() && theSubShape->isEdge()) {
+ const TopoDS_Shape& aSubShape = theSubShape->impl<TopoDS_Shape>();
+ if (aSubShape.ShapeType() == TopAbs_EDGE && BRep_Tool::Degenerated(TopoDS::Edge(aSubShape))) {
+ return;
+ }
+ }
+
int aNewTag = mySize->Get() + 1;
TDF_Label aNewLab = mySize->Label().FindChild(aNewTag);
if (owner()) {
aNewAttr->setObject(owner());
}
+ aNewAttr->setID(id());
mySize->Set(aNewTag);
aNewAttr->setValue(theContext, theSubShape);
owner()->data()->sendAttributeUpdated(this);
}
}
+bool Model_AttributeSelectionList::isInitialized()
+{
+ if (size() == 0) { // empty list is not initialized list: sketch will be not valid after add/undo
+ return false;
+ }
+ return ModelAPI_AttributeSelectionList::isInitialized();
+}
+
Model_AttributeSelectionList::Model_AttributeSelectionList(TDF_Label& theLabel)
{
myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), mySize) == Standard_True;