AttributeSelectionListPtr aSelectionListAttr =
this->selectionList(ExchangePlugin_ExportFeature::SELECTION_LIST_ID());
std::list<std::shared_ptr<GeomAPI_Shape> > aShapes;
- for ( int i = 0, aSize = aSelectionListAttr->size(); i < aSize; ++i ) {
+ for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; ++i) {
aShapes.push_back(aSelectionListAttr->value(i)->value());
}
std::shared_ptr<GeomAPI_Shape> aShape =
exportFile(aFilePath, aFormat, aShape);
}
-std::list<std::string> ExchangePlugin_ExportFeature::getFormats() const
-{
- // This value is a copy of string_list attribute of format_choice in plugin-Exchange.xml
- // XPath:plugin-Exchange.xml:string(//*[@id="format_choice"]/@string_list)
- std::string aFormats = "BREP STEP IGES-5.1 IGES-5.3";
- return ExchangePlugin_Tools::split(aFormats, ' ');
-}
-
bool ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName,
const std::string& theFormat,
std::shared_ptr<GeomAPI_Shape> theShape)
{
// retrieve the file and plugin library names
TCollection_AsciiString aFileName(theFileName.c_str());
- OSD_Path aPath(aFileName);
TCollection_AsciiString aFormatName(theFormat.c_str());
// Perform the export
TCollection_AsciiString anError;
- TDF_Label anUnknownLabel = TDF_Label();
-
TopoDS_Shape aShape(theShape->impl<TopoDS_Shape>());
bool aResult = false;
if (aFormatName == "BREP") {
- aResult = BREPExport::Export(aFileName, aFormatName, aShape, anError, anUnknownLabel);
+ aResult = BREPExport::Export(aFileName, aFormatName, aShape, anError);
} else if (aFormatName == "STEP") {
- aResult = STEPExport::Export(aFileName, aFormatName, aShape, anError, anUnknownLabel);
+ aResult = STEPExport::Export(aFileName, aFormatName, aShape, anError);
} else if (aFormatName.SubString(1, 4) == "IGES") {
- aResult = IGESExport::Export(aFileName, aFormatName, aShape, anError, anUnknownLabel);
+ aResult = IGESExport::Export(aFileName, aFormatName, aShape, anError);
} else {
anError = TCollection_AsciiString("Unsupported format ") + aFormatName;
}
*/
class ExchangePlugin_ExportFeature : public ModelAPI_Feature
{
- public:
+public:
inline static const std::string& ID()
{
static const std::string MY_EXPORT_ID("Export");
*/
void ExchangePlugin_ImportFeature::execute()
{
- AttributeStringPtr aFilePathAttr = std::dynamic_pointer_cast<ModelAPI_AttributeString>(
- data()->attribute(ExchangePlugin_ImportFeature::FILE_PATH_ID()));
+ AttributeStringPtr aFilePathAttr =
+ this->string(ExchangePlugin_ImportFeature::FILE_PATH_ID());
std::string aFilePath = aFilePathAttr->value();
- if(aFilePath.empty())
+ if (aFilePath.empty())
return;
+
importFile(aFilePath);
}
// retrieve the file and plugin library names
TCollection_AsciiString aFileName(theFileName.c_str());
OSD_Path aPath(aFileName);
- TCollection_AsciiString aFormatName = aPath.Extension();
+ TCollection_AsciiString anExtension = aPath.Extension();
// ".brep" -> "BREP", TCollection_AsciiString are numbered from 1
- aFormatName = aFormatName.SubString(2, aFormatName.Length());
- aFormatName.UpperCase();
+ anExtension = anExtension.SubString(2, anExtension.Length());
+ anExtension.UpperCase();
// Perform the import
TCollection_AsciiString anError;
- TDF_Label anUnknownLabel = TDF_Label();
TopoDS_Shape aShape;
- if (aFormatName == "BREP") {
- aShape = BREPImport::Import(aFileName, aFormatName, anError, anUnknownLabel);
- } else if (aFormatName == "STEP" || aFormatName == "STP") {
- aShape = STEPImport::Import(aFileName, aFormatName, anError, anUnknownLabel);
- } else if (aFormatName == "IGES") {
- aShape = IGESImport::Import(aFileName, aFormatName, anError, anUnknownLabel);
+ if (anExtension == "BREP") {
+ aShape = BREPImport::Import(aFileName, anExtension, anError);
+ } else if (anExtension == "STEP" || anExtension == "STP") {
+ aShape = STEPImport::Import(aFileName, anExtension, anError);
+ } else if (anExtension == "IGES") {
+ aShape = IGESImport::Import(aFileName, anExtension, anError);
}
// Check if shape is valid
if ( aShape.IsNull() ) {
- const static std::string aShapeError =
+ const static std::string aShapeError =
"An error occurred while importing " + theFileName + ": " + anError.ToCString();
setError(aShapeError);
return false;
int aTag(1);
std::string aNameMS = "Shape";
theResultBody->loadFirstLevel(theGeomShape, aNameMS, aTag);
- //std::string aNameDE = "DiscEdges";
- //theResultBody->loadDisconnectedEdges(theGeomShape, aNameDE, aTag);
- //std::string aNameDV = "DiscVertexes";
- //theResultBody->loadDisconnectedVertexes(theGeomShape, aNameDV, aTag);
}
bool Export(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString&,
const TopoDS_Shape& theShape,
- TCollection_AsciiString& theError, const TDF_Label&)
+ TCollection_AsciiString& theError)
{
#ifdef _DEBUG
std::cout << "Export BREP into file " << theFileName << std::endl;
bool Export(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatName,
const TopoDS_Shape& theShape,
- TCollection_AsciiString& theError, const TDF_Label&);
+ TCollection_AsciiString& theError);
}
namespace BREPImport {
TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString&,
- TCollection_AsciiString& theError, const TDF_Label&)
+ TCollection_AsciiString& theError)
{
#ifdef _DEBUG
std::cout << "Import BREP from file " << theFileName << std::endl;
GEOMALGOAPI_EXPORT
TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatName,
- TCollection_AsciiString& theError, const TDF_Label&);
+ TCollection_AsciiString& theError);
}
bool Export(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatName,
const TopoDS_Shape& theShape,
- TCollection_AsciiString& theError, const TDF_Label&)
+ TCollection_AsciiString& theError)
{
// theFormatName expected "IGES-5.1", "IGES-5.3"...
TCollection_AsciiString aVersion = theFormatName.Token("-", 2);
bool Export(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatName,
const TopoDS_Shape& theShape,
- TCollection_AsciiString& theError, const TDF_Label&);
+ TCollection_AsciiString& theError);
}
namespace IGESImport {
TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString&,
- TCollection_AsciiString& theError, const TDF_Label&)
+ TCollection_AsciiString& theError)
{
#ifdef _DEBUG
std::cout << "Import IGES from file " << theFileName << std::endl;
GEOMALGOAPI_EXPORT
TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatName,
- TCollection_AsciiString& theError, const TDF_Label&);
+ TCollection_AsciiString& theError);
}
bool Export(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatName,
const TopoDS_Shape& theShape,
- TCollection_AsciiString& theError,
- const TDF_Label& theShapeLabel)
+ TCollection_AsciiString& theError)
{
#ifdef _DEBUG
std::cout << "Export STEP into file " << theFileName.ToCString() << std::endl;
bool Export(const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatName,
const TopoDS_Shape& theShape,
- TCollection_AsciiString& theError,
- const TDF_Label& theShapeLabel);
+ TCollection_AsciiString& theError);
}
#endif /* GEOMALGOAPI_STEPEXPORT_H_ */
TopoDS_Shape Import (const TCollection_AsciiString& theFileName,
const TCollection_AsciiString& theFormatName,
- TCollection_AsciiString& theError,
- const TDF_Label& theShapeLabel)
+ TCollection_AsciiString& theError)
{
TopoDS_Shape aResShape;
/// Implementation of the import STEP files algorithms
GEOMALGOAPI_EXPORT
TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
- const TCollection_AsciiString& theFormatName, TCollection_AsciiString& theError,
- const TDF_Label& theShapeLabel);
+ const TCollection_AsciiString& theFormatName,
+ TCollection_AsciiString& theError);
}
#endif /* GEOMALGOAPI_STEPIMPORT_H_ */
{
SessionPtr aMgr = ModelAPI_Session::get();
ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+
std::list<ModelAPI_Validator*> allValidators;
std::list<std::list<std::string> > allArguments;
aFactory->validators(myFeature->getKind(), myAttributeID, allValidators, allArguments);
+
QStringList aResult;
std::list<std::string> anArgumentList = allArguments.front();
std::list<std::string>::const_iterator it = anArgumentList.begin();