X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FExchangePlugin%2FExchangePlugin_ImportFeature.cpp;h=e73ccfbe3070d78754b669ca7b8234a6e55029ab;hb=5a5362530345c00af26fc8226f3066f749dde392;hp=e077e4ca78a81465938ea4da770a33147170b212;hpb=766ce5d72bbae841d6c042befdf95e7d945039e1;p=modules%2Fshaper.git diff --git a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp index e077e4ca7..e73ccfbe3 100644 --- a/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ImportFeature.cpp @@ -1,4 +1,4 @@ -// 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 @@ -168,19 +168,16 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName) 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 aRefListOfGroups = - std::dynamic_pointer_cast(data()->attribute(FEATURES_ID())); + AttributeRefListPtr aRefListOfGroups = reflist(FEATURES_ID()); // Remove previous groups/fields stored in RefList std::list anGroupList = aRefListOfGroups->list(); @@ -217,7 +214,7 @@ void ExchangePlugin_ImportFeature::importFile(const std::string& theFileName) setColorGroups(aResult); } - // create Materiel group + // create Material group if (anMaterialsGroupSelected){ setMaterielGroup(aResult,theMaterialShape); } @@ -341,10 +338,10 @@ void ExchangePlugin_ImportFeature::setMaterielGroup( 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()); @@ -631,6 +628,15 @@ void ExchangePlugin_ImportFeatureBase::loadNamingDS( //load result theResultBody->store(theGeomShape); + // to store color of higher-level shape + std::wstring aName = theResultBody->findShapeName(theGeomShape); + if (!aName.empty()) + { + std::vector aColor = theResultBody->findShapeColor(aName); + if (!aColor.empty()) + ModelAPI_Tools::setColor(theResultBody, aColor); + } + std::string aNameMS = "Shape"; theResultBody->loadFirstLevel(theGeomShape, aNameMS); }