#include <ExchangePlugin_Tools.h>
-#include <TopExp_Explorer.hxx>
-#include <OSD_Exception.hxx>
ExchangePlugin_ImportFeature::ExchangePlugin_ImportFeature()
std::string anError;
std::shared_ptr<GeomAPI_Shape> aGeomShape;
- std::map< std::wstring, std::list<std::wstring>> theMaterialShape;
+ std::map<std::wstring, std::list<std::wstring>> theMaterialShape;
std::string anObjectName = GeomAlgoAPI_Tools::File_Tools::name(theFileName);
data()->setName(Locale::Convert::toWString(anObjectName));
bool anScalInterUnits =
boolean(ExchangePlugin_ImportFeature::STEP_SCALE_INTER_UNITS_ID())->value();
- try{
+ // Process groups/fields
+ std::shared_ptr<ModelAPI_AttributeRefList> aRefListOfGroups =
+ std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(FEATURES_ID()));
- aResult->clearShapeNameAndColor();
- // Process groups/fields
- std::shared_ptr<ModelAPI_AttributeRefList> aRefListOfGroups =
- std::dynamic_pointer_cast<ModelAPI_AttributeRefList>(data()->attribute(FEATURES_ID()));
-
- // Remove previous groups/fields stored in RefList
- std::list<ObjectPtr> anGroupList = aRefListOfGroups->list();
- std::list<ObjectPtr>::iterator anGroupIt = anGroupList.begin();
- for (; anGroupIt != anGroupList.end(); ++anGroupIt) {
- std::shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_Feature::feature(*anGroupIt);
- if (aFeature)
+ // Remove previous groups/fields stored in RefList
+ std::list<ObjectPtr> anGroupList = aRefListOfGroups->list();
+ std::list<ObjectPtr>::iterator anGroupIt = anGroupList.begin();
+ for (; anGroupIt != anGroupList.end(); ++anGroupIt) {
+ std::shared_ptr<ModelAPI_Feature> aFeature = ModelAPI_Feature::feature(*anGroupIt);
+ if (aFeature)
document()->removeFeature(aFeature);
- }
-
- aGeomShape = STEPImportAttributs(theFileName, aResult, anScalInterUnits,
- anMaterialsGroupSelected, anColorGroupSelected,
- theMaterialShape,anError);
-
- }
- catch (OSD_Exception& e) {
- //Try to load STEP file without colors...
- aGeomShape = STEPImport(theFileName, anExtension,anScalInterUnits,anError);
}
+
+ aGeomShape = STEPImportAttributs(theFileName, aResult, anScalInterUnits,
+ anMaterialsGroupSelected, anColorGroupSelected,
+ theMaterialShape, anError);
} else if (anExtension == "IGES" || anExtension == "IGS") {
aGeomShape = IGESImport(theFileName, anExtension, anError);
} else {
}
setResult(aResult);
+ aResult->clearShapeNameAndColor();
}
{
std::vector<int> aColor;
int anIndice = 1;
- std::list< std::vector<int> > aColorsRead;
+ std::list<std::vector<int>> aColorsRead;
ModelAPI_Tools::getColor(theResultBody, aColor);
if (!aColor.empty() ){
std::wstringstream aColorName;
aColorName <<L"Color_"<< anIndice;
- setColorGroup( theResultBody, aColor, aColorName.str());
+ setColorGroup(theResultBody, aColor, aColorName.str());
anIndice++;
aColorsRead.push_back(aColor);
}
AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
ModelAPI_Tools::getColor(theResultBody, aColor);
- if (!aColor.empty() ){
- if (aColor == theColor ) {
+ if (!aColor.empty()){
+ if (aColor == theColor) {
GeomShapePtr aShape = theResultBody->shape();
- aSelectionList->setSelectionType(aShape->shapeTypeStr() );
+ aSelectionList->setSelectionType(aShape->shapeTypeStr());
aSelectionList->append(theResultBody,aShape);
}
}
ModelAPI_Tools::getColor(*aRes, aColor);
GeomShapePtr aShape = (*aRes)->shape();
- if (!aColor.empty() ){
- if (aRes->get() && aColor == theColor ) {
- aSelectionList->setSelectionType(aShape->shapeTypeStr() );
+ if (!aColor.empty()){
+ if (aRes->get() && aColor == theColor) {
+ aSelectionList->setSelectionType(aShape->shapeTypeStr());
aSelectionList->append(theResultBody,aShape);
}
}
ModelAPI_Tools::setColor(aGroupFeature->lastResult(),theColor);
- if (aSelectionList->size() == 0 ){
+ if (aSelectionList->size() == 0) {
document()->removeFeature(aGroupFeature);
}
}
std::map< std::wstring,std::list<std::wstring>>& theMaterialShape)
{
std::map< std::wstring, std::list<std::wstring>>::iterator anIt;
- for( anIt = theMaterialShape.begin(); anIt != theMaterialShape.end(); ++anIt) {
+ for (anIt = theMaterialShape.begin(); anIt != theMaterialShape.end(); ++anIt) {
std::shared_ptr<ModelAPI_Feature> aGroupFeature = addFeature("Group");
// group name
// fill selection
AttributeSelectionListPtr aSelectionList = aGroupFeature->selectionList("group_list");
- GeomShapePtr aShape = theResultBody->shape();
std::list<ResultPtr> allRes;
ModelAPI_Tools::allSubs(theResultBody, allRes);
- for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); ++aRes) {
+ for (std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); ++aRes) {
GeomShapePtr aShape = (*aRes)->shape();
- for(std::list<std::wstring>::iterator aResMat = anIt->second.begin();
+ for (std::list<std::wstring>::iterator aResMat = anIt->second.begin();
aResMat != anIt->second.end(); ++aResMat) {
if (aRes->get() && ((*aRes)->data()->name() == (*aResMat)))
{
aSelectionList->append(theResultBody,aShape);
- aSelectionList->setSelectionType(aShape->shapeTypeStr() );
+ aSelectionList->setSelectionType(aShape->shapeTypeStr());
break;
}
}