-// Copyright (C) 2014-2021 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022 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
data()->setName(Locale::Convert::toWString(anObjectName));
ResultBodyPtr aResult = document()->createBody(data());
-
- bool anColorGroupSelected = boolean(ExchangePlugin_ImportFeature::STEP_COLORS_ID())->value();
- bool anMaterialsGroupSelected =
- boolean(ExchangePlugin_ImportFeature::STEP_MATERIALS_ID())->value();
+ bool anColorGroupSelected = false, anMaterialsGroupSelected = false;
if (anExtension == "BREP" || anExtension == "BRP") {
aGeomShape = BREPImport(theFileName, anExtension, anError);
} else if (anExtension == "STEP" || anExtension == "STP") {
- bool anScalInterUnits =
- boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID())->value();
+ bool anScalInterUnits = boolean(STEP_SCALE_INTER_UNITS_ID())->value();
+ anColorGroupSelected = boolean(STEP_COLORS_ID())->value();
+ anMaterialsGroupSelected = boolean(STEP_MATERIALS_ID())->value();
// Process groups/fields
- std::shared_ptr<ModelAPI_AttributeRefList> aRefListOfGroups =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(FEATURES_ID()));
+ AttributeRefListPtr aRefListOfGroups = reflist(FEATURES_ID());
// Remove previous groups/fields stored in RefList
std::list<ObjectPtr> anGroupList = aRefListOfGroups->list();
setColorGroups(aResult);
}
- // create Materiel group
+ // create Material group
if (anMaterialsGroupSelected){
setMaterielGroup(aResult,theMaterialShape);
}
if (aRes->get() && ((*aRes)->data()->name() == (*aResMat)))
{
if (aShape->isCompound() || aShape->isCompSolid()) {
- GeomAPI_ShapeIterator anIt(aShape);
- for (; anIt.more(); anIt.next()) {
- aSelectionList->setSelectionType(anIt.current()->shapeTypeStr());
- aSelectionList->append(theResultBody,anIt.current());
+ GeomAPI_ShapeIterator aShapeIt(aShape);
+ for (; aShapeIt.more(); aShapeIt.next()) {
+ aSelectionList->setSelectionType(aShapeIt.current()->shapeTypeStr());
+ aSelectionList->append(theResultBody, aShapeIt.current());
}
} else {
aSelectionList->setSelectionType(aShape->shapeTypeStr());
//load result
theResultBody->store(theGeomShape);
+ // to store color of higher-level shape
+ std::wstring aName = theResultBody->findShapeName(theGeomShape);
+ if (!aName.empty())
+ {
+ std::vector<int> aColor = theResultBody->findShapeColor(aName);
+ if (!aColor.empty())
+ ModelAPI_Tools::setColor(theResultBody, aColor);
+ }
+
std::string aNameMS = "Shape";
theResultBody->loadFirstLevel(theGeomShape, aNameMS);
}