-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2021 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
void FeaturesPlugin_Union::initAttributes()
{
data()->addAttribute(BASE_OBJECTS_ID(), ModelAPI_AttributeSelectionList::typeId());
- initVersion(THE_VERSION_1, selectionList(BASE_OBJECTS_ID()));
+ initVersion(BOP_VERSION_9_4(), selectionList(BASE_OBJECTS_ID()));
}
//=================================================================================================
void FeaturesPlugin_Union::execute()
{
- ObjectHierarchy anObjects;
+ GeomAPI_ShapeHierarchy anObjects;
ListOfShape anEmptyList;
// Getting objects.
if (!processAttribute(BASE_OBJECTS_ID(), anObjects, anEmptyList))
return;
- if(anObjects.Objects().size() < 2) {
+ if(anObjects.objects().size() < 2) {
setError("Error: Not enough objects for operation. Should be at least 2.");
return;
}
std::vector<FeaturesPlugin_Tools::ResultBaseAlgo> aResultBaseAlgoList;
ListOfShape aResultShapesList;
- int aUnionVersion = version();
GeomShapePtr aResultCompound = GeomAlgoAPI_CompoundBuilder::compound(ListOfShape());
// Fuse objects.
bool isOk = true;
- for (ObjectHierarchy::Iterator anObjectsIt = anObjects.Begin();
- anObjectsIt != anObjects.End() && isOk;
+ for (GeomAPI_ShapeHierarchy::iterator anObjectsIt = anObjects.begin();
+ anObjectsIt != anObjects.end() && isOk;
++anObjectsIt) {
GeomShapePtr anObject = *anObjectsIt;
- GeomShapePtr aParent = anObjects.Parent(anObject, false);
+ GeomShapePtr aParent = anObjects.parent(anObject, false);
if (aParent && aParent->shapeType() <= GeomAPI_Shape::COMPSOLID) {
// get parent once again to mark it and the subs as processed
- aParent = anObjects.Parent(anObject);
+ aParent = anObjects.parent(anObject);
// compsolid handling
isOk = processCompsolid(GeomAlgoAPI_Tools::BOOL_FUSE,
anObjects, aParent, anEmptyList, anEmptyList,
GeomShapePtr aShape;
GeomAPI_ShapeIterator aCIt(aResultCompound);
- if (aUnionVersion < THE_VERSION_1) {
+ if (data()->version().empty()) {
// if the compound consists of a single sub-shape, take it,
// otherwise, take the full compound
aShape = aCIt.current();
}
else {
// merge hierarchies of compounds containing objects and tools
- aShape = keepUnusedSubsOfCompound(aCIt.current(), anObjects, ObjectHierarchy(), aMakeShapeList);
+ aShape = keepUnusedSubsOfCompound(aCIt.current(), anObjects, GeomAPI_ShapeHierarchy(),
+ aMakeShapeList);
for (aCIt.next(); aCIt.more(); aCIt.next()) {
std::shared_ptr<GeomAlgoAPI_ShapeBuilder> aBuilder(new GeomAlgoAPI_ShapeBuilder);
aBuilder->add(aShape, aCIt.current());
// Store result and naming.
std::shared_ptr<ModelAPI_ResultBody> aResultBody = document()->createBody(data());
- ListOfShape anObjectsList = anObjects.Objects();
+ ListOfShape anObjectsList = anObjects.objects();
aResultBody->storeModified(anObjectsList.front(), aShape);
for(ListOfShape::const_iterator anIter = anObjectsList.begin();