#include <ostream>
#endif
+
#include <Config_Common.h>
#include <Config_PropManager.h>
#include <GeomAlgoAPI_CompoundBuilder.h>
#include <GeomAlgoAPI_IGESExport.h>
#include <GeomAlgoAPI_STEPExport.h>
+#include <GeomAlgoAPI_STLExport.h>
#include <GeomAlgoAPI_Tools.h>
#include <GeomAlgoAPI_XAOExport.h>
#include <GeomAPI_ShapeExplorer.h>
#include <GeomAPI_Trsf.h>
+#include <Locale_Convert.h>
+
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
#include <ModelAPI_AttributeStringArray.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_AttributeTables.h>
+#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_Object.h>
ModelAPI_AttributeString::typeId());
data()->addAttribute(ExchangePlugin_ExportFeature::XAO_SELECTION_LIST_ID(),
ModelAPI_AttributeSelectionList::typeId());
+ data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID(),
+ ModelAPI_AttributeString::typeId());
+ data()->addAttribute(ExchangePlugin_ExportFeature::STL_OBJECT_SELECTED(),
+ ModelAPI_AttributeSelection::typeId());
+ data()->addAttribute(ExchangePlugin_ExportFeature::STL_DEFLECTION_TYPE(),
+ ModelAPI_AttributeString::typeId());
+ data()->addAttribute(ExchangePlugin_ExportFeature::STL_RELATIVE(),
+ ModelAPI_AttributeDouble::typeId());
+
+ double defelection = Config_PropManager::real("Visualization", "body_deflection");
+ real(ExchangePlugin_ExportFeature::STL_RELATIVE())->setValue(defelection);
+
+ data()->addAttribute(ExchangePlugin_ExportFeature::STL_ABSOLUTE(),
+ ModelAPI_AttributeDouble::typeId());
+ data()->addAttribute(ExchangePlugin_ExportFeature::STL_FILE_TYPE(),
+ ModelAPI_AttributeString::typeId());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID());
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
+ ExchangePlugin_ExportFeature::STL_FILE_PATH_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
ExchangePlugin_ExportFeature::XAO_AUTHOR_ID());
ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(),
string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue(
string(ExchangePlugin_ExportFeature::XAO_FILE_PATH_ID())->value());
}
+ else if (theID == STL_FILE_PATH_ID()) {
+ string(ExchangePlugin_ExportFeature::FILE_PATH_ID())->setValue(
+ string(ExchangePlugin_ExportFeature::STL_FILE_PATH_ID())->value());
+ }
+
}
/*
if (aFormatName == "XAO") {
exportXAO(theFileName);
return;
+ }else if (aFormatName == "STL") {
+ exportSTL(theFileName);
+ return;
}
// make shape for export from selected shapes
anError = "Unsupported format: " + aFormatName;
}
- if (!anError.empty()) {
+ if (!aResult || !anError.empty()) {
setError("An error occurred while exporting " + theFileName + ": " + anError);
return;
}
{
// collect all results into a cashed set
if (theCashedResults.empty()) {
- std::list<ResultPtr> aResults;
std::list<ResultPtr>::const_iterator aRes = theResults.cbegin();
for(; aRes != theResults.cend(); aRes++) {
if (theCashedResults.count(*aRes))
return false;
}
+void ExchangePlugin_ExportFeature::exportSTL(const std::string& theFileName)
+{
+ // Get shape.
+ AttributeSelectionPtr aSelection = selection(STL_OBJECT_SELECTED());
+ GeomShapePtr aShape = aSelection->value();
+ if (!aShape.get()) {
+ aShape = aSelection->context()->shape();
+ }
+
+ // Get relative value and percent flag.
+ double aValue;
+ bool anIsRelative = false;
+ bool anIsASCII = false;
+
+ if (string(STL_DEFLECTION_TYPE())->value() == STL_DEFLECTION_TYPE_RELATIVE()) {
+ aValue = real(STL_RELATIVE())->value();
+ anIsRelative = true;
+ } else {
+ aValue = real(STL_ABSOLUTE())->value();
+ }
+
+ if (string(STL_FILE_TYPE())->value() == STL_FILE_TYPE_ASCII()) {
+ anIsASCII = true;
+ }
+ // Perform the export
+ std::string anError;
+ bool aResult = false;
+
+ aResult = STLExport(theFileName,
+ aShape,
+ aValue,
+ anIsRelative,
+ anIsASCII,
+ anError);
+
+ if (!aResult || !anError.empty()) {
+ setError("An error occurred while exporting " + theFileName + ": " + anError);
+ return;
+ }
+}
+
+
void ExchangePlugin_ExportFeature::exportXAO(const std::string& theFileName)
{
try {
if (aGeometryName.empty() && aResults.size() == 1) {
// get the name from the first result
ResultPtr aResultBody = *aResults.begin();
- aGeometryName = aResultBody->data()->name();
+ aGeometryName = Locale::Convert::toString(aResultBody->data()->name());
}
aXao.getGeometry()->setName(aGeometryName);
XAO::Dimension aGroupDimension = XAO::XaoUtils::stringToDimension(aDimensionString);
XAO::Group* aXaoGroup = aXao.addGroup(aGroupDimension,
- aResultGroup->data()->name());
+ Locale::Convert::toString(aResultGroup->data()->name()));
try {
GeomAPI_ShapeExplorer aGroupResExplorer(aResultGroup->shape(), aSelType);
} catch (XAO::XAO_Exception& e) {
// LCOV_EXCL_START
std::string msg = "An error occurred while exporting group " +
- aResultGroup->data()->name();
+ Locale::Convert::toString(aResultGroup->data()->name());
msg += ".\n";
msg += e.what();
msg += "\n";
XAO::Type aFieldType = XAO::XaoUtils::stringToFieldType(aTypeString);
XAO::Field* aXaoField = aXao.addField(aFieldType, aFieldDimension, aTables->columns(),
- aResultField->data()->name());
+ Locale::Convert::toString(aResultField->data()->name()));
try {
int anElementID = 0;
if (!isWholePart) {
// element index actually is the ID of the selection
- AttributeSelectionPtr aSelection = aSelectionList->value(aRow - 1);
- int aReferenceID = GeomAlgoAPI_CompoundBuilder::id(aShape, aSelection->value());
+ AttributeSelectionPtr aSel = aSelectionList->value(aRow - 1);
+ int aReferenceID = GeomAlgoAPI_CompoundBuilder::id(aShape, aSel->value());
if (aReferenceID == 0) // selected value does not found in the exported shape
continue;
} catch (XAO::XAO_Exception& e) {
// LCOV_EXCL_START
std::string msg = "An error occurred while exporting field " +
- aResultField->data()->name();
+ Locale::Convert::toString(aResultField->data()->name());
msg += ".\n";
msg += e.what();
msg += "\n";