#include <GeomAlgoAPI_XAOExport.h>
#include <GeomAPI_Shape.h>
+#include <GeomAPI_ShapeExplorer.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
aFormatName = "STEP";
} else if (anExtension == "IGES" || anExtension == "IGS") {
aFormatName = "IGES-5.1";
- } else if (anExtension == "XAO") {
- aFormatName = "XAO";
} else {
aFormatName = anExtension;
}
}
// Store compound if we have more than one shape.
- std::shared_ptr<GeomAPI_Shape> aShape;
- if(aShapes.size() == 1) {
- aShape = aShapes.front();
- } else {
- aShape = GeomAlgoAPI_CompoundBuilder::compound(aShapes);
- }
+ std::shared_ptr<GeomAPI_Shape> aShape =
+ aShapes.size() == 1 ? aShapes.front() : GeomAlgoAPI_CompoundBuilder::compound(aShapes);
// Perform the export
std::string anError;
// if context is in results, return true
for(int a = 0; a < theSelection->size(); a++) {
AttributeSelectionPtr anAttr = theSelection->value(a);
- ResultBodyPtr aSelected= std::dynamic_pointer_cast<ModelAPI_ResultBody>(anAttr->context());
- if (aSelected.get() && theCashedResults.count(aSelected))
+ ResultPtr aContext = anAttr->context();
+ // check is it group selected for groups BOP
+ if (aContext.get() && aContext->groupName() == ModelAPI_ResultGroup::group()) {
+ // it is impossible by used results check which result is used in this group result,
+ // so check the results shapes is it in results of this document or not
+ FeaturePtr aSelFeature =
+ std::dynamic_pointer_cast<ModelAPI_Feature>(theSelection->owner());
+ if (!aSelFeature.get() || aSelFeature->results().empty())
+ continue;
+ GeomShapePtr aGroupResShape = aSelFeature->firstResult()->shape();
+
+ std::set<ResultPtr>::iterator allResultsIter = theCashedResults.begin();
+ for(; allResultsIter != theCashedResults.end(); allResultsIter++) {
+ GeomShapePtr aResultShape = (*allResultsIter)->shape();
+
+ GeomAPI_Shape::ShapeType aType =
+ GeomAPI_Shape::shapeTypeByStr(theSelection->selectionType());
+ GeomAPI_ShapeExplorer aGroupResExp(aGroupResShape, aType);
+ for(; aGroupResExp.more(); aGroupResExp.next()) {
+ if (aResultShape->isSubShape(aGroupResExp.current(), false))
+ return true; // at least one shape of the group is in the used results
+ }
+ }
+ }
+ ResultBodyPtr aSelected = std::dynamic_pointer_cast<ModelAPI_ResultBody>(anAttr->context());
+ if (!aSelected.get()) { // try to get selected feature and all its results
+ FeaturePtr aContextFeature = anAttr->contextFeature();
+ if (aContextFeature.get() && !aContextFeature->results().empty()) {
+ const std::list<ResultPtr>& allResluts = aContextFeature->results();
+ std::list<ResultPtr>::const_iterator aResIter = allResluts.cbegin();
+ for(; aResIter != allResluts.cend(); aResIter++) {
+ if (aResIter->get() && theCashedResults.count(*aResIter))
+ return true;
+ }
+ }
+ } else if (aSelected.get() && theCashedResults.count(aSelected))
return true;
}
return false;
for (int aGroupIndex = 0; aGroupIndex < aGroupCount; ++aGroupIndex) {
ResultGroupPtr aResultGroup = std::dynamic_pointer_cast<ModelAPI_ResultGroup>(
(*aDoc)->object(ModelAPI_ResultGroup::group(), aGroupIndex));
+ if (!aResultGroup.get() || !aResultGroup->shape().get())
+ continue;
FeaturePtr aGroupFeature = (*aDoc)->feature(aResultGroup);
// conversion of dimension
std::string aSelectionType = aSelectionList->selectionType();
+ GeomAPI_Shape::ShapeType aSelType = GeomAPI_Shape::shapeTypeByStr(aSelectionType);
std::string aDimensionString =
ExchangePlugin_Tools::selectionType2xaoDimension(aSelectionType);
XAO::Dimension aGroupDimension = XAO::XaoUtils::stringToDimension(aDimensionString);
aResultGroup->data()->name());
try {
- for (int aSelectionIndex = 0; aSelectionIndex < aSelectionList->size(); ++aSelectionIndex){
- AttributeSelectionPtr aSelection = aSelectionList->value(aSelectionIndex);
-
- // complex conversion of reference id to element index
- // gives bad id in case the selection is done from python script
- // => using GeomAlgoAPI_CompoundBuilder::id instead
- // int aReferenceID_old = aSelection->Id();
-
- int aReferenceID = GeomAlgoAPI_CompoundBuilder::id(aShape, aSelection->value());
-
+ GeomAPI_ShapeExplorer aGroupResExplorer(aResultGroup->shape(), aSelType);
+ for(; aGroupResExplorer.more(); aGroupResExplorer.next()) {
+ int aReferenceID = GeomAlgoAPI_CompoundBuilder::id(aShape, aGroupResExplorer.current());
if (aReferenceID == 0) // selected value does not found in the exported shape
continue;
-
std::string aReferenceString = XAO::XaoUtils::intToString(aReferenceID);
int anElementID =
aXao.getGeometry()->getElementIndexByReference(aGroupDimension, aReferenceString);
-
aXaoGroup->add(anElementID);
}
} catch (XAO::XAO_Exception& e) {
AttributeIntArrayPtr aStamps = aFieldFeature->intArray("stamps");
for (int aStepIndex = 0; aStepIndex < aTables->tables(); aStepIndex++) {
- XAO::Step* aStep = aXaoField->addNewStep(aStepIndex);
- aStep->setStep(aStepIndex);
+ XAO::Step* aStep = aXaoField->addNewStep(aStepIndex + 1);
+ aStep->setStep(aStepIndex + 1);
int aStampIndex = aStamps->value(aStepIndex);
aStep->setStamp(aStampIndex);
int aNumElements = isWholePart ? aXaoField->countElements() : aTables->rows();
return false;
ExchangePlugin_ExportFeature* aThis = ((ExchangePlugin_ExportFeature*)(this));
AttributeStringPtr aFormatAttr = aThis->string(FILE_FORMAT_ID());
- if (!aFormatAttr.get())
- return false;
- std::string aFormat = aFormatAttr->value();
+ std::string aFormat(aFormatAttr.get() ? aFormatAttr->value() : "");
if (aFormat.empty()) { // get default format for the extension
AttributeStringPtr aFilePathAttr = aThis->string(FILE_PATH_ID());
std::string aFilePath = aFilePathAttr->value();
if (!aFilePath.empty()) {
std::string anExtension = GeomAlgoAPI_Tools::File_Tools::extension(aFilePath);
- if (anExtension == "XAO") {
- aFormat = "XAO";
- }
+ aFormat = anExtension;
}
}