if (anOriginal.IsNull()) return;
//Export the shape to the file
- char* aFileName = strdup(theFileName);
- char* aFormatName = strdup(theFormatName);
- GetOperations()->Export(anOriginal, aFileName, aFormatName);
- free(aFileName);
- free(aFormatName);
+ GetOperations()->Export(anOriginal, theFileName, theFormatName);
}
//=============================================================================
GetOperations()->SetNotDone();
//Import the shape from the file
- char* aFileName = strdup(theFileName);
- char* aFormatName = strdup(theFormatName);
- Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->Import(aFileName, aFormatName);
-
- if( strcmp(aFormatName,"IGES_UNIT")==0 && !aHSeq.IsNull() ) {
- free(aFileName);
- free(aFormatName);
- return aSeq._retn();
- }
-
- free(aFileName);
- free(aFormatName);
+ Handle(TColStd_HSequenceOfTransient) aHSeq = GetOperations()->Import(theFileName, theFormatName);
if (!GetOperations()->IsDone() || aHSeq.IsNull()) {
return aSeq._retn();
Standard_Integer aLength = aHSeq->Length();
aSeq->length(aLength);
-
- for (Standard_Integer i = 1; i <= aLength; i++) {
+ for (Standard_Integer i = 1; i <= aLength; i++)
aSeq[i-1] = GetObject(Handle(GEOM_Object)::DownCast(aHSeq->Value(i)));
- }
return aSeq._retn();
}
//Set a not done flag
GetOperations()->SetNotDone();
- char* aFileName = strdup(theFileName);
- char* aFormatName = strdup(theFormatName);
- char* aParameterName = strdup(theParameterName);
-
TCollection_AsciiString aUnits = GetOperations()->ReadValue
- (aFileName, aFormatName, aParameterName);
-
- free(aFileName);
- free(aFormatName);
- free(aParameterName);
+ (theFileName, theFormatName, theParameterName);
return CORBA::string_dup(aUnits.ToCString());
}
-//=============================================================================
-/*!
- * ImportTranslators
- */
-//=============================================================================
-void GEOM_IInsertOperations_i::ImportTranslators
- (GEOM::string_array_out theFormats, GEOM::string_array_out thePatterns)
-{
- // allocate the CORBA arrays
- GEOM::string_array_var aFormatsArray = new GEOM::string_array();
- GEOM::string_array_var aPatternsArray = new GEOM::string_array();
-
- // Get sequences of available formats
- Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString;
- Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString;
- if (GetOperations()->ImportTranslators(aFormats, aPatterns)) {
- const int formSize = aFormats->Length();
- if (formSize == aPatterns->Length()) {
- aFormatsArray->length(formSize);
- aPatternsArray->length(formSize);
-
- // fill the local CORBA arrays with values from sequences
- CORBA::Long i = 1;
- for (; i <= formSize; i++) {
- aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString());
- aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString());
- }
- }
- }
-
- // initialize out-parameters with local arrays
- theFormats = aFormatsArray._retn();
- thePatterns = aPatternsArray._retn();
-}
-
-//=============================================================================
-/*!
- * ExportTranslators
- */
-//=============================================================================
-void GEOM_IInsertOperations_i::ExportTranslators
- (GEOM::string_array_out theFormats, GEOM::string_array_out thePatterns)
-{
- // allocate the CORBA arrays
- GEOM::string_array_var aFormatsArray = new GEOM::string_array();
- GEOM::string_array_var aPatternsArray = new GEOM::string_array();
-
- // Get sequences of available formats
- Handle(TColStd_HSequenceOfAsciiString) aFormats = new TColStd_HSequenceOfAsciiString;
- Handle(TColStd_HSequenceOfAsciiString) aPatterns = new TColStd_HSequenceOfAsciiString;
- if (GetOperations()->ExportTranslators(aFormats, aPatterns)) {
- const int formSize = aFormats->Length();
- if (formSize == aPatterns->Length()) {
- aFormatsArray->length(formSize);
- aPatternsArray->length(formSize);
-
- // fill the local CORBA arrays with values from sequences
- CORBA::Long i = 1;
- for (; i <= formSize; i++) {
- aFormatsArray[i-1] = CORBA::string_dup(aFormats->Value(i).ToCString());
- aPatternsArray[i-1] = CORBA::string_dup(aPatterns->Value(i).ToCString());
- }
- }
- }
-
- // initialize out-parameters with local arrays
- theFormats = aFormatsArray._retn();
- thePatterns = aPatternsArray._retn();
-}
-
//=============================================================================
/*!
* RestoreShape
return anIDs._retn();
}
-//=============================================================================
-/*!
- * Export a shape to XAO format
- * \param shape The shape to export
- * \param groups The list of groups to export
- * \param fields The list of fields to export
- * \param author The author of the export
- * \param fileName The name of the exported file
- * \return boolean indicating if export was succeful.
- */
-//=============================================================================
-CORBA::Boolean GEOM_IInsertOperations_i::ExportXAO(GEOM::GEOM_Object_ptr shape,
- const GEOM::ListOfGO& groups,
- const GEOM::ListOfFields& fields,
- const char* author,
- const char* fileName)
-{
- bool isGood = false;
- // Set a not done flag
- GetOperations()->SetNotDone();
-
- // Get the reference shape
- Handle(GEOM_Object) reference = GetObjectImpl(shape);
-
- // Get the reference groups
- int ind = 0;
- std::list<Handle(GEOM_Object)> groupsObj;
- for (; ind < groups.length(); ind++)
- {
- Handle(GEOM_Object) gobj = GetObjectImpl(groups[ind]);
- if (gobj.IsNull()) return false;
- groupsObj.push_back(gobj);
- }
- // Get the reference fields
- ind = 0;
- std::list<Handle(GEOM_Field)> fieldsObj;
- for (; ind < fields.length(); ind++)
- {
- Handle(GEOM_Field) fobj = Handle(GEOM_Field)::DownCast(GetBaseObjectImpl(fields[ind]));
- if (fobj.IsNull()) return false;
- fieldsObj.push_back(fobj);
- }
-
- if (!reference.IsNull())
- {
- // Export XAO
- isGood = GetOperations()->ExportXAO(reference, groupsObj, fieldsObj, author, fileName);
- }
-
- return isGood;
-}
-
-//=============================================================================
-/*!
- * Import a shape from XAO format
- * \param fileName The name of the file to import
- * \param shape The imported shape
- * \param subShapes The list of imported subShapes
- * \param groups The list of imported groups
- * \param fields The list of imported fields
- * \return boolean indicating if import was succeful.
- */
-//=============================================================================
-CORBA::Boolean GEOM_IInsertOperations_i::ImportXAO(const char* fileName,
- GEOM::GEOM_Object_out shape,
- GEOM::ListOfGO_out subShapes,
- GEOM::ListOfGO_out groups,
- GEOM::ListOfFields_out fields)
-{
- GEOM::GEOM_Object_var vshape;
- shape = vshape._retn();
-
- subShapes = new GEOM::ListOfGO;
- groups = new GEOM::ListOfGO;
- fields = new GEOM::ListOfFields;
-
- // Set a not done flag
- GetOperations()->SetNotDone();
-
- Handle(TColStd_HSequenceOfTransient) importedSubShapes = new TColStd_HSequenceOfTransient();
- Handle(TColStd_HSequenceOfTransient) importedGroups = new TColStd_HSequenceOfTransient();
- Handle(TColStd_HSequenceOfTransient) importedFields = new TColStd_HSequenceOfTransient();
- Handle(GEOM_Object) hshape;
- bool res = GetOperations()->ImportXAO(fileName, hshape, importedSubShapes, importedGroups, importedFields);
-
- if (!GetOperations()->IsDone() || !res)
- return false;
-
- // parse fields
- int n = importedSubShapes->Length();
- subShapes->length(n);
- for (int i = 1; i <= n; i++)
- {
- (*subShapes)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedSubShapes->Value(i)));
- }
-
- // parse groups
- n = importedGroups->Length();
- groups->length(n);
- for (int i = 1; i <= n; i++)
- {
- (*groups)[i - 1] = GetObject(Handle(GEOM_Object)::DownCast(importedGroups->Value(i)));
- }
-
- // parse fields
- n = importedFields->Length();
- fields->length(n);
- for (int i = 1; i <= n; i++)
- {
- (*fields)[i - 1] = GEOM::GEOM_Field::_narrow(
- GetBaseObject(Handle(GEOM_Field)::DownCast(importedFields->Value(i))));
- }
-
- shape = GetObject(hshape);
-
- return res;
-}